Chromium Code Reviews| Index: cc/resources/picture.cc |
| diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc |
| index 8c2ba8aabd233b4a6836ed3590c176ed029a45bd..6ec061bc41f5db03d2c999a02e99a589b3384a39 100644 |
| --- a/cc/resources/picture.cc |
| +++ b/cc/resources/picture.cc |
| @@ -191,6 +191,11 @@ Picture::~Picture() { |
| } |
| Picture* Picture::GetCloneForDrawingOnThread(unsigned thread_index) { |
| + // We don't need clones to draw from multiple threads with SkRecord. |
| + if (playback_.get() != NULL) { |
|
danakj
2014/04/22 17:25:53
nit: if (playback_) is all you need for scoped_ptr
mtklein
2014/04/22 17:48:56
Done everywhere.
|
| + return this; |
| + } |
| + |
| // SkPicture is not thread-safe to rasterize with, this returns a clone |
| // to rasterize with on a specific thread. |
| CHECK_GE(clones_.size(), thread_index); |
| @@ -213,6 +218,11 @@ bool Picture::IsSuitableForGpuRasterization() const { |
| void Picture::CloneForDrawing(int num_threads) { |
| TRACE_EVENT1("cc", "Picture::CloneForDrawing", "num_threads", num_threads); |
| + // We don't need clones to draw from multiple threads with SkRecord. |
| + if (playback_.get() != NULL) { |
| + return; |
| + } |
| + |
| DCHECK(picture_); |
| DCHECK(clones_.empty()); |
| @@ -254,6 +264,8 @@ void Picture::Record(ContentLayerClient* painter, |
| skia::AdoptRef(new SkTileGridPictureFactory(tile_grid_info)); |
| SkPictureRecorder recorder(factory.get()); |
| + EXPERIMENTAL::SkRecording* recording = NULL; |
|
danakj
2014/04/22 17:25:53
given the Delete() API I guess this isn't possible
enne (OOO)
2014/04/22 17:26:04
Can you help me understand the lifetime issues wit
|
| + |
| skia::RefPtr<SkCanvas> canvas; |
| canvas = skia::SharePtr( |
| recorder.beginRecording(layer_rect_.width(), |
| @@ -272,6 +284,11 @@ void Picture::Record(ContentLayerClient* painter, |
| // canvas. |
| canvas.clear(); |
| break; |
| + case RECORD_WITH_SKRECORD: |
| + recording = EXPERIMENTAL::SkRecording::Create(layer_rect_.width(), |
| + layer_rect_.height()); |
| + canvas = skia::SharePtr(recording->canvas()); |
| + break; |
| default: |
| NOTREACHED(); |
| } |
| @@ -296,6 +313,11 @@ void Picture::Record(ContentLayerClient* painter, |
| picture_ = skia::AdoptRef(recorder.endRecording()); |
| DCHECK(picture_); |
| + if (recording != NULL) { |
|
danakj
2014/04/22 17:25:53
nit: just if (recording)
|
| + canvas.clear(); // Drop ref on canvas before Delete invalidates it. |
|
enne (OOO)
2014/04/22 17:26:04
Why?
|
| + playback_.reset(EXPERIMENTAL::SkRecording::Delete(recording)); |
| + } |
| + |
| opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); |
| EmitTraceSnapshot(); |
| @@ -378,7 +400,11 @@ int Picture::Raster( |
| canvas->scale(contents_scale, contents_scale); |
| canvas->translate(layer_rect_.x(), layer_rect_.y()); |
| - picture_->draw(canvas, callback); |
| + if (playback_.get() != NULL) { |
| + playback_->draw(canvas); |
| + } else { |
| + picture_->draw(canvas, callback); |
| + } |
| SkIRect bounds; |
| canvas->getClipDeviceBounds(&bounds); |
| canvas->restore(); |
| @@ -393,7 +419,11 @@ void Picture::Replay(SkCanvas* canvas) { |
| TRACE_EVENT_BEGIN0("cc", "Picture::Replay"); |
| DCHECK(picture_); |
| - picture_->draw(canvas); |
| + if (playback_.get() != NULL) { |
| + playback_->draw(canvas); |
| + } else { |
| + picture_->draw(canvas); |
| + } |
| SkIRect bounds; |
| canvas->getClipDeviceBounds(&bounds); |
| TRACE_EVENT_END1("cc", "Picture::Replay", |