diff options
author | Tor Lillqvist <tml@collabora.com> | 2014-04-04 14:28:23 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2014-04-04 14:31:25 +0300 |
commit | 561f5a875379a01f1c31a5b0226bfefe82432df2 (patch) | |
tree | a1a89f0c0d63e8ff014974fdaa42894e1988bef2 /ios | |
parent | 2bd665fadb312356f09ba59ad84957bc88e35e6d (diff) |
Use tile coordinates for the DRAW_ONLY_TILE functionality
CATiledLayer does not guarantee that tiles are drawn in the same order
each time so using a "tile number" for DRAW_ONLY_TILE was not
perfect. Use tile coordinates instead when wanting to restrict to
showing just one tile.
Change-Id: I23f4a3ecaf47cd3392d2d950bd279260b3a7b9f4
Diffstat (limited to 'ios')
-rw-r--r-- | ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m b/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m index cea417a91732..80680dd52269 100644 --- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m +++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m @@ -102,6 +102,15 @@ static void updateTilesPerSecond(UILabel *label) return [CATiledLayer class]; } +static bool tileMatches(const char *spec, CGRect bb) +{ + int x, y; + + return (sscanf(spec, "%d,%d", &x, &y) == 2 && + x == (int) (bb.origin.x / bb.size.width) && + y == (int) (bb.origin.y / bb.size.height)); +} + - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { // Even if I set the CATL's tileSize to 512x512 above, this is @@ -129,10 +138,7 @@ static void updateTilesPerSecond(UILabel *label) // as needed at the current zoom levels. I keep thinking about // "pixels" incorrectly. - volatile static int number = 0; - int thisTile = number++; - - if (!getenv("DRAW_ONLY_TILE") || thisTile == atoi(getenv("DRAW_ONLY_TILE"))) + if (!getenv("DRAW_ONLY_TILE") || tileMatches(getenv("DRAW_ONLY_TILE"), bb)) touch_lo_draw_tile(ctx, tileSize.width, tileSize.height, CGPointMake(bb.origin.x/self.scale, bb.origin.y/self.scale), @@ -157,10 +163,10 @@ static void updateTilesPerSecond(UILabel *label) } if (getenv("DRAW_TILE_NUMBERS")) { - // Also draw the order number of the tile;) + // Also draw the coordinates of the tile;) CGContextSaveGState(ctx); float scale = 1/[((View *) [self superview]) zoomScale]; - NSString *s = [NSString stringWithFormat:@"%d", thisTile]; + NSString *s = [NSString stringWithFormat:@"%d,%d", (int) (bb.origin.x / bb.size.width), (int) (bb.origin.y / bb.size.height)]; CFAttributedStringRef as = CFAttributedStringCreate(NULL, (__bridge CFStringRef)(s), NULL); CTLineRef l = CTLineCreateWithAttributedString(as); CGContextTranslateCTM(ctx, bb.origin.x, bb.origin.y); |