blob: 4970e43a2032b891898390d7121705e322356fd4 [file] [log] [blame]
robertphillips76948d42016-05-04 12:47:41 -07001/*
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// This is a GPU-backend specific test.
9
10#include "Test.h"
11
12#if SK_SUPPORT_GPU
Robert Phillips8bf1f9f2017-05-31 15:01:20 -040013
Greg Danielbcf612b2017-05-01 13:50:58 +000014#include "GrBackendSurface.h"
Robert Phillips1afd4cd2018-01-08 13:40:32 -050015#include "GrContextPriv.h"
Robert Phillips0bd24dc2018-01-16 08:06:32 -050016#include "GrProxyProvider.h"
Robert Phillipsc7635fa2016-10-28 13:25:24 -040017#include "GrRenderTargetPriv.h"
robertphillips76948d42016-05-04 12:47:41 -070018#include "GrRenderTargetProxy.h"
Brian Osman32342f02017-03-04 08:12:46 -050019#include "GrResourceProvider.h"
Robert Phillipsf95b1752017-08-31 08:56:07 -040020#include "GrSurfaceProxyPriv.h"
Robert Phillips646e4292017-06-13 12:44:56 -040021#include "GrTexture.h"
Brian Osman32342f02017-03-04 08:12:46 -050022#include "GrTextureProxy.h"
Greg Daniel2a303902018-02-20 10:25:54 -050023#include "SkGr.h"
robertphillips76948d42016-05-04 12:47:41 -070024
robertphillips8abb3702016-08-31 14:04:06 -070025// Check that the surface proxy's member vars are set as expected
robertphillips76948d42016-05-04 12:47:41 -070026static void check_surface(skiatest::Reporter* reporter,
27 GrSurfaceProxy* proxy,
28 GrSurfaceOrigin origin,
Greg Danielbcf612b2017-05-01 13:50:58 +000029 int width, int height,
robertphillips8abb3702016-08-31 14:04:06 -070030 GrPixelConfig config,
Robert Phillipsabacf092016-11-02 10:23:32 -040031 SkBudgeted budgeted) {
robertphillips76948d42016-05-04 12:47:41 -070032 REPORTER_ASSERT(reporter, proxy->origin() == origin);
33 REPORTER_ASSERT(reporter, proxy->width() == width);
34 REPORTER_ASSERT(reporter, proxy->height() == height);
35 REPORTER_ASSERT(reporter, proxy->config() == config);
Robert Phillips0bd24dc2018-01-16 08:06:32 -050036 REPORTER_ASSERT(reporter, !proxy->uniqueID().isInvalid());
Robert Phillipsabacf092016-11-02 10:23:32 -040037 REPORTER_ASSERT(reporter, proxy->isBudgeted() == budgeted);
robertphillips76948d42016-05-04 12:47:41 -070038}
39
40static void check_rendertarget(skiatest::Reporter* reporter,
Robert Phillipsec2249f2016-11-09 08:54:35 -050041 const GrCaps& caps,
Brian Osman32342f02017-03-04 08:12:46 -050042 GrResourceProvider* provider,
robertphillips76948d42016-05-04 12:47:41 -070043 GrRenderTargetProxy* rtProxy,
Robert Phillipsabacf092016-11-02 10:23:32 -040044 int numSamples,
Robert Phillipsec2249f2016-11-09 08:54:35 -050045 SkBackingFit fit,
Greg Daniel2a303902018-02-20 10:25:54 -050046 int expectedMaxWindowRects) {
Robert Phillipsec2249f2016-11-09 08:54:35 -050047 REPORTER_ASSERT(reporter, rtProxy->maxWindowRectangles(caps) == expectedMaxWindowRects);
Robert Phillipsabacf092016-11-02 10:23:32 -040048 REPORTER_ASSERT(reporter, rtProxy->numStencilSamples() == numSamples);
49
Robert Phillips294870f2016-11-11 12:38:40 -050050 GrSurfaceProxy::UniqueID idBefore = rtProxy->uniqueID();
Brian Salomonf7778972018-03-08 10:13:17 -050051 bool preinstantiated = rtProxy->priv().isInstantiated();
Robert Phillipseee4d6e2017-06-05 09:26:07 -040052 REPORTER_ASSERT(reporter, rtProxy->instantiate(provider));
53 GrRenderTarget* rt = rtProxy->priv().peekRenderTarget();
robertphillips76948d42016-05-04 12:47:41 -070054
Robert Phillips294870f2016-11-11 12:38:40 -050055 REPORTER_ASSERT(reporter, rtProxy->uniqueID() == idBefore);
Greg Daniel2a303902018-02-20 10:25:54 -050056 // Deferred resources should always have a different ID from their instantiated rendertarget
Brian Salomonf7778972018-03-08 10:13:17 -050057 if (preinstantiated) {
58 REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() == rt->uniqueID().asUInt());
59 } else {
60 REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() != rt->uniqueID().asUInt());
61 }
Robert Phillips294870f2016-11-11 12:38:40 -050062
robertphillips76948d42016-05-04 12:47:41 -070063 if (SkBackingFit::kExact == fit) {
64 REPORTER_ASSERT(reporter, rt->width() == rtProxy->width());
65 REPORTER_ASSERT(reporter, rt->height() == rtProxy->height());
66 } else {
67 REPORTER_ASSERT(reporter, rt->width() >= rtProxy->width());
Robert Phillips294870f2016-11-11 12:38:40 -050068 REPORTER_ASSERT(reporter, rt->height() >= rtProxy->height());
robertphillips76948d42016-05-04 12:47:41 -070069 }
70 REPORTER_ASSERT(reporter, rt->config() == rtProxy->config());
71
Brian Salomon7c8460e2017-05-12 11:36:10 -040072 REPORTER_ASSERT(reporter, rt->fsaaType() == rtProxy->fsaaType());
robertphillips76948d42016-05-04 12:47:41 -070073 REPORTER_ASSERT(reporter, rt->numColorSamples() == rtProxy->numColorSamples());
74 REPORTER_ASSERT(reporter, rt->numStencilSamples() == rtProxy->numStencilSamples());
csmartdaltonf9635992016-08-10 11:09:07 -070075 REPORTER_ASSERT(reporter, rt->renderTargetPriv().flags() == rtProxy->testingOnly_getFlags());
robertphillips76948d42016-05-04 12:47:41 -070076}
77
78static void check_texture(skiatest::Reporter* reporter,
Brian Osman32342f02017-03-04 08:12:46 -050079 GrResourceProvider* provider,
robertphillips76948d42016-05-04 12:47:41 -070080 GrTextureProxy* texProxy,
Greg Daniel2a303902018-02-20 10:25:54 -050081 SkBackingFit fit) {
Robert Phillips294870f2016-11-11 12:38:40 -050082 GrSurfaceProxy::UniqueID idBefore = texProxy->uniqueID();
Robert Phillipseee4d6e2017-06-05 09:26:07 -040083
Brian Salomonf7778972018-03-08 10:13:17 -050084 bool preinstantiated = texProxy->priv().isInstantiated();
Robert Phillipseee4d6e2017-06-05 09:26:07 -040085 REPORTER_ASSERT(reporter, texProxy->instantiate(provider));
86 GrTexture* tex = texProxy->priv().peekTexture();
robertphillips76948d42016-05-04 12:47:41 -070087
Robert Phillips294870f2016-11-11 12:38:40 -050088 REPORTER_ASSERT(reporter, texProxy->uniqueID() == idBefore);
Greg Daniel2a303902018-02-20 10:25:54 -050089 // Deferred resources should always have a different ID from their instantiated texture
Brian Salomonf7778972018-03-08 10:13:17 -050090 if (preinstantiated) {
91 REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() == tex->uniqueID().asUInt());
92 } else {
93 REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() != tex->uniqueID().asUInt());
94 }
Robert Phillips294870f2016-11-11 12:38:40 -050095
robertphillips76948d42016-05-04 12:47:41 -070096 if (SkBackingFit::kExact == fit) {
97 REPORTER_ASSERT(reporter, tex->width() == texProxy->width());
98 REPORTER_ASSERT(reporter, tex->height() == texProxy->height());
99 } else {
100 REPORTER_ASSERT(reporter, tex->width() >= texProxy->width());
101 REPORTER_ASSERT(reporter, tex->height() >= texProxy->height());
102 }
103 REPORTER_ASSERT(reporter, tex->config() == texProxy->config());
104}
105
106
robertphillips8abb3702016-08-31 14:04:06 -0700107DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500108 GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
Robert Phillips6be756b2018-01-16 15:07:54 -0500109 GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider();
Robert Phillipsabacf092016-11-02 10:23:32 -0400110 const GrCaps& caps = *ctxInfo.grContext()->caps();
robertphillips76948d42016-05-04 12:47:41 -0700111
Robert Phillips6520a692017-02-01 09:20:00 -0500112 int attempt = 0; // useful for debugging
113
robertphillips76948d42016-05-04 12:47:41 -0700114 for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
Robert Phillips40d94952017-01-30 14:15:59 -0500115 for (auto widthHeight : { 100, 128, 1048576 }) {
Robert Phillips6520a692017-02-01 09:20:00 -0500116 for (auto config : { kAlpha_8_GrPixelConfig, kRGB_565_GrPixelConfig,
Brian Osman10fc6fd2018-03-02 11:01:10 -0500117 kRGBA_8888_GrPixelConfig, kRGBA_1010102_GrPixelConfig }) {
robertphillips76948d42016-05-04 12:47:41 -0700118 for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
119 for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
Brian Salomonbdecacf2018-02-02 20:32:49 -0500120 for (auto numSamples : {1, 4, 16, 128}) {
robertphillips76948d42016-05-04 12:47:41 -0700121 GrSurfaceDesc desc;
Robert Phillips84a81202016-11-04 11:59:10 -0400122 desc.fFlags = kRenderTarget_GrSurfaceFlag;
robertphillips76948d42016-05-04 12:47:41 -0700123 desc.fWidth = widthHeight;
124 desc.fHeight = widthHeight;
125 desc.fConfig = config;
126 desc.fSampleCnt = numSamples;
127
Robert Phillips6520a692017-02-01 09:20:00 -0500128 {
129 sk_sp<GrTexture> tex;
130 if (SkBackingFit::kApprox == fit) {
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500131 tex = resourceProvider->createApproxTexture(desc, 0);
Robert Phillips6520a692017-02-01 09:20:00 -0500132 } else {
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500133 tex = resourceProvider->createTexture(desc, budgeted);
Robert Phillips6520a692017-02-01 09:20:00 -0500134 }
135
Brian Salomon2a4f9832018-03-03 22:43:43 -0500136 sk_sp<GrTextureProxy> proxy =
137 proxyProvider->createProxy(desc, origin, fit, budgeted);
Robert Phillips2f493142017-03-02 18:18:38 -0500138 REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
139 if (proxy) {
140 REPORTER_ASSERT(reporter, proxy->asRenderTargetProxy());
Robert Phillips40d94952017-01-30 14:15:59 -0500141 // This forces the proxy to compute and cache its
142 // pre-instantiation size guess. Later, when it is actually
143 // instantiated, it checks that the instantiated size is <= to
144 // the pre-computation. If the proxy never computed its
145 // pre-instantiation size then the check is skipped.
Robert Phillips2f493142017-03-02 18:18:38 -0500146 proxy->gpuMemorySize();
Robert Phillipsb4460882016-11-17 14:43:51 -0500147
Robert Phillips2f493142017-03-02 18:18:38 -0500148 check_surface(reporter, proxy.get(), origin,
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500149 widthHeight, widthHeight, config, budgeted);
Brian Salomonbdecacf2018-02-02 20:32:49 -0500150 int supportedSamples =
151 caps.getRenderTargetSampleCount(numSamples, config);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500152 check_rendertarget(reporter, caps, resourceProvider,
Robert Phillips2f493142017-03-02 18:18:38 -0500153 proxy->asRenderTargetProxy(),
Greg Daniel81e7bf82017-07-19 14:47:42 -0400154 supportedSamples,
Greg Daniel2a303902018-02-20 10:25:54 -0500155 fit, caps.maxWindowRectangles());
Robert Phillips40d94952017-01-30 14:15:59 -0500156 }
robertphillips76948d42016-05-04 12:47:41 -0700157 }
158
Robert Phillips84a81202016-11-04 11:59:10 -0400159 desc.fFlags = kNone_GrSurfaceFlags;
robertphillips76948d42016-05-04 12:47:41 -0700160
Robert Phillips6520a692017-02-01 09:20:00 -0500161 {
162 sk_sp<GrTexture> tex;
163 if (SkBackingFit::kApprox == fit) {
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500164 tex = resourceProvider->createApproxTexture(desc, 0);
Robert Phillips6520a692017-02-01 09:20:00 -0500165 } else {
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500166 tex = resourceProvider->createTexture(desc, budgeted);
Robert Phillips6520a692017-02-01 09:20:00 -0500167 }
Robert Phillipsb4460882016-11-17 14:43:51 -0500168
Brian Salomon2a4f9832018-03-03 22:43:43 -0500169 sk_sp<GrTextureProxy> proxy(
170 proxyProvider->createProxy(desc, origin, fit, budgeted));
Robert Phillips2f493142017-03-02 18:18:38 -0500171 REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
172 if (proxy) {
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500173 // This forces the proxy to compute and cache its
174 // pre-instantiation size guess. Later, when it is actually
175 // instantiated, it checks that the instantiated size is <= to
176 // the pre-computation. If the proxy never computed its
177 // pre-instantiation size then the check is skipped.
Robert Phillips2f493142017-03-02 18:18:38 -0500178 proxy->gpuMemorySize();
Robert Phillips6520a692017-02-01 09:20:00 -0500179
Robert Phillips2f493142017-03-02 18:18:38 -0500180 check_surface(reporter, proxy.get(), origin,
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500181 widthHeight, widthHeight, config, budgeted);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500182 check_texture(reporter, resourceProvider,
Greg Daniel2a303902018-02-20 10:25:54 -0500183 proxy->asTextureProxy(), fit);
Robert Phillips6520a692017-02-01 09:20:00 -0500184 }
Robert Phillips40d94952017-01-30 14:15:59 -0500185 }
Robert Phillips6520a692017-02-01 09:20:00 -0500186
187 attempt++;
robertphillips76948d42016-05-04 12:47:41 -0700188 }
189 }
190 }
191 }
192 }
193 }
194}
195
egdanielab527a52016-06-28 08:07:26 -0700196DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500197 GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
Robert Phillips6be756b2018-01-16 15:07:54 -0500198 GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider();
Greg Daniel2a303902018-02-20 10:25:54 -0500199 GrGpu* gpu = ctxInfo.grContext()->contextPriv().getGpu();
csmartdaltonf9635992016-08-10 11:09:07 -0700200 const GrCaps& caps = *ctxInfo.grContext()->caps();
robertphillips76948d42016-05-04 12:47:41 -0700201
202 static const int kWidthHeight = 100;
203
204 for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
Brian Osman10fc6fd2018-03-02 11:01:10 -0500205 for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType,
206 kRGBA_1010102_SkColorType }) {
Brian Salomon52e943a2018-03-13 09:32:39 -0400207 // External on-screen render target.
208 // Tests wrapBackendRenderTarget with a GrBackendRenderTarget
209 // Our test-only function that creates a backend render target doesn't currently support
210 // sample counts :(.
211 if (ctxInfo.grContext()->colorTypeSupportedAsSurface(colorType)) {
212 GrBackendRenderTarget backendRT = gpu->createTestingOnlyBackendRenderTarget(
213 kWidthHeight, kWidthHeight, SkColorTypeToGrColorType(colorType),
214 GrSRGBEncoded::kNo);
215 sk_sp<GrSurfaceProxy> sProxy(
216 proxyProvider->wrapBackendRenderTarget(backendRT, origin));
217 check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight,
218 backendRT.testingOnly_getPixelConfig(), SkBudgeted::kNo);
219 static constexpr int kExpectedNumSamples = 1;
220 check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
221 kExpectedNumSamples, SkBackingFit::kExact,
222 caps.maxWindowRectangles());
223 gpu->deleteTestingOnlyBackendRenderTarget(backendRT);
224 }
225
Greg Daniel2a303902018-02-20 10:25:54 -0500226 for (auto numSamples : {1, 4}) {
227 GrPixelConfig config = SkImageInfo2GrPixelConfig(colorType, nullptr, caps);
Greg Daniel0a7aa142018-02-21 13:02:32 -0500228 SkASSERT(kUnknown_GrPixelConfig != config);
Greg Daniel2a303902018-02-20 10:25:54 -0500229 int supportedNumSamples = caps.getRenderTargetSampleCount(numSamples, config);
robertphillips76948d42016-05-04 12:47:41 -0700230
Greg Daniel2a303902018-02-20 10:25:54 -0500231 if (!supportedNumSamples) {
232 continue;
233 }
robertphillips76948d42016-05-04 12:47:41 -0700234
Brian Salomon52e943a2018-03-13 09:32:39 -0400235 // Test wrapping FBO 0 (with made up properties). This tests sample count and the
236 // special case where FBO 0 doesn't support window rectangles.
237 if (kOpenGL_GrBackend == ctxInfo.backend()) {
Greg Daniel2a303902018-02-20 10:25:54 -0500238 GrGLFramebufferInfo fboInfo;
239 fboInfo.fFBOID = 0;
Brian Salomon52e943a2018-03-13 09:32:39 -0400240 static constexpr int kStencilBits = 8;
241 GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples,
242 kStencilBits, config, fboInfo);
Brian Salomon7578f3e2018-03-07 14:39:54 -0500243 sk_sp<GrSurfaceProxy> sProxy(
244 proxyProvider->wrapBackendRenderTarget(backendRT, origin));
Greg Daniel2a303902018-02-20 10:25:54 -0500245 check_surface(reporter, sProxy.get(), origin,
246 kWidthHeight, kWidthHeight,
247 backendRT.testingOnly_getPixelConfig(), SkBudgeted::kNo);
248 check_rendertarget(reporter, caps, resourceProvider,
249 sProxy->asRenderTargetProxy(),
250 supportedNumSamples, SkBackingFit::kExact, 0);
251 }
252
Brian Salomon7578f3e2018-03-07 14:39:54 -0500253 // Tests wrapBackendRenderTarget with a GrBackendTexture
Greg Daniel2a303902018-02-20 10:25:54 -0500254 {
255 GrBackendTexture backendTex =
256 gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight,
257 kWidthHeight, colorType, true,
258 GrMipMapped::kNo);
Brian Salomon7578f3e2018-03-07 14:39:54 -0500259 sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTextureAsRenderTarget(
260 backendTex, origin, supportedNumSamples);
Greg Daniel2a303902018-02-20 10:25:54 -0500261 if (!sProxy) {
Brian Salomon26102cb2018-03-09 09:33:19 -0500262 gpu->deleteTestingOnlyBackendTexture(backendTex);
Greg Daniel2a303902018-02-20 10:25:54 -0500263 continue; // This can fail on Mesa
csmartdaltonf9635992016-08-10 11:09:07 -0700264 }
265
Greg Daniel2a303902018-02-20 10:25:54 -0500266 check_surface(reporter, sProxy.get(), origin,
267 kWidthHeight, kWidthHeight,
268 backendTex.testingOnly_getPixelConfig(), SkBudgeted::kNo);
269 check_rendertarget(reporter, caps, resourceProvider,
270 sProxy->asRenderTargetProxy(),
271 supportedNumSamples, SkBackingFit::kExact,
272 caps.maxWindowRectangles());
robertphillips76948d42016-05-04 12:47:41 -0700273
Brian Salomon26102cb2018-03-09 09:33:19 -0500274 gpu->deleteTestingOnlyBackendTexture(backendTex);
Greg Daniel2a303902018-02-20 10:25:54 -0500275 }
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500276
Brian Salomon7578f3e2018-03-07 14:39:54 -0500277 // Tests wrapBackendTexture that is only renderable
Greg Danielf87651e2018-02-21 11:36:53 -0500278 {
279 GrBackendTexture backendTex =
280 gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight,
281 kWidthHeight, colorType, true,
282 GrMipMapped::kNo);
283
Brian Salomon7578f3e2018-03-07 14:39:54 -0500284 sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapRenderableBackendTexture(
285 backendTex, origin, supportedNumSamples);
Greg Danielf87651e2018-02-21 11:36:53 -0500286 if (!sProxy) {
Brian Salomon26102cb2018-03-09 09:33:19 -0500287 gpu->deleteTestingOnlyBackendTexture(backendTex);
Greg Danielf87651e2018-02-21 11:36:53 -0500288 continue; // This can fail on Mesa
289 }
290
291 check_surface(reporter, sProxy.get(), origin,
292 kWidthHeight, kWidthHeight,
293 backendTex.testingOnly_getPixelConfig(), SkBudgeted::kNo);
294 check_rendertarget(reporter, caps, resourceProvider,
295 sProxy->asRenderTargetProxy(),
296 supportedNumSamples, SkBackingFit::kExact,
297 caps.maxWindowRectangles());
298
Brian Salomon26102cb2018-03-09 09:33:19 -0500299 gpu->deleteTestingOnlyBackendTexture(backendTex);
Greg Danielf87651e2018-02-21 11:36:53 -0500300 }
301
Brian Salomon7578f3e2018-03-07 14:39:54 -0500302 // Tests wrapBackendTexture that is only textureable
Greg Daniel2a303902018-02-20 10:25:54 -0500303 {
304 // Internal offscreen texture
305 GrBackendTexture backendTex =
306 gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight,
307 kWidthHeight, colorType, false,
308 GrMipMapped::kNo);
robertphillips76948d42016-05-04 12:47:41 -0700309
Brian Salomon7578f3e2018-03-07 14:39:54 -0500310 sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTexture(
311 backendTex, origin, kBorrow_GrWrapOwnership, nullptr, nullptr);
Greg Daniel2a303902018-02-20 10:25:54 -0500312 if (!sProxy) {
Brian Salomon26102cb2018-03-09 09:33:19 -0500313 gpu->deleteTestingOnlyBackendTexture(backendTex);
Greg Daniel2a303902018-02-20 10:25:54 -0500314 continue;
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500315 }
Greg Daniel2a303902018-02-20 10:25:54 -0500316
317 check_surface(reporter, sProxy.get(), origin,
318 kWidthHeight, kWidthHeight,
319 backendTex.testingOnly_getPixelConfig(), SkBudgeted::kNo);
320 check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
321 SkBackingFit::kExact);
322
Brian Salomon26102cb2018-03-09 09:33:19 -0500323 gpu->deleteTestingOnlyBackendTexture(backendTex);
robertphillips76948d42016-05-04 12:47:41 -0700324 }
325 }
326 }
327 }
328}
329
Robert Phillips78de2122017-04-26 07:44:26 -0400330DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ZeroSizedProxyTest, reporter, ctxInfo) {
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500331 GrProxyProvider* provider = ctxInfo.grContext()->contextPriv().proxyProvider();
Robert Phillips78de2122017-04-26 07:44:26 -0400332
333 for (auto flags : { kRenderTarget_GrSurfaceFlag, kNone_GrSurfaceFlags }) {
334 for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
335 for (int width : { 0, 100 }) {
336 for (int height : { 0, 100}) {
337 if (width && height) {
338 continue; // not zero-sized
339 }
340
341 GrSurfaceDesc desc;
342 desc.fFlags = flags;
Robert Phillips78de2122017-04-26 07:44:26 -0400343 desc.fWidth = width;
344 desc.fHeight = height;
345 desc.fConfig = kRGBA_8888_GrPixelConfig;
Brian Salomonbdecacf2018-02-02 20:32:49 -0500346 desc.fSampleCnt = 1;
Robert Phillips78de2122017-04-26 07:44:26 -0400347
Brian Salomon2a4f9832018-03-03 22:43:43 -0500348 sk_sp<GrTextureProxy> proxy = provider->createProxy(
349 desc, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kNo);
Robert Phillips78de2122017-04-26 07:44:26 -0400350 REPORTER_ASSERT(reporter, !proxy);
351 }
352 }
353 }
354 }
355}
356
robertphillips76948d42016-05-04 12:47:41 -0700357#endif