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 | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 78 | if (context) { |
| 79 | REPORTER_ASSERT(reporter, kSmallerSize == bitmap.width()); |
| 80 | REPORTER_ASSERT(reporter, kSmallerSize == bitmap.height()); |
| 81 | } else { |
| 82 | REPORTER_ASSERT(reporter, size == bitmap.width()); |
| 83 | REPORTER_ASSERT(reporter, size == bitmap.height()); |
| 84 | } |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 85 | |
| 86 | //-------------- |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 87 | // Test that draw restricts itself to the subset |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 88 | SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlphaType); |
| 89 | |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 90 | sk_sp<SkSpecialSurface> surf(img->makeSurface(info)); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 91 | |
| 92 | SkCanvas* canvas = surf->getCanvas(); |
| 93 | |
| 94 | canvas->clear(SK_ColorBLUE); |
robertphillips | e8c3497 | 2016-02-16 12:09:36 -0800 | [diff] [blame] | 95 | img->draw(canvas, SkIntToScalar(kPad), SkIntToScalar(kPad), nullptr); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 96 | |
| 97 | SkBitmap bm; |
| 98 | bm.allocN32Pixels(kFullSize, kFullSize, true); |
| 99 | |
| 100 | bool result = canvas->readPixels(bm.info(), bm.getPixels(), bm.rowBytes(), 0, 0); |
| 101 | SkASSERT_RELEASE(result); |
| 102 | |
| 103 | // Only the center (red) portion should've been drawn into the canvas |
| 104 | REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kPad-1, kPad-1)); |
| 105 | REPORTER_ASSERT(reporter, SK_ColorRED == bm.getColor(kPad, kPad)); |
| 106 | REPORTER_ASSERT(reporter, SK_ColorRED == bm.getColor(kSmallerSize+kPad-1, |
| 107 | kSmallerSize+kPad-1)); |
| 108 | REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kSmallerSize+kPad, |
| 109 | kSmallerSize+kPad)); |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 110 | |
| 111 | //-------------- |
| 112 | // Test that makeTightSubset & makeTightSurface return appropriately sized objects |
| 113 | // of the correct backing type |
| 114 | SkIRect newSubset = SkIRect::MakeWH(subset.width(), subset.height()); |
| 115 | { |
| 116 | sk_sp<SkImage> tightImg(img->makeTightSubset(newSubset)); |
| 117 | |
| 118 | REPORTER_ASSERT(reporter, tightImg->width() == subset.width()); |
| 119 | REPORTER_ASSERT(reporter, tightImg->height() == subset.height()); |
| 120 | REPORTER_ASSERT(reporter, peekTextureSucceeds == !!tightImg->getTexture()); |
| 121 | SkPixmap tmpPixmap; |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 122 | REPORTER_ASSERT(reporter, peekTextureSucceeds != !!tightImg->peekPixels(&tmpPixmap)); |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 123 | } |
| 124 | { |
| 125 | SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), |
| 126 | kPremul_SkAlphaType); |
| 127 | sk_sp<SkSurface> tightSurf(img->makeTightSurface(info)); |
| 128 | |
| 129 | REPORTER_ASSERT(reporter, tightSurf->width() == subset.width()); |
| 130 | REPORTER_ASSERT(reporter, tightSurf->height() == subset.height()); |
| 131 | REPORTER_ASSERT(reporter, peekTextureSucceeds == |
| 132 | !!tightSurf->getTextureHandle(SkSurface::kDiscardWrite_BackendHandleAccess)); |
| 133 | SkPixmap tmpPixmap; |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 134 | REPORTER_ASSERT(reporter, peekTextureSucceeds != !!tightSurf->peekPixels(&tmpPixmap)); |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 135 | } |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | DEF_TEST(SpecialImage_Raster, reporter) { |
| 139 | SkBitmap bm = create_bm(); |
| 140 | |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 141 | sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromRaster( |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 142 | SkIRect::MakeWH(kFullSize, kFullSize), |
| 143 | bm)); |
| 144 | |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 145 | const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
| 146 | |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 147 | { |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 148 | sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromRaster(subset, bm)); |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 149 | test_image(subSImg1, reporter, nullptr, false, kPad, kFullSize); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | { |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 153 | sk_sp<SkSpecialImage> subSImg2(fullSImage->makeSubset(subset)); |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 154 | test_image(subSImg2, reporter, nullptr, false, 0, kSmallerSize); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 155 | } |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | DEF_TEST(SpecialImage_Image, reporter) { |
| 159 | SkBitmap bm = create_bm(); |
| 160 | |
reed | 9ce9d67 | 2016-03-17 10:51:11 -0700 | [diff] [blame] | 161 | sk_sp<SkImage> fullImage(SkImage::MakeFromBitmap(bm)); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 162 | |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 163 | sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromImage( |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 164 | SkIRect::MakeWH(kFullSize, kFullSize), |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 165 | fullImage)); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 166 | |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 167 | const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
| 168 | |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 169 | { |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 170 | sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromImage(subset, fullImage)); |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 171 | test_image(subSImg1, reporter, nullptr, false, kPad, kFullSize); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | { |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 175 | sk_sp<SkSpecialImage> subSImg2(fullSImage->makeSubset(subset)); |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 176 | test_image(subSImg2, reporter, nullptr, false, 0, kSmallerSize); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 177 | } |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 178 | } |
| 179 | |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 180 | DEF_TEST(SpecialImage_Pixmap, reporter) { |
| 181 | SkAutoPixmapStorage pixmap; |
| 182 | |
| 183 | const SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlphaType); |
| 184 | pixmap.alloc(info); |
| 185 | pixmap.erase(SK_ColorGREEN); |
| 186 | |
| 187 | const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
| 188 | |
| 189 | pixmap.erase(SK_ColorRED, subset); |
| 190 | |
| 191 | { |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 192 | sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromPixmap(subset, pixmap, |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 193 | nullptr, nullptr)); |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 194 | test_image(img, reporter, nullptr, false, kPad, kFullSize); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 195 | } |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 199 | #if SK_SUPPORT_GPU |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 200 | |
| 201 | static void test_texture_backed(skiatest::Reporter* reporter, |
| 202 | const sk_sp<SkSpecialImage>& orig, |
| 203 | const sk_sp<SkSpecialImage>& gpuBacked) { |
| 204 | REPORTER_ASSERT(reporter, gpuBacked); |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 205 | REPORTER_ASSERT(reporter, gpuBacked->isTextureBacked()); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 206 | REPORTER_ASSERT(reporter, gpuBacked->uniqueID() == orig->uniqueID()); |
| 207 | REPORTER_ASSERT(reporter, gpuBacked->subset().width() == orig->subset().width() && |
| 208 | gpuBacked->subset().height() == orig->subset().height()); |
| 209 | } |
| 210 | |
| 211 | // Test out the SkSpecialImage::makeTextureImage entry point |
bsalomon | 68d9134 | 2016-04-12 09:59:58 -0700 | [diff] [blame] | 212 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo) { |
bsalomon | 8b7451a | 2016-05-11 06:33:06 -0700 | [diff] [blame^] | 213 | GrContext* context = ctxInfo.grContext(); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 214 | SkBitmap bm = create_bm(); |
| 215 | |
| 216 | const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
| 217 | |
| 218 | { |
| 219 | // raster |
| 220 | sk_sp<SkSpecialImage> rasterImage(SkSpecialImage::MakeFromRaster( |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 221 | SkIRect::MakeWH(kFullSize, |
| 222 | kFullSize), |
| 223 | bm)); |
| 224 | |
| 225 | { |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 226 | sk_sp<SkSpecialImage> fromRaster(rasterImage->makeTextureImage(context)); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 227 | test_texture_backed(reporter, rasterImage, fromRaster); |
| 228 | } |
| 229 | |
| 230 | { |
| 231 | sk_sp<SkSpecialImage> subRasterImage(rasterImage->makeSubset(subset)); |
| 232 | |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 233 | sk_sp<SkSpecialImage> fromSubRaster(subRasterImage->makeTextureImage(context)); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 234 | test_texture_backed(reporter, subRasterImage, fromSubRaster); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | { |
| 239 | // gpu |
| 240 | GrSurfaceDesc desc; |
| 241 | desc.fConfig = kSkia8888_GrPixelConfig; |
| 242 | desc.fFlags = kNone_GrSurfaceFlags; |
| 243 | desc.fWidth = kFullSize; |
| 244 | desc.fHeight = kFullSize; |
| 245 | |
robertphillips | c91fd34 | 2016-04-25 12:32:54 -0700 | [diff] [blame] | 246 | sk_sp<GrTexture> texture(context->textureProvider()->createTexture(desc, |
| 247 | SkBudgeted::kNo, |
| 248 | bm.getPixels(), |
| 249 | 0)); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 250 | if (!texture) { |
| 251 | return; |
| 252 | } |
| 253 | |
| 254 | sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeFromGpu( |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 255 | SkIRect::MakeWH(kFullSize, |
| 256 | kFullSize), |
| 257 | kNeedNewImageUniqueID_SpecialImage, |
robertphillips | c91fd34 | 2016-04-25 12:32:54 -0700 | [diff] [blame] | 258 | std::move(texture))); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 259 | |
| 260 | { |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 261 | sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(context)); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 262 | test_texture_backed(reporter, gpuImage, fromGPU); |
| 263 | } |
| 264 | |
| 265 | { |
| 266 | sk_sp<SkSpecialImage> subGPUImage(gpuImage->makeSubset(subset)); |
| 267 | |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 268 | sk_sp<SkSpecialImage> fromSubGPU(subGPUImage->makeTextureImage(context)); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 269 | test_texture_backed(reporter, subGPUImage, fromSubGPU); |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | |
bsalomon | 68d9134 | 2016-04-12 09:59:58 -0700 | [diff] [blame] | 274 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) { |
bsalomon | 8b7451a | 2016-05-11 06:33:06 -0700 | [diff] [blame^] | 275 | GrContext* context = ctxInfo.grContext(); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 276 | SkBitmap bm = create_bm(); |
| 277 | |
| 278 | GrSurfaceDesc desc; |
| 279 | desc.fConfig = kSkia8888_GrPixelConfig; |
| 280 | desc.fFlags = kNone_GrSurfaceFlags; |
| 281 | desc.fWidth = kFullSize; |
| 282 | desc.fHeight = kFullSize; |
| 283 | |
robertphillips | c91fd34 | 2016-04-25 12:32:54 -0700 | [diff] [blame] | 284 | sk_sp<GrTexture> texture(context->textureProvider()->createTexture(desc, |
| 285 | SkBudgeted::kNo, |
| 286 | bm.getPixels(), 0)); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 287 | if (!texture) { |
| 288 | return; |
| 289 | } |
| 290 | |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 291 | sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeFromGpu( |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 292 | SkIRect::MakeWH(kFullSize, kFullSize), |
| 293 | kNeedNewImageUniqueID_SpecialImage, |
| 294 | texture)); |
| 295 | |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 296 | const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
| 297 | |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 298 | { |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 299 | sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromGpu( |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 300 | subset, |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 301 | kNeedNewImageUniqueID_SpecialImage, |
| 302 | texture)); |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 303 | test_image(subSImg1, reporter, context, true, kPad, kFullSize); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | { |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 307 | sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset)); |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 308 | test_image(subSImg2, reporter, context, true, kPad, kFullSize); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 309 | } |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | #endif |