diff options
author | Brian Salomon <bsalomon@google.com> | 2017-05-11 11:39:08 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-11 16:35:13 +0000 |
commit | 028a9a5fcb1db10147c640f3be34df6d976a9f88 (patch) | |
tree | 75bcf7b55dda00c0d16b42d53bbd24ccb08426c9 | |
parent | 7b1cc7625be39fdf7d9642373b16f1aa5a37bf94 (diff) |
Workaround for Intel 6xxx clear to opaque black bug
Bug: skia:
Change-Id: Id5e29b483c2b6f698219abfc5bbb2d858c4fc117
Reviewed-on: https://skia-review.googlesource.com/16427
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 8 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 11 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUtil.cpp | 10 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUtil.h | 2 |
5 files changed, 33 insertions, 0 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 2c2f7ec113..232c013f11 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -53,6 +53,7 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, fDoManualMipmapping = false; fSRGBDecodeDisableSupport = false; fSRGBDecodeDisableAffectsMipmaps = false; + fClearToOpaqueBlackIsBroken = false; fBlitFramebufferFlags = kNoSupport_BlitFramebufferFlag; @@ -572,6 +573,13 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, fSRGBDecodeDisableAffectsMipmaps = fSRGBDecodeDisableSupport && kChromium_GrGLDriver != ctxInfo.driver(); + // See http://crbug.com/710443 +#ifdef SK_BUILD_FOR_MAC + if (kIntel6xxx_GrGLRenderer == ctxInfo.renderer()) { + fClearToOpaqueBlackIsBroken = true; + } +#endif + // Requires fTextureRedSupport, fTextureSwizzleSupport, msaa support, ES compatibility have // already been detected. this->initConfigTable(contextOptions, ctxInfo, gli, shaderCaps); diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index c32e41916f..bba4d8e033 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -359,6 +359,7 @@ public: return fRGBAToBGRAReadbackConversionsAreSlow; } + bool clearToOpaqueBlackIsBroken() const { return fClearToOpaqueBlackIsBroken; } bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc, bool* rectsMustMatch, bool* disallowSubrect) const override; @@ -430,6 +431,7 @@ private: bool fDoManualMipmapping : 1; bool fSRGBDecodeDisableSupport : 1; bool fSRGBDecodeDisableAffectsMipmaps : 1; + bool fClearToOpaqueBlackIsBroken : 1; uint32_t fBlitFramebufferFlags; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index a2eabe4e46..9b507a42a6 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -7,6 +7,7 @@ #include "GrGLGpu.h" +#include <cmath> #include "../private/GrGLSL.h" #include "GrBackendSurface.h" #include "GrFixedClip.h" @@ -2104,6 +2105,16 @@ void GrGLGpu::clear(const GrFixedClip& clip, GrColor color, GrRenderTarget* targ GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); fHWWriteToColor = kYes_TriState; + + if (this->glCaps().clearToOpaqueBlackIsBroken() && 0 == r && 0 == g && 0 == b && 1 == a) { +#ifdef SK_BUILD_FOR_ANDROID + // Android doesn't have std::nextafter but has nextafter. + static const GrGLfloat safeAlpha = nextafter(1.f, 2.f); +#else + static const GrGLfloat safeAlpha = std::nextafter(1.f, 2.f); +#endif + a = safeAlpha; + } GL_CALL(ClearColor(r, g, b, a)); GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT)); } diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp index 443d77c3ef..58b5860f13 100644 --- a/src/gpu/gl/GrGLUtil.cpp +++ b/src/gpu/gl/GrGLUtil.cpp @@ -313,6 +313,16 @@ GrGLRenderer GrGLGetRendererFromString(const char* rendererString) { } } } + int intelNumber; + n = sscanf(rendererString, "Intel(R) Iris(TM) Graphics %d", &intelNumber); + if (1 != n) { + n = sscanf(rendererString, "Intel(R) HD Graphics %d", &intelNumber); + } + if (1 == n) { + if (intelNumber >= 6000 && intelNumber < 7000) { + return kIntel6xxx_GrGLRenderer; + } + } if (0 == strcmp("Mesa Offscreen", rendererString)) { return kOSMesa_GrGLRenderer; } diff --git a/src/gpu/gl/GrGLUtil.h b/src/gpu/gl/GrGLUtil.h index 7503371097..25bd68175b 100644 --- a/src/gpu/gl/GrGLUtil.h +++ b/src/gpu/gl/GrGLUtil.h @@ -54,6 +54,8 @@ enum GrGLRenderer { kAdreno4xx_GrGLRenderer, kAdreno5xx_GrGLRenderer, kOSMesa_GrGLRenderer, + /** Either HD 6xxx or Iris 6xxx */ + kIntel6xxx_GrGLRenderer, kOther_GrGLRenderer }; |