blob: 5e050a371c4ea00f66ccd16f5f4af3840c60070d [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
Greg Danielbcf612b2017-05-01 13:50:58 +000012#include "GrBackendSurface.h"
Robert Phillips1afd4cd2018-01-08 13:40:32 -050013#include "GrContextPriv.h"
Robert Phillips0bd24dc2018-01-16 08:06:32 -050014#include "GrProxyProvider.h"
Robert Phillipsc7635fa2016-10-28 13:25:24 -040015#include "GrRenderTargetPriv.h"
robertphillips76948d42016-05-04 12:47:41 -070016#include "GrRenderTargetProxy.h"
Brian Osman32342f02017-03-04 08:12:46 -050017#include "GrResourceProvider.h"
Robert Phillipsfe0253f2018-03-16 16:47:25 -040018#include "GrSurfacePriv.h"
Robert Phillipsf95b1752017-08-31 08:56:07 -040019#include "GrSurfaceProxyPriv.h"
Robert Phillips646e4292017-06-13 12:44:56 -040020#include "GrTexture.h"
Brian Osman32342f02017-03-04 08:12:46 -050021#include "GrTextureProxy.h"
Greg Daniel2a303902018-02-20 10:25:54 -050022#include "SkGr.h"
robertphillips76948d42016-05-04 12:47:41 -070023
robertphillips8abb3702016-08-31 14:04:06 -070024// Check that the surface proxy's member vars are set as expected
robertphillips76948d42016-05-04 12:47:41 -070025static void check_surface(skiatest::Reporter* reporter,
26 GrSurfaceProxy* proxy,
27 GrSurfaceOrigin origin,
Greg Danielbcf612b2017-05-01 13:50:58 +000028 int width, int height,
robertphillips8abb3702016-08-31 14:04:06 -070029 GrPixelConfig config,
Robert Phillipsabacf092016-11-02 10:23:32 -040030 SkBudgeted budgeted) {
robertphillips76948d42016-05-04 12:47:41 -070031 REPORTER_ASSERT(reporter, proxy->origin() == origin);
32 REPORTER_ASSERT(reporter, proxy->width() == width);
33 REPORTER_ASSERT(reporter, proxy->height() == height);
34 REPORTER_ASSERT(reporter, proxy->config() == config);
Robert Phillips0bd24dc2018-01-16 08:06:32 -050035 REPORTER_ASSERT(reporter, !proxy->uniqueID().isInvalid());
Robert Phillipsabacf092016-11-02 10:23:32 -040036 REPORTER_ASSERT(reporter, proxy->isBudgeted() == budgeted);
robertphillips76948d42016-05-04 12:47:41 -070037}
38
39static void check_rendertarget(skiatest::Reporter* reporter,
Robert Phillipsec2249f2016-11-09 08:54:35 -050040 const GrCaps& caps,
Brian Osman32342f02017-03-04 08:12:46 -050041 GrResourceProvider* provider,
robertphillips76948d42016-05-04 12:47:41 -070042 GrRenderTargetProxy* rtProxy,
Robert Phillipsabacf092016-11-02 10:23:32 -040043 int numSamples,
Robert Phillipsec2249f2016-11-09 08:54:35 -050044 SkBackingFit fit,
Greg Daniel2a303902018-02-20 10:25:54 -050045 int expectedMaxWindowRects) {
Robert Phillipsec2249f2016-11-09 08:54:35 -050046 REPORTER_ASSERT(reporter, rtProxy->maxWindowRectangles(caps) == expectedMaxWindowRects);
Robert Phillipsabacf092016-11-02 10:23:32 -040047 REPORTER_ASSERT(reporter, rtProxy->numStencilSamples() == numSamples);
48
Robert Phillips294870f2016-11-11 12:38:40 -050049 GrSurfaceProxy::UniqueID idBefore = rtProxy->uniqueID();
Brian Salomonfd98c2c2018-07-31 17:25:29 -040050 bool preinstantiated = rtProxy->isInstantiated();
Robert Phillipseee4d6e2017-06-05 09:26:07 -040051 REPORTER_ASSERT(reporter, rtProxy->instantiate(provider));
Brian Salomonfd98c2c2018-07-31 17:25:29 -040052 GrRenderTarget* rt = rtProxy->peekRenderTarget();
robertphillips76948d42016-05-04 12:47:41 -070053
Robert Phillips294870f2016-11-11 12:38:40 -050054 REPORTER_ASSERT(reporter, rtProxy->uniqueID() == idBefore);
Greg Daniel2a303902018-02-20 10:25:54 -050055 // Deferred resources should always have a different ID from their instantiated rendertarget
Brian Salomonf7778972018-03-08 10:13:17 -050056 if (preinstantiated) {
57 REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() == rt->uniqueID().asUInt());
58 } else {
59 REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() != rt->uniqueID().asUInt());
60 }
Robert Phillips294870f2016-11-11 12:38:40 -050061
robertphillips76948d42016-05-04 12:47:41 -070062 if (SkBackingFit::kExact == fit) {
63 REPORTER_ASSERT(reporter, rt->width() == rtProxy->width());
64 REPORTER_ASSERT(reporter, rt->height() == rtProxy->height());
65 } else {
66 REPORTER_ASSERT(reporter, rt->width() >= rtProxy->width());
Robert Phillips294870f2016-11-11 12:38:40 -050067 REPORTER_ASSERT(reporter, rt->height() >= rtProxy->height());
robertphillips76948d42016-05-04 12:47:41 -070068 }
69 REPORTER_ASSERT(reporter, rt->config() == rtProxy->config());
70
Brian Salomon7c8460e2017-05-12 11:36:10 -040071 REPORTER_ASSERT(reporter, rt->fsaaType() == rtProxy->fsaaType());
robertphillips76948d42016-05-04 12:47:41 -070072 REPORTER_ASSERT(reporter, rt->numColorSamples() == rtProxy->numColorSamples());
73 REPORTER_ASSERT(reporter, rt->numStencilSamples() == rtProxy->numStencilSamples());
Robert Phillipsfe0253f2018-03-16 16:47:25 -040074 REPORTER_ASSERT(reporter, rt->surfacePriv().flags() == rtProxy->testingOnly_getFlags());
robertphillips76948d42016-05-04 12:47:41 -070075}
76
77static void check_texture(skiatest::Reporter* reporter,
Brian Osman32342f02017-03-04 08:12:46 -050078 GrResourceProvider* provider,
robertphillips76948d42016-05-04 12:47:41 -070079 GrTextureProxy* texProxy,
Greg Daniel2a303902018-02-20 10:25:54 -050080 SkBackingFit fit) {
Robert Phillips294870f2016-11-11 12:38:40 -050081 GrSurfaceProxy::UniqueID idBefore = texProxy->uniqueID();
Robert Phillipseee4d6e2017-06-05 09:26:07 -040082
Brian Salomonfd98c2c2018-07-31 17:25:29 -040083 bool preinstantiated = texProxy->isInstantiated();
Robert Phillipseee4d6e2017-06-05 09:26:07 -040084 REPORTER_ASSERT(reporter, texProxy->instantiate(provider));
Brian Salomonfd98c2c2018-07-31 17:25:29 -040085 GrTexture* tex = texProxy->peekTexture();
robertphillips76948d42016-05-04 12:47:41 -070086
Robert Phillips294870f2016-11-11 12:38:40 -050087 REPORTER_ASSERT(reporter, texProxy->uniqueID() == idBefore);
Greg Daniel2a303902018-02-20 10:25:54 -050088 // Deferred resources should always have a different ID from their instantiated texture
Brian Salomonf7778972018-03-08 10:13:17 -050089 if (preinstantiated) {
90 REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() == tex->uniqueID().asUInt());
91 } else {
92 REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() != tex->uniqueID().asUInt());
93 }
Robert Phillips294870f2016-11-11 12:38:40 -050094
robertphillips76948d42016-05-04 12:47:41 -070095 if (SkBackingFit::kExact == fit) {
96 REPORTER_ASSERT(reporter, tex->width() == texProxy->width());
97 REPORTER_ASSERT(reporter, tex->height() == texProxy->height());
98 } else {
99 REPORTER_ASSERT(reporter, tex->width() >= texProxy->width());
100 REPORTER_ASSERT(reporter, tex->height() >= texProxy->height());
101 }
102 REPORTER_ASSERT(reporter, tex->config() == texProxy->config());
103}
104
105
robertphillips8abb3702016-08-31 14:04:06 -0700106DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500107 GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
Robert Phillips6be756b2018-01-16 15:07:54 -0500108 GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider();
Brian Salomonc7fe0f72018-05-11 10:14:21 -0400109 const GrCaps& caps = *ctxInfo.grContext()->contextPriv().caps();
robertphillips76948d42016-05-04 12:47:41 -0700110
Robert Phillips6520a692017-02-01 09:20:00 -0500111 int attempt = 0; // useful for debugging
112
robertphillips76948d42016-05-04 12:47:41 -0700113 for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
Robert Phillips40d94952017-01-30 14:15:59 -0500114 for (auto widthHeight : { 100, 128, 1048576 }) {
Robert Phillips6520a692017-02-01 09:20:00 -0500115 for (auto config : { kAlpha_8_GrPixelConfig, kRGB_565_GrPixelConfig,
Brian Osman10fc6fd2018-03-02 11:01:10 -0500116 kRGBA_8888_GrPixelConfig, kRGBA_1010102_GrPixelConfig }) {
robertphillips76948d42016-05-04 12:47:41 -0700117 for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
118 for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
Brian Salomonbdecacf2018-02-02 20:32:49 -0500119 for (auto numSamples : {1, 4, 16, 128}) {
robertphillips76948d42016-05-04 12:47:41 -0700120 GrSurfaceDesc desc;
Robert Phillips84a81202016-11-04 11:59:10 -0400121 desc.fFlags = kRenderTarget_GrSurfaceFlag;
robertphillips76948d42016-05-04 12:47:41 -0700122 desc.fWidth = widthHeight;
123 desc.fHeight = widthHeight;
124 desc.fConfig = config;
125 desc.fSampleCnt = numSamples;
126
Robert Phillips6520a692017-02-01 09:20:00 -0500127 {
128 sk_sp<GrTexture> tex;
129 if (SkBackingFit::kApprox == fit) {
Chris Daltond004e0b2018-09-27 09:28:03 -0600130 tex = resourceProvider->createApproxTexture(
131 desc, GrResourceProvider::Flags::kNone);
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) {
Chris Daltond004e0b2018-09-27 09:28:03 -0600164 tex = resourceProvider->createApproxTexture(
165 desc, GrResourceProvider::Flags::kNone);
Robert Phillips6520a692017-02-01 09:20:00 -0500166 } else {
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500167 tex = resourceProvider->createTexture(desc, budgeted);
Robert Phillips6520a692017-02-01 09:20:00 -0500168 }
Robert Phillipsb4460882016-11-17 14:43:51 -0500169
Brian Salomon2a4f9832018-03-03 22:43:43 -0500170 sk_sp<GrTextureProxy> proxy(
171 proxyProvider->createProxy(desc, origin, fit, budgeted));
Robert Phillips2f493142017-03-02 18:18:38 -0500172 REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
173 if (proxy) {
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500174 // This forces the proxy to compute and cache its
175 // pre-instantiation size guess. Later, when it is actually
176 // instantiated, it checks that the instantiated size is <= to
177 // the pre-computation. If the proxy never computed its
178 // pre-instantiation size then the check is skipped.
Robert Phillips2f493142017-03-02 18:18:38 -0500179 proxy->gpuMemorySize();
Robert Phillips6520a692017-02-01 09:20:00 -0500180
Robert Phillips2f493142017-03-02 18:18:38 -0500181 check_surface(reporter, proxy.get(), origin,
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500182 widthHeight, widthHeight, config, budgeted);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500183 check_texture(reporter, resourceProvider,
Greg Daniel2a303902018-02-20 10:25:54 -0500184 proxy->asTextureProxy(), fit);
Robert Phillips6520a692017-02-01 09:20:00 -0500185 }
Robert Phillips40d94952017-01-30 14:15:59 -0500186 }
Robert Phillips6520a692017-02-01 09:20:00 -0500187
188 attempt++;
robertphillips76948d42016-05-04 12:47:41 -0700189 }
190 }
191 }
192 }
193 }
194 }
195}
196
egdanielab527a52016-06-28 08:07:26 -0700197DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500198 GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
Robert Phillips6be756b2018-01-16 15:07:54 -0500199 GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider();
Greg Daniel2a303902018-02-20 10:25:54 -0500200 GrGpu* gpu = ctxInfo.grContext()->contextPriv().getGpu();
Brian Salomonc7fe0f72018-05-11 10:14:21 -0400201 const GrCaps& caps = *ctxInfo.grContext()->contextPriv().caps();
robertphillips76948d42016-05-04 12:47:41 -0700202
203 static const int kWidthHeight = 100;
204
205 for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
Brian Osman10fc6fd2018-03-02 11:01:10 -0500206 for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType,
207 kRGBA_1010102_SkColorType }) {
Brian Salomon52e943a2018-03-13 09:32:39 -0400208 // External on-screen render target.
209 // Tests wrapBackendRenderTarget with a GrBackendRenderTarget
210 // Our test-only function that creates a backend render target doesn't currently support
211 // sample counts :(.
212 if (ctxInfo.grContext()->colorTypeSupportedAsSurface(colorType)) {
213 GrBackendRenderTarget backendRT = gpu->createTestingOnlyBackendRenderTarget(
Brian Osman2d010b62018-08-09 10:55:09 -0400214 kWidthHeight, kWidthHeight, SkColorTypeToGrColorType(colorType));
Brian Salomon52e943a2018-03-13 09:32:39 -0400215 sk_sp<GrSurfaceProxy> sProxy(
216 proxyProvider->wrapBackendRenderTarget(backendRT, origin));
217 check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight,
Greg Daniel108bb232018-07-03 16:18:29 -0400218 backendRT.pixelConfig(), SkBudgeted::kNo);
Brian Salomon52e943a2018-03-13 09:32:39 -0400219 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}) {
Brian Osman2b23c4b2018-06-01 12:25:08 -0400227 GrPixelConfig config = SkColorType2GrPixelConfig(colorType);
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,
Greg Daniel108bb232018-07-03 16:18:29 -0400242 kStencilBits, fboInfo);
243 backendRT.setPixelConfig(config);
Brian Salomon7578f3e2018-03-07 14:39:54 -0500244 sk_sp<GrSurfaceProxy> sProxy(
245 proxyProvider->wrapBackendRenderTarget(backendRT, origin));
Greg Daniel2a303902018-02-20 10:25:54 -0500246 check_surface(reporter, sProxy.get(), origin,
247 kWidthHeight, kWidthHeight,
Greg Daniel108bb232018-07-03 16:18:29 -0400248 backendRT.pixelConfig(), SkBudgeted::kNo);
Greg Daniel2a303902018-02-20 10:25:54 -0500249 check_rendertarget(reporter, caps, resourceProvider,
250 sProxy->asRenderTargetProxy(),
251 supportedNumSamples, SkBackingFit::kExact, 0);
252 }
253
Brian Salomon7578f3e2018-03-07 14:39:54 -0500254 // Tests wrapBackendRenderTarget with a GrBackendTexture
Greg Daniel2a303902018-02-20 10:25:54 -0500255 {
256 GrBackendTexture backendTex =
257 gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight,
Brian Osman2b23c4b2018-06-01 12:25:08 -0400258 kWidthHeight, colorType,
Greg Daniel57bf4a32018-04-19 10:28:37 -0400259 true, GrMipMapped::kNo);
Brian Salomon7578f3e2018-03-07 14:39:54 -0500260 sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTextureAsRenderTarget(
261 backendTex, origin, supportedNumSamples);
Greg Daniel2a303902018-02-20 10:25:54 -0500262 if (!sProxy) {
Brian Salomon26102cb2018-03-09 09:33:19 -0500263 gpu->deleteTestingOnlyBackendTexture(backendTex);
Greg Daniel2a303902018-02-20 10:25:54 -0500264 continue; // This can fail on Mesa
csmartdaltonf9635992016-08-10 11:09:07 -0700265 }
266
Greg Daniel2a303902018-02-20 10:25:54 -0500267 check_surface(reporter, sProxy.get(), origin,
268 kWidthHeight, kWidthHeight,
Greg Daniel108bb232018-07-03 16:18:29 -0400269 backendTex.pixelConfig(), SkBudgeted::kNo);
Greg Daniel2a303902018-02-20 10:25:54 -0500270 check_rendertarget(reporter, caps, resourceProvider,
271 sProxy->asRenderTargetProxy(),
272 supportedNumSamples, SkBackingFit::kExact,
273 caps.maxWindowRectangles());
robertphillips76948d42016-05-04 12:47:41 -0700274
Brian Salomon26102cb2018-03-09 09:33:19 -0500275 gpu->deleteTestingOnlyBackendTexture(backendTex);
Greg Daniel2a303902018-02-20 10:25:54 -0500276 }
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500277
Brian Salomon7578f3e2018-03-07 14:39:54 -0500278 // Tests wrapBackendTexture that is only renderable
Greg Danielf87651e2018-02-21 11:36:53 -0500279 {
280 GrBackendTexture backendTex =
281 gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight,
Brian Osman2b23c4b2018-06-01 12:25:08 -0400282 kWidthHeight, colorType,
Greg Daniel57bf4a32018-04-19 10:28:37 -0400283 true, GrMipMapped::kNo);
Greg Danielf87651e2018-02-21 11:36:53 -0500284
Brian Salomon7578f3e2018-03-07 14:39:54 -0500285 sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapRenderableBackendTexture(
286 backendTex, origin, supportedNumSamples);
Greg Danielf87651e2018-02-21 11:36:53 -0500287 if (!sProxy) {
Brian Salomon26102cb2018-03-09 09:33:19 -0500288 gpu->deleteTestingOnlyBackendTexture(backendTex);
Greg Danielf87651e2018-02-21 11:36:53 -0500289 continue; // This can fail on Mesa
290 }
291
292 check_surface(reporter, sProxy.get(), origin,
293 kWidthHeight, kWidthHeight,
Greg Daniel108bb232018-07-03 16:18:29 -0400294 backendTex.pixelConfig(), SkBudgeted::kNo);
Greg Danielf87651e2018-02-21 11:36:53 -0500295 check_rendertarget(reporter, caps, resourceProvider,
296 sProxy->asRenderTargetProxy(),
297 supportedNumSamples, SkBackingFit::kExact,
298 caps.maxWindowRectangles());
299
Brian Salomon26102cb2018-03-09 09:33:19 -0500300 gpu->deleteTestingOnlyBackendTexture(backendTex);
Greg Danielf87651e2018-02-21 11:36:53 -0500301 }
302
Brian Salomon7578f3e2018-03-07 14:39:54 -0500303 // Tests wrapBackendTexture that is only textureable
Greg Daniel2a303902018-02-20 10:25:54 -0500304 {
305 // Internal offscreen texture
306 GrBackendTexture backendTex =
307 gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight,
Brian Osman2b23c4b2018-06-01 12:25:08 -0400308 kWidthHeight, colorType,
Greg Daniel57bf4a32018-04-19 10:28:37 -0400309 false, GrMipMapped::kNo);
robertphillips76948d42016-05-04 12:47:41 -0700310
Brian Salomon7578f3e2018-03-07 14:39:54 -0500311 sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTexture(
312 backendTex, origin, kBorrow_GrWrapOwnership, nullptr, nullptr);
Greg Daniel2a303902018-02-20 10:25:54 -0500313 if (!sProxy) {
Brian Salomon26102cb2018-03-09 09:33:19 -0500314 gpu->deleteTestingOnlyBackendTexture(backendTex);
Greg Daniel2a303902018-02-20 10:25:54 -0500315 continue;
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500316 }
Greg Daniel2a303902018-02-20 10:25:54 -0500317
318 check_surface(reporter, sProxy.get(), origin,
319 kWidthHeight, kWidthHeight,
Greg Daniel108bb232018-07-03 16:18:29 -0400320 backendTex.pixelConfig(), SkBudgeted::kNo);
Greg Daniel2a303902018-02-20 10:25:54 -0500321 check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
322 SkBackingFit::kExact);
323
Brian Salomon26102cb2018-03-09 09:33:19 -0500324 gpu->deleteTestingOnlyBackendTexture(backendTex);
robertphillips76948d42016-05-04 12:47:41 -0700325 }
326 }
327 }
328 }
329}
330
Robert Phillips78de2122017-04-26 07:44:26 -0400331DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ZeroSizedProxyTest, reporter, ctxInfo) {
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500332 GrProxyProvider* provider = ctxInfo.grContext()->contextPriv().proxyProvider();
Robert Phillips78de2122017-04-26 07:44:26 -0400333
334 for (auto flags : { kRenderTarget_GrSurfaceFlag, kNone_GrSurfaceFlags }) {
335 for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
336 for (int width : { 0, 100 }) {
337 for (int height : { 0, 100}) {
338 if (width && height) {
339 continue; // not zero-sized
340 }
341
342 GrSurfaceDesc desc;
343 desc.fFlags = flags;
Robert Phillips78de2122017-04-26 07:44:26 -0400344 desc.fWidth = width;
345 desc.fHeight = height;
346 desc.fConfig = kRGBA_8888_GrPixelConfig;
Brian Salomonbdecacf2018-02-02 20:32:49 -0500347 desc.fSampleCnt = 1;
Robert Phillips78de2122017-04-26 07:44:26 -0400348
Brian Salomon2a4f9832018-03-03 22:43:43 -0500349 sk_sp<GrTextureProxy> proxy = provider->createProxy(
350 desc, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kNo);
Robert Phillips78de2122017-04-26 07:44:26 -0400351 REPORTER_ASSERT(reporter, !proxy);
352 }
353 }
354 }
355 }
356}