Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(640)

Side by Side Diff: cc/output/output_surface_unittest.cc

Issue 20185002: ContextProvider in OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: contextprovider: don't access Context3d() in OutputSurface contructors, it's not bound yet Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/output/output_surface.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
78 } 72 }
79 73
80 virtual base::TimeDelta AlternateRetroactiveBeginFramePeriod() OVERRIDE { 74 virtual base::TimeDelta AlternateRetroactiveBeginFramePeriod() OVERRIDE {
81 return alternate_retroactive_begin_frame_period_; 75 return alternate_retroactive_begin_frame_period_;
82 } 76 }
83 77
84 base::TimeDelta alternate_retroactive_begin_frame_period_; 78 base::TimeDelta alternate_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
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.SetAlternateRetroactiveBeginFramePeriod( 262 output_surface.SetAlternateRetroactiveBeginFramePeriod(
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
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, RetroactiveBeginFrameDoesNotDoubleTickWhenEmulating) { 300 TEST(OutputSurfaceTest, RetroactiveBeginFrameDoesNotDoubleTickWhenEmulating) {
321 scoped_ptr<TestWebGraphicsContext3D> context3d = 301 scoped_refptr<TestContextProvider> context_provider =
322 TestWebGraphicsContext3D::Create(); 302 TestContextProvider::Create();
323 303
324 TestOutputSurface output_surface( 304 TestOutputSurface output_surface(context_provider);
325 context3d.PassAs<WebKit::WebGraphicsContext3D>()); 305 EXPECT_FALSE(output_surface.HasClient());
326 EXPECT_FALSE(output_surface.HasClientForTesting());
327 306
328 FakeOutputSurfaceClient client; 307 FakeOutputSurfaceClient client;
329 EXPECT_TRUE(output_surface.BindToClient(&client)); 308 EXPECT_TRUE(output_surface.BindToClient(&client));
330 EXPECT_TRUE(output_surface.HasClientForTesting()); 309 EXPECT_TRUE(output_surface.HasClient());
331 EXPECT_FALSE(client.deferred_initialize_called()); 310 EXPECT_FALSE(client.deferred_initialize_called());
332 311
333 base::TimeDelta big_interval = base::TimeDelta::FromSeconds(1000); 312 base::TimeDelta big_interval = base::TimeDelta::FromSeconds(1000);
334 313
335 // Initialize BeginFrame emulation 314 // Initialize BeginFrame emulation
336 scoped_refptr<base::TestSimpleTaskRunner> task_runner = 315 scoped_refptr<base::TestSimpleTaskRunner> task_runner =
337 new base::TestSimpleTaskRunner; 316 new base::TestSimpleTaskRunner;
338 bool throttle_frame_production = true; 317 bool throttle_frame_production = true;
339 const base::TimeDelta display_refresh_interval = big_interval; 318 const base::TimeDelta display_refresh_interval = big_interval;
340 319
(...skipping 27 matching lines...) Expand all
368 EXPECT_EQ(client.begin_frame_count(), 1); 347 EXPECT_EQ(client.begin_frame_count(), 1);
369 348
370 // The second SetNeedBeginFrame(true) should not retroactively start a 349 // The second SetNeedBeginFrame(true) should not retroactively start a
371 // BeginFrame if the timestamp would be the same as the previous BeginFrame. 350 // BeginFrame if the timestamp would be the same as the previous BeginFrame.
372 output_surface.SetNeedsBeginFrame(true); 351 output_surface.SetNeedsBeginFrame(true);
373 EXPECT_TRUE(task_runner->HasPendingTask()); 352 EXPECT_TRUE(task_runner->HasPendingTask());
374 EXPECT_EQ(client.begin_frame_count(), 1); 353 EXPECT_EQ(client.begin_frame_count(), 1);
375 } 354 }
376 355
377 TEST(OutputSurfaceTest, MemoryAllocation) { 356 TEST(OutputSurfaceTest, MemoryAllocation) {
378 scoped_ptr<TestWebGraphicsContext3D> scoped_context = 357 scoped_refptr<TestContextProvider> context_provider =
379 TestWebGraphicsContext3D::Create(); 358 TestContextProvider::Create();
380 TestWebGraphicsContext3D* context = scoped_context.get();
381 359
382 TestOutputSurface output_surface( 360 TestOutputSurface output_surface(context_provider);
383 scoped_context.PassAs<WebKit::WebGraphicsContext3D>());
384 361
385 FakeOutputSurfaceClient client; 362 FakeOutputSurfaceClient client;
386 EXPECT_TRUE(output_surface.BindToClient(&client)); 363 EXPECT_TRUE(output_surface.BindToClient(&client));
387 364
388 WebGraphicsMemoryAllocation allocation; 365 ManagedMemoryPolicy policy(0);
389 allocation.suggestHaveBackbuffer = true; 366 policy.bytes_limit_when_visible = 1234;
390 allocation.bytesLimitWhenVisible = 1234; 367 policy.priority_cutoff_when_visible =
391 allocation.priorityCutoffWhenVisible = 368 ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY;
392 WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleOnly; 369 policy.bytes_limit_when_not_visible = 4567;
393 allocation.bytesLimitWhenNotVisible = 4567; 370 policy.priority_cutoff_when_not_visible =
394 allocation.priorityCutoffWhenNotVisible = 371 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING;
395 WebGraphicsMemoryAllocation::PriorityCutoffAllowNothing;
396 372
397 context->SetMemoryAllocation(allocation); 373 bool discard_backbuffer_when_not_visible = false;
398 374
375 context_provider->SetMemoryAllocation(policy,
376 discard_backbuffer_when_not_visible);
399 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible); 377 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible);
400 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY, 378 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY,
401 client.memory_policy().priority_cutoff_when_visible); 379 client.memory_policy().priority_cutoff_when_visible);
402 EXPECT_EQ(4567u, client.memory_policy().bytes_limit_when_not_visible); 380 EXPECT_EQ(4567u, client.memory_policy().bytes_limit_when_not_visible);
403 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING, 381 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING,
404 client.memory_policy().priority_cutoff_when_not_visible); 382 client.memory_policy().priority_cutoff_when_not_visible);
405 EXPECT_FALSE(client.discard_backbuffer_when_not_visible()); 383 EXPECT_FALSE(client.discard_backbuffer_when_not_visible());
406 384
407 allocation.suggestHaveBackbuffer = false; 385 discard_backbuffer_when_not_visible = true;
408 context->SetMemoryAllocation(allocation); 386 context_provider->SetMemoryAllocation(policy,
387 discard_backbuffer_when_not_visible);
409 EXPECT_TRUE(client.discard_backbuffer_when_not_visible()); 388 EXPECT_TRUE(client.discard_backbuffer_when_not_visible());
410 389
411 allocation.priorityCutoffWhenVisible = 390 policy.priority_cutoff_when_visible =
412 WebGraphicsMemoryAllocation::PriorityCutoffAllowEverything; 391 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING;
413 allocation.priorityCutoffWhenNotVisible = 392 policy.priority_cutoff_when_not_visible =
414 WebGraphicsMemoryAllocation::PriorityCutoffAllowVisibleAndNearby; 393 ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE;
415 context->SetMemoryAllocation(allocation); 394 context_provider->SetMemoryAllocation(policy,
395 discard_backbuffer_when_not_visible);
416 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, 396 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING,
417 client.memory_policy().priority_cutoff_when_visible); 397 client.memory_policy().priority_cutoff_when_visible);
418 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE, 398 EXPECT_EQ(ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE,
419 client.memory_policy().priority_cutoff_when_not_visible); 399 client.memory_policy().priority_cutoff_when_not_visible);
420 400
421 // 0 bytes limit should be ignored. 401 // 0 bytes limit should be ignored.
422 allocation.bytesLimitWhenVisible = 0; 402 policy.bytes_limit_when_visible = 0;
423 context->SetMemoryAllocation(allocation); 403 context_provider->SetMemoryAllocation(policy,
404 discard_backbuffer_when_not_visible);
424 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible); 405 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible);
425 } 406 }
426 407
427 } // namespace 408 } // namespace
428 } // namespace cc 409 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/output_surface.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698