hwc: Avoid framebuffer id caching for virtual displays.

-- Same private hnd can point to differet buffers.
-- Bail out of buffer ids caching where handles change frequently ie;
   color conversion.

CRs-Fixed: 2679538
Change-Id: I8640453bed21b56af7936fae7ce7fd9c4f3f3f15
diff --git a/composer/gl_common.cpp b/composer/gl_common.cpp
index 4d1db6f..8245e5f 100644
--- a/composer/gl_common.cpp
+++ b/composer/gl_common.cpp
@@ -100,9 +100,9 @@
   }
 }
 
-void GLCommon::SetDestinationBuffer(const private_handle_t *dst_hnd) {
+void GLCommon::SetDestinationBuffer(const private_handle_t *dst_hnd, bool force_set) {
   DTRACE_SCOPED();
-  if (dst_hnd_ == dst_hnd) {
+  if (!force_set && (dst_hnd_ == dst_hnd)) {
     return;
   }
   EGLImageBuffer *dst_buffer = image_wrapper_.wrap(reinterpret_cast<const void *>(dst_hnd));
diff --git a/composer/gl_common.h b/composer/gl_common.h
index fadd6b1..bfeaade 100644
--- a/composer/gl_common.h
+++ b/composer/gl_common.h
@@ -61,7 +61,7 @@
   virtual void DumpShaderLog(int shader);
   virtual void MakeCurrent(const GLContext *ctx);
   virtual void SetProgram(uint32_t id);
-  virtual void SetDestinationBuffer(const private_handle_t *dst_hnd);
+  virtual void SetDestinationBuffer(const private_handle_t *dst_hnd, bool force_set = true);
   virtual void SetSourceBuffer(const private_handle_t *src_hnd);
   virtual void DestroyContext(GLContext *ctx);
   virtual void DeleteProgram(uint32_t id);
diff --git a/composer/gl_layer_stitch_impl.cpp b/composer/gl_layer_stitch_impl.cpp
index 709f190..f3b18dc 100644
--- a/composer/gl_layer_stitch_impl.cpp
+++ b/composer/gl_layer_stitch_impl.cpp
@@ -148,7 +148,7 @@
   bool can_batch = !NeedsGLScissor(stitch_params);
   for (auto &info : stitch_params) {
     SetSourceBuffer(info.src_hnd);
-    SetDestinationBuffer(info.dst_hnd);
+    SetDestinationBuffer(info.dst_hnd, false);
     SetViewport(info.dst_rect);
     ClearWithTransparency(info.scissor_rect);
     glDrawArrays(GL_TRIANGLES, 0, 3);