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

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

Issue 1645043006: Fix GL readback code to handle rowbytes correctly for non-32bit formats (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 4 years, 11 months 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 | « no previous file | tests/ReadPixelsTest.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 6a61f3109ebee1777229beb534c013676a356104..3b7ccd32417718a14367399125d5247981f84978 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2296,7 +2296,8 @@ bool GrGLGpu::onReadPixels(GrSurface* surface,
GrGLIRect readRect;
readRect.setRelativeTo(glvp, left, top, width, height, renderTarget->origin());
- size_t tightRowBytes = GrBytesPerPixel(config) * width;
+ size_t bytesPerPixel = GrBytesPerPixel(config);
+ size_t tightRowBytes = bytesPerPixel * width;
size_t readDstRowBytes = tightRowBytes;
void* readDst = buffer;
@@ -2305,10 +2306,9 @@ bool GrGLGpu::onReadPixels(GrSurface* surface,
// a scratch buffer.
SkAutoSMalloc<32 * sizeof(GrColor)> scratch;
if (rowBytes != tightRowBytes) {
- if (this->glCaps().packRowLengthSupport()) {
- SkASSERT(!(rowBytes % sizeof(GrColor)));
+ if (this->glCaps().packRowLengthSupport() && !(rowBytes % bytesPerPixel)) {
GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH,
- static_cast<GrGLint>(rowBytes / sizeof(GrColor))));
+ static_cast<GrGLint>(rowBytes / bytesPerPixel)));
readDstRowBytes = rowBytes;
} else {
scratch.reset(tightRowBytes * height);
@@ -2353,7 +2353,8 @@ bool GrGLGpu::onReadPixels(GrSurface* surface,
}
}
} else {
- SkASSERT(readDst != buffer); SkASSERT(rowBytes != tightRowBytes);
+ SkASSERT(readDst != buffer);
+ SkASSERT(rowBytes != tightRowBytes);
// copy from readDst to buffer while flipping y
// const int halfY = height >> 1;
const char* src = reinterpret_cast<const char*>(readDst);
« no previous file with comments | « no previous file | tests/ReadPixelsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698