| 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 "cc/layers/tiled_layer_impl.h" | 5 #include "cc/layers/tiled_layer_impl.h" |
| 6 | 6 |
| 7 #include "cc/layers/append_quads_data.h" | 7 #include "cc/layers/append_quads_data.h" |
| 8 #include "cc/quads/tile_draw_quad.h" | 8 #include "cc/quads/tile_draw_quad.h" |
| 9 #include "cc/resources/layer_tiling_data.h" | 9 #include "cc/resources/layer_tiling_data.h" |
| 10 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // No checkerboarding | 165 // No checkerboarding |
| 166 { | 166 { |
| 167 MockOcclusionTracker<LayerImpl> occlusion_tracker; | 167 MockOcclusionTracker<LayerImpl> occlusion_tracker; |
| 168 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 168 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 169 | 169 |
| 170 AppendQuadsData data; | 170 AppendQuadsData data; |
| 171 layer->AppendQuads(render_pass.get(), occlusion_tracker, &data); | 171 layer->AppendQuads(render_pass.get(), occlusion_tracker, &data); |
| 172 EXPECT_EQ(render_pass->quad_list.size(), 4u); | 172 EXPECT_EQ(render_pass->quad_list.size(), 4u); |
| 173 EXPECT_EQ(0u, data.num_missing_tiles); | 173 EXPECT_EQ(0u, data.num_missing_tiles); |
| 174 | 174 |
| 175 for (size_t i = 0; i < render_pass->quad_list.size(); ++i) | 175 for (QuadList::Iterator iter = render_pass->quad_list.begin(); |
| 176 EXPECT_EQ(render_pass->quad_list[i]->material, DrawQuad::TILED_CONTENT); | 176 iter != render_pass->quad_list.end(); |
| 177 ++iter) |
| 178 EXPECT_EQ(iter->material, DrawQuad::TILED_CONTENT); |
| 177 } | 179 } |
| 178 | 180 |
| 179 for (int i = 0; i < num_tiles_x; ++i) | 181 for (int i = 0; i < num_tiles_x; ++i) |
| 180 for (int j = 0; j < num_tiles_y; ++j) | 182 for (int j = 0; j < num_tiles_y; ++j) |
| 181 layer->PushTileProperties(i, j, 0, gfx::Rect(), false); | 183 layer->PushTileProperties(i, j, 0, gfx::Rect(), false); |
| 182 | 184 |
| 183 // All checkerboarding | 185 // All checkerboarding |
| 184 { | 186 { |
| 185 MockOcclusionTracker<LayerImpl> occlusion_tracker; | 187 MockOcclusionTracker<LayerImpl> occlusion_tracker; |
| 186 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 188 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 187 | 189 |
| 188 AppendQuadsData data; | 190 AppendQuadsData data; |
| 189 layer->AppendQuads(render_pass.get(), occlusion_tracker, &data); | 191 layer->AppendQuads(render_pass.get(), occlusion_tracker, &data); |
| 190 EXPECT_LT(0u, data.num_missing_tiles); | 192 EXPECT_LT(0u, data.num_missing_tiles); |
| 191 EXPECT_EQ(render_pass->quad_list.size(), 4u); | 193 EXPECT_EQ(render_pass->quad_list.size(), 4u); |
| 192 for (size_t i = 0; i < render_pass->quad_list.size(); ++i) | 194 for (QuadList::Iterator iter = render_pass->quad_list.begin(); |
| 193 EXPECT_NE(render_pass->quad_list[i]->material, DrawQuad::TILED_CONTENT); | 195 iter != render_pass->quad_list.end(); |
| 196 ++iter) |
| 197 EXPECT_NE(iter->material, DrawQuad::TILED_CONTENT); |
| 194 } | 198 } |
| 195 } | 199 } |
| 196 | 200 |
| 197 // Test with both border texels and without. | 201 // Test with both border texels and without. |
| 198 #define WITH_AND_WITHOUT_BORDER_TEST(text_fixture_name) \ | 202 #define WITH_AND_WITHOUT_BORDER_TEST(text_fixture_name) \ |
| 199 TEST_F(TiledLayerImplBorderTest, text_fixture_name##NoBorders) { \ | 203 TEST_F(TiledLayerImplBorderTest, text_fixture_name##NoBorders) { \ |
| 200 text_fixture_name(LayerTilingData::NO_BORDER_TEXELS); \ | 204 text_fixture_name(LayerTilingData::NO_BORDER_TEXELS); \ |
| 201 } \ | 205 } \ |
| 202 TEST_F(TiledLayerImplBorderTest, text_fixture_name##HasBorders) { \ | 206 TEST_F(TiledLayerImplBorderTest, text_fixture_name##HasBorders) { \ |
| 203 text_fixture_name(LayerTilingData::HAS_BORDER_TEXELS); \ | 207 text_fixture_name(LayerTilingData::HAS_BORDER_TEXELS); \ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 TEST_F(TiledLayerImplTest, TextureInfoForLayerNoBorders) { | 263 TEST_F(TiledLayerImplTest, TextureInfoForLayerNoBorders) { |
| 260 gfx::Size tile_size(50, 50); | 264 gfx::Size tile_size(50, 50); |
| 261 gfx::Size layer_size(250, 250); | 265 gfx::Size layer_size(250, 250); |
| 262 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 266 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 263 GetQuads(render_pass.get(), | 267 GetQuads(render_pass.get(), |
| 264 tile_size, | 268 tile_size, |
| 265 layer_size, | 269 layer_size, |
| 266 LayerTilingData::NO_BORDER_TEXELS, | 270 LayerTilingData::NO_BORDER_TEXELS, |
| 267 gfx::Rect(layer_size)); | 271 gfx::Rect(layer_size)); |
| 268 | 272 |
| 269 for (size_t i = 0; i < render_pass->quad_list.size(); ++i) { | 273 size_t i = 0; |
| 270 const TileDrawQuad* quad = | 274 for (QuadList::Iterator iter = render_pass->quad_list.begin(); |
| 271 TileDrawQuad::MaterialCast(render_pass->quad_list[i]); | 275 iter != render_pass->quad_list.end(); |
| 276 ++iter) { |
| 277 const TileDrawQuad* quad = TileDrawQuad::MaterialCast(&*iter); |
| 272 | 278 |
| 273 EXPECT_NE(0u, quad->resource_id) << LayerTestCommon::quad_string << i; | 279 EXPECT_NE(0u, quad->resource_id) << LayerTestCommon::quad_string << i; |
| 274 EXPECT_EQ(gfx::RectF(gfx::PointF(), tile_size), quad->tex_coord_rect) | 280 EXPECT_EQ(gfx::RectF(gfx::PointF(), tile_size), quad->tex_coord_rect) |
| 275 << LayerTestCommon::quad_string << i; | 281 << LayerTestCommon::quad_string << i; |
| 276 EXPECT_EQ(tile_size, quad->texture_size) << LayerTestCommon::quad_string | 282 EXPECT_EQ(tile_size, quad->texture_size) << LayerTestCommon::quad_string |
| 277 << i; | 283 << i; |
| 278 EXPECT_EQ(gfx::Size(1, 1).ToString(), quad->opaque_rect.size().ToString()) | 284 EXPECT_EQ(gfx::Size(1, 1).ToString(), quad->opaque_rect.size().ToString()) |
| 279 << LayerTestCommon::quad_string << i; | 285 << LayerTestCommon::quad_string << i; |
| 286 ++i; |
| 280 } | 287 } |
| 281 } | 288 } |
| 282 | 289 |
| 283 TEST_F(TiledLayerImplTest, GPUMemoryUsage) { | 290 TEST_F(TiledLayerImplTest, GPUMemoryUsage) { |
| 284 gfx::Size tile_size(20, 30); | 291 gfx::Size tile_size(20, 30); |
| 285 int num_tiles_x = 12; | 292 int num_tiles_x = 12; |
| 286 int num_tiles_y = 32; | 293 int num_tiles_y = 32; |
| 287 gfx::Size layer_size(tile_size.width() * num_tiles_x, | 294 gfx::Size layer_size(tile_size.width() * num_tiles_x, |
| 288 tile_size.height() * num_tiles_y); | 295 tile_size.height() * num_tiles_y); |
| 289 | 296 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 occluded, | 384 occluded, |
| 378 &partially_occluded_count); | 385 &partially_occluded_count); |
| 379 // The layer outputs one quad, which is partially occluded. | 386 // The layer outputs one quad, which is partially occluded. |
| 380 EXPECT_EQ(100u - 10u, impl.quad_list().size()); | 387 EXPECT_EQ(100u - 10u, impl.quad_list().size()); |
| 381 EXPECT_EQ(10u + 10u, partially_occluded_count); | 388 EXPECT_EQ(10u + 10u, partially_occluded_count); |
| 382 } | 389 } |
| 383 } | 390 } |
| 384 | 391 |
| 385 } // namespace | 392 } // namespace |
| 386 } // namespace cc | 393 } // namespace cc |
| OLD | NEW |