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

Unified Diff: cc/layers/picture_layer.cc

Issue 2141233002: cc: Clean up RecordingSource API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: keep RecordingSource, move three members to PictureLayer Created 4 years, 5 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 081e3158841943ab15a3d8bfaeff318afe457f5e..1ad1daf48bae94a95a0988fd90e4db09f54ac966 100644
--- a/cc/layers/picture_layer.cc
+++ b/cc/layers/picture_layer.cc
@@ -19,6 +19,10 @@
namespace cc {
+PictureLayer::Inputs::Inputs() = default;
+
+PictureLayer::Inputs::~Inputs() = default;
+
scoped_refptr<PictureLayer> PictureLayer::Create(ContentLayerClient* client) {
return make_scoped_refptr(new PictureLayer(client));
}
@@ -57,7 +61,9 @@ void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) {
// Preserve lcd text settings from the current raster source.
bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText();
scoped_refptr<RasterSource> raster_source =
- recording_source_->CreateRasterSource(can_use_lcd_text);
+ recording_source_->CreateRasterSource(
+ can_use_lcd_text, inputs_.recorded_viewport, inputs_.display_list,
+ inputs_.painter_reported_memory_usage);
layer_impl->set_gpu_raster_max_texture_size(
layer_tree_host()->device_viewport_size());
layer_impl->UpdateRasterSource(raster_source, &last_updated_invalidation_,
@@ -109,9 +115,19 @@ bool PictureLayer::Update() {
// to the impl side so that it drops tiles that may not have a recording
// for them.
DCHECK(inputs_.client);
+
+ gfx::Rect old_recorded_viewport = inputs_.recorded_viewport;
+ inputs_.recorded_viewport = inputs_.client->PaintableRegion();
+ // TODO(vmpstr): Add a slow_down_recording_scale_factor_for_debug_ to be able
+ // to slow down recording.
+ inputs_.display_list = inputs_.client->PaintContentsToDisplayList(
+ ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
+ inputs_.painter_reported_memory_usage =
+ inputs_.client->GetApproximateUnsharedMemoryUsage();
+
updated |= recording_source_->UpdateAndExpandInvalidation(
inputs_.client, &last_updated_invalidation_, layer_size,
- update_source_frame_number_, RecordingSource::RECORD_NORMALLY);
+ old_recorded_viewport, inputs_.recorded_viewport, inputs_.display_list);
vmpstr 2016/07/25 20:29:14 We're passing some more inputs in here, which is f
Menglin 2016/07/25 20:41:08 So RecordingSource still has all its current membe
if (updated) {
SetNeedsPushProperties();
@@ -138,18 +154,36 @@ sk_sp<SkPicture> PictureLayer::GetPicture() const {
gfx::Size layer_size = bounds();
std::unique_ptr<RecordingSource> recording_source(new RecordingSource);
Region recording_invalidation;
+
+ gfx::Rect old_recorded_viewport;
+ gfx::Rect new_recorded_viewport = inputs_.client->PaintableRegion();
+ // TODO(vmpstr): Add a slow_down_recording_scale_factor_for_debug_ to be able
vmpstr 2016/07/25 20:29:14 This todo doesn't need to be here.
Menglin 2016/07/25 21:58:52 Done.
+ // to slow down recording.
+ scoped_refptr<DisplayItemList> display_list =
+ inputs_.client->PaintContentsToDisplayList(
+ ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
+ size_t painter_reported_memory_usage =
+ inputs_.client->GetApproximateUnsharedMemoryUsage();
+
recording_source->UpdateAndExpandInvalidation(
inputs_.client, &recording_invalidation, layer_size,
- update_source_frame_number_, RecordingSource::RECORD_NORMALLY);
+ old_recorded_viewport, new_recorded_viewport, display_list);
scoped_refptr<RasterSource> raster_source =
- recording_source->CreateRasterSource(false);
+ recording_source->CreateRasterSource(false, new_recorded_viewport,
+ display_list,
+ painter_reported_memory_usage);
return raster_source->GetFlattenedPicture();
}
bool PictureLayer::IsSuitableForGpuRasterization() const {
- return recording_source_->IsSuitableForGpuRasterization();
+ // The display list needs to be created (see: UpdateAndExpandInvalidation)
+ // before checking for suitability. There are cases where an update will not
+ // create a display list (e.g., if the size is empty). We return true in these
+ // cases because the gpu suitability bit sticks false.
+ return !inputs_.display_list ||
+ inputs_.display_list->IsSuitableForGpuRasterization();
}
void PictureLayer::ClearClient() {
@@ -181,10 +215,11 @@ void PictureLayer::LayerSpecificPropertiesToProto(
proto::PictureLayerProperties* picture = proto->mutable_picture();
recording_source_->ToProtobuf(picture->mutable_recording_source());
- // Add all SkPicture items to the picture cache.
- const DisplayItemList* display_list = recording_source_->GetDisplayItemList();
- if (display_list) {
- for (auto it = display_list->begin(); it != display_list->end(); ++it) {
+ RectToProto(inputs_.recorded_viewport, picture->mutable_recorded_viewport());
+ if (inputs_.display_list) {
+ inputs_.display_list->ToProtobuf(picture->mutable_display_list());
+ for (auto it = inputs_.display_list->begin();
+ it != inputs_.display_list->end(); ++it) {
sk_sp<const SkPicture> picture = it->GetPicture();
// Only DrawingDisplayItems have SkPictures.
if (!picture)
@@ -214,9 +249,24 @@ void PictureLayer::FromLayerSpecificPropertiesProto(
recording_source_.reset(new RecordingSource);
std::vector<uint32_t> used_engine_picture_ids;
+
+ inputs_.recorded_viewport = ProtoToRect(picture.recorded_viewport());
+
+ ClientPictureCache* client_picture_cache =
+ layer_tree_host()->client_picture_cache();
+ DCHECK(client_picture_cache);
+ // This might not exist if the |input_.display_list| of the serialized
+ // RecordingSource was null, which can happen if |Clear()| is
+ // called.
+ if (picture.has_display_list()) {
+ inputs_.display_list = DisplayItemList::CreateFromProto(
+ picture.display_list(), client_picture_cache, &used_engine_picture_ids);
+ } else {
+ inputs_.display_list = nullptr;
+ }
+
recording_source_->FromProtobuf(picture.recording_source(),
- layer_tree_host()->client_picture_cache(),
- &used_engine_picture_ids);
+ inputs_.display_list);
// Inform picture cache about which SkPictures are now in use.
for (uint32_t engine_picture_id : used_engine_picture_ids)
@@ -255,6 +305,9 @@ void PictureLayer::DropRecordingSourceContentIfInvalid() {
// for example), even though it has resized making the recording source no
// longer valid. In this case just destroy the recording source.
recording_source_->SetEmptyBounds();
+ inputs_.recorded_viewport = gfx::Rect();
+ inputs_.display_list = nullptr;
+ inputs_.painter_reported_memory_usage = 0;
}
}

Powered by Google App Engine
This is Rietveld 408576698