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

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

Issue 1412923004: Revert of Move gpu memory calculations to Compositor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 1 month 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
« no previous file with comments | « cc/output/output_surface.cc ('k') | cc/raster/tile_task_worker_pool_perftest.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/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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 worker_context_provider->UnboundTestContext3d()->set_context_lost(true); 145 worker_context_provider->UnboundTestContext3d()->set_context_lost(true);
146 146
147 TestOutputSurface output_surface(context_provider, worker_context_provider); 147 TestOutputSurface output_surface(context_provider, worker_context_provider);
148 EXPECT_FALSE(output_surface.HasClient()); 148 EXPECT_FALSE(output_surface.HasClient());
149 149
150 FakeOutputSurfaceClient client; 150 FakeOutputSurfaceClient client;
151 EXPECT_FALSE(output_surface.BindToClient(&client)); 151 EXPECT_FALSE(output_surface.BindToClient(&client));
152 EXPECT_FALSE(output_surface.HasClient()); 152 EXPECT_FALSE(output_surface.HasClient());
153 } 153 }
154 154
155 TEST(OutputSurfaceTest, MemoryAllocation) {
156 scoped_refptr<TestContextProvider> context_provider =
157 TestContextProvider::Create();
158
159 TestOutputSurface output_surface(context_provider);
160
161 FakeOutputSurfaceClient client;
162 EXPECT_TRUE(output_surface.BindToClient(&client));
163
164 ManagedMemoryPolicy policy(0);
165 policy.bytes_limit_when_visible = 1234;
166 policy.priority_cutoff_when_visible =
167 gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY;
168
169 context_provider->SetMemoryAllocation(policy);
170 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible);
171 EXPECT_EQ(gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY,
172 client.memory_policy().priority_cutoff_when_visible);
173
174 policy.priority_cutoff_when_visible =
175 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING;
176 context_provider->SetMemoryAllocation(policy);
177 EXPECT_EQ(gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING,
178 client.memory_policy().priority_cutoff_when_visible);
179
180 // 0 bytes limit should be ignored.
181 policy.bytes_limit_when_visible = 0;
182 context_provider->SetMemoryAllocation(policy);
183 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible);
184 }
185
155 TEST(OutputSurfaceTest, SoftwareOutputDeviceBackbufferManagement) { 186 TEST(OutputSurfaceTest, SoftwareOutputDeviceBackbufferManagement) {
156 TestSoftwareOutputDevice* software_output_device = 187 TestSoftwareOutputDevice* software_output_device =
157 new TestSoftwareOutputDevice(); 188 new TestSoftwareOutputDevice();
158 189
159 // TestOutputSurface now owns software_output_device and has responsibility to 190 // TestOutputSurface now owns software_output_device and has responsibility to
160 // free it. 191 // free it.
161 TestOutputSurface output_surface(make_scoped_ptr(software_output_device)); 192 TestOutputSurface output_surface(make_scoped_ptr(software_output_device));
162 193
163 EXPECT_EQ(0, software_output_device->ensure_backbuffer_count()); 194 EXPECT_EQ(0, software_output_device->ensure_backbuffer_count());
164 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); 195 EXPECT_EQ(0, software_output_device->discard_backbuffer_count());
165 196
166 output_surface.EnsureBackbuffer(); 197 output_surface.EnsureBackbuffer();
167 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); 198 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count());
168 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); 199 EXPECT_EQ(0, software_output_device->discard_backbuffer_count());
169 output_surface.DiscardBackbuffer(); 200 output_surface.DiscardBackbuffer();
170 201
171 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); 202 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count());
172 EXPECT_EQ(1, software_output_device->discard_backbuffer_count()); 203 EXPECT_EQ(1, software_output_device->discard_backbuffer_count());
173 } 204 }
174 205
175 } // namespace 206 } // namespace
176 } // namespace cc 207 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/output_surface.cc ('k') | cc/raster/tile_task_worker_pool_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698