From: bsalomon Date: Wed, 24 Jun 2015 22:04:13 +0000 (-0700) Subject: Revert of remove workaround for dx9 angle slow rgba pixel ops (patchset #1 id:1 of... X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~1949 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=47c1ccbcd8e17efdc89a325e314c414a7c75846c;p=platform%2Fupstream%2FlibSkiaSharp.git Revert of remove workaround for dx9 angle slow rgba pixel ops (patchset #1 id:1 of https://codereview.chromium.org/1207003002/) Reason for revert: users are still on dx9 angle :( Original issue's description: > remove workaround for dx9 angle slow rgba pixel ops > > TBR=robertphillips@google.com > > Committed: https://skia.googlesource.com/skia/+/1e1adc33ba1acb9a2ad41c0a5a9b6166ee9d7a2a TBR=robertphillips@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1205183002 --- diff --git a/include/gpu/gl/GrGLConfig.h b/include/gpu/gl/GrGLConfig.h index 665ebed..93d5b39 100644 --- a/include/gpu/gl/GrGLConfig.h +++ b/include/gpu/gl/GrGLConfig.h @@ -65,6 +65,10 @@ * The GrGLInterface field fCallback specifies the function ptr and there is an * additional field fCallbackData of type intptr_t for client data. * + * GR_GL_RGBA_8888_PIXEL_OPS_SLOW: Set this to 1 if it is known that performing + * glReadPixels / glTex(Sub)Image with format=GL_RGBA, type=GL_UNISIGNED_BYTE is + * significantly slower than format=GL_BGRA, type=GL_UNISIGNED_BYTE. + * * GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL: Set this to 1 if calling * glReadPixels to read the entire framebuffer is faster than calling it with * the same sized rectangle but with a framebuffer bound that is larger than @@ -124,6 +128,10 @@ #define GR_GL_PER_GL_FUNC_CALLBACK 0 #endif +#if !defined(GR_GL_RGBA_8888_PIXEL_OPS_SLOW) + #define GR_GL_RGBA_8888_PIXEL_OPS_SLOW 0 +#endif + #if !defined(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL) #define GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL 0 #endif diff --git a/include/gpu/gl/GrGLConfig_chrome.h b/include/gpu/gl/GrGLConfig_chrome.h index b4776ab..ee875b7 100644 --- a/include/gpu/gl/GrGLConfig_chrome.h +++ b/include/gpu/gl/GrGLConfig_chrome.h @@ -12,9 +12,13 @@ #define GR_GL_CHECK_ERROR_START 0 #if defined(SK_BUILD_FOR_WIN32) +// For RGBA teximage/readpixels ANGLE will sw-convert to/from BGRA. +#define GR_GL_RGBA_8888_PIXEL_OPS_SLOW 1 + // ANGLE can go faster if the entire fbo is read rather than a subrect #define GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL 1 #else +#define GR_GL_RGBA_8888_PIXEL_OPS_SLOW 0 #define GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL 0 #endif @@ -39,4 +43,8 @@ // (const char* const instead of char**). #define GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE 1 +#if !defined(GR_GL_IGNORE_ES3_MSAA) + #define GR_GL_IGNORE_ES3_MSAA 1 +#endif + #endif diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index d9c2e18..3bb84a4 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -148,7 +148,8 @@ public: } /** - * Called before uploading writing pixels to a GrTexture. + * Called before uploading writing pixels to a GrTexture when the src pixel config doesn't + * match the texture's config. */ virtual bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const = 0; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 6366b44..20669b8 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -270,14 +270,21 @@ void GrGLGpu::contextAbandoned() { /////////////////////////////////////////////////////////////////////////////// GrPixelConfig GrGLGpu::preferredReadPixelsConfig(GrPixelConfig readConfig, GrPixelConfig surfaceConfig) const { - if (kMesa_GrGLDriver == this->glContext().driver() && - GrBytesPerPixel(readConfig) == 4 && GrPixelConfigSwapRAndB(readConfig) == surfaceConfig) { - // Mesa 3D takes a slow path on when reading back BGRA from an RGBA surface and vice-versa. - // Perhaps this should be guarded by some compile-time or runtime check. + if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig) { + return kBGRA_8888_GrPixelConfig; + } else if (kMesa_GrGLDriver == this->glContext().driver() && + GrBytesPerPixel(readConfig) == 4 && + GrPixelConfigSwapRAndB(readConfig) == surfaceConfig) { + // Mesa 3D takes a slow path on when reading back BGRA from an RGBA surface and vice-versa. + // Perhaps this should be guarded by some compiletime or runtime check. return surfaceConfig; - } else if (readConfig == kBGRA_8888_GrPixelConfig && - !this->glCaps().readPixelsSupported(this->glInterface(), GR_GL_BGRA, - GR_GL_UNSIGNED_BYTE, surfaceConfig)) { + } else if (readConfig == kBGRA_8888_GrPixelConfig + && !this->glCaps().readPixelsSupported( + this->glInterface(), + GR_GL_BGRA, + GR_GL_UNSIGNED_BYTE, + surfaceConfig + )) { return kRGBA_8888_GrPixelConfig; } else { return readConfig; @@ -286,7 +293,11 @@ GrPixelConfig GrGLGpu::preferredReadPixelsConfig(GrPixelConfig readConfig, GrPixelConfig GrGLGpu::preferredWritePixelsConfig(GrPixelConfig writeConfig, GrPixelConfig surfaceConfig) const { - return writeConfig; + if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == writeConfig) { + return kBGRA_8888_GrPixelConfig; + } else { + return writeConfig; + } } bool GrGLGpu::canWriteTexturePixels(const GrTexture* texture, GrPixelConfig srcConfig) const {