aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ProxyConversionTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ProxyConversionTest.cpp')
-rw-r--r--tests/ProxyConversionTest.cpp58
1 files changed, 35 insertions, 23 deletions
diff --git a/tests/ProxyConversionTest.cpp b/tests/ProxyConversionTest.cpp
index 3ebfbf4778..7103403d43 100644
--- a/tests/ProxyConversionTest.cpp
+++ b/tests/ProxyConversionTest.cpp
@@ -12,6 +12,7 @@
#if SK_SUPPORT_GPU
#include "GrBackendSurface.h"
#include "GrContextPriv.h"
+#include "GrGpu.h"
#include "GrProxyProvider.h"
#include "GrRenderTarget.h"
#include "GrRenderTargetProxy.h"
@@ -19,36 +20,46 @@
#include "GrTexture.h"
#include "GrTextureProxy.h"
-static sk_sp<GrSurfaceProxy> make_wrapped_FBO0(GrProxyProvider* provider,
- skiatest::Reporter* reporter,
- const GrSurfaceDesc& desc,
- GrSurfaceOrigin origin) {
- GrGLFramebufferInfo fboInfo;
- fboInfo.fFBOID = 0;
- GrBackendRenderTarget backendRT(desc.fWidth, desc.fHeight, desc.fSampleCnt, 8,
- desc.fConfig, fboInfo);
-
+static sk_sp<GrSurfaceProxy> make_wrapped_rt(GrProxyProvider* provider,
+ GrGpu* gpu,
+ skiatest::Reporter* reporter,
+ const GrSurfaceDesc& desc,
+ GrSurfaceOrigin origin) {
+ // We don't currently have a way of making MSAA backend render targets.
+ SkASSERT(1 == desc.fSampleCnt);
+ GrSRGBEncoded srgbEncoded;
+ auto ct = GrPixelConfigToColorTypeAndEncoding(desc.fConfig, &srgbEncoded);
+ auto backendRT = gpu->createTestingOnlyBackendRenderTarget(desc.fWidth, desc.fHeight, ct,
+ GrSRGBEncoded::kNo);
return provider->wrapBackendRenderTarget(backendRT, origin);
}
-static sk_sp<GrSurfaceProxy> make_wrapped_offscreen_rt(GrProxyProvider* provider,
- const GrSurfaceDesc& desc,
- GrSurfaceOrigin origin) {
+void clean_up_wrapped_rt(GrGpu* gpu, sk_sp<GrSurfaceProxy> proxy) {
+ SkASSERT(proxy->isUnique_debugOnly());
+ SkASSERT(proxy->priv().peekRenderTarget());
+ GrBackendRenderTarget rt = proxy->priv().peekRenderTarget()->getBackendRenderTarget();
+ proxy.reset();
+ gpu->deleteTestingOnlyBackendRenderTarget(rt);
+}
+
+static sk_sp<GrSurfaceProxy> make_offscreen_rt(GrProxyProvider* provider,
+ const GrSurfaceDesc& desc,
+ GrSurfaceOrigin origin) {
SkASSERT(kRenderTarget_GrSurfaceFlag == desc.fFlags);
return provider->createInstantiatedProxy(desc, origin, SkBackingFit::kExact, SkBudgeted::kYes);
}
-static sk_sp<GrSurfaceProxy> make_wrapped_texture(GrProxyProvider* provider,
- const GrSurfaceDesc& desc,
- GrSurfaceOrigin origin) {
+static sk_sp<GrSurfaceProxy> make_texture(GrProxyProvider* provider,
+ const GrSurfaceDesc& desc,
+ GrSurfaceOrigin origin) {
return provider->createInstantiatedProxy(desc, origin, SkBackingFit::kExact, SkBudgeted::kYes);
}
-// Test converting between RenderTargetProxies and TextureProxies for wrapped
-// Proxies
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo) {
+// Test converting between RenderTargetProxies and TextureProxies for preinstantiated Proxies
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PreinstantiatedProxyConversionTest, reporter, ctxInfo) {
GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
+ GrGpu* gpu = ctxInfo.grContext()->contextPriv().getGpu();
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
@@ -56,23 +67,24 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo
desc.fHeight = 64;
desc.fConfig = kRGBA_8888_GrPixelConfig;
- if (kOpenGL_GrBackend == ctxInfo.backend()) {
+ {
// External on-screen render target.
sk_sp<GrSurfaceProxy> sProxy(
- make_wrapped_FBO0(proxyProvider, reporter, desc, kBottomLeft_GrSurfaceOrigin));
+ make_wrapped_rt(proxyProvider, gpu, reporter, desc, kBottomLeft_GrSurfaceOrigin));
if (sProxy) {
// RenderTarget-only
GrRenderTargetProxy* rtProxy = sProxy->asRenderTargetProxy();
REPORTER_ASSERT(reporter, rtProxy);
REPORTER_ASSERT(reporter, !rtProxy->asTextureProxy());
REPORTER_ASSERT(reporter, rtProxy->asRenderTargetProxy() == rtProxy);
+ clean_up_wrapped_rt(gpu, std::move(sProxy));
}
}
{
// Internal offscreen render target.
sk_sp<GrSurfaceProxy> sProxy(
- make_wrapped_offscreen_rt(proxyProvider, desc, kBottomLeft_GrSurfaceOrigin));
+ make_offscreen_rt(proxyProvider, desc, kBottomLeft_GrSurfaceOrigin));
if (sProxy) {
// Both RenderTarget and Texture
GrRenderTargetProxy* rtProxy = sProxy->asRenderTargetProxy();
@@ -87,7 +99,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo
{
// Internal offscreen render target - but through GrTextureProxy
sk_sp<GrSurfaceProxy> sProxy(
- make_wrapped_texture(proxyProvider, desc, kBottomLeft_GrSurfaceOrigin));
+ make_texture(proxyProvider, desc, kBottomLeft_GrSurfaceOrigin));
if (sProxy) {
// Both RenderTarget and Texture
GrTextureProxy* tProxy = sProxy->asTextureProxy();
@@ -103,7 +115,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyConversionTest, reporter, ctxInfo
desc.fFlags = kNone_GrSurfaceFlags; // force no-RT
sk_sp<GrSurfaceProxy> sProxy(
- make_wrapped_texture(proxyProvider, desc, kBottomLeft_GrSurfaceOrigin));
+ make_texture(proxyProvider, desc, kBottomLeft_GrSurfaceOrigin));
if (sProxy) {
// Texture-only
GrTextureProxy* tProxy = sProxy->asTextureProxy();