aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ImageCacheTest.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-27 20:22:23 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-27 20:22:23 +0000
commit23d2cf9b072e75ef37e8eec466b811a9e2da643d (patch)
treea29d2cc917c833272056676fea7c08ee84658ba7 /tests/ImageCacheTest.cpp
parenta50418f65e857ff05b3a71d3e03db44c1f232977 (diff)
Trying to add the same scaled image twice shouldn't assert.
This unbreaks bench_pictures --multi foo for me. BUG=skia:1868 R=reed@google.com Author: mtklein@google.com Review URL: https://codereview.chromium.org/89293002 git-svn-id: http://skia.googlecode.com/svn/trunk@12422 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/ImageCacheTest.cpp')
-rw-r--r--tests/ImageCacheTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/ImageCacheTest.cpp b/tests/ImageCacheTest.cpp
index 877591acc7..b8815a3217 100644
--- a/tests/ImageCacheTest.cpp
+++ b/tests/ImageCacheTest.cpp
@@ -63,3 +63,22 @@ static void TestImageCache(skiatest::Reporter* reporter) {
#include "TestClassDef.h"
DEFINE_TESTCLASS("ImageCache", TestImageCacheClass, TestImageCache)
+
+DEF_TEST(ImageCache_doubleAdd, r) {
+ // Adding the same key twice should be safe.
+ SkScaledImageCache cache(1024);
+
+ SkBitmap original;
+ original.setConfig(SkBitmap::kARGB_8888_Config, 40, 40);
+ original.allocPixels();
+
+ SkBitmap scaled;
+ scaled.setConfig(SkBitmap::kARGB_8888_Config, 20, 20);
+ scaled.allocPixels();
+
+ SkScaledImageCache::ID* id1 = cache.addAndLock(original, 0.5f, 0.5f, scaled);
+ SkScaledImageCache::ID* id2 = cache.addAndLock(original, 0.5f, 0.5f, scaled);
+ // We don't really care if id1 == id2 as long as unlocking both works.
+ cache.unlock(id1);
+ cache.unlock(id2);
+}