| 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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "cc/layers/painted_scrollbar_layer_impl.h" | 10 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 211 } |
| 212 | 212 |
| 213 scoped_refptr<UIResourceBitmap> PaintedScrollbarLayer::RasterizeScrollbarPart( | 213 scoped_refptr<UIResourceBitmap> PaintedScrollbarLayer::RasterizeScrollbarPart( |
| 214 gfx::Rect rect, | 214 gfx::Rect rect, |
| 215 ScrollbarPart part) { | 215 ScrollbarPart part) { |
| 216 DCHECK(!rect.size().IsEmpty()); | 216 DCHECK(!rect.size().IsEmpty()); |
| 217 | 217 |
| 218 scoped_refptr<UIResourceBitmap> bitmap = | 218 scoped_refptr<UIResourceBitmap> bitmap = |
| 219 UIResourceBitmap::Create(new uint8_t[rect.width() * rect.height() * 4], | 219 UIResourceBitmap::Create(new uint8_t[rect.width() * rect.height() * 4], |
| 220 UIResourceBitmap::RGBA8, | 220 UIResourceBitmap::RGBA8, |
| 221 UIResourceBitmap::CLAMP_TO_EDGE, |
| 221 rect.size()); | 222 rect.size()); |
| 222 | 223 |
| 223 SkBitmap skbitmap; | 224 SkBitmap skbitmap; |
| 224 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); | 225 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); |
| 225 skbitmap.setPixels(bitmap->GetPixels()); | 226 skbitmap.setPixels(bitmap->GetPixels()); |
| 226 | 227 |
| 227 SkCanvas skcanvas(skbitmap); | 228 SkCanvas skcanvas(skbitmap); |
| 228 skcanvas.translate(SkFloatToScalar(-rect.x()), SkFloatToScalar(-rect.y())); | 229 skcanvas.translate(SkFloatToScalar(-rect.x()), SkFloatToScalar(-rect.y())); |
| 229 skcanvas.scale(SkFloatToScalar(contents_scale_x()), | 230 skcanvas.scale(SkFloatToScalar(contents_scale_x()), |
| 230 SkFloatToScalar(contents_scale_y())); | 231 SkFloatToScalar(contents_scale_y())); |
| 231 | 232 |
| 232 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( | 233 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( |
| 233 rect, 1.f / contents_scale_x(), 1.f / contents_scale_y()); | 234 rect, 1.f / contents_scale_x(), 1.f / contents_scale_y()); |
| 234 SkRect layer_skrect = RectToSkRect(layer_rect); | 235 SkRect layer_skrect = RectToSkRect(layer_rect); |
| 235 SkPaint paint; | 236 SkPaint paint; |
| 236 paint.setAntiAlias(false); | 237 paint.setAntiAlias(false); |
| 237 paint.setXfermodeMode(SkXfermode::kClear_Mode); | 238 paint.setXfermodeMode(SkXfermode::kClear_Mode); |
| 238 skcanvas.drawRect(layer_skrect, paint); | 239 skcanvas.drawRect(layer_skrect, paint); |
| 239 skcanvas.clipRect(layer_skrect); | 240 skcanvas.clipRect(layer_skrect); |
| 240 | 241 |
| 241 scrollbar_->PaintPart(&skcanvas, part, layer_rect); | 242 scrollbar_->PaintPart(&skcanvas, part, layer_rect); |
| 242 | 243 |
| 243 return bitmap; | 244 return bitmap; |
| 244 } | 245 } |
| 245 | 246 |
| 246 } // namespace cc | 247 } // namespace cc |
| OLD | NEW |