Skip to content

Commit

Permalink
Replace LayerImpl::sorting_context_id with transform reference.
Browse files Browse the repository at this point in the history
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2615773003
Cr-Commit-Position: refs/heads/master@{#442121}
  • Loading branch information
shaper authored and Commit bot committed Jan 7, 2017
1 parent 4ce240b commit f09921d
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 130 deletions.
1 change: 0 additions & 1 deletion cc/layers/layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,6 @@ void Layer::PushPropertiesTo(LayerImpl* layer) {
layer->SetUseLocalTransformForBackfaceVisibility(
use_local_transform_for_backface_visibility_);
layer->SetShouldCheckBackfaceVisibility(should_check_backface_visibility_);
layer->Set3dSortingContextId(inputs_.sorting_context_id);

layer->SetScrollClipLayer(inputs_.scroll_clip_layer_id);
layer->set_user_scrollable_horizontal(inputs_.user_scrollable_horizontal);
Expand Down
20 changes: 10 additions & 10 deletions cc/layers/layer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id)
effect_tree_index_(EffectTree::kInvalidNodeId),
clip_tree_index_(ClipTree::kInvalidNodeId),
scroll_tree_index_(ScrollTree::kInvalidNodeId),
sorting_context_id_(0),
current_draw_mode_(DRAW_MODE_NONE),
mutable_properties_(MutableProperty::kNone),
debug_info_(nullptr),
Expand Down Expand Up @@ -170,7 +169,7 @@ void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const {
state->SetAll(draw_properties_.target_space_transform, bounds(),
draw_properties_.visible_layer_rect, draw_properties_.clip_rect,
draw_properties_.is_clipped, draw_properties_.opacity,
draw_blend_mode_, sorting_context_id_);
draw_blend_mode_, GetSortingContextId());
}

void LayerImpl::PopulateScaledSharedQuadState(
Expand All @@ -190,7 +189,7 @@ void LayerImpl::PopulateScaledSharedQuadState(
state->SetAll(scaled_draw_transform, scaled_bounds, scaled_visible_layer_rect,
draw_properties().clip_rect, draw_properties().is_clipped,
draw_properties().opacity, draw_blend_mode_,
sorting_context_id_);
GetSortingContextId());
}

bool LayerImpl::WillDraw(DrawMode draw_mode,
Expand Down Expand Up @@ -353,7 +352,6 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) {
layer->effect_tree_index_ = effect_tree_index_;
layer->clip_tree_index_ = clip_tree_index_;
layer->scroll_tree_index_ = scroll_tree_index_;
layer->sorting_context_id_ = sorting_context_id_;
layer->has_will_change_transform_hint_ = has_will_change_transform_hint_;
layer->scrollbars_hidden_ = scrollbars_hidden_;

Expand Down Expand Up @@ -450,8 +448,7 @@ std::unique_ptr<base::DictionaryValue> LayerImpl::LayerTreeAsJson() {
}

bool LayerImpl::LayerPropertyChanged() const {
if (layer_property_changed_ ||
(GetPropertyTrees() && GetPropertyTrees()->full_tree_damaged))
if (layer_property_changed_ || GetPropertyTrees()->full_tree_damaged)
return true;
if (transform_tree_index() == TransformTree::kInvalidNodeId)
return false;
Expand Down Expand Up @@ -768,10 +765,6 @@ void LayerImpl::SetPosition(const gfx::PointF& position) {
position_ = position;
}

void LayerImpl::Set3dSortingContextId(int id) {
sorting_context_id_ = id;
}

bool LayerImpl::TransformIsAnimating() const {
return GetMutatorHost()->IsAnimatingTransformProperty(
element_id(), GetElementTypeForAnimation());
Expand Down Expand Up @@ -1038,6 +1031,13 @@ bool LayerImpl::CanUseLCDText() const {
return true;
}

int LayerImpl::GetSortingContextId() const {
return layer_tree_impl()
->property_trees()
->transform_tree.Node(transform_tree_index())
->sorting_context_id;
}

Region LayerImpl::GetInvalidationRegionForDebugging() {
return Region(update_rect_);
}
Expand Down
13 changes: 5 additions & 8 deletions cc/layers/layer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class CC_EXPORT LayerImpl {

gfx::Vector2dF FixedContainerSizeDelta() const;

bool Is3dSorted() const { return sorting_context_id_ != 0; }
bool Is3dSorted() const { return GetSortingContextId() != 0; }

void SetUseParentBackfaceVisibility(bool use) {
use_parent_backface_visibility_ = use;
Expand Down Expand Up @@ -409,8 +409,10 @@ class CC_EXPORT LayerImpl {
void set_may_contain_video(bool yes) { may_contain_video_ = yes; }
bool may_contain_video() const { return may_contain_video_; }

void Set3dSortingContextId(int id);
int sorting_context_id() { return sorting_context_id_; }
// Layers that share a sorting context id will be sorted together in 3d
// space. 0 is a special value that means this layer will not be sorted and
// will be drawn in paint order.
int GetSortingContextId() const;

// Get the correct invalidation region instead of conservative Rect
// for layers that provide it.
Expand Down Expand Up @@ -538,11 +540,6 @@ class CC_EXPORT LayerImpl {
protected:
friend class TreeSynchronizer;

// Layers that share a sorting context id will be sorted together in 3d
// space. 0 is a special value that means this layer will not be sorted and
// will be drawn in paint order.
int sorting_context_id_;

DrawMode current_draw_mode_;

private:
Expand Down
1 change: 1 addition & 0 deletions cc/layers/layer_impl_test_properties.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ LayerImplTestProperties::LayerImplTestProperties(LayerImpl* owning_layer)
hide_layer_and_subtree(false),
opacity_can_animate(false),
num_descendants_that_draw_content(0),
sorting_context_id(0),
num_unclipped_descendants(0),
opacity(1.f),
blend_mode(SkBlendMode::kSrcOver),
Expand Down
1 change: 1 addition & 0 deletions cc/layers/layer_impl_test_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct CC_EXPORT LayerImplTestProperties {
bool hide_layer_and_subtree;
bool opacity_can_animate;
int num_descendants_that_draw_content;
int sorting_context_id;
size_t num_unclipped_descendants;
float opacity;
FilterOperations filters;
Expand Down
4 changes: 0 additions & 4 deletions cc/layers/layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) {
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetMasksToBounds(true));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
root->SetPosition(arbitrary_point_f));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->Set3dSortingContextId(1));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetContentsOpaque(true));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetDrawsContent(true));
EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetBounds(bounds_size));
Expand Down Expand Up @@ -329,8 +328,6 @@ TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) {
layer->NoteLayerPropertyChanged());
VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetPosition(arbitrary_point_f);
layer->NoteLayerPropertyChanged());
VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1);
layer->NoteLayerPropertyChanged());
VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
layer->SetBackgroundColor(arbitrary_color));
VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
Expand All @@ -357,7 +354,6 @@ TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) {
VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true));
VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
layer2->SetPosition(arbitrary_point_f));
VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1));
VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true));
VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
layer->SetBackgroundColor(arbitrary_color));
Expand Down
12 changes: 10 additions & 2 deletions cc/layers/nine_patch_layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ void NinePatchLayerLayoutTest(const gfx::Size& bitmap_size,
layer->SetUIResourceId(uid);
layer->SetImageBounds(bitmap_size);
layer->SetLayout(aperture_rect, border, gfx::Rect(), fill_center, false);
host_impl.active_tree()->SetRootLayerForTesting(std::move(layer));
host_impl.active_tree()->BuildPropertyTreesForTesting();

AppendQuadsData data;
layer->AppendQuads(render_pass.get(), &data);
host_impl.active_tree()->root_layer_for_testing()->AppendQuads(
render_pass.get(), &data);

// Verify quad rects
const QuadList& quads = render_pass->quad_list;
Expand Down Expand Up @@ -170,8 +174,12 @@ void NinePatchLayerLayoutTestWithOcclusion(const gfx::Size& bitmap_size,
layer->SetUIResourceId(uid);
layer->SetImageBounds(bitmap_size);
layer->SetLayout(aperture_rect, border, occlusion, false, false);
host_impl.active_tree()->SetRootLayerForTesting(std::move(layer));
host_impl.active_tree()->BuildPropertyTreesForTesting();

AppendQuadsData data;
layer->AppendQuads(render_pass.get(), &data);
host_impl.active_tree()->root_layer_for_testing()->AppendQuads(
render_pass.get(), &data);

// Verify quad rects
const QuadList& quads = render_pass->quad_list;
Expand Down
1 change: 1 addition & 0 deletions cc/layers/picture_layer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ TEST(PictureLayerTest, ClearVisibleRectWhenNoTiling) {
// We should now have invalid contents and should therefore clear the
// recording source.
layer->PushPropertiesTo(layer_impl);
host_impl.pending_tree()->BuildPropertyTreesForTesting();

host_impl.ActivateSyncTree();

Expand Down
59 changes: 21 additions & 38 deletions cc/layers/solid_color_layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ TEST(SolidColorLayerImplTest, VerifyTilingCompleteAndNoOverlap) {
layer->draw_properties().visible_layer_rect = visible_layer_rect;
layer->SetBounds(layer_size);
layer->test_properties()->force_render_surface = true;

host_impl.active_tree()->SetRootLayerForTesting(std::move(layer));
host_impl.active_tree()->BuildPropertyTreesForTesting();
AppendQuadsData data;
layer->AppendQuads(render_pass.get(), &data);
host_impl.active_tree()->root_layer_for_testing()->AppendQuads(
render_pass.get(), &data);

LayerTestCommon::VerifyQuadsExactlyCoverRect(render_pass->quad_list,
visible_layer_rect);
Expand All @@ -63,9 +65,11 @@ TEST(SolidColorLayerImplTest, VerifyCorrectBackgroundColorInQuad) {
layer->SetBounds(layer_size);
layer->SetBackgroundColor(test_color);
layer->test_properties()->force_render_surface = true;

host_impl.active_tree()->SetRootLayerForTesting(std::move(layer));
host_impl.active_tree()->BuildPropertyTreesForTesting();
AppendQuadsData data;
layer->AppendQuads(render_pass.get(), &data);
host_impl.active_tree()->root_layer_for_testing()->AppendQuads(
render_pass.get(), &data);

ASSERT_EQ(render_pass->quad_list.size(), 1U);
EXPECT_EQ(
Expand All @@ -90,39 +94,18 @@ TEST(SolidColorLayerImplTest, VerifyCorrectOpacityInQuad) {
layer->SetBounds(layer_size);
layer->draw_properties().opacity = opacity;
layer->test_properties()->force_render_surface = true;

host_impl.active_tree()->SetRootLayerForTesting(std::move(layer));
host_impl.active_tree()->BuildPropertyTreesForTesting();
AppendQuadsData data;
layer->AppendQuads(render_pass.get(), &data);
host_impl.active_tree()->root_layer_for_testing()->AppendQuads(
render_pass.get(), &data);

ASSERT_EQ(render_pass->quad_list.size(), 1U);
EXPECT_EQ(opacity,
SolidColorDrawQuad::MaterialCast(render_pass->quad_list.front())
->shared_quad_state->opacity);
}

TEST(SolidColorLayerImplTest, VerifyCorrectBlendModeInQuad) {
const SkBlendMode blend_mode = SkBlendMode::kMultiply;

std::unique_ptr<RenderPass> render_pass = RenderPass::Create();

gfx::Size layer_size = gfx::Size(100, 100);

FakeImplTaskRunnerProvider task_runner_provider;
TestTaskGraphRunner task_graph_runner;
FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
std::unique_ptr<SolidColorLayerImpl> layer =
SolidColorLayerImpl::Create(host_impl.active_tree(), 1);
layer->SetBounds(layer_size);
layer->set_draw_blend_mode(blend_mode);

AppendQuadsData data;
layer->AppendQuads(render_pass.get(), &data);

ASSERT_EQ(render_pass->quad_list.size(), 1U);
EXPECT_EQ(blend_mode,
render_pass->quad_list.front()->shared_quad_state->blend_mode);
}

TEST(SolidColorLayerImplTest, VerifyOpaqueRect) {
gfx::Size layer_size = gfx::Size(100, 100);
gfx::Rect visible_layer_rect = gfx::Rect(layer_size);
Expand All @@ -149,10 +132,10 @@ TEST(SolidColorLayerImplTest, VerifyOpaqueRect) {
layer->SetBackgroundColor(SkColorSetARGBInline(255, 10, 20, 30));
EXPECT_TRUE(layer->contents_opaque());
{
std::unique_ptr<SolidColorLayerImpl> layer_impl =
SolidColorLayerImpl::Create(host->host_impl()->active_tree(),
layer->id());
layer->PushPropertiesTo(layer_impl.get());
DebugScopedSetImplThread scoped_impl_thread(host->GetTaskRunnerProvider());
host->FinishCommitOnImplThread(host->host_impl());
LayerImpl* layer_impl =
host->host_impl()->active_tree()->LayerById(layer->id());

// The impl layer should call itself opaque as well.
EXPECT_TRUE(layer_impl->contents_opaque());
Expand All @@ -175,12 +158,12 @@ TEST(SolidColorLayerImplTest, VerifyOpaqueRect) {
layer->SetBackgroundColor(SkColorSetARGBInline(254, 10, 20, 30));
EXPECT_FALSE(layer->contents_opaque());
{
std::unique_ptr<SolidColorLayerImpl> layer_impl =
SolidColorLayerImpl::Create(host->host_impl()->active_tree(),
layer->id());
layer->PushPropertiesTo(layer_impl.get());
DebugScopedSetImplThread scoped_impl_thread(host->GetTaskRunnerProvider());
host->FinishCommitOnImplThread(host->host_impl());
LayerImpl* layer_impl =
host->host_impl()->active_tree()->LayerById(layer->id());

// The impl layer should callnot itself opaque anymore.
// The impl layer should not call itself opaque anymore.
EXPECT_FALSE(layer_impl->contents_opaque());

// Impl layer has 1 opacity, but the color is not opaque, so the opaque_rect
Expand Down
3 changes: 3 additions & 0 deletions cc/layers/surface_layer_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ TEST(SurfaceLayerImplTest, SurfaceStretchedToLayerBounds) {
// aspect ratios.
gfx::Size layer_size(400, 100);
gfx::Size surface_size(300, 300);
gfx::Size viewport_size(1000, 1000);
float surface_scale = 1.f;
gfx::Transform target_space_transform(
surface_layer_impl->draw_properties().target_space_transform);
Expand All @@ -89,6 +90,8 @@ TEST(SurfaceLayerImplTest, SurfaceStretchedToLayerBounds) {
SurfaceInfo(surface_id, surface_scale, surface_size));
surface_layer_impl->SetStretchContentToFillBounds(true);

impl.CalcDrawProps(viewport_size);

std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
AppendQuadsData data;
surface_layer_impl->AppendQuads(render_pass.get(), &data);
Expand Down
Loading

0 comments on commit f09921d

Please sign in to comment.