Use GL_R8 rather than GL_RED for glTexImage2D on IMG/ES3. Check for failure of FP creation in SkImageFilter
BUG=skia:2922
Review URL: https://codereview.chromium.org/656853002
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index c431ece..6456d17 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -269,18 +269,18 @@
bounds.offset(-srcOffset);
SkMatrix matrix(ctx.ctm());
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
- this->asFragmentProcessor(&fp, srcTexture, matrix, bounds);
- SkASSERT(fp);
- GrPaint paint;
- paint.addColorProcessor(fp)->unref();
- context->drawRectToRect(paint, dstRect, srcRect);
+ if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) {
+ SkASSERT(fp);
+ GrPaint paint;
+ paint.addColorProcessor(fp)->unref();
+ context->drawRectToRect(paint, dstRect, srcRect);
- SkAutoTUnref<GrTexture> resultTex(dst.detach());
- WrapTexture(resultTex, bounds.width(), bounds.height(), result);
- return true;
-#else
- return false;
+ SkAutoTUnref<GrTexture> resultTex(dst.detach());
+ WrapTexture(resultTex, bounds.width(), bounds.height(), result);
+ return true;
+ }
#endif
+ return false;
}
bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src,
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index a4665f9..97f2a11 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -587,11 +587,13 @@
// size of the internal format whenever possible and so only use a sized internal format when
// using texture storage.
bool useSizedFormat = useTexStorage;
- // At least some versions of the desktop ES3 drivers for NVIDIA won't accept GL_RED in
+ // At least some versions of the ES3 drivers for NVIDIA and IMG won't accept GL_RED in
// glTexImage2D for the internal format but will accept GL_R8.
- if (!useSizedFormat && kNVIDIA_GrGLVendor == this->glContext().vendor() &&
- kGLES_GrGLStandard == this->glStandard() && this->glVersion() >= GR_GL_VER(3, 0)) {
- useSizedFormat = true;
+ if (kNVIDIA_GrGLVendor == this->glContext().vendor() ||
+ kImagination_GrGLVendor == this->glContext().vendor()) {
+ if (kGLES_GrGLStandard == this->glStandard() && this->glVersion() >= GR_GL_VER(3, 0)) {
+ useSizedFormat = true;
+ }
}
if (!this->configToGLFormats(dataConfig, useSizedFormat, &internalFormat,
&externalFormat, &externalType)) {