diff options
author | bohu <bohu@google.com> | 2015-01-26 09:25:23 -0800 |
---|---|---|
committer | bohu <bohu@google.com> | 2015-01-26 11:26:25 -0800 |
commit | 5a50ac8819525f851c677be88a466b14737dbb18 (patch) | |
tree | 7a377f350404b364e961b49cc85b54bb57d72a17 /opengl | |
parent | 7d9f6e9b35c43e19b810a089557e561f5f2b63bf (diff) | |
download | android_device_generic_goldfish-5a50ac8819525f851c677be88a466b14737dbb18.tar.gz android_device_generic_goldfish-5a50ac8819525f851c677be88a466b14737dbb18.tar.bz2 android_device_generic_goldfish-5a50ac8819525f851c677be88a466b14737dbb18.zip |
guest system gles fix: Enable screen capture with gpu on
Currently, when running emulator with gpu on, screen capture does not work.
This commit fixes that by doing the following steps:
1. enable gralloc to allocate buffer in gralloc_alloc for screen capture
usage mode.
2. read back screen pixels in gralloc_lock for screen capture usage mode
Note: This commit only fixes guest side, and to make screen capture work,
we also need the corresponding fix on host side in the following CL:
e36c098b5563adcc7442cb3a172ff769ee3fb4b6
Change-Id: I24b91bb70669fe2ddad3a5fc2eaccf3f3eaa0e1b
Diffstat (limited to 'opengl')
-rw-r--r-- | opengl/system/gralloc/gralloc.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/opengl/system/gralloc/gralloc.cpp b/opengl/system/gralloc/gralloc.cpp index a6f7d91..d74af08 100644 --- a/opengl/system/gralloc/gralloc.cpp +++ b/opengl/system/gralloc/gralloc.cpp @@ -141,9 +141,11 @@ static int gralloc_alloc(alloc_device_t* dev, bool sw_write = (0 != (usage & GRALLOC_USAGE_SW_WRITE_MASK)); bool hw_write = (usage & GRALLOC_USAGE_HW_RENDER); if (hw_write && sw_write) { - ALOGE("gralloc_alloc: Mismatched usage flags: %d x %d, usage %x", - w, h, usage); - return -EINVAL; + // screen-capture has both hw_write and sw_write enabled, and we + // should allow this usage. + // ALOGE("gralloc_alloc: Mismatched usage flags: %d x %d, usage %x", + // w, h, usage); + // return -EINVAL; } bool sw_read = (0 != (usage & GRALLOC_USAGE_SW_READ_MASK)); bool hw_cam_write = usage & GRALLOC_USAGE_HW_CAMERA_WRITE; @@ -685,6 +687,15 @@ static int gralloc_lock(gralloc_module_t const* module, return -EBUSY; } + const bool sw_read = (cb->usage & GRALLOC_USAGE_SW_READ_MASK); + const bool hw_write = (cb->usage & GRALLOC_USAGE_HW_RENDER); + const bool screen_capture_mode = (sw_read && hw_write); + if (screen_capture_mode) { + D("gralloc_lock read back color buffer %d %d\n", cb->width, cb->height); + DEFINE_AND_VALIDATE_HOST_CONNECTION; + rcEnc->rcReadColorBuffer(rcEnc, cb->hostHandle, + 0, 0, cb->width, cb->height, GL_RGBA, GL_UNSIGNED_BYTE, cpu_addr); + } } // |