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

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

Issue 448303002: Use custom ListContainer to allocate DrawQuads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@perftest
Patch Set: change header files to try fix compile error Created 6 years, 2 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 "base/containers/hash_tables.h" 5 #include "base/containers/hash_tables.h"
6 #include "cc/layers/append_quads_data.h" 6 #include "cc/layers/append_quads_data.h"
7 #include "cc/layers/nine_patch_layer_impl.h" 7 #include "cc/layers/nine_patch_layer_impl.h"
8 #include "cc/quads/texture_draw_quad.h" 8 #include "cc/quads/texture_draw_quad.h"
9 #include "cc/resources/ui_resource_bitmap.h" 9 #include "cc/resources/ui_resource_bitmap.h"
10 #include "cc/resources/ui_resource_client.h" 10 #include "cc/resources/ui_resource_client.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 layer->SetImageBounds(bitmap_size); 63 layer->SetImageBounds(bitmap_size);
64 layer->SetLayout(aperture_rect, border, fill_center); 64 layer->SetLayout(aperture_rect, border, fill_center);
65 AppendQuadsData data; 65 AppendQuadsData data;
66 layer->AppendQuads(render_pass.get(), occlusion_tracker, &data); 66 layer->AppendQuads(render_pass.get(), occlusion_tracker, &data);
67 67
68 // Verify quad rects 68 // Verify quad rects
69 const QuadList& quads = render_pass->quad_list; 69 const QuadList& quads = render_pass->quad_list;
70 EXPECT_EQ(expected_quad_size, quads.size()); 70 EXPECT_EQ(expected_quad_size, quads.size());
71 71
72 Region remaining(visible_content_rect); 72 Region remaining(visible_content_rect);
73 for (size_t i = 0; i < quads.size(); ++i) { 73 size_t i = 0;
74 DrawQuad* quad = quads[i]; 74 for (QuadList::ConstIterator iter = quads.begin(); iter != quads.end();
75 gfx::Rect quad_rect = quad->rect; 75 ++iter) {
76 gfx::Rect quad_rect = iter->rect;
76 77
77 EXPECT_TRUE(visible_content_rect.Contains(quad_rect)) << i; 78 EXPECT_TRUE(visible_content_rect.Contains(quad_rect)) << i;
78 EXPECT_TRUE(remaining.Contains(quad_rect)) << i; 79 EXPECT_TRUE(remaining.Contains(quad_rect)) << i;
79 remaining.Subtract(Region(quad_rect)); 80 remaining.Subtract(Region(quad_rect));
81 ++i;
80 } 82 }
81 83
82 // Check if the left-over quad is the same size as the mapped aperture quad in 84 // Check if the left-over quad is the same size as the mapped aperture quad in
83 // layer space. 85 // layer space.
84 if (!fill_center) { 86 if (!fill_center) {
85 EXPECT_RECT_EQ(expected_remaining, gfx::ToEnclosedRect(remaining.bounds())); 87 EXPECT_RECT_EQ(expected_remaining, gfx::ToEnclosedRect(remaining.bounds()));
86 } else { 88 } else {
87 EXPECT_TRUE(remaining.bounds().IsEmpty()); 89 EXPECT_TRUE(remaining.bounds().IsEmpty());
88 } 90 }
89 91
90 // Verify UV rects 92 // Verify UV rects
91 gfx::Rect bitmap_rect(bitmap_size); 93 gfx::Rect bitmap_rect(bitmap_size);
92 Region tex_remaining(bitmap_rect); 94 Region tex_remaining(bitmap_rect);
93 for (size_t i = 0; i < quads.size(); ++i) { 95 for (QuadList::ConstIterator iter = quads.begin(); iter != quads.end();
94 DrawQuad* quad = quads[i]; 96 ++iter) {
95 const TextureDrawQuad* tex_quad = TextureDrawQuad::MaterialCast(quad); 97 const TextureDrawQuad* tex_quad = TextureDrawQuad::MaterialCast(&*iter);
96 gfx::RectF tex_rect = 98 gfx::RectF tex_rect =
97 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);
98 tex_rect.Scale(bitmap_size.width(), bitmap_size.height()); 100 tex_rect.Scale(bitmap_size.width(), bitmap_size.height());
99 tex_remaining.Subtract(Region(ToRoundedIntRect(tex_rect))); 101 tex_remaining.Subtract(Region(ToRoundedIntRect(tex_rect)));
100 } 102 }
101 103
102 if (!fill_center) { 104 if (!fill_center) {
103 EXPECT_RECT_EQ(aperture_rect, tex_remaining.bounds()); 105 EXPECT_RECT_EQ(aperture_rect, tex_remaining.bounds());
104 Region aperture_region(aperture_rect); 106 Region aperture_region(aperture_rect);
105 EXPECT_EQ(aperture_region, tex_remaining); 107 EXPECT_EQ(aperture_region, tex_remaining);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 impl.quad_list(), occluded, &partially_occluded_count); 271 impl.quad_list(), occluded, &partially_occluded_count);
270 // The layer outputs nine quads, three of which are partially occluded, and 272 // The layer outputs nine quads, three of which are partially occluded, and
271 // three fully occluded. 273 // three fully occluded.
272 EXPECT_EQ(6u, impl.quad_list().size()); 274 EXPECT_EQ(6u, impl.quad_list().size());
273 EXPECT_EQ(3u, partially_occluded_count); 275 EXPECT_EQ(3u, partially_occluded_count);
274 } 276 }
275 } 277 }
276 278
277 } // namespace 279 } // namespace
278 } // namespace cc 280 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/delegated_renderer_layer_impl_unittest.cc ('k') | cc/layers/picture_image_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698