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

Unified Diff: cc/layers/painted_scrollbar_layer.cc

Issue 1560403002: Scale scrollbar in use-zoom-for-dsf mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | cc/trees/layer_tree_host.h » ('j') | third_party/WebKit/Source/platform/scroll/Scrollbar.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/painted_scrollbar_layer.cc
diff --git a/cc/layers/painted_scrollbar_layer.cc b/cc/layers/painted_scrollbar_layer.cc
index 13826e7e462ade4d5d9743a98f3eaa0c3462a7ea..452351ea6f602ec1abd43c4d50a3dd7ee26553d2 100644
--- a/cc/layers/painted_scrollbar_layer.cc
+++ b/cc/layers/painted_scrollbar_layer.cc
@@ -279,28 +279,36 @@ UIResourceBitmap PaintedScrollbarLayer::RasterizeScrollbarPart(
DCHECK(!content_rect.size().IsEmpty());
DCHECK(!layer_rect.size().IsEmpty());
+ // If zoom is used to scale the content for device scale factor,
+ // convert the size of layer_rect to DIP so that it will generate
+ // the image for scaled scrollbar.
+ float scale = 1.0f / layer_tree_host()->painted_device_scale_factor();
+ gfx::Rect adjusted_layer_rect(
skobes 2016/01/07 21:49:10 "scaled_layer_rect" is clearer
oshima 2016/01/09 00:58:39 I used adjusted because its origin isn't scaled. I
+ layer_rect.origin(),
skobes 2016/01/07 21:49:10 Don't we need to scale the origin as well? I assu
oshima 2016/01/09 00:58:39 This is correct. We want to scale the size only an
+ gfx::ScaleToFlooredSize(layer_rect.size(), scale, scale));
+
SkBitmap skbitmap;
skbitmap.allocN32Pixels(content_rect.width(), content_rect.height());
SkCanvas skcanvas(skbitmap);
float scale_x =
- content_rect.width() / static_cast<float>(layer_rect.width());
+ content_rect.width() / static_cast<float>(adjusted_layer_rect.width());
float scale_y =
- content_rect.height() / static_cast<float>(layer_rect.height());
+ content_rect.height() / static_cast<float>(adjusted_layer_rect.height());
skcanvas.scale(SkFloatToScalar(scale_x),
SkFloatToScalar(scale_y));
- skcanvas.translate(SkFloatToScalar(-layer_rect.x()),
- SkFloatToScalar(-layer_rect.y()));
+ skcanvas.translate(SkFloatToScalar(-adjusted_layer_rect.x()),
+ SkFloatToScalar(-adjusted_layer_rect.y()));
- SkRect layer_skrect = RectToSkRect(layer_rect);
+ SkRect layer_skrect = RectToSkRect(adjusted_layer_rect);
SkPaint paint;
paint.setAntiAlias(false);
paint.setXfermodeMode(SkXfermode::kClear_Mode);
skcanvas.drawRect(layer_skrect, paint);
skcanvas.clipRect(layer_skrect);
- scrollbar_->PaintPart(&skcanvas, part, layer_rect);
+ scrollbar_->PaintPart(&skcanvas, part, adjusted_layer_rect);
// Make sure that the pixels are no longer mutable to unavoid unnecessary
// allocation and copying.
skbitmap.setImmutable();
« no previous file with comments | « no previous file | cc/trees/layer_tree_host.h » ('j') | third_party/WebKit/Source/platform/scroll/Scrollbar.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698