#include <dali-toolkit/public-api/transition/transition-set.h>
#include <dali-toolkit/public-api/transition/transition.h>
#include <dali/devel-api/actors/actor-devel.h>
+#include <dali/public-api/rendering/decorated-visual-renderer.h> // for Renderer Property Index.
#include <stdlib.h>
#include <iostream>
DALI_TEST_NOT_EQUALS(destinationPosition, control2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.00001f, TEST_LOCATION);
DALI_TEST_EQUALS(1, control2.GetRendererCount(), TEST_LOCATION);
- Dali::Renderer renderer = control2.GetRendererAt(0);
- Property::Index index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
- cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
+ Dali::Renderer renderer = control2.GetRendererAt(0);
+ cornerRadius = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
DALI_TEST_NOT_EQUALS(destinationRadiusV4, cornerRadius, 0.00001f, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
- borderlineWidth = renderer.GetCurrentProperty<float>(index);
+ borderlineWidth = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
DALI_TEST_NOT_EQUALS(destinationBorderlineWidth, borderlineWidth, 0.00001f, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
- borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
+ borderlineColor = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
DALI_TEST_NOT_EQUALS(destinationBorderlineColor, borderlineColor, 0.00001f, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
- borderlineOffset = renderer.GetCurrentProperty<float>(index);
+ borderlineOffset = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET);
DALI_TEST_NOT_EQUALS(destinationBorderlineOffset, borderlineOffset, 0.00001f, TEST_LOCATION);
application.SendNotification();
DALI_TEST_EQUALS(destinationOpacity, control2.GetCurrentProperty<float>(Actor::Property::OPACITY), TEST_LOCATION);
DALI_TEST_EQUALS(1, control2.GetRendererCount(), TEST_LOCATION);
renderer = control2.GetRendererAt(0);
- index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
- cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
+ cornerRadius = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
DALI_TEST_EQUALS(destinationRadiusV4, cornerRadius, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
- borderlineWidth = renderer.GetCurrentProperty<float>(index);
+ borderlineWidth = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
DALI_TEST_EQUALS(destinationBorderlineWidth, borderlineWidth, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
- borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
+ borderlineColor = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
DALI_TEST_EQUALS(destinationBorderlineColor, borderlineColor, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
- borderlineOffset = renderer.GetCurrentProperty<float>(index);
+ borderlineOffset = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET);
DALI_TEST_EQUALS(destinationBorderlineOffset, borderlineOffset, TEST_LOCATION);
END_TEST;
DALI_TEST_NOT_EQUALS(destinationPosition, control1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.00001f, TEST_LOCATION);
DALI_TEST_EQUALS(1, control1.GetRendererCount(), TEST_LOCATION);
- Dali::Renderer renderer = control1.GetRendererAt(0);
- Property::Index index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
- cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
+ Dali::Renderer renderer = control1.GetRendererAt(0);
+ cornerRadius = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
DALI_TEST_NOT_EQUALS(destinationRadiusV4, cornerRadius, 0.00001f, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
- borderlineWidth = renderer.GetCurrentProperty<float>(index);
+ borderlineWidth = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
DALI_TEST_NOT_EQUALS(destinationBorderlineWidth, borderlineWidth, 0.00001f, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
- borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
+ borderlineColor = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
DALI_TEST_NOT_EQUALS(destinationBorderlineColor, borderlineColor, 0.00001f, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
- borderlineOffset = renderer.GetCurrentProperty<float>(index);
+ borderlineOffset = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET);
DALI_TEST_NOT_EQUALS(destinationBorderlineOffset, borderlineOffset, 0.00001f, TEST_LOCATION);
application.SendNotification();
DALI_TEST_EQUALS(1, control1.GetRendererCount(), TEST_LOCATION);
renderer = control1.GetRendererAt(0);
- index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
- cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
+ cornerRadius = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
DALI_TEST_EQUALS(destinationRadiusV4, cornerRadius, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
- borderlineWidth = renderer.GetCurrentProperty<float>(index);
+ borderlineWidth = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
DALI_TEST_EQUALS(destinationBorderlineWidth, borderlineWidth, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
- borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
+ borderlineColor = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
DALI_TEST_EQUALS(destinationBorderlineColor, borderlineColor, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
- borderlineOffset = renderer.GetCurrentProperty<float>(index);
+ borderlineOffset = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET);
DALI_TEST_EQUALS(destinationBorderlineOffset, borderlineOffset, TEST_LOCATION);
// every actor properties of control1 are returned to the source properties.
// after next update, renderer properties are returned to the source properties.
DALI_TEST_EQUALS(1, control1.GetRendererCount(), TEST_LOCATION);
renderer = control1.GetRendererAt(0);
- index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
- cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
+ cornerRadius = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
DALI_TEST_EQUALS(sourceRadiusV4, cornerRadius, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
- borderlineWidth = renderer.GetCurrentProperty<float>(index);
+ borderlineWidth = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
DALI_TEST_EQUALS(sourceBorderlineWidth, borderlineWidth, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
- borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
+ borderlineColor = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
DALI_TEST_EQUALS(sourceBorderlineColor, borderlineColor, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
- borderlineOffset = renderer.GetCurrentProperty<float>(index);
+ borderlineOffset = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET);
DALI_TEST_EQUALS(sourceBorderlineOffset, borderlineOffset, TEST_LOCATION);
END_TEST;
return true;
}
+void TestShaderCodeContainSubstrings(Control control, std::vector<std::pair<std::string, bool>> substringCheckList, const char* location)
+{
+ Renderer renderer = control.GetRendererAt(0);
+ Shader shader = renderer.GetShader();
+ Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
+ Property::Map* map = value.GetMap();
+ DALI_TEST_CHECK(map);
+
+ Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
+ DALI_TEST_CHECK(fragment);
+ std::string fragmentShader;
+ DALI_TEST_CHECK(fragment->Get(fragmentShader));
+ for(const auto& checkPair : substringCheckList)
+ {
+ const auto& keyword = checkPair.first;
+ const auto& expect = checkPair.second;
+ tet_printf("check [%s] %s exist in fragment shader\n", keyword.c_str(), expect ? "is" : "is not");
+ DALI_TEST_EQUALS((fragmentShader.find(keyword.c_str()) != std::string::npos), expect, location);
+ }
+
+ Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
+ std::string vertexShader;
+ DALI_TEST_CHECK(vertex->Get(vertexShader));
+ for(const auto& checkPair : substringCheckList)
+ {
+ const auto& keyword = checkPair.first;
+ const auto& expect = checkPair.second;
+ tet_printf("check [%s] %s exist in vertex shader\n", keyword.c_str(), expect ? "is" : "is not");
+ DALI_TEST_EQUALS((vertexShader.find(keyword.c_str()) != std::string::npos), expect, location);
+ }
+}
+
} //namespace
void dali_visual_startup(void)
value = resultMap.Find(ImageVisual::Property::BORDER, Property::RECTANGLE);
DALI_TEST_CHECK(value);
- DALI_TEST_CHECK(value->Get<Rect<int> >() == border);
+ DALI_TEST_CHECK(value->Get<Rect<int>>() == border);
value = resultMap.Find(DevelImageVisual::Property::AUXILIARY_IMAGE, Property::STRING);
DALI_TEST_CHECK(value);
value = resultMap.Find(ImageVisual::Property::BORDER, Property::RECTANGLE);
DALI_TEST_CHECK(value);
- DALI_TEST_CHECK(value->Get<Rect<int> >() == border);
+ DALI_TEST_CHECK(value->Get<Rect<int>>() == border);
END_TEST;
}
application.SendNotification();
application.Render();
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", false},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", false},
+ },
+ TEST_LOCATION);
+
callStack.Reset();
callStack.Enable(true);
DALI_TEST_CHECK(cornerRadiusPolicyValue);
DALI_TEST_EQUALS(cornerRadiusPolicyValue->Get<int>(), static_cast<int>(Toolkit::Visual::Transform::Policy::RELATIVE), TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", false},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true},
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
DALI_TEST_CHECK(borderlineOffsetValue);
DALI_TEST_EQUALS(borderlineOffsetValue->Get<float>(), targetBorderlineOffset, TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos);
- // Note : mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos);
- // Note : mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", true},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true.
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
DALI_TEST_CHECK(borderlineOffsetValue);
DALI_TEST_EQUALS(borderlineOffsetValue->Get<float>(), 0.0f, TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- // Note : mAlwaysUsingBorderline and mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- // Note : mAlwaysUsingBorderline and mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", true}, // Note : mAlwaysUsingBorderline is true.
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true.
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
application.SendNotification();
application.Render();
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", false},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", false},
+ },
+ TEST_LOCATION);
Vector4 targetCornerRadius = Vector4(0.0f, 0.0f, 0.0f, 0.0f);
DALI_TEST_CHECK(cornerRadiusValue);
DALI_TEST_EQUALS(cornerRadiusValue->Get<Vector4>(), targetCornerRadius, TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- // Note : corner radius is zero. so we don't change shader!
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- // Note : corner radius is zero. so we don't change shader!
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", false},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", false}, // Note : corner radius is zero. so we don't change shader!
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
DALI_TEST_CHECK(borderlineOffsetValue);
DALI_TEST_EQUALS(borderlineOffsetValue->Get<float>(), targetBorderlineOffset, TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- // Note : borderline width is zero. so we don't change shader!
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- // Note : borderline width is zero. so we don't change shader!
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", false}, // Note : borderline width is zero. so we don't change shader!
+ {"#define IS_REQUIRED_ROUNDED_CORNER", false},
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
application.SendNotification();
application.Render();
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BLUR 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BLUR 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BLUR", false},
+ {"#define IS_REQUIRED_BORDERLINE", false},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", false},
+ },
+ TEST_LOCATION);
float targetBlurRadius = 15.0f;
Vector4 targetCornerRadius = Vector4(1.0f, 0.1f, 1.1f, 0.0f);
DALI_TEST_CHECK(cornerRadiusValue);
DALI_TEST_EQUALS(cornerRadiusValue->Get<Vector4>(), targetCornerRadius, TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BLUR 1") != std::string::npos);
- // Note : We ignore borderline when blur radius occured
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BLUR 1") != std::string::npos);
- // Note : We ignore borderline when blur radius occured
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BLUR", true},
+ {"#define IS_REQUIRED_BORDERLINE", false}, // Note : We ignore borderline when blur radius occured
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true},
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
DALI_TEST_CHECK(cornerRadiusValue);
DALI_TEST_EQUALS(cornerRadiusValue->Get<Vector4>(), Vector4::ZERO, TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- // Note : mAlwaysUsingBlurRadius and mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BLUR 1") != std::string::npos);
- // Note : We ignore borderline when blur radius occured
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- // Note : mAlwaysUsingBlurRadius and mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BLUR 1") != std::string::npos);
- // Note : We ignore borderline when blur radius occured
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BLUR", true}, // Note : mAlwaysUsingBlurRadius is true.
+ {"#define IS_REQUIRED_BORDERLINE", false}, // Note : We ignore borderline when blur radius occured
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true.
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
application.SendNotification();
application.Render();
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", false},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true},
+ },
+ TEST_LOCATION);
+
callStack.Reset();
callStack.Enable(true);
application.Render();
application.Render(1001u); // End of animation
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- // Note : mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- // Note : mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", false},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true.
+ },
+ TEST_LOCATION);
+
callStack.Enable(false);
// Shader not changed
DALI_TEST_CHECK(!callStack.FindMethod("CreateShader"));
DALI_TEST_CHECK(borderlineWidthValue);
DALI_TEST_EQUALS(borderlineWidthValue->Get<float>(), targetBorderlineWidth, TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos);
- // Note : mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos);
- // Note : mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", true},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true.
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
set(PREFIX ${prefix})
set(EXEC_PREFIX ${CMAKE_INSTALL_PREFIX})
- set(DEV_INCLUDE_PATH ${repo_root_dir})
+ set(DEV_INCLUDE_PATH ${INCLUDE_DIR})
set(core_pkg_cfg_file dali2-scene-loader.pc)
configure_file(${CMAKE_CURRENT_LIST_DIR}/${core_pkg_cfg_file}.in ${core_pkg_cfg_file} @ONLY)
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
{
namespace DevelStyleManager
{
-const Property::Map GetConfigurations(StyleManager styleManager)
+const Property::Map& GetConfigurations(StyleManager styleManager)
{
return GetImpl(styleManager).GetConfigurations();
}
#define DALI_TOOLKIT_STYLE_MANAGER_DEVEL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
* @param[in] styleManager The instance of StyleManager
* @return A property map to the currently defined configurations
**/
-DALI_TOOLKIT_API const Property::Map GetConfigurations(StyleManager styleManager);
+DALI_TOOLKIT_API const Property::Map& GetConfigurations(StyleManager styleManager);
/**
* @brief Sets an image to be used when a visual has failed to correctly render
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
if(styleManager)
{
- Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
- mAlwaysShowIndicator = config["alwaysShowFocus"].Get<bool>() ? ALWAYS_SHOW : NONE;
+ const Property::Map& config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
+ const auto alwaysShowFocusValue = config.Find("alwaysShowFocus", Property::Type::BOOLEAN);
+
+ mAlwaysShowIndicator = (alwaysShowFocusValue && alwaysShowFocusValue->Get<bool>()) ? ALWAYS_SHOW : NONE;
mIsFocusIndicatorShown = (mAlwaysShowIndicator == ALWAYS_SHOW) ? SHOW : HIDE;
mClearFocusOnTouch = (mIsFocusIndicatorShown == SHOW) ? false : true;
}
nextFocusableActor = mPreFocusChangeSignal.Emit(currentFocusActor, Actor(), direction);
mIsWaitingKeyboardFocusChangeCommit = false;
}
- else if (mEnableDefaultAlgorithm)
+ else if(mEnableDefaultAlgorithm)
{
Actor rootActor = mFocusFinderRootActor.GetHandle();
if(!rootActor)
{
- if (currentFocusActor)
+ if(currentFocusActor)
{
// Find the window of the focused actor.
Integration::SceneHolder window = Integration::SceneHolder::Get(currentFocusActor);
- if (window)
+ if(window)
{
rootActor = window.GetRootLayer();
}
void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
{
- const std::string& keyName = event.GetKeyName();
+ const std::string& keyName = event.GetKeyName();
const std::string& deviceName = event.GetDeviceName();
if(mIsFocusIndicatorShown == UNKNOWN)
bool KeyboardFocusManager::OnCustomWheelEvent(const WheelEvent& event)
{
- bool consumed = false;
- Actor actor = GetCurrentFocusActor();
+ bool consumed = false;
+ Actor actor = GetCurrentFocusActor();
if(actor)
{
// Notify the actor about the wheel event
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix( uSize.xy*size, size, offsetSizeMode.zw );
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy );
- return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy );
+ return vec4( (aPosition + anchorPoint)*visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0 );
}
void main()
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
vPosition = aPosition* visualSize;
- return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+ return vec4( vPosition + anchorPoint*visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0 );
}
void main()
vec2 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
- return (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy;
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
+ return (aPosition + anchorPoint)*visualSize + visualOffset + origin * uSize.xy;
}
void main()
-#ifndef IS_REQUIRED_ROUNDED_CORNER
-#define IS_REQUIRED_ROUNDED_CORNER 0
-#endif
-#ifndef IS_REQUIRED_BORDERLINE
-#define IS_REQUIRED_BORDERLINE 0
-#endif
-#ifndef IS_REQUIRED_BLUR
-#define IS_REQUIRED_BLUR 0
-#endif
-
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE || IS_REQUIRED_BLUR
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
INPUT mediump vec2 vPosition;
INPUT mediump vec2 vRectSize;
INPUT mediump vec2 vOptRectSize;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
INPUT mediump vec4 vCornerRadius;
#endif
#endif
uniform lowp vec4 uColor;
uniform lowp vec3 mixColor;
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_BORDERLINE
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
uniform mediump float borderlineWidth;
uniform mediump float borderlineOffset;
uniform lowp vec4 borderlineColor;
uniform lowp vec4 uActorColor;
#endif
-#if IS_REQUIRED_BLUR
+#ifdef IS_REQUIRED_BLUR
uniform mediump float blurRadius;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE || IS_REQUIRED_BLUR
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
// Global values both rounded corner and borderline use
// radius of rounded corner on this quadrant
void calculateCornerRadius()
{
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
gRadius =
mix(
mix(vCornerRadius.x, vCornerRadius.y, sign(vPosition.x) * 0.5 + 0.5),
{
gFragmentPosition = abs(vPosition) - vRectSize;
gCenterPosition = -gRadius;
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_BORDERLINE
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
gCenterPosition += borderlineWidth * (clamp(borderlineOffset, -1.0, 1.0) + 1.0) * 0.5;
#endif
gDiff = gFragmentPosition - gCenterPosition;
gMaxOutlinePotential = gRadius + gPotentialRange;
gMinOutlinePotential = gRadius - gPotentialRange;
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_BORDERLINE
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
gMaxInlinePotential = gMaxOutlinePotential - borderlineWidth;
gMinInlinePotential = gMinOutlinePotential - borderlineWidth;
#else
}
#endif
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_BORDERLINE
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
{
mediump float potential = gPotential;
}
#endif
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_ROUNDED_CORNER
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_ROUNDED_CORNER)
mediump float calculateCornerOpacity()
{
mediump float potential = gPotential;
}
#endif
-#if IS_REQUIRED_BLUR
+#ifdef IS_REQUIRED_BLUR
mediump float calculateBlurOpacity()
{
// Don't use borderline!
mediump float cy = gRadius + blurRadius;
mediump float cr = gRadius + blurRadius;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
// This routine make perfect circle. If corner radius is not exist, we don't consider prefect circle.
cy = min(cy, min(vRectSize.x, vRectSize.y) - gRadius);
#endif
// highest point of that circle is (x, x + r) and potential is x + r
// solve (v.x - x)^2 + (v.y - x)^2 = (cr / cy * x)^2
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
// Note : lowspec HW cannot calculate here. need to reduce numeric error
highp float A = (cr * cr - 2.0 * cy * cy);
highp float B = cy * (v.x + v.y);
{
lowp vec4 targetColor = vec4(mixColor, 1.0) * uColor;
-#if IS_REQUIRED_BLUR || IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_BLUR) || defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
// skip most potential calculate for performance
if(abs(vPosition.x) < vOptRectSize.x && abs(vPosition.y) < vOptRectSize.y)
{
PreprocessPotential();
#endif
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_BORDERLINE
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
targetColor = convertBorderlineColor(targetColor);
#endif
OUT_COLOR = targetColor;
-#if IS_REQUIRED_BLUR
+#ifdef IS_REQUIRED_BLUR
mediump float opacity = calculateBlurOpacity();
OUT_COLOR.a *= opacity;
-#elif IS_REQUIRED_ROUNDED_CORNER
+#elif defined(IS_REQUIRED_ROUNDED_CORNER)
mediump float opacity = calculateCornerOpacity();
OUT_COLOR.a *= opacity;
#endif
-#if IS_REQUIRED_BLUR || IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_BLUR) || defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
}
#endif
}
-#ifndef IS_REQUIRED_ROUNDED_CORNER
-#define IS_REQUIRED_ROUNDED_CORNER 0
-#endif
-#ifndef IS_REQUIRED_BORDERLINE
-#define IS_REQUIRED_BORDERLINE 0
-#endif
-#ifndef IS_REQUIRED_BLUR
-#define IS_REQUIRED_BLUR 0
-#endif
-
INPUT mediump vec2 aPosition;
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE || IS_REQUIRED_BLUR
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
OUTPUT mediump vec2 vPosition;
OUTPUT mediump vec2 vRectSize;
OUTPUT mediump vec2 vOptRectSize;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
OUTPUT mediump vec4 vCornerRadius;
#endif
#endif
uniform mediump vec4 offsetSizeMode;
uniform mediump vec2 origin;
uniform mediump vec2 anchorPoint;
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_BORDERLINE
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
uniform mediump float borderlineWidth;
uniform mediump float borderlineOffset;
#endif
-#if IS_REQUIRED_BLUR
+#ifdef IS_REQUIRED_BLUR
uniform mediump float blurRadius;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
uniform mediump vec4 cornerRadius;
uniform mediump float cornerRadiusPolicy;
#endif
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
- vec2 visualOffset = mix(offset, offset/uSize.xy, offsetSizeMode.xy);
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw ) + extraSize;
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE || IS_REQUIRED_BLUR
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
vRectSize = visualSize * 0.5;
vOptRectSize = vRectSize;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_ROUNDED_CORNER
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
mediump float minSize = min(visualSize.x, visualSize.y) + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth;
#else
mediump float minSize = min(visualSize.x, visualSize.y);
vOptRectSize -= 0.2929 * maxRadius + 1.0;
#endif
-#if IS_REQUIRED_BLUR
+#ifdef IS_REQUIRED_BLUR
vPosition = aPosition * (visualSize + 2.0 * blurRadius);
vOptRectSize -= blurRadius + 1.0;
-#elif IS_REQUIRED_BORDERLINE
+#elif defined(IS_REQUIRED_BORDERLINE)
vPosition = aPosition * (visualSize + (1.0 + clamp(borderlineOffset, -1.0, 1.0))* borderlineWidth);
vOptRectSize -= (1.0 - clamp(borderlineOffset, -1.0, 1.0)) * 0.5 * borderlineWidth + 1.0;
-#elif IS_REQUIRED_ROUNDED_CORNER
+#elif defined(IS_REQUIRED_ROUNDED_CORNER)
vPosition = aPosition * visualSize;
#else
mediump vec2 vPosition = aPosition * visualSize;
#endif
- return vec4(vPosition + anchorPoint * visualSize + (visualOffset + origin) * uSize.xy, 0.0, 1.0);
+ return vec4(vPosition + anchorPoint * visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0);
}
void main()
-#ifndef IS_REQUIRED_ROUNDED_CORNER
-#define IS_REQUIRED_ROUNDED_CORNER 0
-#endif
-#ifndef IS_REQUIRED_BORDERLINE
-#define IS_REQUIRED_BORDERLINE 0
-#endif
-#ifndef RADIAL
-#define RADIAL 0
-#endif
-
INPUT mediump vec2 vTexCoord;
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
INPUT mediump vec2 vPosition;
INPUT mediump vec2 vRectSize;
INPUT mediump vec2 vOptRectSize;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
INPUT mediump vec4 vCornerRadius;
#endif
#endif
uniform sampler2D sTexture; // sampler1D?
uniform lowp vec4 uColor;
uniform lowp vec3 mixColor;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
uniform mediump float borderlineWidth;
uniform mediump float borderlineOffset;
uniform lowp vec4 borderlineColor;
uniform lowp vec4 uActorColor;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
// Global values both rounded corner and borderline use
// radius of rounded corner on this quadrant
void calculateCornerRadius()
{
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
gRadius =
mix(
mix(vCornerRadius.x, vCornerRadius.y, sign(vPosition.x) * 0.5 + 0.5),
{
gFragmentPosition = abs(vPosition) - vRectSize;
gCenterPosition = -gRadius;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
gCenterPosition += borderlineWidth * (clamp(borderlineOffset, -1.0, 1.0) + 1.0) * 0.5;
#endif
gDiff = gFragmentPosition - gCenterPosition;
gMaxOutlinePotential = gRadius + gPotentialRange;
gMinOutlinePotential = gRadius - gPotentialRange;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
gMaxInlinePotential = gMaxOutlinePotential - borderlineWidth;
gMinInlinePotential = gMinOutlinePotential - borderlineWidth;
#else
#endif
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
{
mediump float potential = gPotential;
}
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
mediump float calculateCornerOpacity()
{
mediump float potential = gPotential;
void main()
{
-#if RADIAL
+#ifdef RADIAL
lowp vec4 textureColor = TEXTURE(sTexture, vec2(length(vTexCoord), 0.5)) * vec4(mixColor, 1.0) * uColor;
#else
lowp vec4 textureColor = TEXTURE(sTexture, vec2(vTexCoord.y, 0.5)) * vec4(mixColor, 1.0) * uColor;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
// skip most potential calculate for performance
if(abs(vPosition.x) < vOptRectSize.x && abs(vPosition.y) < vOptRectSize.y)
{
PreprocessPotential();
#endif
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
textureColor = convertBorderlineColor(textureColor);
#endif
OUT_COLOR = textureColor;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
mediump float opacity = calculateCornerOpacity();
OUT_COLOR *= opacity;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
}
#endif
}
-#ifndef IS_REQUIRED_ROUNDED_CORNER
-#define IS_REQUIRED_ROUNDED_CORNER 0
-#endif
-#ifndef IS_REQUIRED_BORDERLINE
-#define IS_REQUIRED_BORDERLINE 0
-#endif
-#ifndef USER_SPACE
-#define USER_SPACE 0
-#endif
-
INPUT mediump vec2 aPosition;
OUTPUT mediump vec2 vTexCoord;
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
OUTPUT mediump vec2 vPosition;
OUTPUT mediump vec2 vRectSize;
OUTPUT mediump vec2 vOptRectSize;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
OUTPUT mediump vec4 vCornerRadius;
#endif
#endif
uniform mediump vec4 offsetSizeMode;
uniform mediump vec2 origin;
uniform mediump vec2 anchorPoint;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
uniform mediump float borderlineWidth;
uniform mediump float borderlineOffset;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
uniform mediump vec4 cornerRadius;
uniform mediump float cornerRadiusPolicy;
#endif
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
vRectSize = visualSize * 0.5;
vOptRectSize = vRectSize;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_BORDERLINE
mediump float minSize = min(visualSize.x, visualSize.y) + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth;
#else
mediump float minSize = min(visualSize.x, visualSize.y);
#endif
mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
vPosition = aPosition * (visualSize + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth);
vertexPosition.xy *= (1.0 + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth / visualSize);
vOptRectSize -= (1.0 - clamp(borderlineOffset, -1.0, 1.0)) * 0.5 * borderlineWidth + 1.0;
-#elif IS_REQUIRED_ROUNDED_CORNER
+#elif defined(IS_REQUIRED_ROUNDED_CORNER)
vPosition = aPosition * visualSize;
#else
mediump vec2 vPosition = aPosition * visualSize;
#endif
-#if USER_SPACE
+#ifdef USER_SPACE
vertexPosition.xyz *= uSize;
#endif
vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;
- return vec4(vPosition + anchorPoint * visualSize + (visualOffset + origin) * uSize.xy, 0.0, 1.0);
+ return vec4(vPosition + anchorPoint * visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0);
}
void main()
-#ifndef IS_REQUIRED_ROUNDED_CORNER
-#define IS_REQUIRED_ROUNDED_CORNER 0
-#endif
-#ifndef IS_REQUIRED_BORDERLINE
-#define IS_REQUIRED_BORDERLINE 0
-#endif
-#ifndef IS_REQUIRED_ALPHA_MASKING
-#define IS_REQUIRED_ALPHA_MASKING 0
-#endif
-#ifndef ATLAS_DEFAULT_WARP
-#define ATLAS_DEFAULT_WARP 0
-#endif
-#ifndef ATLAS_CUSTOM_WARP
-#define ATLAS_CUSTOM_WARP 0
-#endif
-
INPUT mediump vec2 vTexCoord;
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
INPUT mediump vec2 vPosition;
INPUT mediump vec2 vRectSize;
INPUT mediump vec2 vOptRectSize;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
INPUT mediump vec4 vCornerRadius;
#endif
#endif
uniform sampler2D sTexture;
-#if IS_REQUIRED_ALPHA_MASKING
+#ifdef IS_REQUIRED_ALPHA_MASKING
uniform sampler2D sMaskTexture;
INPUT mediump vec2 vMaskTexCoord;
#endif
-#if ATLAS_DEFAULT_WARP
+#ifdef ATLAS_DEFAULT_WARP
uniform mediump vec4 uAtlasRect;
-#elif ATLAS_CUSTOM_WARP
+#elif defined(ATLAS_CUSTOM_WARP)
// WrapMode -- 0: CLAMP; 1: REPEAT; 2: REFLECT;
uniform lowp vec2 wrapMode;
#endif
uniform lowp vec4 uColor;
uniform lowp vec3 mixColor;
uniform lowp float preMultipliedAlpha;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
uniform mediump float borderlineWidth;
uniform mediump float borderlineOffset;
uniform lowp vec4 borderlineColor;
uniform lowp vec4 uActorColor;
#endif
-#if ATLAS_CUSTOM_WARP
+#ifdef ATLAS_CUSTOM_WARP
mediump float wrapCoordinate( mediump vec2 range, mediump float coordinate, lowp float wrap )
{
mediump float coord;
}
#endif
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
// Global values both rounded corner and borderline use
// radius of rounded corner on this quadrant
void calculateCornerRadius()
{
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
gRadius =
mix(
mix(vCornerRadius.x, vCornerRadius.y, sign(vPosition.x) * 0.5 + 0.5),
{
gFragmentPosition = abs(vPosition) - vRectSize;
gCenterPosition = -gRadius;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
gCenterPosition += borderlineWidth * (clamp(borderlineOffset, -1.0, 1.0) + 1.0) * 0.5;
#endif
gDiff = gFragmentPosition - gCenterPosition;
gMaxOutlinePotential = gRadius + gPotentialRange;
gMinOutlinePotential = gRadius - gPotentialRange;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
gMaxInlinePotential = gMaxOutlinePotential - borderlineWidth;
gMinInlinePotential = gMinOutlinePotential - borderlineWidth;
#else
}
#endif
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
{
mediump float potential = gPotential;
}
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
mediump float calculateCornerOpacity()
{
mediump float potential = gPotential;
void main()
{
-#if ATLAS_DEFAULT_WARP
+#ifdef ATLAS_DEFAULT_WARP
mediump vec2 texCoord = clamp( mix( uAtlasRect.xy, uAtlasRect.zw, vTexCoord ), uAtlasRect.xy, uAtlasRect.zw );
-#elif ATLAS_CUSTOM_WARP
+#elif defined(ATLAS_CUSTOM_WARP)
mediump vec2 texCoord = vec2( wrapCoordinate( uAtlasRect.xz, vTexCoord.x, wrapMode.x ),
wrapCoordinate( uAtlasRect.yw, vTexCoord.y, wrapMode.y ) );
#else
lowp vec4 textureColor = TEXTURE( sTexture, texCoord ) * vec4( mixColor, 1.0 ) * uColor;
-#if IS_REQUIRED_ALPHA_MASKING
+#ifdef IS_REQUIRED_ALPHA_MASKING
mediump float maskAlpha = TEXTURE(sMaskTexture, vMaskTexCoord).a;
textureColor.a *= maskAlpha;
textureColor.rgb *= mix(1.0, maskAlpha, preMultipliedAlpha);
#endif
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
// skip most potential calculate for performance
if(abs(vPosition.x) < vOptRectSize.x && abs(vPosition.y) < vOptRectSize.y)
{
PreprocessPotential();
#endif
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
textureColor = convertBorderlineColor(textureColor);
#endif
OUT_COLOR = textureColor;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
mediump float opacity = calculateCornerOpacity();
OUT_COLOR.a *= opacity;
OUT_COLOR.rgb *= mix(1.0, opacity, preMultipliedAlpha);
#endif
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
}
#endif
}
-#ifndef IS_REQUIRED_ROUNDED_CORNER
-#define IS_REQUIRED_ROUNDED_CORNER 0
-#endif
-#ifndef IS_REQUIRED_BORDERLINE
-#define IS_REQUIRED_BORDERLINE 0
-#endif
-#ifndef IS_REQUIRED_ALPHA_MASKING
-#define IS_REQUIRED_ALPHA_MASKING 0
-#endif
-
INPUT mediump vec2 aPosition;
OUTPUT mediump vec2 vTexCoord;
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
OUTPUT mediump vec2 vPosition;
OUTPUT mediump vec2 vRectSize;
OUTPUT mediump vec2 vOptRectSize;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
OUTPUT mediump vec4 vCornerRadius;
#endif
#endif
uniform mediump vec4 offsetSizeMode;
uniform mediump vec2 origin;
uniform mediump vec2 anchorPoint;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
uniform mediump float borderlineWidth;
uniform mediump float borderlineOffset;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
uniform mediump vec4 cornerRadius;
uniform mediump float cornerRadiusPolicy;
#endif
-#if IS_REQUIRED_ALPHA_MASKING
+#ifdef IS_REQUIRED_ALPHA_MASKING
OUTPUT mediump vec2 vMaskTexCoord;
uniform lowp float cropToMask;
uniform mediump vec2 maskTextureRatio;
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy * size, size, offsetSizeMode.zw) + extraSize;
- vec2 visualOffset = mix(offset, offset/uSize.xy, offsetSizeMode.xy);
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw) + extraSize;
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
vRectSize = visualSize * 0.5;
vOptRectSize = vRectSize;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_BORDERLINE
mediump float minSize = min(visualSize.x, visualSize.y) + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth;
#else
mediump float minSize = min(visualSize.x, visualSize.y);
vOptRectSize -= 0.2929 * maxRadius + 1.0;
#endif
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
vPosition = aPosition * (visualSize + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth);
vOptRectSize -= (1.0 - clamp(borderlineOffset, -1.0, 1.0)) * 0.5 * borderlineWidth + 1.0;
-#elif IS_REQUIRED_ROUNDED_CORNER
+#elif defined(IS_REQUIRED_ROUNDED_CORNER)
vPosition = aPosition * visualSize;
#else
mediump vec2 vPosition = aPosition * visualSize;
#endif
vec4 finalPixelArea = pixelArea;
-#if IS_REQUIRED_ALPHA_MASKING
+#ifdef IS_REQUIRED_ALPHA_MASKING
finalPixelArea = mix(pixelArea,
vec4(
vec2(0.5) + (pixelArea.xy - vec2(0.5)) * maskTextureRatio,
#endif
vTexCoord = finalPixelArea.xy + finalPixelArea.zw * (vPosition.xy / max(vec2(1.0), visualSize) + vec2(0.5));
- return vec4(vPosition + anchorPoint * visualSize + (visualOffset + origin) * uSize.xy, 0.0, 1.0);
+ return vec4(vPosition + anchorPoint * visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0);
}
void main()
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw );
float scaleFactor = min( visualSize.x, visualSize.y );
vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
- vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
- return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+ vec3 visualOffset = vec3( offset * offsetSizeMode.xy + offset * uSize.xy * (1.0 - offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+ return vec4( (aPosition + anchorPointFlipY)*scaleFactor + visualOffset + originFlipY * uSize, 1.0 );
}
void main()
float scaleFactor = min( visualSize.x, visualSize.y );
vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
- vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
- return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+ vec3 visualOffset = vec3( offset * offsetSizeMode.xy + offset * uSize.xy * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+ return vec4( (aPosition + anchorPointFlipY)*scaleFactor + visualOffset + originFlipY * uSize, 1.0 );
}
void main()
float scaleFactor = min( visualSize.x, visualSize.y );
vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
- vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
- return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+ vec3 visualOffset = vec3( offset * offsetSizeMode.xy + offset * uSize.xy * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+ return vec4( (aPosition + anchorPointFlipY)*scaleFactor + visualOffset + originFlipY * uSize, 1.0 );
}
void main()
void main()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw ) + extraSize;
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
mediump vec2 size = visualSize.xy;
mediump vec4 gridPosition = vec4( fixedFactor * fixedScaleDownRate + ( size - fixedTotal * fixedScaleDownRate ) * stretch, 0.0, 1.0 );
mediump vec4 vertexPosition = gridPosition;
vertexPosition.xy -= size * vec2( 0.5, 0.5 );
- vertexPosition.xy += anchorPoint*size + (visualOffset + origin)*uSize.xy;
+ vertexPosition.xy += anchorPoint*size + visualOffset + origin * uSize.xy;
vertexPosition = uMvpMatrix * vertexPosition;
mediump vec2 fixedTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].x, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].x );
mediump vec2 stretchTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].y, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].y );
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw ) + extraSize;
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
// Scale down if fixedTotal is bigger than visualSize
mediump float fixedScaleDownRate = min(1.0, min(visualSize.x / fixedTotal.x, visualSize.y / fixedTotal.y));
mediump vec4 gridPosition = vec4( fixedFactor * fixedScaleDownRate + ( visualSize.xy - fixedTotal * fixedScaleDownRate ) * stretch / stretchTotal, 0.0, 1.0 );
mediump vec4 vertexPosition = gridPosition;
vertexPosition.xy -= visualSize.xy * vec2( 0.5, 0.5 );
- vertexPosition.xy += anchorPoint*visualSize + (visualOffset + origin)*uSize.xy;
+ vertexPosition.xy += anchorPoint*visualSize + visualOffset + origin * uSize.xy;
vertexPosition = uMvpMatrix * vertexPosition;
vTexCoord = ( fixedFactor + stretch ) / ( fixedTotal + stretchTotal );
float scaleFactor = min( visualSize.x / uObjectDimensions.x, visualSize.y / uObjectDimensions.y );
vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
- vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+ vec3 visualOffset = vec3( offset * offsetSizeMode.xy + offset * uSize.xy * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
- return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+ return vec4( (aPosition + anchorPointFlipY)*scaleFactor + visualOffset + originFlipY * uSize, 1.0 );
}
void main()
void main()
{
- highp vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy );
- highp vec2 visualSize = mix( uSize.xy * size, size, offsetSizeMode.zw );
+ highp vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw);
+ highp vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
vTexCoord.x = ( uDelta + uHorizontalAlign * ( uTextureSize.x - visualSize.x - uGap ) + aPosition.x * visualSize.x - uGap * 0.5 ) / uTextureSize.x + 0.5;
vTexCoord.y = ( uVerticalAlign * ( uTextureSize.y - visualSize.y ) + aPosition.y * visualSize.y ) / ( uTextureSize.y ) + 0.5;
- highp vec4 vertexPosition = vec4( ( aPosition + anchorPoint ) * visualSize + ( visualOffset + origin ) * uSize.xy, 0.0, 1.0 );
+ highp vec4 vertexPosition = vec4( ( aPosition + anchorPoint ) * visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0 );
gl_Position = uMvpMatrix * vertexPosition;
}
\ No newline at end of file
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
- return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
+ return vec4( (aPosition + anchorPoint) * visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0 );
}
void main()
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
- return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
+ return vec4( (aPosition + anchorPoint)*visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0 );
}
void main()
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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 Property::Map StyleManager::GetConfigurations()
+const Property::Map& StyleManager::GetConfigurations()
{
DALI_LOG_STREAM(gLogFilter, Debug::Concise, "GetConfigurations()\n On entry, mThemeBuilder: " << (bool(mThemeBuilder) ? "Created" : "Empty") << " mThemeFile: " << mThemeFile);
- Property::Map result;
- if(mThemeBuilder)
- {
- result = mThemeBuilder.GetConfigurations();
- }
- else
+ if(!mThemeBuilder)
{
DALI_LOG_STREAM(gLogFilter, Debug::Concise, "GetConfigurations() Loading default theme");
- bool themeLoaded = false;
-
mThemeBuilder = CreateBuilder(mThemeBuilderConstants);
// Load default theme because this is first try to load stylesheet.
- themeLoaded = LoadJSON(mThemeBuilder, mDefaultThemeFilePath);
- mThemeFile = mDefaultThemeFilePath;
-
- if(themeLoaded)
- {
- result = mThemeBuilder.GetConfigurations();
- }
+#if defined(DEBUG_ENABLED)
+ bool themeLoaded = LoadJSON(mThemeBuilder, mDefaultThemeFilePath);
DALI_LOG_STREAM(gLogFilter, Debug::Concise, " themeLoaded" << (themeLoaded ? "success" : "failure"));
+#else
+ LoadJSON(mThemeBuilder, mDefaultThemeFilePath);
+#endif
+
+ mThemeFile = mDefaultThemeFilePath;
}
+#if defined(DEBUG_ENABLED)
+ Property::Map result = mThemeBuilder.GetConfigurations();
DALI_LOG_STREAM(gLogFilter, Debug::Concise, "GetConfigurations()\n On exit, result Count: " << (result.Count() != 0));
DALI_LOG_STREAM(gLogFilter, Debug::Verbose, " result: " << result);
+#endif
- return result;
+ return mThemeBuilder.GetConfigurations();
}
void StyleManager::SetBrokenImageUrl(DevelStyleManager::BrokenImageType brokenImageType, const std::string& brokenImageUrl)
{
- int brokenType = static_cast<int>(brokenImageType);
- mBrokenImageUrls[brokenType] = brokenImageUrl;
+ int brokenType = static_cast<int>(brokenImageType);
+ mBrokenImageUrls[brokenType] = brokenImageUrl;
Toolkit::StyleManager styleManager = StyleManager::Get();
mBrokenImageChangedSignal.Emit(styleManager);
}
#define DALI_TOOLKIT_INTERNAL_STYLE_MANAGER_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/builder/builder.h>
+#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
#include <dali-toolkit/internal/builder/style.h>
#include <dali-toolkit/public-api/styling/style-manager.h>
-#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
namespace Dali
{
/**
* @copydoc Toolkit::StyleManager::GetConfigurations
*/
- const Property::Map GetConfigurations();
+ const Property::Map& GetConfigurations();
/**
* @copydoc Toolkit::DevelStyleManager::SetBrokenImageUrl
Toolkit::Internal::FeedbackStyle* mFeedbackStyle; ///< Feedback style
- std::vector<std::string> mBrokenImageUrls; ///< Broken Image Urls received from user
+ std::vector<std::string> mBrokenImageUrls; ///< Broken Image Urls received from user
// Signals
Toolkit::StyleManager::StyleChangedSignalType mControlStyleChangeSignal; ///< Emitted when the style( theme/font ) changes for the controls to style themselves
markupProcessData.characterSpacingCharacterRuns.Resize(characterSpacingCharacterRunIndex);
#ifdef DEBUG_ENABLED
- for(unsigned int i = 0; i < colorRunIndex; ++i)
+ for(uint32_t i = 0; gLogFilter->IsEnabledFor(Debug::Verbose) && i < colorRunIndex; ++i)
{
ColorRun& run = markupProcessData.colorRuns[i];
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "run[%d] index: %d, length: %d, color %f,%f,%f,%f\n", i, run.characterRun.characterIndex, run.characterRun.numberOfCharacters, run.color.r, run.color.g, run.color.b, run.color.a);
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
scriptRunEndIt);
#ifdef DEBUG_ENABLED
+ if(gLogFilter->IsEnabledFor(Debug::Verbose))
{
Dali::TextAbstraction::FontDescription description;
fontClient.GetDescription(fontId, description);
}
#ifdef DEBUG_ENABLED
+ if(gLogFilter->IsEnabledFor(Debug::Verbose))
{
Dali::TextAbstraction::FontDescription description;
fontClient.GetDescription(fontId, description);
glyphBufferData.width,
glyphBufferData.height,
glyphBufferData.format,
- PixelData::DELETE_ARRAY);
+ PixelData::FREE);
if(bitmap)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "%s\n", metrics.mVerboseGlyphCounts.c_str());
- for(uint32_t i = 0; i < metrics.mAtlasMetrics.mAtlasCount; ++i)
+ for(uint32_t i = 0; gLogFilter->IsEnabledFor(Debug::Verbose) && i < metrics.mAtlasMetrics.mAtlasCount; ++i)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, " Atlas [%i] %sPixels: %s Size: %ix%i, BlockSize: %ix%i, BlocksUsed: %i/%i\n", i + 1, i > 8 ? "" : " ", metrics.mAtlasMetrics.mAtlasMetrics[i].mPixelFormat == Pixel::L8 ? "L8 " : "BGRA", metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mWidth, metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mHeight, metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mBlockWidth, metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mBlockHeight, metrics.mAtlasMetrics.mAtlasMetrics[i].mBlocksUsed, metrics.mAtlasMetrics.mAtlasMetrics[i].mTotalBlocks);
}
const int32_t xOffset = data.horizontalOffset + position->x;
// Whether the given glyph is a color one.
- const bool isColorGlyph = data.glyphBitmap.isColorEmoji || data.glyphBitmap.isColorBitmap;
- const uint32_t glyphPixelSize = Pixel::GetBytesPerPixel(data.glyphBitmap.format);
- const uint32_t alphaIndex = glyphPixelSize - 1u;
+ const bool isColorGlyph = data.glyphBitmap.isColorEmoji || data.glyphBitmap.isColorBitmap;
+ const uint32_t glyphPixelSize = Pixel::GetBytesPerPixel(data.glyphBitmap.format);
+ const uint32_t glyphAlphaIndex = glyphPixelSize - 1u;
// Determinate iterator range.
const int32_t lineIndexRangeMin = std::max(0, -yOffset);
if(Pixel::RGBA8888 == pixelFormat)
{
- const bool swapChannelsBR = Pixel::BGRA8888 == data.glyphBitmap.format;
-
uint32_t* bitmapBuffer = reinterpret_cast<uint32_t*>(data.bitmapBuffer.GetBuffer());
+ // Skip basic line.
+ bitmapBuffer += (lineIndexRangeMin + yOffset) * static_cast<int32_t>(data.width);
// Fast-cut if style is MASK or OUTLINE. Outline not shown for color glyph.
// Just overwrite transparent color and return.
{
for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
{
- const int32_t yOffsetIndex = yOffset + lineIndex;
- const int32_t verticalOffset = yOffsetIndex * data.width;
-
// We can use memset here.
- memset(bitmapBuffer + verticalOffset + xOffset + indexRangeMin, 0, (indexRangeMax - indexRangeMin) * sizeof(uint32_t));
+ memset(bitmapBuffer + xOffset + indexRangeMin, 0, (indexRangeMax - indexRangeMin) * sizeof(uint32_t));
+ bitmapBuffer += data.width;
}
return;
}
+ const bool swapChannelsBR = Pixel::BGRA8888 == data.glyphBitmap.format;
+
// Pointer to the color glyph if there is one.
- const uint32_t* const colorGlyphBuffer = isColorGlyph ? reinterpret_cast<uint32_t*>(data.glyphBitmap.buffer) : NULL;
+ const uint8_t* glyphBuffer = data.glyphBitmap.buffer;
// Precalculate input color's packed result.
uint32_t packedInputColor = 0u;
*(packedInputColorBuffer + 1u) = static_cast<uint8_t>(color->g * 255);
*(packedInputColorBuffer) = static_cast<uint8_t>(color->r * 255);
+ // Skip basic line of glyph.
+ glyphBuffer += (lineIndexRangeMin) * static_cast<int32_t>(data.glyphBitmap.width) * glyphPixelSize;
+
// Traverse the pixels of the glyph line per line.
- for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
+ if(isColorGlyph)
{
- const int32_t yOffsetIndex = yOffset + lineIndex;
-
- const int32_t verticalOffset = yOffsetIndex * data.width;
- const int32_t glyphBufferOffset = lineIndex * static_cast<int32_t>(data.glyphBitmap.width);
- for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
+ for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
{
- const int32_t xOffsetIndex = xOffset + index;
-
- if(isColorGlyph)
+ for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
{
+ const int32_t xOffsetIndex = xOffset + index;
+
// Retrieves the color from the color glyph.
- uint32_t packedColorGlyph = *(colorGlyphBuffer + glyphBufferOffset + index);
+ uint32_t packedColorGlyph = *(reinterpret_cast<const uint32_t*>(glyphBuffer + (index << 2)));
uint8_t* packedColorGlyphBuffer = reinterpret_cast<uint8_t*>(&packedColorGlyph);
// Update the alpha channel.
}
// Set the color into the final pixel buffer.
- *(bitmapBuffer + verticalOffset + xOffsetIndex) = packedColorGlyph;
+ *(bitmapBuffer + xOffsetIndex) = packedColorGlyph;
}
- else
+ bitmapBuffer += data.width;
+ glyphBuffer += data.glyphBitmap.width * glyphPixelSize;
+ }
+ }
+ else
+ {
+ for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
+ {
+ for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
{
- // Pack the given color into a 32bit buffer. The alpha channel will be updated later for each pixel.
- // The format is RGBA8888.
- uint32_t packedColor = 0u;
- uint8_t* packedColorBuffer = reinterpret_cast<uint8_t*>(&packedColor);
-
// Update the alpha channel.
- const uint8_t alpha = *(data.glyphBitmap.buffer + glyphPixelSize * (glyphBufferOffset + index) + alphaIndex);
+ const uint8_t alpha = *(glyphBuffer + index * glyphPixelSize + glyphAlphaIndex);
// Copy non-transparent pixels only
if(alpha > 0u)
{
+ const int32_t xOffsetIndex = xOffset + index;
+
// Check alpha of overlapped pixels
- uint32_t& currentColor = *(bitmapBuffer + verticalOffset + xOffsetIndex);
+ uint32_t& currentColor = *(bitmapBuffer + xOffsetIndex);
uint8_t* packedCurrentColorBuffer = reinterpret_cast<uint8_t*>(¤tColor);
// For any pixel overlapped with the pixel in previous glyphs, make sure we don't
}
else
{
+ // Pack the given color into a 32bit buffer. The alpha channel will be updated later for each pixel.
+ // The format is RGBA8888.
+ uint32_t packedColor = 0u;
+ uint8_t* packedColorBuffer = reinterpret_cast<uint8_t*>(&packedColor);
+
// Color is pre-muliplied with its alpha.
*(packedColorBuffer + 3u) = MultiplyAndNormalizeColor(*(packedInputColorBuffer + 3u), currentAlpha);
*(packedColorBuffer + 2u) = MultiplyAndNormalizeColor(*(packedInputColorBuffer + 2u), currentAlpha);
}
}
}
+ bitmapBuffer += data.width;
+ glyphBuffer += data.glyphBitmap.width * glyphPixelSize;
}
}
}
- else
+ else // Pixel::L8
{
// Below codes required only if not color glyph.
if(!isColorGlyph)
{
- uint8_t* bitmapBuffer = reinterpret_cast<uint8_t*>(data.bitmapBuffer.GetBuffer());
+ uint8_t* bitmapBuffer = data.bitmapBuffer.GetBuffer();
+ const uint8_t* glyphBuffer = data.glyphBitmap.buffer;
+
+ // Skip basic line.
+ bitmapBuffer += (lineIndexRangeMin + yOffset) * static_cast<int32_t>(data.width);
+ glyphBuffer += (lineIndexRangeMin) * static_cast<int32_t>(data.glyphBitmap.width) * glyphPixelSize;
// Traverse the pixels of the glyph line per line.
for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
{
- const int32_t yOffsetIndex = yOffset + lineIndex;
-
- const int32_t verticalOffset = yOffsetIndex * data.width;
- const int32_t glyphBufferOffset = lineIndex * static_cast<int32_t>(data.glyphBitmap.width);
for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
{
const int32_t xOffsetIndex = xOffset + index;
// Update the alpha channel.
- const uint8_t alpha = *(data.glyphBitmap.buffer + glyphPixelSize * (glyphBufferOffset + index) + alphaIndex);
+ const uint8_t alpha = *(glyphBuffer + index * glyphPixelSize + glyphAlphaIndex);
// Copy non-transparent pixels only
if(alpha > 0u)
{
// Check alpha of overlapped pixels
- uint8_t& currentAlpha = *(bitmapBuffer + verticalOffset + xOffsetIndex);
+ uint8_t& currentAlpha = *(bitmapBuffer + xOffsetIndex);
// For any pixel overlapped with the pixel in previous glyphs, make sure we don't
// overwrite a previous bigger alpha with a smaller alpha (in order to avoid
currentAlpha = std::max(currentAlpha, alpha);
}
}
+
+ bitmapBuffer += data.width;
+ glyphBuffer += data.glyphBitmap.width * glyphPixelSize;
}
}
}
glyphData.verticalOffset += glyphData.glyphBitmap.outlineOffsetY;
}
- // delete the glyphBitmap.buffer as it is now copied into glyphData.bitmapBuffer
- delete[] glyphData.glyphBitmap.buffer;
+ // free the glyphBitmap.buffer as it is now copied into glyphData.bitmapBuffer
+ free(glyphData.glyphBitmap.buffer);
glyphData.glyphBitmap.buffer = NULL;
}
{
namespace Text
{
-const float DEFAULT_TEXTFIT_MIN = 10.f;
-const float DEFAULT_TEXTFIT_MAX = 100.f;
-const float DEFAULT_TEXTFIT_STEP = 1.f;
-const float DEFAULT_FONT_SIZE_SCALE = 1.f;
+const float DEFAULT_TEXTFIT_MIN = 10.f;
+const float DEFAULT_TEXTFIT_MAX = 100.f;
+const float DEFAULT_TEXTFIT_STEP = 1.f;
+const float DEFAULT_FONT_SIZE_SCALE = 1.f;
const float DEFAULT_DISABLED_COLOR_OPACITY = 0.3f;
//Forward declarations
Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
if(styleManager)
{
- bool temp;
- Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
- if(config["clearFocusOnEscape"].Get(temp))
- {
- mShouldClearFocusOnEscape = temp;
- }
+ const Property::Map& config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
+ const auto clearFocusOnEscapeValue = config.Find("clearFocusOnEscape", Property::Type::BOOLEAN);
+
+ // Default is true. If config don't have "clearFocusOnEscape" property, make it true.
+ mShouldClearFocusOnEscape = (!clearFocusOnEscapeValue || clearFocusOnEscapeValue->Get<bool>());
}
}
SHAPE_TEXT |
GET_GLYPH_METRICS);
- const OperationsMask sizeOperations = static_cast<OperationsMask>(LAYOUT | ALIGN | REORDER);
+ const OperationsMask sizeOperations = static_cast<OperationsMask>(LAYOUT | ALIGN | REORDER);
// Set the update info to relayout the whole text.
TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo;
void Controller::Relayouter::CalculateVerticalOffset(Controller::Impl& impl, const Size& controlSize)
{
- ModelPtr& model = impl.mModel;
- VisualModelPtr& visualModel = model->mVisualModel;
- Size layoutSize = model->mVisualModel->GetLayoutSize();
- Size oldLayoutSize = layoutSize;
- float offsetY = 0.f;
- bool needRecalc = false;
- float defaultFontLineHeight = impl.GetDefaultFontLineHeight();
+ ModelPtr& model = impl.mModel;
+ VisualModelPtr& visualModel = model->mVisualModel;
+ Size layoutSize = model->mVisualModel->GetLayoutSize();
+ Size oldLayoutSize = layoutSize;
+ float offsetY = 0.f;
+ bool needRecalc = false;
+ float defaultFontLineHeight = impl.GetDefaultFontLineHeight();
if(fabsf(layoutSize.height) < Math::MACHINE_EPSILON_1000)
{
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/image-loading.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/rendering/decorated-visual-renderer.h>
#include <memory>
// INTERNAL INCLUDES
{
namespace
{
-const int CUSTOM_PROPERTY_COUNT(10); // ltr, wrap, pixel area, crop to mask, mask texture ratio + border/corner
+const int CUSTOM_PROPERTY_COUNT(5); // ltr, wrap, pixel area, crop to mask, mask texture ratio
// stop behavior
DALI_ENUM_TO_STRING_TABLE_BEGIN(STOP_BEHAVIOR)
if(mAnimatedImageLoading)
{
- mImageCache = new RollingAnimatedImageCache(textureManager, mAnimatedImageLoading, mMaskingData, *this, mCacheSize, mBatchSize, IsSynchronousLoadingRequired(),mFactoryCache.GetPreMultiplyOnLoad());
+ mImageCache = new RollingAnimatedImageCache(textureManager, mAnimatedImageLoading, mMaskingData, *this, mCacheSize, mBatchSize, IsSynchronousLoadingRequired(), mFactoryCache.GetPreMultiplyOnLoad());
}
else if(mImageUrls)
{
Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
- mImpl->mRenderer = VisualRenderer::New(geometry, shader);
+ mImpl->mRenderer = DecoratedVisualRenderer::New(geometry, shader);
mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT);
// Register transform properties
{
if(mMaskingData && !mMaskingData->mPreappliedMasking)
{
- bool maskLoadFailed = true;
- TextureSet textures = mImpl->mRenderer.GetTextures();
+ bool maskLoadFailed = true;
+ TextureSet textures = mImpl->mRenderer.GetTextures();
if(textures && textures.GetTextureCount() >= TEXTURE_COUNT_FOR_GPU_ALPHA_MASK)
{
maskLoadFailed = false;
Debug::Filter* gAnimImgLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ANIMATED_IMAGE");
#define LOG_CACHE \
+ if(gAnimImgLogFilter->IsEnabledFor(Debug::Concise)) \
{ \
std::ostringstream oss; \
oss << "Size:" << mQueue.Count() << " [ "; \
mLoadState = TextureManager::LoadState::LOADING;
auto preMultiplyOnLoading = mPreMultiplyOnLoad ? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD
- : TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
+ : TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
TextureManager::TextureId loadTextureId = TextureManager::INVALID_TEXTURE_ID;
TextureSet textureSet = mTextureManager.LoadAnimatedImageTexture(mImageUrl,
Debug::Filter* gAnimImgLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ANIMATED_IMAGE");
#define LOG_CACHE \
+ if(gAnimImgLogFilter->IsEnabledFor(Debug::Concise)) \
{ \
std::ostringstream oss; \
oss << "Size:" << mQueue.Count() << " [ "; \
#include <dali/devel-api/common/stage.h>
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/rendering/decorated-visual-renderer.h>
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-signals-devel.h>
{
namespace
{
-const int CUSTOM_PROPERTY_COUNT(6); // 5 transform properties + pixel area,
+const int CUSTOM_PROPERTY_COUNT(1); // pixel area,
const Dali::Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
- mImpl->mRenderer = VisualRenderer::New(geometry, shader);
+ mImpl->mRenderer = DecoratedVisualRenderer::New(geometry, shader);
mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT);
TextureSet textureSet = TextureSet::New();
// EXTERNAL INCLUDES
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/rendering/decorated-visual-renderer.h>
//INTERNAL INCLUDES
#include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
{
namespace
{
-const int CUSTOM_PROPERTY_COUNT(6); // Blur Radius + border/corner
+const int CUSTOM_PROPERTY_COUNT(0);
VisualFactoryCache::ShaderType SHADER_TYPE_TABLE[6] =
{
ColorVisual::ColorVisual(VisualFactoryCache& factoryCache)
: Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::COLOR),
mBlurRadius(0.0f),
- mBlurRadiusIndex(Property::INVALID_INDEX),
mAlwaysUsingBlurRadius(false)
{
}
DALI_LOG_ERROR("ColorVisual:DoSetProperties:: BLUR_RADIUS property has incorrect type: %d\n", blurRadiusValue->GetType());
}
- if(mBlurRadiusIndex != Property::INVALID_INDEX)
- {
- mImpl->mRenderer.SetProperty(mBlurRadiusIndex, mBlurRadius);
- }
- else if(DALI_UNLIKELY(mImpl->mRenderer && (!EqualsZero(mBlurRadius) || mAlwaysUsingBlurRadius)))
+ if(DALI_UNLIKELY(mImpl->mRenderer))
{
// Unusual case. SetProperty called after OnInitialize().
// Assume that DoAction call UPDATE_PROPERTY.
- // We must regist properies into renderer, and update shader.
-
- // BlurRadius added by this action. Regist property to renderer.
- mBlurRadiusIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_NAME, mBlurRadius);
- mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
+ DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterBlurRadiusUniform();
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BLUR_RADIUS, mBlurRadius);
- // Change the shader must not be occured many times. we always have to use blur feature.
- mAlwaysUsingBlurRadius = true;
-
- // Change shader
- UpdateShader();
+ // Check whether we must update shader.
+ if(!mAlwaysUsingBlurRadius && IsBlurRequired())
+ {
+ // Change the shader must not be occured many times. we always have to use blur feature.
+ mAlwaysUsingBlurRadius = true;
+
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
+ // Change shader
+ if(!mImpl->mCustomShader)
+ {
+ UpdateShader();
+ }
+ }
}
}
}
map.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
map.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, mImpl->mMixColor);
- if(mImpl->mRenderer && mBlurRadiusIndex != Property::INVALID_INDEX)
+ if(mImpl->mRenderer)
{
// Update values from Renderer
- float blurRadius = mImpl->mRenderer.GetProperty<float>(mBlurRadiusIndex);
+ float blurRadius = mImpl->mRenderer.GetProperty<float>(DecoratedVisualRenderer::Property::BLUR_RADIUS);
map.Insert(Toolkit::DevelColorVisual::Property::BLUR_RADIUS, blurRadius);
}
else
Shader shader = GenerateShader();
- mImpl->mRenderer = VisualRenderer::New(geometry, shader);
+ mImpl->mRenderer = DecoratedVisualRenderer::New(geometry, shader);
mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT);
mImpl->mRenderer.SetProperty(VisualRenderer::Property::VISUAL_MIX_COLOR, Vector3(mImpl->mMixColor));
- if(!EqualsZero(mBlurRadius))
+ if(mAlwaysUsingBlurRadius || !EqualsZero(mBlurRadius))
{
- mBlurRadiusIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_NAME, mBlurRadius);
+ DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterBlurRadiusUniform();
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BLUR_RADIUS, mBlurRadius);
mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
}
bool roundedCorner = IsRoundedCornerRequired();
bool borderline = IsBorderlineRequired();
- bool blur = !EqualsZero(mBlurRadius) || mAlwaysUsingBlurRadius;
+ bool blur = IsBlurRequired();
int shaderTypeFlag = ColorVisualRequireFlag::DEFAULT;
if(roundedCorner)
std::string fragmentShaderPrefixList;
if(roundedCorner)
{
- vertexShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER 1\n";
- fragmentShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER 1\n";
+ vertexShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER\n";
+ fragmentShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER\n";
}
if(blur)
{
- vertexShaderPrefixList += "#define IS_REQUIRED_BLUR 1\n";
- fragmentShaderPrefixList += "#define IS_REQUIRED_BLUR 1\n";
+ vertexShaderPrefixList += "#define IS_REQUIRED_BLUR\n";
+ fragmentShaderPrefixList += "#define IS_REQUIRED_BLUR\n";
}
if(borderline)
{
- vertexShaderPrefixList += "#define IS_REQUIRED_BORDERLINE 1\n";
- fragmentShaderPrefixList += "#define IS_REQUIRED_BORDERLINE 1\n";
+ vertexShaderPrefixList += "#define IS_REQUIRED_BORDERLINE\n";
+ fragmentShaderPrefixList += "#define IS_REQUIRED_BORDERLINE\n";
}
shader = Shader::New(Dali::Shader::GetVertexShaderPrefix() + vertexShaderPrefixList + SHADER_COLOR_VISUAL_SHADER_VERT.data(),
Dali::Shader::GetFragmentShaderPrefix() + fragmentShaderPrefixList + SHADER_COLOR_VISUAL_SHADER_FRAG.data());
if((key.type == Property::Key::INDEX && key.indexKey == DevelColorVisual::Property::BLUR_RADIUS) || (key.type == Property::Key::STRING && key.stringKey == BLUR_RADIUS_NAME))
{
- mBlurRadiusIndex = mImpl->mRenderer.RegisterProperty(DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_NAME, mBlurRadius);
+ const bool updateShader = !mImpl->mCustomShader && !IsBlurRequired();
// Blur is animated now. we always have to use blur feature.
mAlwaysUsingBlurRadius = true;
- mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
-
- // Change shader
- UpdateShader();
+ if(updateShader)
+ {
+ // Update each values to renderer
+ DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterBlurRadiusUniform();
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BLUR_RADIUS, mBlurRadius);
- return Dali::Property(mImpl->mRenderer, mBlurRadiusIndex);
+ // Change shader
+ UpdateShader();
+ }
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
+ return Dali::Property(mImpl->mRenderer, DecoratedVisualRenderer::Property::BLUR_RADIUS);
}
Handle handle;
return Dali::Property(handle, Property::INVALID_INDEX);
}
+bool ColorVisual::IsBlurRequired() const
+{
+ float blurRadius = mBlurRadius;
+ if(mImpl->mRenderer)
+ {
+ // Update values from Renderer
+ blurRadius = mImpl->mRenderer.GetProperty<float>(DecoratedVisualRenderer::Property::BLUR_RADIUS);
+ }
+ return mAlwaysUsingBlurRadius || !EqualsZero(blurRadius);
+}
+
} // namespace Internal
} // namespace Toolkit
*/
Dali::Property OnGetPropertyObject(Dali::Property::Key key) override;
+protected:
+ /**
+ * @brief Query whether the visual requires to be blur.
+ *
+ * @return Returns true if the blur is required, false otherwise.
+ */
+ bool IsBlurRequired() const;
+
private:
// Undefined
ColorVisual(const ColorVisual& colorRenderer);
ColorVisual& operator=(const ColorVisual& colorRenderer);
private:
- float mBlurRadius; ///< The blur radius
- Property::Index mBlurRadiusIndex; ///< The blur radius property index
- bool mAlwaysUsingBlurRadius : 1; ///< Whether we need the blur radius in shader always.
+ float mBlurRadius; ///< The blur radius
+ bool mAlwaysUsingBlurRadius : 1; ///< Whether we need the blur radius in shader always.
};
} // namespace Internal
#include <dali/integration-api/debug.h>
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/object/property-array.h>
+#include <dali/public-api/rendering/decorated-visual-renderer.h>
#include <typeinfo>
// INTERNAL INCLUDES
{
namespace
{
-const int CUSTOM_PROPERTY_COUNT(6); // alignment + corner/border
+const int CUSTOM_PROPERTY_COUNT(1); // alignment
DALI_ENUM_TO_STRING_TABLE_BEGIN(UNITS)
DALI_ENUM_TO_STRING_WITH_SCOPE(Toolkit::GradientVisual::Units, OBJECT_BOUNDING_BOX)
sampler.SetWrapMode(wrap, wrap);
textureSet.SetSampler(0u, sampler);
- mImpl->mRenderer = VisualRenderer::New(geometry, shader);
+ mImpl->mRenderer = DecoratedVisualRenderer::New(geometry, shader);
mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT);
mImpl->mRenderer.SetTextures(textureSet);
if(roundedCorner)
{
- vertexShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER 1\n";
- fragmentShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER 1\n";
+ vertexShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER\n";
+ fragmentShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER\n";
}
if(borderline)
{
- vertexShaderPrefixList += "#define IS_REQUIRED_BORDERLINE 1\n";
- fragmentShaderPrefixList += "#define IS_REQUIRED_BORDERLINE 1\n";
+ vertexShaderPrefixList += "#define IS_REQUIRED_BORDERLINE\n";
+ fragmentShaderPrefixList += "#define IS_REQUIRED_BORDERLINE\n";
}
if(radialGradient)
{
- fragmentShaderPrefixList += "#define RADIAL 1\n";
+ fragmentShaderPrefixList += "#define RADIAL\n";
}
if(userspaceUnit)
{
- vertexShaderPrefixList += "#define USER_SPACE 1\n";
+ vertexShaderPrefixList += "#define USER_SPACE\n";
}
shader = Shader::New(Dali::Shader::GetVertexShaderPrefix() + vertexShaderPrefixList + SHADER_GRADIENT_VISUAL_SHADER_VERT.data(),
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
ALPHA_MASKING = 1 << 2,
};
-static constexpr auto SHADER_TYPE_COUNT = 8u;
+static constexpr auto SHADER_TYPE_COUNT = 8u;
VisualFactoryCache::ShaderType SHADER_TYPE_TABLE[SHADER_TYPE_COUNT] =
-{
- VisualFactoryCache::IMAGE_SHADER,
- VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER,
- VisualFactoryCache::IMAGE_SHADER_BORDERLINE,
- VisualFactoryCache::IMAGE_SHADER_ROUNDED_BORDERLINE,
- VisualFactoryCache::IMAGE_SHADER_MASKING,
- VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER_MASKING,
- VisualFactoryCache::IMAGE_SHADER_BORDERLINE_MASKING,
- VisualFactoryCache::IMAGE_SHADER_ROUNDED_BORDERLINE_MASKING
-};
+ {
+ VisualFactoryCache::IMAGE_SHADER,
+ VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER,
+ VisualFactoryCache::IMAGE_SHADER_BORDERLINE,
+ VisualFactoryCache::IMAGE_SHADER_ROUNDED_BORDERLINE,
+ VisualFactoryCache::IMAGE_SHADER_MASKING,
+ VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER_MASKING,
+ VisualFactoryCache::IMAGE_SHADER_BORDERLINE_MASKING,
+ VisualFactoryCache::IMAGE_SHADER_ROUNDED_BORDERLINE_MASKING};
} // unnamed namespace
Shader ImageVisualShaderFactory::GetShader(VisualFactoryCache& factoryCache, const ImageVisualShaderFeature::FeatureBuilder& featureBuilder)
{
- Shader shader;
+ Shader shader;
VisualFactoryCache::ShaderType shaderType = VisualFactoryCache::IMAGE_SHADER;
const auto& atlasing = featureBuilder.mTextureAtlas;
const auto& borderline = featureBuilder.mBorderline;
const auto& alphaMaskingOnRendering = featureBuilder.mAlphaMaskingOnRendering;
const auto& changeFragmentShader = (featureBuilder.mTexture && DevelTexture::IsNative(featureBuilder.mTexture))
- ? ImageVisualShaderFeature::ChangeFragmentShader::NEED_CHANGE
- : ImageVisualShaderFeature::ChangeFragmentShader::DONT_CHANGE;
+ ? ImageVisualShaderFeature::ChangeFragmentShader::NEED_CHANGE
+ : ImageVisualShaderFeature::ChangeFragmentShader::DONT_CHANGE;
if(atlasing == ImageVisualShaderFeature::TextureAtlas::ENABLED)
{
{
if(defaultTextureWrapping == ImageVisualShaderFeature::DefaultTextureWrapMode::APPLY)
{
- fragmentShaderPrefixList += "#define ATLAS_DEFAULT_WARP 1\n";
+ fragmentShaderPrefixList += "#define ATLAS_DEFAULT_WARP\n";
}
else
{
- fragmentShaderPrefixList += "#define ATLAS_CUSTOM_WARP 1\n";
+ fragmentShaderPrefixList += "#define ATLAS_CUSTOM_WARP\n";
}
}
else
{
if(roundedCorner == ImageVisualShaderFeature::RoundedCorner::ENABLED)
{
- vertexShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER 1\n";
- fragmentShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER 1\n";
+ vertexShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER\n";
+ fragmentShaderPrefixList += "#define IS_REQUIRED_ROUNDED_CORNER\n";
}
if(borderline == ImageVisualShaderFeature::Borderline::ENABLED)
{
- vertexShaderPrefixList += "#define IS_REQUIRED_BORDERLINE 1\n";
- fragmentShaderPrefixList += "#define IS_REQUIRED_BORDERLINE 1\n";
+ vertexShaderPrefixList += "#define IS_REQUIRED_BORDERLINE\n";
+ fragmentShaderPrefixList += "#define IS_REQUIRED_BORDERLINE\n";
}
if(alphaMaskingOnRendering == ImageVisualShaderFeature::AlphaMaskingOnRendering::ENABLED)
{
- vertexShaderPrefixList += "#define IS_REQUIRED_ALPHA_MASKING 1\n";
- fragmentShaderPrefixList += "#define IS_REQUIRED_ALPHA_MASKING 1\n";
+ vertexShaderPrefixList += "#define IS_REQUIRED_ALPHA_MASKING\n";
+ fragmentShaderPrefixList += "#define IS_REQUIRED_ALPHA_MASKING\n";
}
}
- std::string vertexShader = std::string(Dali::Shader::GetVertexShaderPrefix() + vertexShaderPrefixList + SHADER_IMAGE_VISUAL_SHADER_VERT.data());
+ std::string vertexShader = std::string(Dali::Shader::GetVertexShaderPrefix() + vertexShaderPrefixList + SHADER_IMAGE_VISUAL_SHADER_VERT.data());
std::string fragmentShader = std::string(Dali::Shader::GetFragmentShaderPrefix() + fragmentShaderPrefixList + SHADER_IMAGE_VISUAL_SHADER_FRAG.data());
if(changeFragmentShader == ImageVisualShaderFeature::ChangeFragmentShader::NEED_CHANGE)
#include <dali/devel-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
#include <dali/public-api/actors/layer.h>
+#include <dali/public-api/rendering/decorated-visual-renderer.h>
#include <cstring> // for strlen()
// INTERNAL HEADERS
{
namespace
{
-const int CUSTOM_PROPERTY_COUNT(12); // ltr, wrap, pixel area, atlas, pixalign, crop to mask, mask texture ratio + border/corner
+const int CUSTOM_PROPERTY_COUNT(7); // ltr, wrap, pixel area, atlas, pixalign, crop to mask, mask texture ratio
// fitting modes
DALI_ENUM_TO_STRING_TABLE_BEGIN(FITTING_MODE)
Shader shader = GenerateShader();
// Create the renderer
- mImpl->mRenderer = VisualRenderer::New(geometry, shader);
+ mImpl->mRenderer = DecoratedVisualRenderer::New(geometry, shader);
mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT);
//Register transform properties
if(useStandardShader)
{
- bool requiredAlphaMaskingOnRendering = (mMaskingData && !mMaskingData->mMaskImageLoadingFailed) ? !mMaskingData->mPreappliedMasking : false;
+ bool requiredAlphaMaskingOnRendering = (mMaskingData && !mMaskingData->mMaskImageLoadingFailed) ? !mMaskingData->mPreappliedMasking : false;
// Create and cache the standard shader
shader = mImageVisualShaderFactory.GetShader(
mFactoryCache,
{
if(mMaskingData && !mMaskingData->mPreappliedMasking)
{
- bool maskLoadFailed = true;
- TextureSet textures = mImpl->mRenderer.GetTextures();
+ bool maskLoadFailed = true;
+ TextureSet textures = mImpl->mRenderer.GetTextures();
if(textures && textures.GetTextureCount() >= TEXTURE_COUNT_FOR_GPU_ALPHA_MASK)
{
if(mMaskingData->mCropToMask)
// EXTERNAL INCLUDES
#include <dali/devel-api/common/stage.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/rendering/decorated-visual-renderer.h>
namespace Dali
{
{
namespace
{
-const int CUSTOM_PROPERTY_COUNT(6); // atlas + corner/border
+const int CUSTOM_PROPERTY_COUNT(1); // atlas
// property name
const Dali::Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
{
Shader shader = GenerateShader();
Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
- mImpl->mRenderer = VisualRenderer::New(geometry, shader);
+ mImpl->mRenderer = DecoratedVisualRenderer::New(geometry, shader);
mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT);
Vector2 dpi = Stage::GetCurrent().GetDpi();
mCornerRadius(Vector4::ZERO),
mCornerRadiusPolicy(1.0f),
mDepthIndex(0.0f),
- mBorderlineWidthIndex(Property::INVALID_INDEX),
- mBorderlineColorIndex(Property::INVALID_INDEX),
- mBorderlineOffsetIndex(Property::INVALID_INDEX),
- mCornerRadiusIndex(Property::INVALID_INDEX),
mFittingMode(fittingMode),
mFlags(0),
mResourceStatus(Toolkit::Visual::ResourceStatus::PREPARING),
Vector4 mCornerRadius;
float mCornerRadiusPolicy;
int mDepthIndex;
- Property::Index mBorderlineWidthIndex;
- Property::Index mBorderlineColorIndex;
- Property::Index mBorderlineOffsetIndex;
- Property::Index mCornerRadiusIndex;
FittingMode mFittingMode; ///< How the contents should fit the view
int mFlags;
Toolkit::Visual::ResourceStatus mResourceStatus;
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/rendering/decorated-visual-renderer.h>
#include <dali/public-api/rendering/visual-renderer.h>
//INTERNAL HEARDER
if(mImpl->mRenderer)
{
RegisterMixColor();
+ RegisterDecoration();
- if(IsRoundedCornerRequired())
- {
- mImpl->mCornerRadiusIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelVisual::Property::CORNER_RADIUS, CORNER_RADIUS, mImpl->mCornerRadius);
- mImpl->mRenderer.RegisterUniqueProperty(CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
-
- mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
- }
if(IsBorderlineRequired())
{
- mImpl->mBorderlineWidthIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelVisual::Property::BORDERLINE_WIDTH, BORDERLINE_WIDTH, mImpl->mBorderlineWidth);
- mImpl->mBorderlineColorIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelVisual::Property::BORDERLINE_COLOR, BORDERLINE_COLOR, mImpl->mBorderlineColor);
- mImpl->mBorderlineOffsetIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelVisual::Property::BORDERLINE_OFFSET, BORDERLINE_OFFSET, mImpl->mBorderlineOffset);
-
mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
}
+ else if(IsRoundedCornerRequired())
+ {
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
+ }
}
}
mImpl->mBorderlineWidth = width;
}
- if(mImpl->mBorderlineWidthIndex != Property::INVALID_INDEX)
- {
- mImpl->mRenderer.SetProperty(mImpl->mBorderlineWidthIndex, mImpl->mBorderlineWidth);
- }
- else if(DALI_UNLIKELY(mImpl->mRenderer && IsBorderlineRequired()))
+ if(DALI_UNLIKELY(mImpl->mRenderer))
{
// Unusual case. SetProperty called after OnInitialize().
// Assume that DoAction call UPDATE_PROPERTY.
- // We must regist properies into renderer, and update shader.
+ DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterBorderlineUniform();
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH, mImpl->mBorderlineWidth);
- // Borderline added by this action. Register property to renderer.
- mImpl->mBorderlineWidthIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelVisual::Property::BORDERLINE_WIDTH, BORDERLINE_WIDTH, mImpl->mBorderlineWidth);
- mImpl->mBorderlineColorIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelVisual::Property::BORDERLINE_COLOR, BORDERLINE_COLOR, mImpl->mBorderlineColor);
- mImpl->mBorderlineOffsetIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelVisual::Property::BORDERLINE_OFFSET, BORDERLINE_OFFSET, mImpl->mBorderlineOffset);
-
- // Make Blend mode ON_WITHOUT_CULL for transparent mix color.
- mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
+ // Check whether we must update shader.
+ if(!mImpl->mAlwaysUsingBorderline && IsBorderlineRequired())
+ {
+ // Make Blend mode ON_WITHOUT_CULL for transparent mix color.
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
- // Change the shader must not be occured many times. we always have to use borderline feature.
- mImpl->mAlwaysUsingBorderline = true;
+ // Change the shader must not be occured many times. we always have to use borderline feature.
+ mImpl->mAlwaysUsingBorderline = true;
- // Change shader
- needUpdateShader = true;
+ // Change shader
+ if(!mImpl->mCustomShader)
+ {
+ needUpdateShader = true;
+ }
+ }
}
break;
}
mImpl->mBorderlineColor = color;
}
- if(mImpl->mBorderlineColorIndex != Property::INVALID_INDEX)
+ if(DALI_UNLIKELY(mImpl->mRenderer))
{
- mImpl->mRenderer.SetProperty(mImpl->mBorderlineColorIndex, mImpl->mBorderlineColor);
+ // Unusual case. SetProperty called after OnInitialize().
+ // Assume that DoAction call UPDATE_PROPERTY.
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, mImpl->mBorderlineColor);
}
break;
}
mImpl->mBorderlineOffset = offset;
}
- if(mImpl->mBorderlineOffsetIndex != Property::INVALID_INDEX)
+ if(DALI_UNLIKELY(mImpl->mRenderer))
{
- mImpl->mRenderer.SetProperty(mImpl->mBorderlineOffsetIndex, mImpl->mBorderlineOffset);
+ // Unusual case. SetProperty called after OnInitialize().
+ // Assume that DoAction call UPDATE_PROPERTY.
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET, mImpl->mBorderlineOffset);
}
break;
}
}
}
- if(mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
- {
- mImpl->mRenderer.SetProperty(mImpl->mCornerRadiusIndex, mImpl->mCornerRadius);
- }
- else if(DALI_UNLIKELY(mImpl->mRenderer && IsRoundedCornerRequired()))
+ if(DALI_UNLIKELY(mImpl->mRenderer))
{
// Unusual case. SetProperty called after OnInitialize().
// Assume that DoAction call UPDATE_PROPERTY.
- // We must regist properies into renderer, and update shader.
+ DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterCornerRadiusUniform();
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS, mImpl->mCornerRadius);
- // CornerRadius added by this action. Regist property to renderer.
- mImpl->mCornerRadiusIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelVisual::Property::CORNER_RADIUS, CORNER_RADIUS, mImpl->mCornerRadius);
- mImpl->mRenderer.RegisterUniqueProperty(CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
+ // Check whether we must update shader.
+ if(!mImpl->mAlwaysUsingCornerRadius && IsRoundedCornerRequired())
+ {
+ // Change the shader must not be occured many times. we always have to use corner radius feature.
+ mImpl->mAlwaysUsingCornerRadius = true;
- // Change the shader must not be occured many times. we always have to use corner radius feature.
- mImpl->mAlwaysUsingCornerRadius = true;
+ if(!IsBorderlineRequired())
+ {
+ // If IsBorderlineRequired is true, BLEND_MODE is already BlendMode::ON_WITHOUT_CULL. So we don't overwrite it.
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
+ }
- if(!IsBorderlineRequired())
- {
- // If IsBorderlineRequired is true, BLEND_MODE is already BlendMode::ON_WITHOUT_CULL. So we don't overwrite it.
- mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
+ // Change shader
+ if(!mImpl->mCustomShader)
+ {
+ needUpdateShader = true;
+ }
}
-
- // Change shader
- needUpdateShader = true;
}
+
break;
}
case Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY:
case Toolkit::Visual::Transform::Policy::ABSOLUTE:
{
mImpl->mCornerRadiusPolicy = policy;
- if(DALI_UNLIKELY(mImpl->mRenderer && mImpl->mCornerRadiusIndex != Property::INVALID_INDEX))
+ if(DALI_UNLIKELY(mImpl->mRenderer))
{
// Unusual case. SetProperty called after OnInitialize().
// Assume that DoAction call UPDATE_PROPERTY.
- // We must update properies result into renderer
- // Note : mImpl->mCornerRadiusIndex is not INVALID_INDEX.
- // So CornerRadiusPolicy property is already registed.
- mImpl->mRenderer.SetProperty(mImpl->mRenderer.GetPropertyIndex(CORNER_RADIUS_POLICY), mImpl->mCornerRadiusPolicy);
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
}
break;
}
mImpl->mTransform.mOffset = mImpl->mRenderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_OFFSET);
mImpl->mTransform.mSize = mImpl->mRenderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_SIZE);
- if(mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
- {
- mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<Vector4>(mImpl->mCornerRadiusIndex);
- }
- if(mImpl->mBorderlineWidthIndex != Property::INVALID_INDEX)
+ if(IsTypeAvailableForCornerRadius(mImpl->mType))
{
- mImpl->mBorderlineWidth = mImpl->mRenderer.GetProperty<float>(mImpl->mBorderlineWidthIndex);
+ mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
}
- if(mImpl->mBorderlineColorIndex != Property::INVALID_INDEX)
+ if(IsTypeAvailableForBorderline(mImpl->mType))
{
- mImpl->mBorderlineColor = mImpl->mRenderer.GetProperty<Vector4>(mImpl->mBorderlineColorIndex);
- }
- if(mImpl->mBorderlineOffsetIndex != Property::INVALID_INDEX)
- {
- mImpl->mBorderlineOffset = mImpl->mRenderer.GetProperty<float>(mImpl->mBorderlineOffsetIndex);
+ mImpl->mBorderlineWidth = mImpl->mRenderer.GetProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
+ mImpl->mBorderlineColor = mImpl->mRenderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
+ mImpl->mBorderlineOffset = mImpl->mRenderer.GetProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET);
}
}
// If VisualType doesn't support rounded corner, always return false.
if(IsTypeAvailableForCornerRadius(mImpl->mType))
{
- if(mImpl->mRenderer && mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
+ if(mImpl->mRenderer)
{
// Update values from Renderer
- mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<Vector4>(mImpl->mCornerRadiusIndex);
+ Property::Value value = mImpl->mRenderer.GetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS);
+ value.Get(mImpl->mCornerRadius);
}
- return !(mImpl->mCornerRadius == Vector4::ZERO) || mImpl->mAlwaysUsingCornerRadius;
+ return mImpl->mAlwaysUsingCornerRadius || !(mImpl->mCornerRadius == Vector4::ZERO);
}
return false;
}
// If VisualType doesn't support borderline, always return false.
if(IsTypeAvailableForBorderline(mImpl->mType))
{
- if(mImpl->mRenderer && mImpl->mBorderlineWidthIndex != Property::INVALID_INDEX)
+ if(mImpl->mRenderer)
{
// Update values from Renderer
- mImpl->mBorderlineWidth = mImpl->mRenderer.GetProperty<float>(mImpl->mBorderlineWidthIndex);
+ Property::Value value = mImpl->mRenderer.GetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
+ value.Get(mImpl->mBorderlineWidth);
}
- return !EqualsZero(mImpl->mBorderlineWidth) || mImpl->mAlwaysUsingBorderline;
+ return mImpl->mAlwaysUsingBorderline || !EqualsZero(mImpl->mBorderlineWidth);
}
return false;
}
}
}
+void Visual::Base::RegisterDecoration()
+{
+ if(mImpl->mRenderer)
+ {
+ if(IsTypeAvailableForCornerRadius(mImpl->mType))
+ {
+ if(mImpl->mAlwaysUsingCornerRadius || !(mImpl->mCornerRadius == Vector4::ZERO))
+ {
+ DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterCornerRadiusUniform();
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS, mImpl->mCornerRadius);
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
+ }
+ }
+ if(IsTypeAvailableForBorderline(mImpl->mType))
+ {
+ if(mImpl->mAlwaysUsingBorderline || !EqualsZero(mImpl->mBorderlineWidth))
+ {
+ DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterBorderlineUniform();
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH, mImpl->mBorderlineWidth);
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, mImpl->mBorderlineColor);
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET, mImpl->mBorderlineOffset);
+ }
+ }
+ }
+}
+
void Visual::Base::SetMixColor(const Vector4& color)
{
mImpl->mMixColor = color;
{
return VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA;
}
+ case Dali::Toolkit::DevelVisual::Property::CORNER_RADIUS:
+ {
+ return DecoratedVisualRenderer::Property::CORNER_RADIUS;
+ }
+ case Dali::Toolkit::DevelVisual::Property::BORDERLINE_WIDTH:
+ {
+ return DecoratedVisualRenderer::Property::BORDERLINE_WIDTH;
+ }
+ case Dali::Toolkit::DevelVisual::Property::BORDERLINE_COLOR:
+ {
+ return DecoratedVisualRenderer::Property::BORDERLINE_COLOR;
+ }
+ case Dali::Toolkit::DevelVisual::Property::BORDERLINE_OFFSET:
+ {
+ return DecoratedVisualRenderer::Property::BORDERLINE_OFFSET;
+ }
}
Property::Index index = mImpl->mRenderer.GetPropertyIndex(key);
Internal::TransitionData::Animator& animator)
{
#if defined(DEBUG_ENABLED)
+ if(gVisualBaseLogFilter->IsEnabledFor(Debug::General))
{
std::ostringstream oss;
oss << "Visual::Base::AnimateProperty(Visual:" << mImpl->mName << " Property:" << animator.propertyKey << " Target: " << animator.targetValue << std::endl;
return Dali::Property(handle, Property::INVALID_INDEX);
}
- // Default animatable properties from VisualRenderer
switch(GetIntKey(key))
{
+ // Default animatable properties from VisualRenderer
case Toolkit::Visual::Property::MIX_COLOR:
{
return Dali::Property(mImpl->mRenderer, VisualRenderer::Property::VISUAL_MIX_COLOR);
{
return Dali::Property(mImpl->mRenderer, VisualRenderer::Property::TRANSFORM_SIZE);
}
- default:
- {
- if(key.type == Property::Key::INDEX &&
- ((mImpl->mType == Toolkit::Visual::COLOR && key.indexKey == ColorVisual::Property::MIX_COLOR) ||
- (mImpl->mType == Toolkit::Visual::PRIMITIVE && key.indexKey == PrimitiveVisual::Property::MIX_COLOR)))
- {
- return Dali::Property(mImpl->mRenderer, VisualRenderer::Property::VISUAL_MIX_COLOR);
- }
- }
- }
- // Other cases
- Property::Index index = GetPropertyIndex(key);
- if(index == Property::INVALID_INDEX)
- {
- if(IsTypeAvailableForBorderline(mImpl->mType) &&
- ((key.type == Property::Key::INDEX && key.indexKey == DevelVisual::Property::BORDERLINE_WIDTH) || (key.type == Property::Key::STRING && key.stringKey == BORDERLINE_WIDTH) ||
- (key.type == Property::Key::INDEX && key.indexKey == DevelVisual::Property::BORDERLINE_COLOR) || (key.type == Property::Key::STRING && key.stringKey == BORDERLINE_COLOR) ||
- (key.type == Property::Key::INDEX && key.indexKey == DevelVisual::Property::BORDERLINE_OFFSET) || (key.type == Property::Key::STRING && key.stringKey == BORDERLINE_OFFSET)))
+ // Default animatable properties from DecoratedVisualRenderer
+ case Toolkit::DevelVisual::Property::CORNER_RADIUS:
{
- mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
-
- // Register borderline properties
- mImpl->mBorderlineWidthIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelVisual::Property::BORDERLINE_WIDTH, BORDERLINE_WIDTH, mImpl->mBorderlineWidth);
- mImpl->mBorderlineColorIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelVisual::Property::BORDERLINE_COLOR, BORDERLINE_COLOR, mImpl->mBorderlineColor);
- mImpl->mBorderlineOffsetIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelVisual::Property::BORDERLINE_OFFSET, BORDERLINE_OFFSET, mImpl->mBorderlineOffset);
+ if(IsTypeAvailableForCornerRadius(mImpl->mType))
+ {
+ const bool updateShader = !mImpl->mCustomShader && !IsRoundedCornerRequired();
- // Borderline is animated now. we always have to use borderline feature.
- mImpl->mAlwaysUsingBorderline = true;
+ // CornerRadius is animated now. we always have to use corner radius feature.
+ mImpl->mAlwaysUsingCornerRadius = true;
- index = mImpl->mRenderer.GetPropertyIndex(key);
+ if(updateShader)
+ {
+ // Update each values to renderer
+ DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterCornerRadiusUniform();
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS, mImpl->mCornerRadius);
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
- // Change shader
- UpdateShader();
+ // Change shader
+ UpdateShader();
+ }
+ if(!IsBorderlineRequired())
+ {
+ // If IsBorderlineRequired is true, BLEND_MODE is already BlendMode::ON_WITHOUT_CULL. So we don't overwrite it.
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
+ }
+ return Dali::Property(mImpl->mRenderer, DecoratedVisualRenderer::Property::CORNER_RADIUS);
+ }
+ break;
}
- else if(IsTypeAvailableForCornerRadius(mImpl->mType) && ((key.type == Property::Key::INDEX && key.indexKey == DevelVisual::Property::CORNER_RADIUS) || (key.type == Property::Key::STRING && key.stringKey == CORNER_RADIUS)))
+ case Toolkit::DevelVisual::Property::BORDERLINE_WIDTH:
+ case Toolkit::DevelVisual::Property::BORDERLINE_COLOR:
+ case Toolkit::DevelVisual::Property::BORDERLINE_OFFSET:
{
- // Register CORNER_RADIUS property
- mImpl->mCornerRadiusIndex = mImpl->mRenderer.RegisterUniqueProperty(DevelVisual::Property::CORNER_RADIUS, CORNER_RADIUS, mImpl->mCornerRadius);
- mImpl->mRenderer.RegisterUniqueProperty(CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
+ if(IsTypeAvailableForBorderline(mImpl->mType))
+ {
+ const bool updateShader = !mImpl->mCustomShader && !IsBorderlineRequired();
- // CornerRadius is animated now. we always have to use corner radius feature.
- mImpl->mAlwaysUsingCornerRadius = true;
+ // Borderline is animated now. we always have to use borderline feature.
+ mImpl->mAlwaysUsingBorderline = true;
- if(!IsBorderlineRequired())
- {
- // If IsBorderlineRequired is true, BLEND_MODE is already BlendMode::ON_WITHOUT_CULL. So we don't overwrite it.
- mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
- }
+ if(updateShader)
+ {
+ // Update each values to renderer
+ DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterBorderlineUniform();
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH, mImpl->mBorderlineWidth);
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, mImpl->mBorderlineColor);
+ mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET, mImpl->mBorderlineOffset);
- index = mImpl->mCornerRadiusIndex;
+ // Change shader
+ UpdateShader();
+ }
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
- // Change shader
- UpdateShader();
- }
- else
- {
- // We can't find the property in the base class.
- // Request to child class
- return OnGetPropertyObject(key);
- }
- }
- else
- {
- if(index == mImpl->mBorderlineWidthIndex ||
- index == mImpl->mBorderlineColorIndex ||
- index == mImpl->mBorderlineOffsetIndex)
- {
- // Borderline is animated now. we always have to use borderline feature.
- mImpl->mAlwaysUsingBorderline = true;
+ return Dali::Property(mImpl->mRenderer, GetPropertyIndex(key));
+ }
+ break;
}
- if(index == mImpl->mCornerRadiusIndex)
+ // Special case for MIX_COLOR
+ default:
{
- // CornerRadius is animated now. we always have to use corner radius feature.
- mImpl->mAlwaysUsingCornerRadius = true;
+ if(key.type == Property::Key::INDEX &&
+ ((mImpl->mType == Toolkit::Visual::COLOR && key.indexKey == ColorVisual::Property::MIX_COLOR) ||
+ (mImpl->mType == Toolkit::Visual::PRIMITIVE && key.indexKey == PrimitiveVisual::Property::MIX_COLOR)))
+ {
+ return Dali::Property(mImpl->mRenderer, VisualRenderer::Property::VISUAL_MIX_COLOR);
+ }
}
}
- return Dali::Property(mImpl->mRenderer, index);
+ // We can't find the property in the base class.
+ // Request to child class
+ return OnGetPropertyObject(key);
}
} // namespace Internal
void RegisterMixColor();
/**
+ * Register the uniform on the DecoratedVisualRenderer and store the property index if necessary.
+ */
+ void RegisterDecoration();
+
+ /**
* Find the matching property on the renderer or shader. If it's a shader
* property, register it on the renderer in order to animate it for this
* visual independently.
if(styleManager)
{
- customBrokenImageUrlList = Toolkit::DevelStyleManager::GetBrokenImageUrlList(styleManager);
- Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
- config["brokenImageUrl"].Get(brokenImageUrl);
+ customBrokenImageUrlList = Toolkit::DevelStyleManager::GetBrokenImageUrlList(styleManager);
+ const Property::Map& config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
+ const auto brokenImageUrlValue = config.Find("brokenImageUrl", Property::Type::STRING);
+ if(brokenImageUrlValue)
+ {
+ brokenImageUrlValue->Get(brokenImageUrl);
+ }
}
// Add default image