diff options
author | 2016-02-01 12:49:30 -0800 | |
---|---|---|
committer | 2016-02-01 12:49:30 -0800 | |
commit | 9d02b264b72be64702e43cb797b7899a8a6926ca (patch) | |
tree | 391a09559455c791b7005c510596498a11debbf4 /src/gpu/gl/GrGLGpu.cpp | |
parent | b21c752eb3d55970ac45daaf3fd2cbda39c7658a (diff) |
Fix GL readback code to handle rowbytes correctly for non-32bit formats
Update tests to exercise more rowbytes.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1645043006
Review URL: https://codereview.chromium.org/1645043006
Diffstat (limited to 'src/gpu/gl/GrGLGpu.cpp')
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 6a61f3109e..3b7ccd3241 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); |