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

Unified Diff: cc/resources/picture.cc

Issue 236633008: Switching Chromium to use new Skia SkPictureRecorder API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address code review issue Created 6 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: cc/resources/picture.cc
diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc
index 93b59aea7435532456ab03b9248113b8e5c8d46c..03ddec0226595e9814dbfa6379c64f9bd1f68423 100644
--- a/cc/resources/picture.cc
+++ b/cc/resources/picture.cc
@@ -249,17 +249,21 @@ void Picture::Record(ContentLayerClient* painter,
DCHECK(!picture_);
DCHECK(!tile_grid_info.fTileInterval.isEmpty());
- picture_ = skia::AdoptRef(new SkTileGridPicture(
- layer_rect_.width(), layer_rect_.height(), tile_grid_info));
+
+ skia::RefPtr<SkPictureFactory> factory =
+ skia::AdoptRef(new SkTileGridPictureFactory(tile_grid_info));
+ SkPictureRecorder recorder(factory.get());
skia::RefPtr<SkCanvas> canvas;
+ canvas = skia::SharePtr(recorder.beginRecording(
enne (OOO) 2014/04/15 01:10:39 Should all the beginRecording calls be wrapped in
robertphillips 2014/04/15 15:37:04 As is, I think the behavior is correct here but ma
enne (OOO) 2014/04/15 16:45:16 Gotcha. The ref here is just RAII. Makes sense.
+ layer_rect_.width(),
+ layer_rect_.height(),
+ SkPicture::kUsePathBoundsForClip_RecordingFlag |
+ SkPicture::kOptimizeForClippedPlayback_RecordingFlag));
+
switch (recording_mode) {
case RECORD_NORMALLY:
- canvas = skia::SharePtr(picture_->beginRecording(
- layer_rect_.width(),
- layer_rect_.height(),
- SkPicture::kUsePathBoundsForClip_RecordingFlag |
- SkPicture::kOptimizeForClippedPlayback_RecordingFlag));
+ // Already setup for normal recording
enne (OOO) 2014/04/15 01:10:39 Why did the code move out of this switch?
robertphillips 2014/04/15 15:37:04 The old code always generated an SkPicture (albeit
enne (OOO) 2014/04/15 16:45:16 I guess I'm asking because in all other cases, the
robertphillips 2014/04/15 19:17:32 The RECORD_WITH_PAINTING_DISABLED and RECORD_WITH_
enne (OOO) 2014/04/15 19:43:27 I see. So even though you delete the canvas that
break;
case RECORD_WITH_SK_NULL_CANVAS:
canvas = skia::AdoptRef(SkCreateNullCanvas());
@@ -267,6 +271,7 @@ void Picture::Record(ContentLayerClient* painter,
case RECORD_WITH_PAINTING_DISABLED:
// Blink's GraphicsContext will disable painting when given a NULL
// canvas.
+ canvas.clear();
break;
default:
NOTREACHED();
@@ -289,8 +294,7 @@ void Picture::Record(ContentLayerClient* painter,
if (canvas)
canvas->restore();
- if (picture_->getRecordingCanvas())
- picture_->endRecording();
+ picture_ = skia::AdoptRef(recorder.endRecording());
enne (OOO) 2014/04/15 01:10:39 Previously, picture_ was always non-null if the cc
robertphillips 2014/04/15 15:37:04 picture_ should still always be non-null after a c
enne (OOO) 2014/04/15 16:45:16 Oh, ok! I misunderstood the change description her
robertphillips 2014/04/15 19:17:32 I have added a DCHECK.
opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect);

Powered by Google App Engine
This is Rietveld 408576698