robertphillips | b6c65e9 | 2016-02-04 10:52:42 -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 | |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 8 | #include "SkAutoPixmapStorage.h" |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 9 | #include "SkBitmap.h" |
| 10 | #include "SkCanvas.h" |
| 11 | #include "SkImage.h" |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 12 | #include "SkPixmap.h" |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 13 | #include "SkSpecialImage.h" |
| 14 | #include "SkSpecialSurface.h" |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 15 | #include "SkSurface.h" |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 16 | #include "Test.h" |
| 17 | |
| 18 | #if SK_SUPPORT_GPU |
| 19 | #include "GrContext.h" |
| 20 | #endif |
| 21 | |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 22 | |
| 23 | // This test creates backing resources exactly sized to [kFullSize x kFullSize]. |
| 24 | // It then wraps them in an SkSpecialImage with only the center (red) region being active. |
| 25 | // It then draws the SkSpecialImage to a full sized (all blue) canvas and checks that none |
| 26 | // of the inactive (green) region leaked out. |
| 27 | |
| 28 | static const int kSmallerSize = 10; |
| 29 | static const int kPad = 3; |
| 30 | static const int kFullSize = kSmallerSize + 2 * kPad; |
| 31 | |
| 32 | // Create a bitmap with red in the center and green around it |
| 33 | static SkBitmap create_bm() { |
| 34 | SkBitmap bm; |
| 35 | bm.allocN32Pixels(kFullSize, kFullSize, true); |
| 36 | |
| 37 | SkCanvas temp(bm); |
| 38 | |
| 39 | temp.clear(SK_ColorGREEN); |
| 40 | SkPaint p; |
| 41 | p.setColor(SK_ColorRED); |
| 42 | p.setAntiAlias(false); |
| 43 | |
| 44 | temp.drawRect(SkRect::MakeXYWH(SkIntToScalar(kPad), SkIntToScalar(kPad), |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 45 | SkIntToScalar(kSmallerSize), SkIntToScalar(kSmallerSize)), |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 46 | p); |
| 47 | |
| 48 | return bm; |
| 49 | } |
| 50 | |
| 51 | // Basic test of the SkSpecialImage public API (e.g., peekTexture, peekPixels & draw) |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 52 | static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* reporter, |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 53 | GrContext* context, bool peekTextureSucceeds, |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 54 | int offset, int size) { |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 55 | const SkIRect subset = img->subset(); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 56 | REPORTER_ASSERT(reporter, offset == subset.left()); |
| 57 | REPORTER_ASSERT(reporter, offset == subset.top()); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 58 | REPORTER_ASSERT(reporter, kSmallerSize == subset.width()); |
| 59 | REPORTER_ASSERT(reporter, kSmallerSize == subset.height()); |
| 60 | |
| 61 | //-------------- |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 62 | // Test that peekTexture reports the correct backing type |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 63 | REPORTER_ASSERT(reporter, peekTextureSucceeds == img->isTextureBacked()); |
| 64 | |
| 65 | #if SK_SUPPORT_GPU |
| 66 | //-------------- |
| 67 | // Test getTextureAsRef - as long as there is a context this should succeed |
| 68 | if (context) { |
| 69 | sk_sp<GrTexture> texture(img->asTextureRef(context)); |
| 70 | REPORTER_ASSERT(reporter, texture); |
| 71 | } |
| 72 | #endif |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 73 | |
| 74 | //-------------- |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 75 | // Test getROPixels - this should always succeed regardless of backing store |
| 76 | SkBitmap bitmap; |
| 77 | REPORTER_ASSERT(reporter, img->getROPixels(&bitmap)); |
robertphillips | 0533d6e | 2016-04-26 14:33:36 -0700 | [diff] [blame] | 78 | REPORTER_ASSERT(reporter, size == bitmap.width()); |
| 79 | REPORTER_ASSERT(reporter, size == bitmap.height()); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 80 | |
| 81 | //-------------- |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 82 | // Test that draw restricts itself to the subset |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 83 | SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlphaType); |
| 84 | |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 85 | sk_sp<SkSpecialSurface> surf(img->makeSurface(info)); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 86 | |
| 87 | SkCanvas* canvas = surf->getCanvas(); |
| 88 | |
| 89 | canvas->clear(SK_ColorBLUE); |
robertphillips | e8c3497 | 2016-02-16 12:09:36 -0800 | [diff] [blame] | 90 | img->draw(canvas, SkIntToScalar(kPad), SkIntToScalar(kPad), nullptr); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 91 | |
| 92 | SkBitmap bm; |
| 93 | bm.allocN32Pixels(kFullSize, kFullSize, true); |
| 94 | |
| 95 | bool result = canvas->readPixels(bm.info(), bm.getPixels(), bm.rowBytes(), 0, 0); |
| 96 | SkASSERT_RELEASE(result); |
| 97 | |
| 98 | // Only the center (red) portion should've been drawn into the canvas |
| 99 | REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kPad-1, kPad-1)); |
| 100 | REPORTER_ASSERT(reporter, SK_ColorRED == bm.getColor(kPad, kPad)); |
| 101 | REPORTER_ASSERT(reporter, SK_ColorRED == bm.getColor(kSmallerSize+kPad-1, |
| 102 | kSmallerSize+kPad-1)); |
| 103 | REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kSmallerSize+kPad, |
| 104 | kSmallerSize+kPad)); |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 105 | |
| 106 | //-------------- |
| 107 | // Test that makeTightSubset & makeTightSurface return appropriately sized objects |
| 108 | // of the correct backing type |
| 109 | SkIRect newSubset = SkIRect::MakeWH(subset.width(), subset.height()); |
| 110 | { |
| 111 | sk_sp<SkImage> tightImg(img->makeTightSubset(newSubset)); |
| 112 | |
| 113 | REPORTER_ASSERT(reporter, tightImg->width() == subset.width()); |
| 114 | REPORTER_ASSERT(reporter, tightImg->height() == subset.height()); |
| 115 | REPORTER_ASSERT(reporter, peekTextureSucceeds == !!tightImg->getTexture()); |
| 116 | SkPixmap tmpPixmap; |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 117 | REPORTER_ASSERT(reporter, peekTextureSucceeds != !!tightImg->peekPixels(&tmpPixmap)); |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 118 | } |
| 119 | { |
| 120 | SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), |
| 121 | kPremul_SkAlphaType); |
| 122 | sk_sp<SkSurface> tightSurf(img->makeTightSurface(info)); |
| 123 | |
| 124 | REPORTER_ASSERT(reporter, tightSurf->width() == subset.width()); |
| 125 | REPORTER_ASSERT(reporter, tightSurf->height() == subset.height()); |
| 126 | REPORTER_ASSERT(reporter, peekTextureSucceeds == |
| 127 | !!tightSurf->getTextureHandle(SkSurface::kDiscardWrite_BackendHandleAccess)); |
| 128 | SkPixmap tmpPixmap; |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 129 | REPORTER_ASSERT(reporter, peekTextureSucceeds != !!tightSurf->peekPixels(&tmpPixmap)); |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 130 | } |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | DEF_TEST(SpecialImage_Raster, reporter) { |
| 134 | SkBitmap bm = create_bm(); |
| 135 | |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 136 | sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromRaster( |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 137 | SkIRect::MakeWH(kFullSize, kFullSize), |
| 138 | bm)); |
| 139 | |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 140 | const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
| 141 | |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 142 | { |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 143 | sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromRaster(subset, bm)); |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 144 | test_image(subSImg1, reporter, nullptr, false, kPad, kFullSize); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | { |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 148 | sk_sp<SkSpecialImage> subSImg2(fullSImage->makeSubset(subset)); |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 149 | test_image(subSImg2, reporter, nullptr, false, 0, kSmallerSize); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 150 | } |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | DEF_TEST(SpecialImage_Image, reporter) { |
| 154 | SkBitmap bm = create_bm(); |
| 155 | |
reed | 9ce9d67 | 2016-03-17 10:51:11 -0700 | [diff] [blame] | 156 | sk_sp<SkImage> fullImage(SkImage::MakeFromBitmap(bm)); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 157 | |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 158 | sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromImage( |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 159 | SkIRect::MakeWH(kFullSize, kFullSize), |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 160 | fullImage)); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 161 | |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 162 | const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
| 163 | |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 164 | { |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 165 | sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromImage(subset, fullImage)); |
robertphillips | 0533d6e | 2016-04-26 14:33:36 -0700 | [diff] [blame] | 166 | test_image(subSImg1, reporter, nullptr, false, kPad, kSmallerSize); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | { |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 170 | sk_sp<SkSpecialImage> subSImg2(fullSImage->makeSubset(subset)); |
robertphillips | 0533d6e | 2016-04-26 14:33:36 -0700 | [diff] [blame] | 171 | test_image(subSImg2, reporter, nullptr, false, kPad, kSmallerSize); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 172 | } |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 173 | } |
| 174 | |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 175 | DEF_TEST(SpecialImage_Pixmap, reporter) { |
| 176 | SkAutoPixmapStorage pixmap; |
| 177 | |
| 178 | const SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlphaType); |
| 179 | pixmap.alloc(info); |
| 180 | pixmap.erase(SK_ColorGREEN); |
| 181 | |
| 182 | const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
| 183 | |
| 184 | pixmap.erase(SK_ColorRED, subset); |
| 185 | |
| 186 | { |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 187 | sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromPixmap(subset, pixmap, |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 188 | nullptr, nullptr)); |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 189 | test_image(img, reporter, nullptr, false, kPad, kFullSize); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 190 | } |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 194 | #if SK_SUPPORT_GPU |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 195 | |
| 196 | static void test_texture_backed(skiatest::Reporter* reporter, |
| 197 | const sk_sp<SkSpecialImage>& orig, |
| 198 | const sk_sp<SkSpecialImage>& gpuBacked) { |
| 199 | REPORTER_ASSERT(reporter, gpuBacked); |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 200 | REPORTER_ASSERT(reporter, gpuBacked->isTextureBacked()); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 201 | REPORTER_ASSERT(reporter, gpuBacked->uniqueID() == orig->uniqueID()); |
| 202 | REPORTER_ASSERT(reporter, gpuBacked->subset().width() == orig->subset().width() && |
| 203 | gpuBacked->subset().height() == orig->subset().height()); |
| 204 | } |
| 205 | |
| 206 | // Test out the SkSpecialImage::makeTextureImage entry point |
bsalomon | 68d9134 | 2016-04-12 09:59:58 -0700 | [diff] [blame] | 207 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo) { |
bsalomon | f2f1c17 | 2016-04-05 12:59:06 -0700 | [diff] [blame] | 208 | GrContext* context = ctxInfo.fGrContext; |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 209 | SkBitmap bm = create_bm(); |
| 210 | |
| 211 | const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
| 212 | |
| 213 | { |
| 214 | // raster |
| 215 | sk_sp<SkSpecialImage> rasterImage(SkSpecialImage::MakeFromRaster( |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 216 | SkIRect::MakeWH(kFullSize, |
| 217 | kFullSize), |
| 218 | bm)); |
| 219 | |
| 220 | { |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 221 | sk_sp<SkSpecialImage> fromRaster(rasterImage->makeTextureImage(context)); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 222 | test_texture_backed(reporter, rasterImage, fromRaster); |
| 223 | } |
| 224 | |
| 225 | { |
| 226 | sk_sp<SkSpecialImage> subRasterImage(rasterImage->makeSubset(subset)); |
| 227 | |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 228 | sk_sp<SkSpecialImage> fromSubRaster(subRasterImage->makeTextureImage(context)); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 229 | test_texture_backed(reporter, subRasterImage, fromSubRaster); |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | { |
| 234 | // gpu |
| 235 | GrSurfaceDesc desc; |
| 236 | desc.fConfig = kSkia8888_GrPixelConfig; |
| 237 | desc.fFlags = kNone_GrSurfaceFlags; |
| 238 | desc.fWidth = kFullSize; |
| 239 | desc.fHeight = kFullSize; |
| 240 | |
robertphillips | c91fd34 | 2016-04-25 12:32:54 -0700 | [diff] [blame] | 241 | sk_sp<GrTexture> texture(context->textureProvider()->createTexture(desc, |
| 242 | SkBudgeted::kNo, |
| 243 | bm.getPixels(), |
| 244 | 0)); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 245 | if (!texture) { |
| 246 | return; |
| 247 | } |
| 248 | |
| 249 | sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeFromGpu( |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 250 | SkIRect::MakeWH(kFullSize, |
| 251 | kFullSize), |
| 252 | kNeedNewImageUniqueID_SpecialImage, |
robertphillips | c91fd34 | 2016-04-25 12:32:54 -0700 | [diff] [blame] | 253 | std::move(texture))); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 254 | |
| 255 | { |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 256 | sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(context)); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 257 | test_texture_backed(reporter, gpuImage, fromGPU); |
| 258 | } |
| 259 | |
| 260 | { |
| 261 | sk_sp<SkSpecialImage> subGPUImage(gpuImage->makeSubset(subset)); |
| 262 | |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 263 | sk_sp<SkSpecialImage> fromSubGPU(subGPUImage->makeTextureImage(context)); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 264 | test_texture_backed(reporter, subGPUImage, fromSubGPU); |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | |
bsalomon | 68d9134 | 2016-04-12 09:59:58 -0700 | [diff] [blame] | 269 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) { |
bsalomon | f2f1c17 | 2016-04-05 12:59:06 -0700 | [diff] [blame] | 270 | GrContext* context = ctxInfo.fGrContext; |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 271 | SkBitmap bm = create_bm(); |
| 272 | |
| 273 | GrSurfaceDesc desc; |
| 274 | desc.fConfig = kSkia8888_GrPixelConfig; |
| 275 | desc.fFlags = kNone_GrSurfaceFlags; |
| 276 | desc.fWidth = kFullSize; |
| 277 | desc.fHeight = kFullSize; |
| 278 | |
robertphillips | c91fd34 | 2016-04-25 12:32:54 -0700 | [diff] [blame] | 279 | sk_sp<GrTexture> texture(context->textureProvider()->createTexture(desc, |
| 280 | SkBudgeted::kNo, |
| 281 | bm.getPixels(), 0)); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 282 | if (!texture) { |
| 283 | return; |
| 284 | } |
| 285 | |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 286 | sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeFromGpu( |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 287 | SkIRect::MakeWH(kFullSize, kFullSize), |
| 288 | kNeedNewImageUniqueID_SpecialImage, |
| 289 | texture)); |
| 290 | |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 291 | const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
| 292 | |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 293 | { |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 294 | sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromGpu( |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 295 | subset, |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 296 | kNeedNewImageUniqueID_SpecialImage, |
| 297 | texture)); |
robertphillips | 0533d6e | 2016-04-26 14:33:36 -0700 | [diff] [blame] | 298 | test_image(subSImg1, reporter, context, true, kPad, kSmallerSize); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | { |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 302 | sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); |
robertphillips | 0533d6e | 2016-04-26 14:33:36 -0700 | [diff] [blame] | 303 | test_image(subSImg2, reporter, context, true, kPad, kSmallerSize); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 304 | } |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | #endif |