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

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

Issue 2083083004: cc: nine patch: add occlusion support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for hidpi screens Created 4 years, 5 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
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "cc/layers/append_quads_data.h" 7 #include "cc/layers/append_quads_data.h"
8 #include "cc/layers/nine_patch_layer_impl.h" 8 #include "cc/layers/nine_patch_layer_impl.h"
9 #include "cc/quads/texture_draw_quad.h" 9 #include "cc/quads/texture_draw_quad.h"
10 #include "cc/resources/ui_resource_bitmap.h" 10 #include "cc/resources/ui_resource_bitmap.h"
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 void NinePatchLayerLayoutTest(const gfx::Size& bitmap_size, 34 void NinePatchLayerLayoutTest(const gfx::Size& bitmap_size,
35 const gfx::Rect& aperture_rect, 35 const gfx::Rect& aperture_rect,
36 const gfx::Size& layer_size, 36 const gfx::Size& layer_size,
37 const gfx::Rect& border, 37 const gfx::Rect& border,
38 bool fill_center, 38 bool fill_center,
39 size_t expected_quad_size) { 39 size_t expected_quad_size) {
40 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); 40 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
41 gfx::Rect visible_layer_rect(layer_size); 41 gfx::Rect visible_layer_rect(layer_size);
42 gfx::Rect expected_remaining(border.x(), 42 gfx::Rect expected_remaining(border.x(), border.y(),
43 border.y(),
44 layer_size.width() - border.width(), 43 layer_size.width() - border.width(),
45 layer_size.height() - border.height()); 44 layer_size.height() - border.height());
46 45
47 FakeImplTaskRunnerProvider task_runner_provider; 46 FakeImplTaskRunnerProvider task_runner_provider;
48 TestSharedBitmapManager shared_bitmap_manager; 47 TestSharedBitmapManager shared_bitmap_manager;
49 TestTaskGraphRunner task_graph_runner; 48 TestTaskGraphRunner task_graph_runner;
50 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); 49 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d();
51 FakeUIResourceLayerTreeHostImpl host_impl( 50 FakeUIResourceLayerTreeHostImpl host_impl(
52 &task_runner_provider, &shared_bitmap_manager, &task_graph_runner); 51 &task_runner_provider, &shared_bitmap_manager, &task_graph_runner);
53 host_impl.SetVisible(true); 52 host_impl.SetVisible(true);
54 host_impl.InitializeRenderer(output_surface.get()); 53 host_impl.InitializeRenderer(output_surface.get());
55 54
56 std::unique_ptr<NinePatchLayerImpl> layer = 55 std::unique_ptr<NinePatchLayerImpl> layer =
57 NinePatchLayerImpl::Create(host_impl.active_tree(), 1); 56 NinePatchLayerImpl::Create(host_impl.active_tree(), 1);
58 layer->draw_properties().visible_layer_rect = visible_layer_rect; 57 layer->draw_properties().visible_layer_rect = visible_layer_rect;
59 layer->SetBounds(layer_size); 58 layer->SetBounds(layer_size);
60 layer->test_properties()->force_render_surface = true; 59 layer->test_properties()->force_render_surface = true;
61 60
62 UIResourceId uid = 1; 61 UIResourceId uid = 1;
63 bool is_opaque = false; 62 bool is_opaque = false;
64 UIResourceBitmap bitmap(bitmap_size, is_opaque); 63 UIResourceBitmap bitmap(bitmap_size, is_opaque);
65 64
66 host_impl.CreateUIResource(uid, bitmap); 65 host_impl.CreateUIResource(uid, bitmap);
67 layer->SetUIResourceId(uid); 66 layer->SetUIResourceId(uid);
68 layer->SetImageBounds(bitmap_size); 67 layer->SetImageBounds(bitmap_size);
69 layer->SetLayout(aperture_rect, border, fill_center, false); 68 layer->SetLayout(aperture_rect, border, gfx::Rect(), fill_center, false);
70 AppendQuadsData data; 69 AppendQuadsData data;
71 layer->AppendQuads(render_pass.get(), &data); 70 layer->AppendQuads(render_pass.get(), &data);
72 71
73 // Verify quad rects 72 // Verify quad rects
74 const QuadList& quads = render_pass->quad_list; 73 const QuadList& quads = render_pass->quad_list;
75 EXPECT_EQ(expected_quad_size, quads.size()); 74 EXPECT_EQ(expected_quad_size, quads.size());
76 75
77 Region remaining(visible_layer_rect); 76 Region layer_remaining(visible_layer_rect);
78 for (auto iter = quads.cbegin(); iter != quads.cend(); ++iter) { 77 for (auto iter = quads.cbegin(); iter != quads.cend(); ++iter) {
79 gfx::Rect quad_rect = iter->rect; 78 gfx::Rect quad_rect = iter->rect;
80 79
81 EXPECT_TRUE(visible_layer_rect.Contains(quad_rect)) << iter.index(); 80 EXPECT_TRUE(visible_layer_rect.Contains(quad_rect)) << iter.index();
82 EXPECT_TRUE(remaining.Contains(quad_rect)) << iter.index(); 81 EXPECT_TRUE(layer_remaining.Contains(quad_rect)) << iter.index();
83 remaining.Subtract(Region(quad_rect)); 82 layer_remaining.Subtract(Region(quad_rect));
84 } 83 }
85 84
86 // Check if the left-over quad is the same size as the mapped aperture quad in 85 // Check if the left-over quad is the same size as the mapped aperture quad in
87 // layer space. 86 // layer space.
88 if (!fill_center) { 87 if (!fill_center) {
89 EXPECT_EQ(expected_remaining, remaining.bounds()); 88 EXPECT_EQ(expected_remaining, layer_remaining.bounds());
90 } else { 89 } else {
91 EXPECT_TRUE(remaining.bounds().IsEmpty()); 90 EXPECT_TRUE(layer_remaining.bounds().IsEmpty());
92 } 91 }
93 92
94 // Verify UV rects 93 // Verify UV rects
95 gfx::Rect bitmap_rect(bitmap_size); 94 gfx::Rect bitmap_rect(bitmap_size);
96 Region tex_remaining(bitmap_rect); 95 Region tex_remaining(bitmap_rect);
97 for (const auto& quad : quads) { 96 for (const auto& quad : quads) {
98 const TextureDrawQuad* tex_quad = TextureDrawQuad::MaterialCast(quad); 97 const TextureDrawQuad* tex_quad = TextureDrawQuad::MaterialCast(quad);
99 gfx::RectF tex_rect = 98 gfx::RectF tex_rect =
100 gfx::BoundingRect(tex_quad->uv_top_left, tex_quad->uv_bottom_right); 99 gfx::BoundingRect(tex_quad->uv_top_left, tex_quad->uv_bottom_right);
101 tex_rect.Scale(bitmap_size.width(), bitmap_size.height()); 100 tex_rect.Scale(bitmap_size.width(), bitmap_size.height());
102 tex_remaining.Subtract(Region(ToRoundedIntRect(tex_rect))); 101 tex_remaining.Subtract(Region(ToRoundedIntRect(tex_rect)));
103 } 102 }
104 103
105 if (!fill_center) { 104 if (!fill_center) {
106 EXPECT_EQ(aperture_rect, tex_remaining.bounds()); 105 EXPECT_EQ(aperture_rect, tex_remaining.bounds());
107 Region aperture_region(aperture_rect); 106 Region aperture_region(aperture_rect);
108 EXPECT_EQ(aperture_region, tex_remaining); 107 EXPECT_EQ(aperture_region, tex_remaining);
109 } else { 108 } else {
110 EXPECT_TRUE(remaining.bounds().IsEmpty()); 109 EXPECT_TRUE(layer_remaining.bounds().IsEmpty());
111 } 110 }
112 } 111 }
113 112
113 void NinePatchLayerLayoutTestWithOcclusion(const gfx::Size& bitmap_size,
114 const gfx::Rect& aperture_rect,
115 const gfx::Size& layer_size,
116 const gfx::Rect& border,
117 const gfx::Rect& occlusion,
118 bool fill_center,
119 size_t expected_quad_size) {
120 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
121 gfx::Rect visible_layer_rect(layer_size);
122 int border_left = std::min(border.x(), occlusion.x()),
123 border_top = std::min(border.y(), occlusion.y()),
124 border_right = std::min(border.width() - border.x(),
125 layer_size.width() - occlusion.right()),
126 border_bottom = std::min(border.height() - border.y(),
127 layer_size.height() - occlusion.bottom());
128 gfx::Rect expected_layer_remaining(
129 border_left, border_top, layer_size.width() - border_left - border_right,
130 layer_size.height() - border_top - border_bottom);
131 float ratio_left = border_left == 0 ? 0 : (aperture_rect.x() / border.x()),
132 ratio_top = border_top == 0 ? 0 : (aperture_rect.y() / border.y()),
133 ratio_right = border_right == 0
134 ? 0
135 : ((bitmap_size.width() - aperture_rect.right()) /
136 (border.width() - border.x())),
137 ratio_bottom = border_bottom == 0
138 ? 0
139 : ((bitmap_size.height() - aperture_rect.bottom()) /
140 (border.height() - border.y()));
141 int image_remaining_left = border_left * ratio_left,
142 image_remaining_top = border_top * ratio_top,
143 image_remaining_right = border_right * ratio_right,
144 image_remaining_bottom = border_bottom * ratio_bottom;
145 gfx::Rect expected_tex_remaining(
146 image_remaining_left, image_remaining_top,
147 bitmap_size.width() - image_remaining_right - image_remaining_left,
148 bitmap_size.height() - image_remaining_bottom - image_remaining_top);
149
150 FakeImplTaskRunnerProvider task_runner_provider;
151 TestSharedBitmapManager shared_bitmap_manager;
152 TestTaskGraphRunner task_graph_runner;
153 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d();
154 FakeUIResourceLayerTreeHostImpl host_impl(
155 &task_runner_provider, &shared_bitmap_manager, &task_graph_runner);
156 host_impl.SetVisible(true);
157 host_impl.InitializeRenderer(output_surface.get());
158
159 std::unique_ptr<NinePatchLayerImpl> layer =
160 NinePatchLayerImpl::Create(host_impl.active_tree(), 1);
161 layer->draw_properties().visible_layer_rect = visible_layer_rect;
162 layer->SetBounds(layer_size);
163 layer->test_properties()->force_render_surface = true;
164
165 UIResourceId uid = 1;
166 bool is_opaque = false;
167 UIResourceBitmap bitmap(bitmap_size, is_opaque);
168
169 host_impl.CreateUIResource(uid, bitmap);
170 layer->SetUIResourceId(uid);
171 layer->SetImageBounds(bitmap_size);
172 layer->SetLayout(aperture_rect, border, occlusion, false, false);
173 AppendQuadsData data;
174 layer->AppendQuads(render_pass.get(), &data);
175
176 // Verify quad rects
177 const QuadList& quads = render_pass->quad_list;
178 EXPECT_EQ(expected_quad_size, quads.size());
179
180 Region layer_remaining(visible_layer_rect);
181 for (auto iter = quads.cbegin(); iter != quads.cend(); ++iter) {
182 gfx::Rect quad_rect = iter->rect;
183
184 EXPECT_TRUE(visible_layer_rect.Contains(quad_rect)) << iter.index();
185 EXPECT_TRUE(layer_remaining.Contains(quad_rect)) << iter.index();
186 layer_remaining.Subtract(Region(quad_rect));
187 }
188
189 // Check if the left-over quad is the same size as the mapped aperture quad in
190 // layer space.
191 EXPECT_EQ(expected_layer_remaining, layer_remaining.bounds());
192
193 // Verify UV rects
194 gfx::Rect bitmap_rect(bitmap_size);
195 Region tex_remaining(bitmap_rect);
196 for (const auto& quad : quads) {
197 const TextureDrawQuad* tex_quad = TextureDrawQuad::MaterialCast(quad);
198 gfx::RectF tex_rect =
199 gfx::BoundingRect(tex_quad->uv_top_left, tex_quad->uv_bottom_right);
200 tex_rect.Scale(bitmap_size.width(), bitmap_size.height());
201 tex_remaining.Subtract(Region(ToRoundedIntRect(tex_rect)));
202 }
203
204 EXPECT_EQ(expected_tex_remaining, tex_remaining.bounds());
205 Region aperture_region(expected_tex_remaining);
206 EXPECT_EQ(aperture_region, tex_remaining);
207 }
208
114 TEST(NinePatchLayerImplTest, VerifyDrawQuads) { 209 TEST(NinePatchLayerImplTest, VerifyDrawQuads) {
115 // Input is a 100x100 bitmap with a 40x50 aperture at x=20, y=30. 210 // Input is a 100x100 bitmap with a 40x50 aperture at x=20, y=30.
116 // The bounds of the layer are set to 400x400. 211 // The bounds of the layer are set to 400x400.
117 gfx::Size bitmap_size(100, 100); 212 gfx::Size bitmap_size(100, 100);
118 gfx::Size layer_size(400, 500); 213 gfx::Size layer_size(400, 500);
119 gfx::Rect aperture_rect(20, 30, 40, 50); 214 gfx::Rect aperture_rect(20, 30, 40, 50);
120 gfx::Rect border(40, 40, 80, 80); 215 gfx::Rect border(40, 40, 80, 80);
121 bool fill_center = false; 216 bool fill_center = false;
122 size_t expected_quad_size = 8; 217 size_t expected_quad_size = 8;
123 NinePatchLayerLayoutTest(bitmap_size, 218 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border,
124 aperture_rect, 219 fill_center, expected_quad_size);
125 layer_size,
126 border,
127 fill_center,
128 expected_quad_size);
129 220
130 // The bounds of the layer are set to less than the bitmap size. 221 // The bounds of the layer are set to less than the bitmap size.
131 bitmap_size = gfx::Size(100, 100); 222 bitmap_size = gfx::Size(100, 100);
132 layer_size = gfx::Size(40, 50); 223 layer_size = gfx::Size(40, 50);
133 aperture_rect = gfx::Rect(20, 30, 40, 50); 224 aperture_rect = gfx::Rect(20, 30, 40, 50);
134 border = gfx::Rect(10, 10, 25, 15); 225 border = gfx::Rect(10, 10, 25, 15);
135 fill_center = true; 226 fill_center = true;
136 expected_quad_size = 9; 227 expected_quad_size = 9;
137 NinePatchLayerLayoutTest(bitmap_size, 228 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border,
138 aperture_rect, 229 fill_center, expected_quad_size);
139 layer_size,
140 border,
141 fill_center,
142 expected_quad_size);
143 230
144 // Layer and image sizes are equal. 231 // Layer and image sizes are equal.
145 bitmap_size = gfx::Size(100, 100); 232 bitmap_size = gfx::Size(100, 100);
146 layer_size = gfx::Size(100, 100); 233 layer_size = gfx::Size(100, 100);
147 aperture_rect = gfx::Rect(20, 30, 40, 50); 234 aperture_rect = gfx::Rect(20, 30, 40, 50);
148 border = gfx::Rect(20, 30, 40, 50); 235 border = gfx::Rect(20, 30, 40, 50);
149 fill_center = true; 236 fill_center = true;
150 expected_quad_size = 9; 237 expected_quad_size = 9;
151 NinePatchLayerLayoutTest(bitmap_size, 238 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border,
152 aperture_rect, 239 fill_center, expected_quad_size);
153 layer_size, 240 }
154 border, 241
155 fill_center, 242 TEST(NinePatchLayerImplTest, VerifyDrawQuadsWithOcclusion) {
156 expected_quad_size); 243 // Occlusion removed part of the border and leaves us with 12 patches.
244 gfx::Size bitmap_size(100, 100);
245 gfx::Rect aperture_rect(30, 30, 40, 40);
246 gfx::Size layer_size(400, 400);
247 gfx::Rect occlusion(20, 20, 360, 360);
248 gfx::Rect border(30, 30, 60, 60);
249 size_t expected_quad_size = 12;
250 NinePatchLayerLayoutTestWithOcclusion(bitmap_size, aperture_rect, layer_size,
251 border, occlusion, false,
252 expected_quad_size);
253
254 bitmap_size = gfx::Size(100, 100);
255 aperture_rect = gfx::Rect(20, 30, 60, 40);
256 layer_size = gfx::Size(400, 400);
257 occlusion = gfx::Rect(10, 10, 380, 380);
258 border = gfx::Rect(20, 30, 40, 60);
259 expected_quad_size = 12;
260 NinePatchLayerLayoutTestWithOcclusion(bitmap_size, aperture_rect, layer_size,
261 border, occlusion, false,
262 expected_quad_size);
263
264 // All borders are empty, so nothing should be drawn.
265 bitmap_size = gfx::Size(100, 100);
266 aperture_rect = gfx::Rect(0, 0, 100, 100);
267 layer_size = gfx::Size(400, 400);
268 occlusion = gfx::Rect(0, 0, 400, 400);
269 border = gfx::Rect(0, 0, 0, 0);
270 expected_quad_size = 0;
271 NinePatchLayerLayoutTestWithOcclusion(bitmap_size, aperture_rect, layer_size,
272 border, occlusion, false,
273 expected_quad_size);
274
275 // Right border is empty, we should have no quads on the right side.
276 bitmap_size = gfx::Size(100, 100);
277 aperture_rect = gfx::Rect(20, 30, 80, 40);
278 layer_size = gfx::Size(400, 400);
279 occlusion = gfx::Rect(10, 10, 390, 380);
280 border = gfx::Rect(20, 30, 20, 60);
281 expected_quad_size = 7;
282 NinePatchLayerLayoutTestWithOcclusion(bitmap_size, aperture_rect, layer_size,
283 border, occlusion, false,
284 expected_quad_size);
157 } 285 }
158 286
159 TEST(NinePatchLayerImplTest, VerifyDrawQuadsWithEmptyPatches) { 287 TEST(NinePatchLayerImplTest, VerifyDrawQuadsWithEmptyPatches) {
160 // The top component of the 9-patch is empty, so there should be no quads for 288 // The top component of the 9-patch is empty, so there should be no quads for
161 // the top three components. 289 // the top three components.
162 gfx::Size bitmap_size(100, 100); 290 gfx::Size bitmap_size(100, 100);
163 gfx::Size layer_size(100, 100); 291 gfx::Size layer_size(100, 100);
164 gfx::Rect aperture_rect(10, 0, 80, 90); 292 gfx::Rect aperture_rect(10, 0, 80, 90);
165 gfx::Rect border(10, 0, 20, 10); 293 gfx::Rect border(10, 0, 20, 10);
166 bool fill_center = false; 294 bool fill_center = false;
167 size_t expected_quad_size = 5; 295 size_t expected_quad_size = 5;
168 NinePatchLayerLayoutTest(bitmap_size, 296 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border,
169 aperture_rect, 297 fill_center, expected_quad_size);
170 layer_size,
171 border,
172 fill_center,
173 expected_quad_size);
174 298
175 // The top and left components of the 9-patch are empty, so there should be no 299 // The top and left components of the 9-patch are empty, so there should be no
176 // quads for the left and top components. 300 // quads for the left and top components.
177 bitmap_size = gfx::Size(100, 100); 301 bitmap_size = gfx::Size(100, 100);
178 layer_size = gfx::Size(100, 100); 302 layer_size = gfx::Size(100, 100);
179 aperture_rect = gfx::Rect(0, 0, 90, 90); 303 aperture_rect = gfx::Rect(0, 0, 90, 90);
180 border = gfx::Rect(0, 0, 10, 10); 304 border = gfx::Rect(0, 0, 10, 10);
181 fill_center = false; 305 fill_center = false;
182 expected_quad_size = 3; 306 expected_quad_size = 3;
183 NinePatchLayerLayoutTest(bitmap_size, 307 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border,
184 aperture_rect, 308 fill_center, expected_quad_size);
185 layer_size,
186 border,
187 fill_center,
188 expected_quad_size);
189 309
190 // The aperture is the size of the bitmap and the center doesn't draw. 310 // The aperture is the size of the bitmap and the center doesn't draw.
191 bitmap_size = gfx::Size(100, 100); 311 bitmap_size = gfx::Size(100, 100);
192 layer_size = gfx::Size(100, 100); 312 layer_size = gfx::Size(100, 100);
193 aperture_rect = gfx::Rect(0, 0, 100, 100); 313 aperture_rect = gfx::Rect(0, 0, 100, 100);
194 border = gfx::Rect(0, 0, 0, 0); 314 border = gfx::Rect(0, 0, 0, 0);
195 fill_center = false; 315 fill_center = false;
196 expected_quad_size = 0; 316 expected_quad_size = 0;
197 NinePatchLayerLayoutTest(bitmap_size, 317 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border,
198 aperture_rect, 318 fill_center, expected_quad_size);
199 layer_size,
200 border,
201 fill_center,
202 expected_quad_size);
203 319
204 // The aperture is the size of the bitmap and the center does draw. 320 // The aperture is the size of the bitmap and the center does draw.
205 bitmap_size = gfx::Size(100, 100); 321 bitmap_size = gfx::Size(100, 100);
206 layer_size = gfx::Size(100, 100); 322 layer_size = gfx::Size(100, 100);
207 aperture_rect = gfx::Rect(0, 0, 100, 100); 323 aperture_rect = gfx::Rect(0, 0, 100, 100);
208 border = gfx::Rect(0, 0, 0, 0); 324 border = gfx::Rect(0, 0, 0, 0);
209 fill_center = true; 325 fill_center = true;
210 expected_quad_size = 1; 326 expected_quad_size = 1;
211 NinePatchLayerLayoutTest(bitmap_size, 327 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border,
212 aperture_rect, 328 fill_center, expected_quad_size);
213 layer_size,
214 border,
215 fill_center,
216 expected_quad_size);
217 } 329 }
218 330
219 TEST(NinePatchLayerImplTest, Occlusion) { 331 TEST(NinePatchLayerImplTest, Occlusion) {
220 gfx::Size layer_size(1000, 1000); 332 gfx::Size layer_size(1000, 1000);
221 gfx::Size viewport_size(1000, 1000); 333 gfx::Size viewport_size(1000, 1000);
222 334
223 LayerTestCommon::LayerImplTest impl; 335 LayerTestCommon::LayerImplTest impl;
224 336
225 SkBitmap sk_bitmap; 337 SkBitmap sk_bitmap;
226 sk_bitmap.allocN32Pixels(10, 10); 338 sk_bitmap.allocN32Pixels(10, 10);
227 sk_bitmap.setImmutable(); 339 sk_bitmap.setImmutable();
228 UIResourceId uid = 5; 340 UIResourceId uid = 5;
229 UIResourceBitmap bitmap(sk_bitmap); 341 UIResourceBitmap bitmap(sk_bitmap);
230 impl.host_impl()->CreateUIResource(uid, bitmap); 342 impl.host_impl()->CreateUIResource(uid, bitmap);
231 343
232 NinePatchLayerImpl* nine_patch_layer_impl = 344 NinePatchLayerImpl* nine_patch_layer_impl =
233 impl.AddChildToRoot<NinePatchLayerImpl>(); 345 impl.AddChildToRoot<NinePatchLayerImpl>();
234 nine_patch_layer_impl->SetBounds(layer_size); 346 nine_patch_layer_impl->SetBounds(layer_size);
235 nine_patch_layer_impl->SetDrawsContent(true); 347 nine_patch_layer_impl->SetDrawsContent(true);
236 nine_patch_layer_impl->SetUIResourceId(uid); 348 nine_patch_layer_impl->SetUIResourceId(uid);
237 nine_patch_layer_impl->SetImageBounds(gfx::Size(10, 10)); 349 nine_patch_layer_impl->SetImageBounds(gfx::Size(10, 10));
238 350
239 gfx::Rect aperture = gfx::Rect(3, 3, 4, 4); 351 gfx::Rect aperture = gfx::Rect(3, 3, 4, 4);
240 gfx::Rect border = gfx::Rect(300, 300, 400, 400); 352 gfx::Rect border = gfx::Rect(300, 300, 400, 400);
241 nine_patch_layer_impl->SetLayout(aperture, border, true, false); 353 nine_patch_layer_impl->SetLayout(aperture, border, gfx::Rect(), true, false);
242 354
243 impl.CalcDrawProps(viewport_size); 355 impl.CalcDrawProps(viewport_size);
244 356
245 { 357 {
246 SCOPED_TRACE("No occlusion"); 358 SCOPED_TRACE("No occlusion");
247 gfx::Rect occluded; 359 gfx::Rect occluded;
248 impl.AppendQuadsWithOcclusion(nine_patch_layer_impl, occluded); 360 impl.AppendQuadsWithOcclusion(nine_patch_layer_impl, occluded);
249 361
250 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), 362 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(),
251 gfx::Rect(layer_size)); 363 gfx::Rect(layer_size));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 impl.CalcDrawProps(viewport_size); 421 impl.CalcDrawProps(viewport_size);
310 422
311 { 423 {
312 SCOPED_TRACE("Use opaque image"); 424 SCOPED_TRACE("Use opaque image");
313 425
314 nine_patch_layer_impl->SetUIResourceId(uid_opaque); 426 nine_patch_layer_impl->SetUIResourceId(uid_opaque);
315 nine_patch_layer_impl->SetImageBounds(gfx::Size(10, 10)); 427 nine_patch_layer_impl->SetImageBounds(gfx::Size(10, 10));
316 428
317 gfx::Rect aperture = gfx::Rect(3, 3, 4, 4); 429 gfx::Rect aperture = gfx::Rect(3, 3, 4, 4);
318 gfx::Rect border = gfx::Rect(300, 300, 400, 400); 430 gfx::Rect border = gfx::Rect(300, 300, 400, 400);
319 nine_patch_layer_impl->SetLayout(aperture, border, true, false); 431 nine_patch_layer_impl->SetLayout(aperture, border, gfx::Rect(), true,
432 false);
320 433
321 impl.AppendQuadsWithOcclusion(nine_patch_layer_impl, gfx::Rect()); 434 impl.AppendQuadsWithOcclusion(nine_patch_layer_impl, gfx::Rect());
322 435
323 const QuadList &quad_list = impl.quad_list(); 436 const QuadList &quad_list = impl.quad_list();
324 for (QuadList::ConstBackToFrontIterator it = quad_list.BackToFrontBegin(); 437 for (QuadList::ConstBackToFrontIterator it = quad_list.BackToFrontBegin();
325 it != quad_list.BackToFrontEnd(); ++it) 438 it != quad_list.BackToFrontEnd(); ++it)
326 EXPECT_FALSE(it->ShouldDrawWithBlending()); 439 EXPECT_FALSE(it->ShouldDrawWithBlending());
327 } 440 }
328 441
329 { 442 {
330 SCOPED_TRACE("Use tranparent image"); 443 SCOPED_TRACE("Use tranparent image");
331 444
332 nine_patch_layer_impl->SetUIResourceId(uid_alpha); 445 nine_patch_layer_impl->SetUIResourceId(uid_alpha);
333 446
334 impl.AppendQuadsWithOcclusion(nine_patch_layer_impl, gfx::Rect()); 447 impl.AppendQuadsWithOcclusion(nine_patch_layer_impl, gfx::Rect());
335 448
336 const QuadList &quad_list = impl.quad_list(); 449 const QuadList &quad_list = impl.quad_list();
337 for (QuadList::ConstBackToFrontIterator it = quad_list.BackToFrontBegin(); 450 for (QuadList::ConstBackToFrontIterator it = quad_list.BackToFrontBegin();
338 it != quad_list.BackToFrontEnd(); ++it) 451 it != quad_list.BackToFrontEnd(); ++it)
339 EXPECT_TRUE(it->ShouldDrawWithBlending()); 452 EXPECT_TRUE(it->ShouldDrawWithBlending());
340 } 453 }
341 } 454 }
342 455
343 } // namespace 456 } // namespace
344 } // namespace cc 457 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698