Authored by Justin R. Miller

Merge branch 'upstream-develop' into develop

... ... @@ -27,6 +27,8 @@
@property (nonatomic, assign) id <RMMapTiledLayerViewDelegate> delegate;
@property (nonatomic, assign) BOOL useSnapshotRenderer;
- (id)initWithFrame:(CGRect)frame mapView:(RMMapView *)aMapView;
@end
... ...
... ... @@ -20,6 +20,7 @@
@implementation RMMapTiledLayerView
@synthesize delegate;
@synthesize useSnapshotRenderer;
+ (Class)layerClass
{
... ... @@ -42,6 +43,8 @@
self.multipleTouchEnabled = YES;
self.opaque = NO;
self.useSnapshotRenderer = NO;
CATiledLayer *tiledLayer = [self tiledLayer];
tiledLayer.levelsOfDetail = [[mapView tileSource] maxZoom];
tiledLayer.levelsOfDetailBias = [[mapView tileSource] maxZoom];
... ... @@ -87,21 +90,7 @@
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (zoom == (short)ceilf(mapView.adjustedZoomForRetinaDisplay))
{
int x = floor(rect.origin.x / rect.size.width),
y = floor(fabs(rect.origin.y / rect.size.height));
// NSLog(@"Tile @ x:%d, y:%d, zoom:%d", x, y, zoom);
UIGraphicsPushContext(context);
UIImage *tileImage = [[mapView tileSource] imageForTile:RMTileMake(x, y, zoom) inCache:[mapView tileCache]];
[tileImage drawInRect:rect];
UIGraphicsPopContext();
}
else // Probably due to renderInContext:
if (self.useSnapshotRenderer)
{
zoom = (short)ceilf(mapView.adjustedZoomForRetinaDisplay);
CGFloat rectSize = bounds.size.width / powf(2.0, (float)zoom);
... ... @@ -126,6 +115,20 @@
UIGraphicsPopContext();
}
else
{
int x = floor(rect.origin.x / rect.size.width),
y = floor(fabs(rect.origin.y / rect.size.height));
// NSLog(@"Tile @ x:%d, y:%d, zoom:%d", x, y, zoom);
UIGraphicsPushContext(context);
UIImage *tileImage = [[mapView tileSource] imageForTile:RMTileMake(x, y, zoom) inCache:[mapView tileCache]];
[tileImage drawInRect:rect];
UIGraphicsPopContext();
}
[pool release]; pool = nil;
}
... ...
... ... @@ -1193,7 +1193,10 @@
UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, [[UIScreen mainScreen] scale]);
tiledLayerView.useSnapshotRenderer = YES;
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
tiledLayerView.useSnapshotRenderer = NO;
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
... ...