Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(790)

Unified Diff: skia/ext/skia_utils_mac.mm

Issue 611253004: Fix pixeldated HiDPI Mac widgets with impl-side painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « skia/ext/skia_utils_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/skia_utils_mac.mm
diff --git a/skia/ext/skia_utils_mac.mm b/skia/ext/skia_utils_mac.mm
index f050ac9bd92c61cff5c190219ed43427d2aa0dad..dd8f560e1d9cd7632265eea9980794bb4bbcd692 100644
--- a/skia/ext/skia_utils_mac.mm
+++ b/skia/ext/skia_utils_mac.mm
@@ -269,14 +269,18 @@ SkiaBitLocker::SkiaBitLocker(SkCanvas* canvas)
: canvas_(canvas),
userClipRectSpecified_(false),
cgContext_(0),
+ bitmapScaleFactor_(1),
useDeviceBits_(false),
bitmapIsDummy_(false) {
}
-SkiaBitLocker::SkiaBitLocker(SkCanvas* canvas, const SkIRect& userClipRect)
+SkiaBitLocker::SkiaBitLocker(SkCanvas* canvas,
+ const SkIRect& userClipRect,
+ SkScalar bitmapScaleFactor)
: canvas_(canvas),
userClipRectSpecified_(true),
cgContext_(0),
+ bitmapScaleFactor_(bitmapScaleFactor),
useDeviceBits_(false),
bitmapIsDummy_(false) {
canvas_->save();
@@ -382,8 +386,10 @@ void SkiaBitLocker::releaseIfNeeded() {
return;
canvas_->save();
canvas_->concat(inverse);
- canvas_->drawBitmap(subset, bounds.x() + bitmapOffset_.x(),
- bounds.y() + bitmapOffset_.y());
+ canvas_->translate(bounds.x() + bitmapOffset_.x(),
+ bounds.y() + bitmapOffset_.y());
+ canvas_->scale(1.f / bitmapScaleFactor_, 1.f / bitmapScaleFactor_);
+ canvas_->drawBitmap(subset, 0, 0);
canvas_->restore();
}
CGContextRelease(cgContext_);
@@ -431,7 +437,8 @@ CGContextRef SkiaBitLocker::cgContext() {
bitmap_.lockPixels();
} else {
bool result = bitmap_.tryAllocN32Pixels(
- clip_bounds.width(), clip_bounds.height());
+ SkScalarCeilToInt(bitmapScaleFactor_ * clip_bounds.width()),
+ SkScalarCeilToInt(bitmapScaleFactor_ * clip_bounds.height()));
DCHECK(result);
if (!result)
return 0;
@@ -447,7 +454,7 @@ CGContextRef SkiaBitLocker::cgContext() {
SkMatrix matrix = canvas_->getTotalMatrix();
matrix.postTranslate(-SkIntToScalar(bitmapOffset_.x()),
-SkIntToScalar(bitmapOffset_.y()));
- matrix.postScale(1, -1);
+ matrix.postScale(bitmapScaleFactor_, -bitmapScaleFactor_);
matrix.postTranslate(0, SkIntToScalar(bitmap_.height()));
CGContextConcatCTM(cgContext_, SkMatrixToCGAffineTransform(matrix));
« no previous file with comments | « skia/ext/skia_utils_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698