/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
static std::vector<UniformData> customUniforms =
{
+ UniformData("pixelArea", Property::Type::VECTOR4),
UniformData("cornerRadius", Property::Type::VECTOR4),
UniformData("borderlineWidth", Property::Type::FLOAT),
UniformData("borderlineColor", Property::Type::VECTOR4),
application.Render();
float targetOpacity = 0.5f;
+ Vector4 targetPixelArea(0.0f, 1.0f, 2.0f, -0.5f);
Vector4 targetCornerRadius(20.0f, 20.0f, 0.0f, 0.0f);
float targetBorderlineWidth = 10.0f;
Vector4 targetBorderlineColor(1.0f, 0.0f, 1.0f, 0.5f);
Animation animation = Animation::New(1.0f);
animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::OPACITY), targetOpacity);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, ImageVisual::Property::PIXEL_AREA), targetPixelArea);
animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Property::CORNER_RADIUS), targetCornerRadius);
animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Property::BORDERLINE_WIDTH), targetBorderlineWidth);
animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Property::BORDERLINE_COLOR), targetBorderlineColor);
DALI_TEST_CHECK(colorValue);
DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(1.0f, 1.0f, 1.0f, targetOpacity), TEST_LOCATION);
+ Property::Value* pixelAreaValue = resultMap.Find(ImageVisual::Property::PIXEL_AREA, Property::VECTOR4);
+ DALI_TEST_CHECK(pixelAreaValue);
+ DALI_TEST_EQUALS(pixelAreaValue->Get<Vector4>(), targetPixelArea, TEST_LOCATION);
+
Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
DALI_TEST_CHECK(cornerRadiusValue);
DALI_TEST_EQUALS(cornerRadiusValue->Get<Vector4>(), targetCornerRadius, TEST_LOCATION);
DALI_TEST_EQUALS(borderlineOffsetValue->Get<float>(), targetBorderlineOffset, TEST_LOCATION);
// Test uniform value
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", targetPixelArea), true, TEST_LOCATION);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("borderlineWidth", targetBorderlineWidth), true, TEST_LOCATION);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("borderlineColor", targetBorderlineColor), true, TEST_LOCATION);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("borderlineOffset", targetBorderlineOffset), true, TEST_LOCATION);
+ // Test non-animatable index, for coverage.
+ DALI_TEST_EQUALS(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, ImageVisual::Property::URL).propertyIndex, Property::INVALID_INDEX, TEST_LOCATION);
+
END_TEST;
}
Dali::SamplingMode::Type samplingMode)
: Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::IMAGE),
mPixelArea(FULL_TEXTURE_RECT),
+ mPixelAreaIndex(Property::INVALID_INDEX),
mPlacementActor(),
mImageUrl(imageUrl),
mMaskingData(),
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.
+ mPixelAreaIndex = mImpl->mRenderer.RegisterProperty(mPixelAreaIndex, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
+ }
break;
}
if(mPixelArea != FULL_TEXTURE_RECT)
{
- mImpl->mRenderer.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, mPixelArea);
+ mPixelAreaIndex = mImpl->mRenderer.RegisterProperty(mPixelAreaIndex, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
}
if(mLoadState == TextureManager::LoadState::LOAD_FINISHED)
map.Insert(Toolkit::ImageVisual::Property::FITTING_MODE, mFittingMode);
map.Insert(Toolkit::ImageVisual::Property::SAMPLING_MODE, mSamplingMode);
- map.Insert(Toolkit::ImageVisual::Property::PIXEL_AREA, mPixelArea);
+ if(mImpl->mRenderer && mPixelAreaIndex != Property::INVALID_INDEX)
+ {
+ // Update values from Renderer
+ Vector4 pixelArea = mImpl->mRenderer.GetProperty<Vector4>(mPixelAreaIndex);
+ map.Insert(Toolkit::ImageVisual::Property::PIXEL_AREA, pixelArea);
+ }
+ else
+ {
+ map.Insert(Toolkit::ImageVisual::Property::PIXEL_AREA, mPixelArea);
+ }
+
map.Insert(Toolkit::ImageVisual::Property::WRAP_MODE_U, mWrapModeU);
map.Insert(Toolkit::ImageVisual::Property::WRAP_MODE_V, mWrapModeV);
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(DALI_LIKELY(mImpl->mRenderer))
+ {
+ if(mPixelAreaIndex == Property::INVALID_INDEX)
+ {
+ mPixelAreaIndex = mImpl->mRenderer.RegisterProperty(mPixelAreaIndex, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
+ }
+ return Dali::Property(mImpl->mRenderer, mPixelAreaIndex);
+ }
+ }
+
+ Handle handle;
+ return Dali::Property(handle, Property::INVALID_INDEX);
+}
+
void ImageVisual::CheckMaskTexture()
{
if(mMaskingData && !mMaskingData->mPreappliedMasking)