| OLD | NEW |
| 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 Loading... |
| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 &partially_occluded_count); | 274 &partially_occluded_count); |
| 273 // The layer outputs nine quads, three of which are partially occluded, and | 275 // The layer outputs nine quads, three of which are partially occluded, and |
| 274 // three fully occluded. | 276 // three fully occluded. |
| 275 EXPECT_EQ(6u, impl.quad_list().size()); | 277 EXPECT_EQ(6u, impl.quad_list().size()); |
| 276 EXPECT_EQ(3u, partially_occluded_count); | 278 EXPECT_EQ(3u, partially_occluded_count); |
| 277 } | 279 } |
| 278 } | 280 } |
| 279 | 281 |
| 280 } // namespace | 282 } // namespace |
| 281 } // namespace cc | 283 } // namespace cc |
| OLD | NEW |