| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/output/output_surface.h" | 5 #include "cc/output/output_surface.h" |
| 6 | 6 |
| 7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "cc/debug/test_context_provider.h" |
| 8 #include "cc/debug/test_web_graphics_context_3d.h" | 9 #include "cc/debug/test_web_graphics_context_3d.h" |
| 9 #include "cc/output/managed_memory_policy.h" | 10 #include "cc/output/managed_memory_policy.h" |
| 10 #include "cc/output/output_surface_client.h" | 11 #include "cc/output/output_surface_client.h" |
| 11 #include "cc/output/software_output_device.h" | 12 #include "cc/output/software_output_device.h" |
| 12 #include "cc/test/fake_output_surface.h" | 13 #include "cc/test/fake_output_surface.h" |
| 13 #include "cc/test/fake_output_surface_client.h" | 14 #include "cc/test/fake_output_surface_client.h" |
| 14 #include "cc/test/scheduler_test_common.h" | 15 #include "cc/test/scheduler_test_common.h" |
| 15 #include "gpu/GLES2/gl2extchromium.h" | 16 #include "gpu/GLES2/gl2extchromium.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "third_party/WebKit/public/platform/WebGraphicsMemoryAllocation.h" | |
| 18 | |
| 19 using WebKit::WebGraphicsMemoryAllocation; | |
| 20 | 18 |
| 21 namespace cc { | 19 namespace cc { |
| 22 namespace { | 20 namespace { |
| 23 | 21 |
| 24 class TestOutputSurface : public OutputSurface { | 22 class TestOutputSurface : public OutputSurface { |
| 25 public: | 23 public: |
| 26 explicit TestOutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d) | 24 explicit TestOutputSurface(scoped_refptr<ContextProvider> context_provider) |
| 27 : OutputSurface(context3d.Pass()) {} | 25 : OutputSurface(context_provider) {} |
| 28 | 26 |
| 29 explicit TestOutputSurface( | 27 explicit TestOutputSurface( |
| 30 scoped_ptr<cc::SoftwareOutputDevice> software_device) | 28 scoped_ptr<cc::SoftwareOutputDevice> software_device) |
| 31 : OutputSurface(software_device.Pass()) {} | 29 : OutputSurface(software_device.Pass()) {} |
| 32 | 30 |
| 33 TestOutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d, | 31 TestOutputSurface(scoped_refptr<ContextProvider> context_provider, |
| 34 scoped_ptr<cc::SoftwareOutputDevice> software_device) | 32 scoped_ptr<cc::SoftwareOutputDevice> software_device) |
| 35 : OutputSurface(context3d.Pass(), software_device.Pass()) {} | 33 : OutputSurface(context_provider, software_device.Pass()) {} |
| 36 | 34 |
| 37 bool InitializeNewContext3D( | 35 bool InitializeNewContext3d( |
| 38 scoped_ptr<WebKit::WebGraphicsContext3D> new_context3d) { | 36 scoped_refptr<ContextProvider> new_context_provider) { |
| 39 return InitializeAndSetContext3D(new_context3d.Pass(), | 37 return InitializeAndSetContext3d(new_context_provider, |
| 40 scoped_refptr<ContextProvider>()); | 38 scoped_refptr<ContextProvider>()); |
| 41 } | 39 } |
| 42 | 40 |
| 43 using OutputSurface::ReleaseGL; | 41 using OutputSurface::ReleaseGL; |
| 44 | 42 |
| 45 bool HasClientForTesting() { | |
| 46 return HasClient(); | |
| 47 } | |
| 48 | |
| 49 void OnVSyncParametersChangedForTesting(base::TimeTicks timebase, | 43 void OnVSyncParametersChangedForTesting(base::TimeTicks timebase, |
| 50 base::TimeDelta interval) { | 44 base::TimeDelta interval) { |
| 51 OnVSyncParametersChanged(timebase, interval); | 45 OnVSyncParametersChanged(timebase, interval); |
| 52 } | 46 } |
| 53 | 47 |
| 54 void BeginFrameForTesting() { | 48 void BeginFrameForTesting() { |
| 55 OutputSurface::BeginFrame(BeginFrameArgs::CreateExpiredForTesting()); | 49 OutputSurface::BeginFrame(BeginFrameArgs::CreateExpiredForTesting()); |
| 56 } | 50 } |
| 57 | 51 |
| 58 void DidSwapBuffersForTesting() { | 52 void DidSwapBuffersForTesting() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 78 } | 72 } |
| 79 | 73 |
| 80 virtual base::TimeDelta RetroactiveBeginFramePeriod() OVERRIDE { | 74 virtual base::TimeDelta RetroactiveBeginFramePeriod() OVERRIDE { |
| 81 return retroactive_begin_frame_period_; | 75 return retroactive_begin_frame_period_; |
| 82 } | 76 } |
| 83 | 77 |
| 84 base::TimeDelta retroactive_begin_frame_period_; | 78 base::TimeDelta retroactive_begin_frame_period_; |
| 85 }; | 79 }; |
| 86 | 80 |
| 87 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientSuccess) { | 81 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientSuccess) { |
| 88 scoped_ptr<TestWebGraphicsContext3D> context3d = | 82 TestOutputSurface output_surface(TestContextProvider::Create()); |
| 89 TestWebGraphicsContext3D::Create(); | 83 EXPECT_FALSE(output_surface.HasClient()); |
| 90 | |
| 91 TestOutputSurface output_surface( | |
| 92 context3d.PassAs<WebKit::WebGraphicsContext3D>()); | |
| 93 EXPECT_FALSE(output_surface.HasClientForTesting()); | |
| 94 | 84 |
| 95 FakeOutputSurfaceClient client; | 85 FakeOutputSurfaceClient client; |
| 96 EXPECT_TRUE(output_surface.BindToClient(&client)); | 86 EXPECT_TRUE(output_surface.BindToClient(&client)); |
| 97 EXPECT_TRUE(output_surface.HasClientForTesting()); | 87 EXPECT_TRUE(output_surface.HasClient()); |
| 98 EXPECT_FALSE(client.deferred_initialize_called()); | 88 EXPECT_FALSE(client.deferred_initialize_called()); |
| 99 | 89 |
| 100 // Verify DidLoseOutputSurface callback is hooked up correctly. | 90 // Verify DidLoseOutputSurface callback is hooked up correctly. |
| 101 EXPECT_FALSE(client.did_lose_output_surface_called()); | 91 EXPECT_FALSE(client.did_lose_output_surface_called()); |
| 102 output_surface.context3d()->loseContextCHROMIUM( | 92 output_surface.context_provider()->Context3d()->loseContextCHROMIUM( |
| 103 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); | 93 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); |
| 104 EXPECT_TRUE(client.did_lose_output_surface_called()); | 94 EXPECT_TRUE(client.did_lose_output_surface_called()); |
| 105 } | 95 } |
| 106 | 96 |
| 107 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientFailure) { | 97 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientFailure) { |
| 108 scoped_ptr<TestWebGraphicsContext3D> context3d = | 98 scoped_refptr<TestContextProvider> context_provider = |
| 109 TestWebGraphicsContext3D::Create(); | 99 TestContextProvider::Create(); |
| 110 | 100 |
| 111 // Lose the context so BindToClient fails. | 101 // Lose the context so BindToClient fails. |
| 112 context3d->set_times_make_current_succeeds(0); | 102 context_provider->TestContext3d()->set_times_make_current_succeeds(0); |
| 113 | 103 |
| 114 TestOutputSurface output_surface( | 104 TestOutputSurface output_surface(context_provider); |
| 115 context3d.PassAs<WebKit::WebGraphicsContext3D>()); | 105 EXPECT_FALSE(output_surface.HasClient()); |
| 116 EXPECT_FALSE(output_surface.HasClientForTesting()); | |
| 117 | 106 |
| 118 FakeOutputSurfaceClient client; | 107 FakeOutputSurfaceClient client; |
| 119 EXPECT_FALSE(output_surface.BindToClient(&client)); | 108 EXPECT_FALSE(output_surface.BindToClient(&client)); |
| 120 EXPECT_FALSE(output_surface.HasClientForTesting()); | 109 EXPECT_FALSE(output_surface.HasClient()); |
| 121 } | 110 } |
| 122 | 111 |
| 123 class InitializeNewContext3D : public ::testing::Test { | 112 class OutputSurfaceTestInitializeNewContext3d : public ::testing::Test { |
| 124 public: | 113 public: |
| 125 InitializeNewContext3D() | 114 OutputSurfaceTestInitializeNewContext3d() |
| 126 : context3d_(TestWebGraphicsContext3D::Create()), | 115 : context_provider_(TestContextProvider::Create()), |
| 127 output_surface_( | 116 output_surface_( |
| 128 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)) {} | 117 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice)) {} |
| 129 | 118 |
| 130 protected: | 119 protected: |
| 131 void BindOutputSurface() { | 120 void BindOutputSurface() { |
| 132 EXPECT_TRUE(output_surface_.BindToClient(&client_)); | 121 EXPECT_TRUE(output_surface_.BindToClient(&client_)); |
| 133 EXPECT_TRUE(output_surface_.HasClientForTesting()); | 122 EXPECT_TRUE(output_surface_.HasClient()); |
| 134 } | 123 } |
| 135 | 124 |
| 136 void InitializeNewContextExpectFail() { | 125 void InitializeNewContextExpectFail() { |
| 137 EXPECT_FALSE(output_surface_.InitializeNewContext3D( | 126 EXPECT_FALSE(output_surface_.InitializeNewContext3d(context_provider_)); |
| 138 context3d_.PassAs<WebKit::WebGraphicsContext3D>())); | 127 EXPECT_TRUE(output_surface_.HasClient()); |
| 139 EXPECT_TRUE(output_surface_.HasClientForTesting()); | |
| 140 | 128 |
| 141 EXPECT_FALSE(output_surface_.context3d()); | 129 EXPECT_FALSE(output_surface_.context_provider()); |
| 142 EXPECT_TRUE(output_surface_.software_device()); | 130 EXPECT_TRUE(output_surface_.software_device()); |
| 143 } | 131 } |
| 144 | 132 |
| 145 scoped_ptr<TestWebGraphicsContext3D> context3d_; | 133 scoped_refptr<TestContextProvider> context_provider_; |
| 146 TestOutputSurface output_surface_; | 134 TestOutputSurface output_surface_; |
| 147 FakeOutputSurfaceClient client_; | 135 FakeOutputSurfaceClient client_; |
| 148 }; | 136 }; |
| 149 | 137 |
| 150 TEST_F(InitializeNewContext3D, Success) { | 138 TEST_F(OutputSurfaceTestInitializeNewContext3d, Success) { |
| 151 BindOutputSurface(); | 139 BindOutputSurface(); |
| 152 EXPECT_FALSE(client_.deferred_initialize_called()); | 140 EXPECT_FALSE(client_.deferred_initialize_called()); |
| 153 | 141 |
| 154 EXPECT_TRUE(output_surface_.InitializeNewContext3D( | 142 EXPECT_TRUE(output_surface_.InitializeNewContext3d(context_provider_)); |
| 155 context3d_.PassAs<WebKit::WebGraphicsContext3D>())); | |
| 156 EXPECT_TRUE(client_.deferred_initialize_called()); | 143 EXPECT_TRUE(client_.deferred_initialize_called()); |
| 144 EXPECT_EQ(context_provider_, output_surface_.context_provider()); |
| 157 | 145 |
| 158 EXPECT_FALSE(client_.did_lose_output_surface_called()); | 146 EXPECT_FALSE(client_.did_lose_output_surface_called()); |
| 159 output_surface_.context3d()->loseContextCHROMIUM( | 147 context_provider_->Context3d()->loseContextCHROMIUM( |
| 160 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); | 148 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); |
| 161 EXPECT_TRUE(client_.did_lose_output_surface_called()); | 149 EXPECT_TRUE(client_.did_lose_output_surface_called()); |
| 162 | 150 |
| 163 output_surface_.ReleaseGL(); | 151 output_surface_.ReleaseGL(); |
| 164 EXPECT_FALSE(output_surface_.context3d()); | 152 EXPECT_FALSE(output_surface_.context_provider()); |
| 165 } | 153 } |
| 166 | 154 |
| 167 TEST_F(InitializeNewContext3D, Context3dMakeCurrentFails) { | 155 TEST_F(OutputSurfaceTestInitializeNewContext3d, Context3dMakeCurrentFails) { |
| 168 BindOutputSurface(); | 156 BindOutputSurface(); |
| 169 context3d_->set_times_make_current_succeeds(0); | 157 context_provider_->TestContext3d()->set_times_make_current_succeeds(0); |
| 170 InitializeNewContextExpectFail(); | 158 InitializeNewContextExpectFail(); |
| 171 } | 159 } |
| 172 | 160 |
| 173 TEST_F(InitializeNewContext3D, ClientDeferredInitializeFails) { | 161 TEST_F(OutputSurfaceTestInitializeNewContext3d, ClientDeferredInitializeFails) { |
| 174 BindOutputSurface(); | 162 BindOutputSurface(); |
| 175 client_.set_deferred_initialize_result(false); | 163 client_.set_deferred_initialize_result(false); |
| 176 InitializeNewContextExpectFail(); | 164 InitializeNewContextExpectFail(); |
| 177 } | 165 } |
| 178 | 166 |
| 179 TEST(OutputSurfaceTest, BeginFrameEmulation) { | 167 TEST(OutputSurfaceTest, BeginFrameEmulation) { |
| 180 scoped_ptr<TestWebGraphicsContext3D> context3d = | 168 TestOutputSurface output_surface(TestContextProvider::Create()); |
| 181 TestWebGraphicsContext3D::Create(); | 169 EXPECT_FALSE(output_surface.HasClient()); |
| 182 | |
| 183 TestOutputSurface output_surface( | |
| 184 context3d.PassAs<WebKit::WebGraphicsContext3D>()); | |
| 185 EXPECT_FALSE(output_surface.HasClientForTesting()); | |
| 186 | 170 |
| 187 FakeOutputSurfaceClient client; | 171 FakeOutputSurfaceClient client; |
| 188 EXPECT_TRUE(output_surface.BindToClient(&client)); | 172 EXPECT_TRUE(output_surface.BindToClient(&client)); |
| 189 EXPECT_TRUE(output_surface.HasClientForTesting()); | 173 EXPECT_TRUE(output_surface.HasClient()); |
| 190 EXPECT_FALSE(client.deferred_initialize_called()); | 174 EXPECT_FALSE(client.deferred_initialize_called()); |
| 191 | 175 |
| 192 // Initialize BeginFrame emulation | 176 // Initialize BeginFrame emulation |
| 193 scoped_refptr<base::TestSimpleTaskRunner> task_runner = | 177 scoped_refptr<base::TestSimpleTaskRunner> task_runner = |
| 194 new base::TestSimpleTaskRunner; | 178 new base::TestSimpleTaskRunner; |
| 195 bool throttle_frame_production = true; | 179 bool throttle_frame_production = true; |
| 196 const base::TimeDelta display_refresh_interval = | 180 const base::TimeDelta display_refresh_interval = |
| 197 BeginFrameArgs::DefaultInterval(); | 181 BeginFrameArgs::DefaultInterval(); |
| 198 | 182 |
| 199 output_surface.InitializeBeginFrameEmulation( | 183 output_surface.InitializeBeginFrameEmulation( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 241 |
| 258 // Disabling SetNeedsBeginFrame should prevent further BeginFrames. | 242 // Disabling SetNeedsBeginFrame should prevent further BeginFrames. |
| 259 output_surface.SetNeedsBeginFrame(false); | 243 output_surface.SetNeedsBeginFrame(false); |
| 260 task_runner->RunPendingTasks(); | 244 task_runner->RunPendingTasks(); |
| 261 EXPECT_FALSE(task_runner->HasPendingTask()); | 245 EXPECT_FALSE(task_runner->HasPendingTask()); |
| 262 EXPECT_EQ(client.begin_frame_count(), 4); | 246 EXPECT_EQ(client.begin_frame_count(), 4); |
| 263 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); | 247 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); |
| 264 } | 248 } |
| 265 | 249 |
| 266 TEST(OutputSurfaceTest, OptimisticAndRetroactiveBeginFrames) { | 250 TEST(OutputSurfaceTest, OptimisticAndRetroactiveBeginFrames) { |
| 267 scoped_ptr<TestWebGraphicsContext3D> context3d = | 251 TestOutputSurface output_surface(TestContextProvider::Create()); |
| 268 TestWebGraphicsContext3D::Create(); | 252 EXPECT_FALSE(output_surface.HasClient()); |
| 269 | |
| 270 TestOutputSurface output_surface( | |
| 271 context3d.PassAs<WebKit::WebGraphicsContext3D>()); | |
| 272 EXPECT_FALSE(output_surface.HasClientForTesting()); | |
| 273 | 253 |
| 274 FakeOutputSurfaceClient client; | 254 FakeOutputSurfaceClient client; |
| 275 EXPECT_TRUE(output_surface.BindToClient(&client)); | 255 EXPECT_TRUE(output_surface.BindToClient(&client)); |
| 276 EXPECT_TRUE(output_surface.HasClientForTesting()); | 256 EXPECT_TRUE(output_surface.HasClient()); |
| 277 EXPECT_FALSE(client.deferred_initialize_called()); | 257 EXPECT_FALSE(client.deferred_initialize_called()); |
| 278 | 258 |
| 279 output_surface.SetMaxFramesPending(2); | 259 output_surface.SetMaxFramesPending(2); |
| 280 | 260 |
| 281 // Enable retroactive BeginFrames. | 261 // Enable retroactive BeginFrames. |
| 282 output_surface.SetRetroactiveBeginFramePeriod( | 262 output_surface.SetRetroactiveBeginFramePeriod( |
| 283 base::TimeDelta::FromSeconds(100000)); | 263 base::TimeDelta::FromSeconds(100000)); |
| 284 | 264 |
| 285 // Optimistically injected BeginFrames should be throttled if | 265 // Optimistically injected BeginFrames should be throttled if |
| 286 // SetNeedsBeginFrame is false... | 266 // SetNeedsBeginFrame is false... |
| (...skipping 24 matching lines...) Expand all Loading... |
| 311 EXPECT_EQ(client.begin_frame_count(), 3); | 291 EXPECT_EQ(client.begin_frame_count(), 3); |
| 312 EXPECT_EQ(output_surface.pending_swap_buffers(), 2); | 292 EXPECT_EQ(output_surface.pending_swap_buffers(), 2); |
| 313 output_surface.BeginFrameForTesting(); | 293 output_surface.BeginFrameForTesting(); |
| 314 EXPECT_EQ(client.begin_frame_count(), 3); | 294 EXPECT_EQ(client.begin_frame_count(), 3); |
| 315 // ...and retroactively triggered by OnSwapBuffersComplete | 295 // ...and retroactively triggered by OnSwapBuffersComplete |
| 316 output_surface.OnSwapBuffersCompleteForTesting(); | 296 output_surface.OnSwapBuffersCompleteForTesting(); |
| 317 EXPECT_EQ(client.begin_frame_count(), 4); | 297 EXPECT_EQ(client.begin_frame_count(), 4); |
| 318 } | 298 } |
| 319 | 299 |
| 320 TEST(OutputSurfaceTest, MemoryAllocation) { | 300 TEST(OutputSurfaceTest, MemoryAllocation) { |
| 321 scoped_ptr<TestWebGraphicsContext3D> scoped_context = | 301 scoped_refptr<TestContextProvider> context_provider = |
| 322 TestWebGraphicsContext3D::Create(); | 302 TestContextProvider::Create(); |
| 323 TestWebGraphicsContext3D* context = scoped_context.get(); | |
| 324 | 303 |
| 325 TestOutputSurface output_surface( | 304 TestOutputSurface output_surface(context_provider); |
| 326 scoped_context.PassAs<WebKit::WebGraphicsContext3D>()); | |
| 327 | 305 |
| 328 FakeOutputSurfaceClient client; | 306 FakeOutputSurfaceClient client; |
| 329 EXPECT_TRUE(output_surface.BindToClient(&client)); | 307 EXPECT_TRUE(output_surface.BindToClient(&client)); |
| 330 | 308 |
| 331 WebGraphicsMemoryAllocation allocation; | 309 ManagedMemoryPolicy policy(0); |
| 332 allocation.suggestHaveBackbuffer = true; | 310 policy.bytes_limit_when_visible = 1234; |
| 333 allocation.bytesLimitWhenVisible = 1234; | 311 policy.priority_cutoff_when_visible = |
| 334 allocation.priorityCutoffWhenVisible = | 312 ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY; |
| 335 WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly; | 313 policy.bytes_limit_when_not_visible = 4567; |
| 336 allocation.bytesLimitWhenNotVisible = 4567; | 314 policy.priority_cutoff_when_not_visible = |
| 337 allocation.priorityCutoffWhenNotVisible = | 315 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; |
| 338 WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing; | |
| 339 | 316 |
| 340 context->SetMemoryAllocation(allocation); | 317 bool discard_backbuffer_when_not_visible = false; |
| 341 | 318 |
| 319 context_provider->SetMemoryAllocation(policy, |
| 320 discard_backbuffer_when_not_visible); |
| 342 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible); | 321 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible); |
| 343 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY, | 322 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY, |
| 344 client.memory_policy().priority_cutoff_when_visible); | 323 client.memory_policy().priority_cutoff_when_visible); |
| 345 EXPECT_EQ(4567u, client.memory_policy().bytes_limit_when_not_visible); | 324 EXPECT_EQ(4567u, client.memory_policy().bytes_limit_when_not_visible); |
| 346 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING, | 325 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING, |
| 347 client.memory_policy().priority_cutoff_when_not_visible); | 326 client.memory_policy().priority_cutoff_when_not_visible); |
| 348 EXPECT_FALSE(client.discard_backbuffer_when_not_visible()); | 327 EXPECT_FALSE(client.discard_backbuffer_when_not_visible()); |
| 349 | 328 |
| 350 allocation.suggestHaveBackbuffer = false; | 329 discard_backbuffer_when_not_visible = true; |
| 351 context->SetMemoryAllocation(allocation); | 330 context_provider->SetMemoryAllocation(policy, |
| 331 discard_backbuffer_when_not_visible); |
| 352 EXPECT_TRUE(client.discard_backbuffer_when_not_visible()); | 332 EXPECT_TRUE(client.discard_backbuffer_when_not_visible()); |
| 353 | 333 |
| 354 allocation.priorityCutoffWhenVisible = | 334 policy.priority_cutoff_when_visible = |
| 355 WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything; | 335 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING; |
| 356 allocation.priorityCutoffWhenNotVisible = | 336 policy.priority_cutoff_when_not_visible = |
| 357 WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearby; | 337 ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE; |
| 358 context->SetMemoryAllocation(allocation); | 338 context_provider->SetMemoryAllocation(policy, |
| 339 discard_backbuffer_when_not_visible); |
| 359 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, | 340 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, |
| 360 client.memory_policy().priority_cutoff_when_visible); | 341 client.memory_policy().priority_cutoff_when_visible); |
| 361 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE, | 342 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE, |
| 362 client.memory_policy().priority_cutoff_when_not_visible); | 343 client.memory_policy().priority_cutoff_when_not_visible); |
| 363 | 344 |
| 364 // 0 bytes limit should be ignored. | 345 // 0 bytes limit should be ignored. |
| 365 allocation.bytesLimitWhenVisible = 0; | 346 policy.bytes_limit_when_visible = 0; |
| 366 context->SetMemoryAllocation(allocation); | 347 context_provider->SetMemoryAllocation(policy, |
| 348 discard_backbuffer_when_not_visible); |
| 367 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible); | 349 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible); |
| 368 } | 350 } |
| 369 | 351 |
| 370 } // namespace | 352 } // namespace |
| 371 } // namespace cc | 353 } // namespace cc |
| OLD | NEW |