| 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 = |
| 1942 LayerTreeHost::Create(&client, settings, scoped_ptr<Thread>()); | 1940 LayerTreeHost::Create(&client, settings, NULL); |
| 1943 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 1941 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
| 1944 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); | 1942 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); |
| 1945 } | 1943 } |
| 1946 | 1944 |
| 1947 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { | 1945 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { |
| 1948 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); | 1946 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); |
| 1949 | 1947 |
| 1950 LayerTreeSettings settings; | 1948 LayerTreeSettings settings; |
| 1951 settings.max_partial_texture_updates = 4; | 1949 settings.max_partial_texture_updates = 4; |
| 1952 | 1950 |
| 1953 scoped_ptr<LayerTreeHost> host = | 1951 scoped_ptr<LayerTreeHost> host = |
| 1954 LayerTreeHost::Create(&client, settings, scoped_ptr<Thread>()); | 1952 LayerTreeHost::Create(&client, settings, NULL); |
| 1955 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 1953 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
| 1956 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); | 1954 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); |
| 1957 } | 1955 } |
| 1958 | 1956 |
| 1959 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { | 1957 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { |
| 1960 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); | 1958 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); |
| 1961 | 1959 |
| 1962 LayerTreeSettings settings; | 1960 LayerTreeSettings settings; |
| 1963 settings.max_partial_texture_updates = 4; | 1961 settings.max_partial_texture_updates = 4; |
| 1964 | 1962 |
| 1965 scoped_ptr<LayerTreeHost> host = | 1963 scoped_ptr<LayerTreeHost> host = |
| 1966 LayerTreeHost::Create(&client, settings, scoped_ptr<Thread>()); | 1964 LayerTreeHost::Create(&client, settings, NULL); |
| 1967 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 1965 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
| 1968 EXPECT_EQ(0u, host->settings().max_partial_texture_updates); | 1966 EXPECT_EQ(0u, host->settings().max_partial_texture_updates); |
| 1969 } | 1967 } |
| 1970 | 1968 |
| 1971 TEST(LayerTreeHostTest, | 1969 TEST(LayerTreeHostTest, |
| 1972 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { | 1970 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { |
| 1973 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); | 1971 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); |
| 1974 | 1972 |
| 1975 LayerTreeSettings settings; | 1973 LayerTreeSettings settings; |
| 1976 settings.max_partial_texture_updates = 4; | 1974 settings.max_partial_texture_updates = 4; |
| 1977 | 1975 |
| 1978 scoped_ptr<LayerTreeHost> host = | 1976 scoped_ptr<LayerTreeHost> host = |
| 1979 LayerTreeHost::Create(&client, settings, scoped_ptr<Thread>()); | 1977 LayerTreeHost::Create(&client, settings, NULL); |
| 1980 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 1978 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
| 1981 EXPECT_EQ(0u, host->settings().max_partial_texture_updates); | 1979 EXPECT_EQ(0u, host->settings().max_partial_texture_updates); |
| 1982 } | 1980 } |
| 1983 | 1981 |
| 1984 class LayerTreeHostTestCapturePicture : public LayerTreeHostTest { | 1982 class LayerTreeHostTestCapturePicture : public LayerTreeHostTest { |
| 1985 public: | 1983 public: |
| 1986 LayerTreeHostTestCapturePicture() | 1984 LayerTreeHostTestCapturePicture() |
| 1987 : bounds_(gfx::Size(100, 100)), | 1985 : bounds_(gfx::Size(100, 100)), |
| 1988 layer_(PictureLayer::Create(&content_client_)) {} | 1986 layer_(PictureLayer::Create(&content_client_)) {} |
| 1989 | 1987 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2250 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 2248 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 2251 settings->begin_frame_scheduling_enabled = true; | 2249 settings->begin_frame_scheduling_enabled = true; |
| 2252 settings->using_synchronous_renderer_compositor = true; | 2250 settings->using_synchronous_renderer_compositor = true; |
| 2253 } | 2251 } |
| 2254 | 2252 |
| 2255 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 2253 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 2256 | 2254 |
| 2257 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 2255 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 2258 // The BeginFrame notification is turned off now but will get enabled | 2256 // The BeginFrame notification is turned off now but will get enabled |
| 2259 // once we return. End test while it's enabled. | 2257 // once we return. End test while it's enabled. |
| 2260 ImplThread()->PostTask(base::Bind( | 2258 ImplThreadTaskRunner()->PostTask( |
| 2261 &LayerTreeHostTestBeginFrameNotification::EndTest, | 2259 FROM_HERE, |
| 2262 base::Unretained(this))); | 2260 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest, |
| 2261 base::Unretained(this))); |
| 2263 } | 2262 } |
| 2264 | 2263 |
| 2265 virtual void AfterTest() OVERRIDE {} | 2264 virtual void AfterTest() OVERRIDE {} |
| 2266 }; | 2265 }; |
| 2267 | 2266 |
| 2268 MULTI_THREAD_TEST_F( | 2267 MULTI_THREAD_TEST_F( |
| 2269 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); | 2268 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); |
| 2270 | 2269 |
| 2271 class LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation | 2270 class LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation |
| 2272 : public LayerTreeHostTest { | 2271 : public LayerTreeHostTest { |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2820 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)) | 2819 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)) |
| 2821 .PassAs<OutputSurface>(); | 2820 .PassAs<OutputSurface>(); |
| 2822 } | 2821 } |
| 2823 | 2822 |
| 2824 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 2823 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 2825 ASSERT_TRUE(host_impl->RootLayer()); | 2824 ASSERT_TRUE(host_impl->RootLayer()); |
| 2826 FakePictureLayerImpl* layer_impl = | 2825 FakePictureLayerImpl* layer_impl = |
| 2827 static_cast<FakePictureLayerImpl*>(host_impl->RootLayer()); | 2826 static_cast<FakePictureLayerImpl*>(host_impl->RootLayer()); |
| 2828 if (!initialized_gl_) { | 2827 if (!initialized_gl_) { |
| 2829 EXPECT_EQ(1u, layer_impl->append_quads_count()); | 2828 EXPECT_EQ(1u, layer_impl->append_quads_count()); |
| 2830 ImplThread()->PostTask(base::Bind( | 2829 ImplThreadTaskRunner()->PostTask(FROM_HERE, base::Bind( |
| 2831 &LayerTreeHostTestDeferredInitialize::DeferredInitializeAndRedraw, | 2830 &LayerTreeHostTestDeferredInitialize::DeferredInitializeAndRedraw, |
| 2832 base::Unretained(this), | 2831 base::Unretained(this), |
| 2833 base::Unretained(host_impl))); | 2832 base::Unretained(host_impl))); |
| 2834 } else { | 2833 } else { |
| 2835 EXPECT_EQ(2u, layer_impl->append_quads_count()); | 2834 EXPECT_EQ(2u, layer_impl->append_quads_count()); |
| 2836 EndTest(); | 2835 EndTest(); |
| 2837 } | 2836 } |
| 2838 } | 2837 } |
| 2839 | 2838 |
| 2840 void DeferredInitializeAndRedraw(LayerTreeHostImpl* host_impl) { | 2839 void DeferredInitializeAndRedraw(LayerTreeHostImpl* host_impl) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2856 private: | 2855 private: |
| 2857 FakeContentLayerClient client_; | 2856 FakeContentLayerClient client_; |
| 2858 scoped_refptr<FakePictureLayer> layer_; | 2857 scoped_refptr<FakePictureLayer> layer_; |
| 2859 bool initialized_gl_; | 2858 bool initialized_gl_; |
| 2860 }; | 2859 }; |
| 2861 | 2860 |
| 2862 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); | 2861 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); |
| 2863 | 2862 |
| 2864 } // namespace | 2863 } // namespace |
| 2865 } // namespace cc | 2864 } // namespace cc |
| OLD | NEW |