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) { |