Let we make MixColor as Renderer property.
And also, make VisualRenderer's MixColor use Renderer's MixColor property directly.
And also, make we don't register preMultipliedAlpha uniform for whole visual renderer.
Due to the Visual MixColor was Vector3 and Renderer MixColor is Vector4,
we need to make VisualMixColor non-animatable.
TODO : Need to change toolkit side codes.
Change-Id: Ida7b788be00ef7b14bba7d86d937a4581726339d
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
#include <test-actor-utils.h>
#include <test-native-image.h>
-#include <cfloat> // For FLT_MAX
-#include <string>
+#include <cfloat> // For FLT_MAX
#include <functional> // for std::function
+#include <string>
#include "assert.h"
DALI_TEST_CHECK(renderer);
// Make Renderer opacity 0.
- renderer[DevelRenderer::Property::OPACITY] = 0.0f;
+ renderer[Dali::Renderer::Property::OPACITY] = 0.0f;
// Note: Scissor coords are have flipped Y values compared with DALi's coordinate system.
// We choose BOTTOM_LEFT to give us x=0, y=0 starting coordinates for the first test.
// Make an animation
Renderer renderer = actor.GetRendererAt(0);
Animation animation = Animation::New(1.0f);
- animation.AnimateTo(Property(renderer, DevelRenderer::Property::OPACITY), 0.5f, TimePeriod(0.5f, 0.5f));
+ animation.AnimateTo(Property(renderer, Dali::Renderer::Property::OPACITY), 0.5f, TimePeriod(0.5f, 0.5f));
animation.SetLoopCount(3);
animation.Play();
// Make the actor transparent by changing opacity of the Renderer
// It changes a uniform value
- Renderer renderer = actor.GetRendererAt(0);
- renderer[DevelRenderer::Property::OPACITY] = 0.0f;
+ Renderer renderer = actor.GetRendererAt(0);
+ renderer[Dali::Renderer::Property::OPACITY] = 0.0f;
application.SendNotification();
DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
// Make the actor opaque again
- renderer[DevelRenderer::Property::OPACITY] = 1.0f;
+ renderer[Dali::Renderer::Property::OPACITY] = 1.0f;
application.SendNotification();
DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
// Make the actor translucent
- renderer[DevelRenderer::Property::OPACITY] = 0.5f;
+ renderer[Dali::Renderer::Property::OPACITY] = 0.5f;
application.SendNotification();
DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
// Change Renderer opacity - also translucent
- renderer[DevelRenderer::Property::OPACITY] = 0.2f;
+ renderer[Dali::Renderer::Property::OPACITY] = 0.2f;
application.SendNotification();
DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
// Make renderer2 dirty
- renderer2[DevelRenderer::Property::OPACITY] = 0.5f;
+ renderer2[Dali::Renderer::Property::OPACITY] = 0.5f;
application.SendNotification();
DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
// Make renderer dirty
- renderer[DevelRenderer::Property::OPACITY] = 0.5f;
+ renderer[Dali::Renderer::Property::OPACITY] = 0.5f;
application.SendNotification();
tet_infoline("Check the current position value if leaf actor doesn't inherit scale. (Real world usecase error)");
- Actor rootActor = Actor::New();
+ Actor rootActor = Actor::New();
Actor middleActor = Actor::New();
- Actor leafActor = Actor::New();
+ Actor leafActor = Actor::New();
Vector3 rootActorPosition = Vector3(0.0f, 50.0f, 100.0f);
rootActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
rootActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
- Vector3 middleActorPosition = Vector3(100.0f, 0.0f, 0.0f);
- Vector3 middleActorSize = Vector3(200.0f, 400.0f, 0.0f);
+ Vector3 middleActorPosition = Vector3(100.0f, 0.0f, 0.0f);
+ Vector3 middleActorSize = Vector3(200.0f, 400.0f, 0.0f);
middleActor[Actor::Property::POSITION] = middleActorPosition;
middleActor[Actor::Property::SCALE] = Vector3::ONE;
middleActor[Actor::Property::SIZE] = middleActorSize;
middleActor[Actor::Property::ANCHOR_POINT] = AnchorPoint::CENTER;
middleActor[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER;
- Vector3 leafActorPosition = Vector3(0.0f, 100.0f, 0.0f);
+ Vector3 leafActorPosition = Vector3(0.0f, 100.0f, 0.0f);
leafActor[Actor::Property::POSITION] = leafActorPosition;
leafActor[Actor::Property::SCALE] = Vector3::ONE;
leafActor[Actor::Property::SIZE] = Vector2(200, 400);
application.SendNotification();
application.Render(0);
- Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ Matrix actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
Vector3 worldPosition = Vector3(actualMatrix.GetTranslation());
Vector3 actualWorldPosition = rootActorPosition + middleActorPosition - middleActorSize * 0.5 /*ParentOrigin::TOP_LEFT*/ + leafActorPosition;
application.SendNotification();
application.Render(0);
- actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
worldPosition = Vector3(actualMatrix.GetTranslation());
DALI_TEST_EQUALS(actualWorldPosition, worldPosition, 0.001f, TEST_LOCATION);
application.SendNotification();
application.Render(0);
- actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
worldPosition = Vector3(actualMatrix.GetTranslation());
DALI_TEST_EQUALS(actualWorldPosition, worldPosition, 0.001f, TEST_LOCATION);
// Change rootActor's position.
// Test at least 2 frames.
- rootActorPosition = Vector3(-200.0f, -100.0f, 300.0f);
+ rootActorPosition = Vector3(-200.0f, -100.0f, 300.0f);
rootActor[Actor::Property::POSITION] = rootActorPosition;
// Actual world position changed
application.SendNotification();
application.Render(0);
- actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
worldPosition = Vector3(actualMatrix.GetTranslation());
DALI_TEST_EQUALS(actualWorldPosition, worldPosition, 0.001f, TEST_LOCATION);
application.SendNotification();
application.Render(0);
- actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
worldPosition = Vector3(actualMatrix.GetTranslation());
DALI_TEST_EQUALS(actualWorldPosition, worldPosition, 0.001f, TEST_LOCATION);
// Change middleActor's size.
// Test at least 2 frames.
- middleActorSize = Vector3(400.0f, 300.0f, 0.0f);
+ middleActorSize = Vector3(400.0f, 300.0f, 0.0f);
middleActor[Actor::Property::SIZE] = middleActorSize;
// Actual world position changed
application.SendNotification();
application.Render(0);
- actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
worldPosition = Vector3(actualMatrix.GetTranslation());
DALI_TEST_EQUALS(actualWorldPosition, worldPosition, 0.001f, TEST_LOCATION);
application.SendNotification();
application.Render(0);
- actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
worldPosition = Vector3(actualMatrix.GetTranslation());
DALI_TEST_EQUALS(actualWorldPosition, worldPosition, 0.001f, TEST_LOCATION);
application.SendNotification();
application.Render(0);
- actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
worldPosition = Vector3(actualMatrix.GetTranslation());
DALI_TEST_EQUALS(actualWorldPosition, worldPosition, 0.001f, TEST_LOCATION);
application.SendNotification();
application.Render(0);
- actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
+ actualMatrix = leafActor.GetCurrentProperty<Matrix>(Actor::Property::WORLD_MATRIX);
worldPosition = Vector3(actualMatrix.GetTranslation());
DALI_TEST_EQUALS(actualWorldPosition, worldPosition, 0.001f, TEST_LOCATION);
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
VisualRenderer baseVisualRenderer = VisualRenderer::New(geometry, shader);
Renderer baseRenderer = Renderer::New(geometry, shader);
- DALI_TEST_EQUALS(baseRenderer.GetPropertyCount(), 28, TEST_LOCATION);
- DALI_TEST_EQUALS(baseVisualRenderer.GetPropertyCount(), 28 + 8, TEST_LOCATION);
- DALI_TEST_EQUALS(renderer.GetPropertyCount(), 28 + 8 + 6, TEST_LOCATION);
+ DALI_TEST_EQUALS(baseRenderer.GetPropertyCount(), 32, TEST_LOCATION);
+ DALI_TEST_EQUALS(baseVisualRenderer.GetPropertyCount(), 32 + 8, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetPropertyCount(), 32 + 8 + 6, TEST_LOCATION);
TEST_RENDERER_PROPERTY(renderer, "cornerRadius", Property::VECTOR4, true, true, true, DecoratedVisualRenderer::Property::CORNER_RADIUS, TEST_LOCATION);
TEST_RENDERER_PROPERTY(renderer, "cornerRadiusPolicy", Property::FLOAT, true, false, true, DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, TEST_LOCATION);
END_TEST;
}
+namespace
+{
struct DecoratedVisualProperties
{
DecoratedVisualProperties() = default;
progress.mTransformOffset = start.mTransformOffset + (end.mTransformOffset - start.mTransformOffset) * alpha;
progress.mTransformSize = start.mTransformSize + (end.mTransformSize - start.mTransformSize) * alpha;
progress.mExtraSize = start.mExtraSize + (end.mExtraSize - start.mExtraSize) * alpha;
- progress.mMixColor = start.mMixColor + (end.mMixColor - start.mMixColor) * alpha;
progress.mCornerRadius = start.mCornerRadius + (end.mCornerRadius - start.mCornerRadius) * alpha;
progress.mBorderlineWidth = start.mBorderlineWidth + (end.mBorderlineWidth - start.mBorderlineWidth) * alpha;
progress.mBorderlineColor = start.mBorderlineColor + (end.mBorderlineColor - start.mBorderlineColor) * alpha;
progress.mBorderlineOffset = start.mBorderlineOffset + (end.mBorderlineOffset - start.mBorderlineOffset) * alpha;
progress.mBlurRadius = start.mBlurRadius + (end.mBlurRadius - start.mBlurRadius) * alpha;
+ progress.mMixColor = end.mMixColor; ///< mMixColor is not animatable anymore.
progress.mTransformOffsetSizeMode = end.mTransformOffsetSizeMode;
progress.mTransformOrigin = end.mTransformOrigin;
progress.mTransformAnchorPoint = end.mTransformAnchorPoint;
actualProps.mTransformOffsetSizeMode = renderer.GetCurrentProperty<Vector4>(VisualRenderer::Property::TRANSFORM_OFFSET_SIZE_MODE);
actualProps.mExtraSize = renderer.GetCurrentProperty<Vector2>(VisualRenderer::Property::EXTRA_SIZE);
actualProps.mMixColor = renderer.GetCurrentProperty<Vector3>(VisualRenderer::Property::VISUAL_MIX_COLOR);
+ actualProps.mPreMultipliedAlpha = renderer.GetCurrentProperty<float>(VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA);
actualProps.mCornerRadius = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
actualProps.mCornerRadiusPolicy = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY);
tet_infoline("CheckUniforms\n");
TraceCallStack::NamedParams params;
+ uint32_t uniformIndex = 0;
tet_printf("Callback trace: \n%s\n", callStack.GetTraceString().c_str());
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[0].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[0].name.c_str(), props.mTransformOffset));
-
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[1].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[1].name.c_str(), props.mTransformSize));
-
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[2].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[2].name.c_str(), props.mTransformOrigin));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[uniformIndex].name.c_str(), props.mTransformOffset));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[3].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[3].name.c_str(), props.mTransformAnchorPoint));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[uniformIndex].name.c_str(), props.mTransformSize));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[4].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector4>(uniforms[4].name.c_str(), props.mTransformOffsetSizeMode));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[uniformIndex].name.c_str(), props.mTransformOrigin));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[5].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[5].name.c_str(), props.mExtraSize));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[uniformIndex].name.c_str(), props.mTransformAnchorPoint));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[6].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector3>(uniforms[6].name.c_str(), props.mMixColor));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>(uniforms[uniformIndex].name.c_str(), props.mTransformOffsetSizeMode));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[7].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[7].name.c_str(), props.mPreMultipliedAlpha));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[uniformIndex].name.c_str(), props.mExtraSize));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[8].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector4>(uniforms[8].name.c_str(), props.mCornerRadius));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>(uniforms[uniformIndex].name.c_str(), props.mCornerRadius));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[9].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[9].name.c_str(), props.mCornerRadiusPolicy));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[uniformIndex].name.c_str(), props.mCornerRadiusPolicy));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[10].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[10].name.c_str(), props.mBorderlineWidth));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[uniformIndex].name.c_str(), props.mBorderlineWidth));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[11].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector4>(uniforms[11].name.c_str(), props.mBorderlineColor));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>(uniforms[uniformIndex].name.c_str(), props.mBorderlineColor));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[12].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[12].name.c_str(), props.mBorderlineOffset));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[uniformIndex].name.c_str(), props.mBorderlineOffset));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[13].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[13].name.c_str(), props.mBlurRadius));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[uniformIndex].name.c_str(), props.mBlurRadius));
+ ++uniformIndex;
}
+} // namespace
int UtcDaliDecoratedVisualRendererAnimatedProperty03(void)
{
{"anchorPoint", Property::VECTOR2},
{"offsetSizeMode", Property::VECTOR4},
{"extraSize", Property::VECTOR2},
- {"mixColor", Property::VECTOR3},
- {"preMultipliedAlpha", Property::FLOAT},
{"cornerRadius", Property::VECTOR4},
{"cornerRadiusPolicy", Property::FLOAT},
{"borderlineWidth", Property::FLOAT},
animation.AnimateTo(Property(renderer, VisualRenderer::Property::TRANSFORM_OFFSET), targetProps.mTransformOffset);
animation.AnimateTo(Property(renderer, VisualRenderer::Property::TRANSFORM_SIZE), targetProps.mTransformSize);
animation.AnimateTo(Property(renderer, VisualRenderer::Property::EXTRA_SIZE), targetProps.mExtraSize);
- animation.AnimateTo(Property(renderer, VisualRenderer::Property::VISUAL_MIX_COLOR), targetProps.mMixColor);
+ renderer.SetProperty(VisualRenderer::Property::VISUAL_MIX_COLOR, targetProps.mMixColor); ///< visual mix color is not animatable.
animation.AnimateTo(Property(renderer, DecoratedVisualRenderer::Property::CORNER_RADIUS), targetProps.mCornerRadius);
animation.AnimateTo(Property(renderer, DecoratedVisualRenderer::Property::BORDERLINE_WIDTH), targetProps.mBorderlineWidth);
{
TestApplication application;
/* from renderer-impl.cpp
- DALI_PROPERTY( "depthIndex", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX )
- DALI_PROPERTY( "faceCullingMode", INTEGER, true, false, false, Dali::Renderer::Property::FACE_CULLING_MODE )
- DALI_PROPERTY( "blendMode", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_MODE )
- DALI_PROPERTY( "blendEquationRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_RGB )
- DALI_PROPERTY( "blendEquationAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_ALPHA )
- DALI_PROPERTY( "blendFactorSrcRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB )
- DALI_PROPERTY( "blendFactorDestRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB )
- DALI_PROPERTY( "blendFactorSrcAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA )
- DALI_PROPERTY( "blendFactorDestAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA )
- DALI_PROPERTY( "blendColor", VECTOR4, true, false, false, Dali::Renderer::Property::BLEND_COLOR )
- DALI_PROPERTY( "blendPreMultipliedAlpha", BOOLEAN, true, false, false, Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA )
- DALI_PROPERTY( "indexRangeFirst", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_FIRST )
- DALI_PROPERTY( "indexRangeCount", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_COUNT )
- DALI_PROPERTY( "depthWriteMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_WRITE_MODE )
- DALI_PROPERTY( "depthFunction", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_FUNCTION )
- DALI_PROPERTY( "depthTestMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_TEST_MODE )
- DALI_PROPERTY( "renderMode", INTEGER, true, false, false, Dali::Renderer::Property::RENDER_MODE )
- DALI_PROPERTY( "stencilFunction", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION )
- DALI_PROPERTY( "stencilFunctionMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_MASK )
- DALI_PROPERTY( "stencilFunctionReference", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE )
- DALI_PROPERTY( "stencilMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_MASK )
- DALI_PROPERTY( "stencilOperationOnFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL )
- DALI_PROPERTY( "stencilOperationOnZFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL )
- 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("depthIndex", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX)
+ DALI_PROPERTY("faceCullingMode", INTEGER, true, false, false, Dali::Renderer::Property::FACE_CULLING_MODE)
+ DALI_PROPERTY("blendMode", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_MODE)
+ DALI_PROPERTY("blendEquationRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_RGB)
+ DALI_PROPERTY("blendEquationAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_ALPHA)
+ DALI_PROPERTY("blendFactorSrcRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB)
+ DALI_PROPERTY("blendFactorDestRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB)
+ DALI_PROPERTY("blendFactorSrcAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA)
+ DALI_PROPERTY("blendFactorDestAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA)
+ DALI_PROPERTY("blendColor", VECTOR4, true, false, false, Dali::Renderer::Property::BLEND_COLOR)
+ DALI_PROPERTY("blendPreMultipliedAlpha", BOOLEAN, true, false, false, Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA)
+ DALI_PROPERTY("indexRangeFirst", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_FIRST)
+ DALI_PROPERTY("indexRangeCount", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_COUNT)
+ DALI_PROPERTY("depthWriteMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_WRITE_MODE)
+ DALI_PROPERTY("depthFunction", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_FUNCTION)
+ DALI_PROPERTY("depthTestMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_TEST_MODE)
+ DALI_PROPERTY("renderMode", INTEGER, true, false, false, Dali::Renderer::Property::RENDER_MODE)
+ DALI_PROPERTY("stencilFunction", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION)
+ DALI_PROPERTY("stencilFunctionMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_MASK)
+ DALI_PROPERTY("stencilFunctionReference", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE)
+ DALI_PROPERTY("stencilMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_MASK)
+ DALI_PROPERTY("stencilOperationOnFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL)
+ DALI_PROPERTY("stencilOperationOnZFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL)
+ DALI_PROPERTY("stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS)
+ DALI_PROPERTY("rendererMixColor", VECTOR4, true, true, true, Dali::Renderer::Property::MIX_COLOR)
+ DALI_PROPERTY("rendererMixColorRed", FLOAT, true, true, true, Dali::Renderer::Property::MIX_COLOR_RED)
+ DALI_PROPERTY("rendererMixColorGreen", FLOAT, true, true, true, Dali::Renderer::Property::MIX_COLOR_GREEN)
+ DALI_PROPERTY("rendererMixColorBlue", FLOAT, true, true, true, Dali::Renderer::Property::MIX_COLOR_BLUE)
+ DALI_PROPERTY("rendererOpacity", FLOAT, true, true, true, Dali::Renderer::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("instanceCount", INTEGER, true, false, false, Dali::DevelRenderer::Property::INSTANCE_COUNT)
*/
Geometry geometry = CreateQuadGeometry();
Shader shader = CreateShader();
Renderer renderer = Renderer::New(geometry, shader);
- DALI_TEST_EQUALS(renderer.GetPropertyCount(), 28, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetPropertyCount(), 32, 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, "stencilOperationOnFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_FAIL, TEST_LOCATION);
TEST_RENDERER_PROPERTY(renderer, "stencilOperationOnZFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, 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, "rendererMixColor", Property::VECTOR4, true, true, true, Renderer::Property::MIX_COLOR, TEST_LOCATION);
+ TEST_RENDERER_PROPERTY(renderer, "rendererMixColorRed", Property::FLOAT, true, true, true, Renderer::Property::MIX_COLOR_RED, TEST_LOCATION);
+ TEST_RENDERER_PROPERTY(renderer, "rendererMixColorGreen", Property::FLOAT, true, true, true, Renderer::Property::MIX_COLOR_GREEN, TEST_LOCATION);
+ TEST_RENDERER_PROPERTY(renderer, "rendererMixColorBlue", Property::FLOAT, true, true, true, Renderer::Property::MIX_COLOR_BLUE, TEST_LOCATION);
+ TEST_RENDERER_PROPERTY(renderer, "rendererOpacity", Property::FLOAT, true, true, true, Renderer::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);
- TEST_RENDERER_PROPERTY(renderer, "instanceCount", Property::INTEGER, true, false, false, Dali::DevelRenderer::Property::INSTANCE_COUNT, TEST_LOCATION);
+ TEST_RENDERER_PROPERTY(renderer, "instanceCount", Property::INTEGER, true, false, false, DevelRenderer::Property::INSTANCE_COUNT, TEST_LOCATION);
END_TEST;
}
actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
application.GetScene().Add(actor);
- Property::Value value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
+ Property::Value value = renderer.GetProperty(Dali::Renderer::Property::OPACITY);
float opacity;
DALI_TEST_CHECK(value.Get(opacity));
DALI_TEST_EQUALS(opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uActorColor", actualActorColor));
DALI_TEST_EQUALS(actualActorColor.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
- renderer.SetProperty(DevelRenderer::Property::OPACITY, 0.5f);
+ renderer.SetProperty(Dali::Renderer::Property::OPACITY, 0.5f);
application.SendNotification();
application.Render();
- value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
+ value = renderer.GetProperty(Dali::Renderer::Property::OPACITY);
DALI_TEST_CHECK(value.Get(opacity));
DALI_TEST_EQUALS(opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
- value = renderer.GetCurrentProperty(DevelRenderer::Property::OPACITY);
+ value = renderer.GetCurrentProperty(Dali::Renderer::Property::OPACITY);
DALI_TEST_CHECK(value.Get(opacity));
DALI_TEST_EQUALS(opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
application.SendNotification();
application.Render(0);
- Property::Value value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
+ Property::Value value = renderer.GetProperty(Dali::Renderer::Property::OPACITY);
float opacity;
DALI_TEST_CHECK(value.Get(opacity));
DALI_TEST_EQUALS(opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
Animation animation = Animation::New(1.0f);
- animation.AnimateTo(Property(renderer, DevelRenderer::Property::OPACITY), 0.0f);
+ animation.AnimateTo(Property(renderer, Dali::Renderer::Property::OPACITY), 0.0f);
animation.Play();
application.SendNotification();
application.Render(1000);
- value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
+ value = renderer.GetProperty(Dali::Renderer::Property::OPACITY);
DALI_TEST_CHECK(value.Get(opacity));
DALI_TEST_EQUALS(opacity, 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
// Need to clear the animation before setting the property as the animation value is baked and will override any previous setters
animation.Clear();
- renderer.SetProperty(DevelRenderer::Property::OPACITY, 0.1f);
+ renderer.SetProperty(Dali::Renderer::Property::OPACITY, 0.1f);
- animation.AnimateBy(Property(renderer, DevelRenderer::Property::OPACITY), 0.5f);
+ animation.AnimateBy(Property(renderer, Dali::Renderer::Property::OPACITY), 0.5f);
animation.Play();
application.SendNotification();
application.Render(1000);
- value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
+ value = renderer.GetProperty(Dali::Renderer::Property::OPACITY);
DALI_TEST_CHECK(value.Get(opacity));
DALI_TEST_EQUALS(opacity, 0.6f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
- DALI_TEST_EQUALS(opacity, renderer.GetCurrentProperty(DevelRenderer::Property::OPACITY).Get<float>(), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(opacity, renderer.GetCurrentProperty(Dali::Renderer::Property::OPACITY).Get<float>(), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliRendererMixColor(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test MIX_COLOR property");
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New("vertexSrc", "fragmentSrc");
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ Vector4 actorColor(0.8f, 0.5f, 0.7f, 1.0f);
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
+ actor.SetProperty(Actor::Property::COLOR, actorColor);
+ application.GetScene().Add(actor);
+
+ Property::Value value;
+ Vector4 mixColor;
+ float mixColorRed;
+ float mixColorGreen;
+ float mixColorBlue;
+ float opacity;
+
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR);
+ DALI_TEST_CHECK(value.Get(mixColor));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_RED);
+ DALI_TEST_CHECK(value.Get(mixColorRed));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_GREEN);
+ DALI_TEST_CHECK(value.Get(mixColorGreen));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_BLUE);
+ DALI_TEST_CHECK(value.Get(mixColorBlue));
+ value = renderer.GetProperty(Dali::Renderer::Property::OPACITY);
+ DALI_TEST_CHECK(value.Get(opacity));
+ DALI_TEST_EQUALS(mixColor, Vector4::ONE, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorRed, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorGreen, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorBlue, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ Vector4 actualValue;
+ Vector4 actualActorColor;
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
+ DALI_TEST_EQUALS(actualValue, Vector4::ONE * actorColor, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uActorColor", actualActorColor));
+ DALI_TEST_EQUALS(actualActorColor, Vector4::ONE * actorColor, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ Vector4 targetValue(0.2, 0.3f, 0.4f, 0.5f);
+ renderer.SetProperty(Dali::Renderer::Property::MIX_COLOR, targetValue);
+
+ application.SendNotification();
+ application.Render();
+
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR);
+ DALI_TEST_CHECK(value.Get(mixColor));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_RED);
+ DALI_TEST_CHECK(value.Get(mixColorRed));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_GREEN);
+ DALI_TEST_CHECK(value.Get(mixColorGreen));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_BLUE);
+ DALI_TEST_CHECK(value.Get(mixColorBlue));
+ value = renderer.GetProperty(Dali::Renderer::Property::OPACITY);
+ DALI_TEST_CHECK(value.Get(opacity));
+ DALI_TEST_EQUALS(mixColor, targetValue, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorRed, targetValue.r, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorGreen, targetValue.g, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorBlue, targetValue.b, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(opacity, targetValue.a, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
+ DALI_TEST_EQUALS(actualValue, targetValue * actorColor, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(actualValue.r, targetValue.r * actorColor.r, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(actualValue.g, targetValue.g * actorColor.g, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(actualValue.b, targetValue.b * actorColor.b, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(actualValue.a, targetValue.a * actorColor.a, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ // Note : Renderer opacity doesn't apply to uActorColor.
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uActorColor", actualActorColor));
+ DALI_TEST_EQUALS(actualActorColor, Vector4::ONE * actorColor, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliRendererMixColorAnimation01(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test MIX_COLOR property animation");
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New("vertexSrc", "fragmentSrc");
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ Vector4 actorColor(0.8f, 0.5f, 0.7f, 1.0f);
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
+ actor.SetProperty(Actor::Property::COLOR, actorColor);
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ application.Render(0);
+
+ Property::Value value;
+ Vector4 mixColor;
+ float mixColorRed;
+ float mixColorGreen;
+ float mixColorBlue;
+ float opacity;
+
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR);
+ DALI_TEST_CHECK(value.Get(mixColor));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_RED);
+ DALI_TEST_CHECK(value.Get(mixColorRed));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_GREEN);
+ DALI_TEST_CHECK(value.Get(mixColorGreen));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_BLUE);
+ DALI_TEST_CHECK(value.Get(mixColorBlue));
+ value = renderer.GetProperty(Dali::Renderer::Property::OPACITY);
+ DALI_TEST_CHECK(value.Get(opacity));
+ DALI_TEST_EQUALS(mixColor, Vector4::ONE, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorRed, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorGreen, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorBlue, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ Vector4 targetValue(0.2, 0.3f, 0.4f, 0.5f);
+ Animation animation = Animation::New(1.0f);
+ animation.AnimateTo(Property(renderer, Dali::Renderer::Property::MIX_COLOR), targetValue);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(1000);
+
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR);
+ DALI_TEST_CHECK(value.Get(mixColor));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_RED);
+ DALI_TEST_CHECK(value.Get(mixColorRed));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_GREEN);
+ DALI_TEST_CHECK(value.Get(mixColorGreen));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_BLUE);
+ DALI_TEST_CHECK(value.Get(mixColorBlue));
+ value = renderer.GetProperty(Dali::Renderer::Property::OPACITY);
+ DALI_TEST_CHECK(value.Get(opacity));
+ DALI_TEST_EQUALS(mixColor, targetValue, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorRed, targetValue.r, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorGreen, targetValue.g, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorBlue, targetValue.b, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(opacity, targetValue.a, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ // Need to clear the animation before setting the property as the animation value is baked and will override any previous setters
+ animation.Clear();
+ Vector4 originValue(0.1f, 0.1f, 0.1f, 0.1f);
+ renderer.SetProperty(Dali::Renderer::Property::MIX_COLOR, originValue);
+
+ animation.AnimateBy(Property(renderer, Dali::Renderer::Property::MIX_COLOR), targetValue - originValue);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(1000);
+
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR);
+ DALI_TEST_CHECK(value.Get(mixColor));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_RED);
+ DALI_TEST_CHECK(value.Get(mixColorRed));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_GREEN);
+ DALI_TEST_CHECK(value.Get(mixColorGreen));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_BLUE);
+ DALI_TEST_CHECK(value.Get(mixColorBlue));
+ value = renderer.GetProperty(Dali::Renderer::Property::OPACITY);
+ DALI_TEST_CHECK(value.Get(opacity));
+ DALI_TEST_EQUALS(mixColor, targetValue, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorRed, targetValue.r, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorGreen, targetValue.g, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorBlue, targetValue.b, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(opacity, targetValue.a, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(renderer.GetCurrentProperty(Dali::Renderer::Property::MIX_COLOR).Get<Vector4>(), targetValue, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetCurrentProperty(Dali::Renderer::Property::MIX_COLOR_RED).Get<float>(), targetValue.r, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetCurrentProperty(Dali::Renderer::Property::MIX_COLOR_GREEN).Get<float>(), targetValue.g, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetCurrentProperty(Dali::Renderer::Property::MIX_COLOR_BLUE).Get<float>(), targetValue.b, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetCurrentProperty(Dali::Renderer::Property::OPACITY).Get<float>(), targetValue.a, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliRendererMixColorAnimation02(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test MIX_COLOR_RED, MIX_COLOR_GREEN, MIX_COLOR_BLUE, OPACITY property animation");
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New("vertexSrc", "fragmentSrc");
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ Vector4 actorColor(0.8f, 0.5f, 0.7f, 1.0f);
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
+ actor.SetProperty(Actor::Property::COLOR, actorColor);
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ application.Render(0);
+
+ Property::Value value;
+ Vector4 mixColor;
+ float mixColorRed;
+ float mixColorGreen;
+ float mixColorBlue;
+ float opacity;
+
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR);
+ DALI_TEST_CHECK(value.Get(mixColor));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_RED);
+ DALI_TEST_CHECK(value.Get(mixColorRed));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_GREEN);
+ DALI_TEST_CHECK(value.Get(mixColorGreen));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_BLUE);
+ DALI_TEST_CHECK(value.Get(mixColorBlue));
+ value = renderer.GetProperty(Dali::Renderer::Property::OPACITY);
+ DALI_TEST_CHECK(value.Get(opacity));
+ DALI_TEST_EQUALS(mixColor, Vector4::ONE, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorRed, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorGreen, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorBlue, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ Vector4 targetValue(0.2, 0.3f, 0.4f, 0.5f);
+ Animation animation = Animation::New(1.0f);
+ animation.AnimateTo(Property(renderer, Dali::Renderer::Property::MIX_COLOR_RED), targetValue.r);
+ animation.AnimateTo(Property(renderer, Dali::Renderer::Property::MIX_COLOR_GREEN), targetValue.g);
+ animation.AnimateTo(Property(renderer, Dali::Renderer::Property::MIX_COLOR_BLUE), targetValue.b);
+ animation.AnimateTo(Property(renderer, Dali::Renderer::Property::OPACITY), targetValue.a);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(1000);
+
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR);
+ DALI_TEST_CHECK(value.Get(mixColor));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_RED);
+ DALI_TEST_CHECK(value.Get(mixColorRed));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_GREEN);
+ DALI_TEST_CHECK(value.Get(mixColorGreen));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_BLUE);
+ DALI_TEST_CHECK(value.Get(mixColorBlue));
+ value = renderer.GetProperty(Dali::Renderer::Property::OPACITY);
+ DALI_TEST_CHECK(value.Get(opacity));
+ DALI_TEST_EQUALS(mixColor, targetValue, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorRed, targetValue.r, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorGreen, targetValue.g, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorBlue, targetValue.b, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(opacity, targetValue.a, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ // Need to clear the animation before setting the property as the animation value is baked and will override any previous setters
+ animation.Clear();
+ Vector4 originValue(0.1f, 0.1f, 0.1f, 0.1f);
+ renderer.SetProperty(Dali::Renderer::Property::MIX_COLOR_RED, originValue.r);
+ renderer.SetProperty(Dali::Renderer::Property::MIX_COLOR_GREEN, originValue.g);
+ renderer.SetProperty(Dali::Renderer::Property::MIX_COLOR_BLUE, originValue.b);
+ renderer.SetProperty(Dali::Renderer::Property::OPACITY, originValue.a);
+
+ animation.AnimateBy(Property(renderer, Dali::Renderer::Property::MIX_COLOR_RED), targetValue.r - originValue.r);
+ animation.AnimateBy(Property(renderer, Dali::Renderer::Property::MIX_COLOR_GREEN), targetValue.g - originValue.g);
+ animation.AnimateBy(Property(renderer, Dali::Renderer::Property::MIX_COLOR_BLUE), targetValue.b - originValue.b);
+ animation.AnimateBy(Property(renderer, Dali::Renderer::Property::OPACITY), targetValue.a - originValue.a);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(1000);
+
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR);
+ DALI_TEST_CHECK(value.Get(mixColor));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_RED);
+ DALI_TEST_CHECK(value.Get(mixColorRed));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_GREEN);
+ DALI_TEST_CHECK(value.Get(mixColorGreen));
+ value = renderer.GetProperty(Dali::Renderer::Property::MIX_COLOR_BLUE);
+ DALI_TEST_CHECK(value.Get(mixColorBlue));
+ value = renderer.GetProperty(Dali::Renderer::Property::OPACITY);
+ DALI_TEST_CHECK(value.Get(opacity));
+ DALI_TEST_EQUALS(mixColor, targetValue, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorRed, targetValue.r, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorGreen, targetValue.g, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(mixColorBlue, targetValue.b, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(opacity, targetValue.a, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(renderer.GetCurrentProperty(Dali::Renderer::Property::MIX_COLOR).Get<Vector4>(), targetValue, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetCurrentProperty(Dali::Renderer::Property::MIX_COLOR_RED).Get<float>(), targetValue.r, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetCurrentProperty(Dali::Renderer::Property::MIX_COLOR_GREEN).Get<float>(), targetValue.g, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetCurrentProperty(Dali::Renderer::Property::MIX_COLOR_BLUE).Get<float>(), targetValue.b, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetCurrentProperty(Dali::Renderer::Property::OPACITY).Get<float>(), targetValue.a, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
END_TEST;
}
{
// Render again and check the update status
Animation animation = Animation::New(1.0f);
- animation.AnimateTo(Property(renderer, DevelRenderer::Property::OPACITY), 0.0f, TimePeriod(0.5f, 0.5f));
+ animation.AnimateTo(Property(renderer, Dali::Renderer::Property::OPACITY), 0.0f, TimePeriod(0.5f, 0.5f));
animation.Play();
drawTrace.Reset();
application.RenderWithPartialUpdate(damagedRects, clippingRect);
// 3. Change a property value of the Renderer
- renderer.SetProperty(DevelRenderer::Property::OPACITY, 0.5f);
+ renderer.SetProperty(Dali::Renderer::Property::MIX_COLOR, Vector4(0.5f, 0.5f, 0.5f, 0.5f));
application.SendNotification();
damagedRects.clear();
VisualRenderer renderer = VisualRenderer::New(geometry, shader);
Renderer baseRenderer = Renderer::New(geometry, shader);
- DALI_TEST_EQUALS(baseRenderer.GetPropertyCount(), 28, TEST_LOCATION);
- DALI_TEST_EQUALS(renderer.GetPropertyCount(), 28 + 8, TEST_LOCATION);
+ DALI_TEST_EQUALS(baseRenderer.GetPropertyCount(), 32, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetPropertyCount(), 32 + 8, TEST_LOCATION);
TEST_RENDERER_PROPERTY(renderer, "transformOffset", Property::VECTOR2, true, true, true, VisualRenderer::Property::TRANSFORM_OFFSET, TEST_LOCATION);
TEST_RENDERER_PROPERTY(renderer, "transformSize", Property::VECTOR2, true, true, true, VisualRenderer::Property::TRANSFORM_SIZE, TEST_LOCATION);
TEST_RENDERER_PROPERTY(renderer, "transformAnchorPoint", Property::VECTOR2, true, false, false, VisualRenderer::Property::TRANSFORM_ANCHOR_POINT, TEST_LOCATION);
TEST_RENDERER_PROPERTY(renderer, "transformOffsetSizeMode", Property::VECTOR4, true, false, false, VisualRenderer::Property::TRANSFORM_OFFSET_SIZE_MODE, TEST_LOCATION);
TEST_RENDERER_PROPERTY(renderer, "extraSize", Property::VECTOR2, true, true, true, VisualRenderer::Property::EXTRA_SIZE, TEST_LOCATION);
-
- TEST_RENDERER_PROPERTY(renderer, "visualMixColor", Property::VECTOR3, true, true, true, VisualRenderer::Property::VISUAL_MIX_COLOR, TEST_LOCATION);
- TEST_RENDERER_PROPERTY(renderer, "preMultipliedAlpha", Property::FLOAT, true, false, false, VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA, TEST_LOCATION);
+ TEST_RENDERER_PROPERTY(renderer, "visualMixColor", Property::VECTOR3, true, false, true, VisualRenderer::Property::VISUAL_MIX_COLOR, TEST_LOCATION);
+ TEST_RENDERER_PROPERTY(renderer, "visualPreMultipliedAlpha", Property::FLOAT, true, false, false, VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA, TEST_LOCATION);
END_TEST;
}
{
TestApplication application;
- tet_infoline("Test that a visual renderer property can be animated");
+ tet_infoline("Test that a visual renderer property cannot be animated anymore");
Shader shader = Shader::New("VertexSource", "FragmentSource");
Geometry geometry = CreateQuadGeometry();
KeyFrames keyFrames = KeyFrames::New();
keyFrames.Add(0.0f, Vector3(1.0f, 0.0f, 1.0f));
keyFrames.Add(1.0f, Vector3(0.0f, 0.0f, 0.0f));
- animation.AnimateBetween(Property(renderer, colorIndex), keyFrames);
- animation.Play();
-
- application.SendNotification();
- application.Render(500);
-
- DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector3>(colorIndex), Vector3(0.5f, 0.f, 0.5f), TEST_LOCATION);
-
- application.Render(400);
- DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector3>(colorIndex), Vector3(0.1f, 0.f, 0.1f), TEST_LOCATION);
-
- application.Render(100);
- DALI_TEST_EQUALS(renderer.GetCurrentProperty<Vector3>(colorIndex), Vector3(0.f, 0.f, 0.f), TEST_LOCATION);
- DALI_TEST_EQUALS(renderer.GetProperty<Vector3>(colorIndex), Vector3(0.f, 0.f, 0.f), TEST_LOCATION);
+ try
+ {
+ animation.AnimateBetween(Property(renderer, colorIndex), keyFrames);
+ animation.Play();
+ tet_result(TET_FAIL);
+ }
+ catch(...)
+ {
+ tet_result(TET_PASS);
+ }
// Can we test to see if the actor has stopped being drawn?
END_TEST;
END_TEST;
}
+namespace
+{
struct VisualProperties
{
VisualProperties() = default;
static VisualProperties GetPropsAt(float alpha, const VisualProperties& start, const VisualProperties& end)
{
VisualProperties progress;
- progress.mTransformOffset = start.mTransformOffset + (end.mTransformOffset - start.mTransformOffset) * alpha;
- progress.mTransformSize = start.mTransformSize + (end.mTransformSize - start.mTransformSize) * alpha;
- progress.mExtraSize = start.mExtraSize + (end.mExtraSize - start.mExtraSize) * alpha;
- progress.mMixColor = start.mMixColor + (end.mMixColor - start.mMixColor) * alpha;
+
+ progress.mTransformOffset = start.mTransformOffset + (end.mTransformOffset - start.mTransformOffset) * alpha;
+ progress.mTransformSize = start.mTransformSize + (end.mTransformSize - start.mTransformSize) * alpha;
+ progress.mExtraSize = start.mExtraSize + (end.mExtraSize - start.mExtraSize) * alpha;
+
+ progress.mMixColor = end.mMixColor; ///< mMixColor is not animatable anymore.
progress.mTransformOffsetSizeMode = end.mTransformOffsetSizeMode;
progress.mTransformOrigin = end.mTransformOrigin;
progress.mTransformAnchorPoint = end.mTransformAnchorPoint;
actualProps.mTransformOffsetSizeMode = renderer.GetCurrentProperty<Vector4>(VisualRenderer::Property::TRANSFORM_OFFSET_SIZE_MODE);
actualProps.mExtraSize = renderer.GetCurrentProperty<Vector2>(VisualRenderer::Property::EXTRA_SIZE);
actualProps.mMixColor = renderer.GetCurrentProperty<Vector3>(VisualRenderer::Property::VISUAL_MIX_COLOR);
- actualProps.mPreMultipliedAlpha = renderer.GetProperty<float>(VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA);
+ actualProps.mPreMultipliedAlpha = renderer.GetCurrentProperty<float>(VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA);
PrintVisualProperties(actualProps, "Actual update props");
tet_infoline("CheckUniforms\n");
TraceCallStack::NamedParams params;
+ uint32_t uniformIndex = 0;
tet_printf("Callback trace: \n%s\n", callStack.GetTraceString().c_str());
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[0].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[0].name.c_str(), props.mTransformOffset));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[uniformIndex].name.c_str(), props.mTransformOffset));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[1].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[1].name.c_str(), props.mTransformSize));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[uniformIndex].name.c_str(), props.mTransformSize));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[2].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[2].name.c_str(), props.mTransformOrigin));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[uniformIndex].name.c_str(), props.mTransformOrigin));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[3].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[3].name.c_str(), props.mTransformAnchorPoint));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[uniformIndex].name.c_str(), props.mTransformAnchorPoint));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[4].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector4>(uniforms[4].name.c_str(), props.mTransformOffsetSizeMode));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>(uniforms[uniformIndex].name.c_str(), props.mTransformOffsetSizeMode));
+ ++uniformIndex;
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[5].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[5].name.c_str(), props.mExtraSize));
-
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[6].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<Vector3>(uniforms[6].name.c_str(), props.mMixColor));
-
- DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[7].name, params));
- DALI_TEST_CHECK(gl.GetUniformValue<float>(uniforms[7].name.c_str(), props.mPreMultipliedAlpha));
+ DALI_TEST_CHECK(callStack.FindMethodAndGetParameters(uniforms[uniformIndex].name, params));
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector2>(uniforms[uniformIndex].name.c_str(), props.mExtraSize));
+ ++uniformIndex;
}
+} // namespace
+
int UtcDaliVisualRendererAnimatedProperty03(void)
{
TestApplication application;
{"origin", Property::VECTOR2},
{"anchorPoint", Property::VECTOR2},
{"offsetSizeMode", Property::VECTOR4},
- {"extraSize", Property::VECTOR2},
- {"mixColor", Property::VECTOR3},
- {"preMultipliedAlpha", Property::FLOAT}};
+ {"extraSize", Property::VECTOR2}};
application.GetGraphicsController().AddCustomUniforms(customUniforms);
animation.AnimateTo(Property(renderer, VisualRenderer::Property::TRANSFORM_OFFSET), targetProps.mTransformOffset);
animation.AnimateTo(Property(renderer, VisualRenderer::Property::TRANSFORM_SIZE), targetProps.mTransformSize);
animation.AnimateTo(Property(renderer, VisualRenderer::Property::EXTRA_SIZE), targetProps.mExtraSize);
- animation.AnimateTo(Property(renderer, VisualRenderer::Property::VISUAL_MIX_COLOR), targetProps.mMixColor);
+ renderer.SetProperty(VisualRenderer::Property::VISUAL_MIX_COLOR, targetProps.mMixColor); ///< visual mix color is not animatable.
animation.Play();
CheckEventVisualProperties(renderer, targetProps);
actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
application.GetScene().Add(actor);
- Property::Index index = DevelRenderer::Property::OPACITY;
+ Property::Index index = Dali::Renderer::Property::OPACITY;
renderer.SetProperty(index, 1.0f);
application.SendNotification();
application.Render(0);
DALI_TEST_EQUALS(renderer.GetProperty<float>(index), 1.0f, 0.001f, TEST_LOCATION);
- DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(DevelRenderer::Property::OPACITY), 1.0f, 0.0001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(Dali::Renderer::Property::OPACITY), 1.0f, 0.0001f, TEST_LOCATION);
Animation animation = Animation::New(1.0f);
KeyFrames keyFrames = KeyFrames::New();
application.SendNotification();
// Test that the event side properties are set to target value of 0
- DALI_TEST_EQUALS(renderer.GetProperty<float>(DevelRenderer::Property::OPACITY), 0.0f, 0.0001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetProperty<float>(Dali::Renderer::Property::OPACITY), 0.0f, 0.0001f, TEST_LOCATION);
application.Render(500);
DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(index), 0.25f, 0.0001f, TEST_LOCATION);
- DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(DevelRenderer::Property::OPACITY), 0.25f, 0.0001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(Dali::Renderer::Property::OPACITY), 0.25f, 0.0001f, TEST_LOCATION);
// Test that the event side properties are set to target value 0f 0
- DALI_TEST_EQUALS(renderer.GetProperty<float>(DevelRenderer::Property::OPACITY), 0.0f, 0.0001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetProperty<float>(Dali::Renderer::Property::OPACITY), 0.0f, 0.0001f, TEST_LOCATION);
// Complete the animation
application.Render(500);
DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(index), 0.0f, 0.0001f, TEST_LOCATION);
- DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(DevelRenderer::Property::OPACITY), 0.0f, 0.0001f, TEST_LOCATION);
- DALI_TEST_EQUALS(renderer.GetProperty<float>(DevelRenderer::Property::OPACITY), 0.0f, 0.0001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetCurrentProperty<float>(Dali::Renderer::Property::OPACITY), 0.0f, 0.0001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer.GetProperty<float>(Dali::Renderer::Property::OPACITY), 0.0f, 0.0001f, TEST_LOCATION);
END_TEST;
}
#define DALI_RENDERER_DEVEL_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
STENCIL_OPERATION_ON_FAIL = Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL,
STENCIL_OPERATION_ON_Z_FAIL = Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL,
STENCIL_OPERATION_ON_Z_PASS = Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS,
-
- /**
- * @brief The opacity of the renderer.
- * @details Name "opacity", type Property::FLOAT.
- */
- OPACITY = STENCIL_OPERATION_ON_Z_PASS + 1,
+ MIX_COLOR = Dali::Renderer::Property::MIX_COLOR,
+ MIX_COLOR_RED = Dali::Renderer::Property::MIX_COLOR_RED,
+ MIX_COLOR_GREEN = Dali::Renderer::Property::MIX_COLOR_GREEN,
+ MIX_COLOR_BLUE = Dali::Renderer::Property::MIX_COLOR_BLUE,
+ OPACITY = Dali::Renderer::Property::OPACITY,
/**
* @brief The rendering behavior of the renderer.
* @details Name "renderingBehavior", type Property::INTEGER.
*/
- RENDERING_BEHAVIOR = STENCIL_OPERATION_ON_Z_PASS + 2,
+ RENDERING_BEHAVIOR = OPACITY + 1,
/**
* @brief name "blendEquation", type INTEGER
* @note The default value is BlendEquation::ADD
*/
- BLEND_EQUATION = STENCIL_OPERATION_ON_Z_PASS + 3,
+ BLEND_EQUATION = OPACITY + 2,
/**
* @brief Which vertex to render first from a vertex buffer without indices
* @note Overrides computed instance count on vertex buffer.
* @details name "instanceCount", type INTEGER
*/
- INSTANCE_COUNT = STENCIL_OPERATION_ON_Z_PASS + 4,
+ INSTANCE_COUNT = OPACITY + 3,
};
} // namespace Property
DALI_PROPERTY("stencilOperationOnFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL)
DALI_PROPERTY("stencilOperationOnZFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL)
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("rendererMixColor", VECTOR4, true, true, true, Dali::Renderer::Property::MIX_COLOR)
+DALI_PROPERTY("rendererMixColorRed", FLOAT, true, true, true, Dali::Renderer::Property::MIX_COLOR_RED)
+DALI_PROPERTY("rendererMixColorGreen", FLOAT, true, true, true, Dali::Renderer::Property::MIX_COLOR_GREEN)
+DALI_PROPERTY("rendererMixColorBlue", FLOAT, true, true, true, Dali::Renderer::Property::MIX_COLOR_BLUE)
+DALI_PROPERTY("rendererOpacity", FLOAT, true, true, true, Dali::Renderer::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("instanceCount", INTEGER, true, false, false, Dali::DevelRenderer::Property::INSTANCE_COUNT)
}
break;
}
- case Dali::DevelRenderer::Property::OPACITY:
+ case Dali::Renderer::Property::MIX_COLOR:
{
- float opacity;
- if(propertyValue.Get(opacity))
+ Vector4 mixColor;
+ if(propertyValue.Get(mixColor))
{
- if(!Equals(mOpacity, opacity))
+ if(mMixColor != mixColor)
{
- mOpacity = opacity;
+ mMixColor = mixColor;
auto sceneObject = const_cast<SceneGraph::Renderer*>(&GetRendererSceneObject());
- SceneGraph::BakeOpacityMessage(GetEventThreadServices(), *sceneObject, mOpacity);
+ SceneGraph::BakeMixColorMessage(GetEventThreadServices(), *sceneObject, mMixColor);
+ }
+ }
+ break;
+ }
+ case Dali::Renderer::Property::MIX_COLOR_RED:
+ case Dali::Renderer::Property::MIX_COLOR_GREEN:
+ case Dali::Renderer::Property::MIX_COLOR_BLUE:
+ case Dali::Renderer::Property::OPACITY:
+ {
+ const uint8_t componentIndex = static_cast<uint8_t>(static_cast<uint32_t>(index) - static_cast<uint32_t>(Dali::Renderer::Property::MIX_COLOR_RED));
+
+ float mixColorComponentValue;
+ if(propertyValue.Get(mixColorComponentValue))
+ {
+ if(!Equals(mMixColor[componentIndex], mixColorComponentValue))
+ {
+ mMixColor[componentIndex] = mixColorComponentValue;
+ auto sceneObject = const_cast<SceneGraph::Renderer*>(&GetRendererSceneObject());
+ SceneGraph::BakeMixColorComponentMessage(GetEventThreadServices(), *sceneObject, mixColorComponentValue, componentIndex);
}
}
break;
{
switch(index)
{
- case Dali::DevelRenderer::Property::OPACITY:
+ case Dali::Renderer::Property::MIX_COLOR:
+ {
+ value.Get(mMixColor);
+ break;
+ }
+ case Dali::Renderer::Property::MIX_COLOR_RED:
+ case Dali::Renderer::Property::MIX_COLOR_GREEN:
+ case Dali::Renderer::Property::MIX_COLOR_BLUE:
+ case Dali::Renderer::Property::OPACITY:
{
- value.Get(mOpacity);
+ const uint8_t componentIndex = static_cast<uint8_t>(static_cast<uint32_t>(index) - static_cast<uint32_t>(Dali::Renderer::Property::MIX_COLOR_RED));
+ value.Get(mMixColor[componentIndex]);
break;
}
}
{
switch(index)
{
- case Dali::DevelRenderer::Property::OPACITY:
+ case Dali::Renderer::Property::MIX_COLOR:
{
- AdjustValue<float>(mOpacity, value);
+ AdjustValue<Vector4>(mMixColor, value);
+ break;
+ }
+ case Dali::Renderer::Property::MIX_COLOR_RED:
+ case Dali::Renderer::Property::MIX_COLOR_GREEN:
+ case Dali::Renderer::Property::MIX_COLOR_BLUE:
+ case Dali::Renderer::Property::OPACITY:
+ {
+ const uint8_t componentIndex = static_cast<uint8_t>(static_cast<uint32_t>(index) - static_cast<uint32_t>(Dali::Renderer::Property::MIX_COLOR_RED));
+ AdjustValue<float>(mMixColor[componentIndex], value);
break;
}
}
{
const SceneGraph::PropertyBase* property = nullptr;
- if(index == DevelRenderer::Property::OPACITY)
+ switch(index)
{
- property = &GetRendererSceneObject().mOpacity;
+ case Dali::Renderer::Property::MIX_COLOR:
+ case Dali::Renderer::Property::MIX_COLOR_RED:
+ case Dali::Renderer::Property::MIX_COLOR_GREEN:
+ case Dali::Renderer::Property::MIX_COLOR_BLUE:
+ case Dali::Renderer::Property::OPACITY:
+ {
+ property = &GetRendererSceneObject().mMixColor;
+ break;
+ }
}
+
if(!property)
{
// not our property, ask base
return GetSceneObjectAnimatableProperty(index);
}
+int32_t Renderer::GetPropertyComponentIndex(Property::Index index) const
+{
+ int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
+
+ switch(index)
+ {
+ case Dali::Renderer::Property::MIX_COLOR_RED:
+ case Dali::Renderer::Property::MIX_COLOR_GREEN:
+ case Dali::Renderer::Property::MIX_COLOR_BLUE:
+ case Dali::Renderer::Property::OPACITY:
+ {
+ componentIndex = static_cast<uint32_t>(index) - static_cast<uint32_t>(Dali::Renderer::Property::MIX_COLOR_RED);
+ break;
+ }
+
+ default:
+ {
+ // Do nothing
+ break;
+ }
+ }
+
+ if(Property::INVALID_COMPONENT_INDEX == componentIndex)
+ {
+ // ask base
+ componentIndex = Object::GetPropertyComponentIndex(index);
+ }
+
+ return componentIndex;
+}
+
void Renderer::AddDrawCommand(const Dali::DevelRenderer::DrawCommand& command)
{
if(!mDrawCommands.capacity())
Renderer::Renderer(const SceneGraph::Renderer* sceneObject)
: Object(sceneObject),
+ mMixColor(Color::WHITE),
mDepthIndex(0),
mIndexedDrawFirstElement(0),
mIndexedDrawElementCount(0),
mStencilParameters(RenderMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP),
mBlendingOptions(),
- mOpacity(1.0f),
mDepthFunction(DepthFunction::LESS),
mFaceCullingMode(FaceCullingMode::NONE),
mBlendMode(BlendMode::AUTO),
value = mStencilParameters.stencilOperationOnZPass;
break;
}
- case Dali::DevelRenderer::Property::OPACITY:
+ case Dali::Renderer::Property::MIX_COLOR:
{
- value = mOpacity;
+ value = mMixColor;
+ break;
+ }
+ case Dali::Renderer::Property::MIX_COLOR_RED:
+ case Dali::Renderer::Property::MIX_COLOR_GREEN:
+ case Dali::Renderer::Property::MIX_COLOR_BLUE:
+ case Dali::Renderer::Property::OPACITY:
+ {
+ value = mMixColor[static_cast<uint32_t>(index) - static_cast<uint32_t>(Dali::Renderer::Property::MIX_COLOR_RED)];
break;
}
case Dali::DevelRenderer::Property::RENDERING_BEHAVIOR:
value = stencilParameters.stencilOperationOnZPass;
break;
}
- case Dali::DevelRenderer::Property::OPACITY:
+ case Dali::Renderer::Property::MIX_COLOR:
+ {
+ value = sceneObject.GetMixColor(GetEventThreadServices().GetEventBufferIndex());
+ break;
+ }
+ case Dali::Renderer::Property::MIX_COLOR_RED:
+ case Dali::Renderer::Property::MIX_COLOR_GREEN:
+ case Dali::Renderer::Property::MIX_COLOR_BLUE:
+ case Dali::Renderer::Property::OPACITY:
{
- value = sceneObject.GetOpacity(GetEventThreadServices().GetEventBufferIndex());
+ value = sceneObject.GetMixColor(GetEventThreadServices().GetEventBufferIndex())[static_cast<uint32_t>(index) - static_cast<uint32_t>(Dali::Renderer::Property::MIX_COLOR_RED)];
break;
}
case Dali::DevelRenderer::Property::RENDERING_BEHAVIOR:
#define DALI_INTERNAL_RENDERER_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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 PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const override;
+ /**
+ * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
+ */
+ int32_t GetPropertyComponentIndex(Property::Index index) const override;
+
/**
* @brief Adds a draw command to the Renderer.
* DrawCommands override Renderer's default behaviour.
TextureSetPtr mTextureSet; ///< Intrusive pointer to the texture set used by this renderer
ShaderPtr mShader; ///< Intrusive pointer to the shader used by this renderer
+ Vector4 mMixColor; ///< Local copy of the mix color
+
int32_t mDepthIndex;
uint32_t mIndexedDrawFirstElement; ///< Offset of first element to draw from bound index buffer
Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options
BlendingOptions mBlendingOptions; ///< Local copy of blending options bitmask
- float mOpacity; ///< Local copy of the opacity
DepthFunction::Type mDepthFunction : 4; ///< Local copy of the depth function
FaceCullingMode::Type mFaceCullingMode : 3; ///< Local copy of the mode of face culling
BlendMode::Type mBlendMode : 3; ///< Local copy of the mode of blending
DALI_PROPERTY("transformAnchorPoint", VECTOR2, true, false, false, Dali::VisualRenderer::Property::TRANSFORM_ANCHOR_POINT)
DALI_PROPERTY("transformOffsetSizeMode", VECTOR4, true, false, false, Dali::VisualRenderer::Property::TRANSFORM_OFFSET_SIZE_MODE)
DALI_PROPERTY("extraSize", VECTOR2, true, true, true, Dali::VisualRenderer::Property::EXTRA_SIZE)
-DALI_PROPERTY("visualMixColor", VECTOR3, true, true, true, Dali::VisualRenderer::Property::VISUAL_MIX_COLOR)
-DALI_PROPERTY("preMultipliedAlpha", FLOAT, true, false, false, Dali::VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA)
+DALI_PROPERTY("visualMixColor", VECTOR3, true, false, true, Dali::VisualRenderer::Property::VISUAL_MIX_COLOR)
+DALI_PROPERTY("visualPreMultipliedAlpha", FLOAT, true, false, false, Dali::VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA)
DALI_PROPERTY_TABLE_END(Dali::VisualRenderer::Property::DEFAULT_VISUAL_RENDERER_PROPERTY_START_INDEX, VisualRendererDefaultProperties)
// Property string to enumeration tables:
}
case Dali::VisualRenderer::Property::VISUAL_MIX_COLOR:
{
- if(propertyValue.Get(mPropertyCache.mMixColor))
+ Vector3 mixColorVec3;
+ if(propertyValue.Get(mixColorVec3))
{
- const SceneGraph::Renderer& sceneObject = GetVisualRendererSceneObject();
- auto visualProperties = sceneObject.GetVisualProperties();
- if(visualProperties)
- {
- BakeMessage<Vector3>(GetEventThreadServices(), *mUpdateObject, visualProperties->mMixColor, mPropertyCache.mMixColor);
- }
+ float opacity = Renderer::GetDefaultProperty(Dali::Renderer::Property::OPACITY).Get<float>();
+ Renderer::SetDefaultProperty(Dali::Renderer::Property::MIX_COLOR, Vector4(mixColorVec3.r, mixColorVec3.g, mixColorVec3.b, opacity));
}
break;
}
case Dali::VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA:
{
- float preMultipliedAlpha;
+ float preMultipliedAlpha = 0.0f;
if(propertyValue.Get(preMultipliedAlpha))
{
- if(!Equals(mPropertyCache.mPreMultipliedAlpha, preMultipliedAlpha))
- {
- const SceneGraph::Renderer& sceneObject = GetVisualRendererSceneObject();
- auto visualProperties = sceneObject.GetVisualProperties();
- if(visualProperties)
- {
- mPropertyCache.mPreMultipliedAlpha = preMultipliedAlpha;
- BakeMessage<float>(GetEventThreadServices(), *mUpdateObject, visualProperties->mPreMultipliedAlpha, preMultipliedAlpha);
- }
- }
+ Renderer::SetDefaultProperty(Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, !Dali::EqualsZero(preMultipliedAlpha));
}
break;
}
}
case Dali::VisualRenderer::Property::VISUAL_MIX_COLOR:
{
- value = mPropertyCache.mMixColor;
+ Vector4 mixColor = Renderer::GetDefaultProperty(Dali::Renderer::Property::MIX_COLOR).Get<Vector4>();
+ Vector3 mixColorVec3 = Vector3(mixColor.r, mixColor.g, mixColor.b);
+ value = mixColorVec3;
break;
}
case Dali::VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA:
{
- value = mPropertyCache.mPreMultipliedAlpha;
+ bool blendPreMultipliedAlpha = Renderer::GetDefaultProperty(Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA).Get<bool>();
+ value = blendPreMultipliedAlpha ? 1.0f : 0.0f;
break;
}
default:
}
case Dali::VisualRenderer::Property::VISUAL_MIX_COLOR:
{
- auto visualProperties = sceneObject.GetVisualProperties();
- if(visualProperties)
- {
- value = visualProperties->mMixColor[GetEventThreadServices().GetEventBufferIndex()];
- }
+ Vector4 mixColor = Renderer::GetDefaultPropertyCurrentValue(Dali::Renderer::Property::MIX_COLOR).Get<Vector4>();
+ Vector3 mixColorVec3 = Vector3(mixColor.r, mixColor.g, mixColor.b);
+ value = mixColorVec3;
break;
}
case Dali::VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA:
{
- auto visualProperties = sceneObject.GetVisualProperties();
- if(visualProperties)
- {
- value = visualProperties->mPreMultipliedAlpha[GetEventThreadServices().GetEventBufferIndex()];
- }
+ bool blendPreMultipliedAlpha = Renderer::GetDefaultPropertyCurrentValue(Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA).Get<bool>();
+ value = blendPreMultipliedAlpha ? 1.0f : 0.0f;
break;
}
}
value.Get(mPropertyCache.mExtraSize);
break;
}
- case Dali::VisualRenderer::Property::VISUAL_MIX_COLOR:
- {
- value.Get(mPropertyCache.mMixColor);
- break;
- }
}
break;
}
AdjustValue<Vector2>(mPropertyCache.mExtraSize, value);
break;
}
- case Dali::VisualRenderer::Property::VISUAL_MIX_COLOR:
- {
- AdjustValue<Vector3>(mPropertyCache.mMixColor, value);
- break;
- }
}
break;
}
}
case Dali::VisualRenderer::Property::VISUAL_MIX_COLOR:
{
- auto visualProperties = GetVisualRendererSceneObject().GetVisualProperties();
- if(visualProperties)
- {
- property = &visualProperties->mMixColor;
- }
+ // We should use Dali::Renderer::Property::MIX_COLOR, instead of it.
+ property = Renderer::GetSceneObjectAnimatableProperty(Dali::Renderer::Property::MIX_COLOR);
break;
}
}
}
break;
}
- case Dali::VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA:
+ case Dali::VisualRenderer::Property::VISUAL_MIX_COLOR:
{
- auto visualProperties = GetVisualRendererSceneObject().GetVisualProperties();
- if(visualProperties)
- {
- return &visualProperties->mPreMultipliedAlpha;
- }
- break;
+ // We should use Dali::Renderer::Property::MIX_COLOR, instead of it.
+ return Renderer::GetSceneObjectInputProperty(Dali::Renderer::Property::MIX_COLOR);
}
default:
{
AddUniformMapping(Dali::VisualRenderer::Property::TRANSFORM_ORIGIN, ConstString("origin"));
AddUniformMapping(Dali::VisualRenderer::Property::TRANSFORM_ANCHOR_POINT, ConstString("anchorPoint"));
AddUniformMapping(Dali::VisualRenderer::Property::EXTRA_SIZE, ConstString("extraSize"));
- AddUniformMapping(Dali::VisualRenderer::Property::VISUAL_MIX_COLOR, ConstString("mixColor"));
- AddUniformMapping(Dali::VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA, ConstString("preMultipliedAlpha"));
}
} // namespace Internal
#define DALI_INTERNAL_VISUAL_RENDERER_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
~VisualRenderer() override;
private:
- VisualRenderer(const VisualRenderer&) = delete;
+ VisualRenderer(const VisualRenderer&) = delete;
VisualRenderer& operator=(const VisualRenderer&) = delete;
public:
Vector2 mTransformAnchorPoint{Vector2::ZERO};
Vector4 mTransformOffsetSizeMode{Vector2::ZERO};
Vector2 mExtraSize{Vector2::ZERO};
- Vector3 mMixColor{Vector3::ONE};
float mPreMultipliedAlpha{0.0f};
};
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_DATA_PROVIDER_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
virtual const Dali::Vector<Render::TextureKey>* GetTextures() const = 0;
/**
- * Get the opacity
+ * Get the mix color
* @param[in] bufferIndex The current buffer index.
- * @return The opacity
+ * @return The mix color
*/
- virtual float GetOpacity(BufferIndex bufferIndex) const = 0;
+ virtual Vector4 GetMixColor(BufferIndex bufferIndex) const = 0;
/**
* @brief Retrieve if the render data is updated
WriteDefaultUniformV2(program->GetDefaultUniform(Program::DefaultUniformIndex::SCALE), uboViews, scale);
- Vector4 finalColor; ///< Applied renderer's opacity color
- const Vector4& color = node.GetRenderColor(bufferIndex); ///< Actor's original color
+ const Vector4& color = node.GetRenderColor(bufferIndex); ///< Actor's original color
+ const Vector4& mixColor = mRenderDataProvider->GetMixColor(bufferIndex); ///< Renderer's mix color
+ Vector4 finalColor = color * mixColor; ///< Applied renderer's mix color
if(mPremultipliedAlphaEnabled)
{
- const float& alpha = color.a * mRenderDataProvider->GetOpacity(bufferIndex);
- finalColor = Vector4(color.r * alpha, color.g * alpha, color.b * alpha, alpha);
- }
- else
- {
- finalColor = Vector4(color.r, color.g, color.b, color.a * mRenderDataProvider->GetOpacity(bufferIndex));
+ const float alpha = finalColor.a;
+ finalColor.r *= alpha;
+ finalColor.g *= alpha;
+ finalColor.b *= alpha;
}
WriteDefaultUniformV2(program->GetDefaultUniform(Program::DefaultUniformIndex::COLOR), uboViews, finalColor);
WriteDefaultUniformV2(program->GetDefaultUniform(Program::DefaultUniformIndex::ACTOR_COLOR), uboViews, color);
#define DALI_INTERNAL_SCENE_GRAPH_RENDERER_MESSAGES_H
/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
new(slot) LocalType(&renderer, &Renderer::SetStencilOperationOnZPass, stencilOperation);
}
-inline void BakeOpacityMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, float opacity)
+inline void BakeMixColorMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, Vector4 mixColor)
{
- using LocalType = MessageDoubleBuffered1<Renderer, float>;
+ using LocalType = MessageDoubleBuffered1<Renderer, Vector4>;
// Reserve some memory inside the message queue
uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new(slot) LocalType(&renderer, &Renderer::BakeOpacity, opacity);
+ new(slot) LocalType(&renderer, &Renderer::BakeMixColor, mixColor);
OwnerPointer<SceneGraph::PropertyResetterBase> resetter(
new SceneGraph::BakerResetter(const_cast<Renderer*>(&renderer),
- const_cast<AnimatableProperty<float>*>(&renderer.mOpacity),
+ const_cast<AnimatableProperty<Vector4>*>(&renderer.mMixColor),
+ SceneGraph::BakerResetter::Lifetime::BAKE));
+ SceneGraph::AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter);
+}
+
+inline void BakeMixColorComponentMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, float componentValue, uint8_t componentIndex)
+{
+ using LocalType = MessageDoubleBuffered2<Renderer, float, uint8_t>;
+
+ // Reserve some memory inside the message queue
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
+
+ new(slot) LocalType(&renderer, &Renderer::BakeMixColorComponent, componentValue, componentIndex);
+
+ OwnerPointer<SceneGraph::PropertyResetterBase> resetter(
+ new SceneGraph::BakerResetter(const_cast<Renderer*>(&renderer),
+ const_cast<AnimatableProperty<Vector4>*>(&renderer.mMixColor),
SceneGraph::BakerResetter::Lifetime::BAKE));
SceneGraph::AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter);
}
mVisualPropertiesDirtyFlags(CLEAN_FLAG),
mRegenerateUniformMap(false),
mPremultipledAlphaEnabled(false),
- mOpacity(1.0f),
+ mMixColor(Color::WHITE),
mDepthIndex(0)
{
}
return mStencilParameters;
}
-void Renderer::BakeOpacity(BufferIndex updateBufferIndex, float opacity)
+void Renderer::BakeMixColor(BufferIndex updateBufferIndex, const Vector4& mixColor)
{
- mOpacity.Bake(updateBufferIndex, opacity);
+ mMixColor.Bake(updateBufferIndex, mixColor);
SetUpdated(true);
}
-float Renderer::GetOpacity(BufferIndex updateBufferIndex) const
+void Renderer::BakeMixColorComponent(BufferIndex updateBufferIndex, float componentValue, uint8_t componentIndex)
{
- return mOpacity[updateBufferIndex];
+ switch(componentIndex)
+ {
+ case 0:
+ {
+ mMixColor.BakeX(updateBufferIndex, componentValue);
+ break;
+ }
+ case 1:
+ {
+ mMixColor.BakeY(updateBufferIndex, componentValue);
+ break;
+ }
+ case 2:
+ {
+ mMixColor.BakeZ(updateBufferIndex, componentValue);
+ break;
+ }
+ case 3:
+ {
+ mMixColor.BakeW(updateBufferIndex, componentValue);
+ break;
+ }
+ default:
+ {
+ DALI_ASSERT_ALWAYS(0 && "Invalid mix color component comes!");
+ break;
+ }
+ }
+
+ SetUpdated(true);
+}
+
+Vector4 Renderer::GetMixColor(BufferIndex updateBufferIndex) const
+{
+ return mMixColor[updateBufferIndex];
}
void Renderer::SetRenderingBehavior(DevelRenderer::Rendering::Type renderingBehavior)
}
case BlendMode::ON: // If the renderer should always be use blending
{
- float alpha = node.GetWorldColor(updateBufferIndex).a * mOpacity[updateBufferIndex];
+ float alpha = node.GetWorldColor(updateBufferIndex).a * mMixColor[updateBufferIndex].a;
if(alpha <= FULLY_TRANSPARENT)
{
opacityType = Renderer::TRANSPARENT;
}
// renderer should determine opacity using the actor color
- float alpha = node.GetWorldColor(updateBufferIndex).a * mOpacity[updateBufferIndex];
+ float alpha = node.GetWorldColor(updateBufferIndex).a * mMixColor[updateBufferIndex].a;
if(alpha <= FULLY_TRANSPARENT)
{
opacityType = Renderer::TRANSPARENT;
bool Renderer::IsDirty() const
{
// Check whether the opacity property has changed
- return (Updated() || !mOpacity.IsClean());
+ return (Updated() || !mMixColor.IsClean());
}
void Renderer::RequestResetToBaseValues()
{
- mOpacity.RequestResetToBaseValue();
+ mMixColor.RequestResetToBaseValue();
if(mVisualProperties)
{
mVisualProperties->RequestResetToBaseValues();
const Render::Renderer::StencilParameters& GetStencilParameters() const;
/**
- * Bakes the opacity
+ * Bakes the mixColor
* @param[in] updateBufferIndex The current update buffer index.
- * @param[in] opacity The opacity
+ * @param[in] mixColor The mix color
*/
- void BakeOpacity(BufferIndex updateBufferIndex, float opacity);
+ void BakeMixColor(BufferIndex updateBufferIndex, const Vector4& mixColor);
/**
- * @copydoc RenderDataProvider::GetOpacity()
+ * Bakes the component of mixColor
+ * @param[in] updateBufferIndex The current update buffer index.
+ * @param[in] componentValue The value of mix colorcomponent.
+ * @param[in] componentIndex The index of mix color component.
+ */
+ void BakeMixColorComponent(BufferIndex updateBufferIndex, float componentValue, uint8_t componentIndex);
+
+ /**
+ * @copydoc RenderDataProvider::GetMixColor()
*/
- float GetOpacity(BufferIndex updateBufferIndex) const override;
+ Vector4 GetMixColor(BufferIndex updateBufferIndex) const override;
/**
* Sets the rendering behavior
Dali::RenderCallback* mRenderCallback{nullptr};
public:
- AnimatableProperty<float> mOpacity; ///< The opacity value
- int32_t mDepthIndex; ///< Used only in PrepareRenderInstructions
+ AnimatableProperty<Vector4> mMixColor; ///< The mix color value
+ int32_t mDepthIndex; ///< Used only in PrepareRenderInstructions
};
} // namespace SceneGraph
mTransformAnchorPoint.RequestResetToBaseValue();
mTransformOffsetSizeMode.RequestResetToBaseValue();
mExtraSize.RequestResetToBaseValue();
- mMixColor.RequestResetToBaseValue();
mPreMultipliedAlpha.RequestResetToBaseValue();
if(mExtendedProperties)
{
mTransformAnchorPoint(Vector2::ZERO),
mTransformOffsetSizeMode(Vector4::ZERO),
mExtraSize(Vector2::ZERO),
- mMixColor(Vector3::ONE),
mPreMultipliedAlpha(0.0f),
mExtendedProperties(nullptr)
{
PROPERTY_WRAPPER(mTransformOffsetSizeMode, VisualRendererProperty, Vector2, mExtraSize);
// Properties that don't give any effort to coefficient.
- AnimatableProperty<Vector3> mMixColor;
- AnimatableProperty<float> mPreMultipliedAlpha;
+ AnimatableProperty<float> mPreMultipliedAlpha;
public: // Extended properties for decorated visual properties
AnimatableDecoratedVisualProperties* mExtendedProperties{nullptr};
#define DALI_RENDERER_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
*/
enum Type
{
- OFF, ///< Blending is disabled. @SINCE_1_1.43
- AUTO, ///< Blending is enabled if there is alpha channel. This is the default mode. @SINCE_1_1.43
- ON, ///< Blending is enabled. @SINCE_1_1.43
- ON_WITHOUT_CULL, ///< Blending is enabled, and don't cull the renderer @SINCE_2_0.43
- USE_ACTOR_OPACITY ///< Blending is enabled when the actor is not opaque @SINCE_2_2.7
+ OFF, ///< Blending is disabled. @SINCE_1_1.43
+ AUTO, ///< Blending is enabled if there is alpha channel. This is the default mode. @SINCE_1_1.43
+ ON, ///< Blending is enabled. @SINCE_1_1.43
+ ON_WITHOUT_CULL, ///< Blending is enabled, and don't cull the renderer @SINCE_2_0.43
+ USE_ACTOR_OPACITY ///< Blending is enabled when the actor is not opaque @SINCE_2_2.7
};
} // namespace BlendMode
* @note The default value is StencilOperation::KEEP.
*/
STENCIL_OPERATION_ON_Z_PASS,
+
+ /**
+ * @brief The mix color of the renderer, include opacity.
+ * The final color of this renderer will be multiplied by this value.
+ * @SINCE_2_3.41
+ * @details name "rendererMixColor", type VECTOR4
+ */
+ MIX_COLOR,
+
+ /**
+ * @brief The red component of mix color of the renderer.
+ * @SINCE_2_3.41
+ * @details name "rendererMixColorRed", type FLOAT
+ */
+ MIX_COLOR_RED,
+
+ /**
+ * @brief The green component of mix color of the renderer.
+ * @SINCE_2_3.41
+ * @details name "rendererMixColorGreen", type FLOAT
+ */
+ MIX_COLOR_GREEN,
+
+ /**
+ * @brief The blue component of mix color of the renderer.
+ * @SINCE_2_3.41
+ * @details name "rendererMixColorBlue", type FLOAT
+ */
+ MIX_COLOR_BLUE,
+
+ /**
+ * @brief The opacity of the renderer. It is alpha component of the mix color property.
+ * @SINCE_2_3.41
+ * @details Name "rendererOpacity", type FLOAT.
+ */
+ OPACITY,
};
};
#define DALI_VISUAL_RENDERER_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
/**
* @brief Mix color is a generic color for any visual.
- * @details Name "visualMixColor", type Property::VECTOR3, animatable
+ * @details Name "visualMixColor", type Property::VECTOR3
* @SINCE_2_1.13
+ * @DEPRECATED_2_3.41 Use Renderer::Property::MIX_COLOR instead.
*/
VISUAL_MIX_COLOR,
/**
* @brief PremultipliedAlpha is a float representing a bool, and is either 0.0f, or 1.0f
- * @details Name "preMultipliedAlpha", type Property::FLOAT
+ * @details Name "visualPreMultipliedAlpha", type Property::FLOAT
* @SINCE_2_1.13
+ * @DEPRECATED_2_3.41 Not be added as uniform anymore. Use Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA instead.
*/
VISUAL_PRE_MULTIPLIED_ALPHA,
};