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

Unified Diff: ui/gfx/canvas.cc

Issue 2792133002: Paint: remove readPixels. (Closed)
Patch Set: update Created 3 years, 8 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..53226fd3fee922d13592f23159fb9ab0b597fa29 100644
--- a/ui/gfx/canvas.cc
+++ b/ui/gfx/canvas.cc
@@ -104,15 +104,14 @@ 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.
+ bool result = bitmap_->copyTo(&bitmap_copy);
+ // This should succeed since the destination bitmap is empty to begin with.
+ // The only failure is an allocation failure, which we want to DCHECK anyway.
+ DCHECK(result);
+ 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