When wrapping external textures, clamp the MSAA sample count to max.
authorsenorblanco <senorblanco@chromium.org>
Mon, 6 Apr 2015 16:42:57 +0000 (09:42 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 6 Apr 2015 16:42:57 +0000 (09:42 -0700)
This is the same clamp we do in onCreateTexture() for Skia-native textures.

Without this fix, setting to a count higher than the max in Chrome results
in a black screen.

BUG=skia:

Review URL: https://codereview.chromium.org/1056253003

src/gpu/gl/GrGLGpu.cpp

index 566c8c5..aff40cc 100644 (file)
@@ -401,7 +401,7 @@ GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc) {
     surfDesc.fWidth = desc.fWidth;
     surfDesc.fHeight = desc.fHeight;
     surfDesc.fConfig = desc.fConfig;
-    surfDesc.fSampleCnt = desc.fSampleCnt;
+    surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount());
     bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFlag);
     // FIXME:  this should be calling resolve_origin(), but Chrome code is currently
     // assuming the old behaviour, which is that backend textures are always
@@ -442,7 +442,7 @@ GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
     desc.fFlags = kCheckAllocation_GrSurfaceFlag;
     desc.fWidth = wrapDesc.fWidth;
     desc.fHeight = wrapDesc.fHeight;
-    desc.fSampleCnt = wrapDesc.fSampleCnt;
+    desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount());
     desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true);
 
     GrRenderTarget* tgt = SkNEW_ARGS(GrGLRenderTarget, (this, desc, idDesc));