Chromium Code Reviews| Index: cc/resources/picture.cc |
| diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc |
| index 48f03e0ba842a864975eef07cb8e19cf2988db4f..a95cdaa9ad3770b1f4f619f18066447bf8312013 100644 |
| --- a/cc/resources/picture.cc |
| +++ b/cc/resources/picture.cc |
| @@ -192,6 +192,11 @@ Picture::~Picture() { |
| } |
| Picture* Picture::GetCloneForDrawingOnThread(unsigned thread_index) { |
| + // We don't need clones to draw from multiple threads with SkRecord. |
| + if (playback_) { |
| + 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); |
| @@ -214,6 +219,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_) { |
| + return; |
| + } |
| + |
| DCHECK(picture_); |
| DCHECK(clones_.empty()); |
| @@ -254,6 +264,8 @@ void Picture::Record(ContentLayerClient* painter, |
| SkTileGridFactory factory(tile_grid_info); |
| SkPictureRecorder recorder; |
| + scoped_ptr<EXPERIMENTAL::SkRecording> recording; |
| + |
| skia::RefPtr<SkCanvas> canvas; |
| canvas = skia::SharePtr( |
| recorder.beginRecording(layer_rect_.width(), |
| @@ -273,6 +285,11 @@ void Picture::Record(ContentLayerClient* painter, |
| // canvas. |
| canvas.clear(); |
| break; |
| + case RECORD_WITH_SKRECORD: |
| + recording.reset(new EXPERIMENTAL::SkRecording(layer_rect_.width(), |
| + layer_rect_.height())); |
| + canvas = skia::SharePtr(recording->canvas()); |
| + break; |
| default: |
| NOTREACHED(); |
| } |
| @@ -297,6 +314,11 @@ void Picture::Record(ContentLayerClient* painter, |
| picture_ = skia::AdoptRef(recorder.endRecording()); |
| DCHECK(picture_); |
| + if (recording) { |
| + canvas.clear(); // Drop ref on canvas before calling releasePlayback(). |
|
enne (OOO)
2014/04/25 17:34:22
Can this comment say why and not what?
Alternativ
mtklein
2014/04/28 19:03:18
Done.
|
| + playback_.reset(recording->releasePlayback()); |
| + } |
| + |
| opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); |
| EmitTraceSnapshot(); |
| @@ -379,7 +401,11 @@ int Picture::Raster( |
| canvas->scale(contents_scale, contents_scale); |
| canvas->translate(layer_rect_.x(), layer_rect_.y()); |
| - picture_->draw(canvas, callback); |
| + if (playback_) { |
| + playback_->draw(canvas); |
| + } else { |
| + picture_->draw(canvas, callback); |
| + } |
| SkIRect bounds; |
| canvas->getClipDeviceBounds(&bounds); |
| canvas->restore(); |
| @@ -394,7 +420,11 @@ void Picture::Replay(SkCanvas* canvas) { |
| TRACE_EVENT_BEGIN0("cc", "Picture::Replay"); |
| DCHECK(picture_); |
| - picture_->draw(canvas); |
| + if (playback_) { |
| + playback_->draw(canvas); |
| + } else { |
| + picture_->draw(canvas); |
| + } |
| SkIRect bounds; |
| canvas->getClipDeviceBounds(&bounds); |
| TRACE_EVENT_END1("cc", "Picture::Replay", |