[Tizen] Support to get raw pixel informations of framebuffer for old driver device
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles-impl / gles-context.cpp
index 56625a0..e38c3cd 100644 (file)
@@ -63,8 +63,15 @@ struct Context::Impl
       hash ^= std::hash<uint32_t>{}(attr.location);
     }
 
-    auto& gl   = *mController.GetGL();
-    auto  iter = mProgramVAOMap.find(program);
+    auto& gl = *mController.GetGL();
+
+    if(DALI_UNLIKELY(!mDiscardedVAOList.empty()))
+    {
+      gl.DeleteVertexArrays(static_cast<Dali::GLsizei>(mDiscardedVAOList.size()), mDiscardedVAOList.data());
+      mDiscardedVAOList.clear();
+    }
+
+    auto iter = mProgramVAOMap.find(program);
     if(iter != mProgramVAOMap.end())
     {
       auto attributeIter = iter->second.find(hash);
@@ -228,6 +235,7 @@ struct Context::Impl
   std::unordered_map<const GLES::ProgramImpl*, std::map<std::size_t, uint32_t>> mProgramVAOMap;              ///< GL program-VAO map
   uint32_t                                                                      mProgramVAOCurrentState{0u}; ///< Currently bound VAO
   GLStateCache                                                                  mGlStateCache{};             ///< GL status cache
+  std::vector<Dali::GLuint>                                                     mDiscardedVAOList{};
 
   bool mGlContextCreated{false}; ///< True if the OpenGL context has been created
 
@@ -313,6 +321,12 @@ void Context::Flush(bool reset, const GLES::DrawCallDescriptor& drawCall, GLES::
   // elements. This avoids having to sort the bindings.
   for(const auto& binding : mImpl->mCurrentTextureBindings)
   {
+    if(currentSampler >= samplers.size())
+    {
+      // Don't bind more textures than there are active samplers.
+      break;
+    }
+
     auto texture = const_cast<GLES::Texture*>(static_cast<const GLES::Texture*>(binding.texture));
 
     // Texture may not have been initialized yet...(tbm_surface timing issue?)
@@ -336,11 +350,6 @@ void Context::Flush(bool reset, const GLES::DrawCallDescriptor& drawCall, GLES::
       ++currentSampler;
       currentElement = 0;
     }
-    if(currentSampler >= samplers.size())
-    {
-      // Don't bind more textures than there are active samplers.
-      break;
-    }
   }
 
   // for each attribute bind vertices
@@ -756,6 +765,11 @@ void Context::EndRenderPass(GLES::TextureDependencyChecker& dependencyChecker)
       auto& gl = *mImpl->mController.GetGL();
       gl.Flush();
 
+      if(framebuffer->CaptureRequested())
+      {
+        framebuffer->DrawRenderedBuffer();
+      }
+
       /* @todo Full dependency checking would need to store textures in Begin, and create
        * fence objects here; but we're going to draw all fbos on shared context in serial,
        * so no real need (yet). Might want to consider ensuring order of render passes,
@@ -1073,12 +1087,18 @@ void Context::InvalidateCachedPipeline(GLES::Pipeline* pipeline)
           for(auto& attributeHashPair : iter->second)
           {
             auto vao = attributeHashPair.second;
-            gl->DeleteVertexArrays(1, &vao);
+
+            // Do not delete vao now. (Since Context might not be current.)
+            mImpl->mDiscardedVAOList.emplace_back(vao);
             if(mImpl->mProgramVAOCurrentState == vao)
             {
               mImpl->mProgramVAOCurrentState = 0u;
             }
           }
+
+          // Clear cached Vertex buffer.
+          mImpl->mCurrentVertexBufferBindings.clear();
+
           mImpl->mProgramVAOMap.erase(iter);
         }
       }