OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "cc/base/math_util.h" | 12 #include "cc/base/math_util.h" |
13 #include "cc/layers/append_quads_data.h" | 13 #include "cc/layers/append_quads_data.h" |
14 #include "cc/layers/picture_layer.h" | 14 #include "cc/layers/picture_layer.h" |
15 #include "cc/quads/draw_quad.h" | 15 #include "cc/quads/draw_quad.h" |
16 #include "cc/quads/tile_draw_quad.h" | 16 #include "cc/quads/tile_draw_quad.h" |
17 #include "cc/resources/tiling_set_raster_queue_all.h" | 17 #include "cc/resources/tiling_set_raster_queue_all.h" |
18 #include "cc/resources/tiling_set_raster_queue_required.h" | 18 #include "cc/resources/tiling_set_raster_queue_required.h" |
19 #include "cc/test/begin_frame_args_test.h" | 19 #include "cc/test/begin_frame_args_test.h" |
20 #include "cc/test/fake_content_layer_client.h" | 20 #include "cc/test/fake_content_layer_client.h" |
21 #include "cc/test/fake_impl_proxy.h" | 21 #include "cc/test/fake_impl_proxy.h" |
22 #include "cc/test/fake_layer_tree_host_impl.h" | 22 #include "cc/test/fake_layer_tree_host_impl.h" |
23 #include "cc/test/fake_output_surface.h" | 23 #include "cc/test/fake_output_surface.h" |
24 #include "cc/test/fake_picture_layer_impl.h" | 24 #include "cc/test/fake_picture_layer_impl.h" |
25 #include "cc/test/fake_picture_pile_impl.h" | 25 #include "cc/test/fake_picture_pile_impl.h" |
26 #include "cc/test/geometry_test_utils.h" | 26 #include "cc/test/geometry_test_utils.h" |
27 #include "cc/test/impl_side_painting_settings.h" | 27 #include "cc/test/impl_side_painting_settings.h" |
28 #include "cc/test/layer_test_common.h" | 28 #include "cc/test/layer_test_common.h" |
29 #include "cc/test/test_shared_bitmap_manager.h" | 29 #include "cc/test/test_shared_bitmap_manager.h" |
| 30 #include "cc/test/test_task_graph_runner.h" |
30 #include "cc/test/test_web_graphics_context_3d.h" | 31 #include "cc/test/test_web_graphics_context_3d.h" |
31 #include "cc/trees/layer_tree_impl.h" | 32 #include "cc/trees/layer_tree_impl.h" |
32 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
33 #include "ui/gfx/geometry/rect_conversions.h" | 34 #include "ui/gfx/geometry/rect_conversions.h" |
34 #include "ui/gfx/geometry/size_conversions.h" | 35 #include "ui/gfx/geometry/size_conversions.h" |
35 | 36 |
36 namespace cc { | 37 namespace cc { |
37 namespace { | 38 namespace { |
38 | 39 |
39 #define EXPECT_BOTH_EQ(expression, x) \ | 40 #define EXPECT_BOTH_EQ(expression, x) \ |
(...skipping 24 matching lines...) Expand all Loading... |
64 | 65 |
65 class LowResTilingsSettings : public ImplSidePaintingSettings { | 66 class LowResTilingsSettings : public ImplSidePaintingSettings { |
66 public: | 67 public: |
67 LowResTilingsSettings() { create_low_res_tiling = true; } | 68 LowResTilingsSettings() { create_low_res_tiling = true; } |
68 }; | 69 }; |
69 | 70 |
70 class PictureLayerImplTest : public testing::Test { | 71 class PictureLayerImplTest : public testing::Test { |
71 public: | 72 public: |
72 PictureLayerImplTest() | 73 PictureLayerImplTest() |
73 : proxy_(base::MessageLoopProxy::current()), | 74 : proxy_(base::MessageLoopProxy::current()), |
74 host_impl_(LowResTilingsSettings(), &proxy_, &shared_bitmap_manager_), | 75 host_impl_(LowResTilingsSettings(), |
| 76 &proxy_, |
| 77 &shared_bitmap_manager_, |
| 78 &task_graph_runner_), |
75 root_id_(6), | 79 root_id_(6), |
76 id_(7), | 80 id_(7), |
77 pending_layer_(nullptr), | 81 pending_layer_(nullptr), |
78 old_pending_layer_(nullptr), | 82 old_pending_layer_(nullptr), |
79 active_layer_(nullptr) { | 83 active_layer_(nullptr) { |
80 host_impl_.SetViewportSize(gfx::Size(10000, 10000)); | 84 host_impl_.SetViewportSize(gfx::Size(10000, 10000)); |
81 } | 85 } |
82 | 86 |
83 explicit PictureLayerImplTest(const LayerTreeSettings& settings) | 87 explicit PictureLayerImplTest(const LayerTreeSettings& settings) |
84 : proxy_(base::MessageLoopProxy::current()), | 88 : proxy_(base::MessageLoopProxy::current()), |
85 host_impl_(settings, &proxy_, &shared_bitmap_manager_), | 89 host_impl_(settings, |
| 90 &proxy_, |
| 91 &shared_bitmap_manager_, |
| 92 &task_graph_runner_), |
86 root_id_(6), | 93 root_id_(6), |
87 id_(7) { | 94 id_(7) { |
88 host_impl_.SetViewportSize(gfx::Size(10000, 10000)); | 95 host_impl_.SetViewportSize(gfx::Size(10000, 10000)); |
89 } | 96 } |
90 | 97 |
91 ~PictureLayerImplTest() override {} | 98 ~PictureLayerImplTest() override {} |
92 | 99 |
93 void SetUp() override { InitializeRenderer(); } | 100 void SetUp() override { InitializeRenderer(); } |
94 | 101 |
95 virtual void InitializeRenderer() { | 102 virtual void InitializeRenderer() { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 for (size_t i = 0; i < tiles.size(); ++i) | 309 for (size_t i = 0; i < tiles.size(); ++i) |
303 EXPECT_FALSE(tiles[i]->required_for_activation()) << "i: " << i; | 310 EXPECT_FALSE(tiles[i]->required_for_activation()) << "i: " << i; |
304 EXPECT_GT(tiles.size(), 0u); | 311 EXPECT_GT(tiles.size(), 0u); |
305 } | 312 } |
306 | 313 |
307 protected: | 314 protected: |
308 void TestQuadsForSolidColor(bool test_for_solid); | 315 void TestQuadsForSolidColor(bool test_for_solid); |
309 | 316 |
310 FakeImplProxy proxy_; | 317 FakeImplProxy proxy_; |
311 TestSharedBitmapManager shared_bitmap_manager_; | 318 TestSharedBitmapManager shared_bitmap_manager_; |
| 319 TestTaskGraphRunner task_graph_runner_; |
312 FakeLayerTreeHostImpl host_impl_; | 320 FakeLayerTreeHostImpl host_impl_; |
313 int root_id_; | 321 int root_id_; |
314 int id_; | 322 int id_; |
315 FakePictureLayerImpl* pending_layer_; | 323 FakePictureLayerImpl* pending_layer_; |
316 FakePictureLayerImpl* old_pending_layer_; | 324 FakePictureLayerImpl* old_pending_layer_; |
317 FakePictureLayerImpl* active_layer_; | 325 FakePictureLayerImpl* active_layer_; |
318 | 326 |
319 private: | 327 private: |
320 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); | 328 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); |
321 }; | 329 }; |
(...skipping 4613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4935 EXPECT_EQ(result.width(), 192); | 4943 EXPECT_EQ(result.width(), 192); |
4936 EXPECT_EQ(result.height(), 192); | 4944 EXPECT_EQ(result.height(), 192); |
4937 result = layer->CalculateTileSize(gfx::Size(199, 199)); | 4945 result = layer->CalculateTileSize(gfx::Size(199, 199)); |
4938 EXPECT_EQ(result.width(), 200); | 4946 EXPECT_EQ(result.width(), 200); |
4939 EXPECT_EQ(result.height(), 200); | 4947 EXPECT_EQ(result.height(), 200); |
4940 | 4948 |
4941 // Gpu-rasterization uses 25% viewport-height tiles. | 4949 // Gpu-rasterization uses 25% viewport-height tiles. |
4942 // The +2's below are for border texels. | 4950 // The +2's below are for border texels. |
4943 host_impl_.SetUseGpuRasterization(true); | 4951 host_impl_.SetUseGpuRasterization(true); |
4944 host_impl_.SetViewportSize(gfx::Size(2000, 2000)); | 4952 host_impl_.SetViewportSize(gfx::Size(2000, 2000)); |
| 4953 |
| 4954 layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); |
4945 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); | 4955 result = layer->CalculateTileSize(gfx::Size(10000, 10000)); |
4946 EXPECT_EQ(result.width(), 2000); | 4956 EXPECT_EQ(result.width(), 2000); |
4947 EXPECT_EQ(result.height(), 500 + 2); | 4957 EXPECT_EQ(result.height(), 500 + 2); |
4948 | 4958 |
4949 // Clamp and round-up, when smaller than viewport. | 4959 // Clamp and round-up, when smaller than viewport. |
4950 // Tile-height doubles to 50% when width shrinks to <= 50%. | 4960 // Tile-height doubles to 50% when width shrinks to <= 50%. |
4951 host_impl_.SetViewportSize(gfx::Size(1000, 1000)); | 4961 host_impl_.SetViewportSize(gfx::Size(1000, 1000)); |
| 4962 layer->set_gpu_raster_max_texture_size(host_impl_.device_viewport_size()); |
4952 result = layer->CalculateTileSize(gfx::Size(447, 10000)); | 4963 result = layer->CalculateTileSize(gfx::Size(447, 10000)); |
4953 EXPECT_EQ(result.width(), 448); | 4964 EXPECT_EQ(result.width(), 448); |
4954 EXPECT_EQ(result.height(), 500 + 2); | 4965 EXPECT_EQ(result.height(), 500 + 2); |
4955 | 4966 |
4956 // Largest layer is 50% of viewport width (rounded up), and | 4967 // Largest layer is 50% of viewport width (rounded up), and |
4957 // 50% of viewport in height. | 4968 // 50% of viewport in height. |
4958 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4969 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
4959 EXPECT_EQ(result.width(), 448); | 4970 EXPECT_EQ(result.width(), 448); |
4960 EXPECT_EQ(result.height(), 448); | 4971 EXPECT_EQ(result.height(), 448); |
4961 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4972 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
4962 EXPECT_EQ(result.width(), 512); | 4973 EXPECT_EQ(result.width(), 512); |
4963 EXPECT_EQ(result.height(), 500 + 2); | 4974 EXPECT_EQ(result.height(), 500 + 2); |
4964 } | 4975 } |
4965 | 4976 |
4966 } // namespace | 4977 } // namespace |
4967 } // namespace cc | 4978 } // namespace cc |
OLD | NEW |