aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-07-16 08:23:13 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-07-16 08:23:13 -0700
commite8d21e8f24aa676765d0ff8f433228665c75cdc2 (patch)
treeaafa1819213283a04e2f04a3415da4a899471cfc /src/gpu/gl
parentdbe1e6f0c32bd07b7669b1b1ac3c7f58c9b8d773 (diff)
Make readpixels work on GrTextures
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLGpu.cpp38
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;
}