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

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

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months 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/layer_test_common.h ('k') | cc/test/layer_tree_pixel_resource_test.cc » ('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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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());
79 gfx::Rect target_rect = 78 gfx::Rect target_rect =
80 MathUtil::MapEnclosingClippedRect(quad->quadTransform(), quad->rect); 79 MathUtil::MapEnclosingClippedRect(quad->quadTransform(), quad->rect);
80 if (!quad->quadTransform().IsIdentityOrIntegerTranslation()) {
81 DCHECK(quad->quadTransform().IsPositiveScaleOrTranslation())
82 << quad->quadTransform().ToString();
83 gfx::RectF target_rectf =
84 MathUtil::MapClippedRect(quad->quadTransform(), quad->rect);
85 // Scale transforms allowed, as long as the final transformed rect
86 // ends up on integer boundaries for ease of testing.
87 DCHECK_EQ(target_rectf.ToString(), gfx::RectF(target_rect).ToString());
88 }
81 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect( 89 gfx::Rect target_visible_rect = MathUtil::MapEnclosingClippedRect(
82 quad->quadTransform(), quad->visible_rect); 90 quad->quadTransform(), quad->visible_rect);
83 91
84 bool fully_occluded_horizontal = target_rect.x() >= occluded.x() && 92 bool fully_occluded_horizontal = target_rect.x() >= occluded.x() &&
85 target_rect.right() <= occluded.right(); 93 target_rect.right() <= occluded.right();
86 bool fully_occluded_vertical = target_rect.y() >= occluded.y() && 94 bool fully_occluded_vertical = target_rect.y() >= occluded.y() &&
87 target_rect.bottom() <= occluded.bottom(); 95 target_rect.bottom() <= occluded.bottom();
88 bool should_be_occluded = 96 bool should_be_occluded =
89 target_rect.Intersects(occluded) && 97 target_rect.Intersects(occluded) &&
90 (fully_occluded_vertical || fully_occluded_horizontal); 98 (fully_occluded_vertical || fully_occluded_horizontal);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 LayerImpl* layer_impl, 130 LayerImpl* layer_impl,
123 const gfx::Rect& occluded) { 131 const gfx::Rect& occluded) {
124 AppendQuadsData data; 132 AppendQuadsData data;
125 133
126 render_pass_->quad_list.clear(); 134 render_pass_->quad_list.clear();
127 render_pass_->shared_quad_state_list.clear(); 135 render_pass_->shared_quad_state_list.clear();
128 136
129 Occlusion occlusion(layer_impl->draw_transform(), 137 Occlusion occlusion(layer_impl->draw_transform(),
130 SimpleEnclosedRegion(occluded), 138 SimpleEnclosedRegion(occluded),
131 SimpleEnclosedRegion()); 139 SimpleEnclosedRegion());
140 layer_impl->draw_properties().occlusion_in_content_space = occlusion;
132 141
133 layer_impl->WillDraw(DRAW_MODE_HARDWARE, resource_provider()); 142 layer_impl->WillDraw(DRAW_MODE_HARDWARE, resource_provider());
134 layer_impl->AppendQuads(render_pass_.get(), occlusion, &data); 143 layer_impl->AppendQuads(render_pass_.get(), &data);
135 layer_impl->DidDraw(resource_provider()); 144 layer_impl->DidDraw(resource_provider());
136 } 145 }
137 146
138 void LayerTestCommon::LayerImplTest::AppendQuadsForPassWithOcclusion( 147 void LayerTestCommon::LayerImplTest::AppendQuadsForPassWithOcclusion(
139 LayerImpl* layer_impl, 148 LayerImpl* layer_impl,
140 RenderPass* given_render_pass, 149 RenderPass* given_render_pass,
141 const gfx::Rect& occluded) { 150 const gfx::Rect& occluded) {
142 AppendQuadsData data; 151 AppendQuadsData data;
143 152
144 given_render_pass->quad_list.clear(); 153 given_render_pass->quad_list.clear();
145 given_render_pass->shared_quad_state_list.clear(); 154 given_render_pass->shared_quad_state_list.clear();
146 155
147 Occlusion occlusion(layer_impl->draw_transform(), 156 Occlusion occlusion(layer_impl->draw_transform(),
148 SimpleEnclosedRegion(occluded), 157 SimpleEnclosedRegion(occluded),
149 SimpleEnclosedRegion()); 158 SimpleEnclosedRegion());
159 layer_impl->draw_properties().occlusion_in_content_space = occlusion;
150 160
151 layer_impl->WillDraw(DRAW_MODE_HARDWARE, resource_provider()); 161 layer_impl->WillDraw(DRAW_MODE_HARDWARE, resource_provider());
152 layer_impl->AppendQuads(given_render_pass, occlusion, &data); 162 layer_impl->AppendQuads(given_render_pass, &data);
153 layer_impl->DidDraw(resource_provider()); 163 layer_impl->DidDraw(resource_provider());
154 } 164 }
155 165
156 void LayerTestCommon::LayerImplTest::AppendSurfaceQuadsWithOcclusion( 166 void LayerTestCommon::LayerImplTest::AppendSurfaceQuadsWithOcclusion(
157 RenderSurfaceImpl* surface_impl, 167 RenderSurfaceImpl* surface_impl,
158 const gfx::Rect& occluded) { 168 const gfx::Rect& occluded) {
159 AppendQuadsData data; 169 AppendQuadsData data;
160 170
161 render_pass_->quad_list.clear(); 171 render_pass_->quad_list.clear();
162 render_pass_->shared_quad_state_list.clear(); 172 render_pass_->shared_quad_state_list.clear();
163 occlusion_tracker_.set_occluded_target_rect_for_contributing_surface( 173
164 occluded);
165 bool for_replica = false;
166 RenderPassId id(1, 1);
167 surface_impl->AppendQuads( 174 surface_impl->AppendQuads(
168 render_pass_.get(), occlusion_tracker_, &data, for_replica, id); 175 render_pass_.get(), gfx::Transform(),
176 Occlusion(gfx::Transform(), SimpleEnclosedRegion(occluded),
177 SimpleEnclosedRegion()),
178 SK_ColorBLACK, 1.f, nullptr, &data, RenderPassId(1, 1));
169 } 179 }
170 180
171 } // namespace cc 181 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_test_common.h ('k') | cc/test/layer_tree_pixel_resource_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698