Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / render / renderers / render-renderer.cpp
index 80449e8..cb316e8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -134,7 +134,7 @@ Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider,
                     DepthFunction::Type depthFunction,
                     StencilParameters& stencilParameters )
 : mRenderDataProvider( dataProvider ),
-  mContext( NULL),
+  mContext( nullptr),
   mGeometry( geometry ),
   mUniformIndexMap(),
   mAttributesLocation(),
@@ -165,9 +165,7 @@ void Renderer::Initialize( Context& context )
   mContext = &context;
 }
 
-Renderer::~Renderer()
-{
-}
+Renderer::~Renderer() = default;
 
 void Renderer::SetGeometry( Render::Geometry* geometry )
 {
@@ -203,8 +201,21 @@ void Renderer::SetBlending( Context& context, bool blend )
                                mBlendingOptions.GetBlendDestFactorAlpha() );
 
     // Set blend equations
-    context.BlendEquationSeparate( mBlendingOptions.GetBlendEquationRgb(),
-                                   mBlendingOptions.GetBlendEquationAlpha() );
+    Dali::DevelBlendEquation::Type rgbEquation   = mBlendingOptions.GetBlendEquationRgb();
+    Dali::DevelBlendEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
+
+    if( mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled )
+    {
+      if( rgbEquation != alphaEquation )
+      {
+        DALI_LOG_ERROR( "Advanced Blend Equation have to be appried by using BlendEquation.\n" );
+      }
+      context.BlendEquation( rgbEquation );
+    }
+    else
+    {
+      context.BlendEquationSeparate( rgbEquation, alphaEquation );
+    }
   }
 
   mUpdated = true;
@@ -651,6 +662,11 @@ void Renderer::Render( Context& context,
       mUpdateAttributesLocation = false;
     }
 
+    if( mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled )
+    {
+      context.BlendBarrier();
+    }
+
     if(mDrawCommands.empty())
     {
       SetBlending( context, blend );
@@ -703,8 +719,7 @@ bool Renderer::Updated(BufferIndex bufferIndex, const SceneGraph::NodeDataProvid
     return true;
   }
 
-  std::vector<Render::Texture*> textures = mRenderDataProvider->GetTextures();
-  for (Render::Texture* texture : textures)
+  for( const auto& texture : mRenderDataProvider->GetTextures() )
   {
     if (texture && texture->IsNativeImage())
     {