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));
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 */
{
}
+ inline void BlendBarrier(void)
+ {
+ }
+
private:
inline void AddUniformCallToTraceStack(GLint location, std::string& value)
{
#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>
}
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;
+}
#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>
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);
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;
}
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;
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;
}
*
* 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
--- /dev/null
+/*\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
--- /dev/null
+#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
${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
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
*/
// 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);
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
{
/**
* @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
} // 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
*/
#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.
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.
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
};
#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
*------------------------------------------------------------------------*/
/*
- * 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.
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.
* @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.
* @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;
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;
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
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 );
}
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
#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.
// 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>
/**
* @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.
*/
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.
Integration::PartialUpdateAvailable partialUpdateAvailable )
: mRenderController( renderController ),
mPlatform(platform),
+ mGlAbstraction(glAbstraction),
mProcessingEvent(false),
mForceNextUpdate( false )
{
return *(mAnimationPlaylist);
}
+Integration::GlAbstraction& Core::GetGlAbstraction() const
+{
+ return mGlAbstraction;
+}
+
void Core::AddScene( Scene* scene )
{
mScenes.push_back( scene );
*/
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:
/**
// 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.
#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>
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
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 );
}
}
+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
mLayoutDirection( LayoutDirection::LEFT_TO_RIGHT ),
mDrawMode( DrawMode::NORMAL ),
mColorMode( Node::DEFAULT_COLOR_MODE ),
- mClippingMode( ClippingMode::DISABLED )
+ mClippingMode( ClippingMode::DISABLED ),
+ mBlendEquation( DevelBlendEquation::ADD ),
+ mIsBlendEquationSet( false )
{
}
*/
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:
/**
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:
break;
}
+ case Dali::DevelActor::Property::BLEND_EQUATION:
+ {
+ int value;
+ if( property.Get( value ) )
+ {
+ actor.SetBlendEquation( static_cast<DevelBlendEquation::Type>( value ) );
+ }
+ break;
+ }
default:
{
break;
}
+ case Dali::DevelActor::Property::BLEND_EQUATION:
+ {
+ value = actor.GetBlendEquation();
+ break;
+ }
+
default:
{
// Must be a scene-graph only property
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 );
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.
/*
- * 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.
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:
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 )
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();
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() );
}
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() );
}
}
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() );
}
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() );
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();
#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.
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
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
}
}
+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
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
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;
*/
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 ) );
+ }
}
/**
}
/**
- * Wrapper for OpenGL ES 3.0 glUnmapBubffer()
+ * Wrapper for OpenGL ES 3.0 glUnmapBuffer()
*/
GLboolean UnmapBuffer(GLenum target)
{
GLboolean val = CHECK_GL( mGlAbstraction, mGlAbstraction.UnmapBuffer(target) );
return val;
}
+
/**
* Wrapper for OpenGL ES 2.0 glViewport()
*/
}
/**
+ * 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
*/
/*
- * 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.
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;
mUpdateAttributesLocation = false;
}
+ if( mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled )
+ {
+ context.BlendBarrier();
+ }
+
if(mDrawCommands.empty())
{
SetBlending( context, blend );
{
}
+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
*/
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.