diff options
author | bohu <bohu@google.com> | 2015-01-26 09:25:23 -0800 |
---|---|---|
committer | bohu <bohu@google.com> | 2015-01-29 12:09:32 -0800 |
commit | dd14cf865c04bf9d15ca2c60409f1b131e9818f6 (patch) | |
tree | 8d080406bfd8ae03ab7164f7d6a1d3acb0e759ab | |
parent | 8142de3a67193062b0aa41cd197b473089b135df (diff) | |
download | device_generic_goldfish-android-cts-5.1_r1.tar.gz device_generic_goldfish-android-cts-5.1_r1.tar.bz2 device_generic_goldfish-android-cts-5.1_r1.zip |
guest system gles fix: Enable screen capture with gpu onandroid-cts-5.1_r9android-cts-5.1_r8android-cts-5.1_r7android-cts-5.1_r6android-cts-5.1_r5android-cts-5.1_r4android-cts-5.1_r3android-cts-5.1_r28android-cts-5.1_r27android-cts-5.1_r26android-cts-5.1_r25android-cts-5.1_r24android-cts-5.1_r23android-cts-5.1_r22android-cts-5.1_r21android-cts-5.1_r20android-cts-5.1_r2android-cts-5.1_r19android-cts-5.1_r18android-cts-5.1_r17android-cts-5.1_r16android-cts-5.1_r15android-cts-5.1_r14android-cts-5.1_r13android-cts-5.1_r10android-cts-5.1_r1android-5.1.1_r9android-5.1.1_r8android-5.1.1_r7android-5.1.1_r6android-5.1.1_r4android-5.1.1_r38android-5.1.1_r37android-5.1.1_r36android-5.1.1_r35android-5.1.1_r34android-5.1.1_r33android-5.1.1_r30android-5.1.1_r3android-5.1.1_r29android-5.1.1_r26android-5.1.1_r25android-5.1.1_r24android-5.1.1_r23android-5.1.1_r20android-5.1.1_r2android-5.1.1_r19android-5.1.1_r18android-5.1.1_r16android-5.1.1_r15android-5.1.1_r14android-5.1.1_r13android-5.1.1_r10android-5.1.1_r1android-5.1.0_r5android-5.1.0_r4android-5.1.0_r3android-5.1.0_r1lollipop-mr1-releaselollipop-mr1-fi-releaselollipop-mr1-devlollipop-mr1-cts-release
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
(cherry picked from commit 5a50ac8819525f851c677be88a466b14737dbb18)
Change-Id: Ie9307eda411ab3d0b3842fbb4a71926dd62a1875
-rw-r--r-- | opengl/system/gralloc/gralloc.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/opengl/system/gralloc/gralloc.cpp b/opengl/system/gralloc/gralloc.cpp index a6f7d917..059bf127 100644 --- a/opengl/system/gralloc/gralloc.cpp +++ b/opengl/system/gralloc/gralloc.cpp @@ -136,15 +136,11 @@ static int gralloc_alloc(alloc_device_t* dev, } // - // Validate usage: buffer cannot be written both by s/w and h/w access. + // Note: in screen capture mode, both sw_write and hw_write will be on + // and this is a valid usage // 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; - } bool sw_read = (0 != (usage & GRALLOC_USAGE_SW_READ_MASK)); bool hw_cam_write = usage & GRALLOC_USAGE_HW_CAMERA_WRITE; bool hw_cam_read = usage & GRALLOC_USAGE_HW_CAMERA_READ; @@ -685,6 +681,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); + } } // |