Chromium Code Reviews| Index: src/gpu/GrGpu.cpp |
| diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp |
| index c7137ef6918fb67141d0eee2b3840fbc114e15c9..c3501bc99687503c24ab12339bed9f5e6c64bd24 100644 |
| --- a/src/gpu/GrGpu.cpp |
| +++ b/src/gpu/GrGpu.cpp |
| @@ -17,6 +17,7 @@ |
| #include "GrResourceCache.h" |
| #include "GrRenderTargetPriv.h" |
| #include "GrStencilAttachment.h" |
| +#include "GrSurfacePriv.h" |
| #include "GrVertexBuffer.h" |
| #include "GrVertices.h" |
| @@ -292,7 +293,30 @@ bool GrGpu::readPixels(GrSurface* surface, |
| GrPixelConfig config, void* buffer, |
| size_t rowBytes) { |
| this->handleDirtyContext(); |
| - return this->onReadPixels(surface, left, top, width, height, config, buffer, rowBytes); |
| + |
| + // We cannot read pixels into a compressed buffer |
|
egdaniel
2015/07/30 18:00:49
It can be argued this one is dependent on the back
bsalomon
2015/07/30 18:27:22
If we're going to do this then we should also move
egdaniel
2015/07/30 18:47:34
Done.
|
| + if (GrPixelConfigIsCompressed(config)) { |
| + return false; |
| + } |
| + |
| + size_t bpp = GrBytesPerPixel(config); |
| + if (!GrSurfacePriv::AdjustReadPixelParams(surface->width(), surface->height(), bpp, |
| + &left, &top, &width, &height, |
| + &buffer, |
| + &rowBytes)) { |
| + return false; |
| + } |
| + |
| + size_t tightRowBytes = bpp * width; |
| + if (0 == rowBytes) { |
|
bsalomon
2015/07/30 18:27:22
AdjustReadPixelParams already does this (sets rowB
egdaniel
2015/07/30 18:47:34
Done.
|
| + rowBytes = tightRowBytes; |
| + } |
| + |
| + return this->onReadPixels(surface, |
| + left, top, width, height, |
| + config, buffer, |
| + rowBytes ? rowBytes : tightRowBytes, |
| + tightRowBytes); |
| } |
| bool GrGpu::writePixels(GrSurface* surface, |