diff options
| author | 2016-03-09 16:54:45 -0800 | |
|---|---|---|
| committer | 2016-03-10 10:54:40 -0800 | |
| commit | f3209b03b3adbf6868c2dcadb07adc5f865f5688 (patch) | |
| tree | f7f15ae334b46d86b6ba8fd883aa59001babefab | |
| parent | 8d1a222f50a93b9f078ad48cc94a2dfc50fef611 (diff) | |
Do not queue trivial buffer for unsupported screenshot request.
When screenshot is not supported, we queue an empty buffer to the
requesting producer. Besides returning a useless screenshot, this
overwrites the valuable error code, returning ERROR_OK whenever we
successfully return the trivial buffer.
Instead, refuse to queue the trivial buffer, and return the original
error code.
This replaces the workaround proposed in
I6da5d2fdecdef6c87d4dd7b353e2464678800110
BUG:27505438
Change-Id: I597a9be25071d2a6ddafb7d39cc1b09fb48d5fd0
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 8 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger_hwc1.cpp | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index db03c23b36..3a0e21fb76 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3440,14 +3440,18 @@ status_t SurfaceFlinger::captureScreenImplLocked( } else { ALOGE("got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot"); result = INVALID_OPERATION; + window->cancelBuffer(window, buffer, syncFd); + buffer = NULL; } // destroy our image eglDestroyImageKHR(mEGLDisplay, image); } else { result = BAD_VALUE; } - // queueBuffer takes ownership of syncFd - result = window->queueBuffer(window, buffer, syncFd); + if (buffer) { + // queueBuffer takes ownership of syncFd + result = window->queueBuffer(window, buffer, syncFd); + } } } else { result = BAD_VALUE; diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp index 16332f34cd..d864874a55 100644 --- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp +++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp @@ -3478,14 +3478,18 @@ status_t SurfaceFlinger::captureScreenImplLocked( } else { ALOGE("got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot"); result = INVALID_OPERATION; + window->cancelBuffer(window, buffer, syncFd); + buffer = NULL; } // destroy our image eglDestroyImageKHR(mEGLDisplay, image); } else { result = BAD_VALUE; } - // queueBuffer takes ownership of syncFd - result = window->queueBuffer(window, buffer, syncFd); + if (buffer) { + // queueBuffer takes ownership of syncFd + result = window->queueBuffer(window, buffer, syncFd); + } } } else { result = BAD_VALUE; |