| 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" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return false; | 141 return false; |
| 142 | 142 |
| 143 gfx::Rect paint_rect = OriginThumbRectForPainting(); | 143 gfx::Rect paint_rect = OriginThumbRectForPainting(); |
| 144 aperture_ = scrollbar_->NinePatchThumbAperture(); | 144 aperture_ = scrollbar_->NinePatchThumbAperture(); |
| 145 | 145 |
| 146 DCHECK(!paint_rect.size().IsEmpty()); | 146 DCHECK(!paint_rect.size().IsEmpty()); |
| 147 DCHECK(paint_rect.origin().IsOrigin()); | 147 DCHECK(paint_rect.origin().IsOrigin()); |
| 148 | 148 |
| 149 SkBitmap skbitmap; | 149 SkBitmap skbitmap; |
| 150 skbitmap.allocN32Pixels(paint_rect.width(), paint_rect.height()); | 150 skbitmap.allocN32Pixels(paint_rect.width(), paint_rect.height()); |
| 151 PaintCanvas canvas(skbitmap); | 151 SkCanvas skcanvas(skbitmap); |
| 152 | 152 |
| 153 SkRect content_skrect = RectToSkRect(paint_rect); | 153 SkRect content_skrect = RectToSkRect(paint_rect); |
| 154 PaintFlags flags; | 154 SkPaint paint; |
| 155 flags.setAntiAlias(false); | 155 paint.setAntiAlias(false); |
| 156 flags.setBlendMode(SkBlendMode::kClear); | 156 paint.setBlendMode(SkBlendMode::kClear); |
| 157 canvas.drawRect(content_skrect, flags); | 157 skcanvas.drawRect(content_skrect, paint); |
| 158 canvas.clipRect(content_skrect); | 158 skcanvas.clipRect(content_skrect); |
| 159 | 159 |
| 160 scrollbar_->PaintPart(&canvas, THUMB, paint_rect); | 160 scrollbar_->PaintPart(&skcanvas, THUMB, paint_rect); |
| 161 // Make sure that the pixels are no longer mutable to unavoid unnecessary | 161 // Make sure that the pixels are no longer mutable to unavoid unnecessary |
| 162 // allocation and copying. | 162 // allocation and copying. |
| 163 skbitmap.setImmutable(); | 163 skbitmap.setImmutable(); |
| 164 | 164 |
| 165 thumb_resource_ = ScopedUIResource::Create( | 165 thumb_resource_ = ScopedUIResource::Create( |
| 166 layer_tree_host()->GetUIResourceManager(), UIResourceBitmap(skbitmap)); | 166 layer_tree_host()->GetUIResourceManager(), UIResourceBitmap(skbitmap)); |
| 167 | 167 |
| 168 SetNeedsPushProperties(); | 168 SetNeedsPushProperties(); |
| 169 | 169 |
| 170 return true; | 170 return true; |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace cc | 173 } // namespace cc |
| OLD | NEW |