diff options
author | egdaniel <egdaniel@google.com> | 2015-07-30 12:02:15 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-30 12:02:15 -0700 |
commit | 6d901da0ec4b10010eca05114ab8f9564bd04af3 (patch) | |
tree | 8faa4cc2db701111f3e3f205cbcb9d6fb6f2b123 /src | |
parent | b46e5e2033e4ef25c515adf780a4e0d007da0d20 (diff) |
Move some parts of onReadPixels up to GrGpu readPixels.
BUG=skia:
Review URL: https://codereview.chromium.org/1270583003
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrGpu.cpp | 25 | ||||
-rw-r--r-- | src/gpu/GrGpu.h | 3 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 22 |
3 files changed, 28 insertions, 22 deletions
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index c7137ef691..bb020f5b50 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" @@ -239,6 +240,11 @@ bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, int width, int height, size SkASSERT(tempDrawInfo); SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference); + // We currently do not support reading into a compressed buffer + if (GrPixelConfigIsCompressed(readConfig)) { + return false; + } + if (!this->onGetReadPixelsInfo(srcSurface, width, height, rowBytes, readConfig, drawPreference, tempDrawInfo)) { return false; @@ -292,7 +298,24 @@ 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 + 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; + } + + return this->onReadPixels(surface, + left, top, width, height, + config, buffer, + rowBytes); } bool GrGpu::writePixels(GrSurface* surface, diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index e6f37cc1cf..b814abf688 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -470,7 +470,8 @@ private: // overridden by backend-specific derived class to perform the surface read virtual bool onReadPixels(GrSurface*, - int left, int top, int width, int height, + int left, int top, + int width, int height, GrPixelConfig, void* buffer, size_t rowBytes) = 0; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 781e7721e3..74f7e0bc10 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1731,10 +1731,6 @@ static bool read_pixels_pays_for_y_flip(GrRenderTarget* renderTarget, const GrGL bool GrGLGpu::onGetReadPixelsInfo(GrSurface* srcSurface, int width, int height, size_t rowBytes, GrPixelConfig readConfig, DrawPreference* drawPreference, ReadPixelTempDrawInfo* tempDrawInfo) { - if (GrPixelConfigIsCompressed(readConfig)) { - return false; - } - // This subclass can only read pixels from a render target. We could use glTexSubImage2D on // GL versions that support it but we don't today. if (!srcSurface->asRenderTarget()) { @@ -1796,11 +1792,6 @@ bool GrGLGpu::onReadPixels(GrSurface* surface, size_t rowBytes) { SkASSERT(surface); - // We cannot read pixels into a compressed buffer - if (GrPixelConfigIsCompressed(config)) { - return false; - } - GrGLRenderTarget* tgt = static_cast<GrGLRenderTarget*>(surface->asRenderTarget()); if (!tgt) { return false; @@ -1812,13 +1803,6 @@ bool GrGLGpu::onReadPixels(GrSurface* surface, if (!this->configToGLFormats(config, false, NULL, &format, &type)) { return false; } - size_t bpp = GrBytesPerPixel(config); - if (!GrSurfacePriv::AdjustReadPixelParams(surface->width(), surface->height(), bpp, - &left, &top, &width, &height, - &buffer, - &rowBytes)) { - return false; - } // resolve the render target if necessary switch (tgt->getResolveType()) { @@ -1844,10 +1828,8 @@ bool GrGLGpu::onReadPixels(GrSurface* surface, GrGLIRect readRect; readRect.setRelativeTo(glvp, left, top, width, height, tgt->origin()); - size_t tightRowBytes = bpp * width; - if (0 == rowBytes) { - rowBytes = tightRowBytes; - } + size_t tightRowBytes = GrBytesPerPixel(config) * width; + size_t readDstRowBytes = tightRowBytes; void* readDst = buffer; |