OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/software_image_decode_cache.h" | 5 #include "cc/tiles/software_image_decode_cache.h" |
6 | 6 |
7 #include "cc/paint/draw_image.h" | 7 #include "cc/paint/draw_image.h" |
8 #include "cc/resources/resource_format.h" | 8 #include "cc/resources/resource_format.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 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1439 EXPECT_EQ(100, decoded_draw_image_49.image()->height()); | 1439 EXPECT_EQ(100, decoded_draw_image_49.image()->height()); |
1440 | 1440 |
1441 EXPECT_EQ(decoded_draw_image_50.image(), decoded_draw_image_49.image()); | 1441 EXPECT_EQ(decoded_draw_image_50.image(), decoded_draw_image_49.image()); |
1442 | 1442 |
1443 cache.DrawWithImageFinished(draw_image_50, decoded_draw_image_50); | 1443 cache.DrawWithImageFinished(draw_image_50, decoded_draw_image_50); |
1444 cache.UnrefImage(draw_image_50); | 1444 cache.UnrefImage(draw_image_50); |
1445 cache.DrawWithImageFinished(draw_image_49, decoded_draw_image_49); | 1445 cache.DrawWithImageFinished(draw_image_49, decoded_draw_image_49); |
1446 cache.UnrefImage(draw_image_49); | 1446 cache.UnrefImage(draw_image_49); |
1447 } | 1447 } |
1448 | 1448 |
1449 TEST(SoftwareImageDecodeCacheTest, ClearCache) { | |
1450 TestSoftwareImageDecodeCache cache; | |
1451 bool is_decomposable = true; | |
1452 SkFilterQuality quality = kHigh_SkFilterQuality; | |
1453 | |
1454 for (int i = 0; i < 10; ++i) { | |
1455 sk_sp<SkImage> image = CreateImage(100, 100); | |
1456 DrawImage draw_image( | |
1457 image, SkIRect::MakeWH(image->width(), image->height()), quality, | |
1458 CreateMatrix(SkSize::Make(1.0f, 1.0f), is_decomposable)); | |
1459 scoped_refptr<TileTask> task; | |
1460 bool need_unref = cache.GetTaskForImageAndRef( | |
1461 draw_image, ImageDecodeCache::TracingInfo(), &task); | |
1462 EXPECT_TRUE(need_unref); | |
1463 EXPECT_TRUE(task); | |
1464 TestTileTaskRunner::ProcessTask(task.get()); | |
1465 cache.UnrefImage(draw_image); | |
1466 } | |
1467 | |
1468 // Tell our cache to clear resources. | |
1469 cache.ClearCache(); | |
vmpstr
2017/04/04 00:43:17
Is there anything we can query to check if the cac
ericrk
2017/04/04 17:17:18
yup - meant to ask you if you were OK with adding
| |
1470 } | |
1471 | |
1449 } // namespace | 1472 } // namespace |
1450 } // namespace cc | 1473 } // namespace cc |
OLD | NEW |