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

Side by Side Diff: cc/tiles/gpu_image_decode_cache_unittest.cc

Issue 2537683002: cc: Add image decode queue functionality to image manager. (Closed)
Patch Set: test fix Created 3 years, 11 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
« no previous file with comments | « cc/tiles/gpu_image_decode_cache.cc ('k') | cc/tiles/image_controller.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/tiles/gpu_image_decode_cache.h" 5 #include "cc/tiles/gpu_image_decode_cache.h"
6 6
7 #include "cc/playback/draw_image.h" 7 #include "cc/playback/draw_image.h"
8 #include "cc/test/test_context_provider.h" 8 #include "cc/test/test_context_provider.h"
9 #include "cc/test/test_tile_task_runner.h" 9 #include "cc/test/test_tile_task_runner.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 sk_sp<SkImage> image = CreateImage(100, 100); 490 sk_sp<SkImage> image = CreateImage(100, 100);
491 DrawImage draw_image(image, SkIRect::MakeWH(image->width(), image->height()), 491 DrawImage draw_image(image, SkIRect::MakeWH(image->width(), image->height()),
492 quality, 492 quality,
493 CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable)); 493 CreateMatrix(SkSize::Make(0.5f, 0.5f), is_decomposable));
494 scoped_refptr<TileTask> task; 494 scoped_refptr<TileTask> task;
495 bool need_unref = cache.GetTaskForImageAndRef( 495 bool need_unref = cache.GetTaskForImageAndRef(
496 draw_image, ImageDecodeCache::TracingInfo(), &task); 496 draw_image, ImageDecodeCache::TracingInfo(), &task);
497 EXPECT_TRUE(need_unref); 497 EXPECT_TRUE(need_unref);
498 EXPECT_TRUE(task); 498 EXPECT_TRUE(task);
499 499
500 ASSERT_GT(task->dependencies().size(), 0u);
500 TestTileTaskRunner::ProcessTask(task->dependencies()[0].get()); 501 TestTileTaskRunner::ProcessTask(task->dependencies()[0].get());
501 502
502 scoped_refptr<TileTask> another_task; 503 scoped_refptr<TileTask> another_task;
503 need_unref = cache.GetTaskForImageAndRef( 504 need_unref = cache.GetTaskForImageAndRef(
504 draw_image, ImageDecodeCache::TracingInfo(), &another_task); 505 draw_image, ImageDecodeCache::TracingInfo(), &another_task);
505 EXPECT_TRUE(need_unref); 506 EXPECT_TRUE(need_unref);
506 EXPECT_TRUE(another_task.get() == task.get()); 507 EXPECT_TRUE(another_task.get() == task.get());
507 508
508 // Didn't run the task, so cancel it. 509 // Didn't run the task, so cancel it.
509 TestTileTaskRunner::CancelTask(task.get()); 510 TestTileTaskRunner::CancelTask(task.get());
510 TestTileTaskRunner::CompleteTask(task.get()); 511 TestTileTaskRunner::CompleteTask(task.get());
511 512
513 // 2 Unrefs, so that the decode is unlocked as well.
514 cache.UnrefImage(draw_image);
515 cache.UnrefImage(draw_image);
516
512 // Note that here, everything is reffed, but a new task is created. This is 517 // Note that here, everything is reffed, but a new task is created. This is
513 // possible with repeated schedule/cancel operations. 518 // possible with repeated schedule/cancel operations.
514 scoped_refptr<TileTask> third_task; 519 scoped_refptr<TileTask> third_task;
515 need_unref = cache.GetTaskForImageAndRef( 520 need_unref = cache.GetTaskForImageAndRef(
516 draw_image, ImageDecodeCache::TracingInfo(), &third_task); 521 draw_image, ImageDecodeCache::TracingInfo(), &third_task);
517 EXPECT_TRUE(need_unref); 522 EXPECT_TRUE(need_unref);
518 EXPECT_TRUE(third_task); 523 EXPECT_TRUE(third_task);
519 EXPECT_FALSE(third_task.get() == task.get()); 524 EXPECT_FALSE(third_task.get() == task.get());
520 525
526 ASSERT_GT(third_task->dependencies().size(), 0u);
521 TestTileTaskRunner::ProcessTask(third_task->dependencies()[0].get()); 527 TestTileTaskRunner::ProcessTask(third_task->dependencies()[0].get());
522 TestTileTaskRunner::ProcessTask(third_task.get()); 528 TestTileTaskRunner::ProcessTask(third_task.get());
523 529
524 // 3 Unrefs! 530 // Unref!
525 cache.UnrefImage(draw_image);
526 cache.UnrefImage(draw_image);
527 cache.UnrefImage(draw_image); 531 cache.UnrefImage(draw_image);
528 } 532 }
529 533
530 TEST(GpuImageDecodeCacheTest, NoTaskForImageAlreadyFailedDecoding) { 534 TEST(GpuImageDecodeCacheTest, NoTaskForImageAlreadyFailedDecoding) {
531 auto context_provider = TestContextProvider::Create(); 535 auto context_provider = TestContextProvider::Create();
532 context_provider->BindToCurrentThread(); 536 context_provider->BindToCurrentThread();
533 TestGpuImageDecodeCache cache(context_provider.get()); 537 TestGpuImageDecodeCache cache(context_provider.get());
534 bool is_decomposable = true; 538 bool is_decomposable = true;
535 SkFilterQuality quality = kHigh_SkFilterQuality; 539 SkFilterQuality quality = kHigh_SkFilterQuality;
536 540
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 EXPECT_TRUE(need_unref); 1360 EXPECT_TRUE(need_unref);
1357 EXPECT_TRUE(task); 1361 EXPECT_TRUE(task);
1358 1362
1359 TestTileTaskRunner::ProcessTask(task->dependencies()[0].get()); 1363 TestTileTaskRunner::ProcessTask(task->dependencies()[0].get());
1360 TestTileTaskRunner::ProcessTask(task.get()); 1364 TestTileTaskRunner::ProcessTask(task.get());
1361 cache.UnrefImage(draw_image); 1365 cache.UnrefImage(draw_image);
1362 } 1366 }
1363 1367
1364 } // namespace 1368 } // namespace
1365 } // namespace cc 1369 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/gpu_image_decode_cache.cc ('k') | cc/tiles/image_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698