| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // No checkerboarding | 161 // No checkerboarding |
| 162 { | 162 { |
| 163 MockOcclusionTracker<LayerImpl> occlusion_tracker; | 163 MockOcclusionTracker<LayerImpl> occlusion_tracker; |
| 164 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 164 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 165 | 165 |
| 166 AppendQuadsData data; | 166 AppendQuadsData data; |
| 167 layer->AppendQuads(render_pass.get(), occlusion_tracker, &data); | 167 layer->AppendQuads(render_pass.get(), occlusion_tracker, &data); |
| 168 EXPECT_EQ(render_pass->quad_list.size(), 4u); | 168 EXPECT_EQ(render_pass->quad_list.size(), 4u); |
| 169 EXPECT_EQ(0u, data.num_missing_tiles); | 169 EXPECT_EQ(0u, data.num_missing_tiles); |
| 170 | 170 |
| 171 for (size_t i = 0; i < render_pass->quad_list.size(); ++i) | 171 for (QuadList::Iterator iter = render_pass->quad_list.begin(); |
| 172 EXPECT_EQ(render_pass->quad_list[i]->material, DrawQuad::TILED_CONTENT); | 172 iter != render_pass->quad_list.end(); |
| 173 ++iter) |
| 174 EXPECT_EQ(iter->material, DrawQuad::TILED_CONTENT); |
| 173 } | 175 } |
| 174 | 176 |
| 175 for (int i = 0; i < num_tiles_x; ++i) | 177 for (int i = 0; i < num_tiles_x; ++i) |
| 176 for (int j = 0; j < num_tiles_y; ++j) | 178 for (int j = 0; j < num_tiles_y; ++j) |
| 177 layer->PushTileProperties(i, j, 0, false); | 179 layer->PushTileProperties(i, j, 0, false); |
| 178 | 180 |
| 179 // All checkerboarding | 181 // All checkerboarding |
| 180 { | 182 { |
| 181 MockOcclusionTracker<LayerImpl> occlusion_tracker; | 183 MockOcclusionTracker<LayerImpl> occlusion_tracker; |
| 182 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 184 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 183 | 185 |
| 184 AppendQuadsData data; | 186 AppendQuadsData data; |
| 185 layer->AppendQuads(render_pass.get(), occlusion_tracker, &data); | 187 layer->AppendQuads(render_pass.get(), occlusion_tracker, &data); |
| 186 EXPECT_LT(0u, data.num_missing_tiles); | 188 EXPECT_LT(0u, data.num_missing_tiles); |
| 187 EXPECT_EQ(render_pass->quad_list.size(), 4u); | 189 EXPECT_EQ(render_pass->quad_list.size(), 4u); |
| 188 for (size_t i = 0; i < render_pass->quad_list.size(); ++i) | 190 for (QuadList::Iterator iter = render_pass->quad_list.begin(); |
| 189 EXPECT_NE(render_pass->quad_list[i]->material, DrawQuad::TILED_CONTENT); | 191 iter != render_pass->quad_list.end(); |
| 192 ++iter) |
| 193 EXPECT_NE(iter->material, DrawQuad::TILED_CONTENT); |
| 190 } | 194 } |
| 191 } | 195 } |
| 192 | 196 |
| 193 // Test with both border texels and without. | 197 // Test with both border texels and without. |
| 194 #define WITH_AND_WITHOUT_BORDER_TEST(text_fixture_name) \ | 198 #define WITH_AND_WITHOUT_BORDER_TEST(text_fixture_name) \ |
| 195 TEST_F(TiledLayerImplBorderTest, text_fixture_name##NoBorders) { \ | 199 TEST_F(TiledLayerImplBorderTest, text_fixture_name##NoBorders) { \ |
| 196 text_fixture_name(LayerTilingData::NO_BORDER_TEXELS); \ | 200 text_fixture_name(LayerTilingData::NO_BORDER_TEXELS); \ |
| 197 } \ | 201 } \ |
| 198 TEST_F(TiledLayerImplBorderTest, text_fixture_name##HasBorders) { \ | 202 TEST_F(TiledLayerImplBorderTest, text_fixture_name##HasBorders) { \ |
| 199 text_fixture_name(LayerTilingData::HAS_BORDER_TEXELS); \ | 203 text_fixture_name(LayerTilingData::HAS_BORDER_TEXELS); \ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 TEST_F(TiledLayerImplTest, TextureInfoForLayerNoBorders) { | 259 TEST_F(TiledLayerImplTest, TextureInfoForLayerNoBorders) { |
| 256 gfx::Size tile_size(50, 50); | 260 gfx::Size tile_size(50, 50); |
| 257 gfx::Size layer_size(250, 250); | 261 gfx::Size layer_size(250, 250); |
| 258 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 262 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 259 GetQuads(render_pass.get(), | 263 GetQuads(render_pass.get(), |
| 260 tile_size, | 264 tile_size, |
| 261 layer_size, | 265 layer_size, |
| 262 LayerTilingData::NO_BORDER_TEXELS, | 266 LayerTilingData::NO_BORDER_TEXELS, |
| 263 gfx::Rect(layer_size)); | 267 gfx::Rect(layer_size)); |
| 264 | 268 |
| 265 for (size_t i = 0; i < render_pass->quad_list.size(); ++i) { | 269 size_t i = 0; |
| 266 const TileDrawQuad* quad = | 270 for (QuadList::Iterator iter = render_pass->quad_list.begin(); |
| 267 TileDrawQuad::MaterialCast(render_pass->quad_list[i]); | 271 iter != render_pass->quad_list.end(); |
| 272 ++iter) { |
| 273 const TileDrawQuad* quad = TileDrawQuad::MaterialCast(&*iter); |
| 268 | 274 |
| 269 EXPECT_NE(0u, quad->resource_id) << LayerTestCommon::quad_string << i; | 275 EXPECT_NE(0u, quad->resource_id) << LayerTestCommon::quad_string << i; |
| 270 EXPECT_EQ(gfx::RectF(gfx::PointF(), tile_size), quad->tex_coord_rect) | 276 EXPECT_EQ(gfx::RectF(gfx::PointF(), tile_size), quad->tex_coord_rect) |
| 271 << LayerTestCommon::quad_string << i; | 277 << LayerTestCommon::quad_string << i; |
| 272 EXPECT_EQ(tile_size, quad->texture_size) << LayerTestCommon::quad_string | 278 EXPECT_EQ(tile_size, quad->texture_size) << LayerTestCommon::quad_string |
| 273 << i; | 279 << i; |
| 274 } | 280 } |
| 275 } | 281 } |
| 276 | 282 |
| 277 TEST_F(TiledLayerImplTest, GPUMemoryUsage) { | 283 TEST_F(TiledLayerImplTest, GPUMemoryUsage) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 LayerTestCommon::VerifyQuadsAreOccluded( | 374 LayerTestCommon::VerifyQuadsAreOccluded( |
| 369 impl.quad_list(), occluded, &partially_occluded_count); | 375 impl.quad_list(), occluded, &partially_occluded_count); |
| 370 // The layer outputs one quad, which is partially occluded. | 376 // The layer outputs one quad, which is partially occluded. |
| 371 EXPECT_EQ(100u - 10u, impl.quad_list().size()); | 377 EXPECT_EQ(100u - 10u, impl.quad_list().size()); |
| 372 EXPECT_EQ(10u + 10u, partially_occluded_count); | 378 EXPECT_EQ(10u + 10u, partially_occluded_count); |
| 373 } | 379 } |
| 374 } | 380 } |
| 375 | 381 |
| 376 } // namespace | 382 } // namespace |
| 377 } // namespace cc | 383 } // namespace cc |
| OLD | NEW |