summaryrefslogtreecommitdiffstats
path: root/skia/ext
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-23 00:27:56 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-23 00:27:56 +0000
commitd9fa3e909f8e841522a8fecf226bc2c9f515e0d9 (patch)
treeaca3c745a6100e4ec1b3d4e06f94af4ebba11249 /skia/ext
parent560614baf90ebdf300433f65d9b268edbf7776f1 (diff)
downloadchromium_src-d9fa3e909f8e841522a8fecf226bc2c9f515e0d9.zip
chromium_src-d9fa3e909f8e841522a8fecf226bc2c9f515e0d9.tar.gz
chromium_src-d9fa3e909f8e841522a8fecf226bc2c9f515e0d9.tar.bz2
Teach CanvasSkiaPaint about HiDPI contexts.
BUG=132937 TEST=download progress indicator is more hidpi (still isn't perfect) Review URL: https://chromiumcodereview.appspot.com/10656006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143760 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext')
-rw-r--r--skia/ext/canvas_paint_mac.h39
1 files changed, 24 insertions, 15 deletions
diff --git a/skia/ext/canvas_paint_mac.h b/skia/ext/canvas_paint_mac.h
index 441af82..56dc2e9 100644
--- a/skia/ext/canvas_paint_mac.h
+++ b/skia/ext/canvas_paint_mac.h
@@ -1,5 +1,5 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -42,24 +42,24 @@ class CanvasPaintT : public T {
// Blit the dirty rect to the current context.
CGImageRef image = CGBitmapContextCreateImage(context_);
- CGRect destRect = NSRectToCGRect(rectangle_);
+ CGRect dest_rect = NSRectToCGRect(rectangle_);
- CGContextRef destinationContext =
+ CGContextRef destination_context =
(CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
- CGContextSaveGState(destinationContext);
+ CGContextSaveGState(destination_context);
CGContextSetBlendMode(
- destinationContext,
+ destination_context,
composite_alpha_ ? kCGBlendModeNormal : kCGBlendModeCopy);
if ([[NSGraphicsContext currentContext] isFlipped]) {
// Mirror context on the target's rect middle scanline.
- CGContextTranslateCTM(destinationContext, 0.0, NSMidY(rectangle_));
- CGContextScaleCTM(destinationContext, 1.0, -1.0);
- CGContextTranslateCTM(destinationContext, 0.0, -NSMidY(rectangle_));
+ CGContextTranslateCTM(destination_context, 0.0, NSMidY(rectangle_));
+ CGContextScaleCTM(destination_context, 1.0, -1.0);
+ CGContextTranslateCTM(destination_context, 0.0, -NSMidY(rectangle_));
}
- CGContextDrawImage(destinationContext, destRect, image);
- CGContextRestoreGState(destinationContext);
+ CGContextDrawImage(destination_context, dest_rect, image);
+ CGContextRestoreGState(destination_context);
CFRelease(image);
}
@@ -83,19 +83,28 @@ class CanvasPaintT : public T {
private:
void init(bool opaque) {
+ CGContextRef destination_context =
+ (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
+ CGRect scaled_unit_rect = CGContextConvertRectToDeviceSpace(
+ destination_context, CGRectMake(0, 0, 1, 1));
+ CGFloat x_scale = scaled_unit_rect.size.width;
+ CGFloat y_scale = scaled_unit_rect.size.height;
+
PlatformCanvas* canvas = GetPlatformCanvas(this);
- if (!canvas->initialize(NSWidth(rectangle_),
- NSHeight(rectangle_),
+ if (!canvas->initialize(NSWidth(rectangle_) * x_scale,
+ NSHeight(rectangle_) * y_scale,
opaque, NULL)) {
- // Cause a deliberate crash;
+ // Cause a deliberate crash.
*(volatile char*) 0 = 0;
}
canvas->clear(SkColorSetARGB(0, 0, 0, 0));
// Need to translate so that the dirty region appears at the origin of the
// surface.
- canvas->translate(-SkDoubleToScalar(NSMinX(rectangle_)),
- -SkDoubleToScalar(NSMinY(rectangle_)));
+ canvas->translate(-SkDoubleToScalar(NSMinX(rectangle_) * x_scale),
+ -SkDoubleToScalar(NSMinY(rectangle_) * y_scale));
+ // Scale appropriately.
+ canvas->scale(SkFloatToScalar(x_scale), SkFloatToScalar(y_scale));
context_ = GetBitmapContext(GetTopDevice(*canvas));
}