| 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" |
| 11 #include "cc/test/fake_layer_tree_host_impl.h" | 11 #include "cc/test/fake_layer_tree_host_impl.h" |
| 12 #include "cc/test/fake_output_surface.h" |
| 12 #include "cc/test/layer_test_common.h" | 13 #include "cc/test/layer_test_common.h" |
| 13 #include "cc/test/test_task_graph_runner.h" | 14 #include "cc/test/test_task_graph_runner.h" |
| 14 #include "cc/trees/single_thread_proxy.h" | 15 #include "cc/trees/single_thread_proxy.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 namespace cc { | 19 namespace cc { |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 class TiledLayerImplTest : public testing::Test { | 22 class TiledLayerImplTest : public testing::Test { |
| 22 public: | 23 public: |
| 23 TiledLayerImplTest() | 24 TiledLayerImplTest() |
| 24 : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_) {} | 25 : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_) { |
| 26 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); |
| 27 } |
| 25 | 28 |
| 26 scoped_ptr<TiledLayerImpl> CreateLayerNoTiles( | 29 scoped_ptr<TiledLayerImpl> CreateLayerNoTiles( |
| 27 const gfx::Size& tile_size, | 30 const gfx::Size& tile_size, |
| 28 const gfx::Size& layer_size, | 31 const gfx::Size& layer_size, |
| 29 LayerTilingData::BorderTexelOption border_texels) { | 32 LayerTilingData::BorderTexelOption border_texels) { |
| 30 scoped_ptr<TiledLayerImpl> layer = | 33 scoped_ptr<TiledLayerImpl> layer = |
| 31 TiledLayerImpl::Create(host_impl_.active_tree(), 1); | 34 TiledLayerImpl::Create(host_impl_.active_tree(), 1); |
| 32 scoped_ptr<LayerTilingData> tiler = | 35 scoped_ptr<LayerTilingData> tiler = |
| 33 LayerTilingData::Create(tile_size, border_texels); | 36 LayerTilingData::Create(tile_size, border_texels); |
| 34 tiler->SetTilingSize(layer_size); | 37 tiler->SetTilingSize(layer_size); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 46 | 49 |
| 47 // Create a default tiled layer with textures for all tiles and a default | 50 // Create a default tiled layer with textures for all tiles and a default |
| 48 // visibility of the entire layer size. | 51 // visibility of the entire layer size. |
| 49 scoped_ptr<TiledLayerImpl> CreateLayer( | 52 scoped_ptr<TiledLayerImpl> CreateLayer( |
| 50 const gfx::Size& tile_size, | 53 const gfx::Size& tile_size, |
| 51 const gfx::Size& layer_size, | 54 const gfx::Size& layer_size, |
| 52 LayerTilingData::BorderTexelOption border_texels) { | 55 LayerTilingData::BorderTexelOption border_texels) { |
| 53 scoped_ptr<TiledLayerImpl> layer = | 56 scoped_ptr<TiledLayerImpl> layer = |
| 54 CreateLayerNoTiles(tile_size, layer_size, border_texels); | 57 CreateLayerNoTiles(tile_size, layer_size, border_texels); |
| 55 | 58 |
| 56 ResourceProvider::ResourceId resource_id = 1; | |
| 57 for (int i = 0; i < layer->TilingForTesting()->num_tiles_x(); ++i) { | 59 for (int i = 0; i < layer->TilingForTesting()->num_tiles_x(); ++i) { |
| 58 for (int j = 0; j < layer->TilingForTesting()->num_tiles_y(); ++j) | 60 for (int j = 0; j < layer->TilingForTesting()->num_tiles_y(); ++j) { |
| 59 layer->PushTileProperties(i, j, resource_id++, false); | 61 ResourceProvider::ResourceId resource_id = |
| 62 host_impl_.resource_provider()->CreateResource( |
| 63 gfx::Size(1, 1), GL_CLAMP_TO_EDGE, |
| 64 ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); |
| 65 layer->PushTileProperties(i, j, resource_id, false); |
| 66 } |
| 60 } | 67 } |
| 61 | 68 |
| 62 return layer.Pass(); | 69 return layer.Pass(); |
| 63 } | 70 } |
| 64 | 71 |
| 65 void GetQuads(RenderPass* render_pass, | 72 void GetQuads(RenderPass* render_pass, |
| 66 const gfx::Size& tile_size, | 73 const gfx::Size& tile_size, |
| 67 const gfx::Size& layer_size, | 74 const gfx::Size& layer_size, |
| 68 LayerTilingData::BorderTexelOption border_texel_option, | 75 LayerTilingData::BorderTexelOption border_texel_option, |
| 69 const gfx::Rect& visible_content_rect) { | 76 const gfx::Rect& visible_content_rect) { |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 tiled_layer->SetBounds(layer_bounds); | 333 tiled_layer->SetBounds(layer_bounds); |
| 327 tiled_layer->SetContentBounds(layer_bounds); | 334 tiled_layer->SetContentBounds(layer_bounds); |
| 328 tiled_layer->SetDrawsContent(true); | 335 tiled_layer->SetDrawsContent(true); |
| 329 tiled_layer->set_skips_draw(false); | 336 tiled_layer->set_skips_draw(false); |
| 330 | 337 |
| 331 scoped_ptr<LayerTilingData> tiler = | 338 scoped_ptr<LayerTilingData> tiler = |
| 332 LayerTilingData::Create(tile_size, LayerTilingData::NO_BORDER_TEXELS); | 339 LayerTilingData::Create(tile_size, LayerTilingData::NO_BORDER_TEXELS); |
| 333 tiler->SetTilingSize(layer_bounds); | 340 tiler->SetTilingSize(layer_bounds); |
| 334 tiled_layer->SetTilingData(*tiler); | 341 tiled_layer->SetTilingData(*tiler); |
| 335 | 342 |
| 336 ResourceProvider::ResourceId resource_id = 1; | |
| 337 for (int i = 0; i < tiled_layer->TilingForTesting()->num_tiles_x(); ++i) { | 343 for (int i = 0; i < tiled_layer->TilingForTesting()->num_tiles_x(); ++i) { |
| 338 for (int j = 0; j < tiled_layer->TilingForTesting()->num_tiles_y(); ++j) | 344 for (int j = 0; j < tiled_layer->TilingForTesting()->num_tiles_y(); ++j) { |
| 339 tiled_layer->PushTileProperties(i, j, resource_id++, false); | 345 ResourceProvider::ResourceId resource_id = |
| 346 impl.resource_provider()->CreateResource( |
| 347 gfx::Size(1, 1), GL_CLAMP_TO_EDGE, |
| 348 ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); |
| 349 tiled_layer->PushTileProperties(i, j, resource_id, false); |
| 350 } |
| 340 } | 351 } |
| 341 | 352 |
| 342 impl.CalcDrawProps(viewport_size); | 353 impl.CalcDrawProps(viewport_size); |
| 343 | 354 |
| 344 { | 355 { |
| 345 SCOPED_TRACE("No occlusion"); | 356 SCOPED_TRACE("No occlusion"); |
| 346 gfx::Rect occluded; | 357 gfx::Rect occluded; |
| 347 impl.AppendQuadsWithOcclusion(tiled_layer, occluded); | 358 impl.AppendQuadsWithOcclusion(tiled_layer, occluded); |
| 348 | 359 |
| 349 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), | 360 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 369 LayerTestCommon::VerifyQuadsAreOccluded( | 380 LayerTestCommon::VerifyQuadsAreOccluded( |
| 370 impl.quad_list(), occluded, &partially_occluded_count); | 381 impl.quad_list(), occluded, &partially_occluded_count); |
| 371 // The layer outputs one quad, which is partially occluded. | 382 // The layer outputs one quad, which is partially occluded. |
| 372 EXPECT_EQ(100u - 10u, impl.quad_list().size()); | 383 EXPECT_EQ(100u - 10u, impl.quad_list().size()); |
| 373 EXPECT_EQ(10u + 10u, partially_occluded_count); | 384 EXPECT_EQ(10u + 10u, partially_occluded_count); |
| 374 } | 385 } |
| 375 } | 386 } |
| 376 | 387 |
| 377 } // namespace | 388 } // namespace |
| 378 } // namespace cc | 389 } // namespace cc |
| OLD | NEW |