| 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/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "cc/animation/timing_function.h" | 10 #include "cc/animation/timing_function.h" |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 | 710 |
| 711 EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks()); | 711 EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks()); |
| 712 EndTest(); | 712 EndTest(); |
| 713 } | 713 } |
| 714 | 714 |
| 715 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 715 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 716 // Ensure there isn't a commit between the two draws, to ensure that a | 716 // Ensure there isn't a commit between the two draws, to ensure that a |
| 717 // commit isn't required for updating the current frame time. We can | 717 // commit isn't required for updating the current frame time. We can |
| 718 // only check for this in the multi-threaded case, since in the single- | 718 // only check for this in the multi-threaded case, since in the single- |
| 719 // threaded case there will always be a commit between consecutive draws. | 719 // threaded case there will always be a commit between consecutive draws. |
| 720 if (ImplThread()) | 720 if (HasImplThread()) |
| 721 EXPECT_EQ(0, frame_); | 721 EXPECT_EQ(0, frame_); |
| 722 } | 722 } |
| 723 | 723 |
| 724 virtual void AfterTest() OVERRIDE {} | 724 virtual void AfterTest() OVERRIDE {} |
| 725 | 725 |
| 726 private: | 726 private: |
| 727 int frame_; | 727 int frame_; |
| 728 base::TimeTicks first_frame_time_; | 728 base::TimeTicks first_frame_time_; |
| 729 }; | 729 }; |
| 730 | 730 |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1618 identity_matrix, | 1618 identity_matrix, |
| 1619 gfx::PointF(0.f, 0.f), | 1619 gfx::PointF(0.f, 0.f), |
| 1620 gfx::PointF(0.f, 0.f), | 1620 gfx::PointF(0.f, 0.f), |
| 1621 gfx::Size(10, 20), | 1621 gfx::Size(10, 20), |
| 1622 true); | 1622 true); |
| 1623 | 1623 |
| 1624 PostSetNeedsCommitToMainThread(); | 1624 PostSetNeedsCommitToMainThread(); |
| 1625 } | 1625 } |
| 1626 | 1626 |
| 1627 void PostEvictTextures() { | 1627 void PostEvictTextures() { |
| 1628 DCHECK(ImplThread()); | 1628 DCHECK(HasImplThread()); |
| 1629 ImplThread()->PostTask( | 1629 ImplThreadTaskRunner()->PostTask( |
| 1630 FROM_HERE, |
| 1630 base::Bind(&LayerTreeHostTestEvictTextures::EvictTexturesOnImplThread, | 1631 base::Bind(&LayerTreeHostTestEvictTextures::EvictTexturesOnImplThread, |
| 1631 base::Unretained(this))); | 1632 base::Unretained(this))); |
| 1632 } | 1633 } |
| 1633 | 1634 |
| 1634 void EvictTexturesOnImplThread() { | 1635 void EvictTexturesOnImplThread() { |
| 1635 DCHECK(impl_for_evict_textures_); | 1636 DCHECK(impl_for_evict_textures_); |
| 1636 impl_for_evict_textures_->EnforceManagedMemoryPolicy( | 1637 impl_for_evict_textures_->EnforceManagedMemoryPolicy( |
| 1637 ManagedMemoryPolicy(0)); | 1638 ManagedMemoryPolicy(0)); |
| 1638 } | 1639 } |
| 1639 | 1640 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1872 proxy->SetLayerTreeHost(this); | 1873 proxy->SetLayerTreeHost(this); |
| 1873 EXPECT_TRUE(InitializeForTesting(proxy.PassAs<Proxy>())); | 1874 EXPECT_TRUE(InitializeForTesting(proxy.PassAs<Proxy>())); |
| 1874 } | 1875 } |
| 1875 }; | 1876 }; |
| 1876 | 1877 |
| 1877 TEST(LayerTreeHostTest, LimitPartialUpdates) { | 1878 TEST(LayerTreeHostTest, LimitPartialUpdates) { |
| 1878 // When partial updates are not allowed, max updates should be 0. | 1879 // When partial updates are not allowed, max updates should be 0. |
| 1879 { | 1880 { |
| 1880 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 1881 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 1881 | 1882 |
| 1882 scoped_ptr<FakeProxy> proxy = | 1883 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
| 1883 make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>())); | |
| 1884 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; | 1884 proxy->GetRendererCapabilities().allow_partial_texture_updates = false; |
| 1885 proxy->SetMaxPartialTextureUpdates(5); | 1885 proxy->SetMaxPartialTextureUpdates(5); |
| 1886 | 1886 |
| 1887 LayerTreeSettings settings; | 1887 LayerTreeSettings settings; |
| 1888 settings.max_partial_texture_updates = 10; | 1888 settings.max_partial_texture_updates = 10; |
| 1889 | 1889 |
| 1890 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 1890 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
| 1891 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); | 1891 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); |
| 1892 | 1892 |
| 1893 EXPECT_EQ(0u, host.settings().max_partial_texture_updates); | 1893 EXPECT_EQ(0u, host.settings().max_partial_texture_updates); |
| 1894 } | 1894 } |
| 1895 | 1895 |
| 1896 // When partial updates are allowed, | 1896 // When partial updates are allowed, |
| 1897 // max updates should be limited by the proxy. | 1897 // max updates should be limited by the proxy. |
| 1898 { | 1898 { |
| 1899 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 1899 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 1900 | 1900 |
| 1901 scoped_ptr<FakeProxy> proxy = | 1901 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
| 1902 make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>())); | |
| 1903 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; | 1902 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; |
| 1904 proxy->SetMaxPartialTextureUpdates(5); | 1903 proxy->SetMaxPartialTextureUpdates(5); |
| 1905 | 1904 |
| 1906 LayerTreeSettings settings; | 1905 LayerTreeSettings settings; |
| 1907 settings.max_partial_texture_updates = 10; | 1906 settings.max_partial_texture_updates = 10; |
| 1908 | 1907 |
| 1909 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 1908 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
| 1910 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); | 1909 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); |
| 1911 | 1910 |
| 1912 EXPECT_EQ(5u, host.settings().max_partial_texture_updates); | 1911 EXPECT_EQ(5u, host.settings().max_partial_texture_updates); |
| 1913 } | 1912 } |
| 1914 | 1913 |
| 1915 // When partial updates are allowed, | 1914 // When partial updates are allowed, |
| 1916 // max updates should also be limited by the settings. | 1915 // max updates should also be limited by the settings. |
| 1917 { | 1916 { |
| 1918 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 1917 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 1919 | 1918 |
| 1920 scoped_ptr<FakeProxy> proxy = | 1919 scoped_ptr<FakeProxy> proxy(new FakeProxy); |
| 1921 make_scoped_ptr(new FakeProxy(scoped_ptr<Thread>())); | |
| 1922 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; | 1920 proxy->GetRendererCapabilities().allow_partial_texture_updates = true; |
| 1923 proxy->SetMaxPartialTextureUpdates(20); | 1921 proxy->SetMaxPartialTextureUpdates(20); |
| 1924 | 1922 |
| 1925 LayerTreeSettings settings; | 1923 LayerTreeSettings settings; |
| 1926 settings.max_partial_texture_updates = 10; | 1924 settings.max_partial_texture_updates = 10; |
| 1927 | 1925 |
| 1928 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); | 1926 LayerTreeHostWithProxy host(&client, settings, proxy.Pass()); |
| 1929 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); | 1927 EXPECT_TRUE(host.InitializeOutputSurfaceIfNeeded()); |
| 1930 | 1928 |
| 1931 EXPECT_EQ(10u, host.settings().max_partial_texture_updates); | 1929 EXPECT_EQ(10u, host.settings().max_partial_texture_updates); |
| 1932 } | 1930 } |
| 1933 } | 1931 } |
| 1934 | 1932 |
| 1935 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { | 1933 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { |
| 1936 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 1934 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 1937 | 1935 |
| 1938 LayerTreeSettings settings; | 1936 LayerTreeSettings settings; |
| 1939 settings.max_partial_texture_updates = 4; | 1937 settings.max_partial_texture_updates = 4; |
| 1940 | 1938 |
| 1941 scoped_ptr<LayerTreeHost> host = | 1939 scoped_ptr<LayerTreeHost> host = LayerTreeHost::Create( |
| 1942 LayerTreeHost::Create(&client, settings, scoped_ptr<Thread>()); | 1940 &client, |
| 1941 settings, |
| 1942 scoped_refptr<base::SingleThreadTaskRunner>()); |
| 1943 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 1943 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
| 1944 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); | 1944 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); |
| 1945 } | 1945 } |
| 1946 | 1946 |
| 1947 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { | 1947 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { |
| 1948 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); | 1948 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); |
| 1949 | 1949 |
| 1950 LayerTreeSettings settings; | 1950 LayerTreeSettings settings; |
| 1951 settings.max_partial_texture_updates = 4; | 1951 settings.max_partial_texture_updates = 4; |
| 1952 | 1952 |
| 1953 scoped_ptr<LayerTreeHost> host = | 1953 scoped_ptr<LayerTreeHost> host = LayerTreeHost::Create( |
| 1954 LayerTreeHost::Create(&client, settings, scoped_ptr<Thread>()); | 1954 &client, |
| 1955 settings, |
| 1956 scoped_refptr<base::SingleThreadTaskRunner>()); |
| 1955 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 1957 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
| 1956 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); | 1958 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); |
| 1957 } | 1959 } |
| 1958 | 1960 |
| 1959 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { | 1961 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { |
| 1960 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); | 1962 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); |
| 1961 | 1963 |
| 1962 LayerTreeSettings settings; | 1964 LayerTreeSettings settings; |
| 1963 settings.max_partial_texture_updates = 4; | 1965 settings.max_partial_texture_updates = 4; |
| 1964 | 1966 |
| 1965 scoped_ptr<LayerTreeHost> host = | 1967 scoped_ptr<LayerTreeHost> host = LayerTreeHost::Create( |
| 1966 LayerTreeHost::Create(&client, settings, scoped_ptr<Thread>()); | 1968 &client, |
| 1969 settings, |
| 1970 scoped_refptr<base::SingleThreadTaskRunner>()); |
| 1967 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 1971 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
| 1968 EXPECT_EQ(0u, host->settings().max_partial_texture_updates); | 1972 EXPECT_EQ(0u, host->settings().max_partial_texture_updates); |
| 1969 } | 1973 } |
| 1970 | 1974 |
| 1971 TEST(LayerTreeHostTest, | 1975 TEST(LayerTreeHostTest, |
| 1972 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { | 1976 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { |
| 1973 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); | 1977 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); |
| 1974 | 1978 |
| 1975 LayerTreeSettings settings; | 1979 LayerTreeSettings settings; |
| 1976 settings.max_partial_texture_updates = 4; | 1980 settings.max_partial_texture_updates = 4; |
| 1977 | 1981 |
| 1978 scoped_ptr<LayerTreeHost> host = | 1982 scoped_ptr<LayerTreeHost> host = LayerTreeHost::Create( |
| 1979 LayerTreeHost::Create(&client, settings, scoped_ptr<Thread>()); | 1983 &client, |
| 1984 settings, |
| 1985 scoped_refptr<base::SingleThreadTaskRunner>()); |
| 1980 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 1986 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
| 1981 EXPECT_EQ(0u, host->settings().max_partial_texture_updates); | 1987 EXPECT_EQ(0u, host->settings().max_partial_texture_updates); |
| 1982 } | 1988 } |
| 1983 | 1989 |
| 1984 class LayerTreeHostTestCapturePicture : public LayerTreeHostTest { | 1990 class LayerTreeHostTestCapturePicture : public LayerTreeHostTest { |
| 1985 public: | 1991 public: |
| 1986 LayerTreeHostTestCapturePicture() | 1992 LayerTreeHostTestCapturePicture() |
| 1987 : bounds_(gfx::Size(100, 100)), | 1993 : bounds_(gfx::Size(100, 100)), |
| 1988 layer_(PictureLayer::Create(&content_client_)) {} | 1994 layer_(PictureLayer::Create(&content_client_)) {} |
| 1989 | 1995 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2250 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2256 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 2251 settings->begin_frame_scheduling_enabled = true; | 2257 settings->begin_frame_scheduling_enabled = true; |
| 2252 settings->using_synchronous_renderer_compositor = true; | 2258 settings->using_synchronous_renderer_compositor = true; |
| 2253 } | 2259 } |
| 2254 | 2260 |
| 2255 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 2261 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 2256 | 2262 |
| 2257 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 2263 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 2258 // The BeginFrame notification is turned off now but will get enabled | 2264 // The BeginFrame notification is turned off now but will get enabled |
| 2259 // once we return. End test while it's enabled. | 2265 // once we return. End test while it's enabled. |
| 2260 ImplThread()->PostTask(base::Bind( | 2266 ImplThreadTaskRunner()->PostTask( |
| 2261 &LayerTreeHostTestBeginFrameNotification::EndTest, | 2267 FROM_HERE, |
| 2262 base::Unretained(this))); | 2268 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest, |
| 2269 base::Unretained(this))); |
| 2263 } | 2270 } |
| 2264 | 2271 |
| 2265 virtual void AfterTest() OVERRIDE {} | 2272 virtual void AfterTest() OVERRIDE {} |
| 2266 }; | 2273 }; |
| 2267 | 2274 |
| 2268 MULTI_THREAD_TEST_F( | 2275 MULTI_THREAD_TEST_F( |
| 2269 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); | 2276 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); |
| 2270 | 2277 |
| 2271 class LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation | 2278 class LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation |
| 2272 : public LayerTreeHostTest { | 2279 : public LayerTreeHostTest { |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2820 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)) | 2827 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)) |
| 2821 .PassAs<OutputSurface>(); | 2828 .PassAs<OutputSurface>(); |
| 2822 } | 2829 } |
| 2823 | 2830 |
| 2824 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 2831 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 2825 ASSERT_TRUE(host_impl->RootLayer()); | 2832 ASSERT_TRUE(host_impl->RootLayer()); |
| 2826 FakePictureLayerImpl* layer_impl = | 2833 FakePictureLayerImpl* layer_impl = |
| 2827 static_cast<FakePictureLayerImpl*>(host_impl->RootLayer()); | 2834 static_cast<FakePictureLayerImpl*>(host_impl->RootLayer()); |
| 2828 if (!initialized_gl_) { | 2835 if (!initialized_gl_) { |
| 2829 EXPECT_EQ(1u, layer_impl->append_quads_count()); | 2836 EXPECT_EQ(1u, layer_impl->append_quads_count()); |
| 2830 ImplThread()->PostTask(base::Bind( | 2837 ImplThreadTaskRunner()->PostTask(FROM_HERE, base::Bind( |
| 2831 &LayerTreeHostTestDeferredInitialize::DeferredInitializeAndRedraw, | 2838 &LayerTreeHostTestDeferredInitialize::DeferredInitializeAndRedraw, |
| 2832 base::Unretained(this), | 2839 base::Unretained(this), |
| 2833 base::Unretained(host_impl))); | 2840 base::Unretained(host_impl))); |
| 2834 } else { | 2841 } else { |
| 2835 EXPECT_EQ(2u, layer_impl->append_quads_count()); | 2842 EXPECT_EQ(2u, layer_impl->append_quads_count()); |
| 2836 EndTest(); | 2843 EndTest(); |
| 2837 } | 2844 } |
| 2838 } | 2845 } |
| 2839 | 2846 |
| 2840 void DeferredInitializeAndRedraw(LayerTreeHostImpl* host_impl) { | 2847 void DeferredInitializeAndRedraw(LayerTreeHostImpl* host_impl) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2856 private: | 2863 private: |
| 2857 FakeContentLayerClient client_; | 2864 FakeContentLayerClient client_; |
| 2858 scoped_refptr<FakePictureLayer> layer_; | 2865 scoped_refptr<FakePictureLayer> layer_; |
| 2859 bool initialized_gl_; | 2866 bool initialized_gl_; |
| 2860 }; | 2867 }; |
| 2861 | 2868 |
| 2862 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); | 2869 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); |
| 2863 | 2870 |
| 2864 } // namespace | 2871 } // namespace |
| 2865 } // namespace cc | 2872 } // namespace cc |
| OLD | NEW |