Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1222)

Side by Side Diff: cc/test/layer_test_common.cc

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/test/fake_picture_layer_impl.h ('k') | cc/test/layer_tree_pixel_resource_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/test/layer_test_common.h" 5 #include "cc/test/layer_test_common.h"
6 6
7 #include "cc/base/math_util.h" 7 #include "cc/base/math_util.h"
8 #include "cc/base/region.h" 8 #include "cc/base/region.h"
9 #include "cc/layers/append_quads_data.h" 9 #include "cc/layers/append_quads_data.h"
10 #include "cc/quads/draw_quad.h" 10 #include "cc/quads/draw_quad.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 EXPECT_TRUE(remaining.IsEmpty()); 62 EXPECT_TRUE(remaining.IsEmpty());
63 } 63 }
64 64
65 // static 65 // static
66 void LayerTestCommon::VerifyQuadsAreOccluded(const QuadList& quads, 66 void LayerTestCommon::VerifyQuadsAreOccluded(const QuadList& quads,
67 const gfx::Rect& occluded, 67 const gfx::Rect& occluded,
68 size_t* partially_occluded_count) { 68 size_t* partially_occluded_count) {
69 // No quad should exist if it's fully occluded. 69 // No quad should exist if it's fully occluded.
70 for (const auto& quad : quads) { 70 for (const auto& quad : quads) {
71 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect( 71 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect(
72 quad.quadTransform(), quad.visible_rect); 72 quad->quadTransform(), quad->visible_rect);
73 EXPECT_FALSE(occluded.Contains(target_visible_rect)); 73 EXPECT_FALSE(occluded.Contains(target_visible_rect));
74 } 74 }
75 75
76 // Quads that are fully occluded on one axis only should be shrunken. 76 // Quads that are fully occluded on one axis only should be shrunken.
77 for (const auto& quad : quads) { 77 for (const auto& quad : quads) {
78 DCHECK(quad.quadTransform().IsIdentityOrIntegerTranslation()); 78 DCHECK(quad->quadTransform().IsIdentityOrIntegerTranslation());
79 gfx::Rect target_rect = 79 gfx::Rect target_rect =
80 MathUtil::MapEnclosingClippedRect(quad.quadTransform(), quad.rect); 80 MathUtil::MapEnclosingClippedRect(quad->quadTransform(), quad->rect);
81 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect( 81 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect(
82 quad.quadTransform(), quad.visible_rect); 82 quad->quadTransform(), quad->visible_rect);
83 83
84 bool fully_occluded_horizontal = target_rect.x() >= occluded.x() && 84 bool fully_occluded_horizontal = target_rect.x() >= occluded.x() &&
85 target_rect.right() <= occluded.right(); 85 target_rect.right() <= occluded.right();
86 bool fully_occluded_vertical = target_rect.y() >= occluded.y() && 86 bool fully_occluded_vertical = target_rect.y() >= occluded.y() &&
87 target_rect.bottom() <= occluded.bottom(); 87 target_rect.bottom() <= occluded.bottom();
88 bool should_be_occluded = 88 bool should_be_occluded =
89 target_rect.Intersects(occluded) && 89 target_rect.Intersects(occluded) &&
90 (fully_occluded_vertical || fully_occluded_horizontal); 90 (fully_occluded_vertical || fully_occluded_horizontal);
91 if (!should_be_occluded) { 91 if (!should_be_occluded) {
92 EXPECT_EQ(quad.rect.ToString(), quad.visible_rect.ToString()); 92 EXPECT_EQ(quad->rect.ToString(), quad->visible_rect.ToString());
93 } else { 93 } else {
94 EXPECT_NE(quad.rect.ToString(), quad.visible_rect.ToString()); 94 EXPECT_NE(quad->rect.ToString(), quad->visible_rect.ToString());
95 EXPECT_TRUE(quad.rect.Contains(quad.visible_rect)); 95 EXPECT_TRUE(quad->rect.Contains(quad->visible_rect));
96 ++(*partially_occluded_count); 96 ++(*partially_occluded_count);
97 } 97 }
98 } 98 }
99 } 99 }
100 100
101 LayerTestCommon::LayerImplTest::LayerImplTest() 101 LayerTestCommon::LayerImplTest::LayerImplTest()
102 : client_(FakeLayerTreeHostClient::DIRECT_3D), 102 : client_(FakeLayerTreeHostClient::DIRECT_3D),
103 host_(FakeLayerTreeHost::Create(&client_)), 103 host_(FakeLayerTreeHost::Create(&client_)),
104 root_layer_impl_(LayerImpl::Create(host_->host_impl()->active_tree(), 1)), 104 root_layer_impl_(LayerImpl::Create(host_->host_impl()->active_tree(), 1)),
105 render_pass_(RenderPass::Create()) { 105 render_pass_(RenderPass::Create()) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 render_pass_->shared_quad_state_list.clear(); 161 render_pass_->shared_quad_state_list.clear();
162 occlusion_tracker_.set_occluded_target_rect_for_contributing_surface( 162 occlusion_tracker_.set_occluded_target_rect_for_contributing_surface(
163 occluded); 163 occluded);
164 bool for_replica = false; 164 bool for_replica = false;
165 RenderPassId id(1, 1); 165 RenderPassId id(1, 1);
166 surface_impl->AppendQuads( 166 surface_impl->AppendQuads(
167 render_pass_.get(), occlusion_tracker_, &data, for_replica, id); 167 render_pass_.get(), occlusion_tracker_, &data, for_replica, id);
168 } 168 }
169 169
170 } // namespace cc 170 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_picture_layer_impl.h ('k') | cc/test/layer_tree_pixel_resource_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698