Prevent creation of zero-sized proxies
This wasn't seen locally b.c. it is an assert and I only ran release locally and the CQ also only runs release.
I have added linux_trusty_blink_dbg as a try job.
TBR=bsalomon@google.com
Bug: 715392
Change-Id: I010626cb97e886d2fbfd767f948bc640f0534338
Reviewed-on: https://skia-review.googlesource.com/14361
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index e7252de..a250f68 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -203,6 +203,7 @@
ASSERT_SINGLE_OWNER
SkASSERT(!this->isAbandoned());
SkASSERT(!GrPixelConfigIsCompressed(inDesc.fConfig));
+ SkASSERT(inDesc.fWidth > 0 && inDesc.fHeight > 0);
SkTCopyOnFirstWrite<GrSurfaceDesc> desc(inDesc);
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index b55d12a..fd9a9c4 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -191,7 +191,7 @@
maxSize = caps->maxTextureSize();
}
- if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
+ if (desc.fWidth > maxSize || desc.fHeight > maxSize || desc.fWidth <= 0 || desc.fHeight <= 0) {
return nullptr;
}
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 7fd3029..db407d7 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -213,7 +213,10 @@
for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfig }) {
for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
for (auto numSamples: { 0, 4}) {
- if (caps.maxSampleCount() < numSamples) continue;
+ if (caps.maxSampleCount() < numSamples) {
+ continue;
+ }
+
bool renderable = caps.isConfigRenderable(config, numSamples > 0);
GrSurfaceDesc desc;
@@ -279,4 +282,34 @@
}
}
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ZeroSizedProxyTest, reporter, ctxInfo) {
+ GrResourceProvider* provider = ctxInfo.grContext()->resourceProvider();
+
+ for (auto flags : { kRenderTarget_GrSurfaceFlag, kNone_GrSurfaceFlags }) {
+ 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.fFlags = flags;
+ desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
+ desc.fWidth = width;
+ desc.fHeight = height;
+ desc.fConfig = kRGBA_8888_GrPixelConfig;
+ desc.fSampleCnt = 0;
+
+ sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(provider,
+ desc,
+ fit,
+ SkBudgeted::kNo));
+ REPORTER_ASSERT(reporter, !proxy);
+ }
+ }
+ }
+ }
+}
+
#endif