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

Unified Diff: cc/layers/painted_scrollbar_layer.cc

Issue 22870016: Update the nine patch layer to use UI resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 7 years, 3 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 | « cc/layers/painted_scrollbar_layer.h ('k') | cc/layers/scrollbar_layer_unittest.cc » ('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 f5795de21129d5fadcedd4b49a38cb6c4b0b1e36..4272fe688cc6e9b5ad118f222ade8c05c1141ae8 100644
--- a/cc/layers/painted_scrollbar_layer.cc
+++ b/cc/layers/painted_scrollbar_layer.cc
@@ -210,20 +210,14 @@ bool PaintedScrollbarLayer::Update(ResourceUpdateQueue* queue,
return true;
}
-scoped_refptr<UIResourceBitmap> PaintedScrollbarLayer::RasterizeScrollbarPart(
+UIResourceBitmap PaintedScrollbarLayer::RasterizeScrollbarPart(
gfx::Rect rect,
ScrollbarPart part) {
DCHECK(!rect.size().IsEmpty());
- scoped_refptr<UIResourceBitmap> bitmap =
- UIResourceBitmap::Create(new uint8_t[rect.width() * rect.height() * 4],
- UIResourceBitmap::RGBA8,
- UIResourceBitmap::CLAMP_TO_EDGE,
- rect.size());
-
SkBitmap skbitmap;
skbitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height());
- skbitmap.setPixels(bitmap->GetPixels());
+ skbitmap.allocPixels();
SkCanvas skcanvas(skbitmap);
skcanvas.translate(SkFloatToScalar(-rect.x()), SkFloatToScalar(-rect.y()));
@@ -240,8 +234,11 @@ scoped_refptr<UIResourceBitmap> PaintedScrollbarLayer::RasterizeScrollbarPart(
skcanvas.clipRect(layer_skrect);
scrollbar_->PaintPart(&skcanvas, part, layer_rect);
+ // Make sure that the pixels are no longer mutable to unavoid unnecessary
+ // allocation and copying.
+ skbitmap.setImmutable();
- return bitmap;
+ return UIResourceBitmap(skbitmap);
}
} // namespace cc
« no previous file with comments | « cc/layers/painted_scrollbar_layer.h ('k') | cc/layers/scrollbar_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698