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

Side by Side Diff: tests/ImageFilterCacheTest.cpp

Issue 1720743002: fix race: this kCacheSize is probably not meant to be static (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | 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 2016 Google Inc. 2 * Copyright 2016 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 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 SkIPoint foundOffset; 71 SkIPoint foundOffset;
72 REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset)); 72 REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset));
73 REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset)); 73 REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset));
74 REPORTER_ASSERT(reporter, !cache->get(key3, &foundOffset)); 74 REPORTER_ASSERT(reporter, !cache->get(key3, &foundOffset));
75 REPORTER_ASSERT(reporter, !cache->get(key4, &foundOffset)); 75 REPORTER_ASSERT(reporter, !cache->get(key4, &foundOffset));
76 } 76 }
77 77
78 // Test purging when the max cache size is exceeded 78 // Test purging when the max cache size is exceeded
79 static void test_internal_purge(skiatest::Reporter* reporter, SkSpecialImage* im age) { 79 static void test_internal_purge(skiatest::Reporter* reporter, SkSpecialImage* im age) {
80 SkASSERT(image->getSize()); 80 SkASSERT(image->getSize());
81 static const size_t kCacheSize = image->getSize() + 10; 81 const size_t kCacheSize = image->getSize() + 10;
82 SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kCache Size)); 82 SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kCache Size));
83 83
84 SkIRect clip = SkIRect::MakeWH(100, 100); 84 SkIRect clip = SkIRect::MakeWH(100, 100);
85 SkImageFilter::Cache::Key key1(0, SkMatrix::I(), clip, image->uniqueID(), im age->subset()); 85 SkImageFilter::Cache::Key key1(0, SkMatrix::I(), clip, image->uniqueID(), im age->subset());
86 SkImageFilter::Cache::Key key2(1, SkMatrix::I(), clip, image->uniqueID(), im age->subset()); 86 SkImageFilter::Cache::Key key2(1, SkMatrix::I(), clip, image->uniqueID(), im age->subset());
87 87
88 SkIPoint offset = SkIPoint::Make(3, 4); 88 SkIPoint offset = SkIPoint::Make(3, 4);
89 cache->set(key1, image, offset); 89 cache->set(key1, image, offset);
90 90
91 SkIPoint foundOffset; 91 SkIPoint foundOffset;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_GPUBacked, reporter, context ) { 212 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_GPUBacked, reporter, context ) {
213 213
214 SkAutoTUnref<GrTexture> srcTexture(create_texture(context)); 214 SkAutoTUnref<GrTexture> srcTexture(create_texture(context));
215 if (!srcTexture) { 215 if (!srcTexture) {
216 return; 216 return;
217 } 217 }
218 218
219 const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); 219 const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize);
220 220
221 SkAutoTUnref<SkSpecialImage> fullImg(SkSpecialImage::NewFromGpu( 221 SkAutoTUnref<SkSpecialImage> fullImg(SkSpecialImage::NewFromGpu(
222 nullptr, full, 222 nullptr, full,
223 kNeedNewImageUni queID_SpecialImage, 223 kNeedNewImageUni queID_SpecialImage,
224 srcTexture)); 224 srcTexture));
225 225
226 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller Size); 226 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmaller Size);
227 227
228 SkAutoTUnref<SkSpecialImage> subsetImg(SkSpecialImage::NewFromGpu( 228 SkAutoTUnref<SkSpecialImage> subsetImg(SkSpecialImage::NewFromGpu(
229 nullptr, subset, 229 nullptr, subset,
230 kNeedNewImageUni queID_SpecialImage, 230 kNeedNewImageUni queID_SpecialImage,
231 srcTexture)); 231 srcTexture));
232 232
233 test_find_existing(reporter, fullImg, subsetImg); 233 test_find_existing(reporter, fullImg, subsetImg);
234 test_dont_find_if_diff_key(reporter, fullImg, subsetImg); 234 test_dont_find_if_diff_key(reporter, fullImg, subsetImg);
235 test_internal_purge(reporter, fullImg); 235 test_internal_purge(reporter, fullImg);
236 test_explicit_purging(reporter, fullImg, subsetImg); 236 test_explicit_purging(reporter, fullImg, subsetImg);
237 } 237 }
238 #endif 238 #endif
239 239
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698