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

Unified Diff: ui/gfx/canvas.cc

Issue 2792133002: Paint: remove readPixels. (Closed)
Patch Set: Created 3 years, 9 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
Index: ui/gfx/canvas.cc
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
index 0b064b5cbbbea48dcef0e8e50b211583dd65ef00..85db639987ae817ee37e2c543338f44fa880dc88 100644
--- a/ui/gfx/canvas.cc
+++ b/ui/gfx/canvas.cc
@@ -104,15 +104,12 @@ int Canvas::DefaultCanvasTextAlignment() {
}
ImageSkiaRep Canvas::ExtractImageRep() const {
- // Make a bitmap to return, and a canvas to draw into it. We don't just want
- // to call extractSubset or the copy constructor, since we want an actual copy
- // of the bitmap.
- const SkISize size = canvas_->getBaseLayerSize();
- SkBitmap result;
- result.allocN32Pixels(size.width(), size.height());
-
- canvas_->readPixels(&result, 0, 0);
- return ImageSkiaRep(result, image_scale_);
+ DCHECK(bitmap_);
+ SkBitmap bitmap_copy;
+ // |copyTo| will perform a deep copy, which is what we want.
sky 2017/04/05 03:00:24 Generally we use |s for references to variables an
vmpstr 2017/04/05 19:13:39 Done.
+ bool result = bitmap_->copyTo(&bitmap_copy);
+ DCHECK(result);
sky 2017/04/05 03:00:24 Document why result should be true here.
vmpstr 2017/04/05 19:13:39 Done.
+ return ImageSkiaRep(bitmap_copy, image_scale_);
}
void Canvas::DrawDashedRect(const Rect& rect, SkColor color) {
« no previous file with comments | « media/renderers/skcanvas_video_renderer_unittest.cc ('k') | ui/message_center/views/notification_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698