OLD | NEW |
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/paint/draw_image.h" | 7 #include "cc/paint/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 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 TestGpuImageDecodeCache cache(context_provider.get()); | 1456 TestGpuImageDecodeCache cache(context_provider.get()); |
1457 | 1457 |
1458 sk_sp<SkImage> image = CreateImage(1, 1); | 1458 sk_sp<SkImage> image = CreateImage(1, 1); |
1459 bool is_decomposable = true; | 1459 bool is_decomposable = true; |
1460 SkMatrix matrix = CreateMatrix(SkSize::Make(1.0f, 1.0f), is_decomposable); | 1460 SkMatrix matrix = CreateMatrix(SkSize::Make(1.0f, 1.0f), is_decomposable); |
1461 DrawImage draw_image(CreatePaintImage(image), | 1461 DrawImage draw_image(CreatePaintImage(image), |
1462 SkIRect::MakeWH(image->width(), image->height()), | 1462 SkIRect::MakeWH(image->width(), image->height()), |
1463 kLow_SkFilterQuality, matrix, DefaultColorSpace()); | 1463 kLow_SkFilterQuality, matrix, DefaultColorSpace()); |
1464 | 1464 |
1465 scoped_refptr<TileTask> task; | 1465 scoped_refptr<TileTask> task; |
1466 bool need_unref = | 1466 bool need_unref = cache.GetOutOfRasterDecodeTaskForImageAndRef( |
1467 cache.GetOutOfRasterDecodeTaskForImageAndRef(draw_image, &task); | 1467 draw_image, ImageDecodeCache::ImageDecodeType::kCheckerImaging, &task); |
1468 EXPECT_TRUE(need_unref); | 1468 EXPECT_TRUE(need_unref); |
1469 EXPECT_TRUE(task); | 1469 EXPECT_TRUE(task); |
1470 EXPECT_TRUE(cache.IsInInUseCacheForTesting(draw_image)); | 1470 EXPECT_TRUE(cache.IsInInUseCacheForTesting(draw_image)); |
1471 | 1471 |
1472 // Run the decode task. | 1472 // Run the decode task. |
1473 TestTileTaskRunner::ProcessTask(task.get()); | 1473 TestTileTaskRunner::ProcessTask(task.get()); |
1474 | 1474 |
1475 // The image should remain in the cache till we unref it. | 1475 // The image should remain in the cache till we unref it. |
1476 EXPECT_TRUE(cache.IsInInUseCacheForTesting(draw_image)); | 1476 EXPECT_TRUE(cache.IsInInUseCacheForTesting(draw_image)); |
1477 cache.UnrefImage(draw_image); | 1477 cache.UnrefImage(draw_image); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 TestTileTaskRunner::ProcessTask(second_task->dependencies()[0].get()); | 1709 TestTileTaskRunner::ProcessTask(second_task->dependencies()[0].get()); |
1710 TestTileTaskRunner::ProcessTask(second_task.get()); | 1710 TestTileTaskRunner::ProcessTask(second_task.get()); |
1711 | 1711 |
1712 cache.UnrefImage(first_draw_image); | 1712 cache.UnrefImage(first_draw_image); |
1713 cache.UnrefImage(second_draw_image); | 1713 cache.UnrefImage(second_draw_image); |
1714 cache.UnrefImage(third_draw_image); | 1714 cache.UnrefImage(third_draw_image); |
1715 } | 1715 } |
1716 | 1716 |
1717 } // namespace | 1717 } // namespace |
1718 } // namespace cc | 1718 } // namespace cc |
OLD | NEW |