Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Unified Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1525193002: Set GL_PACK_ALIGNMENT before calling glReadPixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/gpu/GrTypes.h ('k') | tests/ReadWriteAlphaTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLGpu.cpp
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index a83386840e68c959efb43d57c03d80878d3d6875..fdf7eece7efb6f38b4d28e00a9cd4958bc00c887 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -648,6 +648,27 @@ bool GrGLGpu::onWritePixels(GrSurface* surface,
return false;
}
+// For GL_[UN]PACK_ALIGNMENT.
+static inline GrGLint config_alignment(GrPixelConfig config) {
+ SkASSERT(!GrPixelConfigIsCompressed(config));
+ switch (config) {
+ case kAlpha_8_GrPixelConfig:
+ return 1;
+ case kRGB_565_GrPixelConfig:
+ case kRGBA_4444_GrPixelConfig:
+ case kAlpha_half_GrPixelConfig:
+ case kRGBA_half_GrPixelConfig:
+ return 2;
+ case kRGBA_8888_GrPixelConfig:
+ case kBGRA_8888_GrPixelConfig:
+ case kSRGBA_8888_GrPixelConfig:
+ case kRGBA_float_GrPixelConfig:
+ return 4;
+ default:
+ return 0;
+ }
+}
+
static inline GrGLenum check_alloc_error(const GrSurfaceDesc& desc,
const GrGLInterface* interface) {
if (SkToBool(desc.fFlags & kCheckAllocation_GrSurfaceFlag)) {
@@ -768,8 +789,7 @@ bool GrGLGpu::uploadTexData(const GrSurfaceDesc& desc,
if (glFlipY) {
GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_TRUE));
}
- GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT,
- static_cast<GrGLint>(GrUnpackAlignment(dataConfig))));
+ GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, config_alignment(dataConfig)));
}
bool succeeded = true;
if (isNewTexture &&
@@ -2081,6 +2101,8 @@ bool GrGLGpu::onReadPixels(GrSurface* surface,
if (flipY && this->glCaps().packFlipYSupport()) {
GL_CALL(PixelStorei(GR_GL_PACK_REVERSE_ROW_ORDER, 1));
}
+ GL_CALL(PixelStorei(GR_GL_PACK_ALIGNMENT, config_alignment(config)));
+
GL_CALL(ReadPixels(readRect.fLeft, readRect.fBottom,
readRect.fWidth, readRect.fHeight,
format, type, readDst));
« no previous file with comments | « include/gpu/GrTypes.h ('k') | tests/ReadWriteAlphaTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698