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

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

Issue 2631453002: Revert of cc: Add image decode queue functionality to image manager. (Closed)
Patch Set: 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);
501 TestTileTaskRunner::ProcessTask(task->dependencies()[0].get()); 500 TestTileTaskRunner::ProcessTask(task->dependencies()[0].get());
502 501
503 scoped_refptr<TileTask> another_task; 502 scoped_refptr<TileTask> another_task;
504 need_unref = cache.GetTaskForImageAndRef( 503 need_unref = cache.GetTaskForImageAndRef(
505 draw_image, ImageDecodeCache::TracingInfo(), &another_task); 504 draw_image, ImageDecodeCache::TracingInfo(), &another_task);
506 EXPECT_TRUE(need_unref); 505 EXPECT_TRUE(need_unref);
507 EXPECT_TRUE(another_task.get() == task.get()); 506 EXPECT_TRUE(another_task.get() == task.get());
508 507
509 // Didn't run the task, so cancel it. 508 // Didn't run the task, so cancel it.
510 TestTileTaskRunner::CancelTask(task.get()); 509 TestTileTaskRunner::CancelTask(task.get());
511 TestTileTaskRunner::CompleteTask(task.get()); 510 TestTileTaskRunner::CompleteTask(task.get());
512 511
513 // 2 Unrefs, so that the decode is unlocked as well.
514 cache.UnrefImage(draw_image);
515 cache.UnrefImage(draw_image);
516
517 // Note that here, everything is reffed, but a new task is created. This is 512 // Note that here, everything is reffed, but a new task is created. This is
518 // possible with repeated schedule/cancel operations. 513 // possible with repeated schedule/cancel operations.
519 scoped_refptr<TileTask> third_task; 514 scoped_refptr<TileTask> third_task;
520 need_unref = cache.GetTaskForImageAndRef( 515 need_unref = cache.GetTaskForImageAndRef(
521 draw_image, ImageDecodeCache::TracingInfo(), &third_task); 516 draw_image, ImageDecodeCache::TracingInfo(), &third_task);
522 EXPECT_TRUE(need_unref); 517 EXPECT_TRUE(need_unref);
523 EXPECT_TRUE(third_task); 518 EXPECT_TRUE(third_task);
524 EXPECT_FALSE(third_task.get() == task.get()); 519 EXPECT_FALSE(third_task.get() == task.get());
525 520
526 ASSERT_GT(third_task->dependencies().size(), 0u);
527 TestTileTaskRunner::ProcessTask(third_task->dependencies()[0].get()); 521 TestTileTaskRunner::ProcessTask(third_task->dependencies()[0].get());
528 TestTileTaskRunner::ProcessTask(third_task.get()); 522 TestTileTaskRunner::ProcessTask(third_task.get());
529 523
530 // Unref! 524 // 3 Unrefs!
525 cache.UnrefImage(draw_image);
526 cache.UnrefImage(draw_image);
531 cache.UnrefImage(draw_image); 527 cache.UnrefImage(draw_image);
532 } 528 }
533 529
534 TEST(GpuImageDecodeCacheTest, NoTaskForImageAlreadyFailedDecoding) { 530 TEST(GpuImageDecodeCacheTest, NoTaskForImageAlreadyFailedDecoding) {
535 auto context_provider = TestContextProvider::Create(); 531 auto context_provider = TestContextProvider::Create();
536 context_provider->BindToCurrentThread(); 532 context_provider->BindToCurrentThread();
537 TestGpuImageDecodeCache cache(context_provider.get()); 533 TestGpuImageDecodeCache cache(context_provider.get());
538 bool is_decomposable = true; 534 bool is_decomposable = true;
539 SkFilterQuality quality = kHigh_SkFilterQuality; 535 SkFilterQuality quality = kHigh_SkFilterQuality;
540 536
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 EXPECT_TRUE(need_unref); 1356 EXPECT_TRUE(need_unref);
1361 EXPECT_TRUE(task); 1357 EXPECT_TRUE(task);
1362 1358
1363 TestTileTaskRunner::ProcessTask(task->dependencies()[0].get()); 1359 TestTileTaskRunner::ProcessTask(task->dependencies()[0].get());
1364 TestTileTaskRunner::ProcessTask(task.get()); 1360 TestTileTaskRunner::ProcessTask(task.get());
1365 cache.UnrefImage(draw_image); 1361 cache.UnrefImage(draw_image);
1366 } 1362 }
1367 1363
1368 } // namespace 1364 } // namespace
1369 } // namespace cc 1365 } // 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