Blend Equation Advanced Supporting 00/224500/45
authorSeungho, Baek <sbsh.baek@samsung.com>
Tue, 11 Feb 2020 05:51:46 +0000 (14:51 +0900)
committerseungho <seungho@seungho.tn.corp.samsungelectronics.net>
Fri, 30 Oct 2020 02:11:39 +0000 (11:11 +0900)
Change-Id: I7a813e3831424de2b63e1cc53fd5682bbaaa4683
Signed-off-by: Seungho, Baek <sbsh.baek@samsung.com>
30 files changed:
automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp
automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h
automated-tests/src/dali/utc-Dali-Actor.cpp
automated-tests/src/dali/utc-Dali-Renderer.cpp
dali/devel-api/actors/actor-devel.h
dali/devel-api/common/capabilities.cpp [new file with mode: 0644]
dali/devel-api/common/capabilities.h [new file with mode: 0644]
dali/devel-api/file.list
dali/devel-api/rendering/renderer-devel.cpp
dali/devel-api/rendering/renderer-devel.h
dali/integration-api/gl-abstraction.h
dali/integration-api/gl-defines.h
dali/internal/common/blending-options.cpp
dali/internal/common/blending-options.h
dali/internal/common/core-impl.cpp
dali/internal/common/core-impl.h
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/actor-impl.h
dali/internal/event/actors/actor-property-handler.cpp
dali/internal/event/common/thread-local-storage.cpp
dali/internal/event/common/thread-local-storage.h
dali/internal/event/rendering/renderer-impl.cpp
dali/internal/event/rendering/renderer-impl.h
dali/internal/event/rendering/shader-impl.cpp
dali/internal/event/rendering/shader-impl.h
dali/internal/event/rendering/texture-impl.cpp
dali/internal/render/gl-resources/context.h
dali/internal/render/renderers/render-renderer.cpp
dali/public-api/rendering/shader.cpp
dali/public-api/rendering/shader.h

index a694eeb..9e8c7a8 100644 (file)
@@ -112,6 +112,31 @@ bool TestGlAbstraction::IsSurfacelessContextSupported() const
   return true;
 }
 
+bool TestGlAbstraction::IsAdvancedBlendEquationSupported()
+{
+  return true;
+}
+
+bool TestGlAbstraction::IsBlendEquationSupported(DevelBlendEquation::Type blendEquation)
+{
+  return true;
+}
+
+std::string TestGlAbstraction::GetShaderVersionPrefix()
+{
+  return std::string("");
+}
+
+std::string TestGlAbstraction::GetVertexShaderPrefix()
+{
+  return std::string("");
+}
+
+std::string TestGlAbstraction::GetFragmentShaderPrefix()
+{
+  return std::string("");
+}
+
 bool TestGlAbstraction::TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const
 {
   return ((imageGlFormat == GL_RGB) && (textureGlFormat == GL_RGBA));
index 99dca10..861f4ae 100644 (file)
@@ -61,6 +61,16 @@ public:
 
   bool IsSurfacelessContextSupported() const override;
 
+  bool IsAdvancedBlendEquationSupported() override;
+
+  bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation) override;
+
+  std::string GetShaderVersionPrefix();
+
+  std::string GetVertexShaderPrefix();
+
+  std::string GetFragmentShaderPrefix();
+
   bool TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const override;
 
   /* OpenGL ES 2.0 */
@@ -1889,6 +1899,10 @@ public:
   {
   }
 
+  inline void BlendBarrier(void)
+  {
+  }
+
 private:
   inline void AddUniformCallToTraceStack(GLint location, std::string& value)
   {
index 1093bf7..5ac38fa 100755 (executable)
@@ -23,6 +23,7 @@
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/events/hover-event-integ.h>
 #include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/devel-api/common/capabilities.h>
 #include <dali/public-api/dali-core.h>
 #include <mesh-builder.h>
 
@@ -8612,3 +8613,40 @@ int UtcDaliActorGetParentNegative(void)
   }
   END_TEST;
 }
+
+int UtcDaliActorPropertyBlendEquation(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test SetProperty AdvancedBlendEquation");
+
+  Geometry geometry = CreateQuadGeometry();
+  Shader shader = CreateShader();
+  Renderer renderer1 = Renderer::New( geometry, shader );
+
+  Actor actor = Actor::New();
+  actor.SetProperty(Actor::Property::OPACITY, 0.1f);
+
+  actor.AddRenderer(renderer1);
+  actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
+  application.GetScene().Add(actor);
+
+  if( !Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) )
+  {
+    actor.SetProperty( Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN );
+    int equation = actor.GetProperty<int>( Dali::DevelActor::Property::BLEND_EQUATION );
+    DALI_TEST_EQUALS( ( Dali::DevelBlendEquation::SCREEN == equation ), false, TEST_LOCATION );
+  }
+
+  if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) )
+  {
+    actor.SetProperty( Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN );
+    int equation = actor.GetProperty<int>( Dali::DevelActor::Property::BLEND_EQUATION );
+    DALI_TEST_EQUALS( ( Dali::DevelBlendEquation::SCREEN == equation ), true, TEST_LOCATION );
+  }
+
+  Renderer renderer2 = Renderer::New( geometry, shader );
+  actor.AddRenderer(renderer2);
+
+  END_TEST;
+}
index d77fabc..b50d710 100644 (file)
@@ -21,7 +21,7 @@
 #include <dali/devel-api/rendering/renderer-devel.h>
 #include <dali/integration-api/render-task-list-integ.h>
 #include <dali/public-api/dali-core.h>
-
+#include <dali/devel-api/common/capabilities.h>
 #include <cstdio>
 #include <string>
 
@@ -256,12 +256,13 @@ int UtcDaliRendererDefaultProperties(void)
   DALI_PROPERTY( "stencilOperationOnZPass",         INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS )
   DALI_PROPERTY( "opacity",                         FLOAT,     true, true,   true,  Dali::DevelRenderer::Property::OPACITY )
   DALI_PROPERTY( "renderingBehavior",               INTEGER,   true, false,  false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR )
+  DALI_PROPERTY( "blendEquation",                   INTEGER,   true, false,  false, Dali::DevelRenderer::Property::BLEND_EQUATION )
 */
 
   Geometry geometry = CreateQuadGeometry();
   Shader   shader   = CreateShader();
   Renderer renderer = Renderer::New(geometry, shader);
-  DALI_TEST_EQUALS(renderer.GetPropertyCount(), 26, TEST_LOCATION);
+  DALI_TEST_EQUALS(renderer.GetPropertyCount(), 27, TEST_LOCATION);
 
   TEST_RENDERER_PROPERTY(renderer, "depthIndex", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_INDEX, TEST_LOCATION);
   TEST_RENDERER_PROPERTY(renderer, "faceCullingMode", Property::INTEGER, true, false, false, Renderer::Property::FACE_CULLING_MODE, TEST_LOCATION);
@@ -289,6 +290,7 @@ int UtcDaliRendererDefaultProperties(void)
   TEST_RENDERER_PROPERTY(renderer, "stencilOperationOnZPass", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, TEST_LOCATION);
   TEST_RENDERER_PROPERTY(renderer, "opacity", Property::FLOAT, true, true, true, DevelRenderer::Property::OPACITY, TEST_LOCATION);
   TEST_RENDERER_PROPERTY(renderer, "renderingBehavior", Property::INTEGER, true, false, false, DevelRenderer::Property::RENDERING_BEHAVIOR, TEST_LOCATION);
+  TEST_RENDERER_PROPERTY(renderer, "blendEquation", Property::INTEGER, true, false, false, DevelRenderer::Property::BLEND_EQUATION, TEST_LOCATION);
 
   END_TEST;
 }
@@ -654,6 +656,127 @@ int UtcDaliRendererBlendOptions04(void)
   END_TEST;
 }
 
+int UtcDaliRendererBlendOptions05(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test SetAdvancedBlendEquation ");
+
+  Geometry geometry = CreateQuadGeometry();
+  Shader shader = CreateShader();
+  Renderer renderer = Renderer::New( geometry, shader );
+
+  Actor actor = Actor::New();
+  actor.SetProperty(Actor::Property::OPACITY, 0.1f);
+
+  actor.AddRenderer(renderer);
+  actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
+  application.GetScene().Add(actor);
+
+  if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MAX ) )
+  {
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MAX );
+    int equationRgb = renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::MAX, equationRgb, TEST_LOCATION );
+  }
+
+  if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) )
+  {
+    renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true );
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN );
+    int equation = renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION );
+
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::SCREEN, equation, TEST_LOCATION );
+    DALI_TEST_EQUALS( DevelRenderer::IsAdvancedBlendEquationApplied( renderer ), true, TEST_LOCATION );
+
+    application.SendNotification();
+    application.Render();
+  }
+
+  if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MULTIPLY ) )
+  {
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::ADD );
+    renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true );
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION_RGB, DevelBlendEquation::SCREEN );
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION_ALPHA, DevelBlendEquation::MULTIPLY );
+    int equationRgb = renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION_RGB );
+    int equationAlpha = renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION_ALPHA );
+
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::ADD, equationRgb, TEST_LOCATION );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::ADD, equationAlpha, TEST_LOCATION );
+    DALI_TEST_EQUALS( DevelRenderer::IsAdvancedBlendEquationApplied( renderer ), false, TEST_LOCATION );
+
+    application.SendNotification();
+    application.Render();
+  }
+
+  tet_infoline("Error Checking\n");
+  if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MULTIPLY ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::OVERLAY ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::DARKEN ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::LIGHTEN ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::COLOR_DODGE ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::COLOR_BURN ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::HARD_LIGHT ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SOFT_LIGHT ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::DIFFERENCE ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::EXCLUSION ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::HUE ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SATURATION ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::COLOR ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::LUMINOSITY ) )
+  {
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MULTIPLY );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::MULTIPLY, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::SCREEN, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::OVERLAY );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::OVERLAY, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::DARKEN );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::DARKEN, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::LIGHTEN );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::LIGHTEN, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR_DODGE );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::COLOR_DODGE, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR_BURN );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::COLOR_BURN, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::HARD_LIGHT );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::HARD_LIGHT, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SOFT_LIGHT );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::SOFT_LIGHT, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::DIFFERENCE );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::DIFFERENCE, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::EXCLUSION );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::EXCLUSION, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::HUE );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::HUE, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SATURATION );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::SATURATION, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::COLOR, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+
+    renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::LUMINOSITY );
+    DALI_TEST_EQUALS( (int)DevelBlendEquation::LUMINOSITY, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+  }
+
+  END_TEST;
+}
+
 int UtcDaliRendererSetBlendMode01(void)
 {
   TestApplication application;
@@ -2341,6 +2464,21 @@ int UtcDaliRendererEnumProperties(void)
   CheckEnumerationProperty<StencilOperation::Type>(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT");
   CheckEnumerationProperty<StencilOperation::Type>(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT");
 
+  if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MAX ) &&
+      Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MIN ) )
+  {
+    application.SendNotification();
+    application.Render();
+    CheckEnumerationProperty< DevelBlendEquation::Type >( application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::REVERSE_SUBTRACT, DevelBlendEquation::MAX, DevelBlendEquation::MIN, "MIN" );
+  }
+
+  if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) )
+  {
+    application.SendNotification();
+    application.Render();
+    CheckEnumerationProperty< DevelBlendEquation::Type >( application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MIN, DevelBlendEquation::MULTIPLY, DevelBlendEquation::SCREEN, "SCREEN" );
+  }
+
   END_TEST;
 }
 
index 6c9eba0..5821af0 100755 (executable)
@@ -131,7 +131,16 @@ enum Type
     *
     *  If you want to reset the touch area to an area different with the size of the actor, you can set this TOUCH_AREA property.
     */
-  TOUCH_AREA
+  TOUCH_AREA,
+
+  /**
+   * @brief Determines which blend equation will be used to render renderers of this actor.
+   * @pre To use Advanced Blend Equation(DevelBlendEquation::MULTIPLY ~ DevelBlendEquation::LUMINOSITY), the color to be rendered should be pre-multipled alpha.
+   * @details Name "blendEquation", type Property::INTEGER.
+   * @note Color of each renderer will be blended with rendering framebuffer.
+   * @note To check the blend equation is supported in the system, use Dali::Capabilities::IsBlendEquationSupported
+   */
+  BLEND_EQUATION
 };
 
 } // namespace Property
diff --git a/dali/devel-api/common/capabilities.cpp b/dali/devel-api/common/capabilities.cpp
new file mode 100644 (file)
index 0000000..fb04891
--- /dev/null
@@ -0,0 +1,41 @@
+/*\r
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+// CLASS HEADER\r
+#include <dali/devel-api/common/capabilities.h>\r
+#include <dali/internal/event/common/thread-local-storage.h>\r
+\r
+namespace Dali\r
+{\r
+\r
+namespace Capabilities\r
+{\r
+\r
+bool IsBlendEquationSupported( BlendEquation::Type blendEquation )\r
+{\r
+  return IsBlendEquationSupported( static_cast<DevelBlendEquation::Type>( blendEquation ) );\r
+}\r
+\r
+bool IsBlendEquationSupported( DevelBlendEquation::Type blendEquation )\r
+{\r
+  Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get();\r
+  return tls.IsBlendEquationSupported(blendEquation);\r
+}\r
+\r
+} // namespace Capabilities\r
+\r
+} // namespace Dali
\ No newline at end of file
diff --git a/dali/devel-api/common/capabilities.h b/dali/devel-api/common/capabilities.h
new file mode 100644 (file)
index 0000000..f56c27d
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef DALI_CAPABILITIES_H\r
+#define DALI_CAPABILITIES_H\r
+\r
+/*\r
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+// INTERNAL INCLUDES\r
+#include <dali/devel-api/rendering/renderer-devel.h>\r
+\r
+namespace Dali\r
+{\r
+\r
+namespace Capabilities\r
+{\r
+\r
+/**\r
+ * @brief Returns whether the blend equation is supported in the system or not.\r
+ * @param[in] blendEquation blend equation to be checked.\r
+ * @return True if the blend equation supported.\r
+ */\r
+DALI_CORE_API bool IsBlendEquationSupported( BlendEquation::Type blendEquation );\r
+\r
+/**\r
+ * @brief Returns whether the blend equation is supported in the system or not.\r
+ * @param[in] blendEquation blend equation to be checked.\r
+ * @return True if the blend equation supported.\r
+ */\r
+DALI_CORE_API bool IsBlendEquationSupported( DevelBlendEquation::Type blendEquation );\r
+\r
+} // namespace Capabilities\r
+\r
+} // namespace Dali\r
+\r
+#endif // DALI_CAPABILITIES_H
\ No newline at end of file
index a6dba21..d65e823 100644 (file)
@@ -9,6 +9,7 @@ SET( devel_api_src_files
   ${devel_api_src_dir}/animation/animation-devel.cpp
   ${devel_api_src_dir}/animation/path-constrainer.cpp
   ${devel_api_src_dir}/common/addon-binder.cpp
+  ${devel_api_src_dir}/common/capabilities.cpp
   ${devel_api_src_dir}/common/hash.cpp
   ${devel_api_src_dir}/common/singleton-service.cpp
   ${devel_api_src_dir}/common/stage-devel.cpp
@@ -64,6 +65,7 @@ SET( devel_api_core_animation_header_files
 SET( devel_api_core_common_header_files
   ${devel_api_src_dir}/common/addon-binder.h
   ${devel_api_src_dir}/common/bitwise-enum.h
+  ${devel_api_src_dir}/common/capabilities.h
   ${devel_api_src_dir}/common/circular-queue.h
   ${devel_api_src_dir}/common/hash.h
   ${devel_api_src_dir}/common/singleton-service.h
index 303f389..d0913b6 100644 (file)
  */
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/rendering/renderer-devel.h>
 #include <dali/internal/event/rendering/renderer-impl.h>
 
 namespace Dali
 {
 namespace DevelRenderer
 {
+bool IsAdvancedBlendEquationApplied(const Renderer& renderer)
+{
+  return GetImplementation(renderer).IsAdvancedBlendEquationApplied();
+}
+
 void AddDrawCommand(Dali::Renderer renderer, const DrawCommand& drawCommand)
 {
   auto& impl = GetImplementation(renderer);
index 59d9247..9c1ad32 100644 (file)
 
 namespace Dali
 {
+
+namespace DevelBlendEquation
+{
+
+/**
+ * @brief Enumeration for blend equation.
+ */
+enum Type
+{
+  ADD                           = Dali::BlendEquation::ADD,
+  SUBTRACT                      = Dali::BlendEquation::SUBTRACT,
+  REVERSE_SUBTRACT              = Dali::BlendEquation::REVERSE_SUBTRACT,
+
+  // OpenGL es 3.0 enumeration
+  MIN                           = 0x8007,
+  MAX                           = 0x8008,
+
+  // OpenGL es 3.2 or KHR_Blend_Equation_Advanced enumeration
+  MULTIPLY                      = 0x9294,
+  SCREEN                        = 0x9295,
+  OVERLAY                       = 0x9296,
+  DARKEN                        = 0x9297,
+  LIGHTEN                       = 0x9298,
+  COLOR_DODGE                   = 0x9299,
+  COLOR_BURN                    = 0x929A,
+  HARD_LIGHT                    = 0x929B,
+  SOFT_LIGHT                    = 0x929C,
+  DIFFERENCE                    = 0x929E,
+  EXCLUSION                     = 0x92A0,
+  HUE                           = 0x92AD,
+  SATURATION                    = 0x92AE,
+  COLOR                         = 0x92AF,
+  LUMINOSITY                    = 0x92B0
+};
+
+} // namespace DevelBlendEquation
+
 namespace DevelRenderer
 {
 /**
@@ -104,6 +141,12 @@ enum Type
      * @details Name "renderingBehavior", type Property::INTEGER.
      */
   RENDERING_BEHAVIOR = STENCIL_OPERATION_ON_Z_PASS + 2,
+
+  /**
+   * @brief name "blendEquation", type INTEGER
+   * @note The default value is BlendEquation::ADD
+   */
+  BLEND_EQUATION,
 };
 } // namespace Property
 
@@ -120,6 +163,14 @@ enum Type
 
 } // namespace Rendering
 
+
+/**
+ * @brief Query whether current blend equation is advanced option.
+ * @param[in] renderer to be checked whether it has been applied advanced blend equation or not
+ * @return True if current blend equation is advanced.
+ */
+DALI_CORE_API bool IsAdvancedBlendEquationApplied( const Renderer& renderer );
+
 } // namespace DevelRenderer
 
 } // namespace Dali
index ed36bdc..11a96b1 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <stdint.h>
+#include <dali/devel-api/rendering/renderer-devel.h>
 
 /*
  * This file is based on gl3.h, the following licence is included for conformance.
@@ -118,6 +119,36 @@ public:
   virtual bool IsSurfacelessContextSupported() const = 0;
 
   /**
+   * Returns current gles can support advanced blend equation
+   * @Return true current gles support advanced blend equation
+   */
+  virtual bool IsAdvancedBlendEquationSupported() = 0;
+
+  /**
+   * Returns current gles can support the blend equation
+   * @Return true current gles support the blend equation
+   */
+  virtual bool IsBlendEquationSupported( DevelBlendEquation::Type blendEquation ) = 0;
+
+  /**
+   * Returns shader prefix of shading language version.
+   * @Return shader prefix of shading language version.
+   */
+  virtual std::string GetShaderVersionPrefix() = 0;
+
+  /**
+   * Returns vertex shader prefix including shading language version.
+   * @Return vertex shader prefix including shading language version.
+   */
+  virtual std::string GetVertexShaderPrefix() = 0;
+
+  /**
+   * Returns fragment shader prefix including shading language version and extension information.
+   * @Return fragment shader prefix including shading language version and extension information.
+   */
+  virtual std::string GetFragmentShaderPrefix() = 0;
+
+  /**
    * Determine whether to convert pixel format or not.
    * @param[in] imageGlFormat GLformat of input image.
    * @param[in] textureGlFormat GLformat of Texture.
@@ -382,6 +413,7 @@ public:
   virtual void           TexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) = 0;
   virtual void           TexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) = 0;
   virtual void           GetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) = 0;
+  virtual void           BlendBarrier (void) = 0;
   // clang-format on
 };
 
index ab7e5e2..8bb7d18 100644 (file)
 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR        0x93DC
 #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR        0x93DD
 
+// GL_blend_equation_advanced / GLES 3.2
+#define GL_MULTIPLY                                      0x9294
+#define GL_SCREEN                                        0x9295
+#define GL_OVERLAY                                       0x9296
+#define GL_DARKEN                                        0x9297
+#define GL_LIGHTEN                                       0x9298
+#define GL_COLORDODGE                                    0x9299
+#define GL_COLORBURN                                     0x929A
+#define GL_HARDLIGHT                                     0x929B
+#define GL_SOFTLIGHT                                     0x929C
+#define GL_DIFFERENCE                                    0x929E
+#define GL_EXCLUSION                                     0x92A0
+#define GL_HSL_HUE                                       0x92AD
+#define GL_HSL_SATURATION                                0x92AE
+#define GL_HSL_COLOR                                     0x92AF
+#define GL_HSL_LUMINOSITY                                0x92B0
+
 /*------------------------------------------------------------------------*
  * EXT extension tokens
  *------------------------------------------------------------------------*/
index 81b4db4..596e544 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 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.
@@ -27,18 +27,18 @@ const int MASK_SRC_FACTOR_RGB    = 0x0000000F;
 const int MASK_SRC_FACTOR_ALPHA  = 0x000000F0;
 const int MASK_DEST_FACTOR_RGB   = 0x00000F00;
 const int MASK_DEST_FACTOR_ALPHA = 0x0000F000;
-const int MASK_EQUATION_RGB      = 0x000F0000;
-const int MASK_EQUATION_ALPHA    = 0x00F00000;
+const int MASK_EQUATION_RGB      = 0x00FF0000;
+const int MASK_EQUATION_ALPHA    = 0xFF000000;
 
 const int SHIFT_TO_SRC_FACTOR_RGB    =  0;
 const int SHIFT_TO_SRC_FACTOR_ALPHA  =  4;
 const int SHIFT_TO_DEST_FACTOR_RGB   =  8;
 const int SHIFT_TO_DEST_FACTOR_ALPHA = 12;
 const int SHIFT_TO_EQUATION_RGB      = 16;
-const int SHIFT_TO_EQUATION_ALPHA    = 20;
+const int SHIFT_TO_EQUATION_ALPHA    = 24;
 
 static unsigned int CLEAR_BLEND_FUNC_MASK     = 0xFFFF0000; // Bottom 16 bits cleared
-static unsigned int CLEAR_BLEND_EQUATION_MASK = 0xFF00FFFF; // 8 bits cleared
+static unsigned int CLEAR_BLEND_EQUATION_MASK = 0x0000FFFF; // Top 16 bits cleared
 
 /**
  * Utility to store one of the BlendFunc values.
@@ -148,54 +148,203 @@ void StoreBlendFactor( unsigned int& options, BlendFactor::Type factor, int bitS
  * @param[in] factor The BlendEquation value.
  * @param[in] bitshift Used to shift to the correct part of options.
  */
-void StoreBlendEquation( unsigned int& options, BlendEquation::Type factor, int bitShift )
+void StoreBlendEquation( unsigned int& options, DevelBlendEquation::Type factor, int bitShift )
 {
+  // Must be same order as BLENDING_EQUATIONS, below:
+  enum {
+    ADD_BITVAL = 0u,
+    SUBTRACT_BITVAL,
+    REVERSE_SUBTRACT_BITVAL,
+    MIN_BITVAL,
+    MAX_BITVAL,
+    MULTIPLY_BITVAL,
+    SCREEN_BITVAL,
+    OVERLAY_BITVAL,
+    DARKEN_BITVAL,
+    LIGHTEN_BITVAL,
+    COLOR_DODGE_BITVAL,
+    COLOR_BURN_BITVAL,
+    HARD_LIGHT_BITVAL,
+    SOFT_LIGHT_BITVAL,
+    DIFFERENCE_BITVAL,
+    EXCLUSION_BITVAL,
+    HUE_BITVAL,
+    SATURATION_BITVAL,
+    COLOR_BITVAL,
+    LUMINOSITY_BITVAL
+  };
+
   switch ( factor )
   {
-    case BlendEquation::ADD:
+    case DevelBlendEquation::ADD:
     {
-      options |= ( 0u << bitShift );
+      options |= ( ADD_BITVAL << bitShift );
       break;
     }
 
-    case BlendEquation::SUBTRACT:
+    case DevelBlendEquation::SUBTRACT:
     {
-      options |= ( 1u << bitShift );
+      options |= ( SUBTRACT_BITVAL << bitShift );
       break;
     }
 
-    case BlendEquation::REVERSE_SUBTRACT:
+    case DevelBlendEquation::REVERSE_SUBTRACT:
     {
-      options |= ( 2u << bitShift );
+      options |= ( REVERSE_SUBTRACT_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::MIN:
+    {
+      options |= ( MIN_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::MAX:
+    {
+      options |= ( MAX_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::MULTIPLY:
+    {
+      options |= ( MULTIPLY_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::SCREEN:
+    {
+      options |= ( SCREEN_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::OVERLAY:
+    {
+      options |= ( OVERLAY_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::DARKEN:
+    {
+      options |= ( DARKEN_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::LIGHTEN:
+    {
+      options |= ( LIGHTEN_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::COLOR_DODGE:
+    {
+      options |= ( COLOR_DODGE_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::COLOR_BURN:
+    {
+      options |= ( COLOR_BURN_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::HARD_LIGHT:
+    {
+      options |= ( HARD_LIGHT_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::SOFT_LIGHT:
+    {
+      options |= ( SOFT_LIGHT_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::DIFFERENCE:
+    {
+      options |= ( DIFFERENCE_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::EXCLUSION:
+    {
+      options |= ( EXCLUSION_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::HUE:
+    {
+      options |= ( HUE_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::SATURATION:
+    {
+      options |= ( SATURATION_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::COLOR:
+    {
+      options |= ( COLOR_BITVAL << bitShift );
+      break;
+    }
+
+    case DevelBlendEquation::LUMINOSITY:
+    {
+      options |= ( LUMINOSITY_BITVAL << bitShift );
       break;
     }
   }
 }
 
 const unsigned int BLENDING_FACTOR_COUNT   = 15;
-const unsigned int BLENDING_EQUATION_COUNT = 3;
+const unsigned int BLENDING_EQUATION_COUNT = 20;
+const unsigned int BLENDING_EQUATION_ADVANCED_INDEX_START = 5;
+const unsigned int BLENDING_EQUATION_ADVANCED_INDEX_END = 19;
 
 BlendFactor::Type BLENDING_FACTORS[ BLENDING_FACTOR_COUNT ] =
-  { BlendFactor::ZERO,
-    BlendFactor::ONE,
-    BlendFactor::SRC_COLOR,
-    BlendFactor::ONE_MINUS_SRC_COLOR,
-    BlendFactor::SRC_ALPHA,
-    BlendFactor::ONE_MINUS_SRC_ALPHA,
-    BlendFactor::DST_ALPHA,
-    BlendFactor::ONE_MINUS_DST_ALPHA,
-    BlendFactor::DST_COLOR,
-    BlendFactor::ONE_MINUS_DST_COLOR,
-    BlendFactor::SRC_ALPHA_SATURATE,
-    BlendFactor::CONSTANT_COLOR,
-    BlendFactor::ONE_MINUS_CONSTANT_COLOR,
-    BlendFactor::CONSTANT_ALPHA,
-    BlendFactor::ONE_MINUS_CONSTANT_ALPHA };
-
-BlendEquation::Type BLENDING_EQUATIONS[ BLENDING_EQUATION_COUNT ] =
-  { BlendEquation::ADD,
-    BlendEquation::SUBTRACT,
-    BlendEquation::REVERSE_SUBTRACT };
+{
+  BlendFactor::ZERO,
+  BlendFactor::ONE,
+  BlendFactor::SRC_COLOR,
+  BlendFactor::ONE_MINUS_SRC_COLOR,
+  BlendFactor::SRC_ALPHA,
+  BlendFactor::ONE_MINUS_SRC_ALPHA,
+  BlendFactor::DST_ALPHA,
+  BlendFactor::ONE_MINUS_DST_ALPHA,
+  BlendFactor::DST_COLOR,
+  BlendFactor::ONE_MINUS_DST_COLOR,
+  BlendFactor::SRC_ALPHA_SATURATE,
+  BlendFactor::CONSTANT_COLOR,
+  BlendFactor::ONE_MINUS_CONSTANT_COLOR,
+  BlendFactor::CONSTANT_ALPHA,
+  BlendFactor::ONE_MINUS_CONSTANT_ALPHA
+};
+
+DevelBlendEquation::Type BLENDING_EQUATIONS[ BLENDING_EQUATION_COUNT ] =
+{
+  DevelBlendEquation::ADD,
+  DevelBlendEquation::SUBTRACT,
+  DevelBlendEquation::REVERSE_SUBTRACT,
+  DevelBlendEquation::MIN,
+  DevelBlendEquation::MAX,
+  DevelBlendEquation::MULTIPLY,
+  DevelBlendEquation::SCREEN,
+  DevelBlendEquation::OVERLAY,
+  DevelBlendEquation::DARKEN,
+  DevelBlendEquation::LIGHTEN,
+  DevelBlendEquation::COLOR_DODGE,
+  DevelBlendEquation::COLOR_BURN,
+  DevelBlendEquation::HARD_LIGHT,
+  DevelBlendEquation::SOFT_LIGHT,
+  DevelBlendEquation::DIFFERENCE,
+  DevelBlendEquation::EXCLUSION,
+  DevelBlendEquation::HUE,
+  DevelBlendEquation::SATURATION,
+  DevelBlendEquation::COLOR,
+  DevelBlendEquation::LUMINOSITY
+};
 
 /**
  * Utility to retrieve one of the BlendFunc values.
@@ -221,7 +370,7 @@ BlendFactor::Type RetrieveBlendFactor( unsigned int options, int mask, int bitSh
  * @param[in] bitshift Used to shift to the correct part of options.
  * @return The blending equation.
  */
-BlendEquation::Type RetrieveBlendEquation( unsigned int options, int mask, int bitShift )
+DevelBlendEquation::Type RetrieveBlendEquation( unsigned int options, int mask, int bitShift )
 {
   unsigned int index = options & mask;
   index = index >> bitShift;
@@ -246,7 +395,7 @@ BlendingOptions::BlendingOptions()
   SetBlendFunc( BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA,
                 BlendFactor::ONE,       BlendFactor::ONE_MINUS_SRC_ALPHA );
 
-  SetBlendEquation( BlendEquation::ADD, BlendEquation::ADD );
+  SetBlendEquation( DevelBlendEquation::ADD, DevelBlendEquation::ADD );
 }
 
 BlendingOptions::~BlendingOptions() = default;
@@ -292,7 +441,7 @@ BlendFactor::Type BlendingOptions::GetBlendDestFactorAlpha() const
   return RetrieveBlendFactor( mBitmask, MASK_DEST_FACTOR_ALPHA, SHIFT_TO_DEST_FACTOR_ALPHA );
 }
 
-void BlendingOptions::SetBlendEquation( BlendEquation::Type equationRgb, BlendEquation::Type equationAlpha )
+void BlendingOptions::SetBlendEquation( DevelBlendEquation::Type equationRgb, DevelBlendEquation::Type equationAlpha )
 {
   mBitmask &= CLEAR_BLEND_EQUATION_MASK; // Clear the BlendEquation values
 
@@ -300,12 +449,12 @@ void BlendingOptions::SetBlendEquation( BlendEquation::Type equationRgb, BlendEq
   StoreBlendEquation( mBitmask, equationAlpha, SHIFT_TO_EQUATION_ALPHA );
 }
 
-BlendEquation::Type BlendingOptions::GetBlendEquationRgb() const
+DevelBlendEquation::Type BlendingOptions::GetBlendEquationRgb() const
 {
   return RetrieveBlendEquation( mBitmask, MASK_EQUATION_RGB, SHIFT_TO_EQUATION_RGB );
 }
 
-BlendEquation::Type BlendingOptions::GetBlendEquationAlpha() const
+DevelBlendEquation::Type BlendingOptions::GetBlendEquationAlpha() const
 {
   return RetrieveBlendEquation( mBitmask, MASK_EQUATION_ALPHA, SHIFT_TO_EQUATION_ALPHA );
 }
@@ -335,6 +484,47 @@ const Vector4* BlendingOptions::GetBlendColor() const
   return mBlendColor.Get();
 }
 
+bool BlendingOptions::IsAdvancedBlendEquationApplied()
+{
+  unsigned int indexRgb = mBitmask & MASK_EQUATION_RGB;
+  indexRgb = indexRgb >> SHIFT_TO_EQUATION_RGB;
+  unsigned int indexA = mBitmask & MASK_EQUATION_ALPHA;
+  indexA = indexA >> SHIFT_TO_EQUATION_ALPHA;
+
+  return ( ( ( indexRgb >= BLENDING_EQUATION_ADVANCED_INDEX_START ) && ( indexRgb <= BLENDING_EQUATION_ADVANCED_INDEX_END ) ) ||
+           ( ( indexA   >= BLENDING_EQUATION_ADVANCED_INDEX_START ) && ( indexA   <= BLENDING_EQUATION_ADVANCED_INDEX_END ) ) );
+}
+
+bool BlendingOptions::IsAdvancedBlendEquation( DevelBlendEquation::Type equation )
+{
+  switch ( equation )
+  {
+    case DevelBlendEquation::MULTIPLY:
+    case DevelBlendEquation::SCREEN:
+    case DevelBlendEquation::OVERLAY:
+    case DevelBlendEquation::DARKEN:
+    case DevelBlendEquation::LIGHTEN:
+    case DevelBlendEquation::COLOR_DODGE:
+    case DevelBlendEquation::COLOR_BURN:
+    case DevelBlendEquation::HARD_LIGHT:
+    case DevelBlendEquation::SOFT_LIGHT:
+    case DevelBlendEquation::DIFFERENCE:
+    case DevelBlendEquation::EXCLUSION:
+    case DevelBlendEquation::HUE:
+    case DevelBlendEquation::SATURATION:
+    case DevelBlendEquation::COLOR:
+    case DevelBlendEquation::LUMINOSITY:
+    {
+      return true;
+    }
+
+    default:
+    {
+      return false;
+    }
+  }
+}
+
 } // namespace Internal
 
 } // namespace Dali
index b469c26..f150685 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_BLENDING_OPTIONS_H
 
 /*
- * Copyright (c) 2017 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.
@@ -20,6 +20,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/public-api/rendering/renderer.h>
+#include <dali/devel-api/rendering/renderer-devel.h>
 #include <dali/public-api/math/vector4.h>
 #include <dali/internal/common/owner-pointer.h>
 
@@ -83,17 +84,17 @@ struct BlendingOptions
   /**
    * @copydoc Dali::RenderableActor::SetBlendEquation()
    */
-  void SetBlendEquation( BlendEquation::Type equationRgb, BlendEquation::Type equationAlpha );
+  void SetBlendEquation( DevelBlendEquation::Type equationRgb, DevelBlendEquation::Type equationAlpha );
 
   /**
    * @copydoc Dali::RenderableActor::GetBlendEquation()
    */
-  BlendEquation::Type GetBlendEquationRgb() const;
+  DevelBlendEquation::Type GetBlendEquationRgb() const;
 
   /**
    * @copydoc Dali::RenderableActor::GetBlendEquation()
    */
-  BlendEquation::Type GetBlendEquationAlpha() const;
+  DevelBlendEquation::Type GetBlendEquationAlpha() const;
 
   /**
    * Set the blend color.
@@ -108,6 +109,18 @@ struct BlendingOptions
    */
   const Vector4* GetBlendColor() const;
 
+  /**
+   * Query whether current blend equation is advanced option.
+   * @return True if current blend equation is advanced.
+   */
+  bool IsAdvancedBlendEquationApplied();
+
+  /**
+   * Query whether input blend equation is advanced option.
+   * @return True if input blend equation is advanced.
+   */
+  static bool IsAdvancedBlendEquation( DevelBlendEquation::Type equation );
+
 private:
 
   // Undefined copy constructor.
index b3b953f..cffc170 100644 (file)
@@ -91,6 +91,7 @@ Core::Core( RenderController& renderController,
             Integration::PartialUpdateAvailable partialUpdateAvailable )
 : mRenderController( renderController ),
   mPlatform(platform),
+  mGlAbstraction(glAbstraction),
   mProcessingEvent(false),
   mForceNextUpdate( false )
 {
@@ -422,6 +423,11 @@ AnimationPlaylist& Core::GetAnimationPlaylist() const
   return *(mAnimationPlaylist);
 }
 
+Integration::GlAbstraction& Core::GetGlAbstraction() const
+{
+  return mGlAbstraction;
+}
+
 void Core::AddScene( Scene* scene )
 {
   mScenes.push_back( scene );
index 1e72470..478bfcd 100644 (file)
@@ -311,6 +311,13 @@ private:
    */
   AnimationPlaylist& GetAnimationPlaylist() const;
 
+  /**
+   * @brief Returns GlAbstraction.
+   * @note Use only for the capability. Do not use this for bypass context
+   * @return GlAbstraction
+   */
+  Integration::GlAbstraction& GetGlAbstraction() const;
+
 private:
 
   /**
@@ -349,6 +356,10 @@ private:
   // The object registry
   ObjectRegistryPtr                             mObjectRegistry;
 
+  // GlAbstraction for capabilities of GL
+  // Not to use this for bypass Context.
+  Integration::GlAbstraction&               mGlAbstraction;
+
   bool                                      mProcessingEvent  : 1;        ///< True during ProcessEvents()
   bool                                      mForceNextUpdate:1;           ///< True if the next rendering is really required.
 
index f4a1067..35131c1 100755 (executable)
@@ -31,6 +31,7 @@
 #include <dali/public-api/math/vector3.h>
 #include <dali/public-api/math/radian.h>
 #include <dali/public-api/object/type-registry.h>
+#include <dali/devel-api/common/capabilities.h>
 #include <dali/devel-api/actors/actor-devel.h>
 #include <dali/internal/event/actors/actor-property-handler.h>
 #include <dali/internal/event/actors/actor-relayouter.h>
@@ -144,6 +145,7 @@ DALI_PROPERTY( "siblingOrder",              INTEGER,  true,  false, false, Dali:
 DALI_PROPERTY( "updateSizeHint",            VECTOR2,  true,  false, false, Dali::DevelActor::Property::UPDATE_SIZE_HINT )
 DALI_PROPERTY( "captureAllTouchAfterStart", BOOLEAN,  true,  false, false, Dali::DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START )
 DALI_PROPERTY( "touchArea",                 VECTOR2,  true,  false, false, Dali::DevelActor::Property::TOUCH_AREA )
+DALI_PROPERTY( "blendEquation",             INTEGER,  true,  false, false, Dali::DevelActor::Property::BLEND_EQUATION )
 DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX, ActorDefaultProperties )
 
 // Signals
@@ -1195,6 +1197,12 @@ uint32_t Actor::AddRenderer( Renderer& renderer )
     mRenderers = new RendererContainer;
   }
 
+  if(mIsBlendEquationSet)
+  {
+    renderer.SetBlendMode(Dali::BlendMode::ON);
+    renderer.SetBlendEquation(static_cast<DevelBlendEquation::Type>(mBlendEquation));
+  }
+
   uint32_t index = static_cast<uint32_t>( mRenderers->size() ); //  4,294,967,295 renderers per actor
   RendererPtr rendererPtr = RendererPtr( &renderer );
   mRenderers->push_back( rendererPtr );
@@ -1251,6 +1259,34 @@ void Actor::RemoveRenderer( uint32_t index )
   }
 }
 
+void Actor::SetBlendEquation(DevelBlendEquation::Type blendEquation)
+{
+  if(Dali::Capabilities::IsBlendEquationSupported(blendEquation))
+  {
+    if(mBlendEquation != blendEquation)
+    {
+      mBlendEquation         = blendEquation;
+      uint32_t rendererCount = GetRendererCount();
+      for(uint32_t i = 0; i < rendererCount; ++i)
+      {
+        RendererPtr renderer = GetRendererAt(i);
+        renderer->SetBlendMode(Dali::BlendMode::ON);
+        renderer->SetBlendEquation(static_cast<DevelBlendEquation::Type>(blendEquation));
+      }
+    }
+    mIsBlendEquationSet = true;
+  }
+  else
+  {
+    DALI_LOG_ERROR("Invalid blend equation is entered.\n");
+  }
+}
+
+DevelBlendEquation::Type Actor::GetBlendEquation() const
+{
+  return mBlendEquation;
+}
+
 void Actor::SetDrawMode( DrawMode::Type drawMode )
 {
   // this flag is not animatable so keep the value
@@ -1473,7 +1509,9 @@ Actor::Actor( DerivedType derivedType, const SceneGraph::Node& node )
   mLayoutDirection( LayoutDirection::LEFT_TO_RIGHT ),
   mDrawMode( DrawMode::NORMAL ),
   mColorMode( Node::DEFAULT_COLOR_MODE ),
-  mClippingMode( ClippingMode::DISABLED )
+  mClippingMode( ClippingMode::DISABLED ),
+  mBlendEquation( DevelBlendEquation::ADD ),
+  mIsBlendEquationSet( false )
 {
 }
 
index a3ad757..367beeb 100755 (executable)
@@ -1241,6 +1241,16 @@ public:
    */
   void RemoveRenderer( uint32_t index );
 
+  /**
+   * Set BlendEquation at each renderer that added on this Actor.
+   */
+  void SetBlendEquation( DevelBlendEquation::Type blendEquation );
+
+  /**
+   * @brief Get Blend Equation that applied to this Actor
+   */
+  DevelBlendEquation::Type GetBlendEquation() const;
+
 public:
 
   /**
@@ -2071,6 +2081,8 @@ protected:
   DrawMode::Type mDrawMode                         : 3; ///< Cached: How the actor and its children should be drawn
   ColorMode mColorMode                             : 3; ///< Cached: Determines whether mWorldColor is inherited
   ClippingMode::Type mClippingMode                 : 3; ///< Cached: Determines which clipping mode (if any) to use.
+  DevelBlendEquation::Type mBlendEquation          : 16;///< Cached: Determines which blend equation will be used to render renderers.
+  bool mIsBlendEquationSet                         : 1; ///< Flag to identify whether the Blend equation is set
 
 private:
 
index 3df53fc..76f82f5 100755 (executable)
@@ -584,6 +584,15 @@ void Actor::PropertyHandler::SetDefaultProperty( Internal::Actor& actor, Propert
       break;
     }
 
+    case Dali::DevelActor::Property::BLEND_EQUATION:
+    {
+      int value;
+      if( property.Get( value ) )
+      {
+        actor.SetBlendEquation( static_cast<DevelBlendEquation::Type>( value ) );
+      }
+      break;
+    }
 
     default:
     {
@@ -1620,6 +1629,12 @@ bool Actor::PropertyHandler::GetCachedPropertyValue(const Internal::Actor& actor
       break;
     }
 
+    case Dali::DevelActor::Property::BLEND_EQUATION:
+    {
+      value = actor.GetBlendEquation();
+      break;
+    }
+
     default:
     {
       // Must be a scene-graph only property
index 5962768..0628fbe 100644 (file)
@@ -149,6 +149,26 @@ AnimationPlaylist& ThreadLocalStorage::GetAnimationPlaylist()
   return mCore->GetAnimationPlaylist();
 }
 
+bool ThreadLocalStorage::IsBlendEquationSupported( DevelBlendEquation::Type blendEquation )
+{
+  return mCore->GetGlAbstraction().IsBlendEquationSupported( blendEquation );
+}
+
+std::string ThreadLocalStorage::GetShaderVersionPrefix()
+{
+  return mCore->GetGlAbstraction().GetShaderVersionPrefix();
+}
+
+std::string ThreadLocalStorage::GetVertexShaderPrefix()
+{
+  return mCore->GetGlAbstraction().GetVertexShaderPrefix();
+}
+
+std::string ThreadLocalStorage::GetFragmentShaderPrefix()
+{
+  return mCore->GetGlAbstraction().GetFragmentShaderPrefix();
+}
+
 void ThreadLocalStorage::AddScene( Scene* scene )
 {
   mCore->AddScene( scene );
index f994a12..052b438 100644 (file)
@@ -163,6 +163,28 @@ public:
   AnimationPlaylist& GetAnimationPlaylist();
 
   /**
+   * @brief Returns whether the blend equation is supported in the system or not.
+   * @param[in] blendEquation blend equation to be checked.
+   * @return True if the blend equation supported.
+   */
+  bool IsBlendEquationSupported( DevelBlendEquation::Type blendEquation );
+
+  /**
+   * @brief Returns shader prefix of shading language version.
+   */
+  std::string GetShaderVersionPrefix();
+
+  /**
+   * @brief Returns vertex shader prefix including shading language version.
+   */
+  std::string GetVertexShaderPrefix();
+
+  /**
+   * @brief Returns fragment shader prefix including shading language version and extension information.
+   */
+  std::string GetFragmentShaderPrefix();
+
+  /**
    * Add a Scene to the Core.
    * This is only used by the Scene to add itself to the core when the Scene is created.
    * @param[in] scene The Scene.
index ef47828..838e047 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 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.
@@ -65,6 +65,7 @@ DALI_PROPERTY( "stencilOperationOnZFail",         INTEGER,   true, false,  false
 DALI_PROPERTY( "stencilOperationOnZPass",         INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS )
 DALI_PROPERTY( "opacity",                         FLOAT,     true, true,   true,  Dali::DevelRenderer::Property::OPACITY )
 DALI_PROPERTY( "renderingBehavior",               INTEGER,   true, false,  false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR )
+DALI_PROPERTY( "blendEquation",                   INTEGER,   true, false,  false, Dali::DevelRenderer::Property::BLEND_EQUATION )
 DALI_PROPERTY_TABLE_END( DEFAULT_RENDERER_PROPERTY_START_INDEX, RendererDefaultProperties )
 
 // Property string to enumeration tables:
@@ -86,6 +87,23 @@ DALI_ENUM_TO_STRING_TABLE_BEGIN( BLEND_EQUATION )
 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendEquation, ADD )
 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendEquation, SUBTRACT )
 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendEquation, REVERSE_SUBTRACT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, MIN )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, MAX )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, MULTIPLY )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, SCREEN )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, OVERLAY )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, DARKEN )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, LIGHTEN )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, COLOR_DODGE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, COLOR_BURN )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, HARD_LIGHT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, SOFT_LIGHT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, DIFFERENCE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, EXCLUSION )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, HUE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, SATURATION )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, COLOR )
+DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, LUMINOSITY )
 DALI_ENUM_TO_STRING_TABLE_END( BLEND_EQUATION )
 
 DALI_ENUM_TO_STRING_TABLE_BEGIN( BLEND_FACTOR )
@@ -281,21 +299,26 @@ void Renderer::GetBlendFunc( BlendFactor::Type& srcFactorRgb,
   destFactorAlpha = mBlendingOptions.GetBlendDestFactorAlpha();
 }
 
-void Renderer::SetBlendEquation( BlendEquation::Type equationRgba )
+void Renderer::SetBlendEquation( DevelBlendEquation::Type equationRgba )
 {
   mBlendingOptions.SetBlendEquation( equationRgba, equationRgba );
   SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
 }
 
-void Renderer::SetBlendEquation( BlendEquation::Type equationRgb,
-                                 BlendEquation::Type equationAlpha )
+void Renderer::SetBlendEquation( DevelBlendEquation::Type equationRgb,
+                                 DevelBlendEquation::Type equationAlpha )
 {
+  if( mBlendingOptions.IsAdvancedBlendEquation( equationRgb ) || mBlendingOptions.IsAdvancedBlendEquation( equationAlpha ) )
+  {
+    DALI_LOG_ERROR("Advanced blend equation requires to be set by using SetBlendEquation( DevelBlendEquation::Type equationRgba ).");
+    return;
+  }
   mBlendingOptions.SetBlendEquation( equationRgb, equationAlpha );
   SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
 }
 
-void Renderer::GetBlendEquation( BlendEquation::Type& equationRgb,
-                                 BlendEquation::Type& equationAlpha ) const
+void Renderer::GetBlendEquation( DevelBlendEquation::Type& equationRgb,
+                                 DevelBlendEquation::Type& equationAlpha ) const
 {
   // These are not animatable, the cached values are up-to-date.
   equationRgb   = mBlendingOptions.GetBlendEquationRgb();
@@ -343,6 +366,19 @@ bool Renderer::IsPreMultipliedAlphaEnabled() const
   return mPremultipledAlphaEnabled;
 }
 
+bool Renderer::IsAdvancedBlendEquationApplied() const
+{
+  DevelBlendEquation::Type equationRgb, equationAlpha;
+  GetBlendEquation( equationRgb, equationAlpha );
+
+  if( equationRgb != equationAlpha )
+  {
+    return false;
+  }
+
+  return mBlendingOptions.IsAdvancedBlendEquation( equationRgb );
+}
+
 const SceneGraph::Renderer& Renderer::GetRendererSceneObject() const
 {
   return static_cast<const SceneGraph::Renderer&>( GetSceneObject() );
@@ -377,13 +413,29 @@ void Renderer::SetDefaultProperty( Property::Index index,
       }
       break;
     }
+    case Dali::DevelRenderer::Property::BLEND_EQUATION:
+    {
+      DevelBlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationRgb();
+
+      if( Scripting::GetEnumerationProperty< DevelBlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) )
+      {
+        mBlendingOptions.SetBlendEquation( convertedValue, convertedValue );
+        SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
+      }
+      break;
+    }
     case Dali::Renderer::Property::BLEND_EQUATION_RGB:
     {
-      BlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationRgb();
+      DevelBlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationRgb();
 
-      if( Scripting::GetEnumerationProperty< BlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) )
+      if( Scripting::GetEnumerationProperty< DevelBlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) )
       {
-        BlendEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
+        if( mBlendingOptions.IsAdvancedBlendEquation( convertedValue ) )
+        {
+          DALI_LOG_ERROR("Advanced blend equation requires to be set by using DevelBlendEquation::BLEND_EQUATION.");
+          break;
+        }
+        DevelBlendEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
         mBlendingOptions.SetBlendEquation( convertedValue, alphaEquation );
         SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
       }
@@ -391,11 +443,16 @@ void Renderer::SetDefaultProperty( Property::Index index,
     }
     case Dali::Renderer::Property::BLEND_EQUATION_ALPHA:
     {
-      BlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationAlpha();
+      DevelBlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationAlpha();
 
-      if( Scripting::GetEnumerationProperty< BlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) )
+      if( Scripting::GetEnumerationProperty< DevelBlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) )
       {
-        BlendEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb();
+        if( mBlendingOptions.IsAdvancedBlendEquation( convertedValue ) )
+        {
+          DALI_LOG_ERROR("Advanced blend equation requires to be set by using DevelBlendEquation::BLEND_EQUATION.");
+          break;
+        }
+        DevelBlendEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb();
         mBlendingOptions.SetBlendEquation( rgbEquation, convertedValue );
         SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
       }
@@ -775,6 +832,11 @@ bool Renderer::GetCachedPropertyValue( Property::Index index, Property::Value& v
       value = mBlendMode;
       break;
     }
+    case Dali::DevelRenderer::Property::BLEND_EQUATION:
+    {
+      value = static_cast<int32_t>( mBlendingOptions.GetBlendEquationRgb() );
+      break;
+    }
     case Dali::Renderer::Property::BLEND_EQUATION_RGB:
     {
       value = static_cast<int32_t>( mBlendingOptions.GetBlendEquationRgb() );
@@ -943,6 +1005,14 @@ bool Renderer::GetCurrentPropertyValue( Property::Index index, Property::Value&
       value = sceneObject.GetBlendMode();
       break;
     }
+    case Dali::DevelRenderer::Property::BLEND_EQUATION:
+    {
+      uint32_t bitMask = sceneObject.GetBlendingOptions();
+      BlendingOptions blendingOptions;
+      blendingOptions.SetBitmask( bitMask );
+      value = static_cast<int32_t>( blendingOptions.GetBlendEquationRgb() );
+      break;
+    }
     case Dali::Renderer::Property::BLEND_EQUATION_RGB:
     {
       uint32_t bitMask = sceneObject.GetBlendingOptions();
index 2ec0e5c..6849bf3 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_RENDERER_H
 
 /*
- * Copyright (c) 2018 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.
@@ -123,19 +123,19 @@ public:
                     BlendFactor::Type& srcFactorAlpha, BlendFactor::Type& destFactorAlpha ) const;
 
   /**
-   * @copydoc Dali::Renderer::SetBlendEquation()
+   * @brief Set same Blend Equation for the RGB and alpha
    */
-  void SetBlendEquation( BlendEquation::Type equationRgba );
+  void SetBlendEquation( DevelBlendEquation::Type equationRgba );
 
   /**
-   * @copydoc Dali::Renderer::SetBlendEquation()
+   * @brief Set Blend Equation separately for the RGB and alpha
    */
-  void SetBlendEquation( BlendEquation::Type equationRgb, BlendEquation::Type equationAlpha );
+  void SetBlendEquation( DevelBlendEquation::Type equationRgb, DevelBlendEquation::Type equationAlpha );
 
   /**
-   * @copydoc Dali::Renderer::GetBlendEquation()
+   * @brief Get Blend Equation of rgb and alpha
    */
-  void GetBlendEquation( BlendEquation::Type& equationRgb, BlendEquation::Type& equationAlpha ) const;
+  void GetBlendEquation( DevelBlendEquation::Type& equationRgb, DevelBlendEquation::Type& equationAlpha ) const;
 
   /**
    * @copydoc Dali::Renderer::SetIndexedDrawFirstElement
@@ -162,6 +162,13 @@ public:
   bool IsPreMultipliedAlphaEnabled() const;
 
   /**
+   * @brief Query whether Blend Equation Advanced is used in this renderer
+   *
+   * @return True is Blend Equation Advanced is used, false otherwise.
+   */
+  bool IsAdvancedBlendEquationApplied() const;
+
+  /**
    * @brief Get the scene graph object
    *
    * @return the scene object
index 3c3dcf9..aa85ac7 100644 (file)
@@ -223,6 +223,23 @@ Shader::~Shader()
   }
 }
 
+std::string Shader::GetShaderVersionPrefix()
+{
+  Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get();
+  return tls.GetShaderVersionPrefix();
+}
+
+std::string Shader::GetVertexShaderPrefix()
+{
+  Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get();
+  return tls.GetVertexShaderPrefix();
+}
+
+std::string Shader::GetFragmentShaderPrefix()
+{
+  Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get();
+  return tls.GetFragmentShaderPrefix();
+}
 
 } // namespace Internal
 } // namespace Dali
index 565e6e4..9476f40 100644 (file)
@@ -106,6 +106,23 @@ private:
 
   Internal::ShaderDataPtr mShaderData;
 
+public:
+
+  /**
+   * @copydoc Dali::Shader::GetShaderVersionPrefix()
+   */
+  static std::string GetShaderVersionPrefix();
+
+  /**
+   * @copydoc Dali::Shader::GetVertexShaderPrefix()
+   */
+  static std::string GetVertexShaderPrefix();
+
+  /**
+   * @copydoc Dali::Shader::GetFragmentShaderPrefix()
+   */
+  static std::string GetFragmentShaderPrefix();
+
 };
 
 } // namespace Internal
index 54d611f..ccf284b 100644 (file)
@@ -217,11 +217,20 @@ bool Texture::ApplyNativeFragmentShader(std::string& shader)
     const char* fragmentPrefix        = mNativeImage->GetCustomFragmentPrefix();
     const char* customSamplerTypename = mNativeImage->GetCustomSamplerTypename();
 
+    size_t prefixIndex = shader.find(Dali::Shader::GetShaderVersionPrefix());
     if(fragmentPrefix != nullptr)
     {
       modified       = true;
-      fragmentShader = fragmentPrefix;
-      fragmentShader += "\n";
+      if(prefixIndex == std::string::npos)
+      {
+        fragmentShader = fragmentPrefix;
+        fragmentShader += "\n";
+      }
+      else
+      {
+        fragmentShader.clear();
+        shader.insert(prefixIndex + Dali::Shader::GetShaderVersionPrefix().length(), std::string(fragmentPrefix) + "\n");
+      }
     }
     fragmentShader += shader;
 
index 89538f0..fe4d2dd 100644 (file)
@@ -408,8 +408,16 @@ public:
    */
   void BlendEquation(GLenum mode)
   {
-    // use BlendEquationSeparate to set the rgb and alpha modes the same
-    BlendEquationSeparate( mode, mode );
+    // DO NOT USE BlendEquationSeparate to set the same rgb and alpha modes
+    // KHR blending extensions require use of glBlendEquation
+
+    if( mBlendEquationSeparateModeRGB != mode || mBlendEquationSeparateModeAlpha != mode )
+    {
+      mBlendEquationSeparateModeRGB = mode;
+      mBlendEquationSeparateModeAlpha = mode;
+      LOG_GL("BlendEquation %d\n", mode);
+      CHECK_GL( mGlAbstraction, mGlAbstraction.BlendEquation( mode ) );
+    }
   }
 
   /**
@@ -1727,7 +1735,7 @@ public:
   }
 
   /**
-   * Wrapper for OpenGL ES 3.0 glUnmapBubffer()
+   * Wrapper for OpenGL ES 3.0 glUnmapBuffer()
    */
   GLboolean UnmapBuffer(GLenum target)
   {
@@ -1735,6 +1743,7 @@ public:
     GLboolean val = CHECK_GL( mGlAbstraction, mGlAbstraction.UnmapBuffer(target) );
     return val;
   }
+
   /**
    * Wrapper for OpenGL ES 2.0 glViewport()
    */
@@ -1756,6 +1765,15 @@ public:
   }
 
   /**
+   * Wrapper for OpenGL ES 3.2 and GL_KHR_blend_equation_advanced extention glBlendBarrier()
+   */
+  void BlendBarrier()
+  {
+    LOG_GL( "BlendBarrier\n" );
+    CHECK_GL( mGlAbstraction, mGlAbstraction.BlendBarrier() );
+  }
+
+  /**
    * Get the implementation defined MAX_TEXTURE_SIZE. This values is cached when the context is created
    * @return The implementation defined MAX_TEXTURE_SIZE
    */
index 2c82094..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.
@@ -201,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;
@@ -649,6 +662,11 @@ void Renderer::Render( Context& context,
       mUpdateAttributesLocation = false;
     }
 
+    if( mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled )
+    {
+      context.BlendBarrier();
+    }
+
     if(mDrawCommands.empty())
     {
       SetBlending( context, blend );
index 760bf79..9adf7de 100644 (file)
@@ -53,4 +53,19 @@ Shader::Shader(Internal::Shader* pointer)
 {
 }
 
+std::string Shader::GetShaderVersionPrefix()
+{
+  return Dali::Internal::Shader::GetShaderVersionPrefix();
+}
+
+std::string Shader::GetVertexShaderPrefix()
+{
+  return Dali::Internal::Shader::GetVertexShaderPrefix();
+}
+
+std::string Shader::GetFragmentShaderPrefix()
+{
+  return Dali::Internal::Shader::GetFragmentShaderPrefix();
+}
+
 } // namespace Dali
index 2535639..f20c707 100644 (file)
@@ -187,6 +187,33 @@ public:
    */
   Shader& operator=(Shader&& rhs);
 
+  /**
+   * @brief Get shader preprocessor of shading language version.
+   * @note This can potentially block until GL has been initialized
+   * when the first time any DALi application is launched in the system.
+   * @SINCE_1_9.36
+   * @return shader preprocessor string.
+   */
+  static std::string GetShaderVersionPrefix();
+
+  /**
+   * @brief Get vertex shader preprocessor that includes shading language version.
+   * @note This can potentially block until GL has been initialized
+   * when the first time any DALi application is launched in the system.
+   * @SINCE_1_9.36
+   * @return Vertex shader preprocessor string.
+   */
+  static std::string GetVertexShaderPrefix();
+
+  /**
+   * @brief Get fragment shader preprocessor that includes shading language version.
+   * @note This can potentially block until GL has been initialized
+   * when the first time any DALi application is launched in the system.
+   * @SINCE_1_9.36
+   * @return Fragment shader preprocessor string.
+   */
+  static std::string GetFragmentShaderPrefix();
+
 public:
   /**
    * @brief This constructor is used by Dali New() methods.