OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "cc/test/fake_content_layer_impl.h" | 34 #include "cc/test/fake_content_layer_impl.h" |
35 #include "cc/test/fake_layer_tree_host_client.h" | 35 #include "cc/test/fake_layer_tree_host_client.h" |
36 #include "cc/test/fake_output_surface.h" | 36 #include "cc/test/fake_output_surface.h" |
37 #include "cc/test/fake_painted_scrollbar_layer.h" | 37 #include "cc/test/fake_painted_scrollbar_layer.h" |
38 #include "cc/test/fake_picture_layer.h" | 38 #include "cc/test/fake_picture_layer.h" |
39 #include "cc/test/fake_picture_layer_impl.h" | 39 #include "cc/test/fake_picture_layer_impl.h" |
40 #include "cc/test/fake_picture_pile.h" | 40 #include "cc/test/fake_picture_pile.h" |
41 #include "cc/test/fake_proxy.h" | 41 #include "cc/test/fake_proxy.h" |
42 #include "cc/test/fake_scoped_ui_resource.h" | 42 #include "cc/test/fake_scoped_ui_resource.h" |
43 #include "cc/test/geometry_test_utils.h" | 43 #include "cc/test/geometry_test_utils.h" |
| 44 #include "cc/test/impl_side_painting_settings.h" |
44 #include "cc/test/layer_tree_test.h" | 45 #include "cc/test/layer_tree_test.h" |
45 #include "cc/test/test_shared_bitmap_manager.h" | 46 #include "cc/test/test_shared_bitmap_manager.h" |
46 #include "cc/test/test_web_graphics_context_3d.h" | 47 #include "cc/test/test_web_graphics_context_3d.h" |
47 #include "cc/trees/layer_tree_host_impl.h" | 48 #include "cc/trees/layer_tree_host_impl.h" |
48 #include "cc/trees/layer_tree_impl.h" | 49 #include "cc/trees/layer_tree_impl.h" |
49 #include "cc/trees/single_thread_proxy.h" | 50 #include "cc/trees/single_thread_proxy.h" |
50 #include "cc/trees/thread_proxy.h" | 51 #include "cc/trees/thread_proxy.h" |
51 #include "gpu/GLES2/gl2extchromium.h" | 52 #include "gpu/GLES2/gl2extchromium.h" |
52 #include "skia/ext/refptr.h" | 53 #include "skia/ext/refptr.h" |
53 #include "testing/gmock/include/gmock/gmock.h" | 54 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 5488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5542 | 5543 |
5543 scoped_refptr<Layer> root = Layer::Create(); | 5544 scoped_refptr<Layer> root = Layer::Create(); |
5544 root->SetBounds(gfx::Size(500, 500)); | 5545 root->SetBounds(gfx::Size(500, 500)); |
5545 | 5546 |
5546 scoped_refptr<Layer> pinch = Layer::Create(); | 5547 scoped_refptr<Layer> pinch = Layer::Create(); |
5547 pinch->SetBounds(gfx::Size(500, 500)); | 5548 pinch->SetBounds(gfx::Size(500, 500)); |
5548 pinch->SetScrollClipLayerId(root->id()); | 5549 pinch->SetScrollClipLayerId(root->id()); |
5549 pinch->SetIsContainerForFixedPositionLayers(true); | 5550 pinch->SetIsContainerForFixedPositionLayers(true); |
5550 root->AddChild(pinch); | 5551 root->AddChild(pinch); |
5551 | 5552 |
5552 scoped_ptr<FakePicturePile> pile(new FakePicturePile); | 5553 scoped_ptr<FakePicturePile> pile( |
| 5554 new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale, |
| 5555 ImplSidePaintingSettings().default_tile_grid_size)); |
5553 pile->SetPlaybackAllowedEvent(&playback_allowed_event_); | 5556 pile->SetPlaybackAllowedEvent(&playback_allowed_event_); |
5554 scoped_refptr<FakePictureLayer> layer = | 5557 scoped_refptr<FakePictureLayer> layer = |
5555 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); | 5558 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); |
5556 layer->SetBounds(gfx::Size(500, 500)); | 5559 layer->SetBounds(gfx::Size(500, 500)); |
5557 layer->SetContentsOpaque(true); | 5560 layer->SetContentsOpaque(true); |
5558 // Avoid LCD text on the layer so we don't cause extra commits when we | 5561 // Avoid LCD text on the layer so we don't cause extra commits when we |
5559 // pinch. | 5562 // pinch. |
5560 layer->disable_lcd_text(); | 5563 layer->disable_lcd_text(); |
5561 pinch->AddChild(layer); | 5564 pinch->AddChild(layer); |
5562 | 5565 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5745 settings->impl_side_painting = true; | 5748 settings->impl_side_painting = true; |
5746 settings->gpu_rasterization_forced = true; | 5749 settings->gpu_rasterization_forced = true; |
5747 } | 5750 } |
5748 | 5751 |
5749 void SetupTree() override { | 5752 void SetupTree() override { |
5750 client_.set_fill_with_nonsolid_color(true); | 5753 client_.set_fill_with_nonsolid_color(true); |
5751 | 5754 |
5752 scoped_refptr<Layer> root = Layer::Create(); | 5755 scoped_refptr<Layer> root = Layer::Create(); |
5753 root->SetBounds(gfx::Size(500, 500)); | 5756 root->SetBounds(gfx::Size(500, 500)); |
5754 | 5757 |
5755 scoped_ptr<FakePicturePile> pile(new FakePicturePile); | 5758 scoped_ptr<FakePicturePile> pile( |
| 5759 new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale, |
| 5760 ImplSidePaintingSettings().default_tile_grid_size)); |
5756 scoped_refptr<FakePictureLayer> layer = | 5761 scoped_refptr<FakePictureLayer> layer = |
5757 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); | 5762 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); |
5758 layer->SetBounds(gfx::Size(500, 500)); | 5763 layer->SetBounds(gfx::Size(500, 500)); |
5759 layer->SetContentsOpaque(true); | 5764 layer->SetContentsOpaque(true); |
5760 root->AddChild(layer); | 5765 root->AddChild(layer); |
5761 | 5766 |
5762 layer_tree_host()->SetRootLayer(root); | 5767 layer_tree_host()->SetRootLayer(root); |
5763 LayerTreeHostTest::SetupTree(); | 5768 LayerTreeHostTest::SetupTree(); |
5764 } | 5769 } |
5765 | 5770 |
(...skipping 19 matching lines...) Expand all Loading... |
5785 | 5790 |
5786 void InitializeSettings(LayerTreeSettings* settings) override { | 5791 void InitializeSettings(LayerTreeSettings* settings) override { |
5787 settings->impl_side_painting = true; | 5792 settings->impl_side_painting = true; |
5788 settings->gpu_rasterization_enabled = true; | 5793 settings->gpu_rasterization_enabled = true; |
5789 settings->gpu_rasterization_forced = true; | 5794 settings->gpu_rasterization_forced = true; |
5790 } | 5795 } |
5791 | 5796 |
5792 void SetupTree() override { | 5797 void SetupTree() override { |
5793 client_.set_fill_with_nonsolid_color(true); | 5798 client_.set_fill_with_nonsolid_color(true); |
5794 | 5799 |
5795 scoped_ptr<FakePicturePile> pile(new FakePicturePile); | 5800 scoped_ptr<FakePicturePile> pile( |
| 5801 new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale, |
| 5802 ImplSidePaintingSettings().default_tile_grid_size)); |
5796 scoped_refptr<FakePictureLayer> root = | 5803 scoped_refptr<FakePictureLayer> root = |
5797 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); | 5804 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); |
5798 root->SetBounds(gfx::Size(viewport_size_.width(), 10000)); | 5805 root->SetBounds(gfx::Size(viewport_size_.width(), 10000)); |
5799 root->SetContentsOpaque(true); | 5806 root->SetContentsOpaque(true); |
5800 | 5807 |
5801 layer_tree_host()->SetRootLayer(root); | 5808 layer_tree_host()->SetRootLayer(root); |
5802 LayerTreeHostTest::SetupTree(); | 5809 LayerTreeHostTest::SetupTree(); |
5803 layer_tree_host()->SetViewportSize(viewport_size_); | 5810 layer_tree_host()->SetViewportSize(viewport_size_); |
5804 } | 5811 } |
5805 | 5812 |
5806 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 5813 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
5807 | 5814 |
5808 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 5815 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
5809 LayerTreeHostImpl::FrameData* frame_data, | 5816 LayerTreeHostImpl::FrameData* frame_data, |
5810 DrawResult draw_result) override { | 5817 DrawResult draw_result) override { |
5811 EXPECT_EQ(4u, host_impl->resource_provider()->num_resources()); | 5818 EXPECT_EQ(4u, host_impl->resource_provider()->num_resources()); |
5812 | 5819 |
5813 // Verify which tiles got resources using an eviction iterator, which has to | 5820 // Verify which tiles got resources using an eviction iterator, which has to |
5814 // return all tiles that have resources. | 5821 // return all tiles that have resources. |
5815 EvictionTilePriorityQueue eviction_queue; | 5822 scoped_ptr<EvictionTilePriorityQueue> eviction_queue( |
5816 host_impl->BuildEvictionQueue(&eviction_queue, | 5823 host_impl->BuildEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES)); |
5817 SAME_PRIORITY_FOR_BOTH_TREES); | |
5818 int tile_count = 0; | 5824 int tile_count = 0; |
5819 for (; !eviction_queue.IsEmpty(); eviction_queue.Pop()) { | 5825 for (; !eviction_queue->IsEmpty(); eviction_queue->Pop()) { |
5820 Tile* tile = eviction_queue.Top(); | 5826 Tile* tile = eviction_queue->Top(); |
5821 // Ensure this tile is within the viewport. | 5827 // Ensure this tile is within the viewport. |
5822 EXPECT_TRUE(tile->content_rect().Intersects(gfx::Rect(viewport_size_))); | 5828 EXPECT_TRUE(tile->content_rect().Intersects(gfx::Rect(viewport_size_))); |
5823 // Ensure that the tile is 1/4 of the viewport tall (plus padding). | 5829 // Ensure that the tile is 1/4 of the viewport tall (plus padding). |
5824 EXPECT_EQ(tile->content_rect().height(), | 5830 EXPECT_EQ(tile->content_rect().height(), |
5825 (viewport_size_.height() / 4) + 2); | 5831 (viewport_size_.height() / 4) + 2); |
5826 ++tile_count; | 5832 ++tile_count; |
5827 } | 5833 } |
5828 EXPECT_EQ(4, tile_count); | 5834 EXPECT_EQ(4, tile_count); |
5829 EndTest(); | 5835 EndTest(); |
5830 return draw_result; | 5836 return draw_result; |
(...skipping 25 matching lines...) Expand all Loading... |
5856 | 5862 |
5857 scoped_refptr<Layer> root = Layer::Create(); | 5863 scoped_refptr<Layer> root = Layer::Create(); |
5858 root->SetBounds(gfx::Size(500, 500)); | 5864 root->SetBounds(gfx::Size(500, 500)); |
5859 | 5865 |
5860 scoped_refptr<Layer> pinch = Layer::Create(); | 5866 scoped_refptr<Layer> pinch = Layer::Create(); |
5861 pinch->SetBounds(gfx::Size(500, 500)); | 5867 pinch->SetBounds(gfx::Size(500, 500)); |
5862 pinch->SetScrollClipLayerId(root->id()); | 5868 pinch->SetScrollClipLayerId(root->id()); |
5863 pinch->SetIsContainerForFixedPositionLayers(true); | 5869 pinch->SetIsContainerForFixedPositionLayers(true); |
5864 root->AddChild(pinch); | 5870 root->AddChild(pinch); |
5865 | 5871 |
5866 scoped_ptr<FakePicturePile> pile(new FakePicturePile); | 5872 scoped_ptr<FakePicturePile> pile( |
| 5873 new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale, |
| 5874 ImplSidePaintingSettings().default_tile_grid_size)); |
5867 pile->SetPlaybackAllowedEvent(&playback_allowed_event_); | 5875 pile->SetPlaybackAllowedEvent(&playback_allowed_event_); |
5868 scoped_refptr<FakePictureLayer> layer = | 5876 scoped_refptr<FakePictureLayer> layer = |
5869 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); | 5877 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); |
5870 layer->SetBounds(gfx::Size(500, 500)); | 5878 layer->SetBounds(gfx::Size(500, 500)); |
5871 layer->SetContentsOpaque(true); | 5879 layer->SetContentsOpaque(true); |
5872 // Avoid LCD text on the layer so we don't cause extra commits when we | 5880 // Avoid LCD text on the layer so we don't cause extra commits when we |
5873 // pinch. | 5881 // pinch. |
5874 layer->disable_lcd_text(); | 5882 layer->disable_lcd_text(); |
5875 pinch->AddChild(layer); | 5883 pinch->AddChild(layer); |
5876 | 5884 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6147 | 6155 |
6148 void AfterTest() override { EXPECT_TRUE(did_commit_); } | 6156 void AfterTest() override { EXPECT_TRUE(did_commit_); } |
6149 | 6157 |
6150 private: | 6158 private: |
6151 bool did_commit_; | 6159 bool did_commit_; |
6152 }; | 6160 }; |
6153 | 6161 |
6154 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); | 6162 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); |
6155 | 6163 |
6156 } // namespace cc | 6164 } // namespace cc |
OLD | NEW |