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

Side by Side Diff: cc/layers/ui_resource_layer_impl_unittest.cc

Issue 203463015: cc: Apply occlusion before creating quads in UIResourceLayerImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « cc/layers/ui_resource_layer_impl.cc ('k') | cc/test/layer_test_common.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/layers/append_quads_data.h" 5 #include "cc/layers/append_quads_data.h"
6 #include "cc/layers/ui_resource_layer_impl.h" 6 #include "cc/layers/ui_resource_layer_impl.h"
7 #include "cc/resources/ui_resource_bitmap.h" 7 #include "cc/resources/ui_resource_bitmap.h"
8 #include "cc/resources/ui_resource_client.h" 8 #include "cc/resources/ui_resource_client.h"
9 #include "cc/test/fake_impl_proxy.h" 9 #include "cc/test/fake_impl_proxy.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 10 #include "cc/test/fake_layer_tree_host_impl.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 gfx::Rect expected_opaque_bounds; 141 gfx::Rect expected_opaque_bounds;
142 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); 142 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds);
143 143
144 layer = GenerateUIResourceLayer( 144 layer = GenerateUIResourceLayer(
145 &host_impl, bitmap_size, layer_size, skbitmap_opaque, uid); 145 &host_impl, bitmap_size, layer_size, skbitmap_opaque, uid);
146 layer->SetContentsOpaque(true); 146 layer->SetContentsOpaque(true);
147 expected_opaque_bounds = gfx::Rect(layer->bounds()); 147 expected_opaque_bounds = gfx::Rect(layer->bounds());
148 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); 148 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds);
149 } 149 }
150 150
151 TEST(UIResourceLayerImplTest, Occlusion) {
152 gfx::Size layer_size(1000, 1000);
153 gfx::Size viewport_size(1000, 1000);
154
155 LayerTestCommon::LayerImplTest impl;
156
157 SkBitmap sk_bitmap;
158 sk_bitmap.allocN32Pixels(10, 10);
159 sk_bitmap.setImmutable();
160 UIResourceId uid = 5;
161 UIResourceBitmap bitmap(sk_bitmap);
162 impl.host_impl()->CreateUIResource(uid, bitmap);
163
164 UIResourceLayerImpl* ui_resource_layer_impl =
165 impl.AddChildToRoot<UIResourceLayerImpl>();
166 ui_resource_layer_impl->SetAnchorPoint(gfx::PointF());
167 ui_resource_layer_impl->SetBounds(layer_size);
168 ui_resource_layer_impl->SetContentBounds(layer_size);
169 ui_resource_layer_impl->SetDrawsContent(true);
170 ui_resource_layer_impl->SetUIResourceId(uid);
171
172 impl.CalcDrawProps(viewport_size);
173
174 {
175 SCOPED_TRACE("No occlusion");
176 gfx::Rect occluded;
177 impl.AppendQuadsWithOcclusion(ui_resource_layer_impl, occluded);
178
179 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(),
180 gfx::Rect(layer_size));
181 EXPECT_EQ(1u, impl.quad_list().size());
182 }
183
184 {
185 SCOPED_TRACE("Full occlusion");
186 gfx::Rect occluded(ui_resource_layer_impl->visible_content_rect());
187 impl.AppendQuadsWithOcclusion(ui_resource_layer_impl, occluded);
188
189 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect());
190 EXPECT_EQ(impl.quad_list().size(), 0u);
191 }
192
193 {
194 SCOPED_TRACE("Partial occlusion");
195 gfx::Rect occluded(200, 0, 800, 1000);
196 impl.AppendQuadsWithOcclusion(ui_resource_layer_impl, occluded);
197
198 size_t partially_occluded_count = 0;
199 LayerTestCommon::VerifyQuadsCoverRectWithOcclusion(
200 impl.quad_list(),
201 gfx::Rect(layer_size),
202 occluded,
203 &partially_occluded_count);
204 // The layer outputs one quad, which is partially occluded.
205 EXPECT_EQ(1u, impl.quad_list().size());
206 EXPECT_EQ(1u, partially_occluded_count);
207 }
208 }
209
151 } // namespace 210 } // namespace
152 } // namespace cc 211 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/ui_resource_layer_impl.cc ('k') | cc/test/layer_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698