robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "Test.h" |
| 9 | |
| 10 | #include "SkBitmap.h" |
| 11 | #include "SkImage.h" |
| 12 | #include "SkImageFilter.h" |
senorblanco | 900c367 | 2016-04-27 11:31:23 -0700 | [diff] [blame] | 13 | #include "SkImageFilterCache.h" |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 14 | #include "SkMatrix.h" |
| 15 | #include "SkSpecialImage.h" |
| 16 | |
| 17 | static const int kSmallerSize = 10; |
| 18 | static const int kPad = 3; |
| 19 | static const int kFullSize = kSmallerSize + 2 * kPad; |
| 20 | |
| 21 | static SkBitmap create_bm() { |
| 22 | SkBitmap bm; |
| 23 | bm.allocN32Pixels(kFullSize, kFullSize, true); |
| 24 | bm.eraseColor(SK_ColorTRANSPARENT); |
| 25 | return bm; |
| 26 | } |
| 27 | |
| 28 | // Ensure the cache can return a cached image |
| 29 | static void test_find_existing(skiatest::Reporter* reporter, |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 30 | const sk_sp<SkSpecialImage>& image, |
| 31 | const sk_sp<SkSpecialImage>& subset) { |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 32 | static const size_t kCacheSize = 1000000; |
Hal Canary | 342b7ac | 2016-11-04 11:49:42 -0400 | [diff] [blame] | 33 | sk_sp<SkImageFilterCache> cache(SkImageFilterCache::Create(kCacheSize)); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 34 | |
| 35 | SkIRect clip = SkIRect::MakeWH(100, 100); |
senorblanco | 900c367 | 2016-04-27 11:31:23 -0700 | [diff] [blame] | 36 | SkImageFilterCacheKey key1(0, SkMatrix::I(), clip, image->uniqueID(), image->subset()); |
| 37 | SkImageFilterCacheKey key2(0, SkMatrix::I(), clip, subset->uniqueID(), subset->subset()); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 38 | |
| 39 | SkIPoint offset = SkIPoint::Make(3, 4); |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 40 | cache->set(key1, image.get(), offset); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 41 | |
| 42 | SkIPoint foundOffset; |
| 43 | |
Florin Malita | a022e2d | 2017-01-12 12:06:14 -0500 | [diff] [blame] | 44 | sk_sp<SkSpecialImage> foundImage = cache->get(key1, &foundOffset); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 45 | REPORTER_ASSERT(reporter, foundImage); |
| 46 | REPORTER_ASSERT(reporter, offset == foundOffset); |
| 47 | |
| 48 | REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset)); |
| 49 | } |
| 50 | |
| 51 | // If either id is different or the clip or the matrix are different the |
| 52 | // cached image won't be found. Even if it is caching the same bitmap. |
| 53 | static void test_dont_find_if_diff_key(skiatest::Reporter* reporter, |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 54 | const sk_sp<SkSpecialImage>& image, |
| 55 | const sk_sp<SkSpecialImage>& subset) { |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 56 | static const size_t kCacheSize = 1000000; |
Hal Canary | 342b7ac | 2016-11-04 11:49:42 -0400 | [diff] [blame] | 57 | sk_sp<SkImageFilterCache> cache(SkImageFilterCache::Create(kCacheSize)); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 58 | |
| 59 | SkIRect clip1 = SkIRect::MakeWH(100, 100); |
| 60 | SkIRect clip2 = SkIRect::MakeWH(200, 200); |
senorblanco | 900c367 | 2016-04-27 11:31:23 -0700 | [diff] [blame] | 61 | SkImageFilterCacheKey key0(0, SkMatrix::I(), clip1, image->uniqueID(), image->subset()); |
| 62 | SkImageFilterCacheKey key1(1, SkMatrix::I(), clip1, image->uniqueID(), image->subset()); |
| 63 | SkImageFilterCacheKey key2(0, SkMatrix::MakeTrans(5, 5), clip1, |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 64 | image->uniqueID(), image->subset()); |
senorblanco | 900c367 | 2016-04-27 11:31:23 -0700 | [diff] [blame] | 65 | SkImageFilterCacheKey key3(0, SkMatrix::I(), clip2, image->uniqueID(), image->subset()); |
| 66 | SkImageFilterCacheKey key4(0, SkMatrix::I(), clip1, subset->uniqueID(), subset->subset()); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 67 | |
| 68 | SkIPoint offset = SkIPoint::Make(3, 4); |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 69 | cache->set(key0, image.get(), offset); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 70 | |
| 71 | SkIPoint foundOffset; |
| 72 | REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset)); |
| 73 | REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset)); |
| 74 | REPORTER_ASSERT(reporter, !cache->get(key3, &foundOffset)); |
| 75 | REPORTER_ASSERT(reporter, !cache->get(key4, &foundOffset)); |
| 76 | } |
| 77 | |
| 78 | // Test purging when the max cache size is exceeded |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 79 | static void test_internal_purge(skiatest::Reporter* reporter, const sk_sp<SkSpecialImage>& image) { |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 80 | SkASSERT(image->getSize()); |
mtklein | 03762fe | 2016-02-21 13:36:50 -0800 | [diff] [blame] | 81 | const size_t kCacheSize = image->getSize() + 10; |
Hal Canary | 342b7ac | 2016-11-04 11:49:42 -0400 | [diff] [blame] | 82 | sk_sp<SkImageFilterCache> cache(SkImageFilterCache::Create(kCacheSize)); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 83 | |
| 84 | SkIRect clip = SkIRect::MakeWH(100, 100); |
senorblanco | 900c367 | 2016-04-27 11:31:23 -0700 | [diff] [blame] | 85 | SkImageFilterCacheKey key1(0, SkMatrix::I(), clip, image->uniqueID(), image->subset()); |
| 86 | SkImageFilterCacheKey key2(1, SkMatrix::I(), clip, image->uniqueID(), image->subset()); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 87 | |
| 88 | SkIPoint offset = SkIPoint::Make(3, 4); |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 89 | cache->set(key1, image.get(), offset); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 90 | |
| 91 | SkIPoint foundOffset; |
| 92 | |
| 93 | REPORTER_ASSERT(reporter, cache->get(key1, &foundOffset)); |
| 94 | |
| 95 | // This should knock the first one out of the cache |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 96 | cache->set(key2, image.get(), offset); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 97 | |
| 98 | REPORTER_ASSERT(reporter, cache->get(key2, &foundOffset)); |
| 99 | REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset)); |
| 100 | } |
| 101 | |
| 102 | // Exercise the purgeByKeys and purge methods |
| 103 | static void test_explicit_purging(skiatest::Reporter* reporter, |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 104 | const sk_sp<SkSpecialImage>& image, |
| 105 | const sk_sp<SkSpecialImage>& subset) { |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 106 | static const size_t kCacheSize = 1000000; |
Hal Canary | 342b7ac | 2016-11-04 11:49:42 -0400 | [diff] [blame] | 107 | sk_sp<SkImageFilterCache> cache(SkImageFilterCache::Create(kCacheSize)); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 108 | |
| 109 | SkIRect clip = SkIRect::MakeWH(100, 100); |
senorblanco | 900c367 | 2016-04-27 11:31:23 -0700 | [diff] [blame] | 110 | SkImageFilterCacheKey key1(0, SkMatrix::I(), clip, image->uniqueID(), image->subset()); |
| 111 | SkImageFilterCacheKey key2(1, SkMatrix::I(), clip, subset->uniqueID(), image->subset()); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 112 | |
| 113 | SkIPoint offset = SkIPoint::Make(3, 4); |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 114 | cache->set(key1, image.get(), offset); |
| 115 | cache->set(key2, image.get(), offset); |
robertphillips | bde57ed | 2016-04-18 14:49:57 -0700 | [diff] [blame] | 116 | SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache->count());) |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 117 | |
| 118 | SkIPoint foundOffset; |
| 119 | |
| 120 | REPORTER_ASSERT(reporter, cache->get(key1, &foundOffset)); |
| 121 | REPORTER_ASSERT(reporter, cache->get(key2, &foundOffset)); |
| 122 | |
| 123 | cache->purgeByKeys(&key1, 1); |
robertphillips | bde57ed | 2016-04-18 14:49:57 -0700 | [diff] [blame] | 124 | SkDEBUGCODE(REPORTER_ASSERT(reporter, 1 == cache->count());) |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 125 | |
| 126 | REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset)); |
| 127 | REPORTER_ASSERT(reporter, cache->get(key2, &foundOffset)); |
| 128 | |
| 129 | cache->purge(); |
robertphillips | bde57ed | 2016-04-18 14:49:57 -0700 | [diff] [blame] | 130 | SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache->count());) |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 131 | |
| 132 | REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset)); |
| 133 | REPORTER_ASSERT(reporter, !cache->get(key2, &foundOffset)); |
| 134 | } |
| 135 | |
| 136 | DEF_TEST(ImageFilterCache_RasterBacked, reporter) { |
| 137 | SkBitmap srcBM = create_bm(); |
| 138 | |
| 139 | const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); |
| 140 | |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 141 | sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromRaster(full, srcBM)); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 142 | |
| 143 | const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
| 144 | |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 145 | sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromRaster(subset, srcBM)); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 146 | |
| 147 | test_find_existing(reporter, fullImg, subsetImg); |
| 148 | test_dont_find_if_diff_key(reporter, fullImg, subsetImg); |
| 149 | test_internal_purge(reporter, fullImg); |
| 150 | test_explicit_purging(reporter, fullImg, subsetImg); |
| 151 | } |
| 152 | |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 153 | |
robertphillips | cbc5bcc | 2016-02-19 10:41:12 -0800 | [diff] [blame] | 154 | // Shared test code for both the raster and gpu-backed image cases |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 155 | static void test_image_backed(skiatest::Reporter* reporter, const sk_sp<SkImage>& srcImage) { |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 156 | const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); |
Brian Osman | 61624f0 | 2016-12-09 14:51:59 -0500 | [diff] [blame] | 157 | SkColorSpace* legacyColorSpace = nullptr; |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 158 | |
Brian Osman | 61624f0 | 2016-12-09 14:51:59 -0500 | [diff] [blame] | 159 | sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromImage(full, srcImage, legacyColorSpace)); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 160 | |
| 161 | const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
| 162 | |
Brian Osman | 61624f0 | 2016-12-09 14:51:59 -0500 | [diff] [blame] | 163 | sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromImage(subset, srcImage, |
| 164 | legacyColorSpace)); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 165 | |
| 166 | test_find_existing(reporter, fullImg, subsetImg); |
| 167 | test_dont_find_if_diff_key(reporter, fullImg, subsetImg); |
| 168 | test_internal_purge(reporter, fullImg); |
| 169 | test_explicit_purging(reporter, fullImg, subsetImg); |
| 170 | } |
| 171 | |
robertphillips | cbc5bcc | 2016-02-19 10:41:12 -0800 | [diff] [blame] | 172 | DEF_TEST(ImageFilterCache_ImageBackedRaster, reporter) { |
| 173 | SkBitmap srcBM = create_bm(); |
| 174 | |
reed | 9ce9d67 | 2016-03-17 10:51:11 -0700 | [diff] [blame] | 175 | sk_sp<SkImage> srcImage(SkImage::MakeFromBitmap(srcBM)); |
robertphillips | cbc5bcc | 2016-02-19 10:41:12 -0800 | [diff] [blame] | 176 | |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 177 | test_image_backed(reporter, srcImage); |
robertphillips | cbc5bcc | 2016-02-19 10:41:12 -0800 | [diff] [blame] | 178 | } |
| 179 | |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 180 | #if SK_SUPPORT_GPU |
| 181 | #include "GrContext.h" |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame^] | 182 | #include "GrResourceProvider.h" |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 183 | |
robertphillips | cbc5bcc | 2016-02-19 10:41:12 -0800 | [diff] [blame] | 184 | static GrTexture* create_texture(GrContext* context) { |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 185 | SkBitmap srcBM = create_bm(); |
| 186 | |
| 187 | GrSurfaceDesc desc; |
Brian Osman | 273f7d4 | 2016-10-14 16:48:17 -0400 | [diff] [blame] | 188 | desc.fConfig = kRGBA_8888_GrPixelConfig; |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 189 | desc.fFlags = kNone_GrSurfaceFlags; |
| 190 | desc.fWidth = kFullSize; |
| 191 | desc.fHeight = kFullSize; |
| 192 | |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame^] | 193 | return context->resourceProvider()->createTexture(desc, SkBudgeted::kNo, srcBM.getPixels(), 0); |
robertphillips | cbc5bcc | 2016-02-19 10:41:12 -0800 | [diff] [blame] | 194 | } |
| 195 | |
Robert Phillips | 2c6d2bf | 2017-02-21 10:19:29 -0500 | [diff] [blame] | 196 | static sk_sp<GrTextureProxy> create_proxy(GrContext* context) { |
| 197 | SkBitmap srcBM = create_bm(); |
| 198 | |
| 199 | GrSurfaceDesc desc; |
| 200 | desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 201 | desc.fFlags = kNone_GrSurfaceFlags; |
| 202 | desc.fWidth = kFullSize; |
| 203 | desc.fHeight = kFullSize; |
| 204 | |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 205 | return GrSurfaceProxy::MakeDeferred(*context->caps(), |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame^] | 206 | context->resourceProvider(), |
Robert Phillips | 2f49314 | 2017-03-02 18:18:38 -0500 | [diff] [blame] | 207 | desc, SkBudgeted::kYes, |
| 208 | srcBM.getPixels(), |
| 209 | srcBM.rowBytes()); |
Robert Phillips | 2c6d2bf | 2017-02-21 10:19:29 -0500 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | |
egdaniel | ab527a5 | 2016-06-28 08:07:26 -0700 | [diff] [blame] | 213 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ctxInfo) { |
Hal Canary | 342b7ac | 2016-11-04 11:49:42 -0400 | [diff] [blame] | 214 | sk_sp<GrTexture> srcTexture(create_texture(ctxInfo.grContext())); |
robertphillips | cbc5bcc | 2016-02-19 10:41:12 -0800 | [diff] [blame] | 215 | if (!srcTexture) { |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | GrBackendTextureDesc backendDesc; |
robertphillips | cbc5bcc | 2016-02-19 10:41:12 -0800 | [diff] [blame] | 220 | backendDesc.fFlags = kNone_GrBackendTextureFlag; |
Robert Phillips | 3390e15 | 2017-01-31 17:53:34 -0500 | [diff] [blame] | 221 | backendDesc.fOrigin = kTopLeft_GrSurfaceOrigin; |
| 222 | backendDesc.fConfig = kRGBA_8888_GrPixelConfig; |
robertphillips | cbc5bcc | 2016-02-19 10:41:12 -0800 | [diff] [blame] | 223 | backendDesc.fWidth = kFullSize; |
| 224 | backendDesc.fHeight = kFullSize; |
| 225 | backendDesc.fSampleCnt = 0; |
| 226 | backendDesc.fTextureHandle = srcTexture->getTextureHandle(); |
Robert Phillips | 3390e15 | 2017-01-31 17:53:34 -0500 | [diff] [blame] | 227 | sk_sp<SkImage> srcImage(SkImage::MakeFromTexture(ctxInfo.grContext(), |
| 228 | backendDesc, |
| 229 | kPremul_SkAlphaType)); |
robertphillips | cbc5bcc | 2016-02-19 10:41:12 -0800 | [diff] [blame] | 230 | if (!srcImage) { |
| 231 | return; |
| 232 | } |
| 233 | |
Robert Phillips | 3390e15 | 2017-01-31 17:53:34 -0500 | [diff] [blame] | 234 | GrSurfaceOrigin readBackOrigin; |
| 235 | GrBackendObject readBackHandle = srcImage->getTextureHandle(false, &readBackOrigin); |
| 236 | // TODO: Make it so we can check this (see skbug.com/5019) |
| 237 | #if 0 |
| 238 | if (readBackHandle != backendDesc.fTextureHandle) { |
| 239 | ERRORF(reporter, "backend mismatch %d %d\n", |
| 240 | (int)readBackHandle, (int)backendDesc.fTextureHandle); |
| 241 | } |
| 242 | REPORTER_ASSERT(reporter, readBackHandle == backendDesc.fTextureHandle); |
| 243 | #else |
| 244 | REPORTER_ASSERT(reporter, SkToBool(readBackHandle)); |
| 245 | #endif |
| 246 | if (readBackOrigin != backendDesc.fOrigin) { |
| 247 | ERRORF(reporter, "origin mismatch %d %d\n", readBackOrigin, backendDesc.fOrigin); |
| 248 | } |
| 249 | REPORTER_ASSERT(reporter, readBackOrigin == backendDesc.fOrigin); |
| 250 | |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 251 | test_image_backed(reporter, srcImage); |
robertphillips | cbc5bcc | 2016-02-19 10:41:12 -0800 | [diff] [blame] | 252 | } |
| 253 | |
bsalomon | 68d9134 | 2016-04-12 09:59:58 -0700 | [diff] [blame] | 254 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_GPUBacked, reporter, ctxInfo) { |
Robert Phillips | 2c6d2bf | 2017-02-21 10:19:29 -0500 | [diff] [blame] | 255 | GrContext* context = ctxInfo.grContext(); |
robertphillips | cbc5bcc | 2016-02-19 10:41:12 -0800 | [diff] [blame] | 256 | |
Robert Phillips | 2c6d2bf | 2017-02-21 10:19:29 -0500 | [diff] [blame] | 257 | sk_sp<GrTextureProxy> srcProxy(create_proxy(context)); |
| 258 | if (!srcProxy) { |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 259 | return; |
| 260 | } |
| 261 | |
| 262 | const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); |
| 263 | |
Robert Phillips | 2c6d2bf | 2017-02-21 10:19:29 -0500 | [diff] [blame] | 264 | sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeDeferredFromGpu( |
| 265 | context, full, |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 266 | kNeedNewImageUniqueID_SpecialImage, |
Robert Phillips | 2c6d2bf | 2017-02-21 10:19:29 -0500 | [diff] [blame] | 267 | srcProxy, nullptr)); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 268 | |
| 269 | const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
| 270 | |
Robert Phillips | 2c6d2bf | 2017-02-21 10:19:29 -0500 | [diff] [blame] | 271 | sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeDeferredFromGpu( |
| 272 | context, subset, |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 273 | kNeedNewImageUniqueID_SpecialImage, |
Robert Phillips | 2c6d2bf | 2017-02-21 10:19:29 -0500 | [diff] [blame] | 274 | srcProxy, nullptr)); |
robertphillips | df7bb47 | 2016-02-19 08:19:40 -0800 | [diff] [blame] | 275 | |
| 276 | test_find_existing(reporter, fullImg, subsetImg); |
| 277 | test_dont_find_if_diff_key(reporter, fullImg, subsetImg); |
| 278 | test_internal_purge(reporter, fullImg); |
| 279 | test_explicit_purging(reporter, fullImg, subsetImg); |
| 280 | } |
| 281 | #endif |