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

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

Issue 2795803002: Clear Image Decode Cache on Navigation (Closed)
Patch Set: fix conversion Created 3 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
« no previous file with comments | « cc/tiles/software_image_decode_cache.cc ('k') | cc/trees/layer_tree_host.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 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
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 EXPECT_EQ(10u, cache.GetNumCacheEntriesForTesting());
1469
1470 // Tell our cache to clear resources.
1471 cache.ClearCache();
1472
1473 EXPECT_EQ(0u, cache.GetNumCacheEntriesForTesting());
1474 }
1475
1449 } // namespace 1476 } // namespace
1450 } // namespace cc 1477 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/software_image_decode_cache.cc ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698