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

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') | no next file with comments »
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..d1fd6b23c7513334a051a822b64cf2f98c8272be 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,
danakj 2016/01/12 20:07:03 "zoom" isn't a concept here. Instead "If device sc
oshima 2016/01/12 23:19:05 Done.
+ // 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::Size scaled_layer_size =
+ gfx::ScaleToFlooredSize(layer_rect.size(), scale, scale);
danakj 2016/01/12 20:07:03 But why isn't blink just making the scrollbar laye
oshima 2016/01/12 23:19:05 It does (in viewport size) and that's why I have t
+
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>(scaled_layer_size.width());
float scale_y =
- content_rect.height() / static_cast<float>(layer_rect.height());
+ content_rect.height() / static_cast<float>(scaled_layer_size.height());
skcanvas.scale(SkFloatToScalar(scale_x),
SkFloatToScalar(scale_y));
skcanvas.translate(SkFloatToScalar(-layer_rect.x()),
SkFloatToScalar(-layer_rect.y()));
- SkRect layer_skrect = RectToSkRect(layer_rect);
+ gfx::Rect scaled_layer_rect(layer_rect.origin(), scaled_layer_size);
+ SkRect layer_skrect = RectToSkRect(scaled_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, scaled_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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698