| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 num_draws_++; | 84 num_draws_++; |
| 85 if (!impl->active_tree()->source_frame_number()) | 85 if (!impl->active_tree()->source_frame_number()) |
| 86 EndTest(); | 86 EndTest(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 89 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 90 num_commits_++; | 90 num_commits_++; |
| 91 } | 91 } |
| 92 | 92 |
| 93 virtual void AfterTest() OVERRIDE { | 93 virtual void AfterTest() OVERRIDE { |
| 94 EXPECT_GE(1, num_commits_); | 94 EXPECT_LE(1, num_commits_); |
| 95 EXPECT_GE(1, num_draws_); | 95 EXPECT_LE(1, num_draws_); |
| 96 } | 96 } |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 int num_commits_; | 99 int num_commits_; |
| 100 int num_draws_; | 100 int num_draws_; |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit1); | 103 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit1); |
| 104 | 104 |
| 105 // A SetNeedsCommit should lead to 1 commit. Issuing a second commit after that | 105 // A SetNeedsCommit should lead to 1 commit. Issuing a second commit after that |
| (...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1960 virtual void AfterTest() OVERRIDE { | 1960 virtual void AfterTest() OVERRIDE { |
| 1961 EXPECT_EQ(1, num_commits_deferred_); | 1961 EXPECT_EQ(1, num_commits_deferred_); |
| 1962 EXPECT_EQ(2, num_complete_commits_); | 1962 EXPECT_EQ(2, num_complete_commits_); |
| 1963 } | 1963 } |
| 1964 | 1964 |
| 1965 private: | 1965 private: |
| 1966 int num_commits_deferred_; | 1966 int num_commits_deferred_; |
| 1967 int num_complete_commits_; | 1967 int num_complete_commits_; |
| 1968 }; | 1968 }; |
| 1969 | 1969 |
| 1970 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits); | 1970 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDeferCommits); |
| 1971 | 1971 |
| 1972 class LayerTreeHostWithProxy : public LayerTreeHost { | 1972 class LayerTreeHostWithProxy : public LayerTreeHost { |
| 1973 public: | 1973 public: |
| 1974 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client, | 1974 LayerTreeHostWithProxy(FakeLayerTreeHostClient* client, |
| 1975 const LayerTreeSettings& settings, | 1975 const LayerTreeSettings& settings, |
| 1976 scoped_ptr<FakeProxy> proxy) | 1976 scoped_ptr<FakeProxy> proxy) |
| 1977 : LayerTreeHost(client, NULL, settings) { | 1977 : LayerTreeHost(client, NULL, settings) { |
| 1978 proxy->SetLayerTreeHost(this); | 1978 proxy->SetLayerTreeHost(this); |
| 1979 InitializeForTesting(proxy.PassAs<Proxy>()); | 1979 InitializeForTesting(proxy.PassAs<Proxy>()); |
| 1980 } | 1980 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2033 | 2033 |
| 2034 EXPECT_EQ(10u, host.MaxPartialTextureUpdates()); | 2034 EXPECT_EQ(10u, host.MaxPartialTextureUpdates()); |
| 2035 } | 2035 } |
| 2036 } | 2036 } |
| 2037 | 2037 |
| 2038 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { | 2038 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { |
| 2039 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2039 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
| 2040 | 2040 |
| 2041 LayerTreeSettings settings; | 2041 LayerTreeSettings settings; |
| 2042 settings.max_partial_texture_updates = 4; | 2042 settings.max_partial_texture_updates = 4; |
| 2043 settings.single_thread_proxy_scheduler = false; |
| 2043 | 2044 |
| 2044 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 2045 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 2045 new TestSharedBitmapManager()); | 2046 new TestSharedBitmapManager()); |
| 2046 scoped_ptr<LayerTreeHost> host = | 2047 scoped_ptr<LayerTreeHost> host = |
| 2047 LayerTreeHost::CreateSingleThreaded(&client, | 2048 LayerTreeHost::CreateSingleThreaded(&client, |
| 2048 &client, | 2049 &client, |
| 2049 shared_bitmap_manager.get(), | 2050 shared_bitmap_manager.get(), |
| 2050 settings, | 2051 settings, |
| 2051 base::MessageLoopProxy::current()); | 2052 base::MessageLoopProxy::current()); |
| 2052 host->Composite(base::TimeTicks::Now()); | 2053 host->Composite(base::TimeTicks::Now()); |
| 2053 | 2054 |
| 2054 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); | 2055 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); |
| 2055 } | 2056 } |
| 2056 | 2057 |
| 2057 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { | 2058 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { |
| 2058 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); | 2059 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); |
| 2059 | 2060 |
| 2060 LayerTreeSettings settings; | 2061 LayerTreeSettings settings; |
| 2061 settings.max_partial_texture_updates = 4; | 2062 settings.max_partial_texture_updates = 4; |
| 2063 settings.single_thread_proxy_scheduler = false; |
| 2062 | 2064 |
| 2063 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 2065 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 2064 new TestSharedBitmapManager()); | 2066 new TestSharedBitmapManager()); |
| 2065 scoped_ptr<LayerTreeHost> host = | 2067 scoped_ptr<LayerTreeHost> host = |
| 2066 LayerTreeHost::CreateSingleThreaded(&client, | 2068 LayerTreeHost::CreateSingleThreaded(&client, |
| 2067 &client, | 2069 &client, |
| 2068 shared_bitmap_manager.get(), | 2070 shared_bitmap_manager.get(), |
| 2069 settings, | 2071 settings, |
| 2070 base::MessageLoopProxy::current()); | 2072 base::MessageLoopProxy::current()); |
| 2071 host->Composite(base::TimeTicks::Now()); | 2073 host->Composite(base::TimeTicks::Now()); |
| 2072 | 2074 |
| 2073 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); | 2075 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); |
| 2074 } | 2076 } |
| 2075 | 2077 |
| 2076 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { | 2078 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { |
| 2077 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); | 2079 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); |
| 2078 | 2080 |
| 2079 LayerTreeSettings settings; | 2081 LayerTreeSettings settings; |
| 2080 settings.max_partial_texture_updates = 4; | 2082 settings.max_partial_texture_updates = 4; |
| 2083 settings.single_thread_proxy_scheduler = false; |
| 2081 | 2084 |
| 2082 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 2085 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 2083 new TestSharedBitmapManager()); | 2086 new TestSharedBitmapManager()); |
| 2084 scoped_ptr<LayerTreeHost> host = | 2087 scoped_ptr<LayerTreeHost> host = |
| 2085 LayerTreeHost::CreateSingleThreaded(&client, | 2088 LayerTreeHost::CreateSingleThreaded(&client, |
| 2086 &client, | 2089 &client, |
| 2087 shared_bitmap_manager.get(), | 2090 shared_bitmap_manager.get(), |
| 2088 settings, | 2091 settings, |
| 2089 base::MessageLoopProxy::current()); | 2092 base::MessageLoopProxy::current()); |
| 2090 host->Composite(base::TimeTicks::Now()); | 2093 host->Composite(base::TimeTicks::Now()); |
| 2091 | 2094 |
| 2092 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); | 2095 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); |
| 2093 } | 2096 } |
| 2094 | 2097 |
| 2095 TEST(LayerTreeHostTest, | 2098 TEST(LayerTreeHostTest, |
| 2096 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { | 2099 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { |
| 2097 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); | 2100 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); |
| 2098 | 2101 |
| 2099 LayerTreeSettings settings; | 2102 LayerTreeSettings settings; |
| 2100 settings.max_partial_texture_updates = 4; | 2103 settings.max_partial_texture_updates = 4; |
| 2104 settings.single_thread_proxy_scheduler = false; |
| 2101 | 2105 |
| 2102 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 2106 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 2103 new TestSharedBitmapManager()); | 2107 new TestSharedBitmapManager()); |
| 2104 scoped_ptr<LayerTreeHost> host = | 2108 scoped_ptr<LayerTreeHost> host = |
| 2105 LayerTreeHost::CreateSingleThreaded(&client, | 2109 LayerTreeHost::CreateSingleThreaded(&client, |
| 2106 &client, | 2110 &client, |
| 2107 shared_bitmap_manager.get(), | 2111 shared_bitmap_manager.get(), |
| 2108 settings, | 2112 settings, |
| 2109 base::MessageLoopProxy::current()); | 2113 base::MessageLoopProxy::current()); |
| 2110 host->Composite(base::TimeTicks::Now()); | 2114 host->Composite(base::TimeTicks::Now()); |
| (...skipping 2856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4967 const gfx::Size bounds_; | 4971 const gfx::Size bounds_; |
| 4968 FakeContentLayerClient client_; | 4972 FakeContentLayerClient client_; |
| 4969 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 4973 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
| 4970 scoped_refptr<FakePictureLayer> picture_layer_; | 4974 scoped_refptr<FakePictureLayer> picture_layer_; |
| 4971 Layer* child_layer_; | 4975 Layer* child_layer_; |
| 4972 }; | 4976 }; |
| 4973 | 4977 |
| 4974 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 4978 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
| 4975 | 4979 |
| 4976 } // namespace cc | 4980 } // namespace cc |
| OLD | NEW |