2016-05-04 19:47:41 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// This is a GPU-backend specific test.
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/gpu/GrBackendSurface.h"
|
2020-07-06 14:56:46 +00:00
|
|
|
#include "include/gpu/GrDirectContext.h"
|
2022-04-07 15:20:24 +00:00
|
|
|
#include "src/gpu/ganesh/GrDirectContextPriv.h"
|
|
|
|
#include "src/gpu/ganesh/GrGpu.h"
|
|
|
|
#include "src/gpu/ganesh/GrProxyProvider.h"
|
|
|
|
#include "src/gpu/ganesh/GrRenderTarget.h"
|
|
|
|
#include "src/gpu/ganesh/GrRenderTargetProxy.h"
|
|
|
|
#include "src/gpu/ganesh/GrResourceProvider.h"
|
|
|
|
#include "src/gpu/ganesh/GrSurface.h"
|
|
|
|
#include "src/gpu/ganesh/GrSurfaceProxyPriv.h"
|
|
|
|
#include "src/gpu/ganesh/GrTexture.h"
|
|
|
|
#include "src/gpu/ganesh/GrTextureProxy.h"
|
|
|
|
#include "src/gpu/ganesh/SkGr.h"
|
2020-10-13 00:45:06 +00:00
|
|
|
#include "tests/Test.h"
|
|
|
|
#include "tools/gpu/ManagedBackendTexture.h"
|
2019-11-08 21:18:15 +00:00
|
|
|
#ifdef SK_GL
|
2022-04-07 15:20:24 +00:00
|
|
|
#include "src/gpu/ganesh/gl/GrGLDefines_impl.h"
|
|
|
|
#include "src/gpu/ganesh/gl/GrGLUtil.h"
|
2019-11-08 21:18:15 +00:00
|
|
|
#endif
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2020-05-06 15:40:03 +00:00
|
|
|
#include "tests/TestUtils.h"
|
|
|
|
|
2016-08-31 21:04:06 +00:00
|
|
|
// Check that the surface proxy's member vars are set as expected
|
2016-05-04 19:47:41 +00:00
|
|
|
static void check_surface(skiatest::Reporter* reporter,
|
|
|
|
GrSurfaceProxy* proxy,
|
2017-05-01 13:50:58 +00:00
|
|
|
int width, int height,
|
2016-11-02 14:23:32 +00:00
|
|
|
SkBudgeted budgeted) {
|
2016-05-04 19:47:41 +00:00
|
|
|
REPORTER_ASSERT(reporter, proxy->width() == width);
|
|
|
|
REPORTER_ASSERT(reporter, proxy->height() == height);
|
2018-01-16 13:06:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, !proxy->uniqueID().isInvalid());
|
2016-11-02 14:23:32 +00:00
|
|
|
REPORTER_ASSERT(reporter, proxy->isBudgeted() == budgeted);
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void check_rendertarget(skiatest::Reporter* reporter,
|
2016-11-09 13:54:35 +00:00
|
|
|
const GrCaps& caps,
|
2017-03-04 13:12:46 +00:00
|
|
|
GrResourceProvider* provider,
|
2016-05-04 19:47:41 +00:00
|
|
|
GrRenderTargetProxy* rtProxy,
|
2016-11-02 14:23:32 +00:00
|
|
|
int numSamples,
|
2016-11-09 13:54:35 +00:00
|
|
|
SkBackingFit fit,
|
2018-02-20 15:25:54 +00:00
|
|
|
int expectedMaxWindowRects) {
|
2016-11-09 13:54:35 +00:00
|
|
|
REPORTER_ASSERT(reporter, rtProxy->maxWindowRectangles(caps) == expectedMaxWindowRects);
|
2019-06-24 00:07:38 +00:00
|
|
|
REPORTER_ASSERT(reporter, rtProxy->numSamples() == numSamples);
|
2016-11-02 14:23:32 +00:00
|
|
|
|
2016-11-11 17:38:40 +00:00
|
|
|
GrSurfaceProxy::UniqueID idBefore = rtProxy->uniqueID();
|
2018-07-31 21:25:29 +00:00
|
|
|
bool preinstantiated = rtProxy->isInstantiated();
|
2017-06-05 13:26:07 +00:00
|
|
|
REPORTER_ASSERT(reporter, rtProxy->instantiate(provider));
|
2018-07-31 21:25:29 +00:00
|
|
|
GrRenderTarget* rt = rtProxy->peekRenderTarget();
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2016-11-11 17:38:40 +00:00
|
|
|
REPORTER_ASSERT(reporter, rtProxy->uniqueID() == idBefore);
|
2018-02-20 15:25:54 +00:00
|
|
|
// Deferred resources should always have a different ID from their instantiated rendertarget
|
2018-03-08 15:13:17 +00:00
|
|
|
if (preinstantiated) {
|
|
|
|
REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() == rt->uniqueID().asUInt());
|
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() != rt->uniqueID().asUInt());
|
|
|
|
}
|
2016-11-11 17:38:40 +00:00
|
|
|
|
2016-05-04 19:47:41 +00:00
|
|
|
if (SkBackingFit::kExact == fit) {
|
2019-10-22 14:37:46 +00:00
|
|
|
REPORTER_ASSERT(reporter, rt->dimensions() == rtProxy->dimensions());
|
2016-05-04 19:47:41 +00:00
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(reporter, rt->width() >= rtProxy->width());
|
2016-11-11 17:38:40 +00:00
|
|
|
REPORTER_ASSERT(reporter, rt->height() >= rtProxy->height());
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
2020-01-22 21:53:38 +00:00
|
|
|
REPORTER_ASSERT(reporter, rt->backendFormat() == rtProxy->backendFormat());
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2019-06-24 00:07:38 +00:00
|
|
|
REPORTER_ASSERT(reporter, rt->numSamples() == rtProxy->numSamples());
|
2020-07-28 13:23:35 +00:00
|
|
|
REPORTER_ASSERT(reporter, rt->flags() == rtProxy->testingOnly_getFlags());
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void check_texture(skiatest::Reporter* reporter,
|
2017-03-04 13:12:46 +00:00
|
|
|
GrResourceProvider* provider,
|
2016-05-04 19:47:41 +00:00
|
|
|
GrTextureProxy* texProxy,
|
2018-02-20 15:25:54 +00:00
|
|
|
SkBackingFit fit) {
|
2016-11-11 17:38:40 +00:00
|
|
|
GrSurfaceProxy::UniqueID idBefore = texProxy->uniqueID();
|
2017-06-05 13:26:07 +00:00
|
|
|
|
2018-07-31 21:25:29 +00:00
|
|
|
bool preinstantiated = texProxy->isInstantiated();
|
2019-09-13 19:29:41 +00:00
|
|
|
// The instantiated texture should have these dimensions. If the fit is kExact, then
|
2019-10-23 16:41:29 +00:00
|
|
|
// 'backingStoreDimensions' reports the original WxH. If it is kApprox, make sure that
|
|
|
|
// the texture is that size and didn't reuse one of the kExact surfaces in the provider.
|
|
|
|
// This is important because upstream usage (e.g. SkImage) reports size based on the
|
|
|
|
// backingStoreDimensions and client code may rely on that if they are creating backend
|
|
|
|
// resources.
|
|
|
|
// NOTE: we store these before instantiating, since after instantiation backingStoreDimensions
|
|
|
|
// just returns the target's dimensions. In this instance, we want to ensure the target's
|
2019-10-22 14:37:46 +00:00
|
|
|
// dimensions are no different from the original approximate (or exact) dimensions.
|
2019-10-23 16:41:29 +00:00
|
|
|
SkISize expectedSize = texProxy->backingStoreDimensions();
|
2019-09-13 19:29:41 +00:00
|
|
|
|
2017-06-05 13:26:07 +00:00
|
|
|
REPORTER_ASSERT(reporter, texProxy->instantiate(provider));
|
2018-07-31 21:25:29 +00:00
|
|
|
GrTexture* tex = texProxy->peekTexture();
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2016-11-11 17:38:40 +00:00
|
|
|
REPORTER_ASSERT(reporter, texProxy->uniqueID() == idBefore);
|
2018-02-20 15:25:54 +00:00
|
|
|
// Deferred resources should always have a different ID from their instantiated texture
|
2018-03-08 15:13:17 +00:00
|
|
|
if (preinstantiated) {
|
|
|
|
REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() == tex->uniqueID().asUInt());
|
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() != tex->uniqueID().asUInt());
|
|
|
|
}
|
2016-11-11 17:38:40 +00:00
|
|
|
|
2019-10-22 14:37:46 +00:00
|
|
|
REPORTER_ASSERT(reporter, tex->dimensions() == expectedSize);
|
2019-09-13 19:29:41 +00:00
|
|
|
|
2020-01-22 21:53:38 +00:00
|
|
|
REPORTER_ASSERT(reporter, tex->backendFormat() == texProxy->backendFormat());
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-31 21:04:06 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
|
2020-07-06 14:56:46 +00:00
|
|
|
auto direct = ctxInfo.directContext();
|
|
|
|
GrProxyProvider* proxyProvider = direct->priv().proxyProvider();
|
|
|
|
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
|
|
|
|
const GrCaps& caps = *direct->priv().caps();
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2017-02-01 14:20:00 +00:00
|
|
|
|
2020-02-14 15:47:18 +00:00
|
|
|
for (auto widthHeight : {100, 128, 1048576}) {
|
|
|
|
for (auto ct : {GrColorType::kAlpha_8, GrColorType::kBGR_565, GrColorType::kRGBA_8888,
|
|
|
|
GrColorType::kRGBA_1010102}) {
|
|
|
|
for (auto fit : {SkBackingFit::kExact, SkBackingFit::kApprox}) {
|
|
|
|
for (auto budgeted : {SkBudgeted::kYes, SkBudgeted::kNo}) {
|
|
|
|
for (auto numSamples : {1, 4, 16, 128}) {
|
|
|
|
SkISize dims = {widthHeight, widthHeight};
|
|
|
|
|
|
|
|
auto format = caps.getDefaultBackendFormat(ct, GrRenderable::kYes);
|
|
|
|
if (!format.isValid()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Renderable
|
|
|
|
{
|
|
|
|
sk_sp<GrTexture> tex;
|
|
|
|
if (SkBackingFit::kApprox == fit) {
|
2022-05-03 20:00:24 +00:00
|
|
|
tex = resourceProvider->createApproxTexture(dims,
|
|
|
|
format,
|
|
|
|
GrTextureType::k2D,
|
|
|
|
GrRenderable::kYes,
|
|
|
|
numSamples,
|
|
|
|
GrProtected::kNo,
|
|
|
|
/*label=*/{});
|
2020-02-14 15:47:18 +00:00
|
|
|
} else {
|
2022-05-03 20:00:24 +00:00
|
|
|
tex = resourceProvider->createTexture(dims,
|
|
|
|
format,
|
|
|
|
GrTextureType::k2D,
|
|
|
|
GrRenderable::kYes,
|
|
|
|
numSamples,
|
|
|
|
GrMipmapped::kNo,
|
|
|
|
budgeted,
|
|
|
|
GrProtected::kNo,
|
|
|
|
/*label=*/{});
|
2019-06-13 19:21:38 +00:00
|
|
|
}
|
2020-02-14 15:47:18 +00:00
|
|
|
|
|
|
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
|
2020-07-21 13:27:25 +00:00
|
|
|
format, dims, GrRenderable::kYes, numSamples, GrMipmapped::kNo,
|
2022-06-08 17:45:19 +00:00
|
|
|
fit, budgeted, GrProtected::kNo, /*label=*/{});
|
2020-02-14 15:47:18 +00:00
|
|
|
REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
|
|
|
|
if (proxy) {
|
|
|
|
REPORTER_ASSERT(reporter, proxy->asRenderTargetProxy());
|
|
|
|
// This forces the proxy to compute and cache its
|
|
|
|
// pre-instantiation size guess. Later, when it is actually
|
|
|
|
// instantiated, it checks that the instantiated size is <= to
|
|
|
|
// the pre-computation. If the proxy never computed its
|
|
|
|
// pre-instantiation size then the check is skipped.
|
2020-10-01 17:46:00 +00:00
|
|
|
proxy->gpuMemorySize();
|
2020-02-14 15:47:18 +00:00
|
|
|
|
|
|
|
check_surface(reporter, proxy.get(), widthHeight, widthHeight,
|
|
|
|
budgeted);
|
|
|
|
int supportedSamples =
|
|
|
|
caps.getRenderTargetSampleCount(numSamples, format);
|
|
|
|
check_rendertarget(reporter, caps, resourceProvider,
|
|
|
|
proxy->asRenderTargetProxy(), supportedSamples,
|
|
|
|
fit, caps.maxWindowRectangles());
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
2020-02-14 15:47:18 +00:00
|
|
|
}
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2020-02-14 15:47:18 +00:00
|
|
|
// Not renderable
|
|
|
|
{
|
|
|
|
sk_sp<GrTexture> tex;
|
|
|
|
if (SkBackingFit::kApprox == fit) {
|
2022-05-03 20:00:24 +00:00
|
|
|
tex = resourceProvider->createApproxTexture(dims,
|
|
|
|
format,
|
|
|
|
GrTextureType::k2D,
|
|
|
|
GrRenderable::kNo,
|
|
|
|
numSamples,
|
|
|
|
GrProtected::kNo,
|
|
|
|
/*label=*/{});
|
2020-02-14 15:47:18 +00:00
|
|
|
} else {
|
2022-05-03 20:00:24 +00:00
|
|
|
tex = resourceProvider->createTexture(dims,
|
|
|
|
format,
|
|
|
|
GrTextureType::k2D,
|
|
|
|
GrRenderable::kNo,
|
|
|
|
numSamples,
|
|
|
|
GrMipmapped::kNo,
|
|
|
|
budgeted,
|
|
|
|
GrProtected::kNo,
|
|
|
|
/*label=*/{});
|
2017-01-30 19:15:59 +00:00
|
|
|
}
|
2017-02-01 14:20:00 +00:00
|
|
|
|
2020-02-14 15:47:18 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy(proxyProvider->createProxy(
|
2020-07-21 13:27:25 +00:00
|
|
|
format, dims, GrRenderable::kNo, numSamples, GrMipmapped::kNo,
|
2022-06-08 17:45:19 +00:00
|
|
|
fit, budgeted, GrProtected::kNo, /*label=*/{}));
|
2020-02-14 15:47:18 +00:00
|
|
|
REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
|
|
|
|
if (proxy) {
|
|
|
|
// This forces the proxy to compute and cache its
|
|
|
|
// pre-instantiation size guess. Later, when it is actually
|
|
|
|
// instantiated, it checks that the instantiated size is <= to
|
|
|
|
// the pre-computation. If the proxy never computed its
|
|
|
|
// pre-instantiation size then the check is skipped.
|
2020-10-01 17:46:00 +00:00
|
|
|
proxy->gpuMemorySize();
|
2020-02-14 15:47:18 +00:00
|
|
|
|
|
|
|
check_surface(reporter, proxy.get(), widthHeight, widthHeight,
|
|
|
|
budgeted);
|
|
|
|
check_texture(reporter, resourceProvider, proxy->asTextureProxy(),
|
|
|
|
fit);
|
|
|
|
}
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-28 15:07:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
2020-07-06 14:56:46 +00:00
|
|
|
auto direct = ctxInfo.directContext();
|
|
|
|
GrProxyProvider* proxyProvider = direct->priv().proxyProvider();
|
|
|
|
GrResourceProvider* resourceProvider = direct->priv().resourceProvider();
|
|
|
|
GrGpu* gpu = direct->priv().getGpu();
|
|
|
|
const GrCaps& caps = *direct->priv().caps();
|
2016-05-04 19:47:41 +00:00
|
|
|
|
|
|
|
static const int kWidthHeight = 100;
|
|
|
|
|
2020-02-14 15:47:18 +00:00
|
|
|
for (auto colorType :
|
|
|
|
{kAlpha_8_SkColorType, kRGBA_8888_SkColorType, kRGBA_1010102_SkColorType}) {
|
|
|
|
GrColorType grColorType = SkColorTypeToGrColorType(colorType);
|
|
|
|
|
|
|
|
// External on-screen render target.
|
|
|
|
// Tests wrapBackendRenderTarget with a GrBackendRenderTarget
|
|
|
|
// Our test-only function that creates a backend render target doesn't currently support
|
|
|
|
// sample counts :(.
|
2020-07-06 14:56:46 +00:00
|
|
|
if (direct->colorTypeSupportedAsSurface(colorType)) {
|
2020-02-14 15:47:18 +00:00
|
|
|
GrBackendRenderTarget backendRT = gpu->createTestingOnlyBackendRenderTarget(
|
2020-10-06 14:07:38 +00:00
|
|
|
{kWidthHeight, kWidthHeight}, grColorType);
|
2020-03-27 14:42:15 +00:00
|
|
|
sk_sp<GrSurfaceProxy> sProxy(
|
2020-06-29 17:05:29 +00:00
|
|
|
proxyProvider->wrapBackendRenderTarget(backendRT, nullptr));
|
2020-02-14 15:47:18 +00:00
|
|
|
check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight, SkBudgeted::kNo);
|
|
|
|
static constexpr int kExpectedNumSamples = 1;
|
|
|
|
check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
|
|
|
|
kExpectedNumSamples, SkBackingFit::kExact,
|
|
|
|
caps.maxWindowRectangles());
|
|
|
|
gpu->deleteTestingOnlyBackendRenderTarget(backendRT);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto numSamples : {1, 4}) {
|
|
|
|
auto beFormat = caps.getDefaultBackendFormat(grColorType, GrRenderable::kYes);
|
|
|
|
int supportedNumSamples = caps.getRenderTargetSampleCount(numSamples, beFormat);
|
|
|
|
if (!supportedNumSamples) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SK_GL
|
|
|
|
// Test wrapping FBO 0 (with made up properties). This tests sample count and the
|
|
|
|
// special case where FBO 0 doesn't support window rectangles.
|
|
|
|
if (GrBackendApi::kOpenGL == ctxInfo.backend()) {
|
|
|
|
GrGLFramebufferInfo fboInfo;
|
|
|
|
fboInfo.fFBOID = 0;
|
|
|
|
fboInfo.fFormat = GrGLFormatToEnum(beFormat.asGLFormat());
|
|
|
|
SkASSERT(fboInfo.fFormat);
|
|
|
|
static constexpr int kStencilBits = 8;
|
|
|
|
GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples,
|
|
|
|
kStencilBits, fboInfo);
|
2020-03-27 14:42:15 +00:00
|
|
|
sk_sp<GrSurfaceProxy> sProxy(
|
2020-06-29 17:05:29 +00:00
|
|
|
proxyProvider->wrapBackendRenderTarget(backendRT, nullptr));
|
2020-02-13 19:25:00 +00:00
|
|
|
check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight, SkBudgeted::kNo);
|
2018-03-13 13:32:39 +00:00
|
|
|
check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
|
2020-02-14 15:47:18 +00:00
|
|
|
supportedNumSamples, SkBackingFit::kExact, 0);
|
2018-03-13 13:32:39 +00:00
|
|
|
}
|
2020-02-14 15:47:18 +00:00
|
|
|
#endif
|
2018-03-13 13:32:39 +00:00
|
|
|
|
2020-02-14 15:47:18 +00:00
|
|
|
// Tests wrapBackendTexture that is only renderable
|
|
|
|
{
|
2020-10-13 00:45:06 +00:00
|
|
|
auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(direct,
|
|
|
|
kWidthHeight,
|
|
|
|
kWidthHeight,
|
|
|
|
colorType,
|
|
|
|
GrMipmapped::kNo,
|
|
|
|
GrRenderable::kYes);
|
|
|
|
if (!mbet) {
|
|
|
|
ERRORF(reporter,
|
|
|
|
"Could not create renderable backend texture of color type %d",
|
|
|
|
colorType);
|
|
|
|
continue;
|
|
|
|
}
|
2020-02-14 15:47:18 +00:00
|
|
|
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapRenderableBackendTexture(
|
2020-10-13 00:45:06 +00:00
|
|
|
mbet->texture(), supportedNumSamples, kBorrow_GrWrapOwnership,
|
2020-06-29 17:05:29 +00:00
|
|
|
GrWrapCacheable::kNo, nullptr);
|
2020-02-14 15:47:18 +00:00
|
|
|
if (!sProxy) {
|
2020-10-13 00:45:06 +00:00
|
|
|
ERRORF(reporter, "wrapRenderableBackendTexture failed");
|
|
|
|
continue;
|
2018-02-21 16:36:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 15:47:18 +00:00
|
|
|
check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight, SkBudgeted::kNo);
|
|
|
|
check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
|
|
|
|
supportedNumSamples, SkBackingFit::kExact,
|
|
|
|
caps.maxWindowRectangles());
|
|
|
|
}
|
2018-01-16 13:06:32 +00:00
|
|
|
|
2020-02-14 15:47:18 +00:00
|
|
|
{
|
2020-10-13 00:45:06 +00:00
|
|
|
// Tests wrapBackendTexture that is only textureable
|
|
|
|
auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(direct,
|
|
|
|
kWidthHeight,
|
|
|
|
kWidthHeight,
|
|
|
|
colorType,
|
|
|
|
GrMipmapped::kNo,
|
|
|
|
GrRenderable::kNo);
|
|
|
|
if (!mbet) {
|
|
|
|
ERRORF(reporter,
|
|
|
|
"Could not create non-renderable backend texture of color type %d",
|
|
|
|
colorType);
|
|
|
|
continue;
|
|
|
|
}
|
2020-02-14 15:47:18 +00:00
|
|
|
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTexture(
|
2020-10-13 00:45:06 +00:00
|
|
|
mbet->texture(), kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
|
|
|
|
kRead_GrIOType, mbet->refCountedCallback());
|
2020-02-14 15:47:18 +00:00
|
|
|
if (!sProxy) {
|
2020-10-13 00:45:06 +00:00
|
|
|
ERRORF(reporter, "wrapBackendTexture failed");
|
2020-02-14 15:47:18 +00:00
|
|
|
continue;
|
2018-02-20 15:25:54 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 15:47:18 +00:00
|
|
|
check_surface(reporter, sProxy.get(), kWidthHeight, kWidthHeight, SkBudgeted::kNo);
|
|
|
|
check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
|
|
|
|
SkBackingFit::kExact);
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 11:44:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ZeroSizedProxyTest, reporter, ctxInfo) {
|
2020-07-06 14:56:46 +00:00
|
|
|
auto direct = ctxInfo.directContext();
|
|
|
|
GrProxyProvider* provider = direct->priv().proxyProvider();
|
2017-04-26 11:44:26 +00:00
|
|
|
|
2019-07-17 13:59:59 +00:00
|
|
|
for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
|
2017-04-26 11:44:26 +00:00
|
|
|
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
|
|
|
|
for (int width : { 0, 100 }) {
|
|
|
|
for (int height : { 0, 100}) {
|
|
|
|
if (width && height) {
|
|
|
|
continue; // not zero-sized
|
|
|
|
}
|
|
|
|
|
2018-11-16 20:43:41 +00:00
|
|
|
const GrBackendFormat format =
|
2020-07-06 14:56:46 +00:00
|
|
|
direct->priv().caps()->getDefaultBackendFormat(
|
2019-07-30 16:49:10 +00:00
|
|
|
GrColorType::kRGBA_8888,
|
|
|
|
renderable);
|
2018-11-16 20:43:41 +00:00
|
|
|
|
2020-02-14 15:47:18 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy = provider->createProxy(
|
2020-07-21 13:27:25 +00:00
|
|
|
format, {width, height}, renderable, 1, GrMipmapped::kNo, fit,
|
2022-06-08 17:45:19 +00:00
|
|
|
SkBudgeted::kNo, GrProtected::kNo, /*label=*/{});
|
2017-04-26 11:44:26 +00:00
|
|
|
REPORTER_ASSERT(reporter, !proxy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|