Commit fbdb86ee authored by jaydasika's avatar jaydasika Committed by Commit bot

cc:: Remove RenderSurfaceImpl::TargetEffectTreeIndex

Need to remove it as it uses layer tree hierarchy information.
It is used for computing surface draw opacity which can be computed directly
from effect tree.

BUG=568799
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review URL: https://codereview.chromium.org/1613583002

Cr-Commit-Position: refs/heads/master@{#370739}
parent 6c6d7821
......@@ -108,12 +108,6 @@ int RenderSurfaceImpl::EffectTreeIndex() const {
return owning_layer_->effect_tree_index();
}
int RenderSurfaceImpl::TargetEffectTreeIndex() const {
if (!owning_layer_->parent() || !owning_layer_->parent()->render_target())
return -1;
return owning_layer_->parent()->render_target()->effect_tree_index();
}
void RenderSurfaceImpl::SetClipRect(const gfx::Rect& clip_rect) {
if (clip_rect_ == clip_rect)
return;
......
......@@ -155,7 +155,6 @@ class CC_EXPORT RenderSurfaceImpl {
int TransformTreeIndex() const;
int ClipTreeIndex() const;
int EffectTreeIndex() const;
int TargetEffectTreeIndex() const;
private:
LayerImpl* owning_layer_;
......
......@@ -915,15 +915,13 @@ static float LayerDrawOpacity(const LayerImpl* layer, const EffectTree& tree) {
static float SurfaceDrawOpacity(RenderSurfaceImpl* render_surface,
const EffectTree& tree) {
// Draw opacity of a surface is the product of opacities between the surface
// (included) and its target surface (excluded).
const EffectNode* node = tree.Node(render_surface->EffectTreeIndex());
float target_opacity_tree_index = render_surface->TargetEffectTreeIndex();
if (target_opacity_tree_index < 0)
return node->data.screen_space_opacity;
const EffectNode* target_node = tree.Node(target_opacity_tree_index);
float draw_opacity = 1.f;
while (node != target_node) {
float draw_opacity = node->data.opacity;
for (node = tree.parent(node); node && !node->data.has_render_surface;
node = tree.parent(node)) {
draw_opacity *= node->data.opacity;
node = tree.parent(node);
}
return draw_opacity;
}
......
......@@ -1432,6 +1432,43 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) {
EXPECT_EQ(SkXfermode::kSrcOver_Mode, child->draw_blend_mode());
}
TEST_F(LayerTreeHostCommonTest, RenderSurfaceDrawOpacity) {
LayerImpl* root = root_layer();
LayerImpl* surface1 = AddChildToRoot<LayerImpl>();
LayerImpl* not_surface = AddChild<LayerImpl>(surface1);
LayerImpl* surface2 = AddChild<LayerImpl>(not_surface);
const gfx::Transform identity_matrix;
SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
gfx::PointF(), gfx::Size(10, 10), true, false,
true);
SetLayerPropertiesForTesting(surface1, identity_matrix, gfx::Point3F(),
gfx::PointF(), gfx::Size(10, 10), true, false,
true);
SetLayerPropertiesForTesting(not_surface, identity_matrix, gfx::Point3F(),
gfx::PointF(), gfx::Size(10, 10), true, false,
false);
SetLayerPropertiesForTesting(surface2, identity_matrix, gfx::Point3F(),
gfx::PointF(), gfx::Size(10, 10), true, false,
true);
surface1->SetDrawsContent(true);
surface2->SetDrawsContent(true);
surface1->SetOpacity(0.5f);
not_surface->SetOpacity(0.5f);
surface2->SetOpacity(0.5f);
ExecuteCalculateDrawProperties(root);
ASSERT_TRUE(surface1->render_surface());
ASSERT_FALSE(not_surface->render_surface());
ASSERT_TRUE(surface2->render_surface());
EXPECT_EQ(0.5f, surface1->render_surface()->draw_opacity());
// surface2's draw opacity should include the opacity of not-surface and
// itself, but not the opacity of surface1.
EXPECT_EQ(0.25f, surface2->render_surface()->draw_opacity());
}
TEST_F(LayerTreeHostCommonTest, DrawOpacityWhenCannotRenderToSeparateSurface) {
// Tests that when separate surfaces are disabled, a layer's draw opacity is
// the product of all ancestor layer opacties and the layer's own opacity.
......
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