Commit c3b9f252 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Use RefCountedPropertyTreeState in GraphicsLayer

This is to workaround under-invalidation of GraphicsLayer property tree
state.

Bug: 1139839
Change-Id: I8f4540c9d323578f619483e6fe67c3f948c30592
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2512517Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823439}
parent a377982d
...@@ -297,10 +297,11 @@ bool GraphicsLayer::PaintRecursively( ...@@ -297,10 +297,11 @@ bool GraphicsLayer::PaintRecursively(
}, },
[&](const GraphicsLayer& layer, cc::Layer& contents_layer) { [&](const GraphicsLayer& layer, cc::Layer& contents_layer) {
PaintChunkSubsetRecorder subset_recorder(context.GetPaintController()); PaintChunkSubsetRecorder subset_recorder(context.GetPaintController());
auto contents_state = layer.GetContentsPropertyTreeState();
RecordForeignLayer( RecordForeignLayer(
context, layer, DisplayItem::kForeignLayerContentsWrapper, context, layer, DisplayItem::kForeignLayerContentsWrapper,
&contents_layer, layer.GetContentsOffsetFromTransformNode(), &contents_layer, layer.GetContentsOffsetFromTransformNode(),
&layer.GetContentsPropertyTreeState()); &contents_state);
pre_composited_layers.push_back( pre_composited_layers.push_back(
PreCompositedLayerInfo{subset_recorder.Get()}); PreCompositedLayerInfo{subset_recorder.Get()});
}); });
...@@ -364,8 +365,8 @@ void GraphicsLayer::Paint(Vector<PreCompositedLayerInfo>& pre_composited_layers, ...@@ -364,8 +365,8 @@ void GraphicsLayer::Paint(Vector<PreCompositedLayerInfo>& pre_composited_layers,
if (!cached) { if (!cached) {
GraphicsContext context(paint_controller); GraphicsContext context(paint_controller);
DCHECK(layer_state_) << "No layer state for GraphicsLayer: " << DebugName(); DCHECK(layer_state_) << "No layer state for GraphicsLayer: " << DebugName();
paint_controller.UpdateCurrentPaintChunkProperties(nullptr, paint_controller.UpdateCurrentPaintChunkProperties(
layer_state_->state); nullptr, layer_state_->state.GetPropertyTreeState());
previous_interest_rect_ = new_interest_rect; previous_interest_rect_ = new_interest_rect;
client_.PaintContents(this, context, painting_phase_, new_interest_rect); client_.PaintContents(this, context, painting_phase_, new_interest_rect);
paint_controller.CommitNewDisplayItems(); paint_controller.CommitNewDisplayItems();
...@@ -389,9 +390,9 @@ void GraphicsLayer::Paint(Vector<PreCompositedLayerInfo>& pre_composited_layers, ...@@ -389,9 +390,9 @@ void GraphicsLayer::Paint(Vector<PreCompositedLayerInfo>& pre_composited_layers,
auto& raster_invalidator = EnsureRasterInvalidator(); auto& raster_invalidator = EnsureRasterInvalidator();
gfx::Size old_layer_size = raster_invalidator.LayerBounds().size(); gfx::Size old_layer_size = raster_invalidator.LayerBounds().size();
gfx::Rect layer_bounds(layer_state_->offset, Size()); gfx::Rect layer_bounds(layer_state_->offset, Size());
PropertyTreeState property_tree_state = GetPropertyTreeState().Unalias();
EnsureRasterInvalidator().Generate(raster_invalidation_function_, chunks, EnsureRasterInvalidator().Generate(raster_invalidation_function_, chunks,
layer_bounds, layer_bounds, property_tree_state, this);
layer_state_->state.Unalias(), this);
base::Optional<RasterUnderInvalidationCheckingParams> base::Optional<RasterUnderInvalidationCheckingParams>
raster_under_invalidation_params; raster_under_invalidation_params;
...@@ -408,7 +409,7 @@ void GraphicsLayer::Paint(Vector<PreCompositedLayerInfo>& pre_composited_layers, ...@@ -408,7 +409,7 @@ void GraphicsLayer::Paint(Vector<PreCompositedLayerInfo>& pre_composited_layers,
if (raster_invalidated_ || !cc_display_item_list_ || if (raster_invalidated_ || !cc_display_item_list_ ||
old_layer_size != Size() || raster_under_invalidation_params) { old_layer_size != Size() || raster_under_invalidation_params) {
cc_display_item_list_ = PaintChunksToCcLayer::Convert( cc_display_item_list_ = PaintChunksToCcLayer::Convert(
chunks, layer_state_->state.Unalias(), chunks, property_tree_state,
gfx::Vector2dF(layer_state_->offset.X(), layer_state_->offset.Y()), gfx::Vector2dF(layer_state_->offset.X(), layer_state_->offset.Y()),
cc::DisplayItemList::kTopLevelDisplayItemList, cc::DisplayItemList::kTopLevelDisplayItemList,
base::OptionalOrNullptr(raster_under_invalidation_params)); base::OptionalOrNullptr(raster_under_invalidation_params));
...@@ -682,8 +683,8 @@ void GraphicsLayer::SetLayerState(const PropertyTreeStateOrAlias& layer_state, ...@@ -682,8 +683,8 @@ void GraphicsLayer::SetLayerState(const PropertyTreeStateOrAlias& layer_state,
layer_state_->state = layer_state; layer_state_->state = layer_state;
layer_state_->offset = layer_offset; layer_state_->offset = layer_offset;
} else { } else {
layer_state_ = layer_state_ = std::make_unique<LayerState>(
std::make_unique<LayerState>(LayerState{layer_state, layer_offset}); LayerState{RefCountedPropertyTreeState(layer_state), layer_offset});
} }
CcLayer().SetSubtreePropertyChanged(); CcLayer().SetSubtreePropertyChanged();
...@@ -702,8 +703,8 @@ void GraphicsLayer::SetContentsLayerState( ...@@ -702,8 +703,8 @@ void GraphicsLayer::SetContentsLayerState(
contents_layer_state_->state = layer_state; contents_layer_state_->state = layer_state;
contents_layer_state_->offset = layer_offset; contents_layer_state_->offset = layer_offset;
} else { } else {
contents_layer_state_ = contents_layer_state_ = std::make_unique<LayerState>(
std::make_unique<LayerState>(LayerState{layer_state, layer_offset}); LayerState{RefCountedPropertyTreeState(layer_state), layer_offset});
} }
ContentsLayer()->SetSubtreePropertyChanged(); ContentsLayer()->SetSubtreePropertyChanged();
......
...@@ -203,15 +203,16 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient, ...@@ -203,15 +203,16 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient,
bool HasLayerState() const { return layer_state_.get(); } bool HasLayerState() const { return layer_state_.get(); }
void SetLayerState(const PropertyTreeStateOrAlias&, void SetLayerState(const PropertyTreeStateOrAlias&,
const IntPoint& layer_offset); const IntPoint& layer_offset);
const PropertyTreeStateOrAlias& GetPropertyTreeState() const { PropertyTreeStateOrAlias GetPropertyTreeState() const {
return layer_state_->state; return layer_state_->state.GetPropertyTreeState();
} }
IntPoint GetOffsetFromTransformNode() const { return layer_state_->offset; } IntPoint GetOffsetFromTransformNode() const { return layer_state_->offset; }
void SetContentsLayerState(const PropertyTreeStateOrAlias&, void SetContentsLayerState(const PropertyTreeStateOrAlias&,
const IntPoint& layer_offset); const IntPoint& layer_offset);
const PropertyTreeStateOrAlias& GetContentsPropertyTreeState() const { PropertyTreeStateOrAlias GetContentsPropertyTreeState() const {
return contents_layer_state_ ? contents_layer_state_->state return contents_layer_state_
? contents_layer_state_->state.GetPropertyTreeState()
: GetPropertyTreeState(); : GetPropertyTreeState();
} }
IntPoint GetContentsOffsetFromTransformNode() const { IntPoint GetContentsOffsetFromTransformNode() const {
...@@ -310,7 +311,11 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient, ...@@ -310,7 +311,11 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient,
IntRect previous_interest_rect_; IntRect previous_interest_rect_;
struct LayerState { struct LayerState {
PropertyTreeStateOrAlias state; // In theory, it's unnecessary to use RefCountedPropertyTreeState because
// when it's used, the state should always reference current paint property
// nodes in ObjectPaintProperties. This is to workaround under-invalidation
// of layer state.
RefCountedPropertyTreeState state;
IntPoint offset; IntPoint offset;
}; };
std::unique_ptr<LayerState> layer_state_; std::unique_ptr<LayerState> layer_state_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment