Chromium Code Reviews| 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/output/managed_memory_policy.h" | 8 #include "cc/output/managed_memory_policy.h" |
| 9 #include "cc/output/output_surface_client.h" | 9 #include "cc/output/output_surface_client.h" |
| 10 #include "cc/output/software_output_device.h" | 10 #include "cc/output/software_output_device.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 TestOutputSurface output_surface(context_provider); | 159 TestOutputSurface output_surface(context_provider); |
| 160 | 160 |
| 161 FakeOutputSurfaceClient client; | 161 FakeOutputSurfaceClient client; |
| 162 EXPECT_TRUE(output_surface.BindToClient(&client)); | 162 EXPECT_TRUE(output_surface.BindToClient(&client)); |
| 163 | 163 |
| 164 ManagedMemoryPolicy policy(0); | 164 ManagedMemoryPolicy policy(0); |
| 165 policy.bytes_limit_when_visible = 1234; | 165 policy.bytes_limit_when_visible = 1234; |
| 166 policy.priority_cutoff_when_visible = | 166 policy.priority_cutoff_when_visible = |
| 167 gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY; | 167 gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY; |
| 168 | 168 |
| 169 context_provider->SetMemoryAllocation(policy); | |
|
piman
2015/09/28 18:32:38
I assume the test will need to be updated to pass,
sohanjg
2015/09/29 14:19:26
Done.
| |
| 170 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible); | 169 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible); |
| 171 EXPECT_EQ(gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY, | 170 EXPECT_EQ(gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY, |
| 172 client.memory_policy().priority_cutoff_when_visible); | 171 client.memory_policy().priority_cutoff_when_visible); |
| 173 | 172 |
| 174 policy.priority_cutoff_when_visible = | 173 policy.priority_cutoff_when_visible = |
| 175 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING; | 174 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING; |
| 176 context_provider->SetMemoryAllocation(policy); | |
| 177 EXPECT_EQ(gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, | 175 EXPECT_EQ(gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, |
| 178 client.memory_policy().priority_cutoff_when_visible); | 176 client.memory_policy().priority_cutoff_when_visible); |
| 179 | 177 |
| 180 // 0 bytes limit should be ignored. | 178 // 0 bytes limit should be ignored. |
| 181 policy.bytes_limit_when_visible = 0; | 179 policy.bytes_limit_when_visible = 0; |
| 182 context_provider->SetMemoryAllocation(policy); | |
| 183 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible); | 180 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible); |
| 184 } | 181 } |
| 185 | 182 |
| 186 TEST(OutputSurfaceTest, SoftwareOutputDeviceBackbufferManagement) { | 183 TEST(OutputSurfaceTest, SoftwareOutputDeviceBackbufferManagement) { |
| 187 TestSoftwareOutputDevice* software_output_device = | 184 TestSoftwareOutputDevice* software_output_device = |
| 188 new TestSoftwareOutputDevice(); | 185 new TestSoftwareOutputDevice(); |
| 189 | 186 |
| 190 // TestOutputSurface now owns software_output_device and has responsibility to | 187 // TestOutputSurface now owns software_output_device and has responsibility to |
| 191 // free it. | 188 // free it. |
| 192 TestOutputSurface output_surface(make_scoped_ptr(software_output_device)); | 189 TestOutputSurface output_surface(make_scoped_ptr(software_output_device)); |
| 193 | 190 |
| 194 EXPECT_EQ(0, software_output_device->ensure_backbuffer_count()); | 191 EXPECT_EQ(0, software_output_device->ensure_backbuffer_count()); |
| 195 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); | 192 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); |
| 196 | 193 |
| 197 output_surface.EnsureBackbuffer(); | 194 output_surface.EnsureBackbuffer(); |
| 198 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); | 195 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); |
| 199 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); | 196 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); |
| 200 output_surface.DiscardBackbuffer(); | 197 output_surface.DiscardBackbuffer(); |
| 201 | 198 |
| 202 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); | 199 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); |
| 203 EXPECT_EQ(1, software_output_device->discard_backbuffer_count()); | 200 EXPECT_EQ(1, software_output_device->discard_backbuffer_count()); |
| 204 } | 201 } |
| 205 | 202 |
| 206 } // namespace | 203 } // namespace |
| 207 } // namespace cc | 204 } // namespace cc |
| OLD | NEW |