| 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 <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 17 matching lines...) Expand all Loading... |
| 28 return gfx::Rect(gfx::ToRoundedInt(rect_f.x()), | 28 return gfx::Rect(gfx::ToRoundedInt(rect_f.x()), |
| 29 gfx::ToRoundedInt(rect_f.y()), | 29 gfx::ToRoundedInt(rect_f.y()), |
| 30 gfx::ToRoundedInt(rect_f.width()), | 30 gfx::ToRoundedInt(rect_f.width()), |
| 31 gfx::ToRoundedInt(rect_f.height())); | 31 gfx::ToRoundedInt(rect_f.height())); |
| 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 const gfx::Rect& occlusion, | |
| 39 bool fill_center, | 38 bool fill_center, |
| 40 size_t expected_quad_size) { | 39 size_t expected_quad_size) { |
| 41 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); | 40 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 42 gfx::Rect visible_layer_rect(layer_size); | 41 gfx::Rect visible_layer_rect(layer_size); |
| 43 gfx::Rect expected_layer_remaining; | 42 gfx::Rect expected_remaining(border.x(), border.y(), |
| 44 gfx::Rect expected_tex_remaining; | 43 layer_size.width() - border.width(), |
| 45 | 44 layer_size.height() - border.height()); |
| 46 if (!occlusion.IsEmpty()) { | |
| 47 expected_layer_remaining = occlusion; | |
| 48 expected_tex_remaining.SetRect( | |
| 49 occlusion.x(), occlusion.y(), | |
| 50 (bitmap_size.width() - occlusion.x()) - | |
| 51 (layer_size.width() - occlusion.right()), | |
| 52 (bitmap_size.height() - occlusion.y()) - | |
| 53 (layer_size.height() - occlusion.bottom())); | |
| 54 } else { | |
| 55 expected_layer_remaining.SetRect(border.x(), border.y(), | |
| 56 layer_size.width() - border.width(), | |
| 57 layer_size.height() - border.height()); | |
| 58 expected_tex_remaining = aperture_rect; | |
| 59 } | |
| 60 | 45 |
| 61 FakeImplTaskRunnerProvider task_runner_provider; | 46 FakeImplTaskRunnerProvider task_runner_provider; |
| 62 TestSharedBitmapManager shared_bitmap_manager; | 47 TestSharedBitmapManager shared_bitmap_manager; |
| 63 TestTaskGraphRunner task_graph_runner; | 48 TestTaskGraphRunner task_graph_runner; |
| 64 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 49 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
| 65 FakeUIResourceLayerTreeHostImpl host_impl( | 50 FakeUIResourceLayerTreeHostImpl host_impl( |
| 66 &task_runner_provider, &shared_bitmap_manager, &task_graph_runner); | 51 &task_runner_provider, &shared_bitmap_manager, &task_graph_runner); |
| 67 host_impl.SetVisible(true); | 52 host_impl.SetVisible(true); |
| 68 host_impl.InitializeRenderer(output_surface.get()); | 53 host_impl.InitializeRenderer(output_surface.get()); |
| 69 | 54 |
| 70 std::unique_ptr<NinePatchLayerImpl> layer = | 55 std::unique_ptr<NinePatchLayerImpl> layer = |
| 71 NinePatchLayerImpl::Create(host_impl.active_tree(), 1); | 56 NinePatchLayerImpl::Create(host_impl.active_tree(), 1); |
| 72 layer->draw_properties().visible_layer_rect = visible_layer_rect; | 57 layer->draw_properties().visible_layer_rect = visible_layer_rect; |
| 73 layer->SetBounds(layer_size); | 58 layer->SetBounds(layer_size); |
| 74 layer->test_properties()->force_render_surface = true; | 59 layer->test_properties()->force_render_surface = true; |
| 75 | 60 |
| 76 UIResourceId uid = 1; | 61 UIResourceId uid = 1; |
| 77 bool is_opaque = false; | 62 bool is_opaque = false; |
| 78 UIResourceBitmap bitmap(bitmap_size, is_opaque); | 63 UIResourceBitmap bitmap(bitmap_size, is_opaque); |
| 79 | 64 |
| 80 host_impl.CreateUIResource(uid, bitmap); | 65 host_impl.CreateUIResource(uid, bitmap); |
| 81 layer->SetUIResourceId(uid); | 66 layer->SetUIResourceId(uid); |
| 82 layer->SetImageBounds(bitmap_size); | 67 layer->SetImageBounds(bitmap_size); |
| 83 layer->SetLayout(aperture_rect, border, occlusion, fill_center, false); | 68 layer->SetLayout(aperture_rect, border, gfx::Rect(), fill_center, false); |
| 84 AppendQuadsData data; | 69 AppendQuadsData data; |
| 85 layer->AppendQuads(render_pass.get(), &data); | 70 layer->AppendQuads(render_pass.get(), &data); |
| 86 | 71 |
| 87 // Verify quad rects | 72 // Verify quad rects |
| 88 const QuadList& quads = render_pass->quad_list; | 73 const QuadList& quads = render_pass->quad_list; |
| 89 EXPECT_EQ(expected_quad_size, quads.size()); | 74 EXPECT_EQ(expected_quad_size, quads.size()); |
| 90 | 75 |
| 91 Region layer_remaining(visible_layer_rect); | 76 Region layer_remaining(visible_layer_rect); |
| 92 for (auto iter = quads.cbegin(); iter != quads.cend(); ++iter) { | 77 for (auto iter = quads.cbegin(); iter != quads.cend(); ++iter) { |
| 93 gfx::Rect quad_rect = iter->rect; | 78 gfx::Rect quad_rect = iter->rect; |
| 94 | 79 |
| 95 EXPECT_TRUE(visible_layer_rect.Contains(quad_rect)) << iter.index(); | 80 EXPECT_TRUE(visible_layer_rect.Contains(quad_rect)) << iter.index(); |
| 96 EXPECT_TRUE(layer_remaining.Contains(quad_rect)) << iter.index(); | 81 EXPECT_TRUE(layer_remaining.Contains(quad_rect)) << iter.index(); |
| 97 layer_remaining.Subtract(Region(quad_rect)); | 82 layer_remaining.Subtract(Region(quad_rect)); |
| 98 } | 83 } |
| 99 | 84 |
| 100 // 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 |
| 101 // layer space. | 86 // layer space. |
| 102 if (!fill_center) { | 87 if (!fill_center) { |
| 103 EXPECT_EQ(expected_layer_remaining, layer_remaining.bounds()); | 88 EXPECT_EQ(expected_remaining, layer_remaining.bounds()); |
| 104 } else { | 89 } else { |
| 105 EXPECT_TRUE(layer_remaining.bounds().IsEmpty()); | 90 EXPECT_TRUE(layer_remaining.bounds().IsEmpty()); |
| 106 } | 91 } |
| 107 | 92 |
| 108 // Verify UV rects | 93 // Verify UV rects |
| 109 gfx::Rect bitmap_rect(bitmap_size); | 94 gfx::Rect bitmap_rect(bitmap_size); |
| 110 Region tex_remaining(bitmap_rect); | 95 Region tex_remaining(bitmap_rect); |
| 111 for (const auto& quad : quads) { | 96 for (const auto& quad : quads) { |
| 112 const TextureDrawQuad* tex_quad = TextureDrawQuad::MaterialCast(quad); | 97 const TextureDrawQuad* tex_quad = TextureDrawQuad::MaterialCast(quad); |
| 113 gfx::RectF tex_rect = | 98 gfx::RectF tex_rect = |
| 114 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); |
| 115 tex_rect.Scale(bitmap_size.width(), bitmap_size.height()); | 100 tex_rect.Scale(bitmap_size.width(), bitmap_size.height()); |
| 116 tex_remaining.Subtract(Region(ToRoundedIntRect(tex_rect))); | 101 tex_remaining.Subtract(Region(ToRoundedIntRect(tex_rect))); |
| 117 } | 102 } |
| 118 | 103 |
| 119 if (!fill_center) { | 104 if (!fill_center) { |
| 120 EXPECT_EQ(expected_tex_remaining, tex_remaining.bounds()); | 105 EXPECT_EQ(aperture_rect, tex_remaining.bounds()); |
| 121 Region aperture_region(expected_tex_remaining); | 106 Region aperture_region(aperture_rect); |
| 122 EXPECT_EQ(aperture_region, tex_remaining); | 107 EXPECT_EQ(aperture_region, tex_remaining); |
| 123 } else { | 108 } else { |
| 124 EXPECT_TRUE(layer_remaining.bounds().IsEmpty()); | 109 EXPECT_TRUE(layer_remaining.bounds().IsEmpty()); |
| 125 } | 110 } |
| 126 } | 111 } |
| 127 | 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 |
| 128 TEST(NinePatchLayerImplTest, VerifyDrawQuads) { | 209 TEST(NinePatchLayerImplTest, VerifyDrawQuads) { |
| 129 // 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. |
| 130 // The bounds of the layer are set to 400x400. | 211 // The bounds of the layer are set to 400x400. |
| 131 gfx::Size bitmap_size(100, 100); | 212 gfx::Size bitmap_size(100, 100); |
| 132 gfx::Size layer_size(400, 500); | 213 gfx::Size layer_size(400, 500); |
| 133 gfx::Rect aperture_rect(20, 30, 40, 50); | 214 gfx::Rect aperture_rect(20, 30, 40, 50); |
| 134 gfx::Rect border(40, 40, 80, 80); | 215 gfx::Rect border(40, 40, 80, 80); |
| 135 bool fill_center = false; | 216 bool fill_center = false; |
| 136 size_t expected_quad_size = 8; | 217 size_t expected_quad_size = 8; |
| 137 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border, | 218 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border, |
| 138 gfx::Rect(), fill_center, expected_quad_size); | 219 fill_center, expected_quad_size); |
| 139 | 220 |
| 140 // 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. |
| 141 bitmap_size = gfx::Size(100, 100); | 222 bitmap_size = gfx::Size(100, 100); |
| 142 layer_size = gfx::Size(40, 50); | 223 layer_size = gfx::Size(40, 50); |
| 143 aperture_rect = gfx::Rect(20, 30, 40, 50); | 224 aperture_rect = gfx::Rect(20, 30, 40, 50); |
| 144 border = gfx::Rect(10, 10, 25, 15); | 225 border = gfx::Rect(10, 10, 25, 15); |
| 145 fill_center = true; | 226 fill_center = true; |
| 146 expected_quad_size = 9; | 227 expected_quad_size = 9; |
| 147 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border, | 228 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border, |
| 148 gfx::Rect(), fill_center, expected_quad_size); | 229 fill_center, expected_quad_size); |
| 149 | 230 |
| 150 // Layer and image sizes are equal. | 231 // Layer and image sizes are equal. |
| 151 bitmap_size = gfx::Size(100, 100); | 232 bitmap_size = gfx::Size(100, 100); |
| 152 layer_size = gfx::Size(100, 100); | 233 layer_size = gfx::Size(100, 100); |
| 153 aperture_rect = gfx::Rect(20, 30, 40, 50); | 234 aperture_rect = gfx::Rect(20, 30, 40, 50); |
| 154 border = gfx::Rect(20, 30, 40, 50); | 235 border = gfx::Rect(20, 30, 40, 50); |
| 155 fill_center = true; | 236 fill_center = true; |
| 156 expected_quad_size = 9; | 237 expected_quad_size = 9; |
| 157 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border, | 238 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border, |
| 158 gfx::Rect(), fill_center, expected_quad_size); | 239 fill_center, expected_quad_size); |
| 159 } | 240 } |
| 160 | 241 |
| 161 TEST(NinePatchLayerImplTest, VerifyDrawQuadsWithOcclusion) { | 242 TEST(NinePatchLayerImplTest, VerifyDrawQuadsWithOcclusion) { |
| 162 // Input is a 100x100 bitmap with a 40x50 aperture at x=20, y=30. | 243 // Occlusion removed part of the border and leaves us with 12 patches. |
| 163 // The bounds of the layer are set to 400x400. | |
| 164 gfx::Size bitmap_size(100, 100); | 244 gfx::Size bitmap_size(100, 100); |
| 165 gfx::Rect aperture_rect(30, 30, 40, 40); | 245 gfx::Rect aperture_rect(30, 30, 40, 40); |
| 166 gfx::Size layer_size(400, 400); | 246 gfx::Size layer_size(400, 400); |
| 167 gfx::Rect occlusion(20, 20, 360, 360); | 247 gfx::Rect occlusion(20, 20, 360, 360); |
| 168 bool fill_center = false; | 248 gfx::Rect border(30, 30, 60, 60); |
| 169 size_t expected_quad_size = 12; | 249 size_t expected_quad_size = 12; |
| 170 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, gfx::Rect(), | 250 NinePatchLayerLayoutTestWithOcclusion(bitmap_size, aperture_rect, layer_size, |
| 171 occlusion, fill_center, expected_quad_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); |
| 172 } | 285 } |
| 173 | 286 |
| 174 TEST(NinePatchLayerImplTest, VerifyDrawQuadsWithEmptyPatches) { | 287 TEST(NinePatchLayerImplTest, VerifyDrawQuadsWithEmptyPatches) { |
| 175 // 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 |
| 176 // the top three components. | 289 // the top three components. |
| 177 gfx::Size bitmap_size(100, 100); | 290 gfx::Size bitmap_size(100, 100); |
| 178 gfx::Size layer_size(100, 100); | 291 gfx::Size layer_size(100, 100); |
| 179 gfx::Rect aperture_rect(10, 0, 80, 90); | 292 gfx::Rect aperture_rect(10, 0, 80, 90); |
| 180 gfx::Rect border(10, 0, 20, 10); | 293 gfx::Rect border(10, 0, 20, 10); |
| 181 bool fill_center = false; | 294 bool fill_center = false; |
| 182 size_t expected_quad_size = 5; | 295 size_t expected_quad_size = 5; |
| 183 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border, | 296 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border, |
| 184 gfx::Rect(), fill_center, expected_quad_size); | 297 fill_center, expected_quad_size); |
| 185 | 298 |
| 186 // 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 |
| 187 // quads for the left and top components. | 300 // quads for the left and top components. |
| 188 bitmap_size = gfx::Size(100, 100); | 301 bitmap_size = gfx::Size(100, 100); |
| 189 layer_size = gfx::Size(100, 100); | 302 layer_size = gfx::Size(100, 100); |
| 190 aperture_rect = gfx::Rect(0, 0, 90, 90); | 303 aperture_rect = gfx::Rect(0, 0, 90, 90); |
| 191 border = gfx::Rect(0, 0, 10, 10); | 304 border = gfx::Rect(0, 0, 10, 10); |
| 192 fill_center = false; | 305 fill_center = false; |
| 193 expected_quad_size = 3; | 306 expected_quad_size = 3; |
| 194 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border, | 307 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border, |
| 195 gfx::Rect(), fill_center, expected_quad_size); | 308 fill_center, expected_quad_size); |
| 196 | 309 |
| 197 // 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. |
| 198 bitmap_size = gfx::Size(100, 100); | 311 bitmap_size = gfx::Size(100, 100); |
| 199 layer_size = gfx::Size(100, 100); | 312 layer_size = gfx::Size(100, 100); |
| 200 aperture_rect = gfx::Rect(0, 0, 100, 100); | 313 aperture_rect = gfx::Rect(0, 0, 100, 100); |
| 201 border = gfx::Rect(0, 0, 0, 0); | 314 border = gfx::Rect(0, 0, 0, 0); |
| 202 fill_center = false; | 315 fill_center = false; |
| 203 expected_quad_size = 0; | 316 expected_quad_size = 0; |
| 204 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border, | 317 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border, |
| 205 gfx::Rect(), fill_center, expected_quad_size); | 318 fill_center, expected_quad_size); |
| 206 | 319 |
| 207 // 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. |
| 208 bitmap_size = gfx::Size(100, 100); | 321 bitmap_size = gfx::Size(100, 100); |
| 209 layer_size = gfx::Size(100, 100); | 322 layer_size = gfx::Size(100, 100); |
| 210 aperture_rect = gfx::Rect(0, 0, 100, 100); | 323 aperture_rect = gfx::Rect(0, 0, 100, 100); |
| 211 border = gfx::Rect(0, 0, 0, 0); | 324 border = gfx::Rect(0, 0, 0, 0); |
| 212 fill_center = true; | 325 fill_center = true; |
| 213 expected_quad_size = 1; | 326 expected_quad_size = 1; |
| 214 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border, | 327 NinePatchLayerLayoutTest(bitmap_size, aperture_rect, layer_size, border, |
| 215 gfx::Rect(), fill_center, expected_quad_size); | 328 fill_center, expected_quad_size); |
| 216 } | 329 } |
| 217 | 330 |
| 218 TEST(NinePatchLayerImplTest, Occlusion) { | 331 TEST(NinePatchLayerImplTest, Occlusion) { |
| 219 gfx::Size layer_size(1000, 1000); | 332 gfx::Size layer_size(1000, 1000); |
| 220 gfx::Size viewport_size(1000, 1000); | 333 gfx::Size viewport_size(1000, 1000); |
| 221 | 334 |
| 222 LayerTestCommon::LayerImplTest impl; | 335 LayerTestCommon::LayerImplTest impl; |
| 223 | 336 |
| 224 SkBitmap sk_bitmap; | 337 SkBitmap sk_bitmap; |
| 225 sk_bitmap.allocN32Pixels(10, 10); | 338 sk_bitmap.allocN32Pixels(10, 10); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |