blob: a9cd1c7b5645d941a22587abf036c31e6147a1f7 [file] [log] [blame]
robertphillipsb6c65e92016-02-04 10:52:42 -08001/*
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
robertphillipsc5035e72016-03-17 06:58:39 -07008#include "SkAutoPixmapStorage.h"
robertphillipsb6c65e92016-02-04 10:52:42 -08009#include "SkBitmap.h"
10#include "SkCanvas.h"
11#include "SkImage.h"
robertphillipsc5035e72016-03-17 06:58:39 -070012#include "SkPixmap.h"
robertphillipsb6c65e92016-02-04 10:52:42 -080013#include "SkSpecialImage.h"
14#include "SkSpecialSurface.h"
robertphillipsb4bd11e2016-03-21 13:44:18 -070015#include "SkSurface.h"
robertphillipsb6c65e92016-02-04 10:52:42 -080016#include "Test.h"
17
18#if SK_SUPPORT_GPU
Robert Phillips8caf85f2018-04-05 09:30:38 -040019#include "GrBackendSurface.h"
robertphillipsb6c65e92016-02-04 10:52:42 -080020#include "GrContext.h"
Robert Phillips1afd4cd2018-01-08 13:40:32 -050021#include "GrContextPriv.h"
Robert Phillips0bd24dc2018-01-16 08:06:32 -050022#include "GrProxyProvider.h"
Robert Phillips37430132016-11-09 06:50:43 -050023#include "GrSurfaceProxy.h"
Mike Reed84dd8572017-03-08 22:21:00 -050024#include "GrTextureProxy.h"
Brian Osman3b655982017-03-07 16:58:08 -050025#include "SkGr.h"
robertphillipsb6c65e92016-02-04 10:52:42 -080026#endif
27
robertphillipsb6c65e92016-02-04 10:52:42 -080028
29// This test creates backing resources exactly sized to [kFullSize x kFullSize].
30// It then wraps them in an SkSpecialImage with only the center (red) region being active.
31// It then draws the SkSpecialImage to a full sized (all blue) canvas and checks that none
32// of the inactive (green) region leaked out.
33
34static const int kSmallerSize = 10;
35static const int kPad = 3;
36static const int kFullSize = kSmallerSize + 2 * kPad;
37
38// Create a bitmap with red in the center and green around it
39static SkBitmap create_bm() {
40 SkBitmap bm;
41 bm.allocN32Pixels(kFullSize, kFullSize, true);
42
43 SkCanvas temp(bm);
44
45 temp.clear(SK_ColorGREEN);
46 SkPaint p;
47 p.setColor(SK_ColorRED);
48 p.setAntiAlias(false);
49
50 temp.drawRect(SkRect::MakeXYWH(SkIntToScalar(kPad), SkIntToScalar(kPad),
halcanary9d524f22016-03-29 09:03:52 -070051 SkIntToScalar(kSmallerSize), SkIntToScalar(kSmallerSize)),
robertphillipsb6c65e92016-02-04 10:52:42 -080052 p);
53
54 return bm;
55}
56
57// Basic test of the SkSpecialImage public API (e.g., peekTexture, peekPixels & draw)
robertphillips37bd7c32016-03-17 14:31:39 -070058static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* reporter,
Robert Phillips6de99042017-01-31 11:31:39 -050059 GrContext* context, bool isGPUBacked,
robertphillipsc5035e72016-03-17 06:58:39 -070060 int offset, int size) {
robertphillips3e302272016-04-20 11:48:36 -070061 const SkIRect subset = img->subset();
robertphillipsc5035e72016-03-17 06:58:39 -070062 REPORTER_ASSERT(reporter, offset == subset.left());
63 REPORTER_ASSERT(reporter, offset == subset.top());
robertphillipsb6c65e92016-02-04 10:52:42 -080064 REPORTER_ASSERT(reporter, kSmallerSize == subset.width());
65 REPORTER_ASSERT(reporter, kSmallerSize == subset.height());
66
67 //--------------
Robert Phillips2c6d2bf2017-02-21 10:19:29 -050068 // Test that isTextureBacked reports the correct backing type
Robert Phillips6de99042017-01-31 11:31:39 -050069 REPORTER_ASSERT(reporter, isGPUBacked == img->isTextureBacked());
robertphillips64612512016-04-08 12:10:42 -070070
71#if SK_SUPPORT_GPU
72 //--------------
Robert Phillips8e1c4e62017-02-19 12:27:01 -050073 // Test asTextureProxyRef - as long as there is a context this should succeed
robertphillips64612512016-04-08 12:10:42 -070074 if (context) {
Robert Phillips8e1c4e62017-02-19 12:27:01 -050075 sk_sp<GrTextureProxy> proxy(img->asTextureProxyRef(context));
76 REPORTER_ASSERT(reporter, proxy);
robertphillips64612512016-04-08 12:10:42 -070077 }
78#endif
robertphillipsb6c65e92016-02-04 10:52:42 -080079
80 //--------------
robertphillips64612512016-04-08 12:10:42 -070081 // Test getROPixels - this should always succeed regardless of backing store
82 SkBitmap bitmap;
83 REPORTER_ASSERT(reporter, img->getROPixels(&bitmap));
robertphillipsed086ca2016-04-26 15:02:25 -070084 if (context) {
85 REPORTER_ASSERT(reporter, kSmallerSize == bitmap.width());
86 REPORTER_ASSERT(reporter, kSmallerSize == bitmap.height());
87 } else {
88 REPORTER_ASSERT(reporter, size == bitmap.width());
89 REPORTER_ASSERT(reporter, size == bitmap.height());
90 }
robertphillipsb6c65e92016-02-04 10:52:42 -080091
92 //--------------
robertphillipsb4bd11e2016-03-21 13:44:18 -070093 // Test that draw restricts itself to the subset
brianosmaneed6b0e2016-09-23 13:04:05 -070094 SkImageFilter::OutputProperties outProps(img->getColorSpace());
95 sk_sp<SkSpecialSurface> surf(img->makeSurface(outProps, SkISize::Make(kFullSize, kFullSize),
Matt Sarettcb6266b2017-01-17 10:48:53 -050096 kPremul_SkAlphaType));
robertphillipsb6c65e92016-02-04 10:52:42 -080097
98 SkCanvas* canvas = surf->getCanvas();
99
100 canvas->clear(SK_ColorBLUE);
robertphillipse8c34972016-02-16 12:09:36 -0800101 img->draw(canvas, SkIntToScalar(kPad), SkIntToScalar(kPad), nullptr);
robertphillipsb6c65e92016-02-04 10:52:42 -0800102
103 SkBitmap bm;
Matt Sarettcb6266b2017-01-17 10:48:53 -0500104 bm.allocN32Pixels(kFullSize, kFullSize, false);
robertphillipsb6c65e92016-02-04 10:52:42 -0800105
106 bool result = canvas->readPixels(bm.info(), bm.getPixels(), bm.rowBytes(), 0, 0);
107 SkASSERT_RELEASE(result);
108
109 // Only the center (red) portion should've been drawn into the canvas
110 REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kPad-1, kPad-1));
111 REPORTER_ASSERT(reporter, SK_ColorRED == bm.getColor(kPad, kPad));
112 REPORTER_ASSERT(reporter, SK_ColorRED == bm.getColor(kSmallerSize+kPad-1,
113 kSmallerSize+kPad-1));
114 REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kSmallerSize+kPad,
115 kSmallerSize+kPad));
robertphillipsb4bd11e2016-03-21 13:44:18 -0700116
117 //--------------
Robert Phillipsa5fdc972017-02-18 16:58:09 -0500118 // Test that asImage & makeTightSurface return appropriately sized objects
robertphillipsb4bd11e2016-03-21 13:44:18 -0700119 // of the correct backing type
120 SkIRect newSubset = SkIRect::MakeWH(subset.width(), subset.height());
121 {
Robert Phillipsa5fdc972017-02-18 16:58:09 -0500122 sk_sp<SkImage> tightImg(img->asImage(&newSubset));
robertphillipsb4bd11e2016-03-21 13:44:18 -0700123
124 REPORTER_ASSERT(reporter, tightImg->width() == subset.width());
125 REPORTER_ASSERT(reporter, tightImg->height() == subset.height());
Robert Phillips0ae6faa2017-03-21 16:22:00 -0400126 REPORTER_ASSERT(reporter, isGPUBacked == tightImg->isTextureBacked());
robertphillipsb4bd11e2016-03-21 13:44:18 -0700127 SkPixmap tmpPixmap;
Robert Phillips6de99042017-01-31 11:31:39 -0500128 REPORTER_ASSERT(reporter, isGPUBacked != !!tightImg->peekPixels(&tmpPixmap));
robertphillipsb4bd11e2016-03-21 13:44:18 -0700129 }
Robert Phillips8caf85f2018-04-05 09:30:38 -0400130#if SK_SUPPORT_GPU
robertphillipsb4bd11e2016-03-21 13:44:18 -0700131 {
brianosmaneed6b0e2016-09-23 13:04:05 -0700132 SkImageFilter::OutputProperties outProps(img->getColorSpace());
133 sk_sp<SkSurface> tightSurf(img->makeTightSurface(outProps, subset.size()));
robertphillipsb4bd11e2016-03-21 13:44:18 -0700134
135 REPORTER_ASSERT(reporter, tightSurf->width() == subset.width());
136 REPORTER_ASSERT(reporter, tightSurf->height() == subset.height());
Robert Phillips8caf85f2018-04-05 09:30:38 -0400137 GrBackendTexture backendTex = tightSurf->getBackendTexture(
138 SkSurface::kDiscardWrite_BackendHandleAccess);
139 REPORTER_ASSERT(reporter, isGPUBacked == backendTex.isValid());
robertphillipsb4bd11e2016-03-21 13:44:18 -0700140 SkPixmap tmpPixmap;
Robert Phillips6de99042017-01-31 11:31:39 -0500141 REPORTER_ASSERT(reporter, isGPUBacked != !!tightSurf->peekPixels(&tmpPixmap));
robertphillipsb4bd11e2016-03-21 13:44:18 -0700142 }
Robert Phillips8caf85f2018-04-05 09:30:38 -0400143#endif
robertphillipsb6c65e92016-02-04 10:52:42 -0800144}
145
146DEF_TEST(SpecialImage_Raster, reporter) {
147 SkBitmap bm = create_bm();
148
robertphillips37bd7c32016-03-17 14:31:39 -0700149 sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromRaster(
robertphillipsc5035e72016-03-17 06:58:39 -0700150 SkIRect::MakeWH(kFullSize, kFullSize),
151 bm));
152
robertphillipsb6c65e92016-02-04 10:52:42 -0800153 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
154
robertphillipsc5035e72016-03-17 06:58:39 -0700155 {
robertphillips3e302272016-04-20 11:48:36 -0700156 sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromRaster(subset, bm));
robertphillips64612512016-04-08 12:10:42 -0700157 test_image(subSImg1, reporter, nullptr, false, kPad, kFullSize);
robertphillipsc5035e72016-03-17 06:58:39 -0700158 }
159
160 {
robertphillips37bd7c32016-03-17 14:31:39 -0700161 sk_sp<SkSpecialImage> subSImg2(fullSImage->makeSubset(subset));
robertphillips64612512016-04-08 12:10:42 -0700162 test_image(subSImg2, reporter, nullptr, false, 0, kSmallerSize);
robertphillipsc5035e72016-03-17 06:58:39 -0700163 }
robertphillipsb6c65e92016-02-04 10:52:42 -0800164}
165
Brian Osman61624f02016-12-09 14:51:59 -0500166static void test_specialimage_image(skiatest::Reporter* reporter, SkColorSpace* dstColorSpace) {
robertphillipsb6c65e92016-02-04 10:52:42 -0800167 SkBitmap bm = create_bm();
168
reed9ce9d672016-03-17 10:51:11 -0700169 sk_sp<SkImage> fullImage(SkImage::MakeFromBitmap(bm));
robertphillipsb6c65e92016-02-04 10:52:42 -0800170
robertphillips37bd7c32016-03-17 14:31:39 -0700171 sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromImage(
robertphillipsc5035e72016-03-17 06:58:39 -0700172 SkIRect::MakeWH(kFullSize, kFullSize),
Brian Osman61624f02016-12-09 14:51:59 -0500173 fullImage, dstColorSpace));
robertphillipsc5035e72016-03-17 06:58:39 -0700174
robertphillipsb6c65e92016-02-04 10:52:42 -0800175 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
176
robertphillipsc5035e72016-03-17 06:58:39 -0700177 {
Brian Osman61624f02016-12-09 14:51:59 -0500178 sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromImage(subset, fullImage,
179 dstColorSpace));
robertphillipsed086ca2016-04-26 15:02:25 -0700180 test_image(subSImg1, reporter, nullptr, false, kPad, kFullSize);
robertphillipsc5035e72016-03-17 06:58:39 -0700181 }
182
183 {
robertphillips37bd7c32016-03-17 14:31:39 -0700184 sk_sp<SkSpecialImage> subSImg2(fullSImage->makeSubset(subset));
robertphillipsed086ca2016-04-26 15:02:25 -0700185 test_image(subSImg2, reporter, nullptr, false, 0, kSmallerSize);
robertphillipsc5035e72016-03-17 06:58:39 -0700186 }
robertphillipsb6c65e92016-02-04 10:52:42 -0800187}
188
Brian Osman7992da32016-11-18 11:28:24 -0500189DEF_TEST(SpecialImage_Image_Legacy, reporter) {
Brian Osman61624f02016-12-09 14:51:59 -0500190 SkColorSpace* legacyColorSpace = nullptr;
191 test_specialimage_image(reporter, legacyColorSpace);
Brian Osman7992da32016-11-18 11:28:24 -0500192}
193
194DEF_TEST(SpecialImage_Image_ColorSpaceAware, reporter) {
Matt Sarett77a7a1b2017-02-07 13:56:11 -0500195 sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeSRGB();
Brian Osman61624f02016-12-09 14:51:59 -0500196 test_specialimage_image(reporter, srgbColorSpace.get());
Brian Osman7992da32016-11-18 11:28:24 -0500197}
198
robertphillipsb6c65e92016-02-04 10:52:42 -0800199#if SK_SUPPORT_GPU
robertphillips83c17fa2016-03-18 08:14:27 -0700200
201static void test_texture_backed(skiatest::Reporter* reporter,
202 const sk_sp<SkSpecialImage>& orig,
203 const sk_sp<SkSpecialImage>& gpuBacked) {
204 REPORTER_ASSERT(reporter, gpuBacked);
robertphillips64612512016-04-08 12:10:42 -0700205 REPORTER_ASSERT(reporter, gpuBacked->isTextureBacked());
robertphillips83c17fa2016-03-18 08:14:27 -0700206 REPORTER_ASSERT(reporter, gpuBacked->uniqueID() == orig->uniqueID());
207 REPORTER_ASSERT(reporter, gpuBacked->subset().width() == orig->subset().width() &&
208 gpuBacked->subset().height() == orig->subset().height());
brianosmanafbf71d2016-07-21 07:15:37 -0700209 REPORTER_ASSERT(reporter, gpuBacked->getColorSpace() == orig->getColorSpace());
robertphillips83c17fa2016-03-18 08:14:27 -0700210}
211
212// Test out the SkSpecialImage::makeTextureImage entry point
bsalomon68d91342016-04-12 09:59:58 -0700213DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo) {
bsalomon8b7451a2016-05-11 06:33:06 -0700214 GrContext* context = ctxInfo.grContext();
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500215 GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
robertphillips83c17fa2016-03-18 08:14:27 -0700216 SkBitmap bm = create_bm();
217
218 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
219
220 {
221 // raster
222 sk_sp<SkSpecialImage> rasterImage(SkSpecialImage::MakeFromRaster(
robertphillips83c17fa2016-03-18 08:14:27 -0700223 SkIRect::MakeWH(kFullSize,
224 kFullSize),
225 bm));
226
227 {
robertphillips3e302272016-04-20 11:48:36 -0700228 sk_sp<SkSpecialImage> fromRaster(rasterImage->makeTextureImage(context));
robertphillips83c17fa2016-03-18 08:14:27 -0700229 test_texture_backed(reporter, rasterImage, fromRaster);
230 }
231
232 {
233 sk_sp<SkSpecialImage> subRasterImage(rasterImage->makeSubset(subset));
234
robertphillips3e302272016-04-20 11:48:36 -0700235 sk_sp<SkSpecialImage> fromSubRaster(subRasterImage->makeTextureImage(context));
robertphillips83c17fa2016-03-18 08:14:27 -0700236 test_texture_backed(reporter, subRasterImage, fromSubRaster);
237 }
238 }
239
240 {
241 // gpu
Robert Phillips2c6d2bf2017-02-21 10:19:29 -0500242 const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->caps());
robertphillips83c17fa2016-03-18 08:14:27 -0700243
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500244 sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(
Brian Salomon58389b92018-03-07 13:01:25 -0500245 desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes());
Robert Phillips2f493142017-03-02 18:18:38 -0500246 if (!proxy) {
robertphillips83c17fa2016-03-18 08:14:27 -0700247 return;
248 }
249
Robert Phillips2c6d2bf2017-02-21 10:19:29 -0500250 sk_sp<SkSpecialImage> gpuImage(SkSpecialImage::MakeDeferredFromGpu(
Robert Phillips2f493142017-03-02 18:18:38 -0500251 context,
252 SkIRect::MakeWH(kFullSize, kFullSize),
253 kNeedNewImageUniqueID_SpecialImage,
254 std::move(proxy), nullptr));
robertphillips83c17fa2016-03-18 08:14:27 -0700255
256 {
robertphillips3e302272016-04-20 11:48:36 -0700257 sk_sp<SkSpecialImage> fromGPU(gpuImage->makeTextureImage(context));
robertphillips83c17fa2016-03-18 08:14:27 -0700258 test_texture_backed(reporter, gpuImage, fromGPU);
259 }
260
261 {
262 sk_sp<SkSpecialImage> subGPUImage(gpuImage->makeSubset(subset));
263
robertphillips3e302272016-04-20 11:48:36 -0700264 sk_sp<SkSpecialImage> fromSubGPU(subGPUImage->makeTextureImage(context));
robertphillips83c17fa2016-03-18 08:14:27 -0700265 test_texture_backed(reporter, subGPUImage, fromSubGPU);
266 }
267 }
268}
269
bsalomon68d91342016-04-12 09:59:58 -0700270DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) {
bsalomon8b7451a2016-05-11 06:33:06 -0700271 GrContext* context = ctxInfo.grContext();
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500272 GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
robertphillipsb6c65e92016-02-04 10:52:42 -0800273 SkBitmap bm = create_bm();
274
Robert Phillips2c6d2bf2017-02-21 10:19:29 -0500275 const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->caps());
robertphillipsb6c65e92016-02-04 10:52:42 -0800276
Brian Salomon58389b92018-03-07 13:01:25 -0500277 sk_sp<GrTextureProxy> proxy =
278 proxyProvider->createTextureProxy(desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes());
Robert Phillips2f493142017-03-02 18:18:38 -0500279 if (!proxy) {
robertphillipsb6c65e92016-02-04 10:52:42 -0800280 return;
281 }
282
Robert Phillips2c6d2bf2017-02-21 10:19:29 -0500283 sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeDeferredFromGpu(
284 context,
robertphillipsc5035e72016-03-17 06:58:39 -0700285 SkIRect::MakeWH(kFullSize, kFullSize),
286 kNeedNewImageUniqueID_SpecialImage,
Robert Phillips2f493142017-03-02 18:18:38 -0500287 proxy, nullptr));
robertphillipsc5035e72016-03-17 06:58:39 -0700288
robertphillipsb6c65e92016-02-04 10:52:42 -0800289 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
290
robertphillipsc5035e72016-03-17 06:58:39 -0700291 {
Robert Phillips2c6d2bf2017-02-21 10:19:29 -0500292 sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeDeferredFromGpu(
Robert Phillips2f493142017-03-02 18:18:38 -0500293 context, subset,
robertphillipsc5035e72016-03-17 06:58:39 -0700294 kNeedNewImageUniqueID_SpecialImage,
Robert Phillips2f493142017-03-02 18:18:38 -0500295 std::move(proxy), nullptr));
robertphillipsed086ca2016-04-26 15:02:25 -0700296 test_image(subSImg1, reporter, context, true, kPad, kFullSize);
robertphillipsc5035e72016-03-17 06:58:39 -0700297 }
298
299 {
robertphillips37bd7c32016-03-17 14:31:39 -0700300 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset));
robertphillipsed086ca2016-04-26 15:02:25 -0700301 test_image(subSImg2, reporter, context, true, kPad, kFullSize);
robertphillipsc5035e72016-03-17 06:58:39 -0700302 }
robertphillipsb6c65e92016-02-04 10:52:42 -0800303}
304
Robert Phillips8bc06d02016-11-01 17:28:40 -0400305DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_DeferredGpu, reporter, ctxInfo) {
306 GrContext* context = ctxInfo.grContext();
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500307 GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
Robert Phillips8bc06d02016-11-01 17:28:40 -0400308 SkBitmap bm = create_bm();
309
310 GrSurfaceDesc desc;
Robert Phillips96be9df2017-07-21 14:17:45 +0000311 desc.fFlags = kNone_GrSurfaceFlags;
Robert Phillips8bc06d02016-11-01 17:28:40 -0400312 desc.fWidth = kFullSize;
313 desc.fHeight = kFullSize;
Robert Phillips16d8ec62017-07-27 16:16:25 -0400314 desc.fConfig = kSkia8888_GrPixelConfig;
Robert Phillips8bc06d02016-11-01 17:28:40 -0400315
Brian Salomon58389b92018-03-07 13:01:25 -0500316 sk_sp<GrTextureProxy> proxy =
317 proxyProvider->createTextureProxy(desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes());
Robert Phillips8bc06d02016-11-01 17:28:40 -0400318 if (!proxy) {
319 return;
320 }
321
322 sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeDeferredFromGpu(
323 context,
324 SkIRect::MakeWH(kFullSize, kFullSize),
325 kNeedNewImageUniqueID_SpecialImage,
Robert Phillips2f493142017-03-02 18:18:38 -0500326 proxy, nullptr));
Robert Phillips8bc06d02016-11-01 17:28:40 -0400327
328 const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
329
330 {
331 sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeDeferredFromGpu(
Robert Phillips2f493142017-03-02 18:18:38 -0500332 context, subset,
Robert Phillips8bc06d02016-11-01 17:28:40 -0400333 kNeedNewImageUniqueID_SpecialImage,
Robert Phillips2f493142017-03-02 18:18:38 -0500334 std::move(proxy), nullptr));
Robert Phillips8bc06d02016-11-01 17:28:40 -0400335 test_image(subSImg1, reporter, context, true, kPad, kFullSize);
336 }
337
338 {
339 sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset));
340 test_image(subSImg2, reporter, context, true, kPad, kFullSize);
341 }
342}
343
robertphillipsb6c65e92016-02-04 10:52:42 -0800344#endif