aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ProxyTest.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-02-20 10:25:54 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-20 15:32:33 +0000
commit2a30390ce6130b27c18152edf75d48616adeb934 (patch)
tree0985a31a81f35df3111540319bbcb25dcf087854 /tests/ProxyTest.cpp
parent0c7861ff0c727160ab5306f531e94d40650d7466 (diff)
Update createWrappedRenderTargetProxy with BackendRT to work with lazy proxies.
This change also triggered a bunch of side changes thanks to WrappedProxyTest fixing/improving how we handle wrapped proxies in genernal. Bug: skia: Change-Id: I743a458923cff1c2e947627d0e9154a4c808a668 Reviewed-on: https://skia-review.googlesource.com/108102 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/ProxyTest.cpp')
-rw-r--r--tests/ProxyTest.cpp153
1 files changed, 79 insertions, 74 deletions
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index dff230c9bb..3a46438e79 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -20,6 +20,7 @@
#include "GrSurfaceProxyPriv.h"
#include "GrTexture.h"
#include "GrTextureProxy.h"
+#include "SkGr.h"
// Check that the surface proxy's member vars are set as expected
static void check_surface(skiatest::Reporter* reporter,
@@ -42,8 +43,7 @@ static void check_rendertarget(skiatest::Reporter* reporter,
GrRenderTargetProxy* rtProxy,
int numSamples,
SkBackingFit fit,
- int expectedMaxWindowRects,
- bool wasWrapped) {
+ int expectedMaxWindowRects) {
REPORTER_ASSERT(reporter, rtProxy->maxWindowRectangles(caps) == expectedMaxWindowRects);
REPORTER_ASSERT(reporter, rtProxy->numStencilSamples() == numSamples);
@@ -52,13 +52,8 @@ static void check_rendertarget(skiatest::Reporter* reporter,
GrRenderTarget* rt = rtProxy->priv().peekRenderTarget();
REPORTER_ASSERT(reporter, rtProxy->uniqueID() == idBefore);
- if (wasWrapped) {
- // Wrapped resources share their uniqueID with the wrapping RenderTargetProxy
- REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() == rt->uniqueID().asUInt());
- } else {
- // Deferred resources should always have a different ID from their instantiated rendertarget
- REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() != rt->uniqueID().asUInt());
- }
+ // Deferred resources should always have a different ID from their instantiated rendertarget
+ REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() != rt->uniqueID().asUInt());
if (SkBackingFit::kExact == fit) {
REPORTER_ASSERT(reporter, rt->width() == rtProxy->width());
@@ -78,21 +73,15 @@ static void check_rendertarget(skiatest::Reporter* reporter,
static void check_texture(skiatest::Reporter* reporter,
GrResourceProvider* provider,
GrTextureProxy* texProxy,
- SkBackingFit fit,
- bool wasWrapped) {
+ SkBackingFit fit) {
GrSurfaceProxy::UniqueID idBefore = texProxy->uniqueID();
REPORTER_ASSERT(reporter, texProxy->instantiate(provider));
GrTexture* tex = texProxy->priv().peekTexture();
REPORTER_ASSERT(reporter, texProxy->uniqueID() == idBefore);
- if (wasWrapped) {
- // Wrapped resources share their uniqueID with the wrapping TextureProxy
- REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() == tex->uniqueID().asUInt());
- } else {
- // Deferred resources should always have a different ID from their instantiated texture
- REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() != tex->uniqueID().asUInt());
- }
+ // Deferred resources should always have a different ID from their instantiated texture
+ REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() != tex->uniqueID().asUInt());
if (SkBackingFit::kExact == fit) {
REPORTER_ASSERT(reporter, tex->width() == texProxy->width());
@@ -154,7 +143,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
check_rendertarget(reporter, caps, resourceProvider,
proxy->asRenderTargetProxy(),
supportedSamples,
- fit, caps.maxWindowRectangles(), false);
+ fit, caps.maxWindowRectangles());
}
}
@@ -182,7 +171,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
check_surface(reporter, proxy.get(), origin,
widthHeight, widthHeight, config, budgeted);
check_texture(reporter, resourceProvider,
- proxy->asTextureProxy(), fit, false);
+ proxy->asTextureProxy(), fit);
}
}
@@ -198,71 +187,87 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider();
+ GrGpu* gpu = ctxInfo.grContext()->contextPriv().getGpu();
const GrCaps& caps = *ctxInfo.grContext()->caps();
static const int kWidthHeight = 100;
+ if (kOpenGL_GrBackend != ctxInfo.backend()) {
+ return;
+ }
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
- for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfig }) {
- for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
- for (auto numSamples : {1, 4}) {
- int supportedNumSamples = caps.getRenderTargetSampleCount(numSamples, config);
+ for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType }) {
+ for (auto numSamples : {1, 4}) {
+ GrPixelConfig config = SkImageInfo2GrPixelConfig(colorType, nullptr, caps);
+ int supportedNumSamples = caps.getRenderTargetSampleCount(numSamples, config);
- GrSurfaceDesc desc;
- desc.fOrigin = origin;
- desc.fWidth = kWidthHeight;
- desc.fHeight = kWidthHeight;
- desc.fConfig = config;
- desc.fSampleCnt = supportedNumSamples;
-
- // External on-screen render target.
- if (supportedNumSamples && kOpenGL_GrBackend == ctxInfo.backend()) {
- GrGLFramebufferInfo fboInfo;
- fboInfo.fFBOID = 0;
- GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples, 8,
- config, fboInfo);
-
- sk_sp<GrSurfaceProxy> sProxy(proxyProvider->createWrappedRenderTargetProxy(
- backendRT, origin));
- check_surface(reporter, sProxy.get(), origin,
- kWidthHeight, kWidthHeight, config, SkBudgeted::kNo);
- check_rendertarget(reporter, caps, resourceProvider,
- sProxy->asRenderTargetProxy(),
- supportedNumSamples, SkBackingFit::kExact, 0, true);
- }
+ if (!supportedNumSamples) {
+ continue;
+ }
- if (supportedNumSamples) {
- // Internal offscreen render target.
- desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ // External on-screen render target.
+ {
+ GrGLFramebufferInfo fboInfo;
+ fboInfo.fFBOID = 0;
+ GrBackendRenderTarget backendRT(kWidthHeight, kWidthHeight, numSamples, 8,
+ config, fboInfo);
+
+ sk_sp<GrSurfaceProxy> sProxy(proxyProvider->createWrappedRenderTargetProxy(
+ backendRT, origin));
+ check_surface(reporter, sProxy.get(), origin,
+ kWidthHeight, kWidthHeight,
+ backendRT.testingOnly_getPixelConfig(), SkBudgeted::kNo);
+ check_rendertarget(reporter, caps, resourceProvider,
+ sProxy->asRenderTargetProxy(),
+ supportedNumSamples, SkBackingFit::kExact, 0);
+ }
- sk_sp<GrSurfaceProxy> sProxy = proxyProvider->createInstantiatedProxy(
- desc, SkBackingFit::kExact, budgeted);
- if (!sProxy) {
- continue; // This can fail on Mesa
- }
+ {
+ GrBackendTexture backendTex =
+ gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight,
+ kWidthHeight, colorType, true,
+ GrMipMapped::kNo);
+
+ sk_sp<GrSurfaceProxy> sProxy =
+ proxyProvider->createWrappedTextureProxy(backendTex, origin,
+ supportedNumSamples);
+ if (!sProxy) {
+ continue; // This can fail on Mesa
+ }
- check_surface(reporter, sProxy.get(), origin,
- kWidthHeight, kWidthHeight, config, budgeted);
- check_rendertarget(reporter, caps, resourceProvider,
- sProxy->asRenderTargetProxy(),
- supportedNumSamples, SkBackingFit::kExact,
- caps.maxWindowRectangles(), true);
- } else {
- // Internal offscreen texture
- SkASSERT(kNone_GrSurfaceFlags == desc.fFlags );
- desc.fSampleCnt = 1;
-
- sk_sp<GrSurfaceProxy> sProxy = proxyProvider->createInstantiatedProxy(
- desc, SkBackingFit::kExact, budgeted);
- if (!sProxy) {
- continue;
- }
+ check_surface(reporter, sProxy.get(), origin,
+ kWidthHeight, kWidthHeight,
+ backendTex.testingOnly_getPixelConfig(), SkBudgeted::kNo);
+ check_rendertarget(reporter, caps, resourceProvider,
+ sProxy->asRenderTargetProxy(),
+ supportedNumSamples, SkBackingFit::kExact,
+ caps.maxWindowRectangles());
- check_surface(reporter, sProxy.get(), origin,
- kWidthHeight, kWidthHeight, config, budgeted);
- check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
- SkBackingFit::kExact, true);
+ gpu->deleteTestingOnlyBackendTexture(&backendTex);
+ }
+
+ {
+ // Internal offscreen texture
+ GrBackendTexture backendTex =
+ gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight,
+ kWidthHeight, colorType, false,
+ GrMipMapped::kNo);
+
+ sk_sp<GrSurfaceProxy> sProxy =
+ proxyProvider->createWrappedTextureProxy(backendTex, origin,
+ kBorrow_GrWrapOwnership,
+ nullptr, nullptr);
+ if (!sProxy) {
+ continue;
}
+
+ check_surface(reporter, sProxy.get(), origin,
+ kWidthHeight, kWidthHeight,
+ backendTex.testingOnly_getPixelConfig(), SkBudgeted::kNo);
+ check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
+ SkBackingFit::kExact);
+
+ gpu->deleteTestingOnlyBackendTexture(&backendTex);
}
}
}