Index: cc/playback/recording_source.cc |
diff --git a/cc/playback/recording_source.cc b/cc/playback/recording_source.cc |
index feaae8807570e375de7348471d7fa2999721a920..412e7f04ab74c7e7a5da01d268c968d384bcee46 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,13 @@ RecordingSource::RecordingSource() |
clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), |
solid_color_(SK_ColorTRANSPARENT), |
background_color_(SK_ColorTRANSPARENT), |
+ engine_picture_cache_(nullptr), |
+ client_picture_cache_(nullptr), |
painter_reported_memory_usage_(0) {} |
RecordingSource::~RecordingSource() {} |
-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 +56,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 +76,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. |
+ MarkForUnregistration(); |
+ 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; |
} |
+ MarkForRegistration(); |
+} |
+ |
+void RecordingSource::MarkForRegistration() { |
+ if (!display_list_) |
+ return; |
+ |
+ if (engine_picture_cache_) |
vmpstr
2016/06/01 00:10:57
Can you explain in a few sentences why both server
nyquist
2016/06/04 00:24:58
Hmm... I split these out to separate methods, so n
|
+ display_list_->MarkForRegistrationEngine(engine_picture_cache_); |
+ if (client_picture_cache_) |
+ display_list_->MarkForRegistrationClient(client_picture_cache_); |
+} |
+ |
+void RecordingSource::MarkForUnregistration() { |
+ if (!display_list_) |
+ return; |
+ |
+ if (engine_picture_cache_) |
+ display_list_->MarkForUnregistrationEngine(engine_picture_cache_); |
+ if (client_picture_cache_) |
+ display_list_->MarkForUnregistrationClient(client_picture_cache_); |
} |
void RecordingSource::UpdateInvalidationForNewViewport( |
@@ -172,7 +191,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. |
+ MarkForUnregistration(); |
display_list_ = painter->PaintContentsToDisplayList(painting_control); |
+ MarkForRegistration(); |
+ |
painter_reported_memory_usage_ = painter->GetApproximateUnsharedMemoryUsage(); |
FinishDisplayItemListUpdate(); |
@@ -237,6 +261,7 @@ void RecordingSource::DetermineIfSolidColor() { |
} |
void RecordingSource::Clear() { |
+ MarkForUnregistration(); |
recorded_viewport_ = gfx::Rect(); |
display_list_ = nullptr; |
painter_reported_memory_usage_ = 0; |