Fixed the case when the new program is not set whe GLES Context Flush() is called.
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles-impl / gles-context.cpp
index fb32249..31e0713 100644 (file)
@@ -181,11 +181,25 @@ void Context::Flush(bool reset, const GLES::DrawCallDescriptor& drawCall)
 {
   auto& gl = *mImpl->mController.GetGL();
 
+  // early out if neither current nor new pipelines are set
+  // this behaviour may be valid so no assert
+  if(!mImpl->mCurrentPipeline && !mImpl->mNewPipeline)
+  {
+    return;
+  }
+
   // Execute states if pipeline is changed
-  const auto& currentProgram = mImpl->mCurrentPipeline ? static_cast<const GLES::Program*>(mImpl->mCurrentPipeline->GetCreateInfo().programState->program) : nullptr;
-  const auto& newProgram     = static_cast<const GLES::Program*>(mImpl->mNewPipeline->GetCreateInfo().programState->program);
+  const auto currentProgram = mImpl->mCurrentPipeline ? static_cast<const GLES::Program*>(mImpl->mCurrentPipeline->GetCreateInfo().programState->program) : nullptr;
+
+  // case when new pipeline has been set
+  const GLES::Program* newProgram = nullptr;
+
+  if(mImpl->mNewPipeline)
+  {
+    newProgram = static_cast<const GLES::Program*>(mImpl->mNewPipeline->GetCreateInfo().programState->program);
+  }
 
-  if(mImpl->mCurrentPipeline != mImpl->mNewPipeline)
+  if(mImpl->mNewPipeline && mImpl->mCurrentPipeline != mImpl->mNewPipeline)
   {
     if(!currentProgram || currentProgram->GetImplementation()->GetGlProgram() != newProgram->GetImplementation()->GetGlProgram())
     {
@@ -204,7 +218,7 @@ void Context::Flush(bool reset, const GLES::DrawCallDescriptor& drawCall)
 
   // Bind textures
   // Map binding# to sampler location
-  const auto& reflection = newProgram->GetReflection();
+  const auto& reflection = !newProgram ? currentProgram->GetReflection() : newProgram->GetReflection();
   const auto& samplers   = reflection.GetSamplers();
   for(const auto& binding : mImpl->mCurrentTextureBindings)
   {