diff options
Diffstat (limited to 'skia')
-rw-r--r-- | skia/ext/bitmap_platform_device_mac.cc | 9 | ||||
-rw-r--r-- | skia/ext/platform_device_mac.cc | 10 |
2 files changed, 11 insertions, 8 deletions
diff --git a/skia/ext/bitmap_platform_device_mac.cc b/skia/ext/bitmap_platform_device_mac.cc index 8a46736..feb192b 100644 --- a/skia/ext/bitmap_platform_device_mac.cc +++ b/skia/ext/bitmap_platform_device_mac.cc @@ -160,9 +160,6 @@ void BitmapPlatformDevice::BitmapPlatformDeviceData::LoadConfig() { return; // Nothing to do. config_dirty_ = false; - // Transform. - SkMatrix t(transform_); - // We must restore and then save the state of the graphics context since the // calls to Load the clipping region to the context are strictly cummulative, // i.e., you can't replace a clip rect, other than with a save/restore. @@ -171,10 +168,8 @@ void BitmapPlatformDevice::BitmapPlatformDeviceData::LoadConfig() { // calls in LoadClippingRegionToCGContext() with an image mask instead. CGContextRestoreGState(bitmap_context_); CGContextSaveGState(bitmap_context_); - LoadTransformToCGContext(bitmap_context_, t); - t.setTranslateX(-t.getTranslateX()); - t.setTranslateY(-t.getTranslateY()); - LoadClippingRegionToCGContext(bitmap_context_, clip_region_, t); + LoadTransformToCGContext(bitmap_context_, transform_); + LoadClippingRegionToCGContext(bitmap_context_, clip_region_, transform_); } diff --git a/skia/ext/platform_device_mac.cc b/skia/ext/platform_device_mac.cc index ae9228e..42927cc 100644 --- a/skia/ext/platform_device_mac.cc +++ b/skia/ext/platform_device_mac.cc @@ -128,10 +128,18 @@ void PlatformDevice::LoadClippingRegionToCGContext( rect.setEmpty(); CGContextClipToRect(context, gfx::SkRectToCGRect(rect)); } else if (region.isRect()) { + // CoreGraphics applies the current transform to clip rects, which is + // unwanted. Inverse-transform the rect before sending it to CG. This only + // works for translations and scaling, but not for rotations (but the + // viewport is never rotated anyway). + SkMatrix t; + bool did_invert = transformation.invert(&t); + if (!did_invert) + t.reset(); // Do the transformation. SkRect rect; rect.set(region.getBounds()); - transformation.mapRect(&rect); + t.mapRect(&rect); SkIRect irect; rect.round(&irect); CGContextClipToRect(context, gfx::SkIRectToCGRect(irect)); |