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/location.h" | 10 #include "base/location.h" |
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 } | 1554 } |
1555 | 1555 |
1556 void AfterTest() override { EXPECT_EQ(1, num_draws_); } | 1556 void AfterTest() override { EXPECT_EQ(1, num_draws_); } |
1557 | 1557 |
1558 private: | 1558 private: |
1559 int num_draws_; | 1559 int num_draws_; |
1560 }; | 1560 }; |
1561 | 1561 |
1562 MULTI_THREAD_TEST_F(LayerTreeHostTestSetVisible); | 1562 MULTI_THREAD_TEST_F(LayerTreeHostTestSetVisible); |
1563 | 1563 |
1564 class TestOpacityChangeLayerDelegate : public ContentLayerClient { | |
1565 public: | |
1566 TestOpacityChangeLayerDelegate() : test_layer_(0) {} | |
1567 | |
1568 void SetTestLayer(Layer* test_layer) { test_layer_ = test_layer; } | |
1569 | |
1570 gfx::Rect PaintableRegion() override { | |
1571 return gfx::Rect(test_layer_->bounds()); | |
1572 } | |
1573 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( | |
1574 PaintingControlSetting picture_control) override { | |
1575 // Set layer opacity to 0. | |
1576 if (test_layer_) | |
1577 test_layer_->SetOpacity(0.f); | |
1578 | |
1579 // Return a dummy display list. | |
1580 scoped_refptr<DisplayItemList> display_list = | |
1581 DisplayItemList::Create(PaintableRegion(), DisplayItemListSettings()); | |
1582 return display_list; | |
1583 } | |
1584 bool FillsBoundsCompletely() const override { return false; } | |
1585 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } | |
1586 | |
1587 private: | |
1588 Layer* test_layer_; | |
1589 }; | |
1590 | |
1591 // Layer opacity change during paint should not prevent compositor resources | |
1592 // from being updated during commit. | |
1593 class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { | |
1594 public: | |
1595 LayerTreeHostTestOpacityChange() : test_opacity_change_delegate_() {} | |
1596 | |
1597 void SetupTree() override { | |
1598 LayerTreeHostTest::SetupTree(); | |
1599 | |
1600 update_check_picture_layer_ = FakePictureLayer::Create( | |
1601 layer_settings(), &test_opacity_change_delegate_); | |
1602 test_opacity_change_delegate_.SetTestLayer( | |
1603 update_check_picture_layer_.get()); | |
1604 layer_tree_host()->root_layer()->AddChild(update_check_picture_layer_); | |
1605 } | |
1606 | |
1607 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | |
1608 | |
1609 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { EndTest(); } | |
1610 | |
1611 void AfterTest() override { | |
1612 // Update() should have been called once. | |
1613 EXPECT_EQ(1, update_check_picture_layer_->update_count()); | |
1614 } | |
1615 | |
1616 private: | |
1617 TestOpacityChangeLayerDelegate test_opacity_change_delegate_; | |
1618 scoped_refptr<FakePictureLayer> update_check_picture_layer_; | |
1619 }; | |
1620 | |
1621 MULTI_THREAD_TEST_F(LayerTreeHostTestOpacityChange); | |
1622 | |
1623 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers | 1564 class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers |
1624 : public LayerTreeHostTest { | 1565 : public LayerTreeHostTest { |
1625 public: | 1566 public: |
1626 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() {} | 1567 LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() {} |
1627 | 1568 |
1628 void BeginTest() override { | 1569 void BeginTest() override { |
1629 client_.set_fill_with_nonsolid_color(true); | 1570 client_.set_fill_with_nonsolid_color(true); |
1630 root_layer_ = FakePictureLayer::Create(layer_settings(), &client_); | 1571 root_layer_ = FakePictureLayer::Create(layer_settings(), &client_); |
1631 child_layer_ = FakePictureLayer::Create(layer_settings(), &client_); | 1572 child_layer_ = FakePictureLayer::Create(layer_settings(), &client_); |
1632 | 1573 |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2159 } | 2100 } |
2160 | 2101 |
2161 void AfterTest() override {} | 2102 void AfterTest() override {} |
2162 | 2103 |
2163 FakeContentLayerClient client_; | 2104 FakeContentLayerClient client_; |
2164 }; | 2105 }; |
2165 | 2106 |
2166 SINGLE_AND_MULTI_THREAD_TEST_F( | 2107 SINGLE_AND_MULTI_THREAD_TEST_F( |
2167 LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation); | 2108 LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation); |
2168 | 2109 |
2169 class LayerTreeHostTestChangeLayerPropertiesInPaintContents | |
2170 : public LayerTreeHostTest { | |
2171 public: | |
2172 class SetBoundsClient : public ContentLayerClient { | |
2173 public: | |
2174 SetBoundsClient() : layer_(0) {} | |
2175 | |
2176 void set_layer(Layer* layer) { layer_ = layer; } | |
2177 | |
2178 gfx::Rect PaintableRegion() override { return gfx::Rect(layer_->bounds()); } | |
2179 | |
2180 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( | |
2181 PaintingControlSetting picture_control) override { | |
2182 layer_->SetBounds(gfx::Size(2, 2)); | |
2183 | |
2184 // Return a dummy display list. | |
2185 scoped_refptr<DisplayItemList> display_list = | |
2186 DisplayItemList::Create(PaintableRegion(), DisplayItemListSettings()); | |
2187 return display_list; | |
2188 } | |
2189 | |
2190 bool FillsBoundsCompletely() const override { return false; } | |
2191 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } | |
2192 | |
2193 private: | |
2194 Layer* layer_; | |
2195 }; | |
2196 | |
2197 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {} | |
2198 | |
2199 void SetupTree() override { | |
2200 scoped_refptr<PictureLayer> root_layer = | |
2201 PictureLayer::Create(layer_settings(), &client_); | |
2202 root_layer->SetIsDrawable(true); | |
2203 root_layer->SetBounds(gfx::Size(1, 1)); | |
2204 client_.set_layer(root_layer.get()); | |
2205 | |
2206 layer_tree_host()->SetRootLayer(root_layer); | |
2207 LayerTreeHostTest::SetupTree(); | |
2208 } | |
2209 | |
2210 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | |
2211 void AfterTest() override {} | |
2212 | |
2213 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | |
2214 num_commits_++; | |
2215 if (num_commits_ == 1) { | |
2216 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); | |
2217 EXPECT_EQ(gfx::Size(1, 1), root_layer->bounds()); | |
2218 } else { | |
2219 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); | |
2220 EXPECT_EQ(gfx::Size(2, 2), root_layer->bounds()); | |
2221 EndTest(); | |
2222 } | |
2223 } | |
2224 | |
2225 private: | |
2226 SetBoundsClient client_; | |
2227 int num_commits_; | |
2228 }; | |
2229 | |
2230 SINGLE_AND_MULTI_THREAD_TEST_F( | |
2231 LayerTreeHostTestChangeLayerPropertiesInPaintContents); | |
2232 | |
2233 class MockIOSurfaceWebGraphicsContext3D : public TestWebGraphicsContext3D { | 2110 class MockIOSurfaceWebGraphicsContext3D : public TestWebGraphicsContext3D { |
2234 public: | 2111 public: |
2235 MockIOSurfaceWebGraphicsContext3D() { | 2112 MockIOSurfaceWebGraphicsContext3D() { |
2236 test_capabilities_.gpu.iosurface = true; | 2113 test_capabilities_.gpu.iosurface = true; |
2237 test_capabilities_.gpu.texture_rectangle = true; | 2114 test_capabilities_.gpu.texture_rectangle = true; |
2238 } | 2115 } |
2239 | 2116 |
2240 GLuint createTexture() override { return 1; } | 2117 GLuint createTexture() override { return 1; } |
2241 MOCK_METHOD1(activeTexture, void(GLenum texture)); | 2118 MOCK_METHOD1(activeTexture, void(GLenum texture)); |
2242 MOCK_METHOD2(bindTexture, void(GLenum target, | 2119 MOCK_METHOD2(bindTexture, void(GLenum target, |
(...skipping 4302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6545 EndTest(); | 6422 EndTest(); |
6546 } | 6423 } |
6547 | 6424 |
6548 void AfterTest() override {} | 6425 void AfterTest() override {} |
6549 }; | 6426 }; |
6550 | 6427 |
6551 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); | 6428 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); |
6552 | 6429 |
6553 } // namespace | 6430 } // namespace |
6554 } // namespace cc | 6431 } // namespace cc |
OLD | NEW |