| Index: cc/playback/recording_source.cc
|
| diff --git a/cc/playback/recording_source.cc b/cc/playback/recording_source.cc
|
| index feaae8807570e375de7348471d7fa2999721a920..07d5eae2a0ec58487c845f0044ca0ebe2bb6ab51 100644
|
| --- a/cc/playback/recording_source.cc
|
| +++ b/cc/playback/recording_source.cc
|
| @@ -14,6 +14,7 @@
|
| #include "cc/playback/display_item_list.h"
|
| #include "cc/playback/raster_source.h"
|
| #include "cc/proto/gfx_conversions.h"
|
| +#include "cc/proto/picture_cache.h"
|
| #include "cc/proto/recording_source.pb.h"
|
| #include "skia/ext/analysis_canvas.h"
|
|
|
| @@ -28,7 +29,6 @@ const bool kDefaultClearCanvasSetting = true;
|
| } // namespace
|
|
|
| namespace cc {
|
| -class ImageSerializationProcessor;
|
|
|
| RecordingSource::RecordingSource()
|
| : slow_down_raster_scale_factor_for_debug_(0),
|
| @@ -38,13 +38,15 @@ RecordingSource::RecordingSource()
|
| clear_canvas_with_debug_color_(kDefaultClearCanvasSetting),
|
| solid_color_(SK_ColorTRANSPARENT),
|
| background_color_(SK_ColorTRANSPARENT),
|
| - painter_reported_memory_usage_(0) {}
|
| + painter_reported_memory_usage_(0),
|
| + engine_picture_cache_(nullptr),
|
| + client_picture_cache_(nullptr) {}
|
|
|
| -RecordingSource::~RecordingSource() {}
|
| +RecordingSource::~RecordingSource() {
|
| + Clear();
|
| +}
|
|
|
| -void RecordingSource::ToProtobuf(
|
| - proto::RecordingSource* proto,
|
| - ImageSerializationProcessor* image_serialization_processor) const {
|
| +void RecordingSource::ToProtobuf(proto::RecordingSource* proto) const {
|
| RectToProto(recorded_viewport_, proto->mutable_recorded_viewport());
|
| SizeToProto(size_, proto->mutable_size());
|
| proto->set_slow_down_raster_scale_factor_for_debug(
|
| @@ -56,15 +58,12 @@ void RecordingSource::ToProtobuf(
|
| proto->set_clear_canvas_with_debug_color(clear_canvas_with_debug_color_);
|
| proto->set_solid_color(static_cast<uint64_t>(solid_color_));
|
| proto->set_background_color(static_cast<uint64_t>(background_color_));
|
| - if (display_list_) {
|
| - display_list_->ToProtobuf(proto->mutable_display_list(),
|
| - image_serialization_processor);
|
| - }
|
| + if (display_list_)
|
| + display_list_->ToProtobuf(proto->mutable_display_list());
|
| }
|
|
|
| -void RecordingSource::FromProtobuf(
|
| - const proto::RecordingSource& proto,
|
| - ImageSerializationProcessor* image_serialization_processor) {
|
| +void RecordingSource::FromProtobuf(const proto::RecordingSource& proto) {
|
| + DCHECK(client_picture_cache_);
|
| recorded_viewport_ = ProtoToRect(proto.recorded_viewport());
|
| size_ = ProtoToSize(proto.size());
|
| slow_down_raster_scale_factor_for_debug_ =
|
| @@ -79,14 +78,36 @@ void RecordingSource::FromProtobuf(
|
|
|
| // This might not exist if the |display_list_| of the serialized
|
| // RecordingSource was null, wich can happen if |Clear()| is
|
| - // called.
|
| + // called. Whenever the |display_list_| is updated, first unregister the
|
| + // current content, and then register the new content directly afterwards.
|
| + MarkForUnregistrationClient();
|
| + display_list_ = nullptr;
|
| if (proto.has_display_list()) {
|
| - display_list_ = DisplayItemList::CreateFromProto(
|
| - proto.display_list(), image_serialization_processor);
|
| + display_list_ = DisplayItemList::CreateFromProto(proto.display_list(),
|
| + client_picture_cache_);
|
| FinishDisplayItemListUpdate();
|
| - } else {
|
| - display_list_ = nullptr;
|
| }
|
| + MarkForRegistrationClient();
|
| +}
|
| +
|
| +void RecordingSource::MarkForRegistrationEngine() {
|
| + if (display_list_ && engine_picture_cache_)
|
| + display_list_->MarkForRegistrationEngine(engine_picture_cache_);
|
| +}
|
| +
|
| +void RecordingSource::MarkForUnregistrationEngine() {
|
| + if (display_list_ && engine_picture_cache_)
|
| + display_list_->MarkForUnregistrationEngine(engine_picture_cache_);
|
| +}
|
| +
|
| +void RecordingSource::MarkForRegistrationClient() {
|
| + if (display_list_ && client_picture_cache_)
|
| + display_list_->MarkForRegistrationClient(client_picture_cache_);
|
| +}
|
| +
|
| +void RecordingSource::MarkForUnregistrationClient() {
|
| + if (display_list_ && client_picture_cache_)
|
| + display_list_->MarkForUnregistrationClient(client_picture_cache_);
|
| }
|
|
|
| void RecordingSource::UpdateInvalidationForNewViewport(
|
| @@ -118,6 +139,24 @@ void RecordingSource::SetNeedsDisplayRect(const gfx::Rect& layer_rect) {
|
| }
|
| }
|
|
|
| +void RecordingSource::SetEnginePictureCache(
|
| + EnginePictureCache* engine_picture_cache) {
|
| + if (engine_picture_cache_)
|
| + MarkForUnregistrationEngine();
|
| + engine_picture_cache_ = engine_picture_cache;
|
| + if (engine_picture_cache_)
|
| + MarkForRegistrationEngine();
|
| +}
|
| +
|
| +void RecordingSource::SetClientPictureCache(
|
| + ClientPictureCache* client_picture_cache) {
|
| + if (client_picture_cache_)
|
| + MarkForUnregistrationClient();
|
| + client_picture_cache_ = client_picture_cache;
|
| + if (client_picture_cache_)
|
| + MarkForRegistrationClient();
|
| +}
|
| +
|
| bool RecordingSource::UpdateAndExpandInvalidation(
|
| ContentLayerClient* painter,
|
| Region* invalidation,
|
| @@ -172,7 +211,12 @@ bool RecordingSource::UpdateAndExpandInvalidation(
|
|
|
| // TODO(vmpstr): Add a slow_down_recording_scale_factor_for_debug_ to be able
|
| // to slow down recording.
|
| + // Whenever the |display_list_| is updated, first unregister the
|
| + // current content, and then register the new content directly afterwards.
|
| + MarkForUnregistrationEngine();
|
| display_list_ = painter->PaintContentsToDisplayList(painting_control);
|
| + MarkForRegistrationEngine();
|
| +
|
| painter_reported_memory_usage_ = painter->GetApproximateUnsharedMemoryUsage();
|
|
|
| FinishDisplayItemListUpdate();
|
| @@ -237,6 +281,10 @@ void RecordingSource::DetermineIfSolidColor() {
|
| }
|
|
|
| void RecordingSource::Clear() {
|
| + // Depending on whether this code is being run on either the engine or client
|
| + // side, the picture cache needs to be informed that the SkPicture
|
| + MarkForUnregistrationEngine();
|
| + MarkForUnregistrationClient();
|
| recorded_viewport_ = gfx::Rect();
|
| display_list_ = nullptr;
|
| painter_reported_memory_usage_ = 0;
|
|
|