summaryrefslogtreecommitdiffstats
path: root/chromium/cc/layers/picture_layer_impl.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-01-20 13:40:20 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-01-22 12:41:23 +0000
commit7961cea6d1041e3e454dae6a1da660b453efd238 (patch)
treec0eeb4a9ff9ba32986289c1653d9608e53ccb444 /chromium/cc/layers/picture_layer_impl.cc
parentb7034d0803538058e5c9d904ef03cf5eab34f6ef (diff)
BASELINE: Update Chromium to 78.0.3904.130
Change-Id: If185e0c0061b3437531c97c9c8c78f239352a68b Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/cc/layers/picture_layer_impl.cc')
-rw-r--r--chromium/cc/layers/picture_layer_impl.cc82
1 files changed, 55 insertions, 27 deletions
diff --git a/chromium/cc/layers/picture_layer_impl.cc b/chromium/cc/layers/picture_layer_impl.cc
index 23c71d964ec..20ee14ed392 100644
--- a/chromium/cc/layers/picture_layer_impl.cc
+++ b/chromium/cc/layers/picture_layer_impl.cc
@@ -106,11 +106,20 @@ PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl,
PictureLayerImpl::~PictureLayerImpl() {
if (twin_layer_)
twin_layer_->twin_layer_ = nullptr;
+
// We only track PaintWorklet-containing PictureLayerImpls on the pending
// tree. However this deletion may happen outside the commit flow when we are
// on the recycle tree instead, so just check !IsActiveTree().
if (!paint_worklet_records_.empty() && !layer_tree_impl()->IsActiveTree())
layer_tree_impl()->NotifyLayerHasPaintWorkletsChanged(this, false);
+
+ // Similarly, AnimatedPaintWorkletTracker is only valid on the pending tree.
+ if (!layer_tree_impl()->IsActiveTree()) {
+ layer_tree_impl()
+ ->paint_worklet_tracker()
+ .UpdatePaintWorkletInputProperties({}, this);
+ }
+
layer_tree_impl()->UnregisterPictureLayerImpl(this);
// Unregister for all images on the current raster source.
@@ -641,25 +650,6 @@ void PictureLayerImpl::UpdateViewportRectForTilePriorityInContentSpace() {
}
viewport_rect_for_tile_priority_in_content_space_ =
visible_rect_in_content_space;
-
- float total_controls_height = layer_tree_impl()->top_controls_height() +
- layer_tree_impl()->bottom_controls_height();
- if (total_controls_height) {
- // If sliding top controls are being used, the pending tree does not
- // reflect the fact that we may be hiding the top or bottom controls. Thus,
- // it would believe that the viewport is smaller than it actually is which
- // can cause activation flickering issues. So, if we're in this situation
- // adjust the visible rect by the the controls height.
- if (layer_tree_impl()->IsPendingTree() &&
- layer_tree_impl()->IsActivelyScrolling() &&
- layer_tree_impl()->browser_controls_shrink_blink_size()) {
- viewport_rect_for_tile_priority_in_content_space_.Inset(
- 0, // left
- 0, // top,
- 0, // right,
- -total_controls_height); // bottom
- }
- }
}
PictureLayerImpl* PictureLayerImpl::GetPendingOrActiveTwinLayer() const {
@@ -692,10 +682,17 @@ void PictureLayerImpl::UpdateRasterSource(
UnregisterAnimatedImages();
// When the display list changes, the set of PaintWorklets may also change.
- if (pending_paint_worklet_records)
+ if (pending_paint_worklet_records) {
paint_worklet_records_ = *pending_paint_worklet_records;
- else
- SetPaintWorkletInputs(raster_source->GetPaintWorkletInputs());
+ } else {
+ if (raster_source->GetDisplayItemList()) {
+ SetPaintWorkletInputs(raster_source->GetDisplayItemList()
+ ->discardable_image_map()
+ .paint_worklet_inputs());
+ } else {
+ SetPaintWorkletInputs({});
+ }
+ }
}
// The |raster_source_| is initially null, so have to check for that for the
@@ -1603,10 +1600,10 @@ PictureLayerImpl::InvalidateRegionForImages(
}
void PictureLayerImpl::SetPaintWorkletRecord(
- scoped_refptr<PaintWorkletInput> input,
+ scoped_refptr<const PaintWorkletInput> input,
sk_sp<PaintRecord> record) {
DCHECK(paint_worklet_records_.find(input) != paint_worklet_records_.end());
- paint_worklet_records_[input] = std::move(record);
+ paint_worklet_records_[input].second = std::move(record);
}
void PictureLayerImpl::RegisterAnimatedImages() {
@@ -1638,12 +1635,23 @@ void PictureLayerImpl::UnregisterAnimatedImages() {
}
void PictureLayerImpl::SetPaintWorkletInputs(
- const std::vector<scoped_refptr<PaintWorkletInput>>& inputs) {
+ const std::vector<DiscardableImageMap::PaintWorkletInputWithImageId>&
+ inputs) {
+ // PaintWorklets are not supported when committing directly to the active
+ // tree, so in that case the |inputs| should always be empty.
+ DCHECK(layer_tree_impl()->IsPendingTree() || inputs.empty());
+
bool had_paint_worklets = !paint_worklet_records_.empty();
PaintWorkletRecordMap new_records;
- for (const auto& input : inputs) {
+ for (const auto& input_with_id : inputs) {
+ const auto& input = input_with_id.first;
+ const auto& paint_image_id = input_with_id.second;
+ auto it = new_records.find(input);
+ // We should never have multiple PaintImages sharing the same paint worklet.
+ DCHECK(it == new_records.end() || it->second.first == paint_image_id);
// Attempt to re-use an existing PaintRecord if possible.
- new_records[input] = std::move(paint_worklet_records_[input]);
+ new_records[input] = std::make_pair(
+ paint_image_id, std::move(paint_worklet_records_[input].second));
}
paint_worklet_records_.swap(new_records);
@@ -1652,9 +1660,29 @@ void PictureLayerImpl::SetPaintWorkletInputs(
bool has_paint_worklets = !paint_worklet_records_.empty();
if ((has_paint_worklets != had_paint_worklets) &&
layer_tree_impl()->IsPendingTree()) {
+ // TODO(xidachen): We don't need additional tracking on LayerTreeImpl. The
+ // tracking in AnimatedPaintWorkletTracker should be enough.
layer_tree_impl()->NotifyLayerHasPaintWorkletsChanged(this,
has_paint_worklets);
}
+ if (layer_tree_impl()->IsPendingTree()) {
+ layer_tree_impl()
+ ->paint_worklet_tracker()
+ .UpdatePaintWorkletInputProperties(inputs, this);
+ }
+}
+
+void PictureLayerImpl::InvalidatePaintWorklets(
+ const PaintWorkletInput::PropertyKey& key) {
+ for (auto& entry : paint_worklet_records_) {
+ const std::vector<PaintWorkletInput::PropertyKey>& prop_ids =
+ entry.first->GetPropertyKeys();
+ // If the PaintWorklet depends on the property whose value was changed by
+ // the animation system, then invalidate its associated PaintRecord so that
+ // we can repaint the PaintWorklet during impl side invalidation.
+ if (base::Contains(prop_ids, key))
+ entry.second.second = nullptr;
+ }
}
std::unique_ptr<base::DictionaryValue> PictureLayerImpl::LayerAsJson() const {