SpecialImageTest.cpp revision c5035e70cc3fb290f95fd1c052c637aa0dbaf9ea
1b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips/*
2b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips * Copyright 2016 Google Inc.
3b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips *
4b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips * Use of this source code is governed by a BSD-style license that can be
5b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips * found in the LICENSE file
6b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips */
7b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
8c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips#include "SkAutoPixmapStorage.h"
9b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips#include "SkBitmap.h"
10b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips#include "SkCanvas.h"
11b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips#include "SkImage.h"
12c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips#include "SkPixmap.h"
13b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips#include "SkSpecialImage.h"
14b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips#include "SkSpecialSurface.h"
15b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips#include "Test.h"
164418dbac3386f26c8da62ab242be9c178961eb18robertphillips#include "TestingSpecialImageAccess.h"
17b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
18b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips#if SK_SUPPORT_GPU
19b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips#include "GrContext.h"
20b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips#endif
21b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
22b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
23b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips// This test creates backing resources exactly sized to [kFullSize x kFullSize].
24b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips// It then wraps them in an SkSpecialImage with only the center (red) region being active.
25b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips// It then draws the SkSpecialImage to a full sized (all blue) canvas and checks that none
26b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips// of the inactive (green) region leaked out.
27b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
28b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillipsstatic const int kSmallerSize = 10;
29b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillipsstatic const int kPad = 3;
30b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillipsstatic const int kFullSize = kSmallerSize + 2 * kPad;
31b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
32b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips// Create a bitmap with red in the center and green around it
33b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillipsstatic SkBitmap create_bm() {
34b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    SkBitmap bm;
35b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    bm.allocN32Pixels(kFullSize, kFullSize, true);
36b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
37b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    SkCanvas temp(bm);
38b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
39b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    temp.clear(SK_ColorGREEN);
40b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    SkPaint p;
41b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    p.setColor(SK_ColorRED);
42b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    p.setAntiAlias(false);
43b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
44b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    temp.drawRect(SkRect::MakeXYWH(SkIntToScalar(kPad), SkIntToScalar(kPad),
45b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips                                   SkIntToScalar(kSmallerSize), SkIntToScalar(kSmallerSize)),
46b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips                  p);
47b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
48b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    return bm;
49b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips}
50b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
51b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips// Basic test of the SkSpecialImage public API (e.g., peekTexture, peekPixels & draw)
52b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillipsstatic void test_image(SkSpecialImage* img, skiatest::Reporter* reporter,
53c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                       bool peekPixelsSucceeds, bool peekTextureSucceeds,
54c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                       int offset, int size) {
55b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    const SkIRect subset = TestingSpecialImageAccess::Subset(img);
56c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    REPORTER_ASSERT(reporter, offset == subset.left());
57c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    REPORTER_ASSERT(reporter, offset == subset.top());
58b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    REPORTER_ASSERT(reporter, kSmallerSize == subset.width());
59b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    REPORTER_ASSERT(reporter, kSmallerSize == subset.height());
60b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
61b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    //--------------
62b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    REPORTER_ASSERT(reporter, peekTextureSucceeds == !!TestingSpecialImageAccess::PeekTexture(img));
63b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
64b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    //--------------
65b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    SkPixmap pixmap;
66b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    REPORTER_ASSERT(reporter, peekPixelsSucceeds ==
67b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips                              !!TestingSpecialImageAccess::PeekPixels(img, &pixmap));
68b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    if (peekPixelsSucceeds) {
69c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        REPORTER_ASSERT(reporter, size == pixmap.width());
70c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        REPORTER_ASSERT(reporter, size == pixmap.height());
71b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    }
72b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
73b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    //--------------
74b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlphaType);
75b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
76b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    SkAutoTUnref<SkSpecialSurface> surf(img->newSurface(info));
77b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
78b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    SkCanvas* canvas = surf->getCanvas();
79b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
80b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    canvas->clear(SK_ColorBLUE);
81e8c34974c42b302d78c5cc8c7dcfb36956256baarobertphillips    img->draw(canvas, SkIntToScalar(kPad), SkIntToScalar(kPad), nullptr);
82b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
83b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    SkBitmap bm;
84b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    bm.allocN32Pixels(kFullSize, kFullSize, true);
85b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
86b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    bool result = canvas->readPixels(bm.info(), bm.getPixels(), bm.rowBytes(), 0, 0);
87b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    SkASSERT_RELEASE(result);
88b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
89b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    // Only the center (red) portion should've been drawn into the canvas
90b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kPad-1, kPad-1));
91b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    REPORTER_ASSERT(reporter, SK_ColorRED  == bm.getColor(kPad, kPad));
92b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    REPORTER_ASSERT(reporter, SK_ColorRED  == bm.getColor(kSmallerSize+kPad-1,
93b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips                                                          kSmallerSize+kPad-1));
94b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    REPORTER_ASSERT(reporter, SK_ColorBLUE == bm.getColor(kSmallerSize+kPad,
95b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips                                                          kSmallerSize+kPad));
96b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips}
97b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
98b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillipsDEF_TEST(SpecialImage_Raster, reporter) {
99b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    SkBitmap bm = create_bm();
100b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
101c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    SkAutoTUnref<SkSpecialImage> fullSImage(SkSpecialImage::NewFromRaster(
102c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                            nullptr,
103c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                            SkIRect::MakeWH(kFullSize, kFullSize),
104c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                            bm));
105c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips
106b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
107b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
108c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    {
109c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        SkAutoTUnref<SkSpecialImage> subSImg1(SkSpecialImage::NewFromRaster(nullptr, subset, bm));
110c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        test_image(subSImg1, reporter, true, false, kPad, kFullSize);
111c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    }
112c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips
113c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    {
114c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        SkAutoTUnref<SkSpecialImage> subSImg2(fullSImage->extractSubset(subset));
115c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        test_image(subSImg2, reporter, true, false, 0, kSmallerSize);
116c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    }
117b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips}
118b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
119b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillipsDEF_TEST(SpecialImage_Image, reporter) {
120b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    SkBitmap bm = create_bm();
121b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
122b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    SkAutoTUnref<SkImage> fullImage(SkImage::NewFromBitmap(bm));
123b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
124c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    SkAutoTUnref<SkSpecialImage> fullSImage(SkSpecialImage::NewFromImage(
125c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                            nullptr,
126c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                            SkIRect::MakeWH(kFullSize, kFullSize),
127c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                            fullImage));
128c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips
129b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
130b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
131c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    {
132c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        SkAutoTUnref<SkSpecialImage> subSImg1(SkSpecialImage::NewFromImage(nullptr,
133c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                                           subset,
134c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                                           fullImage));
135c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        test_image(subSImg1, reporter, true, false, kPad, kFullSize);
136c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    }
137c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips
138c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    {
139c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        SkAutoTUnref<SkSpecialImage> subSImg2(fullSImage->extractSubset(subset));
140c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        test_image(subSImg2, reporter, true, false, 0, kSmallerSize);
141c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    }
142b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips}
143b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
144c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillipsDEF_TEST(SpecialImage_Pixmap, reporter) {
145c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    SkAutoPixmapStorage pixmap;
146c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips
147c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    const SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlphaType);
148c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    pixmap.alloc(info);
149c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    pixmap.erase(SK_ColorGREEN);
150c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips
151c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
152c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips
153c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    pixmap.erase(SK_ColorRED, subset);
154c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips
155c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    {
156c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        // The SkAutoPixmapStorage keeps hold of the memory
157c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        SkAutoTUnref<SkSpecialImage> img(SkSpecialImage::NewFromPixmap(nullptr, subset, pixmap,
158c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                                       nullptr, nullptr));
159c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        test_image(img, reporter, true, false, kPad, kFullSize);
160c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    }
161c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips
162c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    {
163c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        // The image takes ownership of the memory
164c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        SkAutoTUnref<SkSpecialImage> img(SkSpecialImage::NewFromPixmap(
165c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                               nullptr, subset, pixmap,
166c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                               [] (void* addr, void*) -> void { sk_free(addr); },
167c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                               nullptr));
168c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        pixmap.release();
169c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        test_image(img, reporter, true, false, kPad, kFullSize);
170c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    }
171c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips}
172c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips
173c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips
174b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips#if SK_SUPPORT_GPU
175b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillipsDEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, context) {
176b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    SkBitmap bm = create_bm();
177b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
178b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    GrSurfaceDesc desc;
179b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    desc.fConfig = kSkia8888_GrPixelConfig;
180b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    desc.fFlags  = kNone_GrSurfaceFlags;
181b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    desc.fWidth  = kFullSize;
182b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    desc.fHeight = kFullSize;
183b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
1845ec26ae9bfca635ccc98283aad5deda11519d826bsalomon    SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(desc, SkBudgeted::kNo,
185b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips                                                                              bm.getPixels(), 0));
186b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    if (!texture) {
187b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips        return;
188b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    }
189b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
190c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    SkAutoTUnref<SkSpecialImage> fullSImg(SkSpecialImage::NewFromGpu(
191c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                            nullptr,
192c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                            SkIRect::MakeWH(kFullSize, kFullSize),
193c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                            kNeedNewImageUniqueID_SpecialImage,
194c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                            texture));
195c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips
196b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips    const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
197b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
198c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    {
199c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        SkAutoTUnref<SkSpecialImage> subSImg1(SkSpecialImage::NewFromGpu(
200c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                               nullptr, subset,
201c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                               kNeedNewImageUniqueID_SpecialImage,
202c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips                                                               texture));
203c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        test_image(subSImg1, reporter, false, true, kPad, kFullSize);
204c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    }
205c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips
206c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    {
207c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        SkAutoTUnref<SkSpecialImage> subSImg2(fullSImg->extractSubset(subset));
208c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips        test_image(subSImg2, reporter, false, true, kPad, kFullSize);
209c5035e70cc3fb290f95fd1c052c637aa0dbaf9earobertphillips    }
210b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips}
211b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips
212b6c65e99956b867e24bd5bd68ae37673a9fd4b27robertphillips#endif
213