summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-16 18:49:11 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-16 18:49:11 +0000
commitbff545e65a6767bbf860058d713d4cdea0501d74 (patch)
tree49112b5c8a70a735efb16374b99c39e7db31d4ef /skia
parent47d209421f46bfe6910ac8f87a28f684c3768987 (diff)
downloadchromium_src-bff545e65a6767bbf860058d713d4cdea0501d74.zip
chromium_src-bff545e65a6767bbf860058d713d4cdea0501d74.tar.gz
chromium_src-bff545e65a6767bbf860058d713d4cdea0501d74.tar.bz2
Mac: Fix drawing when the device's transform has a scaling part.
This currently never happens in practice, but I have a patch which uses the PaintAt IPC, which doesn't work without this fix. Without this, the clip rect is scaled down too, which means if I send a PaintAt IPC that draws the renderer at 800x600 into a 400x300 pixmap, the clip rect is 200x150, because render_view sets the scale t0 0.5 and the clip rect to 400x300. BUG=none TEST=Everything still paints correctly. Review URL: http://codereview.chromium.org/3033005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52712 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/bitmap_platform_device_mac.cc9
-rw-r--r--skia/ext/platform_device_mac.cc10
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));