hwc: Combine all requests to stitch. CRs-Fixed: 2660235 Change-Id: I752b69153ae8a4854e2be4f7324862c4444a5a9e
diff --git a/composer/gl_common.cpp b/composer/gl_common.cpp index 4d4744d..4d1db6f 100644 --- a/composer/gl_common.cpp +++ b/composer/gl_common.cpp
@@ -27,6 +27,9 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <vector> +#include <string> + #include "gl_common.h" #define __CLASS__ "GLCommon" @@ -97,21 +100,29 @@ } } -void GLCommon::SetDestinationBuffer(const private_handle_t *dst_hnd, const GLRect &dst_rect) { +void GLCommon::SetDestinationBuffer(const private_handle_t *dst_hnd) { DTRACE_SCOPED(); + if (dst_hnd_ == dst_hnd) { + return; + } EGLImageBuffer *dst_buffer = image_wrapper_.wrap(reinterpret_cast<const void *>(dst_hnd)); if (dst_buffer) { GL(glBindFramebuffer(GL_FRAMEBUFFER, dst_buffer->getFramebuffer())); - float width = dst_rect.right - dst_rect.left; - float height = dst_rect.bottom - dst_rect.top; - GL(glViewport(dst_rect.left, dst_rect.top, width, height)); } + + // Same buffer gets reprogrammed. Avoid repeated setting. + dst_hnd_ = dst_hnd; } -int GLCommon::WaitOnInputFence(const shared_ptr<Fence> &in_fence) { +int GLCommon::WaitOnInputFence(const std::vector<shared_ptr<Fence>> &in_fences) { DTRACE_SCOPED(); + shared_ptr<Fence> in_fence = Fence::Merge(in_fences, true /* ignore signaled*/); + if (in_fence == nullptr) { + return 0; + } + int fd = Fence::Dup(in_fence); EGLint attribs[] = {EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fd, EGL_NONE}; EGLSyncKHR sync = eglCreateSyncKHR(eglGetCurrentDisplay(), EGL_SYNC_NATIVE_FENCE_ANDROID, @@ -182,5 +193,12 @@ } } +void GLCommon::SetViewport(const GLRect &dst_rect) { + DTRACE_SCOPED(); + float width = dst_rect.right - dst_rect.left; + float height = dst_rect.bottom - dst_rect.top; + GL(glViewport(dst_rect.left, dst_rect.top, width, height)); +} + } // namespace sdm