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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 gfx::Rect quad_rect = iter->rect; | 73 gfx::Rect quad_rect = iter->rect; |
74 | 74 |
75 EXPECT_TRUE(visible_content_rect.Contains(quad_rect)) << iter.index(); | 75 EXPECT_TRUE(visible_content_rect.Contains(quad_rect)) << iter.index(); |
76 EXPECT_TRUE(remaining.Contains(quad_rect)) << iter.index(); | 76 EXPECT_TRUE(remaining.Contains(quad_rect)) << iter.index(); |
77 remaining.Subtract(Region(quad_rect)); | 77 remaining.Subtract(Region(quad_rect)); |
78 } | 78 } |
79 | 79 |
80 // Check if the left-over quad is the same size as the mapped aperture quad in | 80 // Check if the left-over quad is the same size as the mapped aperture quad in |
81 // layer space. | 81 // layer space. |
82 if (!fill_center) { | 82 if (!fill_center) { |
83 EXPECT_RECT_EQ(expected_remaining, gfx::ToEnclosedRect(remaining.bounds())); | 83 EXPECT_EQ(expected_remaining, gfx::ToEnclosedRect(remaining.bounds())); |
84 } else { | 84 } else { |
85 EXPECT_TRUE(remaining.bounds().IsEmpty()); | 85 EXPECT_TRUE(remaining.bounds().IsEmpty()); |
86 } | 86 } |
87 | 87 |
88 // Verify UV rects | 88 // Verify UV rects |
89 gfx::Rect bitmap_rect(bitmap_size); | 89 gfx::Rect bitmap_rect(bitmap_size); |
90 Region tex_remaining(bitmap_rect); | 90 Region tex_remaining(bitmap_rect); |
91 for (const auto& quad : quads) { | 91 for (const auto& quad : quads) { |
92 const TextureDrawQuad* tex_quad = TextureDrawQuad::MaterialCast(quad); | 92 const TextureDrawQuad* tex_quad = TextureDrawQuad::MaterialCast(quad); |
93 gfx::RectF tex_rect = | 93 gfx::RectF tex_rect = |
94 gfx::BoundingRect(tex_quad->uv_top_left, tex_quad->uv_bottom_right); | 94 gfx::BoundingRect(tex_quad->uv_top_left, tex_quad->uv_bottom_right); |
95 tex_rect.Scale(bitmap_size.width(), bitmap_size.height()); | 95 tex_rect.Scale(bitmap_size.width(), bitmap_size.height()); |
96 tex_remaining.Subtract(Region(ToRoundedIntRect(tex_rect))); | 96 tex_remaining.Subtract(Region(ToRoundedIntRect(tex_rect))); |
97 } | 97 } |
98 | 98 |
99 if (!fill_center) { | 99 if (!fill_center) { |
100 EXPECT_RECT_EQ(aperture_rect, tex_remaining.bounds()); | 100 EXPECT_EQ(aperture_rect, tex_remaining.bounds()); |
101 Region aperture_region(aperture_rect); | 101 Region aperture_region(aperture_rect); |
102 EXPECT_EQ(aperture_region, tex_remaining); | 102 EXPECT_EQ(aperture_region, tex_remaining); |
103 } else { | 103 } else { |
104 EXPECT_TRUE(remaining.bounds().IsEmpty()); | 104 EXPECT_TRUE(remaining.bounds().IsEmpty()); |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 TEST(NinePatchLayerImplTest, VerifyDrawQuads) { | 108 TEST(NinePatchLayerImplTest, VerifyDrawQuads) { |
109 // Input is a 100x100 bitmap with a 40x50 aperture at x=20, y=30. | 109 // Input is a 100x100 bitmap with a 40x50 aperture at x=20, y=30. |
110 // The bounds of the layer are set to 400x400. | 110 // The bounds of the layer are set to 400x400. |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 331 |
332 const QuadList &quad_list = impl.quad_list(); | 332 const QuadList &quad_list = impl.quad_list(); |
333 for (QuadList::ConstBackToFrontIterator it = quad_list.BackToFrontBegin(); | 333 for (QuadList::ConstBackToFrontIterator it = quad_list.BackToFrontBegin(); |
334 it != quad_list.BackToFrontEnd(); ++it) | 334 it != quad_list.BackToFrontEnd(); ++it) |
335 EXPECT_TRUE(it->ShouldDrawWithBlending()); | 335 EXPECT_TRUE(it->ShouldDrawWithBlending()); |
336 } | 336 } |
337 } | 337 } |
338 | 338 |
339 } // namespace | 339 } // namespace |
340 } // namespace cc | 340 } // namespace cc |
OLD | NEW |