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 "tests/Test.h"
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/gpu/GrBackendSurface.h"
|
|
|
|
#include "include/gpu/GrTexture.h"
|
|
|
|
#include "src/gpu/GrContextPriv.h"
|
|
|
|
#include "src/gpu/GrProxyProvider.h"
|
|
|
|
#include "src/gpu/GrRenderTargetPriv.h"
|
2019-06-18 13:58:02 +00:00
|
|
|
#include "src/gpu/GrRenderTargetProxy.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/GrResourceProvider.h"
|
|
|
|
#include "src/gpu/GrSurfacePriv.h"
|
|
|
|
#include "src/gpu/GrSurfaceProxyPriv.h"
|
2019-06-18 13:58:02 +00:00
|
|
|
#include "src/gpu/GrTextureProxy.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/SkGr.h"
|
2019-11-08 21:18:15 +00:00
|
|
|
#ifdef SK_GL
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/gl/GrGLDefines.h"
|
2019-08-08 16:08:24 +00:00
|
|
|
#include "src/gpu/gl/GrGLUtil.h"
|
2019-11-08 21:18:15 +00:00
|
|
|
#endif
|
2016-05-04 19:47:41 +00:00
|
|
|
|
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,
|
|
|
|
GrSurfaceOrigin origin,
|
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->origin() == origin);
|
|
|
|
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());
|
2018-03-16 20:47:25 +00:00
|
|
|
REPORTER_ASSERT(reporter, rt->surfacePriv().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) {
|
2019-02-04 18:26:26 +00:00
|
|
|
GrProxyProvider* proxyProvider = ctxInfo.grContext()->priv().proxyProvider();
|
|
|
|
GrResourceProvider* resourceProvider = ctxInfo.grContext()->priv().resourceProvider();
|
|
|
|
const GrCaps& caps = *ctxInfo.grContext()->priv().caps();
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2017-02-01 14:20:00 +00:00
|
|
|
int attempt = 0; // useful for debugging
|
|
|
|
|
2016-05-04 19:47:41 +00:00
|
|
|
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
|
2017-01-30 19:15:59 +00:00
|
|
|
for (auto widthHeight : { 100, 128, 1048576 }) {
|
2019-07-09 16:34:38 +00:00
|
|
|
for (auto ct : { GrColorType::kAlpha_8, GrColorType::kBGR_565,
|
|
|
|
GrColorType::kRGBA_8888, GrColorType::kRGBA_1010102 } ) {
|
2016-05-04 19:47:41 +00:00
|
|
|
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
|
|
|
|
for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
|
2018-02-03 01:32:49 +00:00
|
|
|
for (auto numSamples : {1, 4, 16, 128}) {
|
2016-05-04 19:47:41 +00:00
|
|
|
GrSurfaceDesc desc;
|
|
|
|
desc.fWidth = widthHeight;
|
|
|
|
desc.fHeight = widthHeight;
|
|
|
|
|
2019-07-30 16:49:10 +00:00
|
|
|
auto format = caps.getDefaultBackendFormat(ct, GrRenderable::kYes);
|
2019-06-13 19:21:38 +00:00
|
|
|
if (!format.isValid()) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-01-21 19:29:57 +00:00
|
|
|
GrSwizzle swizzle = caps.getReadSwizzle(format, ct);
|
2018-11-16 20:43:41 +00:00
|
|
|
|
2019-07-17 13:59:59 +00:00
|
|
|
// Renderable
|
2017-02-01 14:20:00 +00:00
|
|
|
{
|
|
|
|
sk_sp<GrTexture> tex;
|
|
|
|
if (SkBackingFit::kApprox == fit) {
|
2018-09-27 15:28:03 +00:00
|
|
|
tex = resourceProvider->createApproxTexture(
|
2019-08-05 16:58:39 +00:00
|
|
|
desc, format, GrRenderable::kYes, numSamples,
|
2019-09-06 15:48:27 +00:00
|
|
|
GrProtected::kNo);
|
2017-02-01 14:20:00 +00:00
|
|
|
} else {
|
2019-04-09 22:41:27 +00:00
|
|
|
tex = resourceProvider->createTexture(
|
2019-09-17 13:01:56 +00:00
|
|
|
desc, format, GrRenderable::kYes, numSamples,
|
|
|
|
GrMipMapped::kNo, budgeted, GrProtected::kNo);
|
2017-02-01 14:20:00 +00:00
|
|
|
}
|
|
|
|
|
2019-07-17 13:59:59 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
|
2020-01-21 19:29:57 +00:00
|
|
|
format, desc, swizzle, GrRenderable::kYes, numSamples,
|
|
|
|
origin, GrMipMapped::kNo, fit, budgeted, GrProtected::kNo);
|
2017-03-02 23:18:38 +00:00
|
|
|
REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
|
|
|
|
if (proxy) {
|
|
|
|
REPORTER_ASSERT(reporter, proxy->asRenderTargetProxy());
|
2017-01-30 19:15:59 +00:00
|
|
|
// 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.
|
2019-10-10 20:10:31 +00:00
|
|
|
proxy->gpuMemorySize(caps);
|
2017-01-30 19:15:59 +00:00
|
|
|
|
2017-03-02 23:18:38 +00:00
|
|
|
check_surface(reporter, proxy.get(), origin,
|
2020-01-22 21:53:38 +00:00
|
|
|
widthHeight, widthHeight, budgeted);
|
2018-02-03 01:32:49 +00:00
|
|
|
int supportedSamples =
|
2019-08-07 19:52:37 +00:00
|
|
|
caps.getRenderTargetSampleCount(numSamples, format);
|
2018-01-08 18:40:32 +00:00
|
|
|
check_rendertarget(reporter, caps, resourceProvider,
|
2017-03-02 23:18:38 +00:00
|
|
|
proxy->asRenderTargetProxy(),
|
2017-07-19 18:47:42 +00:00
|
|
|
supportedSamples,
|
2018-02-20 15:25:54 +00:00
|
|
|
fit, caps.maxWindowRectangles());
|
2017-01-30 19:15:59 +00:00
|
|
|
}
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
|
|
|
|
2019-07-17 13:59:59 +00:00
|
|
|
// Not renderable
|
2017-02-01 14:20:00 +00:00
|
|
|
{
|
|
|
|
sk_sp<GrTexture> tex;
|
|
|
|
if (SkBackingFit::kApprox == fit) {
|
2018-09-27 15:28:03 +00:00
|
|
|
tex = resourceProvider->createApproxTexture(
|
2019-08-05 16:58:39 +00:00
|
|
|
desc, format, GrRenderable::kNo, numSamples,
|
2019-09-06 15:48:27 +00:00
|
|
|
GrProtected::kNo);
|
2017-02-01 14:20:00 +00:00
|
|
|
} else {
|
2019-04-09 22:41:27 +00:00
|
|
|
tex = resourceProvider->createTexture(
|
2019-09-17 13:01:56 +00:00
|
|
|
desc, format, GrRenderable::kNo, numSamples,
|
|
|
|
GrMipMapped::kNo, budgeted, GrProtected::kNo);
|
2017-02-01 14:20:00 +00:00
|
|
|
}
|
|
|
|
|
2019-07-17 13:59:59 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy(proxyProvider->createProxy(
|
2020-01-21 19:29:57 +00:00
|
|
|
format, desc, swizzle, GrRenderable::kNo, numSamples,
|
|
|
|
origin, GrMipMapped::kNo, fit, budgeted, GrProtected::kNo));
|
2017-03-02 23:18:38 +00:00
|
|
|
REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(proxy));
|
|
|
|
if (proxy) {
|
2018-01-08 18:40:32 +00:00
|
|
|
// 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.
|
2019-10-10 20:10:31 +00:00
|
|
|
proxy->gpuMemorySize(caps);
|
2017-02-01 14:20:00 +00:00
|
|
|
|
2017-03-02 23:18:38 +00:00
|
|
|
check_surface(reporter, proxy.get(), origin,
|
2020-01-22 21:53:38 +00:00
|
|
|
widthHeight, widthHeight, budgeted);
|
2018-01-08 18:40:32 +00:00
|
|
|
check_texture(reporter, resourceProvider,
|
2018-02-20 15:25:54 +00:00
|
|
|
proxy->asTextureProxy(), fit);
|
2017-02-01 14:20:00 +00:00
|
|
|
}
|
2017-01-30 19:15:59 +00:00
|
|
|
}
|
2017-02-01 14:20:00 +00:00
|
|
|
|
|
|
|
attempt++;
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-28 15:07:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
2019-02-04 18:26:26 +00:00
|
|
|
GrProxyProvider* proxyProvider = ctxInfo.grContext()->priv().proxyProvider();
|
2019-05-17 14:01:21 +00:00
|
|
|
GrContext* context = ctxInfo.grContext();
|
|
|
|
GrResourceProvider* resourceProvider = context->priv().resourceProvider();
|
|
|
|
GrGpu* gpu = context->priv().getGpu();
|
|
|
|
const GrCaps& caps = *context->priv().caps();
|
2016-05-04 19:47:41 +00:00
|
|
|
|
|
|
|
static const int kWidthHeight = 100;
|
|
|
|
|
|
|
|
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
|
2018-03-02 16:01:10 +00:00
|
|
|
for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType,
|
|
|
|
kRGBA_1010102_SkColorType }) {
|
2019-07-08 20:48:14 +00:00
|
|
|
GrColorType grColorType = SkColorTypeToGrColorType(colorType);
|
2019-07-23 14:27:09 +00:00
|
|
|
|
2018-03-13 13:32:39 +00:00
|
|
|
// 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 :(.
|
|
|
|
if (ctxInfo.grContext()->colorTypeSupportedAsSurface(colorType)) {
|
|
|
|
GrBackendRenderTarget backendRT = gpu->createTestingOnlyBackendRenderTarget(
|
2019-07-08 20:48:14 +00:00
|
|
|
kWidthHeight, kWidthHeight, grColorType);
|
2018-03-13 13:32:39 +00:00
|
|
|
sk_sp<GrSurfaceProxy> sProxy(
|
2019-07-23 14:27:09 +00:00
|
|
|
proxyProvider->wrapBackendRenderTarget(backendRT, grColorType,
|
|
|
|
origin, nullptr, nullptr));
|
2018-03-13 13:32:39 +00:00
|
|
|
check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight,
|
2020-01-22 21:53:38 +00:00
|
|
|
SkBudgeted::kNo);
|
2018-03-13 13:32:39 +00:00
|
|
|
static constexpr int kExpectedNumSamples = 1;
|
|
|
|
check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
|
|
|
|
kExpectedNumSamples, SkBackingFit::kExact,
|
|
|
|
caps.maxWindowRectangles());
|
|
|
|
gpu->deleteTestingOnlyBackendRenderTarget(backendRT);
|
|
|
|
}
|
|
|
|
|
2018-02-20 15:25:54 +00:00
|
|
|
for (auto numSamples : {1, 4}) {
|
2019-08-07 19:52:37 +00:00
|
|
|
auto beFormat = caps.getDefaultBackendFormat(grColorType, GrRenderable::kYes);
|
|
|
|
int supportedNumSamples = caps.getRenderTargetSampleCount(numSamples, beFormat);
|
2018-02-20 15:25:54 +00:00
|
|
|
if (!supportedNumSamples) {
|
|
|
|
continue;
|
|
|
|
}
|
2018-01-16 13:06:32 +00:00
|
|
|
|
2019-11-08 21:18:15 +00:00
|
|
|
#ifdef SK_GL
|
2018-03-13 13:32:39 +00:00
|
|
|
// Test wrapping FBO 0 (with made up properties). This tests sample count and the
|
|
|
|
// special case where FBO 0 doesn't support window rectangles.
|
2018-10-12 13:31:11 +00:00
|
|
|
if (GrBackendApi::kOpenGL == ctxInfo.backend()) {
|
2018-02-20 15:25:54 +00:00
|
|
|
GrGLFramebufferInfo fboInfo;
|
|
|
|
fboInfo.fFBOID = 0;
|
2019-08-08 16:08:24 +00:00
|
|
|
fboInfo.fFormat = GrGLFormatToEnum(beFormat.asGLFormat());
|
|
|
|
SkASSERT(fboInfo.fFormat);
|
2018-03-13 13:32:39 +00:00
|
|
|
static constexpr int kStencilBits = 8;
|
|
|
|
GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples,
|
2018-07-03 20:18:29 +00:00
|
|
|
kStencilBits, fboInfo);
|
2018-03-07 19:39:54 +00:00
|
|
|
sk_sp<GrSurfaceProxy> sProxy(
|
2019-07-23 14:27:09 +00:00
|
|
|
proxyProvider->wrapBackendRenderTarget(backendRT, grColorType,
|
|
|
|
origin, nullptr, nullptr));
|
2018-02-20 15:25:54 +00:00
|
|
|
check_surface(reporter, sProxy.get(), origin,
|
2020-01-22 21:53:38 +00:00
|
|
|
kWidthHeight, kWidthHeight, SkBudgeted::kNo);
|
2018-02-20 15:25:54 +00:00
|
|
|
check_rendertarget(reporter, caps, resourceProvider,
|
|
|
|
sProxy->asRenderTargetProxy(),
|
|
|
|
supportedNumSamples, SkBackingFit::kExact, 0);
|
|
|
|
}
|
2019-11-08 21:18:15 +00:00
|
|
|
#endif
|
2016-05-04 19:47:41 +00:00
|
|
|
|
2018-03-07 19:39:54 +00:00
|
|
|
// Tests wrapBackendRenderTarget with a GrBackendTexture
|
2018-02-21 16:36:53 +00:00
|
|
|
{
|
|
|
|
GrBackendTexture backendTex =
|
2019-06-04 15:03:06 +00:00
|
|
|
context->createBackendTexture(kWidthHeight, kWidthHeight,
|
|
|
|
colorType,
|
|
|
|
SkColors::kTransparent,
|
|
|
|
GrMipMapped::kNo,
|
2019-07-01 19:04:06 +00:00
|
|
|
GrRenderable::kYes,
|
|
|
|
GrProtected::kNo);
|
2018-03-07 19:39:54 +00:00
|
|
|
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTextureAsRenderTarget(
|
2019-07-23 14:27:09 +00:00
|
|
|
backendTex, grColorType, origin, supportedNumSamples);
|
2018-02-21 16:36:53 +00:00
|
|
|
if (!sProxy) {
|
2019-05-20 12:38:07 +00:00
|
|
|
context->deleteBackendTexture(backendTex);
|
2018-02-21 16:36:53 +00:00
|
|
|
continue; // This can fail on Mesa
|
|
|
|
}
|
|
|
|
|
|
|
|
check_surface(reporter, sProxy.get(), origin,
|
2020-01-22 21:53:38 +00:00
|
|
|
kWidthHeight, kWidthHeight, SkBudgeted::kNo);
|
2018-02-21 16:36:53 +00:00
|
|
|
check_rendertarget(reporter, caps, resourceProvider,
|
|
|
|
sProxy->asRenderTargetProxy(),
|
|
|
|
supportedNumSamples, SkBackingFit::kExact,
|
|
|
|
caps.maxWindowRectangles());
|
|
|
|
|
2019-05-20 12:38:07 +00:00
|
|
|
context->deleteBackendTexture(backendTex);
|
2018-02-21 16:36:53 +00:00
|
|
|
}
|
|
|
|
|
2018-03-07 19:39:54 +00:00
|
|
|
// Tests wrapBackendTexture that is only renderable
|
2018-02-20 15:25:54 +00:00
|
|
|
{
|
|
|
|
GrBackendTexture backendTex =
|
2019-06-04 15:03:06 +00:00
|
|
|
context->createBackendTexture(kWidthHeight, kWidthHeight,
|
|
|
|
colorType,
|
|
|
|
SkColors::kTransparent,
|
|
|
|
GrMipMapped::kNo,
|
2019-07-01 19:04:06 +00:00
|
|
|
GrRenderable::kYes,
|
|
|
|
GrProtected::kNo);
|
2018-02-20 15:25:54 +00:00
|
|
|
|
2018-03-07 19:39:54 +00:00
|
|
|
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapRenderableBackendTexture(
|
2019-07-16 11:47:56 +00:00
|
|
|
backendTex, origin, supportedNumSamples,
|
|
|
|
grColorType, kBorrow_GrWrapOwnership,
|
2019-02-05 15:08:43 +00:00
|
|
|
GrWrapCacheable::kNo, nullptr, nullptr);
|
2018-02-20 15:25:54 +00:00
|
|
|
if (!sProxy) {
|
2019-05-20 12:38:07 +00:00
|
|
|
context->deleteBackendTexture(backendTex);
|
2018-02-20 15:25:54 +00:00
|
|
|
continue; // This can fail on Mesa
|
|
|
|
}
|
|
|
|
|
|
|
|
check_surface(reporter, sProxy.get(), origin,
|
2020-01-22 21:53:38 +00:00
|
|
|
kWidthHeight, kWidthHeight, SkBudgeted::kNo);
|
2018-02-20 15:25:54 +00:00
|
|
|
check_rendertarget(reporter, caps, resourceProvider,
|
|
|
|
sProxy->asRenderTargetProxy(),
|
|
|
|
supportedNumSamples, SkBackingFit::kExact,
|
|
|
|
caps.maxWindowRectangles());
|
2018-01-16 13:06:32 +00:00
|
|
|
|
2019-05-20 12:38:07 +00:00
|
|
|
context->deleteBackendTexture(backendTex);
|
2018-02-20 15:25:54 +00:00
|
|
|
}
|
|
|
|
|
2018-03-07 19:39:54 +00:00
|
|
|
// Tests wrapBackendTexture that is only textureable
|
2018-02-20 15:25:54 +00:00
|
|
|
{
|
|
|
|
// Internal offscreen texture
|
|
|
|
GrBackendTexture backendTex =
|
2019-06-04 15:03:06 +00:00
|
|
|
context->createBackendTexture(kWidthHeight, kWidthHeight,
|
|
|
|
colorType,
|
|
|
|
SkColors::kTransparent,
|
|
|
|
GrMipMapped::kNo,
|
2019-07-01 19:04:06 +00:00
|
|
|
GrRenderable::kNo,
|
|
|
|
GrProtected::kNo);
|
2018-02-20 15:25:54 +00:00
|
|
|
|
2018-03-07 19:39:54 +00:00
|
|
|
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTexture(
|
2019-07-23 14:27:09 +00:00
|
|
|
backendTex, grColorType, origin, kBorrow_GrWrapOwnership,
|
|
|
|
GrWrapCacheable::kNo, kRead_GrIOType);
|
2018-02-20 15:25:54 +00:00
|
|
|
if (!sProxy) {
|
2019-05-20 12:38:07 +00:00
|
|
|
context->deleteBackendTexture(backendTex);
|
2018-02-20 15:25:54 +00:00
|
|
|
continue;
|
2018-01-16 13:06:32 +00:00
|
|
|
}
|
2018-02-20 15:25:54 +00:00
|
|
|
|
|
|
|
check_surface(reporter, sProxy.get(), origin,
|
2020-01-22 21:53:38 +00:00
|
|
|
kWidthHeight, kWidthHeight, SkBudgeted::kNo);
|
2018-02-20 15:25:54 +00:00
|
|
|
check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
|
|
|
|
SkBackingFit::kExact);
|
|
|
|
|
2019-05-20 12:38:07 +00:00
|
|
|
context->deleteBackendTexture(backendTex);
|
2016-05-04 19:47:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-26 11:44:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ZeroSizedProxyTest, reporter, ctxInfo) {
|
2019-07-30 16:49:10 +00:00
|
|
|
GrContext* context = ctxInfo.grContext();
|
|
|
|
GrProxyProvider* provider = context->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
|
|
|
|
}
|
|
|
|
|
|
|
|
GrSurfaceDesc desc;
|
|
|
|
desc.fWidth = width;
|
|
|
|
desc.fHeight = height;
|
|
|
|
|
2018-11-16 20:43:41 +00:00
|
|
|
const GrBackendFormat format =
|
2019-07-30 16:49:10 +00:00
|
|
|
context->priv().caps()->getDefaultBackendFormat(
|
|
|
|
GrColorType::kRGBA_8888,
|
|
|
|
renderable);
|
2020-01-21 19:29:57 +00:00
|
|
|
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(
|
|
|
|
format, GrColorType::kRGBA_8888);
|
2018-11-16 20:43:41 +00:00
|
|
|
|
2019-07-19 18:24:36 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy = provider->createProxy(
|
2020-01-21 19:29:57 +00:00
|
|
|
format, desc, swizzle, renderable, 1, kBottomLeft_GrSurfaceOrigin,
|
2019-08-30 20:19:42 +00:00
|
|
|
GrMipMapped::kNo, fit, SkBudgeted::kNo, GrProtected::kNo);
|
2017-04-26 11:44:26 +00:00
|
|
|
REPORTER_ASSERT(reporter, !proxy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|