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

Unified Diff: cc/layers/picture_layer.cc

Issue 1982893002: [blimp] Add SkPicture caching support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git merge origin/master Created 4 years, 7 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/layers/picture_layer.cc
diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc
index 526c7a498e72a2b52e3eb70014116f7cd66fa74f..c18dc5931080a2322a997b55050919b5b4b3eee3 100644
--- a/cc/layers/picture_layer.cc
+++ b/cc/layers/picture_layer.cc
@@ -37,6 +37,9 @@ PictureLayer::PictureLayer(ContentLayerClient* client,
}
PictureLayer::~PictureLayer() {
+ // If there is a RecordingSource, it needs to be unregistered.
+ if (recording_source_)
+ recording_source_->MarkForUnregistration();
}
std::unique_ptr<LayerImpl> PictureLayer::CreateLayerImpl(
@@ -66,12 +69,37 @@ void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) {
}
void PictureLayer::SetLayerTreeHost(LayerTreeHost* host) {
+ LayerTreeHost* old_host = layer_tree_host();
Layer::SetLayerTreeHost(host);
+ if (old_host == host)
vmpstr 2016/06/01 00:10:56 When does this happen? Should this check be even h
nyquist 2016/06/04 00:24:57 Removed now.
+ return;
+
+ if (old_host && recording_source_) {
+ // The LayerTreeHost has changed and there was already a recording source,
+ // so unregister everything in the RecordingSource.
+ recording_source_->MarkForUnregistration();
vmpstr 2016/06/01 00:10:56 This feels wrong.
nyquist 2016/06/04 00:24:57 Removed this block.
+ recording_source_->set_engine_picture_cache(nullptr);
+ recording_source_->set_client_picture_cache(nullptr);
+ }
+
if (!host)
return;
if (!recording_source_)
recording_source_.reset(new RecordingSource);
vmpstr 2016/06/01 00:10:56 This makes me believe that we can just do the Unma
nyquist 2016/06/04 00:24:57 Done.
+
+ // Ensure the recording source has a pointer to the correct picture cache.
+ if (layer_tree_host()->IsRemoteServer()) {
+ recording_source_->set_engine_picture_cache(
vmpstr 2016/06/01 00:10:57 likewise, we can mark things in the set function?
nyquist 2016/06/04 00:24:57 Done.
+ layer_tree_host()->engine_picture_cache());
+ }
+ if (layer_tree_host()->IsRemoteClient()) {
+ recording_source_->set_client_picture_cache(
+ layer_tree_host()->client_picture_cache());
+ }
+ // Ensure that the currently empty RecordingSource is set in the marked state.
+ recording_source_->MarkForRegistration();
+
recording_source_->SetSlowdownRasterScaleFactor(
host->debug_state().slow_down_raster_scale_factor);
// If we need to enable image decode tasks, then we have to generate the
@@ -179,9 +207,8 @@ void PictureLayer::LayerSpecificPropertiesToProto(
DropRecordingSourceContentIfInvalid();
proto::PictureLayerProperties* picture = proto->mutable_picture();
- recording_source_->ToProtobuf(
- picture->mutable_recording_source(),
- layer_tree_host()->image_serialization_processor());
+ recording_source_->ToProtobuf(picture->mutable_recording_source());
+
RegionToProto(last_updated_invalidation_, picture->mutable_invalidation());
picture->set_is_mask(is_mask_);
picture->set_nearest_neighbor(nearest_neighbor_);
@@ -198,12 +225,14 @@ void PictureLayer::FromLayerSpecificPropertiesProto(
// If this is a new layer, ensure it has a recording source. During layer
// hierarchy deserialization, ::SetLayerTreeHost(...) is not called, but
// instead the member is set directly, so it needs to be set here explicitly.
- if (!recording_source_)
+ if (!recording_source_) {
recording_source_.reset(new RecordingSource);
+ // A RecordingSource is only ever deserialized on the client.
+ recording_source_->set_client_picture_cache(
+ layer_tree_host()->client_picture_cache());
+ }
- recording_source_->FromProtobuf(
- picture.recording_source(),
- layer_tree_host()->image_serialization_processor());
+ recording_source_->FromProtobuf(picture.recording_source());
Region new_invalidation = RegionFromProto(picture.invalidation());
last_updated_invalidation_.Swap(&new_invalidation);

Powered by Google App Engine
This is Rietveld 408576698