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(
},
[&](const GraphicsLayer& layer, cc::Layer& contents_layer) {
PaintChunkSubsetRecorder subset_recorder(context.GetPaintController());
auto contents_state = layer.GetContentsPropertyTreeState();
RecordForeignLayer(
context, layer, DisplayItem::kForeignLayerContentsWrapper,
&contents_layer, layer.GetContentsOffsetFromTransformNode(),
&layer.GetContentsPropertyTreeState());
&contents_state);
pre_composited_layers.push_back(
PreCompositedLayerInfo{subset_recorder.Get()});
});
......@@ -364,8 +365,8 @@ void GraphicsLayer::Paint(Vector<PreCompositedLayerInfo>& pre_composited_layers,
if (!cached) {
GraphicsContext context(paint_controller);
DCHECK(layer_state_) << "No layer state for GraphicsLayer: " << DebugName();
paint_controller.UpdateCurrentPaintChunkProperties(nullptr,
layer_state_->state);
paint_controller.UpdateCurrentPaintChunkProperties(
nullptr, layer_state_->state.GetPropertyTreeState());
previous_interest_rect_ = new_interest_rect;
client_.PaintContents(this, context, painting_phase_, new_interest_rect);
paint_controller.CommitNewDisplayItems();
......@@ -389,9 +390,9 @@ void GraphicsLayer::Paint(Vector<PreCompositedLayerInfo>& pre_composited_layers,
auto& raster_invalidator = EnsureRasterInvalidator();
gfx::Size old_layer_size = raster_invalidator.LayerBounds().size();
gfx::Rect layer_bounds(layer_state_->offset, Size());
PropertyTreeState property_tree_state = GetPropertyTreeState().Unalias();
EnsureRasterInvalidator().Generate(raster_invalidation_function_, chunks,
layer_bounds,
layer_state_->state.Unalias(), this);
layer_bounds, property_tree_state, this);
base::Optional<RasterUnderInvalidationCheckingParams>
raster_under_invalidation_params;
......@@ -408,7 +409,7 @@ void GraphicsLayer::Paint(Vector<PreCompositedLayerInfo>& pre_composited_layers,
if (raster_invalidated_ || !cc_display_item_list_ ||
old_layer_size != Size() || raster_under_invalidation_params) {
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()),
cc::DisplayItemList::kTopLevelDisplayItemList,
base::OptionalOrNullptr(raster_under_invalidation_params));
......@@ -682,8 +683,8 @@ void GraphicsLayer::SetLayerState(const PropertyTreeStateOrAlias& layer_state,
layer_state_->state = layer_state;
layer_state_->offset = layer_offset;
} else {
layer_state_ =
std::make_unique<LayerState>(LayerState{layer_state, layer_offset});
layer_state_ = std::make_unique<LayerState>(
LayerState{RefCountedPropertyTreeState(layer_state), layer_offset});
}
CcLayer().SetSubtreePropertyChanged();
......@@ -702,8 +703,8 @@ void GraphicsLayer::SetContentsLayerState(
contents_layer_state_->state = layer_state;
contents_layer_state_->offset = layer_offset;
} else {
contents_layer_state_ =
std::make_unique<LayerState>(LayerState{layer_state, layer_offset});
contents_layer_state_ = std::make_unique<LayerState>(
LayerState{RefCountedPropertyTreeState(layer_state), layer_offset});
}
ContentsLayer()->SetSubtreePropertyChanged();
......
......@@ -203,16 +203,17 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient,
bool HasLayerState() const { return layer_state_.get(); }
void SetLayerState(const PropertyTreeStateOrAlias&,
const IntPoint& layer_offset);
const PropertyTreeStateOrAlias& GetPropertyTreeState() const {
return layer_state_->state;
PropertyTreeStateOrAlias GetPropertyTreeState() const {
return layer_state_->state.GetPropertyTreeState();
}
IntPoint GetOffsetFromTransformNode() const { return layer_state_->offset; }
void SetContentsLayerState(const PropertyTreeStateOrAlias&,
const IntPoint& layer_offset);
const PropertyTreeStateOrAlias& GetContentsPropertyTreeState() const {
return contents_layer_state_ ? contents_layer_state_->state
: GetPropertyTreeState();
PropertyTreeStateOrAlias GetContentsPropertyTreeState() const {
return contents_layer_state_
? contents_layer_state_->state.GetPropertyTreeState()
: GetPropertyTreeState();
}
IntPoint GetContentsOffsetFromTransformNode() const {
return contents_layer_state_ ? contents_layer_state_->offset
......@@ -310,7 +311,11 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient,
IntRect previous_interest_rect_;
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;
};
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