Chromium Code Reviews| 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..d9f4147d84ec5d3d99f0fbc457b409765945651b 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; |
| @@ -448,6 +455,7 @@ CGContextRef SkiaBitLocker::cgContext() { |
| matrix.postTranslate(-SkIntToScalar(bitmapOffset_.x()), |
| -SkIntToScalar(bitmapOffset_.y())); |
| matrix.postScale(1, -1); |
| + matrix.postScale(bitmapScaleFactor_, bitmapScaleFactor_); |
|
reed1
2014/09/30 18:57:24
nit : seems like we can combine these two postScal
ccameron
2014/09/30 19:01:46
Done.
|
| matrix.postTranslate(0, SkIntToScalar(bitmap_.height())); |
| CGContextConcatCTM(cgContext_, SkMatrixToCGAffineTransform(matrix)); |