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

Side by Side Diff: tests/ImageCacheTest.cpp

Issue 89293002: Trying to add the same scaled image twice shouldn't assert. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkScaledImageCache.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Test.h" 8 #include "Test.h"
9 #include "SkScaledImageCache.h" 9 #include "SkScaledImageCache.h"
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 id = cache.addAndLock(bm[0], scale, scale, tmp); 56 id = cache.addAndLock(bm[0], scale, scale, tmp);
57 REPORTER_ASSERT(reporter, NULL != id); 57 REPORTER_ASSERT(reporter, NULL != id);
58 cache.unlock(id); 58 cache.unlock(id);
59 } 59 }
60 60
61 cache.setByteLimit(0); 61 cache.setByteLimit(0);
62 } 62 }
63 63
64 #include "TestClassDef.h" 64 #include "TestClassDef.h"
65 DEFINE_TESTCLASS("ImageCache", TestImageCacheClass, TestImageCache) 65 DEFINE_TESTCLASS("ImageCache", TestImageCacheClass, TestImageCache)
66
67 DEF_TEST(ImageCache_doubleAdd, r) {
68 // Adding the same key twice should be safe.
69 SkScaledImageCache cache(1024);
70
71 SkBitmap original;
72 original.setConfig(SkBitmap::kARGB_8888_Config, 40, 40);
73 original.allocPixels();
74
75 SkBitmap scaled;
76 scaled.setConfig(SkBitmap::kARGB_8888_Config, 20, 20);
77 scaled.allocPixels();
78
79 SkScaledImageCache::ID* id1 = cache.addAndLock(original, 0.5f, 0.5f, scaled) ;
80 SkScaledImageCache::ID* id2 = cache.addAndLock(original, 0.5f, 0.5f, scaled) ;
81 // We don't really care if id1 == id2 as long as unlocking both works.
82 cache.unlock(id1);
83 cache.unlock(id2);
84 }
OLDNEW
« no previous file with comments | « src/core/SkScaledImageCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698