Commit 3b85aa06 authored by Stefan Zager's avatar Stefan Zager Committed by Chromium LUCI CQ

Remove contents_opaque functionality from GraphicsLayer

Instead, set contents_opaque directly on the cc::Layer. This makes it
more straightforward to migrate the logic to PaintArtifactCompositor.

Bug: 1069546
Change-Id: Ifa338b89bb2636b257b34e67e51c7a300c9e5754
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2607668
Commit-Queue: Stefan Zager <szager@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840110}
parent 190c9a13
...@@ -143,7 +143,7 @@ static void DetachScrollbarLayerFromGraphicsLayer( ...@@ -143,7 +143,7 @@ static void DetachScrollbarLayerFromGraphicsLayer(
GraphicsLayer* scrollbar_graphics_layer) { GraphicsLayer* scrollbar_graphics_layer) {
DCHECK(scrollbar_graphics_layer); DCHECK(scrollbar_graphics_layer);
scrollbar_graphics_layer->SetContentsToCcLayer(nullptr, false); scrollbar_graphics_layer->SetContentsToCcLayer(nullptr);
scrollbar_graphics_layer->SetDrawsContent(true); scrollbar_graphics_layer->SetDrawsContent(true);
scrollbar_graphics_layer->SetHitTestable(true); scrollbar_graphics_layer->SetHitTestable(true);
} }
...@@ -159,9 +159,7 @@ static void SetupScrollbarLayer(GraphicsLayer* scrollbar_graphics_layer, ...@@ -159,9 +159,7 @@ static void SetupScrollbarLayer(GraphicsLayer* scrollbar_graphics_layer,
} }
scrollbar_layer->SetScrollElementId(scrolling_layer->element_id()); scrollbar_layer->SetScrollElementId(scrolling_layer->element_id());
scrollbar_graphics_layer->SetContentsToCcLayer( scrollbar_graphics_layer->SetContentsToCcLayer(scrollbar_layer);
scrollbar_layer,
/*prevent_contents_opaque_changes=*/true);
scrollbar_graphics_layer->SetDrawsContent(false); scrollbar_graphics_layer->SetDrawsContent(false);
scrollbar_graphics_layer->SetHitTestable(false); scrollbar_graphics_layer->SetHitTestable(false);
} }
...@@ -226,7 +224,7 @@ void ScrollingCoordinator::ScrollableAreaScrollbarLayerDidChange( ...@@ -226,7 +224,7 @@ void ScrollingCoordinator::ScrollableAreaScrollbarLayerDidChange(
scrollable_area->LayerForScrolling()); scrollable_area->LayerForScrolling());
SetScrollbarLayer(scrollable_area, orientation, SetScrollbarLayer(scrollable_area, orientation,
std::move(new_scrollbar_layer)); std::move(new_scrollbar_layer));
scrollbar_graphics_layer->SetContentsOpaque(contents_opaque); scrollbar_graphics_layer->CcLayer().SetContentsOpaque(contents_opaque);
} else { } else {
RemoveScrollbarLayer(scrollable_area, orientation); RemoveScrollbarLayer(scrollable_area, orientation);
} }
......
...@@ -224,16 +224,16 @@ void CompositedLayerMapping::UpdateGraphicsLayerContentsOpaque( ...@@ -224,16 +224,16 @@ void CompositedLayerMapping::UpdateGraphicsLayerContentsOpaque(
if (BackgroundPaintsOntoGraphicsLayer()) { if (BackgroundPaintsOntoGraphicsLayer()) {
bool contents_opaque = owning_layer_.BackgroundIsKnownToBeOpaqueInRect( bool contents_opaque = owning_layer_.BackgroundIsKnownToBeOpaqueInRect(
CompositedBounds(), should_check_children); CompositedBounds(), should_check_children);
graphics_layer_->SetContentsOpaque(contents_opaque); graphics_layer_->CcLayer().SetContentsOpaque(contents_opaque);
if (!contents_opaque) { if (!contents_opaque) {
graphics_layer_->SetContentsOpaqueForText( graphics_layer_->CcLayer().SetContentsOpaqueForText(
GetLayoutObject().TextIsKnownToBeOnOpaqueBackground()); GetLayoutObject().TextIsKnownToBeOnOpaqueBackground());
} }
} else { } else {
// If we only paint the background onto the scrolling contents layer we // If we only paint the background onto the scrolling contents layer we
// are going to leave a hole in the m_graphicsLayer where the background // are going to leave a hole in the m_graphicsLayer where the background
// is so it is not opaque. // is so it is not opaque.
graphics_layer_->SetContentsOpaque(false); graphics_layer_->CcLayer().SetContentsOpaque(false);
} }
} }
...@@ -252,9 +252,9 @@ void CompositedLayerMapping::UpdateContentsOpaque() { ...@@ -252,9 +252,9 @@ void CompositedLayerMapping::UpdateContentsOpaque() {
bool contents_opaque = owning_layer_.BackgroundIsKnownToBeOpaqueInRect( bool contents_opaque = owning_layer_.BackgroundIsKnownToBeOpaqueInRect(
To<LayoutBox>(GetLayoutObject()).PhysicalPaddingBoxRect(), To<LayoutBox>(GetLayoutObject()).PhysicalPaddingBoxRect(),
should_check_children); should_check_children);
scrolling_contents_layer_->SetContentsOpaque(contents_opaque); scrolling_contents_layer_->CcLayer().SetContentsOpaque(contents_opaque);
if (!contents_opaque) { if (!contents_opaque) {
scrolling_contents_layer_->SetContentsOpaqueForText( scrolling_contents_layer_->CcLayer().SetContentsOpaqueForText(
GetLayoutObject().TextIsKnownToBeOnOpaqueBackground()); GetLayoutObject().TextIsKnownToBeOnOpaqueBackground());
} }
...@@ -262,12 +262,12 @@ void CompositedLayerMapping::UpdateContentsOpaque() { ...@@ -262,12 +262,12 @@ void CompositedLayerMapping::UpdateContentsOpaque() {
} else { } else {
DCHECK(BackgroundPaintsOntoGraphicsLayer()); DCHECK(BackgroundPaintsOntoGraphicsLayer());
if (scrolling_contents_layer_) if (scrolling_contents_layer_)
scrolling_contents_layer_->SetContentsOpaque(false); scrolling_contents_layer_->CcLayer().SetContentsOpaque(false);
UpdateGraphicsLayerContentsOpaque(should_check_children); UpdateGraphicsLayerContentsOpaque(should_check_children);
} }
if (non_scrolling_squashing_layer_) { if (non_scrolling_squashing_layer_) {
non_scrolling_squashing_layer_->SetContentsOpaque(false); non_scrolling_squashing_layer_->CcLayer().SetContentsOpaque(false);
bool contents_opaque_for_text = true; bool contents_opaque_for_text = true;
for (const GraphicsLayerPaintInfo& squashed_layer : for (const GraphicsLayerPaintInfo& squashed_layer :
non_scrolling_squashed_layers_) { non_scrolling_squashed_layers_) {
...@@ -277,7 +277,7 @@ void CompositedLayerMapping::UpdateContentsOpaque() { ...@@ -277,7 +277,7 @@ void CompositedLayerMapping::UpdateContentsOpaque() {
break; break;
} }
} }
non_scrolling_squashing_layer_->SetContentsOpaqueForText( non_scrolling_squashing_layer_->CcLayer().SetContentsOpaqueForText(
contents_opaque_for_text); contents_opaque_for_text);
} }
} }
...@@ -351,22 +351,19 @@ bool CompositedLayerMapping::UpdateGraphicsLayerConfiguration( ...@@ -351,22 +351,19 @@ bool CompositedLayerMapping::UpdateGraphicsLayerConfiguration(
if (layout_object.IsLayoutEmbeddedContent()) { if (layout_object.IsLayoutEmbeddedContent()) {
if (WebPluginContainerImpl* plugin = GetPluginContainer(layout_object)) { if (WebPluginContainerImpl* plugin = GetPluginContainer(layout_object)) {
graphics_layer_->SetContentsToCcLayer(plugin->CcLayer(), true); graphics_layer_->SetContentsToCcLayer(plugin->CcLayer());
} else if (auto* frame_owner = } else if (auto* frame_owner =
DynamicTo<HTMLFrameOwnerElement>(layout_object.GetNode())) { DynamicTo<HTMLFrameOwnerElement>(layout_object.GetNode())) {
if (auto* remote = DynamicTo<RemoteFrame>(frame_owner->ContentFrame())) { if (auto* remote = DynamicTo<RemoteFrame>(frame_owner->ContentFrame())) {
graphics_layer_->SetContentsToCcLayer(remote->GetCcLayer(), true); graphics_layer_->SetContentsToCcLayer(remote->GetCcLayer());
} }
} }
} else if (IsA<LayoutVideo>(layout_object)) { } else if (IsA<LayoutVideo>(layout_object)) {
auto* media_element = To<HTMLMediaElement>(layout_object.GetNode()); auto* media_element = To<HTMLMediaElement>(layout_object.GetNode());
graphics_layer_->SetContentsToCcLayer( graphics_layer_->SetContentsToCcLayer(media_element->CcLayer());
media_element->CcLayer(),
/*prevent_contents_opaque_changes=*/true);
} else if (layout_object.IsCanvas()) { } else if (layout_object.IsCanvas()) {
graphics_layer_->SetContentsToCcLayer( graphics_layer_->SetContentsToCcLayer(
To<HTMLCanvasElement>(layout_object.GetNode())->ContentsCcLayer(), To<HTMLCanvasElement>(layout_object.GetNode())->ContentsCcLayer());
/*prevent_contents_opaque_changes=*/true);
layer_config_changed = true; layer_config_changed = true;
} }
......
...@@ -1475,7 +1475,7 @@ TEST_F(CompositedLayerMappingTest, ContentsNotOpaqueWithForegroundLayer) { ...@@ -1475,7 +1475,7 @@ TEST_F(CompositedLayerMappingTest, ContentsNotOpaqueWithForegroundLayer) {
PaintLayer* target_layer = GetPaintLayerByElementId("target"); PaintLayer* target_layer = GetPaintLayerByElementId("target");
CompositedLayerMapping* mapping = target_layer->GetCompositedLayerMapping(); CompositedLayerMapping* mapping = target_layer->GetCompositedLayerMapping();
EXPECT_TRUE(mapping->ForegroundLayer()); EXPECT_TRUE(mapping->ForegroundLayer());
EXPECT_FALSE(mapping->MainGraphicsLayer()->ContentsOpaque()); EXPECT_FALSE(mapping->MainGraphicsLayer()->CcLayer().contents_opaque());
} }
TEST_F(CompositedLayerMappingTest, EmptyBoundsDoesntDrawContent) { TEST_F(CompositedLayerMappingTest, EmptyBoundsDoesntDrawContent) {
...@@ -1532,7 +1532,7 @@ TEST_F(CompositedLayerMappingTest, ContentsOpaque) { ...@@ -1532,7 +1532,7 @@ TEST_F(CompositedLayerMappingTest, ContentsOpaque) {
PaintLayer* target_layer = GetPaintLayerByElementId("target"); PaintLayer* target_layer = GetPaintLayerByElementId("target");
CompositedLayerMapping* mapping = target_layer->GetCompositedLayerMapping(); CompositedLayerMapping* mapping = target_layer->GetCompositedLayerMapping();
EXPECT_FALSE(mapping->ForegroundLayer()); EXPECT_FALSE(mapping->ForegroundLayer());
EXPECT_TRUE(mapping->MainGraphicsLayer()->ContentsOpaque()); EXPECT_TRUE(mapping->MainGraphicsLayer()->CcLayer().contents_opaque());
} }
TEST_F(CompositedLayerMappingTest, NullOverflowControlLayers) { TEST_F(CompositedLayerMappingTest, NullOverflowControlLayers) {
......
...@@ -112,7 +112,8 @@ class PaintLayerScrollableAreaTest : public RenderingTest, ...@@ -112,7 +112,8 @@ class PaintLayerScrollableAreaTest : public RenderingTest,
return To<LayoutBoxModelObject>(scroller) return To<LayoutBoxModelObject>(scroller)
->Layer() ->Layer()
->GraphicsLayerBacking() ->GraphicsLayerBacking()
->ContentsOpaque(); ->CcLayer()
.contents_opaque();
} }
private: private:
......
...@@ -67,7 +67,6 @@ namespace blink { ...@@ -67,7 +67,6 @@ namespace blink {
GraphicsLayer::GraphicsLayer(GraphicsLayerClient& client) GraphicsLayer::GraphicsLayer(GraphicsLayerClient& client)
: client_(client), : client_(client),
prevent_contents_opaque_changes_(false),
draws_content_(false), draws_content_(false),
paints_hit_test_(false), paints_hit_test_(false),
contents_visible_(true), contents_visible_(true),
...@@ -459,14 +458,12 @@ void GraphicsLayer::UpdateContentsLayerBounds() { ...@@ -459,14 +458,12 @@ void GraphicsLayer::UpdateContentsLayerBounds() {
} }
void GraphicsLayer::SetContentsToCcLayer( void GraphicsLayer::SetContentsToCcLayer(
scoped_refptr<cc::Layer> contents_layer, scoped_refptr<cc::Layer> contents_layer) {
bool prevent_contents_opaque_changes) {
DCHECK_NE(contents_layer, layer_); DCHECK_NE(contents_layer, layer_);
SetContentsTo(std::move(contents_layer), prevent_contents_opaque_changes); SetContentsTo(std::move(contents_layer));
} }
void GraphicsLayer::SetContentsTo(scoped_refptr<cc::Layer> layer, void GraphicsLayer::SetContentsTo(scoped_refptr<cc::Layer> layer) {
bool prevent_contents_opaque_changes) {
if (layer) { if (layer) {
if (contents_layer_ != layer) { if (contents_layer_ != layer) {
contents_layer_ = std::move(layer); contents_layer_ = std::move(layer);
...@@ -478,7 +475,6 @@ void GraphicsLayer::SetContentsTo(scoped_refptr<cc::Layer> layer, ...@@ -478,7 +475,6 @@ void GraphicsLayer::SetContentsTo(scoped_refptr<cc::Layer> layer,
NotifyChildListChange(); NotifyChildListChange();
} }
UpdateContentsLayerBounds(); UpdateContentsLayerBounds();
prevent_contents_opaque_changes_ = prevent_contents_opaque_changes;
} else if (contents_layer_) { } else if (contents_layer_) {
contents_layer_ = nullptr; contents_layer_ = nullptr;
NotifyChildListChange(); NotifyChildListChange();
...@@ -591,20 +587,6 @@ void GraphicsLayer::SetContentsVisible(bool contents_visible) { ...@@ -591,20 +587,6 @@ void GraphicsLayer::SetContentsVisible(bool contents_visible) {
UpdateLayerIsDrawable(); UpdateLayerIsDrawable();
} }
bool GraphicsLayer::ContentsOpaque() const {
return CcLayer().contents_opaque();
}
void GraphicsLayer::SetContentsOpaque(bool opaque) {
CcLayer().SetContentsOpaque(opaque);
if (contents_layer_ && !prevent_contents_opaque_changes_)
contents_layer_->SetContentsOpaque(opaque);
}
void GraphicsLayer::SetContentsOpaqueForText(bool opaque) {
CcLayer().SetContentsOpaqueForText(opaque);
}
void GraphicsLayer::SetPaintsHitTest(bool paints_hit_test) { void GraphicsLayer::SetPaintsHitTest(bool paints_hit_test) {
if (paints_hit_test_ == paints_hit_test) if (paints_hit_test_ == paints_hit_test)
return; return;
......
...@@ -139,11 +139,6 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient, ...@@ -139,11 +139,6 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient,
bool ContentsAreVisible() const { return contents_visible_; } bool ContentsAreVisible() const { return contents_visible_; }
void SetContentsVisible(bool); void SetContentsVisible(bool);
// Opaque means that we know the layer contents have no alpha.
bool ContentsOpaque() const;
void SetContentsOpaque(bool);
void SetContentsOpaqueForText(bool);
void SetHitTestable(bool); void SetHitTestable(bool);
bool IsHitTestable() const { return hit_testable_; } bool IsHitTestable() const { return hit_testable_; }
...@@ -156,12 +151,7 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient, ...@@ -156,12 +151,7 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient,
// Set that the position/size of the contents (image or video). // Set that the position/size of the contents (image or video).
void SetContentsRect(const IntRect&); void SetContentsRect(const IntRect&);
// If |prevent_contents_opaque_changes| is set to true, then calls to void SetContentsToCcLayer(scoped_refptr<cc::Layer> contents_layer);
// SetContentsOpaque() will not be passed on to |contents_layer|. Use when
// the client wants to have control of the opaqueness of |contents_layer|
// independently of what outcome painting produces.
void SetContentsToCcLayer(scoped_refptr<cc::Layer> contents_layer,
bool prevent_contents_opaque_changes);
bool HasContentsLayer() const { return ContentsLayer(); } bool HasContentsLayer() const { return ContentsLayer(); }
cc::Layer* ContentsLayer() const { return contents_layer_.get(); } cc::Layer* ContentsLayer() const { return contents_layer_.get(); }
...@@ -262,8 +252,7 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient, ...@@ -262,8 +252,7 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient,
void UpdateLayerIsDrawable(); void UpdateLayerIsDrawable();
void UpdateContentsLayerBounds(); void UpdateContentsLayerBounds();
void SetContentsTo(scoped_refptr<cc::Layer>, void SetContentsTo(scoped_refptr<cc::Layer>);
bool prevent_contents_opaque_changes);
RasterInvalidator& EnsureRasterInvalidator(); RasterInvalidator& EnsureRasterInvalidator();
void InvalidateRaster(const IntRect&); void InvalidateRaster(const IntRect&);
...@@ -275,7 +264,6 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient, ...@@ -275,7 +264,6 @@ class PLATFORM_EXPORT GraphicsLayer : public DisplayItemClient,
TransformationMatrix transform_; TransformationMatrix transform_;
bool prevent_contents_opaque_changes_ : 1;
bool draws_content_ : 1; bool draws_content_ : 1;
bool paints_hit_test_ : 1; bool paints_hit_test_ : 1;
bool contents_visible_ : 1; bool contents_visible_ : 1;
......
...@@ -188,10 +188,10 @@ TEST_F(GraphicsLayerTest, ContentsLayer) { ...@@ -188,10 +188,10 @@ TEST_F(GraphicsLayerTest, ContentsLayer) {
FakeGraphicsLayerClient client; FakeGraphicsLayerClient client;
GraphicsLayer graphics_layer(client); GraphicsLayer graphics_layer(client);
auto contents_layer = cc::Layer::Create(); auto contents_layer = cc::Layer::Create();
graphics_layer.SetContentsToCcLayer(contents_layer, true); graphics_layer.SetContentsToCcLayer(contents_layer);
EXPECT_TRUE(graphics_layer.HasContentsLayer()); EXPECT_TRUE(graphics_layer.HasContentsLayer());
EXPECT_EQ(contents_layer.get(), graphics_layer.ContentsLayer()); EXPECT_EQ(contents_layer.get(), graphics_layer.ContentsLayer());
graphics_layer.SetContentsToCcLayer(nullptr, true); graphics_layer.SetContentsToCcLayer(nullptr);
EXPECT_FALSE(graphics_layer.HasContentsLayer()); EXPECT_FALSE(graphics_layer.HasContentsLayer());
EXPECT_EQ(nullptr, graphics_layer.ContentsLayer()); EXPECT_EQ(nullptr, graphics_layer.ContentsLayer());
} }
......
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