Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/layers/painted_scrollbar_layer.h" | 5 #include "cc/layers/painted_scrollbar_layer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 return updated; | 272 return updated; |
| 273 } | 273 } |
| 274 | 274 |
| 275 UIResourceBitmap PaintedScrollbarLayer::RasterizeScrollbarPart( | 275 UIResourceBitmap PaintedScrollbarLayer::RasterizeScrollbarPart( |
| 276 const gfx::Rect& layer_rect, | 276 const gfx::Rect& layer_rect, |
| 277 const gfx::Rect& content_rect, | 277 const gfx::Rect& content_rect, |
| 278 ScrollbarPart part) { | 278 ScrollbarPart part) { |
| 279 DCHECK(!content_rect.size().IsEmpty()); | 279 DCHECK(!content_rect.size().IsEmpty()); |
| 280 DCHECK(!layer_rect.size().IsEmpty()); | 280 DCHECK(!layer_rect.size().IsEmpty()); |
| 281 | 281 |
| 282 // 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.
| |
| 283 // convert the size of layer_rect to DIP so that it will generate | |
| 284 // the image for scaled scrollbar. | |
| 285 float scale = 1.0f / layer_tree_host()->painted_device_scale_factor(); | |
| 286 gfx::Size scaled_layer_size = | |
| 287 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
| |
| 288 | |
| 282 SkBitmap skbitmap; | 289 SkBitmap skbitmap; |
| 283 skbitmap.allocN32Pixels(content_rect.width(), content_rect.height()); | 290 skbitmap.allocN32Pixels(content_rect.width(), content_rect.height()); |
| 284 SkCanvas skcanvas(skbitmap); | 291 SkCanvas skcanvas(skbitmap); |
| 285 | 292 |
| 286 float scale_x = | 293 float scale_x = |
| 287 content_rect.width() / static_cast<float>(layer_rect.width()); | 294 content_rect.width() / static_cast<float>(scaled_layer_size.width()); |
| 288 float scale_y = | 295 float scale_y = |
| 289 content_rect.height() / static_cast<float>(layer_rect.height()); | 296 content_rect.height() / static_cast<float>(scaled_layer_size.height()); |
| 290 | 297 |
| 291 skcanvas.scale(SkFloatToScalar(scale_x), | 298 skcanvas.scale(SkFloatToScalar(scale_x), |
| 292 SkFloatToScalar(scale_y)); | 299 SkFloatToScalar(scale_y)); |
| 293 skcanvas.translate(SkFloatToScalar(-layer_rect.x()), | 300 skcanvas.translate(SkFloatToScalar(-layer_rect.x()), |
| 294 SkFloatToScalar(-layer_rect.y())); | 301 SkFloatToScalar(-layer_rect.y())); |
| 295 | 302 |
| 296 SkRect layer_skrect = RectToSkRect(layer_rect); | 303 gfx::Rect scaled_layer_rect(layer_rect.origin(), scaled_layer_size); |
| 304 SkRect layer_skrect = RectToSkRect(scaled_layer_rect); | |
| 297 SkPaint paint; | 305 SkPaint paint; |
| 298 paint.setAntiAlias(false); | 306 paint.setAntiAlias(false); |
| 299 paint.setXfermodeMode(SkXfermode::kClear_Mode); | 307 paint.setXfermodeMode(SkXfermode::kClear_Mode); |
| 300 skcanvas.drawRect(layer_skrect, paint); | 308 skcanvas.drawRect(layer_skrect, paint); |
| 301 skcanvas.clipRect(layer_skrect); | 309 skcanvas.clipRect(layer_skrect); |
| 302 | 310 |
| 303 scrollbar_->PaintPart(&skcanvas, part, layer_rect); | 311 scrollbar_->PaintPart(&skcanvas, part, scaled_layer_rect); |
| 304 // Make sure that the pixels are no longer mutable to unavoid unnecessary | 312 // Make sure that the pixels are no longer mutable to unavoid unnecessary |
| 305 // allocation and copying. | 313 // allocation and copying. |
| 306 skbitmap.setImmutable(); | 314 skbitmap.setImmutable(); |
| 307 | 315 |
| 308 return UIResourceBitmap(skbitmap); | 316 return UIResourceBitmap(skbitmap); |
| 309 } | 317 } |
| 310 | 318 |
| 311 } // namespace cc | 319 } // namespace cc |
| OLD | NEW |