summaryrefslogtreecommitdiff
path: root/libs/hwui/Readback.cpp
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2016-04-25 13:03:44 -0700
committerJohn Reck <jreck@google.com>2016-04-26 15:41:43 -0700
commite94cbc76d560a157c0a0d47181b4ed2a0aadbeb1 (patch)
treef0f09618a3bcf57851147fb9c4082f99ae023f9f /libs/hwui/Readback.cpp
parenta5bbbe55b74d3a835b64fa18959f487da2df967e (diff)
API tweaks to PixelCopy and make it public
Bug: 27708453 Change-Id: I81667ce42f9ca1c1a13e1e61299927900845fc84
Diffstat (limited to 'libs/hwui/Readback.cpp')
-rw-r--r--libs/hwui/Readback.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/libs/hwui/Readback.cpp b/libs/hwui/Readback.cpp
index 4a325897d4ec..49596e143ebf 100644
--- a/libs/hwui/Readback.cpp
+++ b/libs/hwui/Readback.cpp
@@ -30,7 +30,7 @@
namespace android {
namespace uirenderer {
-bool Readback::copySurfaceInto(renderthread::RenderThread& renderThread,
+CopyResult Readback::copySurfaceInto(renderthread::RenderThread& renderThread,
Surface& surface, SkBitmap* bitmap) {
// TODO: Clean this up and unify it with LayerRenderer::copyLayer,
// of which most of this is copied from.
@@ -44,12 +44,12 @@ bool Readback::copySurfaceInto(renderthread::RenderThread& renderThread,
|| destHeight > caches.maxTextureSize) {
ALOGW("Can't copy surface into bitmap, %dx%d exceeds max texture size %d",
destWidth, destHeight, caches.maxTextureSize);
- return false;
+ return CopyResult::DestinationInvalid;
}
GLuint fbo = renderState.createFramebuffer();
if (!fbo) {
ALOGW("Could not obtain an FBO");
- return false;
+ return CopyResult::UnknownError;
}
SkAutoLockPixels alp(*bitmap);
@@ -104,16 +104,20 @@ bool Readback::copySurfaceInto(renderthread::RenderThread& renderThread,
status_t err = surface.getLastQueuedBuffer(&sourceBuffer, &sourceFence);
if (err != NO_ERROR) {
ALOGW("Failed to get last queued buffer, error = %d", err);
- return false;
+ return CopyResult::UnknownError;
}
if (!sourceBuffer.get()) {
ALOGW("Surface doesn't have any previously queued frames, nothing to readback from");
- return false;
+ return CopyResult::SourceEmpty;
+ }
+ if (sourceBuffer->getUsage() & GRALLOC_USAGE_PROTECTED) {
+ ALOGW("Surface is protected, unable to copy from it");
+ return CopyResult::SourceInvalid;
}
err = sourceFence->wait(500 /* ms */);
if (err != NO_ERROR) {
ALOGE("Timeout (500ms) exceeded waiting for buffer fence, abandoning readback attempt");
- return false;
+ return CopyResult::Timeout;
}
// TODO: Can't use Image helper since it forces GL_TEXTURE_2D usage via
@@ -130,7 +134,7 @@ bool Readback::copySurfaceInto(renderthread::RenderThread& renderThread,
if (sourceImage == EGL_NO_IMAGE_KHR) {
ALOGW("Error creating image (%#x)", eglGetError());
- return false;
+ return CopyResult::UnknownError;
}
GLuint sourceTexId;
// Create a 2D texture to sample from the EGLImage
@@ -141,7 +145,7 @@ bool Readback::copySurfaceInto(renderthread::RenderThread& renderThread,
GLenum status = GL_NO_ERROR;
while ((status = glGetError()) != GL_NO_ERROR) {
ALOGW("Error creating image (%#x)", status);
- return false;
+ return CopyResult::UnknownError;
}
Texture sourceTexture(caches);
@@ -178,7 +182,7 @@ bool Readback::copySurfaceInto(renderthread::RenderThread& renderThread,
GL_CHECKPOINT(MODERATE);
- return true;
+ return CopyResult::Success;
}
} // namespace uirenderer