| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_overlay_scrollbar_layer.h" | 5 #include "cc/layers/painted_overlay_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 "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| 11 #include "cc/layers/painted_overlay_scrollbar_layer_impl.h" | 11 #include "cc/layers/painted_overlay_scrollbar_layer_impl.h" |
| 12 #include "cc/paint/skia_paint_canvas.h" |
| 12 #include "cc/resources/ui_resource_bitmap.h" | 13 #include "cc/resources/ui_resource_bitmap.h" |
| 13 #include "cc/resources/ui_resource_manager.h" | 14 #include "cc/resources/ui_resource_manager.h" |
| 14 #include "cc/trees/layer_tree_host.h" | 15 #include "cc/trees/layer_tree_host.h" |
| 15 #include "cc/trees/layer_tree_impl.h" | 16 #include "cc/trees/layer_tree_impl.h" |
| 16 #include "skia/ext/platform_canvas.h" | 17 #include "skia/ext/platform_canvas.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" | 18 #include "third_party/skia/include/core/SkBitmap.h" |
| 18 #include "third_party/skia/include/core/SkCanvas.h" | 19 #include "third_party/skia/include/core/SkCanvas.h" |
| 19 #include "third_party/skia/include/core/SkSize.h" | 20 #include "third_party/skia/include/core/SkSize.h" |
| 20 #include "ui/gfx/geometry/size_conversions.h" | 21 #include "ui/gfx/geometry/size_conversions.h" |
| 21 #include "ui/gfx/skia_util.h" | 22 #include "ui/gfx/skia_util.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return false; | 142 return false; |
| 142 | 143 |
| 143 gfx::Rect paint_rect = OriginThumbRectForPainting(); | 144 gfx::Rect paint_rect = OriginThumbRectForPainting(); |
| 144 aperture_ = scrollbar_->NinePatchThumbAperture(); | 145 aperture_ = scrollbar_->NinePatchThumbAperture(); |
| 145 | 146 |
| 146 DCHECK(!paint_rect.size().IsEmpty()); | 147 DCHECK(!paint_rect.size().IsEmpty()); |
| 147 DCHECK(paint_rect.origin().IsOrigin()); | 148 DCHECK(paint_rect.origin().IsOrigin()); |
| 148 | 149 |
| 149 SkBitmap skbitmap; | 150 SkBitmap skbitmap; |
| 150 skbitmap.allocN32Pixels(paint_rect.width(), paint_rect.height()); | 151 skbitmap.allocN32Pixels(paint_rect.width(), paint_rect.height()); |
| 151 PaintCanvas canvas(skbitmap); | 152 SkiaPaintCanvas canvas(skbitmap); |
| 152 | 153 |
| 153 SkRect content_skrect = RectToSkRect(paint_rect); | 154 SkRect content_skrect = RectToSkRect(paint_rect); |
| 154 PaintFlags flags; | 155 PaintFlags flags; |
| 155 flags.setAntiAlias(false); | 156 flags.setAntiAlias(false); |
| 156 flags.setBlendMode(SkBlendMode::kClear); | 157 flags.setBlendMode(SkBlendMode::kClear); |
| 157 canvas.drawRect(content_skrect, flags); | 158 canvas.drawRect(content_skrect, flags); |
| 158 canvas.clipRect(content_skrect); | 159 canvas.clipRect(content_skrect); |
| 159 | 160 |
| 160 scrollbar_->PaintPart(&canvas, THUMB, paint_rect); | 161 scrollbar_->PaintPart(&canvas, THUMB, paint_rect); |
| 161 // Make sure that the pixels are no longer mutable to unavoid unnecessary | 162 // Make sure that the pixels are no longer mutable to unavoid unnecessary |
| 162 // allocation and copying. | 163 // allocation and copying. |
| 163 skbitmap.setImmutable(); | 164 skbitmap.setImmutable(); |
| 164 | 165 |
| 165 thumb_resource_ = ScopedUIResource::Create( | 166 thumb_resource_ = ScopedUIResource::Create( |
| 166 layer_tree_host()->GetUIResourceManager(), UIResourceBitmap(skbitmap)); | 167 layer_tree_host()->GetUIResourceManager(), UIResourceBitmap(skbitmap)); |
| 167 | 168 |
| 168 SetNeedsPushProperties(); | 169 SetNeedsPushProperties(); |
| 169 | 170 |
| 170 return true; | 171 return true; |
| 171 } | 172 } |
| 172 | 173 |
| 173 } // namespace cc | 174 } // namespace cc |
| OLD | NEW |