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

Side by Side Diff: content/common/gpu/gpu_memory_manager_unittest.cc

Issue 10083056: GpuMemoryManager suggests values for renderer Contents Texture Managers' preferred memory limit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Making allocations clearer to read, and changing the distribution to include canvas/webgl etc. Created 8 years, 8 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 | « content/common/gpu/gpu_memory_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/common/gpu/gpu_command_buffer_stub.h" 5 #include "content/common/gpu/gpu_command_buffer_stub.h"
6 #include "content/common/gpu/gpu_memory_allocation.h" 6 #include "content/common/gpu/gpu_memory_allocation.h"
7 #include "content/common/gpu/gpu_memory_manager.h" 7 #include "content/common/gpu/gpu_memory_manager.h"
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false); 191 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false);
192 192
193 // Test stubs without surface, with share group of 1 stub. 193 // Test stubs without surface, with share group of 1 stub.
194 FakeCommandBufferStubWithoutSurface stub3, stub4; 194 FakeCommandBufferStubWithoutSurface stub3, stub4;
195 stub3.share_group_.push_back(&stub1); 195 stub3.share_group_.push_back(&stub1);
196 stub4.share_group_.push_back(&stub2); 196 stub4.share_group_.push_back(&stub2);
197 client_.stubs_.push_back(&stub3); 197 client_.stubs_.push_back(&stub3);
198 client_.stubs_.push_back(&stub4); 198 client_.stubs_.push_back(&stub4);
199 199
200 Manage(); 200 Manage();
201 EXPECT_EQ(stub1.allocation_, stub3.allocation_); 201 EXPECT_GT(stub1.allocation_.gpu_resource_size_in_bytes, 1ul);
mmocny 2012/04/20 18:47:30 I am already working on making it clearer why and
202 EXPECT_EQ(stub2.allocation_, stub4.allocation_); 202 EXPECT_EQ(stub2.allocation_.gpu_resource_size_in_bytes, 0ul);
203 EXPECT_GT(stub3.allocation_.gpu_resource_size_in_bytes, 1ul);
204 EXPECT_EQ(stub4.allocation_.gpu_resource_size_in_bytes, 1ul);
203 205
204 // Test stub without surface, with share group of multiple stubs. 206 // Test stub without surface, with share group of multiple stubs.
205 FakeCommandBufferStubWithoutSurface stub5; 207 FakeCommandBufferStubWithoutSurface stub5;
206 stub5.share_group_.push_back(&stub1); 208 stub5.share_group_.push_back(&stub1);
207 stub5.share_group_.push_back(&stub2); 209 stub5.share_group_.push_back(&stub2);
208 client_.stubs_.push_back(&stub5); 210 client_.stubs_.push_back(&stub5);
209 211
210 Manage(); 212 Manage();
211 EXPECT_EQ(stub1.allocation_, stub5.allocation_); 213 EXPECT_GT(stub5.allocation_.gpu_resource_size_in_bytes, 1ul);
212 } 214 }
213 215
214 // Test GpuMemoryManager::Manage functionality: changing visibility. 216 // Test GpuMemoryManager::Manage functionality: changing visibility.
215 // Expect memory allocation to set suggest_have_frontbuffer/backbuffer according 217 // Expect memory allocation to set suggest_have_frontbuffer/backbuffer according
216 // to visibility and last used time for stubs with surface. 218 // to visibility and last used time for stubs with surface.
217 // Expect memory allocation to be shared according to share groups for stubs 219 // Expect memory allocation to be shared according to share groups for stubs
218 // without a surface. 220 // without a surface.
219 TEST_F(GpuMemoryManagerTest, TestManageChangingVisibility) { 221 TEST_F(GpuMemoryManagerTest, TestManageChangingVisibility) {
220 FakeCommandBufferStub stub1(GenerateUniqueSurfaceId(), true, older_), 222 FakeCommandBufferStub stub1(GenerateUniqueSurfaceId(), true, older_),
221 stub2(GenerateUniqueSurfaceId(), false, older_); 223 stub2(GenerateUniqueSurfaceId(), false, older_);
222 client_.stubs_.push_back(&stub1); 224 client_.stubs_.push_back(&stub1);
223 client_.stubs_.push_back(&stub2); 225 client_.stubs_.push_back(&stub2);
224 226
225 FakeCommandBufferStubWithoutSurface stub3, stub4; 227 FakeCommandBufferStubWithoutSurface stub3, stub4;
226 stub3.share_group_.push_back(&stub1); 228 stub3.share_group_.push_back(&stub1);
227 stub4.share_group_.push_back(&stub2); 229 stub4.share_group_.push_back(&stub2);
228 client_.stubs_.push_back(&stub3); 230 client_.stubs_.push_back(&stub3);
229 client_.stubs_.push_back(&stub4); 231 client_.stubs_.push_back(&stub4);
230 232
231 FakeCommandBufferStubWithoutSurface stub5; 233 FakeCommandBufferStubWithoutSurface stub5;
232 stub5.share_group_.push_back(&stub1); 234 stub5.share_group_.push_back(&stub1);
233 stub5.share_group_.push_back(&stub2); 235 stub5.share_group_.push_back(&stub2);
234 client_.stubs_.push_back(&stub5); 236 client_.stubs_.push_back(&stub5);
235 237
236 Manage(); 238 Manage();
237 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, true); 239 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, true);
238 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, true); 240 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, true);
239 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true); 241 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true);
240 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false); 242 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false);
241 EXPECT_EQ(stub1.allocation_, stub3.allocation_); 243 EXPECT_GT(stub1.allocation_.gpu_resource_size_in_bytes, 1ul);
242 EXPECT_EQ(stub2.allocation_, stub4.allocation_); 244 EXPECT_EQ(stub2.allocation_.gpu_resource_size_in_bytes, 0ul);
243 EXPECT_EQ(stub1.allocation_, stub5.allocation_); 245 EXPECT_GT(stub3.allocation_.gpu_resource_size_in_bytes, 1ul);
246 EXPECT_EQ(stub4.allocation_.gpu_resource_size_in_bytes, 1ul);
247 EXPECT_GT(stub5.allocation_.gpu_resource_size_in_bytes, 1ul);
244 248
245 stub1.surface_state_.visible = false; 249 stub1.surface_state_.visible = false;
246 stub2.surface_state_.visible = true; 250 stub2.surface_state_.visible = true;
247 251
248 Manage(); 252 Manage();
249 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, true); 253 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, true);
250 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false); 254 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false);
251 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true); 255 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true);
252 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, true); 256 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, true);
253 EXPECT_EQ(stub1.allocation_, stub3.allocation_); 257 EXPECT_EQ(stub1.allocation_.gpu_resource_size_in_bytes, 0ul);
254 EXPECT_EQ(stub2.allocation_, stub4.allocation_); 258 EXPECT_GT(stub2.allocation_.gpu_resource_size_in_bytes, 1ul);
255 EXPECT_EQ(stub2.allocation_, stub5.allocation_); 259 EXPECT_EQ(stub3.allocation_.gpu_resource_size_in_bytes, 1ul);
260 EXPECT_GT(stub4.allocation_.gpu_resource_size_in_bytes, 1ul);
261 EXPECT_GT(stub5.allocation_.gpu_resource_size_in_bytes, 1ul);
256 } 262 }
257 263
258 // Test GpuMemoryManager::Manage functionality: Test more than threshold number 264 // Test GpuMemoryManager::Manage functionality: Test more than threshold number
259 // of visible stubs. 265 // of visible stubs.
260 // Expect all allocations to continue to have frontbuffer. 266 // Expect all allocations to continue to have frontbuffer.
261 TEST_F(GpuMemoryManagerTest, TestManageManyVisibleStubs) { 267 TEST_F(GpuMemoryManagerTest, TestManageManyVisibleStubs) {
262 FakeCommandBufferStub stub1(GenerateUniqueSurfaceId(), true, older_), 268 FakeCommandBufferStub stub1(GenerateUniqueSurfaceId(), true, older_),
263 stub2(GenerateUniqueSurfaceId(), true, older_), 269 stub2(GenerateUniqueSurfaceId(), true, older_),
264 stub3(GenerateUniqueSurfaceId(), true, older_), 270 stub3(GenerateUniqueSurfaceId(), true, older_),
265 stub4(GenerateUniqueSurfaceId(), true, older_); 271 stub4(GenerateUniqueSurfaceId(), true, older_);
(...skipping 15 matching lines...) Expand all
281 287
282 Manage(); 288 Manage();
283 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, true); 289 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, true);
284 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, true); 290 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, true);
285 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true); 291 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true);
286 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, true); 292 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, true);
287 EXPECT_EQ(stub3.allocation_.suggest_have_frontbuffer, true); 293 EXPECT_EQ(stub3.allocation_.suggest_have_frontbuffer, true);
288 EXPECT_EQ(stub3.allocation_.suggest_have_backbuffer, true); 294 EXPECT_EQ(stub3.allocation_.suggest_have_backbuffer, true);
289 EXPECT_EQ(stub4.allocation_.suggest_have_frontbuffer, true); 295 EXPECT_EQ(stub4.allocation_.suggest_have_frontbuffer, true);
290 EXPECT_EQ(stub4.allocation_.suggest_have_backbuffer, true); 296 EXPECT_EQ(stub4.allocation_.suggest_have_backbuffer, true);
291 EXPECT_EQ(stub5.allocation_, stub1.allocation_); 297 EXPECT_GT(stub5.allocation_.gpu_resource_size_in_bytes, 1ul);
292 EXPECT_EQ(stub6.allocation_, stub2.allocation_); 298 EXPECT_GT(stub6.allocation_.gpu_resource_size_in_bytes, 1ul);
293 EXPECT_EQ(stub7.allocation_, stub1.allocation_); 299 EXPECT_GT(stub7.allocation_.gpu_resource_size_in_bytes, 1ul);
294 } 300 }
295 301
296 // Test GpuMemoryManager::Manage functionality: Test more than threshold number 302 // Test GpuMemoryManager::Manage functionality: Test more than threshold number
297 // of not visible stubs. 303 // of not visible stubs.
298 // Expect the stubs surpassing the threshold to not have a backbuffer. 304 // Expect the stubs surpassing the threshold to not have a backbuffer.
299 TEST_F(GpuMemoryManagerTest, TestManageManyNotVisibleStubs) { 305 TEST_F(GpuMemoryManagerTest, TestManageManyNotVisibleStubs) {
300 FakeCommandBufferStub stub1(GenerateUniqueSurfaceId(), false, newer_), 306 FakeCommandBufferStub stub1(GenerateUniqueSurfaceId(), false, newer_),
301 stub2(GenerateUniqueSurfaceId(), false, newer_), 307 stub2(GenerateUniqueSurfaceId(), false, newer_),
302 stub3(GenerateUniqueSurfaceId(), false, newer_), 308 stub3(GenerateUniqueSurfaceId(), false, newer_),
303 stub4(GenerateUniqueSurfaceId(), false, older_); 309 stub4(GenerateUniqueSurfaceId(), false, older_);
(...skipping 15 matching lines...) Expand all
319 325
320 Manage(); 326 Manage();
321 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, true); 327 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, true);
322 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false); 328 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false);
323 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true); 329 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true);
324 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false); 330 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false);
325 EXPECT_EQ(stub3.allocation_.suggest_have_frontbuffer, true); 331 EXPECT_EQ(stub3.allocation_.suggest_have_frontbuffer, true);
326 EXPECT_EQ(stub3.allocation_.suggest_have_backbuffer, false); 332 EXPECT_EQ(stub3.allocation_.suggest_have_backbuffer, false);
327 EXPECT_EQ(stub4.allocation_.suggest_have_frontbuffer, false); 333 EXPECT_EQ(stub4.allocation_.suggest_have_frontbuffer, false);
328 EXPECT_EQ(stub4.allocation_.suggest_have_backbuffer, false); 334 EXPECT_EQ(stub4.allocation_.suggest_have_backbuffer, false);
329 EXPECT_EQ(stub5.allocation_, stub1.allocation_); 335 EXPECT_EQ(stub5.allocation_.gpu_resource_size_in_bytes, 1ul);
330 EXPECT_EQ(stub6.allocation_, stub4.allocation_); 336 EXPECT_EQ(stub6.allocation_.gpu_resource_size_in_bytes, 0ul);
331 EXPECT_EQ(stub7.allocation_, stub1.allocation_); 337 EXPECT_EQ(stub7.allocation_.gpu_resource_size_in_bytes, 1ul);
332 } 338 }
333 339
334 // Test GpuMemoryManager::Manage functionality: Test changing the last used 340 // Test GpuMemoryManager::Manage functionality: Test changing the last used
335 // time of stubs when doing so causes change in which stubs surpass threshold. 341 // time of stubs when doing so causes change in which stubs surpass threshold.
336 // Expect frontbuffer to be dropped for the older stub. 342 // Expect frontbuffer to be dropped for the older stub.
337 TEST_F(GpuMemoryManagerTest, TestManageChangingLastUsedTime) { 343 TEST_F(GpuMemoryManagerTest, TestManageChangingLastUsedTime) {
338 FakeCommandBufferStub stub1(GenerateUniqueSurfaceId(), false, newer_), 344 FakeCommandBufferStub stub1(GenerateUniqueSurfaceId(), false, newer_),
339 stub2(GenerateUniqueSurfaceId(), false, newer_), 345 stub2(GenerateUniqueSurfaceId(), false, newer_),
340 stub3(GenerateUniqueSurfaceId(), false, newer_), 346 stub3(GenerateUniqueSurfaceId(), false, newer_),
341 stub4(GenerateUniqueSurfaceId(), false, older_); 347 stub4(GenerateUniqueSurfaceId(), false, older_);
(...skipping 11 matching lines...) Expand all
353 FakeCommandBufferStubWithoutSurface stub7; 359 FakeCommandBufferStubWithoutSurface stub7;
354 stub7.share_group_.push_back(&stub3); 360 stub7.share_group_.push_back(&stub3);
355 stub7.share_group_.push_back(&stub4); 361 stub7.share_group_.push_back(&stub4);
356 client_.stubs_.push_back(&stub7); 362 client_.stubs_.push_back(&stub7);
357 363
358 Manage(); 364 Manage();
359 EXPECT_EQ(stub3.allocation_.suggest_have_frontbuffer, true); 365 EXPECT_EQ(stub3.allocation_.suggest_have_frontbuffer, true);
360 EXPECT_EQ(stub3.allocation_.suggest_have_backbuffer, false); 366 EXPECT_EQ(stub3.allocation_.suggest_have_backbuffer, false);
361 EXPECT_EQ(stub4.allocation_.suggest_have_frontbuffer, false); 367 EXPECT_EQ(stub4.allocation_.suggest_have_frontbuffer, false);
362 EXPECT_EQ(stub4.allocation_.suggest_have_backbuffer, false); 368 EXPECT_EQ(stub4.allocation_.suggest_have_backbuffer, false);
363 EXPECT_EQ(stub5.allocation_, stub3.allocation_); 369 EXPECT_EQ(stub5.allocation_.gpu_resource_size_in_bytes, 1ul);
364 EXPECT_EQ(stub6.allocation_, stub4.allocation_); 370 EXPECT_EQ(stub6.allocation_.gpu_resource_size_in_bytes, 0ul);
365 EXPECT_EQ(stub7.allocation_, stub3.allocation_); 371 EXPECT_EQ(stub7.allocation_.gpu_resource_size_in_bytes, 1ul);
366 372
367 stub3.surface_state_.last_used_time = older_; 373 stub3.surface_state_.last_used_time = older_;
368 stub4.surface_state_.last_used_time = newer_; 374 stub4.surface_state_.last_used_time = newer_;
369 375
370 Manage(); 376 Manage();
371 EXPECT_EQ(stub3.allocation_.suggest_have_frontbuffer, false); 377 EXPECT_EQ(stub3.allocation_.suggest_have_frontbuffer, false);
372 EXPECT_EQ(stub3.allocation_.suggest_have_backbuffer, false); 378 EXPECT_EQ(stub3.allocation_.suggest_have_backbuffer, false);
373 EXPECT_EQ(stub4.allocation_.suggest_have_frontbuffer, true); 379 EXPECT_EQ(stub4.allocation_.suggest_have_frontbuffer, true);
374 EXPECT_EQ(stub4.allocation_.suggest_have_backbuffer, false); 380 EXPECT_EQ(stub4.allocation_.suggest_have_backbuffer, false);
375 EXPECT_EQ(stub5.allocation_, stub3.allocation_); 381 EXPECT_EQ(stub5.allocation_.gpu_resource_size_in_bytes, 0ul);
376 EXPECT_EQ(stub6.allocation_, stub4.allocation_); 382 EXPECT_EQ(stub6.allocation_.gpu_resource_size_in_bytes, 1ul);
377 EXPECT_EQ(stub7.allocation_, stub4.allocation_); 383 EXPECT_EQ(stub7.allocation_.gpu_resource_size_in_bytes, 1ul);
378 } 384 }
379 385
380 // Test GpuMemoryManager::Manage functionality: Test changing importance of 386 // Test GpuMemoryManager::Manage functionality: Test changing importance of
381 // enough stubs so that every stub in share group crosses threshold. 387 // enough stubs so that every stub in share group crosses threshold.
382 // Expect memory allocation of the stubs without surface to share memory 388 // Expect memory allocation of the stubs without surface to share memory
383 // allocation with the most visible stub in share group. 389 // allocation with the most visible stub in share group.
384 TEST_F(GpuMemoryManagerTest, TestManageChangingImportanceShareGroup) { 390 TEST_F(GpuMemoryManagerTest, TestManageChangingImportanceShareGroup) {
385 FakeCommandBufferStub stubA(GenerateUniqueSurfaceId(), true, newer_), 391 FakeCommandBufferStub stubA(GenerateUniqueSurfaceId(), true, newer_),
386 stubB(GenerateUniqueSurfaceId(), false, newer_), 392 stubB(GenerateUniqueSurfaceId(), false, newer_),
387 stubC(GenerateUniqueSurfaceId(), false, newer_); 393 stubC(GenerateUniqueSurfaceId(), false, newer_);
(...skipping 11 matching lines...) Expand all
399 stub4.share_group_.push_back(&stub1); 405 stub4.share_group_.push_back(&stub1);
400 stub4.share_group_.push_back(&stub2); 406 stub4.share_group_.push_back(&stub2);
401 client_.stubs_.push_back(&stub3); 407 client_.stubs_.push_back(&stub3);
402 client_.stubs_.push_back(&stub4); 408 client_.stubs_.push_back(&stub4);
403 409
404 Manage(); 410 Manage();
405 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, true); 411 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, true);
406 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, true); 412 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, true);
407 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true); 413 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true);
408 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, true); 414 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, true);
409 EXPECT_EQ(stub3.allocation_, stub1.allocation_); 415 EXPECT_GT(stub1.allocation_.gpu_resource_size_in_bytes, 1ul);
410 EXPECT_EQ(stub3.allocation_, stub2.allocation_); 416 EXPECT_GT(stub2.allocation_.gpu_resource_size_in_bytes, 1ul);
411 EXPECT_EQ(stub4.allocation_, stub1.allocation_); 417 EXPECT_GT(stub3.allocation_.gpu_resource_size_in_bytes, 1ul);
412 EXPECT_EQ(stub4.allocation_, stub2.allocation_); 418 EXPECT_GT(stub4.allocation_.gpu_resource_size_in_bytes, 1ul);
413 419
414 stub1.surface_state_.visible = false; 420 stub1.surface_state_.visible = false;
415 421
416 Manage(); 422 Manage();
417 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, true); 423 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, true);
418 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false); 424 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false);
419 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true); 425 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true);
420 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, true); 426 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, true);
421 EXPECT_NE(stub3.allocation_, stub1.allocation_); 427 EXPECT_EQ(stub1.allocation_.gpu_resource_size_in_bytes, 0ul);
422 EXPECT_EQ(stub3.allocation_, stub2.allocation_); 428 EXPECT_GT(stub2.allocation_.gpu_resource_size_in_bytes, 1ul);
423 EXPECT_NE(stub4.allocation_, stub1.allocation_); 429 EXPECT_GT(stub3.allocation_.gpu_resource_size_in_bytes, 1ul);
424 EXPECT_EQ(stub4.allocation_, stub2.allocation_); 430 EXPECT_GT(stub4.allocation_.gpu_resource_size_in_bytes, 1ul);
425 431
426 stub2.surface_state_.visible = false; 432 stub2.surface_state_.visible = false;
427 433
428 Manage(); 434 Manage();
429 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, true); 435 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, true);
430 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false); 436 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false);
431 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true); 437 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true);
432 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false); 438 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false);
433 EXPECT_EQ(stub3.allocation_, stub1.allocation_); 439 EXPECT_EQ(stub1.allocation_.gpu_resource_size_in_bytes, 0ul);
434 EXPECT_EQ(stub3.allocation_, stub2.allocation_); 440 EXPECT_EQ(stub2.allocation_.gpu_resource_size_in_bytes, 0ul);
435 EXPECT_EQ(stub4.allocation_, stub1.allocation_); 441 EXPECT_EQ(stub3.allocation_.gpu_resource_size_in_bytes, 1ul);
436 EXPECT_EQ(stub4.allocation_, stub2.allocation_); 442 EXPECT_EQ(stub4.allocation_.gpu_resource_size_in_bytes, 1ul);
437 443
438 stub1.surface_state_.last_used_time = older_; 444 stub1.surface_state_.last_used_time = older_;
439 445
440 Manage(); 446 Manage();
441 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, false); 447 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, false);
442 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false); 448 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false);
443 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true); 449 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, true);
444 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false); 450 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false);
445 EXPECT_NE(stub3.allocation_, stub1.allocation_); 451 EXPECT_EQ(stub1.allocation_.gpu_resource_size_in_bytes, 0ul);
446 EXPECT_EQ(stub3.allocation_, stub2.allocation_); 452 EXPECT_EQ(stub2.allocation_.gpu_resource_size_in_bytes, 0ul);
447 EXPECT_NE(stub4.allocation_, stub1.allocation_); 453 EXPECT_EQ(stub3.allocation_.gpu_resource_size_in_bytes, 1ul);
448 EXPECT_EQ(stub4.allocation_, stub2.allocation_); 454 EXPECT_EQ(stub4.allocation_.gpu_resource_size_in_bytes, 1ul);
449 455
450 stub2.surface_state_.last_used_time = older_; 456 stub2.surface_state_.last_used_time = older_;
451 457
452 Manage(); 458 Manage();
453 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, false); 459 EXPECT_EQ(stub1.allocation_.suggest_have_frontbuffer, false);
454 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false); 460 EXPECT_EQ(stub1.allocation_.suggest_have_backbuffer, false);
455 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, false); 461 EXPECT_EQ(stub2.allocation_.suggest_have_frontbuffer, false);
456 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false); 462 EXPECT_EQ(stub2.allocation_.suggest_have_backbuffer, false);
457 EXPECT_EQ(stub3.allocation_, stub1.allocation_); 463 EXPECT_EQ(stub1.allocation_.gpu_resource_size_in_bytes, 0ul);
458 EXPECT_EQ(stub3.allocation_, stub2.allocation_); 464 EXPECT_EQ(stub2.allocation_.gpu_resource_size_in_bytes, 0ul);
459 EXPECT_EQ(stub4.allocation_, stub1.allocation_); 465 EXPECT_EQ(stub3.allocation_.gpu_resource_size_in_bytes, 0ul);
460 EXPECT_EQ(stub4.allocation_, stub2.allocation_); 466 EXPECT_EQ(stub4.allocation_.gpu_resource_size_in_bytes, 0ul);
461 } 467 }
462 468
463 // Test GpuMemoryAllocation comparison operators: Iterate over all possible 469 // Test GpuMemoryAllocation comparison operators: Iterate over all possible
464 // combinations of gpu_resource_size_in_bytes, suggest_have_backbuffer, and 470 // combinations of gpu_resource_size_in_bytes, suggest_have_backbuffer, and
465 // suggest_have_frontbuffer, and make sure allocations with equal values test 471 // suggest_have_frontbuffer, and make sure allocations with equal values test
466 // equal and non equal values test not equal. 472 // equal and non equal values test not equal.
467 TEST_F(GpuMemoryManagerTest, GpuMemoryAllocationCompareTests) { 473 TEST_F(GpuMemoryManagerTest, GpuMemoryAllocationCompareTests) {
468 int gpu_resource_size_in_bytes_values[] = { 0, 1, 12345678 }; 474 int gpu_resource_size_in_bytes_values[] = { 0, 1, 12345678 };
469 bool suggest_have_backbuffer_values[] = { false, true }; 475 bool suggest_have_backbuffer_values[] = { false, true };
470 bool suggest_have_frontbuffer_values[] = { false, true }; 476 bool suggest_have_frontbuffer_values[] = { false, true };
471 477
472 for(int* sz = &gpu_resource_size_in_bytes_values[0]; 478 for(int* sz = &gpu_resource_size_in_bytes_values[0];
473 sz != &gpu_resource_size_in_bytes_values[3]; ++sz) { 479 sz != &gpu_resource_size_in_bytes_values[3]; ++sz) {
474 for(bool* shbb = &suggest_have_backbuffer_values[0]; 480 for(bool* shbb = &suggest_have_backbuffer_values[0];
475 shbb != &suggest_have_backbuffer_values[2]; ++shbb) { 481 shbb != &suggest_have_backbuffer_values[2]; ++shbb) {
476 for(bool* shfb = &suggest_have_frontbuffer_values[0]; 482 for(bool* shfb = &suggest_have_frontbuffer_values[0];
477 shfb != &suggest_have_frontbuffer_values[2]; ++shfb) { 483 shfb != &suggest_have_frontbuffer_values[2]; ++shfb) {
478 GpuMemoryAllocation allocation(*sz, *shbb, *shfb); 484 GpuMemoryAllocation allocation(*sz, *shbb, *shfb);
479 EXPECT_EQ(allocation, GpuMemoryAllocation(*sz, *shbb, *shfb)); 485 EXPECT_EQ(allocation, GpuMemoryAllocation(*sz, *shbb, *shfb));
480 EXPECT_NE(allocation, GpuMemoryAllocation(*sz+1, *shbb, *shfb)); 486 EXPECT_NE(allocation, GpuMemoryAllocation(*sz+1, *shbb, *shfb));
481 EXPECT_NE(allocation, GpuMemoryAllocation(*sz, !*shbb, *shfb)); 487 EXPECT_NE(allocation, GpuMemoryAllocation(*sz, !*shbb, *shfb));
482 EXPECT_NE(allocation, GpuMemoryAllocation(*sz, *shbb, !*shfb)); 488 EXPECT_NE(allocation, GpuMemoryAllocation(*sz, *shbb, !*shfb));
483 } 489 }
484 } 490 }
485 } 491 }
486 } 492 }
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_memory_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698