Their was several mis-ussing cases for RegisterProperty.
Since the first value of RegisterProperty is the key of custom-property.
But some codes works like "Set or Register".
It will return invalid values when we try to get some item
by INVALID_KEY.
+
Some codes are mis-implements at AnimatedImageVisual or AnimatedVectorVisual, SvgVisual.
Let we follow them as latest code scenario, and add some UTC for it.
Change-Id: I2a5b23a1cc321b2fc1fdd880ba85b8859451c153
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali/devel-api/adaptor-framework/window-devel.h>
END_TEST;
}
+int UtcDaliAnimatedImageVisualCustomShader(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliAnimatedImageVisualCustomShader Test custom shader");
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map properties;
+ Property::Map shader;
+ const std::string vertexShader = "Foobar";
+ const std::string fragmentShader = "Foobar sampler2D Foobar";
+ shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
+ shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
+
+ properties[Visual::Property::TYPE] = Visual::IMAGE;
+ properties[Visual::Property::SHADER] = shader;
+ properties[ImageVisual::Property::URL] = TEST_GIF_FILE_NAME;
+
+ Visual::Base visual = factory.CreateVisual(properties);
+
+ // trigger creation through setting on stage
+ DummyControl dummy = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ dummy.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ application.GetScene().Add(dummy);
+
+ application.SendNotification();
+ application.Render();
+
+ // Trigger count is 2 - load & render a frame
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ Renderer renderer = dummy.GetRendererAt(0);
+ Shader shader2 = renderer.GetShader();
+ Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
+ Property::Map* map = value.GetMap();
+ DALI_TEST_CHECK(map);
+
+ std::string resultFragmentShader, resultVertexShader;
+ Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
+ fragment->Get(resultFragmentShader);
+ DALI_TEST_CHECK(resultFragmentShader.find(fragmentShader) != std::string::npos);
+
+ Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
+ vertex->Get(resultVertexShader);
+ DALI_TEST_CHECK(resultVertexShader.find(vertexShader) != std::string::npos);
+
+ END_TEST;
+}
+
int UtcDaliAnimatedImageVisualWrapMode(void)
{
ToolkitTestApplication application;
END_TEST;
}
+
+int UtcDaliAnimatedImageVisualAnimatePixelArea(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("AnimatedImageVisual animate pixel area");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("pixelArea", Property::Type::VECTOR4),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ application.GetPlatform().SetClosestImageSize(Vector2(100, 100));
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
+ propertyMap.Insert("mixColor", Color::BLUE);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+
+ DummyControl actor = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
+ actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ actor.SetProperty(Actor::Property::COLOR, Color::BLACK);
+ application.GetScene().Add(actor);
+
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
+
+ Renderer renderer = actor.GetRendererAt(0);
+
+ Animation animation = Animation::New(4.0f);
+ animation.AnimateTo(DevelControl::GetVisualProperty(actor, DummyControl::Property::TEST_VISUAL, ImageVisual::Property::PIXEL_AREA), Vector4(0.0f, 0.0f, 0.0f, 1.0f));
+ animation.AnimateTo(Property(actor, Actor::Property::COLOR), Color::WHITE);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(0); // Ensure animation starts
+ application.Render(2000u); // Halfway point
+
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", Vector4(0.0f, 0.0f, 0.5f, 1.0f)), true, TEST_LOCATION);
+
+ application.Render(2000u); // End of animation
+
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", Vector4(0.0f, 0.0f, 0.0f, 1.0f)), true, TEST_LOCATION);
+
+ animation = Animation::New(4.0f);
+ animation.AnimateTo(DevelControl::GetVisualProperty(actor, DummyControl::Property::TEST_VISUAL, "pixelArea"), Vector4(1.0f, -1.0f, 2.0f, 2.0f));
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(0); // Ensure animation starts
+ application.Render(2000u); // Halfway point
+
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", Vector4(0.5f, -0.5f, 1.0f, 1.5f)), true, TEST_LOCATION);
+
+ application.Render(2000u); // End of animation
+
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", Vector4(1.0f, -1.0f, 2.0f, 2.0f)), true, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedImageVisualUpdatePixelAreaByAction(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("AnimatedImageVisual update pixel area by action");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("pixelArea", Property::Type::VECTOR4),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ application.GetPlatform().SetClosestImageSize(Vector2(100, 100));
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
+ propertyMap.Insert("mixColor", Color::BLUE);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+
+ DummyControl actor = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
+ actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ actor.SetProperty(Actor::Property::COLOR, Color::BLACK);
+ application.GetScene().Add(actor);
+
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
+
+ Renderer renderer = actor.GetRendererAt(0);
+
+ application.SendNotification();
+ application.Render(0);
+
+ // Default uniform is full-rect
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", Vector4(0.0f, 0.0f, 1.0f, 1.0f)), true, TEST_LOCATION);
+
+ Property::Map attributes;
+ Vector4 targetPixelArea = Vector4(0.0f, 1.0f, 1.0f, -1.0f);
+
+ attributes.Add(ImageVisual::Property::PIXEL_AREA, targetPixelArea);
+ DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
+
+ Property::Map resultMap;
+ resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
+
+ Property::Value* value = resultMap.Find(ImageVisual::Property::PIXEL_AREA);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(targetPixelArea, value->Get<Vector4>(), TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(0);
+
+ // Check uniform value updated
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", targetPixelArea), true, TEST_LOCATION);
+
+ targetPixelArea = Vector4(-1.0f, -1.0f, 3.0f, 3.0f);
+
+ attributes.Clear();
+ attributes.Add(ImageVisual::Property::PIXEL_AREA, targetPixelArea);
+ DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
+
+ resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
+
+ value = resultMap.Find(ImageVisual::Property::PIXEL_AREA);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(targetPixelArea, value->Get<Vector4>(), TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(0);
+
+ // Check uniform value updated
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", targetPixelArea), true, TEST_LOCATION);
+
+ END_TEST;
+}
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
#include <dali-toolkit/public-api/image-loader/image-url.h>
#include <dali-toolkit/public-api/image-loader/image.h>
END_TEST;
}
+
+int UtcDaliImageVisualUpdatePixelAreaByAction(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("ImageVisual animate pixel area");
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("pixelArea", Property::Type::VECTOR4),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ application.GetPlatform().SetClosestImageSize(Vector2(100, 100));
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
+ propertyMap.Insert("mixColor", Color::BLUE);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+
+ DummyControl actor = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
+ actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ actor.SetProperty(Actor::Property::COLOR, Color::BLACK);
+ application.GetScene().Add(actor);
+
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
+
+ Renderer renderer = actor.GetRendererAt(0);
+
+ application.SendNotification();
+ application.Render(0);
+
+ // Default uniform is full-rect
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", Vector4(0.0f, 0.0f, 1.0f, 1.0f)), true, TEST_LOCATION);
+
+ Property::Map attributes;
+ Vector4 targetPixelArea = Vector4(0.0f, 1.0f, 1.0f, -1.0f);
+
+ attributes.Add(ImageVisual::Property::PIXEL_AREA, targetPixelArea);
+ DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
+
+ Property::Map resultMap;
+ resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
+
+ Property::Value* value = resultMap.Find(ImageVisual::Property::PIXEL_AREA);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(targetPixelArea, value->Get<Vector4>(), TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(0);
+
+ // Check uniform value updated
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", targetPixelArea), true, TEST_LOCATION);
+
+ targetPixelArea = Vector4(-1.0f, -1.0f, 3.0f, 3.0f);
+
+ attributes.Clear();
+ attributes.Add(ImageVisual::Property::PIXEL_AREA, targetPixelArea);
+ DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
+
+ resultMap = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
+
+ value = resultMap.Find(ImageVisual::Property::PIXEL_AREA);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(targetPixelArea, value->Get<Vector4>(), TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(0);
+
+ // Check uniform value updated
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", targetPixelArea), true, TEST_LOCATION);
+
+ END_TEST;
+}
Renderer renderer = dummy.GetRendererAt(0);
auto textures = renderer.GetTextures();
DALI_TEST_EQUALS(textures.GetTextureCount(), 2, TEST_LOCATION);
+
+ // SceneOff + SceneOn immediatly. Let we check cached texture still exist.
+ dummy.Unparent();
+ application.GetScene().Add(dummy);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 0), false, TEST_LOCATION);
+
UnparentAndReset(dummy);
END_TEST;
constexpr float MINIMUM_FRAME_SPEED_FACTOR(0.01f);
constexpr float MAXIMUM_FRAME_SPEED_FACTOR(100.0f);
+constexpr float ALPHA_VALUE_PREMULTIPLIED(1.0f);
+
constexpr uint32_t TEXTURE_COUNT_FOR_GPU_ALPHA_MASK = 2u;
#if defined(DEBUG_ENABLED)
{
if(mImpl->mRenderer)
{
- if(mPreMultipliedAlphaIndex != Property::INVALID_INDEX || !preMultiplied)
+ if(mPreMultipliedAlphaIndex != Property::INVALID_INDEX)
+ {
+ mImpl->mRenderer.SetProperty(mPreMultipliedAlphaIndex, preMultiplied ? 1.0f : 0.0f);
+ }
+ else if(!preMultiplied)
{
- // RegisterUniqueProperty call SetProperty internally.
// Register PREMULTIPLIED_ALPHA only if it become false.
// Default PREMULTIPLIED_ALPHA value is 1.0f, at image-visual-shader-factory.cpp
- mPreMultipliedAlphaIndex = mImpl->mRenderer.RegisterUniqueProperty(mPreMultipliedAlphaIndex, PREMULTIPLIED_ALPHA, preMultiplied ? 1.0f : 0.0f);
+ mPreMultipliedAlphaIndex = mImpl->mRenderer.RegisterProperty(Toolkit::Visual::Property::PREMULTIPLIED_ALPHA, PREMULTIPLIED_ALPHA, preMultiplied ? 1.0f : 0.0f);
}
}
case Toolkit::ImageVisual::Property::PIXEL_AREA:
{
value.Get(mPixelArea);
+
+ if(DALI_UNLIKELY(mImpl->mRenderer))
+ {
+ // Unusual case. SetProperty called after OnInitialize().
+ // Assume that DoAction call UPDATE_PROPERTY.
+ if(mPixelAreaIndex != Property::INVALID_INDEX)
+ {
+ mImpl->mRenderer.SetProperty(mPixelAreaIndex, mPixelArea);
+ }
+ else if(mPixelArea != FULL_TEXTURE_RECT)
+ {
+ mPixelAreaIndex = mImpl->mRenderer.RegisterProperty(Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
+ }
+ }
break;
}
case Toolkit::ImageVisual::Property::WRAP_MODE_U:
Shader AnimatedImageVisual::GenerateShader() const
{
- bool defaultWrapMode = mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE;
- bool requiredAlphaMaskingOnRendering = (mMaskingData && !mMaskingData->mMaskImageLoadingFailed) ? !mMaskingData->mPreappliedMasking : false;
Shader shader;
- shader = mImageVisualShaderFactory.GetShader(
- mFactoryCache,
- ImageVisualShaderFeature::FeatureBuilder()
- .ApplyDefaultTextureWrapMode(defaultWrapMode)
- .EnableRoundedCorner(IsRoundedCornerRequired(), IsSquircleCornerRequired())
- .EnableBorderline(IsBorderlineRequired())
- .EnableAlphaMaskingOnRendering(requiredAlphaMaskingOnRendering));
+ if(mImpl->mCustomShader)
+ {
+ shader = Shader::New(mImpl->mCustomShader->mVertexShader.empty() ? mImageVisualShaderFactory.GetVertexShaderSource().data() : mImpl->mCustomShader->mVertexShader,
+ mImpl->mCustomShader->mFragmentShader.empty() ? mImageVisualShaderFactory.GetFragmentShaderSource().data() : mImpl->mCustomShader->mFragmentShader,
+ mImpl->mCustomShader->mHints);
+
+ shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT);
+
+ // Most of image visual shader user (like svg, animated vector image visual) use pre-multiplied alpha.
+ // If the visual dont want to using pre-multiplied alpha, it should be set as 0.0f as renderer side.
+ shader.RegisterProperty(PREMULTIPLIED_ALPHA, ALPHA_VALUE_PREMULTIPLIED);
+ }
+ else
+ {
+ bool defaultWrapMode = mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE;
+ bool requiredAlphaMaskingOnRendering = (mMaskingData && !mMaskingData->mMaskImageLoadingFailed) ? !mMaskingData->mPreappliedMasking : false;
+
+ shader = mImageVisualShaderFactory.GetShader(
+ mFactoryCache,
+ ImageVisualShaderFeature::FeatureBuilder()
+ .ApplyDefaultTextureWrapMode(defaultWrapMode)
+ .EnableRoundedCorner(IsRoundedCornerRequired(), IsSquircleCornerRequired())
+ .EnableBorderline(IsBorderlineRequired())
+ .EnableAlphaMaskingOnRendering(requiredAlphaMaskingOnRendering));
+ }
return shader;
}
+Dali::Property AnimatedImageVisual::OnGetPropertyObject(Dali::Property::Key key)
+{
+ if((key.type == Property::Key::INDEX && key.indexKey == Toolkit::ImageVisual::Property::PIXEL_AREA) ||
+ (key.type == Property::Key::STRING && key.stringKey == PIXEL_AREA_UNIFORM_NAME))
+ {
+ if(DALI_LIKELY(mImpl->mRenderer))
+ {
+ if(mPixelAreaIndex == Property::INVALID_INDEX)
+ {
+ mPixelAreaIndex = mImpl->mRenderer.RegisterProperty(Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
+ }
+ return Dali::Property(mImpl->mRenderer, mPixelAreaIndex);
+ }
+ }
+
+ Handle handle;
+ return Dali::Property(handle, Property::INVALID_INDEX);
+}
+
void AnimatedImageVisual::OnInitialize()
{
CreateImageCache();
{
Vector2 wrapMode(mWrapModeU - WrapMode::CLAMP_TO_EDGE, mWrapModeV - WrapMode::CLAMP_TO_EDGE);
wrapMode.Clamp(Vector2::ZERO, Vector2(2.f, 2.f));
- mImpl->mRenderer.RegisterProperty(WRAP_MODE_UNIFORM_NAME, wrapMode);
+ mImpl->mRenderer.RegisterUniqueProperty(WRAP_MODE_UNIFORM_NAME, wrapMode);
}
if(mPixelArea != FULL_TEXTURE_RECT)
{
- mPixelAreaIndex = mImpl->mRenderer.RegisterProperty(mPixelAreaIndex, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
+ mPixelAreaIndex = mImpl->mRenderer.RegisterUniqueProperty(Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
}
if(mMaskingData)
{
- mImpl->mRenderer.RegisterProperty(CROP_TO_MASK_NAME, static_cast<float>(mMaskingData->mCropToMask));
+ mImpl->mRenderer.RegisterUniqueProperty(Toolkit::ImageVisual::Property::CROP_TO_MASK, CROP_TO_MASK_NAME, static_cast<float>(mMaskingData->mCropToMask));
}
// Enable PreMultipliedAlpha if it need.
*/
Shader GenerateShader() const override;
+ /**
+ * @copydoc Visual::Base::OnGetPropertyObject
+ */
+ Dali::Property OnGetPropertyObject(Dali::Property::Key key) override;
+
private:
/**
* @brief Initialize the animated image variables.
{
namespace
{
-const int CUSTOM_PROPERTY_COUNT(1); // pixel area,
+const int CUSTOM_PROPERTY_COUNT(1); // PixelArea
const Dali::Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
+constexpr float ALPHA_VALUE_PREMULTIPLIED(1.0f);
+
// stop behavior
DALI_ENUM_TO_STRING_TABLE_BEGIN(STOP_BEHAVIOR)
DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::Toolkit::DevelImageVisual::StopBehavior, CURRENT_FRAME)
mImpl->mCustomShader->mHints);
shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT);
+
+ // Most of image visual shader user (like svg, animated vector image visual) use pre-multiplied alpha.
+ // If the visual dont want to using pre-multiplied alpha, it should be set as 0.0f as renderer side.
+ shader.RegisterProperty(PREMULTIPLIED_ALPHA, ALPHA_VALUE_PREMULTIPLIED);
}
else
{
{
const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
-constexpr float ALPHA_PRE_MULTIPLIED(1.0f);
+constexpr float ALPHA_VALUE_PREMULTIPLIED(1.0f);
constexpr int CUSTOM_PROPERTY_COUNT(2); // PixelArea, pre-multiplied alpha
// Most of image visual shader user (like svg, animated vector image visual) use pre-multiplied alpha.
// If the visual dont want to using pre-multiplied alpha, it should be set as 0.0f as renderer side.
- shader.RegisterProperty(PREMULTIPLIED_ALPHA, ALPHA_PRE_MULTIPLIED);
+ shader.RegisterProperty(PREMULTIPLIED_ALPHA, ALPHA_VALUE_PREMULTIPLIED);
if(featureBuilder.IsEnabledAlphaMaskingOnRendering())
{
const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
+constexpr float ALPHA_VALUE_PREMULTIPLIED(1.0f);
+
constexpr uint32_t TEXTURE_COUNT_FOR_GPU_ALPHA_MASK = 2u;
constexpr uint32_t MINIMUM_SHADER_VERSION_SUPPORT_UNIFIED_YUV_AND_RGB = 300;
{
// Unusual case. SetProperty called after OnInitialize().
// Assume that DoAction call UPDATE_PROPERTY.
- mPixelAreaIndex = mImpl->mRenderer.RegisterProperty(mPixelAreaIndex, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
+ if(mPixelAreaIndex != Property::INVALID_INDEX)
+ {
+ mImpl->mRenderer.SetProperty(mPixelAreaIndex, mPixelArea);
+ }
+ else if(mPixelArea != FULL_TEXTURE_RECT)
+ {
+ mPixelAreaIndex = mImpl->mRenderer.RegisterProperty(Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
+ }
}
break;
}
mImpl->mRenderer = DecoratedVisualRenderer::New(geometry, shader);
mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT);
+ if(mPixelArea != FULL_TEXTURE_RECT)
+ {
+ mPixelAreaIndex = mImpl->mRenderer.RegisterUniqueProperty(Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
+ }
+
//Register transform properties
mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
if(mMaskingData)
{
- mImpl->mRenderer.RegisterProperty(CROP_TO_MASK_NAME, static_cast<float>(mMaskingData->mCropToMask));
+ mImpl->mRenderer.RegisterUniqueProperty(Toolkit::ImageVisual::Property::CROP_TO_MASK, CROP_TO_MASK_NAME, static_cast<float>(mMaskingData->mCropToMask));
}
}
mPlacementActor = actor;
- if(mPixelArea != FULL_TEXTURE_RECT)
- {
- mPixelAreaIndex = mImpl->mRenderer.RegisterProperty(mPixelAreaIndex, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
- }
-
if(mLoadState == TextureManager::LoadState::LOAD_FINISHED)
{
actor.AddRenderer(mImpl->mRenderer);
{
if(mImpl->mRenderer)
{
- if(mPreMultipliedAlphaIndex != Property::INVALID_INDEX || !preMultiplied)
+ if(mPreMultipliedAlphaIndex != Property::INVALID_INDEX)
+ {
+ mImpl->mRenderer.SetProperty(mPreMultipliedAlphaIndex, preMultiplied ? 1.0f : 0.0f);
+ }
+ else if(!preMultiplied)
{
- // RegisterUniqueProperty call SetProperty internally.
// Register PREMULTIPLIED_ALPHA only if it become false.
// Default PREMULTIPLIED_ALPHA value is 1.0f, at image-visual-shader-factory.cpp
- mPreMultipliedAlphaIndex = mImpl->mRenderer.RegisterUniqueProperty(mPreMultipliedAlphaIndex, PREMULTIPLIED_ALPHA, preMultiplied ? 1.0f : 0.0f);
+ mPreMultipliedAlphaIndex = mImpl->mRenderer.RegisterProperty(Toolkit::Visual::Property::PREMULTIPLIED_ALPHA, PREMULTIPLIED_ALPHA, preMultiplied ? 1.0f : 0.0f);
}
}
{
shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT);
}
+
+ // Most of image visual shader user (like svg, animated vector image visual) use pre-multiplied alpha.
+ // If the visual dont want to using pre-multiplied alpha, it should be set as 0.0f as renderer side.
+ shader.RegisterProperty(PREMULTIPLIED_ALPHA, ALPHA_VALUE_PREMULTIPLIED);
}
return shader;
Dali::Property ImageVisual::OnGetPropertyObject(Dali::Property::Key key)
{
- if((key.type == Property::Key::INDEX && key.indexKey == Toolkit::ImageVisual::Property::PIXEL_AREA) || (key.type == Property::Key::STRING && key.stringKey == PIXEL_AREA_UNIFORM_NAME))
+ if((key.type == Property::Key::INDEX && key.indexKey == Toolkit::ImageVisual::Property::PIXEL_AREA) ||
+ (key.type == Property::Key::STRING && key.stringKey == PIXEL_AREA_UNIFORM_NAME))
{
if(DALI_LIKELY(mImpl->mRenderer))
{
if(mPixelAreaIndex == Property::INVALID_INDEX)
{
- mPixelAreaIndex = mImpl->mRenderer.RegisterProperty(mPixelAreaIndex, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
+ mPixelAreaIndex = mImpl->mRenderer.RegisterProperty(Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
}
return Dali::Property(mImpl->mRenderer, mPixelAreaIndex);
}
? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD
: TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
- // Register PREMULTIPLIED_ALPHA property here.
- mPreMultipliedAlphaIndex = mImpl->mRenderer.RegisterUniqueProperty(mPreMultipliedAlphaIndex, PREMULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled() ? 1.0f : 0.0f);
+ if(mPreMultipliedAlphaIndex != Property::INVALID_INDEX)
+ {
+ mImpl->mRenderer.SetProperty(mPreMultipliedAlphaIndex, IsPreMultipliedAlphaEnabled() ? 1.0f : 0.0f);
+ }
+ else
+ {
+ // Register PREMULTIPLIED_ALPHA here.
+ mPreMultipliedAlphaIndex = mImpl->mRenderer.RegisterProperty(Toolkit::Visual::Property::PREMULTIPLIED_ALPHA, PREMULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled() ? 1.0f : 0.0f);
+ }
TextureManager::MaskingDataPointer maskingDataPtr = nullptr;
ImageAtlasManagerPtr imageAtlasManagerPtr = nullptr;
constexpr Dali::Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
+constexpr float ALPHA_VALUE_PREMULTIPLIED(1.0f);
+
} // namespace
SvgVisualPtr SvgVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties)
if(DALI_UNLIKELY(mAtlasRect != FULL_TEXTURE_RECT))
{
// Register atlas rect property only if it's not full texture rect.
- mAtlasRectIndex = mImpl->mRenderer.RegisterUniqueProperty(mAtlasRectIndex, ATLAS_RECT_UNIFORM_NAME, mAtlasRect);
+ mAtlasRectIndex = mImpl->mRenderer.RegisterProperty(ATLAS_RECT_UNIFORM_NAME, mAtlasRect);
}
}
else
mImpl->mCustomShader->mHints);
shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT);
+
+ // Most of image visual shader user (like svg, animated vector image visual) use pre-multiplied alpha.
+ // If the visual dont want to using pre-multiplied alpha, it should be set as 0.0f as renderer side.
+ shader.RegisterProperty(PREMULTIPLIED_ALPHA, ALPHA_VALUE_PREMULTIPLIED);
}
return shader;
}
}
}
+ // Fast-out for invalid key.
+ if((key.type == Property::Key::INDEX && key.indexKey == Property::INVALID_KEY) ||
+ (key.type == Property::Key::STRING && key.stringKey.empty()))
+ {
+ return Property::INVALID_INDEX;
+ }
+
Property::Index index = mImpl->mRenderer.GetPropertyIndex(key);
if(index == Property::INVALID_INDEX)
{
const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
+constexpr float ALPHA_VALUE_PREMULTIPLIED(1.0f);
+
constexpr auto LOAD_IMAGE_YUV_PLANES_ENV = "DALI_LOAD_IMAGE_YUV_PLANES";
bool NeedToLoadYuvPlanes()
{
shader = GenerateAndSaveShader(IMAGE_SHADER, Dali::Shader::GetVertexShaderPrefix() + SHADER_IMAGE_VISUAL_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_IMAGE_VISUAL_SHADER_FRAG.data());
shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT);
+ shader.RegisterProperty(PREMULTIPLIED_ALPHA, ALPHA_VALUE_PREMULTIPLIED);
}
renderer.SetGeometry(geometry);
renderer.SetShader(shader);