aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ProxyTest.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-02-01 09:20:00 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-01 14:57:16 +0000
commit6520a69e6455afe371d647e033aa3ae5dabf6010 (patch)
treefef9a0288eb06f5df1f8fbfde85af03be14be8f7 /tests/ProxyTest.cpp
parentd689f7a5313a7fd501c2572c493fe6d91a88cba4 (diff)
Add test for proactive proxy-creation failure
This is a follow up to https://skia-review.googlesource.com/c/7828/ (Add more pre-checks to surfaceProxy creation) BUG=687174 Change-Id: I97385afbdaf1881b806ee37737020564e3f4d444 Reviewed-on: https://skia-review.googlesource.com/7864 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests/ProxyTest.cpp')
-rw-r--r--tests/ProxyTest.cpp75
1 files changed, 46 insertions, 29 deletions
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 894c37eea3..f5a3a2c9c8 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -114,16 +114,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
const GrGpuResource::UniqueID kInvalidResourceID = GrGpuResource::UniqueID::InvalidID();
+ int attempt = 0; // useful for debugging
+
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
for (auto widthHeight : { 100, 128, 1048576 }) {
- for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfig }) {
+ for (auto config : { kAlpha_8_GrPixelConfig, kRGB_565_GrPixelConfig,
+ kETC1_GrPixelConfig, kRGBA_8888_GrPixelConfig }) {
for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
- for (auto numSamples : { 0, 4}) {
- bool renderable = caps.isConfigRenderable(config, numSamples > 0) &&
- numSamples <= caps.maxColorSampleCount();
- bool allocable = widthHeight <= caps.maxTextureSize();
-
+ for (auto numSamples : { 0, 4, 16, 128 }) {
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fOrigin = origin;
@@ -132,11 +131,18 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
desc.fConfig = config;
desc.fSampleCnt = numSamples;
- if (renderable) {
+ {
+ sk_sp<GrTexture> tex;
+ if (SkBackingFit::kApprox == fit) {
+ tex = sk_ref_sp(provider->createApproxTexture(desc));
+ } else {
+ tex = sk_ref_sp(provider->createTexture(desc, budgeted));
+ }
+
sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeDeferred(
caps, desc,
fit, budgeted));
- REPORTER_ASSERT(reporter, allocable == SkToBool(sProxy));
+ REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(sProxy));
if (sProxy) {
REPORTER_ASSERT(reporter, sProxy->asRenderTargetProxy());
// This forces the proxy to compute and cache its
@@ -150,33 +156,44 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
widthHeight, widthHeight, config,
kInvalidResourceID, budgeted);
check_rendertarget(reporter, caps, provider,
- sProxy->asRenderTargetProxy(), numSamples,
+ sProxy->asRenderTargetProxy(),
+ SkTMin(numSamples, caps.maxSampleCount()),
fit, caps.maxWindowRectangles(), false);
}
}
desc.fFlags = kNone_GrSurfaceFlags;
- desc.fSampleCnt = 0;
-
- sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeDeferred(caps,
- desc,
- fit,
- budgeted));
- REPORTER_ASSERT(reporter, allocable == SkToBool(sProxy));
- if (sProxy) {
- // 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.
- sProxy->gpuMemorySize();
-
- check_surface(reporter, sProxy.get(), origin,
- widthHeight, widthHeight, config,
- kInvalidResourceID, budgeted);
- check_texture(reporter, provider, sProxy->asTextureProxy(),
- fit, false);
+
+ {
+ sk_sp<GrTexture> tex;
+ if (SkBackingFit::kApprox == fit) {
+ tex = sk_ref_sp(provider->createApproxTexture(desc));
+ } else {
+ tex = sk_ref_sp(provider->createTexture(desc, budgeted));
+ }
+
+ sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeDeferred(caps,
+ desc,
+ fit,
+ budgeted));
+ REPORTER_ASSERT(reporter, SkToBool(tex) == SkToBool(sProxy));
+ if (sProxy) {
+ // 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.
+ sProxy->gpuMemorySize();
+
+ check_surface(reporter, sProxy.get(), origin,
+ widthHeight, widthHeight, config,
+ kInvalidResourceID, budgeted);
+ check_texture(reporter, provider, sProxy->asTextureProxy(),
+ fit, false);
+ }
}
+
+ attempt++;
}
}
}