Fix BGRA readback on Android
R=bsalomon@google.com, robertphillips@google.com Author: snorp@snorp.net Review URL: https://chromiumcodereview.appspot.com/22522002 git-svn-id: http://skia.googlecode.com/svn/trunk@10624 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
7bb36ab259
commit
28621517f4
@ -231,29 +231,32 @@ void GrGpuGL::fillInConfigRenderableTable() {
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
GrPixelConfig preferred_pixel_ops_config(GrPixelConfig cpuConfig, GrPixelConfig surfaceConfig) {
|
||||
if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == cpuConfig) {
|
||||
GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig readConfig,
|
||||
GrPixelConfig surfaceConfig) const {
|
||||
if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig) {
|
||||
return kBGRA_8888_GrPixelConfig;
|
||||
} else if (GrBytesPerPixel(cpuConfig) == 4 &&
|
||||
GrPixelConfigSwapRAndB(cpuConfig) == surfaceConfig) {
|
||||
} else if (fGLContext.info().isMesa() &&
|
||||
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)) {
|
||||
return kRGBA_8888_GrPixelConfig;
|
||||
} else {
|
||||
return cpuConfig;
|
||||
return readConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GrPixelConfig GrGpuGL::preferredReadPixelsConfig(GrPixelConfig readConfig,
|
||||
GrPixelConfig surfaceConfig) const {
|
||||
return preferred_pixel_ops_config(readConfig, surfaceConfig);
|
||||
}
|
||||
|
||||
GrPixelConfig GrGpuGL::preferredWritePixelsConfig(GrPixelConfig writeConfig,
|
||||
GrPixelConfig surfaceConfig) const {
|
||||
return preferred_pixel_ops_config(writeConfig, surfaceConfig);
|
||||
if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == writeConfig) {
|
||||
return kBGRA_8888_GrPixelConfig;
|
||||
} else {
|
||||
return writeConfig;
|
||||
}
|
||||
}
|
||||
|
||||
bool GrGpuGL::canWriteTexturePixels(const GrTexture* texture, GrPixelConfig srcConfig) const {
|
||||
|
@ -36,14 +36,7 @@ void fillCanvas(SkCanvas* canvas, SkCanvas::Config8888 unpremulConfig) {
|
||||
|
||||
static const SkCanvas::Config8888 gUnpremulConfigs[] = {
|
||||
SkCanvas::kNative_Unpremul_Config8888,
|
||||
/**
|
||||
* There is a bug in Ganesh (http://code.google.com/p/skia/issues/detail?id=438)
|
||||
* that causes the readback of pixels from BGRA canvas to an RGBA bitmap to
|
||||
* fail. This should be removed as soon as the issue above is resolved.
|
||||
*/
|
||||
#if !defined(SK_BUILD_FOR_ANDROID)
|
||||
SkCanvas::kBGRA_Unpremul_Config8888,
|
||||
#endif
|
||||
SkCanvas::kRGBA_Unpremul_Config8888,
|
||||
};
|
||||
|
||||
|
@ -345,15 +345,10 @@ void ReadPixelsTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
|
||||
static const SkCanvas::Config8888 gReadConfigs[] = {
|
||||
SkCanvas::kNative_Premul_Config8888,
|
||||
SkCanvas::kNative_Unpremul_Config8888,
|
||||
/**
|
||||
* There is a bug in Ganesh (http://code.google.com/p/skia/issues/detail?id=438)
|
||||
* that causes the readback of pixels from BGRA canvas to an RGBA bitmap to
|
||||
* fail. This should be removed as soon as the issue above is resolved.
|
||||
*/
|
||||
#if !defined(SK_BUILD_FOR_ANDROID)
|
||||
|
||||
SkCanvas::kBGRA_Premul_Config8888,
|
||||
SkCanvas::kBGRA_Unpremul_Config8888,
|
||||
#endif
|
||||
|
||||
SkCanvas::kRGBA_Premul_Config8888,
|
||||
SkCanvas::kRGBA_Unpremul_Config8888,
|
||||
};
|
||||
|
@ -473,7 +473,5 @@ void WritePixelsTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef SK_BUILD_FOR_ANDROID
|
||||
#include "TestClassDef.h"
|
||||
DEFINE_GPUTESTCLASS("WritePixels", WritePixelsTestClass, WritePixelsTest)
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user