diff options
author | 2015-07-16 08:23:13 -0700 | |
---|---|---|
committer | 2015-07-16 08:23:13 -0700 | |
commit | e8d21e8f24aa676765d0ff8f433228665c75cdc2 (patch) | |
tree | aafa1819213283a04e2f04a3415da4a899471cfc /src/gpu/gl | |
parent | dbe1e6f0c32bd07b7669b1b1ac3c7f58c9b8d773 (diff) |
Make readpixels work on GrTextures
Review URL: https://codereview.chromium.org/1234313002
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 5c03ab57d2..1a9566ae38 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -596,32 +596,6 @@ bool GrGLGpu::onWriteTexturePixels(GrTexture* texture, return false; } -static bool adjust_pixel_ops_params(int surfaceWidth, - int surfaceHeight, - size_t bpp, - int* left, int* top, int* width, int* height, - const void** data, - size_t* rowBytes) { - if (!*rowBytes) { - *rowBytes = *width * bpp; - } - - SkIRect subRect = SkIRect::MakeXYWH(*left, *top, *width, *height); - SkIRect bounds = SkIRect::MakeWH(surfaceWidth, surfaceHeight); - - if (!subRect.intersect(bounds)) { - return false; - } - *data = reinterpret_cast<const void*>(reinterpret_cast<intptr_t>(*data) + - (subRect.fTop - *top) * *rowBytes + (subRect.fLeft - *left) * bpp); - - *left = subRect.fLeft; - *top = subRect.fTop; - *width = subRect.width(); - *height = subRect.height(); - return true; -} - static inline GrGLenum check_alloc_error(const GrSurfaceDesc& desc, const GrGLInterface* interface) { if (SkToBool(desc.fFlags & kCheckAllocation_GrSurfaceFlag)) { @@ -643,8 +617,8 @@ bool GrGLGpu::uploadTexData(const GrSurfaceDesc& desc, SkASSERT(!GrPixelConfigIsCompressed(dataConfig)); size_t bpp = GrBytesPerPixel(dataConfig); - if (!adjust_pixel_ops_params(desc.fWidth, desc.fHeight, bpp, &left, &top, - &width, &height, &data, &rowBytes)) { + if (!GrSurfacePriv::AdjustWritePixelParams(desc.fWidth, desc.fHeight, bpp, &left, &top, + &width, &height, &data, &rowBytes)) { return false; } size_t trimRowBytes = width * bpp; @@ -1781,10 +1755,10 @@ bool GrGLGpu::onReadPixels(GrRenderTarget* target, return false; } size_t bpp = GrBytesPerPixel(config); - if (!adjust_pixel_ops_params(target->width(), target->height(), bpp, - &left, &top, &width, &height, - const_cast<const void**>(&buffer), - &rowBytes)) { + if (!GrSurfacePriv::AdjustReadPixelParams(target->width(), target->height(), bpp, + &left, &top, &width, &height, + &buffer, + &rowBytes)) { return false; } |