#define DALI_TEST_SUITE_UTILS_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 expressions code to execute
* @param except the exception expected in the assert
*/
-#define DALI_TEST_THROWS(expressions, except) \
- try \
- { \
- TestApplication::EnableLogging(false); \
- expressions; \
- TestApplication::EnableLogging(true); \
- fprintf(stderr, "Test failed in %s, expected exception: '%s' didn't occur\n", __FILELINE__, #except); \
- tet_result(TET_FAIL); \
- throw("TET_FAIL"); \
- } \
- catch(except &) \
- { \
- tet_result(TET_PASS); \
- } \
- catch(...) \
- { \
- fprintf(stderr, "Test failed in %s, unexpected exception\n", __FILELINE__); \
- tet_result(TET_FAIL); \
- throw; \
+#define DALI_TEST_THROWS(expressions, except) \
+ try \
+ { \
+ TestApplication::EnableLogging(false); \
+ expressions; \
+ TestApplication::EnableLogging(true); \
+ fprintf(stderr, "Test failed in %s, expected exception: '%s' didn't occur\n", __FILELINE__, #except); \
+ tet_result(TET_FAIL); \
+ throw("TET_FAIL"); \
+ } \
+ catch(except&) \
+ { \
+ tet_result(TET_PASS); \
+ } \
+ catch(...) \
+ { \
+ fprintf(stderr, "Test failed in %s, unexpected exception\n", __FILELINE__); \
+ tet_result(TET_FAIL); \
+ throw; \
}
// Functor to test whether an Applied signal is emitted
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7681, 7681", startIndex)); // GL_KEEP, GL_REPLACE, GL_REPLACE
// Check the correct setup was done to test against first bit-plane (only) of the stencil buffer.
- DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex)); // 514 is GL_EQUAL
+ DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 1, 1", startIndex)); // 514 is GL_EQUAL
DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
// Check we are set up to write to the second bitplane of the stencil buffer (only).
// Check we are set up to test against both the first and second bit-planes of the stencil buffer.
// (Both must be set to pass the check).
- DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
+ DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilFunc", "514, 3, 3", startIndex)); // 514 is GL_EQUAL, Test both bit-planes 1 & 2
DALI_TEST_CHECK(stencilTrace.FindMethodAndParamsFromStartIndex("StencilOp", "7680, 7680, 7680", startIndex)); // GL_KEEP, GL_KEEP, GL_KEEP
// If we are on the first loop, set the layer to 3D and loop to perform the test again.
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
END_TEST;
}
-
int UtcDaliLayerLower1(void)
{
tet_infoline("Testing Dali::Layer::Lower()");
END_TEST;
}
-
int UtcDaliLayerLower2(void)
{
tet_infoline("Testing Dali::Layer lower Action");
END_TEST;
}
-
int UtcDaliLayerSetClipping(void)
{
tet_infoline("Testing Dali::Layer::SetClipping()");
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
DALI_TEST_EQUALS(false, mutex3.IsLocked(), TEST_LOCATION);
{
- Mutex mutex4;
- Mutex mutex5(std::move(mutex4)); // move constructor
+ Mutex mutex4;
+ Mutex mutex5(std::move(mutex4)); // move constructor
Mutex::ScopedLock lock(mutex5);
DALI_TEST_EQUALS(true, mutex5.IsLocked(), TEST_LOCATION);
}
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
// EXTERNAL INCLUDES
#include <dali/devel-api/actors/actor-devel.h>
+#include <dali/devel-api/common/capabilities.h>
#include <dali/devel-api/common/stage.h>
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/integration-api/render-task-list-integ.h>
#include <dali/public-api/dali-core.h>
-#include <dali/devel-api/common/capabilities.h>
#include <cstdio>
#include <string>
tet_infoline("Test SetAdvancedBlendEquation ");
Geometry geometry = CreateQuadGeometry();
- Shader shader = CreateShader();
- Renderer renderer = Renderer::New( geometry, shader );
+ Shader shader = CreateShader();
+ Renderer renderer = Renderer::New(geometry, shader);
Actor actor = Actor::New();
actor.SetProperty(Actor::Property::OPACITY, 0.1f);
actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400));
application.GetScene().Add(actor);
- if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MAX ) )
+ if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MAX))
{
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MAX );
- int equationRgb = renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::MAX, equationRgb, TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MAX);
+ int equationRgb = renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::MAX, equationRgb, TEST_LOCATION);
}
- if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) )
+ if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
{
- renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true );
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN );
- int equation = renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION );
+ renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN);
+ int equation = renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION);
- DALI_TEST_EQUALS( (int)DevelBlendEquation::SCREEN, equation, TEST_LOCATION );
- DALI_TEST_EQUALS( DevelRenderer::IsAdvancedBlendEquationApplied( renderer ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS((int)DevelBlendEquation::SCREEN, equation, TEST_LOCATION);
+ DALI_TEST_EQUALS(DevelRenderer::IsAdvancedBlendEquationApplied(renderer), true, TEST_LOCATION);
application.SendNotification();
application.Render();
}
- if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MULTIPLY ) )
+ if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MULTIPLY))
{
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::ADD );
- renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true );
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION_RGB, DevelBlendEquation::SCREEN );
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION_ALPHA, DevelBlendEquation::MULTIPLY );
- int equationRgb = renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION_RGB );
- int equationAlpha = renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION_ALPHA );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::ADD);
+ renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION_RGB, DevelBlendEquation::SCREEN);
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION_ALPHA, DevelBlendEquation::MULTIPLY);
+ int equationRgb = renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION_RGB);
+ int equationAlpha = renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION_ALPHA);
- DALI_TEST_EQUALS( (int)DevelBlendEquation::ADD, equationRgb, TEST_LOCATION );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::ADD, equationAlpha, TEST_LOCATION );
- DALI_TEST_EQUALS( DevelRenderer::IsAdvancedBlendEquationApplied( renderer ), false, TEST_LOCATION );
+ DALI_TEST_EQUALS((int)DevelBlendEquation::ADD, equationRgb, TEST_LOCATION);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::ADD, equationAlpha, TEST_LOCATION);
+ DALI_TEST_EQUALS(DevelRenderer::IsAdvancedBlendEquationApplied(renderer), false, TEST_LOCATION);
application.SendNotification();
application.Render();
}
tet_infoline("Error Checking\n");
- if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MULTIPLY ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::OVERLAY ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::DARKEN ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::LIGHTEN ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::COLOR_DODGE ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::COLOR_BURN ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::HARD_LIGHT ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SOFT_LIGHT ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::DIFFERENCE ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::EXCLUSION ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::HUE ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SATURATION ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::COLOR ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::LUMINOSITY ) )
+ if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MULTIPLY) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::OVERLAY) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::DARKEN) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::LIGHTEN) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::COLOR_DODGE) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::COLOR_BURN) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::HARD_LIGHT) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SOFT_LIGHT) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::DIFFERENCE) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::EXCLUSION) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::HUE) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SATURATION) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::COLOR) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::LUMINOSITY))
{
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MULTIPLY );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::MULTIPLY, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MULTIPLY);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::MULTIPLY, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::SCREEN, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::SCREEN, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::OVERLAY );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::OVERLAY, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::OVERLAY);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::OVERLAY, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::DARKEN );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::DARKEN, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::DARKEN);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::DARKEN, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::LIGHTEN );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::LIGHTEN, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::LIGHTEN);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::LIGHTEN, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR_DODGE );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::COLOR_DODGE, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR_DODGE);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::COLOR_DODGE, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR_BURN );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::COLOR_BURN, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR_BURN);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::COLOR_BURN, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::HARD_LIGHT );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::HARD_LIGHT, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::HARD_LIGHT);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::HARD_LIGHT, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SOFT_LIGHT );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::SOFT_LIGHT, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SOFT_LIGHT);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::SOFT_LIGHT, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::DIFFERENCE );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::DIFFERENCE, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::DIFFERENCE);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::DIFFERENCE, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::EXCLUSION );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::EXCLUSION, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::EXCLUSION);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::EXCLUSION, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::HUE );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::HUE, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::HUE);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::HUE, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SATURATION );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::SATURATION, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SATURATION);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::SATURATION, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::COLOR, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::COLOR, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::LUMINOSITY );
- DALI_TEST_EQUALS( (int)DevelBlendEquation::LUMINOSITY, renderer.GetProperty<int>( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION );
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::LUMINOSITY);
+ DALI_TEST_EQUALS((int)DevelBlendEquation::LUMINOSITY, renderer.GetProperty<int>(DevelRenderer::Property::BLEND_EQUATION), TEST_LOCATION);
}
END_TEST;
tet_infoline("Test setting the blend mode to auto with opaque color and Advanced Blend Equation.");
- if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) )
+ if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
{
Geometry geometry = CreateQuadGeometry();
Shader shader = CreateShader();
application.GetScene().Add(actor);
renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::AUTO);
- renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true );
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN );
+ renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN);
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
glAbstraction.EnableEnableDisableCallTrace(true);
tet_infoline("Test setting the blend mode to off with opaque color and Advanced Blend Equation.");
- if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) )
+ if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
{
Geometry geometry = CreateQuadGeometry();
Shader shader = CreateShader();
application.GetScene().Add(actor);
renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::OFF);
- renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true );
- renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN );
+ renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
+ renderer.SetProperty(DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN);
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
glAbstraction.EnableEnableDisableCallTrace(true);
CheckEnumerationProperty<StencilOperation::Type>(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT");
CheckEnumerationProperty<StencilOperation::Type>(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT");
- if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MAX ) &&
- Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MIN ) )
+ if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MAX) &&
+ Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::MIN))
{
application.SendNotification();
application.Render();
- CheckEnumerationProperty< DevelBlendEquation::Type >( application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::REVERSE_SUBTRACT, DevelBlendEquation::MAX, DevelBlendEquation::MIN, "MIN" );
+ CheckEnumerationProperty<DevelBlendEquation::Type>(application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::REVERSE_SUBTRACT, DevelBlendEquation::MAX, DevelBlendEquation::MIN, "MIN");
}
- if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) )
+ if(Dali::Capabilities::IsBlendEquationSupported(DevelBlendEquation::SCREEN))
{
application.SendNotification();
application.Render();
- CheckEnumerationProperty< DevelBlendEquation::Type >( application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MIN, DevelBlendEquation::MULTIPLY, DevelBlendEquation::SCREEN, "SCREEN" );
+ CheckEnumerationProperty<DevelBlendEquation::Type>(application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MIN, DevelBlendEquation::MULTIPLY, DevelBlendEquation::SCREEN, "SCREEN");
}
END_TEST;
DALI_TEST_CHECK(!(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING));
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
+ TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
drawTrace.Enable(true);
drawTrace.Reset();
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
END_TEST;
}
-#define CLIPPING_RECT_X (16)
-#define CLIPPING_RECT_Y (768)
-#define CLIPPING_RECT_WIDTH (32)
-#define CLIPPING_RECT_HEIGHT (32)
+#define CLIPPING_RECT_X (16)
+#define CLIPPING_RECT_Y (768)
+#define CLIPPING_RECT_WIDTH (32)
+#define CLIPPING_RECT_HEIGHT (32)
int UtcDaliSceneSurfaceRotatedWithAngle0(void)
{
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
- TestApplication::DEFAULT_SURFACE_HEIGHT, 0);
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ 0);
application.SendNotification();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
- TestApplication::DEFAULT_SURFACE_HEIGHT, 90);
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ 90);
application.SendNotification();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
// It is recalculation for glScissor.
// Because surface is rotated and glScissor is called with recalcurated value.
- clippingRect.x = TestApplication::DEFAULT_SURFACE_HEIGHT - (CLIPPING_RECT_Y + CLIPPING_RECT_HEIGHT);
- clippingRect.y = CLIPPING_RECT_X;
- clippingRect.width = CLIPPING_RECT_HEIGHT;
+ clippingRect.x = TestApplication::DEFAULT_SURFACE_HEIGHT - (CLIPPING_RECT_Y + CLIPPING_RECT_HEIGHT);
+ clippingRect.y = CLIPPING_RECT_X;
+ clippingRect.width = CLIPPING_RECT_HEIGHT;
clippingRect.height = CLIPPING_RECT_WIDTH;
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
- TestApplication::DEFAULT_SURFACE_HEIGHT, 180);
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ 180);
application.SendNotification();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
// It is recalculation for glScissor.
// Because surface is rotated and glScissor is called with recalcurated value.
- clippingRect.x = TestApplication::DEFAULT_SURFACE_WIDTH - (CLIPPING_RECT_X + CLIPPING_RECT_WIDTH);
- clippingRect.y = TestApplication::DEFAULT_SURFACE_HEIGHT - (CLIPPING_RECT_Y +CLIPPING_RECT_HEIGHT);
- clippingRect.width = CLIPPING_RECT_WIDTH;
+ clippingRect.x = TestApplication::DEFAULT_SURFACE_WIDTH - (CLIPPING_RECT_X + CLIPPING_RECT_WIDTH);
+ clippingRect.y = TestApplication::DEFAULT_SURFACE_HEIGHT - (CLIPPING_RECT_Y + CLIPPING_RECT_HEIGHT);
+ clippingRect.width = CLIPPING_RECT_WIDTH;
clippingRect.height = CLIPPING_RECT_HEIGHT;
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
damagedRects.clear();
application.GetScene().SurfaceRotated(TestApplication::DEFAULT_SURFACE_WIDTH,
- TestApplication::DEFAULT_SURFACE_HEIGHT, 270);
+ TestApplication::DEFAULT_SURFACE_HEIGHT,
+ 270);
application.SendNotification();
application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
// It is recalculation for glScissor.
// Because surface is rotated and glScissor is called with recalcurated value.
- clippingRect.x = CLIPPING_RECT_Y;
- clippingRect.y = TestApplication::DEFAULT_SURFACE_WIDTH - (CLIPPING_RECT_X + CLIPPING_RECT_WIDTH);
- clippingRect.width = CLIPPING_RECT_HEIGHT;
+ clippingRect.x = CLIPPING_RECT_Y;
+ clippingRect.y = TestApplication::DEFAULT_SURFACE_WIDTH - (CLIPPING_RECT_X + CLIPPING_RECT_WIDTH);
+ clippingRect.width = CLIPPING_RECT_HEIGHT;
clippingRect.height = CLIPPING_RECT_WIDTH;
DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/public-api/dali-core.h>
#include <algorithm>
#include <chrono>
+#include <future>
#include <stdexcept>
#include <thread>
-#include <future>
int UtcDaliSemaphoreTryAcquire(void)
{
constexpr std::ptrdiff_t numTasks{2};
- auto f = [](Dali::Semaphore<numTasks> &sem, bool &flag)
- {
+ auto f = [](Dali::Semaphore<numTasks>& sem, bool& flag) {
sem.Acquire();
flag = true;
};
- auto flag1{false}, flag2{false};
+ auto flag1{false}, flag2{false};
Dali::Semaphore<numTasks> sem(0);
auto fut1 = std::async(std::launch::async, f, std::ref(sem), std::ref(flag1));
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
WheelEventSignalData& signalData;
};
-
bool DummyTouchCallback(Actor actor, const TouchEvent& touch)
{
return true;
END_TEST;
}
-
int UtcDaliStageTouchedSignalP2(void)
{
TestApplication application;
END_TEST;
}
-
int UtcDaliStageSignalWheelEventP2(void)
{
TestApplication application;
Stage stage = Stage::GetCurrent();
tet_printf("UtcDaliStageSignalWheelEventP2 - check wheel signal connection by name\n");
- WheelEventSignalData data;
+ WheelEventSignalData data;
WheelEventReceivedVoidFunctor functor(data);
GetImplementation(stage).ConnectSignal(&application, "wheelEvent", functor);
END_TEST;
}
-
-
-
int UtcDaliStageContextRegainedSignalN(void)
{
TestApplication application;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
DALI_TEST_CHECK(boundTextures0[boundTextures0.size() - 1] == 1u); // the latest one should be 0.
const std::vector<GLuint>& boundTextures1 = application.GetGlAbstraction().GetBoundTextures(GL_TEXTURE1);
- size_t count = boundTextures1.size();
+ size_t count = boundTextures1.size();
DALI_TEST_CHECK(boundTextures1[count - 1] == 2u); // the latest one should be 1.
// Create a new TextureSet
DALI_TEST_CHECK(gl.GetActiveTextureUnit() == GL_TEXTURE0);
DALI_TEST_CHECK(boundTextures0[boundTextures0.size() - 1] == 1u);
- DALI_TEST_CHECK(boundTextures1.size() == count); // The bound texture count of GL_TEXTURE1 should not be changed.
+ DALI_TEST_CHECK(boundTextures1.size() == count); // The bound texture count of GL_TEXTURE1 should not be changed.
END_TEST;
}
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
END_TEST;
}
-
int UtcDaliTouchEventIntercept(void)
{
TestApplication application;
TouchEventFunctor functor(data, false /* Do not consume */);
actor.TouchedSignal().Connect(&application, functor);
-
// Connect to parent's touched signal
SignalData parentData;
TouchEventFunctor parentFunctor(parentData, false /* Do not consume */);
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali-test-suite-utils.h>
#include <dali/integration-api/events/hover-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/internal/event/common/type-info-impl.h>
#include <dali/internal/common/const-string.h>
+#include <dali/internal/event/common/type-info-impl.h>
#include <dali/public-api/dali-core.h>
#include <stdlib.h>
}
catch(DaliException& e)
{
- DALI_TEST_ASSERT(e, "! \"GetProperty", TEST_LOCATION);
+ DALI_TEST_ASSERT(e, "!\"GetProperty", TEST_LOCATION);
}
END_TEST;
}
}
catch(DaliException& e)
{
- DALI_TEST_ASSERT(e, "! \"Property index already added", TEST_LOCATION);
+ DALI_TEST_ASSERT(e, "!\"Property index already added", TEST_LOCATION);
}
int animatablePropertyIndex = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 100;
}
catch(DaliException& e)
{
- DALI_TEST_ASSERT(e, "! \"Property index already added", TEST_LOCATION);
+ DALI_TEST_ASSERT(e, "!\"Property index already added", TEST_LOCATION);
}
END_TEST;
}
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
DALI_TEST_EQUALS(ZERO, vector.Count(), TEST_LOCATION);
DALI_TEST_EQUALS(ZERO, vector.Capacity(), TEST_LOCATION);
-
vector.PushBack(1);
vector.PushBack(2);
vector.PushBack(3);
DALI_TEST_EQUALS(vector[2], 4, TEST_LOCATION);
DALI_TEST_EQUALS(vector[3], 5, TEST_LOCATION);
-
// erase an element present at start
Dali::Erase(vector, 1);
DALI_TEST_EQUALS(static_cast<Dali::VectorBase::SizeType>(3), vector.Count(), TEST_LOCATION);
Vector<int> vector;
// erasing from empty vector
- Dali::EraseIf(vector, [](const auto & value) {return value == 2;});
+ Dali::EraseIf(vector, [](const auto& value) { return value == 2; });
DALI_TEST_EQUALS(ZERO, vector.Count(), TEST_LOCATION);
DALI_TEST_EQUALS(ZERO, vector.Capacity(), TEST_LOCATION);
-
vector.PushBack(1);
vector.PushBack(2);
vector.PushBack(3);
vector.PushBack(3);
// erase multiple value
- Dali::EraseIf(vector, [](const auto & value) {return value == 3;});
+ Dali::EraseIf(vector, [](const auto& value) { return value == 3; });
DALI_TEST_EQUALS(static_cast<Dali::VectorBase::SizeType>(4), vector.Count(), TEST_LOCATION);
DALI_TEST_EQUALS(vector[0], 1, TEST_LOCATION);
DALI_TEST_EQUALS(vector[2], 4, TEST_LOCATION);
DALI_TEST_EQUALS(vector[3], 5, TEST_LOCATION);
-
// erase an element present at start
- Dali::EraseIf(vector, [](const auto & value) {return value == 1;});
+ Dali::EraseIf(vector, [](const auto& value) { return value == 1; });
DALI_TEST_EQUALS(static_cast<Dali::VectorBase::SizeType>(3), vector.Count(), TEST_LOCATION);
DALI_TEST_EQUALS(vector[0], 2, TEST_LOCATION);
DALI_TEST_EQUALS(vector[1], 4, TEST_LOCATION);
DALI_TEST_EQUALS(vector[2], 5, TEST_LOCATION);
// erase an element present at end
- Dali::EraseIf(vector, [](const auto & value) {return value == 5;});
+ Dali::EraseIf(vector, [](const auto& value) { return value == 5; });
DALI_TEST_EQUALS(static_cast<Dali::VectorBase::SizeType>(2), vector.Count(), TEST_LOCATION);
DALI_TEST_EQUALS(vector[0], 2, TEST_LOCATION);
DALI_TEST_EQUALS(vector[1], 4, TEST_LOCATION);
// erase an element not present in the vector
- Dali::EraseIf(vector, [](const auto & value) {return value == 42;});
+ Dali::EraseIf(vector, [](const auto& value) { return value == 42; });
DALI_TEST_EQUALS(static_cast<Dali::VectorBase::SizeType>(2), vector.Count(), TEST_LOCATION);
DALI_TEST_EQUALS(vector[0], 2, TEST_LOCATION);
DALI_TEST_EQUALS(vector[1], 4, TEST_LOCATION);
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include "dali/public-api/dali-core.h"
-#include <cstdio>
#include <stdarg.h>
+#include <cstdio>
// Link with TET Test application, need to redefine TET functions
void tet_infoline(const char* str)
va_end(args);
}
-
#include "test-application.h"
/*****************************************************************************
* Also ensures TET Test Application is kept up-to-date.
*/
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
#ifndef _ARCH_ARM_
Dali::TestApplication application;
#define DALI_ADDON_DISPATCH_TABLE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
-#include <string>
-#include <algorithm>
#include <dali/public-api/common/vector-wrapper.h>
+#include <algorithm>
+#include <string>
namespace Dali
{
/*\r
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
\r
namespace Dali\r
{\r
-\r
namespace Capabilities\r
{\r
-\r
-bool IsBlendEquationSupported( BlendEquation::Type blendEquation )\r
+bool IsBlendEquationSupported(BlendEquation::Type blendEquation)\r
{\r
- return IsBlendEquationSupported( static_cast<DevelBlendEquation::Type>( blendEquation ) );\r
+ return IsBlendEquationSupported(static_cast<DevelBlendEquation::Type>(blendEquation));\r
}\r
\r
-bool IsBlendEquationSupported( DevelBlendEquation::Type blendEquation )\r
+bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation)\r
{\r
Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get();\r
return tls.IsBlendEquationSupported(blendEquation);\r
#define DALI_CAPABILITIES_H\r
\r
/*\r
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
\r
namespace Dali\r
{\r
-\r
namespace Capabilities\r
{\r
-\r
/**\r
* @brief Returns whether the blend equation is supported in the system or not.\r
* @param[in] blendEquation blend equation to be checked.\r
* @return True if the blend equation supported.\r
*/\r
-DALI_CORE_API bool IsBlendEquationSupported( BlendEquation::Type blendEquation );\r
+DALI_CORE_API bool IsBlendEquationSupported(BlendEquation::Type blendEquation);\r
\r
/**\r
* @brief Returns whether the blend equation is supported in the system or not.\r
* @param[in] blendEquation blend equation to be checked.\r
* @return True if the blend equation supported.\r
*/\r
-DALI_CORE_API bool IsBlendEquationSupported( DevelBlendEquation::Type blendEquation );\r
+DALI_CORE_API bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation);\r
\r
} // namespace Capabilities\r
\r
#define DALI_RENDERER_DEVEL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace DevelBlendEquation
{
-
/**
* @brief Enumeration for blend equation.
*/
enum Type
{
- ADD = Dali::BlendEquation::ADD,
- SUBTRACT = Dali::BlendEquation::SUBTRACT,
- REVERSE_SUBTRACT = Dali::BlendEquation::REVERSE_SUBTRACT,
+ ADD = Dali::BlendEquation::ADD,
+ SUBTRACT = Dali::BlendEquation::SUBTRACT,
+ REVERSE_SUBTRACT = Dali::BlendEquation::REVERSE_SUBTRACT,
// OpenGL es 3.0 enumeration
- MIN = 0x8007,
- MAX = 0x8008,
+ MIN = 0x8007,
+ MAX = 0x8008,
// OpenGL es 3.2 or KHR_Blend_Equation_Advanced enumeration
- MULTIPLY = 0x9294,
- SCREEN = 0x9295,
- OVERLAY = 0x9296,
- DARKEN = 0x9297,
- LIGHTEN = 0x9298,
- COLOR_DODGE = 0x9299,
- COLOR_BURN = 0x929A,
- HARD_LIGHT = 0x929B,
- SOFT_LIGHT = 0x929C,
- DIFFERENCE = 0x929E,
- EXCLUSION = 0x92A0,
- HUE = 0x92AD,
- SATURATION = 0x92AE,
- COLOR = 0x92AF,
- LUMINOSITY = 0x92B0
+ MULTIPLY = 0x9294,
+ SCREEN = 0x9295,
+ OVERLAY = 0x9296,
+ DARKEN = 0x9297,
+ LIGHTEN = 0x9298,
+ COLOR_DODGE = 0x9299,
+ COLOR_BURN = 0x929A,
+ HARD_LIGHT = 0x929B,
+ SOFT_LIGHT = 0x929C,
+ DIFFERENCE = 0x929E,
+ EXCLUSION = 0x92A0,
+ HUE = 0x92AD,
+ SATURATION = 0x92AE,
+ COLOR = 0x92AF,
+ LUMINOSITY = 0x92B0
};
} // namespace DevelBlendEquation
} // namespace Rendering
-
/**
* @brief Query whether current blend equation is advanced option.
* @param[in] renderer to be checked whether it has been applied advanced blend equation or not
* @return True if current blend equation is advanced.
*/
-DALI_CORE_API bool IsAdvancedBlendEquationApplied( const Renderer& renderer );
+DALI_CORE_API bool IsAdvancedBlendEquationApplied(const Renderer& renderer);
} // namespace DevelRenderer
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
}
Mutex::Mutex(Mutex&& rhs) noexcept
- : mImpl(rhs.mImpl)
+: mImpl(rhs.mImpl)
{
rhs.mImpl = nullptr;
}
-Mutex &Mutex::operator=(Mutex&& rhs) noexcept
+Mutex& Mutex::operator=(Mutex&& rhs) noexcept
{
- if (mImpl != rhs.mImpl)
+ if(mImpl != rhs.mImpl)
{
delete mImpl;
- mImpl = rhs.mImpl;
+ mImpl = rhs.mImpl;
rhs.mImpl = nullptr;
}
#define DALI_MUTEX_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* @brief Move assignment
*/
- Mutex &operator=(Mutex&& rhs) noexcept;
+ Mutex& operator=(Mutex&& rhs) noexcept;
/**
* @brief Check if the mutex is locked
#pragma once
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/public-api/common/dali-common.h>
// EXTERNAL INCLUDES
-#include <mutex>
#include <condition_variable>
-#include <stdexcept>
-#include <sstream>
#include <limits>
+#include <mutex>
+#include <sstream>
+#include <stdexcept>
namespace Dali
{
* @param[in] desired the desired initial value of the semaphore
*/
explicit Semaphore(std::ptrdiff_t desired)
- : mCount(desired)
+ : mCount(desired)
{
- if (mCount < 0 || mCount > Max())
+ if(mCount < 0 || mCount > Max())
{
ThrowInvalidParamException(desired);
}
void Release(std::ptrdiff_t update = 1)
{
std::lock_guard<std::mutex> lock(mLock);
- if (update < 0 || update > Max() - mCount)
+ if(update < 0 || update > Max() - mCount)
{
ThrowInvalidParamException(update);
}
mCount += update;
- while (update--)
+ while(update--)
{
mCondVar.notify_one();
}
void Acquire()
{
std::unique_lock<std::mutex> lock(mLock);
- while (mCount == 0)
+ while(mCount == 0)
{
mCondVar.wait(lock);
}
bool TryAcquire()
{
std::lock_guard<std::mutex> lock(mLock);
- if (mCount)
+ if(mCount)
{
--mCount;
return true;
* @return true if it decremented the internal counter, otherwise false
*/
template<typename Rep, typename Period>
- bool TryAcquireFor(const std::chrono::duration<Rep, Period> &relTime)
+ bool TryAcquireFor(const std::chrono::duration<Rep, Period>& relTime)
{
std::unique_lock<std::mutex> lock(mLock);
- while (mCount == 0)
+ while(mCount == 0)
{
- if (mCondVar.wait_for(lock, relTime) == std::cv_status::timeout)
+ if(mCondVar.wait_for(lock, relTime) == std::cv_status::timeout)
{
return false;
}
* @return true if it decremented the internal counter, otherwise false
*/
template<typename Clock, typename Duration>
- bool TryAcquireUntil(const std::chrono::time_point<Clock, Duration> &absTime)
+ bool TryAcquireUntil(const std::chrono::time_point<Clock, Duration>& absTime)
{
std::unique_lock<std::mutex> lock(mLock);
- while (mCount == 0)
+ while(mCount == 0)
{
- if (mCondVar.wait_until(lock, absTime) == std::cv_status::timeout)
+ if(mCondVar.wait_until(lock, absTime) == std::cv_status::timeout)
{
return false;
}
}
std::condition_variable mCondVar;
- std::mutex mLock;
- std::ptrdiff_t mCount;
+ std::mutex mLock;
+ std::ptrdiff_t mCount;
};
-}
+} // namespace Dali
#define DALI_INTEGRATION_DEBUG_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
********************************************************************************/
#if defined(DEBUG_ENABLED)
- /**
+/**
* @brief Get the monotonic time since the clock's epoch.
*
* @param[out] timeInNanoseconds The time in nanoseconds since the reference point.
#define DALI_INTEGRATION_GL_ABSTRACTION_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
-#include <stdint.h>
#include <dali/devel-api/rendering/renderer-devel.h>
+#include <stdint.h>
/*
* This file is based on gl3.h, the following licence is included for conformance.
* Returns current gles can support the blend equation
* @Return true current gles support the blend equation
*/
- virtual bool IsBlendEquationSupported( DevelBlendEquation::Type blendEquation ) = 0;
+ virtual bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation) = 0;
/**
* Returns shader prefix of shading language version.
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 // unnamed namespace
{
-
using namespace Dali;
const int MASK_SRC_FACTOR_RGB = 0x0000000F;
const int MASK_EQUATION_RGB = 0x00FF0000;
const int MASK_EQUATION_ALPHA = 0xFF000000;
-const int SHIFT_TO_SRC_FACTOR_RGB = 0;
-const int SHIFT_TO_SRC_FACTOR_ALPHA = 4;
-const int SHIFT_TO_DEST_FACTOR_RGB = 8;
+const int SHIFT_TO_SRC_FACTOR_RGB = 0;
+const int SHIFT_TO_SRC_FACTOR_ALPHA = 4;
+const int SHIFT_TO_DEST_FACTOR_RGB = 8;
const int SHIFT_TO_DEST_FACTOR_ALPHA = 12;
const int SHIFT_TO_EQUATION_RGB = 16;
const int SHIFT_TO_EQUATION_ALPHA = 24;
* @param[in] factor The BlendFunc value.
* @param[in] bitshift Used to shift to the correct part of options.
*/
-void StoreBlendFactor( unsigned int& options, BlendFactor::Type factor, int bitShift )
+void StoreBlendFactor(unsigned int& options, BlendFactor::Type factor, int bitShift)
{
- switch( factor )
+ switch(factor)
{
case BlendFactor::ZERO:
{
- options |= ( 0u << bitShift );
+ options |= (0u << bitShift);
break;
}
case BlendFactor::ONE:
{
- options |= ( 1u << bitShift );
+ options |= (1u << bitShift);
break;
}
case BlendFactor::SRC_COLOR:
{
- options |= ( 2u << bitShift );
+ options |= (2u << bitShift);
break;
}
case BlendFactor::ONE_MINUS_SRC_COLOR:
{
- options |= ( 3u << bitShift );
+ options |= (3u << bitShift);
break;
}
case BlendFactor::SRC_ALPHA:
{
- options |= ( 4u << bitShift );
+ options |= (4u << bitShift);
break;
}
case BlendFactor::ONE_MINUS_SRC_ALPHA:
{
- options |= ( 5u << bitShift );
+ options |= (5u << bitShift);
break;
}
case BlendFactor::DST_ALPHA:
{
- options |= ( 6u << bitShift );
+ options |= (6u << bitShift);
break;
}
case BlendFactor::ONE_MINUS_DST_ALPHA:
{
- options |= ( 7u << bitShift );
+ options |= (7u << bitShift);
break;
}
case BlendFactor::DST_COLOR:
{
- options |= ( 8u << bitShift );
+ options |= (8u << bitShift);
break;
}
case BlendFactor::ONE_MINUS_DST_COLOR:
{
- options |= ( 9u << bitShift );
+ options |= (9u << bitShift);
break;
}
case BlendFactor::SRC_ALPHA_SATURATE:
{
- options |= ( 10u << bitShift );
+ options |= (10u << bitShift);
break;
}
case BlendFactor::CONSTANT_COLOR:
{
- options |= ( 11u << bitShift );
+ options |= (11u << bitShift);
break;
}
case BlendFactor::ONE_MINUS_CONSTANT_COLOR:
{
- options |= ( 12u << bitShift );
+ options |= (12u << bitShift);
break;
}
case BlendFactor::CONSTANT_ALPHA:
{
- options |= ( 13u << bitShift );
+ options |= (13u << bitShift);
break;
}
case BlendFactor::ONE_MINUS_CONSTANT_ALPHA:
{
- options |= ( 14u << bitShift );
+ options |= (14u << bitShift);
break;
}
}
* @param[in] factor The BlendEquation value.
* @param[in] bitshift Used to shift to the correct part of options.
*/
-void StoreBlendEquation( unsigned int& options, DevelBlendEquation::Type factor, int bitShift )
+void StoreBlendEquation(unsigned int& options, DevelBlendEquation::Type factor, int bitShift)
{
// Must be same order as BLENDING_EQUATIONS, below:
- enum {
+ enum
+ {
ADD_BITVAL = 0u,
SUBTRACT_BITVAL,
REVERSE_SUBTRACT_BITVAL,
LUMINOSITY_BITVAL
};
- switch ( factor )
+ switch(factor)
{
case DevelBlendEquation::ADD:
{
- options |= ( ADD_BITVAL << bitShift );
+ options |= (ADD_BITVAL << bitShift);
break;
}
case DevelBlendEquation::SUBTRACT:
{
- options |= ( SUBTRACT_BITVAL << bitShift );
+ options |= (SUBTRACT_BITVAL << bitShift);
break;
}
case DevelBlendEquation::REVERSE_SUBTRACT:
{
- options |= ( REVERSE_SUBTRACT_BITVAL << bitShift );
+ options |= (REVERSE_SUBTRACT_BITVAL << bitShift);
break;
}
case DevelBlendEquation::MIN:
{
- options |= ( MIN_BITVAL << bitShift );
+ options |= (MIN_BITVAL << bitShift);
break;
}
case DevelBlendEquation::MAX:
{
- options |= ( MAX_BITVAL << bitShift );
+ options |= (MAX_BITVAL << bitShift);
break;
}
case DevelBlendEquation::MULTIPLY:
{
- options |= ( MULTIPLY_BITVAL << bitShift );
+ options |= (MULTIPLY_BITVAL << bitShift);
break;
}
case DevelBlendEquation::SCREEN:
{
- options |= ( SCREEN_BITVAL << bitShift );
+ options |= (SCREEN_BITVAL << bitShift);
break;
}
case DevelBlendEquation::OVERLAY:
{
- options |= ( OVERLAY_BITVAL << bitShift );
+ options |= (OVERLAY_BITVAL << bitShift);
break;
}
case DevelBlendEquation::DARKEN:
{
- options |= ( DARKEN_BITVAL << bitShift );
+ options |= (DARKEN_BITVAL << bitShift);
break;
}
case DevelBlendEquation::LIGHTEN:
{
- options |= ( LIGHTEN_BITVAL << bitShift );
+ options |= (LIGHTEN_BITVAL << bitShift);
break;
}
case DevelBlendEquation::COLOR_DODGE:
{
- options |= ( COLOR_DODGE_BITVAL << bitShift );
+ options |= (COLOR_DODGE_BITVAL << bitShift);
break;
}
case DevelBlendEquation::COLOR_BURN:
{
- options |= ( COLOR_BURN_BITVAL << bitShift );
+ options |= (COLOR_BURN_BITVAL << bitShift);
break;
}
case DevelBlendEquation::HARD_LIGHT:
{
- options |= ( HARD_LIGHT_BITVAL << bitShift );
+ options |= (HARD_LIGHT_BITVAL << bitShift);
break;
}
case DevelBlendEquation::SOFT_LIGHT:
{
- options |= ( SOFT_LIGHT_BITVAL << bitShift );
+ options |= (SOFT_LIGHT_BITVAL << bitShift);
break;
}
case DevelBlendEquation::DIFFERENCE:
{
- options |= ( DIFFERENCE_BITVAL << bitShift );
+ options |= (DIFFERENCE_BITVAL << bitShift);
break;
}
case DevelBlendEquation::EXCLUSION:
{
- options |= ( EXCLUSION_BITVAL << bitShift );
+ options |= (EXCLUSION_BITVAL << bitShift);
break;
}
case DevelBlendEquation::HUE:
{
- options |= ( HUE_BITVAL << bitShift );
+ options |= (HUE_BITVAL << bitShift);
break;
}
case DevelBlendEquation::SATURATION:
{
- options |= ( SATURATION_BITVAL << bitShift );
+ options |= (SATURATION_BITVAL << bitShift);
break;
}
case DevelBlendEquation::COLOR:
{
- options |= ( COLOR_BITVAL << bitShift );
+ options |= (COLOR_BITVAL << bitShift);
break;
}
case DevelBlendEquation::LUMINOSITY:
{
- options |= ( LUMINOSITY_BITVAL << bitShift );
+ options |= (LUMINOSITY_BITVAL << bitShift);
break;
}
}
}
-const unsigned int BLENDING_FACTOR_COUNT = 15;
-const unsigned int BLENDING_EQUATION_COUNT = 20;
+const unsigned int BLENDING_FACTOR_COUNT = 15;
+const unsigned int BLENDING_EQUATION_COUNT = 20;
const unsigned int BLENDING_EQUATION_ADVANCED_INDEX_START = 5;
-const unsigned int BLENDING_EQUATION_ADVANCED_INDEX_END = 19;
+const unsigned int BLENDING_EQUATION_ADVANCED_INDEX_END = 19;
-BlendFactor::Type BLENDING_FACTORS[ BLENDING_FACTOR_COUNT ] =
-{
- BlendFactor::ZERO,
- BlendFactor::ONE,
- BlendFactor::SRC_COLOR,
- BlendFactor::ONE_MINUS_SRC_COLOR,
- BlendFactor::SRC_ALPHA,
- BlendFactor::ONE_MINUS_SRC_ALPHA,
- BlendFactor::DST_ALPHA,
- BlendFactor::ONE_MINUS_DST_ALPHA,
- BlendFactor::DST_COLOR,
- BlendFactor::ONE_MINUS_DST_COLOR,
- BlendFactor::SRC_ALPHA_SATURATE,
- BlendFactor::CONSTANT_COLOR,
- BlendFactor::ONE_MINUS_CONSTANT_COLOR,
- BlendFactor::CONSTANT_ALPHA,
- BlendFactor::ONE_MINUS_CONSTANT_ALPHA
-};
-
-DevelBlendEquation::Type BLENDING_EQUATIONS[ BLENDING_EQUATION_COUNT ] =
-{
- DevelBlendEquation::ADD,
- DevelBlendEquation::SUBTRACT,
- DevelBlendEquation::REVERSE_SUBTRACT,
- DevelBlendEquation::MIN,
- DevelBlendEquation::MAX,
- DevelBlendEquation::MULTIPLY,
- DevelBlendEquation::SCREEN,
- DevelBlendEquation::OVERLAY,
- DevelBlendEquation::DARKEN,
- DevelBlendEquation::LIGHTEN,
- DevelBlendEquation::COLOR_DODGE,
- DevelBlendEquation::COLOR_BURN,
- DevelBlendEquation::HARD_LIGHT,
- DevelBlendEquation::SOFT_LIGHT,
- DevelBlendEquation::DIFFERENCE,
- DevelBlendEquation::EXCLUSION,
- DevelBlendEquation::HUE,
- DevelBlendEquation::SATURATION,
- DevelBlendEquation::COLOR,
- DevelBlendEquation::LUMINOSITY
-};
+BlendFactor::Type BLENDING_FACTORS[BLENDING_FACTOR_COUNT] =
+ {
+ BlendFactor::ZERO,
+ BlendFactor::ONE,
+ BlendFactor::SRC_COLOR,
+ BlendFactor::ONE_MINUS_SRC_COLOR,
+ BlendFactor::SRC_ALPHA,
+ BlendFactor::ONE_MINUS_SRC_ALPHA,
+ BlendFactor::DST_ALPHA,
+ BlendFactor::ONE_MINUS_DST_ALPHA,
+ BlendFactor::DST_COLOR,
+ BlendFactor::ONE_MINUS_DST_COLOR,
+ BlendFactor::SRC_ALPHA_SATURATE,
+ BlendFactor::CONSTANT_COLOR,
+ BlendFactor::ONE_MINUS_CONSTANT_COLOR,
+ BlendFactor::CONSTANT_ALPHA,
+ BlendFactor::ONE_MINUS_CONSTANT_ALPHA};
+
+DevelBlendEquation::Type BLENDING_EQUATIONS[BLENDING_EQUATION_COUNT] =
+ {
+ DevelBlendEquation::ADD,
+ DevelBlendEquation::SUBTRACT,
+ DevelBlendEquation::REVERSE_SUBTRACT,
+ DevelBlendEquation::MIN,
+ DevelBlendEquation::MAX,
+ DevelBlendEquation::MULTIPLY,
+ DevelBlendEquation::SCREEN,
+ DevelBlendEquation::OVERLAY,
+ DevelBlendEquation::DARKEN,
+ DevelBlendEquation::LIGHTEN,
+ DevelBlendEquation::COLOR_DODGE,
+ DevelBlendEquation::COLOR_BURN,
+ DevelBlendEquation::HARD_LIGHT,
+ DevelBlendEquation::SOFT_LIGHT,
+ DevelBlendEquation::DIFFERENCE,
+ DevelBlendEquation::EXCLUSION,
+ DevelBlendEquation::HUE,
+ DevelBlendEquation::SATURATION,
+ DevelBlendEquation::COLOR,
+ DevelBlendEquation::LUMINOSITY};
/**
* Utility to retrieve one of the BlendFunc values.
* @param[in] bitshift Used to shift to the correct part of options.
* @return The blending factor.
*/
-BlendFactor::Type RetrieveBlendFactor( unsigned int options, int mask, int bitShift )
+BlendFactor::Type RetrieveBlendFactor(unsigned int options, int mask, int bitShift)
{
unsigned int index = options & mask;
- index = index >> bitShift;
+ index = index >> bitShift;
- DALI_ASSERT_DEBUG( index < BLENDING_FACTOR_COUNT );
+ DALI_ASSERT_DEBUG(index < BLENDING_FACTOR_COUNT);
- return BLENDING_FACTORS[ index ];
+ return BLENDING_FACTORS[index];
}
/**
* @param[in] bitshift Used to shift to the correct part of options.
* @return The blending equation.
*/
-DevelBlendEquation::Type RetrieveBlendEquation( unsigned int options, int mask, int bitShift )
+DevelBlendEquation::Type RetrieveBlendEquation(unsigned int options, int mask, int bitShift)
{
unsigned int index = options & mask;
- index = index >> bitShift;
+ index = index >> bitShift;
- DALI_ASSERT_DEBUG( index < BLENDING_EQUATION_COUNT );
+ DALI_ASSERT_DEBUG(index < BLENDING_EQUATION_COUNT);
- return BLENDING_EQUATIONS[ index ];
+ return BLENDING_EQUATIONS[index];
}
} // unnamed namespace
namespace Dali
{
-
namespace Internal
{
-
BlendingOptions::BlendingOptions()
-: mBitmask( 0u ),
- mBlendColor( nullptr )
+: mBitmask(0u),
+ mBlendColor(nullptr)
{
- SetBlendFunc( BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA,
- BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA );
+ SetBlendFunc(BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA);
- SetBlendEquation( DevelBlendEquation::ADD, DevelBlendEquation::ADD );
+ SetBlendEquation(DevelBlendEquation::ADD, DevelBlendEquation::ADD);
}
BlendingOptions::~BlendingOptions() = default;
-void BlendingOptions::SetBitmask( unsigned int bitmask )
+void BlendingOptions::SetBitmask(unsigned int bitmask)
{
mBitmask = bitmask;
}
return mBitmask;
}
-void BlendingOptions::SetBlendFunc( BlendFactor::Type srcFactorRgb, BlendFactor::Type destFactorRgb,
- BlendFactor::Type srcFactorAlpha, BlendFactor::Type destFactorAlpha )
+void BlendingOptions::SetBlendFunc(BlendFactor::Type srcFactorRgb, BlendFactor::Type destFactorRgb, BlendFactor::Type srcFactorAlpha, BlendFactor::Type destFactorAlpha)
{
mBitmask &= CLEAR_BLEND_FUNC_MASK; // Clear the BlendFunc values
- StoreBlendFactor( mBitmask, srcFactorRgb, SHIFT_TO_SRC_FACTOR_RGB );
- StoreBlendFactor( mBitmask, destFactorRgb, SHIFT_TO_DEST_FACTOR_RGB );
- StoreBlendFactor( mBitmask, srcFactorAlpha, SHIFT_TO_SRC_FACTOR_ALPHA );
- StoreBlendFactor( mBitmask, destFactorAlpha, SHIFT_TO_DEST_FACTOR_ALPHA );
+ StoreBlendFactor(mBitmask, srcFactorRgb, SHIFT_TO_SRC_FACTOR_RGB);
+ StoreBlendFactor(mBitmask, destFactorRgb, SHIFT_TO_DEST_FACTOR_RGB);
+ StoreBlendFactor(mBitmask, srcFactorAlpha, SHIFT_TO_SRC_FACTOR_ALPHA);
+ StoreBlendFactor(mBitmask, destFactorAlpha, SHIFT_TO_DEST_FACTOR_ALPHA);
}
BlendFactor::Type BlendingOptions::GetBlendSrcFactorRgb() const
{
- return RetrieveBlendFactor( mBitmask, MASK_SRC_FACTOR_RGB, SHIFT_TO_SRC_FACTOR_RGB );
+ return RetrieveBlendFactor(mBitmask, MASK_SRC_FACTOR_RGB, SHIFT_TO_SRC_FACTOR_RGB);
}
BlendFactor::Type BlendingOptions::GetBlendDestFactorRgb() const
{
- return RetrieveBlendFactor( mBitmask, MASK_DEST_FACTOR_RGB, SHIFT_TO_DEST_FACTOR_RGB );
+ return RetrieveBlendFactor(mBitmask, MASK_DEST_FACTOR_RGB, SHIFT_TO_DEST_FACTOR_RGB);
}
BlendFactor::Type BlendingOptions::GetBlendSrcFactorAlpha() const
{
- return RetrieveBlendFactor( mBitmask, MASK_SRC_FACTOR_ALPHA, SHIFT_TO_SRC_FACTOR_ALPHA );
+ return RetrieveBlendFactor(mBitmask, MASK_SRC_FACTOR_ALPHA, SHIFT_TO_SRC_FACTOR_ALPHA);
}
BlendFactor::Type BlendingOptions::GetBlendDestFactorAlpha() const
{
- return RetrieveBlendFactor( mBitmask, MASK_DEST_FACTOR_ALPHA, SHIFT_TO_DEST_FACTOR_ALPHA );
+ return RetrieveBlendFactor(mBitmask, MASK_DEST_FACTOR_ALPHA, SHIFT_TO_DEST_FACTOR_ALPHA);
}
-void BlendingOptions::SetBlendEquation( DevelBlendEquation::Type equationRgb, DevelBlendEquation::Type equationAlpha )
+void BlendingOptions::SetBlendEquation(DevelBlendEquation::Type equationRgb, DevelBlendEquation::Type equationAlpha)
{
mBitmask &= CLEAR_BLEND_EQUATION_MASK; // Clear the BlendEquation values
- StoreBlendEquation( mBitmask, equationRgb, SHIFT_TO_EQUATION_RGB );
- StoreBlendEquation( mBitmask, equationAlpha, SHIFT_TO_EQUATION_ALPHA );
+ StoreBlendEquation(mBitmask, equationRgb, SHIFT_TO_EQUATION_RGB);
+ StoreBlendEquation(mBitmask, equationAlpha, SHIFT_TO_EQUATION_ALPHA);
}
DevelBlendEquation::Type BlendingOptions::GetBlendEquationRgb() const
{
- return RetrieveBlendEquation( mBitmask, MASK_EQUATION_RGB, SHIFT_TO_EQUATION_RGB );
+ return RetrieveBlendEquation(mBitmask, MASK_EQUATION_RGB, SHIFT_TO_EQUATION_RGB);
}
DevelBlendEquation::Type BlendingOptions::GetBlendEquationAlpha() const
{
- return RetrieveBlendEquation( mBitmask, MASK_EQUATION_ALPHA, SHIFT_TO_EQUATION_ALPHA );
+ return RetrieveBlendEquation(mBitmask, MASK_EQUATION_ALPHA, SHIFT_TO_EQUATION_ALPHA);
}
-void BlendingOptions::SetBlendColor( const Vector4& color )
+void BlendingOptions::SetBlendColor(const Vector4& color)
{
- if( Color::TRANSPARENT == color )
+ if(Color::TRANSPARENT == color)
{
mBlendColor = nullptr;
}
else
{
- if( mBlendColor )
+ if(mBlendColor)
{
*mBlendColor = color;
}
else
{
// Lazy allocation when non-default is set
- mBlendColor = new Vector4( color );
+ mBlendColor = new Vector4(color);
}
}
}
bool BlendingOptions::IsAdvancedBlendEquationApplied()
{
unsigned int indexRgb = mBitmask & MASK_EQUATION_RGB;
- indexRgb = indexRgb >> SHIFT_TO_EQUATION_RGB;
- unsigned int indexA = mBitmask & MASK_EQUATION_ALPHA;
- indexA = indexA >> SHIFT_TO_EQUATION_ALPHA;
+ indexRgb = indexRgb >> SHIFT_TO_EQUATION_RGB;
+ unsigned int indexA = mBitmask & MASK_EQUATION_ALPHA;
+ indexA = indexA >> SHIFT_TO_EQUATION_ALPHA;
- return ( ( ( indexRgb >= BLENDING_EQUATION_ADVANCED_INDEX_START ) && ( indexRgb <= BLENDING_EQUATION_ADVANCED_INDEX_END ) ) ||
- ( ( indexA >= BLENDING_EQUATION_ADVANCED_INDEX_START ) && ( indexA <= BLENDING_EQUATION_ADVANCED_INDEX_END ) ) );
+ return (((indexRgb >= BLENDING_EQUATION_ADVANCED_INDEX_START) && (indexRgb <= BLENDING_EQUATION_ADVANCED_INDEX_END)) ||
+ ((indexA >= BLENDING_EQUATION_ADVANCED_INDEX_START) && (indexA <= BLENDING_EQUATION_ADVANCED_INDEX_END)));
}
-bool BlendingOptions::IsAdvancedBlendEquationIncluded( unsigned int bitmask )
+bool BlendingOptions::IsAdvancedBlendEquationIncluded(unsigned int bitmask)
{
unsigned int indexRgb = bitmask & MASK_EQUATION_RGB;
- indexRgb = indexRgb >> SHIFT_TO_EQUATION_RGB;
- unsigned int indexA = bitmask & MASK_EQUATION_ALPHA;
- indexA = indexA >> SHIFT_TO_EQUATION_ALPHA;
+ indexRgb = indexRgb >> SHIFT_TO_EQUATION_RGB;
+ unsigned int indexA = bitmask & MASK_EQUATION_ALPHA;
+ indexA = indexA >> SHIFT_TO_EQUATION_ALPHA;
- return ( ( ( indexRgb >= BLENDING_EQUATION_ADVANCED_INDEX_START ) && ( indexRgb <= BLENDING_EQUATION_ADVANCED_INDEX_END ) ) ||
- ( ( indexA >= BLENDING_EQUATION_ADVANCED_INDEX_START ) && ( indexA <= BLENDING_EQUATION_ADVANCED_INDEX_END ) ) );
+ return (((indexRgb >= BLENDING_EQUATION_ADVANCED_INDEX_START) && (indexRgb <= BLENDING_EQUATION_ADVANCED_INDEX_END)) ||
+ ((indexA >= BLENDING_EQUATION_ADVANCED_INDEX_START) && (indexA <= BLENDING_EQUATION_ADVANCED_INDEX_END)));
}
-bool BlendingOptions::IsAdvancedBlendEquation( DevelBlendEquation::Type equation )
+bool BlendingOptions::IsAdvancedBlendEquation(DevelBlendEquation::Type equation)
{
- switch ( equation )
+ switch(equation)
{
case DevelBlendEquation::MULTIPLY:
case DevelBlendEquation::SCREEN:
#define DALI_BLENDING_OPTIONS_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/rendering/renderer.h>
#include <dali/devel-api/rendering/renderer-devel.h>
-#include <dali/public-api/math/vector4.h>
#include <dali/internal/common/owner-pointer.h>
+#include <dali/public-api/math/vector4.h>
+#include <dali/public-api/rendering/renderer.h>
namespace Dali
{
-
namespace Internal
{
-
// This is an optimization to avoid storing 6 separate blending values
struct BlendingOptions
{
* Set the blending options.
* @param[in] A bitmask of blending options.
*/
- void SetBitmask( unsigned int bitmask );
+ void SetBitmask(unsigned int bitmask);
/**
* Retrieve the blending options as a bitmask.
/**
* @copydoc Dali::RenderableActor::SetBlendFunc()
*/
- void SetBlendFunc( BlendFactor::Type srcFactorRgb, BlendFactor::Type destFactorRgb,
- BlendFactor::Type srcFactorAlpha, BlendFactor::Type destFactorAlpha );
+ void SetBlendFunc(BlendFactor::Type srcFactorRgb, BlendFactor::Type destFactorRgb, BlendFactor::Type srcFactorAlpha, BlendFactor::Type destFactorAlpha);
/**
* @copydoc Dali::RenderableActor::GetBlendFunc()
/**
* @copydoc Dali::RenderableActor::SetBlendEquation()
*/
- void SetBlendEquation( DevelBlendEquation::Type equationRgb, DevelBlendEquation::Type equationAlpha );
+ void SetBlendEquation(DevelBlendEquation::Type equationRgb, DevelBlendEquation::Type equationAlpha);
/**
* @copydoc Dali::RenderableActor::GetBlendEquation()
* @param[in] color The blend color.
* @return True if the blend color changed, otherwise it was already the same color.
*/
- void SetBlendColor( const Vector4& color );
+ void SetBlendColor(const Vector4& color);
/**
* Query the blend color.
* Query whether input bit mask include advanced blend equation.
* @return True if the bit mask include advanced blend equation.
*/
- static bool IsAdvancedBlendEquationIncluded( unsigned int bitmask );
+ static bool IsAdvancedBlendEquationIncluded(unsigned int bitmask);
/**
* Query whether input blend equation is advanced option.
* @return True if input blend equation is advanced.
*/
- static bool IsAdvancedBlendEquation( DevelBlendEquation::Type equation );
+ static bool IsAdvancedBlendEquation(DevelBlendEquation::Type equation);
private:
-
// Undefined copy constructor.
BlendingOptions(const BlendingOptions& typePath);
BlendingOptions& operator=(const BlendingOptions& rhs);
private:
-
unsigned int mBitmask; ///< A bitmask of blending options
- OwnerPointer< Vector4> mBlendColor; ///< A heap-allocated color (owned)
-
+ OwnerPointer<Vector4> mBlendColor; ///< A heap-allocated color (owned)
};
} // namespace Internal
#define DALI_INTERNAL_BUFFER_INDEX_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
using BufferIndex = uint32_t;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstddef>
#include <cstring>
#include <functional>
-#include <vector>
#include <mutex>
+#include <vector>
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
{
class ArenaAllocator
{
-
public:
ArenaAllocator()
{
const std::lock_guard<std::mutex> lock(mMutex);
auto bucketNumber = FindBucket(str);
- auto& bucket = mTable[bucketNumber];
+ auto& bucket = mTable[bucketNumber];
if(bucket)
{
unsigned FindBucket(std::string_view name)
{
- unsigned bucketSize = mBuckets;
- unsigned fullHashValue = std::hash<std::string_view>{}(name);
- unsigned bucketNumber = fullHashValue & (bucketSize - 1);
+ unsigned bucketSize = mBuckets;
+ unsigned fullHashValue = std::hash<std::string_view>{}(name);
+ unsigned bucketNumber = fullHashValue & (bucketSize - 1);
// point to the start of the hashvalue segment.
- unsigned* hashTable = reinterpret_cast<unsigned*>(mTable + mBuckets + 1);
+ unsigned* hashTable = reinterpret_cast<unsigned*>(mTable + mBuckets + 1);
unsigned probeAmt = 1;
while(true)
namespace Dali
{
-
namespace Internal
{
-
/**
* @brief Private implementation class
*/
*/
struct Block
{
- void* blockMemory; ///< The allocated memory from which allocations can be made
- Block* nextBlock; ///< The next block in the linked list
+ void* blockMemory; ///< The allocated memory from which allocations can be made
+ Block* nextBlock; ///< The next block in the linked list
#ifdef DEBUG_ENABLED
SizeType mBlockSize; ///< Size of the block in bytes
#endif
*
* @param size The size of the memory block to allocate in bytes. Must be non-zero.
*/
- Block( SizeType size )
- : nextBlock( nullptr )
+ Block(SizeType size)
+ : nextBlock(nullptr)
#ifdef DEBUG_ENABLED
- ,mBlockSize( size )
+ ,
+ mBlockSize(size)
#endif
{
- blockMemory = ::operator new( size );
- DALI_ASSERT_ALWAYS( blockMemory && "Out of memory" );
+ blockMemory = ::operator new(size);
+ DALI_ASSERT_ALWAYS(blockMemory && "Out of memory");
}
/**
*/
~Block()
{
- ::operator delete( blockMemory );
+ ::operator delete(blockMemory);
}
private:
// Undefined
- Block( const Block& block );
+ Block(const Block& block);
// Undefined
- Block& operator=( const Block& block );
+ Block& operator=(const Block& block);
};
/**
* @brief Constructor
*/
- Impl( SizeType fixedSize, SizeType initialCapacity, SizeType maximumBlockCapacity )
- : mMutex(),
- mFixedSize( fixedSize ),
- mMemoryBlocks( initialCapacity * mFixedSize ),
- mMaximumBlockCapacity( maximumBlockCapacity ),
- mCurrentBlock( &mMemoryBlocks ),
- mCurrentBlockCapacity( initialCapacity ),
- mCurrentBlockSize( 0 ),
- mDeletedObjects( nullptr )
+ Impl(SizeType fixedSize, SizeType initialCapacity, SizeType maximumBlockCapacity)
+ : mMutex(),
+ mFixedSize(fixedSize),
+ mMemoryBlocks(initialCapacity * mFixedSize),
+ mMaximumBlockCapacity(maximumBlockCapacity),
+ mCurrentBlock(&mMemoryBlocks),
+ mCurrentBlockCapacity(initialCapacity),
+ mCurrentBlockSize(0),
+ mDeletedObjects(nullptr)
{
// We need enough room to store the deleted list in the data
- DALI_ASSERT_DEBUG( mFixedSize >= sizeof( void* ) );
+ DALI_ASSERT_DEBUG(mFixedSize >= sizeof(void*));
}
/**
{
// Clean up memory block linked list (mMemoryBlocks will be auto-destroyed by its destructor)
Block* block = mMemoryBlocks.nextBlock;
- while( block )
+ while(block)
{
Block* nextBlock = block->nextBlock;
delete block;
{
// Double capacity for the new block
SizeType size = mCurrentBlockCapacity * 2;
- if( size > mMaximumBlockCapacity || size < mCurrentBlockCapacity ) // Check for overflow of size type
+ if(size > mMaximumBlockCapacity || size < mCurrentBlockCapacity) // Check for overflow of size type
{
size = mMaximumBlockCapacity;
}
mCurrentBlockCapacity = size;
// Allocate
- Block* block = new Block( mCurrentBlockCapacity * mFixedSize );
- mCurrentBlock->nextBlock = block; // Add to end of linked list
- mCurrentBlock = block;
+ Block* block = new Block(mCurrentBlockCapacity * mFixedSize);
+ mCurrentBlock->nextBlock = block; // Add to end of linked list
+ mCurrentBlock = block;
mCurrentBlockSize = 0;
}
* @brief check the memory being free'd exists inside the memory pool
* @param[in] memory address of object to remove
*/
- void CheckMemoryIsInsidePool( const void* const memory )
+ void CheckMemoryIsInsidePool(const void* const memory)
{
- bool inRange = false;
- const Block* block = &mMemoryBlocks;
+ bool inRange = false;
+ const Block* block = &mMemoryBlocks;
- while( block )
+ while(block)
{
- const void* const endOfBlock = reinterpret_cast<char *>( block->blockMemory )+ block->mBlockSize;
+ const void* const endOfBlock = reinterpret_cast<char*>(block->blockMemory) + block->mBlockSize;
- if( ( memory >= block->blockMemory ) && ( memory < (endOfBlock) ) )
+ if((memory >= block->blockMemory) && (memory < (endOfBlock)))
{
inRange = true;
break;
}
block = block->nextBlock;
}
- DALI_ASSERT_DEBUG( inRange && "Freeing memory that does not exist in memory pool" );
+ DALI_ASSERT_DEBUG(inRange && "Freeing memory that does not exist in memory pool");
}
#endif
- Mutex mMutex; ///< Mutex for thread-safe allocation and deallocation
+ Mutex mMutex; ///< Mutex for thread-safe allocation and deallocation
- SizeType mFixedSize; ///< The size of each allocation in bytes
+ SizeType mFixedSize; ///< The size of each allocation in bytes
- Block mMemoryBlocks; ///< Linked list of allocated memory blocks
- SizeType mMaximumBlockCapacity; ///< The maximum allowed capacity of allocations in a new memory block
+ Block mMemoryBlocks; ///< Linked list of allocated memory blocks
+ SizeType mMaximumBlockCapacity; ///< The maximum allowed capacity of allocations in a new memory block
- Block* mCurrentBlock; ///< Pointer to the active block
- SizeType mCurrentBlockCapacity; ///< The maximum number of allocations that can be allocated for the current block
- SizeType mCurrentBlockSize; ///< The number of allocations allocated to the current block
+ Block* mCurrentBlock; ///< Pointer to the active block
+ SizeType mCurrentBlockCapacity; ///< The maximum number of allocations that can be allocated for the current block
+ SizeType mCurrentBlockSize; ///< The number of allocations allocated to the current block
- void* mDeletedObjects; ///< Pointer to the head of the list of deleted objects. The addresses are stored in the allocated memory blocks.
+ void* mDeletedObjects; ///< Pointer to the head of the list of deleted objects. The addresses are stored in the allocated memory blocks.
};
-FixedSizeMemoryPool::FixedSizeMemoryPool( SizeType fixedSize, SizeType initialCapacity, SizeType maximumBlockCapacity )
+FixedSizeMemoryPool::FixedSizeMemoryPool(SizeType fixedSize, SizeType initialCapacity, SizeType maximumBlockCapacity)
{
- mImpl = new Impl( fixedSize, initialCapacity, maximumBlockCapacity );
+ mImpl = new Impl(fixedSize, initialCapacity, maximumBlockCapacity);
}
FixedSizeMemoryPool::~FixedSizeMemoryPool()
void* FixedSizeMemoryPool::Allocate()
{
// First, recycle deleted objects
- if( mImpl->mDeletedObjects )
+ if(mImpl->mDeletedObjects)
{
- void* recycled = mImpl->mDeletedObjects;
- mImpl->mDeletedObjects = *( reinterpret_cast< void** >( mImpl->mDeletedObjects ) ); // Pop head off front of deleted objects list
+ void* recycled = mImpl->mDeletedObjects;
+ mImpl->mDeletedObjects = *(reinterpret_cast<void**>(mImpl->mDeletedObjects)); // Pop head off front of deleted objects list
return recycled;
}
// Check if current block is full
- if( mImpl->mCurrentBlockSize >= mImpl->mCurrentBlockCapacity )
+ if(mImpl->mCurrentBlockSize >= mImpl->mCurrentBlockCapacity)
{
mImpl->AllocateNewBlock();
}
// Placement new the object in block memory
- uint8_t* objectAddress = static_cast< uint8_t* >( mImpl->mCurrentBlock->blockMemory );
+ uint8_t* objectAddress = static_cast<uint8_t*>(mImpl->mCurrentBlock->blockMemory);
objectAddress += mImpl->mCurrentBlockSize * mImpl->mFixedSize;
mImpl->mCurrentBlockSize++;
return objectAddress;
}
-void FixedSizeMemoryPool::Free( void* memory )
+void FixedSizeMemoryPool::Free(void* memory)
{
- if( memory )
+ if(memory)
{
#ifdef DEBUG_ENABLED
- mImpl->CheckMemoryIsInsidePool( memory );
+ mImpl->CheckMemoryIsInsidePool(memory);
#endif
// Add memory to head of deleted objects list. Store next address in the same memory space as the old object.
- *( reinterpret_cast< void** >( memory ) ) = mImpl->mDeletedObjects;
- mImpl->mDeletedObjects = memory;
+ *(reinterpret_cast<void**>(memory)) = mImpl->mDeletedObjects;
+ mImpl->mDeletedObjects = memory;
}
}
void* FixedSizeMemoryPool::AllocateThreadSafe()
{
- Mutex::ScopedLock lock( mImpl->mMutex );
+ Mutex::ScopedLock lock(mImpl->mMutex);
return Allocate();
}
-void FixedSizeMemoryPool::FreeThreadSafe( void* memory )
+void FixedSizeMemoryPool::FreeThreadSafe(void* memory)
{
- if( memory )
+ if(memory)
{
- Mutex::ScopedLock lock( mImpl->mMutex );
- Free( memory );
+ Mutex::ScopedLock lock(mImpl->mMutex);
+ Free(memory);
}
}
-
} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* @brief Calculate the size of a type taking alignment into account
*/
-template< typename T >
+template<typename T>
struct TypeSizeWithAlignment
{
///< The size of the type with alignment taken into account
- static const size_t size = ( ( sizeof( T ) + sizeof( void* ) - 1 ) / sizeof( void* ) ) * sizeof( void* );
+ static const size_t size = ((sizeof(T) + sizeof(void*) - 1) / sizeof(void*)) * sizeof(void*);
};
/**
using SizeType = uint32_t;
public:
-
/**
* @brief Constructor.
*
* @param maximumBlockCapacity The maximum size that a new block of memory can be allocated. Defaults to
* a large value (1024 * 1024 = 1048576).
*/
- explicit FixedSizeMemoryPool( SizeType fixedSize, SizeType initialCapacity = 32, SizeType maximumBlockCapacity = 1048576 );
+ explicit FixedSizeMemoryPool(SizeType fixedSize, SizeType initialCapacity = 32, SizeType maximumBlockCapacity = 1048576);
/**
* @brief Destructor.
*
* @param memory The memory to be deleted. Must have been allocated by this memory pool
*/
- void Free( void* memory );
+ void Free(void* memory);
/**
* @brief Thread-safe version of Free()
*
* @param memory The memory to be deleted. Must have been allocated by this memory pool
*/
- void FreeThreadSafe( void* memory );
+ void FreeThreadSafe(void* memory);
private:
-
// Undefined
- FixedSizeMemoryPool( const FixedSizeMemoryPool& fixedSizeMemoryPool );
+ FixedSizeMemoryPool(const FixedSizeMemoryPool& fixedSizeMemoryPool);
// Undefined
- FixedSizeMemoryPool& operator=( const FixedSizeMemoryPool& fixedSizeMemoryPool );
+ FixedSizeMemoryPool& operator=(const FixedSizeMemoryPool& fixedSizeMemoryPool);
private:
-
struct Impl;
Impl* mImpl;
-
};
} // namespace Internal
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Internal
{
-
const ImageAttributes ImageAttributes::DEFAULT_ATTRIBUTES;
struct ImageAttributes::ImageAttributesImpl
{
ImageAttributesImpl()
- : width(0),
- height(0),
- scaling(Dali::FittingMode::SHRINK_TO_FIT),
- filtering(SamplingMode::BOX),
- mOrientationCorrection(false)
+ : width(0),
+ height(0),
+ scaling(Dali::FittingMode::SHRINK_TO_FIT),
+ filtering(SamplingMode::BOX),
+ mOrientationCorrection(false)
{
}
ImageAttributesImpl& operator=(const ImageAttributesImpl& rhs)
{
- if (this != &rhs)
+ if(this != &rhs)
{
- width = rhs.width;
- height = rhs.height;
- scaling = rhs.scaling;
+ width = rhs.width;
+ height = rhs.height;
+ scaling = rhs.scaling;
filtering = rhs.filtering;
mOrientationCorrection = rhs.mOrientationCorrection;
return *this;
}
- uint16_t width; ///< image width in pixels
- uint16_t height; ///< image height in pixels
- ScalingMode scaling : 3; ///< scaling option, ShrinkToFit is default
- FilterMode filtering : 4; ///< filtering option. Box is the default
- bool mOrientationCorrection : 1; ///< If true, image pixels are reordered according to orientation metadata on load.
+ uint16_t width; ///< image width in pixels
+ uint16_t height; ///< image height in pixels
+ ScalingMode scaling : 3; ///< scaling option, ShrinkToFit is default
+ FilterMode filtering : 4; ///< filtering option. Box is the default
+ bool mOrientationCorrection : 1; ///< If true, image pixels are reordered according to orientation metadata on load.
};
-
ImageAttributes::ImageAttributes()
-: impl( new ImageAttributesImpl() )
+: impl(new ImageAttributesImpl())
{
}
ImageAttributes::ImageAttributes(const ImageAttributes& rhs)
-: impl( new ImageAttributesImpl(*rhs.impl) )
+: impl(new ImageAttributesImpl(*rhs.impl))
{
}
void ImageAttributes::SetSize(uint32_t width, uint32_t height)
{
- impl->width = static_cast<uint16_t>( width ); // truncated
- impl->height = static_cast<uint16_t>( height ); // truncated
+ impl->width = static_cast<uint16_t>(width); // truncated
+ impl->height = static_cast<uint16_t>(height); // truncated
}
-void ImageAttributes::SetSize( const Size& size )
+void ImageAttributes::SetSize(const Size& size)
{
- impl->width = static_cast<uint16_t>( size.width ); // truncated
- impl->height = static_cast<uint16_t>( size.height ); // truncated
+ impl->width = static_cast<uint16_t>(size.width); // truncated
+ impl->height = static_cast<uint16_t>(size.height); // truncated
}
-void ImageAttributes::SetScalingMode( ScalingMode scale )
+void ImageAttributes::SetScalingMode(ScalingMode scale)
{
impl->scaling = scale;
}
-void ImageAttributes::SetFilterMode( FilterMode filtering )
+void ImageAttributes::SetFilterMode(FilterMode filtering)
{
impl->filtering = filtering;
}
impl->mOrientationCorrection = enabled;
}
-void ImageAttributes::Reset( ImageDimensions dimensions, ScalingMode scaling, FilterMode sampling, bool orientationCorrection )
+void ImageAttributes::Reset(ImageDimensions dimensions, ScalingMode scaling, FilterMode sampling, bool orientationCorrection)
{
- impl->width = dimensions.GetWidth();
- impl->height = dimensions.GetHeight();
- impl->scaling = scaling;
- impl->filtering = sampling;
+ impl->width = dimensions.GetWidth();
+ impl->height = dimensions.GetHeight();
+ impl->scaling = scaling;
+ impl->filtering = sampling;
impl->mOrientationCorrection = orientationCorrection;
}
*/
bool operator<(const ImageAttributes& a, const ImageAttributes& b)
{
- if (a.impl->width != b.impl->width)
+ if(a.impl->width != b.impl->width)
{
return a.impl->width < b.impl->width;
}
- if (a.impl->height != b.impl->height)
+ if(a.impl->height != b.impl->height)
{
return a.impl->height < b.impl->height;
}
- if (a.impl->mOrientationCorrection != b.impl->mOrientationCorrection)
+ if(a.impl->mOrientationCorrection != b.impl->mOrientationCorrection)
{
return a.impl->mOrientationCorrection < b.impl->mOrientationCorrection;
}
- if (a.impl->scaling != b.impl->scaling)
+ if(a.impl->scaling != b.impl->scaling)
{
return a.impl->scaling < b.impl->scaling;
}
- if (a.impl->filtering != b.impl->filtering)
+ if(a.impl->filtering != b.impl->filtering)
{
return a.impl->filtering < b.impl->filtering;
}
*/
bool operator==(const ImageAttributes& a, const ImageAttributes& b)
{
- return a.impl->width == b.impl->width &&
- a.impl->height == b.impl->height &&
+ return a.impl->width == b.impl->width &&
+ a.impl->height == b.impl->height &&
a.impl->mOrientationCorrection == b.impl->mOrientationCorrection &&
- a.impl->scaling == b.impl->scaling &&
- a.impl->filtering == b.impl->filtering;
+ a.impl->scaling == b.impl->scaling &&
+ a.impl->filtering == b.impl->filtering;
}
/**
#define DALI_INTERNAL_IMAGE_ATTRIBUTES_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <stdint.h>
// INTERNAL INCLUDES
-#include <dali/public-api/images/pixel.h>
#include <dali/public-api/images/image-operations.h>
+#include <dali/public-api/images/pixel.h>
#include <dali/public-api/math/rect.h>
#include <dali/public-api/math/vector2.h>
{
namespace Internal
{
-
/**
* @brief Describes Image properties like dimensions and pixel format and
* operations to be applied to images during the load process.
class ImageAttributes
{
public:
-
/**
* @brief Scaling options, used when resizing images on load to fit desired dimensions.
*
* @param [in] width desired width.
* @param [in] height desired height
*/
- void SetSize( uint32_t width, uint32_t height);
+ void SetSize(uint32_t width, uint32_t height);
/**
* @brief Set the image dimension properties.
*
* @param [in] size desired size.
*/
- void SetSize( const Size& size );
+ void SetSize(const Size& size);
/**
* @brief Set the scale field of the image attributes.
* By default, ShrinkToFit is set.
* @param [in] scalingMode The desired scaling mode
*/
- void SetScalingMode( ScalingMode scalingMode );
+ void SetScalingMode(ScalingMode scalingMode);
/**
* @brief Setter for the FilterMode.
* By default, Box is set.
* @param [in] filterMode The desired filter mode.
*/
- void SetFilterMode( FilterMode filterMode );
+ void SetFilterMode(FilterMode filterMode);
/**
* @brief Set whether the image will be rotated/flipped back into portrait orientation.
* @param[in] sampling Sampling mode.
* @param[in] orientation Orientation correction toggle.
*/
- void Reset( ImageDimensions dimensions = ImageDimensions(0, 0), ScalingMode scaling = ScalingMode(), FilterMode sampling = FilterMode(), bool orientationCorrection = true );
-
+ void Reset(ImageDimensions dimensions = ImageDimensions(0, 0), ScalingMode scaling = ScalingMode(), FilterMode sampling = FilterMode(), bool orientationCorrection = true);
/**
* @brief Return the width currently represented by the attribute.
namespace Dali
{
-
namespace Internal
{
-
namespace ImageSampler
{
-
/**
* Utility to store one of the sampling parameters values.
* @param[out] options A bitmask used to store the FilterMode values.
* @param[in] factor The FilterMode value.
* @param[in] bitshift Used to shift to the correct part of options.
*/
-void StoreSamplingParameter( unsigned int& options, unsigned int mode, int bitShift )
+void StoreSamplingParameter(unsigned int& options, unsigned int mode, int bitShift)
{
- if( mode != 0 )
+ if(mode != 0)
{
- options |= ( mode << bitShift );
+ options |= (mode << bitShift);
}
}
* @param[in] bitshift Used to shift to the correct part of options.
* @return Return the filter mode.
*/
-unsigned int RetrieveSamplingParameter( unsigned int options, int mask, int bitShift )
+unsigned int RetrieveSamplingParameter(unsigned int options, int mask, int bitShift)
{
unsigned int index = options & mask;
- index = ( index >> bitShift ); // Zero based index for array
+ index = (index >> bitShift); // Zero based index for array
return index;
}
-unsigned int PackBitfield( FilterMode::Type minify, FilterMode::Type magnify, WrapMode::Type uWrap, WrapMode::Type vWrap )
+unsigned int PackBitfield(FilterMode::Type minify, FilterMode::Type magnify, WrapMode::Type uWrap, WrapMode::Type vWrap)
{
unsigned int bitfield = 0;
- StoreSamplingParameter( bitfield, minify, MINIFY_BIT_SHIFT );
- StoreSamplingParameter( bitfield, magnify, MAGNIFY_BIT_SHIFT );
- StoreSamplingParameter( bitfield, uWrap, UWRAP_BIT_SHIFT );
- StoreSamplingParameter( bitfield, vWrap, VWRAP_BIT_SHIFT );
+ StoreSamplingParameter(bitfield, minify, MINIFY_BIT_SHIFT);
+ StoreSamplingParameter(bitfield, magnify, MAGNIFY_BIT_SHIFT);
+ StoreSamplingParameter(bitfield, uWrap, UWRAP_BIT_SHIFT);
+ StoreSamplingParameter(bitfield, vWrap, VWRAP_BIT_SHIFT);
return bitfield;
}
-FilterMode::Type GetMinifyFilterMode( unsigned int bitfield )
+FilterMode::Type GetMinifyFilterMode(unsigned int bitfield)
{
- return static_cast<FilterMode::Type>( RetrieveSamplingParameter( bitfield, MASK_MINIFY_FILTER, MINIFY_BIT_SHIFT ) );
+ return static_cast<FilterMode::Type>(RetrieveSamplingParameter(bitfield, MASK_MINIFY_FILTER, MINIFY_BIT_SHIFT));
}
-FilterMode::Type GetMagnifyFilterMode( unsigned int bitfield )
+FilterMode::Type GetMagnifyFilterMode(unsigned int bitfield)
{
- return static_cast<FilterMode::Type>( RetrieveSamplingParameter( bitfield, MASK_MAGNIFY_FILTER, MAGNIFY_BIT_SHIFT ) );
+ return static_cast<FilterMode::Type>(RetrieveSamplingParameter(bitfield, MASK_MAGNIFY_FILTER, MAGNIFY_BIT_SHIFT));
}
-WrapMode::Type GetUWrapMode( unsigned int bitfield )
+WrapMode::Type GetUWrapMode(unsigned int bitfield)
{
- return static_cast<WrapMode::Type>( RetrieveSamplingParameter( bitfield, MASK_UWRAP_MODE, UWRAP_BIT_SHIFT ) );
+ return static_cast<WrapMode::Type>(RetrieveSamplingParameter(bitfield, MASK_UWRAP_MODE, UWRAP_BIT_SHIFT));
}
-WrapMode::Type GetVWrapMode( unsigned int bitfield )
+WrapMode::Type GetVWrapMode(unsigned int bitfield)
{
- return static_cast<WrapMode::Type>( RetrieveSamplingParameter( bitfield, MASK_VWRAP_MODE, VWRAP_BIT_SHIFT ) );
+ return static_cast<WrapMode::Type>(RetrieveSamplingParameter(bitfield, MASK_VWRAP_MODE, VWRAP_BIT_SHIFT));
}
} // namespace ImageSampler
#define DALI_IMAGE_SAMPLER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* ImageSampler represents a set of sampling settings that can be applied to a texture.
*/
namespace ImageSampler
{
- /**
+/**
* Bitshift values
*/
- enum
- {
- MINIFY_BIT_SHIFT = 0,
- MAGNIFY_BIT_SHIFT = 4,
- UWRAP_BIT_SHIFT = 8,
- VWRAP_BIT_SHIFT = 12
- };
+enum
+{
+ MINIFY_BIT_SHIFT = 0,
+ MAGNIFY_BIT_SHIFT = 4,
+ UWRAP_BIT_SHIFT = 8,
+ VWRAP_BIT_SHIFT = 12
+};
- /**
+/**
* Mask values
*/
- enum
- {
- MASK_MINIFY_FILTER = 0x000F,
- MASK_MAGNIFY_FILTER = 0x00F0,
- MASK_UWRAP_MODE = 0x0F00,
- MASK_VWRAP_MODE = 0xF000,
- };
+enum
+{
+ MASK_MINIFY_FILTER = 0x000F,
+ MASK_MAGNIFY_FILTER = 0x00F0,
+ MASK_UWRAP_MODE = 0x0F00,
+ MASK_VWRAP_MODE = 0xF000,
+};
- /**
+/**
* Precalculate default sampler bitfield
*/
- enum
- {
- DEFAULT_BITFIELD = (Dali::FilterMode::DEFAULT<<MINIFY_BIT_SHIFT) | (Dali::FilterMode::DEFAULT<<MAGNIFY_BIT_SHIFT) | (Dali::WrapMode::DEFAULT<<UWRAP_BIT_SHIFT) | (Dali::WrapMode::DEFAULT<<VWRAP_BIT_SHIFT)
- };
+enum
+{
+ DEFAULT_BITFIELD = (Dali::FilterMode::DEFAULT << MINIFY_BIT_SHIFT) | (Dali::FilterMode::DEFAULT << MAGNIFY_BIT_SHIFT) | (Dali::WrapMode::DEFAULT << UWRAP_BIT_SHIFT) | (Dali::WrapMode::DEFAULT << VWRAP_BIT_SHIFT)
+};
- /**
+/**
* @brief Pack the filter mode into a bitfield.
*
* @param[in] minify The minification filter.
* @param[in] magnify The magnification filter.
* @return Return the packed bitfield.
*/
- unsigned int PackBitfield( FilterMode::Type minify, FilterMode::Type magnify, WrapMode::Type uWrap = WrapMode::DEFAULT, WrapMode::Type vWrap = WrapMode::DEFAULT );
+unsigned int PackBitfield(FilterMode::Type minify, FilterMode::Type magnify, WrapMode::Type uWrap = WrapMode::DEFAULT, WrapMode::Type vWrap = WrapMode::DEFAULT);
- /**
+/**
* @brief Return the minification filter from a packed bitfield.
*
* @return Return the minification filter.
*/
- FilterMode::Type GetMinifyFilterMode( unsigned int bitfield );
+FilterMode::Type GetMinifyFilterMode(unsigned int bitfield);
- /**
+/**
* @brief Return the magnification filter from a packed bitfield.
*
* @return Return the magnification filter.
*/
- FilterMode::Type GetMagnifyFilterMode( unsigned int bitfield );
+FilterMode::Type GetMagnifyFilterMode(unsigned int bitfield);
- /**
+/**
* @brief Return the wrap mode in x direction from a packed bitfield.
*
* @return Return the wrap mode.
*/
- WrapMode::Type GetUWrapMode( unsigned int bitfield );
+WrapMode::Type GetUWrapMode(unsigned int bitfield);
- /**
+/**
* @brief Return the wrap mode in y direction from a packed bitfield.
*
* @return Return the wrap mode.
*/
- WrapMode::Type GetVWrapMode( unsigned int bitfield );
+WrapMode::Type GetVWrapMode(unsigned int bitfield);
} // namespace ImageSampler
#define DALI_INTERNAL_CONSTANTS_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
// Constants used by renderers and actors to determine if something is visible.
static constexpr float FULLY_OPAQUE(0.99f); ///< Alpha values must drop below this, before an object is considered to be transparent.
static constexpr float FULLY_TRANSPARENT(0.01f); ///< Alpha values must rise above this, before an object is considered to be visible.
} // namespace Dali
-
#endif // DALI_INTERNAL_CONSTANTS_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/render/common/performance-monitor.h>
#include <dali/public-api/common/constants.h>
-#include <dali/public-api/math/vector2.h>
#include <dali/public-api/math/matrix.h>
+#include <dali/public-api/math/vector2.h>
-void Dali::Internal::TransformVector3( Vec3 result, const Mat4 m, const Vec3 v )
+void Dali::Internal::TransformVector3(Vec3 result, const Mat4 m, const Vec3 v)
{
#ifndef __ARM_NEON__
#else
- Vec4 temp = { v[0], v[1], v[2], 0.0f };
+ Vec4 temp = {v[0], v[1], v[2], 0.0f};
Vec4 tempResult;
- asm volatile ( "VLD1.F32 {q0}, [%1] \n\t" //Load "temp" from memory to register q0
- "VLD1.F32 {q1}, [%0]! \n\t" //Load first row of the matrix from memory to register q1
- "VMUL.F32 q2, q1, d0[0] \n\t" //q2 = (m[0..3] * v.x)
- "VLD1.F32 {q1}, [%0]! \n\t" //Load second row of the matrix from memory
- "VMLA.F32 q2, q1, d0[1] \n\t" //q2 = (m[0..3] * v.x) + (m[4..7] * v.y)
- "VLD1.F32 {q1}, [%0]! \n\t" //Load third row of the matrix from memory
- "VMLA.F32 q2, q1, d1[0] \n\t" //q2 = (m[0..3] * v.x) + (m[4..7] * v.y) + (m[8...11] * v.z)
- "VST1.F32 {q2}, [%2] \n\t" //Write the result back to memory
- :
- : "r"(m), "r"(temp), "r"(tempResult)
- : "q0", "q1", "q2", "memory" );
+ asm volatile(
+ "VLD1.F32 {q0}, [%1] \n\t" //Load "temp" from memory to register q0
+ "VLD1.F32 {q1}, [%0]! \n\t" //Load first row of the matrix from memory to register q1
+ "VMUL.F32 q2, q1, d0[0] \n\t" //q2 = (m[0..3] * v.x)
+ "VLD1.F32 {q1}, [%0]! \n\t" //Load second row of the matrix from memory
+ "VMLA.F32 q2, q1, d0[1] \n\t" //q2 = (m[0..3] * v.x) + (m[4..7] * v.y)
+ "VLD1.F32 {q1}, [%0]! \n\t" //Load third row of the matrix from memory
+ "VMLA.F32 q2, q1, d1[0] \n\t" //q2 = (m[0..3] * v.x) + (m[4..7] * v.y) + (m[8...11] * v.z)
+ "VST1.F32 {q2}, [%2] \n\t" //Write the result back to memory
+ :
+ : "r"(m), "r"(temp), "r"(tempResult)
+ : "q0", "q1", "q2", "memory");
result[0] = tempResult[0];
result[1] = tempResult[1];
#endif
}
-Dali::Vector2 Dali::Internal::Transform2D( const Dali::Matrix& matrix, const float x, const float y )
+Dali::Vector2 Dali::Internal::Transform2D(const Dali::Matrix& matrix, const float x, const float y)
{
- MATH_INCREASE_BY( PerformanceMonitor::FLOAT_POINT_MULTIPLY, 4 );
+ MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 4);
- const float* matrixArray( matrix.AsFloat() );
+ const float* matrixArray(matrix.AsFloat());
// The following optimizations are applied:
// Matrix[8 -> 11] are optimized out.
// z & w results (if we were doing a transformation to a Vector4) are unneeded and so not calculated.
// As we always multiply by component, we do not store the coordinates in a Vector2 to avoid creation.
// Note: For this reason the NEON SIMD version is no faster than the Dali::Matrix '*' Vector4 operator, and therefore not used.
- return Dali::Vector2( x * matrixArray[0] + y * matrixArray[4] + matrixArray[12], x * matrixArray[1] + y * matrixArray[5] + matrixArray[13] );
+ return Dali::Vector2(x * matrixArray[0] + y * matrixArray[4] + matrixArray[12], x * matrixArray[1] + y * matrixArray[5] + matrixArray[13]);
}
-float Dali::Internal::Length( const Vec3 v )
+float Dali::Internal::Length(const Vec3 v)
{
- return sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
+ return sqrtf(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
}
-
-
#define DALI_INTERNAL_MATH_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
struct Vector2;
class Matrix;
namespace Internal
{
-
typedef float Vec3[3];
typedef float Vec4[4];
typedef float Mat4[16];
* @param[in] m The transformation matrix
* @param[in] v The vector to transform
*/
-void TransformVector3( Vec3 result, const Mat4 m, const Vec3 v );
+void TransformVector3(Vec3 result, const Mat4 m, const Vec3 v);
/**
* @brief Applies a transformation matrix to a Vector2
* @param[in] y The y coordinate to multiply the matrix by
* @return A Vector2 containing the resulting coordinates
*/
-Vector2 Transform2D( const Matrix& matrix, const float x, const float y );
+Vector2 Transform2D(const Matrix& matrix, const float x, const float y);
/**
* @brief Computes the length of a vector3
* @param[in] v The vector
* @return The lenght of the vector
*/
-float Length( const Vec3 v );
+float Length(const Vec3 v);
} // namespace Internal
} // namespace Dali
-#endif // DALI_INTERNAL_MATH_H
+#endif // DALI_INTERNAL_MATH_H
#define DALI_INTERNAL_MEMORY_POOL_OBJECT_ALLOCATOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* @brief Helper for allocating/deallocating objects using a memory pool.
*
* The type may be a class or POD.
*
*/
-template< typename T >
+template<typename T>
class MemoryPoolObjectAllocator
{
public:
-
/**
* @brief Constructor
*/
MemoryPoolObjectAllocator()
- : mPool( nullptr )
+ : mPool(nullptr)
{
ResetMemoryPool();
}
*/
T* Allocate()
{
- return new ( mPool->Allocate() ) T();
+ return new(mPool->Allocate()) T();
}
/**
*/
T* AllocateThreadSafe()
{
- return new ( mPool->AllocateThreadSafe() ) T();
+ return new(mPool->AllocateThreadSafe()) T();
}
/**
*
* @param object Pointer to the object to delete
*/
- void Free( T* object )
+ void Free(T* object)
{
- mPool->Free( object );
+ mPool->Free(object);
}
/**
*
* @param object Pointer to the object to delete
*/
- void FreeThreadSafe( T* object )
+ void FreeThreadSafe(T* object)
{
- mPool->FreeThreadSafe( object );
+ mPool->FreeThreadSafe(object);
}
/**
*
* @param object Pointer to the object to delete
*/
- void Destroy( T* object )
+ void Destroy(T* object)
{
object->~T();
- mPool->Free( object );
+ mPool->Free(object);
}
/**
*
* @param object Pointer to the object to delete
*/
- void DestroyThreadSafe( T* object )
+ void DestroyThreadSafe(T* object)
{
object->~T();
- mPool->FreeThreadSafe( object );
+ mPool->FreeThreadSafe(object);
}
/**
{
delete mPool;
- mPool = new FixedSizeMemoryPool( TypeSizeWithAlignment< T >::size );
+ mPool = new FixedSizeMemoryPool(TypeSizeWithAlignment<T>::size);
}
private:
-
// Undefined
- MemoryPoolObjectAllocator( const MemoryPoolObjectAllocator& memoryPoolObjectAllocator );
+ MemoryPoolObjectAllocator(const MemoryPoolObjectAllocator& memoryPoolObjectAllocator);
// Undefined
- MemoryPoolObjectAllocator& operator=( const MemoryPoolObjectAllocator& memoryPoolObjectAllocator );
+ MemoryPoolObjectAllocator& operator=(const MemoryPoolObjectAllocator& memoryPoolObjectAllocator);
private:
-
- FixedSizeMemoryPool* mPool; ///< Memory pool from which allocations are made
-
+ FixedSizeMemoryPool* mPool; ///< Memory pool from which allocations are made
};
} // namespace Internal
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/common/message-buffer.h>
// EXTERNAL INCLUDES
-#include <limits>
#include <cstdlib>
+#include <limits>
// INTERNAL INCLUDES
#include <dali/integration-api/debug.h>
namespace // unnamed namespace
{
-
// Increase capacity by 1.5 when buffer limit reached
const uint32_t INCREMENT_NUMERATOR = 3u;
const uint32_t INCREMENT_DENOMINATOR = 2u;
const uint32_t MESSAGE_SIZE_PLUS_END_FIELD = MESSAGE_SIZE_FIELD + MESSAGE_END_FIELD;
const std::size_t MAX_DIVISION_BY_WORD_REMAINDER = sizeof(Dali::Internal::MessageBuffer::WordType) - 1u; // For word alignment on ARM
-const std::size_t WORD_SIZE = sizeof(Dali::Internal::MessageBuffer::WordType);
+const std::size_t WORD_SIZE = sizeof(Dali::Internal::MessageBuffer::WordType);
} // unnamed namespace
namespace Dali
{
-
namespace Internal
{
-
-MessageBuffer::MessageBuffer( std::size_t initialCapacity )
-: mInitialCapacity( initialCapacity / WORD_SIZE ),
- mData( nullptr ),
- mNextSlot( nullptr ),
- mCapacity( 0 ),
- mSize( 0 )
+MessageBuffer::MessageBuffer(std::size_t initialCapacity)
+: mInitialCapacity(initialCapacity / WORD_SIZE),
+ mData(nullptr),
+ mNextSlot(nullptr),
+ mCapacity(0),
+ mSize(0)
{
}
MessageBuffer::~MessageBuffer()
{
- free( mData );
+ free(mData);
}
-uint32_t* MessageBuffer::ReserveMessageSlot( std::size_t size )
+uint32_t* MessageBuffer::ReserveMessageSlot(std::size_t size)
{
- DALI_ASSERT_DEBUG( 0 != size );
+ DALI_ASSERT_DEBUG(0 != size);
// Number of aligned words required to handle a message of size in bytes
std::size_t requestedSize = (size + MAX_DIVISION_BY_WORD_REMAINDER) / WORD_SIZE;
- std::size_t requiredSize = requestedSize + MESSAGE_SIZE_PLUS_END_FIELD;
+ std::size_t requiredSize = requestedSize + MESSAGE_SIZE_PLUS_END_FIELD;
// Keep doubling the additional capacity until we have enough
std::size_t nextCapacity = mCapacity ? mCapacity : mInitialCapacity;
- if ( (nextCapacity - mSize) < requiredSize )
+ if((nextCapacity - mSize) < requiredSize)
{
nextCapacity = nextCapacity * INCREMENT_NUMERATOR / INCREMENT_DENOMINATOR;
// Something has gone badly wrong if requiredSize is this big
- DALI_ASSERT_DEBUG( (nextCapacity - mSize) > requiredSize );
+ DALI_ASSERT_DEBUG((nextCapacity - mSize) > requiredSize);
}
- if ( nextCapacity > mCapacity )
+ if(nextCapacity > mCapacity)
{
- IncreaseCapacity( nextCapacity );
+ IncreaseCapacity(nextCapacity);
}
// Now reserve the slot
MessageBuffer::Iterator MessageBuffer::Begin() const
{
- if ( 0 != mSize )
+ if(0 != mSize)
{
- return Iterator( mData );
+ return Iterator(mData);
}
- return Iterator( nullptr );
+ return Iterator(nullptr);
}
void MessageBuffer::Reset()
{
// All messages have been processed, reset the buffer
- mSize = 0;
+ mSize = 0;
mNextSlot = mData;
}
-void MessageBuffer::IncreaseCapacity( std::size_t newCapacity )
+void MessageBuffer::IncreaseCapacity(std::size_t newCapacity)
{
- DALI_ASSERT_DEBUG( newCapacity > mCapacity );
+ DALI_ASSERT_DEBUG(newCapacity > mCapacity);
- if ( mData )
+ if(mData)
{
// Often this avoids the need to copy memory
WordType* oldData = mData;
- mData = reinterpret_cast<WordType*>( realloc( mData, newCapacity * WORD_SIZE ) );
+ mData = reinterpret_cast<WordType*>(realloc(mData, newCapacity * WORD_SIZE));
// if realloc fails the old data is still valid
- if( !mData )
+ if(!mData)
{
// TODO: Process message queue to free up some data?
free(oldData);
- DALI_ASSERT_DEBUG( false && "Realloc failed we're out of memory!" );
+ DALI_ASSERT_DEBUG(false && "Realloc failed we're out of memory!");
}
}
else
{
- mData = reinterpret_cast<WordType*>( malloc( newCapacity * WORD_SIZE ) );
+ mData = reinterpret_cast<WordType*>(malloc(newCapacity * WORD_SIZE));
}
- DALI_ASSERT_ALWAYS( nullptr != mData );
+ DALI_ASSERT_ALWAYS(nullptr != mData);
mCapacity = newCapacity;
mNextSlot = mData + mSize;
: mCurrent(current),
mMessageSize(0)
{
- if( nullptr != mCurrent )
+ if(nullptr != mCurrent)
{
// The first word is the size of the following object
mMessageSize = *mCurrent++;
#define DALI_INTERNAL_MESSAGE_BUFFER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* Utility class to reserve a buffer for storing messages.
*/
* @param[in] The smallest capacity which the buffer will allocate, with respect to the size of type "char".
* @note The buffer will not allocate memory until the first call to ReserveMessageSlot().
*/
- MessageBuffer( std::size_t initialCapacity );
+ MessageBuffer(std::size_t initialCapacity);
/**
* Non-virtual destructor; not suitable as a base class
* @param[in] size The message size with respect to the size of type "char".
* @return A pointer to the address allocated for the message, aligned to a word boundary
*/
- uint32_t* ReserveMessageSlot( std::size_t size );
+ uint32_t* ReserveMessageSlot(std::size_t size);
/**
* Query the capacity of the message buffer.
class Iterator
{
public:
-
// Constructor
Iterator(WordType* current);
// Inlined for performance
WordType* Get()
{
- return ( 0 != mMessageSize ) ? mCurrent : nullptr;
+ return (0 != mMessageSize) ? mCurrent : nullptr;
}
// Inlined for performance
Iterator(const Iterator& copy);
private:
-
// Undefined
Iterator& operator=(const Iterator& rhs);
private:
-
- WordType* mCurrent;
+ WordType* mCurrent;
std::size_t mMessageSize;
};
void Reset();
private:
-
// Undefined
MessageBuffer(const MessageBuffer&);
* @pre The newCapacity is greater than mCapacity.
* @param[in] The newCapacity
*/
- void IncreaseCapacity( std::size_t newCapacity );
+ void IncreaseCapacity(std::size_t newCapacity);
private:
-
std::size_t mInitialCapacity; ///< The capacity to allocate during first call to ReserveMessageSlot
WordType* mData; ///< The data allocated for the message buffer
#define DALI_INTERNAL_MESSAGE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* An abstract base class for messages queued across threads.
* Messages are only allowed to contain value objects, either copies of the parameters or pointers
class MessageBase
{
public:
-
/**
* Construct the message base.
*/
* Called to process the message.
* @param [in] bufferIndex The current update/render buffer index (depending on which thread processes the message).
*/
- virtual void Process( BufferIndex bufferIndex ) = 0;
+ virtual void Process(BufferIndex bufferIndex) = 0;
private:
};
* This allows nodes etc. to be modified in a thread-safe manner, when the update occurs in a separate thread.
* The object lifetime must controlled i.e. not destroyed before the message is processed.
*/
-template< typename T >
+template<typename T>
class Message : public MessageBase
{
public:
- using MemberFunction = void ( T::* )();
+ using MemberFunction = void (T::*)();
/**
* Create a message.
* @param[in] obj The object to be updated in a separate thread.
* @param[in] member The member function of the object.
*/
- Message( const T* obj, MemberFunction member )
+ Message(const T* obj, MemberFunction member)
: MessageBase(),
- object( const_cast< T* >( obj ) ),
- memberFunction( member )
+ object(const_cast<T*>(obj)),
+ memberFunction(member)
{
- DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
+ DALI_ASSERT_DEBUG(object && "nullptr passed into message as object");
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex /*bufferIndex*/ ) override
+ void Process(BufferIndex /*bufferIndex*/) override
{
(object->*memberFunction)();
}
private:
-
- T* object;
+ T* object;
MemberFunction memberFunction;
-
};
/**
* Template parameters need to match the MemberFunction!
* The message will contain copy of the value (in case of & or const&)
*/
-template< typename T, typename P >
+template<typename T, typename P>
class MessageValue1 : public MessageBase
{
public:
- using MemberFunction = void ( T::* )( typename ParameterType<P>::PassingType );
+ using MemberFunction = void (T::*)(typename ParameterType<P>::PassingType);
/**
* Create a message.
* @param[in] member The member function of the object.
* @param[in] p1 The first value-type parameter to pass to the member function.
*/
- MessageValue1( const T* obj,
- MemberFunction member,
- typename ParameterType< P >::PassingType p1 )
+ MessageValue1(const T* obj,
+ MemberFunction member,
+ typename ParameterType<P>::PassingType p1)
: MessageBase(),
- object( const_cast< T* >( obj ) ),
- memberFunction( member ),
- param1( p1 )
+ object(const_cast<T*>(obj)),
+ memberFunction(member),
+ param1(p1)
{
- DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
+ DALI_ASSERT_DEBUG(object && "nullptr passed into message as object");
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex /*bufferIndex*/ ) override
+ void Process(BufferIndex /*bufferIndex*/) override
{
- (object->*memberFunction)( param1 );
+ (object->*memberFunction)(param1);
}
private:
-
- T* object;
- MemberFunction memberFunction;
- typename ParameterType< P >::HolderType param1;
-
+ T* object;
+ MemberFunction memberFunction;
+ typename ParameterType<P>::HolderType param1;
};
/**
* The message will contain copy of the value (in case of & or const&)
*/
-template< typename T, typename P1, typename P2 >
+template<typename T, typename P1, typename P2>
class MessageValue2 : public MessageBase
{
public:
- using MemberFunction = void ( T::* )( typename ParameterType<P1>::PassingType, typename ParameterType<P2>::PassingType );
+ using MemberFunction = void (T::*)(typename ParameterType<P1>::PassingType, typename ParameterType<P2>::PassingType);
/**
* Create a message.
* @param[in] p1 The first parameter to pass to the member function.
* @param[in] p2 The second parameter to pass to the member function.
*/
- MessageValue2( const T* obj,
- MemberFunction member,
- typename ParameterType< P1 >::PassingType p1,
- typename ParameterType< P2 >::PassingType p2 )
+ MessageValue2(const T* obj,
+ MemberFunction member,
+ typename ParameterType<P1>::PassingType p1,
+ typename ParameterType<P2>::PassingType p2)
: MessageBase(),
- object( const_cast< T* >( obj ) ),
- memberFunction( member ),
- param1( p1 ),
- param2( p2 )
+ object(const_cast<T*>(obj)),
+ memberFunction(member),
+ param1(p1),
+ param2(p2)
{
- DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
+ DALI_ASSERT_DEBUG(object && "nullptr passed into message as object");
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex /*bufferIndex*/ ) override
+ void Process(BufferIndex /*bufferIndex*/) override
{
- (object->*memberFunction)( param1, param2 );
+ (object->*memberFunction)(param1, param2);
}
private:
-
- T* object;
- MemberFunction memberFunction;
- typename ParameterType< P1 >::HolderType param1;
- typename ParameterType< P2 >::HolderType param2;
-
+ T* object;
+ MemberFunction memberFunction;
+ typename ParameterType<P1>::HolderType param1;
+ typename ParameterType<P2>::HolderType param2;
};
/**
* Template parameters need to match the MemberFunction!
* The message will contain copy of the value (in case of & or const&)
*/
-template< typename T, typename P1, typename P2, typename P3 >
+template<typename T, typename P1, typename P2, typename P3>
class MessageValue3 : public MessageBase
{
public:
- using MemberFunction = void ( T::* )( typename ParameterType<P1>::PassingType, typename ParameterType<P2>::PassingType, typename ParameterType<P3>::PassingType );
+ using MemberFunction = void (T::*)(typename ParameterType<P1>::PassingType, typename ParameterType<P2>::PassingType, typename ParameterType<P3>::PassingType);
/**
* Create a message.
* @param[in] p2 The second parameter to pass to the member function.
* @param[in] p3 The third parameter to pass to the member function.
*/
- MessageValue3( const T* obj,
- MemberFunction member,
- typename ParameterType< P1 >::PassingType p1,
- typename ParameterType< P2 >::PassingType p2,
- typename ParameterType< P3 >::PassingType p3 )
+ MessageValue3(const T* obj,
+ MemberFunction member,
+ typename ParameterType<P1>::PassingType p1,
+ typename ParameterType<P2>::PassingType p2,
+ typename ParameterType<P3>::PassingType p3)
: MessageBase(),
- object( const_cast< T* >( obj ) ),
- memberFunction( member ),
- param1( p1 ),
- param2( p2 ),
- param3( p3 )
+ object(const_cast<T*>(obj)),
+ memberFunction(member),
+ param1(p1),
+ param2(p2),
+ param3(p3)
{
- DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
+ DALI_ASSERT_DEBUG(object && "nullptr passed into message as object");
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex /*bufferIndex*/ ) override
+ void Process(BufferIndex /*bufferIndex*/) override
{
- (object->*memberFunction)( param1, param2, param3 );
+ (object->*memberFunction)(param1, param2, param3);
}
private:
-
- T* object;
- MemberFunction memberFunction;
- typename ParameterType< P1 >::HolderType param1;
- typename ParameterType< P2 >::HolderType param2;
- typename ParameterType< P3 >::HolderType param3;
-
+ T* object;
+ MemberFunction memberFunction;
+ typename ParameterType<P1>::HolderType param1;
+ typename ParameterType<P2>::HolderType param2;
+ typename ParameterType<P3>::HolderType param3;
};
/**
* Template parameters need to match the MemberFunction!
* The message will contain copy of the value (in case of & or const&)
*/
-template< typename T, typename P1, typename P2, typename P3, typename P4 >
+template<typename T, typename P1, typename P2, typename P3, typename P4>
class MessageValue4 : public MessageBase
{
public:
- using MemberFunction = void ( T::* )( typename ParameterType<P1>::PassingType, typename ParameterType<P2>::PassingType, typename ParameterType<P3>::PassingType, typename ParameterType<P4>::PassingType );
+ using MemberFunction = void (T::*)(typename ParameterType<P1>::PassingType, typename ParameterType<P2>::PassingType, typename ParameterType<P3>::PassingType, typename ParameterType<P4>::PassingType);
/**
* Create a message.
* @param[in] p3 The third parameter to pass to the member function.
* @param[in] p4 The fourth parameter to pass to the member function.
*/
- MessageValue4( const T* obj,
- MemberFunction member,
- typename ParameterType< P1 >::PassingType p1,
- typename ParameterType< P2 >::PassingType p2,
- typename ParameterType< P3 >::PassingType p3,
- typename ParameterType< P4 >::PassingType p4 )
+ MessageValue4(const T* obj,
+ MemberFunction member,
+ typename ParameterType<P1>::PassingType p1,
+ typename ParameterType<P2>::PassingType p2,
+ typename ParameterType<P3>::PassingType p3,
+ typename ParameterType<P4>::PassingType p4)
: MessageBase(),
- object( const_cast< T* >( obj ) ),
- memberFunction( member ),
- param1( p1 ),
- param2( p2 ),
- param3( p3 ),
- param4( p4 )
+ object(const_cast<T*>(obj)),
+ memberFunction(member),
+ param1(p1),
+ param2(p2),
+ param3(p3),
+ param4(p4)
{
- DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
+ DALI_ASSERT_DEBUG(object && "nullptr passed into message as object");
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex /*bufferIndex*/ ) override
+ void Process(BufferIndex /*bufferIndex*/) override
{
- (object->*memberFunction)( param1, param2, param3, param4 );
+ (object->*memberFunction)(param1, param2, param3, param4);
}
private:
-
- T* object;
- MemberFunction memberFunction;
- typename ParameterType< P1 >::HolderType param1;
- typename ParameterType< P2 >::HolderType param2;
- typename ParameterType< P3 >::HolderType param3;
- typename ParameterType< P4 >::HolderType param4;
-
+ T* object;
+ MemberFunction memberFunction;
+ typename ParameterType<P1>::HolderType param1;
+ typename ParameterType<P2>::HolderType param2;
+ typename ParameterType<P3>::HolderType param3;
+ typename ParameterType<P4>::HolderType param4;
};
/**
* Template parameters need to match the MemberFunction!
* The message will contain copy of the value (in case of & or const&)
*/
-template< typename T, typename P1, typename P2, typename P3, typename P4, typename P5 >
+template<typename T, typename P1, typename P2, typename P3, typename P4, typename P5>
class MessageValue5 : public MessageBase
{
public:
- using MemberFunction = void ( T::* )( typename ParameterType<P1>::PassingType, typename ParameterType<P2>::PassingType, typename ParameterType<P3>::PassingType, typename ParameterType<P4>::PassingType, typename ParameterType<P5>::PassingType );
+ using MemberFunction = void (T::*)(typename ParameterType<P1>::PassingType, typename ParameterType<P2>::PassingType, typename ParameterType<P3>::PassingType, typename ParameterType<P4>::PassingType, typename ParameterType<P5>::PassingType);
/**
* Create a message.
* @param[in] p4 The fourth parameter to pass to the member function.
* @param[in] p5 The fifth parameter to pass to the member function.
*/
- MessageValue5( const T* obj,
- MemberFunction member,
- typename ParameterType< P1 >::PassingType p1,
- typename ParameterType< P2 >::PassingType p2,
- typename ParameterType< P3 >::PassingType p3,
- typename ParameterType< P4 >::PassingType p4,
- typename ParameterType< P5 >::PassingType p5 )
+ MessageValue5(const T* obj,
+ MemberFunction member,
+ typename ParameterType<P1>::PassingType p1,
+ typename ParameterType<P2>::PassingType p2,
+ typename ParameterType<P3>::PassingType p3,
+ typename ParameterType<P4>::PassingType p4,
+ typename ParameterType<P5>::PassingType p5)
: MessageBase(),
- object( const_cast< T* >( obj ) ),
- memberFunction( member ),
- param1( p1 ),
- param2( p2 ),
- param3( p3 ),
- param4( p4 ),
- param5( p5 )
+ object(const_cast<T*>(obj)),
+ memberFunction(member),
+ param1(p1),
+ param2(p2),
+ param3(p3),
+ param4(p4),
+ param5(p5)
{
- DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
+ DALI_ASSERT_DEBUG(object && "nullptr passed into message as object");
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex /*bufferIndex*/ ) override
+ void Process(BufferIndex /*bufferIndex*/) override
{
- (object->*memberFunction)( param1, param2, param3, param4, param5 );
+ (object->*memberFunction)(param1, param2, param3, param4, param5);
}
private:
-
- T* object;
- MemberFunction memberFunction;
- typename ParameterType< P1 >::HolderType param1;
- typename ParameterType< P2 >::HolderType param2;
- typename ParameterType< P3 >::HolderType param3;
- typename ParameterType< P4 >::HolderType param4;
- typename ParameterType< P5 >::HolderType param5;
-
+ T* object;
+ MemberFunction memberFunction;
+ typename ParameterType<P1>::HolderType param1;
+ typename ParameterType<P2>::HolderType param2;
+ typename ParameterType<P3>::HolderType param3;
+ typename ParameterType<P4>::HolderType param4;
+ typename ParameterType<P5>::HolderType param5;
};
/**
* Template parameters need to match the MemberFunction!
* The message will contain copy of the value (in case of & or const&)
*/
-template< typename T, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6 >
+template<typename T, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
class MessageValue6 : public MessageBase
{
public:
- using MemberFunction = void ( T::* )( typename ParameterType<P1>::PassingType, typename ParameterType<P2>::PassingType, typename ParameterType<P3>::PassingType, typename ParameterType<P4>::PassingType, typename ParameterType<P5>::PassingType, typename ParameterType<P6>::PassingType );
+ using MemberFunction = void (T::*)(typename ParameterType<P1>::PassingType, typename ParameterType<P2>::PassingType, typename ParameterType<P3>::PassingType, typename ParameterType<P4>::PassingType, typename ParameterType<P5>::PassingType, typename ParameterType<P6>::PassingType);
/**
* Create a message.
* @param[in] p5 The fifth parameter to pass to the member function.
* @param[in] p6 The sixth parameter to pass to the member function.
*/
- MessageValue6( const T* obj,
- MemberFunction member,
- typename ParameterType< P1 >::PassingType p1,
- typename ParameterType< P2 >::PassingType p2,
- typename ParameterType< P3 >::PassingType p3,
- typename ParameterType< P4 >::PassingType p4,
- typename ParameterType< P5 >::PassingType p5,
- typename ParameterType< P6 >::PassingType p6 )
+ MessageValue6(const T* obj,
+ MemberFunction member,
+ typename ParameterType<P1>::PassingType p1,
+ typename ParameterType<P2>::PassingType p2,
+ typename ParameterType<P3>::PassingType p3,
+ typename ParameterType<P4>::PassingType p4,
+ typename ParameterType<P5>::PassingType p5,
+ typename ParameterType<P6>::PassingType p6)
: MessageBase(),
- object( const_cast< T* >( obj ) ),
- memberFunction( member ),
- param1( p1 ),
- param2( p2 ),
- param3( p3 ),
- param4( p4 ),
- param5( p5 ),
- param6( p6 )
+ object(const_cast<T*>(obj)),
+ memberFunction(member),
+ param1(p1),
+ param2(p2),
+ param3(p3),
+ param4(p4),
+ param5(p5),
+ param6(p6)
{
- DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
+ DALI_ASSERT_DEBUG(object && "nullptr passed into message as object");
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex /*bufferIndex*/ ) override
+ void Process(BufferIndex /*bufferIndex*/) override
{
- (object->*memberFunction)( param1, param2, param3, param4, param5, param6 );
+ (object->*memberFunction)(param1, param2, param3, param4, param5, param6);
}
private:
-
- T* object;
- MemberFunction memberFunction;
- typename ParameterType< P1 >::HolderType param1;
- typename ParameterType< P2 >::HolderType param2;
- typename ParameterType< P3 >::HolderType param3;
- typename ParameterType< P4 >::HolderType param4;
- typename ParameterType< P5 >::HolderType param5;
- typename ParameterType< P6 >::HolderType param6;
-
+ T* object;
+ MemberFunction memberFunction;
+ typename ParameterType<P1>::HolderType param1;
+ typename ParameterType<P2>::HolderType param2;
+ typename ParameterType<P3>::HolderType param3;
+ typename ParameterType<P4>::HolderType param4;
+ typename ParameterType<P5>::HolderType param5;
+ typename ParameterType<P6>::HolderType param6;
};
/**
* Templated message which calls a member function of an object.
* This overload passes just the buffer index to the method, no parameters.
*/
-template< typename T >
+template<typename T>
class MessageDoubleBuffered0 : public MessageBase
{
public:
- using MemberFunction = void ( T::* )( BufferIndex );
+ using MemberFunction = void (T::*)(BufferIndex);
/**
* Create a message.
* @param[in] obj The object.
* @param[in] member The member function of the object.
*/
- MessageDoubleBuffered0( const T* obj, MemberFunction member )
+ MessageDoubleBuffered0(const T* obj, MemberFunction member)
: MessageBase(),
- object( const_cast< T* >( obj ) ),
- memberFunction( member )
+ object(const_cast<T*>(obj)),
+ memberFunction(member)
{
- DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
+ DALI_ASSERT_DEBUG(object && "nullptr passed into message as object");
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex bufferIndex ) override
+ void Process(BufferIndex bufferIndex) override
{
- (object->*memberFunction)( bufferIndex );
+ (object->*memberFunction)(bufferIndex);
}
private:
-
- T* object;
+ T* object;
MemberFunction memberFunction;
-
};
-
/**
* Templated message which calls a member function of an object.
* This overload passes a value-type to set a double-buffered property.
* Template parameters need to match the MemberFunction!
* The message will contain copy of the value (in case of & or const&)
*/
-template< typename T, typename P >
+template<typename T, typename P>
class MessageDoubleBuffered1 : public MessageBase
{
public:
- using MemberFunction = void ( T::* )( BufferIndex, typename ParameterType<P>::PassingType );
+ using MemberFunction = void (T::*)(BufferIndex, typename ParameterType<P>::PassingType);
/**
* Create a message.
* @param[in] member The member function of the object.
* @param[in] p The second parameter to pass.
*/
- MessageDoubleBuffered1( const T* obj,
- MemberFunction member,
- typename ParameterType< P >::PassingType p )
+ MessageDoubleBuffered1(const T* obj,
+ MemberFunction member,
+ typename ParameterType<P>::PassingType p)
: MessageBase(),
- object( const_cast< T* >( obj ) ),
- memberFunction( member ),
- param( p )
+ object(const_cast<T*>(obj)),
+ memberFunction(member),
+ param(p)
{
- DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
+ DALI_ASSERT_DEBUG(object && "nullptr passed into message as object");
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex bufferIndex ) override
+ void Process(BufferIndex bufferIndex) override
{
- (object->*memberFunction)( bufferIndex, param );
+ (object->*memberFunction)(bufferIndex, param);
}
private:
-
- T* object;
- MemberFunction memberFunction;
- typename ParameterType< P >::HolderType param;
-
+ T* object;
+ MemberFunction memberFunction;
+ typename ParameterType<P>::HolderType param;
};
/**
* Template parameters need to match the MemberFunction!
* The message will contain copy of the value (in case of & or const&)
*/
-template< typename T, typename P2, typename P3 >
+template<typename T, typename P2, typename P3>
class MessageDoubleBuffered2 : public MessageBase
{
public:
- using MemberFunction = void ( T::* )( BufferIndex, typename ParameterType<P2>::PassingType, typename ParameterType<P3>::PassingType );
+ using MemberFunction = void (T::*)(BufferIndex, typename ParameterType<P2>::PassingType, typename ParameterType<P3>::PassingType);
/**
* Create a message.
* @param[in] p2 The second parameter to pass to the function.
* @param[in] p3 The third parameter to pass to the function.
*/
- MessageDoubleBuffered2( const T* obj,
- MemberFunction member,
- typename ParameterType< P2 >::PassingType p2,
- typename ParameterType< P3 >::PassingType p3 )
+ MessageDoubleBuffered2(const T* obj,
+ MemberFunction member,
+ typename ParameterType<P2>::PassingType p2,
+ typename ParameterType<P3>::PassingType p3)
: MessageBase(),
- object( const_cast< T* >( obj ) ),
- memberFunction( member ),
- param2( p2 ),
- param3( p3 )
+ object(const_cast<T*>(obj)),
+ memberFunction(member),
+ param2(p2),
+ param3(p3)
{
- DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
+ DALI_ASSERT_DEBUG(object && "nullptr passed into message as object");
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex bufferIndex ) override
+ void Process(BufferIndex bufferIndex) override
{
- (object->*memberFunction)( bufferIndex, param2, param3 );
+ (object->*memberFunction)(bufferIndex, param2, param3);
}
private:
-
- T* object;
- MemberFunction memberFunction;
- typename ParameterType< P2 >::HolderType param2;
- typename ParameterType< P3 >::HolderType param3;
-
+ T* object;
+ MemberFunction memberFunction;
+ typename ParameterType<P2>::HolderType param2;
+ typename ParameterType<P3>::HolderType param3;
};
-
/**
* Templated message which calls a member function of an object.
* This overload passes three value-types to set double-buffered properties.
* Template parameters need to match the MemberFunction!
* The message will contain copy of the value (in case of & or const&)
*/
-template< typename T, typename P2, typename P3, typename P4 >
+template<typename T, typename P2, typename P3, typename P4>
class MessageDoubleBuffered3 : public MessageBase
{
public:
- using MemberFunction = void ( T::* )( BufferIndex, typename ParameterType<P2>::PassingType, typename ParameterType<P3>::PassingType, typename ParameterType<P4>::PassingType );
+ using MemberFunction = void (T::*)(BufferIndex, typename ParameterType<P2>::PassingType, typename ParameterType<P3>::PassingType, typename ParameterType<P4>::PassingType);
/**
* Create a message.
* @param[in] p3 The third parameter to pass.
* @param[in] p4 The forth parameter to pass.
*/
- MessageDoubleBuffered3( const T* obj,
- MemberFunction member,
- typename ParameterType< P2 >::PassingType p2,
- typename ParameterType< P3 >::PassingType p3,
- typename ParameterType< P4 >::PassingType p4 )
+ MessageDoubleBuffered3(const T* obj,
+ MemberFunction member,
+ typename ParameterType<P2>::PassingType p2,
+ typename ParameterType<P3>::PassingType p3,
+ typename ParameterType<P4>::PassingType p4)
: MessageBase(),
- object( const_cast< T* >( obj ) ),
- memberFunction( member ),
- param2( p2 ),
- param3( p3 ),
- param4( p4 )
+ object(const_cast<T*>(obj)),
+ memberFunction(member),
+ param2(p2),
+ param3(p3),
+ param4(p4)
{
- DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
+ DALI_ASSERT_DEBUG(object && "nullptr passed into message as object");
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex bufferIndex ) override
+ void Process(BufferIndex bufferIndex) override
{
- (object->*memberFunction)( bufferIndex, param2, param3, param4 );
+ (object->*memberFunction)(bufferIndex, param2, param3, param4);
}
private:
-
- T* object;
- MemberFunction memberFunction;
- typename ParameterType< P2 >::HolderType param2;
- typename ParameterType< P3 >::HolderType param3;
- typename ParameterType< P4 >::HolderType param4;
-
+ T* object;
+ MemberFunction memberFunction;
+ typename ParameterType<P2>::HolderType param2;
+ typename ParameterType<P3>::HolderType param3;
+ typename ParameterType<P4>::HolderType param4;
};
/**
* Template parameters need to match the MemberFunction!
* The message will contain copy of the value (in case of & or const&)
*/
-template< typename T, typename P2, typename P3, typename P4, typename P5 >
+template<typename T, typename P2, typename P3, typename P4, typename P5>
class MessageDoubleBuffered4 : public MessageBase
{
public:
- using MemberFunction = void ( T::* )( BufferIndex, typename ParameterType<P2>::PassingType, typename ParameterType<P3>::PassingType, typename ParameterType<P4>::PassingType, typename ParameterType<P5>::PassingType );
+ using MemberFunction = void (T::*)(BufferIndex, typename ParameterType<P2>::PassingType, typename ParameterType<P3>::PassingType, typename ParameterType<P4>::PassingType, typename ParameterType<P5>::PassingType);
/**
* Create a message.
* @param[in] p4 The forth parameter to pass.
* @param[in] p5 The fifth parameter to pass.
*/
- MessageDoubleBuffered4( const T* obj,
- MemberFunction member,
- typename ParameterType< P2 >::PassingType p2,
- typename ParameterType< P3 >::PassingType p3,
- typename ParameterType< P4 >::PassingType p4,
- typename ParameterType< P5 >::PassingType p5 )
+ MessageDoubleBuffered4(const T* obj,
+ MemberFunction member,
+ typename ParameterType<P2>::PassingType p2,
+ typename ParameterType<P3>::PassingType p3,
+ typename ParameterType<P4>::PassingType p4,
+ typename ParameterType<P5>::PassingType p5)
: MessageBase(),
- object( const_cast< T* >( obj ) ),
- memberFunction( member ),
- param2( p2 ),
- param3( p3 ),
- param4( p4 ),
- param5( p5 )
+ object(const_cast<T*>(obj)),
+ memberFunction(member),
+ param2(p2),
+ param3(p3),
+ param4(p4),
+ param5(p5)
{
- DALI_ASSERT_DEBUG( object && "nullptr passed into message as object" );
+ DALI_ASSERT_DEBUG(object && "nullptr passed into message as object");
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex bufferIndex ) override
+ void Process(BufferIndex bufferIndex) override
{
- (object->*memberFunction)( bufferIndex, param2, param3, param4, param5 );
+ (object->*memberFunction)(bufferIndex, param2, param3, param4, param5);
}
private:
-
- T* object;
- MemberFunction memberFunction;
- typename ParameterType< P2 >::HolderType param2;
- typename ParameterType< P3 >::HolderType param3;
- typename ParameterType< P4 >::HolderType param4;
- typename ParameterType< P5 >::HolderType param5;
-
+ T* object;
+ MemberFunction memberFunction;
+ typename ParameterType<P2>::HolderType param2;
+ typename ParameterType<P3>::HolderType param3;
+ typename ParameterType<P4>::HolderType param4;
+ typename ParameterType<P5>::HolderType param5;
};
} // namespace Internal
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#ifdef LOCK_BACKTRACE_ENABLED
// EXTERNAL INCLUDES
-#include <cstdlib>
#include <execinfo.h>
+#include <cstdlib>
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/common/dali-common.h>
#endif // LOCK_BACKTRACE_ENABLED
namespace Dali
{
#ifdef LOCK_BACKTRACE_ENABLED
-extern std::string Demangle( const char* symbol );
+extern std::string Demangle(const char* symbol);
#endif // LOCK_BACKTRACE_ENABLED
namespace Internal
{
-
namespace MutexTrace
{
-
namespace
{
#ifdef LOCK_BACKTRACE_ENABLED
// Constants
const unsigned int MAX_NUM_STACK_FRAMES = 4;
-const unsigned int MAX_LOCK_SUPPORT = 5;
+const unsigned int MAX_LOCK_SUPPORT = 5;
struct BackTraceInfo
{
- void * frameArray[ MAX_NUM_STACK_FRAMES ]; ///< Stores the frame array where the lock occurred
- int size; ///< Number of frames in the frame array (can be less than MAX_NUM_STACK_FRAMES)
+ void* frameArray[MAX_NUM_STACK_FRAMES]; ///< Stores the frame array where the lock occurred
+ int size; ///< Number of frames in the frame array (can be less than MAX_NUM_STACK_FRAMES)
};
-thread_local BackTraceInfo gBackTraceInfo[ MAX_LOCK_SUPPORT ]; ///< Thread local storage for the backtrace of the locks
+thread_local BackTraceInfo gBackTraceInfo[MAX_LOCK_SUPPORT]; ///< Thread local storage for the backtrace of the locks
#endif // LOCK_BACKTRACE_ENABLED
#ifdef LOCK_BACKTRACE_ENABLED
- if( gThreadLockCount <= MAX_LOCK_SUPPORT )
+ if(gThreadLockCount <= MAX_LOCK_SUPPORT)
{
// Store the frame array for this lock
- int backTraceIndex = gThreadLockCount - 1;
- gBackTraceInfo[ backTraceIndex ].size = backtrace( gBackTraceInfo[ backTraceIndex ].frameArray, MAX_NUM_STACK_FRAMES );
+ int backTraceIndex = gThreadLockCount - 1;
+ gBackTraceInfo[backTraceIndex].size = backtrace(gBackTraceInfo[backTraceIndex].frameArray, MAX_NUM_STACK_FRAMES);
}
else
{
- DALI_LOG_ERROR( "Reached Maximum lock backtrace support. Previous Locks:\n" );
+ DALI_LOG_ERROR("Reached Maximum lock backtrace support. Previous Locks:\n");
}
// If we've got more than one lock, then show a warning with a backtrace for all locks that we currently hold
- if( gThreadLockCount > 1 )
+ if(gThreadLockCount > 1)
{
- for( unsigned int i = 0; ( i < gThreadLockCount ) && ( i < MAX_LOCK_SUPPORT ); ++i )
+ for(unsigned int i = 0; (i < gThreadLockCount) && (i < MAX_LOCK_SUPPORT); ++i)
{
- DALI_LOG_WARNING( "[Lock %d]\n", i+1 );
- char** symbols = backtrace_symbols( gBackTraceInfo[ i ].frameArray, gBackTraceInfo[ i ].size );
- for( int j = 1; j < gBackTraceInfo[ i ].size; ++j )
+ DALI_LOG_WARNING("[Lock %d]\n", i + 1);
+ char** symbols = backtrace_symbols(gBackTraceInfo[i].frameArray, gBackTraceInfo[i].size);
+ for(int j = 1; j < gBackTraceInfo[i].size; ++j)
{
- std::string demangled_symbol = Demangle( symbols[ j ] );
- DALI_LOG_WARNING( " [%02d] %s\n", j, demangled_symbol.c_str() );
+ std::string demangled_symbol = Demangle(symbols[j]);
+ DALI_LOG_WARNING(" [%02d] %s\n", j, demangled_symbol.c_str());
}
free(symbols);
}
- DALI_LOG_WARNING( "====================================\n" );
+ DALI_LOG_WARNING("====================================\n");
}
#else
#define DALI_INTERNAL_MUTEX_TRACE_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* @brief Namespace to ensure mutex locking is done correctly.
*
*/
namespace MutexTrace
{
-
/**
* @brief Increments a thread-local storage counter.
*
#define DALI_INTERNAL_OWNER_POINTER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
-template< typename T >
+template<typename T>
class OwnerPointer
{
public:
-
/**
* Default constructor. Creates an OwnerPointer that does not own any object.
* @note This does not protect against two different OwnerPointers pointing to the same object.
* could lead to a crash.
*/
OwnerPointer()
- : mObject( nullptr )
+ : mObject(nullptr)
{
}
* Constructor. Creates an OwnerPointer that owns the object.
* @param[in] object A pointer to a heap allocated object.
*/
- OwnerPointer( T* object )
- : mObject( object )
+ OwnerPointer(T* object)
+ : mObject(object)
{
}
* Copy constructor. Passes the ownership of a pointer to another.
* @param[in] other The pointer that gives away the ownership.
*/
- OwnerPointer( const OwnerPointer& other )
- : OwnerPointer( static_cast< OwnerPointer&& >( const_cast<OwnerPointer&>( other ) ) ) // Remove constness & cast to rvalue to use the move constructor
+ OwnerPointer(const OwnerPointer& other)
+ : OwnerPointer(static_cast<OwnerPointer&&>(const_cast<OwnerPointer&>(other))) // Remove constness & cast to rvalue to use the move constructor
{
// other needs to be const for compiler to pick up this as copy constructor;
// though we are using this as move as there can only be one owner
* Move constructor. Passes the ownership of a pointer to another.
* @param[in] other The pointer that gives away the ownership.
*/
- OwnerPointer( OwnerPointer&& other )
- : mObject( nullptr )
+ OwnerPointer(OwnerPointer&& other)
+ : mObject(nullptr)
{
- Swap( other );
+ Swap(other);
}
/**
* Assignment operator. Passes the ownership of a pointer to another.
* @param[in] other The pointer that gives away the ownership.
*/
- OwnerPointer& operator=( OwnerPointer& other )
+ OwnerPointer& operator=(OwnerPointer& other)
{
- if( this != &other ) // no self-assignment
+ if(this != &other) // no self-assignment
{
delete mObject;
- mObject = other.mObject;
+ mObject = other.mObject;
other.mObject = nullptr;
}
* Move assignment operator. Passes the ownership of a pointer to another.
* @param[in] other The pointer that gives away the ownership.
*/
- OwnerPointer& operator=( OwnerPointer&& other )
+ OwnerPointer& operator=(OwnerPointer&& other)
{
// Reuse operator=
- return operator=( other );
+ return operator=(other);
}
/**
* If it owns an object already, it will be deleted.
* @param[in] pointer A pointer to a heap allocated object.
*/
- OwnerPointer& operator=( T* pointer )
+ OwnerPointer& operator=(T* pointer)
{
- if( mObject != pointer )
+ if(mObject != pointer)
{
Reset();
mObject = pointer;
*/
T& operator*()
{
- DALI_ASSERT_DEBUG( mObject );
+ DALI_ASSERT_DEBUG(mObject);
return *mObject;
}
*/
T& operator*() const
{
- DALI_ASSERT_DEBUG( mObject );
+ DALI_ASSERT_DEBUG(mObject);
// Pointer semantics: A const pointer does not mean const data.
- return const_cast< T& >( *mObject );
+ return const_cast<T&>(*mObject);
}
/**
T* operator->() const
{
// Pointer semantics: A const pointer does not mean const data.
- return const_cast< T* >( mObject );
+ return const_cast<T*>(mObject);
}
/**
* Compare with a raw pointer.
* @return true if the raw pointer matches the one owned by this object.
*/
- bool operator==( const T* pointer )
+ bool operator==(const T* pointer)
{
- return ( mObject == pointer );
+ return (mObject == pointer);
}
/**
*/
T* Release()
{
- T* tmp = mObject;
+ T* tmp = mObject;
mObject = nullptr;
return tmp;
}
* Swap owned objects
* @param[in] other The pointer to swap the owned objects with.
*/
- void Swap( OwnerPointer& other )
+ void Swap(OwnerPointer& other)
{
- if( this != &other )
+ if(this != &other)
{
- T* tmp = mObject;
- mObject = other.mObject;
+ T* tmp = mObject;
+ mObject = other.mObject;
other.mObject = tmp;
}
}
/**
* Pointer-to-member type. Objects can be implicitly converted to this for validity checks.
*/
- using BooleanType = void ( OwnerPointer<T>::* )() const;
+ using BooleanType = void (OwnerPointer<T>::*)() const;
/**
* Converts an object handle to a BooleanType.
*/
operator BooleanType() const
{
- return ( mObject != nullptr ) ? &OwnerPointer::ThisIsSaferThanReturningVoidStar : nullptr;
+ return (mObject != nullptr) ? &OwnerPointer::ThisIsSaferThanReturningVoidStar : nullptr;
}
private:
-
/**
* Used by the safe bool idiom.
*/
- void ThisIsSaferThanReturningVoidStar() const {}
+ void ThisIsSaferThanReturningVoidStar() const
+ {
+ }
// data
T* mObject; ///< Raw pointer to the object
#define DALI_INTERNAL_SHADER_DATA_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <string>
// INTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/rendering/shader.h> // ShaderHints
namespace Dali
{
-
namespace Internal
{
-
class ShaderData;
using ShaderDataPtr = IntrusivePtr<ShaderData>;
class ShaderData : public Dali::RefObject
{
public:
-
/**
* Constructor
* @param[in] vertexSource Source code for vertex program
* @param[in] fragmentSource Source code for fragment program
*/
ShaderData(std::string vertexSource, std::string fragmentSource, const Dali::Shader::Hint::Value hints)
- : mShaderHash( -1 ),
+ : mShaderHash(-1),
mVertexShader(std::move(vertexSource)),
mFragmentShader(std::move(fragmentSource)),
mHints(hints)
- { }
+ {
+ }
protected:
/**
}
public: // API
-
/**
* Set hash value which is created with vertex and fragment shader code
* @param [in] shaderHash hash key created with vertex and fragment shader code
*/
void SetHashValue(size_t shaderHash)
{
- DALI_ASSERT_DEBUG( shaderHash != size_t(-1) );
+ DALI_ASSERT_DEBUG(shaderHash != size_t(-1));
mShaderHash = shaderHash;
}
*/
size_t GetHashValue() const
{
- DALI_ASSERT_DEBUG( mShaderHash != size_t(-1) );
+ DALI_ASSERT_DEBUG(mShaderHash != size_t(-1));
return mShaderHash;
}
* Allocate a buffer for the compiled binary bytecode
* @param[in] size The size of the buffer in bytes
*/
- void AllocateBuffer( std::size_t size )
+ void AllocateBuffer(std::size_t size)
{
- mBuffer.Resize( size );
+ mBuffer.Resize(size);
}
/**
*/
uint8_t* GetBufferData()
{
- DALI_ASSERT_DEBUG( mBuffer.Size() > 0 );
+ DALI_ASSERT_DEBUG(mBuffer.Size() > 0);
return &mBuffer[0];
}
return mBuffer;
}
-private: // Not implemented
-
- ShaderData(const ShaderData& other); ///< no copying of this object
- ShaderData& operator= (const ShaderData& rhs); ///< no copying of this object
-
-private: // Data
+private: // Not implemented
+ ShaderData(const ShaderData& other); ///< no copying of this object
+ ShaderData& operator=(const ShaderData& rhs); ///< no copying of this object
+private: // Data
std::size_t mShaderHash; ///< hash key created with vertex and fragment shader code
std::string mVertexShader; ///< source code for vertex program
std::string mFragmentShader; ///< source code for fragment program
Dali::Shader::Hint::Value mHints; ///< take a hint
Dali::Vector<uint8_t> mBuffer; ///< buffer containing compiled binary bytecode
-
};
-} // namespace Integration
+} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_SHADER_DISPATCHER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
// EXTERNAL INCLUDES
-
namespace Dali
{
-
namespace Internal
{
class ShaderData;
class ShaderSaver
{
public:
-
/**
* A function saving the binary from a ShaderDataPtr or passing it on to where it can be saved.
* @param[in] shaderData A smart pointer to a ShaderData for which the program binary should be saved.
*/
- virtual void SaveBinary( Internal::ShaderDataPtr shaderData ) = 0;
+ virtual void SaveBinary(Internal::ShaderDataPtr shaderData) = 0;
protected:
/**
#define DALI_INTERNAL_TYPE_ABSTRACTION_ENUMS_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/rendering/renderer.h>
#include <dali/devel-api/common/stage-devel.h>
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/internal/common/type-abstraction.h>
+#include <dali/public-api/rendering/renderer.h>
namespace Dali
{
-
namespace Internal
{
-
-template <> struct ParameterType< Dali::FaceCullingMode::Type > : public BasicType< Dali::FaceCullingMode::Type > {};
-template <> struct ParameterType< Dali::BlendMode::Type > : public BasicType< Dali::BlendMode::Type > {};
-template <> struct ParameterType< Dali::DepthWriteMode::Type > : public BasicType< Dali::DepthWriteMode::Type > {};
-template <> struct ParameterType< Dali::DepthTestMode::Type > : public BasicType< Dali::DepthTestMode::Type > {};
-template <> struct ParameterType< Dali::DepthFunction::Type > : public BasicType< Dali::DepthFunction::Type > {};
-template <> struct ParameterType< Dali::RenderMode::Type > : public BasicType< Dali::RenderMode::Type > {};
-template <> struct ParameterType< Dali::StencilFunction::Type > : public BasicType< Dali::StencilFunction::Type > {};
-template <> struct ParameterType< Dali::StencilOperation::Type > : public BasicType< Dali::StencilOperation::Type > {};
-template <> struct ParameterType< Dali::DevelStage::Rendering > : public BasicType< Dali::DevelStage::Rendering > {};
-template <> struct ParameterType< Dali::DevelRenderer::Rendering::Type > : public BasicType< Dali::DevelRenderer::Rendering::Type > {};
+template<>
+struct ParameterType<Dali::FaceCullingMode::Type> : public BasicType<Dali::FaceCullingMode::Type>
+{
+};
+template<>
+struct ParameterType<Dali::BlendMode::Type> : public BasicType<Dali::BlendMode::Type>
+{
+};
+template<>
+struct ParameterType<Dali::DepthWriteMode::Type> : public BasicType<Dali::DepthWriteMode::Type>
+{
+};
+template<>
+struct ParameterType<Dali::DepthTestMode::Type> : public BasicType<Dali::DepthTestMode::Type>
+{
+};
+template<>
+struct ParameterType<Dali::DepthFunction::Type> : public BasicType<Dali::DepthFunction::Type>
+{
+};
+template<>
+struct ParameterType<Dali::RenderMode::Type> : public BasicType<Dali::RenderMode::Type>
+{
+};
+template<>
+struct ParameterType<Dali::StencilFunction::Type> : public BasicType<Dali::StencilFunction::Type>
+{
+};
+template<>
+struct ParameterType<Dali::StencilOperation::Type> : public BasicType<Dali::StencilOperation::Type>
+{
+};
+template<>
+struct ParameterType<Dali::DevelStage::Rendering> : public BasicType<Dali::DevelStage::Rendering>
+{
+};
+template<>
+struct ParameterType<Dali::DevelRenderer::Rendering::Type> : public BasicType<Dali::DevelRenderer::Rendering::Type>
+{
+};
} //namespace Internal
#define DALI_INTERNAL_TYPE_ABSTRACTION_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <climits>
// INTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
#include <dali/internal/common/owner-pointer.h>
+#include <dali/public-api/object/ref-object.h>
namespace Dali
{
-
namespace Internal
{
-
/**
* Template helpers to strip of const reference and reference to prevent anyone
* from passing references as message parameters
*/
// For basic types, they are always pass by copy
-template <typename Type>
+template<typename Type>
struct BasicType
{
using HolderType = Type;
// For complex types that are copied into the message,
// they are passed as const reference when they don't need to be copied
-template <typename Type>
+template<typename Type>
struct ComplexType
{
using HolderType = Type;
// For complex types that are owned by the message,
// They are passed and hold in an OwnerPointer
-template <typename Type>
+template<typename Type>
struct OwnedType
{
using HolderType = OwnerPointer<Type>;
using PassingType = OwnerPointer<Type>&;
};
-
// Default for Vector3 and other structures
-template <class T> struct ParameterType : public ComplexType< T > {};
+template<class T>
+struct ParameterType : public ComplexType<T>
+{
+};
// For message owned parameters
-template <class T> struct ParameterType< OwnerPointer<T> > : public OwnedType< T > {};
+template<class T>
+struct ParameterType<OwnerPointer<T> > : public OwnedType<T>
+{
+};
// Basic types types
-template <typename T> struct ParameterType< T* > : public BasicType< T* > {};
-template <typename T> struct ParameterType< const T* > : public BasicType< const T* > {};
-template <> struct ParameterType< int > : public BasicType< int > {};
-template <> struct ParameterType< unsigned int > : public BasicType< unsigned int > {};
-template <> struct ParameterType< float > : public BasicType< float > {};
-template <> struct ParameterType< bool > : public BasicType< bool > {};
-template <> struct ParameterType< short int > : public BasicType< short int > {};
+template<typename T>
+struct ParameterType<T*> : public BasicType<T*>
+{
+};
+template<typename T>
+struct ParameterType<const T*> : public BasicType<const T*>
+{
+};
+template<>
+struct ParameterType<int> : public BasicType<int>
+{
+};
+template<>
+struct ParameterType<unsigned int> : public BasicType<unsigned int>
+{
+};
+template<>
+struct ParameterType<float> : public BasicType<float>
+{
+};
+template<>
+struct ParameterType<bool> : public BasicType<bool>
+{
+};
+template<>
+struct ParameterType<short int> : public BasicType<short int>
+{
+};
#if INT_MAX != LONG_MAX
-template <> struct ParameterType< long > : public BasicType< long > {};
-template <> struct ParameterType< unsigned long > : public BasicType< unsigned long > {};
+template<>
+struct ParameterType<long> : public BasicType<long>
+{
+};
+template<>
+struct ParameterType<unsigned long> : public BasicType<unsigned long>
+{
+};
#endif
//TODO: Passing intrusive pointers through messages is potentially dangerous,
// this should be checked
-template <typename T> struct ParameterType< IntrusivePtr<T> >
-: public BasicType< IntrusivePtr<T> > {};
+template<typename T>
+struct ParameterType<IntrusivePtr<T> >
+: public BasicType<IntrusivePtr<T> >
+{
+};
// poorly constructed types, types should not be defined as references
// this will trigger a compilation error.
-template <class U> struct ParameterType< U& > {};
-template <class U> struct ParameterType< const U& > {};
+template<class U>
+struct ParameterType<U&>
+{
+};
+template<class U>
+struct ParameterType<const U&>
+{
+};
} //namespace Internal
return node;
}
-
-void Actor::SetName( std::string_view name )
+void Actor::SetName(std::string_view name)
{
mName = ConstString(name);
// ATTENTION: string for debug purposes is not thread safe.
- DALI_LOG_SET_OBJECT_STRING( const_cast< SceneGraph::Node* >( &GetNode() ), mName.GetCString() );
+ DALI_LOG_SET_OBJECT_STRING(const_cast<SceneGraph::Node*>(&GetNode()), mName.GetCString());
}
uint32_t Actor::GetId() const
// INTERNAL INCLUDES
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/devel-api/rendering/renderer-devel.h>
+#include <dali/internal/common/const-string.h>
#include <dali/internal/common/internal-constants.h>
#include <dali/internal/common/memory-pool-object-allocator.h>
#include <dali/internal/event/actors/actor-declarations.h>
#include <dali/public-api/math/viewport.h>
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/size-negotiation/relayout-container.h>
-#include <dali/internal/common/const-string.h>
namespace Dali
{
* Set the name of the actor.
* @param[in] name The new name.
*/
- void SetName( std::string_view name );
+ void SetName(std::string_view name);
/**
* @copydoc Dali::Actor::GetId
/**
* @copydoc Dali::Internal::ActorParent::FindChildByName
*/
- ActorPtr FindChildByName( ConstString actorName ) override;
+ ActorPtr FindChildByName(ConstString actorName) override;
/**
* @copydoc Dali::Internal::ActorParent::FindChildById
#ifndef DALI_INTERNAL_ACTOR_PARENT_IMPL_H
#define DALI_INTERNAL_ACTOR_PARENT_IMPL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use actor file except in compliance with the License.
// INTERNAL INCLUDES
#include <dali/devel-api/actors/actor-devel.h>
+#include <dali/internal/common/const-string.h>
#include <dali/internal/event/actors/actor-declarations.h>
#include <dali/internal/event/actors/actor-parent.h>
-#include <dali/internal/common/const-string.h>
-
// EXTERNAL INCLUDES
#include <string>
#ifndef DALI_INTERNAL_ACTOR_PARENT_H
#define DALI_INTERNAL_ACTOR_PARENT_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use actor file except in compliance with the License.
// INTERNAL INCLUDES
#include <dali/devel-api/actors/actor-devel.h>
-#include <dali/internal/event/actors/actor-declarations.h>
#include <dali/internal/common/const-string.h>
+#include <dali/internal/event/actors/actor-declarations.h>
namespace Dali
{
#ifndef DALI_INTERNAL_ACTOR_PROPERTY_HANDLER_H
#define DALI_INTERNAL_ACTOR_PROPERTY_HANDLER_H
-
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* Extracts out the property related methods from Actor
*/
/// @copydoc Actor::SetDefaultProperty
static void SetDefaultProperty(
- Internal::Actor& actor,
- Property::Index index,
- const Property::Value& property);
+ Internal::Actor& actor,
+ Property::Index index,
+ const Property::Value& property);
/// @copydoc Actor::SetSceneGraphProperty
static void SetSceneGraphProperty(
- Property::Index index,
- const PropertyMetadata& entry,
- const Property::Value& value,
- EventThreadServices& eventThreadServices,
- const SceneGraph::Node& node);
+ Property::Index index,
+ const PropertyMetadata& entry,
+ const Property::Value& value,
+ EventThreadServices& eventThreadServices,
+ const SceneGraph::Node& node);
/// @copydoc Actor::OnNotifyDefaultPropertyAnimation
static void OnNotifyDefaultPropertyAnimation(
- Internal::Actor& actor,
- Animation& animation,
- Property::Index index,
- const Property::Value& value,
- Animation::Type animationType);
+ Internal::Actor& actor,
+ Animation& animation,
+ Property::Index index,
+ const Property::Value& value,
+ Animation::Type animationType);
/// @copydoc Actor::GetSceneObjectAnimatableProperty
static const PropertyBase* GetSceneObjectAnimatableProperty(
- Property::Index index,
- const SceneGraph::Node& node);
+ Property::Index index,
+ const SceneGraph::Node& node);
/// @copydoc Actor::GetSceneObjectInputProperty
static const PropertyInputImpl* GetSceneObjectInputProperty(
- Property::Index index,
- const SceneGraph::Node& node);
+ Property::Index index,
+ const SceneGraph::Node& node);
/// @copydoc Actor::GetPropertyComponentIndex
static int32_t GetPropertyComponentIndex(Property::Index index);
/// @copydoc Actor::GetCachedPropertyValue
static bool GetCachedPropertyValue(
const Internal::Actor& actor,
- Property::Index index,
- Property::Value& value);
+ Property::Index index,
+ Property::Value& value);
/// @copydoc Actor::GetCurrentPropertyValue
static bool GetCurrentPropertyValue(
const Internal::Actor& actor,
- Property::Index index,
- Property::Value& value);
+ Property::Index index,
+ Property::Value& value);
};
} // namespace Internal
#define DALI_INTERNAL_ACTOR_RELAYOUTER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/actors/actor-impl.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/math/vector3.h>
-#include <dali/internal/event/actors/actor-impl.h>
namespace Dali
{
-
namespace Internal
{
-
/**
* Struct to do some actor specific relayouting and store related variables
*/
struct Actor::Relayouter
{
// Defaults
- static constexpr Vector3 DEFAULT_SIZE_MODE_FACTOR{1.0f, 1.0f, 1.0f};
- static constexpr Vector2 DEFAULT_PREFERRED_SIZE{0.0f, 0.0f};
- static constexpr Vector2 DEFAULT_DIMENSION_PADDING{0.0f, 0.0f};
+ static constexpr Vector3 DEFAULT_SIZE_MODE_FACTOR{1.0f, 1.0f, 1.0f};
+ static constexpr Vector2 DEFAULT_PREFERRED_SIZE{0.0f, 0.0f};
+ static constexpr Vector2 DEFAULT_DIMENSION_PADDING{0.0f, 0.0f};
static constexpr SizeScalePolicy::Type DEFAULT_SIZE_SCALE_POLICY = SizeScalePolicy::USE_SIZE_SET;
/// Constructor
~Relayouter() = default;
/// @copydoc Actor::GetResizePolicy
- ResizePolicy::Type GetResizePolicy( Dimension::Type dimension ) const;
+ ResizePolicy::Type GetResizePolicy(Dimension::Type dimension) const;
/// @copydoc Actor::SetPadding
- void SetPadding( const Vector2& padding, Dimension::Type dimension );
+ void SetPadding(const Vector2& padding, Dimension::Type dimension);
/// @copydoc Actor::SetLayoutNegotiated
- void SetLayoutNegotiated( bool negotiated, Dimension::Type dimension );
+ void SetLayoutNegotiated(bool negotiated, Dimension::Type dimension);
/// @copydoc Actor::IsLayoutNegotiated
- bool IsLayoutNegotiated( Dimension::Type dimension ) const;
+ bool IsLayoutNegotiated(Dimension::Type dimension) const;
/// @copydoc Actor::ApplySizeSetPolicy
- Vector2 ApplySizeSetPolicy( Internal::Actor& actor, const Vector2& size );
+ Vector2 ApplySizeSetPolicy(Internal::Actor& actor, const Vector2& size);
/// @copydoc Actor::SetUseAssignedSize
- void SetUseAssignedSize( bool use, Dimension::Type dimension );
+ void SetUseAssignedSize(bool use, Dimension::Type dimension);
/// @copydoc Actor::GetUseAssignedSize
- bool GetUseAssignedSize( Dimension::Type dimension ) const;
+ bool GetUseAssignedSize(Dimension::Type dimension) const;
/// @copydoc Actor::SetMinimumSize
- void SetMinimumSize( float size, Dimension::Type dimension );
+ void SetMinimumSize(float size, Dimension::Type dimension);
/// @copydoc Actor::GetMinimumSize
- float GetMinimumSize( Dimension::Type dimension ) const;
+ float GetMinimumSize(Dimension::Type dimension) const;
/// @copydoc Actor::SetMaximumSize
- void SetMaximumSize( float size, Dimension::Type dimension );
+ void SetMaximumSize(float size, Dimension::Type dimension);
/// @copydoc Actor::GetMaximumSize
- float GetMaximumSize( Dimension::Type dimension ) const;
+ float GetMaximumSize(Dimension::Type dimension) const;
/// @copydoc Actor::SetResizePolicy
- void SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension, Vector3& targetSize );
+ void SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension, Vector3& targetSize);
/// @copydoc Actor::SetDimensionDependency
- void SetDimensionDependency( Dimension::Type dimension, Dimension::Type dependency );
+ void SetDimensionDependency(Dimension::Type dimension, Dimension::Type dependency);
/// @copydoc Actor::GetDimensionDependency
- Dimension::Type GetDimensionDependency( Dimension::Type dimension ) const;
+ Dimension::Type GetDimensionDependency(Dimension::Type dimension) const;
/// @copydoc Actor::SetLayoutDirty
- void SetLayoutDirty( bool dirty, Dimension::Type dimension );
+ void SetLayoutDirty(bool dirty, Dimension::Type dimension);
/// @copydoc Actor::IsLayoutDirty
- bool IsLayoutDirty( Dimension::Type dimension ) const;
+ bool IsLayoutDirty(Dimension::Type dimension) const;
/// @copydoc Actor::SetPreferredSize
/// @actor[in] actor The Actor whose preferred size we wish to set
- void SetPreferredSize( Actor& actor, const Vector2& size );
+ void SetPreferredSize(Actor& actor, const Vector2& size);
/**
* @brief Clamp a dimension given the relayout constraints on given actor
* @param[in] dimension The dimension the size exists in
* @return Return the clamped size
*/
- static float ClampDimension( const Internal::Actor& actor, float size, Dimension::Type dimension );
+ static float ClampDimension(const Internal::Actor& actor, float size, Dimension::Type dimension);
/**
* Negotiate size for a specific dimension
static void NegotiateSize(Actor& actor, const Vector2& allocatedSize, RelayoutContainer& container);
public:
+ ResizePolicy::Type resizePolicies[Dimension::DIMENSION_COUNT]; ///< Resize policies
+ bool useAssignedSize[Dimension::DIMENSION_COUNT]; ///< The flag to specify whether the size should be assigned to the actor
- ResizePolicy::Type resizePolicies[ Dimension::DIMENSION_COUNT ]; ///< Resize policies
- bool useAssignedSize[ Dimension::DIMENSION_COUNT ]; ///< The flag to specify whether the size should be assigned to the actor
-
- Dimension::Type dimensionDependencies[ Dimension::DIMENSION_COUNT ]; ///< A list of dimension dependencies
+ Dimension::Type dimensionDependencies[Dimension::DIMENSION_COUNT]; ///< A list of dimension dependencies
- Vector2 dimensionPadding[ Dimension::DIMENSION_COUNT ]; ///< Padding for each dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
+ Vector2 dimensionPadding[Dimension::DIMENSION_COUNT]; ///< Padding for each dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
- float negotiatedDimensions[ Dimension::DIMENSION_COUNT ]; ///< Storage for when a dimension is negotiated but before set on actor
+ float negotiatedDimensions[Dimension::DIMENSION_COUNT]; ///< Storage for when a dimension is negotiated but before set on actor
- float minimumSize[ Dimension::DIMENSION_COUNT ]; ///< The minimum size an actor can be
- float maximumSize[ Dimension::DIMENSION_COUNT ]; ///< The maximum size an actor can be
+ float minimumSize[Dimension::DIMENSION_COUNT]; ///< The minimum size an actor can be
+ float maximumSize[Dimension::DIMENSION_COUNT]; ///< The maximum size an actor can be
- bool dimensionNegotiated[ Dimension::DIMENSION_COUNT ]; ///< Has the dimension been negotiated
- bool dimensionDirty[ Dimension::DIMENSION_COUNT ]; ///< Flags indicating whether the layout dimension is dirty or not
+ bool dimensionNegotiated[Dimension::DIMENSION_COUNT]; ///< Has the dimension been negotiated
+ bool dimensionDirty[Dimension::DIMENSION_COUNT]; ///< Flags indicating whether the layout dimension is dirty or not
- Vector3 sizeModeFactor; ///< Factor of size used for certain SizeModes
+ Vector3 sizeModeFactor; ///< Factor of size used for certain SizeModes
- Vector2 preferredSize; ///< The preferred size of the actor
+ Vector2 preferredSize; ///< The preferred size of the actor
- SizeScalePolicy::Type sizeSetPolicy :3; ///< Policy to apply when setting size. Enough room for the enum
+ SizeScalePolicy::Type sizeSetPolicy : 3; ///< Policy to apply when setting size. Enough room for the enum
- bool relayoutEnabled :1; ///< Flag to specify if this actor should be included in size negotiation or not (defaults to true)
- bool insideRelayout :1; ///< Locking flag to prevent recursive relayouts on size set
+ bool relayoutEnabled : 1; ///< Flag to specify if this actor should be included in size negotiation or not (defaults to true)
+ bool insideRelayout : 1; ///< Locking flag to prevent recursive relayouts on size set
};
} // namespace Internal
#define DALI_INTERNAL_CAMERA_ACTOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 INCLUES
-#include <dali/public-api/actors/camera-actor.h>
-#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/actors/actor-declarations.h>
+#include <dali/internal/event/actors/actor-impl.h>
+#include <dali/public-api/actors/camera-actor.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
class Camera;
class CameraActor : public Actor
{
public:
-
/**
* Create an initialised camera actor.
*
*
* @return A smart-pointer to a newly allocated camera actor.
*/
- static CameraActorPtr New( const Size& size );
+ static CameraActorPtr New(const Size& size);
/**
* Sets the reflection plane for the camera
*
* @note plane.xyz are normal vector of the plane.
*/
- void SetReflectByPlane( const Vector4& plane );
+ void SetReflectByPlane(const Vector4& plane);
/**
* @copydoc Dali::CameraActor::SetTargetPosition
*/
- void SetTarget( const Vector3& targetPosition );
+ void SetTarget(const Vector3& targetPosition);
/**
* @copydoc Dali::CameraActor::GetTargetPosition
/**
* @copydoc Dali::CameraActor::SetType
*/
- void SetType( Dali::Camera::Type type );
+ void SetType(Dali::Camera::Type type);
/**
* @copydoc Dali::CameraActor::GetType
/**
* @copydoc Dali::CameraActor::SetProjectionMode
*/
- void SetProjectionMode( Dali::Camera::ProjectionMode mode );
+ void SetProjectionMode(Dali::Camera::ProjectionMode mode);
/**
* @copydoc Dali::CameraActor::GetProjectionMode
/**
* @copydoc Dali::CameraActor::SetFieldOfView
*/
- void SetFieldOfView( float fieldOfView );
+ void SetFieldOfView(float fieldOfView);
/**
* @copydoc Dali::CameraActor::GetFieldOfView
/**
* @copydoc Dali::CameraActor::SetAspectRatio
*/
- void SetAspectRatio( float aspectRatio );
+ void SetAspectRatio(float aspectRatio);
/**
* @copydoc Dali::CameraActor::GetAspectRatio
/**
* @copydoc Dali::CameraActor::SetNearClippingPlane
*/
- void SetNearClippingPlane( float nearClippingPlane );
+ void SetNearClippingPlane(float nearClippingPlane);
/**
* @copydoc Dali::CameraActor::GetNearClippingPlane
/**
* @copydoc Dali::CameraActor::SetFarClippingPlane
*/
- void SetFarClippingPlane( float farClippingPlane );
+ void SetFarClippingPlane(float farClippingPlane);
/**
* @copydoc Dali::CameraActor::GetFarClippingPlane
/**
* @param leftClippingPlane to use
*/
- void SetLeftClippingPlane( float leftClippingPlane );
+ void SetLeftClippingPlane(float leftClippingPlane);
/**
* @param rightClippingPlane to use
*/
- void SetRightClippingPlane( float rightClippingPlane );
+ void SetRightClippingPlane(float rightClippingPlane);
/**
* @param topClippingPlane to use
*/
- void SetTopClippingPlane( float topClippingPlane );
+ void SetTopClippingPlane(float topClippingPlane);
/**
* @param bottomClippingPlane to use
*/
- void SetBottomClippingPlane( float bottomClippingPlane );
+ void SetBottomClippingPlane(float bottomClippingPlane);
/**
* @copydoc Dali::CameraActor::SetInvertYAxis
*/
- void SetInvertYAxis( bool invertYAxis );
+ void SetInvertYAxis(bool invertYAxis);
/**
* @copydoc Dali::CameraActor::GetCurrentInvertYAxis
/**
* @copydoc Dali::CameraActor::SetPerspectiveProjection()
*/
- void SetPerspectiveProjection( const Size& size );
+ void SetPerspectiveProjection(const Size& size);
/**
* @copydoc Dali::CameraActor::SetOrthographicProjection(const Vector2& size);
*/
- void SetOrthographicProjection( const Vector2& size );
+ void SetOrthographicProjection(const Vector2& size);
/**
* @copydoc Dali::CameraActor::SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far);
*/
- void SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far );
+ void SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far);
/**
* Build a picking ray with this camera and given screen coordinates
* @param [out] rayDirection for the picking ray
* @return true if the building was successful, false if its not possible (camera is not valid for hit testing)
*/
- bool BuildPickingRay( const Vector2& screenCoordinates, const Viewport& viewport, Vector4& rayOrigin, Vector4& rayDirection );
+ bool BuildPickingRay(const Vector2& screenCoordinates, const Viewport& viewport, Vector4& rayOrigin, Vector4& rayDirection);
/**
* Retrieve the view-matrix; This will only be valid when the actor is on-stage.
void RotateProjection(int rotationAngle);
public: // properties
-
/**
* copydoc Dali::Internal::Object::SetDefaultProperty()
*/
- void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) override;
+ void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override;
/**
* copydoc Dali::Internal::Object::GetDefaultProperty()
*/
- Property::Value GetDefaultProperty( Property::Index index ) const override;
+ Property::Value GetDefaultProperty(Property::Index index) const override;
/**
* copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
*/
- Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const override;
+ Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
/**
* @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
*/
- const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const override;
+ const PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const override;
private:
-
/**
* Constructor; see also CameraActor::New()
* @param node the scene graph node
*/
- CameraActor( const SceneGraph::Node& node );
+ CameraActor(const SceneGraph::Node& node);
/**
* A reference counted object may only be deleted by calling Unreference()
*/
~CameraActor() override;
-
/**
* @copydoc Dali::Internal::Actor::OnInitialize()
*/
*/
void OnSceneConnectionInternal() override;
-private: // Data
-
+private: // Data
const SceneGraph::Camera* mSceneObject; ///< Not owned
- Vector3 mTarget;
- Vector2 mCanvasSize;
- Dali::Camera::Type mType;
+ Vector3 mTarget;
+ Vector2 mCanvasSize;
+ Dali::Camera::Type mType;
Dali::Camera::ProjectionMode mProjectionMode;
- float mFieldOfView;
- float mAspectRatio;
- float mNearClippingPlane;
- float mFarClippingPlane;
- float mLeftClippingPlane;
- float mRightClippingPlane;
- float mTopClippingPlane;
- float mBottomClippingPlane;
- bool mInvertYAxis;
-
+ float mFieldOfView;
+ float mAspectRatio;
+ float mNearClippingPlane;
+ float mFarClippingPlane;
+ float mLeftClippingPlane;
+ float mRightClippingPlane;
+ float mTopClippingPlane;
+ float mBottomClippingPlane;
+ bool mInvertYAxis;
};
} // namespace Internal
namespace Dali
{
-
namespace Internal
{
-
CustomActorPtr CustomActor::New(CustomActorImpl& extension)
{
- CustomActorPtr actor(new CustomActor( *CreateNode(), extension));
+ CustomActorPtr actor(new CustomActor(*CreateNode(), extension));
// Second-phase construction
extension.Initialize(*actor);
return actor;
}
-CustomActor::CustomActor( const SceneGraph::Node& node, CustomActorImpl& extension)
-: Actor( Actor::BASIC, node ),
- mImpl( &extension )
+CustomActor::CustomActor(const SceneGraph::Node& node, CustomActorImpl& extension)
+: Actor(Actor::BASIC, node),
+ mImpl(&extension)
{
- SetRelayoutEnabled( extension.IsRelayoutEnabled() );
+ SetRelayoutEnabled(extension.IsRelayoutEnabled());
}
CustomActor::~CustomActor() = default;
Dali::TypeInfo CustomActor::GetTypeInfo()
{
- Dali::TypeInfo handle ( const_cast<Dali::Internal::TypeInfo*>(Object::GetTypeInfo()) );
+ Dali::TypeInfo handle(const_cast<Dali::Internal::TypeInfo*>(Object::GetTypeInfo()));
return handle;
}
#define DALI_INTERNAL_CUSTOM_ACTOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/actors/actor-impl.h>
#include <dali/internal/event/actors/actor-declarations.h>
+#include <dali/internal/event/actors/actor-impl.h>
#include <dali/public-api/actors/custom-actor.h>
#include <dali/public-api/animation/animation.h>
namespace Dali
{
-
namespace Internal
{
-
class CustomActor : public Actor
{
public:
-
/**
* Create a new custom actor.
* @return A smart-pointer to the newly allocated Actor.
Dali::TypeInfo GetTypeInfo();
protected:
-
/**
* A reference counted object may only be deleted by calling Unreference()
*/
~CustomActor() override;
private:
-
/**
* @copydoc Internal::Actor::OnSceneConnectionExternal
*/
- void OnSceneConnectionExternal( int32_t depth ) override
+ void OnSceneConnectionExternal(int32_t depth) override
{
- mImpl->OnSceneConnection( depth );
+ mImpl->OnSceneConnection(depth);
}
/**
/**
* @copydoc Internal::Actor::OnPropertySet
*/
- void OnPropertySet( Property::Index index, const Property::Value& propertyValue ) override
+ void OnPropertySet(Property::Index index, const Property::Value& propertyValue) override
{
mImpl->OnPropertySet(index, propertyValue);
}
/**
* @copydoc Internal::Actor::OnRelayout
*/
- void OnRelayout( const Vector2& size, RelayoutContainer& container ) override
+ void OnRelayout(const Vector2& size, RelayoutContainer& container) override
{
- mImpl->OnRelayout( size, container );
+ mImpl->OnRelayout(size, container);
}
/**
* @copydoc Internal::Actor::OnSetResizePolicy
*/
- void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) override
+ void OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension) override
{
- mImpl->OnSetResizePolicy( policy, dimension );
+ mImpl->OnSetResizePolicy(policy, dimension);
}
/**
/**
* @copydoc Internal::Actor::CalculateChildSize
*/
- float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension ) override
+ float CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension) override
{
- return mImpl->CalculateChildSize( child, dimension );
+ return mImpl->CalculateChildSize(child, dimension);
}
/**
* @copydoc Internal::Actor::GetHeightForWidth
*/
- float GetHeightForWidth( float width ) override
+ float GetHeightForWidth(float width) override
{
- return mImpl->GetHeightForWidth( width );
+ return mImpl->GetHeightForWidth(width);
}
/**
* @copydoc Internal::Actor::GetWidthForHeight
*/
- float GetWidthForHeight( float height ) override
+ float GetWidthForHeight(float height) override
{
- return mImpl->GetWidthForHeight( height );
+ return mImpl->GetWidthForHeight(height);
}
/**
* @copydoc Internal::Actor::RelayoutDependentOnChildren
*/
- bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) override
+ bool RelayoutDependentOnChildren(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) override
{
- return mImpl->RelayoutDependentOnChildren( dimension );
+ return mImpl->RelayoutDependentOnChildren(dimension);
}
/**
* @copydoc Internal::Actor::OnCalculateRelayoutSize
*/
- void OnCalculateRelayoutSize( Dimension::Type dimension ) override
+ void OnCalculateRelayoutSize(Dimension::Type dimension) override
{
- return mImpl->OnCalculateRelayoutSize( dimension );
+ return mImpl->OnCalculateRelayoutSize(dimension);
}
/**
* @copydoc Internal::Actor::OnLayoutNegotiated
*/
- void OnLayoutNegotiated( float size, Dimension::Type dimension ) override
+ void OnLayoutNegotiated(float size, Dimension::Type dimension) override
{
- return mImpl->OnLayoutNegotiated( size, dimension );
+ return mImpl->OnLayoutNegotiated(size, dimension);
}
/**
* Private constructor; see also CustomActor::New()
*/
- CustomActor( const SceneGraph::Node& node, CustomActorImpl& extension );
+ CustomActor(const SceneGraph::Node& node, CustomActorImpl& extension);
// no default or copy constructor or assignment
- CustomActor() = delete;
- CustomActor( const CustomActor& ) = delete;
- CustomActor& operator=( const CustomActor& rhs ) = delete;
+ CustomActor() = delete;
+ CustomActor(const CustomActor&) = delete;
+ CustomActor& operator=(const CustomActor& rhs) = delete;
protected:
-
CustomActorImplPtr mImpl;
-
};
} // namespace Internal
inline Internal::CustomActor& GetImpl(Dali::CustomActor& actor)
{
- DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
+ DALI_ASSERT_ALWAYS(actor && "CustomActor handle is empty");
BaseObject& handle = actor.GetBaseObject();
inline const Internal::CustomActor& GetImpl(const Dali::CustomActor& actor)
{
- DALI_ASSERT_ALWAYS( actor && "CustomActor handle is empty" );
+ DALI_ASSERT_ALWAYS(actor && "CustomActor handle is empty");
const BaseObject& handle = actor.GetBaseObject();
#define DALI_INTERNAL_LAYER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/actors/layer.h>
-#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/actors/actor-declarations.h>
+#include <dali/internal/event/actors/actor-impl.h>
+#include <dali/public-api/actors/layer.h>
namespace Dali
{
-
namespace Internal
{
-
class LayerList;
namespace SceneGraph
{
class UpdateManager;
class Layer;
-}
+} // namespace SceneGraph
using ClippingBox = Dali::ClippingBox;
class Layer : public Actor
{
public:
-
/**
* @copydoc Dali::Layer::ZValue(const Vector3&, float)
*
* @param[in] layerList The layer will be added to this ordered list.
* @return A smart-pointer to the newly allocated Actor.
*/
- static LayerPtr NewRoot( LayerList& layerList );
+ static LayerPtr NewRoot(LayerList& layerList);
/**
* @copydoc Dali::Internal::Actor::OnInitialize
/**
* @copydoc Dali::Layer::RaiseAbove
*/
- void RaiseAbove( const Internal::Layer& target );
+ void RaiseAbove(const Internal::Layer& target);
/**
* @copydoc Dali::Layer::LowerBelow
*/
- void LowerBelow( const Internal::Layer& target );
+ void LowerBelow(const Internal::Layer& target);
/**
* @copydoc Dali::Layer::RaiseToTop
/**
* @copydoc Dali::Layer::MoveAbove
*/
- void MoveAbove( const Internal::Layer& target );
+ void MoveAbove(const Internal::Layer& target);
/**
* @copydoc Dali::Layer::MoveAbove
*/
- void MoveBelow( const Internal::Layer& target );
+ void MoveBelow(const Internal::Layer& target);
/**
* @copydoc Dali::Layer::SetClipping()
/**
* @copydoc Dali::Layer::SetBehavior()
*/
- void SetBehavior( Dali::Layer::Behavior behavior );
+ void SetBehavior(Dali::Layer::Behavior behavior);
/**
* @copydoc Dali::Layer::GetBehavior()
/**
* @copydoc Dali::Layer::SetDepthTestDisabled()
*/
- void SetDepthTestDisabled( bool disable );
+ void SetDepthTestDisabled(bool disable);
/**
* @copydoc Dali::Layer::IsDepthTestDisabled()
/**
* @copydoc Dali::Layer::SetTouchConsumed()
*/
- void SetTouchConsumed( bool consume );
+ void SetTouchConsumed(bool consume);
/**
* @copydoc Dali::Layer::IsTouchConsumed()
/**
* @copydoc Dali::Layer::SetHoverConsumed()
*/
- void SetHoverConsumed( bool consume );
+ void SetHoverConsumed(bool consume);
/**
* @copydoc Dali::Layer::IsHoverConsumed()
static bool DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes);
public: // Default property extensions from Object
-
/**
* @copydoc Dali::Internal::Object::SetDefaultProperty()
*/
/**
* @copydoc Dali::Internal::Object::GetDefaultProperty()
*/
- Property::Value GetDefaultProperty( Property::Index index ) const override;
+ Property::Value GetDefaultProperty(Property::Index index) const override;
/**
* @copydoc Dali::Internal::Object::GetDefaultProperty()
*/
- Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const override;
+ Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
protected:
-
/**
* Construct a new layer.
* @param[in] type Either Actor::LAYER or Actor::ROOT_LAYER if this is the root actor.
* @param[in] layer the scene graph layer
*/
- Layer( Actor::DerivedType type, const SceneGraph::Layer& layer );
+ Layer(Actor::DerivedType type, const SceneGraph::Layer& layer);
/**
* A reference counted object may only be deleted by calling Unreference()
~Layer() override;
private: // From Actor
-
/**
* From Actor.
*/
void OnSceneDisconnectionInternal() override;
private:
-
LayerList* mLayerList; ///< Only valid when layer is on-scene
// These properties not animatable; the actor side has the most up-to-date values
- ClippingBox mClippingBox; ///< The clipping box, in window coordinates
- Dali::Layer::SortFunctionType mSortFunction; ///< Used to sort semi-transparent geometry
-
- Dali::Layer::Behavior mBehavior; ///< Behavior of the layer
+ ClippingBox mClippingBox; ///< The clipping box, in window coordinates
+ Dali::Layer::SortFunctionType mSortFunction; ///< Used to sort semi-transparent geometry
- bool mIsClipping:1; ///< True when clipping is enabled
- bool mDepthTestDisabled:1; ///< Whether depth test is disabled.
- bool mTouchConsumed:1; ///< Whether we should consume touch (including gesture).
- bool mHoverConsumed:1; ///< Whether we should consume hover.
+ Dali::Layer::Behavior mBehavior; ///< Behavior of the layer
+ bool mIsClipping : 1; ///< True when clipping is enabled
+ bool mDepthTestDisabled : 1; ///< Whether depth test is disabled.
+ bool mTouchConsumed : 1; ///< Whether we should consume touch (including gesture).
+ bool mHoverConsumed : 1; ///< Whether we should consume hover.
};
} // namespace Internal
} // namespace Dali
-
#endif // DALI_INTERNAL_LAYER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/actors/layer-list.h>
// EXTERNAL INCLUDES
-#include <algorithm> // for std::swap
+#include <algorithm> // for std::swap
// INTERNAL INCLUDES
#include <dali/integration-api/debug.h>
namespace Dali
{
-
namespace Internal
{
-
namespace // unnamed namespace
{
-
typedef std::vector<Layer*> LayerContainer;
using LayerIter = LayerContainer::iterator;
using ReverseLayerIter = LayerContainer::reverse_iterator;
* @param[in] layer to search for
* @return iterator to layer if found
*/
-template<class InputIterator> InputIterator Find( InputIterator first, InputIterator last, const Layer& layer )
+template<class InputIterator>
+InputIterator Find(InputIterator first, InputIterator last, const Layer& layer)
{
- for( ; first != last ; ++first )
+ for(; first != last; ++first)
{
- if( *first == &layer )
+ if(*first == &layer)
{
break;
}
- }
- return first;
+ }
+ return first;
}
} // unnamed namespace
-LayerList* LayerList::New( SceneGraph::UpdateManager& updateManager )
+LayerList* LayerList::New(SceneGraph::UpdateManager& updateManager)
{
- return new LayerList( updateManager );
+ return new LayerList(updateManager);
}
LayerList::~LayerList() = default;
uint32_t LayerList::GetLayerCount() const
{
- return static_cast<uint32_t>( mLayers.size() ); // // only 4,294,967,295 layers supported
+ return static_cast<uint32_t>(mLayers.size()); // // only 4,294,967,295 layers supported
}
-Layer* LayerList::GetLayer( uint32_t depth ) const
+Layer* LayerList::GetLayer(uint32_t depth) const
{
- DALI_ASSERT_ALWAYS( depth < mLayers.size() );
+ DALI_ASSERT_ALWAYS(depth < mLayers.size());
- return mLayers[ depth ];
+ return mLayers[depth];
}
-uint32_t LayerList::GetDepth( const Layer* layer ) const
+uint32_t LayerList::GetDepth(const Layer* layer) const
{
- for( uint32_t count = 0; count < mLayers.size(); ++count )
+ for(uint32_t count = 0; count < mLayers.size(); ++count)
{
- if( layer == mLayers[ count ] )
+ if(layer == mLayers[count])
{
return count;
}
void LayerList::RegisterLayer(Layer& layer)
{
- DALI_ASSERT_DEBUG( mLayers.end() == Find( mLayers.begin(), mLayers.end(), layer) );
+ DALI_ASSERT_DEBUG(mLayers.end() == Find(mLayers.begin(), mLayers.end(), layer));
mLayers.push_back(&layer);
SetLayerDepths();
void LayerList::UnregisterLayer(Layer& layer)
{
// Find the layer...
- LayerIter iter = Find( mLayers.begin(), mLayers.end(), layer);
+ LayerIter iter = Find(mLayers.begin(), mLayers.end(), layer);
DALI_ASSERT_DEBUG(iter != mLayers.end());
// ...and remove it
void LayerList::RaiseLayer(Layer& raiseLayer)
{
- LayerIter iter = Find( mLayers.begin(), mLayers.end(), raiseLayer);
+ LayerIter iter = Find(mLayers.begin(), mLayers.end(), raiseLayer);
- if (iter != mLayers.end() &&
- iter+1 != mLayers.end())
+ if(iter != mLayers.end() &&
+ iter + 1 != mLayers.end())
{
- LayerIter nextIter = iter+1;
+ LayerIter nextIter = iter + 1;
// Swap the pointers
std::swap(*iter, *nextIter);
void LayerList::LowerLayer(Layer& lowerLayer)
{
- ReverseLayerIter iter = Find( mLayers.rbegin(), mLayers.rend(), lowerLayer);
+ ReverseLayerIter iter = Find(mLayers.rbegin(), mLayers.rend(), lowerLayer);
- if (iter != mLayers.rend() &&
- iter+1 != mLayers.rend())
+ if(iter != mLayers.rend() &&
+ iter + 1 != mLayers.rend())
{
- ReverseLayerIter nextIter = iter+1;
+ ReverseLayerIter nextIter = iter + 1;
// Swap the pointers
std::swap(*iter, *nextIter);
}
}
-void LayerList::RaiseLayerToTop( const Layer& layer )
+void LayerList::RaiseLayerToTop(const Layer& layer)
{
- LayerIter iter = Find( mLayers.begin(), mLayers.end(), layer);
+ LayerIter iter = Find(mLayers.begin(), mLayers.end(), layer);
- if (iter != mLayers.end() &&
- iter+1 != mLayers.end())
+ if(iter != mLayers.end() &&
+ iter + 1 != mLayers.end())
{
Layer* raised = *iter;
- copy(iter+1, mLayers.end(), iter);
+ copy(iter + 1, mLayers.end(), iter);
mLayers.back() = raised;
SetLayerDepths();
}
}
-void LayerList::LowerLayerToBottom( const Layer& layer )
+void LayerList::LowerLayerToBottom(const Layer& layer)
{
- ReverseLayerIter iter = Find( mLayers.rbegin(), mLayers.rend(), layer);
+ ReverseLayerIter iter = Find(mLayers.rbegin(), mLayers.rend(), layer);
- if (iter != mLayers.rend() &&
- iter+1 != mLayers.rend())
+ if(iter != mLayers.rend() &&
+ iter + 1 != mLayers.rend())
{
Layer* lowered = *iter;
- copy(iter+1, mLayers.rend(), iter);
+ copy(iter + 1, mLayers.rend(), iter);
mLayers.front() = lowered;
SetLayerDepths();
}
}
-void LayerList::MoveLayerAbove( const Layer& layer, const Layer& target )
+void LayerList::MoveLayerAbove(const Layer& layer, const Layer& target)
{
// check if it already is
- if( layer.GetDepth() == ( target.GetDepth() + 1 ) )
+ if(layer.GetDepth() == (target.GetDepth() + 1))
{
return;
}
// find the layer to move
- LayerIter iter = Find( mLayers.begin(), mLayers.end(), layer);
+ LayerIter iter = Find(mLayers.begin(), mLayers.end(), layer);
- if( iter != mLayers.end() )
+ if(iter != mLayers.end())
{
Layer* moved = *iter;
- mLayers.erase( iter );
+ mLayers.erase(iter);
// find target
- LayerIter iterT = Find( mLayers.begin(), mLayers.end(), target);
+ LayerIter iterT = Find(mLayers.begin(), mLayers.end(), target);
// if target is not found there's a programming error somewhere
- DALI_ASSERT_DEBUG( iterT != mLayers.end() );
+ DALI_ASSERT_DEBUG(iterT != mLayers.end());
// iterT might be the last
- if( ( iterT+1 ) == mLayers.end() )
+ if((iterT + 1) == mLayers.end())
{
- mLayers.push_back( moved );
+ mLayers.push_back(moved);
}
else
{
- mLayers.insert( iterT+1, moved );
+ mLayers.insert(iterT + 1, moved);
}
SetLayerDepths();
}
}
-void LayerList::MoveLayerBelow( const Layer& layer, const Layer& target )
+void LayerList::MoveLayerBelow(const Layer& layer, const Layer& target)
{
// check if it already is in correct order
- if( layer.GetDepth() == ( target.GetDepth() - 1 ) )
+ if(layer.GetDepth() == (target.GetDepth() - 1))
{
return;
}
// find the layer to move
- LayerIter iter = Find( mLayers.begin(), mLayers.end(), layer);
- if( iter != mLayers.end() )
+ LayerIter iter = Find(mLayers.begin(), mLayers.end(), layer);
+ if(iter != mLayers.end())
{
Layer* moved = *iter;
- mLayers.erase( iter );
+ mLayers.erase(iter);
// find target
- LayerIter iterT = Find( mLayers.begin(), mLayers.end(), target);
+ LayerIter iterT = Find(mLayers.begin(), mLayers.end(), target);
// if target is not found there's a programming error somewhere
- DALI_ASSERT_DEBUG( iterT != mLayers.end() );
- mLayers.insert( iterT, moved );
+ DALI_ASSERT_DEBUG(iterT != mLayers.end());
+ mLayers.insert(iterT, moved);
SetLayerDepths();
}
}
-LayerList::LayerList( SceneGraph::UpdateManager& updateManager )
-: mUpdateManager( updateManager ),
- mRoot( nullptr )
+LayerList::LayerList(SceneGraph::UpdateManager& updateManager)
+: mUpdateManager(updateManager),
+ mRoot(nullptr)
{
}
{
// we've got a list of on-stage layers on actor side, need to get their stage
// pointers so we can send them to the update manager
- std::vector< SceneGraph::Layer* > layers;
- layers.reserve( mLayers.size() );
+ std::vector<SceneGraph::Layer*> layers;
+ layers.reserve(mLayers.size());
// Set the layers (possibly) new depth
- for (LayerIter iter = mLayers.begin(); iter != mLayers.end(); ++iter)
+ for(LayerIter iter = mLayers.begin(); iter != mLayers.end(); ++iter)
{
- SceneGraph::Layer* layerPtr = const_cast< SceneGraph::Layer* >( &( (*iter)->GetSceneGraphLayer() ) );
- layers.push_back( layerPtr );
+ SceneGraph::Layer* layerPtr = const_cast<SceneGraph::Layer*>(&((*iter)->GetSceneGraphLayer()));
+ layers.push_back(layerPtr);
}
// Layers are being used in a separate thread; queue a message to set order
- SetLayerDepthsMessage( mUpdateManager, layers, &( mRoot->GetSceneGraphLayer() ) );
+ SetLayerDepthsMessage(mUpdateManager, layers, &(mRoot->GetSceneGraphLayer()));
}
void LayerList::SetRootLayer(Layer* rootLayer)
#define DALI_INTERNAL_LAYER_LIST_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
class UpdateManager;
class LayerList
{
public:
-
/**
* Create a new list of layers.
* @param[in] updateManager A reference to the update manager.
*/
- static LayerList* New( SceneGraph::UpdateManager& updateManager );
+ static LayerList* New(SceneGraph::UpdateManager& updateManager);
/**
* Non-virtual destructor; not suitable as a base class.
* @param[in] depth The depth.
* @return The layer found at the given depth.
*/
- Layer* GetLayer( uint32_t depth ) const;
+ Layer* GetLayer(uint32_t depth) const;
/**
* Gets the depth of a given layer
* @param layer which depth to check
*/
- uint32_t GetDepth( const Layer* layer ) const;
+ uint32_t GetDepth(const Layer* layer) const;
/**
* Register a layer with the stage.
* The stage determines the relative depth of each layer.
*/
- void RegisterLayer( Layer& layer );
+ void RegisterLayer(Layer& layer);
/**
* Unregister a layer from the stage
* @pre layer is on stage
* @param layer to move
*/
- void RaiseLayerToTop( const Layer& layer );
+ void RaiseLayerToTop(const Layer& layer);
/**
* Lowers the layer to the bottom of the stage
* @pre layer is on stage
* @param layer to move
*/
- void LowerLayerToBottom( const Layer& layer );
+ void LowerLayerToBottom(const Layer& layer);
/**
* Moves the layer above the target layer on the stage
* @param layer to move
* @param target to move above of
*/
- void MoveLayerAbove( const Layer& layer, const Layer& target );
+ void MoveLayerAbove(const Layer& layer, const Layer& target);
/**
* Moves the layer below the target layer on the stage
* @param layer to move
* @param target to move below of
*/
- void MoveLayerBelow( const Layer& layer, const Layer& target );
+ void MoveLayerBelow(const Layer& layer, const Layer& target);
/**
* Sets the root layer that this layer list belongs to
void SetRootLayer(Layer* rootLayer);
private:
-
/**
* Protected constructor; see also LayerList::New().
* @param[in] updateManager to send messages.
*/
- LayerList( SceneGraph::UpdateManager& updateManager );
+ LayerList(SceneGraph::UpdateManager& updateManager);
/**
* A private helper method to set the depth for each layer.
void SetLayerDepths();
private:
-
SceneGraph::UpdateManager& mUpdateManager;
- Layer* mRoot; ///< The root layer that this ordered list of layers belong to
+ Layer* mRoot; ///< The root layer that this ordered list of layers belong to
using LayerContainer = std::vector<Layer*>;
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
// EXTERNAL INCLUDES
// INTERNAL INCLUDES
-#include <dali/public-api/animation/alpha-function.h>
-#include <dali/public-api/animation/time-period.h>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/math/radian.h>
#include <dali/internal/event/animation/animation-playlist.h>
#include <dali/internal/event/animation/animator-connector.h>
#include <dali/internal/event/animation/path-impl.h>
#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/update/animation/scene-graph-animator.h>
#include <dali/internal/update/manager/update-manager.h>
+#include <dali/public-api/animation/alpha-function.h>
+#include <dali/public-api/animation/time-period.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/math/radian.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/object/type-registry.h>
-using Dali::Internal::SceneGraph::UpdateManager;
using Dali::Internal::SceneGraph::AnimatorBase;
using Dali::Internal::SceneGraph::Shader;
+using Dali::Internal::SceneGraph::UpdateManager;
namespace Dali
{
-
namespace Internal
{
-
static bool SHOW_VALUE = true;
static bool HIDE_VALUE = false;
namespace
{
-
// Signals
static constexpr std::string_view SIGNAL_FINISHED = "finished";
return Dali::Animation::New(0.f);
}
-TypeRegistration mType( typeid( Dali::Animation ), typeid( Dali::BaseHandle ), Create );
+TypeRegistration mType(typeid(Dali::Animation), typeid(Dali::BaseHandle), Create);
SignalConnectorType signalConnector1(mType, std::string(SIGNAL_FINISHED), &Animation::DoConnectSignal);
TypeAction action2(mType, std::string(ACTION_STOP), &Animation::DoAction);
TypeAction action3(mType, std::string(ACTION_PAUSE), &Animation::DoAction);
-const Dali::Animation::EndAction DEFAULT_END_ACTION( Dali::Animation::BAKE );
-const Dali::Animation::EndAction DEFAULT_DISCONNECT_ACTION( Dali::Animation::BAKE_FINAL );
-const Dali::Animation::Interpolation DEFAULT_INTERPOLATION( Dali::Animation::LINEAR );
-const Dali::AlphaFunction DEFAULT_ALPHA_FUNCTION( Dali::AlphaFunction::DEFAULT );
+const Dali::Animation::EndAction DEFAULT_END_ACTION(Dali::Animation::BAKE);
+const Dali::Animation::EndAction DEFAULT_DISCONNECT_ACTION(Dali::Animation::BAKE_FINAL);
+const Dali::Animation::Interpolation DEFAULT_INTERPOLATION(Dali::Animation::LINEAR);
+const Dali::AlphaFunction DEFAULT_ALPHA_FUNCTION(Dali::AlphaFunction::DEFAULT);
/**
* Helper to tell if a property is animatable (if we have animators for it)
* @param type type to check
* @return true if animatable
*/
-inline bool IsAnimatable( Property::Type type )
+inline bool IsAnimatable(Property::Type type)
{
bool animatable = false;
- switch( type )
+ switch(type)
{
- case Property::BOOLEAN :
- case Property::FLOAT :
- case Property::INTEGER :
- case Property::VECTOR2 :
- case Property::VECTOR3 :
- case Property::VECTOR4 :
- case Property::ROTATION :
+ case Property::BOOLEAN:
+ case Property::FLOAT:
+ case Property::INTEGER:
+ case Property::VECTOR2:
+ case Property::VECTOR3:
+ case Property::VECTOR4:
+ case Property::ROTATION:
{
animatable = true;
break;
}
- case Property::MATRIX : // matrix is allowed as a scene graph property but there's no animators for it
- case Property::MATRIX3 : // matrix3 is allowed as a scene graph property but there's no animators for it
- case Property::NONE :
- case Property::RECTANGLE :
- case Property::STRING :
- case Property::ARRAY :
- case Property::MAP :
- case Property::EXTENTS :
+ case Property::MATRIX: // matrix is allowed as a scene graph property but there's no animators for it
+ case Property::MATRIX3: // matrix3 is allowed as a scene graph property but there's no animators for it
+ case Property::NONE:
+ case Property::RECTANGLE:
+ case Property::STRING:
+ case Property::ARRAY:
+ case Property::MAP:
+ case Property::EXTENTS:
{
break;
}
* @param destinationType type of the target
* @param period time period of the animation
*/
-void ValidateParameters( Property::Type propertyType, Property::Type destinationType, const TimePeriod& period )
+void ValidateParameters(Property::Type propertyType, Property::Type destinationType, const TimePeriod& period)
{
// destination value has to be animatable
- DALI_ASSERT_ALWAYS( IsAnimatable( propertyType ) && "Property type is not animatable" );
- DALI_ASSERT_ALWAYS( IsAnimatable( destinationType ) && "Target value is not animatable" );
- DALI_ASSERT_ALWAYS( propertyType == destinationType && "Property and target types don't match" );
- DALI_ASSERT_ALWAYS( period.durationSeconds >= 0 && "Duration must be >=0" );
+ DALI_ASSERT_ALWAYS(IsAnimatable(propertyType) && "Property type is not animatable");
+ DALI_ASSERT_ALWAYS(IsAnimatable(destinationType) && "Target value is not animatable");
+ DALI_ASSERT_ALWAYS(propertyType == destinationType && "Property and target types don't match");
+ DALI_ASSERT_ALWAYS(period.durationSeconds >= 0 && "Duration must be >=0");
}
} // anonymous namespace
AnimationPtr Animation::New(float durationSeconds)
{
- if( durationSeconds < 0.0f )
+ if(durationSeconds < 0.0f)
{
DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
durationSeconds = 0.0f;
}
- ThreadLocalStorage& tls = ThreadLocalStorage::Get();
- AnimationPtr animation = new Animation( tls.GetEventThreadServices(), tls.GetAnimationPlaylist(), durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, DEFAULT_ALPHA_FUNCTION );
+ ThreadLocalStorage& tls = ThreadLocalStorage::Get();
+ AnimationPtr animation = new Animation(tls.GetEventThreadServices(), tls.GetAnimationPlaylist(), durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, DEFAULT_ALPHA_FUNCTION);
// Second-phase construction
animation->Initialize();
void Animation::Initialize()
{
// Connect to the animation playlist
- mPlaylist.AnimationCreated( *this );
+ mPlaylist.AnimationCreated(*this);
CreateSceneObject();
Animation::~Animation()
{
// Guard to allow handle destruction after Core has been destroyed
- if ( Stage::IsInstalled() )
+ if(Stage::IsInstalled())
{
// Disconnect from the animation playlist
- mPlaylist.AnimationDestroyed( *this );
+ mPlaylist.AnimationDestroyed(*this);
DestroySceneObject();
void Animation::CreateSceneObject()
{
- DALI_ASSERT_DEBUG( mAnimation == NULL );
+ DALI_ASSERT_DEBUG(mAnimation == NULL);
// Create a new animation, Keep a const pointer to the animation.
- mAnimation = SceneGraph::Animation::New( mDurationSeconds, mSpeedFactor, mPlayRange, mLoopCount, mEndAction, mDisconnectAction );
- OwnerPointer< SceneGraph::Animation > transferOwnership( const_cast< SceneGraph::Animation* >( mAnimation ) );
- AddAnimationMessage( mEventThreadServices.GetUpdateManager(), transferOwnership );
+ mAnimation = SceneGraph::Animation::New(mDurationSeconds, mSpeedFactor, mPlayRange, mLoopCount, mEndAction, mDisconnectAction);
+ OwnerPointer<SceneGraph::Animation> transferOwnership(const_cast<SceneGraph::Animation*>(mAnimation));
+ AddAnimationMessage(mEventThreadServices.GetUpdateManager(), transferOwnership);
}
void Animation::DestroySceneObject()
{
- if ( mAnimation != nullptr )
+ if(mAnimation != nullptr)
{
// Remove animation using a message to the update manager
- RemoveAnimationMessage( mEventThreadServices.GetUpdateManager(), *mAnimation );
+ RemoveAnimationMessage(mEventThreadServices.GetUpdateManager(), *mAnimation);
mAnimation = nullptr;
}
}
void Animation::SetDuration(float seconds)
{
- if( seconds < 0.0f )
+ if(seconds < 0.0f)
{
DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
seconds = 0.0f;
mDurationSeconds = seconds;
// mAnimation is being used in a separate thread; queue a message to set the value
- SetDurationMessage( mEventThreadServices, *mAnimation, seconds );
+ SetDurationMessage(mEventThreadServices, *mAnimation, seconds);
}
-void Animation::SetProgressNotification( float progress )
+void Animation::SetProgressNotification(float progress)
{
// mAnimation is being used in a separate thread; queue a message to set the value
mProgressReachedMarker = progress;
void Animation::SetLooping(bool on)
{
- SetLoopCount( on ? 0 : 1 );
+ SetLoopCount(on ? 0 : 1);
}
void Animation::SetLoopCount(int32_t count)
mLoopCount = count;
// mAnimation is being used in a separate thread; queue a message to set the value
- SetLoopingMessage( mEventThreadServices, *mAnimation, mLoopCount );
+ SetLoopingMessage(mEventThreadServices, *mAnimation, mLoopCount);
}
int32_t Animation::GetLoopCount()
mEndAction = action;
// mAnimation is being used in a separate thread; queue a message to set the value
- SetEndActionMessage( mEventThreadServices, *mAnimation, action );
+ SetEndActionMessage(mEventThreadServices, *mAnimation, action);
}
Dali::Animation::EndAction Animation::GetEndAction() const
mDisconnectAction = action;
// mAnimation is being used in a separate thread; queue a message to set the value
- SetDisconnectActionMessage( mEventThreadServices, *mAnimation, action );
+ SetDisconnectActionMessage(mEventThreadServices, *mAnimation, action);
}
Dali::Animation::EndAction Animation::GetDisconnectAction() const
void Animation::Play()
{
// Update the current playlist
- mPlaylist.OnPlay( *this );
+ mPlaylist.OnPlay(*this);
mState = Dali::Animation::PLAYING;
- NotifyObjects( Notify::USE_TARGET_VALUE );
+ NotifyObjects(Notify::USE_TARGET_VALUE);
SendFinalProgressNotificationMessage();
// mAnimation is being used in a separate thread; queue a Play message
- PlayAnimationMessage( mEventThreadServices, *mAnimation );
+ PlayAnimationMessage(mEventThreadServices, *mAnimation);
}
-void Animation::PlayFrom( float progress )
+void Animation::PlayFrom(float progress)
{
- if( progress >= mPlayRange.x && progress <= mPlayRange.y )
+ if(progress >= mPlayRange.x && progress <= mPlayRange.y)
{
// Update the current playlist
- mPlaylist.OnPlay( *this );
+ mPlaylist.OnPlay(*this);
mState = Dali::Animation::PLAYING;
- NotifyObjects( Notify::USE_TARGET_VALUE );
+ NotifyObjects(Notify::USE_TARGET_VALUE);
SendFinalProgressNotificationMessage();
// mAnimation is being used in a separate thread; queue a Play message
- PlayAnimationFromMessage( mEventThreadServices, *mAnimation, progress );
+ PlayAnimationFromMessage(mEventThreadServices, *mAnimation, progress);
}
}
-void Animation::PlayAfter( float delaySeconds )
+void Animation::PlayAfter(float delaySeconds)
{
// The negative delay means play immediately.
- delaySeconds = std::max( 0.f, delaySeconds );
+ delaySeconds = std::max(0.f, delaySeconds);
mDelaySeconds = delaySeconds;
// Update the current playlist
- mPlaylist.OnPlay( *this );
+ mPlaylist.OnPlay(*this);
mState = Dali::Animation::PLAYING;
- NotifyObjects( Notify::USE_TARGET_VALUE );
+ NotifyObjects(Notify::USE_TARGET_VALUE);
SendFinalProgressNotificationMessage();
// mAnimation is being used in a separate thread; queue a message to set the value
- PlayAfterMessage( mEventThreadServices, *mAnimation, delaySeconds );
+ PlayAfterMessage(mEventThreadServices, *mAnimation, delaySeconds);
}
void Animation::Pause()
mState = Dali::Animation::PAUSED;
// mAnimation is being used in a separate thread; queue a Pause message
- PauseAnimationMessage( mEventThreadServices, *mAnimation );
+ PauseAnimationMessage(mEventThreadServices, *mAnimation);
// Notify the objects with the _paused_, i.e. current values
- NotifyObjects( Notify::FORCE_CURRENT_VALUE );
+ NotifyObjects(Notify::FORCE_CURRENT_VALUE);
}
Dali::Animation::State Animation::GetState() const
mState = Dali::Animation::STOPPED;
// mAnimation is being used in a separate thread; queue a Stop message
- StopAnimationMessage( mEventThreadServices.GetUpdateManager(), *mAnimation );
+ StopAnimationMessage(mEventThreadServices.GetUpdateManager(), *mAnimation);
// Only notify the objects with the _stopped_, i.e. current values if the end action is set to BAKE
- if( mEndAction == EndAction::BAKE )
+ if(mEndAction == EndAction::BAKE)
{
- NotifyObjects( Notify::USE_CURRENT_VALUE );
+ NotifyObjects(Notify::USE_CURRENT_VALUE);
}
}
DALI_ASSERT_DEBUG(mAnimation);
// Only notify the objects with the current values if the end action is set to BAKE
- if( mEndAction == EndAction::BAKE )
+ if(mEndAction == EndAction::BAKE)
{
- NotifyObjects( Notify::USE_CURRENT_VALUE );
+ NotifyObjects(Notify::USE_CURRENT_VALUE);
}
// Remove all the connectors
mNotificationCount = 0;
// Update the current playlist
- mPlaylist.OnClear( *this );
+ mPlaylist.OnClear(*this);
}
void Animation::AnimateBy(Property& target, Property::Value relativeValue)
void Animation::AnimateBy(Property& target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
{
- Object& object = GetImplementation(target.object);
- const Property::Type propertyType = object.GetPropertyType( target.propertyIndex );
+ Object& object = GetImplementation(target.object);
+ const Property::Type propertyType = object.GetPropertyType(target.propertyIndex);
const Property::Type destinationType = relativeValue.GetType();
// validate animation parameters, if component index is set then use float as checked type
- ValidateParameters( (target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? propertyType : Property::FLOAT,
- destinationType, period );
+ ValidateParameters((target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? propertyType : Property::FLOAT,
+ destinationType,
+ period);
ExtendDuration(period);
auto connectorIndex = mConnectors.Count();
// using destination type so component animation gets correct type
- switch ( destinationType )
+ switch(destinationType)
{
case Property::BOOLEAN:
{
void Animation::AnimateTo(Property& target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
{
- Object& object = GetImplementation( target.object );
- const Property::Type propertyType = object.GetPropertyType( target.propertyIndex );
+ Object& object = GetImplementation(target.object);
+ const Property::Type propertyType = object.GetPropertyType(target.propertyIndex);
const Property::Type destinationType = destinationValue.GetType();
// validate animation parameters, if component index is set then use float as checked type
- ValidateParameters( (target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? propertyType : Property::FLOAT,
- destinationType, period );
+ ValidateParameters((target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? propertyType : Property::FLOAT,
+ destinationType,
+ period);
- ExtendDuration( period );
+ ExtendDuration(period);
// keep the current count.
auto connectorIndex = mConnectors.Count();
// using destination type so component animation gets correct type
- switch ( destinationType )
+ switch(destinationType)
{
case Property::BOOLEAN:
{
mConnectorTargetValues.push_back({std::move(destinationValue), period, connectorIndex, Animation::TO});
}
-void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames )
+void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames)
{
- AnimateBetween( target, keyFrames, mDefaultAlpha, TimePeriod(mDurationSeconds), DEFAULT_INTERPOLATION );
+ AnimateBetween(target, keyFrames, mDefaultAlpha, TimePeriod(mDurationSeconds), DEFAULT_INTERPOLATION);
}
-void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, Interpolation interpolation )
+void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, Interpolation interpolation)
{
- AnimateBetween( target, keyFrames, mDefaultAlpha, TimePeriod(mDurationSeconds), interpolation );
+ AnimateBetween(target, keyFrames, mDefaultAlpha, TimePeriod(mDurationSeconds), interpolation);
}
-void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, TimePeriod period )
+void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period)
{
- AnimateBetween( target, keyFrames, mDefaultAlpha, period, DEFAULT_INTERPOLATION );
+ AnimateBetween(target, keyFrames, mDefaultAlpha, period, DEFAULT_INTERPOLATION);
}
-void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation )
+void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation)
{
- AnimateBetween( target, keyFrames, mDefaultAlpha, period, interpolation );
+ AnimateBetween(target, keyFrames, mDefaultAlpha, period, interpolation);
}
-void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, AlphaFunction alpha )
+void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha)
{
- AnimateBetween( target, keyFrames, alpha, TimePeriod(mDurationSeconds), DEFAULT_INTERPOLATION );
+ AnimateBetween(target, keyFrames, alpha, TimePeriod(mDurationSeconds), DEFAULT_INTERPOLATION);
}
-void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation )
+void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation)
{
- AnimateBetween( target, keyFrames, alpha, TimePeriod(mDurationSeconds), interpolation );
+ AnimateBetween(target, keyFrames, alpha, TimePeriod(mDurationSeconds), interpolation);
}
-void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period )
+void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
{
- AnimateBetween( target, keyFrames, alpha, period, DEFAULT_INTERPOLATION );
+ AnimateBetween(target, keyFrames, alpha, period, DEFAULT_INTERPOLATION);
}
-void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation )
+void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
{
- Object& object = GetImplementation( target.object );
- const Property::Type propertyType = object.GetPropertyType( target.propertyIndex );
+ Object& object = GetImplementation(target.object);
+ const Property::Type propertyType = object.GetPropertyType(target.propertyIndex);
const Property::Type destinationType = keyFrames.GetType();
// validate animation parameters, if component index is set then use float as checked type
- ValidateParameters( (target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? propertyType : Property::FLOAT,
- destinationType, period );
+ ValidateParameters((target.componentIndex == Property::INVALID_COMPONENT_INDEX) ? propertyType : Property::FLOAT,
+ destinationType,
+ period);
- ExtendDuration( period );
+ ExtendDuration(period);
// Store data to later notify the object that its property is being animated
mConnectorTargetValues.push_back({keyFrames.GetLastKeyFrameValue(), period, mConnectors.Count(), BETWEEN});
// using destination type so component animation gets correct type
- switch( destinationType )
+ switch(destinationType)
{
case Dali::Property::BOOLEAN:
{
bool Animation::HasFinished()
{
- bool hasFinished(false);
+ bool hasFinished(false);
const int32_t playedCount(mAnimation->GetPlayedCount());
// If the play count has been incremented, then another notification is required
mCurrentLoop = mAnimation->GetCurrentLoop();
- if (playedCount > mNotificationCount)
+ if(playedCount > mNotificationCount)
{
// Note that only one signal is emitted, if the animation has been played repeatedly
mNotificationCount = playedCount;
void Animation::EmitSignalFinish()
{
- if ( !mFinishedSignal.Empty() )
+ if(!mFinishedSignal.Empty())
{
- Dali::Animation handle( this );
- mFinishedSignal.Emit( handle );
+ Dali::Animation handle(this);
+ mFinishedSignal.Emit(handle);
}
}
void Animation::EmitSignalProgressReached()
{
- if ( !mProgressReachedSignal.Empty() )
+ if(!mProgressReachedSignal.Empty())
{
- Dali::Animation handle( this );
- mProgressReachedSignal.Emit( handle );
+ Dali::Animation handle(this);
+ mProgressReachedSignal.Emit(handle);
}
}
-bool Animation::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool Animation::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( false );
- Animation* animation = static_cast< Animation* >(object); // TypeRegistry guarantees that this is the correct type.
+ bool connected(false);
+ Animation* animation = static_cast<Animation*>(object); // TypeRegistry guarantees that this is the correct type.
if(SIGNAL_FINISHED == signalName)
{
- animation->FinishedSignal().Connect( tracker, functor );
+ animation->FinishedSignal().Connect(tracker, functor);
connected = true;
}
return connected;
}
-void Animation::AddAnimatorConnector( AnimatorConnectorBase* connector )
+void Animation::AddAnimatorConnector(AnimatorConnectorBase* connector)
{
- DALI_ASSERT_DEBUG( NULL != connector );
+ DALI_ASSERT_DEBUG(NULL != connector);
connector->SetParent(*this);
- mConnectors.PushBack( connector );
+ mConnectors.PushBack(connector);
}
-void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward )
+void Animation::Animate(Actor& actor, const Path& path, const Vector3& forward)
{
- Animate( actor, path, forward, mDefaultAlpha, TimePeriod(mDurationSeconds) );
+ Animate(actor, path, forward, mDefaultAlpha, TimePeriod(mDurationSeconds));
}
-void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha )
+void Animation::Animate(Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha)
{
- Animate( actor, path, forward, alpha, TimePeriod(mDurationSeconds) );
+ Animate(actor, path, forward, alpha, TimePeriod(mDurationSeconds));
}
-void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, TimePeriod period )
+void Animation::Animate(Actor& actor, const Path& path, const Vector3& forward, TimePeriod period)
{
- Animate( actor, path, forward, mDefaultAlpha, period );
+ Animate(actor, path, forward, mDefaultAlpha, period);
}
-void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
+void Animation::Animate(Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
{
- ExtendDuration( period );
+ ExtendDuration(period);
PathPtr pathCopy = Path::Clone(path);
period));
//If forward is zero, PathRotationFunctor will always return the unit quaternion
- if( forward != Vector3::ZERO )
+ if(forward != Vector3::ZERO)
{
//Rotation animation
AddAnimatorConnector(AnimatorConnector<Quaternion>::New(actor,
void Animation::Show(Actor& actor, float delaySeconds)
{
- ExtendDuration( TimePeriod(delaySeconds, 0) );
+ ExtendDuration(TimePeriod(delaySeconds, 0));
AddAnimatorConnector(AnimatorConnector<bool>::New(actor,
Dali::Actor::Property::VISIBLE,
void Animation::Hide(Actor& actor, float delaySeconds)
{
- ExtendDuration( TimePeriod(delaySeconds, 0) );
+ ExtendDuration(TimePeriod(delaySeconds, 0));
AddAnimatorConnector(AnimatorConnector<bool>::New(actor,
Dali::Actor::Property::VISIBLE,
TimePeriod(delaySeconds, 0.0f /*immediate*/)));
}
-bool Animation::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
+bool Animation::DoAction(BaseObject* object, const std::string& actionName, const Property::Map& attributes)
{
- bool done = false;
- Animation* animation = dynamic_cast<Animation*>( object );
+ bool done = false;
+ Animation* animation = dynamic_cast<Animation*>(object);
- if( animation )
+ if(animation)
{
std::string_view name(actionName);
if(name == ACTION_PLAY)
{
- if( Property::Value* value = attributes.Find("duration", Property::FLOAT) )
+ if(Property::Value* value = attributes.Find("duration", Property::FLOAT))
{
- animation->SetDuration( value->Get<float>() );
+ animation->SetDuration(value->Get<float>());
}
animation->Play();
void Animation::SetCurrentProgress(float progress)
{
- if( mAnimation && progress >= mPlayRange.x && progress <= mPlayRange.y )
+ if(mAnimation && progress >= mPlayRange.x && progress <= mPlayRange.y)
{
// mAnimation is being used in a separate thread; queue a message to set the current progress
- SetCurrentProgressMessage( mEventThreadServices, *mAnimation, progress );
+ SetCurrentProgressMessage(mEventThreadServices, *mAnimation, progress);
}
}
float Animation::GetCurrentProgress()
{
float progress = 0.f;
- if( mAnimation ) // always exists in practice
+ if(mAnimation) // always exists in practice
{
progress = mAnimation->GetCurrentProgress();
}
return progress;
}
-void Animation::ExtendDuration( const TimePeriod& timePeriod )
+void Animation::ExtendDuration(const TimePeriod& timePeriod)
{
float duration = timePeriod.delaySeconds + timePeriod.durationSeconds;
- if( duration > mDurationSeconds )
+ if(duration > mDurationSeconds)
{
- SetDuration( duration );
+ SetDuration(duration);
}
}
-void Animation::SetSpeedFactor( float factor )
+void Animation::SetSpeedFactor(float factor)
{
- if( mAnimation )
+ if(mAnimation)
{
mSpeedFactor = factor;
- SetSpeedFactorMessage( mEventThreadServices, *mAnimation, factor );
+ SetSpeedFactorMessage(mEventThreadServices, *mAnimation, factor);
}
}
return mSpeedFactor;
}
-void Animation::SetPlayRange( const Vector2& range)
+void Animation::SetPlayRange(const Vector2& range)
{
//Make sure the range specified is between 0.0 and 1.0
- if( range.x >= 0.0f && range.x <= 1.0f && range.y >= 0.0f && range.y <= 1.0f )
+ if(range.x >= 0.0f && range.x <= 1.0f && range.y >= 0.0f && range.y <= 1.0f)
{
- Vector2 orderedRange( range );
+ Vector2 orderedRange(range);
//If the range is not in order swap values
- if( range.x > range.y )
+ if(range.x > range.y)
{
orderedRange = Vector2(range.y, range.x);
}
mPlayRange = orderedRange;
// mAnimation is being used in a separate thread; queue a message to set play range
- SetPlayRangeMessage( mEventThreadServices, *mAnimation, orderedRange );
+ SetPlayRangeMessage(mEventThreadServices, *mAnimation, orderedRange);
}
}
return mPlayRange;
}
-void Animation::SetLoopingMode( Dali::Animation::LoopingMode loopingMode )
+void Animation::SetLoopingMode(Dali::Animation::LoopingMode loopingMode)
{
- mAutoReverseEnabled = ( loopingMode == Dali::Animation::LoopingMode::AUTO_REVERSE );
+ mAutoReverseEnabled = (loopingMode == Dali::Animation::LoopingMode::AUTO_REVERSE);
// mAnimation is being used in a separate thread; queue a message to set play range
- SetLoopingModeMessage( mEventThreadServices, *mAnimation, mAutoReverseEnabled );
+ SetLoopingModeMessage(mEventThreadServices, *mAnimation, mAutoReverseEnabled);
}
Dali::Animation::LoopingMode Animation::GetLoopingMode() const
return mAutoReverseEnabled ? Dali::Animation::AUTO_REVERSE : Dali::Animation::RESTART;
}
-bool Animation::CompareConnectorEndTimes( const Animation::ConnectorTargetValues& lhs, const Animation::ConnectorTargetValues& rhs )
+bool Animation::CompareConnectorEndTimes(const Animation::ConnectorTargetValues& lhs, const Animation::ConnectorTargetValues& rhs)
{
- return ( ( lhs.timePeriod.delaySeconds + lhs.timePeriod.durationSeconds ) < ( rhs.timePeriod.delaySeconds + rhs.timePeriod.durationSeconds ) );
+ return ((lhs.timePeriod.delaySeconds + lhs.timePeriod.durationSeconds) < (rhs.timePeriod.delaySeconds + rhs.timePeriod.durationSeconds));
}
-void Animation::NotifyObjects( Animation::Notify notifyValueType )
+void Animation::NotifyObjects(Animation::Notify notifyValueType)
{
// If the animation is discarded, then we do not want to change the target values unless we want to force the current values
- if( mEndAction != EndAction::DISCARD || notifyValueType == Notify::FORCE_CURRENT_VALUE )
+ if(mEndAction != EndAction::DISCARD || notifyValueType == Notify::FORCE_CURRENT_VALUE)
{
// Sort according to end time with earlier end times coming first, if the end time is the same, then the connectors are not moved
// Only do this if we're using the target value
- if( notifyValueType == Notify::USE_TARGET_VALUE )
+ if(notifyValueType == Notify::USE_TARGET_VALUE)
{
- std::stable_sort( mConnectorTargetValues.begin(), mConnectorTargetValues.end(), CompareConnectorEndTimes );
+ std::stable_sort(mConnectorTargetValues.begin(), mConnectorTargetValues.end(), CompareConnectorEndTimes);
}
// Loop through all connector target values sorted by increasing end time
- ConnectorTargetValuesContainer::const_iterator iter = mConnectorTargetValues.begin();
+ ConnectorTargetValuesContainer::const_iterator iter = mConnectorTargetValues.begin();
const ConnectorTargetValuesContainer::const_iterator endIter = mConnectorTargetValues.end();
- for( ; iter != endIter; ++iter )
+ for(; iter != endIter; ++iter)
{
- AnimatorConnectorBase* connector = mConnectors[ iter->connectorIndex ];
+ AnimatorConnectorBase* connector = mConnectors[iter->connectorIndex];
Object* object = connector->GetObject();
if(object && object->IsAnimationPossible())
object->NotifyPropertyAnimation(
*this,
propertyIndex,
- ( notifyValueType == Notify::USE_TARGET_VALUE ) ? iter->targetValue : object->GetCurrentProperty( propertyIndex ),
- ( notifyValueType == Notify::USE_TARGET_VALUE ) ? iter->animatorType : Animation::TO ); // If we're setting the current value, then use TO as we want to set, not adjust, the current value
+ (notifyValueType == Notify::USE_TARGET_VALUE) ? iter->targetValue : object->GetCurrentProperty(propertyIndex),
+ (notifyValueType == Notify::USE_TARGET_VALUE) ? iter->animatorType : Animation::TO); // If we're setting the current value, then use TO as we want to set, not adjust, the current value
}
}
}
}
-
void Animation::SendFinalProgressNotificationMessage()
{
- if ( mProgressReachedMarker > 0.0f )
+ if(mProgressReachedMarker > 0.0f)
{
float progressMarkerSeconds = mDurationSeconds * mProgressReachedMarker;
- SetProgressNotificationMessage( mEventThreadServices, *mAnimation, progressMarkerSeconds );
+ SetProgressNotificationMessage(mEventThreadServices, *mAnimation, progressMarkerSeconds);
}
}
#define DALI_INTERNAL_ANIMATION_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/animation/animation.h>
-#include <dali/public-api/object/base-object.h>
#include <dali/devel-api/animation/animation-devel.h>
#include <dali/devel-api/common/owner-container.h>
#include <dali/internal/event/animation/key-frames-impl.h>
#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/public-api/animation/animation.h>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/ref-object.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
class Animation;
class UpdateManager;
-}
+} // namespace SceneGraph
class Actor;
class Animation;
/**
* @copydoc Dali::DevelAnimation::SetProgressNotification()
*/
- void SetProgressNotification( float progress );
+ void SetProgressNotification(float progress);
/**
* @copydoc Dali::DevelAnimation::GetProgressNotification()
/**
* @copydoc Dali::Animation::PlayFrom()
*/
- void PlayFrom( float progress );
+ void PlayFrom(float progress);
/**
* @copydoc Dali::Animation::PlayAfter()
*/
- void PlayAfter( float delaySeconds );
+ void PlayAfter(float delaySeconds);
/**
* @copydoc Dali::Animation::Pause()
* @return True if the signal was connected.
* @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
*/
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
/**
* Performs actions as requested using the action name.
/**
* @copydoc Dali::Animation::AnimateBetween(Property target, KeyFrames& keyFrames, Interpolation interpolation)
*/
- void AnimateBetween(Property target, const KeyFrames& keyFrames, Interpolation interpolation );
+ void AnimateBetween(Property target, const KeyFrames& keyFrames, Interpolation interpolation);
/**
* @copydoc Dali::Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period)
/**
* @copydoc Dali::Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation )
*/
- void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation );
+ void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation);
// Actor-specific convenience functions
/**
* @copydoc Dali::Animation::Animate( Actor actor, Path path, const Vector3& forward )
*/
- void Animate( Actor& actor, const Path& path, const Vector3& forward );
+ void Animate(Actor& actor, const Path& path, const Vector3& forward);
/**
* @copydoc Dali::Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha )
*/
- void Animate( Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha );
+ void Animate(Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha);
/**
* @copydoc Dali::Animation::Animate( Actor actor, Path path, const Vector3& forward, TimePeriod period )
*/
- void Animate( Actor& actor, const Path& path, const Vector3& forward, TimePeriod period );
+ void Animate(Actor& actor, const Path& path, const Vector3& forward, TimePeriod period);
/**
* @copydoc Dali::Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
*/
- void Animate( Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha, TimePeriod period);
+ void Animate(Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha, TimePeriod period);
/**
* @copydoc Dali::Animation::Show()
/**
* @copydoc Dali::Animation::SetSpeedFactor()
*/
- void SetSpeedFactor( float factor );
+ void SetSpeedFactor(float factor);
/**
* @copydoc Dali::Animation::GetSpeedFactor()
/**
* @copydoc Dali::Animation::SetPlayRange()
*/
- void SetPlayRange( const Vector2& range );
+ void SetPlayRange(const Vector2& range);
/**
* @copydoc Dali::Animation::GetPlayRange()
/**
* @copydoc Dali::Animation::SetLoopingMode()
*/
- void SetLoopingMode( Dali::Animation::LoopingMode loopingMode );
+ void SetLoopingMode(Dali::Animation::LoopingMode loopingMode);
/**
* @copydoc Dali::Animation::GetLoopingMode()
Dali::Animation::LoopingMode GetLoopingMode() const;
public: // For connecting animators to animations
-
/**
* Add an animator connector.
* @param[in] connector The animator connector.
*/
- void AddAnimatorConnector( AnimatorConnectorBase* connector );
+ void AddAnimatorConnector(AnimatorConnectorBase* connector);
/**
* Retrieve the SceneGraph::Animation object.
}
protected:
-
/**
* Construct a new Animation.
* @param[in] eventThreadServices The interface for sending messages to the scene graph
* @param[in] disconnectAction The action to perform when the property owner of an animator is disconnected.
* @param[in] defaultAlpha The default alpha function to apply to animators.
*/
- Animation( EventThreadServices& eventThreadServices,
- AnimationPlaylist& playlist,
- float durationSeconds,
- EndAction endAction,
- EndAction disconnectAction,
- AlphaFunction defaultAlpha);
+ Animation(EventThreadServices& eventThreadServices,
+ AnimationPlaylist& playlist,
+ float durationSeconds,
+ EndAction endAction,
+ EndAction disconnectAction,
+ AlphaFunction defaultAlpha);
/**
* Second-phase constructor.
~Animation() override;
private:
-
/**
* Extends the duration when an animator is added with TimePeriod that exceeds current duration.
* @param[in] timePeriod The time period for an animator.
*/
- void ExtendDuration( const TimePeriod& timePeriod );
+ void ExtendDuration(const TimePeriod& timePeriod);
// Undefined
Animation(const Animation&);
Animation& operator=(const Animation& rhs);
private:
-
struct ConnectorTargetValues
{
ConnectorTargetValues() = default;
};
private:
-
/**
* Compares the end times of the animators returning true if lhs end time is less than rhs end time.
* @param[in] lhs The first comparator
* @param[in] rhs The second comparator
* @return True if end time of lhs is less, false otherwise.
*/
- static bool CompareConnectorEndTimes( const ConnectorTargetValues& lhs, const ConnectorTargetValues& rhs );
+ static bool CompareConnectorEndTimes(const ConnectorTargetValues& lhs, const ConnectorTargetValues& rhs);
/**
* Notifies all the objects whose properties are being animated.
* @param[in] notifyValueType Whether we should set the current or target value
*/
- void NotifyObjects( Notify notifyValueType );
+ void NotifyObjects(Notify notifyValueType);
/**
* Sends message to SceneGraph with final progress value
using AnimatorConnectorContainer = OwnerContainer<AnimatorConnectorBase*>;
using ConnectorTargetValuesContainer = std::vector<ConnectorTargetValues>;
- const SceneGraph::Animation* mAnimation{ nullptr };
+ const SceneGraph::Animation* mAnimation{nullptr};
EventThreadServices& mEventThreadServices;
AnimationPlaylist& mPlaylist;
inline Internal::Animation& GetImplementation(Dali::Animation& animation)
{
- DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
+ DALI_ASSERT_ALWAYS(animation && "Animation handle is empty");
BaseObject& handle = animation.GetBaseObject();
inline const Internal::Animation& GetImplementation(const Dali::Animation& animation)
{
- DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
+ DALI_ASSERT_ALWAYS(animation && "Animation handle is empty");
const BaseObject& handle = animation.GetBaseObject();
#define DALI_INTERNAL_ANIMATION_PLAYLIST_DECLARATIONS_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
class AnimationPlaylist;
using AnimationPlaylistOwner = OwnerPointer<AnimationPlaylist>;
} // namespace Dali
#endif // DALI_INTERNAL_ANIMATION_PLAYLIST_DECLARATIONS_H
-
#define DALI_INTERNAL_ANIMATOR_CONNECTOR_BASE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/animation/alpha-function.h>
-#include <dali/public-api/animation/time-period.h>
-#include <dali/public-api/common/dali-common.h>
#include <dali/internal/event/common/object-impl.h>
#include <dali/internal/update/common/property-resetter.h>
#include <dali/internal/update/manager/update-manager.h>
-
+#include <dali/public-api/animation/alpha-function.h>
+#include <dali/public-api/animation/time-period.h>
+#include <dali/public-api/common/dali-common.h>
namespace Dali
{
-
namespace Internal
{
-
class Animation;
/**
* AnimatorConnectorBase observes the proxy object, in order to detect when a scene-graph object is created
* to avoid having unnecessary animations on the scene-graph and allow apps to create animations in initialisation
*/
-class AnimatorConnectorBase: public Object::Observer
+class AnimatorConnectorBase : public Object::Observer
{
public:
-
/**
* Constructor.
*/
mPropertyIndex(propertyIndex),
mComponentIndex(componentIndex)
{
- object.AddObserver( *this );
+ object.AddObserver(*this);
}
/**
*/
~AnimatorConnectorBase() override
{
- if( mObject )
+ if(mObject)
{
- mObject->RemoveObserver( *this );
+ mObject->RemoveObserver(*this);
}
}
*/
void CreateAnimator()
{
- DALI_ASSERT_DEBUG( mAnimator == nullptr );
- DALI_ASSERT_DEBUG( mParent != nullptr );
+ DALI_ASSERT_DEBUG(mAnimator == nullptr);
+ DALI_ASSERT_DEBUG(mParent != nullptr);
//Get the PropertyOwner the animator is going to animate
const SceneGraph::PropertyOwner& propertyOwner = mObject->GetSceneObject();
// Get SceneGraph::BaseProperty
- const SceneGraph::PropertyBase* baseProperty = mObject->GetSceneObjectAnimatableProperty( mPropertyIndex );
- DALI_ASSERT_ALWAYS( baseProperty && "Property is not animatable" );
+ const SceneGraph::PropertyBase* baseProperty = mObject->GetSceneObjectAnimatableProperty(mPropertyIndex);
+ DALI_ASSERT_ALWAYS(baseProperty && "Property is not animatable");
// Check if property is a component of another property
- const int32_t componentIndex = mObject->GetPropertyComponentIndex( mPropertyIndex );
- if( componentIndex != Property::INVALID_COMPONENT_INDEX )
+ const int32_t componentIndex = mObject->GetPropertyComponentIndex(mPropertyIndex);
+ if(componentIndex != Property::INVALID_COMPONENT_INDEX)
{
mComponentIndex = componentIndex;
}
// call the type specific method to create the concrete animator
- bool resetterRequired = DoCreateAnimator( propertyOwner, *baseProperty );
+ bool resetterRequired = DoCreateAnimator(propertyOwner, *baseProperty);
- DALI_ASSERT_DEBUG( mAnimator != nullptr );
+ DALI_ASSERT_DEBUG(mAnimator != nullptr);
// Add the new SceneGraph::Animator to its correspondent SceneGraph::Animation via message
const SceneGraph::Animation* animation = mParent->GetSceneObject();
- DALI_ASSERT_DEBUG( nullptr != animation );
- AddAnimatorMessage( mParent->GetEventThreadServices(), *animation, *mAnimator );
+ DALI_ASSERT_DEBUG(nullptr != animation);
+ AddAnimatorMessage(mParent->GetEventThreadServices(), *animation, *mAnimator);
// Add the new SceneGraph::PropertyResetter to the update manager via message
- if( resetterRequired )
+ if(resetterRequired)
{
- OwnerPointer<SceneGraph::PropertyResetterBase> resetter = SceneGraph::AnimatorResetter::New( propertyOwner, *baseProperty, *mAnimator );
- AddResetterMessage( mParent->GetEventThreadServices().GetUpdateManager(), resetter );
+ OwnerPointer<SceneGraph::PropertyResetterBase> resetter = SceneGraph::AnimatorResetter::New(propertyOwner, *baseProperty, *mAnimator);
+ AddResetterMessage(mParent->GetEventThreadServices().GetUpdateManager(), resetter);
}
}
/**
* Type specific extension of animator creation
*/
- virtual bool DoCreateAnimator( const SceneGraph::PropertyOwner& propertyOwner, const SceneGraph::PropertyBase& baseProperty ) = 0;
+ virtual bool DoCreateAnimator(const SceneGraph::PropertyOwner& propertyOwner, const SceneGraph::PropertyBase& baseProperty) = 0;
/**
* Set the parent of the AnimatorConnector.
* @pre The connector does not already have a parent.
* @param [in] parent The parent object.
*/
- void SetParent( Animation& parent )
+ void SetParent(Animation& parent)
{
- DALI_ASSERT_ALWAYS( mParent == nullptr && "AnimationConnector already has a parent" );
+ DALI_ASSERT_ALWAYS(mParent == nullptr && "AnimationConnector already has a parent");
mParent = &parent;
- if( mObject )
+ if(mObject)
{
CreateAnimator();
}
}
private:
-
/**
* From Object::Observer
*/
- void SceneObjectAdded( Object& object ) final
+ void SceneObjectAdded(Object& object) final
{
// If the animator has not been created yet, create it now.
- if( !mAnimator && mObject )
+ if(!mAnimator && mObject)
{
CreateAnimator();
}
/**
* From Object::Observer
*/
- void SceneObjectRemoved( Object& object ) final
+ void SceneObjectRemoved(Object& object) final
{
}
/**
* From Object::Observer
*/
- void ObjectDestroyed( Object& object ) override
+ void ObjectDestroyed(Object& object) override
{
mObject = nullptr;
}
#define DALI_INTERNAL_ANIMATOR_CONNECTOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <functional>
// INTERNAL INCLUDES
-#include <dali/internal/event/animation/animator-connector-base.h>
#include <dali/internal/event/animation/animation-impl.h>
-#include <dali/internal/update/common/property-owner.h>
+#include <dali/internal/event/animation/animator-connector-base.h>
#include <dali/internal/update/animation/property-accessor.h>
#include <dali/internal/update/animation/property-component-accessor.h>
+#include <dali/internal/update/common/property-owner.h>
namespace Dali
{
-
namespace Internal
{
-
/**
* AnimatorConnector is used to connect SceneGraph::Animators.
*
* Therefore the AnimatorConnector is NOT responsible for disconnecting animators.
* This is the common template for non float properties, there's a specialization for float properties as they can be component properties
*/
-template < typename PropertyType >
+template<typename PropertyType>
class AnimatorConnector : public AnimatorConnectorBase
{
using AnimatorFunction = std::function<PropertyType(float, const PropertyType&)>;
AnimatorFunction mAnimatorFunction;
public:
-
- using AnimatorType = SceneGraph::Animator< PropertyType, PropertyAccessor<PropertyType> >;
- using PropertyInterfaceType = SceneGraph::AnimatableProperty< PropertyType >;
+ using AnimatorType = SceneGraph::Animator<PropertyType, PropertyAccessor<PropertyType> >;
+ using PropertyInterfaceType = SceneGraph::AnimatableProperty<PropertyType>;
/**
* Construct a new animator connector.
~AnimatorConnector() override = default;
private:
-
/**
* Private constructor; see also AnimatorConnector::New().
*/
}
// Undefined
- AnimatorConnector() = delete;
- AnimatorConnector( const AnimatorConnector& ) = delete;
- AnimatorConnector& operator=( const AnimatorConnector& rhs ) = delete;
+ AnimatorConnector() = delete;
+ AnimatorConnector(const AnimatorConnector&) = delete;
+ AnimatorConnector& operator=(const AnimatorConnector& rhs) = delete;
/**
* @copydoc AnimatorConnectorBase::DoCreateAnimator()
*/
- bool DoCreateAnimator( const SceneGraph::PropertyOwner& propertyOwner, const SceneGraph::PropertyBase& baseProperty ) final
+ bool DoCreateAnimator(const SceneGraph::PropertyOwner& propertyOwner, const SceneGraph::PropertyBase& baseProperty) final
{
bool resetterRequired = false;
// components only supported for float property type
- DALI_ASSERT_DEBUG( mComponentIndex == Property::INVALID_COMPONENT_INDEX );
+ DALI_ASSERT_DEBUG(mComponentIndex == Property::INVALID_COMPONENT_INDEX);
// Animating the whole property
// Cast to AnimatableProperty
- const PropertyInterfaceType* animatableProperty = dynamic_cast< const PropertyInterfaceType* >( &baseProperty );
+ const PropertyInterfaceType* animatableProperty = dynamic_cast<const PropertyInterfaceType*>(&baseProperty);
- if( animatableProperty == nullptr )
+ if(animatableProperty == nullptr)
{
- if( baseProperty.IsTransformManagerProperty() )
+ if(baseProperty.IsTransformManagerProperty())
{
mAnimator = SceneGraph::AnimatorTransformProperty<PropertyType, TransformManagerPropertyAccessor<PropertyType> >::New(propertyOwner,
baseProperty,
}
else
{
- DALI_ASSERT_DEBUG( animatableProperty && "Animating non-animatable property" );
+ DALI_ASSERT_DEBUG(animatableProperty && "Animating non-animatable property");
}
}
else
/**
* Specialization for float as that type supports component properties
*/
-template <>
-class AnimatorConnector< float > : public AnimatorConnectorBase
+template<>
+class AnimatorConnector<float> : public AnimatorConnectorBase
{
using AnimatorFunction = std::function<float(float, const float&)>;
AnimatorFunction mAnimatorFunction;
public:
-
- using AnimatorType = SceneGraph::Animator< float, PropertyAccessor<float> >;
- using PropertyInterfaceType = SceneGraph::AnimatableProperty< float >;
+ using AnimatorType = SceneGraph::Animator<float, PropertyAccessor<float> >;
+ using PropertyInterfaceType = SceneGraph::AnimatableProperty<float>;
/**
* Construct a new animator connector.
~AnimatorConnector() override = default;
private:
-
/**
* Private constructor; see also AnimatorConnector::New().
*/
}
// Undefined
- AnimatorConnector() = delete;
- AnimatorConnector( const AnimatorConnector& ) = delete;
- AnimatorConnector& operator=( const AnimatorConnector& rhs ) = delete;
+ AnimatorConnector() = delete;
+ AnimatorConnector(const AnimatorConnector&) = delete;
+ AnimatorConnector& operator=(const AnimatorConnector& rhs) = delete;
/**
* @copydoc AnimatorConnectorBase::DoCreateAnimator()
*/
- bool DoCreateAnimator( const SceneGraph::PropertyOwner& propertyOwner, const SceneGraph::PropertyBase& baseProperty ) final
+ bool DoCreateAnimator(const SceneGraph::PropertyOwner& propertyOwner, const SceneGraph::PropertyBase& baseProperty) final
{
bool resetterRequired = false;
- if( mComponentIndex == Property::INVALID_COMPONENT_INDEX )
+ if(mComponentIndex == Property::INVALID_COMPONENT_INDEX)
{
// Animating the whole property
// Cast to AnimatableProperty
- const PropertyInterfaceType* animatableProperty = dynamic_cast< const PropertyInterfaceType* >( &baseProperty );
+ const PropertyInterfaceType* animatableProperty = dynamic_cast<const PropertyInterfaceType*>(&baseProperty);
- if( animatableProperty == nullptr )
+ if(animatableProperty == nullptr)
{
- if( baseProperty.IsTransformManagerProperty() )
+ if(baseProperty.IsTransformManagerProperty())
{
mAnimator = SceneGraph::AnimatorTransformProperty<float, TransformManagerPropertyAccessor<float> >::New(propertyOwner,
baseProperty,
}
else
{
- DALI_ASSERT_DEBUG( animatableProperty && "Animating non-animatable property" );
+ DALI_ASSERT_DEBUG(animatableProperty && "Animating non-animatable property");
}
}
else
{
{
// Animating a component of the property
- if ( PropertyTypes::Get< Vector2 >() == baseProperty.GetType() )
+ if(PropertyTypes::Get<Vector2>() == baseProperty.GetType())
{
// Animate float component of Vector2 property
// Cast to AnimatableProperty of type Vector2
- const SceneGraph::AnimatableProperty<Vector2>* animatableProperty = dynamic_cast< const SceneGraph::AnimatableProperty<Vector2>* >( &baseProperty );
- DALI_ASSERT_DEBUG( animatableProperty && "Animating non-animatable property" );
+ const SceneGraph::AnimatableProperty<Vector2>* animatableProperty = dynamic_cast<const SceneGraph::AnimatableProperty<Vector2>*>(&baseProperty);
+ DALI_ASSERT_DEBUG(animatableProperty && "Animating non-animatable property");
- switch( mComponentIndex )
+ switch(mComponentIndex)
{
case 0:
{
}
}
- resetterRequired = ( mAnimator != nullptr );
+ resetterRequired = (mAnimator != nullptr);
}
- else if ( PropertyTypes::Get< Vector3 >() == baseProperty.GetType() )
+ else if(PropertyTypes::Get<Vector3>() == baseProperty.GetType())
{
// Animate float component of Vector3 property
// Cast to AnimatableProperty of type Vector3
- const SceneGraph::AnimatableProperty<Vector3>* animatableProperty = dynamic_cast< const SceneGraph::AnimatableProperty<Vector3>* >( &baseProperty );
+ const SceneGraph::AnimatableProperty<Vector3>* animatableProperty = dynamic_cast<const SceneGraph::AnimatableProperty<Vector3>*>(&baseProperty);
- if( animatableProperty == nullptr )
+ if(animatableProperty == nullptr)
{
- if( baseProperty.IsTransformManagerProperty() )
+ if(baseProperty.IsTransformManagerProperty())
{
- if( mComponentIndex == 0 )
+ if(mComponentIndex == 0)
{
mAnimator = SceneGraph::AnimatorTransformProperty<float, TransformManagerPropertyComponentAccessor<Vector3, 0> >::New(propertyOwner,
baseProperty,
mAlphaFunction,
mTimePeriod);
}
- else if( mComponentIndex == 1 )
+ else if(mComponentIndex == 1)
{
mAnimator = SceneGraph::AnimatorTransformProperty<float, TransformManagerPropertyComponentAccessor<Vector3, 1> >::New(propertyOwner,
baseProperty,
mAlphaFunction,
mTimePeriod);
}
- else if( mComponentIndex == 2 )
+ else if(mComponentIndex == 2)
{
mAnimator = SceneGraph::AnimatorTransformProperty<float, TransformManagerPropertyComponentAccessor<Vector3, 2> >::New(propertyOwner,
baseProperty,
}
else
{
- DALI_ASSERT_DEBUG( animatableProperty && "Animating non-animatable property" );
+ DALI_ASSERT_DEBUG(animatableProperty && "Animating non-animatable property");
}
// Don't manually reset transform property - TransformManager will do it more efficiently
}
else
{
// Dynamic cast will fail if BaseProperty is not a Vector3 AnimatableProperty
- DALI_ASSERT_DEBUG( animatableProperty && "Animating non-animatable property" );
+ DALI_ASSERT_DEBUG(animatableProperty && "Animating non-animatable property");
- switch( mComponentIndex )
+ switch(mComponentIndex)
{
case 0:
{
}
}
- resetterRequired = ( mAnimator != nullptr );
+ resetterRequired = (mAnimator != nullptr);
}
}
- else if ( PropertyTypes::Get< Vector4 >() == baseProperty.GetType() )
+ else if(PropertyTypes::Get<Vector4>() == baseProperty.GetType())
{
// Animate float component of Vector4 property
// Cast to AnimatableProperty of type Vector4
- const SceneGraph::AnimatableProperty<Vector4>* animatableProperty = dynamic_cast< const SceneGraph::AnimatableProperty<Vector4>* >( &baseProperty );
+ const SceneGraph::AnimatableProperty<Vector4>* animatableProperty = dynamic_cast<const SceneGraph::AnimatableProperty<Vector4>*>(&baseProperty);
//Dynamic cast will fail if BaseProperty is not a Vector4 AnimatableProperty
- DALI_ASSERT_DEBUG( animatableProperty && "Animating non-animatable property" );
+ DALI_ASSERT_DEBUG(animatableProperty && "Animating non-animatable property");
- switch( mComponentIndex )
+ switch(mComponentIndex)
{
case 0:
{
break;
}
}
- resetterRequired = ( mAnimator != nullptr );
+ resetterRequired = (mAnimator != nullptr);
}
}
}
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
Constrainer::Constrainer()
-:Object( nullptr ) // we don't have our own scene object
+: Object(nullptr) // we don't have our own scene object
{
}
Constrainer::~Constrainer()
{
//Remove all the constraints created by the object
- uint32_t tag = static_cast<uint32_t>( reinterpret_cast<uintptr_t>( this ) ); // taking 32bits of this as tag
+ uint32_t tag = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(this)); // taking 32bits of this as tag
const ObjectIter end = mObservedObjects.End();
- for( ObjectIter iter = mObservedObjects.Begin(); iter != end; ++iter )
+ for(ObjectIter iter = mObservedObjects.Begin(); iter != end; ++iter)
{
//Remove Constrainer from the observers list of the object
- (*iter)->RemoveObserver( *this );
+ (*iter)->RemoveObserver(*this);
//Remove constraints
- (*iter)->RemoveConstraints( tag );
+ (*iter)->RemoveConstraints(tag);
}
}
-void Constrainer::ObjectDestroyed( Object& object )
+void Constrainer::ObjectDestroyed(Object& object)
{
//Remove object from the list of observed
const ObjectIter end = mObservedObjects.End();
- for( ObjectIter iter = mObservedObjects.Begin(); iter != end; ++iter )
+ for(ObjectIter iter = mObservedObjects.Begin(); iter != end; ++iter)
{
- if( *iter == &object )
+ if(*iter == &object)
{
mObservedObjects.Erase(iter);
return;
}
}
-void Constrainer::Remove( Dali::Handle& target )
+void Constrainer::Remove(Dali::Handle& target)
{
- uint32_t tag = static_cast<uint32_t>( reinterpret_cast<uintptr_t>( this ) ); // taking 32bits of this as tag
- Object& object = GetImplementation(target);
- const ObjectIter end = mObservedObjects.End();
- for( ObjectIter iter = mObservedObjects.Begin(); iter != end; ++iter )
+ uint32_t tag = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(this)); // taking 32bits of this as tag
+ Object& object = GetImplementation(target);
+ const ObjectIter end = mObservedObjects.End();
+ for(ObjectIter iter = mObservedObjects.Begin(); iter != end; ++iter)
{
- if( *iter == &object )
+ if(*iter == &object)
{
//Stop observing the object
- (*iter)->RemoveObserver( *this );
+ (*iter)->RemoveObserver(*this);
//Remove constraints created in the object
- target.RemoveConstraints( tag );
+ target.RemoveConstraints(tag);
//Remove object from the vector of observed objects
mObservedObjects.Erase(iter);
}
}
-void Constrainer::Observe( Dali::Handle& handle )
+void Constrainer::Observe(Dali::Handle& handle)
{
Object& object = GetImplementation(handle);
//Add the object to the list of observed objects if it is not in it already
- const ObjectIter end = mObservedObjects.End();
- ObjectIter iter = mObservedObjects.Begin();
- for(; iter != end; ++iter )
+ const ObjectIter end = mObservedObjects.End();
+ ObjectIter iter = mObservedObjects.Begin();
+ for(; iter != end; ++iter)
{
- if( *iter == &object )
+ if(*iter == &object)
{
break;
}
}
- if( iter == end )
+ if(iter == end)
{
//Start observing the object
- object.AddObserver( *this );
+ object.AddObserver(*this);
//Add object in the observed objects vector
- mObservedObjects.PushBack( &object );
+ mObservedObjects.PushBack(&object);
}
}
} // namespace Internal
} // namespace Dali
-
#define DALI_INTERNAL_CONSTRAINER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
-typedef Dali::Vector<Object*> ObjectContainer;
+typedef Dali::Vector<Object*> ObjectContainer;
using ObjectIter = ObjectContainer::Iterator;
/**
class Constrainer : public Object, public Object::Observer
{
public:
-
/**
* Constructor.
*/
~Constrainer() override;
public: // Object::Observer methods
-
/**
* @copydoc Object::Observer::SceneObjectAdded()
*/
- void SceneObjectAdded( Object& object ) override{}
+ void SceneObjectAdded(Object& object) override
+ {
+ }
/**
* @copydoc Object::Observer::SceneObjectRemoved()
*/
- void SceneObjectRemoved( Object& object ) override{}
+ void SceneObjectRemoved(Object& object) override
+ {
+ }
/**
* @copydoc Object::Observer::ObjectDestroyed()
*/
- void ObjectDestroyed( Object& object ) override;
+ void ObjectDestroyed(Object& object) override;
public:
-
/**
* @brief Applies the constraint to the target property
* @param[in] range The range of values in the source property which will be mapped to [0,1]
* @param[in] wrap Wrapping domain. Source property will be wrapped in the domain [wrap.x,wrap.y] before mapping to [0,1]
*/
- virtual void Apply( Property target, Property source, const Vector2& range, const Vector2& wrap) = 0;
+ virtual void Apply(Property target, Property source, const Vector2& range, const Vector2& wrap) = 0;
/**
* @brief Removes the constraint in the target object
*
* @param[in] target A handle to an object constrained by the Constrainer
*/
- void Remove( Dali::Handle& target );
+ void Remove(Dali::Handle& target);
protected:
-
/**
* @brief Adds an object to the list of observed objects
*
* @param[in] handle A handle to the object to be observed
*/
- void Observe( Dali::Handle& handle );
+ void Observe(Dali::Handle& handle);
private:
-
- ObjectContainer mObservedObjects; ///< The list of object which have been constrained by the Constrainer
+ ObjectContainer mObservedObjects; ///< The list of object which have been constrained by the Constrainer
};
} // namespace Internal
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/animation/constraint-base.h>
// INTERNAL INCLUDES
-#include <dali/public-api/object/handle.h>
-#include <dali/public-api/object/type-registry.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/event/common/property-helper.h>
#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/update/animation/scene-graph-constraint-base.h>
#include <dali/internal/update/common/animatable-property.h>
#include <dali/internal/update/common/property-owner-messages.h>
+#include <dali/public-api/object/handle.h>
+#include <dali/public-api/object/type-registry.h>
using Dali::Internal::SceneGraph::AnimatableProperty;
namespace Dali
{
-
namespace Internal
{
-
namespace
{
/**
* @param propertyOwners to add the entries to
* @param object to add
*/
-inline void AddUnique( SceneGraph::PropertyOwnerContainer& propertyOwners, SceneGraph::PropertyOwner* object )
+inline void AddUnique(SceneGraph::PropertyOwnerContainer& propertyOwners, SceneGraph::PropertyOwner* object)
{
- const SceneGraph::PropertyOwnerIter iter = std::find( propertyOwners.Begin(), propertyOwners.End(), object );
- if( iter == propertyOwners.End() )
+ const SceneGraph::PropertyOwnerIter iter = std::find(propertyOwners.Begin(), propertyOwners.End(), object);
+ if(iter == propertyOwners.End())
{
// each owner should only be added once
- propertyOwners.PushBack( object );
+ propertyOwners.PushBack(object);
}
}
} // unnamed namespace
-ConstraintBase::ConstraintBase( Object& object, Property::Index targetPropertyIndex, SourceContainer& sources )
-: mEventThreadServices( EventThreadServices::Get() ),
- mTargetObject( &object ),
- mSceneGraphConstraint( nullptr ),
- mSources( sources ),
+ConstraintBase::ConstraintBase(Object& object, Property::Index targetPropertyIndex, SourceContainer& sources)
+: mEventThreadServices(EventThreadServices::Get()),
+ mTargetObject(&object),
+ mSceneGraphConstraint(nullptr),
+ mSources(sources),
mObservedObjects(),
- mTargetPropertyIndex( targetPropertyIndex ),
- mRemoveAction( Dali::Constraint::DEFAULT_REMOVE_ACTION ),
- mTag( 0 ),
- mApplied( false ),
- mSourceDestroyed( false )
+ mTargetPropertyIndex(targetPropertyIndex),
+ mRemoveAction(Dali::Constraint::DEFAULT_REMOVE_ACTION),
+ mTag(0),
+ mApplied(false),
+ mSourceDestroyed(false)
{
- ObserveObject( object );
+ ObserveObject(object);
}
-ConstraintBase* ConstraintBase::Clone( Object& object )
+ConstraintBase* ConstraintBase::Clone(Object& object)
{
- DALI_ASSERT_ALWAYS( !mSourceDestroyed && "An input source object has been destroyed" );
+ DALI_ASSERT_ALWAYS(!mSourceDestroyed && "An input source object has been destroyed");
// create the type specific object
- ConstraintBase* clone = DoClone( object );
- clone->SetRemoveAction( mRemoveAction );
- clone->SetTag( mTag );
+ ConstraintBase* clone = DoClone(object);
+ clone->SetRemoveAction(mRemoveAction);
+ clone->SetTag(mTag);
return clone;
}
RemoveInternal();
}
-void ConstraintBase::AddSource( Source source )
+void ConstraintBase::AddSource(Source source)
{
- mSources.push_back( source );
+ mSources.push_back(source);
// Observe the object providing this property
- if ( OBJECT_PROPERTY == source.sourceType )
+ if(OBJECT_PROPERTY == source.sourceType)
{
- if ( source.object != nullptr )
+ if(source.object != nullptr)
{
- ObserveObject( *source.object );
+ ObserveObject(*source.object);
}
else
{
- DALI_LOG_ERROR( "Constraint source object not found\n" );
+ DALI_LOG_ERROR("Constraint source object not found\n");
}
}
}
void ConstraintBase::Apply()
{
- if ( mTargetObject && !mApplied && !mSourceDestroyed )
+ if(mTargetObject && !mApplied && !mSourceDestroyed)
{
mApplied = true;
ConnectConstraint();
- mTargetObject->ApplyConstraint( *this );
+ mTargetObject->ApplyConstraint(*this);
}
}
{
RemoveInternal();
- if( mTargetObject )
+ if(mTargetObject)
{
- mTargetObject->RemoveConstraint( *this );
+ mTargetObject->RemoveConstraint(*this);
}
}
void ConstraintBase::RemoveInternal()
{
- if ( mApplied )
+ if(mApplied)
{
mApplied = false;
// Guard against constraint sending messages during core destruction
- if( Stage::IsInstalled() )
+ if(Stage::IsInstalled())
{
- if( mTargetObject && mSceneGraphConstraint )
+ if(mTargetObject && mSceneGraphConstraint)
{
- const SceneGraph::PropertyOwner& propertyOwner = mTargetObject->GetSceneObject();
+ const SceneGraph::PropertyOwner& propertyOwner = mTargetObject->GetSceneObject();
// Remove from scene-graph
- RemoveConstraintMessage( GetEventThreadServices(), propertyOwner, *(mSceneGraphConstraint) );
+ RemoveConstraintMessage(GetEventThreadServices(), propertyOwner, *(mSceneGraphConstraint));
// mSceneGraphConstraint will be deleted in update-thread, remove dangling pointer
mSceneGraphConstraint = nullptr;
}
Dali::Handle ConstraintBase::GetTargetObject()
{
- return Dali::Handle( mTargetObject );
+ return Dali::Handle(mTargetObject);
}
Property::Index ConstraintBase::GetTargetProperty()
return mTargetPropertyIndex;
}
-void ConstraintBase::SetRemoveAction( ConstraintBase::RemoveAction action )
+void ConstraintBase::SetRemoveAction(ConstraintBase::RemoveAction action)
{
mRemoveAction = action;
}
return mRemoveAction;
}
-void ConstraintBase::SetTag( uint32_t tag )
+void ConstraintBase::SetTag(uint32_t tag)
{
mTag = tag;
}
return mTag;
}
-void ConstraintBase::SceneObjectAdded( Object& object )
+void ConstraintBase::SceneObjectAdded(Object& object)
{
- if ( mApplied &&
- ( nullptr == mSceneGraphConstraint ) &&
- mTargetObject )
+ if(mApplied &&
+ (nullptr == mSceneGraphConstraint) &&
+ mTargetObject)
{
ConnectConstraint();
}
}
-void ConstraintBase::SceneObjectRemoved( Object& object )
+void ConstraintBase::SceneObjectRemoved(Object& object)
{
- if ( mSceneGraphConstraint )
+ if(mSceneGraphConstraint)
{
// An input property owning source has been deleted, need to tell the scene-graph-constraint owner to remove it
- if ( &object != mTargetObject )
+ if(&object != mTargetObject)
{
- if( mTargetObject )
+ if(mTargetObject)
{
const SceneGraph::PropertyOwner& propertyOwner = mTargetObject->GetSceneObject();
// Remove from scene-graph
- RemoveConstraintMessage( GetEventThreadServices(), propertyOwner, *(mSceneGraphConstraint) );
+ RemoveConstraintMessage(GetEventThreadServices(), propertyOwner, *(mSceneGraphConstraint));
}
}
}
}
-void ConstraintBase::ObjectDestroyed( Object& object )
+void ConstraintBase::ObjectDestroyed(Object& object)
{
// Remove object pointer from observation set
- ObjectIter iter = std::find( mObservedObjects.Begin(), mObservedObjects.End(), &object );
- DALI_ASSERT_DEBUG( mObservedObjects.End() != iter );
- mObservedObjects.Erase( iter );
+ ObjectIter iter = std::find(mObservedObjects.Begin(), mObservedObjects.End(), &object);
+ DALI_ASSERT_DEBUG(mObservedObjects.End() != iter);
+ mObservedObjects.Erase(iter);
// Constraint is not useful anymore as an input-source has been destroyed
mSourceDestroyed = true;
// Discard all object & scene-graph pointers
mSceneGraphConstraint = nullptr;
- mTargetObject = nullptr;
+ mTargetObject = nullptr;
}
-void ConstraintBase::ObserveObject( Object& object )
+void ConstraintBase::ObserveObject(Object& object)
{
- ObjectIter iter = std::find( mObservedObjects.Begin(), mObservedObjects.End(), &object );
- if ( mObservedObjects.End() == iter )
+ ObjectIter iter = std::find(mObservedObjects.Begin(), mObservedObjects.End(), &object);
+ if(mObservedObjects.End() == iter)
{
- object.AddObserver( *this );
- mObservedObjects.PushBack( &object );
+ object.AddObserver(*this);
+ mObservedObjects.PushBack(&object);
}
}
void ConstraintBase::StopObservation()
{
const ObjectIter end = mObservedObjects.End();
- for( ObjectIter iter = mObservedObjects.Begin(); iter != end; ++iter )
+ for(ObjectIter iter = mObservedObjects.Begin(); iter != end; ++iter)
{
- (*iter)->RemoveObserver( *this );
+ (*iter)->RemoveObserver(*this);
}
mObservedObjects.Clear();
}
-PropertyInputImpl* ConstraintBase::AddInputProperty( Source& source, SceneGraph::PropertyOwnerContainer& propertyOwners, int32_t& componentIndex )
+PropertyInputImpl* ConstraintBase::AddInputProperty(Source& source, SceneGraph::PropertyOwnerContainer& propertyOwners, int32_t& componentIndex)
{
PropertyInputImpl* inputProperty = nullptr;
- if ( OBJECT_PROPERTY == source.sourceType )
+ if(OBJECT_PROPERTY == source.sourceType)
{
- DALI_ASSERT_ALWAYS( source.object->IsPropertyAConstraintInput( source.propertyIndex ) );
+ DALI_ASSERT_ALWAYS(source.object->IsPropertyAConstraintInput(source.propertyIndex));
- SceneGraph::PropertyOwner& owner = const_cast< SceneGraph::PropertyOwner& >( source.object->GetSceneObject() );
+ SceneGraph::PropertyOwner& owner = const_cast<SceneGraph::PropertyOwner&>(source.object->GetSceneObject());
- AddUnique( propertyOwners, &owner );
- inputProperty = const_cast< PropertyInputImpl* >( source.object->GetSceneObjectInputProperty( source.propertyIndex ) );
- componentIndex = source.object->GetPropertyComponentIndex( source.propertyIndex );
+ AddUnique(propertyOwners, &owner);
+ inputProperty = const_cast<PropertyInputImpl*>(source.object->GetSceneObjectInputProperty(source.propertyIndex));
+ componentIndex = source.object->GetPropertyComponentIndex(source.propertyIndex);
// The scene-object property should exist, when the property owner exists
- DALI_ASSERT_ALWAYS( inputProperty && "Constraint source property does not exist" );
+ DALI_ASSERT_ALWAYS(inputProperty && "Constraint source property does not exist");
}
- else if ( LOCAL_PROPERTY == source.sourceType )
+ else if(LOCAL_PROPERTY == source.sourceType)
{
- DALI_ASSERT_ALWAYS( mTargetObject->IsPropertyAConstraintInput( source.propertyIndex ) );
+ DALI_ASSERT_ALWAYS(mTargetObject->IsPropertyAConstraintInput(source.propertyIndex));
- inputProperty = const_cast< PropertyInputImpl* >( mTargetObject->GetSceneObjectInputProperty( source.propertyIndex ) );
- componentIndex = mTargetObject->GetPropertyComponentIndex( source.propertyIndex );
+ inputProperty = const_cast<PropertyInputImpl*>(mTargetObject->GetSceneObjectInputProperty(source.propertyIndex));
+ componentIndex = mTargetObject->GetPropertyComponentIndex(source.propertyIndex);
// The target scene-object should provide this property
- DALI_ASSERT_ALWAYS( inputProperty && "Constraint source property does not exist" );
+ DALI_ASSERT_ALWAYS(inputProperty && "Constraint source property does not exist");
}
else
{
- DALI_ASSERT_ALWAYS( PARENT_PROPERTY == source.sourceType && "Constraint source property type is invalid" );
+ DALI_ASSERT_ALWAYS(PARENT_PROPERTY == source.sourceType && "Constraint source property type is invalid");
- Object* objectParent = dynamic_cast< Actor& >( *mTargetObject ).GetParent();
+ Object* objectParent = dynamic_cast<Actor&>(*mTargetObject).GetParent();
// This will not exist, if the target object is off-stage
- if ( objectParent )
+ if(objectParent)
{
- DALI_ASSERT_ALWAYS( objectParent->IsPropertyAConstraintInput( source.propertyIndex ) );
+ DALI_ASSERT_ALWAYS(objectParent->IsPropertyAConstraintInput(source.propertyIndex));
- SceneGraph::PropertyOwner& owner = const_cast< SceneGraph::PropertyOwner& >( objectParent->GetSceneObject() );
+ SceneGraph::PropertyOwner& owner = const_cast<SceneGraph::PropertyOwner&>(objectParent->GetSceneObject());
- AddUnique( propertyOwners, &owner );
- inputProperty = const_cast< PropertyInputImpl* >( objectParent->GetSceneObjectInputProperty( source.propertyIndex ) );
- componentIndex = objectParent->GetPropertyComponentIndex( source.propertyIndex );
+ AddUnique(propertyOwners, &owner);
+ inputProperty = const_cast<PropertyInputImpl*>(objectParent->GetSceneObjectInputProperty(source.propertyIndex));
+ componentIndex = objectParent->GetPropertyComponentIndex(source.propertyIndex);
// The scene-object property should exist, when the property owner exists
- DALI_ASSERT_ALWAYS( inputProperty && "Constraint source property does not exist" );
+ DALI_ASSERT_ALWAYS(inputProperty && "Constraint source property does not exist");
}
}
return inputProperty;
}
-
} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_ACTIVE_CONSTRAINT_BASE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/animation/constraint.h>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/object/base-object.h>
#include <dali/internal/common/owner-pointer.h>
#include <dali/internal/event/animation/constraint-source-impl.h>
#include <dali/internal/update/animation/scene-graph-constraint-base.h>
+#include <dali/public-api/animation/constraint.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/object/base-object.h>
namespace Dali
{
-
namespace Internal
{
-
class EventThreadServices;
class Object;
using ObjectContainer = Dali::Vector<Object*>;
{
class ConstraintBase;
-template <typename T>
+template<typename T>
class AnimatableProperty;
-}
+} // namespace SceneGraph
/**
* An abstract base class for active constraints.
* @param[in] targetPropertyIndex The index of the property being constrained.
* @param[in] sources The sources of the input properties.
*/
- ConstraintBase( Object& object, Property::Index targetPropertyIndex, SourceContainer& sources );
+ ConstraintBase(Object& object, Property::Index targetPropertyIndex, SourceContainer& sources);
/**
* Clone this constraint for another object.
* @param[in] object The object to clone this constraint for
* @return A new constraint.
*/
- ConstraintBase* Clone( Object& object );
+ ConstraintBase* Clone(Object& object);
/**
* Virtual destructor.
*
* @param[in] source The constraint source input to add
*/
- void AddSource( Source source );
+ void AddSource(Source source);
/**
* @copydoc Dali::Constraint::Apply()
/**
* @copydoc Dali::Constraint::SetTag()
*/
- void SetTag( uint32_t tag );
+ void SetTag(uint32_t tag);
/**
* @copydoc Dali::Constraint::GetTag()
uint32_t GetTag() const;
private: // Object::Observer methods
-
/**
* @copydoc Object::Observer::SceneObjectAdded()
*/
- void SceneObjectAdded( Object& object ) override;
+ void SceneObjectAdded(Object& object) override;
/**
* @copydoc Object::Observer::SceneObjectRemoved()
*/
- void SceneObjectRemoved( Object& object ) override;
+ void SceneObjectRemoved(Object& object) override;
/**
* @copydoc Object::Observer::ObjectDestroyed()
*/
- void ObjectDestroyed( Object& object ) override;
+ void ObjectDestroyed(Object& object) override;
private:
-
/**
* Helper to observe an object, if not already observing it
*/
- void ObserveObject( Object& object );
+ void ObserveObject(Object& object);
/**
* Helper to stop observing objects
* @param object to clone to
* @return pointer to the clone
*/
- virtual ConstraintBase* DoClone( Object& object ) = 0;
+ virtual ConstraintBase* DoClone(Object& object) = 0;
/**
* Connect the constraint
virtual void ConnectConstraint() = 0;
protected:
-
/**
* Helper to Add an input property to the container of property owners
* @param source constraint[in] source used to determine the type and locate the property on the object
* @param componentIndex[out] component index
* @return pointer to input property if it was found, nullptr otherwise
*/
- PropertyInputImpl* AddInputProperty( Source& source, SceneGraph::PropertyOwnerContainer& propertyOwners, int32_t& componentIndex );
+ PropertyInputImpl* AddInputProperty(Source& source, SceneGraph::PropertyOwnerContainer& propertyOwners, int32_t& componentIndex);
/**
* Get the event thread services object - used for sending messages to the scene graph
*/
inline EventThreadServices& GetEventThreadServices()
{
- DALI_ASSERT_DEBUG( EventThreadServices::IsCoreRunning() );
+ DALI_ASSERT_DEBUG(EventThreadServices::IsCoreRunning());
return mEventThreadServices;
}
*/
inline const EventThreadServices& GetEventThreadServices() const
{
- DALI_ASSERT_DEBUG( EventThreadServices::IsCoreRunning() );
+ DALI_ASSERT_DEBUG(EventThreadServices::IsCoreRunning());
return mEventThreadServices;
}
protected:
- EventThreadServices& mEventThreadServices;
- Object* mTargetObject; ///< The object owns the constraint.
+ EventThreadServices& mEventThreadServices;
+ Object* mTargetObject; ///< The object owns the constraint.
const SceneGraph::ConstraintBase* mSceneGraphConstraint;
- SourceContainer mSources;
- ObjectContainer mObservedObjects; // We don't observe the same object twice
- Property::Index mTargetPropertyIndex;
- RemoveAction mRemoveAction;
- uint32_t mTag;
- bool mApplied:1; ///< Whether the constraint has been applied
- bool mSourceDestroyed:1; ///< Is set to true if any of our input source objects are destroyed
+ SourceContainer mSources;
+ ObjectContainer mObservedObjects; // We don't observe the same object twice
+ Property::Index mTargetPropertyIndex;
+ RemoveAction mRemoveAction;
+ uint32_t mTag;
+ bool mApplied : 1; ///< Whether the constraint has been applied
+ bool mSourceDestroyed : 1; ///< Is set to true if any of our input source objects are destroyed
};
} // namespace Internal
inline Internal::ConstraintBase& GetImplementation(Dali::Constraint& constraint)
{
- DALI_ASSERT_ALWAYS( constraint && "Constraint handle is empty" );
+ DALI_ASSERT_ALWAYS(constraint && "Constraint handle is empty");
BaseObject& handle = constraint.GetBaseObject();
inline const Internal::ConstraintBase& GetImplementation(const Dali::Constraint& constraint)
{
- DALI_ASSERT_ALWAYS( constraint && "Constraint handle is empty" );
+ DALI_ASSERT_ALWAYS(constraint && "Constraint handle is empty");
const BaseObject& handle = constraint.GetBaseObject();
#define DALI_INTERNAL_ACTIVE_CONSTRAINT_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/common/message.h>
-#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/event/common/object-impl.h>
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/event/animation/constraint-base.h>
#include <dali/internal/event/animation/constraint-source-impl.h>
#include <dali/internal/event/animation/property-constraint-ptr.h>
+#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/event/common/object-impl.h>
+#include <dali/internal/event/common/stage-impl.h>
+#include <dali/internal/event/common/thread-local-storage.h>
+#include <dali/internal/update/animation/property-accessor.h>
+#include <dali/internal/update/animation/property-component-accessor.h>
+#include <dali/internal/update/animation/scene-graph-constraint.h>
#include <dali/internal/update/common/animatable-property.h>
-#include <dali/internal/update/common/property-owner.h>
#include <dali/internal/update/common/property-owner-messages.h>
+#include <dali/internal/update/common/property-owner.h>
#include <dali/internal/update/common/property-resetter.h>
-#include <dali/internal/update/animation/scene-graph-constraint.h>
-#include <dali/internal/update/animation/property-accessor.h>
-#include <dali/internal/update/animation/property-component-accessor.h>
#include <memory>
namespace Dali
{
-
namespace Internal
{
-
/**
* Connects a constraint which takes another property as an input.
*/
-template < typename PropertyType >
+template<typename PropertyType>
class Constraint : public ConstraintBase
{
public:
-
using ConstraintFunctionPtr = typename PropertyConstraintPtr<PropertyType>::Type;
/**
* @param[in] func The constraint function.
* @return A newly allocated active-constraint.
*/
- static ConstraintBase* New( Object& object,
- Property::Index targetIndex,
- SourceContainer& sources,
- ConstraintFunctionPtr func )
+ static ConstraintBase* New(Object& object,
+ Property::Index targetIndex,
+ SourceContainer& sources,
+ ConstraintFunctionPtr func)
{
- return new Constraint( object, targetIndex, sources, func );
+ return new Constraint(object, targetIndex, sources, func);
}
/**
}
private:
-
/**
* @copydoc ConstraintBase::DoClone()
*/
- ConstraintBase* DoClone( Object& object ) final
+ ConstraintBase* DoClone(Object& object) final
{
- ConstraintFunctionPtr funcPtr( mUserFunction->Clone() );
- return new Constraint( object,
- mTargetPropertyIndex,
- mSources,
- funcPtr );
+ ConstraintFunctionPtr funcPtr(mUserFunction->Clone());
+ return new Constraint(object,
+ mTargetPropertyIndex,
+ mSources,
+ funcPtr);
}
/**
* Private constructor; see also Constraint::New().
*/
- Constraint( Object& object,
- Property::Index targetIndex,
- SourceContainer& sources,
- ConstraintFunctionPtr& func )
- : ConstraintBase( object, targetIndex, sources ),
- mUserFunction( func )
+ Constraint(Object& object,
+ Property::Index targetIndex,
+ SourceContainer& sources,
+ ConstraintFunctionPtr& func)
+ : ConstraintBase(object, targetIndex, sources),
+ mUserFunction(func)
{
}
// Undefined
- Constraint() = delete;
- Constraint( const Constraint& ) = delete;
- Constraint& operator=( const Constraint& rhs ) = delete;
-
+ Constraint() = delete;
+ Constraint(const Constraint&) = delete;
+ Constraint& operator=(const Constraint& rhs) = delete;
/**
* @copydoc ConstraintBase::ConnectConstraint()
void ConnectConstraint() final
{
// Should not come here if target object has been destroyed
- DALI_ASSERT_DEBUG( nullptr != mTargetObject );
+ DALI_ASSERT_DEBUG(nullptr != mTargetObject);
// Guard against double connections
- DALI_ASSERT_DEBUG( nullptr == mSceneGraphConstraint );
+ DALI_ASSERT_DEBUG(nullptr == mSceneGraphConstraint);
- SceneGraph::PropertyOwner& targetObject = const_cast< SceneGraph::PropertyOwner& >( mTargetObject->GetSceneObject() );
+ SceneGraph::PropertyOwner& targetObject = const_cast<SceneGraph::PropertyOwner&>(mTargetObject->GetSceneObject());
// Build a container of property-owners, providing the scene-graph properties
SceneGraph::PropertyOwnerContainer propertyOwners;
- propertyOwners.PushBack( &targetObject );
+ propertyOwners.PushBack(&targetObject);
// Build the constraint function; this requires a scene-graph property from each source
- ConstraintFunctionPtr func( ConnectConstraintFunction( propertyOwners ) );
+ ConstraintFunctionPtr func(ConnectConstraintFunction(propertyOwners));
- if ( func )
+ if(func)
{
OwnerPointer<SceneGraph::PropertyResetterBase> resetter;
// Create the SceneGraphConstraint and PropertyResetter, and connect them to the scene-graph
- const SceneGraph::PropertyBase* targetProperty = mTargetObject->GetSceneObjectAnimatableProperty( mTargetPropertyIndex );
- DALI_ASSERT_ALWAYS( targetProperty && "Constraint target property does not exist" );
- if( targetProperty->IsTransformManagerProperty() ) //It is a property managed by the transform manager
+ const SceneGraph::PropertyBase* targetProperty = mTargetObject->GetSceneObjectAnimatableProperty(mTargetPropertyIndex);
+ DALI_ASSERT_ALWAYS(targetProperty && "Constraint target property does not exist");
+ if(targetProperty->IsTransformManagerProperty()) //It is a property managed by the transform manager
{
// Connect the constraint
- mSceneGraphConstraint = SceneGraph::Constraint< PropertyType, TransformManagerPropertyAccessor<PropertyType> >::New( *targetProperty,
- propertyOwners,
- func,
- mRemoveAction );
+ mSceneGraphConstraint = SceneGraph::Constraint<PropertyType, TransformManagerPropertyAccessor<PropertyType> >::New(*targetProperty,
+ propertyOwners,
+ func,
+ mRemoveAction);
// Don't create a resetter for transform manager property, it's less efficient
}
- else //SceneGraph property
+ else //SceneGraph property
{
// Connect the constraint
- mSceneGraphConstraint = SceneGraph::Constraint< PropertyType, PropertyAccessor<PropertyType> >::New( *targetProperty,
- propertyOwners,
- func,
- mRemoveAction );
- resetter = SceneGraph::ConstraintResetter::New( targetObject, *targetProperty, *mSceneGraphConstraint );
+ mSceneGraphConstraint = SceneGraph::Constraint<PropertyType, PropertyAccessor<PropertyType> >::New(*targetProperty,
+ propertyOwners,
+ func,
+ mRemoveAction);
+ resetter = SceneGraph::ConstraintResetter::New(targetObject, *targetProperty, *mSceneGraphConstraint);
}
- OwnerPointer< SceneGraph::ConstraintBase > transferOwnership( const_cast< SceneGraph::ConstraintBase* >( mSceneGraphConstraint ) );
- ApplyConstraintMessage( GetEventThreadServices(), targetObject, transferOwnership );
- if( resetter )
+ OwnerPointer<SceneGraph::ConstraintBase> transferOwnership(const_cast<SceneGraph::ConstraintBase*>(mSceneGraphConstraint));
+ ApplyConstraintMessage(GetEventThreadServices(), targetObject, transferOwnership);
+ if(resetter)
{
- AddResetterMessage( GetEventThreadServices().GetUpdateManager(), resetter );
+ AddResetterMessage(GetEventThreadServices().GetUpdateManager(), resetter);
}
}
}
* @param[out] propertyOwners The container of property-owners providing the scene-graph properties.
* @return A connected constraint-function, or nullptr if the scene-graph properties are not available.
*/
- PropertyConstraint<PropertyType>* ConnectConstraintFunction( SceneGraph::PropertyOwnerContainer& propertyOwners )
+ PropertyConstraint<PropertyType>* ConnectConstraintFunction(SceneGraph::PropertyOwnerContainer& propertyOwners)
{
PropertyConstraint<PropertyType>* func = mUserFunction->Clone();
- for ( auto&& source : mSources )
+ for(auto&& source : mSources)
{
- int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
- PropertyInputImpl* inputProperty = AddInputProperty( source, propertyOwners, componentIndex );
+ int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
+ PropertyInputImpl* inputProperty = AddInputProperty(source, propertyOwners, componentIndex);
- if ( nullptr == inputProperty )
+ if(nullptr == inputProperty)
{
delete func;
func = nullptr;
break;
}
- func->AddInput( inputProperty, componentIndex );
+ func->AddInput(inputProperty, componentIndex);
}
return func;
}
protected:
-
ConstraintFunctionPtr mUserFunction;
-
};
/**
* Variant which allows float components to be constrained individually.
*/
-template <>
+template<>
class Constraint<float> : public ConstraintBase
{
public:
-
using ConstraintFunctionPtr = typename PropertyConstraintPtr<float>::Type;
/**
* @param[in] func The constraint function.
* @return A newly allocated constraint.
*/
- static ConstraintBase* New( Object& object,
- Property::Index targetIndex,
- SourceContainer& sources,
- ConstraintFunctionPtr func )
+ static ConstraintBase* New(Object& object,
+ Property::Index targetIndex,
+ SourceContainer& sources,
+ ConstraintFunctionPtr func)
{
- return new Constraint( object, targetIndex, sources, func );
+ return new Constraint(object, targetIndex, sources, func);
}
/**
}
private:
-
/**
* @copydoc ConstraintBase::DoClone()
*/
- ConstraintBase* DoClone( Object& object ) final
+ ConstraintBase* DoClone(Object& object) final
{
- ConstraintFunctionPtr funcPtr( mUserFunction->Clone() );
- return new Constraint( object,
- mTargetPropertyIndex,
- mSources,
- funcPtr );
+ ConstraintFunctionPtr funcPtr(mUserFunction->Clone());
+ return new Constraint(object,
+ mTargetPropertyIndex,
+ mSources,
+ funcPtr);
}
/**
* Private constructor; see also Constraint::New().
*/
- Constraint( Object& object,
- Property::Index targetIndex,
- SourceContainer& sources,
- ConstraintFunctionPtr& func )
- : ConstraintBase( object, targetIndex, sources ),
- mUserFunction( func )
+ Constraint(Object& object,
+ Property::Index targetIndex,
+ SourceContainer& sources,
+ ConstraintFunctionPtr& func)
+ : ConstraintBase(object, targetIndex, sources),
+ mUserFunction(func)
{
}
// Undefined
- Constraint() = delete;
- Constraint( const Constraint& ) = delete;
- Constraint& operator=( const Constraint& rhs ) = delete;
+ Constraint() = delete;
+ Constraint(const Constraint&) = delete;
+ Constraint& operator=(const Constraint& rhs) = delete;
/**
* @copydoc ConstraintBase::ConnectConstraint()
void ConnectConstraint() final
{
// Should not come here if target object has been destroyed
- DALI_ASSERT_DEBUG( nullptr != mTargetObject );
+ DALI_ASSERT_DEBUG(nullptr != mTargetObject);
// Guard against double connections
- DALI_ASSERT_DEBUG( nullptr == mSceneGraphConstraint );
+ DALI_ASSERT_DEBUG(nullptr == mSceneGraphConstraint);
- SceneGraph::PropertyOwner& targetObject = const_cast< SceneGraph::PropertyOwner& >( mTargetObject->GetSceneObject() );
+ SceneGraph::PropertyOwner& targetObject = const_cast<SceneGraph::PropertyOwner&>(mTargetObject->GetSceneObject());
// Build a container of property-owners, providing the scene-graph properties
SceneGraph::PropertyOwnerContainer propertyOwners;
- propertyOwners.PushBack( &targetObject );
+ propertyOwners.PushBack(&targetObject);
// Build the constraint function; this requires a scene-graph property from each source
- ConstraintFunctionPtr func( ConnectConstraintFunction( propertyOwners ) );
+ ConstraintFunctionPtr func(ConnectConstraintFunction(propertyOwners));
- if ( func )
+ if(func)
{
// Create the SceneGraphConstraint, and connect to the scene-graph
- bool resetterRequired = false;
- const SceneGraph::PropertyBase* targetProperty = mTargetObject->GetSceneObjectAnimatableProperty( mTargetPropertyIndex );
+ bool resetterRequired = false;
+ const SceneGraph::PropertyBase* targetProperty = mTargetObject->GetSceneObjectAnimatableProperty(mTargetPropertyIndex);
// The targetProperty should exist, when targetObject exists
- DALI_ASSERT_ALWAYS( nullptr != targetProperty && "Constraint target property does not exist" );
- const int32_t componentIndex = mTargetObject->GetPropertyComponentIndex( mTargetPropertyIndex );
- if ( Property::INVALID_COMPONENT_INDEX == componentIndex )
+ DALI_ASSERT_ALWAYS(nullptr != targetProperty && "Constraint target property does not exist");
+ const int32_t componentIndex = mTargetObject->GetPropertyComponentIndex(mTargetPropertyIndex);
+ if(Property::INVALID_COMPONENT_INDEX == componentIndex)
{
// Not a Vector2, Vector3 or Vector4 component, expecting float type
- DALI_ASSERT_DEBUG( PropertyTypes::Get< float >() == targetProperty->GetType() );
+ DALI_ASSERT_DEBUG(PropertyTypes::Get<float>() == targetProperty->GetType());
- mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyAccessor<float> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
- resetterRequired = true;
+ mSceneGraphConstraint = SceneGraph::Constraint<float, PropertyAccessor<float> >::New(*targetProperty, propertyOwners, func, mRemoveAction);
+ resetterRequired = true;
}
else
{
// Expecting Vector2, Vector3 or Vector4 type
- if ( PropertyTypes::Get< Vector2 >() == targetProperty->GetType() )
+ if(PropertyTypes::Get<Vector2>() == targetProperty->GetType())
{
// Constrain float component of Vector2 property
- if ( 0 == componentIndex )
+ if(0 == componentIndex)
{
- mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorX<Vector2> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
+ mSceneGraphConstraint = SceneGraph::Constraint<float, PropertyComponentAccessorX<Vector2> >::New(*targetProperty, propertyOwners, func, mRemoveAction);
}
- else if ( 1 == componentIndex )
+ else if(1 == componentIndex)
{
- mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorY<Vector2> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
+ mSceneGraphConstraint = SceneGraph::Constraint<float, PropertyComponentAccessorY<Vector2> >::New(*targetProperty, propertyOwners, func, mRemoveAction);
}
resetterRequired = (mSceneGraphConstraint != nullptr);
}
- else if ( PropertyTypes::Get< Vector3 >() == targetProperty->GetType() )
+ else if(PropertyTypes::Get<Vector3>() == targetProperty->GetType())
{
// Constrain float component of Vector3 property
- if( targetProperty->IsTransformManagerProperty() )
+ if(targetProperty->IsTransformManagerProperty())
{
- if ( 0 == componentIndex )
+ if(0 == componentIndex)
{
- mSceneGraphConstraint = SceneGraph::Constraint< float, TransformManagerPropertyComponentAccessor<Vector3,0> >::New( *targetProperty,
- propertyOwners,
- func,
- mRemoveAction );
+ mSceneGraphConstraint = SceneGraph::Constraint<float, TransformManagerPropertyComponentAccessor<Vector3, 0> >::New(*targetProperty,
+ propertyOwners,
+ func,
+ mRemoveAction);
}
- else if ( 1 == componentIndex )
+ else if(1 == componentIndex)
{
- mSceneGraphConstraint = SceneGraph::Constraint< float, TransformManagerPropertyComponentAccessor<Vector3,1> >::New( *targetProperty,
- propertyOwners,
- func,
- mRemoveAction );
+ mSceneGraphConstraint = SceneGraph::Constraint<float, TransformManagerPropertyComponentAccessor<Vector3, 1> >::New(*targetProperty,
+ propertyOwners,
+ func,
+ mRemoveAction);
}
- else if ( 2 == componentIndex )
+ else if(2 == componentIndex)
{
- mSceneGraphConstraint = SceneGraph::Constraint< float, TransformManagerPropertyComponentAccessor<Vector3,2> >::New( *targetProperty,
- propertyOwners,
- func,
- mRemoveAction );
+ mSceneGraphConstraint = SceneGraph::Constraint<float, TransformManagerPropertyComponentAccessor<Vector3, 2> >::New(*targetProperty,
+ propertyOwners,
+ func,
+ mRemoveAction);
}
// Do not create a resetter for transform manager property
}
else
{
- if ( 0 == componentIndex )
+ if(0 == componentIndex)
{
- mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorX<Vector3> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
+ mSceneGraphConstraint = SceneGraph::Constraint<float, PropertyComponentAccessorX<Vector3> >::New(*targetProperty, propertyOwners, func, mRemoveAction);
}
- else if ( 1 == componentIndex )
+ else if(1 == componentIndex)
{
- mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorY<Vector3> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
+ mSceneGraphConstraint = SceneGraph::Constraint<float, PropertyComponentAccessorY<Vector3> >::New(*targetProperty, propertyOwners, func, mRemoveAction);
}
- else if ( 2 == componentIndex )
+ else if(2 == componentIndex)
{
- mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorZ<Vector3> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
+ mSceneGraphConstraint = SceneGraph::Constraint<float, PropertyComponentAccessorZ<Vector3> >::New(*targetProperty, propertyOwners, func, mRemoveAction);
}
resetterRequired = (mSceneGraphConstraint != nullptr);
}
}
- else if ( PropertyTypes::Get< Vector4 >() == targetProperty->GetType() )
+ else if(PropertyTypes::Get<Vector4>() == targetProperty->GetType())
{
// Constrain float component of Vector4 property
- if ( 0 == componentIndex )
+ if(0 == componentIndex)
{
- mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorX<Vector4> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
+ mSceneGraphConstraint = SceneGraph::Constraint<float, PropertyComponentAccessorX<Vector4> >::New(*targetProperty, propertyOwners, func, mRemoveAction);
}
- else if ( 1 == componentIndex )
+ else if(1 == componentIndex)
{
- mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorY<Vector4> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
+ mSceneGraphConstraint = SceneGraph::Constraint<float, PropertyComponentAccessorY<Vector4> >::New(*targetProperty, propertyOwners, func, mRemoveAction);
}
- else if ( 2 == componentIndex )
+ else if(2 == componentIndex)
{
- mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorZ<Vector4> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
+ mSceneGraphConstraint = SceneGraph::Constraint<float, PropertyComponentAccessorZ<Vector4> >::New(*targetProperty, propertyOwners, func, mRemoveAction);
}
- else if ( 3 == componentIndex )
+ else if(3 == componentIndex)
{
- mSceneGraphConstraint = SceneGraph::Constraint< float, PropertyComponentAccessorW<Vector4> >::New( *targetProperty, propertyOwners, func, mRemoveAction );
+ mSceneGraphConstraint = SceneGraph::Constraint<float, PropertyComponentAccessorW<Vector4> >::New(*targetProperty, propertyOwners, func, mRemoveAction);
}
resetterRequired = (mSceneGraphConstraint != nullptr);
}
}
- if( mSceneGraphConstraint )
+ if(mSceneGraphConstraint)
{
- OwnerPointer< SceneGraph::ConstraintBase > transferOwnership( const_cast< SceneGraph::ConstraintBase* >( mSceneGraphConstraint ) );
- ApplyConstraintMessage( GetEventThreadServices(), targetObject, transferOwnership );
- if( resetterRequired )
+ OwnerPointer<SceneGraph::ConstraintBase> transferOwnership(const_cast<SceneGraph::ConstraintBase*>(mSceneGraphConstraint));
+ ApplyConstraintMessage(GetEventThreadServices(), targetObject, transferOwnership);
+ if(resetterRequired)
{
- OwnerPointer<SceneGraph::PropertyResetterBase> resetter = SceneGraph::ConstraintResetter::New( targetObject, *targetProperty, *mSceneGraphConstraint );
- AddResetterMessage( GetEventThreadServices().GetUpdateManager(), resetter );
+ OwnerPointer<SceneGraph::PropertyResetterBase> resetter = SceneGraph::ConstraintResetter::New(targetObject, *targetProperty, *mSceneGraphConstraint);
+ AddResetterMessage(GetEventThreadServices().GetUpdateManager(), resetter);
}
}
}
* @param[out] propertyOwners The container of property-owners providing the scene-graph properties.
* @return A connected constraint-function, or nullptr if the scene-graph properties are not available.
*/
- PropertyConstraint<float>* ConnectConstraintFunction( SceneGraph::PropertyOwnerContainer& propertyOwners )
+ PropertyConstraint<float>* ConnectConstraintFunction(SceneGraph::PropertyOwnerContainer& propertyOwners)
{
PropertyConstraint<float>* func = mUserFunction->Clone();
- for ( auto&& source : mSources )
+ for(auto&& source : mSources)
{
- int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
- PropertyInputImpl* inputProperty = AddInputProperty( source, propertyOwners, componentIndex );
+ int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
+ PropertyInputImpl* inputProperty = AddInputProperty(source, propertyOwners, componentIndex);
- if ( nullptr == inputProperty )
+ if(nullptr == inputProperty)
{
delete func;
func = nullptr;
break;
}
- func->AddInput( inputProperty, componentIndex );
+ func->AddInput(inputProperty, componentIndex);
}
return func;
}
protected:
-
ConstraintFunctionPtr mUserFunction;
-
};
} // namespace Internal
#define DALI_INTERNAL_CONSTRAINT_SOURCE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/animation/constraint-source.h>
#include <dali/internal/event/common/object-impl.h>
+#include <dali/public-api/animation/constraint-source.h>
+#include <dali/public-api/common/vector-wrapper.h>
namespace Dali
{
-
namespace Internal
{
-
struct Source;
using SourceContainer = std::vector<Source>;
using SourceIter = SourceContainer::iterator;
* Default constructor
*/
Source()
- : sourceType( OBJECT_PROPERTY ),
- propertyIndex( Property::INVALID_INDEX ),
- object( nullptr )
+ : sourceType(OBJECT_PROPERTY),
+ propertyIndex(Property::INVALID_INDEX),
+ object(nullptr)
{
}
* The internal object is not referenced by the Internal::Source; therefore
* the owner of this object is responsible for observing the Object's lifetime.
*/
- Source( Dali::ConstraintSource& source )
- : sourceType( source.sourceType ),
- propertyIndex( source.propertyIndex ),
- object( nullptr )
+ Source(Dali::ConstraintSource& source)
+ : sourceType(source.sourceType),
+ propertyIndex(source.propertyIndex),
+ object(nullptr)
{
- if ( source.object )
+ if(source.object)
{
- object = &dynamic_cast< Object& > ( GetImplementation(source.object) );
+ object = &dynamic_cast<Object&>(GetImplementation(source.object));
}
}
#define DALI_INTERNAL_KEY_FRAME_CHANNEL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
ProgressValues mValues;
};
-} // Internal
+} // namespace Internal
} // namespace Dali
#endif // DALI_INTERNAL_KEY_FRAME_CHANNEL_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Internal
{
-
KeyFrames* KeyFrames::New()
{
return new KeyFrames();
}
default:
{
- DALI_ABORT( "Property type is not animatable" );
+ DALI_ABORT("Property type is not animatable");
break;
}
}
}
// Once we have created a type, can only add values of the same type
- DALI_ASSERT_ALWAYS( mType == value.GetType() && "Can only add values of the same type to a KeyFrame" );
+ DALI_ASSERT_ALWAYS(mType == value.GetType() && "Can only add values of the same type to a KeyFrame");
auto keyframes = mKeyFrames.get();
Property::Value value;
std::size_t noOfKeyFrames = mKeyFrames->GetNumberOfKeyFrames();
- if( noOfKeyFrames )
+ if(noOfKeyFrames)
{
- mKeyFrames->GetKeyFrameAsValue( noOfKeyFrames - 1, value );
+ mKeyFrames->GetKeyFrameAsValue(noOfKeyFrames - 1, value);
}
return value;
}
-} // Internal
-} // Dali
+} // namespace Internal
+} // namespace Dali
#define DALI_INTERNAL_KEY_FRAMES_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <memory>
// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/internal/event/animation/key-frame-channel.h>
+#include <dali/public-api/animation/alpha-function.h>
#include <dali/public-api/animation/key-frames.h>
+#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/animation/alpha-function.h>
-#include <dali/internal/event/animation/key-frame-channel.h>
namespace Dali
{
static KeyFrames* New();
private:
-
/**
* Create a specialization from the given type, and store it to the mSpec
* member variable
* @param[in] index The index of the key frame to fetch
* @param[out] value The value of the given key frame
*/
- virtual void GetKeyFrameAsValue( std::size_t index, Property::Value& value ) = 0;
+ virtual void GetKeyFrameAsValue(std::size_t index, Property::Value& value) = 0;
};
/**
/**
* @copydoc KeyFrameSpec::GetKeyFrameAsValue()
*/
- void GetKeyFrameAsValue( std::size_t index, Property::Value& value ) override
+ void GetKeyFrameAsValue(std::size_t index, Property::Value& value) override
{
value = mChannel.mValues[index].mValue;
}
return static_cast<DeriveClass>(keyFrames.GetKeyFramesBase());
}
-} // Internal
-
+} // namespace Internal
// Get impl of handle
inline Internal::KeyFrames& GetImplementation(Dali::KeyFrames& keyFrames)
{
- DALI_ASSERT_ALWAYS( keyFrames && "KeyFrames handle is empty" );
+ DALI_ASSERT_ALWAYS(keyFrames && "KeyFrames handle is empty");
Dali::RefObject& object = keyFrames.GetBaseObject();
return static_cast<Internal::KeyFrames&>(object);
}
inline const Internal::KeyFrames& GetImplementation(const Dali::KeyFrames& keyFrames)
{
- DALI_ASSERT_ALWAYS( keyFrames && "KeyFrames handle is empty" );
+ DALI_ASSERT_ALWAYS(keyFrames && "KeyFrames handle is empty");
const Dali::RefObject& object = keyFrames.GetBaseObject();
return static_cast<const Internal::KeyFrames&>(object);
}
-
-} // Dali
+} // namespace Dali
#endif // DALI_INTERNAL_KEY_FRAMES_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstring> // for strcmp
// INTERNAL INCLUDES
+#include <dali/internal/event/common/property-helper.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-array.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/internal/event/common/property-helper.h>
-
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
// Properties
// Name Type writable animatable constraint-input enum for index-checking
DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "value", ARRAY, true, false, false, Dali::LinearConstrainer::Property::VALUE )
-DALI_PROPERTY( "progress", ARRAY, true, false, false, Dali::LinearConstrainer::Property::PROGRESS )
-DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX, LinearConstrainerDefaultProperties )
+DALI_PROPERTY("value", ARRAY, true, false, false, Dali::LinearConstrainer::Property::VALUE)
+DALI_PROPERTY("progress", ARRAY, true, false, false, Dali::LinearConstrainer::Property::PROGRESS)
+DALI_PROPERTY_TABLE_END(DEFAULT_OBJECT_PROPERTY_START_INDEX, LinearConstrainerDefaultProperties)
BaseHandle Create()
{
return Dali::LinearConstrainer::New();
}
-TypeRegistration mType( typeid( Dali::LinearConstrainer ), typeid( Dali::Handle ), Create, LinearConstrainerDefaultProperties );
+TypeRegistration mType(typeid(Dali::LinearConstrainer), typeid(Dali::Handle), Create, LinearConstrainerDefaultProperties);
} //Unnamed namespace
LinearConstrainer::~LinearConstrainer() = default;
-Property::Value LinearConstrainer::GetDefaultProperty( Property::Index index ) const
+Property::Value LinearConstrainer::GetDefaultProperty(Property::Index index) const
{
- if( index == Dali::LinearConstrainer::Property::VALUE )
+ if(index == Dali::LinearConstrainer::Property::VALUE)
{
- Property::Value value( Property::ARRAY );
+ Property::Value value(Property::ARRAY);
Property::Array* array = value.GetArray();
- uint32_t count = static_cast<uint32_t>( mValue.Size() );
+ uint32_t count = static_cast<uint32_t>(mValue.Size());
- if( array )
+ if(array)
{
- array->Reserve( count );
- for( uint32_t i( 0 ); i != count; ++i )
+ array->Reserve(count);
+ for(uint32_t i(0); i != count; ++i)
{
- array->PushBack( mValue[i] );
+ array->PushBack(mValue[i]);
}
}
return value;
}
- else if( index == Dali::LinearConstrainer::Property::PROGRESS )
+ else if(index == Dali::LinearConstrainer::Property::PROGRESS)
{
- Property::Value value( Property::ARRAY );
+ Property::Value value(Property::ARRAY);
Property::Array* array = value.GetArray();
- uint32_t count = static_cast<uint32_t>( mProgress.Size() );
+ uint32_t count = static_cast<uint32_t>(mProgress.Size());
- if( array )
+ if(array)
{
- array->Reserve( count );
- for( uint32_t i( 0 ); i != count; ++i )
+ array->Reserve(count);
+ for(uint32_t i(0); i != count; ++i)
{
- array->PushBack( mProgress[i] );
+ array->PushBack(mProgress[i]);
}
}
return value;
return Property::Value();
}
-Property::Value LinearConstrainer::GetDefaultPropertyCurrentValue( Property::Index index ) const
+Property::Value LinearConstrainer::GetDefaultPropertyCurrentValue(Property::Index index) const
{
- return GetDefaultProperty( index ); // Event-side only properties
+ return GetDefaultProperty(index); // Event-side only properties
}
-void LinearConstrainer::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
+void LinearConstrainer::SetDefaultProperty(Property::Index index, const Property::Value& propertyValue)
{
const Property::Array* array = propertyValue.GetArray();
- if( array )
+ if(array)
{
- uint32_t propertyArrayCount = static_cast<uint32_t>( array->Count() );
- if( index == Dali::LinearConstrainer::Property::VALUE )
+ uint32_t propertyArrayCount = static_cast<uint32_t>(array->Count());
+ if(index == Dali::LinearConstrainer::Property::VALUE)
{
mValue.Clear(); // remove old values
- mValue.Resize( propertyArrayCount );
- for( uint32_t i(0); i != propertyArrayCount; ++i )
+ mValue.Resize(propertyArrayCount);
+ for(uint32_t i(0); i != propertyArrayCount; ++i)
{
- array->GetElementAt( i ).Get( mValue[ i ] );
+ array->GetElementAt(i).Get(mValue[i]);
}
}
- else if( index == Dali::LinearConstrainer::Property::PROGRESS )
+ else if(index == Dali::LinearConstrainer::Property::PROGRESS)
{
mProgress.Clear(); // remove old values
- mProgress.Resize( propertyArrayCount );
- for( uint32_t i(0); i != propertyArrayCount; ++i )
+ mProgress.Resize(propertyArrayCount);
+ for(uint32_t i(0); i != propertyArrayCount; ++i)
{
- array->GetElementAt( i ).Get( mProgress[ i ] );
+ array->GetElementAt(i).Get(mProgress[i]);
}
}
}
}
-void LinearConstrainer::Apply( Property target, Property source, const Vector2& range, const Vector2& wrap)
+void LinearConstrainer::Apply(Property target, Property source, const Vector2& range, const Vector2& wrap)
{
- Dali::Constraint constraint = Dali::Constraint::New<float>( target.object, target.propertyIndex, LinearConstraintFunctor( mValue, mProgress, range, wrap ) );
- constraint.AddSource( Dali::Source(source.object, source.propertyIndex ) );
+ Dali::Constraint constraint = Dali::Constraint::New<float>(target.object, target.propertyIndex, LinearConstraintFunctor(mValue, mProgress, range, wrap));
+ constraint.AddSource(Dali::Source(source.object, source.propertyIndex));
- constraint.SetTag( static_cast<uint32_t>( reinterpret_cast<uintptr_t>( this ) ) ); // taking 32bits of this as tag
- constraint.SetRemoveAction( Dali::Constraint::DISCARD );
+ constraint.SetTag(static_cast<uint32_t>(reinterpret_cast<uintptr_t>(this))); // taking 32bits of this as tag
+ constraint.SetRemoveAction(Dali::Constraint::DISCARD);
constraint.Apply();
//Start observing the object
- Observe( target.object );
+ Observe(target.object);
}
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#define DALI_INTERNAL_LINEAR_CONSTRAINER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
typedef IntrusivePtr<LinearConstrainer> LinearConstrainerPtr;
/**
*
* @note If progress is an empty vector, the values will be assumed to be equally spaced in the x-axis
*/
- LinearConstraintFunctor( Dali::Vector<float>& value, Dali::Vector<float>& progress, const Vector2& range, const Vector2& wrap )
- :mValue(value),
- mProgress(progress),
- mRange(range),
- mWrap(wrap)
- {}
+ LinearConstraintFunctor(Dali::Vector<float>& value, Dali::Vector<float>& progress, const Vector2& range, const Vector2& wrap)
+ : mValue(value),
+ mProgress(progress),
+ mRange(range),
+ mWrap(wrap)
+ {
+ }
/**
* @brief Functor operator for float properties
*
* @return The value of the linear map at the given parameter.
*/
- void operator()( float& value,
- const PropertyInputContainer& inputs)
+ void operator()(float& value,
+ const PropertyInputContainer& inputs)
{
- uint32_t valueCount = static_cast<uint32_t>( mValue.Size() );
- if( valueCount == 0 )
+ uint32_t valueCount = static_cast<uint32_t>(mValue.Size());
+ if(valueCount == 0)
{
//No values.
}
- else if(valueCount == 1 )
+ else if(valueCount == 1)
{
value = mValue[0];
}
else
{
float inputWrapped = inputs[0]->GetFloat();
- if( inputWrapped < mWrap.x || inputWrapped > mWrap.y )
+ if(inputWrapped < mWrap.x || inputWrapped > mWrap.y)
{
inputWrapped = WrapInDomain(inputWrapped, mWrap.x, mWrap.y);
}
- float t = (( inputWrapped - mRange.x ) / ( mRange.y-mRange.x ));
+ float t = ((inputWrapped - mRange.x) / (mRange.y - mRange.x));
//Find min and max values and local t between them
uint32_t min(0);
uint32_t max(0);
- float tLocal(0.0f);
- if( mProgress.Size() < valueCount )
+ float tLocal(0.0f);
+ if(mProgress.Size() < valueCount)
{
- float step = 1.0f / (static_cast<float>( valueCount ) - 1.0f);
+ float step = 1.0f / (static_cast<float>(valueCount) - 1.0f);
float tLocation = t / step;
- if( tLocation < 0 )
+ if(tLocation < 0)
{
min = 0;
max = 1;
}
- else if( tLocation >= static_cast<float>( valueCount-1 ) )
+ else if(tLocation >= static_cast<float>(valueCount - 1))
{
- min = max = valueCount-1;
+ min = max = valueCount - 1;
}
else
{
min = static_cast<uint32_t>(tLocation);
- max = min+1;
+ max = min + 1;
}
- tLocal = (t - static_cast<float>(min)*step) / step;
+ tLocal = (t - static_cast<float>(min) * step) / step;
}
else
{
- while( ( min < valueCount-1 )&&( t >= mProgress[min] ) )
+ while((min < valueCount - 1) && (t >= mProgress[min]))
{
min++;
}
min--;
- max = min+1;
+ max = min + 1;
- if( min >= valueCount-1 )
+ if(min >= valueCount - 1)
{
- min = max = valueCount-1;
- tLocal = 0.0f;
+ min = max = valueCount - 1;
+ tLocal = 0.0f;
}
else
{
- tLocal =(t - mProgress[min]) / ( mProgress[max]-mProgress[min]);
+ tLocal = (t - mProgress[min]) / (mProgress[max] - mProgress[min]);
}
}
//Linear interpolation
- value = (mValue[max]-mValue[min])*tLocal + mValue[min];
+ value = (mValue[max] - mValue[min]) * tLocal + mValue[min];
}
}
-
- Dali::Vector<float> mValue; ///< values for the linear map
- Dali::Vector<float> mProgress; ///< Progress for each of the values normalized to [0,1]
- Vector2 mRange; ///< The range of values in the input property which will be mapped to 0..1
- Vector2 mWrap; ///< Wrapping domain. Input property will be wrapped in this domain before being mapped to [0,1]
+ Dali::Vector<float> mValue; ///< values for the linear map
+ Dali::Vector<float> mProgress; ///< Progress for each of the values normalized to [0,1]
+ Vector2 mRange; ///< The range of values in the input property which will be mapped to 0..1
+ Vector2 mWrap; ///< Wrapping domain. Input property will be wrapped in this domain before being mapped to [0,1]
};
/**
class LinearConstrainer : public Constrainer
{
public:
-
/**
* Create a new LinearConstrainer
* @return A smart-pointer to the newly allocated LinearConstrainer.
static LinearConstrainer* New();
protected:
-
/**
* virtual destructor
*/
~LinearConstrainer() override;
private:
-
/**
* @copydoc Dali::Internal::Object::SetDefaultProperty()
*/
/**
* @copydoc Dali::Internal::Object::GetDefaultProperty()
*/
- Property::Value GetDefaultProperty( Property::Index index ) const override;
+ Property::Value GetDefaultProperty(Property::Index index) const override;
- /**
+ /**
* @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
*/
- Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const override;
+ Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
public:
-
/**
* @copydoc Dali::PathConstrainer::Apply
*/
- void Apply( Property target, Property source, const Vector2& range, const Vector2& wrap ) override;
+ void Apply(Property target, Property source, const Vector2& range, const Vector2& wrap) override;
private:
-
//Constructor
LinearConstrainer();
// Undefined
LinearConstrainer& operator=(const LinearConstrainer& rhs);
- Dali::Vector<float> mValue; ///< values for the linear map
- Dali::Vector<float> mProgress; ///< Progress for each of the values normalized to [0,1]
+ Dali::Vector<float> mValue; ///< values for the linear map
+ Dali::Vector<float> mProgress; ///< Progress for each of the values normalized to [0,1]
};
-} // Internal
+} // namespace Internal
// Get impl of handle
inline Internal::LinearConstrainer& GetImplementation(Dali::LinearConstrainer& linearConstrainer)
{
- DALI_ASSERT_ALWAYS( linearConstrainer && "LinearConstrainer handle is empty" );
+ DALI_ASSERT_ALWAYS(linearConstrainer && "LinearConstrainer handle is empty");
Dali::RefObject& object = linearConstrainer.GetBaseObject();
return static_cast<Internal::LinearConstrainer&>(object);
}
inline const Internal::LinearConstrainer& GetImplementation(const Dali::LinearConstrainer& linearConstrainer)
{
- DALI_ASSERT_ALWAYS( linearConstrainer && "LinearConstrainer handle is empty" );
+ DALI_ASSERT_ALWAYS(linearConstrainer && "LinearConstrainer handle is empty");
const Dali::RefObject& object = linearConstrainer.GetBaseObject();
return static_cast<const Internal::LinearConstrainer&>(object);
}
-} // Dali
+} // namespace Dali
#endif // DALI_INTERNAL_PATH_CONSTRAINER_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstring> // for strcmp
// INTERNAL INCLUDES
+#include <dali/internal/event/common/property-helper.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-array.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/internal/event/common/property-helper.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
// Properties
// Name Type writable animatable constraint-input enum for index-checking
DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "forward", VECTOR3, true, false, false, Dali::PathConstrainer::Property::FORWARD )
-DALI_PROPERTY( "points", ARRAY, true, false, false, Dali::PathConstrainer::Property::POINTS )
-DALI_PROPERTY( "controlPoints", ARRAY, true, false, false, Dali::PathConstrainer::Property::CONTROL_POINTS )
-DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX, PathConstrainerDefaultProperties )
+DALI_PROPERTY("forward", VECTOR3, true, false, false, Dali::PathConstrainer::Property::FORWARD)
+DALI_PROPERTY("points", ARRAY, true, false, false, Dali::PathConstrainer::Property::POINTS)
+DALI_PROPERTY("controlPoints", ARRAY, true, false, false, Dali::PathConstrainer::Property::CONTROL_POINTS)
+DALI_PROPERTY_TABLE_END(DEFAULT_OBJECT_PROPERTY_START_INDEX, PathConstrainerDefaultProperties)
BaseHandle Create()
{
return Dali::PathConstrainer::New();
}
-TypeRegistration mType( typeid( Dali::PathConstrainer ), typeid( Dali::Handle ), Create, PathConstrainerDefaultProperties );
+TypeRegistration mType(typeid(Dali::PathConstrainer), typeid(Dali::Handle), Create, PathConstrainerDefaultProperties);
} //Unnamed namespace
PathConstrainer::PathConstrainer()
: Constrainer(),
- mPath( Path::New() )
+ mPath(Path::New())
{
}
PathConstrainer::~PathConstrainer() = default;
-Property::Value PathConstrainer::GetDefaultProperty( Property::Index index ) const
+Property::Value PathConstrainer::GetDefaultProperty(Property::Index index) const
{
- if( index == Dali::PathConstrainer::Property::FORWARD )
+ if(index == Dali::PathConstrainer::Property::FORWARD)
{
- return Property::Value( mForward );
+ return Property::Value(mForward);
}
else
{
- if( index == Dali::PathConstrainer::Property::POINTS )
+ if(index == Dali::PathConstrainer::Property::POINTS)
{
- Property::Value value( Property::ARRAY );
- Property::Array* array = value.GetArray();
- const Dali::Vector<Vector3>& point = mPath->GetPoints();
- Property::Array::SizeType pointCount = static_cast<Property::Array::SizeType>( point.Size() );
+ Property::Value value(Property::ARRAY);
+ Property::Array* array = value.GetArray();
+ const Dali::Vector<Vector3>& point = mPath->GetPoints();
+ Property::Array::SizeType pointCount = static_cast<Property::Array::SizeType>(point.Size());
- if( array )
+ if(array)
{
- array->Reserve( pointCount );
- for( Property::Array::SizeType i = 0; i < pointCount; ++i )
+ array->Reserve(pointCount);
+ for(Property::Array::SizeType i = 0; i < pointCount; ++i)
{
- array->PushBack( point[i] );
+ array->PushBack(point[i]);
}
}
return value;
}
- else if( index == Dali::PathConstrainer::Property::CONTROL_POINTS )
+ else if(index == Dali::PathConstrainer::Property::CONTROL_POINTS)
{
- Property::Value value( Property::ARRAY );
- Property::Array* array = value.GetArray();
- const Dali::Vector<Vector3>& point = mPath->GetControlPoints();
- Property::Array::SizeType pointCount = static_cast<Property::Array::SizeType>( point.Size() );
+ Property::Value value(Property::ARRAY);
+ Property::Array* array = value.GetArray();
+ const Dali::Vector<Vector3>& point = mPath->GetControlPoints();
+ Property::Array::SizeType pointCount = static_cast<Property::Array::SizeType>(point.Size());
- if( array )
+ if(array)
{
- array->Reserve( pointCount );
- for( Property::Array::SizeType i = 0; i < pointCount; ++i )
+ array->Reserve(pointCount);
+ for(Property::Array::SizeType i = 0; i < pointCount; ++i)
{
- array->PushBack( point[i] );
+ array->PushBack(point[i]);
}
}
return value;
return Property::Value();
}
-Property::Value PathConstrainer::GetDefaultPropertyCurrentValue( Property::Index index ) const
+Property::Value PathConstrainer::GetDefaultPropertyCurrentValue(Property::Index index) const
{
- return GetDefaultProperty( index ); // Event-side only properties
+ return GetDefaultProperty(index); // Event-side only properties
}
-void PathConstrainer::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
+void PathConstrainer::SetDefaultProperty(Property::Index index, const Property::Value& propertyValue)
{
- if( index == Dali::PathConstrainer::Property::FORWARD )
+ if(index == Dali::PathConstrainer::Property::FORWARD)
{
propertyValue.Get(mForward);
}
- else if( index == Dali::PathConstrainer::Property::POINTS )
+ else if(index == Dali::PathConstrainer::Property::POINTS)
{
const Property::Array* array = propertyValue.GetArray();
mPath->ClearPoints();
- if( array )
+ if(array)
{
- for( Property::Array::SizeType i = 0, count = array->Count(); i < count; ++i )
+ for(Property::Array::SizeType i = 0, count = array->Count(); i < count; ++i)
{
Vector3 point;
- array->GetElementAt( i ).Get( point );
- mPath->AddPoint( point );
+ array->GetElementAt(i).Get(point);
+ mPath->AddPoint(point);
}
}
}
- else if( index == Dali::PathConstrainer::Property::CONTROL_POINTS )
+ else if(index == Dali::PathConstrainer::Property::CONTROL_POINTS)
{
const Property::Array* array = propertyValue.GetArray();
mPath->ClearControlPoints();
- if( array )
+ if(array)
{
- for( Property::Array::SizeType i = 0, count = array->Count(); i < count; ++i )
+ for(Property::Array::SizeType i = 0, count = array->Count(); i < count; ++i)
{
Vector3 point;
- array->GetElementAt( i ).Get( point );
- mPath->AddControlPoint( point );
+ array->GetElementAt(i).Get(point);
+ mPath->AddControlPoint(point);
}
}
}
}
-void PathConstrainer::Apply( Property target, Property source, const Vector2& range, const Vector2& wrap)
+void PathConstrainer::Apply(Property target, Property source, const Vector2& range, const Vector2& wrap)
{
- Dali::Property::Type propertyType = target.object.GetPropertyType( target.propertyIndex);
- if( propertyType == Dali::Property::VECTOR3)
+ Dali::Property::Type propertyType = target.object.GetPropertyType(target.propertyIndex);
+ if(propertyType == Dali::Property::VECTOR3)
{
// If property type is Vector3, constrain its value to the position of the path
- Dali::Constraint constraint = Dali::Constraint::New<Vector3>( target.object, target.propertyIndex, PathConstraintFunctor( mPath, range, wrap ) );
- constraint.AddSource( Dali::Source(source.object, source.propertyIndex ) );
+ Dali::Constraint constraint = Dali::Constraint::New<Vector3>(target.object, target.propertyIndex, PathConstraintFunctor(mPath, range, wrap));
+ constraint.AddSource(Dali::Source(source.object, source.propertyIndex));
- constraint.SetTag( static_cast<uint32_t>( reinterpret_cast<uintptr_t>( this ) ) ); // taking 32bits of this as tag
- constraint.SetRemoveAction( Dali::Constraint::DISCARD );
+ constraint.SetTag(static_cast<uint32_t>(reinterpret_cast<uintptr_t>(this))); // taking 32bits of this as tag
+ constraint.SetRemoveAction(Dali::Constraint::DISCARD);
constraint.Apply();
}
- else if( propertyType == Dali::Property::ROTATION )
+ else if(propertyType == Dali::Property::ROTATION)
{
// If property type is Rotation, constrain its value to align the forward vector to the tangent of the path
- Dali::Constraint constraint = Dali::Constraint::New<Quaternion>( target.object, target.propertyIndex, PathConstraintFunctor( mPath, range, mForward, wrap) );
- constraint.AddSource( Dali::Source(source.object, source.propertyIndex ) );
+ Dali::Constraint constraint = Dali::Constraint::New<Quaternion>(target.object, target.propertyIndex, PathConstraintFunctor(mPath, range, mForward, wrap));
+ constraint.AddSource(Dali::Source(source.object, source.propertyIndex));
- constraint.SetTag( static_cast<uint32_t>( reinterpret_cast<uintptr_t>( this ) ) ); // taking 32bits of this as tag
- constraint.SetRemoveAction( Dali::Constraint::DISCARD );
+ constraint.SetTag(static_cast<uint32_t>(reinterpret_cast<uintptr_t>(this))); // taking 32bits of this as tag
+ constraint.SetRemoveAction(Dali::Constraint::DISCARD);
constraint.Apply();
}
//Start observing the object
- Observe( target.object );
+ Observe(target.object);
}
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#define DALI_INTERNAL_PATH_CONSTRAINER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/animation/constrainer.h>
#include <dali/devel-api/animation/path-constrainer.h>
-#include <dali/public-api/math/math-utils.h>
+#include <dali/internal/event/animation/constrainer.h>
#include <dali/internal/event/animation/path-impl.h>
+#include <dali/public-api/math/math-utils.h>
namespace Dali
{
-
namespace Internal
{
-
typedef IntrusivePtr<PathConstrainer> PathConstrainerPtr;
/**
* @param[in] range The range of values in the input property which will be mapped to [0,1]
* @param[in] wrap Wrapping domain. Input property value will be wrapped in the domain [wrap.x,wrap.y] before mapping to [0,1]
*/
- PathConstraintFunctor(PathPtr path, const Vector2& range, const Vector2& wrap ):mPath(path),mRange(range),mWrap(wrap){}
+ PathConstraintFunctor(PathPtr path, const Vector2& range, const Vector2& wrap)
+ : mPath(path),
+ mRange(range),
+ mWrap(wrap)
+ {
+ }
/**
* @brief Constructor.
* @param[in] forward Vector in object space which will be aligned with the tangent of the path
* @param[in] wrap Wrapping domain. Input property value will be wrapped in the domain [wrap.x,wrap.y] before mapping to [0,1]
*/
- PathConstraintFunctor(PathPtr path, const Vector2& range,const Vector3& forward, const Vector2& wrap ):mPath(path),mForward(forward),mRange(range),mWrap(wrap){}
+ PathConstraintFunctor(PathPtr path, const Vector2& range, const Vector3& forward, const Vector2& wrap)
+ : mPath(path),
+ mForward(forward),
+ mRange(range),
+ mWrap(wrap)
+ {
+ }
/**
* @brief Functor operator for Vector3 properties
*
* @return The position of the path at the given parameter.
*/
- void operator()( Vector3& position,
- const PropertyInputContainer& inputs)
+ void operator()(Vector3& position,
+ const PropertyInputContainer& inputs)
{
float inputWrapped = inputs[0]->GetFloat();
- if( inputWrapped < mWrap.x || inputWrapped > mWrap.y )
+ if(inputWrapped < mWrap.x || inputWrapped > mWrap.y)
{
inputWrapped = WrapInDomain(inputWrapped, mWrap.x, mWrap.y);
}
- float t = ( inputWrapped - mRange.x ) / ( mRange.y-mRange.x );
+ float t = (inputWrapped - mRange.x) / (mRange.y - mRange.x);
Vector3 tangent;
- mPath->Sample( t, position, tangent );
+ mPath->Sample(t, position, tangent);
}
/**
*
* @return The rotation which will align the forward vector and the tangent of the path at the given parameter.
*/
- void operator()( Quaternion& current,
- const PropertyInputContainer& inputs)
+ void operator()(Quaternion& current,
+ const PropertyInputContainer& inputs)
{
float inputWrapped = inputs[0]->GetFloat();
- if( inputWrapped < mWrap.x || inputWrapped > mWrap.y )
+ if(inputWrapped < mWrap.x || inputWrapped > mWrap.y)
{
inputWrapped = WrapInDomain(inputWrapped, mWrap.x, mWrap.y);
}
- float t = ( inputWrapped - mRange.x ) / ( mRange.y-mRange.x );
+ float t = (inputWrapped - mRange.x) / (mRange.y - mRange.x);
Vector3 position, tangent;
- mPath->Sample( t, position, tangent );
- current = Quaternion( mForward, tangent );
+ mPath->Sample(t, position, tangent);
+ current = Quaternion(mForward, tangent);
}
- PathPtr mPath; ///< The path used
- Vector3 mForward; ///< Vector in object space which will be aligned with the tangent of the path
- Vector2 mRange; ///< The range of values in the input property which will be mapped to 0..1
- Vector2 mWrap; ///< Wrapping domain. Input property will be wrapped in this domain before being mapped to [0,1]
+ PathPtr mPath; ///< The path used
+ Vector3 mForward; ///< Vector in object space which will be aligned with the tangent of the path
+ Vector2 mRange; ///< The range of values in the input property which will be mapped to 0..1
+ Vector2 mWrap; ///< Wrapping domain. Input property will be wrapped in this domain before being mapped to [0,1]
};
/**
class PathConstrainer : public Constrainer
{
public:
-
/**
* Create a new PathConstrainer
* @return A smart-pointer to the newly allocated PathConstrainer.
static PathConstrainer* New();
protected:
-
/**
* virtual destructor
*/
~PathConstrainer() override;
private:
-
/**
* @copydoc Dali::Internal::Object::SetDefaultProperty()
*/
/**
* @copydoc Dali::Internal::Object::GetDefaultProperty()
*/
- Property::Value GetDefaultProperty( Property::Index index ) const override;
+ Property::Value GetDefaultProperty(Property::Index index) const override;
- /**
+ /**
* @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
*/
- Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const override;
+ Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
public:
-
/**
* @copydoc Dali::PathConstrainer::Apply
*/
- void Apply( Property target, Property source, const Vector2& range, const Vector2& wrap ) override;
+ void Apply(Property target, Property source, const Vector2& range, const Vector2& wrap) override;
private:
-
//Constructor
PathConstrainer();
Vector3 mForward; ///< Vector in object space which will be aligned with the tangent of the path
};
-} // Internal
+} // namespace Internal
// Get impl of handle
inline Internal::PathConstrainer& GetImplementation(Dali::PathConstrainer& pathConstrainer)
{
- DALI_ASSERT_ALWAYS( pathConstrainer && "PathConstrainer handle is empty" );
+ DALI_ASSERT_ALWAYS(pathConstrainer && "PathConstrainer handle is empty");
Dali::RefObject& object = pathConstrainer.GetBaseObject();
return static_cast<Internal::PathConstrainer&>(object);
}
inline const Internal::PathConstrainer& GetImplementation(const Dali::PathConstrainer& pathConstrainer)
{
- DALI_ASSERT_ALWAYS( pathConstrainer && "PathConstrainer handle is empty" );
+ DALI_ASSERT_ALWAYS(pathConstrainer && "PathConstrainer handle is empty");
const Dali::RefObject& object = pathConstrainer.GetBaseObject();
return static_cast<const Internal::PathConstrainer&>(object);
}
-} // Dali
+} // namespace Dali
#endif // DALI_INTERNAL_PATH_CONSTRAINER_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstring> // for strcmp
// INTERNAL INCLUDES
+#include <dali/internal/event/common/property-helper.h>
#include <dali/public-api/object/property-array.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/internal/event/common/property-helper.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
// Properties
// Name Type writable animatable constraint-input enum for index-checking
DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "points", ARRAY, true, false, false, Dali::Path::Property::POINTS )
-DALI_PROPERTY( "controlPoints", ARRAY, true, false, false, Dali::Path::Property::CONTROL_POINTS )
-DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX, PathDefaultProperties )
+DALI_PROPERTY("points", ARRAY, true, false, false, Dali::Path::Property::POINTS)
+DALI_PROPERTY("controlPoints", ARRAY, true, false, false, Dali::Path::Property::CONTROL_POINTS)
+DALI_PROPERTY_TABLE_END(DEFAULT_OBJECT_PROPERTY_START_INDEX, PathDefaultProperties)
/**
* These coefficient arise from the cubic polynomial equations for
* f'(0) = 3*(cp0 - p0)
* f'(1) = 3*(p1-cp1)
*/
-const float BezierBasisCoeff[] = { -1.0f, 3.0f, -3.0f, 1.0f,
- 3.0f, -6.0f, 3.0f, 0.0f,
- -3.0f, 3.0f, 0.0f, 0.0f,
- 1.0f, 0.0f, 0.0f, 0.0f };
+const float BezierBasisCoeff[] = {-1.0f, 3.0f, -3.0f, 1.0f, 3.0f, -6.0f, 3.0f, 0.0f, -3.0f, 3.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f};
-const Dali::Matrix BezierBasis = Dali::Matrix( BezierBasisCoeff );
+const Dali::Matrix BezierBasis = Dali::Matrix(BezierBasisCoeff);
Dali::BaseHandle Create()
{
return Dali::Path::New();
}
-TypeRegistration mType( typeid(Dali::Path), typeid(Dali::Handle), Create, PathDefaultProperties );
+TypeRegistration mType(typeid(Dali::Path), typeid(Dali::Handle), Create, PathDefaultProperties);
inline bool PathIsComplete(const Dali::Vector<Vector3>& point, const Dali::Vector<Vector3>& controlPoint)
{
- return ( point.Size() > 1 && controlPoint.Size() == (point.Size()-1)*2 );
+ return (point.Size() > 1 && controlPoint.Size() == (point.Size() - 1) * 2);
}
} //Unnamed namespace
}
Path::Path()
-: Object( nullptr ) // we don't have our own scene object
+: Object(nullptr) // we don't have our own scene object
{
}
Path* Path::Clone(const Path& path)
{
Path* clone = new Path();
- clone->SetPoints( path.GetPoints() );
- clone->SetControlPoints( path.GetControlPoints() );
+ clone->SetPoints(path.GetPoints());
+ clone->SetControlPoints(path.GetControlPoints());
return clone;
}
-Property::Value Path::GetDefaultProperty( Property::Index index ) const
+Property::Value Path::GetDefaultProperty(Property::Index index) const
{
- if( index == Dali::Path::Property::POINTS )
+ if(index == Dali::Path::Property::POINTS)
{
- Property::Value value( Property::ARRAY );
- Property::Array* array = value.GetArray();
+ Property::Value value(Property::ARRAY);
+ Property::Array* array = value.GetArray();
Property::Array::SizeType pointCount = mPoint.Count();
- if( array )
+ if(array)
{
- array->Reserve( pointCount );
- for( Property::Array::SizeType i = 0; i < pointCount; ++i )
+ array->Reserve(pointCount);
+ for(Property::Array::SizeType i = 0; i < pointCount; ++i)
{
- array->PushBack( mPoint[i] );
+ array->PushBack(mPoint[i]);
}
}
return value;
}
- else if( index == Dali::Path::Property::CONTROL_POINTS )
+ else if(index == Dali::Path::Property::CONTROL_POINTS)
{
- Property::Value value( Property::ARRAY );
- Property::Array* array = value.GetArray();
- Property::Array::SizeType controlpointCount = mControlPoint.Count();
+ Property::Value value(Property::ARRAY);
+ Property::Array* array = value.GetArray();
+ Property::Array::SizeType controlpointCount = mControlPoint.Count();
- if( array )
+ if(array)
{
- array->Reserve( controlpointCount );
- for( Property::Array::SizeType i = 0; i < controlpointCount; ++i )
+ array->Reserve(controlpointCount);
+ for(Property::Array::SizeType i = 0; i < controlpointCount; ++i)
{
- array->PushBack( mControlPoint[i] );
+ array->PushBack(mControlPoint[i]);
}
}
return value;
void Path::SetDefaultProperty(Property::Index index, const Property::Value& propertyValue)
{
const Property::Array* array = propertyValue.GetArray();
- if( array )
+ if(array)
{
Property::Array::SizeType propertyArrayCount = array->Count();
- if( index == Dali::Path::Property::POINTS )
+ if(index == Dali::Path::Property::POINTS)
{
- mPoint.Reserve( propertyArrayCount );
- for( Property::Array::SizeType i = 0; i < propertyArrayCount; ++i )
+ mPoint.Reserve(propertyArrayCount);
+ for(Property::Array::SizeType i = 0; i < propertyArrayCount; ++i)
{
Vector3 point;
- array->GetElementAt( i ).Get( point );
- mPoint.PushBack( point );
+ array->GetElementAt(i).Get(point);
+ mPoint.PushBack(point);
}
}
- else if( index == Dali::Path::Property::CONTROL_POINTS )
+ else if(index == Dali::Path::Property::CONTROL_POINTS)
{
- mControlPoint.Reserve( propertyArrayCount );
- for( Property::Array::SizeType i = 0; i < propertyArrayCount; ++i )
+ mControlPoint.Reserve(propertyArrayCount);
+ for(Property::Array::SizeType i = 0; i < propertyArrayCount; ++i)
{
Vector3 point;
- array->GetElementAt( i ).Get( point );
- mControlPoint.PushBack( point );
+ array->GetElementAt(i).Get(point);
+ mControlPoint.PushBack(point);
}
}
}
}
-void Path::AddPoint(const Vector3& point )
+void Path::AddPoint(const Vector3& point)
{
- mPoint.PushBack( point );
+ mPoint.PushBack(point);
}
-void Path::AddControlPoint(const Vector3& point )
+void Path::AddControlPoint(const Vector3& point)
{
- mControlPoint.PushBack( point );
+ mControlPoint.PushBack(point);
}
uint32_t Path::GetNumberOfSegments() const
{
- return static_cast<uint32_t>( (mPoint.Size()>1) ? mPoint.Size()-1 : 0 );
+ return static_cast<uint32_t>((mPoint.Size() > 1) ? mPoint.Size() - 1 : 0);
}
-void Path::GenerateControlPoints( float curvature )
+void Path::GenerateControlPoints(float curvature)
{
uint32_t numSegments = GetNumberOfSegments();
- DALI_ASSERT_ALWAYS( numSegments > 0 && "Need at least 1 segment to generate control points" ); // need at least 1 segment
+ DALI_ASSERT_ALWAYS(numSegments > 0 && "Need at least 1 segment to generate control points"); // need at least 1 segment
- mControlPoint.Resize( numSegments * 2);
+ mControlPoint.Resize(numSegments * 2);
//Generate two control points for each segment
- for( uint32_t i(0); i<numSegments; ++i )
+ for(uint32_t i(0); i < numSegments; ++i)
{
//Segment end-points
Vector3 p1 = mPoint[i];
- Vector3 p2 = mPoint[i+1];
+ Vector3 p2 = mPoint[i + 1];
Vector3 p0;
- if( i == 0 )
+ if(i == 0)
{
//There's no previous point. We chose a point in the line defined by the two end points at
//a 1/8th of the distance between them.
- p0 = p1 - (p2 - p1)/8.0f;
+ p0 = p1 - (p2 - p1) / 8.0f;
}
else
{
//Previous point
- p0 = mPoint[i-1];
+ p0 = mPoint[i - 1];
}
Vector3 p3;
- if( i == numSegments - 1)
+ if(i == numSegments - 1)
{
//There's no next point. We chose a point in the line defined by the two end points at
//a 1/8th of the distance between them.
- p3 = p2 - (p1 - p2)/8.0f;
+ p3 = p2 - (p1 - p2) / 8.0f;
}
else
{
//Next point
- p3 = mPoint[i+2];
+ p3 = mPoint[i + 2];
}
Vector3 p0p1 = p1 - p0;
float length = p1p2.Length();
- Vector3 tangentOut = ( p0p1*length + p1p2*p0p1.Length() ) * 0.5f;
+ Vector3 tangentOut = (p0p1 * length + p1p2 * p0p1.Length()) * 0.5f;
tangentOut.Normalize();
- Vector3 tangentIn = ( p1p2*p2p3.Length() + p2p3*length ) * 0.5f;
+ Vector3 tangentIn = (p1p2 * p2p3.Length() + p2p3 * length) * 0.5f;
tangentIn.Normalize();
//Use curvature to scale the tangents
length *= curvature;
- mControlPoint[2*i] = p1 + tangentOut*length;
- mControlPoint[2*i+1] = p2 - tangentIn*length;
+ mControlPoint[2 * i] = p1 + tangentOut * length;
+ mControlPoint[2 * i + 1] = p2 - tangentIn * length;
}
}
-void Path::FindSegmentAndProgress( float t, uint32_t& segment, float& tLocal ) const
+void Path::FindSegmentAndProgress(float t, uint32_t& segment, float& tLocal) const
{
//Find segment and local progress
uint32_t numSegs = GetNumberOfSegments();
- if( t <= 0.0f || numSegs == 0 )
+ if(t <= 0.0f || numSegs == 0)
{
segment = 0;
- tLocal = 0.0f;
+ tLocal = 0.0f;
}
- else if( t >= 1.0f )
+ else if(t >= 1.0f)
{
- segment = numSegs-1;
- tLocal = 1.0f;
+ segment = numSegs - 1;
+ tLocal = 1.0f;
}
else
{
- segment = static_cast<uint32_t>( t * static_cast<float>( numSegs ) );
- float segLength = 1.0f / static_cast<float>( numSegs );
- float segStart = static_cast<float>( segment ) * segLength;
- tLocal = (t - segStart) * static_cast<float>( numSegs );
+ segment = static_cast<uint32_t>(t * static_cast<float>(numSegs));
+ float segLength = 1.0f / static_cast<float>(numSegs);
+ float segStart = static_cast<float>(segment) * segLength;
+ tLocal = (t - segStart) * static_cast<float>(numSegs);
}
}
-void Path::Sample( float t, Vector3& position, Vector3& tangent ) const
+void Path::Sample(float t, Vector3& position, Vector3& tangent) const
{
- if( !SampleAt(t, position, tangent) )
+ if(!SampleAt(t, position, tangent))
{
- DALI_ASSERT_ALWAYS(!"Spline not fully initialized" );
+ DALI_ASSERT_ALWAYS(!"Spline not fully initialized");
}
}
-bool Path::SampleAt( float t, Vector3& position, Vector3& tangent ) const
+bool Path::SampleAt(float t, Vector3& position, Vector3& tangent) const
{
bool done = false;
- if( PathIsComplete(mPoint, mControlPoint) )
+ if(PathIsComplete(mPoint, mControlPoint))
{
uint32_t segment;
- float tLocal;
- FindSegmentAndProgress( t, segment, tLocal );
+ float tLocal;
+ FindSegmentAndProgress(t, segment, tLocal);
//Get points and control points in the segment
- const Vector3& controlPoint0 = mControlPoint[2*segment];
- const Vector3& controlPoint1 = mControlPoint[2*segment+1];
- const Vector3& point0 = mPoint[segment];
- const Vector3& point1 = mPoint[segment+1];
+ const Vector3& controlPoint0 = mControlPoint[2 * segment];
+ const Vector3& controlPoint1 = mControlPoint[2 * segment + 1];
+ const Vector3& point0 = mPoint[segment];
+ const Vector3& point1 = mPoint[segment + 1];
if(tLocal < Math::MACHINE_EPSILON_1)
{
position = point0;
- tangent = ( controlPoint0 - point0 ) * 3.0f;
+ tangent = (controlPoint0 - point0) * 3.0f;
tangent.Normalize();
}
- else if( (1.0 - tLocal) < Math::MACHINE_EPSILON_1)
+ else if((1.0 - tLocal) < Math::MACHINE_EPSILON_1)
{
position = point1;
- tangent = ( point1 - controlPoint1 ) * 3.0f;
+ tangent = (point1 - controlPoint1) * 3.0f;
tangent.Normalize();
}
else
{
- const Vector4 sVect(tLocal*tLocal*tLocal, tLocal*tLocal, tLocal, 1.0f );
- const Vector3 sVectDerivative(3.0f*tLocal*tLocal, 2.0f*tLocal, 1.0f );
+ const Vector4 sVect(tLocal * tLocal * tLocal, tLocal * tLocal, tLocal, 1.0f);
+ const Vector3 sVectDerivative(3.0f * tLocal * tLocal, 2.0f * tLocal, 1.0f);
//X
- Vector4 cVect( point0.x, controlPoint0.x, controlPoint1.x, point1.x);
+ Vector4 cVect(point0.x, controlPoint0.x, controlPoint1.x, point1.x);
- Vector4 A = BezierBasis * cVect;
+ Vector4 A = BezierBasis * cVect;
position.x = sVect.Dot4(A);
tangent.x = sVectDerivative.Dot(Vector3(A));
//Y
- cVect.x = point0.y;
- cVect.y = controlPoint0.y;
- cVect.z = controlPoint1.y;
- cVect.w = point1.y;
+ cVect.x = point0.y;
+ cVect.y = controlPoint0.y;
+ cVect.z = controlPoint1.y;
+ cVect.w = point1.y;
- A = BezierBasis * cVect;
+ A = BezierBasis * cVect;
position.y = sVect.Dot4(A);
tangent.y = sVectDerivative.Dot(Vector3(A));
//Z
- cVect.x = point0.z;
- cVect.y = controlPoint0.z;
- cVect.z = controlPoint1.z;
- cVect.w = point1.z;
+ cVect.x = point0.z;
+ cVect.y = controlPoint0.z;
+ cVect.z = controlPoint1.z;
+ cVect.w = point1.z;
- A = BezierBasis * cVect;
+ A = BezierBasis * cVect;
position.z = sVect.Dot4(A);
tangent.z = sVectDerivative.Dot(Vector3(A));
return done;
}
-bool Path::SamplePosition( float t, Vector3& position ) const
+bool Path::SamplePosition(float t, Vector3& position) const
{
bool done = false;
- if( PathIsComplete(mPoint, mControlPoint) )
+ if(PathIsComplete(mPoint, mControlPoint))
{
uint32_t segment;
- float tLocal;
- FindSegmentAndProgress( t, segment, tLocal );
+ float tLocal;
+ FindSegmentAndProgress(t, segment, tLocal);
- const Vector3& controlPoint0 = mControlPoint[2*segment];
- const Vector3& controlPoint1 = mControlPoint[2*segment+1];
- const Vector3& point0 = mPoint[segment];
- const Vector3& point1 = mPoint[segment+1];
+ const Vector3& controlPoint0 = mControlPoint[2 * segment];
+ const Vector3& controlPoint1 = mControlPoint[2 * segment + 1];
+ const Vector3& point0 = mPoint[segment];
+ const Vector3& point1 = mPoint[segment + 1];
if(tLocal < Math::MACHINE_EPSILON_1)
{
position = point0;
}
- else if( (1.0 - tLocal) < Math::MACHINE_EPSILON_1)
+ else if((1.0 - tLocal) < Math::MACHINE_EPSILON_1)
{
position = point1;
}
else
{
- const Vector4 sVect(tLocal*tLocal*tLocal, tLocal*tLocal, tLocal, 1.0f );
+ const Vector4 sVect(tLocal * tLocal * tLocal, tLocal * tLocal, tLocal, 1.0f);
//X
- Vector4 cVect( point0.x, controlPoint0.x, controlPoint1.x, point1.x);
+ Vector4 cVect(point0.x, controlPoint0.x, controlPoint1.x, point1.x);
position.x = sVect.Dot4(BezierBasis * cVect);
//Y
- cVect.x = point0.y;
- cVect.y = controlPoint0.y;
- cVect.z = controlPoint1.y;
- cVect.w = point1.y;
+ cVect.x = point0.y;
+ cVect.y = controlPoint0.y;
+ cVect.z = controlPoint1.y;
+ cVect.w = point1.y;
position.y = sVect.Dot4(BezierBasis * cVect);
//Z
- cVect.x = point0.z;
- cVect.y = controlPoint0.z;
- cVect.z = controlPoint1.z;
- cVect.w = point1.z;
+ cVect.x = point0.z;
+ cVect.y = controlPoint0.z;
+ cVect.z = controlPoint1.z;
+ cVect.w = point1.z;
position.z = sVect.Dot4(BezierBasis * cVect);
}
return done;
}
-bool Path::SampleTangent( float t, Vector3& tangent ) const
+bool Path::SampleTangent(float t, Vector3& tangent) const
{
bool done = false;
- if( PathIsComplete(mPoint, mControlPoint) )
+ if(PathIsComplete(mPoint, mControlPoint))
{
uint32_t segment;
- float tLocal;
- FindSegmentAndProgress( t, segment, tLocal );
+ float tLocal;
+ FindSegmentAndProgress(t, segment, tLocal);
- const Vector3& controlPoint0 = mControlPoint[2*segment];
- const Vector3& controlPoint1 = mControlPoint[2*segment+1];
- const Vector3& point0 = mPoint[segment];
- const Vector3& point1 = mPoint[segment+1];
+ const Vector3& controlPoint0 = mControlPoint[2 * segment];
+ const Vector3& controlPoint1 = mControlPoint[2 * segment + 1];
+ const Vector3& point0 = mPoint[segment];
+ const Vector3& point1 = mPoint[segment + 1];
if(tLocal < Math::MACHINE_EPSILON_1)
{
- tangent = ( controlPoint0 - point0 ) * 3.0f;
+ tangent = (controlPoint0 - point0) * 3.0f;
}
- else if( (1.0f - tLocal) < Math::MACHINE_EPSILON_1)
+ else if((1.0f - tLocal) < Math::MACHINE_EPSILON_1)
{
- tangent = ( point1 - controlPoint1 ) * 3.0f;
+ tangent = (point1 - controlPoint1) * 3.0f;
}
else
{
- const Vector3 sVectDerivative(3.0f*tLocal*tLocal, 2.0f*tLocal, 1.0f );
+ const Vector3 sVectDerivative(3.0f * tLocal * tLocal, 2.0f * tLocal, 1.0f);
//X
- Vector4 cVect( point0.x, controlPoint0.x, controlPoint1.x, point1.x);
- tangent.x = sVectDerivative.Dot(Vector3(BezierBasis * cVect));
+ Vector4 cVect(point0.x, controlPoint0.x, controlPoint1.x, point1.x);
+ tangent.x = sVectDerivative.Dot(Vector3(BezierBasis * cVect));
//Y
- cVect.x = point0.y;
- cVect.y = controlPoint0.y;
- cVect.z = controlPoint1.y;
- cVect.w = point1.y;
- tangent.y = sVectDerivative.Dot(Vector3(BezierBasis * cVect));
+ cVect.x = point0.y;
+ cVect.y = controlPoint0.y;
+ cVect.z = controlPoint1.y;
+ cVect.w = point1.y;
+ tangent.y = sVectDerivative.Dot(Vector3(BezierBasis * cVect));
//Z
- cVect.x = point0.z;
- cVect.y = controlPoint0.z;
- cVect.z = controlPoint1.z;
- cVect.w = point1.z;
- tangent.z = sVectDerivative.Dot(Vector3(BezierBasis * cVect));
+ cVect.x = point0.z;
+ cVect.y = controlPoint0.z;
+ cVect.z = controlPoint1.z;
+ cVect.w = point1.z;
+ tangent.z = sVectDerivative.Dot(Vector3(BezierBasis * cVect));
}
tangent.Normalize();
return done;
}
-Vector3& Path::GetPoint( uint32_t index )
+Vector3& Path::GetPoint(uint32_t index)
{
- DALI_ASSERT_ALWAYS( index < mPoint.Size() && "Path: Point index out of bounds" );
+ DALI_ASSERT_ALWAYS(index < mPoint.Size() && "Path: Point index out of bounds");
return mPoint[index];
}
-Vector3& Path::GetControlPoint( uint32_t index )
+Vector3& Path::GetControlPoint(uint32_t index)
{
- DALI_ASSERT_ALWAYS( index < mControlPoint.Size() && "Path: Control Point index out of bounds" );
+ DALI_ASSERT_ALWAYS(index < mControlPoint.Size() && "Path: Control Point index out of bounds");
return mControlPoint[index];
}
uint32_t Path::GetPointCount() const
{
- return static_cast<uint32_t>( mPoint.Size() );
+ return static_cast<uint32_t>(mPoint.Size());
}
void Path::ClearPoints()
mControlPoint.Clear();
}
-} // Internal
-} // Dali
+} // namespace Internal
+} // namespace Dali
#define DALI_INTERNAL_PATH_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/common/object-impl.h>
#include <dali/public-api/animation/path.h>
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/math/matrix.h>
#include <dali/public-api/common/dali-vector.h>
-#include <dali/internal/event/common/object-impl.h>
+#include <dali/public-api/math/matrix.h>
+#include <dali/public-api/object/base-object.h>
namespace Dali
{
-
namespace Internal
{
using PathPtr = IntrusivePtr<Path>;
class Path : public Object
{
public:
-
/**
* Construct a new path
*/
*/
Path();
-
protected:
/**
* virtual destructor
~Path() override;
private:
-
/**
* @copydoc Dali::Internal::Object::SetDefaultProperty()
*/
void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override;
- /**
+ /**
* @copydoc Dali::Internal::Object::GetDefaultProperty()
*/
- Property::Value GetDefaultProperty( Property::Index index ) const override;
+ Property::Value GetDefaultProperty(Property::Index index) const override;
public:
-
/**
* Returns a clone to the given path
*/
/**
* @copydoc Dali::Path::AddPoint
*/
- void AddPoint(const Vector3& point );
+ void AddPoint(const Vector3& point);
/**
* @copydoc Dali::Path::AddControlPoint
*/
- void AddControlPoint(const Vector3& point );
+ void AddControlPoint(const Vector3& point);
/**
* @copydoc Dali::Path::GenerateControlPoints
*/
- void GenerateControlPoints( float curvature );
+ void GenerateControlPoints(float curvature);
/**
* @copydoc Dali::Path::Sample
*/
- void Sample( float t, Vector3& position, Vector3& tangent ) const;
+ void Sample(float t, Vector3& position, Vector3& tangent) const;
/**
* @brief Sample path at a given progress. Calculates position and tangent at that point of the curve
* @param[out] tangent The interpolated tangent at that progress.
* @return true if Sample could be calculated
*/
- bool SampleAt( float t, Vector3& position, Vector3& tangent ) const;
+ bool SampleAt(float t, Vector3& position, Vector3& tangent) const;
/**
* Sample position at point t.
* @param[out] position The interpolated position at that progress.
* @return true if sample could be calculated
*/
- bool SamplePosition( float t, Vector3& position ) const;
+ bool SamplePosition(float t, Vector3& position) const;
/**
* @brief Sample tangent at point t.
* @param[out] tangent The interpolated tangent at that progress.
* @return true if sample could be calculated
*/
- bool SampleTangent( float t, Vector3& tangent ) const;
+ bool SampleTangent(float t, Vector3& tangent) const;
/**
* @copydoc Dali::Path::GetPoint
*/
- Vector3& GetPoint( uint32_t index );
+ Vector3& GetPoint(uint32_t index);
/**
* @copydoc Dali::Path::GetControlPoint
*/
- Vector3& GetControlPoint( uint32_t index );
+ Vector3& GetControlPoint(uint32_t index);
/**
* @copydoc Dali::Path::GetPointCount
*
* @return A const reference to mPoint vector
*/
- const Dali::Vector<Vector3>& GetPoints() const{ return mPoint; }
+ const Dali::Vector<Vector3>& GetPoints() const
+ {
+ return mPoint;
+ }
/*
* @brief Set mPoint
*
* @param[in] p New value for mPoint property
*/
- void SetPoints( const Dali::Vector<Vector3>& p ){ mPoint = p; }
+ void SetPoints(const Dali::Vector<Vector3>& p)
+ {
+ mPoint = p;
+ }
/**
* @brief Get mCotrolPoint property
*
* @return A const reference to mControlPoint vector
*/
- const Dali::Vector<Vector3>& GetControlPoints() const{ return mControlPoint; }
+ const Dali::Vector<Vector3>& GetControlPoints() const
+ {
+ return mControlPoint;
+ }
/*
* @brief Set mControlPoint property
*
* @param[in] p New value for mControlPoint property
*/
- void SetControlPoints( const Dali::Vector<Vector3>& p ){ mControlPoint = p; }
+ void SetControlPoints(const Dali::Vector<Vector3>& p)
+ {
+ mControlPoint = p;
+ }
private:
-
/**
* Undefined
*/
* @param[out] tLocal Local progress in the segment
*
*/
- void FindSegmentAndProgress( float t, uint32_t& segment, float& tLocal ) const;
+ void FindSegmentAndProgress(float t, uint32_t& segment, float& tLocal) const;
/**
* Helper function to calculate to number of segments in the path
*/
uint32_t GetNumberOfSegments() const;
- Dali::Vector<Vector3> mPoint; ///< Interpolation points
- Dali::Vector<Vector3> mControlPoint; ///< Control points
+ Dali::Vector<Vector3> mPoint; ///< Interpolation points
+ Dali::Vector<Vector3> mControlPoint; ///< Control points
};
-} // Internal
+} // namespace Internal
// Get impl of handle
inline Internal::Path& GetImplementation(Dali::Path& path)
{
- DALI_ASSERT_ALWAYS( path && "Path handle is empty" );
+ DALI_ASSERT_ALWAYS(path && "Path handle is empty");
Dali::RefObject& object = path.GetBaseObject();
return static_cast<Internal::Path&>(object);
}
inline const Internal::Path& GetImplementation(const Dali::Path& path)
{
- DALI_ASSERT_ALWAYS( path && "Path handle is empty" );
+ DALI_ASSERT_ALWAYS(path && "Path handle is empty");
const Dali::RefObject& object = path.GetBaseObject();
return static_cast<const Internal::Path&>(object);
}
-
-} // Dali
+} // namespace Dali
#endif // DALI_INTERNAL_PATH_H
#define DALI_INTERNAL_PROGRESS_VALUE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* Progress / value pair for animating channels (properties) with keyframes
*/
-template <typename T>
+template<typename T>
class ProgressValue
{
public:
- ProgressValue (float progress, T value)
+ ProgressValue(float progress, T value)
: mProgress(progress),
- mValue (value)
+ mValue(value)
{
}
~ProgressValue() = default;
- float GetProgress () const
+ float GetProgress() const
{
return mProgress;
}
- const T& GetValue () const
+ const T& GetValue() const
{
return mValue;
}
public:
- float mProgress; ///< Progress this value applies to animation channel
- T mValue; ///< value this animation channel should take
+ float mProgress; ///< Progress this value applies to animation channel
+ T mValue; ///< value this animation channel should take
};
-inline void Interpolate (Quaternion& result, const Quaternion& a, const Quaternion& b, float progress)
+inline void Interpolate(Quaternion& result, const Quaternion& a, const Quaternion& b, float progress)
{
result = Quaternion::Slerp(a, b, progress);
}
-inline void Interpolate (AngleAxis& result, const AngleAxis& a, const AngleAxis& b, float progress)
+inline void Interpolate(AngleAxis& result, const AngleAxis& a, const AngleAxis& b, float progress)
{
Quaternion q1(a.angle, a.axis);
Quaternion q2(b.angle, b.axis);
iq.ToAxisAngle(result.axis, result.angle);
}
-
-inline void Interpolate (bool& result, bool a, bool b, float progress)
+inline void Interpolate(bool& result, bool a, bool b, float progress)
{
result = progress < 0.5f ? a : b;
}
-inline void Interpolate (int32_t& result, int a, int b, float progress)
+inline void Interpolate(int32_t& result, int a, int b, float progress)
{
- result = static_cast<int>(static_cast<float>( a ) + static_cast<float>(b - a) * progress + 0.5f);
+ result = static_cast<int>(static_cast<float>(a) + static_cast<float>(b - a) * progress + 0.5f);
}
-inline void Interpolate (float& result, float a, float b, float progress)
+inline void Interpolate(float& result, float a, float b, float progress)
{
- result = a + (b-a) * progress;
+ result = a + (b - a) * progress;
}
-inline void Interpolate (Vector2& result, const Vector2& a, const Vector2& b, float progress)
+inline void Interpolate(Vector2& result, const Vector2& a, const Vector2& b, float progress)
{
- result = a + (b-a) * progress;
+ result = a + (b - a) * progress;
}
-inline void Interpolate (Vector3& result, const Vector3& a, const Vector3& b, float progress)
+inline void Interpolate(Vector3& result, const Vector3& a, const Vector3& b, float progress)
{
- result = a + (b-a) * progress;
+ result = a + (b - a) * progress;
}
-inline void Interpolate (Vector4& result, const Vector4& a, const Vector4& b, float progress)
+inline void Interpolate(Vector4& result, const Vector4& a, const Vector4& b, float progress)
{
- result = a + (b-a) * progress;
+ result = a + (b - a) * progress;
}
/* Cubic Interpolation (Catmull-Rom spline) between values p1 and p2. p0 and p3 are prev and next values
* Restrictions: f(0)=p1 f(1)=p2 f'(0)=(p2-p0)*0.5 f'(1)=(p3-p1)*0.5
*/
-inline void CubicInterpolate( int32_t& result, int32_t p0, int32_t p1, int32_t p2, int32_t p3, float progress )
+inline void CubicInterpolate(int32_t& result, int32_t p0, int32_t p1, int32_t p2, int32_t p3, float progress)
{
- float a3 = static_cast<float>( p3 ) * 0.5f - static_cast<float>( p2 ) * 1.5f + static_cast<float>( p1 ) * 1.5f - static_cast<float>( p0 ) * 0.5f;
- float a2 = static_cast<float>( p0 ) - static_cast<float>( p1 ) * 2.5f + static_cast<float>( p2 ) * 2.0f - static_cast<float>( p3 ) * 0.5f;
- float a1 = static_cast<float>( p2 - p0 ) * 0.5f;
+ float a3 = static_cast<float>(p3) * 0.5f - static_cast<float>(p2) * 1.5f + static_cast<float>(p1) * 1.5f - static_cast<float>(p0) * 0.5f;
+ float a2 = static_cast<float>(p0) - static_cast<float>(p1) * 2.5f + static_cast<float>(p2) * 2.0f - static_cast<float>(p3) * 0.5f;
+ float a1 = static_cast<float>(p2 - p0) * 0.5f;
- result = static_cast<int>( a3*progress*progress*progress + a2*progress*progress + a1*progress + static_cast<float>( p1 ) + 0.5f );
+ result = static_cast<int>(a3 * progress * progress * progress + a2 * progress * progress + a1 * progress + static_cast<float>(p1) + 0.5f);
}
-inline void CubicInterpolate( float& result, float p0, float p1, float p2, float p3, float progress )
+inline void CubicInterpolate(float& result, float p0, float p1, float p2, float p3, float progress)
{
- float a3 = p3*0.5f - p2*1.5f + p1*1.5f - p0*0.5f;
- float a2 = p0 - p1*2.5f + p2*2.0f - p3*0.5f;
- float a1 = (p2-p0)*0.5f;
+ float a3 = p3 * 0.5f - p2 * 1.5f + p1 * 1.5f - p0 * 0.5f;
+ float a2 = p0 - p1 * 2.5f + p2 * 2.0f - p3 * 0.5f;
+ float a1 = (p2 - p0) * 0.5f;
- result = a3*progress*progress*progress + a2*progress*progress + a1*progress + p1;
+ result = a3 * progress * progress * progress + a2 * progress * progress + a1 * progress + p1;
}
-inline void CubicInterpolate( Vector2& result, const Vector2& p0, const Vector2& p1, const Vector2& p2, const Vector2& p3, float progress )
+inline void CubicInterpolate(Vector2& result, const Vector2& p0, const Vector2& p1, const Vector2& p2, const Vector2& p3, float progress)
{
- Vector2 a3 = p3*0.5f - p2*1.5f + p1*1.5f - p0*0.5f;
- Vector2 a2 = p0 - p1*2.5f + p2*2.0f - p3*0.5f;
- Vector2 a1 = (p2-p0)*0.5f;
+ Vector2 a3 = p3 * 0.5f - p2 * 1.5f + p1 * 1.5f - p0 * 0.5f;
+ Vector2 a2 = p0 - p1 * 2.5f + p2 * 2.0f - p3 * 0.5f;
+ Vector2 a1 = (p2 - p0) * 0.5f;
- result = a3*progress*progress*progress + a2*progress*progress + a1*progress + p1;
+ result = a3 * progress * progress * progress + a2 * progress * progress + a1 * progress + p1;
}
-inline void CubicInterpolate( Vector3& result, const Vector3& p0, const Vector3& p1, const Vector3& p2, const Vector3& p3, float progress )
+inline void CubicInterpolate(Vector3& result, const Vector3& p0, const Vector3& p1, const Vector3& p2, const Vector3& p3, float progress)
{
- Vector3 a3 = p3*0.5f - p2*1.5f + p1*1.5f - p0*0.5f;
- Vector3 a2 = p0 - p1*2.5f + p2*2.0f - p3*0.5f;
- Vector3 a1 = (p2-p0)*0.5f;
+ Vector3 a3 = p3 * 0.5f - p2 * 1.5f + p1 * 1.5f - p0 * 0.5f;
+ Vector3 a2 = p0 - p1 * 2.5f + p2 * 2.0f - p3 * 0.5f;
+ Vector3 a1 = (p2 - p0) * 0.5f;
- result = a3*progress*progress*progress + a2*progress*progress + a1*progress + p1;
+ result = a3 * progress * progress * progress + a2 * progress * progress + a1 * progress + p1;
}
-inline void CubicInterpolate( Vector4& result, const Vector4& p0, const Vector4& p1, const Vector4& p2, const Vector4& p3, float progress )
+inline void CubicInterpolate(Vector4& result, const Vector4& p0, const Vector4& p1, const Vector4& p2, const Vector4& p3, float progress)
{
- Vector4 a3 = p3*0.5f - p2*1.5f + p1*1.5f - p0*0.5f;
- Vector4 a2 = p0 - p1*2.5f + p2*2.0f - p3*0.5f;
- Vector4 a1 = (p2-p0)*0.5f;
+ Vector4 a3 = p3 * 0.5f - p2 * 1.5f + p1 * 1.5f - p0 * 0.5f;
+ Vector4 a2 = p0 - p1 * 2.5f + p2 * 2.0f - p3 * 0.5f;
+ Vector4 a1 = (p2 - p0) * 0.5f;
- result = a3*progress*progress*progress + a2*progress*progress + a1*progress + p1;
+ result = a3 * progress * progress * progress + a2 * progress * progress + a1 * progress + p1;
}
-inline void CubicInterpolate( bool& result, bool p0, bool p1, bool p2, bool p3, float progress )
+inline void CubicInterpolate(bool& result, bool p0, bool p1, bool p2, bool p3, float progress)
{
- Interpolate( result, p1, p2, progress);
+ Interpolate(result, p1, p2, progress);
}
-inline void CubicInterpolate( Quaternion& result, const Quaternion& p0, const Quaternion& p1, const Quaternion& p2, const Quaternion& p3, float progress )
+inline void CubicInterpolate(Quaternion& result, const Quaternion& p0, const Quaternion& p1, const Quaternion& p2, const Quaternion& p3, float progress)
{
- Interpolate( result, p1, p2, progress);
+ Interpolate(result, p1, p2, progress);
}
-inline void CubicInterpolate( AngleAxis& result, const AngleAxis& p0, const AngleAxis& p1, const AngleAxis& p2, const AngleAxis& p3, float progress )
+inline void CubicInterpolate(AngleAxis& result, const AngleAxis& p0, const AngleAxis& p1, const AngleAxis& p2, const AngleAxis& p3, float progress)
{
- Interpolate( result, p1, p2, progress);
+ Interpolate(result, p1, p2, progress);
}
} // namespace Internal
#define DALI_INTERNAL_PROPERTY_CONSTRAINT_PTR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/animation/property-constraint.h>
#include <dali/internal/common/owner-pointer.h>
+#include <dali/internal/event/animation/property-constraint.h>
namespace Dali
{
-
namespace Internal
{
-
-template <class P>
+template<class P>
struct PropertyConstraintPtr
{
using Type = OwnerPointer<PropertyConstraint<P> >;
#define DALI_PROPERTY_CONSTRAINT_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/animation/constraint.h>
-#include <dali/public-api/common/dali-vector.h>
-#include <dali/public-api/common/vector-wrapper.h>
#include <dali/internal/event/animation/property-input-accessor.h>
#include <dali/internal/event/animation/property-input-indexer.h>
#include <dali/internal/event/common/property-input-impl.h>
+#include <dali/public-api/animation/constraint.h>
+#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/common/vector-wrapper.h>
namespace Dali
{
-
namespace Internal
{
-
/**
* A class for connecting properties to a constraint function.
*/
-template < typename PropertyType >
+template<typename PropertyType>
class PropertyConstraint
{
public:
-
- using ConstraintFunction = Dali::Constraint::Function< PropertyType >;
- using InputContainer = std::vector < PropertyInputAccessor >;
- using InputIndexerContainer = std::vector< PropertyInputIndexer< PropertyInputAccessor > >;
+ using ConstraintFunction = Dali::Constraint::Function<PropertyType>;
+ using InputContainer = std::vector<PropertyInputAccessor>;
+ using InputIndexerContainer = std::vector<PropertyInputIndexer<PropertyInputAccessor> >;
/**
* Create a property constraint.
*
* @param[in] func A constraint function. Ownership of this callback-function is passed to this object.
*/
- PropertyConstraint( ConstraintFunction* func )
- : mFunction( func ),
+ PropertyConstraint(ConstraintFunction* func)
+ : mFunction(func),
mInputs(),
- mInputsInitialized( false )
+ mInputsInitialized(false)
{
}
* @param [in] func A constraint function. Ownership of this callback-function is passed to this object.
* @param [in] inputs Property inputs.
*/
- PropertyConstraint( ConstraintFunction* func,
- const InputContainer& inputs )
- : mFunction( func ),
- mInputs( inputs ),
- mInputsInitialized( false )
+ PropertyConstraint(ConstraintFunction* func,
+ const InputContainer& inputs)
+ : mFunction(func),
+ mInputs(inputs),
+ mInputsInitialized(false)
{
}
*
* @note This function will create a copy of the stored constraint function for the clone.
*/
- PropertyConstraint< PropertyType >* Clone()
+ PropertyConstraint<PropertyType>* Clone()
{
- return new PropertyConstraint< PropertyType >( reinterpret_cast< ConstraintFunction* >( mFunction->Clone() ), mInputs );
+ return new PropertyConstraint<PropertyType>(reinterpret_cast<ConstraintFunction*>(mFunction->Clone()), mInputs);
}
/**
* @param [in] input The interface for receiving a property value.
* @param [in] componentIndex Component index.
*/
- void AddInput( const PropertyInputImpl* input, int32_t componentIndex )
+ void AddInput(const PropertyInputImpl* input, int32_t componentIndex)
{
- mInputs.push_back( PropertyInputAccessor{ input, componentIndex } );
+ mInputs.push_back(PropertyInputAccessor{input, componentIndex});
}
/**
* @param [in] index The parameter index.
* @return The property input, or nullptr if no input exists with this index.
*/
- const PropertyInputImpl* GetInput( uint32_t index ) const
+ const PropertyInputImpl* GetInput(uint32_t index) const
{
- if ( index < mInputs.size() )
+ if(index < mInputs.size())
{
- return mInputs[ index ].GetInput();
+ return mInputs[index].GetInput();
}
return nullptr;
*/
bool InputsInitialized()
{
- if ( !mInputsInitialized )
+ if(!mInputsInitialized)
{
// Check whether the inputs are initialized yet
- uint32_t index( 0u );
- for ( const PropertyInputImpl* input = GetInput( index );
- nullptr != input;
- input = GetInput( ++index ) )
+ uint32_t index(0u);
+ for(const PropertyInputImpl* input = GetInput(index);
+ nullptr != input;
+ input = GetInput(++index))
{
- if ( !input->InputInitialized() )
+ if(!input->InputInitialized())
{
return false;
}
*/
bool InputsChanged()
{
- uint32_t index( 0u );
- for ( const PropertyInputImpl* input = GetInput( index );
- nullptr != input;
- input = GetInput( ++index ) )
+ uint32_t index(0u);
+ for(const PropertyInputImpl* input = GetInput(index);
+ nullptr != input;
+ input = GetInput(++index))
{
- if ( input->InputChanged() )
+ if(input->InputChanged())
{
// At least one of the inputs has changed
return true;
* @param [in] bufferIndex The current update buffer index.
* @param [in,out] current The current property value, will be set to the constrained value upon return.
*/
- void Apply( BufferIndex bufferIndex, PropertyType& current )
+ void Apply(BufferIndex bufferIndex, PropertyType& current)
{
- InputIndexerContainer inputIndices;
+ InputIndexerContainer inputIndices;
PropertyInputContainer indices;
- const uint32_t noOfInputs = static_cast<uint32_t>( mInputs.size() );
+ const uint32_t noOfInputs = static_cast<uint32_t>(mInputs.size());
- inputIndices.reserve( noOfInputs );
- indices.Reserve( noOfInputs );
+ inputIndices.reserve(noOfInputs);
+ indices.Reserve(noOfInputs);
const auto&& endIter = mInputs.end();
- uint32_t index = 0;
- for ( auto&& iter = mInputs.begin(); iter != endIter; ++iter, ++index )
+ uint32_t index = 0;
+ for(auto&& iter = mInputs.begin(); iter != endIter; ++iter, ++index)
{
- DALI_ASSERT_DEBUG( nullptr != iter->GetInput() );
- inputIndices.push_back( PropertyInputIndexer< PropertyInputAccessor >( bufferIndex, &*iter ) );
- indices.PushBack( &inputIndices[ index ] );
+ DALI_ASSERT_DEBUG(nullptr != iter->GetInput());
+ inputIndices.push_back(PropertyInputIndexer<PropertyInputAccessor>(bufferIndex, &*iter));
+ indices.PushBack(&inputIndices[index]);
}
- CallbackBase::Execute< PropertyType&, const PropertyInputContainer& >( *mFunction, current, indices );
+ CallbackBase::Execute<PropertyType&, const PropertyInputContainer&>(*mFunction, current, indices);
}
private:
-
// Undefined
- PropertyConstraint() = delete;
- PropertyConstraint( const PropertyConstraint& ) = delete;
- PropertyConstraint& operator=( const PropertyConstraint& rhs ) = delete;
+ PropertyConstraint() = delete;
+ PropertyConstraint(const PropertyConstraint&) = delete;
+ PropertyConstraint& operator=(const PropertyConstraint& rhs) = delete;
private:
-
ConstraintFunction* mFunction;
- InputContainer mInputs;
- bool mInputsInitialized;
-
+ InputContainer mInputs;
+ bool mInputsInitialized;
};
} // namespace Internal
#define DALI_PROPERTY_INPUT_ACCESSOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/object/property-types.h>
#include <dali/internal/event/common/property-input-impl.h>
+#include <dali/public-api/object/property-types.h>
namespace Dali
{
-
namespace Internal
{
-
class PropertyInputAccessor
{
public:
-
/**
* Create the PropertyInputAccessor.
*/
PropertyInputAccessor()
- : mInput( nullptr ),
- mComponentIndex( -1 )
+ : mInput(nullptr),
+ mComponentIndex(-1)
{
}
/**
* Create the PropertyInputAccessor.
*/
- PropertyInputAccessor( const PropertyInputImpl* input, int32_t componentIndex )
- : mInput( input ),
- mComponentIndex( componentIndex )
+ PropertyInputAccessor(const PropertyInputImpl* input, int32_t componentIndex)
+ : mInput(input),
+ mComponentIndex(componentIndex)
{
}
*/
PropertyInputAccessor& operator=(const PropertyInputAccessor& accessor)
{
- if( this != &accessor )
+ if(this != &accessor)
{
- mInput = accessor.mInput;
+ mInput = accessor.mInput;
mComponentIndex = accessor.mComponentIndex;
}
return *this;
/**
* Set the property input.
*/
- void SetInput( const PropertyInputImpl& input, int32_t componentIndex )
+ void SetInput(const PropertyInputImpl& input, int32_t componentIndex)
{
- mInput = &input;
+ mInput = &input;
mComponentIndex = componentIndex;
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputBoolean()
*/
- const bool& GetConstraintInputBoolean( BufferIndex updateBufferIndex ) const
+ const bool& GetConstraintInputBoolean(BufferIndex updateBufferIndex) const
{
- return mInput->GetConstraintInputBoolean( updateBufferIndex );
+ return mInput->GetConstraintInputBoolean(updateBufferIndex);
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputInteger() const
*/
- const int& GetConstraintInputInteger( BufferIndex updateBufferIndex ) const
+ const int& GetConstraintInputInteger(BufferIndex updateBufferIndex) const
{
- DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
+ DALI_ASSERT_DEBUG(mComponentIndex < 0 && "Did not expect valid component index");
- return mInput->GetConstraintInputInteger( updateBufferIndex );
+ return mInput->GetConstraintInputInteger(updateBufferIndex);
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputFloat()
*/
- const float& GetConstraintInputFloat( BufferIndex updateBufferIndex ) const
+ const float& GetConstraintInputFloat(BufferIndex updateBufferIndex) const
{
// Invalid index is ok
- if ( mComponentIndex < 0 )
+ if(mComponentIndex < 0)
{
// Not a Vector2, Vector3 or Vector4 component, expecting float type
- return mInput->GetConstraintInputFloat( updateBufferIndex );
+ return mInput->GetConstraintInputFloat(updateBufferIndex);
}
- else if ( PropertyTypes::Get< Vector2 >() == mInput->GetType() )
+ else if(PropertyTypes::Get<Vector2>() == mInput->GetType())
{
- if ( 0 == mComponentIndex )
+ if(0 == mComponentIndex)
{
- return mInput->GetConstraintInputVector2( updateBufferIndex ).x;
+ return mInput->GetConstraintInputVector2(updateBufferIndex).x;
}
- DALI_ASSERT_DEBUG( 1 == mComponentIndex && "Invalid Vector2 component index" );
- return mInput->GetConstraintInputVector2( updateBufferIndex ).y;
+ DALI_ASSERT_DEBUG(1 == mComponentIndex && "Invalid Vector2 component index");
+ return mInput->GetConstraintInputVector2(updateBufferIndex).y;
}
- else if ( PropertyTypes::Get< Vector3 >() == mInput->GetType() )
+ else if(PropertyTypes::Get<Vector3>() == mInput->GetType())
{
- if ( 0 == mComponentIndex )
+ if(0 == mComponentIndex)
{
- return mInput->GetConstraintInputVector3( updateBufferIndex ).x;
+ return mInput->GetConstraintInputVector3(updateBufferIndex).x;
}
- else if ( 1 == mComponentIndex )
+ else if(1 == mComponentIndex)
{
- return mInput->GetConstraintInputVector3( updateBufferIndex ).y;
+ return mInput->GetConstraintInputVector3(updateBufferIndex).y;
}
- DALI_ASSERT_DEBUG( 2 == mComponentIndex && "Invalid Vector3 component index" );
- return mInput->GetConstraintInputVector3( updateBufferIndex ).z;
+ DALI_ASSERT_DEBUG(2 == mComponentIndex && "Invalid Vector3 component index");
+ return mInput->GetConstraintInputVector3(updateBufferIndex).z;
}
// Expecting Vector4
- if ( 0 == mComponentIndex )
+ if(0 == mComponentIndex)
{
- return mInput->GetConstraintInputVector4( updateBufferIndex ).x;
+ return mInput->GetConstraintInputVector4(updateBufferIndex).x;
}
- else if ( 1 == mComponentIndex )
+ else if(1 == mComponentIndex)
{
- return mInput->GetConstraintInputVector4( updateBufferIndex ).y;
+ return mInput->GetConstraintInputVector4(updateBufferIndex).y;
}
- else if ( 2 == mComponentIndex )
+ else if(2 == mComponentIndex)
{
- return mInput->GetConstraintInputVector4( updateBufferIndex ).z;
+ return mInput->GetConstraintInputVector4(updateBufferIndex).z;
}
- DALI_ASSERT_DEBUG( 3 == mComponentIndex && "Invalid Vector4 component index" );
- return mInput->GetConstraintInputVector4( updateBufferIndex ).w;
+ DALI_ASSERT_DEBUG(3 == mComponentIndex && "Invalid Vector4 component index");
+ return mInput->GetConstraintInputVector4(updateBufferIndex).w;
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector2()
*/
- const Vector2& GetConstraintInputVector2( BufferIndex updateBufferIndex ) const
+ const Vector2& GetConstraintInputVector2(BufferIndex updateBufferIndex) const
{
- return mInput->GetConstraintInputVector2( updateBufferIndex );
+ return mInput->GetConstraintInputVector2(updateBufferIndex);
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector3()
*/
- const Vector3& GetConstraintInputVector3( BufferIndex updateBufferIndex ) const
+ const Vector3& GetConstraintInputVector3(BufferIndex updateBufferIndex) const
{
- return mInput->GetConstraintInputVector3( updateBufferIndex );
+ return mInput->GetConstraintInputVector3(updateBufferIndex);
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector4()
*/
- const Vector4& GetConstraintInputVector4( BufferIndex updateBufferIndex ) const
+ const Vector4& GetConstraintInputVector4(BufferIndex updateBufferIndex) const
{
- return mInput->GetConstraintInputVector4( updateBufferIndex );
+ return mInput->GetConstraintInputVector4(updateBufferIndex);
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputQuaternion()
*/
- const Quaternion& GetConstraintInputQuaternion( BufferIndex updateBufferIndex ) const
+ const Quaternion& GetConstraintInputQuaternion(BufferIndex updateBufferIndex) const
{
- return mInput->GetConstraintInputQuaternion( updateBufferIndex );
+ return mInput->GetConstraintInputQuaternion(updateBufferIndex);
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix3()
*/
- const Matrix3& GetConstraintInputMatrix3( BufferIndex updateBufferIndex ) const
+ const Matrix3& GetConstraintInputMatrix3(BufferIndex updateBufferIndex) const
{
- return mInput->GetConstraintInputMatrix3( updateBufferIndex );
+ return mInput->GetConstraintInputMatrix3(updateBufferIndex);
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix()
*/
- const Matrix& GetConstraintInputMatrix( BufferIndex updateBufferIndex ) const
+ const Matrix& GetConstraintInputMatrix(BufferIndex updateBufferIndex) const
{
- return mInput->GetConstraintInputMatrix( updateBufferIndex );
+ return mInput->GetConstraintInputMatrix(updateBufferIndex);
}
public:
-
const PropertyInputImpl* mInput;
- int32_t mComponentIndex;
-
+ int32_t mComponentIndex;
};
} // namespace Internal
#define DALI_PROPERTY_INPUT_INDEXER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* Helper object to map public-api PropertyInput methods to internal
* PropertyInputImpl methods (which require the current buffer index).
*/
-template < typename AccessorType >
+template<typename AccessorType>
class PropertyInputIndexer : public PropertyInput
{
public:
-
/**
* Create an indexer object.
* @param[in] bufferIndex The current buffer index.
* @param[in] input The internal property input.
*/
- PropertyInputIndexer( BufferIndex bufferIndex, const AccessorType* input )
- : mBufferIndex( bufferIndex ),
- mInput( input )
+ PropertyInputIndexer(BufferIndex bufferIndex, const AccessorType* input)
+ : mBufferIndex(bufferIndex),
+ mInput(input)
{
}
/**
* Copy constructor
*/
- PropertyInputIndexer( const PropertyInputIndexer& other )
- : mBufferIndex( other.mBufferIndex ),
- mInput( other.mInput )
+ PropertyInputIndexer(const PropertyInputIndexer& other)
+ : mBufferIndex(other.mBufferIndex),
+ mInput(other.mInput)
{
}
/**
* Assignment operator
*/
- PropertyInputIndexer& operator=( const PropertyInputIndexer& other )
+ PropertyInputIndexer& operator=(const PropertyInputIndexer& other)
{
- if( this != &other )
+ if(this != &other)
{
mBufferIndex = other.mBufferIndex;
- mInput = other.mInput;
+ mInput = other.mInput;
}
return *this;
*/
const bool& GetBoolean() const override
{
- return mInput->GetConstraintInputBoolean( mBufferIndex );
+ return mInput->GetConstraintInputBoolean(mBufferIndex);
}
/**
*/
const int& GetInteger() const override
{
- return mInput->GetConstraintInputInteger( mBufferIndex );
+ return mInput->GetConstraintInputInteger(mBufferIndex);
}
/**
*/
const float& GetFloat() const override
{
- return mInput->GetConstraintInputFloat( mBufferIndex );
+ return mInput->GetConstraintInputFloat(mBufferIndex);
}
/**
*/
const Vector2& GetVector2() const override
{
- return mInput->GetConstraintInputVector2( mBufferIndex );
+ return mInput->GetConstraintInputVector2(mBufferIndex);
}
/**
*/
const Vector3& GetVector3() const override
{
- return mInput->GetConstraintInputVector3( mBufferIndex );
+ return mInput->GetConstraintInputVector3(mBufferIndex);
}
/**
*/
const Vector4& GetVector4() const override
{
- return mInput->GetConstraintInputVector4( mBufferIndex );
+ return mInput->GetConstraintInputVector4(mBufferIndex);
}
/**
*/
const Matrix3& GetMatrix3() const override
{
- return mInput->GetConstraintInputMatrix3( mBufferIndex );
+ return mInput->GetConstraintInputMatrix3(mBufferIndex);
}
/**
*/
const Matrix& GetMatrix() const override
{
- return mInput->GetConstraintInputMatrix( mBufferIndex );
+ return mInput->GetConstraintInputMatrix(mBufferIndex);
}
/**
*/
const Quaternion& GetQuaternion() const override
{
- return mInput->GetConstraintInputQuaternion( mBufferIndex );
+ return mInput->GetConstraintInputQuaternion(mBufferIndex);
}
public:
-
- BufferIndex mBufferIndex;
+ BufferIndex mBufferIndex;
const AccessorType* mInput;
};
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
-BaseObject::Impl::Impl( BaseObject& baseObject )
-: mBaseObject( baseObject )
+BaseObject::Impl::Impl(BaseObject& baseObject)
+: mBaseObject(baseObject)
{
}
BaseObject::Impl::~Impl()
{
// Notification for observers
- for( auto&& item : mObservers )
+ for(auto&& item : mObservers)
{
- item->ObjectDestroyed( mBaseObject );
+ item->ObjectDestroyed(mBaseObject);
}
}
-BaseObject::Impl& BaseObject::Impl::Get( BaseObject& baseObject )
+BaseObject::Impl& BaseObject::Impl::Get(BaseObject& baseObject)
{
return *baseObject.mImpl;
}
-const BaseObject::Impl& BaseObject::Impl::Get( const BaseObject& baseObject )
+const BaseObject::Impl& BaseObject::Impl::Get(const BaseObject& baseObject)
{
return *baseObject.mImpl;
}
-void BaseObject::Impl::AddObserver( Observer& observer )
+void BaseObject::Impl::AddObserver(Observer& observer)
{
// make sure an observer doesn't observe the same object twice
// otherwise it will get multiple calls to ObjectDestroyed()
- DALI_ASSERT_DEBUG( mObservers.End() == std::find( mObservers.Begin(), mObservers.End(), &observer) );
+ DALI_ASSERT_DEBUG(mObservers.End() == std::find(mObservers.Begin(), mObservers.End(), &observer));
- mObservers.PushBack( &observer );
+ mObservers.PushBack(&observer);
}
-void BaseObject::Impl::RemoveObserver( Observer& observer )
+void BaseObject::Impl::RemoveObserver(Observer& observer)
{
// Find the observer...
- const auto endIter = mObservers.End();
- for( auto iter = mObservers.Begin(); iter != endIter; ++iter )
+ const auto endIter = mObservers.End();
+ for(auto iter = mObservers.Begin(); iter != endIter; ++iter)
{
- if( ( *iter ) == &observer)
+ if((*iter) == &observer)
{
- mObservers.Erase( iter );
+ mObservers.Erase(iter);
break;
}
}
- DALI_ASSERT_DEBUG( endIter != mObservers.End() );
+ DALI_ASSERT_DEBUG(endIter != mObservers.End());
}
} // namespace Dali
#define DALI_BASE_OBJECT_IMPL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
/**
* @brief Holds the Implementation for the BaseObject class
*/
class BaseObject::Impl
{
-
public:
-
/**
* @brief Retrieves the implementation of the internal BaseObject class.
* @param[in] internalBaseObject A ref to the BaseObject whose internal implementation is required
* @return The internal implementation
*/
- static BaseObject::Impl& Get( BaseObject& baseObject );
+ static BaseObject::Impl& Get(BaseObject& baseObject);
/**
* @copydoc Get( BaseObject& )
*/
- static const BaseObject::Impl& Get( const BaseObject& baseObject );
+ static const BaseObject::Impl& Get(const BaseObject& baseObject);
/**
* @brief Constructor.
* @param[in] baseObject The base object which owns this implementation
*/
- Impl( BaseObject& baseObject );
+ Impl(BaseObject& baseObject);
/**
* @brief Destructor.
class Observer
{
public:
-
/**
* Called shortly before the object itself is destroyed; no further callbacks will be received.
* @param[in] object The base object.
*/
- virtual void ObjectDestroyed( BaseObject& object ) = 0;
+ virtual void ObjectDestroyed(BaseObject& object) = 0;
protected:
-
/**
* Virtual destructor
*/
* Add an observer to the object.
* @param[in] observer The observer to add.
*/
- void AddObserver( Observer& observer );
+ void AddObserver(Observer& observer);
/**
* Remove an observer from the object
* @pre The observer has already been added.
* @param[in] observer The observer to remove.
*/
- void RemoveObserver( Observer& observer );
+ void RemoveObserver(Observer& observer);
private:
-
- BaseObject& mBaseObject;
+ BaseObject& mBaseObject;
Dali::Vector<Observer*> mObservers;
};
#define DALI_INTERNAL_COMPLETE_NOTIFICATION_INTERFACE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* Provides notifications to the event-thread regarding the changes in previous update(s).
* For example after an animation finished
class CompleteNotificationInterface
{
protected:
-
/**
* Constructor, not to be directly instantiated.
*/
virtual ~CompleteNotificationInterface() = default;
public:
-
/**
* This method is called by Notification Manager
*/
virtual void NotifyCompleted() = 0;
-
};
} // namespace Internal
} // namespace Dali
#endif // DALI_INTERNAL_COMPLETE_NOTIFICATION_INTERFACE_H
-
#define DALI_INTERNAL_CONNECTABLE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Internal
{
-
/**
* @brief Interface for objects that can be connected to the stage.
*/
class Connectable
{
public:
-
/**
* @brief Destructor
*/
* @brief Notify this objects that it has been disconnected to the stage.
*/
virtual void Disconnect() = 0;
-
};
} // namespace Internal
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
for(auto i = 0u; i < src.size(); ++i)
{
char c = src[i];
- if( !IsDigit( c ) )
+ if(!IsDigit(c))
{
//update the src view.
src.remove_prefix(i);
return result;
}
-} // anon namespace
+} // namespace
namespace Dali
{
-
namespace Internal
{
std::string DemangleClassName(const char* typeIdName)
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
std::string DemangleClassName(const char* typeIdName)
{
- std::string name = typeIdName;
- int index = name.find_last_of(' ');
+ std::string name = typeIdName;
+ int index = name.find_last_of(' ');
- if( 0 <= index )
+ if(0 <= index)
{
- name = name.substr( index + 1, name.size() - index );
+ name = name.substr(index + 1, name.size() - index);
}
index = name.find_last_of(':');
- if( 0 <= index )
+ if(0 <= index)
{
name = name.substr(index + 1, name.size() - index);
}
#define DALI_DEMANGLER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* @brief Demangle a nested typeid name to its class name.
* @param[in] typeIdName The type id name string to demangle.
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Internal
{
-
EventThreadServices& EventThreadServices::Get()
{
return ThreadLocalStorage::Get().GetEventThreadServices();
return ThreadLocalStorage::Created();
}
-} // Internal
-} // Dali
+} // namespace Internal
+} // namespace Dali
#define DALI_INTERNAL_EVENT_THREAD_SERVICES_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
class BaseObject;
namespace Integration
namespace Internal
{
-
namespace SceneGraph
{
class UpdateManager;
class EventThreadServices
{
public:
-
/**
* Virtual destructor
*/
*
* @param[in] object to register
*/
- virtual void RegisterObject( BaseObject* object) = 0;
+ virtual void RegisterObject(BaseObject* object) = 0;
/**
* @brief Unregisters the object from Object registry.
*
* @param[in] object to unregister
*/
- virtual void UnregisterObject( BaseObject* object) = 0;
+ virtual void UnregisterObject(BaseObject* object) = 0;
/**
* @brief Get a reference to the UpdateManager
* @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update.
* @return A pointer to the first char allocated for the message.
*/
- virtual uint32_t* ReserveMessageSlot( uint32_t size, bool updateScene = true ) = 0;
+ virtual uint32_t* ReserveMessageSlot(uint32_t size, bool updateScene = true) = 0;
/**
* @return the current event-buffer index.
*/
- virtual BufferIndex GetEventBufferIndex() const = 0;
+ virtual BufferIndex GetEventBufferIndex() const = 0;
/**
* @brief Indicate that the next rendering is really required.
#include <dali/internal/event/common/notification-manager.h>
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
#include <dali/devel-api/common/owner-container.h>
#include <dali/devel-api/threading/mutex.h>
#include <dali/internal/common/message.h>
-#include <dali/internal/event/common/property-notification-impl.h>
#include <dali/internal/event/common/complete-notification-interface.h>
+#include <dali/internal/event/common/property-notification-impl.h>
+#include <dali/public-api/common/dali-common.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-typedef Dali::Vector< CompleteNotificationInterface* > InterfaceContainer;
+typedef Dali::Vector<CompleteNotificationInterface*> InterfaceContainer;
/**
* helper to move elements from one container to another
* @param from where to move
* @param to move target
*/
-void MoveElements( InterfaceContainer& from, InterfaceContainer& to )
+void MoveElements(InterfaceContainer& from, InterfaceContainer& to)
{
// check if there's something in from
const InterfaceContainer::SizeType fromCount = from.Count();
- if( fromCount > 0u )
+ if(fromCount > 0u)
{
// check if to has some elements
const InterfaceContainer::SizeType toCount = to.Count();
- if( toCount == 0u )
+ if(toCount == 0u)
{
// to is empty so we can swap with from
- to.Swap( from );
+ to.Swap(from);
}
else
{
- to.Reserve( toCount + fromCount );
- for( InterfaceContainer::SizeType i = 0; i < fromCount; ++i )
+ to.Reserve(toCount + fromCount);
+ for(InterfaceContainer::SizeType i = 0; i < fromCount; ++i)
{
- to.PushBack( from[ i ] );
+ to.PushBack(from[i]);
}
from.Clear();
}
}
}
-}
+} // namespace
using MessageQueueMutex = Dali::Mutex;
using MessageContainer = OwnerContainer<MessageBase*>;
{
// reserve space on the vectors to avoid reallocs
// applications typically have up-to 20-30 notifications at startup
- updateCompletedMessageQueue.Reserve( 32 );
- updateWorkingMessageQueue.Reserve( 32 );
- eventMessageQueue.Reserve( 32 );
+ updateCompletedMessageQueue.Reserve(32);
+ updateWorkingMessageQueue.Reserve(32);
+ eventMessageQueue.Reserve(32);
// only a few manager objects get complete notifications (animation, render list, property notifications, ...)
- updateCompletedInterfaceQueue.Reserve( 4 );
- updateWorkingInterfaceQueue.Reserve( 4 );
- eventInterfaceQueue.Reserve( 4 );
+ updateCompletedInterfaceQueue.Reserve(4);
+ updateWorkingInterfaceQueue.Reserve(4);
+ eventInterfaceQueue.Reserve(4);
}
~Impl() = default;
delete mImpl;
}
-void NotificationManager::QueueCompleteNotification( CompleteNotificationInterface* instance )
+void NotificationManager::QueueCompleteNotification(CompleteNotificationInterface* instance)
{
// queueMutex must be locked whilst accessing queues
- MessageQueueMutex::ScopedLock lock( mImpl->queueMutex );
+ MessageQueueMutex::ScopedLock lock(mImpl->queueMutex);
- mImpl->updateWorkingInterfaceQueue.PushBack( instance );
+ mImpl->updateWorkingInterfaceQueue.PushBack(instance);
}
-void NotificationManager::QueueMessage( MessageBase* message )
+void NotificationManager::QueueMessage(MessageBase* message)
{
- DALI_ASSERT_DEBUG( NULL != message );
+ DALI_ASSERT_DEBUG(NULL != message);
// queueMutex must be locked whilst accessing queues
- MessageQueueMutex::ScopedLock lock( mImpl->queueMutex );
+ MessageQueueMutex::ScopedLock lock(mImpl->queueMutex);
- mImpl->updateWorkingMessageQueue.PushBack( message );
+ mImpl->updateWorkingMessageQueue.PushBack(message);
}
void NotificationManager::UpdateCompleted()
{
// queueMutex must be locked whilst accessing queues
- MessageQueueMutex::ScopedLock lock( mImpl->queueMutex );
+ MessageQueueMutex::ScopedLock lock(mImpl->queueMutex);
// Move messages from update working queue to completed queue
// note that in theory its possible for update completed to have last frames
// events as well still hanging around. we need to keep them as well
- mImpl->updateCompletedMessageQueue.MoveFrom( mImpl->updateWorkingMessageQueue );
+ mImpl->updateCompletedMessageQueue.MoveFrom(mImpl->updateWorkingMessageQueue);
// move pointers from interface queue
- MoveElements( mImpl->updateWorkingInterfaceQueue, mImpl->updateCompletedInterfaceQueue );
+ MoveElements(mImpl->updateWorkingInterfaceQueue, mImpl->updateCompletedInterfaceQueue);
// finally the lock is released
}
bool NotificationManager::MessagesToProcess()
{
// queueMutex must be locked whilst accessing queues
- MessageQueueMutex::ScopedLock lock( mImpl->queueMutex );
+ MessageQueueMutex::ScopedLock lock(mImpl->queueMutex);
- return ( 0u < mImpl->updateCompletedMessageQueue.Count() ||
- ( 0u < mImpl->updateCompletedInterfaceQueue.Count() ) );
+ return (0u < mImpl->updateCompletedMessageQueue.Count() ||
+ (0u < mImpl->updateCompletedInterfaceQueue.Count()));
}
void NotificationManager::ProcessMessages()
{
// queueMutex must be locked whilst accessing queues
{
- MessageQueueMutex::ScopedLock lock( mImpl->queueMutex );
+ MessageQueueMutex::ScopedLock lock(mImpl->queueMutex);
// Move messages from update completed queue to event queue
// note that in theory its possible for event queue to have
// last frames events as well still hanging around so need to keep them
- mImpl->eventMessageQueue.MoveFrom( mImpl->updateCompletedMessageQueue );
- MoveElements( mImpl->updateCompletedInterfaceQueue, mImpl->eventInterfaceQueue );
+ mImpl->eventMessageQueue.MoveFrom(mImpl->updateCompletedMessageQueue);
+ MoveElements(mImpl->updateCompletedInterfaceQueue, mImpl->eventInterfaceQueue);
}
// end of scope, lock is released
- MessageContainer::Iterator iter = mImpl->eventMessageQueue.Begin();
- const MessageContainer::Iterator end = mImpl->eventMessageQueue.End();
- for( ; iter != end; ++iter )
+ MessageContainer::Iterator iter = mImpl->eventMessageQueue.Begin();
+ const MessageContainer::Iterator end = mImpl->eventMessageQueue.End();
+ for(; iter != end; ++iter)
{
- (*iter)->Process( 0u/*ignored*/ );
+ (*iter)->Process(0u /*ignored*/);
}
// release the processed messages from event side queue
mImpl->eventMessageQueue.Clear();
- InterfaceContainer::Iterator iter2 = mImpl->eventInterfaceQueue.Begin();
- const InterfaceContainer::Iterator end2 = mImpl->eventInterfaceQueue.End();
- for( ; iter2 != end2; ++iter2 )
+ InterfaceContainer::Iterator iter2 = mImpl->eventInterfaceQueue.Begin();
+ const InterfaceContainer::Iterator end2 = mImpl->eventInterfaceQueue.End();
+ for(; iter2 != end2; ++iter2)
{
CompleteNotificationInterface* interface = *iter2;
- if( interface )
+ if(interface)
{
interface->NotifyCompleted();
}
#define DALI_INTERNAL_NOTIFICATION_MANAGER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
class CompleteNotificationInterface;
class MessageBase;
class NotificationManager
{
public:
-
/**
* Create an NotificationManager. Owned by Core in event thread side.
*/
*/
virtual ~NotificationManager();
-/// Update side interface, can only be called from Update-thread
+ /// Update side interface, can only be called from Update-thread
/**
* Queue a scene message to an interface. This method is thread-safe.
* @param[in] instance to be notified about completion of the Update side event.
*/
- void QueueCompleteNotification( CompleteNotificationInterface* instance );
+ void QueueCompleteNotification(CompleteNotificationInterface* instance);
/**
* Queue a scene message. This method is thread-safe.
* @param[in] message A newly allocated message; NotificationManager takes ownership.
*/
- void QueueMessage( MessageBase* message );
+ void QueueMessage(MessageBase* message);
/**
* Signal Notification Manager that update frame is completed so it can let event thread process the notifications
*/
void UpdateCompleted();
-/// Event side interface, can only be called from Update-thread
+ /// Event side interface, can only be called from Update-thread
/**
* Query whether the NotificationManager has messages to process.
void ProcessMessages();
private:
-
// Undefined
- NotificationManager( const NotificationManager& notificationManager );
+ NotificationManager(const NotificationManager& notificationManager);
// Undefined
- NotificationManager& operator=( const NotificationManager& notificationManager );
+ NotificationManager& operator=(const NotificationManager& notificationManager);
private:
-
struct Impl;
Impl* mImpl;
-
};
} // namespace Internal
} // namespace Dali
#endif // DALI_INTERNAL_NOTIFICATION_MANAGER_H
-
#define DALI_INTERNAL_OBJECT_CONNECTOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* @brief Wrapper class which helps managing intrusive pointer assignments and Connect / Disconnect.
*
/**
* @brief Copy constructor
*/
- ObjectConnector( const ObjectConnector& connector )
- : mObject( connector.mObject )
+ ObjectConnector(const ObjectConnector& connector)
+ : mObject(connector.mObject)
{
}
/**
* @brief Assignment operator
*/
- ObjectConnector& operator=( const ObjectConnector& connector )
+ ObjectConnector& operator=(const ObjectConnector& connector)
{
this->mObject = connector.mObject;
return *this;
* @param [in] object smart pointer to a object
* @param [in] onScene whether the object is used on stage or not
*/
- void Set( Object& object, bool onScene )
+ void Set(Object& object, bool onScene)
{
- if ( mObject.Get() != &object )
+ if(mObject.Get() != &object)
{
// Disconnect from old object
- if ( mObject && onScene )
+ if(mObject && onScene)
{
mObject->Disconnect();
}
mObject = &object;
// Connect to new object
- if ( mObject && onScene )
+ if(mObject && onScene)
{
mObject->Connect();
}
*/
void OnSceneConnect()
{
- if ( mObject )
+ if(mObject)
{
mObject->Connect();
}
*/
void OnSceneDisconnect()
{
- if ( mObject )
+ if(mObject)
{
mObject->Disconnect();
}
}
-private: //data
- ObjectPtr mObject; ///< intrusive pointer to the Object. ObjectConnector owns this.
-
+private: //data
+ ObjectPtr mObject; ///< intrusive pointer to the Object. ObjectConnector owns this.
};
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <algorithm>
// INTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
#include <dali/devel-api/object/handle-devel.h>
-#include <dali/internal/update/animation/scene-graph-constraint-base.h>
-#include <dali/internal/update/common/animatable-property.h>
-#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/property-owner-messages.h>
-#include <dali/internal/update/common/uniform-map.h>
+#include <dali/integration-api/debug.h>
+#include <dali/internal/common/const-string.h>
#include <dali/internal/event/animation/constraint-impl.h>
#include <dali/internal/event/common/property-helper.h>
#include <dali/internal/event/common/property-notification-impl.h>
#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/event/common/type-registry-impl.h>
-#include <dali/internal/common/const-string.h>
+#include <dali/internal/update/animation/scene-graph-constraint-base.h>
+#include <dali/internal/update/common/animatable-property.h>
+#include <dali/internal/update/common/property-owner-messages.h>
+#include <dali/internal/update/common/property-owner.h>
+#include <dali/internal/update/common/uniform-map.h>
using Dali::Internal::SceneGraph::AnimatableProperty;
using Dali::Internal::SceneGraph::PropertyBase;
namespace Dali
{
-
namespace Internal
{
-
namespace // unnamed namespace
{
-const int32_t SUPPORTED_CAPABILITIES = Dali::Handle::DYNAMIC_PROPERTIES; // Object provides this capability
+const int32_t SUPPORTED_CAPABILITIES = Dali::Handle::DYNAMIC_PROPERTIES; // Object provides this capability
#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_OBJECT" );
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_OBJECT");
#endif
constexpr Property::Index MAX_PER_CLASS_PROPERTY_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX;
IntrusivePtr<Object> Object::New()
{
- return new Object( nullptr ); // no scene object by default
+ return new Object(nullptr); // no scene object by default
}
void Object::AddObserver(Observer& observer)
{
// make sure an observer doesn't observe the same object twice
// otherwise it will get multiple calls to OnSceneObjectAdd(), OnSceneObjectRemove() and ObjectDestroyed()
- DALI_ASSERT_DEBUG( mObservers.End() == std::find( mObservers.Begin(), mObservers.End(), &observer));
+ DALI_ASSERT_DEBUG(mObservers.End() == std::find(mObservers.Begin(), mObservers.End(), &observer));
- mObservers.PushBack( &observer );
+ mObservers.PushBack(&observer);
}
void Object::RemoveObserver(Observer& observer)
{
// Find the observer...
- const auto endIter = mObservers.End();
- for( auto iter = mObservers.Begin(); iter != endIter; ++iter)
+ const auto endIter = mObservers.End();
+ for(auto iter = mObservers.Begin(); iter != endIter; ++iter)
{
- if( (*iter) == &observer)
+ if((*iter) == &observer)
{
- mObservers.Erase( iter );
+ mObservers.Erase(iter);
break;
}
}
DALI_ASSERT_DEBUG(endIter != mObservers.End());
}
-bool Object::Supports( Capability capability ) const
+bool Object::Supports(Capability capability) const
{
return (capability & SUPPORTED_CAPABILITIES);
}
uint32_t Object::GetPropertyCount() const
{
- uint32_t count = 0u;
- const TypeInfo* typeInfo( GetTypeInfo() );
- if ( typeInfo )
+ uint32_t count = 0u;
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
{
count = typeInfo->GetPropertyCount();
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Registered Properties: %d\n", count );
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Registered Properties: %d\n", count);
}
- uint32_t custom = static_cast<uint32_t>( mCustomProperties.Count() );
+ uint32_t custom = static_cast<uint32_t>(mCustomProperties.Count());
count += custom;
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Custom Properties: %d\n", custom );
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Custom Properties: %d\n", custom);
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "Total Properties: %d\n", count );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "Total Properties: %d\n", count);
return count;
}
std::string_view Object::GetPropertyName(Property::Index index) const
{
- DALI_ASSERT_ALWAYS( index > Property::INVALID_INDEX && "Property index out of bounds" );
+ DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index out of bounds");
// is this a per class or per instance property
- if ( index < MAX_PER_CLASS_PROPERTY_INDEX )
+ if(index < MAX_PER_CLASS_PROPERTY_INDEX)
{
- const TypeInfo* typeInfo( GetTypeInfo() );
- if ( typeInfo )
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
{
- return typeInfo->GetPropertyName( index );
+ return typeInfo->GetPropertyName(index);
}
}
else // child property or custom property
{
- CustomPropertyMetadata* custom = FindCustomProperty( index );
- if( custom )
+ CustomPropertyMetadata* custom = FindCustomProperty(index);
+ if(custom)
{
return custom->name.GetStringView();
}
}
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
return {};
}
if(key.mType == Property::Key::STRING)
{
- const TypeInfo* typeInfo( GetTypeInfo() );
- if ( typeInfo )
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
{
index = typeInfo->GetPropertyIndex(key.mString);
}
}
- if( (index == Property::INVALID_INDEX)&&( mCustomProperties.Count() > 0 ) )
+ if((index == Property::INVALID_INDEX) && (mCustomProperties.Count() > 0))
{
Property::Index count = PROPERTY_CUSTOM_START_INDEX;
- const auto end = mCustomProperties.End();
- for( auto iter = mCustomProperties.Begin(); iter != end; ++iter, ++count )
+ const auto end = mCustomProperties.End();
+ for(auto iter = mCustomProperties.Begin(); iter != end; ++iter, ++count)
{
CustomPropertyMetadata* custom = static_cast<CustomPropertyMetadata*>(*iter);
if((key.mType == Property::Key::STRING && custom->name == key.mString) ||
(key.mType == Property::Key::INDEX && custom->key == key.mIndex))
{
- if ( custom->childPropertyIndex != Property::INVALID_INDEX )
+ if(custom->childPropertyIndex != Property::INVALID_INDEX)
{
// If it is a child property, return the child property index
index = custom->childPropertyIndex;
return index;
}
-bool Object::IsPropertyWritable( Property::Index index ) const
+bool Object::IsPropertyWritable(Property::Index index) const
{
DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds");
bool writable = false;
// is this a per class or per instance property
- if ( index < MAX_PER_CLASS_PROPERTY_INDEX )
+ if(index < MAX_PER_CLASS_PROPERTY_INDEX)
{
- const TypeInfo* typeInfo( GetTypeInfo() );
- if ( typeInfo )
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
{
- writable = typeInfo->IsPropertyWritable( index );
+ writable = typeInfo->IsPropertyWritable(index);
}
}
else
{
- CustomPropertyMetadata* custom = FindCustomProperty( index );
- if( custom )
+ CustomPropertyMetadata* custom = FindCustomProperty(index);
+ if(custom)
{
writable = custom->IsWritable();
}
return writable;
}
-bool Object::IsPropertyAnimatable( Property::Index index ) const
+bool Object::IsPropertyAnimatable(Property::Index index) const
{
DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds");
bool animatable = false;
// is this a per class or per instance property
- if ( index < MAX_PER_CLASS_PROPERTY_INDEX )
+ if(index < MAX_PER_CLASS_PROPERTY_INDEX)
{
- const TypeInfo* typeInfo( GetTypeInfo() );
- if ( typeInfo )
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
{
- animatable = typeInfo->IsPropertyAnimatable( index );
+ animatable = typeInfo->IsPropertyAnimatable(index);
}
}
else
{
- CustomPropertyMetadata* custom = FindCustomProperty( index );
- if( custom )
+ CustomPropertyMetadata* custom = FindCustomProperty(index);
+ if(custom)
{
animatable = custom->IsAnimatable();
}
return animatable;
}
-bool Object::IsPropertyAConstraintInput( Property::Index index ) const
+bool Object::IsPropertyAConstraintInput(Property::Index index) const
{
DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds");
bool isConstraintInput = false;
// is this a per class or per instance property
- if ( index < MAX_PER_CLASS_PROPERTY_INDEX )
+ if(index < MAX_PER_CLASS_PROPERTY_INDEX)
{
- const TypeInfo* typeInfo( GetTypeInfo() );
- if ( typeInfo )
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
{
- isConstraintInput = typeInfo->IsPropertyAConstraintInput( index );
+ isConstraintInput = typeInfo->IsPropertyAConstraintInput(index);
}
}
else
{
- CustomPropertyMetadata* custom = FindCustomProperty( index );
- if( custom )
+ CustomPropertyMetadata* custom = FindCustomProperty(index);
+ if(custom)
{
// ... custom properties can be used as input to a constraint.
isConstraintInput = true;
return isConstraintInput;
}
-Property::Type Object::GetPropertyType( Property::Index index ) const
+Property::Type Object::GetPropertyType(Property::Index index) const
{
- DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds" );
+ DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds");
// is this a per class or per instance property
- if ( index < MAX_PER_CLASS_PROPERTY_INDEX )
+ if(index < MAX_PER_CLASS_PROPERTY_INDEX)
{
- const TypeInfo* typeInfo( GetTypeInfo() );
- if ( typeInfo )
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
{
- return typeInfo->GetPropertyType( index );
+ return typeInfo->GetPropertyType(index);
}
}
- CustomPropertyMetadata* custom = FindCustomProperty( index );
- if( custom )
+ CustomPropertyMetadata* custom = FindCustomProperty(index);
+ if(custom)
{
return custom->GetType();
}
void Object::SetProperty(Property::Index index, Property::Value propertyValue)
{
- DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds" );
+ DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds");
- bool propertySet( true );
+ bool propertySet(true);
- if ( index < DEFAULT_PROPERTY_MAX_COUNT )
+ if(index < DEFAULT_PROPERTY_MAX_COUNT)
{
- SetDefaultProperty( index, propertyValue );
+ SetDefaultProperty(index, propertyValue);
}
- else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX))
{
- const TypeInfo* typeInfo( GetTypeInfo() );
- if ( typeInfo )
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
{
- typeInfo->SetProperty( this, index, propertyValue );
+ typeInfo->SetProperty(this, index, propertyValue);
}
else
{
// cannot register this property as there is no setter for it.
// event side properties must have a setter for now so need to be registered
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
propertySet = false;
}
}
- else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX))
{
// check whether the animatable property is registered already, if not then register one.
- AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty( index, &propertyValue );
- if( !animatableProperty )
+ AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty(index, &propertyValue);
+ if(!animatableProperty)
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
propertySet = false;
}
else
{
// update the cached property value
- animatableProperty->SetPropertyValue( propertyValue );
+ animatableProperty->SetPropertyValue(propertyValue);
// set the scene graph property value
- SetSceneGraphProperty( index, *animatableProperty, propertyValue );
+ SetSceneGraphProperty(index, *animatableProperty, propertyValue);
}
}
else
{
- CustomPropertyMetadata* custom = FindCustomProperty( index );
+ CustomPropertyMetadata* custom = FindCustomProperty(index);
- if ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ if((index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX))
{
- if( !custom )
+ if(!custom)
{
// If the child property is not registered yet, register it.
custom = new CustomPropertyMetadata({}, propertyValue, Property::READ_WRITE);
- mCustomProperties.PushBack( custom );
+ mCustomProperties.PushBack(custom);
}
custom->childPropertyIndex = index;
// Resolve name for the child property
Object* parent = GetParentObject();
- if( parent )
+ if(parent)
{
- const TypeInfo* parentTypeInfo( parent->GetTypeInfo() );
- if( parentTypeInfo )
+ const TypeInfo* parentTypeInfo(parent->GetTypeInfo());
+ if(parentTypeInfo)
{
custom->name = ConstString(parentTypeInfo->GetChildPropertyName(index));
}
}
}
- if( custom )
+ if(custom)
{
- if( custom->IsAnimatable() )
+ if(custom->IsAnimatable())
{
// update the cached property value
- custom->SetPropertyValue( propertyValue );
+ custom->SetPropertyValue(propertyValue);
// set the scene graph property value
- SetSceneGraphProperty( index, *custom, propertyValue );
+ SetSceneGraphProperty(index, *custom, propertyValue);
}
- else if( custom->IsWritable() )
+ else if(custom->IsWritable())
{
// update the cached property value
- custom->SetPropertyValue( propertyValue );
+ custom->SetPropertyValue(propertyValue);
}
else
{
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
propertySet = false;
}
}
// Let derived classes know that a property has been set
// TODO: We should not call this for read-only properties, SetDefaultProperty() && TypeInfo::SetProperty() should return a bool, which would be true if the property is set
- if ( propertySet )
+ if(propertySet)
{
- OnPropertySet( index, propertyValue );
+ OnPropertySet(index, propertyValue);
if(!mPropertySetSignal.Empty())
{
Dali::Handle handle(this);
}
}
-Property::Value Object::GetProperty( Property::Index index ) const
+Property::Value Object::GetProperty(Property::Index index) const
{
- DALI_ASSERT_ALWAYS( index > Property::INVALID_INDEX && "Property index is out of bounds" );
+ DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds");
Property::Value value;
- if ( index < DEFAULT_PROPERTY_MAX_COUNT )
+ if(index < DEFAULT_PROPERTY_MAX_COUNT)
{
- value = GetDefaultProperty( index );
+ value = GetDefaultProperty(index);
}
- else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX))
{
- const TypeInfo* typeInfo( GetTypeInfo() );
- if ( typeInfo )
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
{
- value = typeInfo->GetProperty( this, index );
+ value = typeInfo->GetProperty(this, index);
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
}
- else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX))
{
// check whether the animatable property is registered already, if not then register one.
// this is needed because property value may have been set as full property and get as a property component
- AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty( index, nullptr );
- if( animatableProperty )
+ AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty(index, nullptr);
+ if(animatableProperty)
{
// get the cached animatable property value
value = animatableProperty->GetPropertyValue();
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
}
else if(mCustomProperties.Count() > 0)
{
- CustomPropertyMetadata* custom = FindCustomProperty( index );
+ CustomPropertyMetadata* custom = FindCustomProperty(index);
if(custom)
{
// get the cached custom property value
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
} // if custom
return value;
}
-Property::Value Object::GetCurrentProperty( Property::Index index ) const
+Property::Value Object::GetCurrentProperty(Property::Index index) const
{
- DALI_ASSERT_ALWAYS( index > Property::INVALID_INDEX && "Property index is out of bounds" );
+ DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds");
Property::Value value;
- if ( index < DEFAULT_PROPERTY_MAX_COUNT )
+ if(index < DEFAULT_PROPERTY_MAX_COUNT)
{
- value = GetDefaultPropertyCurrentValue( index );
+ value = GetDefaultPropertyCurrentValue(index);
}
- else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX))
{
- const TypeInfo* typeInfo( GetTypeInfo() );
- if ( typeInfo )
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
{
- value = typeInfo->GetProperty( this, index );
+ value = typeInfo->GetProperty(this, index);
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
}
- else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX))
{
// check whether the animatable property is registered already, if not then register one.
// this is needed because property value may have been set as full property and get as a property component
- AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty( index, nullptr );
- if( animatableProperty )
+ AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty(index, nullptr);
+ if(animatableProperty)
{
// get the animatable property value
- value = GetCurrentPropertyValue( *animatableProperty );
+ value = GetCurrentPropertyValue(*animatableProperty);
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
}
else if(mCustomProperties.Count() > 0)
{
- CustomPropertyMetadata* custom = FindCustomProperty( index );
+ CustomPropertyMetadata* custom = FindCustomProperty(index);
if(custom)
{
// get the custom property value
- value = GetCurrentPropertyValue( *custom );
+ value = GetCurrentPropertyValue(*custom);
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
} // if custom
return value;
}
-void Object::GetPropertyIndices( Property::IndexContainer& indices ) const
+void Object::GetPropertyIndices(Property::IndexContainer& indices) const
{
indices.Clear();
// Manual Properties
- const TypeInfo* typeInfo( GetTypeInfo() );
- if ( typeInfo )
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
{
- typeInfo->GetPropertyIndices( indices );
+ typeInfo->GetPropertyIndices(indices);
}
// Custom Properties
- if ( mCustomProperties.Count() > 0 )
+ if(mCustomProperties.Count() > 0)
{
- indices.Reserve( indices.Size() + mCustomProperties.Count() );
+ indices.Reserve(indices.Size() + mCustomProperties.Count());
- auto iter = mCustomProperties.Begin();
+ auto iter = mCustomProperties.Begin();
const auto endIter = mCustomProperties.End();
- int32_t i = 0;
- for ( ; iter != endIter; ++iter, ++i )
+ int32_t i = 0;
+ for(; iter != endIter; ++iter, ++i)
{
- CustomPropertyMetadata* custom = static_cast<CustomPropertyMetadata*>( *iter );
- if ( custom->childPropertyIndex != Property::INVALID_INDEX )
+ CustomPropertyMetadata* custom = static_cast<CustomPropertyMetadata*>(*iter);
+ if(custom->childPropertyIndex != Property::INVALID_INDEX)
{
// If it is a child property, add the child property index
- indices.PushBack( custom->childPropertyIndex );
+ indices.PushBack(custom->childPropertyIndex);
}
else
{
- indices.PushBack( PROPERTY_CUSTOM_START_INDEX + i );
+ indices.PushBack(PROPERTY_CUSTOM_START_INDEX + i);
}
}
}
return RegisterProperty(name, key, std::move(propertyValue), Property::ANIMATABLE);
}
-void Object::SetProperties( const Property::Map& properties )
+void Object::SetProperties(const Property::Map& properties)
{
const auto count = properties.Count();
- for( auto position = 0u; position < count; ++position )
+ for(auto position = 0u; position < count; ++position)
{
// GetKeyAt and GetValue both return references which means no potential copying of maps/arrays.
// Iterating twice to get the value we want should still be fairly quick in a Property::Map.
- const auto& key = properties.GetKeyAt( position );
- const auto propertyIndex = ( key.type == Property::Key::INDEX ) ? key.indexKey : GetPropertyIndex( key );
+ const auto& key = properties.GetKeyAt(position);
+ const auto propertyIndex = (key.type == Property::Key::INDEX) ? key.indexKey : GetPropertyIndex(key);
- if( propertyIndex != Property::INVALID_INDEX )
+ if(propertyIndex != Property::INVALID_INDEX)
{
- const auto& value = properties.GetValue( position );
- SetProperty( propertyIndex, value );
+ const auto& value = properties.GetValue(position);
+ SetProperty(propertyIndex, value);
}
}
}
-void Object::GetProperties( Property::Map& properties )
+void Object::GetProperties(Property::Map& properties)
{
properties.Clear();
Property::IndexContainer indexContainer;
- GetPropertyIndices( indexContainer );
+ GetPropertyIndices(indexContainer);
- for( auto index : indexContainer )
+ for(auto index : indexContainer)
{
- properties[ index ] = GetProperty( index );
+ properties[index] = GetProperty(index);
}
}
auto constString = ConstString(name);
// If property with the required key already exists, then just set it.
Property::Index index = Property::INVALID_INDEX;
- if( key != Property::INVALID_KEY ) // Try integer key first if it's valid
+ if(key != Property::INVALID_KEY) // Try integer key first if it's valid
{
- index = GetPropertyIndex( key );
+ index = GetPropertyIndex(key);
}
- if( index == Property::INVALID_INDEX ) // If it wasn't valid, or doesn't exist, try name
+ if(index == Property::INVALID_INDEX) // If it wasn't valid, or doesn't exist, try name
{
index = GetPropertyIndex(constString);
}
- if( index != Property::INVALID_INDEX ) // If there was a valid index found by either key, set it.
+ if(index != Property::INVALID_INDEX) // If there was a valid index found by either key, set it.
{
SetProperty(index, std::move(propertyValue));
}
else
{
// Otherwise register the property
- if( Property::ANIMATABLE == accessMode )
+ if(Property::ANIMATABLE == accessMode)
{
index = RegisterSceneGraphProperty(
constString,
else
{
// Add entry to the property lookup
- index = PROPERTY_CUSTOM_START_INDEX + static_cast<Property::Index>( mCustomProperties.Count() );
+ index = PROPERTY_CUSTOM_START_INDEX + static_cast<Property::Index>(mCustomProperties.Count());
CustomPropertyMetadata* customProperty =
new CustomPropertyMetadata(constString, std::move(propertyValue), accessMode);
// Resolve index for the child property
Object* parent = GetParentObject();
- if( parent )
+ if(parent)
{
- const TypeInfo* parentTypeInfo( parent->GetTypeInfo() );
- if( parentTypeInfo )
+ const TypeInfo* parentTypeInfo(parent->GetTypeInfo());
+ if(parentTypeInfo)
{
Property::Index childPropertyIndex = parentTypeInfo->GetChildPropertyIndex(customProperty->name);
- if( childPropertyIndex != Property::INVALID_INDEX )
+ if(childPropertyIndex != Property::INVALID_INDEX)
{
customProperty->childPropertyIndex = childPropertyIndex;
- index = childPropertyIndex;
+ index = childPropertyIndex;
}
}
}
- mCustomProperties.PushBack( customProperty );
+ mCustomProperties.PushBack(customProperty);
}
}
return index;
}
-bool Object::DoesCustomPropertyExist( Property::Index index )
+bool Object::DoesCustomPropertyExist(Property::Index index)
{
- auto metadata = FindCustomProperty( index );
+ auto metadata = FindCustomProperty(index);
return metadata != nullptr;
}
-Dali::PropertyNotification Object::AddPropertyNotification( Property::Index index,
- int32_t componentIndex,
- const Dali::PropertyCondition& condition)
+Dali::PropertyNotification Object::AddPropertyNotification(Property::Index index,
+ int32_t componentIndex,
+ const Dali::PropertyCondition& condition)
{
- if ( index >= DEFAULT_PROPERTY_MAX_COUNT )
+ if(index >= DEFAULT_PROPERTY_MAX_COUNT)
{
- if ( index <= PROPERTY_REGISTRATION_MAX_INDEX )
+ if(index <= PROPERTY_REGISTRATION_MAX_INDEX)
{
- DALI_ABORT( "Property notification added to event side only property." );
+ DALI_ABORT("Property notification added to event side only property.");
}
- else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX))
{
// check whether the animatable property is registered already, if not then register one.
- AnimatablePropertyMetadata* animatable = GetSceneAnimatableProperty( index, nullptr );
- DALI_ASSERT_ALWAYS( animatable && "Property index is invalid" );
+ AnimatablePropertyMetadata* animatable = GetSceneAnimatableProperty(index, nullptr);
+ DALI_ASSERT_ALWAYS(animatable && "Property index is invalid");
}
- else if ( mCustomProperties.Count() > 0 )
+ else if(mCustomProperties.Count() > 0)
{
- CustomPropertyMetadata* custom = FindCustomProperty( index );
- DALI_ASSERT_ALWAYS( custom && "Invalid property index" );
- DALI_ASSERT_ALWAYS( custom->IsAnimatable() && "Property notification added to event side only property." );
+ CustomPropertyMetadata* custom = FindCustomProperty(index);
+ DALI_ASSERT_ALWAYS(custom && "Invalid property index");
+ DALI_ASSERT_ALWAYS(custom->IsAnimatable() && "Property notification added to event side only property.");
}
}
Dali::Handle self(this);
- Property target( self, index );
+ Property target(self, index);
- PropertyNotificationPtr internal = PropertyNotification::New( target, componentIndex, condition );
+ PropertyNotificationPtr internal = PropertyNotification::New(target, componentIndex, condition);
Dali::PropertyNotification propertyNotification(internal.Get());
- if( !mPropertyNotifications )
+ if(!mPropertyNotifications)
{
mPropertyNotifications = new PropertyNotificationContainer;
}
void Object::RemovePropertyNotification(Dali::PropertyNotification propertyNotification)
{
- if( mPropertyNotifications )
+ if(mPropertyNotifications)
{
auto iter = mPropertyNotifications->begin();
- while(iter != mPropertyNotifications->end() )
+ while(iter != mPropertyNotifications->end())
{
if(*iter == propertyNotification)
{
void Object::RemovePropertyNotifications()
{
- if( mPropertyNotifications )
+ if(mPropertyNotifications)
{
auto iter = mPropertyNotifications->begin();
- while(iter != mPropertyNotifications->end() )
+ while(iter != mPropertyNotifications->end())
{
// As we can't ensure all references are removed, we can just disable
// the notification.
}
}
-void Object::NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
+void Object::NotifyPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType)
{
- if ( index < DEFAULT_PROPERTY_MAX_COUNT )
+ if(index < DEFAULT_PROPERTY_MAX_COUNT)
{
- OnNotifyDefaultPropertyAnimation( animation, index, value, animationType );
+ OnNotifyDefaultPropertyAnimation(animation, index, value, animationType);
}
else
{
PropertyMetadata* propertyMetadata = nullptr;
- if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ if((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX))
{
- propertyMetadata = FindAnimatableProperty( index );
+ propertyMetadata = FindAnimatableProperty(index);
}
else
{
- CustomPropertyMetadata* custom = FindCustomProperty( index );
- if( custom && custom->IsAnimatable() )
+ CustomPropertyMetadata* custom = FindCustomProperty(index);
+ if(custom && custom->IsAnimatable())
{
propertyMetadata = custom;
}
}
- if( propertyMetadata )
+ if(propertyMetadata)
{
- switch( animationType )
+ switch(animationType)
{
case Animation::TO:
case Animation::BETWEEN:
{
// Update the cached property value
- propertyMetadata->SetPropertyValue( value );
+ propertyMetadata->SetPropertyValue(value);
break;
}
case Animation::BY:
{
// Adjust the cached property value
- propertyMetadata->AdjustPropertyValueBy( value );
+ propertyMetadata->AdjustPropertyValueBy(value);
break;
}
}
void Object::AddUniformMapping(Property::Index propertyIndex, ConstString uniformName) const
{
// Get the address of the property if it's a scene property
- const PropertyInputImpl* propertyPtr = GetSceneObjectInputProperty( propertyIndex );
+ const PropertyInputImpl* propertyPtr = GetSceneObjectInputProperty(propertyIndex);
// Check instead for newly registered properties
- if( propertyPtr == nullptr )
+ if(propertyPtr == nullptr)
{
- PropertyMetadata* animatable = FindAnimatableProperty( propertyIndex );
- if( animatable )
+ PropertyMetadata* animatable = FindAnimatableProperty(propertyIndex);
+ if(animatable)
{
propertyPtr = animatable->GetSceneGraphProperty();
}
}
- if( propertyPtr == nullptr )
+ if(propertyPtr == nullptr)
{
- PropertyMetadata* custom = FindCustomProperty( propertyIndex );
- if( custom )
+ PropertyMetadata* custom = FindCustomProperty(propertyIndex);
+ if(custom)
{
propertyPtr = custom->GetSceneGraphProperty();
}
}
- if( propertyPtr )
+ if(propertyPtr)
{
const SceneGraph::PropertyOwner& sceneObject = GetSceneObject();
SceneGraph::UniformPropertyMapping map(uniformName, propertyPtr);
// Message takes ownership of Uniform map (and will delete it after copy)
- AddUniformMapMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), sceneObject, map );
+ AddUniformMapMessage(const_cast<EventThreadServices&>(GetEventThreadServices()), sceneObject, map);
}
}
-void Object::RemoveUniformMapping( const std::string& uniformName ) const
+void Object::RemoveUniformMapping(const std::string& uniformName) const
{
const SceneGraph::PropertyOwner& sceneObject = GetSceneObject();
- RemoveUniformMapMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), sceneObject, ConstString(uniformName));
+ RemoveUniformMapMessage(const_cast<EventThreadServices&>(GetEventThreadServices()), sceneObject, ConstString(uniformName));
}
-void Object::ApplyConstraint( ConstraintBase& constraint )
+void Object::ApplyConstraint(ConstraintBase& constraint)
{
- if( !mConstraints )
+ if(!mConstraints)
{
mConstraints = new ConstraintContainer;
}
- mConstraints->push_back( Dali::Constraint( &constraint ) );
+ mConstraints->push_back(Dali::Constraint(&constraint));
}
-void Object::RemoveConstraint( ConstraintBase& constraint )
+void Object::RemoveConstraint(ConstraintBase& constraint)
{
// nullptr if the Constraint sources are destroyed before Constraint::Apply()
- if( mConstraints )
+ if(mConstraints)
{
- ConstraintIter it( std::find( mConstraints->begin(), mConstraints->end(), Dali::Constraint( &constraint ) ) );
- if( it != mConstraints->end() )
+ ConstraintIter it(std::find(mConstraints->begin(), mConstraints->end(), Dali::Constraint(&constraint)));
+ if(it != mConstraints->end())
{
- mConstraints->erase( it );
+ mConstraints->erase(it);
}
}
}
void Object::RemoveConstraints()
{
// guard against constraint sending messages during core destruction
- if( mConstraints && Stage::IsInstalled() )
+ if(mConstraints && Stage::IsInstalled())
{
- for ( auto&& item : *mConstraints )
+ for(auto&& item : *mConstraints)
{
- GetImplementation( item ).RemoveInternal();
+ GetImplementation(item).RemoveInternal();
}
delete mConstraints;
}
}
-void Object::RemoveConstraints( uint32_t tag )
+void Object::RemoveConstraints(uint32_t tag)
{
// guard against constraint sending messages during core destruction
- if( mConstraints && Stage::IsInstalled() )
+ if(mConstraints && Stage::IsInstalled())
{
- auto iter( mConstraints->begin() );
- while(iter != mConstraints->end() )
+ auto iter(mConstraints->begin());
+ while(iter != mConstraints->end())
{
- ConstraintBase& constraint = GetImplementation( *iter );
- if( constraint.GetTag() == tag )
+ ConstraintBase& constraint = GetImplementation(*iter);
+ if(constraint.GetTag() == tag)
{
- GetImplementation( *iter ).RemoveInternal();
- iter = mConstraints->erase( iter );
+ GetImplementation(*iter).RemoveInternal();
+ iter = mConstraints->erase(iter);
}
else
{
}
}
- if ( mConstraints->empty() )
+ if(mConstraints->empty())
{
delete mConstraints;
mConstraints = nullptr;
}
}
-void Object::SetTypeInfo( const TypeInfo* typeInfo )
+void Object::SetTypeInfo(const TypeInfo* typeInfo)
{
mTypeInfo = typeInfo;
}
const SceneGraph::PropertyOwner& Object::GetSceneObject() const
{
- if( !mUpdateObject )
+ if(!mUpdateObject)
{
- auto sceneObject = SceneGraph::PropertyOwner::New();
- OwnerPointer< SceneGraph::PropertyOwner > transferOwnership( sceneObject );
+ auto sceneObject = SceneGraph::PropertyOwner::New();
+ OwnerPointer<SceneGraph::PropertyOwner> transferOwnership(sceneObject);
mUpdateObject = sceneObject;
- AddObjectMessage( const_cast<EventThreadServices&>( GetEventThreadServices() ).GetUpdateManager(), transferOwnership );
+ AddObjectMessage(const_cast<EventThreadServices&>(GetEventThreadServices()).GetUpdateManager(), transferOwnership);
}
- DALI_ASSERT_DEBUG( mUpdateObject && "there must always be a scene object" );
+ DALI_ASSERT_DEBUG(mUpdateObject && "there must always be a scene object");
return *mUpdateObject;
}
-const PropertyBase* Object::GetSceneObjectAnimatableProperty( Property::Index index ) const
+const PropertyBase* Object::GetSceneObjectAnimatableProperty(Property::Index index) const
{
const SceneGraph::PropertyBase* property = nullptr;
- if ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX && index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )
+ if(index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX && index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)
{
- AnimatablePropertyMetadata* animatable = GetSceneAnimatableProperty( index, nullptr );
- DALI_ASSERT_ALWAYS( animatable && "Property index is invalid" );
+ AnimatablePropertyMetadata* animatable = GetSceneAnimatableProperty(index, nullptr);
+ DALI_ASSERT_ALWAYS(animatable && "Property index is invalid");
property = animatable->GetSceneGraphProperty();
}
- else if ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && // Child properties are also stored as custom properties
- ( index <= PROPERTY_CUSTOM_MAX_INDEX ) )
+ else if((index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && // Child properties are also stored as custom properties
+ (index <= PROPERTY_CUSTOM_MAX_INDEX))
{
- CustomPropertyMetadata* custom = FindCustomProperty( index );
- DALI_ASSERT_ALWAYS( custom && "Property index is invalid" );
+ CustomPropertyMetadata* custom = FindCustomProperty(index);
+ DALI_ASSERT_ALWAYS(custom && "Property index is invalid");
property = custom->GetSceneGraphProperty();
}
return property;
}
-const PropertyInputImpl* Object::GetSceneObjectInputProperty( Property::Index index ) const
+const PropertyInputImpl* Object::GetSceneObjectInputProperty(Property::Index index) const
{
// reuse animatable version as they are inputs as well
- return GetSceneObjectAnimatableProperty( index );
+ return GetSceneObjectAnimatableProperty(index);
}
-int32_t Object::GetPropertyComponentIndex( Property::Index index ) const
+int32_t Object::GetPropertyComponentIndex(Property::Index index) const
{
int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
- if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ if((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX))
{
// check whether the animatable property is registered already, if not then register one.
- AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty( index, nullptr );
- if( animatableProperty )
+ AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty(index, nullptr);
+ if(animatableProperty)
{
componentIndex = animatableProperty->componentIndex;
}
}
- if( Property::INVALID_COMPONENT_INDEX == componentIndex )
+ if(Property::INVALID_COMPONENT_INDEX == componentIndex)
{
- const TypeInfo* typeInfo( GetTypeInfo() );
- if ( typeInfo )
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
{
componentIndex = typeInfo->GetComponentIndex(index);
}
return mPropertySetSignal;
}
-Object::Object( const SceneGraph::PropertyOwner* sceneObject )
-: mEventThreadServices( EventThreadServices::Get() ),
- mUpdateObject( sceneObject ),
- mTypeInfo( nullptr ),
- mConstraints( nullptr ),
- mPropertyNotifications( nullptr )
+Object::Object(const SceneGraph::PropertyOwner* sceneObject)
+: mEventThreadServices(EventThreadServices::Get()),
+ mUpdateObject(sceneObject),
+ mTypeInfo(nullptr),
+ mConstraints(nullptr),
+ mPropertyNotifications(nullptr)
{
}
Object::~Object()
{
// Notification for observers
- for( auto&& item : mObservers )
+ for(auto&& item : mObservers)
{
- item->ObjectDestroyed( *this );
+ item->ObjectDestroyed(*this);
}
delete mConstraints;
delete mPropertyNotifications;
// Guard to allow handle destruction after Core has been destroyed
- if( Stage::IsInstalled() )
+ if(Stage::IsInstalled())
{
- if( nullptr != mUpdateObject )
+ if(nullptr != mUpdateObject)
{
- RemoveObjectMessage( GetEventThreadServices().GetUpdateManager(), mUpdateObject );
+ RemoveObjectMessage(GetEventThreadServices().GetUpdateManager(), mUpdateObject);
}
}
}
void Object::OnSceneObjectAdd()
{
// Notification for observers
- for( auto&& item : mObservers )
+ for(auto&& item : mObservers)
{
item->SceneObjectAdded(*this);
}
void Object::OnSceneObjectRemove()
{
// Notification for observers
- for( auto&& item : mObservers )
+ for(auto&& item : mObservers)
{
item->SceneObjectRemoved(*this);
}
const TypeInfo* Object::GetTypeInfo() const
{
- if ( !mTypeInfo )
+ if(!mTypeInfo)
{
// This uses a dynamic_cast so can be quite expensive so we only really want to do it once
// especially as the type-info does not change during the life-time of an application
- TypeRegistry::TypeInfoPointer typeInfoHandle = TypeRegistry::Get()->GetTypeInfo( this );
- if ( typeInfoHandle )
+ TypeRegistry::TypeInfoPointer typeInfoHandle = TypeRegistry::Get()->GetTypeInfo(this);
+ if(typeInfoHandle)
{
mTypeInfo = typeInfoHandle.Get(); // just a raw pointer to use, ownership is kept
}
return mTypeInfo;
}
-CustomPropertyMetadata* Object::FindCustomProperty( Property::Index index ) const
+CustomPropertyMetadata* Object::FindCustomProperty(Property::Index index) const
{
CustomPropertyMetadata* property = nullptr;
- if ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ if((index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX))
{
- for ( std::size_t arrayIndex = 0; arrayIndex < mCustomProperties.Count(); arrayIndex++ )
+ for(std::size_t arrayIndex = 0; arrayIndex < mCustomProperties.Count(); arrayIndex++)
{
- CustomPropertyMetadata* custom = static_cast<CustomPropertyMetadata*>( mCustomProperties[ arrayIndex ] );
- if( custom->childPropertyIndex == index )
+ CustomPropertyMetadata* custom = static_cast<CustomPropertyMetadata*>(mCustomProperties[arrayIndex]);
+ if(custom->childPropertyIndex == index)
{
property = custom;
}
else
{
int32_t arrayIndex = index - PROPERTY_CUSTOM_START_INDEX;
- if( arrayIndex >= 0 )
+ if(arrayIndex >= 0)
{
- if( arrayIndex < static_cast<int32_t>( mCustomProperties.Count() ) ) // we can only access the first 2 billion custom properties
+ if(arrayIndex < static_cast<int32_t>(mCustomProperties.Count())) // we can only access the first 2 billion custom properties
{
- property = static_cast<CustomPropertyMetadata*>(mCustomProperties[ arrayIndex ]);
+ property = static_cast<CustomPropertyMetadata*>(mCustomProperties[arrayIndex]);
}
}
}
return property;
}
-AnimatablePropertyMetadata* Object::FindAnimatableProperty( Property::Index index ) const
+AnimatablePropertyMetadata* Object::FindAnimatableProperty(Property::Index index) const
{
- for( auto&& entry : mAnimatableProperties )
+ for(auto&& entry : mAnimatableProperties)
{
- AnimatablePropertyMetadata* property = static_cast<AnimatablePropertyMetadata*>( entry );
- if( property->index == index )
+ AnimatablePropertyMetadata* property = static_cast<AnimatablePropertyMetadata*>(entry);
+ if(property->index == index)
{
return property;
}
// Create a new property
Dali::Internal::OwnerPointer<PropertyBase> newProperty;
- switch ( propertyValue.GetType() )
+ switch(propertyValue.GetType())
{
case Property::BOOLEAN:
{
- newProperty = new AnimatableProperty<bool>( propertyValue.Get<bool>() );
+ newProperty = new AnimatableProperty<bool>(propertyValue.Get<bool>());
break;
}
case Property::INTEGER:
{
- newProperty = new AnimatableProperty<int32_t>( propertyValue.Get<int32_t>() );
+ newProperty = new AnimatableProperty<int32_t>(propertyValue.Get<int32_t>());
break;
}
case Property::FLOAT:
{
- newProperty = new AnimatableProperty<float>( propertyValue.Get<float>() );
+ newProperty = new AnimatableProperty<float>(propertyValue.Get<float>());
break;
}
case Property::VECTOR2:
{
- newProperty = new AnimatableProperty<Vector2>( propertyValue.Get<Vector2>() );
+ newProperty = new AnimatableProperty<Vector2>(propertyValue.Get<Vector2>());
break;
}
case Property::VECTOR3:
{
- newProperty = new AnimatableProperty<Vector3>( propertyValue.Get<Vector3>() );
+ newProperty = new AnimatableProperty<Vector3>(propertyValue.Get<Vector3>());
break;
}
case Property::VECTOR4:
{
- newProperty = new AnimatableProperty<Vector4>( propertyValue.Get<Vector4>() );
+ newProperty = new AnimatableProperty<Vector4>(propertyValue.Get<Vector4>());
break;
}
case Property::MATRIX:
{
- newProperty = new AnimatableProperty<Matrix>( propertyValue.Get<Matrix>() );
+ newProperty = new AnimatableProperty<Matrix>(propertyValue.Get<Matrix>());
break;
}
case Property::MATRIX3:
{
- newProperty = new AnimatableProperty<Matrix3>( propertyValue.Get<Matrix3>() );
+ newProperty = new AnimatableProperty<Matrix3>(propertyValue.Get<Matrix3>());
break;
}
case Property::ROTATION:
{
- newProperty = new AnimatableProperty<Quaternion>( propertyValue.Get<Quaternion>() );
+ newProperty = new AnimatableProperty<Quaternion>(propertyValue.Get<Quaternion>());
break;
}
case Property::EXTENTS:
case Property::NONE:
{
- DALI_ASSERT_ALWAYS( !"Property type is not animatable" );
+ DALI_ASSERT_ALWAYS(!"Property type is not animatable");
break;
}
}
const PropertyBase* property = newProperty.Get();
if(index >= PROPERTY_CUSTOM_START_INDEX)
{
- DALI_ASSERT_ALWAYS( index <= PROPERTY_CUSTOM_MAX_INDEX && "Too many custom properties have been registered" );
+ DALI_ASSERT_ALWAYS(index <= PROPERTY_CUSTOM_MAX_INDEX && "Too many custom properties have been registered");
mCustomProperties.PushBack(new CustomPropertyMetadata(name, key, std::move(propertyValue), property));
}
else
{
- mAnimatableProperties.PushBack( new AnimatablePropertyMetadata( index, std::move(propertyValue), property ) );
+ mAnimatableProperties.PushBack(new AnimatablePropertyMetadata(index, std::move(propertyValue), property));
}
// queue a message to add the property
- InstallCustomPropertyMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), scenePropertyOwner, newProperty ); // Message takes ownership
+ InstallCustomPropertyMessage(const_cast<EventThreadServices&>(GetEventThreadServices()), scenePropertyOwner, newProperty); // Message takes ownership
return index;
}
-void Object::RegisterAnimatableProperty( const TypeInfo& typeInfo,
- Property::Index index,
- const Property::Value* value ) const
+void Object::RegisterAnimatableProperty(const TypeInfo& typeInfo,
+ Property::Index index,
+ const Property::Value* value) const
{
// If the property is not a component of a base property, register the whole property itself.
auto propertyName = ConstString(typeInfo.GetPropertyName(index));
Property::Value initialValue;
- if( value )
+ if(value)
{
initialValue = *value;
}
else
{
- initialValue = typeInfo.GetPropertyDefaultValue( index ); // recurses type hierarchy
- if( Property::NONE == initialValue.GetType() )
+ initialValue = typeInfo.GetPropertyDefaultValue(index); // recurses type hierarchy
+ if(Property::NONE == initialValue.GetType())
{
- initialValue = Property::Value( typeInfo.GetPropertyType( index ) ); // recurses type hierarchy
+ initialValue = Property::Value(typeInfo.GetPropertyType(index)); // recurses type hierarchy
}
}
- RegisterSceneGraphProperty( propertyName, Property::INVALID_KEY, index, initialValue );
- AddUniformMapping( index, propertyName );
+ RegisterSceneGraphProperty(propertyName, Property::INVALID_KEY, index, initialValue);
+ AddUniformMapping(index, propertyName);
}
-AnimatablePropertyMetadata* Object::GetSceneAnimatableProperty( Property::Index index, const Property::Value* value ) const
+AnimatablePropertyMetadata* Object::GetSceneAnimatableProperty(Property::Index index, const Property::Value* value) const
{
// property range already checked by calling methods
// check whether the animatable property is registered already, if not then register one.
- AnimatablePropertyMetadata* animatableProperty = FindAnimatableProperty( index );
- if( !animatableProperty )
+ AnimatablePropertyMetadata* animatableProperty = FindAnimatableProperty(index);
+ if(!animatableProperty)
{
- const TypeInfo* typeInfo( GetTypeInfo() );
- if( typeInfo )
+ const TypeInfo* typeInfo(GetTypeInfo());
+ if(typeInfo)
{
- Property::Index basePropertyIndex = typeInfo->GetBasePropertyIndex( index );
- if( basePropertyIndex == Property::INVALID_INDEX )
+ Property::Index basePropertyIndex = typeInfo->GetBasePropertyIndex(index);
+ if(basePropertyIndex == Property::INVALID_INDEX)
{
// If the property is not a component of a base property, register the whole property itself.
- RegisterAnimatableProperty( *typeInfo, index, value );
+ RegisterAnimatableProperty(*typeInfo, index, value);
}
else
{
// Since the property is a component of a base property, check whether the base property is registered.
- animatableProperty = FindAnimatableProperty( basePropertyIndex );
- if( !animatableProperty )
+ animatableProperty = FindAnimatableProperty(basePropertyIndex);
+ if(!animatableProperty)
{
// If the base property is not registered yet, register the base property first.
- RegisterAnimatableProperty( *typeInfo, basePropertyIndex, value );
- animatableProperty = static_cast<AnimatablePropertyMetadata*>(mAnimatableProperties[mAnimatableProperties.Size()-1]);
+ RegisterAnimatableProperty(*typeInfo, basePropertyIndex, value);
+ animatableProperty = static_cast<AnimatablePropertyMetadata*>(mAnimatableProperties[mAnimatableProperties.Size() - 1]);
}
// Create the metadata for the property component.
- mAnimatableProperties.PushBack( new AnimatablePropertyMetadata( index, typeInfo->GetComponentIndex(index), animatableProperty->value, animatableProperty->GetSceneGraphProperty() ) );
+ mAnimatableProperties.PushBack(new AnimatablePropertyMetadata(index, typeInfo->GetComponentIndex(index), animatableProperty->value, animatableProperty->GetSceneGraphProperty()));
}
// The metadata has just been added and therefore should be in the end of the vector.
- animatableProperty = static_cast<AnimatablePropertyMetadata*>(mAnimatableProperties[mAnimatableProperties.Size()-1]);
+ animatableProperty = static_cast<AnimatablePropertyMetadata*>(mAnimatableProperties[mAnimatableProperties.Size() - 1]);
}
}
{
// Resolve index for the child property
Object* parent = GetParentObject();
- if( parent )
+ if(parent)
{
- const TypeInfo* parentTypeInfo( parent->GetTypeInfo() );
- if( parentTypeInfo )
+ const TypeInfo* parentTypeInfo(parent->GetTypeInfo());
+ if(parentTypeInfo)
{
// Go through each custom property
- for( auto&& entry : mCustomProperties )
+ for(auto&& entry : mCustomProperties)
{
- CustomPropertyMetadata* customProperty = static_cast<CustomPropertyMetadata*>( entry );
+ CustomPropertyMetadata* customProperty = static_cast<CustomPropertyMetadata*>(entry);
if(customProperty->name.IsEmpty())
{
- if( customProperty->childPropertyIndex != Property::INVALID_INDEX )
+ if(customProperty->childPropertyIndex != Property::INVALID_INDEX)
{
// Resolve name for any child property with no name
customProperty->name = ConstString(parentTypeInfo->GetChildPropertyName(customProperty->childPropertyIndex));
else
{
Property::Index childPropertyIndex = parentTypeInfo->GetChildPropertyIndex(customProperty->name);
- if( childPropertyIndex != Property::INVALID_INDEX )
+ if(childPropertyIndex != Property::INVALID_INDEX)
{
// Resolve index for any property with a name that matches the parent's child property name
customProperty->childPropertyIndex = childPropertyIndex;
}
}
-void Object::SetDefaultProperty( Property::Index index, const Property::Value& property )
+void Object::SetDefaultProperty(Property::Index index, const Property::Value& property)
{
// do nothing
}
return Property::Value();
}
-Property::Value Object::GetDefaultPropertyCurrentValue( Property::Index index ) const
+Property::Value Object::GetDefaultPropertyCurrentValue(Property::Index index) const
{
- return GetDefaultProperty( index );
+ return GetDefaultProperty(index);
}
void Object::EnablePropertyNotifications()
{
- if( mPropertyNotifications )
+ if(mPropertyNotifications)
{
- for( auto&& element : *mPropertyNotifications )
+ for(auto&& element : *mPropertyNotifications)
{
- GetImplementation( element ).Enable();
+ GetImplementation(element).Enable();
}
}
}
void Object::DisablePropertyNotifications()
{
- if( mPropertyNotifications )
+ if(mPropertyNotifications)
{
- for( auto&& element : *mPropertyNotifications )
+ for(auto&& element : *mPropertyNotifications)
{
- GetImplementation( element ).Disable();
+ GetImplementation(element).Disable();
}
}
}
-Property::Value Object::GetCurrentPropertyValue( const PropertyMetadata& entry ) const
+Property::Value Object::GetCurrentPropertyValue(const PropertyMetadata& entry) const
{
Property::Value value;
- if( !entry.IsAnimatable() )
+ if(!entry.IsAnimatable())
{
value = entry.GetPropertyValue();
}
else
{
- BufferIndex bufferIndex( GetEventThreadServices().GetEventBufferIndex() );
+ BufferIndex bufferIndex(GetEventThreadServices().GetEventBufferIndex());
- switch ( entry.GetType() )
+ switch(entry.GetType())
{
case Property::BOOLEAN:
{
- const AnimatableProperty<bool>* property = static_cast< const AnimatableProperty<bool>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<bool>* property = static_cast<const AnimatableProperty<bool>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
- value = (*property)[ bufferIndex ];
+ value = (*property)[bufferIndex];
break;
}
case Property::INTEGER:
{
- const AnimatableProperty<int32_t>* property = static_cast< const AnimatableProperty<int32_t>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<int32_t>* property = static_cast<const AnimatableProperty<int32_t>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
- value = (*property)[ bufferIndex ];
+ value = (*property)[bufferIndex];
break;
}
case Property::FLOAT:
{
- const AnimatableProperty<float>* property = static_cast< const AnimatableProperty<float>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<float>* property = static_cast<const AnimatableProperty<float>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
- value = (*property)[ bufferIndex ];
+ value = (*property)[bufferIndex];
break;
}
case Property::VECTOR2:
{
- const AnimatableProperty<Vector2>* property = static_cast< const AnimatableProperty<Vector2>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<Vector2>* property = static_cast<const AnimatableProperty<Vector2>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
if(entry.componentIndex == 0)
{
- value = (*property)[ bufferIndex ].x;
+ value = (*property)[bufferIndex].x;
}
else if(entry.componentIndex == 1)
{
- value = (*property)[ bufferIndex ].y;
+ value = (*property)[bufferIndex].y;
}
else
{
- value = (*property)[ bufferIndex ];
+ value = (*property)[bufferIndex];
}
break;
}
case Property::VECTOR3:
{
- const AnimatableProperty<Vector3>* property = static_cast< const AnimatableProperty<Vector3>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<Vector3>* property = static_cast<const AnimatableProperty<Vector3>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
if(entry.componentIndex == 0)
{
- value = (*property)[ bufferIndex ].x;
+ value = (*property)[bufferIndex].x;
}
else if(entry.componentIndex == 1)
{
- value = (*property)[ bufferIndex ].y;
+ value = (*property)[bufferIndex].y;
}
else if(entry.componentIndex == 2)
{
- value = (*property)[ bufferIndex ].z;
+ value = (*property)[bufferIndex].z;
}
else
{
- value = (*property)[ bufferIndex ];
+ value = (*property)[bufferIndex];
}
break;
}
case Property::VECTOR4:
{
- const AnimatableProperty<Vector4>* property = static_cast< const AnimatableProperty<Vector4>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<Vector4>* property = static_cast<const AnimatableProperty<Vector4>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
if(entry.componentIndex == 0)
{
- value = (*property)[ bufferIndex ].x;
+ value = (*property)[bufferIndex].x;
}
else if(entry.componentIndex == 1)
{
- value = (*property)[ bufferIndex ].y;
+ value = (*property)[bufferIndex].y;
}
else if(entry.componentIndex == 2)
{
- value = (*property)[ bufferIndex ].z;
+ value = (*property)[bufferIndex].z;
}
else if(entry.componentIndex == 3)
{
- value = (*property)[ bufferIndex ].w;
+ value = (*property)[bufferIndex].w;
}
else
{
- value = (*property)[ bufferIndex ];
+ value = (*property)[bufferIndex];
}
break;
}
case Property::MATRIX:
{
- const AnimatableProperty<Matrix>* property = static_cast< const AnimatableProperty<Matrix>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<Matrix>* property = static_cast<const AnimatableProperty<Matrix>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
- value = (*property)[ bufferIndex ];
+ value = (*property)[bufferIndex];
break;
}
case Property::MATRIX3:
{
- const AnimatableProperty<Matrix3>* property = static_cast< const AnimatableProperty<Matrix3>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<Matrix3>* property = static_cast<const AnimatableProperty<Matrix3>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
- value = (*property)[ bufferIndex ];
+ value = (*property)[bufferIndex];
break;
}
case Property::ROTATION:
{
- const AnimatableProperty<Quaternion>* property = static_cast< const AnimatableProperty<Quaternion>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<Quaternion>* property = static_cast<const AnimatableProperty<Quaternion>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
- value = (*property)[ bufferIndex ];
+ value = (*property)[bufferIndex];
break;
}
// unreachable code due to higher level logic
}
} // switch(type)
- } // if animatable
+ } // if animatable
return value;
}
-void Object::SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value )
+void Object::SetSceneGraphProperty(Property::Index index, const PropertyMetadata& entry, const Property::Value& value)
{
- switch ( entry.GetType() )
+ switch(entry.GetType())
{
case Property::BOOLEAN:
{
- const AnimatableProperty<bool>* property = dynamic_cast< const AnimatableProperty<bool>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<bool>* property = dynamic_cast<const AnimatableProperty<bool>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
// property is being used in a separate thread; queue a message to set the property
- BakeMessage<bool>( GetEventThreadServices(), *property, value.Get<bool>() );
+ BakeMessage<bool>(GetEventThreadServices(), *property, value.Get<bool>());
break;
}
case Property::INTEGER:
{
- const AnimatableProperty<int32_t>* property = dynamic_cast< const AnimatableProperty<int32_t>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<int32_t>* property = dynamic_cast<const AnimatableProperty<int32_t>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
// property is being used in a separate thread; queue a message to set the property
- BakeMessage<int32_t>( GetEventThreadServices(), *property, value.Get<int32_t>() );
+ BakeMessage<int32_t>(GetEventThreadServices(), *property, value.Get<int32_t>());
break;
}
case Property::FLOAT:
{
- const AnimatableProperty<float>* property = dynamic_cast< const AnimatableProperty<float>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<float>* property = dynamic_cast<const AnimatableProperty<float>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
// property is being used in a separate thread; queue a message to set the property
- BakeMessage<float>( GetEventThreadServices(), *property, value.Get<float>() );
+ BakeMessage<float>(GetEventThreadServices(), *property, value.Get<float>());
break;
}
case Property::VECTOR2:
{
- const AnimatableProperty<Vector2>* property = dynamic_cast< const AnimatableProperty<Vector2>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<Vector2>* property = dynamic_cast<const AnimatableProperty<Vector2>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
// property is being used in a separate thread; queue a message to set the property
if(entry.componentIndex == 0)
{
- SetXComponentMessage<Vector2>( GetEventThreadServices(), *property, value.Get<float>() );
+ SetXComponentMessage<Vector2>(GetEventThreadServices(), *property, value.Get<float>());
}
else if(entry.componentIndex == 1)
{
- SetYComponentMessage<Vector2>( GetEventThreadServices(), *property, value.Get<float>() );
+ SetYComponentMessage<Vector2>(GetEventThreadServices(), *property, value.Get<float>());
}
else
{
- BakeMessage<Vector2>( GetEventThreadServices(), *property, value.Get<Vector2>() );
+ BakeMessage<Vector2>(GetEventThreadServices(), *property, value.Get<Vector2>());
}
break;
}
case Property::VECTOR3:
{
- const AnimatableProperty<Vector3>* property = dynamic_cast< const AnimatableProperty<Vector3>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<Vector3>* property = dynamic_cast<const AnimatableProperty<Vector3>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
// property is being used in a separate thread; queue a message to set the property
if(entry.componentIndex == 0)
{
- SetXComponentMessage<Vector3>( GetEventThreadServices(), *property, value.Get<float>() );
+ SetXComponentMessage<Vector3>(GetEventThreadServices(), *property, value.Get<float>());
}
else if(entry.componentIndex == 1)
{
- SetYComponentMessage<Vector3>( GetEventThreadServices(), *property, value.Get<float>() );
+ SetYComponentMessage<Vector3>(GetEventThreadServices(), *property, value.Get<float>());
}
else if(entry.componentIndex == 2)
{
- SetZComponentMessage<Vector3>( GetEventThreadServices(), *property, value.Get<float>() );
+ SetZComponentMessage<Vector3>(GetEventThreadServices(), *property, value.Get<float>());
}
else
{
- BakeMessage<Vector3>( GetEventThreadServices(), *property, value.Get<Vector3>() );
+ BakeMessage<Vector3>(GetEventThreadServices(), *property, value.Get<Vector3>());
}
break;
case Property::VECTOR4:
{
- const AnimatableProperty<Vector4>* property = dynamic_cast< const AnimatableProperty<Vector4>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<Vector4>* property = dynamic_cast<const AnimatableProperty<Vector4>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
// property is being used in a separate thread; queue a message to set the property
if(entry.componentIndex == 0)
{
- SetXComponentMessage<Vector4>( GetEventThreadServices(), *property, value.Get<float>() );
+ SetXComponentMessage<Vector4>(GetEventThreadServices(), *property, value.Get<float>());
}
else if(entry.componentIndex == 1)
{
- SetYComponentMessage<Vector4>( GetEventThreadServices(), *property, value.Get<float>() );
+ SetYComponentMessage<Vector4>(GetEventThreadServices(), *property, value.Get<float>());
}
else if(entry.componentIndex == 2)
{
- SetZComponentMessage<Vector4>( GetEventThreadServices(), *property, value.Get<float>() );
+ SetZComponentMessage<Vector4>(GetEventThreadServices(), *property, value.Get<float>());
}
else if(entry.componentIndex == 3)
{
- SetWComponentMessage<Vector4>( GetEventThreadServices(), *property, value.Get<float>() );
+ SetWComponentMessage<Vector4>(GetEventThreadServices(), *property, value.Get<float>());
}
else
{
- BakeMessage<Vector4>( GetEventThreadServices(), *property, value.Get<Vector4>() );
+ BakeMessage<Vector4>(GetEventThreadServices(), *property, value.Get<Vector4>());
}
break;
}
case Property::ROTATION:
{
- const AnimatableProperty<Quaternion>* property = dynamic_cast< const AnimatableProperty<Quaternion>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<Quaternion>* property = dynamic_cast<const AnimatableProperty<Quaternion>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
// property is being used in a separate thread; queue a message to set the property
- BakeMessage<Quaternion>( GetEventThreadServices(), *property, value.Get<Quaternion>() );
+ BakeMessage<Quaternion>(GetEventThreadServices(), *property, value.Get<Quaternion>());
break;
}
case Property::MATRIX:
{
- const AnimatableProperty<Matrix>* property = dynamic_cast< const AnimatableProperty<Matrix>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<Matrix>* property = dynamic_cast<const AnimatableProperty<Matrix>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
// property is being used in a separate thread; queue a message to set the property
- BakeMessage<Matrix>( GetEventThreadServices(), *property, value.Get<Matrix>() );
+ BakeMessage<Matrix>(GetEventThreadServices(), *property, value.Get<Matrix>());
break;
}
case Property::MATRIX3:
{
- const AnimatableProperty<Matrix3>* property = dynamic_cast< const AnimatableProperty<Matrix3>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( property );
+ const AnimatableProperty<Matrix3>* property = dynamic_cast<const AnimatableProperty<Matrix3>*>(entry.GetSceneGraphProperty());
+ DALI_ASSERT_DEBUG(property);
// property is being used in a separate thread; queue a message to set the property
- BakeMessage<Matrix3>( GetEventThreadServices(), *property, value.Get<Matrix3>() );
+ BakeMessage<Matrix3>(GetEventThreadServices(), *property, value.Get<Matrix3>());
break;
}
#define DALI_INTERNAL_OBJECT_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
class PropertyNotification;
namespace Internal
{
class PropertyBase;
class PropertyOwner;
-}
+} // namespace SceneGraph
-using ConstraintContainer = std::vector< Dali::Constraint >;
-using ConstraintIter = ConstraintContainer::iterator;
+using ConstraintContainer = std::vector<Dali::Constraint>;
+using ConstraintIter = ConstraintContainer::iterator;
using ConstraintConstIter = ConstraintContainer::const_iterator;
class KeyRef
class Object : public Dali::BaseObject
{
public:
-
using Capability = Dali::Handle::Capability;
class Observer
{
public:
-
/**
* Called immediately after the object has created & passed ownership of a scene-graph object.
* @param[in] object The object object.
virtual void ObjectDestroyed(Object& object) = 0;
protected:
-
/**
* Virtual destructor
*/
* Add an observer to the object.
* @param[in] observer The observer to add.
*/
- void AddObserver( Observer& observer );
+ void AddObserver(Observer& observer);
/**
* Remove an observer from the object
* @pre The observer has already been added.
* @param[in] observer The observer to remove.
*/
- void RemoveObserver( Observer& observer );
+ void RemoveObserver(Observer& observer);
/**
* @copydoc Dali::Handle::Supports()
*/
- bool Supports( Capability capability ) const;
+ bool Supports(Capability capability) const;
/**
* @copydoc Dali::Handle::GetPropertyCount()
/**
* @copydoc Dali::Handle::IsPropertyWritable()
*/
- bool IsPropertyWritable( Property::Index index ) const;
+ bool IsPropertyWritable(Property::Index index) const;
/**
* @copydoc Dali::Handle::IsPropertyAnimatable()
*/
- bool IsPropertyAnimatable( Property::Index index ) const;
+ bool IsPropertyAnimatable(Property::Index index) const;
/**
* @copydoc Dali::Handle::IsPropertyAConstraintInput()
*/
- bool IsPropertyAConstraintInput( Property::Index index ) const;
+ bool IsPropertyAConstraintInput(Property::Index index) const;
/**
* @copydoc Dali::Handle::GetPropertyType()
*/
- Property::Type GetPropertyType( Property::Index index ) const;
+ Property::Type GetPropertyType(Property::Index index) const;
/**
* @copydoc Dali::Handle::SetProperty()
/**
* @copydoc Dali::Handle::GetProperty()
*/
- Property::Value GetProperty( Property::Index index ) const;
+ Property::Value GetProperty(Property::Index index) const;
/**
* @brief Retrieves the latest value of the property on the scene-graph.
* @param[in] index The index of the property required.
* @return The latest value of the property on the scene-graph.
*/
- Property::Value GetCurrentProperty( Property::Index index ) const;
+ Property::Value GetCurrentProperty(Property::Index index) const;
/**
* @copydoc Dali::Handle::GetPropertyIndices()
*/
- void GetPropertyIndices( Property::IndexContainer& indices ) const;
+ void GetPropertyIndices(Property::IndexContainer& indices) const;
/**
* @copydoc Dali::Handle::RegisterProperty()
/**
* @copydoc Dali::DevelHandle::SetProperties()
*/
- void SetProperties( const Property::Map& properties );
+ void SetProperties(const Property::Map& properties);
/**
* @copydoc Dali::DevelHandle::GetProperties()
*/
- void GetProperties( Property::Map& properties );
+ void GetProperties(Property::Map& properties);
/**
* @copydoc Dali::Handle::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode)
* @param[in] index The property index to look for.
* @return true if the property exists on the object, false otherwise.
*/
- bool DoesCustomPropertyExist( Property::Index index );
+ bool DoesCustomPropertyExist(Property::Index index);
/**
* @copydoc Dali::Handle::AddPropertyNotification()
*/
- Dali::PropertyNotification AddPropertyNotification( Property::Index index,
- int32_t componentIndex,
- const Dali::PropertyCondition& condition );
+ Dali::PropertyNotification AddPropertyNotification(Property::Index index,
+ int32_t componentIndex,
+ const Dali::PropertyCondition& condition);
/**
* @copydoc Dali::Handle::RemovePropertyNotification()
*/
- void RemovePropertyNotification( Dali::PropertyNotification propertyNotification );
+ void RemovePropertyNotification(Dali::PropertyNotification propertyNotification);
/**
* @copydoc Dali::Handle::RemovePropertyNotifications()
* @param[in] value The value of the property after the animation.
* @param[in] animationType Whether the property value given is the target or a relative value.
*/
- void NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
+ void NotifyPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType);
/******************************** Uniform Mappings ********************************/
* Removes uniform mapping for given property
* @param uniformName name of the uniform (same as property name)
*/
- void RemoveUniformMapping( const std::string& uniformName ) const;
+ void RemoveUniformMapping(const std::string& uniformName) const;
/******************************** Constraints ********************************/
* Apply a constraint to an Object.
* @param[in] constraint The constraint to apply.
*/
- void ApplyConstraint( ConstraintBase& constraint );
+ void ApplyConstraint(ConstraintBase& constraint);
/**
* Remove one constraint from an Object.
* @param[in] constraint The constraint to remove.
*/
- void RemoveConstraint( ConstraintBase& constraint );
+ void RemoveConstraint(ConstraintBase& constraint);
/**
* Remove all constraints from a Object.
/**
* @copydoc Dali::Handle::RemoveConstraints( uint32_t )
*/
- void RemoveConstraints( uint32_t tag );
+ void RemoveConstraints(uint32_t tag);
/**
* Called by TypeInfo to set the type-info that this object-impl is created by.
* @param[in] typeInfo The TypeInfo that creates this object-impl.
*/
- void SetTypeInfo( const TypeInfo* typeInfo );
+ void SetTypeInfo(const TypeInfo* typeInfo);
/**
* @return the index from which custom properties start
* @param[in] index The index of the property.
* @return A dereferenceable pointer to a property, or NULL if a scene-object does not exist with this property.
*/
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
+ virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty(Property::Index index) const;
/**
* Retrieve a constraint input-property owned by the scene-graph object.
* @param[in] index The index of the property.
* @return A dereferenceable pointer to an input property, or NULL if a scene-object does not exist with this property.
*/
- virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
+ virtual const PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const;
/**
* Query whether the property is a component of a scene-graph property.
* @param[in] index The index of the property.
* @return The index or Property::INVALID_COMPONENT_INDEX.
*/
- virtual int32_t GetPropertyComponentIndex( Property::Index index ) const;
+ virtual int32_t GetPropertyComponentIndex(Property::Index index) const;
/**
* Query whether playing an animation is possible or not.
Handle::PropertySetSignalType& PropertySetSignal();
protected:
-
/**
* Constructor. Protected so use New to construct an instance of this class
*
* @param sceneObject the scene graph property owner
*/
- Object( const SceneGraph::PropertyOwner* sceneObject );
+ Object(const SceneGraph::PropertyOwner* sceneObject);
/**
* A reference counted object may only be deleted by calling Unreference()
* @param [in] index The index of the property.
* @param [in] propertyValue The value of the property.
*/
- virtual void OnPropertySet( Property::Index index, const Property::Value& propertyValue ) {}
+ virtual void OnPropertySet(Property::Index index, const Property::Value& propertyValue)
+ {
+ }
/**
* Retrieves the TypeInfo for this object. Only retrieves it from the type-registry once and then stores a pointer
* @param index
* @return pointer to the property
*/
- CustomPropertyMetadata* FindCustomProperty( Property::Index index ) const;
+ CustomPropertyMetadata* FindCustomProperty(Property::Index index) const;
/**
* Helper to find animatable property
* @param index
* @return pointer to the property
*/
- AnimatablePropertyMetadata* FindAnimatableProperty( Property::Index index ) const;
+ AnimatablePropertyMetadata* FindAnimatableProperty(Property::Index index) const;
/**
* Helper to register a scene-graph property
* @param index of the property to register
* @param value initial value or nullptr
*/
- void RegisterAnimatableProperty( const TypeInfo& typeInfo, Property::Index index, const Property::Value* value ) const;
+ void RegisterAnimatableProperty(const TypeInfo& typeInfo, Property::Index index, const Property::Value* value) const;
/**
* Check whether the animatable property is registered already, if not then register on.
* @param [in] value optional value for the property
* @return pointer to the property metadata
*/
- AnimatablePropertyMetadata* GetSceneAnimatableProperty( Property::Index index, const Property::Value* value ) const;
+ AnimatablePropertyMetadata* GetSceneAnimatableProperty(Property::Index index, const Property::Value* value) const;
/**
* Resolve the index and name of child properties if any.
void ResolveChildProperties();
private: // Default property extensions for derived classes
-
/**
* Set the value of a default property.
* @pre The property types match i.e. propertyValue.GetType() is equal to GetPropertyType(index).
* @param [in] index The index of the property.
* @param [in] propertyValue The new value of the property.
*/
- virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
+ virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
/**
* Retrieve a default property value.
* @param [in] index The index of the property.
* @return The property value.
*/
- virtual Property::Value GetDefaultProperty( Property::Index index ) const;
+ virtual Property::Value GetDefaultProperty(Property::Index index) const;
/**
* Retrieve the latest scene-graph value of a default property.
* @param[in] index The index of the property.
* @return The latest scene-graph value of a default property.
*/
- virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
+ virtual Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const;
/**
* Notifies that a default property is being animated so the deriving class should update the cached value.
* @param[in] value The value of the property after the animation.
* @param[in] animationType Whether the property value given is the target or a relative value.
*/
- virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type propertyChangeType )
- { }
+ virtual void OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type propertyChangeType)
+ {
+ }
private:
-
// no default, copy or assignment
- Object() = delete;
+ Object() = delete;
Object(const Object& rhs) = delete;
Object& operator=(const Object& rhs) = delete;
* @param[in] entry An entry from the property lookup container.
* @return The latest value of the property.
*/
- Property::Value GetCurrentPropertyValue( const PropertyMetadata& entry ) const;
+ Property::Value GetCurrentPropertyValue(const PropertyMetadata& entry) const;
/**
* Set the value of scene graph property.
* @param [in] entry An entry from the property lookup container.
* @param [in] value The new value of the property.
*/
- virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
+ virtual void SetSceneGraphProperty(Property::Index index, const PropertyMetadata& entry, const Property::Value& value);
protected:
/**
*/
inline EventThreadServices& GetEventThreadServices()
{
- DALI_ASSERT_ALWAYS( EventThreadServices::IsCoreRunning() );
+ DALI_ASSERT_ALWAYS(EventThreadServices::IsCoreRunning());
return mEventThreadServices;
}
*/
inline const EventThreadServices& GetEventThreadServices() const
{
- DALI_ASSERT_ALWAYS( EventThreadServices::IsCoreRunning() );
+ DALI_ASSERT_ALWAYS(EventThreadServices::IsCoreRunning());
return mEventThreadServices;
}
private:
-
EventThreadServices& mEventThreadServices;
protected:
-
// mutable because it's lazy initialised and GetSceneObject has to be const so it can be called from const methods
// const to prevent accidentally calling setters directly from event thread
// protected to allow fast access from derived classes that have their own scene object (no function call overhead)
mutable const SceneGraph::PropertyOwner* mUpdateObject; ///< Reference to object to hold the scene graph properties
private:
-
- Dali::Vector<Observer*> mObservers;
- mutable OwnerContainer<PropertyMetadata*> mCustomProperties; ///< Used for accessing custom Node properties
+ Dali::Vector<Observer*> mObservers;
+ mutable OwnerContainer<PropertyMetadata*> mCustomProperties; ///< Used for accessing custom Node properties
mutable OwnerContainer<PropertyMetadata*> mAnimatableProperties; ///< Used for accessing animatable Node properties
- mutable const TypeInfo* mTypeInfo; ///< The type-info for this object, mutable so it can be lazy initialized from const method if it is required
+ mutable const TypeInfo* mTypeInfo; ///< The type-info for this object, mutable so it can be lazy initialized from const method if it is required
- ConstraintContainer* mConstraints; ///< Container of owned -constraints.
+ ConstraintContainer* mConstraints; ///< Container of owned -constraints.
- using PropertyNotificationContainer = std::vector< Dali::PropertyNotification >;
+ using PropertyNotificationContainer = std::vector<Dali::PropertyNotification>;
PropertyNotificationContainer* mPropertyNotifications; ///< Container of owned property notifications.
Handle::PropertySetSignalType mPropertySetSignal;
inline Internal::Object& GetImplementation(Dali::Handle& object)
{
- DALI_ASSERT_ALWAYS( object && "Object handle is empty" );
+ DALI_ASSERT_ALWAYS(object && "Object handle is empty");
BaseObject& handle = object.GetBaseObject();
inline const Internal::Object& GetImplementation(const Dali::Handle& object)
{
- DALI_ASSERT_ALWAYS( object && "Object handle is empty" );
+ DALI_ASSERT_ALWAYS(object && "Object handle is empty");
const BaseObject& handle = object.GetBaseObject();
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace
{
-
// Signals
-const char* const SIGNAL_OBJECT_CREATED = "objectCreated";
+const char* const SIGNAL_OBJECT_CREATED = "objectCreated";
const char* const SIGNAL_OBJECT_DESTROYED = "objectDestroyed";
-TypeRegistration mType( typeid( Dali::ObjectRegistry ), typeid( Dali::BaseHandle ), nullptr );
+TypeRegistration mType(typeid(Dali::ObjectRegistry), typeid(Dali::BaseHandle), nullptr);
-SignalConnectorType signalConnector1( mType, SIGNAL_OBJECT_CREATED, &ObjectRegistry::DoConnectSignal );
-SignalConnectorType signalConnector2( mType, SIGNAL_OBJECT_DESTROYED, &ObjectRegistry::DoConnectSignal );
+SignalConnectorType signalConnector1(mType, SIGNAL_OBJECT_CREATED, &ObjectRegistry::DoConnectSignal);
+SignalConnectorType signalConnector2(mType, SIGNAL_OBJECT_DESTROYED, &ObjectRegistry::DoConnectSignal);
-}
+} // namespace
ObjectRegistryPtr ObjectRegistry::New()
{
- return ObjectRegistryPtr( new ObjectRegistry() );
+ return ObjectRegistryPtr(new ObjectRegistry());
}
ObjectRegistry::ObjectRegistry() = default;
ObjectRegistry::~ObjectRegistry() = default;
-void ObjectRegistry::RegisterObject( Dali::BaseObject* object )
+void ObjectRegistry::RegisterObject(Dali::BaseObject* object)
{
- if ( !mObjectCreatedSignal.Empty() )
+ if(!mObjectCreatedSignal.Empty())
{
- Dali::BaseHandle handle( object );
- mObjectCreatedSignal.Emit( handle );
+ Dali::BaseHandle handle(object);
+ mObjectCreatedSignal.Emit(handle);
}
}
-void ObjectRegistry::UnregisterObject( Dali::BaseObject* object )
+void ObjectRegistry::UnregisterObject(Dali::BaseObject* object)
{
- mObjectDestroyedSignal.Emit( object );
+ mObjectDestroyedSignal.Emit(object);
}
-bool ObjectRegistry::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool ObjectRegistry::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( true );
- ObjectRegistry* objectRegistry = static_cast< ObjectRegistry* >( object ); // TypeRegistry guarantees that this is the correct type.
+ bool connected(true);
+ ObjectRegistry* objectRegistry = static_cast<ObjectRegistry*>(object); // TypeRegistry guarantees that this is the correct type.
- if( 0 == strcmp( signalName.c_str(), SIGNAL_OBJECT_CREATED ) )
+ if(0 == strcmp(signalName.c_str(), SIGNAL_OBJECT_CREATED))
{
- objectRegistry->ObjectCreatedSignal().Connect( tracker, functor );
+ objectRegistry->ObjectCreatedSignal().Connect(tracker, functor);
}
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_OBJECT_DESTROYED ) )
+ else if(0 == strcmp(signalName.c_str(), SIGNAL_OBJECT_DESTROYED))
{
- objectRegistry->ObjectDestroyedSignal().Connect( tracker, functor );
+ objectRegistry->ObjectDestroyedSignal().Connect(tracker, functor);
}
else
{
#define DALI_INTERNAL_OBJECT_REGISTRY_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/object/object-registry.h>
#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/object-registry.h>
+#include <dali/public-api/object/ref-object.h>
namespace Dali
{
-
struct Vector2;
namespace Internal
{
-
namespace SceneGraph
{
class UpdateManager;
class ObjectRegistry : public BaseObject
{
public:
-
/**
* Create the objectRegistry
*/
* @pre the object is ref counted (held in an intrusive pointer)
* @param[in] object Pointer to the object.
*/
- void RegisterObject( Dali::BaseObject* object );
+ void RegisterObject(Dali::BaseObject* object);
/**
* Unregisters the Object from the Object Registry, Which notifies
* @pre The object is already registered.
* @param[in] object Pointer to the object.
*/
- void UnregisterObject( Dali::BaseObject* object );
+ void UnregisterObject(Dali::BaseObject* object);
/**
* @copydoc Dali::ObjectRegistry::ObjectCreatedSignal()
* @return True if the signal was connected.
* @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
*/
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
private:
-
/**
* Protected constructor; see also ObjectRegistry::New()
*/
~ObjectRegistry() override;
private:
-
- Dali::ObjectRegistry::ObjectCreatedSignalType mObjectCreatedSignal;
+ Dali::ObjectRegistry::ObjectCreatedSignalType mObjectCreatedSignal;
Dali::ObjectRegistry::ObjectDestroyedSignalType mObjectDestroyedSignal;
-
};
} // namespace Internal
inline Internal::ObjectRegistry& GetImplementation(Dali::ObjectRegistry& objectRegistry)
{
- DALI_ASSERT_ALWAYS( objectRegistry && "ObjectRegistry handle is empty" );
+ DALI_ASSERT_ALWAYS(objectRegistry && "ObjectRegistry handle is empty");
BaseObject& handle = objectRegistry.GetBaseObject();
inline const Internal::ObjectRegistry& GetImplementation(const Dali::ObjectRegistry& objectRegistry)
{
- DALI_ASSERT_ALWAYS( objectRegistry && "ObjectRegistry handle is empty" );
+ DALI_ASSERT_ALWAYS(objectRegistry && "ObjectRegistry handle is empty");
const BaseObject& handle = objectRegistry.GetBaseObject();
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/common/projection.h>
// INTERNAL INCLUDES
-#include <dali/public-api/math/rect.h>
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/math/math-utils.h>
#include <dali/public-api/math/matrix.h>
-#include <dali/public-api/math/vector4.h>
+#include <dali/public-api/math/rect.h>
#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/math/vector4.h>
#include <dali/public-api/math/viewport.h>
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/math/math-utils.h>
namespace Dali
{
-
namespace Internal
{
-
-bool Unproject( const Vector4& windowPos,
- const Matrix& inverseMvp,
- float viewportWidth,
- float viewportHeight,
- Vector4& objectPos )
+bool Unproject(const Vector4& windowPos,
+ const Matrix& inverseMvp,
+ float viewportWidth,
+ float viewportHeight,
+ Vector4& objectPos)
{
objectPos.x = windowPos.x;
objectPos.y = windowPos.y;
objectPos = inverseMvp * objectPos;
// In the case where objectPos.w is exactly zero, the unproject fails
- if ( EqualsZero( objectPos.w ) )
+ if(EqualsZero(objectPos.w))
{
return false;
}
return true;
}
-bool UnprojectFull( const Vector4& windowPos,
- const Matrix& modelView,
- const Matrix& projection,
- float viewportWidth,
- float viewportHeight,
- Vector4& objectPos )
+bool UnprojectFull(const Vector4& windowPos,
+ const Matrix& modelView,
+ const Matrix& projection,
+ float viewportWidth,
+ float viewportHeight,
+ Vector4& objectPos)
{
- Matrix invertedMvp( false ); // Don't initialize.
- Matrix::Multiply( invertedMvp, modelView, projection );
+ Matrix invertedMvp(false); // Don't initialize.
+ Matrix::Multiply(invertedMvp, modelView, projection);
- if (invertedMvp.Invert())
+ if(invertedMvp.Invert())
{
- return Unproject( windowPos, invertedMvp, viewportWidth, viewportHeight, objectPos );
+ return Unproject(windowPos, invertedMvp, viewportWidth, viewportHeight, objectPos);
}
return false;
}
-bool XyPlaneIntersect( const Vector4& pointA, const Vector4& pointB, Vector4& intersect )
+bool XyPlaneIntersect(const Vector4& pointA, const Vector4& pointB, Vector4& intersect)
{
const Vector4* near = nullptr;
- const Vector4* far = nullptr;
+ const Vector4* far = nullptr;
- if ( pointA.z > 0.0f && pointB.z < 0.0f )
+ if(pointA.z > 0.0f && pointB.z < 0.0f)
{
near = &pointA;
far = &pointB;
}
- else if ( pointB.z > 0.0f && pointA.z < 0.0f )
+ else if(pointB.z > 0.0f && pointA.z < 0.0f)
{
near = &pointB;
far = &pointA;
return true;
}
-bool ProjectFull( const Vector4& position,
- const Matrix& modelView,
- const Matrix& projection,
- float viewportX,
- float viewportY,
- float viewportWidth,
- float viewportHeight,
- Vector4& windowPos )
+bool ProjectFull(const Vector4& position,
+ const Matrix& modelView,
+ const Matrix& projection,
+ float viewportX,
+ float viewportY,
+ float viewportWidth,
+ float viewportHeight,
+ Vector4& windowPos)
{
bool ok = false;
- Matrix Mvp( false ); // Don't initialize.
- Matrix::Multiply( Mvp, modelView, projection );
+ Matrix Mvp(false); // Don't initialize.
+ Matrix::Multiply(Mvp, modelView, projection);
Vector4 p = Mvp * position;
- Vector2 depthRange(0,1);
+ Vector2 depthRange(0, 1);
- if( !EqualsZero( p.w ) )
+ if(!EqualsZero(p.w))
{
float div = 1.0f / p.w;
- windowPos = Vector4( (1 + p.x * div) * viewportWidth / 2 + viewportX,
- (1 - p.y * div) * viewportHeight / 2 + viewportY,
- (p.z * div) * (depthRange.y - depthRange.x) + depthRange.x,
- div);
- ok = true;
+ windowPos = Vector4((1 + p.x * div) * viewportWidth / 2 + viewportX,
+ (1 - p.y * div) * viewportHeight / 2 + viewportY,
+ (p.z * div) * (depthRange.y - depthRange.x) + depthRange.x,
+ div);
+ ok = true;
}
return ok;
}
-
} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_PROJECTION_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
struct Vector4;
struct Vector2;
namespace Internal
{
-
bool XyPlaneIntersect(const Dali::Vector4& pointA,
const Dali::Vector4& pointB,
- Dali::Vector4& intersect);
+ Dali::Vector4& intersect);
bool UnprojectFull(const Dali::Vector4& windowPos,
- const Matrix& modelView,
- const Matrix& projection,
- float viewportWidth,
- float viewportHeight,
- Dali::Vector4& objectPos);
+ const Matrix& modelView,
+ const Matrix& projection,
+ float viewportWidth,
+ float viewportHeight,
+ Dali::Vector4& objectPos);
bool Unproject(const Dali::Vector4& windowPos,
- const Matrix& inverseMvp,
- float viewportWidth,
- float viewportHeight,
- Dali::Vector4& objectPos);
-
-bool ProjectFull( const Vector4& position,
- const Matrix& modelView,
- const Matrix& projection,
- float viewportX,
- float viewportY,
- float viewportWidth,
- float viewportHeight,
- Vector4& windowPos );
+ const Matrix& inverseMvp,
+ float viewportWidth,
+ float viewportHeight,
+ Dali::Vector4& objectPos);
+
+bool ProjectFull(const Vector4& position,
+ const Matrix& modelView,
+ const Matrix& projection,
+ float viewportX,
+ float viewportY,
+ float viewportWidth,
+ float viewportHeight,
+ Vector4& windowPos);
} // namespace Internal
} // namespace Dali
#endif // DALI_INTERNAL_PROJECTION_H
-
namespace Dali
{
-
namespace Internal
{
-
PropertyCondition::PropertyCondition()
: type(False)
{
-
}
PropertyCondition::~PropertyCondition() = default;
#define DALI_INTERNAL_PROPERTY_CONDITIONS_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/object/property-conditions.h>
#include <dali/public-api/object/property-value.h>
-#include <dali/public-api/object/property-value.h>
namespace Dali
{
-
namespace Internal
{
-
/**
* Structure to contain PropertyCondition internal data
*/
class PropertyCondition : public Dali::BaseObject
{
-
public:
-
/**
* Condition types.
*/
enum Type
{
- False, ///< Result Always False
- LessThan, ///< Magnitude of type is less than float value (arg0).
- GreaterThan, ///< Magnitude of type is greater than float value (arg0).
- Inside, ///< Magnitude of type is within float values (arg0 & arg1).
- Outside, ///< Magnitude of type is outside float values (arg0 & arg1).
- Step, ///< Value of type has crossed a step amount
- VariableStep ///< Similar to step, except user can define a list of steps from reference value
+ False, ///< Result Always False
+ LessThan, ///< Magnitude of type is less than float value (arg0).
+ GreaterThan, ///< Magnitude of type is greater than float value (arg0).
+ Inside, ///< Magnitude of type is within float values (arg0 & arg1).
+ Outside, ///< Magnitude of type is outside float values (arg0 & arg1).
+ Step, ///< Value of type has crossed a step amount
+ VariableStep ///< Similar to step, except user can define a list of steps from reference value
};
/**
~PropertyCondition() override;
private:
-
// Not implemented
PropertyCondition(const PropertyCondition& rhs);
PropertyCondition& operator=(const PropertyCondition& rhs);
public:
-
- Type type; ///< The condition Type.
+ Type type; ///< The condition Type.
Dali::Vector<float> arguments; ///< The condition Arguments.
-
};
} // namespace Internal
inline Internal::PropertyCondition& GetImplementation(Dali::PropertyCondition& pub)
{
- DALI_ASSERT_ALWAYS( pub && "PropertyCondition handle is empty" );
+ DALI_ASSERT_ALWAYS(pub && "PropertyCondition handle is empty");
BaseObject& handle = pub.GetBaseObject();
inline const Internal::PropertyCondition& GetImplementation(const Dali::PropertyCondition& pub)
{
- DALI_ASSERT_ALWAYS( pub && "PropertyCondition handle is empty" );
+ DALI_ASSERT_ALWAYS(pub && "PropertyCondition handle is empty");
const BaseObject& handle = pub.GetBaseObject();
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
-bool CompareTokens( const char * first, const char * second, uint32_t& size )
+bool CompareTokens(const char* first, const char* second, uint32_t& size)
{
size = 0;
- while( ( *first != '\0' ) && ( *second != '\0' ) && ( *first != ',') && ( *second != ',') )
+ while((*first != '\0') && (*second != '\0') && (*first != ',') && (*second != ','))
{
++size;
char ca = *first;
char cb = *second;
- if( ( ( ca == '-' ) || ( ca == '_') ) &&
- ( ( cb == '-' ) || ( cb == '_') ) )
+ if(((ca == '-') || (ca == '_')) &&
+ ((cb == '-') || (cb == '_')))
{
++first;
++second;
continue;
}
- if( ( 'A' <= ca ) && ( ca <= 'Z') )
+ if(('A' <= ca) && (ca <= 'Z'))
{
- ca = static_cast<char>( ca + ( 'a' - 'A' ) ); // don't expect overflow
+ ca = static_cast<char>(ca + ('a' - 'A')); // don't expect overflow
}
- if( ( 'A' <= cb ) && ( cb <= 'Z') )
+ if(('A' <= cb) && (cb <= 'Z'))
{
- cb = static_cast<char>( cb + ( 'a' - 'A' ) ); // don't expect overflow
+ cb = static_cast<char>(cb + ('a' - 'A')); // don't expect overflow
}
- if( ca != cb )
+ if(ca != cb)
{
return false;
}
}
// enums can be comma separated so check ends and comma
- if( ( ( *first == '\0' ) && ( *second == '\0' ) ) ||
- ( ( *first == '\0' ) && ( *second == ',' ) ) ||
- ( ( *first == ',' ) && ( *second == '\0' ) ) )
+ if(((*first == '\0') && (*second == '\0')) ||
+ ((*first == '\0') && (*second == ',')) ||
+ ((*first == ',') && (*second == '\0')))
{
return true;
}
#define DALI_PROPERTY_HELPER_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstdint>
// INTERNAL INCLUDES
-#include <dali/integration-api/bitmap.h>
#include <dali/devel-api/scripting/enum-helper.h>
+#include <dali/integration-api/bitmap.h>
#include <dali/internal/event/object/default-property-metadata.h>
namespace Dali
{
-
namespace Internal
{
-
/**
* These macros are used to define a table of property details per object.
* Checking of the table index VS the property enum index happens during compile time.
* the macros define an instance of PropertyMetadata with the name that is passed to DALI_PROPERTY_TABLE_END
*/
#define DALI_PROPERTY_TABLE_BEGIN static constexpr Dali::PropertyDetails DEFAULT_PROPERTY_DETAILS[] = {
-
#define DALI_PROPERTY_TABLE_END(startIndex, tableName) \
- }; \
+ } \
+ ; \
static constexpr auto tableName = GeneratePropertyMetadata(DEFAULT_PROPERTY_DETAILS); \
static_assert(CheckPropertyMetadata(tableName, startIndex), "Property enumeration mismatch");
-#define DALI_PROPERTY( text, type, writable, animatable, constraint, index ) { text, index, Dali::Property::type, writable, animatable, constraint },
+#define DALI_PROPERTY(text, type, writable, animatable, constraint, index) {text, index, Dali::Property::type, writable, animatable, constraint},
/**
* @brief Case insensitive string comparison.
*
* @return true if strings are the same
*/
-bool CompareTokens( const char * first, const char * second, uint32_t& size );
-
+bool CompareTokens(const char* first, const char* second, uint32_t& size);
/**
* @brief Helper to adjust the current value of a variable from the given property-value
* @param[in] value The relative value as a Property::Value
* @return true if value adjusted, false otherwise
*/
-template< typename PropertyType >
-bool AdjustValue( PropertyType& currentValue, const Property::Value& value )
+template<typename PropertyType>
+bool AdjustValue(PropertyType& currentValue, const Property::Value& value)
{
PropertyType relativeValue;
- if( value.Get( relativeValue ) )
+ if(value.Get(relativeValue))
{
currentValue += relativeValue;
return true;
#define DALI_INTERNAL_PROPERTY_INPUT_IMPL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <iostream>
// INTERNAL INCLUDES
-#include <dali/public-api/object/property-input.h>
+#include <dali/internal/common/buffer-index.h>
+#include <dali/public-api/math/matrix.h>
+#include <dali/public-api/math/matrix3.h>
+#include <dali/public-api/math/quaternion.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/math/vector3.h>
#include <dali/public-api/math/vector4.h>
-#include <dali/public-api/math/quaternion.h>
-#include <dali/public-api/math/matrix3.h>
-#include <dali/public-api/math/matrix.h>
-#include <dali/internal/common/buffer-index.h>
+#include <dali/public-api/object/property-input.h>
-#if defined (ANDROID) || defined(WIN32) || defined(__APPLE__)
+#if defined(ANDROID) || defined(WIN32) || defined(__APPLE__)
namespace std
{
-
uint64_t _Hash_bytes(const void* bytes, uint64_t size, uint64_t seed);
}
namespace Dali
{
-
namespace Internal
{
-
/**
* An abstract interface for receiving property values, and for querying whether
* a property value has changed i.e. whether a constraint needs to be reapplied.
class PropertyInputImpl
{
public:
-
/**
* Virtual destructor.
*/
* @param[in] bufferIndex The buffer to read from.
* @return The boolean value.
*/
- virtual const bool& GetBoolean( BufferIndex bufferIndex ) const
+ virtual const bool& GetBoolean(BufferIndex bufferIndex) const
{
// the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const bool&>(*this);
* @param[in] bufferIndex The buffer to read from.
* @return The integer value.
*/
- virtual const int& GetInteger( BufferIndex bufferIndex ) const
+ virtual const int& GetInteger(BufferIndex bufferIndex) const
{
// the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const int&>(*this);
* @param[in] bufferIndex The buffer to read from.
* @return The float value.
*/
- virtual const float& GetFloat( BufferIndex bufferIndex ) const
+ virtual const float& GetFloat(BufferIndex bufferIndex) const
{
// the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const float&>(*this);
* @param[in] bufferIndex The buffer to read from.
* @return The Vector2 value.
*/
- virtual const Vector2& GetVector2( BufferIndex bufferIndex ) const
+ virtual const Vector2& GetVector2(BufferIndex bufferIndex) const
{
// the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const Vector2&>(*this);
* @param[in] bufferIndex The buffer to read from.
* @return The Vector3 value.
*/
- virtual const Vector3& GetVector3( BufferIndex bufferIndex ) const
+ virtual const Vector3& GetVector3(BufferIndex bufferIndex) const
{
// the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const Vector3&>(*this);
* @param[in] bufferIndex The buffer to read from.
* @return The Vector4 value.
*/
- virtual const Vector4& GetVector4( BufferIndex bufferIndex ) const
+ virtual const Vector4& GetVector4(BufferIndex bufferIndex) const
{
// the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const Vector4&>(*this);
* @param[in] bufferIndex The buffer to read from.
* @return The Quaternion value.
*/
- virtual const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const
+ virtual const Quaternion& GetQuaternion(BufferIndex bufferIndex) const
{
// the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const Quaternion&>(*this);
* @param[in] bufferIndex The buffer to read from.
* @return The Matrix value.
*/
- virtual const Matrix3& GetMatrix3( BufferIndex bufferIndex ) const
+ virtual const Matrix3& GetMatrix3(BufferIndex bufferIndex) const
{
// the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const Matrix3&>(*this);
* @param[in] bufferIndex The buffer to read from.
* @return The Matrix value.
*/
- virtual const Matrix& GetMatrix( BufferIndex bufferIndex ) const
+ virtual const Matrix& GetMatrix(BufferIndex bufferIndex) const
{
// the return will never be executed, it's just to keep the compiler happy
return reinterpret_cast<const Matrix&>(*this);
* @param[in] updateBufferIndex The current update buffer index.
* @return The boolean value.
*/
- virtual const bool& GetConstraintInputBoolean( BufferIndex updateBufferIndex ) const
+ virtual const bool& GetConstraintInputBoolean(BufferIndex updateBufferIndex) const
{
- return GetBoolean( updateBufferIndex );
+ return GetBoolean(updateBufferIndex);
}
/**
* @param[in] updateBufferIndex The current update buffer index.
* @return The integer value.
*/
- virtual const int& GetConstraintInputInteger( BufferIndex updateBufferIndex ) const
+ virtual const int& GetConstraintInputInteger(BufferIndex updateBufferIndex) const
{
- return GetInteger( updateBufferIndex );
+ return GetInteger(updateBufferIndex);
}
/**
* @param[in] updateBufferIndex The current update buffer index.
* @return The float value.
*/
- virtual const float& GetConstraintInputFloat( BufferIndex updateBufferIndex ) const
+ virtual const float& GetConstraintInputFloat(BufferIndex updateBufferIndex) const
{
- return GetFloat( updateBufferIndex );
+ return GetFloat(updateBufferIndex);
}
/**
* @param[in] updateBufferIndex The buffer to read from.
* @return The Vector2 value.
*/
- virtual const Vector2& GetConstraintInputVector2( BufferIndex updateBufferIndex ) const
+ virtual const Vector2& GetConstraintInputVector2(BufferIndex updateBufferIndex) const
{
- return GetVector2( updateBufferIndex );
+ return GetVector2(updateBufferIndex);
}
/**
* @param[in] updateBufferIndex The buffer to read from.
* @return The Vector3 value.
*/
- virtual const Vector3& GetConstraintInputVector3( BufferIndex updateBufferIndex ) const
+ virtual const Vector3& GetConstraintInputVector3(BufferIndex updateBufferIndex) const
{
- return GetVector3( updateBufferIndex );
+ return GetVector3(updateBufferIndex);
}
/**
* @param[in] updateBufferIndex The buffer to read from.
* @return The Vector4 value.
*/
- virtual const Vector4& GetConstraintInputVector4( BufferIndex updateBufferIndex ) const
+ virtual const Vector4& GetConstraintInputVector4(BufferIndex updateBufferIndex) const
{
- return GetVector4( updateBufferIndex );
+ return GetVector4(updateBufferIndex);
}
/**
* @param[in] updateBufferIndex The buffer to read from.
* @return The Quaternion value.
*/
- virtual const Quaternion& GetConstraintInputQuaternion( BufferIndex updateBufferIndex ) const
+ virtual const Quaternion& GetConstraintInputQuaternion(BufferIndex updateBufferIndex) const
{
- return GetQuaternion( updateBufferIndex );
+ return GetQuaternion(updateBufferIndex);
}
/**
* @param[in] updateBufferIndex The buffer to read from.
* @return The Matrix value.
*/
- virtual const Matrix3& GetConstraintInputMatrix3( BufferIndex updateBufferIndex ) const
+ virtual const Matrix3& GetConstraintInputMatrix3(BufferIndex updateBufferIndex) const
{
- return GetMatrix3( updateBufferIndex );
+ return GetMatrix3(updateBufferIndex);
}
/**
* @param[in] updateBufferIndex The buffer to read from.
* @return The Matrix value.
*/
- virtual const Matrix& GetConstraintInputMatrix( BufferIndex updateBufferIndex ) const
+ virtual const Matrix& GetConstraintInputMatrix(BufferIndex updateBufferIndex) const
{
- return GetMatrix( updateBufferIndex );
+ return GetMatrix(updateBufferIndex);
}
/**
std::uint64_t Hash(BufferIndex bufferIndex, uint64_t seed) const
{
- switch ( GetType() )
+ switch(GetType())
{
case Property::BOOLEAN:
{
return seed;
}
-
/**
* Print the property value using a stream.
* @param[in] debugStream The output stream.
* @param[in] bufferIndex The buffer to read from.
* @todo Place this far-too-large-to-be-inlined function in a cpp and remove <iostream> header dependency from this file.
*/
- void DebugPrint( std::ostream& debugStream, BufferIndex bufferIndex ) const
+ void DebugPrint(std::ostream& debugStream, BufferIndex bufferIndex) const
{
- switch ( GetType() )
+ switch(GetType())
{
case Property::BOOLEAN:
{
- debugStream << GetBoolean( bufferIndex );
+ debugStream << GetBoolean(bufferIndex);
break;
}
case Property::INTEGER:
{
- debugStream << GetInteger( bufferIndex );
+ debugStream << GetInteger(bufferIndex);
break;
}
case Property::FLOAT:
{
- debugStream << GetFloat( bufferIndex );
+ debugStream << GetFloat(bufferIndex);
break;
}
case Property::VECTOR2:
{
- debugStream << GetVector2( bufferIndex );
+ debugStream << GetVector2(bufferIndex);
break;
}
case Property::VECTOR3:
{
- debugStream << GetVector3( bufferIndex );
+ debugStream << GetVector3(bufferIndex);
break;
}
case Property::VECTOR4:
{
- debugStream << GetVector4( bufferIndex );
+ debugStream << GetVector4(bufferIndex);
break;
}
case Property::ROTATION:
{
- debugStream << GetQuaternion( bufferIndex );
+ debugStream << GetQuaternion(bufferIndex);
break;
}
case Property::MATRIX:
{
- debugStream << GetMatrix( bufferIndex );
+ debugStream << GetMatrix(bufferIndex);
break;
}
case Property::MATRIX3:
{
- debugStream << GetMatrix3( bufferIndex );
+ debugStream << GetMatrix3(bufferIndex);
break;
}
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/common/property-metadata.h>
// INTERNAL INCLUDES
+#include <dali/public-api/common/extents.h>
+#include <dali/public-api/math/matrix.h>
+#include <dali/public-api/math/matrix3.h>
#include <dali/public-api/math/quaternion.h>
+#include <dali/public-api/math/rect.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/math/vector3.h>
#include <dali/public-api/math/vector4.h>
-#include <dali/public-api/object/property.h>
-#include <dali/public-api/common/extents.h>
-#include <dali/public-api/math/matrix3.h>
-#include <dali/public-api/math/matrix.h>
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/object/property-map.h>
#include <dali/public-api/object/property-array.h>
+#include <dali/public-api/object/property-map.h>
+#include <dali/public-api/object/property.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
/// Helper to adjust the property value by an amount specified in another property-value
-template < typename PropertyType >
-inline void AdjustProperty( Property::Value& currentPropertyValue, const Property::Value& relativePropertyValue )
+template<typename PropertyType>
+inline void AdjustProperty(Property::Value& currentPropertyValue, const Property::Value& relativePropertyValue)
{
PropertyType currentValue;
PropertyType relativeValue;
- if( currentPropertyValue.Get( currentValue ) && relativePropertyValue.Get( relativeValue ) )
+ if(currentPropertyValue.Get(currentValue) && relativePropertyValue.Get(relativeValue))
{
currentPropertyValue = currentValue + relativeValue;
}
} // unnamed namespace
-void PropertyMetadata::SetPropertyValue( const Property::Value& propertyValue )
+void PropertyMetadata::SetPropertyValue(const Property::Value& propertyValue)
{
- switch ( GetType() )
+ switch(GetType())
{
case Property::NONE:
{
case Property::RECTANGLE:
{
Rect<int32_t> convertedValue;
- if( propertyValue.Get( convertedValue ) )
+ if(propertyValue.Get(convertedValue))
{
value = convertedValue;
}
case Property::STRING:
{
std::string convertedValue;
- if( propertyValue.Get( convertedValue ) )
+ if(propertyValue.Get(convertedValue))
{
value = convertedValue;
}
case Property::ARRAY:
{
const Property::Array* array = propertyValue.GetArray();
- if( array )
+ if(array)
{
value = *array;
}
case Property::MAP:
{
const Property::Map* map = propertyValue.GetMap();
- if( map )
+ if(map)
{
value = *map;
}
case Property::EXTENTS:
{
Extents convertedValue;
- if( propertyValue.Get( convertedValue ) )
+ if(propertyValue.Get(convertedValue))
{
value = convertedValue;
}
case Property::BOOLEAN:
{
bool convertedValue;
- if( propertyValue.Get( convertedValue ) )
+ if(propertyValue.Get(convertedValue))
{
value = convertedValue;
}
case Property::INTEGER:
{
int32_t convertedValue;
- if( propertyValue.Get( convertedValue ) )
+ if(propertyValue.Get(convertedValue))
{
value = convertedValue;
}
case Property::FLOAT:
{
float convertedValue;
- if( propertyValue.Get( convertedValue ) )
+ if(propertyValue.Get(convertedValue))
{
value = convertedValue;
}
case Property::ROTATION:
{
Quaternion convertedValue;
- if( propertyValue.Get( convertedValue ) )
+ if(propertyValue.Get(convertedValue))
{
value = convertedValue;
}
case Property::MATRIX:
{
Matrix convertedValue;
- if( propertyValue.Get( convertedValue ) )
+ if(propertyValue.Get(convertedValue))
{
value = convertedValue;
}
case Property::MATRIX3:
{
Matrix3 convertedValue;
- if( propertyValue.Get( convertedValue ) )
+ if(propertyValue.Get(convertedValue))
{
value = convertedValue;
}
case Property::VECTOR2:
{
Vector2 vector2Value;
- value.Get( vector2Value );
+ value.Get(vector2Value);
- if( componentIndex == 0 )
+ if(componentIndex == 0)
{
- vector2Value.x = propertyValue.Get< float >();
+ vector2Value.x = propertyValue.Get<float>();
}
- else if( componentIndex == 1 )
+ else if(componentIndex == 1)
{
- vector2Value.y = propertyValue.Get< float >();
+ vector2Value.y = propertyValue.Get<float>();
}
else
{
- propertyValue.Get( vector2Value );
+ propertyValue.Get(vector2Value);
}
value = vector2Value;
case Property::VECTOR3:
{
Vector3 vector3Value;
- value.Get( vector3Value );
+ value.Get(vector3Value);
- if( componentIndex == 0 )
+ if(componentIndex == 0)
{
- vector3Value.x = propertyValue.Get< float >();
+ vector3Value.x = propertyValue.Get<float>();
}
- else if( componentIndex == 1 )
+ else if(componentIndex == 1)
{
- vector3Value.y = propertyValue.Get< float >();
+ vector3Value.y = propertyValue.Get<float>();
}
- else if( componentIndex == 2 )
+ else if(componentIndex == 2)
{
- vector3Value.z = propertyValue.Get< float >();
+ vector3Value.z = propertyValue.Get<float>();
}
else
{
- propertyValue.Get( vector3Value );
+ propertyValue.Get(vector3Value);
}
value = vector3Value;
case Property::VECTOR4:
{
Vector4 vector4Value;
- value.Get( vector4Value );
+ value.Get(vector4Value);
- if( componentIndex == 0 )
+ if(componentIndex == 0)
{
- vector4Value.x = propertyValue.Get< float >();
+ vector4Value.x = propertyValue.Get<float>();
}
- else if( componentIndex == 1 )
+ else if(componentIndex == 1)
{
- vector4Value.y = propertyValue.Get< float >();
+ vector4Value.y = propertyValue.Get<float>();
}
- else if( componentIndex == 2 )
+ else if(componentIndex == 2)
{
- vector4Value.z = propertyValue.Get< float >();
+ vector4Value.z = propertyValue.Get<float>();
}
- else if( componentIndex == 3 )
+ else if(componentIndex == 3)
{
- vector4Value.w = propertyValue.Get< float >();
+ vector4Value.w = propertyValue.Get<float>();
}
else
{
- propertyValue.Get( vector4Value );
+ propertyValue.Get(vector4Value);
}
value = vector4Value;
{
Property::Value propertyValue;
- if( !IsAnimatable() )
+ if(!IsAnimatable())
{
propertyValue = value;
}
else
{
- switch ( GetType() )
+ switch(GetType())
{
case Property::NONE:
case Property::RECTANGLE:
case Property::VECTOR2:
{
Vector2 vector2Value;
- value.Get( vector2Value );
+ value.Get(vector2Value);
- if( componentIndex == 0 )
+ if(componentIndex == 0)
{
propertyValue = vector2Value.x;
}
- else if( componentIndex == 1 )
+ else if(componentIndex == 1)
{
propertyValue = vector2Value.y;
}
case Property::VECTOR3:
{
Vector3 vector3Value;
- value.Get( vector3Value );
+ value.Get(vector3Value);
- if( componentIndex == 0 )
+ if(componentIndex == 0)
{
propertyValue = vector3Value.x;
}
- else if( componentIndex == 1 )
+ else if(componentIndex == 1)
{
propertyValue = vector3Value.y;
}
- else if( componentIndex == 2 )
+ else if(componentIndex == 2)
{
propertyValue = vector3Value.z;
}
case Property::VECTOR4:
{
Vector4 vector4Value;
- value.Get( vector4Value );
+ value.Get(vector4Value);
- if( componentIndex == 0 )
+ if(componentIndex == 0)
{
propertyValue = vector4Value.x;
}
- else if( componentIndex == 1 )
+ else if(componentIndex == 1)
{
propertyValue = vector4Value.y;
}
- else if( componentIndex == 2 )
+ else if(componentIndex == 2)
{
propertyValue = vector4Value.z;
}
- else if( componentIndex == 3 )
+ else if(componentIndex == 3)
{
propertyValue = vector4Value.w;
}
return propertyValue;
}
-void PropertyMetadata::AdjustPropertyValueBy( const Property::Value& relativePropertyValue )
+void PropertyMetadata::AdjustPropertyValueBy(const Property::Value& relativePropertyValue)
{
- switch ( GetType() )
+ switch(GetType())
{
case Property::NONE:
case Property::RECTANGLE:
case Property::BOOLEAN:
{
- bool currentValue = false;
+ bool currentValue = false;
bool relativeValue = false;
- if( value.Get( currentValue ) && relativePropertyValue.Get( relativeValue ) )
+ if(value.Get(currentValue) && relativePropertyValue.Get(relativeValue))
{
value = currentValue || relativeValue;
}
case Property::INTEGER:
{
- AdjustProperty< int >( value, relativePropertyValue );
+ AdjustProperty<int>(value, relativePropertyValue);
break;
}
case Property::FLOAT:
{
- AdjustProperty< float >( value, relativePropertyValue );
+ AdjustProperty<float>(value, relativePropertyValue);
break;
}
{
Quaternion currentValue;
Quaternion relativeValue;
- if( value.Get( currentValue ) && relativePropertyValue.Get( relativeValue ) )
+ if(value.Get(currentValue) && relativePropertyValue.Get(relativeValue))
{
value = currentValue * relativeValue;
}
case Property::VECTOR2:
{
- if( componentIndex == Property::INVALID_COMPONENT_INDEX )
+ if(componentIndex == Property::INVALID_COMPONENT_INDEX)
{
- AdjustProperty< Vector2 >( value, relativePropertyValue );
+ AdjustProperty<Vector2>(value, relativePropertyValue);
}
else
{
Vector2 vector2Value;
- value.Get( vector2Value );
+ value.Get(vector2Value);
- if( componentIndex == 0 )
+ if(componentIndex == 0)
{
- vector2Value.x += relativePropertyValue.Get< float >();
+ vector2Value.x += relativePropertyValue.Get<float>();
}
- else if( componentIndex == 1 )
+ else if(componentIndex == 1)
{
- vector2Value.y += relativePropertyValue.Get< float >();
+ vector2Value.y += relativePropertyValue.Get<float>();
}
value = vector2Value;
case Property::VECTOR3:
{
- if( componentIndex == Property::INVALID_COMPONENT_INDEX )
+ if(componentIndex == Property::INVALID_COMPONENT_INDEX)
{
- AdjustProperty< Vector3 >( value, relativePropertyValue );
+ AdjustProperty<Vector3>(value, relativePropertyValue);
}
else
{
Vector3 vector3Value;
- value.Get( vector3Value );
+ value.Get(vector3Value);
- if( componentIndex == 0 )
+ if(componentIndex == 0)
{
- vector3Value.x += relativePropertyValue.Get< float >();
+ vector3Value.x += relativePropertyValue.Get<float>();
}
- else if( componentIndex == 1 )
+ else if(componentIndex == 1)
{
- vector3Value.y += relativePropertyValue.Get< float >();
+ vector3Value.y += relativePropertyValue.Get<float>();
}
- else if( componentIndex == 2 )
+ else if(componentIndex == 2)
{
- vector3Value.z += relativePropertyValue.Get< float >();
+ vector3Value.z += relativePropertyValue.Get<float>();
}
value = vector3Value;
case Property::VECTOR4:
{
- if( componentIndex == Property::INVALID_COMPONENT_INDEX )
+ if(componentIndex == Property::INVALID_COMPONENT_INDEX)
{
- AdjustProperty< Vector4 >( value, relativePropertyValue );
+ AdjustProperty<Vector4>(value, relativePropertyValue);
}
else
{
Vector4 vector4Value;
- value.Get( vector4Value );
+ value.Get(vector4Value);
- if( componentIndex == 0 )
+ if(componentIndex == 0)
{
- vector4Value.x += relativePropertyValue.Get< float >();
+ vector4Value.x += relativePropertyValue.Get<float>();
}
- else if( componentIndex == 1 )
+ else if(componentIndex == 1)
{
- vector4Value.y += relativePropertyValue.Get< float >();
+ vector4Value.y += relativePropertyValue.Get<float>();
}
- else if( componentIndex == 2 )
+ else if(componentIndex == 2)
{
- vector4Value.z += relativePropertyValue.Get< float >();
+ vector4Value.z += relativePropertyValue.Get<float>();
}
- else if( componentIndex == 3 )
+ else if(componentIndex == 3)
{
- vector4Value.w += relativePropertyValue.Get< float >();
+ vector4Value.w += relativePropertyValue.Get<float>();
}
value = vector4Value;
#define DALI_INTERNAL_PROPERTY_METADATA_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
class PropertyBase;
class PropertyMetadata
{
public:
-
/**
* @brief Virtual Destructor.
*/
* @brief Returns whether the property is animatable (i.e. if its a scene graph property).
* @return True if animatable, false otherwise
*/
- bool IsAnimatable( void ) const
+ bool IsAnimatable(void) const
{
return nullptr != mSceneGraphProperty;
}
* @brief Whether the property can be written to.
* @return True if the property can be written to, false otherwise
*/
- bool IsWritable( void ) const
+ bool IsWritable(void) const
{
return mWritable;
}
*/
const SceneGraph::PropertyBase* GetSceneGraphProperty() const
{
- DALI_ASSERT_DEBUG( mSceneGraphProperty && "Accessing uninitialized SceneGraph property" );
+ DALI_ASSERT_DEBUG(mSceneGraphProperty && "Accessing uninitialized SceneGraph property");
return mSceneGraphProperty;
}
* Set the cached value of the property.
* @param[in] value The propertyValue to set.
*/
- void SetPropertyValue( const Property::Value& propertyValue );
+ void SetPropertyValue(const Property::Value& propertyValue);
/**
* Get the cached value of a the property.
* Modifies the stored value by the relativeValue.
* @param[in] relativeValue The value to change by.
*/
- void AdjustPropertyValueBy( const Property::Value& relativeValue );
+ void AdjustPropertyValueBy(const Property::Value& relativeValue);
protected:
-
/**
* @brief Constructor to create Metadata for a property.
* @param[in] propertyValue The value of the property (this is used by the event thread)
* @param[in] sceneGraphProperty A pointer to the scene-graph owned property
* @param[in] writable Whether the property is writable
*/
- PropertyMetadata( Property::Value propertyValue,
- const SceneGraph::PropertyBase* sceneGraphProperty,
- bool writable )
- : value( mStoredValue ),
- componentIndex( Property::INVALID_COMPONENT_INDEX ),
- mStoredValue( std::move(propertyValue) ),
- mSceneGraphProperty( sceneGraphProperty ),
- mWritable( writable )
+ PropertyMetadata(Property::Value propertyValue,
+ const SceneGraph::PropertyBase* sceneGraphProperty,
+ bool writable)
+ : value(mStoredValue),
+ componentIndex(Property::INVALID_COMPONENT_INDEX),
+ mStoredValue(std::move(propertyValue)),
+ mSceneGraphProperty(sceneGraphProperty),
+ mWritable(writable)
{
}
* @param[in] baseValueRef A reference to the metadata of the base animatable property
* @param[in] propertyComponentIndex The component index of the property
*/
- PropertyMetadata( const SceneGraph::PropertyBase* sceneGraphProperty, bool writable, Property::Value& baseValueRef, int32_t propertyComponentIndex )
- : value( baseValueRef ),
- componentIndex( propertyComponentIndex ),
+ PropertyMetadata(const SceneGraph::PropertyBase* sceneGraphProperty, bool writable, Property::Value& baseValueRef, int32_t propertyComponentIndex)
+ : value(baseValueRef),
+ componentIndex(propertyComponentIndex),
mStoredValue(),
- mSceneGraphProperty( sceneGraphProperty ),
- mWritable( writable )
+ mSceneGraphProperty(sceneGraphProperty),
+ mWritable(writable)
{
}
private:
-
// Not implemented
- PropertyMetadata( const PropertyMetadata& );
- PropertyMetadata& operator=( const PropertyMetadata& );
+ PropertyMetadata(const PropertyMetadata&);
+ PropertyMetadata& operator=(const PropertyMetadata&);
public: // Data
-
/**
* @brief The value of this property used to read/write by the event thread.
*
int32_t componentIndex;
private:
-
- Property::Value mStoredValue; ///< The cached property value used to read/write by the event thread
- const SceneGraph::PropertyBase* mSceneGraphProperty; ///< A pointer to a scene-graph property; should not be modified from actor-thread
- bool mWritable:1; ///< Whether the property is writable
+ Property::Value mStoredValue; ///< The cached property value used to read/write by the event thread
+ const SceneGraph::PropertyBase* mSceneGraphProperty; ///< A pointer to a scene-graph property; should not be modified from actor-thread
+ bool mWritable : 1; ///< Whether the property is writable
};
/**
class AnimatablePropertyMetadata : public PropertyMetadata
{
public:
-
/**
* @brief Constructs metadata for a registered animatable property.
* @param[in] propertyIndex The index of the animatable property
*
* @note The base animatable property MUST be created before the component animatable property.
*/
- AnimatablePropertyMetadata( Property::Index propertyIndex,
- const Property::Value& propertyValue,
- const SceneGraph::PropertyBase* sceneGraphProperty )
- : PropertyMetadata( propertyValue, sceneGraphProperty, true ),
- index( propertyIndex )
+ AnimatablePropertyMetadata(Property::Index propertyIndex,
+ const Property::Value& propertyValue,
+ const SceneGraph::PropertyBase* sceneGraphProperty)
+ : PropertyMetadata(propertyValue, sceneGraphProperty, true),
+ index(propertyIndex)
{
- DALI_ASSERT_DEBUG( sceneGraphProperty && "Uninitialized scene-graph property" );
+ DALI_ASSERT_DEBUG(sceneGraphProperty && "Uninitialized scene-graph property");
}
/**
*
* @note The base animatable property MUST be created before the component animatable property.
*/
- AnimatablePropertyMetadata( Property::Index propertyIndex,
- int propertyComponentIndex,
- Property::Value& baseValueRef,
- const SceneGraph::PropertyBase* sceneGraphProperty )
- : PropertyMetadata( sceneGraphProperty, true, baseValueRef, propertyComponentIndex ),
- index( propertyIndex )
+ AnimatablePropertyMetadata(Property::Index propertyIndex,
+ int propertyComponentIndex,
+ Property::Value& baseValueRef,
+ const SceneGraph::PropertyBase* sceneGraphProperty)
+ : PropertyMetadata(sceneGraphProperty, true, baseValueRef, propertyComponentIndex),
+ index(propertyIndex)
{
- DALI_ASSERT_DEBUG( sceneGraphProperty && "Uninitialized scene-graph property" );
+ DALI_ASSERT_DEBUG(sceneGraphProperty && "Uninitialized scene-graph property");
}
/**
~AnimatablePropertyMetadata() override = default;
private:
-
// Not implemented
AnimatablePropertyMetadata();
- AnimatablePropertyMetadata( const AnimatablePropertyMetadata& );
- AnimatablePropertyMetadata& operator=( const AnimatablePropertyMetadata& );
-
-public: // Data
+ AnimatablePropertyMetadata(const AnimatablePropertyMetadata&);
+ AnimatablePropertyMetadata& operator=(const AnimatablePropertyMetadata&);
- Property::Index index; ///< The index of the property.
+public: // Data
+ Property::Index index; ///< The index of the property.
};
class CustomPropertyMetadata : public PropertyMetadata
{
public:
-
/**
* Constructs Metadata for scene-graph-based custom properties, i.e. animatable custom properties.
* @param[in] propertyName The name of the custom property
key(propertyKey),
childPropertyIndex(Property::INVALID_INDEX)
{
- DALI_ASSERT_DEBUG( sceneGraphProperty && "Uninitialized scene-graph property" );
+ DALI_ASSERT_DEBUG(sceneGraphProperty && "Uninitialized scene-graph property");
}
/**
key(Property::INVALID_KEY),
childPropertyIndex(Property::INVALID_INDEX)
{
- DALI_ASSERT_DEBUG( accessMode != Property::ANIMATABLE && "Event side only properties should not be animatable" );
+ DALI_ASSERT_DEBUG(accessMode != Property::ANIMATABLE && "Event side only properties should not be animatable");
}
/**
~CustomPropertyMetadata() override = default;
private:
-
// Not implemented
CustomPropertyMetadata();
- CustomPropertyMetadata( const CustomPropertyMetadata& );
- CustomPropertyMetadata& operator=( const CustomPropertyMetadata& );
+ CustomPropertyMetadata(const CustomPropertyMetadata&);
+ CustomPropertyMetadata& operator=(const CustomPropertyMetadata&);
-public: // Data
- ConstString name; ///< The name of the property.
- Property::Index key; ///< The key of the property.
- Property::Index childPropertyIndex; ///< The index as a child property.
+public: // Data
+ ConstString name; ///< The name of the property.
+ Property::Index key; ///< The key of the property.
+ Property::Index childPropertyIndex; ///< The index as a child property.
};
} // namespace Internal
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/common/property-notification-impl.h>
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/math/radian.h>
-#include <dali/public-api/actors/actor.h>
#include <dali/internal/event/actors/actor-impl.h>
-#include <dali/internal/event/common/property-notification-manager.h>
#include <dali/internal/event/common/object-impl.h>
+#include <dali/internal/event/common/property-notification-manager.h>
#include <dali/internal/event/common/stage-impl.h>
-#include <dali/internal/update/manager/update-manager.h>
-#include <dali/internal/update/common/scene-graph-property-notification.h>
#include <dali/internal/event/common/thread-local-storage.h>
+#include <dali/internal/update/common/scene-graph-property-notification.h>
+#include <dali/internal/update/manager/update-manager.h>
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/math/radian.h>
+#include <dali/public-api/math/vector2.h>
using Dali::Internal::SceneGraph::UpdateManager;
namespace Dali
{
-
namespace Internal
{
-
-PropertyNotificationPtr PropertyNotification::New(Property& target,
- int componentIndex,
+PropertyNotificationPtr PropertyNotification::New(Property& target,
+ int componentIndex,
const Dali::PropertyCondition& condition)
{
ThreadLocalStorage& tls = ThreadLocalStorage::Get();
UpdateManager& updateManager = tls.GetUpdateManager();
PropertyNotificationManager& propertyNotificationManager = tls.GetPropertyNotificationManager();
- PropertyNotificationPtr propertyNotification = new PropertyNotification(updateManager,
+ PropertyNotificationPtr propertyNotification = new PropertyNotification(updateManager,
propertyNotificationManager,
target,
componentIndex,
return propertyNotification;
}
-PropertyNotification::PropertyNotification( UpdateManager& updateManager,
- PropertyNotificationManager& propertyNotificationManager,
- Property& target,
- int componentIndex,
- const Dali::PropertyCondition& condition )
-: mUpdateManager( updateManager ),
- mPropertyNotification( nullptr ),
- mPropertyNotificationManager( propertyNotificationManager ),
- mObjectPropertyIndex( target.propertyIndex ),
- mPropertyType( Property::NONE ),
- mComponentIndex( componentIndex ),
- mCondition( condition ),
- mNotifyMode( Dali::PropertyNotification::NOTIFY_ON_TRUE ),
- mNotifyResult( false ),
- mCompare( false )
-{
- const Internal::PropertyCondition& conditionImpl = GetImplementation( condition );
+PropertyNotification::PropertyNotification(UpdateManager& updateManager,
+ PropertyNotificationManager& propertyNotificationManager,
+ Property& target,
+ int componentIndex,
+ const Dali::PropertyCondition& condition)
+: mUpdateManager(updateManager),
+ mPropertyNotification(nullptr),
+ mPropertyNotificationManager(propertyNotificationManager),
+ mObjectPropertyIndex(target.propertyIndex),
+ mPropertyType(Property::NONE),
+ mComponentIndex(componentIndex),
+ mCondition(condition),
+ mNotifyMode(Dali::PropertyNotification::NOTIFY_ON_TRUE),
+ mNotifyResult(false),
+ mCompare(false)
+{
+ const Internal::PropertyCondition& conditionImpl = GetImplementation(condition);
Dali::Vector<float>::SizeType count = conditionImpl.arguments.Count();
- for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
+ for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
{
- mRawConditionArgs.PushBack( conditionImpl.arguments[ index ] );
+ mRawConditionArgs.PushBack(conditionImpl.arguments[index]);
}
// Observe target object and create/destroy notification scene object accordingly.
- mObject = dynamic_cast<Object*>( &GetImplementation(target.object) );
- if ( mObject )
+ mObject = dynamic_cast<Object*>(&GetImplementation(target.object));
+ if(mObject)
{
mPropertyType = mObject->GetPropertyType(mObjectPropertyIndex);
int internalComponentIndex = mObject->GetPropertyComponentIndex(mObjectPropertyIndex);
- if( internalComponentIndex != Property::INVALID_COMPONENT_INDEX )
+ if(internalComponentIndex != Property::INVALID_COMPONENT_INDEX)
{
// override the one passed in
mComponentIndex = internalComponentIndex;
if(mComponentIndex != Property::INVALID_COMPONENT_INDEX)
{
Property::Type type = mObject->GetPropertyType(mObjectPropertyIndex);
- if( type == Property::VECTOR2
- || type == Property::VECTOR3
- || type == Property::VECTOR4 )
+ if(type == Property::VECTOR2 || type == Property::VECTOR3 || type == Property::VECTOR4)
{
mPropertyType = Property::FLOAT;
}
}
- // In Size Property case, swapping components occurs sometimes.
- // To cover swapping components, previous and current components should be compared.
- if( mObjectPropertyIndex == Dali::Actor::Property::SIZE
- && mObject->GetPropertyType(mObjectPropertyIndex) == Property::VECTOR3 )
- {
- mCompare = true;
- for( int i = 0; i < 3; ++i )
+ // In Size Property case, swapping components occurs sometimes.
+ // To cover swapping components, previous and current components should be compared.
+ if(mObjectPropertyIndex == Dali::Actor::Property::SIZE && mObject->GetPropertyType(mObjectPropertyIndex) == Property::VECTOR3)
{
- mRawConditionArgs.PushBack( 0.0f );
+ mCompare = true;
+ for(int i = 0; i < 3; ++i)
+ {
+ mRawConditionArgs.PushBack(0.0f);
+ }
}
- }
// all objects always have scene object
CreateSceneObject();
}
// Connect to the property notification manager
- mPropertyNotificationManager.PropertyNotificationCreated( *this );
+ mPropertyNotificationManager.PropertyNotificationCreated(*this);
}
PropertyNotification::~PropertyNotification()
Disable();
// Guard to disallow use of PropertyNotificationManager after Core has been destroyed
- if ( Stage::IsInstalled() )
+ if(Stage::IsInstalled())
{
// Disconnect from the property notification manager
- mPropertyNotificationManager.PropertyNotificationDestroyed( *this );
+ mPropertyNotificationManager.PropertyNotificationDestroyed(*this);
}
}
{
Dali::PropertyNotification source(this);
- mNotifySignal.Emit( source );
+ mNotifySignal.Emit(source);
}
void PropertyNotification::Enable()
void PropertyNotification::Disable()
{
// Guard to allow handle destruction after Core has been destroyed
- if ( Stage::IsInstalled() )
+ if(Stage::IsInstalled())
{
// Stop scene-graph from monitoring the target's properties.
DestroySceneObject();
}
}
-void PropertyNotification::SetNotifyResult( bool result )
+void PropertyNotification::SetNotifyResult(bool result)
{
mNotifyResult = result;
}
return mObjectPropertyIndex;
}
-void PropertyNotification::SetNotifyMode( NotifyMode mode )
+void PropertyNotification::SetNotifyMode(NotifyMode mode)
{
mNotifyMode = mode;
- if( mPropertyNotification )
+ if(mPropertyNotification)
{
- PropertyNotificationSetNotifyModeMessage( mUpdateManager, mPropertyNotification, mode );
+ PropertyNotificationSetNotifyModeMessage(mUpdateManager, mPropertyNotification, mode);
}
}
return mNotifyResult;
}
-bool PropertyNotification::CompareSceneObject( const SceneGraph::PropertyNotification* sceneObject )
+bool PropertyNotification::CompareSceneObject(const SceneGraph::PropertyNotification* sceneObject)
{
return sceneObject && sceneObject == mPropertyNotification;
}
void PropertyNotification::CreateSceneObject()
{
// this method can be called from constructor and on stage connection
- if( !mPropertyNotification )
+ if(!mPropertyNotification)
{
// Create a new PropertyNotification, keep a const pointer to it
- mPropertyNotification = SceneGraph::PropertyNotification::New( *mObject,
- mObjectPropertyIndex,
- mPropertyType,
- mComponentIndex,
- GetImplementation( mCondition ).type,
- mRawConditionArgs,
- mNotifyMode,
- mCompare );
- OwnerPointer< SceneGraph::PropertyNotification > transferOwnership( const_cast<SceneGraph::PropertyNotification*>( mPropertyNotification ) );
- AddPropertyNotificationMessage( mUpdateManager, transferOwnership );
+ mPropertyNotification = SceneGraph::PropertyNotification::New(*mObject,
+ mObjectPropertyIndex,
+ mPropertyType,
+ mComponentIndex,
+ GetImplementation(mCondition).type,
+ mRawConditionArgs,
+ mNotifyMode,
+ mCompare);
+ OwnerPointer<SceneGraph::PropertyNotification> transferOwnership(const_cast<SceneGraph::PropertyNotification*>(mPropertyNotification));
+ AddPropertyNotificationMessage(mUpdateManager, transferOwnership);
}
}
void PropertyNotification::DestroySceneObject()
{
- if ( mPropertyNotification != nullptr )
+ if(mPropertyNotification != nullptr)
{
// Remove PropertyNotification using a message to the update manager
- RemovePropertyNotificationMessage( mUpdateManager, *mPropertyNotification );
+ RemovePropertyNotificationMessage(mUpdateManager, *mPropertyNotification);
mPropertyNotification = nullptr;
}
}
#define DALI_INTERNAL_PROPERTY_NOTIFICATION_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/common/property-conditions-impl.h>
#include <dali/public-api/common/dali-vector.h>
-#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/object/property-notification.h>
-#include <dali/internal/event/common/property-conditions-impl.h>
+#include <dali/public-api/object/ref-object.h>
namespace Dali
{
-
class PropertyCondition;
namespace Internal
{
-
namespace SceneGraph
{
class PropertyNotification;
class UpdateManager;
-}
+} // namespace SceneGraph
class Actor;
class PropertyNotification;
* @param[in] condition The condition for this notification.
* @return A smart-pointer to the newly allocated PropertyNotification.
*/
- static PropertyNotificationPtr New(Property& target,
- int componentIndex,
+ static PropertyNotificationPtr New(Property& target,
+ int componentIndex,
const Dali::PropertyCondition& condition);
public:
-
/**
* @copydoc Dali::PropertyNotification::NotifySignal()
*/
/**
* @copydoc Dali::PropertyNotification::SetNotifyMode
*/
- void SetNotifyMode( NotifyMode mode );
+ void SetNotifyMode(NotifyMode mode);
/**
* @copydoc Dali::PropertyNotification::GetNotifyMode
* @param[in] sceneObject The SceneGraph::PropertyNotification pointer to compare
* @return true if sceneObject is the same as the one created by this instance
*/
- bool CompareSceneObject( const SceneGraph::PropertyNotification* sceneObject );
+ bool CompareSceneObject(const SceneGraph::PropertyNotification* sceneObject);
protected:
-
/**
* Construct a new PropertyNotification.
* @param[in] updateManager The UpdateManager associated with this PropertyNotification.
* @param[in] componentIndex Index to the component of a complex property such as a Vector
* @param[in] condition The condition for this notification.
*/
- PropertyNotification(SceneGraph::UpdateManager& updateManager,
- PropertyNotificationManager& propertyNotificationManager,
- Property& target,
- int componentIndex,
+ PropertyNotification(SceneGraph::UpdateManager& updateManager,
+ PropertyNotificationManager& propertyNotificationManager,
+ Property& target,
+ int componentIndex,
const Dali::PropertyCondition& condition);
/**
~PropertyNotification() override;
private:
-
// Undefined
PropertyNotification(const PropertyNotification&);
PropertyNotification& operator=(const PropertyNotification& rhs);
protected:
-
- SceneGraph::UpdateManager& mUpdateManager;
+ SceneGraph::UpdateManager& mUpdateManager;
const SceneGraph::PropertyNotification* mPropertyNotification;
Dali::PropertyNotifySignalType mNotifySignal;
private:
-
- PropertyNotificationManager& mPropertyNotificationManager; ///< Reference to the property notification manager
- Object* mObject; ///< Target object, not owned by PropertyNotification.
- Property::Index mObjectPropertyIndex; ///< Target object's property index of interest.
- Property::Type mPropertyType; ///< The type of property to evaluate
- int mComponentIndex; ///< Index to a specific component of a complex property such as a Vector
- Dali::PropertyCondition mCondition; ///< The PropertyCondition handle.
- RawArgumentContainer mRawConditionArgs; ///< The Raw Condition args. (float type)
- NotifyMode mNotifyMode; ///< The current notification mode.
- bool mNotifyResult; ///< The result of the last condition check that caused a signal emit
- bool mCompare; ///< The flag of comparing previous property's raw value and current.
+ PropertyNotificationManager& mPropertyNotificationManager; ///< Reference to the property notification manager
+ Object* mObject; ///< Target object, not owned by PropertyNotification.
+ Property::Index mObjectPropertyIndex; ///< Target object's property index of interest.
+ Property::Type mPropertyType; ///< The type of property to evaluate
+ int mComponentIndex; ///< Index to a specific component of a complex property such as a Vector
+ Dali::PropertyCondition mCondition; ///< The PropertyCondition handle.
+ RawArgumentContainer mRawConditionArgs; ///< The Raw Condition args. (float type)
+ NotifyMode mNotifyMode; ///< The current notification mode.
+ bool mNotifyResult; ///< The result of the last condition check that caused a signal emit
+ bool mCompare; ///< The flag of comparing previous property's raw value and current.
};
} // namespace Internal
inline Internal::PropertyNotification& GetImplementation(Dali::PropertyNotification& pub)
{
- DALI_ASSERT_ALWAYS( pub && "PropertyNotification handle is empty" );
+ DALI_ASSERT_ALWAYS(pub && "PropertyNotification handle is empty");
BaseObject& handle = pub.GetBaseObject();
inline const Internal::PropertyNotification& GetImplementation(const Dali::PropertyNotification& pub)
{
- DALI_ASSERT_ALWAYS( pub && "PropertyNotification handle is empty" );
+ DALI_ASSERT_ALWAYS(pub && "PropertyNotification handle is empty");
const BaseObject& handle = pub.GetBaseObject();
#include <dali/internal/event/common/property-notification-manager.h>
// INTERNAL INCLUDES
-#include <dali/internal/event/common/property-notification-impl.h>
#include <dali/internal/common/message.h>
+#include <dali/internal/event/common/property-notification-impl.h>
namespace Dali
{
-
namespace Internal
{
-
PropertyNotificationManager* PropertyNotificationManager::New()
{
return new PropertyNotificationManager;
PropertyNotificationManager::~PropertyNotificationManager() = default;
-void PropertyNotificationManager::PropertyNotificationCreated( PropertyNotification& propertyNotification )
+void PropertyNotificationManager::PropertyNotificationCreated(PropertyNotification& propertyNotification)
{
- mPropertyNotifications.PushBack( &propertyNotification );
+ mPropertyNotifications.PushBack(&propertyNotification);
}
-void PropertyNotificationManager::PropertyNotificationDestroyed( PropertyNotification& propertyNotification )
+void PropertyNotificationManager::PropertyNotificationDestroyed(PropertyNotification& propertyNotification)
{
- Dali::Vector< PropertyNotification* >::Iterator iter = std::find( mPropertyNotifications.Begin(), mPropertyNotifications.End(), &propertyNotification );
- DALI_ASSERT_ALWAYS( iter != mPropertyNotifications.End() && "PropertyNotification not found" );
+ Dali::Vector<PropertyNotification*>::Iterator iter = std::find(mPropertyNotifications.Begin(), mPropertyNotifications.End(), &propertyNotification);
+ DALI_ASSERT_ALWAYS(iter != mPropertyNotifications.End() && "PropertyNotification not found");
- mPropertyNotifications.Remove( iter );
+ mPropertyNotifications.Remove(iter);
}
-void PropertyNotificationManager::NotifyProperty( SceneGraph::PropertyNotification* propertyNotification, bool validity )
+void PropertyNotificationManager::NotifyProperty(SceneGraph::PropertyNotification* propertyNotification, bool validity)
{
- Dali::Vector< PropertyNotification* >::Iterator iter = mPropertyNotifications.Begin();
- const Dali::Vector< PropertyNotification* >::Iterator endIter = mPropertyNotifications.End();
+ Dali::Vector<PropertyNotification*>::Iterator iter = mPropertyNotifications.Begin();
+ const Dali::Vector<PropertyNotification*>::Iterator endIter = mPropertyNotifications.End();
// walk the collection of PropertyNotifications
- for( ; iter != endIter; ++iter )
+ for(; iter != endIter; ++iter)
{
// found one with the matching SceneGraph::PropertyNotification?
- if( (*iter)->CompareSceneObject( propertyNotification ) )
+ if((*iter)->CompareSceneObject(propertyNotification))
{
// allow application to access the value that triggered this emit incase of NOTIFY_ON_CHANGED mode
(*iter)->SetNotifyResult(validity);
} // namespace Internal
} // namespace Dali
-
#define DALI_INTERNAL_PROPERTY_NOTIFICATION_MANAGER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-vector.h>
#include <dali/internal/event/common/property-notifier.h>
+#include <dali/public-api/common/dali-vector.h>
namespace Dali
{
-
namespace Internal
{
-
class PropertyNotification;
/**
class PropertyNotificationManager : public PropertyNotifier
{
public:
-
/**
* Create an PropertyNotificationManager.
* @return A newly allocated object.
/**
* Called when a PropertyNotification is constructed.
*/
- void PropertyNotificationCreated( PropertyNotification& propertyNotification );
+ void PropertyNotificationCreated(PropertyNotification& propertyNotification);
/**
* Called when a PropertyNotification is destroyed.
*/
- void PropertyNotificationDestroyed( PropertyNotification& propertyNotification );
+ void PropertyNotificationDestroyed(PropertyNotification& propertyNotification);
private: // private virtual overrides
-
/**
* @copydoc PropertyNotifier::NotifyProperty
*/
- void NotifyProperty( SceneGraph::PropertyNotification* propertyNotification, bool validity ) override;
+ void NotifyProperty(SceneGraph::PropertyNotification* propertyNotification, bool validity) override;
private:
-
/**
* Default constructor.
*/
PropertyNotificationManager& operator=(const PropertyNotificationManager& rhs);
private:
-
- Dali::Vector< PropertyNotification* > mPropertyNotifications; ///< All existing PropertyNotifications (not owned)
-
+ Dali::Vector<PropertyNotification*> mPropertyNotifications; ///< All existing PropertyNotifications (not owned)
};
} // namespace Internal
} // namespace Dali
#endif // DALI_INTERNAL_PROPERTY_NOTIFICATION_MANAGER_H
-
#define DALI_INTERNAL_PROPERTY_NOTIFIER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
class PropertyNotification;
} //namespace SceneGraph
class PropertyNotifier
{
public:
-
/**
* Virtual destructor.
*/
* @param[in] propertyNotification A pointer to the SceneGraph::PropertyNotification that has been mnodified.
* @param[in] validity Passes in whether the notification was triggered by a true or false condition result
*/
- virtual void NotifyProperty( SceneGraph::PropertyNotification* propertyNotification, bool validity ) = 0;
+ virtual void NotifyProperty(SceneGraph::PropertyNotification* propertyNotification, bool validity) = 0;
};
/**
* Notification message for when a property has been modified
* @param[in] notifier This will provide the notification signal.
*/
-inline MessageBase* PropertyChangedMessage( PropertyNotifier& notifier, SceneGraph::PropertyNotification* propertyNotification, bool validity )
+inline MessageBase* PropertyChangedMessage(PropertyNotifier& notifier, SceneGraph::PropertyNotification* propertyNotification, bool validity)
{
- return new MessageValue2< PropertyNotifier, SceneGraph::PropertyNotification*, bool >( ¬ifier,
- &PropertyNotifier::NotifyProperty,
- propertyNotification, validity);
+ return new MessageValue2<PropertyNotifier, SceneGraph::PropertyNotification*, bool>(¬ifier,
+ &PropertyNotifier::NotifyProperty,
+ propertyNotification,
+ validity);
}
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/common/scene-impl.h>
// INTERNAL INCLUDES
+#include <dali/internal/event/actors/camera-actor-impl.h>
#include <dali/internal/event/actors/layer-impl.h>
#include <dali/internal/event/actors/layer-list.h>
-#include <dali/internal/event/actors/camera-actor-impl.h>
+#include <dali/internal/event/common/object-registry-impl.h>
#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/render-tasks/render-task-list-impl.h>
#include <dali/internal/event/render-tasks/render-task-impl.h>
-#include <dali/internal/event/common/object-registry-impl.h>
-#include <dali/internal/update/nodes/node.h>
-#include <dali/internal/update/manager/update-manager.h>
+#include <dali/internal/event/render-tasks/render-task-list-impl.h>
+#include <dali/internal/event/rendering/frame-buffer-impl.h>
+#include <dali/internal/event/size-negotiation/relayout-controller-impl.h>
#include <dali/internal/update/common/scene-graph-scene.h>
+#include <dali/internal/update/manager/update-manager.h>
+#include <dali/internal/update/nodes/node.h>
#include <dali/public-api/common/constants.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/render-tasks/render-task-list.h>
-#include <dali/internal/event/rendering/frame-buffer-impl.h>
-#include <dali/internal/event/size-negotiation/relayout-controller-impl.h>
using Dali::Internal::SceneGraph::Node;
namespace Dali
{
-
namespace Internal
{
-
ScenePtr Scene::New(Size size, int orientation)
{
ScenePtr scene = new Scene;
Scene::~Scene()
{
- if( EventThreadServices::IsCoreRunning() && mSceneObject )
+ if(EventThreadServices::IsCoreRunning() && mSceneObject)
{
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
- RemoveSceneMessage( tls->GetUpdateManager(), *mSceneObject );
+ RemoveSceneMessage(tls->GetUpdateManager(), *mSceneObject);
}
- if( mDefaultCamera )
+ if(mDefaultCamera)
{
// its enough to release the handle so the object is released
// don't need to remove it from root actor as root actor will delete the object
mDefaultCamera.Reset();
}
- if( mRootLayer )
+ if(mRootLayer)
{
// we are closing down so just delete the root, no point emit disconnect
// signals or send messages to update
mRootLayer.Reset();
}
- if( mRenderTaskList )
+ if(mRenderTaskList)
{
mRenderTaskList.Reset();
}
{
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
- DALI_ASSERT_ALWAYS( tls && "Attempt to create scene before core exists!" );
+ DALI_ASSERT_ALWAYS(tls && "Attempt to create scene before core exists!");
- tls->AddScene( this );
+ tls->AddScene(this);
SceneGraph::UpdateManager& updateManager = tls->GetUpdateManager();
// Create the ordered list of layers
- mLayerList = LayerList::New( updateManager );
+ mLayerList = LayerList::New(updateManager);
// The scene owns the default layer
- mRootLayer = Layer::NewRoot( *mLayerList );
+ mRootLayer = Layer::NewRoot(*mLayerList);
mRootLayer->SetName("RootLayer");
- mRootLayer->SetScene( *this );
+ mRootLayer->SetScene(*this);
// The root layer needs to have a fixed resize policy (as opposed to the default USE_NATURAL_SIZE).
// This stops actors parented to the stage having their relayout requests propagating
// up to the root layer, and down through other children unnecessarily.
- mRootLayer->SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
+ mRootLayer->SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
// Create the default camera actor first; this is needed by the RenderTaskList
// The default camera attributes and position is such that children of the default layer,
// can be positioned at (0,0) and be at the top-left of the viewport.
- mDefaultCamera = CameraActor::New( size );
+ mDefaultCamera = CameraActor::New(size);
mDefaultCamera->SetParentOrigin(ParentOrigin::CENTER);
Add(*(mDefaultCamera.Get()));
mRenderTaskList = RenderTaskList::New();
// Create the default render-task and ensure clear is enabled on it to show the background color
- RenderTaskPtr renderTask = mRenderTaskList->CreateTask( mRootLayer.Get(), mDefaultCamera.Get() );
+ RenderTaskPtr renderTask = mRenderTaskList->CreateTask(mRootLayer.Get(), mDefaultCamera.Get());
renderTask->SetClearEnabled(true);
// Create scene graph object
mSceneObject = new SceneGraph::Scene();
- OwnerPointer< SceneGraph::Scene > transferOwnership( const_cast< SceneGraph::Scene* >( mSceneObject ) );
- AddSceneMessage( updateManager, transferOwnership );
+ OwnerPointer<SceneGraph::Scene> transferOwnership(const_cast<SceneGraph::Scene*>(mSceneObject));
+ AddSceneMessage(updateManager, transferOwnership);
- SurfaceRotated( size.width, size.height, orientation );
+ SurfaceRotated(size.width, size.height, orientation);
}
void Scene::Add(Actor& actor)
{
- mRootLayer->Add( actor );
+ mRootLayer->Add(actor);
}
void Scene::Remove(Actor& actor)
{
- mRootLayer->Remove( actor );
+ mRootLayer->Remove(actor);
}
Size Scene::GetSize() const
Dali::Layer Scene::GetRootLayer() const
{
- return Dali::Layer( mRootLayer.Get() );
+ return Dali::Layer(mRootLayer.Get());
}
LayerList& Scene::GetLayerList() const
return mLayerList->GetLayerCount();
}
-Dali::Layer Scene::GetLayer( uint32_t depth ) const
+Dali::Layer Scene::GetLayer(uint32_t depth) const
{
- return Dali::Layer(mLayerList->GetLayer( depth ));
+ return Dali::Layer(mLayerList->GetLayer(depth));
}
CameraActor& Scene::GetDefaultCameraActor()
void Scene::SurfaceReplaced()
{
- if ( mSceneObject )
+ if(mSceneObject)
{
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
- SurfaceReplacedMessage( tls->GetUpdateManager(), *mSceneObject );
+ SurfaceReplacedMessage(tls->GetUpdateManager(), *mSceneObject);
}
}
void Scene::Discard()
{
- if( ThreadLocalStorage::Created() )
+ if(ThreadLocalStorage::Created())
{
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
- tls->RemoveScene( this );
+ tls->RemoveScene(this);
}
}
mDepthTreeDirty = true;
}
-void Scene::QueueEvent( const Integration::Event& event )
+void Scene::QueueEvent(const Integration::Event& event)
{
- mEventProcessor.QueueEvent( event );
+ mEventProcessor.QueueEvent(event);
}
void Scene::ProcessEvents()
void Scene::RebuildDepthTree()
{
// If the depth tree needs rebuilding, do it in this frame only.
- if( mDepthTreeDirty )
+ if(mDepthTreeDirty)
{
- ActorPtr actor( mRootLayer.Get() );
+ ActorPtr actor(mRootLayer.Get());
actor->RebuildDepthTree();
mDepthTreeDirty = false;
}
}
-void Scene::SetBackgroundColor( const Vector4& color )
+void Scene::SetBackgroundColor(const Vector4& color)
{
mBackgroundColor = color;
- mRenderTaskList->GetTask( 0u )->SetClearColor( color );
- mRenderTaskList->GetTask( 0u )->SetClearEnabled( true );
+ mRenderTaskList->GetTask(0u)->SetClearColor(color);
+ mRenderTaskList->GetTask(0u)->SetClearEnabled(true);
}
Vector4 Scene::GetBackgroundColor() const
void Scene::EmitKeyEventSignal(const Dali::KeyEvent& event)
{
- if ( !mKeyEventSignal.Empty() )
+ if(!mKeyEventSignal.Empty())
{
- Dali::Integration::Scene handle( this );
- mKeyEventSignal.Emit( event );
+ Dali::Integration::Scene handle(this);
+ mKeyEventSignal.Emit(event);
}
}
mRootLayer->SetSize(width, height);
// Send the surface rectangle/orientation to SceneGraph::Scene for calculating glViewport/Scissor
- ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
+ ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
SetSurfaceRectMessage(tls->GetEventThreadServices(), *mSceneObject, newSize);
SetSurfaceOrientationMessage(tls->GetEventThreadServices(), *mSceneObject, static_cast<int32_t>(orientation));
bool Scene::EmitKeyEventGeneratedSignal(const Dali::KeyEvent& event)
{
// Emit the KeyEventGenerated signal when KeyEvent is generated
- Dali::Integration::Scene handle( this );
- return mKeyEventGeneratedSignal.Emit( event );
+ Dali::Integration::Scene handle(this);
+ return mKeyEventGeneratedSignal.Emit(event);
}
void Scene::EmitEventProcessingFinishedSignal()
{
- if ( !mEventProcessingFinishedSignal.Empty() )
+ if(!mEventProcessingFinishedSignal.Empty())
{
- Dali::Integration::Scene handle( this );
+ Dali::Integration::Scene handle(this);
mEventProcessingFinishedSignal.Emit();
}
}
-void Scene::EmitTouchedSignal( const Dali::TouchEvent& touch )
+void Scene::EmitTouchedSignal(const Dali::TouchEvent& touch)
{
- Dali::Integration::Scene handle( this );
- if ( !mTouchedSignal.Empty() )
+ Dali::Integration::Scene handle(this);
+ if(!mTouchedSignal.Empty())
{
- mTouchedSignal.Emit( touch );
+ mTouchedSignal.Emit(touch);
}
}
void Scene::EmitWheelEventSignal(const Dali::WheelEvent& event)
{
- if ( !mWheelEventSignal.Empty() )
+ if(!mWheelEventSignal.Empty())
{
- Dali::Integration::Scene handle( this );
- mWheelEventSignal.Emit( event );
+ Dali::Integration::Scene handle(this);
+ mWheelEventSignal.Emit(event);
}
}
-void Scene::AddFrameRenderedCallback( std::unique_ptr< CallbackBase > callback, int32_t frameId )
+void Scene::AddFrameRenderedCallback(std::unique_ptr<CallbackBase> callback, int32_t frameId)
{
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
- AddFrameRenderedCallbackMessage( tls->GetEventThreadServices(), *mSceneObject, callback.release(), frameId );
+ AddFrameRenderedCallbackMessage(tls->GetEventThreadServices(), *mSceneObject, callback.release(), frameId);
}
-void Scene::AddFramePresentedCallback( std::unique_ptr< CallbackBase > callback, int32_t frameId )
+void Scene::AddFramePresentedCallback(std::unique_ptr<CallbackBase> callback, int32_t frameId)
{
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
- AddFramePresentedCallbackMessage( tls->GetEventThreadServices(), *mSceneObject, callback.release(), frameId );
+ AddFramePresentedCallbackMessage(tls->GetEventThreadServices(), *mSceneObject, callback.release(), frameId);
}
-void Scene::GetFrameRenderedCallback( Dali::Integration::Scene::FrameCallbackContainer& callbacks )
+void Scene::GetFrameRenderedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks)
{
- mSceneObject->GetFrameRenderedCallback( callbacks );
+ mSceneObject->GetFrameRenderedCallback(callbacks);
}
-void Scene::GetFramePresentedCallback( Dali::Integration::Scene::FrameCallbackContainer& callbacks )
+void Scene::GetFramePresentedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks)
{
- mSceneObject->GetFramePresentedCallback( callbacks );
+ mSceneObject->GetFramePresentedCallback(callbacks);
}
Integration::Scene::KeyEventSignalType& Scene::KeyEventSignal()
return mItemsDirtyRects;
}
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#define DALI_INTERNAL_STAGE_DEF_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
class Stage;
-using StagePtr = Stage *;
+using StagePtr = Stage*;
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#endif // DALI_INTERNAL_STAGE_DEF_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstring> // for strcmp
// INTERNAL INCLUDES
+#include <dali/integration-api/platform-abstraction.h>
+#include <dali/internal/event/actors/camera-actor-impl.h>
#include <dali/internal/event/actors/layer-impl.h>
#include <dali/internal/event/actors/layer-list.h>
-#include <dali/internal/event/actors/camera-actor-impl.h>
-#include <dali/internal/event/common/thread-local-storage.h>
+#include <dali/internal/event/common/object-registry-impl.h>
#include <dali/internal/event/common/property-notification-manager.h>
+#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/event/render-tasks/render-task-list-impl.h>
#include <dali/internal/event/update/frame-callback-interface-impl.h>
-#include <dali/internal/update/nodes/node.h>
#include <dali/internal/update/manager/scene-graph-frame-callback.h>
-#include <dali/internal/event/common/object-registry-impl.h>
-#include <dali/integration-api/platform-abstraction.h>
+#include <dali/internal/update/nodes/node.h>
#include <dali/public-api/common/constants.h>
#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/render-tasks/render-task-list.h>
#include <dali/public-api/rendering/frame-buffer.h>
-#include <dali/public-api/common/constants.h>
using Dali::Internal::SceneGraph::Node;
namespace
{
#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_DEPTH_TIMER" );
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_DEPTH_TIMER");
#endif
-}
+} // namespace
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
// Signals
static constexpr std::string_view SIGNAL_KEY_EVENT = "keyEvent";
static constexpr std::string_view SIGNAL_CONTEXT_REGAINED = "contextRegained";
static constexpr std::string_view SIGNAL_SCENE_CREATED = "sceneCreated";
-TypeRegistration mType( typeid(Dali::Stage), typeid(Dali::BaseHandle), nullptr );
+TypeRegistration mType(typeid(Dali::Stage), typeid(Dali::BaseHandle), nullptr);
SignalConnectorType signalConnector1(mType, std::string(SIGNAL_KEY_EVENT), &Stage::DoConnectSignal);
SignalConnectorType signalConnector2(mType, std::string(SIGNAL_EVENT_PROCESSING_FINISHED), &Stage::DoConnectSignal);
} // unnamed namespace
-StagePtr Stage::New( SceneGraph::UpdateManager& updateManager )
+StagePtr Stage::New(SceneGraph::UpdateManager& updateManager)
{
- return StagePtr( new Stage( updateManager ) );
+ return StagePtr(new Stage(updateManager));
}
-void Stage::Initialize( Scene& scene )
+void Stage::Initialize(Scene& scene)
{
mScene = &scene;
- mScene->SetBackgroundColor( Dali::DEFAULT_BACKGROUND_COLOR );
- mScene->EventProcessingFinishedSignal().Connect( this, &Stage::OnEventProcessingFinished );
- mScene->KeyEventSignal().Connect( this, &Stage::OnKeyEvent );
- mScene->TouchedSignal().Connect( this, &Stage::OnTouchEvent );
- mScene->WheelEventSignal().Connect( this, &Stage::OnWheelEvent );
+ mScene->SetBackgroundColor(Dali::DEFAULT_BACKGROUND_COLOR);
+ mScene->EventProcessingFinishedSignal().Connect(this, &Stage::OnEventProcessingFinished);
+ mScene->KeyEventSignal().Connect(this, &Stage::OnKeyEvent);
+ mScene->TouchedSignal().Connect(this, &Stage::OnTouchEvent);
+ mScene->WheelEventSignal().Connect(this, &Stage::OnWheelEvent);
}
StagePtr Stage::GetCurrent()
{
- StagePtr stage( nullptr );
+ StagePtr stage(nullptr);
// no checking in this version
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
- if( tls )
+ if(tls)
{
stage = tls->GetCurrentStage();
}
Layer& Stage::GetRootActor()
{
Dali::Layer rootLayer = GetRootLayer();
- return GetImplementation( rootLayer );
+ return GetImplementation(rootLayer);
}
-void Stage::Add( Actor& actor )
+void Stage::Add(Actor& actor)
{
- mScene->Add( actor );
+ mScene->Add(actor);
}
-void Stage::Remove( Actor& actor )
+void Stage::Remove(Actor& actor)
{
- mScene->Remove( actor );
+ mScene->Remove(actor);
}
Vector2 Stage::GetSize() const
return mScene->GetLayerCount();
}
-Dali::Layer Stage::GetLayer( uint32_t depth ) const
+Dali::Layer Stage::GetLayer(uint32_t depth) const
{
- return mScene->GetLayer( depth );
+ return mScene->GetLayer(depth);
}
Dali::Layer Stage::GetRootLayer() const
void Stage::SetBackgroundColor(Vector4 color)
{
- mScene->SetBackgroundColor( color );
+ mScene->SetBackgroundColor(color);
}
Vector4 Stage::GetBackgroundColor() const
return mScene->GetDpi();
}
-void Stage::KeepRendering( float durationSeconds )
+void Stage::KeepRendering(float durationSeconds)
{
// Send message to keep rendering
- KeepRenderingMessage( mUpdateManager, durationSeconds );
+ KeepRenderingMessage(mUpdateManager, durationSeconds);
}
-void Stage::SetRenderingBehavior( DevelStage::Rendering renderingBehavior )
+void Stage::SetRenderingBehavior(DevelStage::Rendering renderingBehavior)
{
- if( mRenderingBehavior != renderingBehavior )
+ if(mRenderingBehavior != renderingBehavior)
{
// Send message to change the rendering behavior
- SetRenderingBehaviorMessage( mUpdateManager, renderingBehavior );
+ SetRenderingBehaviorMessage(mUpdateManager, renderingBehavior);
mRenderingBehavior = renderingBehavior;
}
return mRenderingBehavior;
}
-bool Stage::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool Stage::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( true );
- Stage* stage = static_cast< Stage* >(object); // TypeRegistry guarantees that this is the correct type.
+ bool connected(true);
+ Stage* stage = static_cast<Stage*>(object); // TypeRegistry guarantees that this is the correct type.
std::string_view name(signalName);
if(name == SIGNAL_KEY_EVENT)
{
- stage->KeyEventSignal().Connect( tracker, functor );
+ stage->KeyEventSignal().Connect(tracker, functor);
}
else if(name == SIGNAL_KEY_EVENT_GENERATED)
{
- stage->KeyEventGeneratedSignal().Connect( tracker, functor );
+ stage->KeyEventGeneratedSignal().Connect(tracker, functor);
}
else if(name == SIGNAL_EVENT_PROCESSING_FINISHED)
{
- stage->EventProcessingFinishedSignal().Connect( tracker, functor );
+ stage->EventProcessingFinishedSignal().Connect(tracker, functor);
}
else if(name == SIGNAL_TOUCHED)
{
- stage->TouchedSignal().Connect( tracker, functor );
+ stage->TouchedSignal().Connect(tracker, functor);
}
else if(name == SIGNAL_WHEEL_EVENT)
{
- stage->WheelEventSignal().Connect( tracker, functor );
+ stage->WheelEventSignal().Connect(tracker, functor);
}
else if(name == SIGNAL_CONTEXT_LOST)
{
- stage->ContextLostSignal().Connect( tracker, functor );
+ stage->ContextLostSignal().Connect(tracker, functor);
}
else if(name == SIGNAL_CONTEXT_REGAINED)
{
- stage->ContextRegainedSignal().Connect( tracker, functor );
+ stage->ContextRegainedSignal().Connect(tracker, functor);
}
else if(name == SIGNAL_SCENE_CREATED)
{
- stage->SceneCreatedSignal().Connect( tracker, functor );
+ stage->SceneCreatedSignal().Connect(tracker, functor);
}
else
{
EmitEventProcessingFinishedSignal();
}
-void Stage::OnKeyEvent( const Dali::KeyEvent& event )
+void Stage::OnKeyEvent(const Dali::KeyEvent& event)
{
- bool consumed = EmitKeyEventGeneratedSignal( event );
- if( !consumed )
+ bool consumed = EmitKeyEventGeneratedSignal(event);
+ if(!consumed)
{
- EmitKeyEventSignal( event );
+ EmitKeyEventSignal(event);
}
}
-void Stage::OnTouchEvent( const Dali::TouchEvent& touch )
+void Stage::OnTouchEvent(const Dali::TouchEvent& touch)
{
- EmitTouchedSignal( touch );
+ EmitTouchedSignal(touch);
}
-void Stage::OnWheelEvent( const Dali::WheelEvent& event )
+void Stage::OnWheelEvent(const Dali::WheelEvent& event)
{
- EmitWheelEventSignal( event );
+ EmitWheelEventSignal(event);
}
void Stage::EmitKeyEventSignal(const KeyEvent& event)
{
// Emit the key event signal when no actor in the stage has gained the key input focus
- mKeyEventSignal.Emit( event );
+ mKeyEventSignal.Emit(event);
}
bool Stage::EmitKeyEventGeneratedSignal(const KeyEvent& event)
{
// Emit the KeyEventGenerated signal when KeyEvent is generated
- return mKeyEventGeneratedSignal.Emit( event );
+ return mKeyEventGeneratedSignal.Emit(event);
}
void Stage::EmitEventProcessingFinishedSignal()
mEventProcessingFinishedSignal.Emit();
}
-void Stage::EmitTouchedSignal( const Dali::TouchEvent& touch )
+void Stage::EmitTouchedSignal(const Dali::TouchEvent& touch)
{
- mTouchedSignal.Emit( touch );
+ mTouchedSignal.Emit(touch);
}
-void Stage::EmitWheelEventSignal( const WheelEvent& event )
+void Stage::EmitWheelEventSignal(const WheelEvent& event)
{
// Emit the wheel event signal when no actor in the stage has gained the wheel input focus
- mWheelEventSignal.Emit( event );
+ mWheelEventSignal.Emit(event);
}
void Stage::EmitSceneCreatedSignal()
return mKeyEventGeneratedSignal;
}
-void Stage::AddFrameCallback( FrameCallbackInterface& frameCallback, Actor& rootActor )
+void Stage::AddFrameCallback(FrameCallbackInterface& frameCallback, Actor& rootActor)
{
- DALI_ASSERT_ALWAYS( ( ! FrameCallbackInterface::Impl::Get( frameCallback ).IsConnectedToSceneGraph() )
- && "FrameCallbackInterface implementation already added" );
+ DALI_ASSERT_ALWAYS((!FrameCallbackInterface::Impl::Get(frameCallback).IsConnectedToSceneGraph()) && "FrameCallbackInterface implementation already added");
// Create scene-graph object and transfer to UpdateManager
- OwnerPointer< SceneGraph::FrameCallback > transferOwnership( SceneGraph::FrameCallback::New( frameCallback ) );
- AddFrameCallbackMessage( mUpdateManager, transferOwnership, rootActor.GetNode() );
+ OwnerPointer<SceneGraph::FrameCallback> transferOwnership(SceneGraph::FrameCallback::New(frameCallback));
+ AddFrameCallbackMessage(mUpdateManager, transferOwnership, rootActor.GetNode());
}
-void Stage::RemoveFrameCallback( FrameCallbackInterface& frameCallback )
+void Stage::RemoveFrameCallback(FrameCallbackInterface& frameCallback)
{
- FrameCallbackInterface::Impl::Get( frameCallback ).Invalidate();
- RemoveFrameCallbackMessage( mUpdateManager, frameCallback );
+ FrameCallbackInterface::Impl::Get(frameCallback).Invalidate();
+ RemoveFrameCallbackMessage(mUpdateManager, frameCallback);
}
Dali::Stage::EventProcessingFinishedSignalType& Stage::EventProcessingFinishedSignal()
mContextRegainedSignal.Emit();
}
-Stage::Stage( SceneGraph::UpdateManager& updateManager )
-: mUpdateManager( updateManager ),
+Stage::Stage(SceneGraph::UpdateManager& updateManager)
+: mUpdateManager(updateManager),
mKeyEventSignal(),
mKeyEventGeneratedSignal(),
mEventProcessingFinishedSignal(),
mContextLostSignal(),
mContextRegainedSignal(),
mSceneCreatedSignal(),
- mRenderingBehavior( DevelStage::Rendering::IF_REQUIRED )
+ mRenderingBehavior(DevelStage::Rendering::IF_REQUIRED)
{
}
#define DALI_INTERNAL_STAGE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/devel-api/common/stage.h>
-#include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/math/vector3.h>
-#include <dali/public-api/math/vector4.h>
#include <dali/devel-api/common/stage-devel.h>
+#include <dali/devel-api/common/stage.h>
#include <dali/integration-api/context-notifier.h>
#include <dali/internal/common/owner-pointer.h>
#include <dali/internal/event/actors/layer-impl.h>
#include <dali/internal/event/common/object-registry-impl.h>
#include <dali/internal/event/common/stage-def.h>
#include <dali/internal/event/render-tasks/render-task-defaults.h>
-#include <dali/internal/update/manager/update-manager.h>
#include <dali/internal/event/render-tasks/render-task-impl.h>
+#include <dali/internal/update/manager/update-manager.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/math/vector3.h>
+#include <dali/public-api/math/vector4.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/ref-object.h>
namespace Dali
{
-
struct Vector2;
namespace Integration
namespace Internal
{
-
namespace SceneGraph
{
class UpdateManager;
class Stage : public BaseObject, public RenderTaskDefaults, public Integration::ContextNotifierInterface, public ConnectionTracker
{
public:
-
/**
* Create the stage
* @param[in] updateManager
*/
- static StagePtr New( SceneGraph::UpdateManager& updateManager );
+ static StagePtr New(SceneGraph::UpdateManager& updateManager);
/**
* Initialize the stage.
* @param[in] scene The default scene (for main window).
*/
- void Initialize( Scene& scene );
+ void Initialize(Scene& scene);
/**
* @copydoc Dali::Stage::GetCurrent()
/**
* @copydoc Dali::Stage::Add()
*/
- void Add( Actor& actor );
+ void Add(Actor& actor);
/**
* @copydoc Dali::Stage::Remove()
*/
- void Remove( Actor& actor );
+ void Remove(Actor& actor);
/**
* Returns the size of the Stage in pixels as a Vector.
/**
* @copydoc Dali::Stage::GetLayer()
*/
- Dali::Layer GetLayer( uint32_t depth ) const;
+ Dali::Layer GetLayer(uint32_t depth) const;
/**
* @copydoc Dali::Stage::GetRootLayer()
/**
* @copydoc Dali::Stage::KeepRendering()
*/
- void KeepRendering( float durationSeconds );
+ void KeepRendering(float durationSeconds);
/**
* @copydoc Dali::DevelStage::SetRenderingBehavior()
*/
- void SetRenderingBehavior( DevelStage::Rendering renderingBehavior );
+ void SetRenderingBehavior(DevelStage::Rendering renderingBehavior);
/**
* @copydoc Dali::DevelStage::GetRenderingBehavior()
/**
* Callback for Internal::Scene KeyEventSignal signal
*/
- void OnKeyEvent( const Dali::KeyEvent& event );
+ void OnKeyEvent(const Dali::KeyEvent& event);
/**
* Callback for Internal::Scene TouchedSignal signal
*/
- void OnTouchEvent( const Dali::TouchEvent& touch );
+ void OnTouchEvent(const Dali::TouchEvent& touch);
/**
* Callback for Internal::Scene WheelEventSignal signal
*/
- void OnWheelEvent( const Dali::WheelEvent& event );
+ void OnWheelEvent(const Dali::WheelEvent& event);
/**
* Used by the EventProcessor to emit key event signals.
* Emits the touched signal.
* @param[in] touch The touch event details.
*/
- void EmitTouchedSignal( const Dali::TouchEvent& touch );
+ void EmitTouchedSignal(const Dali::TouchEvent& touch);
/**
* Used by the EventProcessor to emit wheel event signals.
* @param[in] event The wheel event.
*/
- void EmitWheelEventSignal( const WheelEvent& event );
+ void EmitWheelEventSignal(const WheelEvent& event);
/**
* Emits the scene created.
/**
* @copydoc Dali::DevelStage::AddFrameCallback()
*/
- void AddFrameCallback( FrameCallbackInterface& frameCallback, Actor& rootActor );
+ void AddFrameCallback(FrameCallbackInterface& frameCallback, Actor& rootActor);
/**
* @copydoc Dali::DevelStage::RemoveFrameCallback()
*/
- void RemoveFrameCallback( FrameCallbackInterface& frameCallback );
+ void RemoveFrameCallback(FrameCallbackInterface& frameCallback);
/**
* Connects a callback function with the object's signals.
* @return True if the signal was connected.
* @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
*/
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
private: // Implementation of ContextNotificationInterface:
-
/**
* @copydoc Dali::Integration::NotifyContextLost();
*/
void NotifyContextRegained() override;
private:
-
/**
* Protected constructor; see also Stage::New()
*/
- Stage( SceneGraph::UpdateManager& updateManager );
+ Stage(SceneGraph::UpdateManager& updateManager);
/**
* A reference counted object may only be deleted by calling Unreference()
~Stage() override;
private:
-
SceneGraph::UpdateManager& mUpdateManager;
IntrusivePtr<Scene> mScene;
// The key event signal
- Dali::Stage::KeyEventSignalType mKeyEventSignal;
- Dali::DevelStage::KeyEventGeneratedSignalType mKeyEventGeneratedSignal;
+ Dali::Stage::KeyEventSignalType mKeyEventSignal;
+ Dali::DevelStage::KeyEventGeneratedSignalType mKeyEventGeneratedSignal;
// The event processing finished signal
- Dali::Stage::EventProcessingFinishedSignalType mEventProcessingFinishedSignal;
+ Dali::Stage::EventProcessingFinishedSignalType mEventProcessingFinishedSignal;
// The touched signal
- Dali::Stage::TouchEventSignalType mTouchedSignal;
+ Dali::Stage::TouchEventSignalType mTouchedSignal;
// The wheel event signal
- Dali::Stage::WheelEventSignalType mWheelEventSignal;
+ Dali::Stage::WheelEventSignalType mWheelEventSignal;
Dali::Stage::ContextStatusSignal mContextLostSignal;
Dali::Stage::ContextStatusSignal mContextRegainedSignal;
inline Internal::Stage& GetImplementation(Dali::Stage& stage)
{
- DALI_ASSERT_ALWAYS( stage && "Stage handle is empty" );
+ DALI_ASSERT_ALWAYS(stage && "Stage handle is empty");
BaseObject& handle = stage.GetBaseObject();
inline const Internal::Stage& GetImplementation(const Dali::Stage& stage)
{
- DALI_ASSERT_ALWAYS( stage && "Stage handle is empty" );
+ DALI_ASSERT_ALWAYS(stage && "Stage handle is empty");
const BaseObject& handle = stage.GetBaseObject();
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/integration-api/debug.h>
-#include <dali/internal/event/common/type-registry-impl.h>
#include <dali/internal/event/common/object-impl.h>
+#include <dali/internal/event/common/type-registry-impl.h>
using std::find_if;
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
/*
* Functor to find by given type for vector of pairs
*/
-template <typename S, typename T>
+template<typename S, typename T>
struct PairFinder
{
PairFinder(const S& find)
}
private:
-
const S& mFind;
};
/**
* Functor to find a matching property name
*/
-template <typename T>
+template<typename T>
struct PropertyNameFinder
{
PropertyNameFinder(ConstString find)
{
}
- bool operator()(const T &p) const
+ bool operator()(const T& p) const
{
return p.second.name == mFind;
}
/**
* Functor to find a matching property component index
*/
-template <typename T>
+template<typename T>
struct PropertyComponentFinder
{
- PropertyComponentFinder( Property::Index basePropertyIndex, const int find )
- : mBasePropertyIndex( basePropertyIndex ),
- mFind( find )
+ PropertyComponentFinder(Property::Index basePropertyIndex, const int find)
+ : mBasePropertyIndex(basePropertyIndex),
+ mFind(find)
{
}
- bool operator()(const T &p) const
+ bool operator()(const T& p) const
{
- return ( p.second.basePropertyIndex == mBasePropertyIndex && p.second.componentIndex == mFind );
+ return (p.second.basePropertyIndex == mBasePropertyIndex && p.second.componentIndex == mFind);
}
private:
-
Property::Index mBasePropertyIndex;
- const int mFind;
+ const int mFind;
};
/**
* Helper function to find the right default property with given index and return the desired detail of it
*/
-template< typename Parameter, typename Member >
-inline bool GetDefaultPropertyField( const Dali::PropertyDetails* propertyTable, Property::Index count, Property::Index index, Member member, Parameter& parameter )
+template<typename Parameter, typename Member>
+inline bool GetDefaultPropertyField(const Dali::PropertyDetails* propertyTable, Property::Index count, Property::Index index, Member member, Parameter& parameter)
{
bool found = false;
// is index inside this table (bigger than first index but smaller than first + count)
- if( ( index >= propertyTable->enumIndex ) && ( index < ( propertyTable->enumIndex + count ) ) )
+ if((index >= propertyTable->enumIndex) && (index < (propertyTable->enumIndex + count)))
{
// return the match. we're assuming here that there is no gaps between the indices in a table
- parameter = propertyTable[ index - propertyTable->enumIndex ].*member;
- found = true;
+ parameter = propertyTable[index - propertyTable->enumIndex].*member;
+ found = true;
}
// should never really get here
return found;
// static pointer value to mark that a base class address has not been resolved
// 0x01 is not a valid pointer but used here to differentiate from nullptr
// unfortunately it cannot be constexpr as C++ does not allow them to be initialised with reinterpret_cast
-Internal::TypeInfo* const UNRESOLVED = reinterpret_cast<Internal::TypeInfo*>( 0x1 );
+Internal::TypeInfo* const UNRESOLVED = reinterpret_cast<Internal::TypeInfo*>(0x1);
/**
* Helper function to resolve and return the pointer to the base type info
* @param[in] baseTypeName string name of the base type
* @return true is base type exists
*/
-inline bool GetBaseType( Internal::TypeInfo*& baseType, TypeRegistry& typeRegistry, const std::string& baseTypeName )
+inline bool GetBaseType(Internal::TypeInfo*& baseType, TypeRegistry& typeRegistry, const std::string& baseTypeName)
{
// if greater than unresolved means we have a base type, null means no base
- bool baseExists = ( baseType > UNRESOLVED );
+ bool baseExists = (baseType > UNRESOLVED);
// base only needs to be resolved once
- if( UNRESOLVED == baseType )
+ if(UNRESOLVED == baseType)
{
- TypeRegistry::TypeInfoPointer base = typeRegistry.GetTypeInfo( baseTypeName );
- if( base )
+ TypeRegistry::TypeInfoPointer base = typeRegistry.GetTypeInfo(baseTypeName);
+ if(base)
{
- baseType = base.Get(); // dont pass ownership, just return raw pointer
+ baseType = base.Get(); // dont pass ownership, just return raw pointer
baseExists = true;
}
else
} // unnamed namespace
-TypeInfo::TypeInfo( const std::string &name, const std::string &baseTypeName, Dali::TypeInfo::CreateFunction creator,
- const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount )
-: mTypeRegistry( *TypeRegistry::Get() ), mBaseType( UNRESOLVED ),
- mTypeName( name ), mBaseTypeName( baseTypeName ), mCreate( creator ), mDefaultProperties( defaultProperties ),
- mDefaultPropertyCount( defaultPropertyCount ), mCSharpType( false )
+TypeInfo::TypeInfo(const std::string& name, const std::string& baseTypeName, Dali::TypeInfo::CreateFunction creator, const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount)
+: mTypeRegistry(*TypeRegistry::Get()),
+ mBaseType(UNRESOLVED),
+ mTypeName(name),
+ mBaseTypeName(baseTypeName),
+ mCreate(creator),
+ mDefaultProperties(defaultProperties),
+ mDefaultPropertyCount(defaultPropertyCount),
+ mCSharpType(false)
{
DALI_ASSERT_ALWAYS(!name.empty() && "Type info construction must have a name");
DALI_ASSERT_ALWAYS(!baseTypeName.empty() && "Type info construction must have a base type name");
}
-TypeInfo::TypeInfo(const std::string &name, const std::string &baseTypeName, Dali::CSharpTypeInfo::CreateFunction creator)
-: mTypeRegistry( *TypeRegistry::Get() ), mBaseType( UNRESOLVED ),
- mTypeName( name ), mBaseTypeName( baseTypeName ), mCSharpCreate( creator ), mCSharpType( true )
+TypeInfo::TypeInfo(const std::string& name, const std::string& baseTypeName, Dali::CSharpTypeInfo::CreateFunction creator)
+: mTypeRegistry(*TypeRegistry::Get()),
+ mBaseType(UNRESOLVED),
+ mTypeName(name),
+ mBaseTypeName(baseTypeName),
+ mCSharpCreate(creator),
+ mCSharpType(true)
{
DALI_ASSERT_ALWAYS(!name.empty() && "Type info construction must have a name");
DALI_ASSERT_ALWAYS(!baseTypeName.empty() && "Type info construction must have a base type name");
if(mCreate)
{
- if ( mCSharpType )
+ if(mCSharpType)
{
// CSharp currently only registers one create function for all custom controls
// it uses the type name to decide which one to create
- ret = *mCSharpCreate( mTypeName.c_str() );
+ ret = *mCSharpCreate(mTypeName.c_str());
}
else
{
ret = mCreate();
}
- if ( ret )
+ if(ret)
{
BaseObject& handle = ret.GetBaseObject();
- Object *object = dynamic_cast<Internal::Object*>(&handle);
+ Object* object = dynamic_cast<Internal::Object*>(&handle);
- if ( object )
+ if(object)
{
- object->SetTypeInfo( this );
+ object->SetTypeInfo(this);
}
}
}
return ret;
}
-bool TypeInfo::DoActionTo(BaseObject *object, const std::string &actionName, const Property::Map &properties)
+bool TypeInfo::DoActionTo(BaseObject* object, const std::string& actionName, const Property::Map& properties)
{
bool done = false;
ActionContainer::iterator iter = find_if(mActions.begin(), mActions.end(), PairFinder<std::string, ActionPair>(actionName));
- if( iter != mActions.end() )
+ if(iter != mActions.end())
{
done = (iter->second)(object, actionName, properties);
}
- if( !done )
+ if(!done)
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- done = mBaseType->DoActionTo( object, actionName, properties );
+ done = mBaseType->DoActionTo(object, actionName, properties);
}
}
return done;
}
-bool TypeInfo::ConnectSignal( BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor )
+bool TypeInfo::ConnectSignal(BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( false );
+ bool connected(false);
- ConnectorContainer::iterator iter = find_if( mSignalConnectors.begin(), mSignalConnectors.end(),
- PairFinder<std::string, ConnectionPair>(signalName) );
+ ConnectorContainer::iterator iter = find_if(mSignalConnectors.begin(), mSignalConnectors.end(), PairFinder<std::string, ConnectionPair>(signalName));
- if( iter != mSignalConnectors.end() )
+ if(iter != mSignalConnectors.end())
{
- connected = (iter->second)( object, connectionTracker, signalName, functor );
+ connected = (iter->second)(object, connectionTracker, signalName, functor);
}
- if( !connected )
+ if(!connected)
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- connected = mBaseType->ConnectSignal( object, connectionTracker, signalName, functor );
+ connected = mBaseType->ConnectSignal(object, connectionTracker, signalName, functor);
}
}
uint32_t TypeInfo::GetActionCount() const
{
- uint32_t count = static_cast<uint32_t>( mActions.size() );
+ uint32_t count = static_cast<uint32_t>(mActions.size());
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
count += mBaseType->GetActionCount();
return count;
}
-std::string TypeInfo::GetActionName( uint32_t index ) const
+std::string TypeInfo::GetActionName(uint32_t index) const
{
- std::string name;
- const uint32_t count = static_cast<uint32_t>( mActions.size() );
+ std::string name;
+ const uint32_t count = static_cast<uint32_t>(mActions.size());
- if( index < count )
+ if(index < count)
{
name = mActions[index].first;
}
else
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetActionName( index - count );
+ return mBaseType->GetActionName(index - count);
}
}
uint32_t TypeInfo::GetSignalCount() const
{
- uint32_t count = static_cast<uint32_t>( mSignalConnectors.size() );
+ uint32_t count = static_cast<uint32_t>(mSignalConnectors.size());
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
count += mBaseType->GetSignalCount();
return count;
}
-std::string TypeInfo::GetSignalName( uint32_t index ) const
+std::string TypeInfo::GetSignalName(uint32_t index) const
{
- std::string name;
- const uint32_t count = static_cast<uint32_t>( mSignalConnectors.size() );
+ std::string name;
+ const uint32_t count = static_cast<uint32_t>(mSignalConnectors.size());
- if( index < count )
+ if(index < count)
{
name = mSignalConnectors[index].first;
}
else
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetSignalName( index - count );
+ return mBaseType->GetSignalName(index - count);
}
}
return name;
}
-void TypeInfo::GetPropertyIndices( Property::IndexContainer& indices ) const
+void TypeInfo::GetPropertyIndices(Property::IndexContainer& indices) const
{
// Default Properties
- if( mDefaultProperties )
+ if(mDefaultProperties)
{
- indices.Reserve( indices.Size() + mDefaultPropertyCount );
- for( Property::Index index = 0; index < mDefaultPropertyCount; ++index )
+ indices.Reserve(indices.Size() + mDefaultPropertyCount);
+ for(Property::Index index = 0; index < mDefaultPropertyCount; ++index)
{
- indices.PushBack( mDefaultProperties[ index ].enumIndex );
+ indices.PushBack(mDefaultProperties[index].enumIndex);
}
}
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- mBaseType->GetPropertyIndices( indices );
+ mBaseType->GetPropertyIndices(indices);
}
- AppendProperties( indices, mRegisteredProperties );
+ AppendProperties(indices, mRegisteredProperties);
}
-void TypeInfo::GetChildPropertyIndices( Property::IndexContainer& indices ) const
+void TypeInfo::GetChildPropertyIndices(Property::IndexContainer& indices) const
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- mBaseType->GetChildPropertyIndices( indices );
+ mBaseType->GetChildPropertyIndices(indices);
}
- AppendProperties( indices, mRegisteredChildProperties );
+ AppendProperties(indices, mRegisteredChildProperties);
}
/**
* Append the indices in RegisteredProperties to the given index container.
*/
-void TypeInfo::AppendProperties( Dali::Property::IndexContainer& indices,
- const TypeInfo::RegisteredPropertyContainer& registeredProperties ) const
+void TypeInfo::AppendProperties(Dali::Property::IndexContainer& indices,
+ const TypeInfo::RegisteredPropertyContainer& registeredProperties) const
{
- if ( ! registeredProperties.empty() )
+ if(!registeredProperties.empty())
{
- indices.Reserve( indices.Size() + registeredProperties.size() );
+ indices.Reserve(indices.Size() + registeredProperties.size());
- for( auto&& elem : registeredProperties )
+ for(auto&& elem : registeredProperties)
{
- indices.PushBack( elem.first );
+ indices.PushBack(elem.first);
}
}
}
std::string_view TypeInfo::GetRegisteredPropertyName(Property::Index index) const
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
- if ( iter != mRegisteredProperties.end() )
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+ if(iter != mRegisteredProperties.end())
{
return iter->second.name.GetStringView();
}
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetRegisteredPropertyName( index );
+ return mBaseType->GetRegisteredPropertyName(index);
}
static std::string empty;
return empty;
{
std::string_view propertyName;
// default or custom
- if ( mDefaultProperties && ( index < DEFAULT_PROPERTY_MAX_COUNT ) )
+ if(mDefaultProperties && (index < DEFAULT_PROPERTY_MAX_COUNT))
{
std::string_view name;
- if( GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::name, name ) )
+ if(GetDefaultPropertyField(mDefaultProperties, mDefaultPropertyCount, index, &Dali::PropertyDetails::name, name))
{
propertyName = name;
}
}
else
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
- if ( iter != mRegisteredProperties.end() )
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+ if(iter != mRegisteredProperties.end())
{
return iter->second.name.GetStringView();
}
}
// if not our property, go to parent
- if( propertyName.empty() )
+ if(propertyName.empty())
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetPropertyName( index );
+ return mBaseType->GetPropertyName(index);
}
}
void TypeInfo::AddActionFunction(std::string actionName, Dali::TypeInfo::ActionFunction function)
{
- if( nullptr == function)
+ if(nullptr == function)
{
DALI_LOG_WARNING("Action function is empty\n");
}
else
{
- ActionContainer::iterator iter = std::find_if(mActions.begin(), mActions.end(),
- PairFinder<std::string, ActionPair>(actionName));
+ ActionContainer::iterator iter = std::find_if(mActions.begin(), mActions.end(), PairFinder<std::string, ActionPair>(actionName));
- if( iter == mActions.end() )
+ if(iter == mActions.end())
{
mActions.push_back(ActionPair(std::move(actionName), function));
}
void TypeInfo::AddConnectorFunction(std::string signalName, Dali::TypeInfo::SignalConnectorFunction function)
{
- if( nullptr == function)
+ if(nullptr == function)
{
DALI_LOG_WARNING("Connector function is empty\n");
}
else
{
- ConnectorContainer::iterator iter = find_if( mSignalConnectors.begin(), mSignalConnectors.end(),
- PairFinder<std::string, ConnectionPair>(signalName) );
+ ConnectorContainer::iterator iter = find_if(mSignalConnectors.begin(), mSignalConnectors.end(), PairFinder<std::string, ConnectionPair>(signalName));
- if( iter == mSignalConnectors.end() )
+ if(iter == mSignalConnectors.end())
{
mSignalConnectors.push_back(ConnectionPair(std::move(signalName), function));
}
{
// The setter can be empty as a property can be read-only.
- if ( nullptr == getFunc )
+ if(nullptr == getFunc)
{
- DALI_ASSERT_ALWAYS( ! "GetProperty Function is empty" );
+ DALI_ASSERT_ALWAYS(!"GetProperty Function is empty");
}
else
{
- RegisteredPropertyContainer::iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair>(index) );
+ RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
- if ( iter == mRegisteredProperties.end() )
+ if(iter == mRegisteredProperties.end())
{
mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
}
else
{
- DALI_ASSERT_ALWAYS( ! "Property index already added to Type" );
+ DALI_ASSERT_ALWAYS(!"Property index already added to Type");
}
}
}
void TypeInfo::AddProperty(std::string name, Property::Index index, Property::Type type, Dali::CSharpTypeInfo::SetPropertyFunction setFunc, Dali::CSharpTypeInfo::GetPropertyFunction getFunc)
{
-
// The setter can be empty as a property can be read-only.
- if ( nullptr == getFunc )
+ if(nullptr == getFunc)
{
- DALI_ASSERT_ALWAYS( ! "GetProperty Function is empty" );
+ DALI_ASSERT_ALWAYS(!"GetProperty Function is empty");
}
else
{
- RegisteredPropertyContainer::iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair>(index) );
+ RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
- if ( iter == mRegisteredProperties.end() )
+ if(iter == mRegisteredProperties.end())
{
mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
}
else
{
- DALI_ASSERT_ALWAYS( ! "Property index already added to Type" );
+ DALI_ASSERT_ALWAYS(!"Property index already added to Type");
}
}
-
}
void TypeInfo::AddAnimatableProperty(std::string name, Property::Index index, Property::Type type)
{
- RegisteredPropertyContainer::iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair>(index) );
+ RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
- if ( iter == mRegisteredProperties.end() )
+ if(iter == mRegisteredProperties.end())
{
mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
}
else
{
- DALI_ASSERT_ALWAYS( ! "Property index already added to Type" );
+ DALI_ASSERT_ALWAYS(!"Property index already added to Type");
}
}
void TypeInfo::AddAnimatableProperty(std::string name, Property::Index index, Property::Value defaultValue)
{
- RegisteredPropertyContainer::iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair>(index) );
+ RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
- if ( iter == mRegisteredProperties.end() )
+ if(iter == mRegisteredProperties.end())
{
mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(defaultValue.GetType(), ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
mPropertyDefaultValues.push_back(PropertyDefaultValuePair(index, std::move(defaultValue)));
}
else
{
- DALI_ASSERT_ALWAYS( ! "Property index already added to Type" );
+ DALI_ASSERT_ALWAYS(!"Property index already added to Type");
}
}
void TypeInfo::AddAnimatablePropertyComponent(std::string name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex)
{
- Property::Type type = GetPropertyType( baseIndex );
- DALI_ASSERT_ALWAYS( ( type == Property::VECTOR2 || type == Property::VECTOR3 || type == Property::VECTOR4 ) && "Base property does not support component" );
+ Property::Type type = GetPropertyType(baseIndex);
+ DALI_ASSERT_ALWAYS((type == Property::VECTOR2 || type == Property::VECTOR3 || type == Property::VECTOR4) && "Base property does not support component");
bool success = false;
- RegisteredPropertyContainer::iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair>(index) );
+ RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
- if ( iter == mRegisteredProperties.end() )
+ if(iter == mRegisteredProperties.end())
{
- iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PropertyComponentFinder< RegisteredPropertyPair >( baseIndex, componentIndex ) );
+ iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PropertyComponentFinder<RegisteredPropertyPair>(baseIndex, componentIndex));
- if ( iter == mRegisteredProperties.end() )
+ if(iter == mRegisteredProperties.end())
{
mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, ConstString(name), baseIndex, componentIndex)));
success = true;
}
}
- DALI_ASSERT_ALWAYS( success && "Property component already registered" );
+ DALI_ASSERT_ALWAYS(success && "Property component already registered");
}
void TypeInfo::AddChildProperty(std::string name, Property::Index index, Property::Type type)
{
- RegisteredPropertyContainer::iterator iter = find_if( mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair>(index) );
+ RegisteredPropertyContainer::iterator iter = find_if(mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
- if ( iter == mRegisteredChildProperties.end() )
+ if(iter == mRegisteredChildProperties.end())
{
mRegisteredChildProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX)));
}
else
{
- DALI_ASSERT_ALWAYS( ! "Property index already added to Type" );
+ DALI_ASSERT_ALWAYS(!"Property index already added to Type");
}
}
uint32_t TypeInfo::GetPropertyCount() const
{
- uint32_t count = mDefaultPropertyCount + static_cast<uint32_t>( mRegisteredProperties.size() );
+ uint32_t count = mDefaultPropertyCount + static_cast<uint32_t>(mRegisteredProperties.size());
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
count += mBaseType->GetPropertyCount();
Property::Index TypeInfo::GetPropertyIndex(ConstString name) const
{
Property::Index index = Property::INVALID_INDEX;
- bool found = false;
+ bool found = false;
// check default properties
- if( mDefaultProperties )
+ if(mDefaultProperties)
{
auto stringView = name.GetStringView();
- for( Property::Index tableIndex = 0; tableIndex < mDefaultPropertyCount; ++tableIndex )
+ for(Property::Index tableIndex = 0; tableIndex < mDefaultPropertyCount; ++tableIndex)
{
if(mDefaultProperties[tableIndex].name == stringView)
{
- index = mDefaultProperties[ tableIndex ].enumIndex;
+ index = mDefaultProperties[tableIndex].enumIndex;
found = true;
break;
}
}
}
- if( !found )
+ if(!found)
{
// Slow but should not be done that often
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PropertyNameFinder< RegisteredPropertyPair >( name ) );
- if ( iter != mRegisteredProperties.end() )
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PropertyNameFinder<RegisteredPropertyPair>(name));
+ if(iter != mRegisteredProperties.end())
{
index = iter->first;
}
- else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- index = mBaseType->GetPropertyIndex( name );
+ index = mBaseType->GetPropertyIndex(name);
}
}
return index;
}
-Property::Index TypeInfo::GetBasePropertyIndex( Property::Index index ) const
+Property::Index TypeInfo::GetBasePropertyIndex(Property::Index index) const
{
Property::Index basePropertyIndex = Property::INVALID_INDEX;
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
- if ( iter != mRegisteredProperties.end() )
+ if(iter != mRegisteredProperties.end())
{
basePropertyIndex = iter->second.basePropertyIndex;
}
- else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- basePropertyIndex = mBaseType->GetBasePropertyIndex( index );
+ basePropertyIndex = mBaseType->GetBasePropertyIndex(index);
}
return basePropertyIndex;
}
-int32_t TypeInfo::GetComponentIndex( Property::Index index ) const
+int32_t TypeInfo::GetComponentIndex(Property::Index index) const
{
int componentIndex = Property::INVALID_COMPONENT_INDEX;
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
- if ( iter != mRegisteredProperties.end() )
+ if(iter != mRegisteredProperties.end())
{
componentIndex = iter->second.componentIndex;
}
- else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- componentIndex = mBaseType->GetComponentIndex( index );
+ componentIndex = mBaseType->GetComponentIndex(index);
}
return componentIndex;
Property::Index index = Property::INVALID_INDEX;
// Slow but should not be done that often
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(),
- PropertyNameFinder< RegisteredPropertyPair >( name ) );
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(), PropertyNameFinder<RegisteredPropertyPair>(name));
- if ( iter != mRegisteredChildProperties.end() )
+ if(iter != mRegisteredChildProperties.end())
{
index = iter->first;
}
- else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- index = mBaseType->GetChildPropertyIndex( name );
+ index = mBaseType->GetChildPropertyIndex(name);
}
return index;
std::string_view TypeInfo::GetChildPropertyName(Property::Index index) const
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
- if ( iter != mRegisteredChildProperties.end() )
+ if(iter != mRegisteredChildProperties.end())
{
return iter->second.name.GetStringView();
}
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetChildPropertyName( index );
+ return mBaseType->GetChildPropertyName(index);
}
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
return {};
}
-Property::Type TypeInfo::GetChildPropertyType( Property::Index index ) const
+Property::Type TypeInfo::GetChildPropertyType(Property::Index index) const
{
- Property::Type type( Property::NONE );
+ Property::Type type(Property::NONE);
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
- if ( iter != mRegisteredChildProperties.end() )
+ if(iter != mRegisteredChildProperties.end())
{
type = iter->second.type;
}
- else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- type = mBaseType->GetChildPropertyType( index );
+ type = mBaseType->GetChildPropertyType(index);
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
return type;
}
-bool TypeInfo::IsPropertyWritable( Property::Index index ) const
+bool TypeInfo::IsPropertyWritable(Property::Index index) const
{
bool writable = false;
- bool found = false;
+ bool found = false;
// default property?
- if ( ( index < DEFAULT_PROPERTY_MAX_COUNT ) && mDefaultProperties )
+ if((index < DEFAULT_PROPERTY_MAX_COUNT) && mDefaultProperties)
{
- found = GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::writable, writable );
+ found = GetDefaultPropertyField(mDefaultProperties, mDefaultPropertyCount, index, &Dali::PropertyDetails::writable, writable);
}
- else if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX))
{
writable = true; // animatable property is writable
- found = true;
+ found = true;
}
else
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
- if ( iter != mRegisteredProperties.end() )
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+ if(iter != mRegisteredProperties.end())
{
writable = iter->second.setFunc ? true : false;
- found = true;
+ found = true;
}
}
// if not found, continue to base
- if( !found )
+ if(!found)
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- writable = mBaseType->IsPropertyWritable( index );
+ writable = mBaseType->IsPropertyWritable(index);
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
}
return writable;
}
-bool TypeInfo::IsPropertyAnimatable( Property::Index index ) const
+bool TypeInfo::IsPropertyAnimatable(Property::Index index) const
{
bool animatable = false;
- bool found = false;
+ bool found = false;
// default property?
- if ( ( index < DEFAULT_PROPERTY_MAX_COUNT ) && mDefaultProperties )
+ if((index < DEFAULT_PROPERTY_MAX_COUNT) && mDefaultProperties)
{
- found = GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::animatable, animatable );
+ found = GetDefaultPropertyField(mDefaultProperties, mDefaultPropertyCount, index, &Dali::PropertyDetails::animatable, animatable);
}
- else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX))
{
// Type Registry event-thread only properties are not animatable.
animatable = false;
- found = true;
+ found = true;
}
- else if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX))
{
animatable = true;
- found = true;
+ found = true;
}
// if not found, continue to base
- if( !found )
+ if(!found)
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- animatable = mBaseType->IsPropertyAnimatable( index );
+ animatable = mBaseType->IsPropertyAnimatable(index);
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
}
return animatable;
}
-bool TypeInfo::IsPropertyAConstraintInput( Property::Index index ) const
+bool TypeInfo::IsPropertyAConstraintInput(Property::Index index) const
{
bool constraintInput = false;
- bool found = false;
+ bool found = false;
// default property?
- if ( ( index < DEFAULT_PROPERTY_MAX_COUNT ) && mDefaultProperties )
+ if((index < DEFAULT_PROPERTY_MAX_COUNT) && mDefaultProperties)
{
- found = GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::constraintInput, constraintInput );
+ found = GetDefaultPropertyField(mDefaultProperties, mDefaultPropertyCount, index, &Dali::PropertyDetails::constraintInput, constraintInput);
}
- else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX))
{
// Type Registry event-thread only properties cannot be used as constraint input
constraintInput = false;
- found = true;
+ found = true;
}
- else if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ else if((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX))
{
constraintInput = true;
- found = true;
+ found = true;
}
// if not found, continue to base
- if( !found )
+ if(!found)
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- constraintInput = mBaseType->IsPropertyAConstraintInput( index );
+ constraintInput = mBaseType->IsPropertyAConstraintInput(index);
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
}
return constraintInput;
}
-
-Property::Type TypeInfo::GetPropertyType( Property::Index index ) const
+Property::Type TypeInfo::GetPropertyType(Property::Index index) const
{
- Property::Type type( Property::NONE );
- bool found = false;
+ Property::Type type(Property::NONE);
+ bool found = false;
// default property?
- if ( ( index < DEFAULT_PROPERTY_MAX_COUNT ) && mDefaultProperties )
+ if((index < DEFAULT_PROPERTY_MAX_COUNT) && mDefaultProperties)
{
- found = GetDefaultPropertyField( mDefaultProperties, mDefaultPropertyCount,index, &Dali::PropertyDetails::type, type );
+ found = GetDefaultPropertyField(mDefaultProperties, mDefaultPropertyCount, index, &Dali::PropertyDetails::type, type);
}
else
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
- if ( iter != mRegisteredProperties.end() )
+ if(iter != mRegisteredProperties.end())
{
- if( iter->second.componentIndex == Property::INVALID_COMPONENT_INDEX )
+ if(iter->second.componentIndex == Property::INVALID_COMPONENT_INDEX)
{
- type = iter->second.type;
+ type = iter->second.type;
found = true;
}
else
{
// If component index is set, then we should return FLOAT
- type = Property::FLOAT;
+ type = Property::FLOAT;
found = true;
}
}
}
- if( !found )
+ if(!found)
{
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- type = mBaseType->GetPropertyType( index );
+ type = mBaseType->GetPropertyType(index);
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
}
return type;
}
-Property::Value TypeInfo::GetPropertyDefaultValue( Property::Index index ) const
+Property::Value TypeInfo::GetPropertyDefaultValue(Property::Index index) const
{
- PropertyDefaultValueContainer::const_iterator iter = find_if( mPropertyDefaultValues.begin(), mPropertyDefaultValues.end(),
- PairFinder< Property::Index, PropertyDefaultValuePair >( index ) );
- if( iter != mPropertyDefaultValues.end() )
+ PropertyDefaultValueContainer::const_iterator iter = find_if(mPropertyDefaultValues.begin(), mPropertyDefaultValues.end(), PairFinder<Property::Index, PropertyDefaultValuePair>(index));
+ if(iter != mPropertyDefaultValues.end())
{
return iter->second;
}
// we didn't have a value so ask base
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetPropertyDefaultValue( index );
+ return mBaseType->GetPropertyDefaultValue(index);
}
return Property::Value(); // return none
}
void TypeInfo::SetProperty(BaseObject* object, Property::Index index, Property::Value value) const
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
- if ( iter != mRegisteredProperties.end() )
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+ if(iter != mRegisteredProperties.end())
{
- if( iter->second.setFunc )
+ if(iter->second.setFunc)
{
- if( mCSharpType )
+ if(mCSharpType)
{
// CSharp wants a property name not an index
auto name = (iter->second).name;
}
}
}
- else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
mBaseType->SetProperty(object, index, std::move(value));
}
else
{
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
}
}
void TypeInfo::SetProperty(BaseObject* object, const std::string& name, Property::Value value) const
{
RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PropertyNameFinder<RegisteredPropertyPair>(ConstString(name)));
- if ( iter != mRegisteredProperties.end() )
+ if(iter != mRegisteredProperties.end())
{
- DALI_ASSERT_ALWAYS( iter->second.setFunc && "Trying to write to a read-only property" );
+ DALI_ASSERT_ALWAYS(iter->second.setFunc && "Trying to write to a read-only property");
- if( mCSharpType )
+ if(mCSharpType)
{
// CSharp wants a property name not an index
- iter->second.cSharpSetFunc( object,name.c_str(), const_cast< Property::Value* >(&value ));
+ iter->second.cSharpSetFunc(object, name.c_str(), const_cast<Property::Value*>(&value));
}
else
{
iter->second.setFunc(object, iter->first, std::move(value));
}
}
- else if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ else if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
mBaseType->SetProperty(object, name, std::move(value));
}
else
{
- DALI_LOG_ERROR( "Property %s not found", name.c_str() );
+ DALI_LOG_ERROR("Property %s not found", name.c_str());
}
}
-Property::Value TypeInfo::GetProperty( const BaseObject *object, Property::Index index ) const
+Property::Value TypeInfo::GetProperty(const BaseObject* object, Property::Index index) const
{
- RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
- PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
- if( iter != mRegisteredProperties.end() )
+ RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder<Property::Index, RegisteredPropertyPair>(index));
+ if(iter != mRegisteredProperties.end())
{
- if( mCSharpType ) // using csharp property get which returns a pointer to a Property::Value
+ if(mCSharpType) // using csharp property get which returns a pointer to a Property::Value
{
// CSharp wants a property name not an index
// CSharp callback can't return an object by value, it can only return a pointer
else
{
// Need to remove the constness here as CustomActor will not be able to call Downcast with a const pointer to the object
- return iter->second.getFunc( const_cast< BaseObject* >( object ), index );
+ return iter->second.getFunc(const_cast<BaseObject*>(object), index);
}
}
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetProperty( object, index );
+ return mBaseType->GetProperty(object, index);
}
- DALI_LOG_ERROR( "Property index %d not found\n", index );
+ DALI_LOG_ERROR("Property index %d not found\n", index);
return Property::Value();
}
-Property::Value TypeInfo::GetProperty( const BaseObject *object, const std::string& name ) const
+Property::Value TypeInfo::GetProperty(const BaseObject* object, const std::string& name) const
{
RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PropertyNameFinder<RegisteredPropertyPair>(ConstString(name)));
- if( iter != mRegisteredProperties.end() )
+ if(iter != mRegisteredProperties.end())
{
- if( mCSharpType ) // using csharp property get which returns a pointer to a Property::Value
+ if(mCSharpType) // using csharp property get which returns a pointer to a Property::Value
{
- // CSharp wants a property name not an index
- // CSharp callback can't return an object by value, it can only return a pointer
- // CSharp has ownership of the pointer contents, which is fine because we are returning by from this function by value
- return *( iter->second.cSharpGetFunc( const_cast< BaseObject* >( object ), name.c_str() ));
-
+ // CSharp wants a property name not an index
+ // CSharp callback can't return an object by value, it can only return a pointer
+ // CSharp has ownership of the pointer contents, which is fine because we are returning by from this function by value
+ return *(iter->second.cSharpGetFunc(const_cast<BaseObject*>(object), name.c_str()));
}
else
{
// Need to remove the constness here as CustomActor will not be able to call Downcast with a const pointer to the object
- return iter->second.getFunc( const_cast< BaseObject* >( object ), iter->first );
+ return iter->second.getFunc(const_cast<BaseObject*>(object), iter->first);
}
}
- if( GetBaseType( mBaseType, mTypeRegistry, mBaseTypeName ) )
+ if(GetBaseType(mBaseType, mTypeRegistry, mBaseTypeName))
{
// call base type recursively
- return mBaseType->GetProperty( object, name );
+ return mBaseType->GetProperty(object, name);
}
- DALI_LOG_ERROR( "Property %s not found", name.c_str() );
+ DALI_LOG_ERROR("Property %s not found", name.c_str());
return Property::Value();
}
#define DALI_INTERNAL_TYPE_INFO_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
class PropertyDetails;
class TypeInfo : public BaseObject
{
public:
-
/**
* Create TypeInfo
* @param [name] the registered name
* @param [baseName] the base type registered name
* @param [creator] the creator function for this type
*/
- TypeInfo( const std::string& name, const std::string& baseName, Dali::TypeInfo::CreateFunction creator,
- const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount );
+ TypeInfo(const std::string& name, const std::string& baseName, Dali::TypeInfo::CreateFunction creator, const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount);
/**
* Create TypeInfo for a csharp object
* @param [baseName] the base type registered name
* @param [creator] the creator function for this type
*/
- TypeInfo( const std::string& name, const std::string& baseName, Dali::CSharpTypeInfo::CreateFunction creator );
+ TypeInfo(const std::string& name, const std::string& baseName, Dali::CSharpTypeInfo::CreateFunction creator);
/**
* Destructor
/**
* @copydoc Dali::TypeInfo::GetActionName
*/
- std::string GetActionName( uint32_t index ) const;
+ std::string GetActionName(uint32_t index) const;
/**
* @copydoc Dali::TypeInfo::GetSignalCount
/**
* @copydoc Dali::TypeInfo::GetSignalName
*/
- std::string GetSignalName( uint32_t index ) const;
+ std::string GetSignalName(uint32_t index) const;
/**
* @copydoc Dali::TypeInfo::GetPropertyCount
* Adds the property indices to the container specified.
* @param[in/out] indices The container where the property indices are added.
*/
- void GetPropertyIndices( Property::IndexContainer& indices ) const;
+ void GetPropertyIndices(Property::IndexContainer& indices) const;
/**
* @copydoc Dali::TypeInfo::GetPropertyName() const
* @param [in] properties The arguments of the action
* @return bool If the action could be executed
*/
- bool DoActionTo(BaseObject *object, const std::string &actionName, const Property::Map &properties);
+ bool DoActionTo(BaseObject* object, const std::string& actionName, const Property::Map& properties);
/**
* Connects a callback function with the object's signals.
* @return True if the signal was connected.
* @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
*/
- bool ConnectSignal( BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor );
+ bool ConnectSignal(BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor);
/**
* Given a property name, retrieve the index.
* @param[in] index The index of the property.
* @return The index of the base property associated with the given property index.
*/
- Property::Index GetBasePropertyIndex( Property::Index index ) const;
+ Property::Index GetBasePropertyIndex(Property::Index index) const;
/**
* Given a property index, retrieve its component index.
* @param[in] index The index of the property.
* @return The component index associated with that property index.
*/
- int32_t GetComponentIndex( Property::Index index ) const;
+ int32_t GetComponentIndex(Property::Index index) const;
/**
* @param[in] index The property index.
* @return True, if writable, false otherwise.
*/
- bool IsPropertyWritable( Property::Index index ) const;
+ bool IsPropertyWritable(Property::Index index) const;
/**
* @param[in] index The property index.
* @return True, if animatable, false otherwise.
*/
- bool IsPropertyAnimatable( Property::Index index ) const;
+ bool IsPropertyAnimatable(Property::Index index) const;
/**
* @param[in] index The property index.
* @return True, if a constraint input, false otherwise.
*/
- bool IsPropertyAConstraintInput( Property::Index index ) const;
+ bool IsPropertyAConstraintInput(Property::Index index) const;
/**
* Retrieve the Property::Type of the property at the given index.
* @param[in] index The property index.
* @return The Property::Type at that index.
*/
- Property::Type GetPropertyType( Property::Index index ) const;
+ Property::Type GetPropertyType(Property::Index index) const;
/**
* Given a child property name, retrieve the index.
* @param[in] index The property index.
* @return The Property::Type at that index.
*/
- Property::Type GetChildPropertyType( Property::Index index ) const;
+ Property::Type GetChildPropertyType(Property::Index index) const;
/**
* Retrive the child indices into the given container.
* @param[in,out] indices The container to put the child indices into
*/
- void GetChildPropertyIndices( Property::IndexContainer& indices ) const;
+ void GetChildPropertyIndices(Property::IndexContainer& indices) const;
/**
* Retrieve the default value of the property at the given index.
* @param[in] index The property index.
* @return The default property value at that index.
*/
- Property::Value GetPropertyDefaultValue( Property::Index index ) const;
+ Property::Value GetPropertyDefaultValue(Property::Index index) const;
/**
* Sets the value of a property at the index specified for the given object.
* @param[in] index The property index.
* @return The current value of the property.
*/
- Property::Value GetProperty( const BaseObject *object, Property::Index index ) const;
+ Property::Value GetProperty(const BaseObject* object, Property::Index index) const;
/**
* Retrieves the value of a property with the name specified for the given object.
* @param[in] name The property name.
* @return The current value of the property.
*/
- Property::Value GetProperty( const BaseObject *object, const std::string& name ) const;
+ Property::Value GetProperty(const BaseObject* object, const std::string& name) const;
private:
-
struct RegisteredProperty
{
RegisteredProperty(Property::Type propType, ConstString propName, Property::Index basePropertyIndex, int32_t componentIndex)
Property::Type type = Property::NONE;
union
{
- Dali::TypeInfo::SetPropertyFunction setFunc = nullptr;
+ Dali::TypeInfo::SetPropertyFunction setFunc = nullptr;
Dali::CSharpTypeInfo::SetPropertyFunction cSharpSetFunc; // only one field can be initialized but this will have same value anyways
};
union
{
- Dali::TypeInfo::GetPropertyFunction getFunc = nullptr;
+ Dali::TypeInfo::GetPropertyFunction getFunc = nullptr;
Dali::CSharpTypeInfo::GetPropertyFunction cSharpGetFunc; // only one field can be initialized but this will have same value anyways
};
ConstString name;
Property::Index basePropertyIndex = Property::INVALID_INDEX;
- int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
+ int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
};
using ConnectionPair = std::pair<std::string, Dali::TypeInfo::SignalConnectorFunction>;
* @param[in,out] indices The vector to append indices onto
* @param[in] registeredProperties The container to retrive indices from
*/
- void AppendProperties( Dali::Property::IndexContainer& indices,
- const TypeInfo::RegisteredPropertyContainer& registeredProperties ) const;
+ void AppendProperties(Dali::Property::IndexContainer& indices,
+ const TypeInfo::RegisteredPropertyContainer& registeredProperties) const;
private:
-
- TypeRegistry& mTypeRegistry;
+ TypeRegistry& mTypeRegistry;
mutable Internal::TypeInfo* mBaseType; // allow changing from const methods, initialised inside constructor
- std::string mTypeName;
- std::string mBaseTypeName;
+ std::string mTypeName;
+ std::string mBaseTypeName;
union
{
- Dali::TypeInfo::CreateFunction mCreate = nullptr;
+ Dali::TypeInfo::CreateFunction mCreate = nullptr;
Dali::CSharpTypeInfo::CreateFunction mCSharpCreate; // only one field can be initialized but this will have same value anyways
};
- ActionContainer mActions;
- ConnectorContainer mSignalConnectors;
- RegisteredPropertyContainer mRegisteredProperties;
- RegisteredPropertyContainer mRegisteredChildProperties;
+ ActionContainer mActions;
+ ConnectorContainer mSignalConnectors;
+ RegisteredPropertyContainer mRegisteredProperties;
+ RegisteredPropertyContainer mRegisteredChildProperties;
PropertyDefaultValueContainer mPropertyDefaultValues;
- const Dali::PropertyDetails* mDefaultProperties = nullptr;
- Property::Index mDefaultPropertyCount = 0;
- bool mCSharpType = false; ///< Whether this type info is for a CSharp control (instead of C++)
+ const Dali::PropertyDetails* mDefaultProperties = nullptr;
+ Property::Index mDefaultPropertyCount = 0;
+ bool mCSharpType = false; ///< Whether this type info is for a CSharp control (instead of C++)
};
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/common/type-registry-impl.h>
// INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/object/base-handle.h>
#include <dali/internal/event/actors/custom-actor-internal.h>
#include <dali/internal/event/common/demangler.h>
#include <dali/internal/event/common/thread-local-storage.h>
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/object/type-registry.h>
#include <dali/integration-api/debug.h>
namespace
{
-
#if defined(DEBUG_ENABLED)
Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_TYPE_REGISTRY");
#endif
-} // namespace anon
+} // namespace
namespace Dali
{
-
namespace Internal
{
-
-TypeRegistry *TypeRegistry::Get()
+TypeRegistry* TypeRegistry::Get()
{
- static TypeRegistry *_reg(new TypeRegistry());
+ static TypeRegistry* _reg(new TypeRegistry());
DALI_ASSERT_DEBUG(_reg);
return _reg;
}
mRegistryLut.clear();
}
-TypeRegistry::TypeInfoPointer TypeRegistry::GetTypeInfo( const std::string& uniqueTypeName )
+TypeRegistry::TypeInfoPointer TypeRegistry::GetTypeInfo(const std::string& uniqueTypeName)
{
- for( auto&& iter : mRegistryLut )
+ for(auto&& iter : mRegistryLut)
{
// Note! mRegistryLut contains Dali::TypeInfo handles, so cannot call GetTypeName()
// as it calls us back resulting in infinite loop (GetTypeName is in BaseHandle part)
- if( iter->GetName() == uniqueTypeName )
+ if(iter->GetName() == uniqueTypeName)
{
return iter;
}
}
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Cannot find requested type '%s'\n", uniqueTypeName.c_str() );
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Cannot find requested type '%s'\n", uniqueTypeName.c_str());
return TypeRegistry::TypeInfoPointer();
}
-TypeRegistry::TypeInfoPointer TypeRegistry::GetTypeInfo( const std::type_info& registerType )
+TypeRegistry::TypeInfoPointer TypeRegistry::GetTypeInfo(const std::type_info& registerType)
{
- std::string typeName = DemangleClassName( registerType.name() );
+ std::string typeName = DemangleClassName(registerType.name());
- return GetTypeInfo( typeName );
+ return GetTypeInfo(typeName);
}
uint32_t TypeRegistry::GetTypeNameCount() const
{
- return static_cast<uint32_t>( mRegistryLut.size() );
+ return static_cast<uint32_t>(mRegistryLut.size());
}
const std::string& TypeRegistry::GetTypeName(uint32_t index) const
{
static std::string EMPTY_STRING{};
- if( index < mRegistryLut.size() )
+ if(index < mRegistryLut.size())
{
return mRegistryLut[index]->GetName();
}
return EMPTY_STRING;
}
-std::string TypeRegistry::Register( const std::type_info& theTypeInfo,
- const std::type_info& baseTypeInfo,
- Dali::TypeInfo::CreateFunction createInstance,
- bool callCreateOnInit )
+std::string TypeRegistry::Register(const std::type_info& theTypeInfo,
+ const std::type_info& baseTypeInfo,
+ Dali::TypeInfo::CreateFunction createInstance,
+ bool callCreateOnInit)
{
- std::string uniqueTypeName = DemangleClassName( theTypeInfo.name() );
+ std::string uniqueTypeName = DemangleClassName(theTypeInfo.name());
- return Register( uniqueTypeName, baseTypeInfo, createInstance, callCreateOnInit );
+ return Register(uniqueTypeName, baseTypeInfo, createInstance, callCreateOnInit);
}
-std::string TypeRegistry::Register( const std::type_info& theTypeInfo,
- const std::type_info& baseTypeInfo,
- Dali::TypeInfo::CreateFunction createInstance,
- bool callCreateOnInit,
- const Dali::PropertyDetails* defaultProperties,
- Property::Index defaultPropertyCount )
+std::string TypeRegistry::Register(const std::type_info& theTypeInfo,
+ const std::type_info& baseTypeInfo,
+ Dali::TypeInfo::CreateFunction createInstance,
+ bool callCreateOnInit,
+ const Dali::PropertyDetails* defaultProperties,
+ Property::Index defaultPropertyCount)
{
- std::string uniqueTypeName = DemangleClassName( theTypeInfo.name() );
+ std::string uniqueTypeName = DemangleClassName(theTypeInfo.name());
- return Register( uniqueTypeName, baseTypeInfo, createInstance, callCreateOnInit, defaultProperties, defaultPropertyCount );
+ return Register(uniqueTypeName, baseTypeInfo, createInstance, callCreateOnInit, defaultProperties, defaultPropertyCount);
}
std::string TypeRegistry::Register(std::string uniqueTypeName,
const Dali::PropertyDetails* defaultProperties,
Property::Index defaultPropertyCount)
{
- std::string baseTypeName = DemangleClassName( baseTypeInfo.name() );
+ std::string baseTypeName = DemangleClassName(baseTypeInfo.name());
// check for duplicates using uniqueTypeName
- for( auto&& iter : mRegistryLut )
+ for(auto&& iter : mRegistryLut)
{
- if( iter->GetName() == uniqueTypeName )
+ if(iter->GetName() == uniqueTypeName)
{
- DALI_LOG_WARNING( "Duplicate name in TypeRegistry for '%s'\n", + uniqueTypeName.c_str() );
- DALI_ASSERT_ALWAYS( !"Duplicate type name in Type Registration" );
+ DALI_LOG_WARNING("Duplicate name in TypeRegistry for '%s'\n", +uniqueTypeName.c_str());
+ DALI_ASSERT_ALWAYS(!"Duplicate type name in Type Registration");
return uniqueTypeName; // never actually happening due to the assert
}
}
- mRegistryLut.push_back( TypeRegistry::TypeInfoPointer(
- new Internal::TypeInfo( uniqueTypeName, baseTypeName, createInstance, defaultProperties, defaultPropertyCount ) ) );
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str() );
+ mRegistryLut.push_back(TypeRegistry::TypeInfoPointer(
+ new Internal::TypeInfo(uniqueTypeName, baseTypeName, createInstance, defaultProperties, defaultPropertyCount)));
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str());
- if( callCreateOnInit )
+ if(callCreateOnInit)
{
mInitFunctions.push_back(createInstance);
}
void TypeRegistry::Register(std::string uniqueTypeName, const std::type_info& baseTypeInfo, Dali::CSharpTypeInfo::CreateFunction createInstance)
{
- std::string baseTypeName = DemangleClassName( baseTypeInfo.name() );
+ std::string baseTypeName = DemangleClassName(baseTypeInfo.name());
// check for duplicates using uniqueTypeName
- for( auto&& iter : mRegistryLut )
+ for(auto&& iter : mRegistryLut)
{
- if( iter->GetName() == uniqueTypeName )
+ if(iter->GetName() == uniqueTypeName)
{
- DALI_LOG_WARNING( "Duplicate name in TypeRegistry for '%s'\n", + uniqueTypeName.c_str() );
- DALI_ASSERT_ALWAYS( !"Duplicate type name in Type Registration" );
+ DALI_LOG_WARNING("Duplicate name in TypeRegistry for '%s'\n", +uniqueTypeName.c_str());
+ DALI_ASSERT_ALWAYS(!"Duplicate type name in Type Registration");
return; // never actually happening due to the assert
}
}
- mRegistryLut.push_back( TypeRegistry::TypeInfoPointer( new Internal::TypeInfo( uniqueTypeName, baseTypeName, createInstance ) ) );
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str() );
+ mRegistryLut.push_back(TypeRegistry::TypeInfoPointer(new Internal::TypeInfo(uniqueTypeName, baseTypeName, createInstance)));
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str());
}
void TypeRegistry::CallInitFunctions(void) const
{
- for( auto&& iter : mInitFunctions )
+ for(auto&& iter : mInitFunctions)
{
(*iter)();
}
}
-std::string TypeRegistry::RegistrationName( const std::type_info& registerType )
+std::string TypeRegistry::RegistrationName(const std::type_info& registerType)
{
- return DemangleClassName( registerType.name() );
+ return DemangleClassName(registerType.name());
}
void TypeRegistry::RegisterSignal(TypeRegistration& typeRegistration, std::string name, Dali::TypeInfo::SignalConnectorFunction func)
{
- for( auto&& iter : mRegistryLut )
+ for(auto&& iter : mRegistryLut)
{
- if( iter->GetName() == typeRegistration.RegisteredName() )
+ if(iter->GetName() == typeRegistration.RegisteredName())
{
iter->AddConnectorFunction(std::move(name), func);
break;
bool TypeRegistry::RegisterAction(TypeRegistration& typeRegistration, std::string name, Dali::TypeInfo::ActionFunction f)
{
- for( auto&& iter : mRegistryLut )
+ for(auto&& iter : mRegistryLut)
{
- if( iter->GetName() == typeRegistration.RegisteredName() )
+ if(iter->GetName() == typeRegistration.RegisteredName())
{
iter->AddActionFunction(std::move(name), f);
return true;
bool TypeRegistry::RegisterProperty(TypeRegistration& typeRegistration, std::string name, Property::Index index, Property::Type type, Dali::TypeInfo::SetPropertyFunction setFunc, Dali::TypeInfo::GetPropertyFunction getFunc)
{
- for( auto&& iter : mRegistryLut )
+ for(auto&& iter : mRegistryLut)
{
- if( iter->GetName() == typeRegistration.RegisteredName() )
+ if(iter->GetName() == typeRegistration.RegisteredName())
{
iter->AddProperty(std::move(name), index, type, setFunc, getFunc);
return true;
bool TypeRegistry::RegisterProperty(const std::string& objectName, std::string name, Property::Index index, Property::Type type, Dali::CSharpTypeInfo::SetPropertyFunction setFunc, Dali::CSharpTypeInfo::GetPropertyFunction getFunc)
{
- for( auto&& iter : mRegistryLut )
+ for(auto&& iter : mRegistryLut)
{
- if( iter->GetName() == objectName )
+ if(iter->GetName() == objectName)
{
iter->AddProperty(std::move(name), index, type, setFunc, getFunc);
return true;
bool TypeRegistry::RegisterAnimatableProperty(TypeRegistration& typeRegistration, std::string name, Property::Index index, Property::Type type)
{
- for( auto&& iter : mRegistryLut )
+ for(auto&& iter : mRegistryLut)
{
- if( iter->GetName() == typeRegistration.RegisteredName() )
+ if(iter->GetName() == typeRegistration.RegisteredName())
{
iter->AddAnimatableProperty(std::move(name), index, type);
return true;
bool TypeRegistry::RegisterAnimatableProperty(TypeRegistration& typeRegistration, std::string name, Property::Index index, Property::Value value)
{
- for( auto&& iter : mRegistryLut )
+ for(auto&& iter : mRegistryLut)
{
- if( iter->GetName() == typeRegistration.RegisteredName() )
+ if(iter->GetName() == typeRegistration.RegisteredName())
{
iter->AddAnimatableProperty(std::move(name), index, std::move(value));
return true;
bool TypeRegistry::RegisterAnimatablePropertyComponent(TypeRegistration& typeRegistration, std::string name, Property::Index index, Property::Index baseIndex, unsigned int componentIndex)
{
- for( auto&& iter : mRegistryLut )
+ for(auto&& iter : mRegistryLut)
{
- if( iter->GetName() == typeRegistration.RegisteredName() )
+ if(iter->GetName() == typeRegistration.RegisteredName())
{
iter->AddAnimatablePropertyComponent(std::move(name), index, baseIndex, componentIndex);
return true;
bool TypeRegistry::RegisterChildProperty(const std::string& registeredType, std::string name, Property::Index index, Property::Type type)
{
- for( auto&& iter : mRegistryLut )
+ for(auto&& iter : mRegistryLut)
{
- if( iter->GetName() == registeredType )
+ if(iter->GetName() == registeredType)
{
iter->AddChildProperty(std::move(name), index, type);
return true;
return RegisterChildProperty(typeRegistration.RegisteredName(), std::move(name), index, type);
}
-bool TypeRegistry::DoActionTo( BaseObject * const object, const std::string& actionName, const Property::Map& properties )
+bool TypeRegistry::DoActionTo(BaseObject* const object, const std::string& actionName, const Property::Map& properties)
{
bool done = false;
- auto&& type = GetTypeInfo( object );
+ auto&& type = GetTypeInfo(object);
// DoActionTo recurses through base classes
- done = type->DoActionTo( object, actionName, properties );
+ done = type->DoActionTo(object, actionName, properties);
- if( !done )
+ if(!done)
{
DALI_LOG_WARNING("Type '%s' cannot do action '%s'\n", type->GetName().c_str(), actionName.c_str());
}
return done;
}
-bool TypeRegistry::ConnectSignal( BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor )
+bool TypeRegistry::ConnectSignal(BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( false );
+ bool connected(false);
- auto&& type = GetTypeInfo( object );
+ auto&& type = GetTypeInfo(object);
// Connect iterates through base classes
- connected = type->ConnectSignal( object, connectionTracker, signalName, functor );
+ connected = type->ConnectSignal(object, connectionTracker, signalName, functor);
- if( !connected )
+ if(!connected)
{
DALI_LOG_WARNING("Type '%s' signal '%s' connection failed \n", type->GetName().c_str(), signalName.c_str());
// Ownership of functor was not passed to Dali::CallbackBase, so clean-up now
return connected;
}
-TypeRegistry::TypeInfoPointer TypeRegistry::GetTypeInfo(const Dali::BaseObject * const pBaseObject)
+TypeRegistry::TypeInfoPointer TypeRegistry::GetTypeInfo(const Dali::BaseObject* const pBaseObject)
{
TypeInfoPointer type;
// test for custom actor which has another indirection to get to the type hiearchy we're after
- const Dali::Internal::CustomActor * const pCustom = dynamic_cast<const Dali::Internal::CustomActor*>(pBaseObject);
+ const Dali::Internal::CustomActor* const pCustom = dynamic_cast<const Dali::Internal::CustomActor*>(pBaseObject);
- if( pCustom )
+ if(pCustom)
{
const Dali::CustomActorImpl& custom = pCustom->GetImplementation();
- type = GetTypeInfo( typeid( custom ) );
- if( !type )
+ type = GetTypeInfo(typeid(custom));
+ if(!type)
{
// the most derived type is a descendant of custom actor but has not registered itself
// so we'll just treat it as a custom actor for now so it "inherits" all of actors properties, actions and signals
- type = GetTypeInfo( typeid( Dali::Internal::CustomActor ) );
+ type = GetTypeInfo(typeid(Dali::Internal::CustomActor));
}
}
else
{
- type = GetTypeInfo( typeid( *pBaseObject ) );
+ type = GetTypeInfo(typeid(*pBaseObject));
}
return type;
#define DALI_INTERNAL_TYPE_REGISTRY_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/devel-api/object/csharp-type-info.h>
-#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/object/base-object.h>
#include <dali/internal/event/common/type-info-impl.h>
#include <dali/internal/event/object/default-property-metadata.h>
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/type-registry.h>
namespace Dali
{
-
namespace Internal
{
-
class PropertyDetails;
/*
class TypeRegistry : public Dali::BaseObject
{
public:
-
// using intrusive pointer instead of handles internally as they are considerably cheaper
using TypeInfoPointer = IntrusivePtr<Dali::Internal::TypeInfo>;
/**
* Get the TypeRegistry
*/
- static TypeRegistry *Get();
+ static TypeRegistry* Get();
/**
* @copydoc Dali::TypeRegistry::GetTypeInfo
*/
- TypeInfoPointer GetTypeInfo( const std::string &uniqueTypeName );
+ TypeInfoPointer GetTypeInfo(const std::string& uniqueTypeName);
/**
* @copydoc Dali::TypeRegistry::GetTypeInfo
*/
- TypeInfoPointer GetTypeInfo( const std::type_info& registerType );
+ TypeInfoPointer GetTypeInfo(const std::type_info& registerType);
/**
* @copydoc Dali::TypeRegistry::GetTypeNameCount
* @param [in] callCreateOnInit If true call createInstance on DALi initialisation
* @return the name of the registered type.
*/
- std::string Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo,
- Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit );
+ std::string Register(const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo, Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit);
/**
* Register a type
* @param [in] defaultPropertyCount count of default properties
* @return the name of the registered type.
*/
- std::string Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo,
- Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit,
- const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount );
+ std::string Register(const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo, Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit, const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount);
/**
* Register a type
* @copydoc Dali::Internal::TypeInfo::DoActionTo
* Walks all base types until it finds a doer.
*/
- bool DoActionTo( BaseObject * const object, const std::string &actionName, const Property::Map& properties);
+ bool DoActionTo(BaseObject* const object, const std::string& actionName, const Property::Map& properties);
/**
* @copydoc Dali::BaseHandle::ConnectSignal()
*/
- bool ConnectSignal( BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor );
+ bool ConnectSignal(BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor);
/**
* Return the type info for a given BaseObject pointer
* @param [in] pBaseObject Pointer to a BaseObject
* @return TypeInfo for the BaseObject.
*/
- TypeInfoPointer GetTypeInfo(const Dali::BaseObject * const pBaseObject);
+ TypeInfoPointer GetTypeInfo(const Dali::BaseObject* const pBaseObject);
/**
* Calls any type creation functions that have been flagged as initialization functions
void CallInitFunctions(void) const;
public:
-
/*
* Return the name derived from type_info used to register the type
* @param [in] registerType Type info for the type to be registered
* @return registered name
*/
- static std::string RegistrationName( const std::type_info& registerType );
+ static std::string RegistrationName(const std::type_info& registerType);
private:
/*
* Mapping from type name to TypeInfo
*/
- std::vector< TypeInfoPointer > mRegistryLut;
+ std::vector<TypeInfoPointer> mRegistryLut;
- std::vector< Dali::TypeInfo::CreateFunction > mInitFunctions;
+ std::vector<Dali::TypeInfo::CreateFunction> mInitFunctions;
private:
TypeRegistry();
/**
* @brief Undefined Copy Constructor
*/
- TypeRegistry(TypeRegistry &);
+ TypeRegistry(TypeRegistry&);
/**
* @brief Undefined Assignment Operator
*/
- TypeRegistry& operator=(const TypeRegistry &);
+ TypeRegistry& operator=(const TypeRegistry&);
};
-
} // namespace Internal
// Helpers for public-api forwarding methods
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <sstream>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-core-version.h>
-#include <dali/public-api/common/dali-common.h>
#include <dali/devel-api/common/hash.h>
#include <dali/integration-api/debug.h>
#include <dali/integration-api/platform-abstraction.h>
#include <dali/internal/event/common/thread-local-storage.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/dali-core-version.h>
namespace
{
const char* VERSION_SEPARATOR = "-";
-const char* SHADER_SUFFIX = ".dali-bin";
-}
+const char* SHADER_SUFFIX = ".dali-bin";
+} // namespace
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
/**
* @brief Generates a filename for a shader binary based on the hash value passed in.
* @param[in] shaderHash A hash over shader sources.
* @param[out] filename A string to overwrite with the filename.
*/
-void shaderBinaryFilename( size_t shaderHash, std::string& filename )
+void shaderBinaryFilename(size_t shaderHash, std::string& filename)
{
- std::stringstream binaryShaderFilenameBuilder( std::ios_base::out );
+ std::stringstream binaryShaderFilenameBuilder(std::ios_base::out);
binaryShaderFilenameBuilder << CORE_MAJOR_VERSION << VERSION_SEPARATOR << CORE_MINOR_VERSION << VERSION_SEPARATOR << CORE_MICRO_VERSION << VERSION_SEPARATOR
<< shaderHash
<< SHADER_SUFFIX;
filename = binaryShaderFilenameBuilder.str();
}
-}
+} // namespace
ShaderFactory::ShaderFactory() = default;
ShaderFactory::~ShaderFactory()
{
// Let all the cached objects destroy themselves:
- for( std::size_t i = 0, cacheSize = mShaderBinaryCache.Size(); i < cacheSize; ++i )
+ for(std::size_t i = 0, cacheSize = mShaderBinaryCache.Size(); i < cacheSize; ++i)
{
- if( mShaderBinaryCache[i] )
+ if(mShaderBinaryCache[i])
{
mShaderBinaryCache[i]->Unreference();
}
}
}
-ShaderDataPtr ShaderFactory::Load( std::string_view vertexSource, std::string_view fragmentSource, const Dali::Shader::Hint::Value hints, size_t& shaderHash )
+ShaderDataPtr ShaderFactory::Load(std::string_view vertexSource, std::string_view fragmentSource, const Dali::Shader::Hint::Value hints, size_t& shaderHash)
{
// Work out the filename for the binary that the glsl source will be compiled and linked to:
- shaderHash = CalculateHash( vertexSource.data(), fragmentSource.data() );
+ shaderHash = CalculateHash(vertexSource.data(), fragmentSource.data());
std::string binaryShaderFilename;
- shaderBinaryFilename( shaderHash, binaryShaderFilename );
+ shaderBinaryFilename(shaderHash, binaryShaderFilename);
ShaderDataPtr shaderData;
/// Check a cache of previously loaded shaders:
- for( std::size_t i = 0, cacheSize = mShaderBinaryCache.Size(); i < cacheSize; ++i )
+ for(std::size_t i = 0, cacheSize = mShaderBinaryCache.Size(); i < cacheSize; ++i)
{
- if( mShaderBinaryCache[i]->GetHashValue() == shaderHash )
+ if(mShaderBinaryCache[i]->GetHashValue() == shaderHash)
{
shaderData = mShaderBinaryCache[i];
- DALI_LOG_INFO( Debug::Filter::gShader, Debug::General, "Mem cache hit on path: \"%s\"\n", binaryShaderFilename.c_str() );
+ DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "Mem cache hit on path: \"%s\"\n", binaryShaderFilename.c_str());
break;
}
}
// If memory cache failed check the file system for a binary or return a source-only ShaderData:
- if( shaderData.Get() == nullptr )
+ if(shaderData.Get() == nullptr)
{
// Allocate the structure that returns the loaded shader:
- shaderData = new ShaderData( std::string(vertexSource), std::string(fragmentSource), hints );
- shaderData->SetHashValue( shaderHash );
+ shaderData = new ShaderData(std::string(vertexSource), std::string(fragmentSource), hints);
+ shaderData->SetHashValue(shaderHash);
shaderData->GetBuffer().Clear();
// Try to load the binary (this will fail if the shader source has never been compiled before):
- ThreadLocalStorage& tls = ThreadLocalStorage::Get();
+ ThreadLocalStorage& tls = ThreadLocalStorage::Get();
Integration::PlatformAbstraction& platformAbstraction = tls.GetPlatformAbstraction();
- const bool loaded = platformAbstraction.LoadShaderBinaryFile( binaryShaderFilename, shaderData->GetBuffer() );
+ const bool loaded = platformAbstraction.LoadShaderBinaryFile(binaryShaderFilename, shaderData->GetBuffer());
- if( loaded )
+ if(loaded)
{
- MemoryCacheInsert( *shaderData );
+ MemoryCacheInsert(*shaderData);
}
- DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, loaded ?
- "loaded on path: \"%s\"\n" :
- "failed to load on path: \"%s\"\n",
- binaryShaderFilename.c_str());
+ DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, loaded ? "loaded on path: \"%s\"\n" : "failed to load on path: \"%s\"\n", binaryShaderFilename.c_str());
}
return shaderData;
}
-void ShaderFactory::SaveBinary( Internal::ShaderDataPtr shaderData )
+void ShaderFactory::SaveBinary(Internal::ShaderDataPtr shaderData)
{
// Save the binary to the file system:
std::string binaryShaderFilename;
- shaderBinaryFilename( shaderData->GetHashValue(), binaryShaderFilename );
+ shaderBinaryFilename(shaderData->GetHashValue(), binaryShaderFilename);
- ThreadLocalStorage& tls = ThreadLocalStorage::Get();
+ ThreadLocalStorage& tls = ThreadLocalStorage::Get();
Integration::PlatformAbstraction& platformAbstraction = tls.GetPlatformAbstraction();
- const bool saved = platformAbstraction.SaveShaderBinaryFile( binaryShaderFilename, &shaderData->GetBuffer()[0], static_cast<unsigned int>( shaderData->GetBufferSize() ) ); // don't expect buffer larger than unsigned int
+ const bool saved = platformAbstraction.SaveShaderBinaryFile(binaryShaderFilename, &shaderData->GetBuffer()[0], static_cast<unsigned int>(shaderData->GetBufferSize())); // don't expect buffer larger than unsigned int
// Save the binary into to memory cache:
- MemoryCacheInsert( *shaderData );
+ MemoryCacheInsert(*shaderData);
- DALI_LOG_INFO( Debug::Filter::gShader, Debug::General, saved ? "Saved to file: %s\n" : "Save to file failed: %s\n", binaryShaderFilename.c_str() );
- if( saved ) {} // Avoid unused variable warning in release builds
+ DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, saved ? "Saved to file: %s\n" : "Save to file failed: %s\n", binaryShaderFilename.c_str());
+ if(saved)
+ {
+ } // Avoid unused variable warning in release builds
}
-void ShaderFactory::MemoryCacheInsert( ShaderData& shaderData )
+void ShaderFactory::MemoryCacheInsert(ShaderData& shaderData)
{
- DALI_ASSERT_DEBUG( shaderData.GetBufferSize() > 0 );
+ DALI_ASSERT_DEBUG(shaderData.GetBufferSize() > 0);
// Save the binary into to memory cache:
- if( shaderData.GetBufferSize() > 0 )
+ if(shaderData.GetBufferSize() > 0)
{
- mShaderBinaryCache.Reserve( mShaderBinaryCache.Size() + 1 ); // Make sure the push won't throw after we inc the ref count.
+ mShaderBinaryCache.Reserve(mShaderBinaryCache.Size() + 1); // Make sure the push won't throw after we inc the ref count.
shaderData.Reference();
- mShaderBinaryCache.PushBack( &shaderData );
- DALI_LOG_INFO( Debug::Filter::gShader, Debug::General, "CACHED BINARY FOR HASH: %u\n", shaderData.GetHashValue() );
+ mShaderBinaryCache.PushBack(&shaderData);
+ DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "CACHED BINARY FOR HASH: %u\n", shaderData.GetHashValue());
}
}
#define DALI_INTERNAL_SHADER_FACTORY_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-vector.h>
#include <dali/internal/common/message.h>
#include <dali/internal/common/shader-data.h>
#include <dali/internal/common/shader-saver.h>
+#include <dali/public-api/common/dali-vector.h>
namespace Dali
{
-
namespace Internal
{
-
class ShaderData;
using ShaderDataPtr = IntrusivePtr<ShaderData>;
class ShaderFactory : public ShaderSaver
{
public:
-
/**
* Default constructor
*/
* a compiled shader program binary if one could be found, else an
* empty binary buffer cleared to size zero.
*/
- Internal::ShaderDataPtr Load( std::string_view vertexSource, std::string_view fragmentSource, const Dali::Shader::Hint::Value hints, size_t& shaderHash );
+ Internal::ShaderDataPtr Load(std::string_view vertexSource, std::string_view fragmentSource, const Dali::Shader::Hint::Value hints, size_t& shaderHash);
/**
* @brief Saves shader to memory cache and filesystem.
* @param[in] shader The data to be saved.
* @sa Load
*/
- void SaveBinary( Internal::ShaderDataPtr shader ) override;
+ void SaveBinary(Internal::ShaderDataPtr shader) override;
private:
-
- void MemoryCacheInsert( Internal::ShaderData& shaderData );
+ void MemoryCacheInsert(Internal::ShaderData& shaderData);
// Undefined
- ShaderFactory( const ShaderFactory& );
+ ShaderFactory(const ShaderFactory&);
// Undefined
- ShaderFactory& operator=( const ShaderFactory& rhs );
+ ShaderFactory& operator=(const ShaderFactory& rhs);
private:
- Dali::Vector< Internal::ShaderData* > mShaderBinaryCache; ///< Cache of pre-compiled shaders.
+ Dali::Vector<Internal::ShaderData*> mShaderBinaryCache; ///< Cache of pre-compiled shaders.
}; // class ShaderFactory
-inline MessageBase* ShaderCompiledMessage( ShaderSaver& factory, Internal::ShaderDataPtr shaderData )
+inline MessageBase* ShaderCompiledMessage(ShaderSaver& factory, Internal::ShaderDataPtr shaderData)
{
- return new MessageValue1< ShaderSaver, Internal::ShaderDataPtr >( &factory,
- &ShaderSaver::SaveBinary,
- shaderData );
+ return new MessageValue1<ShaderSaver, Internal::ShaderDataPtr>(&factory,
+ &ShaderSaver::SaveBinary,
+ shaderData);
}
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
ActorGestureData::ActorGestureData()
-: gesturesRequired( GestureType::Value( 0 ) ),
- panDetectors( nullptr ),
- pinchDetectors( nullptr ),
- longPressDetectors( nullptr ),
- tapDetectors( nullptr ),
- rotationDetectors( nullptr )
+: gesturesRequired(GestureType::Value(0)),
+ panDetectors(nullptr),
+ pinchDetectors(nullptr),
+ longPressDetectors(nullptr),
+ tapDetectors(nullptr),
+ rotationDetectors(nullptr)
{
}
delete rotationDetectors;
}
-void ActorGestureData::AddGestureDetector( GestureDetector& detector )
+void ActorGestureData::AddGestureDetector(GestureDetector& detector)
{
- const GestureType::Value type( detector.GetType() );
+ const GestureType::Value type(detector.GetType());
- GestureDetectorContainer*& containerPtr( GetContainerPtr( type ) );
- if ( nullptr == containerPtr )
+ GestureDetectorContainer*& containerPtr(GetContainerPtr(type));
+ if(nullptr == containerPtr)
{
containerPtr = new GestureDetectorContainer;
}
- containerPtr->push_back( &detector );
+ containerPtr->push_back(&detector);
- gesturesRequired = GestureType::Value( gesturesRequired | type );
+ gesturesRequired = GestureType::Value(gesturesRequired | type);
}
-void ActorGestureData::RemoveGestureDetector( GestureDetector& detector )
+void ActorGestureData::RemoveGestureDetector(GestureDetector& detector)
{
- const GestureType::Value type( detector.GetType() );
+ const GestureType::Value type(detector.GetType());
- GestureDetectorContainer*& containerPtr( GetContainerPtr( type ) );
- DALI_ASSERT_DEBUG( containerPtr && "Container had not been created" );
+ GestureDetectorContainer*& containerPtr(GetContainerPtr(type));
+ DALI_ASSERT_DEBUG(containerPtr && "Container had not been created");
- GestureDetectorContainer& container( *containerPtr );
- GestureDetectorContainer::iterator match( std::remove( container.begin(), container.end(), &detector ) );
- DALI_ASSERT_DEBUG( match != container.end() && "Actor does not have the detector" );
- container.erase( match, container.end() );
+ GestureDetectorContainer& container(*containerPtr);
+ GestureDetectorContainer::iterator match(std::remove(container.begin(), container.end(), &detector));
+ DALI_ASSERT_DEBUG(match != container.end() && "Actor does not have the detector");
+ container.erase(match, container.end());
- if ( container.empty() )
+ if(container.empty())
{
- gesturesRequired = GestureType::Value( gesturesRequired & ~type );
+ gesturesRequired = GestureType::Value(gesturesRequired & ~type);
delete containerPtr;
containerPtr = nullptr;
}
}
-GestureDetectorContainer& ActorGestureData::GetGestureDetectorContainer( GestureType::Value type )
+GestureDetectorContainer& ActorGestureData::GetGestureDetectorContainer(GestureType::Value type)
{
- return *GetContainerPtr( type );
+ return *GetContainerPtr(type);
}
-GestureDetectorContainer*& ActorGestureData::GetContainerPtr( GestureType::Value type )
+GestureDetectorContainer*& ActorGestureData::GetContainerPtr(GestureType::Value type)
{
- switch ( type )
+ switch(type)
{
case GestureType::PAN:
{
}
}
- DALI_ASSERT_DEBUG( ! "Invalid Type" );
- static GestureDetectorContainer* invalidType( nullptr );
+ DALI_ASSERT_DEBUG(!"Invalid Type");
+ static GestureDetectorContainer* invalidType(nullptr);
return invalidType;
}
} // namespace Internal
} // namespace Dali
-
#define DALI_INTERNAL_ACTOR_GESTURE_DATA_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* Holds gesture specific data for an Actor
*/
class ActorGestureData
{
public:
-
/**
* Constructor
*/
* @note A raw pointer to the detector is stored, so the detector MUST remove itself when it is
* destroyed using RemoveGestureDetector()
*/
- void AddGestureDetector( GestureDetector& detector );
+ void AddGestureDetector(GestureDetector& detector);
/**
* Removes a previously added gesture detector from the data. If no more gesture detectors of
* gesture.
* @param[in] detector The detector to remove.
*/
- void RemoveGestureDetector( GestureDetector& detector );
+ void RemoveGestureDetector(GestureDetector& detector);
/**
* Queries whether the actor requires the gesture type.
* @param[in] type The gesture type.
* @return true if the gesture is required, false otherwise.
*/
- inline bool IsGestureRequired( GestureType::Value type ) const
+ inline bool IsGestureRequired(GestureType::Value type) const
{
return type & gesturesRequired;
}
* @param[in] type The container type required
* @pre Ensure IsGestureRequired() is used to check if the container is actually available.
*/
- GestureDetectorContainer& GetGestureDetectorContainer( GestureType::Value type );
+ GestureDetectorContainer& GetGestureDetectorContainer(GestureType::Value type);
private:
-
/**
* Helper to retrieve the appropriate container type.
* @param[in] type The container type required.
*/
- inline GestureDetectorContainer*& GetContainerPtr( GestureType::Value type );
+ inline GestureDetectorContainer*& GetContainerPtr(GestureType::Value type);
private:
-
GestureType::Value gesturesRequired; ///< Stores which gestures are required
GestureDetectorContainer* panDetectors; ///< Pointer to a container of pan-detectors
} // namespace Dali
#endif // DALI_INTERNAL_ACTOR_GESTURE_DATA_H
-
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
// CLASS HEADER
-#include <dali/internal/event/events/actor-observer.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/event/actors/actor-impl.h>
+#include <dali/internal/event/events/actor-observer.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACTOR_OBSERVER" );
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACTOR_OBSERVER");
#endif // defined(DEBUG_ENABLED)
-}
+} // namespace
ActorObserver::ActorObserver()
-: ActorObserver( nullptr )
+: ActorObserver(nullptr)
{
}
-ActorObserver::ActorObserver( CallbackBase* callback )
-: mActor ( nullptr ),
- mActorDisconnected( false ),
- mRemoveCallback( callback )
+ActorObserver::ActorObserver(CallbackBase* callback)
+: mActor(nullptr),
+ mActorDisconnected(false),
+ mRemoveCallback(callback)
{
- DALI_LOG_TRACE_METHOD( gLogFilter );
+ DALI_LOG_TRACE_METHOD(gLogFilter);
}
ActorObserver::~ActorObserver()
{
- DALI_LOG_TRACE_METHOD( gLogFilter );
- SetActor( nullptr );
+ DALI_LOG_TRACE_METHOD(gLogFilter);
+ SetActor(nullptr);
delete mRemoveCallback;
}
-ActorObserver::ActorObserver( ActorObserver&& other )
-: ActorObserver( nullptr )
+ActorObserver::ActorObserver(ActorObserver&& other)
+: ActorObserver(nullptr)
{
- operator=( std::move( other ) );
+ operator=(std::move(other));
}
-ActorObserver& ActorObserver::operator=( ActorObserver&& other )
+ActorObserver& ActorObserver::operator=(ActorObserver&& other)
{
- if( this != &other )
+ if(this != &other)
{
- SetActor( other.mActor );
+ SetActor(other.mActor);
mActorDisconnected = other.mActorDisconnected;
- mRemoveCallback = other.mRemoveCallback;
+ mRemoveCallback = other.mRemoveCallback;
other.ResetActor();
other.mRemoveCallback = nullptr;
}
return mActorDisconnected ? nullptr : mActor;
}
-void ActorObserver::SetActor( Actor* actor )
+void ActorObserver::SetActor(Actor* actor)
{
- DALI_LOG_TRACE_METHOD( gLogFilter );
+ DALI_LOG_TRACE_METHOD(gLogFilter);
- if ( mActor != actor )
+ if(mActor != actor)
{
ResetActor();
mActor = actor;
- if ( mActor )
+ if(mActor)
{
- mActor->AddObserver( *this );
+ mActor->AddObserver(*this);
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Start Observing: %p\n", mActor);
}
}
void ActorObserver::ResetActor()
{
- if ( mActor )
+ if(mActor)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Stop Observing: %p\n", mActor);
- mActor->RemoveObserver( *this );
- mActor = nullptr;
+ mActor->RemoveObserver(*this);
+ mActor = nullptr;
mActorDisconnected = false;
}
}
-void ActorObserver::SceneObjectAdded( Object& object )
+void ActorObserver::SceneObjectAdded(Object& object)
{
- DALI_LOG_TRACE_METHOD( gLogFilter );
+ DALI_LOG_TRACE_METHOD(gLogFilter);
- if ( mActor == &object )
+ if(mActor == &object)
{
mActorDisconnected = false;
}
}
-void ActorObserver::SceneObjectRemoved( Object& object )
+void ActorObserver::SceneObjectRemoved(Object& object)
{
- DALI_LOG_TRACE_METHOD( gLogFilter );
+ DALI_LOG_TRACE_METHOD(gLogFilter);
- if ( mActor == &object )
+ if(mActor == &object)
{
- if ( mRemoveCallback )
+ if(mRemoveCallback)
{
- CallbackBase::Execute( *mRemoveCallback, mActor );
+ CallbackBase::Execute(*mRemoveCallback, mActor);
}
// do not call object.RemoveObserver here, object is currently iterating through observers
void ActorObserver::ObjectDestroyed(Object& object)
{
- DALI_LOG_TRACE_METHOD( gLogFilter );
+ DALI_LOG_TRACE_METHOD(gLogFilter);
- if ( mActor == &object )
+ if(mActor == &object)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Stop Observing: %p\n", mActor);
mActor = nullptr;
} // namespace Internal
} // namespace Dali
-
#define DALI_INTERNAL_ACTOR_OBSERVER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/signals/callback.h>
#include <dali/internal/event/common/object-impl.h>
+#include <dali/public-api/signals/callback.h>
namespace Dali
{
-
namespace Internal
{
-
class Actor;
/**
struct ActorObserver : public Object::Observer
{
public:
-
// Construction & Destruction
/**
*
* @note Ownership of callback is passed onto this class.
*/
- ActorObserver( CallbackBase* callback );
+ ActorObserver(CallbackBase* callback);
/**
* Non virtual destructor
* @note The other's actor is appropriately disconnected.
* @note Ownership of callback is passed onto this class.
*/
- ActorObserver( ActorObserver&& other );
+ ActorObserver(ActorObserver&& other);
/**
* Move assignment operator.
* @note The other's actor is appropriately disconnected.
* @note Ownership of callback is passed onto this class.
*/
- ActorObserver& operator=( ActorObserver&& other );
+ ActorObserver& operator=(ActorObserver&& other);
// Not copyable
- ActorObserver( const ActorObserver& ) = delete; ///< Deleted copy constructor.
- ActorObserver& operator=( const ActorObserver& ) = delete; ///< Deleted copy assignment operator.
+ ActorObserver(const ActorObserver&) = delete; ///< Deleted copy constructor.
+ ActorObserver& operator=(const ActorObserver&) = delete; ///< Deleted copy assignment operator.
// Methods
* This disconnects the required signals from the currently set actor and connects to the required
* signals for the the actor specified (if set).
*/
- void SetActor( Actor* actor );
+ void SetActor(Actor* actor);
/**
* Resets the set actor and disconnects any connected signals.
void ResetActor();
private:
-
/**
* This will be called if an actor is added to the scene.
* @param[in] object The object object.
* @see Object::Observer::SceneObjectAdded()
*/
- void SceneObjectAdded( Object& object ) override;
+ void SceneObjectAdded(Object& object) override;
/**
* This will be called when the actor is removed from the scene.
* @param[in] object The object object.
* @see Object::Observer::SceneObjectRemoved()
*/
- void SceneObjectRemoved( Object& object ) override;
+ void SceneObjectRemoved(Object& object) override;
/**
* This will be called when the actor is destroyed. We should clear the actor.
* No need to stop observing as the object is being destroyed anyway.
* @see Object::Observer::ObjectDestroyed()
*/
- void ObjectDestroyed( Object& object ) override;
+ void ObjectDestroyed(Object& object) override;
private:
- Actor* mActor; ///< Raw pointer to an Actor.
- bool mActorDisconnected; ///< Indicates whether the actor has been disconnected from the scene
- CallbackBase* mRemoveCallback; ///< Callback to call when the observed actor is removed from the scene
+ Actor* mActor; ///< Raw pointer to an Actor.
+ bool mActorDisconnected; ///< Indicates whether the actor has been disconnected from the scene
+ CallbackBase* mRemoveCallback; ///< Callback to call when the observed actor is removed from the scene
};
} // namespace Internal
} // namespace Dali
#endif // DALI_INTERNAL_ACTOR_OBSERVER_H
-
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/integration-api/debug.h>
#include <dali/integration-api/events/event.h>
+#include <dali/integration-api/events/hover-event-integ.h>
#include <dali/integration-api/events/key-event-integ.h>
-#include <dali/integration-api/events/wheel-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/events/hover-event-integ.h>
-#include <dali/internal/event/events/gesture-event-processor.h>
+#include <dali/integration-api/events/wheel-event-integ.h>
#include <dali/internal/common/core-impl.h>
#include <dali/internal/event/common/notification-manager.h>
+#include <dali/internal/event/events/gesture-event-processor.h>
using Dali::Integration::Event;
namespace Dali
{
-
namespace Internal
{
-
namespace // unnamed namespace
{
-
-static const std::size_t MAX_MESSAGE_SIZE = std::max( sizeof(Integration::TouchEvent),
- std::max( sizeof(Integration::KeyEvent), sizeof(Integration::WheelEvent) ) );
+static const std::size_t MAX_MESSAGE_SIZE = std::max(sizeof(Integration::TouchEvent),
+ std::max(sizeof(Integration::KeyEvent), sizeof(Integration::WheelEvent)));
static const std::size_t INITIAL_MIN_CAPACITY = 4;
} // unnamed namespace
-EventProcessor::EventProcessor( Scene& scene, GestureEventProcessor& gestureEventProcessor )
-: mScene( scene ),
- mTouchEventProcessor( scene ),
- mHoverEventProcessor( scene ),
- mGestureEventProcessor( gestureEventProcessor ),
- mKeyEventProcessor( scene ),
- mWheelEventProcessor( scene ),
- mEventQueue0( INITIAL_BUFFER_SIZE ),
- mEventQueue1( INITIAL_BUFFER_SIZE ),
- mCurrentEventQueue( &mEventQueue0 )
+EventProcessor::EventProcessor(Scene& scene, GestureEventProcessor& gestureEventProcessor)
+: mScene(scene),
+ mTouchEventProcessor(scene),
+ mHoverEventProcessor(scene),
+ mGestureEventProcessor(gestureEventProcessor),
+ mKeyEventProcessor(scene),
+ mWheelEventProcessor(scene),
+ mEventQueue0(INITIAL_BUFFER_SIZE),
+ mEventQueue1(INITIAL_BUFFER_SIZE),
+ mCurrentEventQueue(&mEventQueue0)
{
}
EventProcessor::~EventProcessor()
{
- for( MessageBuffer::Iterator iter = mEventQueue0.Begin(); iter.IsValid(); iter.Next() )
+ for(MessageBuffer::Iterator iter = mEventQueue0.Begin(); iter.IsValid(); iter.Next())
{
// Call virtual destructor explictly; since delete will not be called after placement new
- Event* event = reinterpret_cast< Event* >( iter.Get() );
+ Event* event = reinterpret_cast<Event*>(iter.Get());
event->~Event();
}
- for( MessageBuffer::Iterator iter = mEventQueue1.Begin(); iter.IsValid(); iter.Next() )
+ for(MessageBuffer::Iterator iter = mEventQueue1.Begin(); iter.IsValid(); iter.Next())
{
// Call virtual destructor explictly; since delete will not be called after placement new
- Event* event = reinterpret_cast< Event* >( iter.Get() );
+ Event* event = reinterpret_cast<Event*>(iter.Get());
event->~Event();
}
}
-void EventProcessor::QueueEvent( const Event& event )
+void EventProcessor::QueueEvent(const Event& event)
{
- switch( event.type )
+ switch(event.type)
{
case Event::Touch:
{
typedef Integration::TouchEvent DerivedType;
// Reserve some memory inside the message queue
- uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
+ uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot(sizeof(DerivedType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( static_cast<const DerivedType&>(event) );
+ new(slot) DerivedType(static_cast<const DerivedType&>(event));
break;
}
using DerivedType = Integration::HoverEvent;
// Reserve some memory inside the message queue
- uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
+ uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot(sizeof(DerivedType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( static_cast<const DerivedType&>(event) );
+ new(slot) DerivedType(static_cast<const DerivedType&>(event));
break;
}
using DerivedType = Integration::KeyEvent;
// Reserve some memory inside the message queue
- uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
+ uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot(sizeof(DerivedType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( static_cast<const DerivedType&>(event) );
+ new(slot) DerivedType(static_cast<const DerivedType&>(event));
break;
}
using DerivedType = Integration::WheelEvent;
// Reserve some memory inside the message queue
- uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
+ uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot(sizeof(DerivedType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( static_cast<const DerivedType&>(event) );
+ new(slot) DerivedType(static_cast<const DerivedType&>(event));
break;
}
MessageBuffer* queueToProcess = mCurrentEventQueue;
// Switch current queue; events can be added safely while iterating through the other queue.
- mCurrentEventQueue = ( &mEventQueue0 == mCurrentEventQueue ) ? &mEventQueue1 : &mEventQueue0;
+ mCurrentEventQueue = (&mEventQueue0 == mCurrentEventQueue) ? &mEventQueue1 : &mEventQueue0;
- for( MessageBuffer::Iterator iter = queueToProcess->Begin(); iter.IsValid(); iter.Next() )
+ for(MessageBuffer::Iterator iter = queueToProcess->Begin(); iter.IsValid(); iter.Next())
{
- Event* event = reinterpret_cast< Event* >( iter.Get() );
+ Event* event = reinterpret_cast<Event*>(iter.Get());
- switch( event->type )
+ switch(event->type)
{
case Event::Touch:
{
Integration::TouchEvent& touchEvent = static_cast<Integration::TouchEvent&>(*event);
- const bool consumed = mTouchEventProcessor.ProcessTouchEvent( touchEvent );
+ const bool consumed = mTouchEventProcessor.ProcessTouchEvent(touchEvent);
// If touch is consumed, then gestures should be cancelled
// Do this by sending an interrupted event to the GestureEventProcessor
- if( consumed )
+ if(consumed)
{
Integration::Point& point = touchEvent.GetPoint(0);
- point.SetState( PointState::INTERRUPTED );
+ point.SetState(PointState::INTERRUPTED);
}
mGestureEventProcessor.ProcessTouchEvent(mScene, touchEvent);
case Event::Hover:
{
- mHoverEventProcessor.ProcessHoverEvent( static_cast<const Integration::HoverEvent&>(*event) );
+ mHoverEventProcessor.ProcessHoverEvent(static_cast<const Integration::HoverEvent&>(*event));
break;
}
case Event::Key:
{
- mKeyEventProcessor.ProcessKeyEvent( static_cast<const Integration::KeyEvent&>(*event) );
+ mKeyEventProcessor.ProcessKeyEvent(static_cast<const Integration::KeyEvent&>(*event));
break;
}
case Event::Wheel:
{
- mWheelEventProcessor.ProcessWheelEvent( static_cast<const Integration::WheelEvent&>(*event) );
+ mWheelEventProcessor.ProcessWheelEvent(static_cast<const Integration::WheelEvent&>(*event));
break;
}
}
#define DALI_INTERNAL_EVENT_PROCESSOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/touch-event-processor.h>
+#include <dali/internal/common/message-buffer.h>
#include <dali/internal/event/events/hover-event-processor.h>
#include <dali/internal/event/events/key-event-processor.h>
+#include <dali/internal/event/events/touch-event-processor.h>
#include <dali/internal/event/events/wheel-event-processor.h>
-#include <dali/internal/common/message-buffer.h>
namespace Dali
{
-
namespace Integration
{
struct Event;
namespace Internal
{
-
class Scene;
class GestureEventProcessor;
class NotificationManager;
class EventProcessor
{
public:
-
/**
* Constructor
* @param[in] scene The scene.
* @param[in] gestureEventProcessor The gesture event processor.
*/
- EventProcessor( Scene& scene, GestureEventProcessor& gestureEventProcessor );
+ EventProcessor(Scene& scene, GestureEventProcessor& gestureEventProcessor);
/**
* Destructor
virtual ~EventProcessor();
public:
-
/**
* This function is called when an event is queued.
* @param[in] event A event to queue.
*/
- void QueueEvent( const Integration::Event& event );
+ void QueueEvent(const Integration::Event& event);
/**
* This function is called when events are processed.
void ProcessEvents();
private:
-
- Scene& mScene; ///< The Scene events are processed for.
- TouchEventProcessor mTouchEventProcessor; ///< Processes touch events.
- HoverEventProcessor mHoverEventProcessor; ///< Processes hover events.
- GestureEventProcessor& mGestureEventProcessor; ///< Processes gesture events.
- KeyEventProcessor mKeyEventProcessor; ///< Processes key events.
- WheelEventProcessor mWheelEventProcessor; ///< Processes wheel events.
+ Scene& mScene; ///< The Scene events are processed for.
+ TouchEventProcessor mTouchEventProcessor; ///< Processes touch events.
+ HoverEventProcessor mHoverEventProcessor; ///< Processes hover events.
+ GestureEventProcessor& mGestureEventProcessor; ///< Processes gesture events.
+ KeyEventProcessor mKeyEventProcessor; ///< Processes key events.
+ WheelEventProcessor mWheelEventProcessor; ///< Processes wheel events.
// Allow messages to be added safely to one queue, while processing (iterating through) the second queue.
- MessageBuffer mEventQueue0; ///< An event queue.
- MessageBuffer mEventQueue1; ///< Another event queue.
+ MessageBuffer mEventQueue0; ///< An event queue.
+ MessageBuffer mEventQueue1; ///< Another event queue.
MessageBuffer* mCurrentEventQueue; ///< QueueEvent() will queue here.
};
} // namespace Dali
#endif // DALI_INTERNAL_EVENT_PROCESSOR_H
-
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/integration-api/debug.h>
+#include <dali/internal/event/common/stage-impl.h>
+#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/event/events/actor-gesture-data.h>
#include <dali/internal/event/events/gesture-event-processor.h>
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/common/stage-impl.h>
namespace Dali
{
-
namespace Internal
{
-
-GestureDetector::GestureDetector( GestureType::Value type, const SceneGraph::PropertyOwner* sceneObject )
-: Object( sceneObject ),
- mType( type ),
- mGestureEventProcessor( ThreadLocalStorage::Get().GetGestureEventProcessor() )
+GestureDetector::GestureDetector(GestureType::Value type, const SceneGraph::PropertyOwner* sceneObject)
+: Object(sceneObject),
+ mType(type),
+ mGestureEventProcessor(ThreadLocalStorage::Get().GetGestureEventProcessor())
{
}
GestureDetector::~GestureDetector()
{
- if ( !mPendingAttachActors.empty() )
+ if(!mPendingAttachActors.empty())
{
- for ( GestureDetectorActorContainer::iterator iter = mPendingAttachActors.begin(), endIter = mPendingAttachActors.end(); iter != endIter; ++iter )
+ for(GestureDetectorActorContainer::iterator iter = mPendingAttachActors.begin(), endIter = mPendingAttachActors.end(); iter != endIter; ++iter)
{
- Actor* actor( *iter );
- actor->RemoveObserver( *this );
- actor->GetGestureData().RemoveGestureDetector( *this );
+ Actor* actor(*iter);
+ actor->RemoveObserver(*this);
+ actor->GetGestureData().RemoveGestureDetector(*this);
}
mPendingAttachActors.clear();
}
- if ( !mAttachedActors.empty() )
+ if(!mAttachedActors.empty())
{
- for ( GestureDetectorActorContainer::iterator iter = mAttachedActors.begin(), endIter = mAttachedActors.end(); iter != endIter; ++iter )
+ for(GestureDetectorActorContainer::iterator iter = mAttachedActors.begin(), endIter = mAttachedActors.end(); iter != endIter; ++iter)
{
- Actor* actor( *iter );
- actor->RemoveObserver( *this );
- actor->GetGestureData().RemoveGestureDetector( *this );
+ Actor* actor(*iter);
+ actor->RemoveObserver(*this);
+ actor->GetGestureData().RemoveGestureDetector(*this);
}
mAttachedActors.clear();
// Guard to allow handle destruction after Core has been destroyed
- if ( Stage::IsInstalled() )
+ if(Stage::IsInstalled())
{
- mGestureEventProcessor.RemoveGestureDetector( this );
+ mGestureEventProcessor.RemoveGestureDetector(this);
}
}
}
-void GestureDetector::Attach( Actor& actor )
+void GestureDetector::Attach(Actor& actor)
{
- if ( !IsAttached( actor ) )
+ if(!IsAttached(actor))
{
- if( actor.OnScene() )
+ if(actor.OnScene())
{
// Register with EventProcessor if first actor being added
- if( mAttachedActors.empty() )
+ if(mAttachedActors.empty())
{
- mGestureEventProcessor.AddGestureDetector( this, actor.GetScene() );
+ mGestureEventProcessor.AddGestureDetector(this, actor.GetScene());
}
- mAttachedActors.push_back( &actor );
+ mAttachedActors.push_back(&actor);
// We need to observe the actor's destruction
- actor.AddObserver( *this );
+ actor.AddObserver(*this);
// Add the detector to the actor (so the actor knows it requires this gesture when going through hit-test algorithm)
- actor.GetGestureData().AddGestureDetector( *this );
+ actor.GetGestureData().AddGestureDetector(*this);
// Notification for derived classes
- OnActorAttach( actor );
+ OnActorAttach(actor);
}
else
{
- actor.AddObserver( *this );
+ actor.AddObserver(*this);
// Add the detector to the actor (so the actor knows it requires this gesture when going through hit-test algorithm)
- actor.GetGestureData().AddGestureDetector( *this );
+ actor.GetGestureData().AddGestureDetector(*this);
- mPendingAttachActors.push_back( &actor );
+ mPendingAttachActors.push_back(&actor);
}
}
}
-void GestureDetector::SceneObjectAdded( Object& object )
+void GestureDetector::SceneObjectAdded(Object& object)
{
- Actor& actor = dynamic_cast< Actor& >( object );
+ Actor& actor = dynamic_cast<Actor&>(object);
// Make sure the actor has not already been attached. Can't use IsAttached() as that checks the pending list as well
- if( find(mAttachedActors.begin(), mAttachedActors.end(), &actor) == mAttachedActors.end() )
+ if(find(mAttachedActors.begin(), mAttachedActors.end(), &actor) == mAttachedActors.end())
{
GestureDetectorActorContainer::iterator match = find(mPendingAttachActors.begin(), mPendingAttachActors.end(), &actor);
- if ( match != mPendingAttachActors.end() )
+ if(match != mPendingAttachActors.end())
{
mPendingAttachActors.erase(match);
// Register with EventProcessor if first actor being added
- if( mAttachedActors.empty() )
+ if(mAttachedActors.empty())
{
- mGestureEventProcessor.AddGestureDetector( this, actor.GetScene() );
+ mGestureEventProcessor.AddGestureDetector(this, actor.GetScene());
}
- mAttachedActors.push_back( &actor );
+ mAttachedActors.push_back(&actor);
// Notification for derived classes
- OnActorAttach( actor );
+ OnActorAttach(actor);
}
else
{
// Actor was not in the pending list
- DALI_ASSERT_DEBUG( false );
+ DALI_ASSERT_DEBUG(false);
}
}
else
{
// Check if actor has been attached and is still in the pending list - this would not be correct
- DALI_ASSERT_DEBUG( find(mPendingAttachActors.begin(), mPendingAttachActors.end(), &actor) == mPendingAttachActors.end() );
+ DALI_ASSERT_DEBUG(find(mPendingAttachActors.begin(), mPendingAttachActors.end(), &actor) == mPendingAttachActors.end());
}
}
void GestureDetector::Detach(Actor& actor)
{
- if ( !mPendingAttachActors.empty() )
+ if(!mPendingAttachActors.empty())
{
GestureDetectorActorContainer::iterator match = find(mPendingAttachActors.begin(), mPendingAttachActors.end(), &actor);
- if ( match != mPendingAttachActors.end() )
+ if(match != mPendingAttachActors.end())
{
// We no longer need to observe the actor's destruction
actor.RemoveObserver(*this);
// Remove detector from actor-gesture-data
- actor.GetGestureData().RemoveGestureDetector( *this );
+ actor.GetGestureData().RemoveGestureDetector(*this);
mPendingAttachActors.erase(match);
}
}
- if ( !mAttachedActors.empty() )
+ if(!mAttachedActors.empty())
{
GestureDetectorActorContainer::iterator match = find(mAttachedActors.begin(), mAttachedActors.end(), &actor);
- if ( match != mAttachedActors.end() )
+ if(match != mAttachedActors.end())
{
// We no longer need to observe the actor's destruction
actor.RemoveObserver(*this);
// Remove detector from actor-gesture-data
- actor.GetGestureData().RemoveGestureDetector( *this );
+ actor.GetGestureData().RemoveGestureDetector(*this);
mAttachedActors.erase(match);
OnActorDetach(actor);
// Unregister from gesture event processor if we do not have any actors
- if ( mAttachedActors.empty() )
+ if(mAttachedActors.empty())
{
// Guard to allow handle destruction after Core has been destroyed
- if( Stage::IsInstalled() )
+ if(Stage::IsInstalled())
{
mGestureEventProcessor.RemoveGestureDetector(this);
}
void GestureDetector::DetachAll()
{
- if ( !mPendingAttachActors.empty() )
+ if(!mPendingAttachActors.empty())
{
GestureDetectorActorContainer pendingActors(mPendingAttachActors);
mPendingAttachActors.clear();
- for ( GestureDetectorActorContainer::iterator iter = pendingActors.begin(), endIter = pendingActors.end(); iter != endIter; ++iter )
+ for(GestureDetectorActorContainer::iterator iter = pendingActors.begin(), endIter = pendingActors.end(); iter != endIter; ++iter)
{
Actor* actor(*iter);
actor->RemoveObserver(*this);
// Remove detector from actor-gesture-data
- actor->GetGestureData().RemoveGestureDetector( *this );
+ actor->GetGestureData().RemoveGestureDetector(*this);
}
}
- if ( !mAttachedActors.empty() )
+ if(!mAttachedActors.empty())
{
GestureDetectorActorContainer attachedActors(mAttachedActors);
// Clear mAttachedActors before we call OnActorDetach in case derived classes call a method which manipulates mAttachedActors.
mAttachedActors.clear();
- for ( GestureDetectorActorContainer::iterator iter = attachedActors.begin(), endIter = attachedActors.end(); iter != endIter; ++iter )
+ for(GestureDetectorActorContainer::iterator iter = attachedActors.begin(), endIter = attachedActors.end(); iter != endIter; ++iter)
{
Actor* actor(*iter);
actor->RemoveObserver(*this);
// Remove detector from actor-gesture-data
- actor->GetGestureData().RemoveGestureDetector( *this );
+ actor->GetGestureData().RemoveGestureDetector(*this);
// Notification for derived classes
OnActorDetach(*actor);
}
// Guard to allow handle destruction after Core has been destroyed
- if ( Stage::IsInstalled() )
+ if(Stage::IsInstalled())
{
// Unregister from gesture event processor
mGestureEventProcessor.RemoveGestureDetector(this);
{
Dali::Actor actor;
- if( index < mPendingAttachActors.size() )
+ if(index < mPendingAttachActors.size())
{
- actor = Dali::Actor( mPendingAttachActors[index] );
+ actor = Dali::Actor(mPendingAttachActors[index]);
}
- else if( index < mPendingAttachActors.size() + mAttachedActors.size() )
+ else if(index < mPendingAttachActors.size() + mAttachedActors.size())
{
- actor = Dali::Actor( mAttachedActors[index - mPendingAttachActors.size()] );
+ actor = Dali::Actor(mAttachedActors[index - mPendingAttachActors.size()]);
}
return actor;
bool GestureDetector::IsAttached(Actor& actor) const
{
- return ( find(mPendingAttachActors.begin(), mPendingAttachActors.end(), &actor) != mPendingAttachActors.end() ) ||
- ( find(mAttachedActors.begin(), mAttachedActors.end(), &actor) != mAttachedActors.end() );
+ return (find(mPendingAttachActors.begin(), mPendingAttachActors.end(), &actor) != mPendingAttachActors.end()) ||
+ (find(mAttachedActors.begin(), mAttachedActors.end(), &actor) != mAttachedActors.end());
}
void GestureDetector::ObjectDestroyed(Object& object)
{
- if ( !mPendingAttachActors.empty() )
+ if(!mPendingAttachActors.empty())
{
GestureDetectorActorContainer::iterator match = find(mPendingAttachActors.begin(), mPendingAttachActors.end(), &object);
- if ( match != mPendingAttachActors.end() )
+ if(match != mPendingAttachActors.end())
{
mPendingAttachActors.erase(match);
}
}
- if ( !mAttachedActors.empty() )
+ if(!mAttachedActors.empty())
{
GestureDetectorActorContainer::iterator match = find(mAttachedActors.begin(), mAttachedActors.end(), &object);
- if ( match != mAttachedActors.end() )
+ if(match != mAttachedActors.end())
{
mAttachedActors.erase(match);
OnActorDestroyed(object);
// Unregister from gesture event processor if we do not have any actors
- if ( mAttachedActors.empty() )
+ if(mAttachedActors.empty())
{
// Guard to allow handle destruction after Core has been destroyed
- if ( Stage::IsInstalled() )
+ if(Stage::IsInstalled())
{
mGestureEventProcessor.RemoveGestureDetector(this);
}
#define DALI_INTERNAL_GESTURE_DETECTOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/internal/event/actors/actor-impl.h>
#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/events/gesture-detector.h>
#include <dali/public-api/events/gesture.h>
#include <dali/public-api/signals/slot-delegate.h>
-#include <dali/public-api/events/gesture-detector.h>
-#include <dali/internal/event/actors/actor-impl.h>
namespace Dali
{
-
namespace Integration
{
struct GestureEvent;
namespace Internal
{
-
class GestureDetector;
class GestureEventProcessor;
/**
* This is a type trait that should be used by deriving gesture detectors for their container type.
*/
-template< typename Detector >
+template<typename Detector>
struct DerivedGestureDetectorContainer
{
using type = std::vector<Detector*>;
class GestureDetector : public Object, public Object::Observer
{
public:
-
/**
* @copydoc Dali::GestureDetector::Attach()
*/
bool IsAttached(Actor& actor) const;
protected: // Creation & Destruction
-
/**
* Construct a new GestureDetector.
* @param type the type of gesture
* @param pointer to the scene object, nullptr if none
* by default GestureDetectors don't have our own scene object
*/
- GestureDetector( GestureType::Value type, const SceneGraph::PropertyOwner* sceneObject = nullptr );
+ GestureDetector(GestureType::Value type, const SceneGraph::PropertyOwner* sceneObject = nullptr);
/**
* A reference counted object may only be deleted by calling Unreference()
~GestureDetector() override;
private:
-
// Undefined
- GestureDetector() = delete;
+ GestureDetector() = delete;
GestureDetector(const GestureDetector&) = delete;
GestureDetector& operator=(const GestureDetector& rhs) = delete;
/**
* @copydoc Dali::Internal::Object::Observer::SceneObjectAdded()
*/
- void SceneObjectRemoved(Object& object) override {}
+ void SceneObjectRemoved(Object& object) override
+ {
+ }
/**
* @copydoc Dali::Internal::Object::Observer::ObjectDestroyed()
virtual void OnActorDestroyed(Object& object) = 0;
protected:
-
GestureType::Value mType; ///< The gesture detector will detect this type of gesture.
GestureDetectorActorContainer mAttachedActors; ///< Object::Observer is used to provide weak-pointer behaviour
GestureDetectorActorContainer mPendingAttachActors; ///< Object::Observer is used to provide weak-pointer behaviour
inline Internal::GestureDetector& GetImplementation(Dali::GestureDetector& detector)
{
- DALI_ASSERT_ALWAYS( detector && "GestureDetector handle is empty" );
+ DALI_ASSERT_ALWAYS(detector && "GestureDetector handle is empty");
BaseObject& handle = detector.GetBaseObject();
inline const Internal::GestureDetector& GetImplementation(const Dali::GestureDetector& detector)
{
- DALI_ASSERT_ALWAYS( detector && "GestureDetector handle is empty" );
+ DALI_ASSERT_ALWAYS(detector && "GestureDetector handle is empty");
const BaseObject& handle = detector.GetBaseObject();
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#endif
// INTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
#include <dali/integration-api/render-controller.h>
#include <dali/internal/event/common/stage-impl.h>
+#include <dali/internal/event/events/pan-gesture/pan-gesture-impl.h>
#include <dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.h>
#include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
-#include <dali/internal/event/events/pan-gesture/pan-gesture-impl.h>
-#include <dali/integration-api/debug.h>
-
namespace Dali
{
-
namespace Internal
{
-GestureEventProcessor::GestureEventProcessor( SceneGraph::UpdateManager& updateManager, Integration::RenderController& renderController )
+GestureEventProcessor::GestureEventProcessor(SceneGraph::UpdateManager& updateManager, Integration::RenderController& renderController)
: mLongPressGestureProcessor(),
- mPanGestureProcessor( updateManager ),
+ mPanGestureProcessor(updateManager),
mPinchGestureProcessor(),
mTapGestureProcessor(),
mRotationGestureProcessor(),
- mRenderController( renderController ),
+ mRenderController(renderController),
envOptionMinimumPanDistance(-1),
envOptionMinimumPanEvents(-1)
{
GestureEventProcessor::~GestureEventProcessor() = default;
-void GestureEventProcessor::ProcessTouchEvent( Scene& scene, const Integration::TouchEvent& event)
+void GestureEventProcessor::ProcessTouchEvent(Scene& scene, const Integration::TouchEvent& event)
{
mLongPressGestureProcessor.ProcessTouch(scene, event);
mPanGestureProcessor.ProcessTouch(scene, event);
void GestureEventProcessor::AddGestureDetector(GestureDetector* gestureDetector, Scene& scene)
{
- switch (gestureDetector->GetType())
+ switch(gestureDetector->GetType())
{
case GestureType::LONG_PRESS:
{
void GestureEventProcessor::RemoveGestureDetector(GestureDetector* gestureDetector)
{
- switch (gestureDetector->GetType())
+ switch(gestureDetector->GetType())
{
case GestureType::LONG_PRESS:
{
void GestureEventProcessor::GestureDetectorUpdated(GestureDetector* gestureDetector)
{
- switch (gestureDetector->GetType())
+ switch(gestureDetector->GetType())
{
case GestureType::LONG_PRESS:
{
}
}
-void GestureEventProcessor::SetGestureProperties( const Dali::Gesture& gesture )
+void GestureEventProcessor::SetGestureProperties(const Dali::Gesture& gesture)
{
- DALI_ASSERT_DEBUG( gesture.GetType() == GestureType::PAN && "Only PanGesture has a scene object\n" );
+ DALI_ASSERT_DEBUG(gesture.GetType() == GestureType::PAN && "Only PanGesture has a scene object\n");
- const Dali::PanGesture& pan = static_cast< const Dali::PanGesture& >( gesture );
- if( mPanGestureProcessor.SetPanGestureProperties( pan ) )
+ const Dali::PanGesture& pan = static_cast<const Dali::PanGesture&>(gesture);
+ if(mPanGestureProcessor.SetPanGestureProperties(pan))
{
// We may not be updating so we need to ask the render controller for an update.
- mRenderController.RequestUpdate( false );
+ mRenderController.RequestUpdate(false);
}
}
mPanGestureProcessor.SetPredictionMode(mode);
}
-void GestureEventProcessor::SetPanGesturePredictionAmount( uint32_t amount )
+void GestureEventProcessor::SetPanGesturePredictionAmount(uint32_t amount)
{
mPanGestureProcessor.SetPredictionAmount(amount);
}
-void GestureEventProcessor::SetPanGestureMaximumPredictionAmount( uint32_t amount )
+void GestureEventProcessor::SetPanGestureMaximumPredictionAmount(uint32_t amount)
{
mPanGestureProcessor.SetMaximumPredictionAmount(amount);
}
-void GestureEventProcessor::SetPanGestureMinimumPredictionAmount( uint32_t amount )
+void GestureEventProcessor::SetPanGestureMinimumPredictionAmount(uint32_t amount)
{
mPanGestureProcessor.SetMinimumPredictionAmount(amount);
}
-void GestureEventProcessor::SetPanGesturePredictionAmountAdjustment( uint32_t amount )
+void GestureEventProcessor::SetPanGesturePredictionAmountAdjustment(uint32_t amount)
{
mPanGestureProcessor.SetPredictionAmountAdjustment(amount);
}
-void GestureEventProcessor::SetPanGestureSmoothingMode( int32_t mode )
+void GestureEventProcessor::SetPanGestureSmoothingMode(int32_t mode)
{
mPanGestureProcessor.SetSmoothingMode(mode);
}
-void GestureEventProcessor::SetPanGestureSmoothingAmount( float amount )
+void GestureEventProcessor::SetPanGestureSmoothingAmount(float amount)
{
mPanGestureProcessor.SetSmoothingAmount(amount);
}
-void GestureEventProcessor::SetPanGestureUseActualTimes( bool value )
+void GestureEventProcessor::SetPanGestureUseActualTimes(bool value)
{
- mPanGestureProcessor.SetUseActualTimes( value );
+ mPanGestureProcessor.SetUseActualTimes(value);
}
-void GestureEventProcessor::SetPanGestureInterpolationTimeRange( int32_t value )
+void GestureEventProcessor::SetPanGestureInterpolationTimeRange(int32_t value)
{
- mPanGestureProcessor.SetInterpolationTimeRange( value );
+ mPanGestureProcessor.SetInterpolationTimeRange(value);
}
-void GestureEventProcessor::SetPanGestureScalarOnlyPredictionEnabled( bool value )
+void GestureEventProcessor::SetPanGestureScalarOnlyPredictionEnabled(bool value)
{
- mPanGestureProcessor.SetScalarOnlyPredictionEnabled( value );
+ mPanGestureProcessor.SetScalarOnlyPredictionEnabled(value);
}
-void GestureEventProcessor::SetPanGestureTwoPointPredictionEnabled( bool value )
+void GestureEventProcessor::SetPanGestureTwoPointPredictionEnabled(bool value)
{
- mPanGestureProcessor.SetTwoPointPredictionEnabled( value );
+ mPanGestureProcessor.SetTwoPointPredictionEnabled(value);
}
-void GestureEventProcessor::SetPanGestureTwoPointInterpolatePastTime( int value )
+void GestureEventProcessor::SetPanGestureTwoPointInterpolatePastTime(int value)
{
- mPanGestureProcessor.SetTwoPointInterpolatePastTime( value );
+ mPanGestureProcessor.SetTwoPointInterpolatePastTime(value);
}
-void GestureEventProcessor::SetPanGestureTwoPointVelocityBias( float value )
+void GestureEventProcessor::SetPanGestureTwoPointVelocityBias(float value)
{
- mPanGestureProcessor.SetTwoPointVelocityBias( value );
+ mPanGestureProcessor.SetTwoPointVelocityBias(value);
}
-void GestureEventProcessor::SetPanGestureTwoPointAccelerationBias( float value )
+void GestureEventProcessor::SetPanGestureTwoPointAccelerationBias(float value)
{
- mPanGestureProcessor.SetTwoPointAccelerationBias( value );
+ mPanGestureProcessor.SetTwoPointAccelerationBias(value);
}
-void GestureEventProcessor::SetPanGestureMultitapSmoothingRange( int32_t value )
+void GestureEventProcessor::SetPanGestureMultitapSmoothingRange(int32_t value)
{
- mPanGestureProcessor.SetMultitapSmoothingRange( value );
+ mPanGestureProcessor.SetMultitapSmoothingRange(value);
}
-void GestureEventProcessor::SetPanGestureMinimumDistance( int32_t value )
+void GestureEventProcessor::SetPanGestureMinimumDistance(int32_t value)
{
- envOptionMinimumPanDistance = value;
+ envOptionMinimumPanDistance = value;
}
-void GestureEventProcessor::SetPanGestureMinimumPanEvents( int32_t value )
+void GestureEventProcessor::SetPanGestureMinimumPanEvents(int32_t value)
{
envOptionMinimumPanEvents = value;
}
-void GestureEventProcessor::SetPinchGestureMinimumDistance( float value)
+void GestureEventProcessor::SetPinchGestureMinimumDistance(float value)
{
- mPinchGestureProcessor.SetMinimumPinchDistance( value );
+ mPinchGestureProcessor.SetMinimumPinchDistance(value);
}
-void GestureEventProcessor::SetPinchGestureMinimumTouchEvents( uint32_t value )
+void GestureEventProcessor::SetPinchGestureMinimumTouchEvents(uint32_t value)
{
- mPinchGestureProcessor.SetMinimumTouchEvents( value );
+ mPinchGestureProcessor.SetMinimumTouchEvents(value);
}
-void GestureEventProcessor::SetPinchGestureMinimumTouchEventsAfterStart( uint32_t value )
+void GestureEventProcessor::SetPinchGestureMinimumTouchEventsAfterStart(uint32_t value)
{
- mPinchGestureProcessor.SetMinimumTouchEventsAfterStart( value );
+ mPinchGestureProcessor.SetMinimumTouchEventsAfterStart(value);
}
-void GestureEventProcessor::SetRotationGestureMinimumTouchEvents( uint32_t value )
+void GestureEventProcessor::SetRotationGestureMinimumTouchEvents(uint32_t value)
{
- mRotationGestureProcessor.SetMinimumTouchEvents( value );
+ mRotationGestureProcessor.SetMinimumTouchEvents(value);
}
-void GestureEventProcessor::SetRotationGestureMinimumTouchEventsAfterStart( uint32_t value )
+void GestureEventProcessor::SetRotationGestureMinimumTouchEventsAfterStart(uint32_t value)
{
- mRotationGestureProcessor.SetMinimumTouchEventsAfterStart( value );
+ mRotationGestureProcessor.SetMinimumTouchEventsAfterStart(value);
}
-void GestureEventProcessor::SetLongPressMinimumHoldingTime( uint32_t value )
+void GestureEventProcessor::SetLongPressMinimumHoldingTime(uint32_t value)
{
- mLongPressGestureProcessor.SetMinimumHoldingTime( value );
+ mLongPressGestureProcessor.SetMinimumHoldingTime(value);
}
uint32_t GestureEventProcessor::GetLongPressMinimumHoldingTime() const
#define DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/actors/actor.h>
-#include <dali/public-api/events/gesture.h>
#include <dali/internal/event/events/gesture-detector-impl.h>
#include <dali/internal/event/events/long-press-gesture/long-press-gesture-processor.h>
#include <dali/internal/event/events/pan-gesture/pan-gesture-processor.h>
#include <dali/internal/event/events/pinch-gesture/pinch-gesture-processor.h>
#include <dali/internal/event/events/rotation-gesture/rotation-gesture-processor.h>
#include <dali/internal/event/events/tap-gesture/tap-gesture-processor.h>
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/events/gesture.h>
namespace Dali
{
-
namespace Integration
{
-
class RenderController;
}
namespace Internal
{
-
class Stage;
class Scene;
class GestureEventProcessor
{
public:
-
/**
* Create a gesture event processor.
* @param[in] updateManager The update manager
* @param[in] renderController The render controller
*/
- GestureEventProcessor( SceneGraph::UpdateManager& updateManager, Integration::RenderController& renderController );
+ GestureEventProcessor(SceneGraph::UpdateManager& updateManager, Integration::RenderController& renderController);
/**
* Non-virtual destructor; GestureProcessor is not a base class
~GestureEventProcessor();
public: // To be called by EventProcessor
-
/**
* This function is called by Core whenever a touch event occurs
* @param[in] scene The scene
* @param[in] event The event that has occurred
*/
- void ProcessTouchEvent( Scene& scene, const Integration::TouchEvent& event);
+ void ProcessTouchEvent(Scene& scene, const Integration::TouchEvent& event);
public: // To be called by gesture detectors
-
/**
* This method adds the specified gesture detector to the relevant gesture processor.
* @param[in] gestureDetector The gesture detector to add
* @param[in] gesture The gesture whose values will be used in the Update object.
* @note If we are in the middle of processing the gesture being set, then this call is ignored.
*/
- void SetGestureProperties( const Dali::Gesture& gesture );
+ void SetGestureProperties(const Dali::Gesture& gesture);
public: // Called by Core
-
/**
* Returns true if any GestureDetector requires a Core::Update. Clears
* the state flag after reading.
*
* @param[in] mode The prediction mode to use
*/
- void SetPanGesturePredictionMode( int32_t mode );
+ void SetPanGesturePredictionMode(int32_t mode);
/**
* @brief Sets the prediction amount of the pan gesture
*
* @param[in] amount The prediction amount in milliseconds
*/
- void SetPanGesturePredictionAmount( uint32_t amount );
+ void SetPanGesturePredictionAmount(uint32_t amount);
/**
* @brief Sets the upper bound of the prediction amount for clamping
*
* @param[in] amount The prediction amount in milliseconds
*/
- void SetPanGestureMaximumPredictionAmount( uint32_t amount );
+ void SetPanGestureMaximumPredictionAmount(uint32_t amount);
/**
* @brief Sets the lower bound of the prediction amount for clamping
*
* @param[in] amount The prediction amount in milliseconds
*/
- void SetPanGestureMinimumPredictionAmount( uint32_t amount );
+ void SetPanGestureMinimumPredictionAmount(uint32_t amount);
/**
* @brief Sets the prediction amount to adjust when the pan velocity is changed.
*
* @param[in] amount The prediction amount in milliseconds
*/
- void SetPanGesturePredictionAmountAdjustment( uint32_t amount );
+ void SetPanGesturePredictionAmountAdjustment(uint32_t amount);
/**
* @brief Called to set how pan gestures smooth input
*
* @param[in] mode The smoothing mode to use
*/
- void SetPanGestureSmoothingMode( int32_t mode );
+ void SetPanGestureSmoothingMode(int32_t mode);
/**
* @brief Sets the prediction amount of the pan gesture
*
* @param[in] amount The smoothing amount [0.0f,1.0f] - 0.0f would be no smoothing, 1.0f maximum smoothing
*/
- void SetPanGestureSmoothingAmount( float amount );
+ void SetPanGestureSmoothingAmount(float amount);
/*
* @brief Sets whether to use actual times of the real gesture and frames or not.
*
* @param[in] value True = use actual times, False = use perfect values
*/
- void SetPanGestureUseActualTimes( bool value );
+ void SetPanGestureUseActualTimes(bool value);
/**
* @brief Sets the interpolation time range (ms) of past points to use (with weights) when interpolating.
*
* @param[in] value Time range in ms
*/
- void SetPanGestureInterpolationTimeRange( int32_t value );
+ void SetPanGestureInterpolationTimeRange(int32_t value);
/**
* @brief Sets whether to use scalar only prediction, which when enabled, ignores acceleration.
*
* @param[in] value True = use scalar prediction only
*/
- void SetPanGestureScalarOnlyPredictionEnabled( bool value );
+ void SetPanGestureScalarOnlyPredictionEnabled(bool value);
/**
* @brief Sets whether to use two point prediction. This combines two interpolated points to get more steady acceleration and velocity values.
*
* @param[in] value True = use two point prediction
*/
- void SetPanGestureTwoPointPredictionEnabled( bool value );
+ void SetPanGestureTwoPointPredictionEnabled(bool value);
/**
* @brief Sets the time in the past to interpolate the second point when using two point interpolation.
*
* @param[in] value Time in past in ms
*/
- void SetPanGestureTwoPointInterpolatePastTime( int32_t value );
+ void SetPanGestureTwoPointInterpolatePastTime(int32_t value);
/**
* @brief Sets the two point velocity bias. This is the ratio of first and second points to use for velocity.
*
* @param[in] value 0.0f = 100% first point. 1.0f = 100% of second point.
*/
- void SetPanGestureTwoPointVelocityBias( float value );
+ void SetPanGestureTwoPointVelocityBias(float value);
/**
* @brief Sets the two point acceleration bias. This is the ratio of first and second points to use for acceleration.
*
* @param[in] value 0.0f = 100% first point. 1.0f = 100% of second point.
*/
- void SetPanGestureTwoPointAccelerationBias( float value );
+ void SetPanGestureTwoPointAccelerationBias(float value);
/**
* @brief Sets the range of time (ms) of points in the history to perform multitap smoothing with (if enabled).
*
* @param[in] value Time in past in ms
*/
- void SetPanGestureMultitapSmoothingRange( int32_t value );
+ void SetPanGestureMultitapSmoothingRange(int32_t value);
/**
* @brief Sets the minimum distance required to start a pan event
*
* @param[in] value Distance in pixels
*/
- void SetPanGestureMinimumDistance( int32_t value );
+ void SetPanGestureMinimumDistance(int32_t value);
/**
* @brief Sets the minimum number of touch events required to start a pan
*
* @param[in] value Number of touch events
*/
- void SetPanGestureMinimumPanEvents( int32_t value );
+ void SetPanGestureMinimumPanEvents(int32_t value);
/**
* @brief Sets the minimum distance required to start a pinch event
*
* @param[in] value Distance in pixels
*/
- void SetPinchGestureMinimumDistance( float value);
+ void SetPinchGestureMinimumDistance(float value);
/**
* @brief Sets the minimum touch events required before a pinch can be started
*
* @param[in] value The number of touch events
*/
- void SetPinchGestureMinimumTouchEvents( uint32_t value );
+ void SetPinchGestureMinimumTouchEvents(uint32_t value);
/**
* @brief Sets the minimum touch events required after a pinch started
*
* @param[in] value The number of touch events
*/
- void SetPinchGestureMinimumTouchEventsAfterStart( uint32_t value );
+ void SetPinchGestureMinimumTouchEventsAfterStart(uint32_t value);
/**
* @brief Sets the minimum touch events required before a rotation can be started
*
* @param[in] value The number of touch events
*/
- void SetRotationGestureMinimumTouchEvents( uint32_t value );
+ void SetRotationGestureMinimumTouchEvents(uint32_t value);
/**
* @brief Sets the minimum touch events required after a rotation started
*
* @param[in] value The number of touch events
*/
- void SetRotationGestureMinimumTouchEventsAfterStart( uint32_t value );
+ void SetRotationGestureMinimumTouchEventsAfterStart(uint32_t value);
/**
* @brief Sets the minimum holding time required to be recognized as a long press gesture
*
* @param[in] value The time value in milliseconds
*/
- void SetLongPressMinimumHoldingTime( uint32_t value );
+ void SetLongPressMinimumHoldingTime(uint32_t value);
/**
* @return The minimum holding time required to be recognized as a long press gesture in milliseconds
uint32_t GetLongPressMinimumHoldingTime() const;
public: // needed for PanGesture
-
/**
* @return the pan gesture processor
*/
const PanGestureProcessor& GetPanGestureProcessor();
private:
-
// Undefined
GestureEventProcessor(const GestureEventProcessor&);
GestureEventProcessor& operator=(const GestureEventProcessor& rhs);
private:
-
- LongPressGestureProcessor mLongPressGestureProcessor;
- PanGestureProcessor mPanGestureProcessor;
- PinchGestureProcessor mPinchGestureProcessor;
- TapGestureProcessor mTapGestureProcessor;
- RotationGestureProcessor mRotationGestureProcessor;
+ LongPressGestureProcessor mLongPressGestureProcessor;
+ PanGestureProcessor mPanGestureProcessor;
+ PinchGestureProcessor mPinchGestureProcessor;
+ TapGestureProcessor mTapGestureProcessor;
+ RotationGestureProcessor mRotationGestureProcessor;
Integration::RenderController& mRenderController;
int32_t envOptionMinimumPanDistance;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
GestureEvent::~GestureEvent() = default;
-GestureEvent::GestureEvent( GestureType::Value gesture, GestureState gestureState )
-: gestureType( gesture ),
- state( gestureState ),
- time( 0 )
+GestureEvent::GestureEvent(GestureType::Value gesture, GestureState gestureState)
+: gestureType(gesture),
+ state(gestureState),
+ time(0)
{
}
} // namespace Internal
#define DALI_INTERNAL_EVENT_GESTURE_EVENT_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* This is the abstract base structure for any gestures that the adaptor detects and wishes to send
* to the Core.
*/
uint32_t time;
-protected: // Constructors only to be used by derived structures.
-
+protected: // Constructors only to be used by derived structures.
/**
* This constructor is only used by derived classes.
* @param[in] gesture The type of gesture event.
* @param[in] gestureState The state of the gesture event.
*/
- GestureEvent( GestureType::Value gesture, GestureState gestureState);
+ GestureEvent(GestureType::Value gesture, GestureState gestureState);
};
} // namespace Internal
#define DALI_INTERNAL_GESTURE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/events/gesture.h>
#include <dali/integration-api/events/event.h>
+#include <dali/public-api/events/gesture.h>
#include <dali/public-api/object/base-object.h>
namespace Dali
{
-
namespace Internal
{
-
class Gesture;
using GesturePtr = IntrusivePtr<Gesture>;
class Gesture : public BaseObject
{
public:
-
/**
* @brief Get the gesture type.
*
* @brief Set the state of the gesture.
* @param[in] state The state of the gesture to set
*/
- inline void SetState( GestureState state )
+ inline void SetState(GestureState state)
{
mState = state;
}
- /**
+ /**
* @brief Get the state of the gesture.
*
* @return The state of the gesture.
* @brief Set The time the gesture took place.
* @param[in] time The time the gesture took place. to set
*/
- inline void SetTime( uint32_t time )
+ inline void SetTime(uint32_t time)
{
mTime = time;
}
return mTime;
}
- Gesture(const Gesture&) = delete; ///< Deleted copy constructor
- Gesture(Gesture&&) = delete; ///< Deleted move constructor
+ Gesture(const Gesture&) = delete; ///< Deleted copy constructor
+ Gesture(Gesture&&) = delete; ///< Deleted move constructor
Gesture& operator=(const Gesture&) = delete; ///< Deleted copy assignment operator
- Gesture& operator=(Gesture&&) = delete; ///< Deleted move assignment operator
+ Gesture& operator=(Gesture&&) = delete; ///< Deleted move assignment operator
protected:
-
/**
* This constructor is only used by derived classes.
* @param[in] gestureType The type of gesture event.
* @param[in] gestureState The state of the gesture event.
*/
Gesture(GestureType::Value gestureType, GestureState gestureState)
- : mGestureType( gestureType ),
- mState( gestureState )
+ : mGestureType(gestureType),
+ mState(gestureState)
{
}
private:
GestureType::Value mGestureType;
- GestureState mState;
- uint32_t mTime{0u};
+ GestureState mState;
+ uint32_t mTime{0u};
};
} // namespace Internal
*/
inline Internal::Gesture& GetImplementation(Dali::Gesture& gesture)
{
- DALI_ASSERT_ALWAYS( gesture && "gesture handle is empty" );
+ DALI_ASSERT_ALWAYS(gesture && "gesture handle is empty");
BaseObject& handle = gesture.GetBaseObject();
inline const Internal::Gesture& GetImplementation(const Dali::Gesture& gesture)
{
- DALI_ASSERT_ALWAYS( gesture && "gesture handle is empty" );
+ DALI_ASSERT_ALWAYS(gesture && "gesture handle is empty");
const BaseObject& handle = gesture.GetBaseObject();
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/actors/layer-impl.h>
#include <dali/internal/event/common/scene-impl.h>
-#include <dali/internal/event/events/hit-test-algorithm-impl.h>
#include <dali/internal/event/events/actor-gesture-data.h>
+#include <dali/internal/event/events/hit-test-algorithm-impl.h>
#include <dali/internal/event/events/ray-test.h>
#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
/**
* Functor to check whether an actor requires a particular gesture or not
*/
struct GestureHitTestCheck : public HitTestAlgorithm::HitTestInterface
{
- GestureHitTestCheck( GestureType::Value type )
- : mType( type )
+ GestureHitTestCheck(GestureType::Value type)
+ : mType(type)
{
}
- bool IsActorHittable( Actor* actor ) override
+ bool IsActorHittable(Actor* actor) override
{
- return actor->IsGestureRequired( mType ) && // Does the Application or derived actor type require the gesture?
- actor->IsHittable(); // Is actor sensitive, visible and on the scene?
+ return actor->IsGestureRequired(mType) && // Does the Application or derived actor type require the gesture?
+ actor->IsHittable(); // Is actor sensitive, visible and on the scene?
}
- bool DescendActorHierarchy( Actor* actor ) override
+ bool DescendActorHierarchy(Actor* actor) override
{
return actor->IsVisible() && // Actor is visible, if not visible then none of its children are visible.
actor->IsSensitive(); // Actor is sensitive, if insensitive none of its children should be hittable either.
}
- bool DoesLayerConsumeHit( Layer* layer ) override
+ bool DoesLayerConsumeHit(Layer* layer) override
{
return layer->IsTouchConsumed();
}
} // unnamed namespace
-
-GestureProcessor::GestureProcessor( GestureType::Value type )
+GestureProcessor::GestureProcessor(GestureType::Value type)
: mGestureRecognizer(),
- mNeedsUpdate( false ),
- mType( type ),
- mCurrentGesturedActor( nullptr ),
- mGesturedActorDisconnected( false )
+ mNeedsUpdate(false),
+ mType(type),
+ mCurrentGesturedActor(nullptr),
+ mGesturedActorDisconnected(false)
{
}
ResetActor();
}
-void GestureProcessor::ProcessTouch( Scene& scene, const Integration::TouchEvent& event )
+void GestureProcessor::ProcessTouch(Scene& scene, const Integration::TouchEvent& event)
{
- if( mGestureRecognizer )
+ if(mGestureRecognizer)
{
mGestureRecognizer->SendEvent(scene, event);
}
}
-void GestureProcessor::GetGesturedActor( Actor*& actor, GestureDetectorContainer& gestureDetectors )
+void GestureProcessor::GetGesturedActor(Actor*& actor, GestureDetectorContainer& gestureDetectors)
{
- while ( actor )
+ while(actor)
{
// We may be checking a parent so ensure the parent requires this gesture (and do not unintentionally create the gesture data for the parent)
- if ( actor->IsGestureRequired( mType ) )
+ if(actor->IsGestureRequired(mType))
{
// Retrieve the actor's detectors and check if they satisfy current gesture
- const GestureDetectorContainer& connectedDetectors( actor->GetGestureData().GetGestureDetectorContainer( mType ) );
- const GestureDetectorContainer::const_iterator endIter( connectedDetectors.end() );
- for ( GestureDetectorContainer::const_iterator iter = connectedDetectors.begin(); iter != endIter; ++iter )
+ const GestureDetectorContainer& connectedDetectors(actor->GetGestureData().GetGestureDetectorContainer(mType));
+ const GestureDetectorContainer::const_iterator endIter(connectedDetectors.end());
+ for(GestureDetectorContainer::const_iterator iter = connectedDetectors.begin(); iter != endIter; ++iter)
{
GestureDetector* current(*iter);
// Check deriving class for whether the current gesture satisfies the gesture detector's parameters.
- if ( CheckGestureDetector( current, actor ) )
+ if(CheckGestureDetector(current, actor))
{
gestureDetectors.push_back(current);
}
}
// The hit actor or one of the parents is a gestured actor, break out.
- if ( !gestureDetectors.empty() )
+ if(!gestureDetectors.empty())
{
break;
}
}
}
-void GestureProcessor::ProcessAndEmit( HitTestAlgorithm::Results& hitTestResults )
+void GestureProcessor::ProcessAndEmit(HitTestAlgorithm::Results& hitTestResults)
{
- if ( hitTestResults.actor )
+ if(hitTestResults.actor)
{
- Actor* hitTestActor( &GetImplementation( hitTestResults.actor ) );
- Actor* actor( hitTestActor );
+ Actor* hitTestActor(&GetImplementation(hitTestResults.actor));
+ Actor* actor(hitTestActor);
RayTest rayTest;
- while ( actor )
+ while(actor)
{
GestureDetectorContainer gestureDetectors;
- GetGesturedActor( actor, gestureDetectors );
+ GetGesturedActor(actor, gestureDetectors);
- if ( actor && !gestureDetectors.empty() )
+ if(actor && !gestureDetectors.empty())
{
// We have a match but check if the hit point is within the gestured actor's bounds.
// If it is not then continue up the actor hierarchy.
- if ( actor == hitTestActor )
+ if(actor == hitTestActor)
{
// Our gesture detector's attached actor WAS the hit actor so we can can emit the signal.
- EmitGestureSignal( actor, gestureDetectors, hitTestResults.actorCoordinates );
+ EmitGestureSignal(actor, gestureDetectors, hitTestResults.actorCoordinates);
break; // We have found AND emitted a signal on the gestured actor, break out.
}
else
{
- if ( actor->IsHittable() )
+ if(actor->IsHittable())
{
- const Vector3 size( actor->GetCurrentSize() );
+ const Vector3 size(actor->GetCurrentSize());
- if ( ( size.x > 0.0f ) && ( size.y > 0.0f ) )
+ if((size.x > 0.0f) && (size.y > 0.0f))
{
// Ensure tap is within the actor's area
- if ( rayTest.SphereTest( *actor, hitTestResults.rayOrigin, hitTestResults.rayDirection ) ) // Quick check
+ if(rayTest.SphereTest(*actor, hitTestResults.rayOrigin, hitTestResults.rayDirection)) // Quick check
{
Vector2 hitPointLocal;
- float distance( 0.0f );
- if( rayTest.ActorTest( *actor, hitTestResults.rayOrigin, hitTestResults.rayDirection, hitPointLocal, distance ) )
+ float distance(0.0f);
+ if(rayTest.ActorTest(*actor, hitTestResults.rayOrigin, hitTestResults.rayDirection, hitPointLocal, distance))
{
// One of the parents was the gestured actor so we can emit the signal for that actor.
- EmitGestureSignal( actor, gestureDetectors, hitPointLocal );
+ EmitGestureSignal(actor, gestureDetectors, hitPointLocal);
break; // We have found AND emitted a signal on the gestured actor, break out.
}
}
}
// Continue up hierarchy to see if any of the parents require this gesture.
- if ( actor )
+ if(actor)
{
actor = actor->GetParent();
}
}
}
-bool GestureProcessor::HitTest( Scene& scene, Vector2 screenCoordinates, HitTestAlgorithm::Results& hitTestResults )
+bool GestureProcessor::HitTest(Scene& scene, Vector2 screenCoordinates, HitTestAlgorithm::Results& hitTestResults)
{
- GestureHitTestCheck hitCheck( mType );
- HitTestAlgorithm::HitTest( scene.GetSize(), scene.GetRenderTaskList(), scene.GetLayerList(), screenCoordinates, hitTestResults, hitCheck );
+ GestureHitTestCheck hitCheck(mType);
+ HitTestAlgorithm::HitTest(scene.GetSize(), scene.GetRenderTaskList(), scene.GetLayerList(), screenCoordinates, hitTestResults, hitCheck);
return hitTestResults.renderTask && hitTestResults.actor;
}
-void GestureProcessor::SetActor( Actor* actor )
+void GestureProcessor::SetActor(Actor* actor)
{
- if ( actor && actor != mCurrentGesturedActor )
+ if(actor && actor != mCurrentGesturedActor)
{
ResetActor();
mCurrentGesturedActor = actor;
- mCurrentGesturedActor->AddObserver( *this );
+ mCurrentGesturedActor->AddObserver(*this);
}
mGesturedActorDisconnected = false;
}
void GestureProcessor::ResetActor()
{
- if ( mCurrentGesturedActor )
+ if(mCurrentGesturedActor)
{
- mCurrentGesturedActor->RemoveObserver( *this );
- mCurrentGesturedActor = nullptr;
+ mCurrentGesturedActor->RemoveObserver(*this);
+ mCurrentGesturedActor = nullptr;
mGesturedActorDisconnected = false;
}
}
void GestureProcessor::SceneObjectRemoved(Object& object)
{
- if ( mCurrentGesturedActor == &object &&
- !mGesturedActorDisconnected )
+ if(mCurrentGesturedActor == &object &&
+ !mGesturedActorDisconnected)
{
// Inform deriving classes.
OnGesturedActorStageDisconnection();
void GestureProcessor::ObjectDestroyed(Object& object)
{
- if ( mCurrentGesturedActor == &object )
+ if(mCurrentGesturedActor == &object)
{
// Inform deriving classes.
OnGesturedActorStageDisconnection();
#define DALI_INTERNAL_GESTURE_PROCESSOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/common/object-impl.h>
#include <dali/internal/event/events/gesture-detector-impl.h>
-#include <dali/internal/event/events/hit-test-algorithm-impl.h>
#include <dali/internal/event/events/gesture-recognizer.h>
-#include <dali/internal/event/common/object-impl.h>
+#include <dali/internal/event/events/hit-test-algorithm-impl.h>
namespace Dali
{
-
class Actor;
namespace Internal
{
-
/**
* Base class for the different Gesture Processors.
*/
class GestureProcessor : public Object::Observer
{
public:
-
/**
* Process the touch event in the attached recognizer
* @param[in] scene Scene.
* @param[in] event Touch event to process
*/
- void ProcessTouch( Scene& scene, const Integration::TouchEvent& event );
+ void ProcessTouch(Scene& scene, const Integration::TouchEvent& event);
/**
* Returns whether any GestureDetector requires a Core::Update
inline bool NeedsUpdate()
{
bool updateRequired = mNeedsUpdate;
- mNeedsUpdate = false;
+ mNeedsUpdate = false;
return updateRequired;
}
protected:
-
// Construction & Destruction
/**
* Protected constructor. Cannot create an instance of GestureProcessor
*/
- GestureProcessor( GestureType::Value type );
+ GestureProcessor(GestureType::Value type);
/**
* Virtual protected destructor.
* @note Uses CheckGestureDetector() to check if a the current gesture matches the criteria the gesture detector requires.
* @pre gestureDetectors should be empty.
*/
- void GetGesturedActor( Actor*& actor, GestureDetectorContainer& gestureDetectors );
+ void GetGesturedActor(Actor*& actor, GestureDetectorContainer& gestureDetectors);
/**
* Calls the emission method in the deriving class for matching gesture-detectors with the hit-actor (or one of its parents).
* and EmitGestureSignal() to emit the signal.
* @pre Hit Testing should already be done.
*/
- void ProcessAndEmit( HitTestAlgorithm::Results& hitTestResults );
+ void ProcessAndEmit(HitTestAlgorithm::Results& hitTestResults);
/**
* Hit test the screen coordinates, and place the results in hitTestResults.
* @param[out] hitTestResults Structure to write results into.
* @return false if the system overlay was hit or no actor was hit.
*/
- virtual bool HitTest( Scene& scene, Vector2 screenCoordinates, HitTestAlgorithm::Results& hitTestResults);
+ virtual bool HitTest(Scene& scene, Vector2 screenCoordinates, HitTestAlgorithm::Results& hitTestResults);
/**
* Sets the mCurrentGesturedActor and connects to the required signals.
* @actor actor The actor so set.
*/
- void SetActor( Actor* actor );
+ void SetActor(Actor* actor);
/**
* Resets the set actor and disconnects any connected signals.
Actor* GetCurrentGesturedActor();
private:
-
// For derived classes to override
/**
*
* @return true, if the detector meets the parameters, false otherwise.
*/
- virtual bool CheckGestureDetector( GestureDetector* detector, Actor* actor ) = 0;
+ virtual bool CheckGestureDetector(GestureDetector* detector, Actor* actor) = 0;
/**
* Called by the ProcessAndEmit() method when the gesture meets all applicable criteria and
* @param[in] gestureDetectors The detectors that should emit the signal.
* @param[in] actorCoordinates The local actor coordinates where the gesture took place.
*/
- virtual void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates ) = 0;
+ virtual void EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates) = 0;
// Undefined
- GestureProcessor( const GestureProcessor& );
- GestureProcessor& operator=( const GestureProcessor& );
+ GestureProcessor(const GestureProcessor&);
+ GestureProcessor& operator=(const GestureProcessor&);
// SceneObject overrides
* @param[in] object The object object.
* @see Object::Observer::SceneObjectAdded()
*/
- void SceneObjectAdded(Object& object) override { }
+ void SceneObjectAdded(Object& object) override
+ {
+ }
/**
* This will be called when the actor is removed from the stage, we should clear and stop
*/
void ObjectDestroyed(Object& object) override;
+protected: //Data
+ GestureRecognizerPtr mGestureRecognizer; ///< The gesture recognizer
+ bool mNeedsUpdate; ///< Indicates if any GestureDetector requires a Core::Update
-protected: //Data
-
- GestureRecognizerPtr mGestureRecognizer; ///< The gesture recognizer
- bool mNeedsUpdate; ///< Indicates if any GestureDetector requires a Core::Update
-
-private: // Data
-
- GestureType::Value mType; ///< Type of GestureProcessor
- Actor* mCurrentGesturedActor; ///< The current actor that has been gestured.
- bool mGesturedActorDisconnected:1; ///< Indicates whether the gestured actor has been disconnected from the scene
+private: // Data
+ GestureType::Value mType; ///< Type of GestureProcessor
+ Actor* mCurrentGesturedActor; ///< The current actor that has been gestured.
+ bool mGesturedActorDisconnected : 1; ///< Indicates whether the gestured actor has been disconnected from the scene
};
} // namespace Internal
#define DALI_INTERNAL_GESTURE_RECOGNIZER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
// EXTERNAL INCLUDES
+#include <dali/internal/event/events/gesture-event.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/events/gesture.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/object/ref-object.h>
-#include <dali/internal/event/events/gesture-event.h>
namespace Dali
{
-
namespace Integration
{
struct TouchEvent;
struct GestureRequest;
class Scene;
-template< typename T>
+template<typename T>
class RecognizerObserver
{
public:
- virtual void Process( Scene& scene, const T& event ) = 0;
+ virtual void Process(Scene& scene, const T& event) = 0;
virtual ~RecognizerObserver() = default;
;
};
-
/**
* Abstract Base class for all adaptor gesture detectors.
*
class GestureRecognizer : public RefObject
{
public:
-
/**
* Called when it gets a touch event. The gesture recognizer should
* evaluate this event along with previously received events to determine
* Returns the type of gesture detector.
* @return Type of gesture detector.
*/
- GestureType::Value GetType() const { return mType; }
+ GestureType::Value GetType() const
+ {
+ return mType;
+ }
/**
* Called when we get a touch event.
* @param[in] scene The scene the touch event has occurred on
* @param[in] event The latest touch event
*/
- void SendEvent( Scene& scene, const Integration::TouchEvent& event )
+ void SendEvent(Scene& scene, const Integration::TouchEvent& event)
{
mScene = &scene;
- SendEvent( event );
+ SendEvent(event);
}
protected:
-
/**
* Protected Constructor. Should only be able to create derived class objects.
* @param[in] screenSize The size of the screen.
* @param[in] detectorType The type of gesture detector.
*/
- GestureRecognizer( Vector2 screenSize, GestureType::Value detectorType )
- : mScreenSize( screenSize ),
- mType( detectorType ),
- mScene( nullptr )
+ GestureRecognizer(Vector2 screenSize, GestureType::Value detectorType)
+ : mScreenSize(screenSize),
+ mType(detectorType),
+ mScene(nullptr)
{
}
* Use this constructor with the screen size is not used in the dereived class.
* @param[in] detectorType The type of gesture detector.
*/
- GestureRecognizer( GestureType::Value detectorType )
- : GestureRecognizer( Vector2::ZERO, detectorType )
+ GestureRecognizer(GestureType::Value detectorType)
+ : GestureRecognizer(Vector2::ZERO, detectorType)
{
}
~GestureRecognizer() override = default;
protected:
- Vector2 mScreenSize;
+ Vector2 mScreenSize;
GestureType::Value mType;
- Scene* mScene;
+ Scene* mScene;
};
using GestureRecognizerPtr = IntrusivePtr<GestureRecognizer>;
#define DALI_INTERNAL_GESTURE_REQUESTS_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* This structure specifies the gesture type required (or no longer required) by Core.
*/
* Default Constructor
* @param[in] typeRequired The gesture type required
*/
- GestureRequest( GestureType::Value typeRequired )
- : type( typeRequired )
+ GestureRequest(GestureType::Value typeRequired)
+ : type(typeRequired)
{
}
#define DALI_INTERNAL_HIT_TEST_ALGORITHM_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/actors/actor.h>
#include <dali/devel-api/events/hit-test-algorithm.h>
#include <dali/internal/event/render-tasks/render-task-impl.h>
+#include <dali/public-api/actors/actor.h>
namespace Dali
{
-
namespace Internal
{
-
class Layer;
class LayerList;
*/
namespace HitTestAlgorithm
{
-
struct Results
{
RenderTaskPtr renderTask; ///< The render-task displaying the actor.
*
* @return true if actor is hittable, false otherwise.
*/
- virtual bool IsActorHittable( Actor* actor ) = 0;
+ virtual bool IsActorHittable(Actor* actor) = 0;
/**
* Called by the hit-test algorithm to determine whether the algorithm should descend the actor's
*
* @return true if we should descend the actor's hierarchy, false otherwise.
*/
- virtual bool DescendActorHierarchy( Actor* actor ) = 0;
+ virtual bool DescendActorHierarchy(Actor* actor) = 0;
/**
* Called by the hit-test algorithm to determine whether the layer specified consumes the hit
*
* @return true if the layer should consume the hit, false otherwise.
*/
- virtual bool DoesLayerConsumeHit( Layer* layer ) = 0;
+ virtual bool DoesLayerConsumeHit(Layer* layer) = 0;
protected:
-
/**
* Virtual destructor, no deletion through this interface
*/
virtual ~HitTestInterface();
-
};
/**
*
* @see HitTest(Stage&, const Vector2&, Results&, HitTestInterface&)
*/
-bool HitTest( const Vector2& sceneSize, RenderTaskList& renderTaskList, LayerList& layerList, const Vector2& screenCoordinates,
- Dali::HitTestAlgorithm::Results& results, Dali::HitTestAlgorithm::HitTestFunction func );
+bool HitTest(const Vector2& sceneSize, RenderTaskList& renderTaskList, LayerList& layerList, const Vector2& screenCoordinates, Dali::HitTestAlgorithm::Results& results, Dali::HitTestAlgorithm::HitTestFunction func);
/**
* Given screen coordinates, this method returns the hit actor & the local coordinates relative to the actor etc.
* @note Currently, we prefer a child hit over a parent (regardless of the distance from the
* camera) unless the parent is a RenderableActor but this is subject to change.
*/
-bool HitTest( const Vector2& sceneSize, RenderTaskList& renderTaskList, LayerList& layerList, const Vector2& screenCoordinates,
- Results& results, HitTestInterface& hitTestInterface );
+bool HitTest(const Vector2& sceneSize, RenderTaskList& renderTaskList, LayerList& layerList, const Vector2& screenCoordinates, Results& results, HitTestInterface& hitTestInterface);
/**
* Default HitTest where we check if a touch is required.
*
* @see HitTest(Stage&, const Vector2&, Results&, HitTestInterface&)
*/
-bool HitTest( const Vector2& sceneSize, RenderTaskList& renderTaskList, LayerList& layerList, const Vector2& screenCoordinates, Results& results );
+bool HitTest(const Vector2& sceneSize, RenderTaskList& renderTaskList, LayerList& layerList, const Vector2& screenCoordinates, Results& results);
} // namespace HitTestAlgorithm
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
HoverEvent::HoverEvent()
: mPoints(),
- mTime( 0 )
+ mTime(0)
{
}
-HoverEvent::HoverEvent( unsigned long time )
+HoverEvent::HoverEvent(unsigned long time)
: mPoints(),
- mTime( time )
+ mTime(time)
{
}
-HoverEventPtr HoverEvent::Clone( const HoverEvent& rhs )
+HoverEventPtr HoverEvent::Clone(const HoverEvent& rhs)
{
- HoverEventPtr hoverEvent( new HoverEvent );
+ HoverEventPtr hoverEvent(new HoverEvent);
hoverEvent->mPoints = rhs.mPoints;
- hoverEvent->mTime = rhs.mTime;
+ hoverEvent->mTime = rhs.mTime;
return hoverEvent;
}
return mPoints.size();
}
-int32_t HoverEvent::GetDeviceId( std::size_t point ) const
+int32_t HoverEvent::GetDeviceId(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetDeviceId();
+ return mPoints[point].GetDeviceId();
}
return -1;
}
-PointState::Type HoverEvent::GetState( std::size_t point ) const
+PointState::Type HoverEvent::GetState(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetState();
+ return mPoints[point].GetState();
}
return PointState::FINISHED;
}
-Dali::Actor HoverEvent::GetHitActor( std::size_t point ) const
+Dali::Actor HoverEvent::GetHitActor(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetHitActor();
+ return mPoints[point].GetHitActor();
}
return Dali::Actor();
}
-const Vector2& HoverEvent::GetLocalPosition( std::size_t point ) const
+const Vector2& HoverEvent::GetLocalPosition(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetLocalPosition();
+ return mPoints[point].GetLocalPosition();
}
return Vector2::ZERO;
}
-const Vector2& HoverEvent::GetScreenPosition( std::size_t point ) const
+const Vector2& HoverEvent::GetScreenPosition(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetScreenPosition();
+ return mPoints[point].GetScreenPosition();
}
return Vector2::ZERO;
}
-const Integration::Point& HoverEvent::GetPoint( std::size_t point ) const
+const Integration::Point& HoverEvent::GetPoint(std::size_t point) const
{
- DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" );
- return mPoints[ point ];
+ DALI_ASSERT_DEBUG(point < mPoints.size() && "No point at index");
+ return mPoints[point];
}
-Integration::Point& HoverEvent::GetPoint( std::size_t point )
+Integration::Point& HoverEvent::GetPoint(std::size_t point)
{
- DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" );
- return mPoints[ point ];
+ DALI_ASSERT_DEBUG(point < mPoints.size() && "No point at index");
+ return mPoints[point];
}
-void HoverEvent::AddPoint( const Integration::Point& point )
+void HoverEvent::AddPoint(const Integration::Point& point)
{
- mPoints.push_back( point );
+ mPoints.push_back(point);
}
-} // namsespace Internal
+} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_HOVER_EVENT_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/devel-api/events/touch-point.h>
+#include <dali/integration-api/events/point.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/events/hover-event.h>
-#include <dali/devel-api/events/touch-point.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/integration-api/events/point.h>
namespace Dali
{
-
namespace Internal
{
-
class HoverEvent;
using HoverEventPtr = IntrusivePtr<HoverEvent>;
class HoverEvent : public BaseObject
{
public:
-
// Construction & Destruction
/**
* @brief Constructor
* @param[in] time The time the event occurred
*/
- HoverEvent( unsigned long time );
+ HoverEvent(unsigned long time);
/**
* @brief Clones the HoverEvent object.
* @param[in] rhs The HoverEvent to clone from.
* @return A new HoverEvent object which is has the same hover event data.
*/
- static HoverEventPtr Clone( const HoverEvent& rhs );
+ static HoverEventPtr Clone(const HoverEvent& rhs);
// Getters
/**
* @copydoc Dali::HoverEvent::GetDeviceId()
*/
- int32_t GetDeviceId( std::size_t point ) const;
+ int32_t GetDeviceId(std::size_t point) const;
/**
* @copydoc Dali::HoverEvent::GetGetState()
*/
- PointState::Type GetState( std::size_t point ) const;
+ PointState::Type GetState(std::size_t point) const;
/**
* @copydoc Dali::HoverEvent::GetHitActor()
*/
- Dali::Actor GetHitActor( std::size_t point ) const;
+ Dali::Actor GetHitActor(std::size_t point) const;
/**
* @copydoc Dali::HoverEvent::GetLocalPosition()
*/
- const Vector2& GetLocalPosition( std::size_t point ) const;
+ const Vector2& GetLocalPosition(std::size_t point) const;
/**
* @copydoc Dali::HoverEvent::GetScreenPosition()
*/
- const Vector2& GetScreenPosition( std::size_t point ) const;
+ const Vector2& GetScreenPosition(std::size_t point) const;
/**
* @brief Returns a const reference to a point at the index requested.
* @return A const reference to the Point at the position requested
* @note point should be less than the value returned by GetPointCount(). Will assert if out of range.
*/
- const Integration::Point& GetPoint( std::size_t point ) const;
+ const Integration::Point& GetPoint(std::size_t point) const;
/**
* @brief Returns a reference to a point at the index requested.
* @return A reference to the Point at the position requested
* @note point should be less than the value returned by GetPointCount(). Will assert if out of range.
*/
- Integration::Point& GetPoint( std::size_t point );
+ Integration::Point& GetPoint(std::size_t point);
// Setters
* @brief Adds a point to this hover event.
* @param[in] point The point to add to the hover event.
*/
- void AddPoint( const Integration::Point& point );
+ void AddPoint(const Integration::Point& point);
private:
-
/**
* @brief Destructor
*
// Not copyable or movable
- HoverEvent( const HoverEvent& rhs ) = delete; ///< Deleted copy constructor
- HoverEvent( HoverEvent&& rhs ) = delete; ///< Deleted move constructor
- HoverEvent& operator=( const HoverEvent& rhs ) = delete; ///< Deleted copy assignment operator
- HoverEvent& operator=( HoverEvent&& rhs ) = delete; ///< Deleted move assignment operator
+ HoverEvent(const HoverEvent& rhs) = delete; ///< Deleted copy constructor
+ HoverEvent(HoverEvent&& rhs) = delete; ///< Deleted move constructor
+ HoverEvent& operator=(const HoverEvent& rhs) = delete; ///< Deleted copy assignment operator
+ HoverEvent& operator=(HoverEvent&& rhs) = delete; ///< Deleted move assignment operator
private:
-
- std::vector< Integration::Point > mPoints; ///< Container of the points for this hover event
- unsigned long mTime; ///< The time (in ms) that the hover event occurred
+ std::vector<Integration::Point> mPoints; ///< Container of the points for this hover event
+ unsigned long mTime; ///< The time (in ms) that the hover event occurred
};
} // namespace Internal
// Helpers for public-api forwarding methods
-inline Internal::HoverEvent& GetImplementation( Dali::HoverEvent& hoverEvent )
+inline Internal::HoverEvent& GetImplementation(Dali::HoverEvent& hoverEvent)
{
- DALI_ASSERT_ALWAYS( hoverEvent && "Hover Event handle is empty" );
+ DALI_ASSERT_ALWAYS(hoverEvent && "Hover Event handle is empty");
BaseObject& object = hoverEvent.GetBaseObject();
- return static_cast< Internal::HoverEvent& >( object );
+ return static_cast<Internal::HoverEvent&>(object);
}
-inline const Internal::HoverEvent& GetImplementation( const Dali::HoverEvent& hoverEvent )
+inline const Internal::HoverEvent& GetImplementation(const Dali::HoverEvent& hoverEvent)
{
- DALI_ASSERT_ALWAYS( hoverEvent && "Hover Event handle is empty" );
+ DALI_ASSERT_ALWAYS(hoverEvent && "Hover Event handle is empty");
const BaseObject& object = hoverEvent.GetBaseObject();
- return static_cast< const Internal::HoverEvent& >( object );
+ return static_cast<const Internal::HoverEvent&>(object);
}
} // namespace Dali
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#endif
// INTERNAL INCLUDES
-#include <dali/public-api/math/vector2.h>
#include <dali/integration-api/debug.h>
#include <dali/integration-api/events/hover-event-integ.h>
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/actors/layer-impl.h>
#include <dali/internal/event/common/scene-impl.h>
#include <dali/internal/event/events/hit-test-algorithm-impl.h>
-#include <dali/internal/event/events/multi-point-event-util.h>
#include <dali/internal/event/events/hover-event-impl.h>
+#include <dali/internal/event/events/multi-point-event-util.h>
#include <dali/internal/event/render-tasks/render-task-impl.h>
+#include <dali/public-api/math/vector2.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_HOVER_PROCESSOR" );
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_HOVER_PROCESSOR");
-const char * TOUCH_POINT_STATE[PointState::INTERRUPTED + 1] =
-{
- "STARTED",
- "FINISHED",
- "MOTION",
- "LEAVE",
- "STATIONARY",
- "INTERRUPTED",
+const char* TOUCH_POINT_STATE[PointState::INTERRUPTED + 1] =
+ {
+ "STARTED",
+ "FINISHED",
+ "MOTION",
+ "LEAVE",
+ "STATIONARY",
+ "INTERRUPTED",
};
#endif // defined(DEBUG_ENABLED)
/**
* Recursively deliver events to the actor and its parents, until the event is consumed or the stage is reached.
*/
-Dali::Actor EmitHoverSignals( Dali::Actor actor, const Dali::HoverEvent& event )
+Dali::Actor EmitHoverSignals(Dali::Actor actor, const Dali::HoverEvent& event)
{
Dali::Actor consumedActor;
- if ( actor )
+ if(actor)
{
- Dali::Actor oldParent( actor.GetParent() );
+ Dali::Actor oldParent(actor.GetParent());
- Actor& actorImpl( GetImplementation(actor) );
+ Actor& actorImpl(GetImplementation(actor));
- bool consumed( false );
+ bool consumed(false);
// Only emit the signal if the actor's hover signal has connections (or derived actor implementation requires hover).
- if ( actorImpl.GetHoverRequired() )
+ if(actorImpl.GetHoverRequired())
{
- consumed = actorImpl.EmitHoverEventSignal( event );
+ consumed = actorImpl.EmitHoverEventSignal(event);
}
- if ( consumed )
+ if(consumed)
{
// One of this actor's listeners has consumed the event so set this actor as the consumed actor.
- consumedActor = Dali::Actor( &actorImpl );
+ consumedActor = Dali::Actor(&actorImpl);
}
else
{
// The actor may have been removed/reparented during the signal callbacks.
Dali::Actor parent = actor.GetParent();
- if ( parent &&
- (parent == oldParent) )
+ if(parent &&
+ (parent == oldParent))
{
// One of the actor's parents may consumed the event and they should be set as the consumed actor.
- consumedActor = EmitHoverSignals( parent, event );
+ consumedActor = EmitHoverSignals(parent, event);
}
}
}
return consumedActor;
}
-Dali::Actor AllocAndEmitHoverSignals( unsigned long time, Dali::Actor actor, const Integration::Point& point )
+Dali::Actor AllocAndEmitHoverSignals(unsigned long time, Dali::Actor actor, const Integration::Point& point)
{
- HoverEventPtr hoverEvent( new HoverEvent( time ) );
- Dali::HoverEvent hoverEventHandle( hoverEvent.Get() );
+ HoverEventPtr hoverEvent(new HoverEvent(time));
+ Dali::HoverEvent hoverEventHandle(hoverEvent.Get());
- hoverEvent->AddPoint( point );
+ hoverEvent->AddPoint(point);
- return EmitHoverSignals( actor, hoverEventHandle );
+ return EmitHoverSignals(actor, hoverEventHandle);
}
/**
* Changes the state of the primary point to leave and emits the hover signals
*/
-Dali::Actor EmitHoverSignals( Actor* actor, RenderTask& renderTask, const HoverEventPtr& originalEvent, PointState::Type state )
+Dali::Actor EmitHoverSignals(Actor* actor, RenderTask& renderTask, const HoverEventPtr& originalEvent, PointState::Type state)
{
- HoverEventPtr hoverEvent = HoverEvent::Clone( *originalEvent.Get() );
+ HoverEventPtr hoverEvent = HoverEvent::Clone(*originalEvent.Get());
- DALI_ASSERT_DEBUG( NULL != actor && "NULL actor pointer" );
- if( actor )
+ DALI_ASSERT_DEBUG(NULL != actor && "NULL actor pointer");
+ if(actor)
{
- Integration::Point& primaryPoint = hoverEvent->GetPoint( 0 );
+ Integration::Point& primaryPoint = hoverEvent->GetPoint(0);
const Vector2& screenPosition = primaryPoint.GetScreenPosition();
- Vector2 localPosition;
- actor->ScreenToLocal( renderTask, localPosition.x, localPosition.y, screenPosition.x, screenPosition.y );
+ Vector2 localPosition;
+ actor->ScreenToLocal(renderTask, localPosition.x, localPosition.y, screenPosition.x, screenPosition.y);
- primaryPoint.SetLocalPosition( localPosition );
- primaryPoint.SetHitActor( Dali::Actor( actor ) );
- primaryPoint.SetState( state );
+ primaryPoint.SetLocalPosition(localPosition);
+ primaryPoint.SetHitActor(Dali::Actor(actor));
+ primaryPoint.SetState(state);
}
- return EmitHoverSignals( Dali::Actor(actor), Dali::HoverEvent( hoverEvent.Get() ) );
+ return EmitHoverSignals(Dali::Actor(actor), Dali::HoverEvent(hoverEvent.Get()));
}
/**
*/
struct ActorHoverableCheck : public HitTestAlgorithm::HitTestInterface
{
- bool IsActorHittable( Actor* actor ) override
+ bool IsActorHittable(Actor* actor) override
{
return actor->GetHoverRequired() && // Does the Application or derived actor type require a hover event?
actor->IsHittable(); // Is actor sensitive, visible and on the scene?
}
- bool DescendActorHierarchy( Actor* actor ) override
+ bool DescendActorHierarchy(Actor* actor) override
{
return actor->IsVisible() && // Actor is visible, if not visible then none of its children are visible.
actor->IsSensitive(); // Actor is sensitive, if insensitive none of its children should be hittable either.
}
- bool DoesLayerConsumeHit( Layer* layer ) override
+ bool DoesLayerConsumeHit(Layer* layer) override
{
return layer->IsHoverConsumed();
}
} // unnamed namespace
-HoverEventProcessor::HoverEventProcessor( Scene& scene )
-: mScene( scene )
+HoverEventProcessor::HoverEventProcessor(Scene& scene)
+: mScene(scene)
{
- DALI_LOG_TRACE_METHOD( gLogFilter );
+ DALI_LOG_TRACE_METHOD(gLogFilter);
}
HoverEventProcessor::~HoverEventProcessor()
{
- DALI_LOG_TRACE_METHOD( gLogFilter );
+ DALI_LOG_TRACE_METHOD(gLogFilter);
}
-void HoverEventProcessor::ProcessHoverEvent( const Integration::HoverEvent& event )
+void HoverEventProcessor::ProcessHoverEvent(const Integration::HoverEvent& event)
{
- DALI_LOG_TRACE_METHOD( gLogFilter );
- DALI_ASSERT_ALWAYS( !event.points.empty() && "Empty HoverEvent sent from Integration\n" );
+ DALI_LOG_TRACE_METHOD(gLogFilter);
+ DALI_ASSERT_ALWAYS(!event.points.empty() && "Empty HoverEvent sent from Integration\n");
- PointState::Type state = static_cast< PointState::Type >( event.points[0].GetState() );
+ PointState::Type state = static_cast<PointState::Type>(event.points[0].GetState());
PRINT_HIERARCHY(gLogFilter);
// Copy so we can add the results of a hit-test.
- HoverEventPtr hoverEvent( new HoverEvent( event.time ) );
+ HoverEventPtr hoverEvent(new HoverEvent(event.time));
// 1) Check if it is an interrupted event - we should inform our last primary hit actor about this
// and emit the stage signal as well.
- if ( state == PointState::INTERRUPTED )
+ if(state == PointState::INTERRUPTED)
{
- Dali::Actor consumingActor;
- Integration::Point currentPoint( event.points[0] );
+ Dali::Actor consumingActor;
+ Integration::Point currentPoint(event.points[0]);
- Actor* lastPrimaryHitActor( mLastPrimaryHitActor.GetActor() );
- if ( lastPrimaryHitActor )
+ Actor* lastPrimaryHitActor(mLastPrimaryHitActor.GetActor());
+ if(lastPrimaryHitActor)
{
- Dali::Actor lastPrimaryHitActorHandle( lastPrimaryHitActor );
- currentPoint.SetHitActor( lastPrimaryHitActorHandle );
- consumingActor = AllocAndEmitHoverSignals( event.time, lastPrimaryHitActorHandle, currentPoint );
+ Dali::Actor lastPrimaryHitActorHandle(lastPrimaryHitActor);
+ currentPoint.SetHitActor(lastPrimaryHitActorHandle);
+ consumingActor = AllocAndEmitHoverSignals(event.time, lastPrimaryHitActorHandle, currentPoint);
}
// If the last consumed actor was different to the primary hit actor then inform it as well (if it has not already been informed).
- Actor* lastConsumedActor( mLastConsumedActor.GetActor() );
- if ( lastConsumedActor &&
- lastConsumedActor != lastPrimaryHitActor &&
- lastConsumedActor != consumingActor )
+ Actor* lastConsumedActor(mLastConsumedActor.GetActor());
+ if(lastConsumedActor &&
+ lastConsumedActor != lastPrimaryHitActor &&
+ lastConsumedActor != consumingActor)
{
- Dali::Actor lastConsumedActorHandle( lastConsumedActor );
- currentPoint.SetHitActor( lastConsumedActorHandle );
- AllocAndEmitHoverSignals( event.time, lastConsumedActorHandle, currentPoint );
+ Dali::Actor lastConsumedActorHandle(lastConsumedActor);
+ currentPoint.SetHitActor(lastConsumedActorHandle);
+ AllocAndEmitHoverSignals(event.time, lastConsumedActorHandle, currentPoint);
}
// Tell the hover-start consuming actor as well, if required
- Actor* hoverStartConsumedActor( mHoverStartConsumedActor.GetActor() );
- if ( hoverStartConsumedActor &&
- hoverStartConsumedActor != lastPrimaryHitActor &&
- hoverStartConsumedActor != lastConsumedActor &&
- hoverStartConsumedActor != consumingActor )
+ Actor* hoverStartConsumedActor(mHoverStartConsumedActor.GetActor());
+ if(hoverStartConsumedActor &&
+ hoverStartConsumedActor != lastPrimaryHitActor &&
+ hoverStartConsumedActor != lastConsumedActor &&
+ hoverStartConsumedActor != consumingActor)
{
- Dali::Actor hoverStartConsumedActorHandle( hoverStartConsumedActor );
- currentPoint.SetHitActor( hoverStartConsumedActorHandle );
- AllocAndEmitHoverSignals( event.time, hoverStartConsumedActorHandle, currentPoint );
+ Dali::Actor hoverStartConsumedActorHandle(hoverStartConsumedActor);
+ currentPoint.SetHitActor(hoverStartConsumedActorHandle);
+ AllocAndEmitHoverSignals(event.time, hoverStartConsumedActorHandle, currentPoint);
}
- mLastPrimaryHitActor.SetActor( nullptr );
- mLastConsumedActor.SetActor( nullptr );
- mHoverStartConsumedActor.SetActor( nullptr );
+ mLastPrimaryHitActor.SetActor(nullptr);
+ mLastConsumedActor.SetActor(nullptr);
+ mHoverStartConsumedActor.SetActor(nullptr);
mLastRenderTask.Reset();
return; // No need for hit testing
// 2) Hit Testing.
- Dali::HoverEvent hoverEventHandle( hoverEvent.Get() );
+ Dali::HoverEvent hoverEventHandle(hoverEvent.Get());
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, "Point(s): %d\n", event.GetPointCount() );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, "Point(s): %d\n", event.GetPointCount());
RenderTaskPtr currentRenderTask;
- bool firstPointParsed = false;
+ bool firstPointParsed = false;
- for ( auto&& currentPoint : event.points )
+ for(auto&& currentPoint : event.points)
{
HitTestAlgorithm::Results hitTestResults;
- ActorHoverableCheck actorHoverableCheck;
- HitTestAlgorithm::HitTest( mScene.GetSize(), mScene.GetRenderTaskList(), mScene.GetLayerList(), currentPoint.GetScreenPosition(), hitTestResults, actorHoverableCheck );
+ ActorHoverableCheck actorHoverableCheck;
+ HitTestAlgorithm::HitTest(mScene.GetSize(), mScene.GetRenderTaskList(), mScene.GetLayerList(), currentPoint.GetScreenPosition(), hitTestResults, actorHoverableCheck);
- Integration::Point newPoint( currentPoint );
- newPoint.SetHitActor( hitTestResults.actor );
- newPoint.SetLocalPosition( hitTestResults.actorCoordinates );
+ Integration::Point newPoint(currentPoint);
+ newPoint.SetHitActor(hitTestResults.actor);
+ newPoint.SetLocalPosition(hitTestResults.actorCoordinates);
- hoverEvent->AddPoint( newPoint );
+ hoverEvent->AddPoint(newPoint);
- DALI_LOG_INFO( gLogFilter, Debug::General, " State(%s), Screen(%.0f, %.0f), HitActor(%p, %s), Local(%.2f, %.2f)\n",
- TOUCH_POINT_STATE[currentPoint.GetState()], currentPoint.GetScreenPosition().x, currentPoint.GetScreenPosition().y,
- ( hitTestResults.actor ? reinterpret_cast< void* >( &hitTestResults.actor.GetBaseObject() ) : NULL ),
- ( hitTestResults.actor ? hitTestResults.actor.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str() : "" ),
- hitTestResults.actorCoordinates.x, hitTestResults.actorCoordinates.y );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " State(%s), Screen(%.0f, %.0f), HitActor(%p, %s), Local(%.2f, %.2f)\n", TOUCH_POINT_STATE[currentPoint.GetState()], currentPoint.GetScreenPosition().x, currentPoint.GetScreenPosition().y, (hitTestResults.actor ? reinterpret_cast<void*>(&hitTestResults.actor.GetBaseObject()) : NULL), (hitTestResults.actor ? hitTestResults.actor.GetProperty<std::string>(Dali::Actor::Property::NAME).c_str() : ""), hitTestResults.actorCoordinates.x, hitTestResults.actorCoordinates.y);
// Only set the currentRenderTask for the primary hit actor.
- if( !firstPointParsed )
+ if(!firstPointParsed)
{
- firstPointParsed = true;
+ firstPointParsed = true;
currentRenderTask = hitTestResults.renderTask;
}
}
// Emit the touch signal
Dali::Actor consumedActor;
- if ( currentRenderTask )
+ if(currentRenderTask)
{
- consumedActor = EmitHoverSignals( hoverEvent->GetHitActor( 0 ), hoverEventHandle );
+ consumedActor = EmitHoverSignals(hoverEvent->GetHitActor(0), hoverEventHandle);
}
- Integration::Point primaryPoint = hoverEvent->GetPoint( 0 );
- Dali::Actor primaryHitActor = primaryPoint.GetHitActor();
- PointState::Type primaryPointState = primaryPoint.GetState();
+ Integration::Point primaryPoint = hoverEvent->GetPoint(0);
+ Dali::Actor primaryHitActor = primaryPoint.GetHitActor();
+ PointState::Type primaryPointState = primaryPoint.GetState();
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "PrimaryHitActor: (%p) %s\n", primaryHitActor ? reinterpret_cast< void* >( &primaryHitActor.GetBaseObject() ) : NULL, primaryHitActor ? primaryHitActor.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str() : "" );
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "ConsumedActor: (%p) %s\n", consumedActor ? reinterpret_cast< void* >( &consumedActor.GetBaseObject() ) : NULL, consumedActor ? consumedActor.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str() : "" );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "PrimaryHitActor: (%p) %s\n", primaryHitActor ? reinterpret_cast<void*>(&primaryHitActor.GetBaseObject()) : NULL, primaryHitActor ? primaryHitActor.GetProperty<std::string>(Dali::Actor::Property::NAME).c_str() : "");
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "ConsumedActor: (%p) %s\n", consumedActor ? reinterpret_cast<void*>(&consumedActor.GetBaseObject()) : NULL, consumedActor ? consumedActor.GetProperty<std::string>(Dali::Actor::Property::NAME).c_str() : "");
- if ( ( primaryPointState == PointState::STARTED ) &&
- ( hoverEvent->GetPointCount() == 1 ) &&
- ( consumedActor && GetImplementation( consumedActor ).OnScene() ) )
+ if((primaryPointState == PointState::STARTED) &&
+ (hoverEvent->GetPointCount() == 1) &&
+ (consumedActor && GetImplementation(consumedActor).OnScene()))
{
- mHoverStartConsumedActor.SetActor( &GetImplementation( consumedActor ) );
+ mHoverStartConsumedActor.SetActor(&GetImplementation(consumedActor));
}
// 4) Check if the last primary hit actor requires a leave event and if it was different to the current primary
// hit actor. Also process the last consumed actor in the same manner.
- Actor* lastPrimaryHitActor( mLastPrimaryHitActor.GetActor() );
- Actor* lastConsumedActor( mLastConsumedActor.GetActor() );
- if( (primaryPointState == PointState::MOTION) || (primaryPointState == PointState::FINISHED) || (primaryPointState == PointState::STATIONARY) )
+ Actor* lastPrimaryHitActor(mLastPrimaryHitActor.GetActor());
+ Actor* lastConsumedActor(mLastConsumedActor.GetActor());
+ if((primaryPointState == PointState::MOTION) || (primaryPointState == PointState::FINISHED) || (primaryPointState == PointState::STATIONARY))
{
- if ( mLastRenderTask )
+ if(mLastRenderTask)
{
Dali::Actor leaveEventConsumer;
RenderTask& lastRenderTaskImpl = *mLastRenderTask.Get();
- if( lastPrimaryHitActor &&
- lastPrimaryHitActor != primaryHitActor &&
- lastPrimaryHitActor != consumedActor )
+ if(lastPrimaryHitActor &&
+ lastPrimaryHitActor != primaryHitActor &&
+ lastPrimaryHitActor != consumedActor)
{
- if( lastPrimaryHitActor->IsHittable() && IsActuallySensitive( lastPrimaryHitActor ) )
+ if(lastPrimaryHitActor->IsHittable() && IsActuallySensitive(lastPrimaryHitActor))
{
- if ( lastPrimaryHitActor->GetLeaveRequired() )
+ if(lastPrimaryHitActor->GetLeaveRequired())
{
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "LeaveActor(Hit): (%p) %s\n", reinterpret_cast< void* >( lastPrimaryHitActor ), lastPrimaryHitActor->GetName().data() );
- leaveEventConsumer = EmitHoverSignals( mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, hoverEvent, PointState::LEAVE );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "LeaveActor(Hit): (%p) %s\n", reinterpret_cast<void*>(lastPrimaryHitActor), lastPrimaryHitActor->GetName().data());
+ leaveEventConsumer = EmitHoverSignals(mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, hoverEvent, PointState::LEAVE);
}
}
else
{
// At this point mLastPrimaryHitActor was touchable and sensitive in the previous touch event process but is not in the current one.
// An interrupted event is send to allow some actors to go back to their original state (i.e. Button controls)
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "InterruptedActor(Hit): (%p) %s\n", reinterpret_cast< void* >( lastPrimaryHitActor ), lastPrimaryHitActor->GetName().data() );
- leaveEventConsumer = EmitHoverSignals( mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, hoverEvent, PointState::INTERRUPTED );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "InterruptedActor(Hit): (%p) %s\n", reinterpret_cast<void*>(lastPrimaryHitActor), lastPrimaryHitActor->GetName().data());
+ leaveEventConsumer = EmitHoverSignals(mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, hoverEvent, PointState::INTERRUPTED);
}
}
// Check if the motion event has been consumed by another actor's listener. In this case, the previously
// consumed actor's listeners may need to be informed (through a leave event).
// Further checks here to ensure we do not signal the same actor twice for the same event.
- if ( lastConsumedActor &&
- lastConsumedActor != consumedActor &&
- lastConsumedActor != lastPrimaryHitActor &&
- lastConsumedActor != primaryHitActor &&
- lastConsumedActor != leaveEventConsumer )
+ if(lastConsumedActor &&
+ lastConsumedActor != consumedActor &&
+ lastConsumedActor != lastPrimaryHitActor &&
+ lastConsumedActor != primaryHitActor &&
+ lastConsumedActor != leaveEventConsumer)
{
- if( lastConsumedActor->IsHittable() && IsActuallySensitive( lastConsumedActor ) )
+ if(lastConsumedActor->IsHittable() && IsActuallySensitive(lastConsumedActor))
{
- if( lastConsumedActor->GetLeaveRequired() )
+ if(lastConsumedActor->GetLeaveRequired())
{
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "LeaveActor(Consume): (%p) %s\n", reinterpret_cast< void* >( lastConsumedActor ), lastConsumedActor->GetName().data() );
- EmitHoverSignals( lastConsumedActor, lastRenderTaskImpl, hoverEvent, PointState::LEAVE );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "LeaveActor(Consume): (%p) %s\n", reinterpret_cast<void*>(lastConsumedActor), lastConsumedActor->GetName().data());
+ EmitHoverSignals(lastConsumedActor, lastRenderTaskImpl, hoverEvent, PointState::LEAVE);
}
}
else
{
// At this point mLastConsumedActor was touchable and sensitive in the previous touch event process but is not in the current one.
// An interrupted event is send to allow some actors to go back to their original state (i.e. Button controls)
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "InterruptedActor(Consume): (%p) %s\n", reinterpret_cast< void* >( lastConsumedActor ), lastConsumedActor->GetName().data() );
- EmitHoverSignals( mLastConsumedActor.GetActor(), lastRenderTaskImpl, hoverEvent, PointState::INTERRUPTED );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "InterruptedActor(Consume): (%p) %s\n", reinterpret_cast<void*>(lastConsumedActor), lastConsumedActor->GetName().data());
+ EmitHoverSignals(mLastConsumedActor.GetActor(), lastRenderTaskImpl, hoverEvent, PointState::INTERRUPTED);
}
}
}
// 5) If our primary point is a FINISHED event, then the primary point (in multi-touch) will change next
// time so set our last primary actor to NULL. Do the same to the last consumed actor as well.
- if ( primaryPointState == PointState::FINISHED )
+ if(primaryPointState == PointState::FINISHED)
{
- mLastPrimaryHitActor.SetActor( nullptr );
- mLastConsumedActor.SetActor( nullptr );
+ mLastPrimaryHitActor.SetActor(nullptr);
+ mLastConsumedActor.SetActor(nullptr);
mLastRenderTask.Reset();
}
else
{
// The primaryHitActor may have been removed from the scene so ensure it is still on the scene before setting members.
- if ( primaryHitActor && GetImplementation( primaryHitActor ).OnScene() )
+ if(primaryHitActor && GetImplementation(primaryHitActor).OnScene())
{
- mLastPrimaryHitActor.SetActor( &GetImplementation( primaryHitActor ) );
+ mLastPrimaryHitActor.SetActor(&GetImplementation(primaryHitActor));
// Only observe the consumed actor if we have a primaryHitActor (check if it is still on the scene).
- if ( consumedActor && GetImplementation( consumedActor ).OnScene() )
+ if(consumedActor && GetImplementation(consumedActor).OnScene())
{
- mLastConsumedActor.SetActor( &GetImplementation( consumedActor ) );
+ mLastConsumedActor.SetActor(&GetImplementation(consumedActor));
}
else
{
- mLastConsumedActor.SetActor( nullptr );
+ mLastConsumedActor.SetActor(nullptr);
}
mLastRenderTask = currentRenderTask;
}
else
{
- mLastPrimaryHitActor.SetActor( nullptr );
- mLastConsumedActor.SetActor( nullptr );
+ mLastPrimaryHitActor.SetActor(nullptr);
+ mLastConsumedActor.SetActor(nullptr);
mLastRenderTask.Reset();
}
}
// 6) Emit an interrupted event to the hover-started actor if it hasn't consumed the FINISHED.
- if ( hoverEvent->GetPointCount() == 1 ) // Only want the first hover started
+ if(hoverEvent->GetPointCount() == 1) // Only want the first hover started
{
- switch ( primaryPointState )
+ switch(primaryPointState)
{
case PointState::FINISHED:
{
- Actor* hoverStartConsumedActor( mHoverStartConsumedActor.GetActor() );
- if ( hoverStartConsumedActor &&
- hoverStartConsumedActor != consumedActor &&
- hoverStartConsumedActor != lastPrimaryHitActor &&
- hoverStartConsumedActor != lastConsumedActor )
+ Actor* hoverStartConsumedActor(mHoverStartConsumedActor.GetActor());
+ if(hoverStartConsumedActor &&
+ hoverStartConsumedActor != consumedActor &&
+ hoverStartConsumedActor != lastPrimaryHitActor &&
+ hoverStartConsumedActor != lastConsumedActor)
{
- Dali::Actor hoverStartConsumedActorHandle( hoverStartConsumedActor );
- Integration::Point primaryPoint = hoverEvent->GetPoint( 0 );
- primaryPoint.SetHitActor( hoverStartConsumedActorHandle );
- primaryPoint.SetState( PointState::INTERRUPTED );
- AllocAndEmitHoverSignals( event.time, hoverStartConsumedActorHandle, primaryPoint );
+ Dali::Actor hoverStartConsumedActorHandle(hoverStartConsumedActor);
+ Integration::Point primaryPoint = hoverEvent->GetPoint(0);
+ primaryPoint.SetHitActor(hoverStartConsumedActorHandle);
+ primaryPoint.SetState(PointState::INTERRUPTED);
+ AllocAndEmitHoverSignals(event.time, hoverStartConsumedActorHandle, primaryPoint);
// Restore hover-event to original state
- primaryPoint.SetHitActor( primaryHitActor );
- primaryPoint.SetState( primaryPointState );
+ primaryPoint.SetHitActor(primaryHitActor);
+ primaryPoint.SetState(primaryPointState);
}
- mHoverStartConsumedActor.SetActor( nullptr );
+ mHoverStartConsumedActor.SetActor(nullptr);
}
- // No break, Fallthrough
+ // No break, Fallthrough
case PointState::STARTED:
case PointState::MOTION:
#define DALI_INTERNAL_HOVER_EVENT_PROCESSOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
class Actor;
struct Vector2;
struct Vector4;
namespace Internal
{
-
struct ActorObserver;
class Scene;
class HoverEventProcessor
{
public:
-
/**
* Create an event processor.
* @param[in] scene The scene the event processor belongs to.
*/
- HoverEventProcessor( Scene& scene );
+ HoverEventProcessor(Scene& scene);
/**
* Non-virtual destructor; HoverEventProcessor is not a base class
* This function is called by the event processor whenever a hover event occurs.
* @param[in] event The hover event that has occurred.
*/
- void ProcessHoverEvent( const Integration::HoverEvent& event );
+ void ProcessHoverEvent(const Integration::HoverEvent& event);
private:
-
// Undefined
HoverEventProcessor(const HoverEventProcessor&);
// Undefined
HoverEventProcessor& operator=(const HoverEventProcessor& rhs);
- Scene& mScene; ///< Reference to the scene
- ActorObserver mLastPrimaryHitActor; ///< Stores the last primary point hit actor
- ActorObserver mLastConsumedActor; ///< Stores the last consumed actor
+ Scene& mScene; ///< Reference to the scene
+ ActorObserver mLastPrimaryHitActor; ///< Stores the last primary point hit actor
+ ActorObserver mLastConsumedActor; ///< Stores the last consumed actor
ActorObserver mHoverStartConsumedActor; ///< Stores the hover-start consumed actor
- RenderTaskPtr mLastRenderTask; ///< The RenderTask used for the last hit actor
+ RenderTaskPtr mLastRenderTask; ///< The RenderTask used for the last hit actor
};
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace
{
const uint32_t MODIFIER_SHIFT = 0x1;
const uint32_t MODIFIER_CTRL = 0x2;
const uint32_t MODIFIER_ALT = 0x4;
const int32_t KEY_INVALID_CODE = -1;
-}
+} // namespace
namespace Internal
{
-
KeyEvent::KeyEvent()
-: mKeyName( "" ),
- mLogicalKey( "" ),
- mKeyString( "" ),
- mKeyCode( KEY_INVALID_CODE ),
- mKeyModifier( 0 ),
- mTime( 0 ),
- mState( Dali::KeyEvent::DOWN ),
- mCompose( "" ),
- mDeviceName( "" ),
- mDeviceClass( Device::Class::NONE ),
- mDeviceSubclass( Device::Subclass::NONE )
-{
-}
-
-KeyEvent::KeyEvent( const std::string& keyName,
- const std::string& logicalKey,
- const std::string& keyString,
- int keyCode,
- int keyModifier,
- unsigned long timeStamp,
- const Dali::KeyEvent::State& keyState,
- const std::string& compose,
- const std::string& deviceName,
- const Device::Class::Type deviceClass,
- const Device::Subclass::Type deviceSubclass )
-: mKeyName( keyName ),
- mLogicalKey( logicalKey ),
- mKeyString( keyString ),
- mKeyCode( keyCode ),
- mKeyModifier( keyModifier ),
- mTime( timeStamp ),
- mState( keyState ),
- mCompose( compose ),
- mDeviceName( deviceName ),
- mDeviceClass( deviceClass ),
- mDeviceSubclass( deviceSubclass )
-{
-}
-
-KeyEventPtr KeyEvent::New( const std::string& keyName,
- const std::string& logicalKey,
- const std::string& keyString,
- int keyCode,
- int keyModifier,
- unsigned long timeStamp,
- const Dali::KeyEvent::State& keyState,
- const std::string& compose,
- const std::string& deviceName,
- const Device::Class::Type deviceClass,
- const Device::Subclass::Type deviceSubclass )
-{
- KeyEventPtr keyEvent = new KeyEvent( keyName, logicalKey, keyString, keyCode, keyModifier, timeStamp, keyState, compose, deviceName, deviceClass, deviceSubclass );
+: mKeyName(""),
+ mLogicalKey(""),
+ mKeyString(""),
+ mKeyCode(KEY_INVALID_CODE),
+ mKeyModifier(0),
+ mTime(0),
+ mState(Dali::KeyEvent::DOWN),
+ mCompose(""),
+ mDeviceName(""),
+ mDeviceClass(Device::Class::NONE),
+ mDeviceSubclass(Device::Subclass::NONE)
+{
+}
+
+KeyEvent::KeyEvent(const std::string& keyName,
+ const std::string& logicalKey,
+ const std::string& keyString,
+ int keyCode,
+ int keyModifier,
+ unsigned long timeStamp,
+ const Dali::KeyEvent::State& keyState,
+ const std::string& compose,
+ const std::string& deviceName,
+ const Device::Class::Type deviceClass,
+ const Device::Subclass::Type deviceSubclass)
+: mKeyName(keyName),
+ mLogicalKey(logicalKey),
+ mKeyString(keyString),
+ mKeyCode(keyCode),
+ mKeyModifier(keyModifier),
+ mTime(timeStamp),
+ mState(keyState),
+ mCompose(compose),
+ mDeviceName(deviceName),
+ mDeviceClass(deviceClass),
+ mDeviceSubclass(deviceSubclass)
+{
+}
+
+KeyEventPtr KeyEvent::New(const std::string& keyName,
+ const std::string& logicalKey,
+ const std::string& keyString,
+ int keyCode,
+ int keyModifier,
+ unsigned long timeStamp,
+ const Dali::KeyEvent::State& keyState,
+ const std::string& compose,
+ const std::string& deviceName,
+ const Device::Class::Type deviceClass,
+ const Device::Subclass::Type deviceSubclass)
+{
+ KeyEventPtr keyEvent = new KeyEvent(keyName, logicalKey, keyString, keyCode, keyModifier, timeStamp, keyState, compose, deviceName, deviceClass, deviceSubclass);
return keyEvent;
}
bool KeyEvent::IsShiftModifier() const
{
- return ( ( MODIFIER_SHIFT & mKeyModifier ) == MODIFIER_SHIFT );
+ return ((MODIFIER_SHIFT & mKeyModifier) == MODIFIER_SHIFT);
}
bool KeyEvent::IsCtrlModifier() const
{
- return ( ( MODIFIER_CTRL & mKeyModifier ) == MODIFIER_CTRL );
+ return ((MODIFIER_CTRL & mKeyModifier) == MODIFIER_CTRL);
}
bool KeyEvent::IsAltModifier() const
{
- return ( ( MODIFIER_ALT & mKeyModifier ) == MODIFIER_ALT );
+ return ((MODIFIER_ALT & mKeyModifier) == MODIFIER_ALT);
}
const std::string& KeyEvent::GetCompose() const
return mDeviceName;
}
-
Device::Class::Type KeyEvent::GetDeviceClass() const
{
return mDeviceClass;
}
-
Device::Subclass::Type KeyEvent::GetDeviceSubclass() const
{
return mDeviceSubclass;
}
-
const std::string& KeyEvent::GetKeyName() const
{
return mKeyName;
}
-
const std::string& KeyEvent::GetKeyString() const
{
return mKeyString;
}
-
const std::string& KeyEvent::GetLogicalKey() const
{
return mLogicalKey;
}
-
int32_t KeyEvent::GetKeyCode() const
{
return mKeyCode;
}
-
int32_t KeyEvent::GetKeyModifier() const
{
return mKeyModifier;
}
-
unsigned long KeyEvent::GetTime() const
{
return mTime;
}
-
Dali::KeyEvent::State KeyEvent::GetState() const
{
return mState;
}
-
-void KeyEvent::SetKeyName( const std::string& keyName )
+void KeyEvent::SetKeyName(const std::string& keyName)
{
mKeyName = keyName;
}
-
-void KeyEvent::SetKeyString( const std::string& keyString )
+void KeyEvent::SetKeyString(const std::string& keyString)
{
mKeyString = keyString;
}
-
-void KeyEvent::SetKeyCode( int32_t keyCode )
+void KeyEvent::SetKeyCode(int32_t keyCode)
{
mKeyCode = keyCode;
}
-
-void KeyEvent::SetKeyModifier( int32_t keyModifier )
+void KeyEvent::SetKeyModifier(int32_t keyModifier)
{
mKeyModifier = keyModifier;
}
-
-void KeyEvent::SetTime( unsigned long time )
+void KeyEvent::SetTime(unsigned long time)
{
mTime = time;
}
-
-void KeyEvent::SetState( const Dali::KeyEvent::State& state )
+void KeyEvent::SetState(const Dali::KeyEvent::State& state)
{
mState = state;
}
#define DALI_INTERNAL_KEY_EVENT_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
class KeyEvent;
-typedef IntrusivePtr< KeyEvent > KeyEventPtr;
+typedef IntrusivePtr<KeyEvent> KeyEventPtr;
/**
* @copydoc Dali::KeyEvent
class KeyEvent : public BaseObject
{
public:
-
/**
* @brief Default constructor.
*/
* @param[in] deviceClass The class of device the key event originated from
* @param[in] deviceSubclass The subclass of device the key event originated from
*/
- KeyEvent( const std::string& keyName,
- const std::string& logicalKey,
- const std::string& keyString,
- int keyCode,
- int keyModifier,
- unsigned long timeStamp,
- const Dali::KeyEvent::State& keyState,
- const std::string& compose,
- const std::string& deviceName,
- const Device::Class::Type deviceClass,
- const Device::Subclass::Type deviceSubclass );
+ KeyEvent(const std::string& keyName,
+ const std::string& logicalKey,
+ const std::string& keyString,
+ int keyCode,
+ int keyModifier,
+ unsigned long timeStamp,
+ const Dali::KeyEvent::State& keyState,
+ const std::string& compose,
+ const std::string& deviceName,
+ const Device::Class::Type deviceClass,
+ const Device::Subclass::Type deviceSubclass);
/**
* Create a new KeyEvent.
* @param[in] deviceSubclass The subclass of device the key event originated from
* @return A smart-pointer to the newly allocated KeyEvent.
*/
- static KeyEventPtr New( const std::string& keyName,
- const std::string& logicalKey,
- const std::string& keyString,
- int keyCode,
- int keyModifier,
- unsigned long timeStamp,
- const Dali::KeyEvent::State& keyState,
- const std::string& compose,
- const std::string& deviceName,
- const Device::Class::Type deviceClass,
- const Device::Subclass::Type deviceSubclass );
+ static KeyEventPtr New(const std::string& keyName,
+ const std::string& logicalKey,
+ const std::string& keyString,
+ int keyCode,
+ int keyModifier,
+ unsigned long timeStamp,
+ const Dali::KeyEvent::State& keyState,
+ const std::string& compose,
+ const std::string& deviceName,
+ const Device::Class::Type deviceClass,
+ const Device::Subclass::Type deviceSubclass);
/**
* @copydoc Dali::KeyEvent::IsShiftModifier()
*
* @param[in] keyName The name given to the key pressed.
*/
- void SetKeyName( const std::string& keyName );
+ void SetKeyName(const std::string& keyName);
/**
* @brief Set the actual string of input characters that should be used for input editors.
*
* @param[in] The actual string of input characters
*/
- void SetKeyString( const std::string& keyString );
+ void SetKeyString(const std::string& keyString);
/**
* @brief Set the unique key code for the key pressed.
*
* @param[in] keyCode The unique key code for the key pressed
*/
- void SetKeyCode( int32_t keyCode );
+ void SetKeyCode(int32_t keyCode);
/**
* @brief Set the key modifier for special keys like Shift, Alt and Ctrl which modify the next key pressed.
*
* @param[in] keyModifier The key modifier
*/
- void SetKeyModifier( int32_t keyModifier );
+ void SetKeyModifier(int32_t keyModifier);
/**
* @brief Set the time (in ms) that the key event occurred.
*
* @param[in] time The time (in ms)
*/
- void SetTime( unsigned long time );
+ void SetTime(unsigned long time);
/**
* @brief Set the state of the key event.
*
* @param[in] state The state of the key event
*/
- void SetState( const Dali::KeyEvent::State& state );
+ void SetState(const Dali::KeyEvent::State& state);
private:
-
/**
* @brief Destructor.
*
// Not copyable or movable
- KeyEvent( const KeyEvent& rhs ) = delete; ///< Deleted copy constructor
- KeyEvent( KeyEvent&& rhs ) = delete; ///< Deleted move constructor
- KeyEvent& operator=( const KeyEvent& rhs ) = delete; ///< Deleted copy assignment operator
- KeyEvent& operator=( KeyEvent&& rhs ) = delete; ///< Deleted move assignment operator
+ KeyEvent(const KeyEvent& rhs) = delete; ///< Deleted copy constructor
+ KeyEvent(KeyEvent&& rhs) = delete; ///< Deleted move constructor
+ KeyEvent& operator=(const KeyEvent& rhs) = delete; ///< Deleted copy assignment operator
+ KeyEvent& operator=(KeyEvent&& rhs) = delete; ///< Deleted move assignment operator
private:
-
- std::string mKeyName; ///< The name of the key pressed
- std::string mLogicalKey; ///< The logical key symbol
- std::string mKeyString; ///< The string of input characters
- int mKeyCode; ///< TThe unique key code
- int mKeyModifier; ///< The key modifier
- unsigned long mTime; ///< The time that the key event occurred.
- Dali::KeyEvent::State mState; ///< The state of the key event.
- std::string mCompose; ///< The key compose
- std::string mDeviceName; ///< The name of device the key event originated from
- Device::Class::Type mDeviceClass; ///< The class of device the key event originated from
- Device::Subclass::Type mDeviceSubclass; ///< The subclass of device the key event originated from
+ std::string mKeyName; ///< The name of the key pressed
+ std::string mLogicalKey; ///< The logical key symbol
+ std::string mKeyString; ///< The string of input characters
+ int mKeyCode; ///< TThe unique key code
+ int mKeyModifier; ///< The key modifier
+ unsigned long mTime; ///< The time that the key event occurred.
+ Dali::KeyEvent::State mState; ///< The state of the key event.
+ std::string mCompose; ///< The key compose
+ std::string mDeviceName; ///< The name of device the key event originated from
+ Device::Class::Type mDeviceClass; ///< The class of device the key event originated from
+ Device::Subclass::Type mDeviceSubclass; ///< The subclass of device the key event originated from
};
} // namespace Internal
// Helpers for public-api forwarding methods
-inline Internal::KeyEvent& GetImplementation( Dali::KeyEvent& keyEvent )
+inline Internal::KeyEvent& GetImplementation(Dali::KeyEvent& keyEvent)
{
- DALI_ASSERT_ALWAYS( keyEvent && "Key Event handle is empty" );
+ DALI_ASSERT_ALWAYS(keyEvent && "Key Event handle is empty");
BaseObject& object = keyEvent.GetBaseObject();
- return static_cast< Internal::KeyEvent& >( object );
+ return static_cast<Internal::KeyEvent&>(object);
}
-inline const Internal::KeyEvent& GetImplementation( const Dali::KeyEvent& keyEvent )
+inline const Internal::KeyEvent& GetImplementation(const Dali::KeyEvent& keyEvent)
{
- DALI_ASSERT_ALWAYS( keyEvent && "Key Event handle is empty" );
+ DALI_ASSERT_ALWAYS(keyEvent && "Key Event handle is empty");
const BaseObject& object = keyEvent.GetBaseObject();
- return static_cast< const Internal::KeyEvent& >( object );
+ return static_cast<const Internal::KeyEvent&>(object);
}
} // namespace Dali
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/events/key-event-processor.h>
// INTERNAL INCLUDES
-#include <dali/public-api/events/key-event.h>
-#include <dali/internal/event/events/key-event-impl.h>
-#include <dali/internal/event/common/scene-impl.h>
#include <dali/integration-api/events/key-event-integ.h>
+#include <dali/internal/event/common/scene-impl.h>
+#include <dali/internal/event/events/key-event-impl.h>
+#include <dali/public-api/events/key-event.h>
namespace Dali
{
-
namespace Internal
{
-
-KeyEventProcessor::KeyEventProcessor( Scene& scene )
-: mScene( scene )
+KeyEventProcessor::KeyEventProcessor(Scene& scene)
+: mScene(scene)
{
}
KeyEventProcessor::~KeyEventProcessor() = default;
-void KeyEventProcessor::ProcessKeyEvent( const Integration::KeyEvent& event )
+void KeyEventProcessor::ProcessKeyEvent(const Integration::KeyEvent& event)
{
- KeyEventPtr keyEvent( new KeyEvent( event.keyName, event.logicalKey, event.keyString, event.keyCode, event.keyModifier, event.time, static_cast<Dali::KeyEvent::State>( event.state ), event.compose, event.deviceName, event.deviceClass, event.deviceSubclass ) );
- Dali::KeyEvent keyEventHandle( keyEvent.Get() );
+ KeyEventPtr keyEvent(new KeyEvent(event.keyName, event.logicalKey, event.keyString, event.keyCode, event.keyModifier, event.time, static_cast<Dali::KeyEvent::State>(event.state), event.compose, event.deviceName, event.deviceClass, event.deviceSubclass));
+ Dali::KeyEvent keyEventHandle(keyEvent.Get());
// Emit the key event signal from the scene.
- bool consumed = mScene.EmitKeyEventGeneratedSignal( keyEventHandle );
- if( !consumed )
+ bool consumed = mScene.EmitKeyEventGeneratedSignal(keyEventHandle);
+ if(!consumed)
{
- mScene.EmitKeyEventSignal( keyEventHandle );
+ mScene.EmitKeyEventSignal(keyEventHandle);
}
-
}
} // namespace Internal
#define DALI_INTERNAL_KEY_EVENT_PROCESSOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Integration
{
struct KeyEvent;
namespace Internal
{
-
class Scene;
class Stage;
class KeyEventProcessor
{
public:
-
/**
* Create a Key event processor.
* @param[in] scene The scene the event processor belongs to.
*/
- KeyEventProcessor( Scene& scene );
+ KeyEventProcessor(Scene& scene);
/**
* Non-virtual destructor; KeyEventProcessor is not a base class
void ProcessKeyEvent(const Integration::KeyEvent& event);
private:
-
// Undefined
KeyEventProcessor(const KeyEventProcessor&);
KeyEventProcessor& operator=(const KeyEventProcessor& rhs);
private:
-
Scene& mScene; ///< Used to deliver key events
};
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
#include <dali/internal/event/events/gesture-event-processor.h>
+#include <dali/public-api/object/type-registry.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
// Signals
const char* const SIGNAL_LONG_PRESS_DETECTED = "longPressDetected";
return Dali::LongPressGestureDetector::New();
}
-TypeRegistration mType( typeid(Dali::LongPressGestureDetector), typeid(Dali::GestureDetector), Create );
-
-SignalConnectorType signalConnector1( mType, SIGNAL_LONG_PRESS_DETECTED, &LongPressGestureDetector::DoConnectSignal );
+TypeRegistration mType(typeid(Dali::LongPressGestureDetector), typeid(Dali::GestureDetector), Create);
-}
+SignalConnectorType signalConnector1(mType, SIGNAL_LONG_PRESS_DETECTED, &LongPressGestureDetector::DoConnectSignal);
+} // namespace
namespace
{
void LongPressGestureDetector::SetTouchesRequired(unsigned int touches)
{
- DALI_ASSERT_ALWAYS( touches > 0 && "Can only set a positive number of required touches" );
+ DALI_ASSERT_ALWAYS(touches > 0 && "Can only set a positive number of required touches");
- if (mMinimumTouchesRequired != touches || mMaximumTouchesRequired != touches)
+ if(mMinimumTouchesRequired != touches || mMaximumTouchesRequired != touches)
{
mMinimumTouchesRequired = mMaximumTouchesRequired = touches;
- if (!mAttachedActors.empty())
+ if(!mAttachedActors.empty())
{
mGestureEventProcessor.GestureDetectorUpdated(this);
}
DALI_ASSERT_ALWAYS(maxTouches > 0 && "Can only set a positive number of minimum touches");
DALI_ASSERT_ALWAYS(minTouches <= maxTouches && "Number of minimum touches must be less than maximum");
- if (mMinimumTouchesRequired != minTouches || mMaximumTouchesRequired != maxTouches)
+ if(mMinimumTouchesRequired != minTouches || mMaximumTouchesRequired != maxTouches)
{
mMinimumTouchesRequired = minTouches;
mMaximumTouchesRequired = maxTouches;
- if (!mAttachedActors.empty())
+ if(!mAttachedActors.empty())
{
mGestureEventProcessor.GestureDetectorUpdated(this);
}
void LongPressGestureDetector::EmitLongPressGestureSignal(Dali::Actor pressedActor, const Dali::LongPressGesture& longPress)
{
// Guard against destruction during signal emission
- Dali::LongPressGestureDetector handle( this );
+ Dali::LongPressGestureDetector handle(this);
- mDetectedSignal.Emit( pressedActor, longPress );
+ mDetectedSignal.Emit(pressedActor, longPress);
}
-bool LongPressGestureDetector::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool LongPressGestureDetector::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( true );
- LongPressGestureDetector* gesture = static_cast< LongPressGestureDetector* >(object); // TypeRegistry guarantees that this is the correct type.
+ bool connected(true);
+ LongPressGestureDetector* gesture = static_cast<LongPressGestureDetector*>(object); // TypeRegistry guarantees that this is the correct type.
- if ( 0 == strcmp( signalName.c_str(), SIGNAL_LONG_PRESS_DETECTED ) )
+ if(0 == strcmp(signalName.c_str(), SIGNAL_LONG_PRESS_DETECTED))
{
- gesture->DetectedSignal().Connect( tracker, functor );
+ gesture->DetectedSignal().Connect(tracker, functor);
}
else
{
#define DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_IMPL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/events/long-press-gesture-detector.h>
#include <dali/internal/event/events/gesture-detector-impl.h>
+#include <dali/public-api/events/long-press-gesture-detector.h>
namespace Dali
{
-
namespace Internal
{
-
class LongPressGestureDetector;
using LongPressGestureDetectorPtr = IntrusivePtr<LongPressGestureDetector>;
class LongPressGestureDetector : public GestureDetector
{
public: // Creation
-
/**
* Create a new gesture detector.
* @return A smart-pointer to the newly allocated detector.
LongPressGestureDetector(unsigned int minTouches, unsigned int maxTouches);
public:
-
/**
* @copydoc Dali::LongPressGestureDetector::SetTouchesRequired(unsigned int)
*/
uint32_t GetMinimumHoldingTime() const;
public:
-
/**
* Called by the LongPressGestureProcessor when a tap gesture event occurs within the bounds of our
* attached actor.
void EmitLongPressGestureSignal(Dali::Actor pressedActor, const Dali::LongPressGesture& longPress);
public: // Signals
-
/**
* @copydoc Dali::LongPressGestureDetector::DetectedSignal()
*/
* @return True if the signal was connected.
* @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
*/
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
protected:
-
/**
* A reference counted object may only be deleted by calling Unreference()
*/
~LongPressGestureDetector() override;
private:
-
// Undefined
LongPressGestureDetector(const LongPressGestureDetector&);
LongPressGestureDetector& operator=(const LongPressGestureDetector& rhs);
private: // GestureDetector overrides
-
/**
* @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
*/
void OnActorDestroyed(Object& object) override;
private:
-
Dali::LongPressGestureDetector::DetectedSignalType mDetectedSignal;
unsigned int mMinimumTouchesRequired;
inline Internal::LongPressGestureDetector& GetImplementation(Dali::LongPressGestureDetector& detector)
{
- DALI_ASSERT_ALWAYS( detector && "LongPressGestureDetector handle is empty" );
+ DALI_ASSERT_ALWAYS(detector && "LongPressGestureDetector handle is empty");
BaseObject& handle = detector.GetBaseObject();
inline const Internal::LongPressGestureDetector& GetImplementation(const Dali::LongPressGestureDetector& detector)
{
- DALI_ASSERT_ALWAYS( detector && "LongPressGestureDetector handle is empty" );
+ DALI_ASSERT_ALWAYS(detector && "LongPressGestureDetector handle is empty");
const BaseObject& handle = detector.GetBaseObject();
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
-LongPressGestureEvent::LongPressGestureEvent( GestureState state )
-: GestureEvent( GestureType::LONG_PRESS, state ),
+LongPressGestureEvent::LongPressGestureEvent(GestureState state)
+: GestureEvent(GestureType::LONG_PRESS, state),
numberOfTouches(1)
{
}
#define DALI_INTERNAL_EVENT_LONG_PRESS_GESTURE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* If the adaptor detects a long press gesture, then it should create an instance of this structure and
* send it to the Core.
* @param[in] state STARTED, when we detect a long press.
* FINISHED, when all touches are finished.
*/
- LongPressGestureEvent( GestureState state );
+ LongPressGestureEvent(GestureState state);
/**
* Virtual destructor
#define DALI_INTERNAL_LONG_PRESS_GESTURE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
class LongPressGesture;
using LongPressGesturePtr = IntrusivePtr<LongPressGesture>;
class LongPressGesture final : public Gesture
{
public:
-
/**
* Default Constructor
* @param[in] state STARTED, when we detect a long press.
* FINISHED, when all touches are finished.
*/
- LongPressGesture( GestureState state )
- : Gesture( GestureType::LONG_PRESS, state )
+ LongPressGesture(GestureState state)
+ : Gesture(GestureType::LONG_PRESS, state)
{
}
- LongPressGesture(const LongPressGesture&) = delete; ///< Deleted copy constructor
- LongPressGesture(LongPressGesture&&) = delete; ///< Deleted move constructor
+ LongPressGesture(const LongPressGesture&) = delete; ///< Deleted copy constructor
+ LongPressGesture(LongPressGesture&&) = delete; ///< Deleted move constructor
LongPressGesture& operator=(const LongPressGesture&) = delete; ///< Deleted copy assignment operator
- LongPressGesture& operator=(LongPressGesture&&) = delete; ///< Deleted move assignment operator
+ LongPressGesture& operator=(LongPressGesture&&) = delete; ///< Deleted move assignment operator
/**
* @brief Set the number of touch points.
* @param[in] numberOfTouches The number of touch points to set.
*/
- inline void SetNumberOfTouches( uint32_t numberOfTouches )
+ inline void SetNumberOfTouches(uint32_t numberOfTouches)
{
mNumberOfTouches = numberOfTouches;
}
* @brief Set This is the point, in screen coordinates.
* @param[in] screenPoint The point in screen coordinates to set.
*/
- inline void SetScreenPoint( const Vector2& screenPoint )
+ inline void SetScreenPoint(const Vector2& screenPoint)
{
mScreenPoint = screenPoint;
}
* @brief Set This is the point, in local actor coordinates.
* @param[in] localPoint The point in local actor coordinates to set.
*/
- inline void SetLocalPoint( const Vector2& localPoint )
+ inline void SetLocalPoint(const Vector2& localPoint)
{
mLocalPoint = localPoint;
}
}
private:
-
/**
* @brief Virtual destructor
*
~LongPressGesture() override = default;
private:
- Vector2 mScreenPoint;
- Vector2 mLocalPoint;
+ Vector2 mScreenPoint;
+ Vector2 mLocalPoint;
uint32_t mNumberOfTouches{1u};
};
// Helpers for public-api forwarding methods
-inline Internal::LongPressGesture& GetImplementation( Dali::LongPressGesture& longPressGesture )
+inline Internal::LongPressGesture& GetImplementation(Dali::LongPressGesture& longPressGesture)
{
- DALI_ASSERT_ALWAYS( longPressGesture && "longPressGesture handle is empty" );
+ DALI_ASSERT_ALWAYS(longPressGesture && "longPressGesture handle is empty");
BaseObject& object = longPressGesture.GetBaseObject();
- return static_cast< Internal::LongPressGesture& >( object );
+ return static_cast<Internal::LongPressGesture&>(object);
}
-inline const Internal::LongPressGesture& GetImplementation( const Dali::LongPressGesture& longPressGesture )
+inline const Internal::LongPressGesture& GetImplementation(const Dali::LongPressGesture& longPressGesture)
{
- DALI_ASSERT_ALWAYS( longPressGesture && "longPressGesture handle is empty" );
+ DALI_ASSERT_ALWAYS(longPressGesture && "longPressGesture handle is empty");
const BaseObject& object = longPressGesture.GetBaseObject();
- return static_cast< const Internal::LongPressGesture& >( object );
+ return static_cast<const Internal::LongPressGesture&>(object);
}
} // namespace Dali
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <algorithm>
// INTERNAL INCLUDES
-#include <dali/public-api/actors/actor.h>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/internal/event/events/long-press-gesture/long-press-gesture-impl.h>
-#include <dali/internal/event/events/long-press-gesture/long-press-gesture-event.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/common/scene-impl.h>
-#include <dali/internal/event/render-tasks/render-task-impl.h>
-#include <dali/internal/event/events/long-press-gesture/long-press-gesture-recognizer.h>
#include <dali/internal/event/events/gesture-requests.h>
+#include <dali/internal/event/events/long-press-gesture/long-press-gesture-event.h>
+#include <dali/internal/event/events/long-press-gesture/long-press-gesture-impl.h>
+#include <dali/internal/event/events/long-press-gesture/long-press-gesture-recognizer.h>
+#include <dali/internal/event/render-tasks/render-task-impl.h>
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/common/dali-common.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
const unsigned long DEFAULT_MINIMUM_HOLDING_TIME = 500u;
/**
* @param[in] localPoint Relative to the actor attached to the detector.
*/
void EmitLongPressSignal(
- Actor* actor,
- const GestureDetectorContainer& gestureDetectors,
- const LongPressGestureEvent& longPressEvent,
- Vector2 localPoint)
+ Actor* actor,
+ const GestureDetectorContainer& gestureDetectors,
+ const LongPressGestureEvent& longPressEvent,
+ Vector2 localPoint)
{
- Internal::LongPressGesturePtr longPress( new Internal::LongPressGesture(longPressEvent.state ) );
- longPress->SetTime( longPressEvent.time );
- longPress->SetNumberOfTouches( longPressEvent.numberOfTouches );
- longPress->SetScreenPoint( longPressEvent.point );
- longPress->SetLocalPoint( localPoint );
+ Internal::LongPressGesturePtr longPress(new Internal::LongPressGesture(longPressEvent.state));
+ longPress->SetTime(longPressEvent.time);
+ longPress->SetNumberOfTouches(longPressEvent.numberOfTouches);
+ longPress->SetScreenPoint(longPressEvent.point);
+ longPress->SetLocalPoint(localPoint);
- Dali::Actor actorHandle( actor );
+ Dali::Actor actorHandle(actor);
const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end();
- for ( GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter )
+ for(GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter)
{
- static_cast< LongPressGestureDetector* >( *iter )->EmitLongPressGestureSignal( actorHandle, Dali::LongPressGesture( longPress.Get() ) );
+ static_cast<LongPressGestureDetector*>(*iter)->EmitLongPressGestureSignal(actorHandle, Dali::LongPressGesture(longPress.Get()));
}
}
* Constructor
* @param[in] actor The actor to check whether it is attached.
*/
- IsNotAttachedFunctor( Actor* actor )
- : actorToCheck( actor )
+ IsNotAttachedFunctor(Actor* actor)
+ : actorToCheck(actor)
{
}
* @param[in] detector The detector to check.
* @return true, if not attached, false otherwise.
*/
- bool operator()( const GestureDetector* detector ) const
+ bool operator()(const GestureDetector* detector) const
{
- return !detector->IsAttached( *actorToCheck );
+ return !detector->IsAttached(*actorToCheck);
}
Actor* actorToCheck; ///< The actor to check whether it is attached or not.
} // unnamed namespace
LongPressGestureProcessor::LongPressGestureProcessor()
-: GestureProcessor( GestureType::LONG_PRESS ),
+: GestureProcessor(GestureType::LONG_PRESS),
mLongPressGestureDetectors(),
mCurrentEmitters(),
mCurrentRenderTask(),
- mMinTouchesRequired( 1 ),
- mMaxTouchesRequired( 1 ),
- mCurrentLongPressEvent( nullptr ),
- mMinimumHoldingTime( DEFAULT_MINIMUM_HOLDING_TIME )
+ mMinTouchesRequired(1),
+ mMaxTouchesRequired(1),
+ mCurrentLongPressEvent(nullptr),
+ mMinimumHoldingTime(DEFAULT_MINIMUM_HOLDING_TIME)
{
}
LongPressGestureProcessor::~LongPressGestureProcessor() = default;
-void LongPressGestureProcessor::Process( Scene& scene, const LongPressGestureEvent& longPressEvent )
+void LongPressGestureProcessor::Process(Scene& scene, const LongPressGestureEvent& longPressEvent)
{
- switch ( longPressEvent.state )
+ switch(longPressEvent.state)
{
case GestureState::POSSIBLE:
{
ResetActor();
HitTestAlgorithm::Results hitTestResults;
- if( HitTest( scene, longPressEvent.point, hitTestResults ) )
+ if(HitTest(scene, longPressEvent.point, hitTestResults))
{
- SetActor( &GetImplementation( hitTestResults.actor ) );
+ SetActor(&GetImplementation(hitTestResults.actor));
}
break;
}
case GestureState::STARTED:
{
Actor* currentGesturedActor = GetCurrentGesturedActor();
- if ( currentGesturedActor )
+ if(currentGesturedActor)
{
HitTestAlgorithm::Results hitTestResults;
- HitTest( scene, longPressEvent.point, hitTestResults );
+ HitTest(scene, longPressEvent.point, hitTestResults);
- if ( hitTestResults.actor && ( currentGesturedActor == &GetImplementation( hitTestResults.actor ) ) )
+ if(hitTestResults.actor && (currentGesturedActor == &GetImplementation(hitTestResults.actor)))
{
// Record the current render-task for Screen->Actor coordinate conversions
mCurrentRenderTask = hitTestResults.renderTask;
// Set mCurrentLongPressEvent to use inside overridden methods called from ProcessAndEmit()
mCurrentLongPressEvent = &longPressEvent;
- ProcessAndEmit( hitTestResults );
+ ProcessAndEmit(hitTestResults);
mCurrentLongPressEvent = nullptr;
}
else
// Check if actor is still touchable.
Actor* currentGesturedActor = GetCurrentGesturedActor();
- if ( currentGesturedActor )
+ if(currentGesturedActor)
{
- if ( currentGesturedActor->IsHittable() && !mCurrentEmitters.empty() && mCurrentRenderTask )
+ if(currentGesturedActor->IsHittable() && !mCurrentEmitters.empty() && mCurrentRenderTask)
{
// Ensure actor is still attached to the emitters, if it is not then remove the emitter.
- GestureDetectorContainer::iterator endIter = std::remove_if( mCurrentEmitters.begin(), mCurrentEmitters.end(), IsNotAttachedFunctor(currentGesturedActor) );
- mCurrentEmitters.erase( endIter, mCurrentEmitters.end() );
+ GestureDetectorContainer::iterator endIter = std::remove_if(mCurrentEmitters.begin(), mCurrentEmitters.end(), IsNotAttachedFunctor(currentGesturedActor));
+ mCurrentEmitters.erase(endIter, mCurrentEmitters.end());
- if ( !mCurrentEmitters.empty() )
+ if(!mCurrentEmitters.empty())
{
- Vector2 actorCoords;
+ Vector2 actorCoords;
RenderTask& renderTaskImpl = *mCurrentRenderTask.Get();
- currentGesturedActor->ScreenToLocal( renderTaskImpl, actorCoords.x, actorCoords.y, longPressEvent.point.x, longPressEvent.point.y );
+ currentGesturedActor->ScreenToLocal(renderTaskImpl, actorCoords.x, actorCoords.y, longPressEvent.point.x, longPressEvent.point.y);
- EmitLongPressSignal( currentGesturedActor, mCurrentEmitters, longPressEvent, actorCoords );
+ EmitLongPressSignal(currentGesturedActor, mCurrentEmitters, longPressEvent, actorCoords);
}
}
case GestureState::CONTINUING:
{
- DALI_ABORT( "Incorrect state received from Integration layer: CONTINUING\n" );
+ DALI_ABORT("Incorrect state received from Integration layer: CONTINUING\n");
break;
}
case GestureState::CLEAR:
{
- DALI_ABORT( "Incorrect state received from Integration layer: CLEAR\n" );
+ DALI_ABORT("Incorrect state received from Integration layer: CLEAR\n");
break;
}
}
}
-void LongPressGestureProcessor::AddGestureDetector( LongPressGestureDetector* gestureDetector, Scene& scene )
+void LongPressGestureProcessor::AddGestureDetector(LongPressGestureDetector* gestureDetector, Scene& scene)
{
bool firstRegistration(mLongPressGestureDetectors.empty());
mLongPressGestureDetectors.push_back(gestureDetector);
- if (firstRegistration)
+ if(firstRegistration)
{
mMinTouchesRequired = gestureDetector->GetMinimumTouchesRequired();
mMaxTouchesRequired = gestureDetector->GetMaximumTouchesRequired();
Size size = scene.GetSize();
- mGestureRecognizer = new LongPressGestureRecognizer(*this, Vector2(size.width, size.height), static_cast<const LongPressGestureRequest&>(request), mMinimumHoldingTime );
+ mGestureRecognizer = new LongPressGestureRecognizer(*this, Vector2(size.width, size.height), static_cast<const LongPressGestureRequest&>(request), mMinimumHoldingTime);
}
else
{
}
}
-void LongPressGestureProcessor::RemoveGestureDetector( LongPressGestureDetector* gestureDetector )
+void LongPressGestureProcessor::RemoveGestureDetector(LongPressGestureDetector* gestureDetector)
{
// Find detector ...
- LongPressGestureDetectorContainer::iterator endIter = std::remove( mLongPressGestureDetectors.begin(), mLongPressGestureDetectors.end(), gestureDetector );
- DALI_ASSERT_DEBUG( endIter != mLongPressGestureDetectors.end() );
+ LongPressGestureDetectorContainer::iterator endIter = std::remove(mLongPressGestureDetectors.begin(), mLongPressGestureDetectors.end(), gestureDetector);
+ DALI_ASSERT_DEBUG(endIter != mLongPressGestureDetectors.end());
// ... and remove it
- mLongPressGestureDetectors.erase( endIter, mLongPressGestureDetectors.end() );
+ mLongPressGestureDetectors.erase(endIter, mLongPressGestureDetectors.end());
- if ( mLongPressGestureDetectors.empty() )
+ if(mLongPressGestureDetectors.empty())
{
mGestureRecognizer = nullptr;
}
}
}
-void LongPressGestureProcessor::GestureDetectorUpdated( LongPressGestureDetector* gestureDetector )
+void LongPressGestureProcessor::GestureDetectorUpdated(LongPressGestureDetector* gestureDetector)
{
- DALI_ASSERT_DEBUG( find( mLongPressGestureDetectors.begin(), mLongPressGestureDetectors.end(), gestureDetector ) != mLongPressGestureDetectors.end() );
+ DALI_ASSERT_DEBUG(find(mLongPressGestureDetectors.begin(), mLongPressGestureDetectors.end(), gestureDetector) != mLongPressGestureDetectors.end());
UpdateDetection();
}
-void LongPressGestureProcessor::SetMinimumHoldingTime( uint32_t time )
+void LongPressGestureProcessor::SetMinimumHoldingTime(uint32_t time)
{
- if( time > 0u && mMinimumHoldingTime != time )
+ if(time > 0u && mMinimumHoldingTime != time)
{
mMinimumHoldingTime = time;
- if( mGestureRecognizer )
+ if(mGestureRecognizer)
{
- LongPressGestureRecognizer* longPressRecognizer = dynamic_cast<LongPressGestureRecognizer*>( mGestureRecognizer.Get() );
- if( longPressRecognizer )
+ LongPressGestureRecognizer* longPressRecognizer = dynamic_cast<LongPressGestureRecognizer*>(mGestureRecognizer.Get());
+ if(longPressRecognizer)
{
- longPressRecognizer->SetMinimumHoldingTime( time );
+ longPressRecognizer->SetMinimumHoldingTime(time);
}
}
}
unsigned int minimumRequired = UINT_MAX;
unsigned int maximumRequired = 0;
- for ( LongPressGestureDetectorContainer::iterator iter = mLongPressGestureDetectors.begin(), endIter = mLongPressGestureDetectors.end(); iter != endIter; ++iter )
+ for(LongPressGestureDetectorContainer::iterator iter = mLongPressGestureDetectors.begin(), endIter = mLongPressGestureDetectors.end(); iter != endIter; ++iter)
{
LongPressGestureDetector* current(*iter);
- if( current )
+ if(current)
{
unsigned int minimum = current->GetMinimumTouchesRequired();
- if (minimum < minimumRequired)
+ if(minimum < minimumRequired)
{
minimumRequired = minimum;
}
unsigned int maximum = current->GetMaximumTouchesRequired();
- if ( maximum > maximumRequired )
+ if(maximum > maximumRequired)
{
maximumRequired = maximum;
}
}
}
- if ( (minimumRequired != mMinTouchesRequired) || (maximumRequired != mMaxTouchesRequired) )
+ if((minimumRequired != mMinTouchesRequired) || (maximumRequired != mMaxTouchesRequired))
{
mMinTouchesRequired = minimumRequired;
mMaxTouchesRequired = maximumRequired;
mCurrentEmitters.clear();
}
-bool LongPressGestureProcessor::CheckGestureDetector( GestureDetector* detector, Actor* actor )
+bool LongPressGestureProcessor::CheckGestureDetector(GestureDetector* detector, Actor* actor)
{
- DALI_ASSERT_DEBUG( mCurrentLongPressEvent );
+ DALI_ASSERT_DEBUG(mCurrentLongPressEvent);
- LongPressGestureDetector* longPressDetector ( static_cast< LongPressGestureDetector* >( detector ) );
+ LongPressGestureDetector* longPressDetector(static_cast<LongPressGestureDetector*>(detector));
- return ( longPressDetector->GetMinimumTouchesRequired() <= mCurrentLongPressEvent->numberOfTouches ) &&
- ( longPressDetector->GetMaximumTouchesRequired() >= mCurrentLongPressEvent->numberOfTouches );
+ return (longPressDetector->GetMinimumTouchesRequired() <= mCurrentLongPressEvent->numberOfTouches) &&
+ (longPressDetector->GetMaximumTouchesRequired() >= mCurrentLongPressEvent->numberOfTouches);
}
-void LongPressGestureProcessor::EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
+void LongPressGestureProcessor::EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates)
{
- DALI_ASSERT_DEBUG( mCurrentLongPressEvent );
+ DALI_ASSERT_DEBUG(mCurrentLongPressEvent);
mCurrentEmitters.clear();
ResetActor();
- EmitLongPressSignal( actor, gestureDetectors, *mCurrentLongPressEvent, actorCoordinates );
+ EmitLongPressSignal(actor, gestureDetectors, *mCurrentLongPressEvent, actorCoordinates);
- if ( actor->OnScene() )
+ if(actor->OnScene())
{
mCurrentEmitters = gestureDetectors;
- SetActor( actor );
+ SetActor(actor);
}
}
#define DALI_INTERNAL_LONG_PRESS_GESTURE_EVENT_PROCESSOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.h>
#include <dali/internal/event/events/gesture-processor.h>
+#include <dali/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.h>
#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class Stage;
class Scene;
class LongPressGestureProcessor : public GestureProcessor, public RecognizerObserver<LongPressGestureEvent>
{
public:
-
/**
* Create a long press gesture processor.
*/
~LongPressGestureProcessor() override;
public: // To be called by GestureEventProcessor
-
/**
* This method is called whenever a long press gesture event occurs.
* @param[in] scene The scene the long press gesture event occurs in.
* @param[in] longPressEvent The event that has occurred.
*/
- void Process( Scene& scene, const LongPressGestureEvent& longPressEvent ) override;
+ void Process(Scene& scene, const LongPressGestureEvent& longPressEvent) override;
/**
* Adds a gesture detector to this gesture processor.
* @param[in] gestureDetector The gesture detector being added.
* @param[in] scene The scene the long press gesture event occurs in.
*/
- void AddGestureDetector( LongPressGestureDetector* gestureDetector, Scene& scene );
+ void AddGestureDetector(LongPressGestureDetector* gestureDetector, Scene& scene);
/**
* Removes the specified gesture detector from this gesture processor. If, after removing this
* the gesture from the adaptor.
* @param[in] gestureDetector The gesture detector being removed.
*/
- void RemoveGestureDetector( LongPressGestureDetector* gestureDetector );
+ void RemoveGestureDetector(LongPressGestureDetector* gestureDetector);
/**
* This method updates the gesture detection parameters.
*
* @param[in] value The time value in milliseconds
*/
- void SetMinimumHoldingTime( uint32_t time );
+ void SetMinimumHoldingTime(uint32_t time);
/**
* @return The minimum holding time required to be recognized as a long press gesture in milliseconds
uint32_t GetMinimumHoldingTime() const;
private:
-
// Undefined
- LongPressGestureProcessor( const LongPressGestureProcessor& );
- LongPressGestureProcessor& operator=( const LongPressGestureProcessor& rhs );
+ LongPressGestureProcessor(const LongPressGestureProcessor&);
+ LongPressGestureProcessor& operator=(const LongPressGestureProcessor& rhs);
private:
-
/**
* Iterates through our GestureDetectors and determines if we need to ask the adaptor to update
* its detection policy. If it does, it sends the appropriate gesture update request to adaptor.
/**
* @copydoc GestureProcessor::CheckGestureDetector()
*/
- bool CheckGestureDetector( GestureDetector* detector, Actor* actor ) override;
+ bool CheckGestureDetector(GestureDetector* detector, Actor* actor) override;
/**
* @copydoc GestureProcessor::EmitGestureSignal()
*/
- void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates ) override;
+ void EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates) override;
private:
-
LongPressGestureDetectorContainer mLongPressGestureDetectors;
GestureDetectorContainer mCurrentEmitters;
- RenderTaskPtr mCurrentRenderTask;
+ RenderTaskPtr mCurrentRenderTask;
uint32_t mMinTouchesRequired;
uint32_t mMaxTouchesRequired;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/devel-api/events/touch-point.h>
#include <dali/public-api/math/vector2.h>
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/events/gesture-requests.h>
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/integration-api/platform-abstraction.h>
+#include <dali/internal/event/common/thread-local-storage.h>
+#include <dali/internal/event/events/gesture-requests.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
// TODO: Set these according to DPI
} // unnamed namespace
-LongPressGestureRecognizer::LongPressGestureRecognizer(Observer& observer, Vector2 screenSize, const LongPressGestureRequest& request, uint32_t minimumHoldingTime )
-: GestureRecognizer( screenSize, GestureType::LONG_PRESS ),
- mObserver( observer ),
- mState( CLEAR ),
- mMinimumTouchesRequired( request.minTouches ),
- mMaximumTouchesRequired( request.maxTouches ),
- mTouchTime( 0 ),
- mTimerId( 0 ),
- mMinimumHoldingTime( minimumHoldingTime )
+LongPressGestureRecognizer::LongPressGestureRecognizer(Observer& observer, Vector2 screenSize, const LongPressGestureRequest& request, uint32_t minimumHoldingTime)
+: GestureRecognizer(screenSize, GestureType::LONG_PRESS),
+ mObserver(observer),
+ mState(CLEAR),
+ mMinimumTouchesRequired(request.minTouches),
+ mMaximumTouchesRequired(request.maxTouches),
+ mTouchTime(0),
+ mTimerId(0),
+ mMinimumHoldingTime(minimumHoldingTime)
{
}
LongPressGestureRecognizer::~LongPressGestureRecognizer()
{
- if( mTimerId != 0 && ThreadLocalStorage::Created() )
+ if(mTimerId != 0 && ThreadLocalStorage::Created())
{
Dali::Integration::PlatformAbstraction& platformAbstraction = ThreadLocalStorage::Get().GetPlatformAbstraction();
platformAbstraction.CancelTimer(mTimerId);
void LongPressGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
{
- unsigned int pointCount( event.GetPointCount() );
+ unsigned int pointCount(event.GetPointCount());
Dali::Integration::PlatformAbstraction& platformAbstraction = ThreadLocalStorage::Get().GetPlatformAbstraction();
- GestureRecognizerPtr ptr(this); // To keep us from being destroyed during the life-time of this method
+ GestureRecognizerPtr ptr(this); // To keep us from being destroyed during the life-time of this method
- switch (mState)
+ switch(mState)
{
// CLEAR: Wait till one point touches the screen before starting timer.
case CLEAR:
{
const Integration::Point& point = event.points[0];
- if ( point.GetState() == PointState::DOWN )
+ if(point.GetState() == PointState::DOWN)
{
mTouchPositions.clear();
mTouchPositions[point.GetDeviceId()] = point.GetScreenPosition();
mTouchTime = event.time;
- if( mTimerId != 0 )
+ if(mTimerId != 0)
{
platformAbstraction.CancelTimer(mTimerId);
}
- mTimerId = platformAbstraction.StartTimer( mMinimumHoldingTime, MakeCallback( this, &LongPressGestureRecognizer::TimerCallback ) );
+ mTimerId = platformAbstraction.StartTimer(mMinimumHoldingTime, MakeCallback(this, &LongPressGestureRecognizer::TimerCallback));
// A long press gesture may be possible, tell Core about this and change state to TOUCHED.
mState = TOUCHED;
- EmitGesture( GestureState::POSSIBLE );
+ EmitGesture(GestureState::POSSIBLE);
}
break;
// TOUCHED: Monitor movement and addition/removal of points.
case TOUCHED:
{
- if (pointCount > mMaximumTouchesRequired)
+ if(pointCount > mMaximumTouchesRequired)
{
// A long press did not occur, tell Core that it was cancelled and change state to FAILED.
- EmitGesture( GestureState::CANCELLED );
+ EmitGesture(GestureState::CANCELLED);
mTouchPositions.clear();
platformAbstraction.CancelTimer(mTimerId);
mTimerId = 0;
- mState = FAILED;
+ mState = FAILED;
break;
}
bool endLoop(false);
- for ( Integration::PointContainerConstIterator iter = event.points.begin(), endIter = event.points.end();
- iter != endIter && !endLoop; ++iter)
+ for(Integration::PointContainerConstIterator iter = event.points.begin(), endIter = event.points.end();
+ iter != endIter && !endLoop;
+ ++iter)
{
- switch( iter->GetState() )
+ switch(iter->GetState())
{
// add point.
case PointState::DOWN:
case PointState::INTERRUPTED:
{
// System has interrupted us, long press is not possible, inform Core
- EmitGesture( GestureState::CANCELLED );
+ EmitGesture(GestureState::CANCELLED);
mTouchPositions.clear();
platformAbstraction.CancelTimer(mTimerId);
mTimerId = 0;
- mState = ( pointCount == 1 ) ? CLEAR : FAILED; // Change state to CLEAR if only one point, FAILED otherwise.
- endLoop = true;
+ mState = (pointCount == 1) ? CLEAR : FAILED; // Change state to CLEAR if only one point, FAILED otherwise.
+ endLoop = true;
break;
}
case PointState::MOTION:
{
- const Vector2 touchPosition( mTouchPositions[iter->GetDeviceId()] - iter->GetScreenPosition() );
- float distanceSquared = touchPosition.LengthSquared();
+ const Vector2 touchPosition(mTouchPositions[iter->GetDeviceId()] - iter->GetScreenPosition());
+ float distanceSquared = touchPosition.LengthSquared();
- if (distanceSquared > ( MAXIMUM_MOTION_ALLOWED * MAXIMUM_MOTION_ALLOWED ) )
+ if(distanceSquared > (MAXIMUM_MOTION_ALLOWED * MAXIMUM_MOTION_ALLOWED))
{
// We have moved more than the allowable motion for a long press gesture. Inform Core and change state to FAILED.
- EmitGesture( GestureState::CANCELLED );
+ EmitGesture(GestureState::CANCELLED);
platformAbstraction.CancelTimer(mTimerId);
mTimerId = 0;
- mState = FAILED;
- endLoop = true;
+ mState = FAILED;
+ endLoop = true;
}
break;
}
case FINISHED:
{
// eventually the final touch point will be removed, marking the end of this gesture.
- if ( pointCount == 1 )
+ if(pointCount == 1)
{
PointState::Type primaryPointState = event.points[0].GetState();
- if ( (primaryPointState == PointState::UP) || (primaryPointState == PointState::INTERRUPTED) )
+ if((primaryPointState == PointState::UP) || (primaryPointState == PointState::INTERRUPTED))
{
if(mState == FINISHED)
{
mMaximumTouchesRequired = longPress.maxTouches;
}
-void LongPressGestureRecognizer::SetMinimumHoldingTime( uint32_t time )
+void LongPressGestureRecognizer::SetMinimumHoldingTime(uint32_t time)
{
mMinimumHoldingTime = time;
}
-
bool LongPressGestureRecognizer::TimerCallback()
{
EmitGesture(GestureState::STARTED);
void LongPressGestureRecognizer::EmitGesture(GestureState state)
{
- unsigned int touchPoints ( static_cast<unsigned int>( mTouchPositions.size() ) );
+ unsigned int touchPoints(static_cast<unsigned int>(mTouchPositions.size()));
// We should tell Core about the POSSIBLE and CANCELLED states regardless of whether we have satisfied long press requirements.
- if ( (state == GestureState::POSSIBLE) ||
- (state == GestureState::CANCELLED) ||
- (touchPoints >= mMinimumTouchesRequired) )
+ if((state == GestureState::POSSIBLE) ||
+ (state == GestureState::CANCELLED) ||
+ (touchPoints >= mMinimumTouchesRequired))
{
- LongPressGestureEvent longPress( state );
+ LongPressGestureEvent longPress(state);
longPress.numberOfTouches = touchPoints;
- for (std::map<int, Vector2>::iterator iter = mTouchPositions.begin(), endIter = mTouchPositions.end();
- iter != endIter; ++iter)
+ for(std::map<int, Vector2>::iterator iter = mTouchPositions.begin(), endIter = mTouchPositions.end();
+ iter != endIter;
+ ++iter)
{
longPress.point += iter->second;
}
- longPress.point /= static_cast<float>( touchPoints );
+ longPress.point /= static_cast<float>(touchPoints);
longPress.time = mTouchTime;
- if ( state != GestureState::POSSIBLE )
+ if(state != GestureState::POSSIBLE)
{
longPress.time += mMinimumHoldingTime;
}
- if( mScene )
+ if(mScene)
{
// Create another handle so the recognizer cannot be destroyed during process function
GestureRecognizerPtr recognizerHandle = this;
#define DALI_INTERNAL_LONG_PRESS_GESTURE_RECOGNIZER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Integration
{
struct TouchEvent;
namespace Internal
{
-
struct LongPressGestureRequest;
class CoreEventInterface;
class LongPressGestureRecognizer : public GestureRecognizer
{
public:
-
using Observer = RecognizerObserver<LongPressGestureEvent>;
/**
* @param[in] request The long press gesture request.
* @param[in] minimumHoldingTime The minimum holding time required in milliseconds.
*/
- LongPressGestureRecognizer( Observer& observer, Vector2 screenSize, const LongPressGestureRequest& request, uint32_t minimumHoldingTime );
+ LongPressGestureRecognizer(Observer& observer, Vector2 screenSize, const LongPressGestureRequest& request, uint32_t minimumHoldingTime);
/**
* Virtual destructor.
~LongPressGestureRecognizer() override;
public:
-
/**
* @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
*/
*
* @param[in] value The time value in milliseconds
*/
- void SetMinimumHoldingTime( uint32_t time );
+ void SetMinimumHoldingTime(uint32_t time);
private:
-
/**
* Timer Callback
* @return will return false; one-shot timer.
* Emits the long press gesture if all conditions are applicable.
* @param[in] state The state of this gesture event.
*/
- void EmitGesture( GestureState state );
+ void EmitGesture(GestureState state);
private:
-
// Reference to the gesture processor for this recognizer
Observer& mObserver;
*/
enum State
{
- CLEAR, ///< No gesture detected.
- TOUCHED, ///< User is touching the screen.
- FAILED, ///< Gesture has failed.
- FINISHED ///< Gesture has been detected and sent.
+ CLEAR, ///< No gesture detected.
+ TOUCHED, ///< User is touching the screen.
+ FAILED, ///< Gesture has failed.
+ FINISHED ///< Gesture has been detected and sent.
};
State mState; ///< The current state of the detector.
- unsigned int mMinimumTouchesRequired; ///< The minimum touches required before emitting a long press.
- unsigned int mMaximumTouchesRequired; ///< The maximum touches allowable. Any more and a long press is not emitted.
+ unsigned int mMinimumTouchesRequired; ///< The minimum touches required before emitting a long press.
+ unsigned int mMaximumTouchesRequired; ///< The maximum touches allowable. Any more and a long press is not emitted.
std::map<int, Vector2> mTouchPositions; ///< A map with all the touch down positions.
- uint32_t mTouchTime; ///< The time we first pressed down.
+ uint32_t mTouchTime; ///< The time we first pressed down.
uint32_t mTimerId;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
#if defined(DEBUG_ENABLED)
static bool HIERARCHY_GEOMETRY(true);
static bool HIERARCHY_HOVER_REQUIRED(true);
static bool HIERARCHY_HITTABLE(true);
-static const Debug::LogLevel HIERARCHY_DEBUG_LOG_LEVEL( Debug::Verbose );
+static const Debug::LogLevel HIERARCHY_DEBUG_LOG_LEVEL(Debug::Verbose);
-void PrintChildren( Debug::Filter* logFilter, Dali::Actor actor, int level )
+void PrintChildren(Debug::Filter* logFilter, Dali::Actor actor, int level)
{
std::ostringstream output;
- for ( int t = 0; t < level; ++t )
+ for(int t = 0; t < level; ++t)
{
output << " | ";
}
- output << actor.GetProperty< std::string >( Dali::Actor::Property::NAME ) << "(" << actor.GetTypeName() << ", " << actor.GetObjectPtr() << ")";
+ output << actor.GetProperty<std::string>(Dali::Actor::Property::NAME) << "(" << actor.GetTypeName() << ", " << actor.GetObjectPtr() << ")";
- if ( HIERARCHY_GEOMETRY )
+ if(HIERARCHY_GEOMETRY)
{
- output << " Pos: " << actor.GetCurrentProperty< Vector3 >( Dali::Actor::Property::WORLD_POSITION ) << " Size: " << actor.GetCurrentProperty< Vector3 >( Dali::Actor::Property::SIZE ) << " Scale: " << actor.GetCurrentProperty< Vector3 >( Dali::Actor::Property::WORLD_SCALE );
+ output << " Pos: " << actor.GetCurrentProperty<Vector3>(Dali::Actor::Property::WORLD_POSITION) << " Size: " << actor.GetCurrentProperty<Vector3>(Dali::Actor::Property::SIZE) << " Scale: " << actor.GetCurrentProperty<Vector3>(Dali::Actor::Property::WORLD_SCALE);
}
- if ( HIERARCHY_SENSITIVITY )
+ if(HIERARCHY_SENSITIVITY)
{
- output << " Sensitivity: " << ( IsActuallySensitive( &GetImplementation( actor ) ) ? "True " : "False " );
+ output << " Sensitivity: " << (IsActuallySensitive(&GetImplementation(actor)) ? "True " : "False ");
}
- if ( HIERARCHY_TOUCH_REQUIRED )
+ if(HIERARCHY_TOUCH_REQUIRED)
{
- output << " TouchRequired: " << ( GetImplementation(actor).GetTouchRequired() ? "True " : "False " );
+ output << " TouchRequired: " << (GetImplementation(actor).GetTouchRequired() ? "True " : "False ");
}
- if ( HIERARCHY_HOVER_REQUIRED )
+ if(HIERARCHY_HOVER_REQUIRED)
{
- output << " HoverRequired: " << ( GetImplementation(actor).GetHoverRequired() ? "True " : "False " );
+ output << " HoverRequired: " << (GetImplementation(actor).GetHoverRequired() ? "True " : "False ");
}
- if ( HIERARCHY_HITTABLE )
+ if(HIERARCHY_HITTABLE)
{
- output << " Hittable: " << ( GetImplementation(actor).IsHittable() ? "True " : "False " );
+ output << " Hittable: " << (GetImplementation(actor).IsHittable() ? "True " : "False ");
}
output << std::endl;
- if( logFilter )
+ if(logFilter)
{
- DALI_LOG_INFO( logFilter, HIERARCHY_DEBUG_LOG_LEVEL, output.str().c_str() );
+ DALI_LOG_INFO(logFilter, HIERARCHY_DEBUG_LOG_LEVEL, output.str().c_str());
}
++level;
- unsigned int numChildren=actor.GetChildCount();
- for ( unsigned int i=0; i<numChildren; ++i )
+ unsigned int numChildren = actor.GetChildCount();
+ for(unsigned int i = 0; i < numChildren; ++i)
{
- PrintChildren( logFilter, actor.GetChildAt(i), level );
+ PrintChildren(logFilter, actor.GetChildAt(i), level);
}
--level;
}
-void PrintHierarchy( Debug::Filter* logFilter )
+void PrintHierarchy(Debug::Filter* logFilter)
{
- if ( logFilter && logFilter->IsEnabledFor( HIERARCHY_DEBUG_LOG_LEVEL ) )
+ if(logFilter && logFilter->IsEnabledFor(HIERARCHY_DEBUG_LOG_LEVEL))
{
- PrintChildren( logFilter, Dali::Stage().GetCurrent().GetRootLayer(), 0 );
+ PrintChildren(logFilter, Dali::Stage().GetCurrent().GetRootLayer(), 0);
}
}
#endif // defined(DEBUG_ENABLED)
-bool IsActuallySensitive( Actor* actor )
+bool IsActuallySensitive(Actor* actor)
{
bool sensitive = true;
- while ( actor && sensitive )
+ while(actor && sensitive)
{
sensitive = actor->IsSensitive();
- actor = actor->GetParent();
+ actor = actor->GetParent();
}
return sensitive;
} // namespace Internal
} // namespace Dali
-
#define DALI_INTERNAL_MULTI_POINT_EVENT_UTIL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
#if defined(DEBUG_ENABLED)
/**
* @param[in] actor The actor whose children to print.
* @param[in] level The number of " | " to put in front of the children.
*/
-void PrintChildren( Debug::Filter* logFilter, Dali::Actor actor, int level );
+void PrintChildren(Debug::Filter* logFilter, Dali::Actor actor, int level);
/**
* Prints the entire hierarchy of the scene.
*/
-void PrintHierarchy( Debug::Filter* logFilter );
+void PrintHierarchy(Debug::Filter* logFilter);
#define PRINT_HIERARCHY(f) PrintHierarchy(f)
* should also check if any of the actor's parents has become insensitive since we last processed
* it.
*/
-bool IsActuallySensitive( Actor* actor );
+bool IsActuallySensitive(Actor* actor);
} // namespace Internal
} // namespace Dali
#endif // DALI_INTERNAL_MULTI_POINT_EVENT_UTIL_H
-
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstring> // for strcmp
// INTERNAL INCLUDES
-#include <dali/public-api/events/pan-gesture.h>
-#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/math/radian.h>
-#include <dali/public-api/math/degree.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/common/property-helper.h>
#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/event/events/gesture-event-processor.h>
#include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
+#include <dali/public-api/events/pan-gesture.h>
+#include <dali/public-api/math/degree.h>
+#include <dali/public-api/math/radian.h>
+#include <dali/public-api/object/type-registry.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
// Properties
// Name Type writable animatable constraint-input enum for index-checking
DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "screenPosition", VECTOR2, false, false, true, Dali::PanGestureDetector::Property::SCREEN_POSITION )
-DALI_PROPERTY( "screenDisplacement", VECTOR2, false, false, true, Dali::PanGestureDetector::Property::SCREEN_DISPLACEMENT )
-DALI_PROPERTY( "screenVelocity", VECTOR2, false, false, true, Dali::PanGestureDetector::Property::SCREEN_VELOCITY )
-DALI_PROPERTY( "localPosition", VECTOR2, false, false, true, Dali::PanGestureDetector::Property::LOCAL_POSITION )
-DALI_PROPERTY( "localDisplacement", VECTOR2, false, false, true, Dali::PanGestureDetector::Property::LOCAL_DISPLACEMENT )
-DALI_PROPERTY( "localVelocity", VECTOR2, false, false, true, Dali::PanGestureDetector::Property::LOCAL_VELOCITY )
-DALI_PROPERTY( "panning", BOOLEAN, false, false, true, Dali::PanGestureDetector::Property::PANNING )
-DALI_PROPERTY_TABLE_END( DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX, PanGestureDetectorDefaultProperties )
+DALI_PROPERTY("screenPosition", VECTOR2, false, false, true, Dali::PanGestureDetector::Property::SCREEN_POSITION)
+DALI_PROPERTY("screenDisplacement", VECTOR2, false, false, true, Dali::PanGestureDetector::Property::SCREEN_DISPLACEMENT)
+DALI_PROPERTY("screenVelocity", VECTOR2, false, false, true, Dali::PanGestureDetector::Property::SCREEN_VELOCITY)
+DALI_PROPERTY("localPosition", VECTOR2, false, false, true, Dali::PanGestureDetector::Property::LOCAL_POSITION)
+DALI_PROPERTY("localDisplacement", VECTOR2, false, false, true, Dali::PanGestureDetector::Property::LOCAL_DISPLACEMENT)
+DALI_PROPERTY("localVelocity", VECTOR2, false, false, true, Dali::PanGestureDetector::Property::LOCAL_VELOCITY)
+DALI_PROPERTY("panning", BOOLEAN, false, false, true, Dali::PanGestureDetector::Property::PANNING)
+DALI_PROPERTY_TABLE_END(DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX, PanGestureDetectorDefaultProperties)
// Signals
return Dali::PanGestureDetector::New();
}
-TypeRegistration mType( typeid(Dali::PanGestureDetector), typeid(Dali::GestureDetector), Create, PanGestureDetectorDefaultProperties );
+TypeRegistration mType(typeid(Dali::PanGestureDetector), typeid(Dali::GestureDetector), Create, PanGestureDetectorDefaultProperties);
-SignalConnectorType signalConnector1( mType, SIGNAL_PAN_DETECTED, &PanGestureDetector::DoConnectSignal );
+SignalConnectorType signalConnector1(mType, SIGNAL_PAN_DETECTED, &PanGestureDetector::DoConnectSignal);
#if defined(DEBUG_ENABLED)
-Integration::Log::Filter* gLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_PAN_GESTURE_DETECTOR");
+Integration::Log::Filter* gLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_PAN_GESTURE_DETECTOR");
#endif
/**
* Returns the angle going in the opposite direction to that specified by angle.
*/
-float GetOppositeAngle( float angle )
+float GetOppositeAngle(float angle)
{
// Calculate the opposite angle so that we cover both directions.
- if ( angle <= 0.0f )
+ if(angle <= 0.0f)
{
angle += Math::PI;
}
PanGestureDetectorPtr PanGestureDetector::New()
{
const SceneGraph::PanGesture& sceneObject = ThreadLocalStorage::Get().GetGestureEventProcessor().GetPanGestureProcessor().GetSceneObject();
- return new PanGestureDetector( sceneObject );
+ return new PanGestureDetector(sceneObject);
}
void PanGestureDetector::SetMinimumTouchesRequired(unsigned int minimum)
{
- DALI_ASSERT_ALWAYS( minimum > 0 && "Can only set a positive number of required touches" );
+ DALI_ASSERT_ALWAYS(minimum > 0 && "Can only set a positive number of required touches");
- if (mMinimumTouches != minimum)
+ if(mMinimumTouches != minimum)
{
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "Minimum Touches Set: %d\n", minimum );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "Minimum Touches Set: %d\n", minimum);
mMinimumTouches = minimum;
- if (!mAttachedActors.empty())
+ if(!mAttachedActors.empty())
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "Updating Gesture Detector\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, "Updating Gesture Detector\n");
mGestureEventProcessor.GestureDetectorUpdated(this);
}
void PanGestureDetector::SetMaximumTouchesRequired(unsigned int maximum)
{
- DALI_ASSERT_ALWAYS( maximum > 0 && "Can only set a positive number of maximum touches" );
+ DALI_ASSERT_ALWAYS(maximum > 0 && "Can only set a positive number of maximum touches");
- if (mMaximumTouches != maximum)
+ if(mMaximumTouches != maximum)
{
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "Maximum Touches Set: %d\n", maximum );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "Maximum Touches Set: %d\n", maximum);
mMaximumTouches = maximum;
- if (!mAttachedActors.empty())
+ if(!mAttachedActors.empty())
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "Updating Gesture Detector\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, "Updating Gesture Detector\n");
mGestureEventProcessor.GestureDetectorUpdated(this);
}
return mMaximumTouches;
}
-void PanGestureDetector::AddAngle( Radian angle, Radian threshold )
+void PanGestureDetector::AddAngle(Radian angle, Radian threshold)
{
- threshold = fabsf( threshold ); // Ensure the threshold is positive.
+ threshold = fabsf(threshold); // Ensure the threshold is positive.
// If the threshold is greater than PI, then just use PI
// This means that any panned angle will invoke the pan gesture. We should still add this angle as
// an angle may have been added previously with a small threshold.
- if ( threshold > Math::PI )
+ if(threshold > Math::PI)
{
threshold = Math::PI;
}
- angle = WrapInDomain( angle, -Math::PI, Math::PI );
+ angle = WrapInDomain(angle, -Math::PI, Math::PI);
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "Angle Added: %.2f, Threshold: %.2f\n", Degree(angle), Degree(threshold) );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "Angle Added: %.2f, Threshold: %.2f\n", Degree(angle), Degree(threshold));
- AngleThresholdPair pair( angle, threshold );
- mAngleContainer.push_back( pair );
+ AngleThresholdPair pair(angle, threshold);
+ mAngleContainer.push_back(pair);
}
-void PanGestureDetector::AddDirection( Radian direction, Radian threshold )
+void PanGestureDetector::AddDirection(Radian direction, Radian threshold)
{
- AddAngle( direction, threshold );
+ AddAngle(direction, threshold);
// Calculate the opposite angle so that we cover the entire direction.
- direction = GetOppositeAngle( direction );
+ direction = GetOppositeAngle(direction);
- AddAngle( direction, threshold );
+ AddAngle(direction, threshold);
}
uint32_t PanGestureDetector::GetAngleCount() const
{
- return static_cast<uint32_t>( mAngleContainer.size() );
+ return static_cast<uint32_t>(mAngleContainer.size());
}
PanGestureDetector::AngleThresholdPair PanGestureDetector::GetAngle(uint32_t index) const
{
- PanGestureDetector::AngleThresholdPair ret( Radian(0),Radian(0) );
+ PanGestureDetector::AngleThresholdPair ret(Radian(0), Radian(0));
- if( index < mAngleContainer.size() )
+ if(index < mAngleContainer.size())
{
ret = mAngleContainer[index];
}
return ret;
}
-
void PanGestureDetector::ClearAngles()
{
mAngleContainer.clear();
}
-void PanGestureDetector::RemoveAngle( Radian angle )
+void PanGestureDetector::RemoveAngle(Radian angle)
{
- angle = WrapInDomain( angle, -Math::PI, Math::PI );
+ angle = WrapInDomain(angle, -Math::PI, Math::PI);
- for (AngleContainer::iterator iter = mAngleContainer.begin(), endIter = mAngleContainer.end(); iter != endIter; ++iter )
+ for(AngleContainer::iterator iter = mAngleContainer.begin(), endIter = mAngleContainer.end(); iter != endIter; ++iter)
{
- if ( iter->first == angle )
+ if(iter->first == angle)
{
- mAngleContainer.erase( iter );
+ mAngleContainer.erase(iter);
break;
}
}
}
-void PanGestureDetector::RemoveDirection( Radian direction )
+void PanGestureDetector::RemoveDirection(Radian direction)
{
- RemoveAngle( direction );
+ RemoveAngle(direction);
// Calculate the opposite angle so that we cover the entire direction.
- direction = GetOppositeAngle( direction );
+ direction = GetOppositeAngle(direction);
- RemoveAngle( direction );
+ RemoveAngle(direction);
}
bool PanGestureDetector::RequiresDirectionalPan() const
return !mAngleContainer.empty();
}
-bool PanGestureDetector::CheckAngleAllowed( Radian angle ) const
+bool PanGestureDetector::CheckAngleAllowed(Radian angle) const
{
- bool allowed( false );
- if ( mAngleContainer.empty() )
+ bool allowed(false);
+ if(mAngleContainer.empty())
{
allowed = true;
}
else
{
- for ( AngleContainer::const_iterator iter = mAngleContainer.begin(), endIter = mAngleContainer.end(); iter != endIter; ++iter )
+ for(AngleContainer::const_iterator iter = mAngleContainer.begin(), endIter = mAngleContainer.end(); iter != endIter; ++iter)
{
- float angleAllowed( iter->first );
- float threshold ( iter->second );
+ float angleAllowed(iter->first);
+ float threshold(iter->second);
- DALI_LOG_INFO( gLogFilter, Debug::General,
- "AngleToCheck: %.2f, CompareWith: %.2f, Threshold: %.2f\n",
- Degree(angle), Degree(angleAllowed), Degree(threshold) );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "AngleToCheck: %.2f, CompareWith: %.2f, Threshold: %.2f\n", Degree(angle), Degree(angleAllowed), Degree(threshold));
- float relativeAngle( fabsf( WrapInDomain( angle - angleAllowed, -Math::PI, Math::PI ) ) );
- if ( relativeAngle <= threshold )
+ float relativeAngle(fabsf(WrapInDomain(angle - angleAllowed, -Math::PI, Math::PI)));
+ if(relativeAngle <= threshold)
{
allowed = true;
break;
void PanGestureDetector::EmitPanGestureSignal(Dali::Actor actor, const Dali::PanGesture& pan)
{
- if ( !mDetectedSignal.Empty() )
+ if(!mDetectedSignal.Empty())
{
// Guard against destruction during signal emission
- Dali::PanGestureDetector handle( this );
+ Dali::PanGestureDetector handle(this);
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Emitting Signal (%p)\n", this );
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Emitting Signal (%p)\n", this);
- mDetectedSignal.Emit( actor, pan );
+ mDetectedSignal.Emit(actor, pan);
}
}
-bool PanGestureDetector::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool PanGestureDetector::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( true );
- PanGestureDetector* gesture = static_cast< PanGestureDetector* >(object); // TypeRegistry guarantees that this is the correct type.
+ bool connected(true);
+ PanGestureDetector* gesture = static_cast<PanGestureDetector*>(object); // TypeRegistry guarantees that this is the correct type.
- if ( 0 == strcmp( signalName.c_str(), SIGNAL_PAN_DETECTED ) )
+ if(0 == strcmp(signalName.c_str(), SIGNAL_PAN_DETECTED))
{
- gesture->DetectedSignal().Connect( tracker, functor );
+ gesture->DetectedSignal().Connect(tracker, functor);
}
else
{
return connected;
}
-void PanGestureDetector::SetPanGestureProperties( const Dali::PanGesture& pan )
+void PanGestureDetector::SetPanGestureProperties(const Dali::PanGesture& pan)
{
- ThreadLocalStorage::Get().GetGestureEventProcessor().SetGestureProperties( pan );
+ ThreadLocalStorage::Get().GetGestureEventProcessor().SetGestureProperties(pan);
}
-PanGestureDetector::PanGestureDetector( const SceneGraph::PanGesture& sceneObject )
-: GestureDetector( GestureType::PAN, &sceneObject ),
+PanGestureDetector::PanGestureDetector(const SceneGraph::PanGesture& sceneObject)
+: GestureDetector(GestureType::PAN, &sceneObject),
mMinimumTouches(1),
mMaximumTouches(1)
{
const SceneGraph::PanGesture& PanGestureDetector::GetPanGestureSceneObject() const
{
- return static_cast<const SceneGraph::PanGesture&>( GetSceneObject() );
+ return static_cast<const SceneGraph::PanGesture&>(GetSceneObject());
}
void PanGestureDetector::OnActorAttach(Actor& actor)
// Do nothing
}
-void PanGestureDetector::SetDefaultProperty( Property::Index index, const Property::Value& property )
+void PanGestureDetector::SetDefaultProperty(Property::Index index, const Property::Value& property)
{
// None of our properties should be settable from Public API
}
-Property::Value PanGestureDetector::GetDefaultProperty( Property::Index index ) const
+Property::Value PanGestureDetector::GetDefaultProperty(Property::Index index) const
{
- return GetDefaultPropertyCurrentValue( index ); // Scene-graph only properties
+ return GetDefaultPropertyCurrentValue(index); // Scene-graph only properties
}
-Property::Value PanGestureDetector::GetDefaultPropertyCurrentValue( Property::Index index ) const
+Property::Value PanGestureDetector::GetDefaultPropertyCurrentValue(Property::Index index) const
{
Property::Value value;
- switch ( index )
+ switch(index)
{
case Dali::PanGestureDetector::Property::SCREEN_POSITION:
{
default:
{
- DALI_ASSERT_ALWAYS(false && "PanGestureDetector Property index invalid" ); // should not come here
+ DALI_ASSERT_ALWAYS(false && "PanGestureDetector Property index invalid"); // should not come here
break;
}
}
return value;
}
-const PropertyInputImpl* PanGestureDetector::GetSceneObjectInputProperty( Property::Index index ) const
+const PropertyInputImpl* PanGestureDetector::GetSceneObjectInputProperty(Property::Index index) const
{
const PropertyInputImpl* property = nullptr;
- switch ( index )
+ switch(index)
{
case Dali::PanGestureDetector::Property::SCREEN_POSITION:
{
default:
break;
}
- if( !property )
+ if(!property)
{
// not our property, ask base
- property = Object::GetSceneObjectInputProperty( index );
+ property = Object::GetSceneObjectInputProperty(index);
}
return property;
#define DALI_INTERNAL_PAN_GESTURE_DETECTOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/gesture-detector-impl.h>
#include <dali/public-api/events/gesture.h>
#include <dali/public-api/events/pan-gesture-detector.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/internal/event/events/gesture-detector-impl.h>
#include <dali/public-api/events/pan-gesture.h>
+#include <dali/public-api/math/vector2.h>
namespace Dali
{
-
class TouchEvent;
struct Radian;
namespace Internal
{
-
class PanGestureDetector;
using PanGestureDetectorPtr = IntrusivePtr<PanGestureDetector>;
using PanGestureDetectorContainer = DerivedGestureDetectorContainer<PanGestureDetector>::type;
using AngleContainer = std::vector<AngleThresholdPair>;
public: // Creation
-
/**
* Create a new gesture detector.
* @return A smart-pointer to the newly allocated detector.
static PanGestureDetectorPtr New();
public:
-
/**
* @copydoc Dali::PanGestureDetector::SetMinimumTouchesRequired(unsigned int)
*/
/**
* @copydoc Dali::PanGestureDetector::AddAngle()
*/
- void AddAngle( Radian angle, Radian threshold );
+ void AddAngle(Radian angle, Radian threshold);
/**
* @copydoc Dali::PanGestureDetector::AddDirection()
*/
- void AddDirection( Radian direction, Radian threshold );
+ void AddDirection(Radian direction, Radian threshold);
/**
* @copydoc Dali::PanGestureDetector::GetAngleCount()
/**
* @copydoc Dali::PanGestureDetector::RemoveAngle()
*/
- void RemoveAngle( Radian angle );
+ void RemoveAngle(Radian angle);
/**
* @copydoc Dali::PanGestureDetector::RemoveDirection()
*/
- void RemoveDirection( Radian direction );
+ void RemoveDirection(Radian direction);
/**
* Checks whether the pan gesture detector requires a directional pan for emission.
* Checks whether the given pan angle is allowed for this gesture detector.
* @param[in] angle The angle to check.
*/
- bool CheckAngleAllowed( Radian angle ) const;
+ bool CheckAngleAllowed(Radian angle) const;
public:
-
/**
* Called by the PanGestureProcessor when a pan gesture event occurs within the bounds of our
* attached actor.
void EmitPanGestureSignal(Dali::Actor actor, const Dali::PanGesture& pan);
public: // Signals
-
/**
* @copydoc Dali::PanGestureDetector::DetectedSignal()
*/
* @return True if the signal was connected.
* @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
*/
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
public: // Override Pan Gesture
-
/**
* @copydoc Dali::PanGestureDetector::SetPanGestureProperties()
*/
- static void SetPanGestureProperties( const Dali::PanGesture& pan );
+ static void SetPanGestureProperties(const Dali::PanGesture& pan);
protected:
-
/**
* Construct a new PanGestureDetector.
* @param sceneObject the scene object
*/
- PanGestureDetector( const SceneGraph::PanGesture& sceneObject );
+ PanGestureDetector(const SceneGraph::PanGesture& sceneObject);
/**
* A reference counted object may only be deleted by calling Unreference()
~PanGestureDetector() override;
private:
-
// Undefined
- PanGestureDetector() = delete;
+ PanGestureDetector() = delete;
PanGestureDetector(const PanGestureDetector&) = delete;
PanGestureDetector& operator=(const PanGestureDetector& rhs) = delete;
*/
void OnActorDestroyed(Object& object) override;
-
// Default property extensions from Object
/**
/**
* @copydoc Dali::Internal::Object::GetDefaultProperty()
*/
- Property::Value GetDefaultProperty( Property::Index index ) const override;
+ Property::Value GetDefaultProperty(Property::Index index) const override;
/**
* @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
*/
- Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const override;
+ Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
/**
* @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
*/
- const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const override;
+ const PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const override;
private:
-
Dali::PanGestureDetector::DetectedSignalType mDetectedSignal;
unsigned int mMinimumTouches; ///< The minimum number of fingers required to be touching for pan.
unsigned int mMaximumTouches; ///< The maximum number of fingers required to be touching for pan.
AngleContainer mAngleContainer; ///< A container of all angles allowed for pan to occur.
-
};
} // namespace Internal
inline Internal::PanGestureDetector& GetImplementation(Dali::PanGestureDetector& detector)
{
- DALI_ASSERT_ALWAYS( detector && "PanGestureDetector handle is empty" );
+ DALI_ASSERT_ALWAYS(detector && "PanGestureDetector handle is empty");
BaseObject& handle = detector.GetBaseObject();
inline const Internal::PanGestureDetector& GetImplementation(const Dali::PanGestureDetector& detector)
{
- DALI_ASSERT_ALWAYS( detector && "PanGestureDetector handle is empty" );
+ DALI_ASSERT_ALWAYS(detector && "PanGestureDetector handle is empty");
const BaseObject& handle = detector.GetBaseObject();
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
-
PanGestureEvent::PanGestureEvent(GestureState state)
: GestureEvent(GestureType::PAN, state),
timeDelta(0),
#define DALI_INTERNAL_EVENT_PAN_GESTURE_EVENT_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* If the adaptor detects a pan gesture, then it should create an instance of this structure and
* send it to the Core.
* A STARTED state will be ignored if a POSSIBLE state does not precede it.
* Likewise, a CONTINUING or FINISHED state will be ignored if a STARTED state does not precede it.
*/
-struct PanGestureEvent: public GestureEvent
+struct PanGestureEvent : public GestureEvent
{
// Construction & Destruction
#define DALI_INTERNAL_PAN_GESTURE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/gesture-impl.h>
+#include <dali/public-api/events/pan-gesture.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/events/pan-gesture.h>
-#include <dali/internal/event/events/gesture-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class PanGesture;
using PanGesturePtr = IntrusivePtr<PanGesture>;
class PanGesture final : public Gesture
{
public:
-
/**
* @brief Default constructor
*/
{
}
- PanGesture(const PanGesture&) = delete; ///< Deleted copy constructor
- PanGesture(PanGesture&&) = delete; ///< Deleted move constructor
+ PanGesture(const PanGesture&) = delete; ///< Deleted copy constructor
+ PanGesture(PanGesture&&) = delete; ///< Deleted move constructor
PanGesture& operator=(const PanGesture&) = delete; ///< Deleted copy assignment operator
- PanGesture& operator=(PanGesture&&) = delete; ///< Deleted move assignment operator
+ PanGesture& operator=(PanGesture&&) = delete; ///< Deleted move assignment operator
/**
* @brief Set The velocity at which the user is moving their fingers.
}
private:
-
/**
* @brief Virtual destructor
*
~PanGesture() override = default;
private:
- Vector2 mVelocity;
- Vector2 mDisplacement;
- Vector2 mPosition;
- Vector2 mScreenVelocity;
- Vector2 mScreenDisplacement;
- Vector2 mScreenPosition;
+ Vector2 mVelocity;
+ Vector2 mDisplacement;
+ Vector2 mPosition;
+ Vector2 mScreenVelocity;
+ Vector2 mScreenDisplacement;
+ Vector2 mScreenPosition;
uint32_t mNumberOfTouches{1u};
};
// Helpers for public-api forwarding methods
-inline Internal::PanGesture& GetImplementation( Dali::PanGesture& panGesture )
+inline Internal::PanGesture& GetImplementation(Dali::PanGesture& panGesture)
{
- DALI_ASSERT_ALWAYS( panGesture && "panGesture handle is empty" );
+ DALI_ASSERT_ALWAYS(panGesture && "panGesture handle is empty");
BaseObject& object = panGesture.GetBaseObject();
- return static_cast< Internal::PanGesture& >( object );
+ return static_cast<Internal::PanGesture&>(object);
}
-inline const Internal::PanGesture& GetImplementation( const Dali::PanGesture& panGesture )
+inline const Internal::PanGesture& GetImplementation(const Dali::PanGesture& panGesture)
{
- DALI_ASSERT_ALWAYS( panGesture && "panGesture handle is empty" );
+ DALI_ASSERT_ALWAYS(panGesture && "panGesture handle is empty");
const BaseObject& object = panGesture.GetBaseObject();
- return static_cast< const Internal::PanGesture& >( object );
+ return static_cast<const Internal::PanGesture&>(object);
}
} // namespace Dali
#define DALI_INTERNAL_EVENT_PAN_GESTURE_EVENT_PROCESSOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/pan-gesture/pan-gesture-detector-impl.h>
#include <dali/internal/event/events/gesture-processor.h>
+#include <dali/internal/event/events/pan-gesture/pan-gesture-detector-impl.h>
#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class Stage;
class Scene;
struct GestureEvent;
{
class PanGesture;
class UpdateManager;
-}
+} // namespace SceneGraph
/**
* Pan Gesture Event Processing:
class PanGestureProcessor : public GestureProcessor, public RecognizerObserver<PanGestureEvent>
{
public:
-
/**
* Create a pan gesture processor.
* @param[in] updateManager The Update Manager
*/
- PanGestureProcessor( SceneGraph::UpdateManager& updateManager );
+ PanGestureProcessor(SceneGraph::UpdateManager& updateManager);
/**
* Destructor
~PanGestureProcessor() override;
public: // To be called by GestureEventProcessor
-
/**
* This method is called whenever a pan gesture event occurs.
* @param[in] scene The scene the pan gesture event occurs in.
* @param[in] panEvent The event that has occurred.
*/
- void Process( Scene& scene, const PanGestureEvent& panEvent ) override;
+ void Process(Scene& scene, const PanGestureEvent& panEvent) override;
/**
* Adds a gesture detector to this gesture processor.
* gesture with the adaptor.
* @param[in] gestureDetector The gesture detector being added.
*/
- void AddGestureDetector( PanGestureDetector* gestureDetector, Scene& scene, int32_t minDistance, int32_t minPanEvents );
+ void AddGestureDetector(PanGestureDetector* gestureDetector, Scene& scene, int32_t minDistance, int32_t minPanEvents);
/**
* Removes the specified gesture detector from this gesture processor. If, after removing this
* the gesture from the adaptor.
* @param[in] gestureDetector The gesture detector being removed.
*/
- void RemoveGestureDetector( PanGestureDetector* gestureDetector );
+ void RemoveGestureDetector(PanGestureDetector* gestureDetector);
/**
* This method updates the gesture detection parameters.
* @param[in] gestureDetector The gesture detector that has been updated.
*/
- void GestureDetectorUpdated( PanGestureDetector* gestureDetector );
+ void GestureDetectorUpdated(PanGestureDetector* gestureDetector);
/**
* Sets the pan gesture properties stored in the scene object directly,
* @return true if Core::Update required
* @note If we are already processing a normal pan, then this call is ignored.
*/
- bool SetPanGestureProperties( const Dali::PanGesture& pan );
+ bool SetPanGestureProperties(const Dali::PanGesture& pan);
/**
* Called to provide pan-gesture profiling information.
*
* @param[in] value True = use actual times, False = use perfect values
*/
- void SetUseActualTimes( bool value );
+ void SetUseActualTimes(bool value);
/**
* @brief Sets the interpolation time range (ms) of past points to use (with weights) when interpolating.
*
* @param[in] value Time range in ms
*/
- void SetInterpolationTimeRange( int value );
+ void SetInterpolationTimeRange(int value);
/**
* @brief Sets whether to use scalar only prediction, which when enabled, ignores acceleration.
*
* @param[in] value True = use scalar prediction only
*/
- void SetScalarOnlyPredictionEnabled( bool value );
+ void SetScalarOnlyPredictionEnabled(bool value);
/**
* @brief Sets whether to use two point prediction. This combines two interpolated points to get more steady acceleration and velocity values.
*
* @param[in] value True = use two point prediction
*/
- void SetTwoPointPredictionEnabled( bool value );
+ void SetTwoPointPredictionEnabled(bool value);
/**
* @brief Sets the time in the past to interpolate the second point when using two point interpolation.
*
* @param[in] value Time in past in ms
*/
- void SetTwoPointInterpolatePastTime( int value );
+ void SetTwoPointInterpolatePastTime(int value);
/**
* @brief Sets the two point velocity bias. This is the ratio of first and second points to use for velocity.
*
* @param[in] value 0.0f = 100% first point. 1.0f = 100% of second point.
*/
- void SetTwoPointVelocityBias( float value );
+ void SetTwoPointVelocityBias(float value);
/**
* @brief Sets the two point acceleration bias. This is the ratio of first and second points to use for acceleration.
*
* @param[in] value 0.0f = 100% first point. 1.0f = 100% of second point.
*/
- void SetTwoPointAccelerationBias( float value );
+ void SetTwoPointAccelerationBias(float value);
/**
* @brief Sets the range of time (ms) of points in the history to perform multitap smoothing with (if enabled).
*
* @param[in] value Time in past in ms
*/
- void SetMultitapSmoothingRange( int value );
+ void SetMultitapSmoothingRange(int value);
public: // for PanGestureDetector
-
/**
* @return the pan gesture scene object
*/
const SceneGraph::PanGesture& GetSceneObject() const;
private:
-
// Undefined
- PanGestureProcessor( const PanGestureProcessor& );
- PanGestureProcessor& operator=( const PanGestureProcessor& rhs );
+ PanGestureProcessor(const PanGestureProcessor&);
+ PanGestureProcessor& operator=(const PanGestureProcessor& rhs);
/**
* Iterates through our GestureDetectors and determines if we need to ask the adaptor to update
* @param[in] state The state of the gesture.
* @param[in] renderTask The renderTask to use.
*/
- void EmitPanSignal( Actor* actor,
- const GestureDetectorContainer& gestureDetectors,
- const PanGestureEvent& panEvent,
- Vector2 localCurrent,
- GestureState state,
- RenderTaskPtr renderTask );
+ void EmitPanSignal(Actor* actor,
+ const GestureDetectorContainer& gestureDetectors,
+ const PanGestureEvent& panEvent,
+ Vector2 localCurrent,
+ GestureState state,
+ RenderTaskPtr renderTask);
// GestureProcessor overrides
/**
* @copydoc GestureProcessor::CheckGestureDetector()
*/
- bool CheckGestureDetector( GestureDetector* detector, Actor* actor ) override;
+ bool CheckGestureDetector(GestureDetector* detector, Actor* actor) override;
/**
* @copydoc GestureProcessor::EmitGestureSignal()
*/
- void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates ) override;
+ void EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates) override;
private:
-
PanGestureDetectorContainer mPanGestureDetectors;
- GestureDetectorContainer mCurrentPanEmitters;
- RenderTaskPtr mCurrentRenderTask;
- Vector2 mPossiblePanPosition;
+ GestureDetectorContainer mCurrentPanEmitters;
+ RenderTaskPtr mCurrentRenderTask;
+ Vector2 mPossiblePanPosition;
uint32_t mMinTouchesRequired;
uint32_t mMaxTouchesRequired;
Vector2 mLastVelocity; ///< The last recorded velocity in local actor coordinates.
Vector2 mLastScreenVelocity; ///< The last recorded velocity in screen coordinates.
- const PanGestureEvent* mCurrentPanEvent; ///< Pointer to current PanEvent, used when calling ProcessAndEmit()
- SceneGraph::PanGesture* mSceneObject; ///< Not owned, but we write to it directly
+ const PanGestureEvent* mCurrentPanEvent; ///< Pointer to current PanEvent, used when calling ProcessAndEmit()
+ SceneGraph::PanGesture* mSceneObject; ///< Not owned, but we write to it directly
};
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/common/scene-impl.h>
-#include <dali/internal/event/events/pan-gesture/pan-gesture-event.h>
#include <dali/internal/event/events/gesture-requests.h>
+#include <dali/internal/event/events/pan-gesture/pan-gesture-event.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-const float MINIMUM_MOTION_DISTANCE_BEFORE_PAN( 15.0f );
-const float MINIMUM_MOTION_DISTANCE_BEFORE_PAN_SQUARED( MINIMUM_MOTION_DISTANCE_BEFORE_PAN * MINIMUM_MOTION_DISTANCE_BEFORE_PAN );
-const float MINIMUM_MOTION_DISTANCE_TO_THRESHOLD_ADJUSTMENTS_RATIO( 2.0f / 3.0f );
-const unsigned long MINIMUM_TIME_BEFORE_THRESHOLD_ADJUSTMENTS( 100 );
-const unsigned int MINIMUM_MOTION_EVENTS_BEFORE_PAN(2);
+const float MINIMUM_MOTION_DISTANCE_BEFORE_PAN(15.0f);
+const float MINIMUM_MOTION_DISTANCE_BEFORE_PAN_SQUARED(MINIMUM_MOTION_DISTANCE_BEFORE_PAN* MINIMUM_MOTION_DISTANCE_BEFORE_PAN);
+const float MINIMUM_MOTION_DISTANCE_TO_THRESHOLD_ADJUSTMENTS_RATIO(2.0f / 3.0f);
+const unsigned long MINIMUM_TIME_BEFORE_THRESHOLD_ADJUSTMENTS(100);
+const unsigned int MINIMUM_MOTION_EVENTS_BEFORE_PAN(2);
} // unnamed namespace
-PanGestureRecognizer::PanGestureRecognizer( Observer& observer, Vector2 screenSize, const PanGestureRequest& request, int32_t minimumDistance, int32_t minimumPanEvents )
-: GestureRecognizer( screenSize, GestureType::PAN ),
- mObserver( observer ),
- mState( CLEAR ),
- mThresholdAdjustmentsRemaining( 0 ),
- mThresholdTotalAdjustments( static_cast<unsigned int>( MINIMUM_MOTION_DISTANCE_BEFORE_PAN * MINIMUM_MOTION_DISTANCE_TO_THRESHOLD_ADJUSTMENTS_RATIO ) ),
- mPrimaryTouchDownTime( 0 ),
- mMinimumTouchesRequired( request.minTouches ),
- mMaximumTouchesRequired( request.maxTouches ),
- mMinimumDistanceSquared( static_cast<unsigned int>( MINIMUM_MOTION_DISTANCE_BEFORE_PAN_SQUARED ) ),
- mMinimumMotionEvents( MINIMUM_MOTION_EVENTS_BEFORE_PAN ),
- mMotionEvents( 0 )
+PanGestureRecognizer::PanGestureRecognizer(Observer& observer, Vector2 screenSize, const PanGestureRequest& request, int32_t minimumDistance, int32_t minimumPanEvents)
+: GestureRecognizer(screenSize, GestureType::PAN),
+ mObserver(observer),
+ mState(CLEAR),
+ mThresholdAdjustmentsRemaining(0),
+ mThresholdTotalAdjustments(static_cast<unsigned int>(MINIMUM_MOTION_DISTANCE_BEFORE_PAN * MINIMUM_MOTION_DISTANCE_TO_THRESHOLD_ADJUSTMENTS_RATIO)),
+ mPrimaryTouchDownTime(0),
+ mMinimumTouchesRequired(request.minTouches),
+ mMaximumTouchesRequired(request.maxTouches),
+ mMinimumDistanceSquared(static_cast<unsigned int>(MINIMUM_MOTION_DISTANCE_BEFORE_PAN_SQUARED)),
+ mMinimumMotionEvents(MINIMUM_MOTION_EVENTS_BEFORE_PAN),
+ mMotionEvents(0)
{
- if ( minimumDistance >= 0 )
+ if(minimumDistance >= 0)
{
mMinimumDistanceSquared = minimumDistance * minimumDistance;
// Usually, we do not want to apply the threshold straight away, but phased over the first few pans
// Set our distance to threshold adjustments ratio here.
- float fMinimumDistance = static_cast<float>( minimumDistance );
- mThresholdTotalAdjustments = static_cast<unsigned int>( fMinimumDistance * MINIMUM_MOTION_DISTANCE_TO_THRESHOLD_ADJUSTMENTS_RATIO );
+ float fMinimumDistance = static_cast<float>(minimumDistance);
+ mThresholdTotalAdjustments = static_cast<unsigned int>(fMinimumDistance * MINIMUM_MOTION_DISTANCE_TO_THRESHOLD_ADJUSTMENTS_RATIO);
}
- if ( minimumPanEvents >= 1 )
+ if(minimumPanEvents >= 1)
{
mMinimumMotionEvents = minimumPanEvents - 1; // Down is the first event
}
void PanGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
{
- PointState::Type primaryPointState(event.points[0].GetState());
+ PointState::Type primaryPointState(event.points[0].GetState());
GestureRecognizerPtr ptr(this); // To keep us from being destroyed during the life-time of this method
- if (primaryPointState == PointState::INTERRUPTED)
+ if(primaryPointState == PointState::INTERRUPTED)
{
- if ( ( mState == STARTED ) || ( mState == POSSIBLE ) )
+ if((mState == STARTED) || (mState == POSSIBLE))
{
// If our pan had started and we are interrupted, then tell Core that pan is cancelled.
mTouchEvents.push_back(event);
}
else
{
- switch (mState)
+ switch(mState)
{
case CLEAR:
{
- if ( ( primaryPointState == PointState::DOWN ) || ( primaryPointState == PointState::STATIONARY ) || ( primaryPointState == PointState::MOTION ))
+ if((primaryPointState == PointState::DOWN) || (primaryPointState == PointState::STATIONARY) || (primaryPointState == PointState::MOTION))
{
mPrimaryTouchDownLocation = event.points[0].GetScreenPosition();
- mPrimaryTouchDownTime = event.time;
- mMotionEvents = 0;
- if (event.GetPointCount() == mMinimumTouchesRequired)
+ mPrimaryTouchDownTime = event.time;
+ mMotionEvents = 0;
+ if(event.GetPointCount() == mMinimumTouchesRequired)
{
// We have satisfied the minimum touches required for a pan, tell core that a gesture may be possible and change our state accordingly.
mState = POSSIBLE;
case POSSIBLE:
{
unsigned int pointCount(event.GetPointCount());
- if ( (pointCount >= mMinimumTouchesRequired)&&(pointCount <= mMaximumTouchesRequired) )
+ if((pointCount >= mMinimumTouchesRequired) && (pointCount <= mMaximumTouchesRequired))
{
- if (primaryPointState == PointState::MOTION)
+ if(primaryPointState == PointState::MOTION)
{
mTouchEvents.push_back(event);
mMotionEvents++;
Vector2 delta(event.points[0].GetScreenPosition() - mPrimaryTouchDownLocation);
- if ( ( mMotionEvents >= mMinimumMotionEvents ) &&
- ( delta.LengthSquared() >= static_cast<float>( mMinimumDistanceSquared ) ) )
+ if((mMotionEvents >= mMinimumMotionEvents) &&
+ (delta.LengthSquared() >= static_cast<float>(mMinimumDistanceSquared)))
{
// If the touch point(s) have moved enough distance to be considered a pan, then tell Core that the pan gesture has started and change our state accordingly.
mState = STARTED;
SendPan(GestureState::STARTED, event);
}
}
- else if (primaryPointState == PointState::UP)
+ else if(primaryPointState == PointState::UP)
{
Vector2 delta(event.points[0].GetScreenPosition() - mPrimaryTouchDownLocation);
- if (delta.LengthSquared() >= static_cast<float>( mMinimumDistanceSquared ) )
+ if(delta.LengthSquared() >= static_cast<float>(mMinimumDistanceSquared))
{
SendPan(GestureState::STARTED, event);
mTouchEvents.push_back(event);
// We do not satisfy pan conditions, tell Core our Gesture has been cancelled.
SendPan(GestureState::CANCELLED, event);
- if (pointCount == 1 && primaryPointState == PointState::UP)
+ if(pointCount == 1 && primaryPointState == PointState::UP)
{
// If we have lifted the primary touch point, then change our state to CLEAR...
mState = CLEAR;
mTouchEvents.push_back(event);
unsigned int pointCount(event.GetPointCount());
- if ( (pointCount >= mMinimumTouchesRequired)&&(pointCount <= mMaximumTouchesRequired) )
+ if((pointCount >= mMinimumTouchesRequired) && (pointCount <= mMaximumTouchesRequired))
{
- switch (primaryPointState)
+ switch(primaryPointState)
{
case PointState::MOTION:
// Pan is continuing, tell Core.
break;
case PointState::STATIONARY:
- if (pointCount == mMinimumTouchesRequired)
+ if(pointCount == mMinimumTouchesRequired)
{
Integration::PointContainerConstIterator iter = event.points.begin() + 1; // We already know the state of the first point
for(; iter != event.points.end(); ++iter)
// We have gone outside of the pan requirements, inform Core that the gesture is finished.
SendPan(GestureState::FINISHED, event);
- if (pointCount == 1 && primaryPointState == PointState::UP)
+ if(pointCount == 1 && primaryPointState == PointState::UP)
{
// If this was the primary point being released, then we change our state back to CLEAR...
mState = CLEAR;
case FINISHED:
case FAILED:
{
- if (primaryPointState == PointState::UP)
+ if(primaryPointState == PointState::UP)
{
// Change our state back to clear when the primary touch point is released.
mState = CLEAR;
gesture.currentPosition = currentEvent.points[0].GetScreenPosition();
gesture.numberOfTouches = currentEvent.GetPointCount();
- if ( mTouchEvents.size() > 1 )
+ if(mTouchEvents.size() > 1)
{
// Get the second last event in the queue, the last one is the current event
- const Integration::TouchEvent& previousEvent( *( mTouchEvents.rbegin() + 1 ) );
+ const Integration::TouchEvent& previousEvent(*(mTouchEvents.rbegin() + 1));
- Vector2 previousPosition( mPreviousPosition );
- uint32_t previousTime( previousEvent.time );
+ Vector2 previousPosition(mPreviousPosition);
+ uint32_t previousTime(previousEvent.time);
// If we've just started then we want to remove the threshold from Core calculations.
- if ( state == GestureState::STARTED )
+ if(state == GestureState::STARTED)
{
previousPosition = mPrimaryTouchDownLocation;
- previousTime = mPrimaryTouchDownTime;
+ previousTime = mPrimaryTouchDownTime;
// If it's a slow pan, we do not want to phase in the threshold over the first few pan-events
// A slow pan is defined as one that starts the specified number of milliseconds after the down-event
- if ( ( currentEvent.time - previousTime ) > MINIMUM_TIME_BEFORE_THRESHOLD_ADJUSTMENTS )
+ if((currentEvent.time - previousTime) > MINIMUM_TIME_BEFORE_THRESHOLD_ADJUSTMENTS)
{
mThresholdAdjustmentsRemaining = mThresholdTotalAdjustments;
- mThresholdAdjustmentPerFrame = ( gesture.currentPosition - previousPosition ) / static_cast<float>( mThresholdTotalAdjustments );
+ mThresholdAdjustmentPerFrame = (gesture.currentPosition - previousPosition) / static_cast<float>(mThresholdTotalAdjustments);
}
else
{
mThresholdAdjustmentsRemaining = 0;
- mThresholdAdjustmentPerFrame = Vector2::ZERO;
+ mThresholdAdjustmentPerFrame = Vector2::ZERO;
}
}
gesture.previousPosition = previousPosition;
- gesture.timeDelta = currentEvent.time - previousTime;
+ gesture.timeDelta = currentEvent.time - previousTime;
// Apply the threshold with a phased approach
- if ( mThresholdAdjustmentsRemaining > 0 )
+ if(mThresholdAdjustmentsRemaining > 0)
{
--mThresholdAdjustmentsRemaining;
- gesture.currentPosition -= mThresholdAdjustmentPerFrame * static_cast<float>( mThresholdAdjustmentsRemaining );
+ gesture.currentPosition -= mThresholdAdjustmentPerFrame * static_cast<float>(mThresholdAdjustmentsRemaining);
}
mPreviousPosition = gesture.currentPosition;
else
{
gesture.previousPosition = gesture.currentPosition;
- gesture.timeDelta = 0;
+ gesture.timeDelta = 0;
}
gesture.time = currentEvent.time;
- if( mScene )
+ if(mScene)
{
// Create another handle so the recognizer cannot be destroyed during process function
GestureRecognizerPtr recognizerHandle = this;
#define DALI_INTERNAL_EVENT_PAN_GESTURE_RECOGNIZER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
// EXTERNAL INCLUDES
-#include <cstdint> // uint32_t
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/math/vector2.h>
+#include <cstdint> // uint32_t
// INTERNAL INCLUDES
#include <dali/internal/event/events/gesture-recognizer.h>
namespace Dali
{
-
namespace Integration
{
class Core;
struct TouchEvent;
-}
+} // namespace Integration
namespace Internal
{
-
struct PanGestureRequest;
/**
* When given a set of touch events, this detector attempts to determine if a pan gesture has taken place.
class PanGestureRecognizer : public GestureRecognizer
{
public:
-
using Observer = RecognizerObserver<PanGestureEvent>;
/**
* @param[in] screenSize The size of the screen.
* @param[in] request The details of the request.
*/
- PanGestureRecognizer( Observer& observer, Vector2 screenSize, const PanGestureRequest& request, int32_t minimumDistance, int32_t minimumPanEvents);
+ PanGestureRecognizer(Observer& observer, Vector2 screenSize, const PanGestureRequest& request, int32_t minimumDistance, int32_t minimumPanEvents);
/**
* Virtual destructor.
~PanGestureRecognizer() override;
public:
-
/**
* @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
*/
void Update(const GestureRequest& request) override;
private:
-
/**
* Emits the pan gesture event (performs some smoothing operation).
* @param[in] state The state of the pan.
void SendPan(GestureState state, const Integration::TouchEvent& currentEvent);
private:
-
// Reference to the gesture processor for this recognizer
Observer& mObserver;
FAILED, ///< Current touch event data suggests a pan gesture is not possible.
};
- State mState; ///< The current state of the detector.
- std::vector<Integration::TouchEvent> mTouchEvents; ///< A container of all touch events after an initial down event.
+ State mState; ///< The current state of the detector.
+ std::vector<Integration::TouchEvent> mTouchEvents; ///< A container of all touch events after an initial down event.
Vector2 mPrimaryTouchDownLocation; ///< The initial touch down point.
Vector2 mThresholdAdjustmentPerFrame; ///< The adjustment per frame at the start of a slow pan.
unsigned int mThresholdAdjustmentsRemaining; ///< No. of threshold adjustments still to apply (for a slow-pan).
unsigned int mThresholdTotalAdjustments; ///< The total number of adjustments required.
- uint32_t mPrimaryTouchDownTime; ///< The initial touch down time.
+ uint32_t mPrimaryTouchDownTime; ///< The initial touch down time.
unsigned int mMinimumTouchesRequired; ///< The minimum touches required before a pan should be emitted.
unsigned int mMaximumTouchesRequired; ///< The maximum touches after which a pan should not be emitted.
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstring> // for strcmp
// INTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/internal/event/events/gesture-event-processor.h>
#include <dali/public-api/events/pinch-gesture.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/internal/event/events/gesture-event-processor.h>
-#include <dali/integration-api/debug.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
// Signals
const char* const SIGNAL_PINCH_DETECTED = "pinchDetected";
return Dali::PinchGestureDetector::New();
}
-TypeRegistration mType( typeid(Dali::PinchGestureDetector), typeid(Dali::GestureDetector), Create );
+TypeRegistration mType(typeid(Dali::PinchGestureDetector), typeid(Dali::GestureDetector), Create);
-SignalConnectorType signalConnector1( mType, SIGNAL_PINCH_DETECTED, &PinchGestureDetector::DoConnectSignal );
-
-}
+SignalConnectorType signalConnector1(mType, SIGNAL_PINCH_DETECTED, &PinchGestureDetector::DoConnectSignal);
+} // namespace
PinchGestureDetectorPtr PinchGestureDetector::New()
{
void PinchGestureDetector::EmitPinchGestureSignal(Dali::Actor actor, const Dali::PinchGesture& pinch)
{
// Guard against destruction during signal emission
- Dali::PinchGestureDetector handle( this );
+ Dali::PinchGestureDetector handle(this);
- mDetectedSignal.Emit( actor, pinch );
+ mDetectedSignal.Emit(actor, pinch);
}
-bool PinchGestureDetector::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool PinchGestureDetector::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( true );
- PinchGestureDetector* gesture = static_cast< PinchGestureDetector* >(object); // TypeRegistry guarantees that this is the correct type.
+ bool connected(true);
+ PinchGestureDetector* gesture = static_cast<PinchGestureDetector*>(object); // TypeRegistry guarantees that this is the correct type.
- if ( 0 == strcmp( signalName.c_str(), SIGNAL_PINCH_DETECTED ) )
+ if(0 == strcmp(signalName.c_str(), SIGNAL_PINCH_DETECTED))
{
- gesture->DetectedSignal().Connect( tracker, functor );
+ gesture->DetectedSignal().Connect(tracker, functor);
}
else
{
#define DALI_INTERNAL_PINCH_GESTURE_DETECTOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/gesture-detector-impl.h>
#include <dali/public-api/events/pinch-gesture-detector.h>
#include <dali/public-api/events/pinch-gesture.h>
-#include <dali/internal/event/events/gesture-detector-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class PinchGestureDetector;
using PinchGestureDetectorPtr = IntrusivePtr<PinchGestureDetector>;
class PinchGestureDetector : public GestureDetector
{
public: // Creation
-
/**
* Create a new gesture detector.
* @return A smart-pointer to the newly allocated detector.
PinchGestureDetector();
public:
-
/**
* Called by the PinchGestureProcessor when a pinch gesture event occurs within the bounds of our
* attached actor.
void EmitPinchGestureSignal(Dali::Actor actor, const Dali::PinchGesture& pinch);
public: // Signals
-
/**
* @copydoc Dali::PinchGestureDetector::DetectedSignal()
*/
* @return True if the signal was connected.
* @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
*/
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
protected:
-
/**
* A reference counted object may only be deleted by calling Unreference()
*/
~PinchGestureDetector() override;
private:
-
// Undefined
PinchGestureDetector(const PinchGestureDetector&);
PinchGestureDetector& operator=(const PinchGestureDetector& rhs);
private: // GestureDetector overrides
-
/**
* @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
*/
void OnActorDestroyed(Object& object) override;
private:
-
Dali::PinchGestureDetector::DetectedSignalType mDetectedSignal;
};
inline Internal::PinchGestureDetector& GetImplementation(Dali::PinchGestureDetector& detector)
{
- DALI_ASSERT_ALWAYS( detector && "PinchGestureDetector handle is empty" );
+ DALI_ASSERT_ALWAYS(detector && "PinchGestureDetector handle is empty");
BaseObject& handle = detector.GetBaseObject();
inline const Internal::PinchGestureDetector& GetImplementation(const Dali::PinchGestureDetector& detector)
{
- DALI_ASSERT_ALWAYS( detector && "PinchGestureDetector handle is empty" );
+ DALI_ASSERT_ALWAYS(detector && "PinchGestureDetector handle is empty");
const BaseObject& handle = detector.GetBaseObject();
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
PinchGestureEvent::PinchGestureEvent(GestureState state)
: GestureEvent(GestureType::PINCH, state),
scale(0.0f),
#define DALI_INTERNAL_EVENT_PINCH_GESTURE_EVENT_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* If the adaptor detects a pinch gesture, then it should create an instance of this structure and
* send it to the Core.
Vector2 centerPoint;
};
-} // namespace Integration
+} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_PINCH_GESTURE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/gesture-impl.h>
+#include <dali/public-api/events/pinch-gesture.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/events/pinch-gesture.h>
-#include <dali/internal/event/events/gesture-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class PinchGesture;
using PinchGesturePtr = IntrusivePtr<PinchGesture>;
class PinchGesture final : public Gesture
{
public:
-
/**
* @brief Default constructor
*/
- PinchGesture( GestureState state )
+ PinchGesture(GestureState state)
: Gesture(GestureType::PINCH, state)
{
}
- PinchGesture(const PinchGesture&) = delete; ///< Deleted copy constructor
- PinchGesture(PinchGesture&&) = delete; ///< Deleted move constructor
+ PinchGesture(const PinchGesture&) = delete; ///< Deleted copy constructor
+ PinchGesture(PinchGesture&&) = delete; ///< Deleted move constructor
PinchGesture& operator=(const PinchGesture&) = delete; ///< Deleted copy assignment operator
- PinchGesture& operator=(PinchGesture&&) = delete; ///< Deleted move assignment operator
+ PinchGesture& operator=(PinchGesture&&) = delete; ///< Deleted move assignment operator
/**
* @brief The scale factor from the start of the pinch gesture till the latest pinch gesture.
* @param[in] scale The scale to set.
*/
- inline void SetScale( float scale )
+ inline void SetScale(float scale)
{
mScale = scale;
}
* @brief The speed at which the user is moving their fingers.
* @param[in] speed The speed to set.
*/
- inline void SetSpeed( float speed )
+ inline void SetSpeed(float speed)
{
mSpeed = speed;
}
* @brief The center point of the two points that caused the pinch gesture in screen coordinates.
* @param[in] screenCenterPoint The point in screen coordinates to set.
*/
- inline void SetScreenCenterPoint( const Vector2& screenCenterPoint )
+ inline void SetScreenCenterPoint(const Vector2& screenCenterPoint)
{
mScreenCenterPoint = screenCenterPoint;
}
* @brief The center point of the two points that caused the pinch gesture in local actor coordinates.
* @param[in] localCenterPoint The point in local actor coordinates to set.
*/
- inline void SetLocalCenterPoint( const Vector2& localCenterPoint )
+ inline void SetLocalCenterPoint(const Vector2& localCenterPoint)
{
mLocalCenterPoint = localCenterPoint;
}
}
private:
-
/**
* @brief Virtual destructor
*
private:
Vector2 mScreenCenterPoint;
Vector2 mLocalCenterPoint;
- float mScale{0.0f};
- float mSpeed{0.0f};
+ float mScale{0.0f};
+ float mSpeed{0.0f};
};
} // namespace Internal
// Helpers for public-api forwarding methods
-inline Internal::PinchGesture& GetImplementation( Dali::PinchGesture& pinchGesture )
+inline Internal::PinchGesture& GetImplementation(Dali::PinchGesture& pinchGesture)
{
- DALI_ASSERT_ALWAYS( pinchGesture && "pinchGesture handle is empty" );
+ DALI_ASSERT_ALWAYS(pinchGesture && "pinchGesture handle is empty");
BaseObject& object = pinchGesture.GetBaseObject();
- return static_cast< Internal::PinchGesture& >( object );
+ return static_cast<Internal::PinchGesture&>(object);
}
-inline const Internal::PinchGesture& GetImplementation( const Dali::PinchGesture& pinchGesture )
+inline const Internal::PinchGesture& GetImplementation(const Dali::PinchGesture& pinchGesture)
{
- DALI_ASSERT_ALWAYS( pinchGesture && "pinchGesture handle is empty" );
+ DALI_ASSERT_ALWAYS(pinchGesture && "pinchGesture handle is empty");
const BaseObject& object = pinchGesture.GetBaseObject();
- return static_cast< const Internal::PinchGesture& >( object );
+ return static_cast<const Internal::PinchGesture&>(object);
}
} // namespace Dali
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <algorithm>
// INTERNAL INCLUDES
-#include <dali/public-api/actors/actor.h>
-#include <dali/public-api/events/pinch-gesture.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/internal/event/events/pinch-gesture/pinch-gesture-event.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/event/common/scene-impl.h>
-#include <dali/internal/event/render-tasks/render-task-impl.h>
-#include <dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.h>
-#include <dali/internal/event/events/pinch-gesture/pinch-gesture-impl.h>
#include <dali/internal/event/events/gesture-requests.h>
+#include <dali/internal/event/events/pinch-gesture/pinch-gesture-event.h>
+#include <dali/internal/event/events/pinch-gesture/pinch-gesture-impl.h>
+#include <dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.h>
+#include <dali/internal/event/render-tasks/render-task-impl.h>
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/events/pinch-gesture.h>
+#include <dali/public-api/math/vector2.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-const uint32_t MINIMUM_TOUCH_EVENTS_REQUIRED = 4u;
+const uint32_t MINIMUM_TOUCH_EVENTS_REQUIRED = 4u;
const uint32_t MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START = 4u;
/**
* @param[in] localCenter Relative to the actor attached to the detector.
*/
void EmitPinchSignal(
- Actor* actor,
- const GestureDetectorContainer& gestureDetectors,
- const PinchGestureEvent& pinchEvent,
- Vector2 localCenter)
+ Actor* actor,
+ const GestureDetectorContainer& gestureDetectors,
+ const PinchGestureEvent& pinchEvent,
+ Vector2 localCenter)
{
- Internal::PinchGesturePtr pinch( new Internal::PinchGesture(pinchEvent.state ) );
- pinch->SetTime( pinchEvent.time );
+ Internal::PinchGesturePtr pinch(new Internal::PinchGesture(pinchEvent.state));
+ pinch->SetTime(pinchEvent.time);
- pinch->SetScale( pinchEvent.scale );
- pinch->SetSpeed( pinchEvent.speed );
- pinch->SetScreenCenterPoint( pinchEvent.centerPoint );
+ pinch->SetScale(pinchEvent.scale);
+ pinch->SetSpeed(pinchEvent.speed);
+ pinch->SetScreenCenterPoint(pinchEvent.centerPoint);
- pinch->SetLocalCenterPoint( localCenter );
+ pinch->SetLocalCenterPoint(localCenter);
- Dali::Actor actorHandle( actor );
+ Dali::Actor actorHandle(actor);
const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end();
- for ( GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter )
+ for(GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter)
{
- static_cast< PinchGestureDetector* >( *iter )->EmitPinchGestureSignal( actorHandle, Dali::PinchGesture( pinch.Get() ) );
+ static_cast<PinchGestureDetector*>(*iter)->EmitPinchGestureSignal(actorHandle, Dali::PinchGesture(pinch.Get()));
}
}
} // unnamed namespace
PinchGestureProcessor::PinchGestureProcessor()
-: GestureProcessor( GestureType::PINCH ),
+: GestureProcessor(GestureType::PINCH),
mPinchGestureDetectors(),
mCurrentPinchEmitters(),
mCurrentPinchEvent(nullptr),
mMinimumPinchDistance(-1.0f),
- mMinimumTouchEvents( MINIMUM_TOUCH_EVENTS_REQUIRED ),
- mMinimumTouchEventsAfterStart( MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START )
+ mMinimumTouchEvents(MINIMUM_TOUCH_EVENTS_REQUIRED),
+ mMinimumTouchEventsAfterStart(MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START)
{
}
PinchGestureProcessor::~PinchGestureProcessor() = default;
-void PinchGestureProcessor::SetMinimumPinchDistance( float value )
+void PinchGestureProcessor::SetMinimumPinchDistance(float value)
{
mMinimumPinchDistance = value;
- if( mGestureRecognizer )
+ if(mGestureRecognizer)
{
PinchGestureRecognizer* pinchRecognizer = dynamic_cast<PinchGestureRecognizer*>(mGestureRecognizer.Get());
- if( pinchRecognizer )
+ if(pinchRecognizer)
{
pinchRecognizer->SetMinimumPinchDistance(value);
}
}
}
-void PinchGestureProcessor::SetMinimumTouchEvents( uint32_t value )
+void PinchGestureProcessor::SetMinimumTouchEvents(uint32_t value)
{
- if( value > 1u && mMinimumTouchEvents != value )
+ if(value > 1u && mMinimumTouchEvents != value)
{
mMinimumTouchEvents = value;
- if( mGestureRecognizer )
+ if(mGestureRecognizer)
{
- PinchGestureRecognizer* pinchRecognizer = dynamic_cast<PinchGestureRecognizer*>( mGestureRecognizer.Get() );
- if( pinchRecognizer )
+ PinchGestureRecognizer* pinchRecognizer = dynamic_cast<PinchGestureRecognizer*>(mGestureRecognizer.Get());
+ if(pinchRecognizer)
{
- pinchRecognizer->SetMinimumTouchEvents( value );
+ pinchRecognizer->SetMinimumTouchEvents(value);
}
}
}
}
-void PinchGestureProcessor::SetMinimumTouchEventsAfterStart( uint32_t value )
+void PinchGestureProcessor::SetMinimumTouchEventsAfterStart(uint32_t value)
{
- if( value > 1u && mMinimumTouchEventsAfterStart != value )
+ if(value > 1u && mMinimumTouchEventsAfterStart != value)
{
mMinimumTouchEventsAfterStart = value;
- if( mGestureRecognizer )
+ if(mGestureRecognizer)
{
- PinchGestureRecognizer* pinchRecognizer = dynamic_cast<PinchGestureRecognizer*>( mGestureRecognizer.Get() );
- if( pinchRecognizer )
+ PinchGestureRecognizer* pinchRecognizer = dynamic_cast<PinchGestureRecognizer*>(mGestureRecognizer.Get());
+ if(pinchRecognizer)
{
- pinchRecognizer->SetMinimumTouchEventsAfterStart( value );
+ pinchRecognizer->SetMinimumTouchEventsAfterStart(value);
}
}
}
}
-void PinchGestureProcessor::Process( Scene& scene, const PinchGestureEvent& pinchEvent )
+void PinchGestureProcessor::Process(Scene& scene, const PinchGestureEvent& pinchEvent)
{
- switch ( pinchEvent.state )
+ switch(pinchEvent.state)
{
case GestureState::STARTED:
{
ResetActor();
HitTestAlgorithm::Results hitTestResults;
- if( HitTest( scene, pinchEvent.centerPoint, hitTestResults ) )
+ if(HitTest(scene, pinchEvent.centerPoint, hitTestResults))
{
// Record the current render-task for Screen->Actor coordinate conversions
mCurrentRenderTask = hitTestResults.renderTask;
// Set mCurrentPinchEvent to use inside overridden methods called from ProcessAndEmit()
mCurrentPinchEvent = &pinchEvent;
- ProcessAndEmit( hitTestResults );
+ ProcessAndEmit(hitTestResults);
mCurrentPinchEvent = nullptr;
}
break;
// Check if actor is still touchable.
Actor* currentGesturedActor = GetCurrentGesturedActor();
- if ( currentGesturedActor )
+ if(currentGesturedActor)
{
- if ( currentGesturedActor->IsHittable() && !mCurrentPinchEmitters.empty() && mCurrentRenderTask )
+ if(currentGesturedActor->IsHittable() && !mCurrentPinchEmitters.empty() && mCurrentRenderTask)
{
// Ensure actor is still attached to the emitters, if it is not then remove the emitter.
- GestureDetectorContainer::iterator endIter = std::remove_if( mCurrentPinchEmitters.begin(), mCurrentPinchEmitters.end(), IsNotAttachedFunctor(currentGesturedActor) );
- mCurrentPinchEmitters.erase( endIter, mCurrentPinchEmitters.end() );
+ GestureDetectorContainer::iterator endIter = std::remove_if(mCurrentPinchEmitters.begin(), mCurrentPinchEmitters.end(), IsNotAttachedFunctor(currentGesturedActor));
+ mCurrentPinchEmitters.erase(endIter, mCurrentPinchEmitters.end());
- if ( !mCurrentPinchEmitters.empty() )
+ if(!mCurrentPinchEmitters.empty())
{
- Vector2 actorCoords;
- RenderTask& renderTaskImpl( *mCurrentRenderTask.Get() );
- currentGesturedActor->ScreenToLocal( renderTaskImpl, actorCoords.x, actorCoords.y, pinchEvent.centerPoint.x, pinchEvent.centerPoint.y );
+ Vector2 actorCoords;
+ RenderTask& renderTaskImpl(*mCurrentRenderTask.Get());
+ currentGesturedActor->ScreenToLocal(renderTaskImpl, actorCoords.x, actorCoords.y, pinchEvent.centerPoint.x, pinchEvent.centerPoint.y);
- EmitPinchSignal( currentGesturedActor, mCurrentPinchEmitters, pinchEvent, actorCoords );
+ EmitPinchSignal(currentGesturedActor, mCurrentPinchEmitters, pinchEvent, actorCoords);
}
else
{
}
// Clear current emitters if pinch gesture has ended or been cancelled.
- if ( pinchEvent.state == GestureState::FINISHED || pinchEvent.state == GestureState::CANCELLED )
+ if(pinchEvent.state == GestureState::FINISHED || pinchEvent.state == GestureState::CANCELLED)
{
mCurrentPinchEmitters.clear();
ResetActor();
case GestureState::CLEAR:
{
- DALI_ABORT( "Incorrect state received from Integration layer: CLEAR\n" );
+ DALI_ABORT("Incorrect state received from Integration layer: CLEAR\n");
break;
}
case GestureState::POSSIBLE:
{
- DALI_ABORT( "Incorrect state received from Integration layer: POSSIBLE\n" );
+ DALI_ABORT("Incorrect state received from Integration layer: POSSIBLE\n");
break;
}
}
}
-void PinchGestureProcessor::AddGestureDetector( PinchGestureDetector* gestureDetector, Scene& scene )
+void PinchGestureProcessor::AddGestureDetector(PinchGestureDetector* gestureDetector, Scene& scene)
{
bool createRecognizer(mPinchGestureDetectors.empty());
mPinchGestureDetectors.push_back(gestureDetector);
- if (createRecognizer)
+ if(createRecognizer)
{
- Size size = scene.GetSize();
- mGestureRecognizer = new PinchGestureRecognizer( *this, Vector2(size.width, size.height), scene.GetDpi(), mMinimumPinchDistance, mMinimumTouchEventsAfterStart, mMinimumTouchEventsAfterStart );
+ Size size = scene.GetSize();
+ mGestureRecognizer = new PinchGestureRecognizer(*this, Vector2(size.width, size.height), scene.GetDpi(), mMinimumPinchDistance, mMinimumTouchEventsAfterStart, mMinimumTouchEventsAfterStart);
}
}
-void PinchGestureProcessor::RemoveGestureDetector( PinchGestureDetector* gestureDetector )
+void PinchGestureProcessor::RemoveGestureDetector(PinchGestureDetector* gestureDetector)
{
- if ( !mCurrentPinchEmitters.empty() )
+ if(!mCurrentPinchEmitters.empty())
{
// Check if the removed detector was one that is currently being pinched and remove it from emitters.
- GestureDetectorContainer::iterator endIter = std::remove( mCurrentPinchEmitters.begin(), mCurrentPinchEmitters.end(), gestureDetector );
- mCurrentPinchEmitters.erase( endIter, mCurrentPinchEmitters.end() );
+ GestureDetectorContainer::iterator endIter = std::remove(mCurrentPinchEmitters.begin(), mCurrentPinchEmitters.end(), gestureDetector);
+ mCurrentPinchEmitters.erase(endIter, mCurrentPinchEmitters.end());
// If we no longer have any emitters, then we should clear mCurrentGesturedActor as well
- if ( mCurrentPinchEmitters.empty() )
+ if(mCurrentPinchEmitters.empty())
{
ResetActor();
}
}
// Find the detector...
- PinchGestureDetectorContainer::iterator endIter = std::remove( mPinchGestureDetectors.begin(), mPinchGestureDetectors.end(), gestureDetector );
- DALI_ASSERT_DEBUG( endIter != mPinchGestureDetectors.end() );
+ PinchGestureDetectorContainer::iterator endIter = std::remove(mPinchGestureDetectors.begin(), mPinchGestureDetectors.end(), gestureDetector);
+ DALI_ASSERT_DEBUG(endIter != mPinchGestureDetectors.end());
// ...and remove it
mPinchGestureDetectors.erase(endIter, mPinchGestureDetectors.end());
- if (mPinchGestureDetectors.empty())
+ if(mPinchGestureDetectors.empty())
{
mGestureRecognizer = nullptr;
}
}
-void PinchGestureProcessor::GestureDetectorUpdated( PinchGestureDetector* gestureDetector )
+void PinchGestureProcessor::GestureDetectorUpdated(PinchGestureDetector* gestureDetector)
{
// Nothing to do as PinchGestureDetector does not have any specific parameters.
}
mCurrentPinchEmitters.clear();
}
-bool PinchGestureProcessor::CheckGestureDetector( GestureDetector* detector, Actor* actor )
+bool PinchGestureProcessor::CheckGestureDetector(GestureDetector* detector, Actor* actor)
{
// No special case required for pinch.
return true;
}
-void PinchGestureProcessor::EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
+void PinchGestureProcessor::EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates)
{
- DALI_ASSERT_DEBUG( mCurrentPinchEvent );
+ DALI_ASSERT_DEBUG(mCurrentPinchEvent);
- EmitPinchSignal( actor, gestureDetectors, *mCurrentPinchEvent, actorCoordinates );
+ EmitPinchSignal(actor, gestureDetectors, *mCurrentPinchEvent, actorCoordinates);
- if ( actor->OnScene() )
+ if(actor->OnScene())
{
mCurrentPinchEmitters = gestureDetectors;
- SetActor( actor );
+ SetActor(actor);
}
}
#define DALI_INTERNAL_PINCH_GESTURE_EVENT_PROCESSOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.h>
#include <dali/internal/event/events/gesture-processor.h>
+#include <dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.h>
#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class Scene;
class Stage;
class PinchGestureProcessor : public GestureProcessor, public RecognizerObserver<PinchGestureEvent>
{
public:
-
/**
* Create a pinch gesture processor.
*/
~PinchGestureProcessor() override;
public: // To be called by GestureEventProcessor
-
/**
* This method sets the minimum distance to start a pinch
* @param[in] value The distance in pixels
*/
- void SetMinimumPinchDistance( float value );
+ void SetMinimumPinchDistance(float value);
/**
* Sets the minimum touch events required before a pinch can be started
* @param[in] value The number of touch events
*/
- void SetMinimumTouchEvents( uint32_t value );
+ void SetMinimumTouchEvents(uint32_t value);
/**
* Sets the minimum touch events required after a pinch started
* @param[in] value The number of touch events
*/
- void SetMinimumTouchEventsAfterStart( uint32_t value );
+ void SetMinimumTouchEventsAfterStart(uint32_t value);
/**
* This method is called whenever a pinch gesture event occurs.
* @param[in] scene The scene the pinch gesture event occurs in.
* @param[in] pinchEvent The event that has occurred.
*/
- void Process( Scene& scene, const PinchGestureEvent& pinchEvent ) override;
+ void Process(Scene& scene, const PinchGestureEvent& pinchEvent) override;
/**
* Adds a gesture detector to this gesture processor.
void GestureDetectorUpdated(PinchGestureDetector* gestureDetector);
private:
-
// Undefined
PinchGestureProcessor(const PinchGestureProcessor&);
PinchGestureProcessor& operator=(const PinchGestureProcessor& rhs);
private:
-
// GestureProcessor overrides
/**
/**
* @copydoc GestureProcessor::CheckGestureDetector()
*/
- bool CheckGestureDetector( GestureDetector* detector, Actor* actor ) override;
+ bool CheckGestureDetector(GestureDetector* detector, Actor* actor) override;
/**
* @copydoc GestureProcessor::EmitGestureSignal()
*/
- void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates ) override;
+ void EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates) override;
private:
-
PinchGestureDetectorContainer mPinchGestureDetectors;
- GestureDetectorContainer mCurrentPinchEmitters;
- RenderTaskPtr mCurrentRenderTask;
+ GestureDetectorContainer mCurrentPinchEmitters;
+ RenderTaskPtr mCurrentRenderTask;
const PinchGestureEvent* mCurrentPinchEvent; ///< Pointer to current PinchEvent, used when calling ProcessAndEmit()
- float mMinimumPinchDistance;
+ float mMinimumPinchDistance;
uint32_t mMinimumTouchEvents;
uint32_t mMinimumTouchEventsAfterStart;
};
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/devel-api/events/touch-point.h>
#include <dali/public-api/math/vector2.h>
-#include <dali/internal/event/events/pinch-gesture/pinch-gesture-event.h>
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/internal/event/common/scene-impl.h>
+#include <dali/internal/event/events/pinch-gesture/pinch-gesture-event.h>
// INTERNAL INCLUDES
-
namespace Dali
{
-
namespace Internal
{
-
namespace
{
const float MINIMUM_DISTANCE_IN_MILLIINCH = 45.0f; // This value is used for measuring minimum pinch distance in pixel.
-const float MINIMUM_DISTANCE_IN_PIXEL = 10.0f; // This value is for devices that do not provide a valid dpi value. (assumes 220dpi)
+const float MINIMUM_DISTANCE_IN_PIXEL = 10.0f; // This value is for devices that do not provide a valid dpi value. (assumes 220dpi)
inline float GetDistance(const Integration::Point& point1, const Integration::Point& point2)
{
return Vector2(point1.GetScreenPosition() + point2.GetScreenPosition()) * 0.5f;
}
-inline bool IsValidDpi( const Vector2& dpi )
+inline bool IsValidDpi(const Vector2& dpi)
{
return dpi.x > 0.f && dpi.y > 0.f;
}
-inline float GetDefaultMinimumPinchDistance( const Vector2& dpi )
+inline float GetDefaultMinimumPinchDistance(const Vector2& dpi)
{
- return IsValidDpi( dpi ) ? ( ( MINIMUM_DISTANCE_IN_MILLIINCH * std::min( dpi.x, dpi.y ) ) / 1000.f ) : MINIMUM_DISTANCE_IN_PIXEL;
+ return IsValidDpi(dpi) ? ((MINIMUM_DISTANCE_IN_MILLIINCH * std::min(dpi.x, dpi.y)) / 1000.f) : MINIMUM_DISTANCE_IN_PIXEL;
}
} // unnamed namespace
-PinchGestureRecognizer::PinchGestureRecognizer( Observer& observer, Vector2 screenSize, Vector2 screenDpi, float minimumPinchDistance, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart )
-: GestureRecognizer( screenSize, GestureType::PINCH ),
- mObserver( observer ),
- mState( CLEAR ),
+PinchGestureRecognizer::PinchGestureRecognizer(Observer& observer, Vector2 screenSize, Vector2 screenDpi, float minimumPinchDistance, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart)
+: GestureRecognizer(screenSize, GestureType::PINCH),
+ mObserver(observer),
+ mState(CLEAR),
mTouchEvents(),
- mDefaultMinimumDistanceDelta( GetDefaultMinimumPinchDistance( screenDpi ) ),
- mStartingDistance( 0.0f ),
- mMinimumTouchEvents( minimumTouchEvents ),
- mMinimumTouchEventsAfterStart( minimumTouchEventsAfterStart )
+ mDefaultMinimumDistanceDelta(GetDefaultMinimumPinchDistance(screenDpi)),
+ mStartingDistance(0.0f),
+ mMinimumTouchEvents(minimumTouchEvents),
+ mMinimumTouchEventsAfterStart(minimumTouchEventsAfterStart)
{
- SetMinimumPinchDistance( minimumPinchDistance );
+ SetMinimumPinchDistance(minimumPinchDistance);
}
PinchGestureRecognizer::~PinchGestureRecognizer() = default;
void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
{
- int pointCount = event.GetPointCount();
+ int pointCount = event.GetPointCount();
GestureRecognizerPtr ptr(this); // To keep us from being destroyed during the life-time of this method
- switch (mState)
+ switch(mState)
{
case CLEAR:
{
- if (pointCount == 2)
+ if(pointCount == 2)
{
// Change state to possible as we have two touch points.
mState = POSSIBLE;
case POSSIBLE:
{
- if (pointCount != 2)
+ if(pointCount != 2)
{
// We no longer have two touch points so change state back to CLEAR.
mState = CLEAR;
const Integration::Point& currentPoint1 = event.points[0];
const Integration::Point& currentPoint2 = event.points[1];
- if (currentPoint1.GetState() == PointState::UP || currentPoint2.GetState() == PointState::UP || currentPoint1.GetState() == PointState::INTERRUPTED)
+ if(currentPoint1.GetState() == PointState::UP || currentPoint2.GetState() == PointState::UP || currentPoint1.GetState() == PointState::INTERRUPTED)
{
// One of our touch points has an Up event so change our state back to CLEAR.
mState = CLEAR;
mTouchEvents.push_back(event);
// We can only determine a pinch after a certain number of touch points have been collected.
- if( mTouchEvents.size() >= mMinimumTouchEvents )
+ if(mTouchEvents.size() >= mMinimumTouchEvents)
{
const Integration::Point& firstPoint1 = mTouchEvents[0].points[0];
const Integration::Point& firstPoint2 = mTouchEvents[0].points[1];
- float firstDistance = GetDistance(firstPoint1, firstPoint2);
+ float firstDistance = GetDistance(firstPoint1, firstPoint2);
float currentDistance = GetDistance(currentPoint1, currentPoint2);
float distanceChanged = firstDistance - currentDistance;
// Check if distance has changed enough
- if (fabsf(distanceChanged) > mMinimumDistanceDelta)
+ if(fabsf(distanceChanged) > mMinimumDistanceDelta)
{
// Remove the first few events from the vector otherwise values are exaggerated
- mTouchEvents.erase( mTouchEvents.begin(), mTouchEvents.end() - mMinimumTouchEvents );
+ mTouchEvents.erase(mTouchEvents.begin(), mTouchEvents.end() - mMinimumTouchEvents);
- if ( !mTouchEvents.empty() )
+ if(!mTouchEvents.empty())
{
mStartingDistance = GetDistance(mTouchEvents.begin()->points[0], mTouchEvents.begin()->points[1]);
mTouchEvents.clear();
}
- if (mState == POSSIBLE)
+ if(mState == POSSIBLE)
{
// No pinch, so restart detection
mState = CLEAR;
mState = CLEAR;
mTouchEvents.clear();
}
- else if (pointCount != 2)
+ else if(pointCount != 2)
{
// Send pinch finished event
SendPinch(GestureState::FINISHED, event);
const Integration::Point& currentPoint1 = event.points[0];
const Integration::Point& currentPoint2 = event.points[1];
- if (currentPoint1.GetState() == PointState::UP || currentPoint2.GetState() == PointState::UP)
+ if(currentPoint1.GetState() == PointState::UP || currentPoint2.GetState() == PointState::UP)
{
mTouchEvents.push_back(event);
// Send pinch finished event
{
mTouchEvents.push_back(event);
- if( mTouchEvents.size() >= mMinimumTouchEventsAfterStart )
+ if(mTouchEvents.size() >= mMinimumTouchEventsAfterStart)
{
// Send pinch continuing
SendPinch(GestureState::CONTINUING, event);
{
PinchGestureEvent gesture(state);
- if ( !mTouchEvents.empty() )
+ if(!mTouchEvents.empty())
{
const Integration::TouchEvent& firstEvent = mTouchEvents[0];
// Assert if we have been holding TouchEvents that do not have 2 points
- DALI_ASSERT_DEBUG( firstEvent.GetPointCount() == 2 );
+ DALI_ASSERT_DEBUG(firstEvent.GetPointCount() == 2);
// We should use the current event in our calculations unless it does not have two points.
// If it does not have two points, then we should use the last point in mTouchEvents.
- Integration::TouchEvent event( currentEvent );
- if ( event.GetPointCount() != 2 )
+ Integration::TouchEvent event(currentEvent);
+ if(event.GetPointCount() != 2)
{
event = *mTouchEvents.rbegin();
}
- const Integration::Point& firstPoint1( firstEvent.points[0] );
- const Integration::Point& firstPoint2( firstEvent.points[1] );
- const Integration::Point& currentPoint1( event.points[0] );
- const Integration::Point& currentPoint2( event.points[1] );
+ const Integration::Point& firstPoint1(firstEvent.points[0]);
+ const Integration::Point& firstPoint2(firstEvent.points[1]);
+ const Integration::Point& currentPoint1(event.points[0]);
+ const Integration::Point& currentPoint2(event.points[1]);
- float firstDistance = GetDistance(firstPoint1, firstPoint2);
+ float firstDistance = GetDistance(firstPoint1, firstPoint2);
float currentDistance = GetDistance(currentPoint1, currentPoint2);
- gesture.scale = currentDistance / mStartingDistance;
+ gesture.scale = currentDistance / mStartingDistance;
float distanceDelta = fabsf(firstDistance - currentDistance);
- float timeDelta = static_cast<float> ( currentEvent.time - firstEvent.time );
- gesture.speed = ( distanceDelta / timeDelta ) * 1000.0f;
+ float timeDelta = static_cast<float>(currentEvent.time - firstEvent.time);
+ gesture.speed = (distanceDelta / timeDelta) * 1000.0f;
gesture.centerPoint = GetCenterPoint(currentPoint1, currentPoint2);
}
gesture.time = currentEvent.time;
- if( mScene )
+ if(mScene)
{
// Create another handle so the recognizer cannot be destroyed during process function
GestureRecognizerPtr recognizerHandle = this;
}
}
-void PinchGestureRecognizer::SetMinimumTouchEvents( uint32_t value )
+void PinchGestureRecognizer::SetMinimumTouchEvents(uint32_t value)
{
mMinimumTouchEvents = value;
}
-void PinchGestureRecognizer::SetMinimumTouchEventsAfterStart( uint32_t value )
+void PinchGestureRecognizer::SetMinimumTouchEventsAfterStart(uint32_t value)
{
mMinimumTouchEventsAfterStart = value;
}
#define DALI_INTERNAL_EVENT_PINCH_GESTURE_RECOGNIZER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Integration
{
struct TouchEvent;
namespace Internal
{
-
/**
* When given a set of touch events, this detector attempts to determine if a pinch gesture has taken place.
*/
class PinchGestureRecognizer : public GestureRecognizer
{
public:
-
using Observer = RecognizerObserver<PinchGestureEvent>;
/**
* @param[in] minimumTouchEvents The number of touch events required
* @param[in] minimumTouchEventsAfterStart The number of touch events required after a gesture started
*/
- PinchGestureRecognizer( Observer& observer, Vector2 screenSize, Vector2 screenDpi, float minimumPinchDistance, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart );
+ PinchGestureRecognizer(Observer& observer, Vector2 screenSize, Vector2 screenDpi, float minimumPinchDistance, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart);
/**
* Virtual destructor.
~PinchGestureRecognizer() override;
public:
-
void SetMinimumPinchDistance(float value);
/**
* Sets the minimum touch events required before a pinch can be started
* @param[in] value The number of touch events
*/
- void SetMinimumTouchEvents( uint32_t value );
+ void SetMinimumTouchEvents(uint32_t value);
/**
* Sets the minimum touch events required after a pinch started
* @param[in] value The number of touch events
*/
- void SetMinimumTouchEventsAfterStart( uint32_t value );
+ void SetMinimumTouchEventsAfterStart(uint32_t value);
/**
* @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
void Update(const GestureRequest& request) override;
private:
-
/**
* Emits the pinch gesture event to the core.
* @param[in] state The state of the pinch (whether it's starting, continuing or finished).
void SendPinch(GestureState state, const Integration::TouchEvent& currentEvent);
private:
-
// Reference to the gesture processor for this recognizer
Observer& mObserver;
STARTED, ///< A gesture has been detected.
};
- State mState; ///< The current state of the detector.
+ State mState; ///< The current state of the detector.
std::vector<Integration::TouchEvent> mTouchEvents; ///< The touch events since initial touch down.
float mDefaultMinimumDistanceDelta; ///< The default value of the mMinimumDistanceDelta.
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/events/ray-test.h>
// INTERNAL INCLUDES
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/math/vector3.h>
-#include <dali/public-api/math/vector4.h>
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/update/nodes/node.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/math/vector3.h>
+#include <dali/public-api/math/vector4.h>
using Dali::Internal::SceneGraph::Node;
namespace Dali
{
-
namespace Internal
{
-
RayTest::RayTest()
-: mEventThreadServices( EventThreadServices::Get() )
+: mEventThreadServices(EventThreadServices::Get())
{
}
-bool RayTest::SphereTest( const Internal::Actor& actor, const Vector4& rayOrigin, const Vector4& rayDir ) const
+bool RayTest::SphereTest(const Internal::Actor& actor, const Vector4& rayOrigin, const Vector4& rayDir) const
{
/*
http://wiki.cgsociety.org/index.php/Ray_Sphere_Intersection
*/
// Early out if not on the scene
- if( ! actor.OnScene() )
+ if(!actor.OnScene())
{
return false;
}
- const Node& node = actor.GetNode();
+ const Node& node = actor.GetNode();
const BufferIndex bufferIndex = EventThreadServices::Get().GetEventBufferIndex();
- const Vector3& translation = node.GetWorldPosition( bufferIndex );
- const Vector3& size = node.GetSize( bufferIndex );
- const Vector3& scale = node.GetWorldScale( bufferIndex );
+ const Vector3& translation = node.GetWorldPosition(bufferIndex);
+ const Vector3& size = node.GetSize(bufferIndex);
+ const Vector3& scale = node.GetWorldScale(bufferIndex);
// Transforms the ray to the local reference system. As the test is against a sphere, only the translation and scale are needed.
- const Vector3 rayOriginLocal( rayOrigin.x - translation.x, rayOrigin.y - translation.y, rayOrigin.z - translation.z );
+ const Vector3 rayOriginLocal(rayOrigin.x - translation.x, rayOrigin.y - translation.y, rayOrigin.z - translation.z);
// Computing the radius is not needed, a square radius is enough so can just use size but we do need to scale the sphere
- const float width = size.width * scale.width;
+ const float width = size.width * scale.width;
const float height = size.height * scale.height;
- float squareSphereRadius = 0.5f * ( width * width + height * height );
+ float squareSphereRadius = 0.5f * (width * width + height * height);
- float a = rayDir.Dot( rayDir ); // a
- float b2 = rayDir.Dot( rayOriginLocal ); // b/2
- float c = rayOriginLocal.Dot( rayOriginLocal ) - squareSphereRadius; // c
+ float a = rayDir.Dot(rayDir); // a
+ float b2 = rayDir.Dot(rayOriginLocal); // b/2
+ float c = rayOriginLocal.Dot(rayOriginLocal) - squareSphereRadius; // c
- return ( b2 * b2 - a * c ) >= 0.0f;
+ return (b2 * b2 - a * c) >= 0.0f;
}
-
bool RayTest::ActorTest(const Internal::Actor& actor, const Vector4& rayOrigin, const Vector4& rayDir, Vector2& hitPointLocal, float& distance) const
{
bool hit = false;
// Transforms the ray to the local reference system.
// Calculate the inverse of Model matrix
- Matrix invModelMatrix( false/*don't init*/);
+ Matrix invModelMatrix(false /*don't init*/);
invModelMatrix = node.GetWorldMatrix(0);
invModelMatrix.Invert();
float a = -rayOriginLocal.z;
float b = rayDirLocal.z;
- if( fabsf( b ) > Math::MACHINE_EPSILON_1 )
+ if(fabsf(b) > Math::MACHINE_EPSILON_1)
{
// Ray travels distance * rayDirLocal to intersect with plane.
distance = a / b;
const Vector2& size = actor.GetTouchArea() == Vector2::ZERO ? Vector2(node.GetSize(EventThreadServices::Get().GetEventBufferIndex())) : actor.GetTouchArea();
- hitPointLocal.x = rayOriginLocal.x + rayDirLocal.x * distance + size.x * 0.5f;
- hitPointLocal.y = rayOriginLocal.y + rayDirLocal.y * distance + size.y * 0.5f;
+ hitPointLocal.x = rayOriginLocal.x + rayDirLocal.x * distance + size.x * 0.5f;
+ hitPointLocal.y = rayOriginLocal.y + rayDirLocal.y * distance + size.y * 0.5f;
// Test with the actor's geometry.
hit = (hitPointLocal.x >= 0.f) && (hitPointLocal.x <= size.x) && (hitPointLocal.y >= 0.f) && (hitPointLocal.y <= size.y);
#define DALI_INTERNAL_RAY_TEST_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
struct Vector2;
struct Vector4;
namespace Internal
{
-
class Actor;
class EventThreadServices;
class RayTest
{
public:
-
/// Constructor
RayTest();
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstring> // for strcmp
// INTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/internal/event/events/gesture-event-processor.h>
#include <dali/public-api/events/rotation-gesture.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/internal/event/events/gesture-event-processor.h>
-#include <dali/integration-api/debug.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
// Signals
const char* const SIGNAL_ROTATION_DETECTED = "rotationDetected";
return Dali::RotationGestureDetector::New();
}
-TypeRegistration mType( typeid( Dali::RotationGestureDetector ), typeid( Dali::GestureDetector ), Create );
+TypeRegistration mType(typeid(Dali::RotationGestureDetector), typeid(Dali::GestureDetector), Create);
-SignalConnectorType signalConnector1( mType, SIGNAL_ROTATION_DETECTED, &RotationGestureDetector::DoConnectSignal );
-
-}
+SignalConnectorType signalConnector1(mType, SIGNAL_ROTATION_DETECTED, &RotationGestureDetector::DoConnectSignal);
+} // namespace
RotationGestureDetectorPtr RotationGestureDetector::New()
{
}
RotationGestureDetector::RotationGestureDetector()
-: GestureDetector( GestureType::ROTATION )
+: GestureDetector(GestureType::ROTATION)
{
}
-void RotationGestureDetector::EmitRotationGestureSignal( Dali::Actor actor, const Dali::RotationGesture& rotation )
+void RotationGestureDetector::EmitRotationGestureSignal(Dali::Actor actor, const Dali::RotationGesture& rotation)
{
// Guard against destruction during signal emission
- Dali::RotationGestureDetector handle( this );
+ Dali::RotationGestureDetector handle(this);
- mDetectedSignal.Emit( actor, rotation );
+ mDetectedSignal.Emit(actor, rotation);
}
-bool RotationGestureDetector::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool RotationGestureDetector::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( true );
- RotationGestureDetector* gesture = static_cast< RotationGestureDetector* >( object ); // TypeRegistry guarantees that this is the correct type.
+ bool connected(true);
+ RotationGestureDetector* gesture = static_cast<RotationGestureDetector*>(object); // TypeRegistry guarantees that this is the correct type.
- if ( 0 == strcmp( signalName.c_str(), SIGNAL_ROTATION_DETECTED ) )
+ if(0 == strcmp(signalName.c_str(), SIGNAL_ROTATION_DETECTED))
{
- gesture->DetectedSignal().Connect( tracker, functor );
+ gesture->DetectedSignal().Connect(tracker, functor);
}
else
{
#define DALI_INTERNAL_ROTATION_GESTURE_DETECTOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/gesture-detector-impl.h>
#include <dali/public-api/events/rotation-gesture-detector.h>
#include <dali/public-api/events/rotation-gesture.h>
-#include <dali/internal/event/events/gesture-detector-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class RotationGestureDetector;
using RotationGestureDetectorPtr = IntrusivePtr<RotationGestureDetector>;
class RotationGestureDetector : public GestureDetector
{
public: // Creation
-
/**
* Create a new gesture detector.
* @return A smart-pointer to the newly allocated detector.
// Not copyable
- RotationGestureDetector( const RotationGestureDetector& ) = delete; ///< Deleted copy constructor
+ RotationGestureDetector(const RotationGestureDetector&) = delete; ///< Deleted copy constructor
RotationGestureDetector& operator=(const RotationGestureDetector& rhs) = delete; ///< Deleted copy assignment operator
public:
-
/**
* Called by the RotationGestureProcessor when a rotation gesture event occurs within the bounds of our
* attached actor.
* @param[in] actor The rotated actor
* @param[in] rotation The rotation gesture
*/
- void EmitRotationGestureSignal( Dali::Actor actor, const Dali::RotationGesture& rotation );
+ void EmitRotationGestureSignal(Dali::Actor actor, const Dali::RotationGesture& rotation);
public: // Signals
-
/**
* @copydoc Dali::RotationGestureDetector::DetectedSignal()
*/
* @return True if the signal was connected.
* @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
*/
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
protected:
-
/**
* A reference counted object may only be deleted by calling Unreference()
*/
~RotationGestureDetector() override = default;
private: // GestureDetector overrides
-
/**
* @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
*/
- void OnActorAttach( Actor& actor ) override { /* Nothing to do */ }
+ void OnActorAttach(Actor& actor) override
+ { /* Nothing to do */
+ }
/**
* @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
*/
- void OnActorDetach( Actor& actor ) override { /* Nothing to do */ }
+ void OnActorDetach(Actor& actor) override
+ { /* Nothing to do */
+ }
/**
* @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
*/
- void OnActorDestroyed( Object& object ) override { /* Nothing to do */ }
+ void OnActorDestroyed(Object& object) override
+ { /* Nothing to do */
+ }
private:
-
Dali::RotationGestureDetector::DetectedSignalType mDetectedSignal;
};
// Helpers for public-api forwarding methods
-inline Internal::RotationGestureDetector& GetImplementation( Dali::RotationGestureDetector& detector )
+inline Internal::RotationGestureDetector& GetImplementation(Dali::RotationGestureDetector& detector)
{
- DALI_ASSERT_ALWAYS( detector && "RotationGestureDetector handle is empty" );
+ DALI_ASSERT_ALWAYS(detector && "RotationGestureDetector handle is empty");
BaseObject& handle = detector.GetBaseObject();
- return static_cast<Internal::RotationGestureDetector&>( handle );
+ return static_cast<Internal::RotationGestureDetector&>(handle);
}
-inline const Internal::RotationGestureDetector& GetImplementation( const Dali::RotationGestureDetector& detector )
+inline const Internal::RotationGestureDetector& GetImplementation(const Dali::RotationGestureDetector& detector)
{
- DALI_ASSERT_ALWAYS( detector && "RotationGestureDetector handle is empty" );
+ DALI_ASSERT_ALWAYS(detector && "RotationGestureDetector handle is empty");
const BaseObject& handle = detector.GetBaseObject();
- return static_cast<const Internal::RotationGestureDetector&>( handle );
+ return static_cast<const Internal::RotationGestureDetector&>(handle);
}
} // namespace Dali
#define DALI_INTERNAL_EVENT_ROTATION_GESTURE_EVENT_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/gesture-event.h>
#include <dali/public-api/math/radian.h>
#include <dali/public-api/math/vector2.h>
-#include <dali/internal/event/events/gesture-event.h>
namespace Dali
{
-
namespace Internal
{
-
/**
* When a rotation gesture is detected, this structure holds information regarding the gesture.
*
* Default Constructor
* @param[in] state The state of the gesture
*/
- RotationGestureEvent( GestureState state )
- : GestureEvent( GestureType::ROTATION, state )
+ RotationGestureEvent(GestureState state)
+ : GestureEvent(GestureType::ROTATION, state)
{
}
Vector2 centerPoint;
};
-} // namespace Integration
+} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_ROTATION_GESTURE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/gesture-impl.h>
+#include <dali/public-api/events/rotation-gesture.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/events/rotation-gesture.h>
-#include <dali/internal/event/events/gesture-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class RotationGesture;
using RotationGesturePtr = IntrusivePtr<RotationGesture>;
class RotationGesture final : public Gesture
{
public:
-
/**
* @brief Default constructor
*/
- RotationGesture( GestureState state )
- : Gesture( GestureType::ROTATION, state )
+ RotationGesture(GestureState state)
+ : Gesture(GestureType::ROTATION, state)
{
}
- RotationGesture(const RotationGesture&) = delete; ///< Deleted copy constructor
- RotationGesture(RotationGesture&&) = delete; ///< Deleted move constructor
+ RotationGesture(const RotationGesture&) = delete; ///< Deleted copy constructor
+ RotationGesture(RotationGesture&&) = delete; ///< Deleted move constructor
RotationGesture& operator=(const RotationGesture&) = delete; ///< Deleted copy assignment operator
- RotationGesture& operator=(RotationGesture&&) = delete; ///< Deleted move assignment operator
+ RotationGesture& operator=(RotationGesture&&) = delete; ///< Deleted move assignment operator
/**
* @brief The overall rotation from the start of the rotation gesture till the latest rotation gesture.
* @param[in] rotation The rotation to set.
*/
- inline void SetRotation( const Radian& rotation )
+ inline void SetRotation(const Radian& rotation)
{
mRotation = rotation;
}
* @brief The center point of the two points that caused the rotation gesture in screen coordinates.
* @param[in] screenCenterPoint The point in screen coordinates to set.
*/
- inline void SetScreenCenterPoint( const Vector2& screenCenterPoint )
+ inline void SetScreenCenterPoint(const Vector2& screenCenterPoint)
{
mScreenCenterPoint = screenCenterPoint;
}
* @brief The center point of the two points that caused the rotation gesture in local actor coordinates.
* @param[in] localCenterPoint The point in local actor coordinates to set.
*/
- inline void SetLocalCenterPoint( const Vector2& localCenterPoint )
+ inline void SetLocalCenterPoint(const Vector2& localCenterPoint)
{
mLocalCenterPoint = localCenterPoint;
}
}
private:
-
/**
* @brief Virtual destructor
*
~RotationGesture() override = default;
private:
- Radian mRotation;
+ Radian mRotation;
Vector2 mScreenCenterPoint;
Vector2 mLocalCenterPoint;
};
// Helpers for public-api forwarding methods
-inline Internal::RotationGesture& GetImplementation( Dali::RotationGesture& rotationGesture )
+inline Internal::RotationGesture& GetImplementation(Dali::RotationGesture& rotationGesture)
{
- DALI_ASSERT_ALWAYS( rotationGesture && "rotationGesture handle is empty" );
+ DALI_ASSERT_ALWAYS(rotationGesture && "rotationGesture handle is empty");
BaseObject& object = rotationGesture.GetBaseObject();
- return static_cast< Internal::RotationGesture& >( object );
+ return static_cast<Internal::RotationGesture&>(object);
}
-inline const Internal::RotationGesture& GetImplementation( const Dali::RotationGesture& rotationGesture )
+inline const Internal::RotationGesture& GetImplementation(const Dali::RotationGesture& rotationGesture)
{
- DALI_ASSERT_ALWAYS( rotationGesture && "rotationGesture handle is empty" );
+ DALI_ASSERT_ALWAYS(rotationGesture && "rotationGesture handle is empty");
const BaseObject& object = rotationGesture.GetBaseObject();
- return static_cast< const Internal::RotationGesture& >( object );
+ return static_cast<const Internal::RotationGesture&>(object);
}
} // namespace Dali
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <algorithm>
// INTERNAL INCLUDES
-#include <dali/public-api/actors/actor.h>
-#include <dali/public-api/events/rotation-gesture.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/internal/event/events/rotation-gesture/rotation-gesture-event.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/event/common/scene-impl.h>
-#include <dali/internal/event/render-tasks/render-task-impl.h>
-#include <dali/internal/event/events/rotation-gesture/rotation-gesture-recognizer.h>
#include <dali/internal/event/events/gesture-requests.h>
+#include <dali/internal/event/events/rotation-gesture/rotation-gesture-event.h>
#include <dali/internal/event/events/rotation-gesture/rotation-gesture-impl.h>
+#include <dali/internal/event/events/rotation-gesture/rotation-gesture-recognizer.h>
+#include <dali/internal/event/render-tasks/render-task-impl.h>
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/events/rotation-gesture.h>
+#include <dali/public-api/math/vector2.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-const uint32_t MINIMUM_TOUCH_EVENTS_REQUIRED = 4u;
+const uint32_t MINIMUM_TOUCH_EVENTS_REQUIRED = 4u;
const uint32_t MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START = 4u;
/**
* @param[in] localCenter Relative to the actor attached to the detector.
*/
void EmitRotationSignal(
- Actor* actor,
- const GestureDetectorContainer& gestureDetectors,
- const RotationGestureEvent& rotationEvent,
- Vector2 localCenter)
+ Actor* actor,
+ const GestureDetectorContainer& gestureDetectors,
+ const RotationGestureEvent& rotationEvent,
+ Vector2 localCenter)
{
- Internal::RotationGesturePtr rotation( new Internal::RotationGesture(rotationEvent.state ) );
- rotation->SetTime( rotationEvent.time );
- rotation->SetRotation( rotationEvent.rotation );
- rotation->SetScreenCenterPoint( rotationEvent.centerPoint );
- rotation->SetLocalCenterPoint( localCenter );
+ Internal::RotationGesturePtr rotation(new Internal::RotationGesture(rotationEvent.state));
+ rotation->SetTime(rotationEvent.time);
+ rotation->SetRotation(rotationEvent.rotation);
+ rotation->SetScreenCenterPoint(rotationEvent.centerPoint);
+ rotation->SetLocalCenterPoint(localCenter);
- Dali::Actor actorHandle( actor );
+ Dali::Actor actorHandle(actor);
const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end();
- for ( GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter )
+ for(GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter)
{
- static_cast< RotationGestureDetector* >( *iter )->EmitRotationGestureSignal( actorHandle, Dali::RotationGesture( rotation.Get() ) );
+ static_cast<RotationGestureDetector*>(*iter)->EmitRotationGestureSignal(actorHandle, Dali::RotationGesture(rotation.Get()));
}
}
} // unnamed namespace
RotationGestureProcessor::RotationGestureProcessor()
-: GestureProcessor( GestureType::ROTATION ),
+: GestureProcessor(GestureType::ROTATION),
mRotationGestureDetectors(),
mCurrentRotationEmitters(),
- mCurrentRotationEvent( nullptr ),
- mMinimumTouchEvents( MINIMUM_TOUCH_EVENTS_REQUIRED ),
- mMinimumTouchEventsAfterStart( MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START )
+ mCurrentRotationEvent(nullptr),
+ mMinimumTouchEvents(MINIMUM_TOUCH_EVENTS_REQUIRED),
+ mMinimumTouchEventsAfterStart(MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START)
{
}
-void RotationGestureProcessor::Process( Scene& scene, const RotationGestureEvent& rotationEvent )
+void RotationGestureProcessor::Process(Scene& scene, const RotationGestureEvent& rotationEvent)
{
- switch ( rotationEvent.state )
+ switch(rotationEvent.state)
{
case GestureState::STARTED:
{
ResetActor();
HitTestAlgorithm::Results hitTestResults;
- if( HitTest( scene, rotationEvent.centerPoint, hitTestResults ) )
+ if(HitTest(scene, rotationEvent.centerPoint, hitTestResults))
{
// Record the current render-task for Screen->Actor coordinate conversions
mCurrentRenderTask = hitTestResults.renderTask;
// Set mCurrentRotationEvent to use inside overridden methods called from ProcessAndEmit()
mCurrentRotationEvent = &rotationEvent;
- ProcessAndEmit( hitTestResults );
+ ProcessAndEmit(hitTestResults);
mCurrentRotationEvent = nullptr;
}
break;
// Check if actor is still touchable.
Actor* currentGesturedActor = GetCurrentGesturedActor();
- if ( currentGesturedActor )
+ if(currentGesturedActor)
{
- if ( currentGesturedActor->IsHittable() && !mCurrentRotationEmitters.empty() && mCurrentRenderTask )
+ if(currentGesturedActor->IsHittable() && !mCurrentRotationEmitters.empty() && mCurrentRenderTask)
{
// Ensure actor is still attached to the emitters, if it is not then remove the emitter.
- GestureDetectorContainer::iterator endIter = std::remove_if( mCurrentRotationEmitters.begin(), mCurrentRotationEmitters.end(), IsNotAttachedFunctor(currentGesturedActor) );
- mCurrentRotationEmitters.erase( endIter, mCurrentRotationEmitters.end() );
+ GestureDetectorContainer::iterator endIter = std::remove_if(mCurrentRotationEmitters.begin(), mCurrentRotationEmitters.end(), IsNotAttachedFunctor(currentGesturedActor));
+ mCurrentRotationEmitters.erase(endIter, mCurrentRotationEmitters.end());
- if ( !mCurrentRotationEmitters.empty() )
+ if(!mCurrentRotationEmitters.empty())
{
- Vector2 actorCoords;
- RenderTask& renderTaskImpl( *mCurrentRenderTask.Get() );
- currentGesturedActor->ScreenToLocal( renderTaskImpl, actorCoords.x, actorCoords.y, rotationEvent.centerPoint.x, rotationEvent.centerPoint.y );
+ Vector2 actorCoords;
+ RenderTask& renderTaskImpl(*mCurrentRenderTask.Get());
+ currentGesturedActor->ScreenToLocal(renderTaskImpl, actorCoords.x, actorCoords.y, rotationEvent.centerPoint.x, rotationEvent.centerPoint.y);
- EmitRotationSignal( currentGesturedActor, mCurrentRotationEmitters, rotationEvent, actorCoords );
+ EmitRotationSignal(currentGesturedActor, mCurrentRotationEmitters, rotationEvent, actorCoords);
}
else
{
}
// Clear current emitters if rotation gesture has ended or been cancelled.
- if ( rotationEvent.state == GestureState::FINISHED || rotationEvent.state == GestureState::CANCELLED )
+ if(rotationEvent.state == GestureState::FINISHED || rotationEvent.state == GestureState::CANCELLED)
{
mCurrentRotationEmitters.clear();
ResetActor();
}
}
-void RotationGestureProcessor::AddGestureDetector( RotationGestureDetector* gestureDetector, Scene& /* scene */ )
+void RotationGestureProcessor::AddGestureDetector(RotationGestureDetector* gestureDetector, Scene& /* scene */)
{
bool createRecognizer(mRotationGestureDetectors.empty());
mRotationGestureDetectors.push_back(gestureDetector);
- if (createRecognizer)
+ if(createRecognizer)
{
- mGestureRecognizer = new RotationGestureRecognizer( *this, mMinimumTouchEvents, mMinimumTouchEventsAfterStart );
+ mGestureRecognizer = new RotationGestureRecognizer(*this, mMinimumTouchEvents, mMinimumTouchEventsAfterStart);
}
}
-void RotationGestureProcessor::RemoveGestureDetector( RotationGestureDetector* gestureDetector )
+void RotationGestureProcessor::RemoveGestureDetector(RotationGestureDetector* gestureDetector)
{
- if ( !mCurrentRotationEmitters.empty() )
+ if(!mCurrentRotationEmitters.empty())
{
// Check if the removed detector was one that is currently being rotated and remove it from emitters.
- GestureDetectorContainer::iterator endIter = std::remove( mCurrentRotationEmitters.begin(), mCurrentRotationEmitters.end(), gestureDetector );
- mCurrentRotationEmitters.erase( endIter, mCurrentRotationEmitters.end() );
+ GestureDetectorContainer::iterator endIter = std::remove(mCurrentRotationEmitters.begin(), mCurrentRotationEmitters.end(), gestureDetector);
+ mCurrentRotationEmitters.erase(endIter, mCurrentRotationEmitters.end());
// If we no longer have any emitters, then we should clear mCurrentGesturedActor as well
- if ( mCurrentRotationEmitters.empty() )
+ if(mCurrentRotationEmitters.empty())
{
ResetActor();
}
}
// Find the detector...
- RotationGestureDetectorContainer::iterator endIter = std::remove( mRotationGestureDetectors.begin(), mRotationGestureDetectors.end(), gestureDetector );
- DALI_ASSERT_DEBUG( endIter != mRotationGestureDetectors.end() );
+ RotationGestureDetectorContainer::iterator endIter = std::remove(mRotationGestureDetectors.begin(), mRotationGestureDetectors.end(), gestureDetector);
+ DALI_ASSERT_DEBUG(endIter != mRotationGestureDetectors.end());
// ...and remove it
mRotationGestureDetectors.erase(endIter, mRotationGestureDetectors.end());
- if (mRotationGestureDetectors.empty())
+ if(mRotationGestureDetectors.empty())
{
mGestureRecognizer = nullptr;
}
}
-void RotationGestureProcessor::SetMinimumTouchEvents( uint32_t value )
+void RotationGestureProcessor::SetMinimumTouchEvents(uint32_t value)
{
- if( value > 1u && mMinimumTouchEvents != value )
+ if(value > 1u && mMinimumTouchEvents != value)
{
mMinimumTouchEvents = value;
- if( mGestureRecognizer )
+ if(mGestureRecognizer)
{
- RotationGestureRecognizer* rotationRecognizer = dynamic_cast<RotationGestureRecognizer*>( mGestureRecognizer.Get() );
- if( rotationRecognizer )
+ RotationGestureRecognizer* rotationRecognizer = dynamic_cast<RotationGestureRecognizer*>(mGestureRecognizer.Get());
+ if(rotationRecognizer)
{
- rotationRecognizer->SetMinimumTouchEvents( value );
+ rotationRecognizer->SetMinimumTouchEvents(value);
}
}
}
}
-void RotationGestureProcessor::SetMinimumTouchEventsAfterStart( uint32_t value )
+void RotationGestureProcessor::SetMinimumTouchEventsAfterStart(uint32_t value)
{
- if( value > 1u && mMinimumTouchEventsAfterStart != value )
+ if(value > 1u && mMinimumTouchEventsAfterStart != value)
{
mMinimumTouchEventsAfterStart = value;
- if( mGestureRecognizer )
+ if(mGestureRecognizer)
{
- RotationGestureRecognizer* rotationRecognizer = dynamic_cast<RotationGestureRecognizer*>( mGestureRecognizer.Get() );
- if( rotationRecognizer )
+ RotationGestureRecognizer* rotationRecognizer = dynamic_cast<RotationGestureRecognizer*>(mGestureRecognizer.Get());
+ if(rotationRecognizer)
{
- rotationRecognizer->SetMinimumTouchEventsAfterStart( value );
+ rotationRecognizer->SetMinimumTouchEventsAfterStart(value);
}
}
}
mCurrentRotationEmitters.clear();
}
-bool RotationGestureProcessor::CheckGestureDetector( GestureDetector* detector, Actor* actor )
+bool RotationGestureProcessor::CheckGestureDetector(GestureDetector* detector, Actor* actor)
{
// No special case required for rotation.
return true;
}
-void RotationGestureProcessor::EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
+void RotationGestureProcessor::EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates)
{
- DALI_ASSERT_DEBUG( mCurrentRotationEvent );
+ DALI_ASSERT_DEBUG(mCurrentRotationEvent);
- EmitRotationSignal( actor, gestureDetectors, *mCurrentRotationEvent, actorCoordinates );
+ EmitRotationSignal(actor, gestureDetectors, *mCurrentRotationEvent, actorCoordinates);
- if ( actor->OnScene() )
+ if(actor->OnScene())
{
mCurrentRotationEmitters = gestureDetectors;
- SetActor( actor );
+ SetActor(actor);
}
}
#define DALI_INTERNAL_ROTATION_GESTURE_EVENT_PROCESSOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/rotation-gesture/rotation-gesture-detector-impl.h>
#include <dali/internal/event/events/gesture-processor.h>
+#include <dali/internal/event/events/rotation-gesture/rotation-gesture-detector-impl.h>
#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class Scene;
class Stage;
class RotationGestureProcessor : public GestureProcessor, public RecognizerObserver<RotationGestureEvent>
{
public:
-
/**
* Create a rotation gesture processor.
*/
*/
~RotationGestureProcessor() override = default;
- RotationGestureProcessor( const RotationGestureProcessor& ) = delete; ///< Deleted copy constructor.
- RotationGestureProcessor& operator=( const RotationGestureProcessor& rhs ) = delete; ///< Deleted copy assignment operator.
+ RotationGestureProcessor(const RotationGestureProcessor&) = delete; ///< Deleted copy constructor.
+ RotationGestureProcessor& operator=(const RotationGestureProcessor& rhs) = delete; ///< Deleted copy assignment operator.
public: // To be called by GestureEventProcessor
-
/**
* This method is called whenever a rotation gesture event occurs.
* @param[in] scene The scene the rotation gesture event occurs in.
* @param[in] rotationEvent The event that has occurred.
*/
- void Process( Scene& scene, const RotationGestureEvent& rotationEvent ) override;
+ void Process(Scene& scene, const RotationGestureEvent& rotationEvent) override;
/**
* Adds a gesture detector to this gesture processor.
* @param[in] gestureDetector The gesture detector being added
* @param[in] scene The scene the rotation gesture occurred in
*/
- void AddGestureDetector( RotationGestureDetector* gestureDetector, Scene& scene );
+ void AddGestureDetector(RotationGestureDetector* gestureDetector, Scene& scene);
/**
* Removes the specified gesture detector from this gesture processor. If, after removing this
* the gesture from the adaptor.
* @param[in] gestureDetector The gesture detector being removed.
*/
- void RemoveGestureDetector( RotationGestureDetector* gestureDetector );
+ void RemoveGestureDetector(RotationGestureDetector* gestureDetector);
/**
* Sets the minimum touch events required before a rotation can be started
* @param[in] value The number of touch events
*/
- void SetMinimumTouchEvents( uint32_t value );
+ void SetMinimumTouchEvents(uint32_t value);
/**
* Sets the minimum touch events required after a rotation started
* @param[in] value The number of touch events
*/
- void SetMinimumTouchEventsAfterStart( uint32_t value );
+ void SetMinimumTouchEventsAfterStart(uint32_t value);
private:
-
// GestureProcessor overrides
/**
/**
* @copydoc GestureProcessor::CheckGestureDetector()
*/
- bool CheckGestureDetector( GestureDetector* detector, Actor* actor ) override;
+ bool CheckGestureDetector(GestureDetector* detector, Actor* actor) override;
/**
* @copydoc GestureProcessor::EmitGestureSignal()
*/
- void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates ) override;
+ void EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates) override;
private:
-
RotationGestureDetectorContainer mRotationGestureDetectors;
- GestureDetectorContainer mCurrentRotationEmitters;
- RenderTaskPtr mCurrentRenderTask;
+ GestureDetectorContainer mCurrentRotationEmitters;
+ RenderTaskPtr mCurrentRenderTask;
const RotationGestureEvent* mCurrentRotationEvent; ///< Pointer to current RotationEvent, used when calling ProcessAndEmit()
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/devel-api/events/touch-point.h>
-#include <dali/public-api/math/vector2.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/internal/event/events/rotation-gesture/rotation-gesture-event.h>
#include <dali/internal/event/common/scene-impl.h>
+#include <dali/internal/event/events/rotation-gesture/rotation-gesture-event.h>
+#include <dali/public-api/math/vector2.h>
// INTERNAL INCLUDES
-
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
-inline float GetAngle( const Integration::Point& point1, const Integration::Point& point2 )
+inline float GetAngle(const Integration::Point& point1, const Integration::Point& point2)
{
const Vector2& point1ScreenPosition = point1.GetScreenPosition();
const Vector2& point2ScreenPosition = point2.GetScreenPosition();
- return atan2( point2ScreenPosition.y - point1ScreenPosition.y, point2ScreenPosition.x - point1ScreenPosition.x );
+ return atan2(point2ScreenPosition.y - point1ScreenPosition.y, point2ScreenPosition.x - point1ScreenPosition.x);
}
-inline Vector2 GetCenterPoint( const Integration::Point& point1, const Integration::Point& point2 )
+inline Vector2 GetCenterPoint(const Integration::Point& point1, const Integration::Point& point2)
{
- return Vector2( point1.GetScreenPosition() + point2.GetScreenPosition() ) * 0.5f;
+ return Vector2(point1.GetScreenPosition() + point2.GetScreenPosition()) * 0.5f;
}
} // unnamed namespace
-RotationGestureRecognizer::RotationGestureRecognizer( Observer& observer, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart )
-: GestureRecognizer( GestureType::ROTATION ),
- mObserver( observer ),
- mState( CLEAR ),
+RotationGestureRecognizer::RotationGestureRecognizer(Observer& observer, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart)
+: GestureRecognizer(GestureType::ROTATION),
+ mObserver(observer),
+ mState(CLEAR),
mTouchEvents(),
- mStartingAngle( 0.0f ),
- mMinimumTouchEvents( minimumTouchEvents ),
- mMinimumTouchEventsAfterStart( minimumTouchEventsAfterStart )
+ mStartingAngle(0.0f),
+ mMinimumTouchEvents(minimumTouchEvents),
+ mMinimumTouchEventsAfterStart(minimumTouchEventsAfterStart)
{
}
-void RotationGestureRecognizer::SendEvent( const Integration::TouchEvent& event )
+void RotationGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
{
- int pointCount = event.GetPointCount();
+ int pointCount = event.GetPointCount();
GestureRecognizerPtr ptr(this); // To keep us from being destroyed during the life-time of this method
- switch( mState )
+ switch(mState)
{
case CLEAR:
{
- if( pointCount == 2 )
+ if(pointCount == 2)
{
// Change state to possible as we have two touch points.
mState = POSSIBLE;
- mTouchEvents.push_back( event );
+ mTouchEvents.push_back(event);
}
break;
}
case POSSIBLE:
{
- if ( pointCount != 2 )
+ if(pointCount != 2)
{
// We no longer have two touch points so change state back to CLEAR.
mState = CLEAR;
const Integration::Point& currentPoint1 = event.points[0];
const Integration::Point& currentPoint2 = event.points[1];
- if( currentPoint1.GetState() == PointState::UP || currentPoint2.GetState() == PointState::UP || currentPoint1.GetState() == PointState::INTERRUPTED )
+ if(currentPoint1.GetState() == PointState::UP || currentPoint2.GetState() == PointState::UP || currentPoint1.GetState() == PointState::INTERRUPTED)
{
// One of our touch points has an Up event so change our state back to CLEAR.
mState = CLEAR;
}
else
{
- mTouchEvents.push_back( event );
+ mTouchEvents.push_back(event);
// We can only determine a rotation after a certain number of touch points have been collected.
- if( mTouchEvents.size() >= mMinimumTouchEvents )
+ if(mTouchEvents.size() >= mMinimumTouchEvents)
{
// Remove the first few events from the vector otherwise values are exaggerated
- mTouchEvents.erase( mTouchEvents.begin(), mTouchEvents.end() - mMinimumTouchEvents );
+ mTouchEvents.erase(mTouchEvents.begin(), mTouchEvents.end() - mMinimumTouchEvents);
- if( !mTouchEvents.empty() )
+ if(!mTouchEvents.empty())
{
- mStartingAngle = GetAngle( mTouchEvents.begin()->points[0], mTouchEvents.begin()->points[1] );
+ mStartingAngle = GetAngle(mTouchEvents.begin()->points[0], mTouchEvents.begin()->points[1]);
// Send rotation started
- SendRotation( GestureState::STARTED, event );
+ SendRotation(GestureState::STARTED, event);
mState = STARTED;
}
mTouchEvents.clear();
- if( mState == POSSIBLE )
+ if(mState == POSSIBLE)
{
// No rotation, so restart detection
mState = CLEAR;
mState = CLEAR;
mTouchEvents.clear();
}
- else if( pointCount != 2 )
+ else if(pointCount != 2)
{
// Send rotation finished event
- SendRotation( GestureState::FINISHED, event );
+ SendRotation(GestureState::FINISHED, event);
mState = CLEAR;
mTouchEvents.clear();
const Integration::Point& currentPoint1 = event.points[0];
const Integration::Point& currentPoint2 = event.points[1];
- if( ( currentPoint1.GetState() == PointState::UP ) ||
- ( currentPoint2.GetState() == PointState::UP ) )
+ if((currentPoint1.GetState() == PointState::UP) ||
+ (currentPoint2.GetState() == PointState::UP))
{
- mTouchEvents.push_back( event );
+ mTouchEvents.push_back(event);
// Send rotation finished event
- SendRotation( GestureState::FINISHED, event );
+ SendRotation(GestureState::FINISHED, event);
mState = CLEAR;
mTouchEvents.clear();
}
else
{
- mTouchEvents.push_back( event );
+ mTouchEvents.push_back(event);
- if( mTouchEvents.size() >= mMinimumTouchEventsAfterStart )
+ if(mTouchEvents.size() >= mMinimumTouchEventsAfterStart)
{
// Send rotation continuing
- SendRotation( GestureState::CONTINUING, event );
+ SendRotation(GestureState::CONTINUING, event);
mTouchEvents.clear();
}
}
}
-void RotationGestureRecognizer::SetMinimumTouchEvents( uint32_t value )
+void RotationGestureRecognizer::SetMinimumTouchEvents(uint32_t value)
{
mMinimumTouchEvents = value;
}
-void RotationGestureRecognizer::SetMinimumTouchEventsAfterStart( uint32_t value )
+void RotationGestureRecognizer::SetMinimumTouchEventsAfterStart(uint32_t value)
{
mMinimumTouchEventsAfterStart = value;
}
-void RotationGestureRecognizer::SendRotation( GestureState state, const Integration::TouchEvent& currentEvent )
+void RotationGestureRecognizer::SendRotation(GestureState state, const Integration::TouchEvent& currentEvent)
{
- RotationGestureEvent gesture( state );
- if( !mTouchEvents.empty() )
+ RotationGestureEvent gesture(state);
+ if(!mTouchEvents.empty())
{
// Assert if we have been holding TouchEvents that do not have 2 points
- DALI_ASSERT_DEBUG( mTouchEvents[0].GetPointCount() == 2 );
+ DALI_ASSERT_DEBUG(mTouchEvents[0].GetPointCount() == 2);
// We should use the current event in our calculations unless it does not have two points.
// If it does not have two points, then we should use the last point in mTouchEvents.
- Integration::TouchEvent event( currentEvent );
- if( event.GetPointCount() != 2 )
+ Integration::TouchEvent event(currentEvent);
+ if(event.GetPointCount() != 2)
{
event = *mTouchEvents.rbegin();
}
- const Integration::Point& currentPoint1( event.points[0] );
- const Integration::Point& currentPoint2( event.points[1] );
+ const Integration::Point& currentPoint1(event.points[0]);
+ const Integration::Point& currentPoint2(event.points[1]);
- gesture.rotation = GetAngle( currentPoint1, currentPoint2 ) - mStartingAngle;
- gesture.centerPoint = GetCenterPoint( currentPoint1, currentPoint2 );
+ gesture.rotation = GetAngle(currentPoint1, currentPoint2) - mStartingAngle;
+ gesture.centerPoint = GetCenterPoint(currentPoint1, currentPoint2);
}
else
{
gesture.time = currentEvent.time;
- if( mScene )
+ if(mScene)
{
// Create another handle so the recognizer cannot be destroyed during process function
GestureRecognizerPtr recognizerHandle = this;
- mObserver.Process( *mScene, gesture );
+ mObserver.Process(*mScene, gesture);
}
}
#define DALI_INTERNAL_EVENT_ROTATION_GESTURE_RECOGNIZER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Integration
{
struct TouchEvent;
namespace Internal
{
-
/**
* When given a set of touch events, this detector attempts to determine if a rotation gesture has taken place.
*/
class RotationGestureRecognizer : public GestureRecognizer
{
public:
-
- using Observer = RecognizerObserver< RotationGestureEvent >;
+ using Observer = RecognizerObserver<RotationGestureEvent>;
/**
* Constructor
* @param[in] minimumTouchEvents The number of touch events required
* @param[in] minimumTouchEventsAfterStart The number of touch events required after a gesture started
*/
- RotationGestureRecognizer( Observer& observer, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart );
+ RotationGestureRecognizer(Observer& observer, uint32_t minimumTouchEvents, uint32_t minimumTouchEventsAfterStart);
/**
* Virtual destructor.
~RotationGestureRecognizer() override = default;
public:
-
/**
* @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
*/
- void SendEvent( const Integration::TouchEvent& event ) override;
+ void SendEvent(const Integration::TouchEvent& event) override;
/**
* @copydoc Dali::Internal::GestureDetector::Update(const Integration::GestureRequest&)
*/
- void Update( const GestureRequest& request ) override { /* Nothing to do */ }
+ void Update(const GestureRequest& request) override
+ { /* Nothing to do */
+ }
/**
* Sets the minimum touch events required before a rotation can be started
* @param[in] value The number of touch events
*/
- void SetMinimumTouchEvents( uint32_t value );
+ void SetMinimumTouchEvents(uint32_t value);
/**
* Sets the minimum touch events required after a rotation started
* @param[in] value The number of touch events
*/
- void SetMinimumTouchEventsAfterStart( uint32_t value );
+ void SetMinimumTouchEventsAfterStart(uint32_t value);
private:
-
/**
* Emits the rotation gesture event to the core.
* @param[in] state The state of the rotation (whether it's starting, continuing or finished).
* @param[in] currentEvent The latest touch event.
*/
- void SendRotation( GestureState state, const Integration::TouchEvent& currentEvent );
+ void SendRotation(GestureState state, const Integration::TouchEvent& currentEvent);
private:
-
// Reference to the gesture processor for this recognizer
Observer& mObserver;
STARTED, ///< A gesture has been detected.
};
- State mState; ///< The current state of the detector.
- std::vector< Integration::TouchEvent > mTouchEvents; ///< The touch events since initial touch down.
+ State mState; ///< The current state of the detector.
+ std::vector<Integration::TouchEvent> mTouchEvents; ///< The touch events since initial touch down.
float mStartingAngle; ///< The angle between the two touch points when the rotation is first detected.
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstring> // for strcmp
// INTERNAL INCLUDES
-#include <dali/public-api/events/tap-gesture.h>
-#include <dali/public-api/object/type-registry.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/event/events/gesture-event-processor.h>
+#include <dali/public-api/events/tap-gesture.h>
+#include <dali/public-api/object/type-registry.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
-const unsigned int DEFAULT_TAPS_REQUIRED = 1u;
+const unsigned int DEFAULT_TAPS_REQUIRED = 1u;
const unsigned int DEFAULT_TOUCHES_REQUIRED = 1u;
// Signals
return Dali::TapGestureDetector::New();
}
-TypeRegistration mType( typeid(Dali::TapGestureDetector), typeid(Dali::GestureDetector), Create );
+TypeRegistration mType(typeid(Dali::TapGestureDetector), typeid(Dali::GestureDetector), Create);
-SignalConnectorType signalConnector1( mType, SIGNAL_TAP_DETECTED, &TapGestureDetector::DoConnectSignal );
+SignalConnectorType signalConnector1(mType, SIGNAL_TAP_DETECTED, &TapGestureDetector::DoConnectSignal);
-}
+} // namespace
TapGestureDetectorPtr TapGestureDetector::New()
{
return new TapGestureDetector;
}
-TapGestureDetectorPtr TapGestureDetector::New( unsigned int tapsRequired )
+TapGestureDetectorPtr TapGestureDetector::New(unsigned int tapsRequired)
{
- return new TapGestureDetector( tapsRequired );
+ return new TapGestureDetector(tapsRequired);
}
TapGestureDetector::TapGestureDetector()
-: GestureDetector( GestureType::TAP ),
- mMinimumTapsRequired( DEFAULT_TAPS_REQUIRED ),
- mMaximumTapsRequired( DEFAULT_TAPS_REQUIRED ),
- mTouchesRequired( DEFAULT_TOUCHES_REQUIRED )
+: GestureDetector(GestureType::TAP),
+ mMinimumTapsRequired(DEFAULT_TAPS_REQUIRED),
+ mMaximumTapsRequired(DEFAULT_TAPS_REQUIRED),
+ mTouchesRequired(DEFAULT_TOUCHES_REQUIRED)
{
}
-TapGestureDetector::TapGestureDetector( unsigned int tapsRequired )
-: GestureDetector( GestureType::TAP ),
- mMinimumTapsRequired( tapsRequired ),
- mMaximumTapsRequired( tapsRequired ),
- mTouchesRequired( DEFAULT_TOUCHES_REQUIRED )
+TapGestureDetector::TapGestureDetector(unsigned int tapsRequired)
+: GestureDetector(GestureType::TAP),
+ mMinimumTapsRequired(tapsRequired),
+ mMaximumTapsRequired(tapsRequired),
+ mTouchesRequired(DEFAULT_TOUCHES_REQUIRED)
{
}
void TapGestureDetector::SetMinimumTapsRequired(unsigned int taps)
{
- if ( mMinimumTapsRequired != taps )
+ if(mMinimumTapsRequired != taps)
{
mMinimumTapsRequired = taps;
- if ( !mAttachedActors.empty() )
+ if(!mAttachedActors.empty())
{
mGestureEventProcessor.GestureDetectorUpdated(this);
}
void TapGestureDetector::SetMaximumTapsRequired(unsigned int taps)
{
- if ( mMaximumTapsRequired != taps )
+ if(mMaximumTapsRequired != taps)
{
mMaximumTapsRequired = taps;
- if ( !mAttachedActors.empty() )
+ if(!mAttachedActors.empty())
{
mGestureEventProcessor.GestureDetectorUpdated(this);
}
void TapGestureDetector::SetTouchesRequired(unsigned int touches)
{
- if (mTouchesRequired != touches)
+ if(mTouchesRequired != touches)
{
mTouchesRequired = touches;
- if (!mAttachedActors.empty())
+ if(!mAttachedActors.empty())
{
mGestureEventProcessor.GestureDetectorUpdated(this);
}
void TapGestureDetector::EmitTapGestureSignal(Dali::Actor tappedActor, const Dali::TapGesture& tap)
{
// Guard against destruction during signal emission
- Dali::TapGestureDetector handle( this );
+ Dali::TapGestureDetector handle(this);
- mDetectedSignal.Emit( tappedActor, tap );
+ mDetectedSignal.Emit(tappedActor, tap);
}
-bool TapGestureDetector::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool TapGestureDetector::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( true );
- TapGestureDetector* gesture = static_cast< TapGestureDetector* >(object); // TypeRegistry guarantees that this is the correct type.
+ bool connected(true);
+ TapGestureDetector* gesture = static_cast<TapGestureDetector*>(object); // TypeRegistry guarantees that this is the correct type.
- if ( 0 == strcmp( signalName.c_str(), SIGNAL_TAP_DETECTED ) )
+ if(0 == strcmp(signalName.c_str(), SIGNAL_TAP_DETECTED))
{
- gesture->DetectedSignal().Connect( tracker, functor );
+ gesture->DetectedSignal().Connect(tracker, functor);
}
else
{
#define DALI_INTERNAL_TAP_GESTURE_DETECTOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/gesture-detector-impl.h>
#include <dali/public-api/events/tap-gesture-detector.h>
#include <dali/public-api/events/tap-gesture.h>
-#include <dali/internal/event/events/gesture-detector-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class TapGestureDetector;
using TapGestureDetectorPtr = IntrusivePtr<TapGestureDetector>;
class TapGestureDetector : public GestureDetector
{
public: // Creation
-
/**
* Create a new gesture detector.
* @return A smart-pointer to the newly allocated detector.
* @param[in] tapsRequired The number of taps required.
* @return A smart-pointer to the newly allocated detector.
*/
- static TapGestureDetectorPtr New( unsigned int tapsRequired );
+ static TapGestureDetectorPtr New(unsigned int tapsRequired);
/**
* Construct a new GestureDetector.
* Construct a new GestureDetector with the specified parameters.
* @param[in] tapsRequired The number of taps required.
*/
- TapGestureDetector( unsigned int tapsRequired );
+ TapGestureDetector(unsigned int tapsRequired);
public:
-
/**
* @copydoc Dali::TapGestureDetector::SetTouchesRequired(unsigned int)
*/
/**
* @copydoc Dali::TapGestureDetector::SetMinimumTapsRequired()
*/
- void SetMinimumTapsRequired( unsigned int minTaps );
+ void SetMinimumTapsRequired(unsigned int minTaps);
/**
* @copydoc Dali::TapGestureDetector::SetMaximumTapsRequired()
*/
- void SetMaximumTapsRequired( unsigned int maxTaps );
+ void SetMaximumTapsRequired(unsigned int maxTaps);
/**
* @copydoc Dali::TapGestureDetector::GetMinimumTapsRequired()
unsigned int GetTouchesRequired() const;
public:
-
/**
* Called by the TapGestureProcessor when a tap gesture event occurs within the bounds of our
* attached actor.
void EmitTapGestureSignal(Dali::Actor tappedActor, const Dali::TapGesture& tap);
public: // Signals
-
/**
* @copydoc Dali::TapGestureDetector::DetectedSignal()
*/
* @return True if the signal was connected.
* @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
*/
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
protected:
-
/**
* A reference counted object may only be deleted by calling Unreference()
*/
~TapGestureDetector() override;
private:
-
// Undefined
TapGestureDetector(const TapGestureDetector&);
TapGestureDetector& operator=(const TapGestureDetector& rhs);
private: // GestureDetector overrides
-
/**
* @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
*/
void OnActorDestroyed(Object& object) override;
private:
-
Dali::TapGestureDetector::DetectedSignalType mDetectedSignal;
unsigned int mMinimumTapsRequired;
inline Internal::TapGestureDetector& GetImplementation(Dali::TapGestureDetector& detector)
{
- DALI_ASSERT_ALWAYS( detector && "TapGestureDetector handle is empty" );
+ DALI_ASSERT_ALWAYS(detector && "TapGestureDetector handle is empty");
BaseObject& handle = detector.GetBaseObject();
inline const Internal::TapGestureDetector& GetImplementation(const Dali::TapGestureDetector& detector)
{
- DALI_ASSERT_ALWAYS( detector && "TapGestureDetector handle is empty" );
+ DALI_ASSERT_ALWAYS(detector && "TapGestureDetector handle is empty");
const BaseObject& handle = detector.GetBaseObject();
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
-TapGestureEvent::TapGestureEvent( GestureState state )
+TapGestureEvent::TapGestureEvent(GestureState state)
: GestureEvent(GestureType::TAP, state),
numberOfTaps(1),
numberOfTouches(1)
#define DALI_INTERNAL_EVENT_TAP_GESTURE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/math/vector2.h>
#include <dali/internal/event/events/gesture-event.h>
+#include <dali/public-api/math/vector2.h>
namespace Dali
{
-
namespace Internal
{
-
/**
* If the adaptor detects a tap gesture, then it should create an instance of this structure and
* send it to the Core.
* STARTED, of a tap occurs; and
* CANCELLED, when tap does not occur.
*/
- TapGestureEvent( GestureState state );
+ TapGestureEvent(GestureState state);
/**
* Virtual destructor
#define DALI_INTERNAL_TAP_GESTURE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/gesture-impl.h>
+#include <dali/public-api/events/tap-gesture.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/events/tap-gesture.h>
-#include <dali/internal/event/events/gesture-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class TapGesture;
using TapGesturePtr = IntrusivePtr<TapGesture>;
class TapGesture final : public Gesture
{
public:
-
/**
* @brief Default constructor
*/
- TapGesture( GestureState state )
+ TapGesture(GestureState state)
: Gesture(GestureType::TAP, state)
{
}
- TapGesture(const TapGesture&) = delete; ///< Deleted copy constructor
- TapGesture(TapGesture&&) = delete; ///< Deleted move constructor
+ TapGesture(const TapGesture&) = delete; ///< Deleted copy constructor
+ TapGesture(TapGesture&&) = delete; ///< Deleted move constructor
TapGesture& operator=(const TapGesture&) = delete; ///< Deleted copy assignment operator
- TapGesture& operator=(TapGesture&&) = delete; ///< Deleted move assignment operator
+ TapGesture& operator=(TapGesture&&) = delete; ///< Deleted move assignment operator
/**
* @brief The number of taps in this tap gesture.
* @param[in] numberOfTaps The number of taps to set.
*/
- inline void SetNumberOfTaps( uint32_t numberOfTaps )
+ inline void SetNumberOfTaps(uint32_t numberOfTaps)
{
mNumberOfTaps = numberOfTaps;
}
* @brief The number of touch points in this tap gesture, i.e. the number of fingers the user had on the screen to generate the tap gesture.
* @param[in] numberOfTouches The number of touch points in this tap gesture to set.
*/
- inline void SetNumberOfTouches( uint32_t numberOfTouches )
+ inline void SetNumberOfTouches(uint32_t numberOfTouches)
{
mNumberOfTouches = numberOfTouches;
}
* @brief This is the point, in screen coordinates, where the tap occurred.
* @param[in] screenPoint The point in screen coordinates to set.
*/
- inline void SetScreenPoint( const Vector2& screenPoint )
+ inline void SetScreenPoint(const Vector2& screenPoint)
{
mScreenPoint = screenPoint;
}
* @brief This is the point, in local actor coordinates, where the tap occurred.
* @param[in] localPoint The point in local actor coordinates to set.
*/
- inline void SetLocalPoint( const Vector2& localPoint )
+ inline void SetLocalPoint(const Vector2& localPoint)
{
mLocalPoint = localPoint;
}
}
private:
-
/**
* @brief Virtual destructor
*
~TapGesture() override = default;
private:
- Vector2 mScreenPoint;
- Vector2 mLocalPoint;
+ Vector2 mScreenPoint;
+ Vector2 mLocalPoint;
uint32_t mNumberOfTaps{1u};
uint32_t mNumberOfTouches{1u};
};
// Helpers for public-api forwarding methods
-inline Internal::TapGesture& GetImplementation( Dali::TapGesture& tapGesture )
+inline Internal::TapGesture& GetImplementation(Dali::TapGesture& tapGesture)
{
- DALI_ASSERT_ALWAYS( tapGesture && "TapGesture handle is empty" );
+ DALI_ASSERT_ALWAYS(tapGesture && "TapGesture handle is empty");
BaseObject& object = tapGesture.GetBaseObject();
- return static_cast< Internal::TapGesture& >( object );
+ return static_cast<Internal::TapGesture&>(object);
}
-inline const Internal::TapGesture& GetImplementation( const Dali::TapGesture& tapGesture )
+inline const Internal::TapGesture& GetImplementation(const Dali::TapGesture& tapGesture)
{
- DALI_ASSERT_ALWAYS( tapGesture && "TapGesture handle is empty" );
+ DALI_ASSERT_ALWAYS(tapGesture && "TapGesture handle is empty");
const BaseObject& object = tapGesture.GetBaseObject();
- return static_cast< const Internal::TapGesture& >( object );
+ return static_cast<const Internal::TapGesture&>(object);
}
} // namespace Dali
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <algorithm>
// INTERNAL INCLUDES
-#include <dali/public-api/actors/actor.h>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/events/tap-gesture.h>
-#include <dali/public-api/math/vector2.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/event/actors/actor-impl.h>
-#include <dali/internal/event/render-tasks/render-task-impl.h>
#include <dali/internal/event/common/scene-impl.h>
-#include <dali/internal/event/events/tap-gesture/tap-gesture-recognizer.h>
-#include <dali/internal/event/events/tap-gesture/tap-gesture-impl.h>
#include <dali/internal/event/events/gesture-requests.h>
#include <dali/internal/event/events/tap-gesture/tap-gesture-event.h>
+#include <dali/internal/event/events/tap-gesture/tap-gesture-impl.h>
+#include <dali/internal/event/events/tap-gesture/tap-gesture-recognizer.h>
+#include <dali/internal/event/render-tasks/render-task-impl.h>
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/events/tap-gesture.h>
+#include <dali/public-api/math/vector2.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
/**
* Creates a TapGesture and asks the specified detector to emit its detected signal.
* @param[in] actor The actor on which a tap has occurred.
* @param[in] localPoint Relative to the actor attached to the detector.
*/
void EmitTapSignal(
- Actor* actor,
+ Actor* actor,
const GestureDetectorContainer& gestureDetectors,
- const TapGestureEvent& tapEvent,
- Vector2 localPoint)
+ const TapGestureEvent& tapEvent,
+ Vector2 localPoint)
{
- Internal::TapGesturePtr tap( new Internal::TapGesture(tapEvent.state) );
- tap->SetTime( tapEvent.time );
+ Internal::TapGesturePtr tap(new Internal::TapGesture(tapEvent.state));
+ tap->SetTime(tapEvent.time);
tap->SetNumberOfTaps(tapEvent.numberOfTaps);
tap->SetNumberOfTouches(tapEvent.numberOfTouches);
tap->SetScreenPoint(tapEvent.point);
tap->SetLocalPoint(localPoint);
- Dali::Actor actorHandle( actor );
+ Dali::Actor actorHandle(actor);
const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end();
- for ( GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter )
+ for(GestureDetectorContainer::const_iterator iter = gestureDetectors.begin(); iter != endIter; ++iter)
{
- static_cast< TapGestureDetector* >( *iter )->EmitTapGestureSignal( actorHandle, Dali::TapGesture( tap.Get() ) );
+ static_cast<TapGestureDetector*>(*iter)->EmitTapGestureSignal(actorHandle, Dali::TapGesture(tap.Get()));
}
}
} // unnamed namespace
TapGestureProcessor::TapGestureProcessor()
-: GestureProcessor( GestureType::TAP ),
+: GestureProcessor(GestureType::TAP),
mTapGestureDetectors(),
- mMinTapsRequired( 1 ),
- mMaxTapsRequired( 1 ),
- mMinTouchesRequired( 1 ),
- mMaxTouchesRequired( 1 ),
- mCurrentTapEvent( nullptr ),
- mPossibleProcessed( false )
+ mMinTapsRequired(1),
+ mMaxTapsRequired(1),
+ mMinTouchesRequired(1),
+ mMaxTouchesRequired(1),
+ mCurrentTapEvent(nullptr),
+ mPossibleProcessed(false)
{
}
TapGestureProcessor::~TapGestureProcessor() = default;
-void TapGestureProcessor::Process( Scene& scene, const TapGestureEvent& tapEvent )
+void TapGestureProcessor::Process(Scene& scene, const TapGestureEvent& tapEvent)
{
- switch ( tapEvent.state )
+ switch(tapEvent.state)
{
case GestureState::POSSIBLE:
{
// Do a hit test and if an actor has been hit then save to see if tap event is still valid on a tap( same actor being hit )
HitTestAlgorithm::Results hitTestResults;
- if ( HitTest( scene, tapEvent.point, hitTestResults ) )
+ if(HitTest(scene, tapEvent.point, hitTestResults))
{
- SetActor( &GetImplementation( hitTestResults.actor ) );
- mCurrentTapActor.SetActor( GetCurrentGesturedActor() );
+ SetActor(&GetImplementation(hitTestResults.actor));
+ mCurrentTapActor.SetActor(GetCurrentGesturedActor());
// Indicate that we've processed a touch down. Bool should be sufficient as a change in actor will result in a cancellation
mPossibleProcessed = true;
{
// Ensure that we're processing a hit on the current actor and that we've already processed a touch down
HitTestAlgorithm::Results hitTestResults;
- if ( GetCurrentGesturedActor() && HitTest( scene, tapEvent.point, hitTestResults ) && mPossibleProcessed )
+ if(GetCurrentGesturedActor() && HitTest(scene, tapEvent.point, hitTestResults) && mPossibleProcessed)
{
// Check that this actor is still the one that was used for the last touch down ?
- if ( mCurrentTapActor.GetActor() == &GetImplementation( hitTestResults.actor ) )
+ if(mCurrentTapActor.GetActor() == &GetImplementation(hitTestResults.actor))
{
mCurrentTapEvent = &tapEvent;
- ProcessAndEmit( hitTestResults );
+ ProcessAndEmit(hitTestResults);
}
- mCurrentTapEvent = nullptr;
+ mCurrentTapEvent = nullptr;
mPossibleProcessed = false;
}
break;
case GestureState::CONTINUING:
{
- DALI_ABORT( "Incorrect state received from Integration layer: CONTINUING\n" );
+ DALI_ABORT("Incorrect state received from Integration layer: CONTINUING\n");
break;
}
case GestureState::FINISHED:
{
- DALI_ABORT( "Incorrect state received from Integration layer: FINISHED\n" );
+ DALI_ABORT("Incorrect state received from Integration layer: FINISHED\n");
break;
}
case GestureState::CLEAR:
{
- DALI_ABORT( "Incorrect state received from Integration layer: CLEAR\n" );
+ DALI_ABORT("Incorrect state received from Integration layer: CLEAR\n");
break;
}
}
}
-void TapGestureProcessor::AddGestureDetector( TapGestureDetector* gestureDetector, Scene& scene )
+void TapGestureProcessor::AddGestureDetector(TapGestureDetector* gestureDetector, Scene& scene)
{
bool firstRegistration(mTapGestureDetectors.empty());
const unsigned int maxTapsRequired = gestureDetector->GetMaximumTapsRequired();
const unsigned int touchesRequired = gestureDetector->GetTouchesRequired();
- DALI_ASSERT_ALWAYS( minTapsRequired <= maxTapsRequired && "Minimum taps requested is greater than the maximum requested" );
+ DALI_ASSERT_ALWAYS(minTapsRequired <= maxTapsRequired && "Minimum taps requested is greater than the maximum requested");
- if (firstRegistration)
+ if(firstRegistration)
{
// If this is the first tap gesture detector that has been added, then our minimum and maximum
// requirements are the same as each other.
- mMinTapsRequired = minTapsRequired;
- mMaxTapsRequired = maxTapsRequired;
+ mMinTapsRequired = minTapsRequired;
+ mMaxTapsRequired = maxTapsRequired;
mMinTouchesRequired = mMaxTouchesRequired = touchesRequired;
TapGestureRequest request;
- request.minTaps = mMinTapsRequired;
- request.maxTaps = mMaxTapsRequired;
+ request.minTaps = mMinTapsRequired;
+ request.maxTaps = mMaxTapsRequired;
request.minTouches = mMinTouchesRequired;
request.maxTouches = mMaxTouchesRequired;
- Size size = scene.GetSize();
+ Size size = scene.GetSize();
mGestureRecognizer = new TapGestureRecognizer(*this, Vector2(size.width, size.height), static_cast<const TapGestureRequest&>(request));
}
else
// This is quicker than calling UpdateDetection as there is no need to iterate through the container
- unsigned int minTaps = mMinTapsRequired < minTapsRequired ? mMinTapsRequired : minTapsRequired;
- unsigned int maxTaps = mMaxTapsRequired > maxTapsRequired ? mMaxTapsRequired : maxTapsRequired;
+ unsigned int minTaps = mMinTapsRequired < minTapsRequired ? mMinTapsRequired : minTapsRequired;
+ unsigned int maxTaps = mMaxTapsRequired > maxTapsRequired ? mMaxTapsRequired : maxTapsRequired;
unsigned int minTouches = mMinTouchesRequired < touchesRequired ? mMinTouchesRequired : touchesRequired;
unsigned int maxTouches = mMaxTouchesRequired > touchesRequired ? mMaxTouchesRequired : touchesRequired;
- if ( (minTaps != mMinTapsRequired)||(maxTaps != mMaxTapsRequired) ||
- (minTouches != mMinTouchesRequired)||(maxTouches != mMaxTouchesRequired) )
+ if((minTaps != mMinTapsRequired) || (maxTaps != mMaxTapsRequired) ||
+ (minTouches != mMinTouchesRequired) || (maxTouches != mMaxTouchesRequired))
{
TapGestureRequest request;
request.minTaps = mMinTapsRequired = minTaps;
}
}
-void TapGestureProcessor::RemoveGestureDetector( TapGestureDetector* gestureDetector )
+void TapGestureProcessor::RemoveGestureDetector(TapGestureDetector* gestureDetector)
{
// Find detector ...
- TapGestureDetectorContainer::iterator endIter = std::remove( mTapGestureDetectors.begin(), mTapGestureDetectors.end(), gestureDetector );
- DALI_ASSERT_DEBUG( endIter != mTapGestureDetectors.end() );
+ TapGestureDetectorContainer::iterator endIter = std::remove(mTapGestureDetectors.begin(), mTapGestureDetectors.end(), gestureDetector);
+ DALI_ASSERT_DEBUG(endIter != mTapGestureDetectors.end());
// ... and remove it
- mTapGestureDetectors.erase( endIter, mTapGestureDetectors.end() );
+ mTapGestureDetectors.erase(endIter, mTapGestureDetectors.end());
- if ( mTapGestureDetectors.empty() )
+ if(mTapGestureDetectors.empty())
{
mGestureRecognizer = nullptr;
}
}
-void TapGestureProcessor::GestureDetectorUpdated( TapGestureDetector* gestureDetector )
+void TapGestureProcessor::GestureDetectorUpdated(TapGestureDetector* gestureDetector)
{
DALI_ASSERT_DEBUG(find(mTapGestureDetectors.begin(), mTapGestureDetectors.end(), gestureDetector) != mTapGestureDetectors.end());
const unsigned int minTapsRequired = gestureDetector->GetMinimumTapsRequired();
const unsigned int maxTapsRequired = gestureDetector->GetMaximumTapsRequired();
- DALI_ASSERT_ALWAYS( minTapsRequired <= maxTapsRequired && "Minimum taps requested is greater than the maximum requested" );
+ DALI_ASSERT_ALWAYS(minTapsRequired <= maxTapsRequired && "Minimum taps requested is greater than the maximum requested");
UpdateDetection();
}
{
DALI_ASSERT_DEBUG(!mTapGestureDetectors.empty());
- unsigned int minTaps = UINT_MAX;
- unsigned int maxTaps = 0;
+ unsigned int minTaps = UINT_MAX;
+ unsigned int maxTaps = 0;
unsigned int minTouches = UINT_MAX;
unsigned int maxTouches = 0;
- for ( TapGestureDetectorContainer::iterator iter = mTapGestureDetectors.begin(), endIter = mTapGestureDetectors.end(); iter != endIter; ++iter )
+ for(TapGestureDetectorContainer::iterator iter = mTapGestureDetectors.begin(), endIter = mTapGestureDetectors.end(); iter != endIter; ++iter)
{
TapGestureDetector* detector(*iter);
- if( detector )
+ if(detector)
{
const unsigned int minTapsRequired = detector->GetMinimumTapsRequired();
const unsigned int maxTapsRequired = detector->GetMaximumTapsRequired();
const unsigned int touchesRequired = detector->GetTouchesRequired();
- minTaps = minTapsRequired < minTaps ? minTapsRequired : minTaps;
- maxTaps = maxTapsRequired > maxTaps ? maxTapsRequired : maxTaps;
+ minTaps = minTapsRequired < minTaps ? minTapsRequired : minTaps;
+ maxTaps = maxTapsRequired > maxTaps ? maxTapsRequired : maxTaps;
minTouches = touchesRequired < minTouches ? touchesRequired : minTouches;
maxTouches = touchesRequired > maxTouches ? touchesRequired : maxTouches;
}
}
- if ( (minTaps != mMinTapsRequired)||(maxTaps != mMaxTapsRequired) ||
- (minTouches != mMinTouchesRequired)||(maxTouches != mMaxTouchesRequired) )
+ if((minTaps != mMinTapsRequired) || (maxTaps != mMaxTapsRequired) ||
+ (minTouches != mMinTouchesRequired) || (maxTouches != mMaxTouchesRequired))
{
TapGestureRequest request;
request.minTaps = mMinTapsRequired = minTaps;
}
}
-bool TapGestureProcessor::CheckGestureDetector( GestureDetector* detector, Actor* actor )
+bool TapGestureProcessor::CheckGestureDetector(GestureDetector* detector, Actor* actor)
{
- DALI_ASSERT_DEBUG( mCurrentTapEvent );
+ DALI_ASSERT_DEBUG(mCurrentTapEvent);
- TapGestureDetector* tapDetector ( static_cast< TapGestureDetector* >( detector ) );
+ TapGestureDetector* tapDetector(static_cast<TapGestureDetector*>(detector));
- return ( ( tapDetector->GetMinimumTapsRequired() <= mCurrentTapEvent->numberOfTaps ) && ( tapDetector->GetMaximumTapsRequired() >= mCurrentTapEvent->numberOfTaps ) ) &&
- ( tapDetector->GetTouchesRequired() == mCurrentTapEvent->numberOfTouches );
+ return ((tapDetector->GetMinimumTapsRequired() <= mCurrentTapEvent->numberOfTaps) && (tapDetector->GetMaximumTapsRequired() >= mCurrentTapEvent->numberOfTaps)) &&
+ (tapDetector->GetTouchesRequired() == mCurrentTapEvent->numberOfTouches);
}
-void TapGestureProcessor::EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates )
+void TapGestureProcessor::EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates)
{
- DALI_ASSERT_DEBUG( mCurrentTapEvent );
+ DALI_ASSERT_DEBUG(mCurrentTapEvent);
- EmitTapSignal( actor, gestureDetectors, *mCurrentTapEvent, actorCoordinates );
+ EmitTapSignal(actor, gestureDetectors, *mCurrentTapEvent, actorCoordinates);
}
} // namespace Internal
#define DALI_INTERNAL_TAP_GESTURE_EVENT_PROCESSOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/events/tap-gesture/tap-gesture-detector-impl.h>
-#include <dali/internal/event/events/gesture-processor.h>
#include <dali/internal/event/events/actor-observer.h>
+#include <dali/internal/event/events/gesture-processor.h>
+#include <dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class Scene;
class Stage;
class Actor;
class TapGestureProcessor : public GestureProcessor, public RecognizerObserver<TapGestureEvent>
{
public:
-
/**
* Create a tap gesture processor.
*/
~TapGestureProcessor() override;
public: // To be called by GestureEventProcessor
-
/**
* This method is called whenever a tap gesture event occurs.
* @param[in] scene The scene the tap gesture event occurs in.
* @param[in] tapEvent The event that has occurred.
*/
- void Process( Scene& scene, const TapGestureEvent& event) override;
+ void Process(Scene& scene, const TapGestureEvent& event) override;
/**
* Adds a gesture detector to this gesture processor.
void GestureDetectorUpdated(TapGestureDetector* gestureDetector);
private:
-
// Undefined
TapGestureProcessor(const TapGestureProcessor&);
TapGestureProcessor& operator=(const TapGestureProcessor& rhs);
private:
-
/**
* Iterates through our GestureDetectors and determines if we need to ask the adaptor to update
* its detection policy. If it does, it sends the appropriate gesture update request to adaptor.
/**
* @copydoc GestureProcessor::OnGesturedActorStageDisconnection()
*/
- void OnGesturedActorStageDisconnection() override { /* Nothing to do */ }
+ void OnGesturedActorStageDisconnection() override
+ { /* Nothing to do */
+ }
/**
* @copydoc GestureProcessor::CheckGestureDetector()
*/
- bool CheckGestureDetector( GestureDetector* detector, Actor* actor ) override;
+ bool CheckGestureDetector(GestureDetector* detector, Actor* actor) override;
/**
* @copydoc GestureProcessor::EmitGestureSignal()
*/
- void EmitGestureSignal( Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates ) override;
+ void EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates) override;
private:
-
TapGestureDetectorContainer mTapGestureDetectors;
unsigned int mMinTapsRequired;
unsigned int mMinTouchesRequired;
unsigned int mMaxTouchesRequired;
- ActorObserver mCurrentTapActor; ///< Observer for the current gesture actor
- const TapGestureEvent* mCurrentTapEvent; ///< Pointer to current TapEvent, used when calling ProcessAndEmit()
- bool mPossibleProcessed; ///< Indication of whether we've processed a touch down for this gestuee
+ ActorObserver mCurrentTapActor; ///< Observer for the current gesture actor
+ const TapGestureEvent* mCurrentTapEvent; ///< Pointer to current TapEvent, used when calling ProcessAndEmit()
+ bool mPossibleProcessed; ///< Indication of whether we've processed a touch down for this gestuee
};
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/integration-api/events/touch-event-integ.h>
// INTERNAL INCLUDES
-#include <dali/internal/event/events/gesture-requests.h>
#include <dali/internal/event/common/scene-impl.h>
+#include <dali/internal/event/events/gesture-requests.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
// TODO: Set these according to DPI
-const float MAXIMUM_MOTION_ALLOWED = 20.0f;
-const unsigned long MAXIMUM_TIME_ALLOWED = 500u;
+const float MAXIMUM_MOTION_ALLOWED = 20.0f;
+const unsigned long MAXIMUM_TIME_ALLOWED = 500u;
} // unnamed namespace
-TapGestureRecognizer::TapGestureRecognizer( Observer& observer, Vector2 screenSize, const TapGestureRequest& request)
-: GestureRecognizer( screenSize, GestureType::TAP ),
+TapGestureRecognizer::TapGestureRecognizer(Observer& observer, Vector2 screenSize, const TapGestureRequest& request)
+: GestureRecognizer(screenSize, GestureType::TAP),
mObserver(observer),
mState(CLEAR),
mMinimumTapsRequired(request.minTaps),
{
GestureRecognizerPtr ptr(this); // To keep us from being destroyed during the life-time of this method
- if (event.GetPointCount() == 1)
+ if(event.GetPointCount() == 1)
{
- const Integration::Point& point = event.points[0];
- PointState::Type pointState = point.GetState();
+ const Integration::Point& point = event.points[0];
+ PointState::Type pointState = point.GetState();
- switch (mState)
+ switch(mState)
{
case CLEAR:
{
- if (pointState == PointState::DOWN)
+ if(pointState == PointState::DOWN)
{
- SetupForTouchDown( event, point );
+ SetupForTouchDown(event, point);
}
break;
}
{
uint32_t deltaBetweenTouchDownTouchUp = event.time - mTouchTime;
- if ( pointState == PointState::UP )
+ if(pointState == PointState::UP)
{
- if ( deltaBetweenTouchDownTouchUp < MAXIMUM_TIME_ALLOWED )
+ if(deltaBetweenTouchDownTouchUp < MAXIMUM_TIME_ALLOWED)
{
mLastTapTime = mTouchTime;
- EmitSingleTap( event.time, point );
+ EmitSingleTap(event.time, point);
mState = REGISTERED;
}
else
mState = CLEAR;
}
}
- else if (pointState == PointState::INTERRUPTED)
+ else if(pointState == PointState::INTERRUPTED)
{
mState = CLEAR;
}
case REGISTERED:
{
- if ( pointState == PointState::UP )
+ if(pointState == PointState::UP)
{
uint32_t deltaBetweenTouchDownTouchUp = event.time - mTouchTime;
- if ( deltaBetweenTouchDownTouchUp < MAXIMUM_TIME_ALLOWED )
+ if(deltaBetweenTouchDownTouchUp < MAXIMUM_TIME_ALLOWED)
{
// This is a possible multiple tap, so has it been quick enough?
uint32_t timeDelta = event.time - mLastTapTime;
- if( timeDelta > MAXIMUM_TIME_ALLOWED ) // If exceeded time between taps then just a single tap
+ if(timeDelta > MAXIMUM_TIME_ALLOWED) // If exceeded time between taps then just a single tap
{
mLastTapTime = event.time;
EmitSingleTap(event.time, point);
else
{
++mTapsRegistered;
- EmitGesture( GestureState::STARTED, event.time );
+ EmitGesture(GestureState::STARTED, event.time);
mState = CLEAR;
}
}
mState = CLEAR;
}
}
- else if (pointState == PointState::DOWN)
+ else if(pointState == PointState::DOWN)
{
- const Vector2& screen( point.GetScreenPosition() );
- Vector2 distanceDelta(std::abs(mTouchPosition.x - screen.x),
+ const Vector2& screen(point.GetScreenPosition());
+ Vector2 distanceDelta(std::abs(mTouchPosition.x - screen.x),
std::abs(mTouchPosition.y - screen.y));
uint32_t timeDelta = event.time - mLastTapTime;
- if (distanceDelta.x > MAXIMUM_MOTION_ALLOWED ||
- distanceDelta.y > MAXIMUM_MOTION_ALLOWED ||
- timeDelta > MAXIMUM_TIME_ALLOWED )
+ if(distanceDelta.x > MAXIMUM_MOTION_ALLOWED ||
+ distanceDelta.y > MAXIMUM_MOTION_ALLOWED ||
+ timeDelta > MAXIMUM_TIME_ALLOWED)
{
- SetupForTouchDown( event, point );
+ SetupForTouchDown(event, point);
}
else
{
- EmitPossibleState( event );
+ EmitPossibleState(event);
}
}
break;
}
}
-void TapGestureRecognizer::SetupForTouchDown( const Integration::TouchEvent& event, const Integration::Point& point )
+void TapGestureRecognizer::SetupForTouchDown(const Integration::TouchEvent& event, const Integration::Point& point)
{
- mTouchPosition = point.GetScreenPosition();
- mTouchTime = event.time;
- mLastTapTime = 0u;
+ mTouchPosition = point.GetScreenPosition();
+ mTouchTime = event.time;
+ mLastTapTime = 0u;
mTapsRegistered = 0;
- mState = TOUCHED;
- EmitPossibleState( event );
+ mState = TOUCHED;
+ EmitPossibleState(event);
}
-void TapGestureRecognizer::EmitPossibleState( const Integration::TouchEvent& event )
+void TapGestureRecognizer::EmitPossibleState(const Integration::TouchEvent& event)
{
- TapGestureEvent tapEvent( GestureState::POSSIBLE );
+ TapGestureEvent tapEvent(GestureState::POSSIBLE);
tapEvent.point = mTouchPosition;
- tapEvent.time = event.time;
+ tapEvent.time = event.time;
- ProcessEvent( tapEvent );
+ ProcessEvent(tapEvent);
}
-
void TapGestureRecognizer::Update(const GestureRequest& request)
{
const TapGestureRequest& tap = static_cast<const TapGestureRequest&>(request);
mMaximumTapsRequired = tap.maxTaps;
}
-void TapGestureRecognizer::EmitGesture( GestureState state, uint32_t time )
+void TapGestureRecognizer::EmitGesture(GestureState state, uint32_t time)
{
- if ( (state == GestureState::CANCELLED) ||
- (mTapsRegistered >= mMinimumTapsRequired && mTapsRegistered <= mMaximumTapsRequired) )
+ if((state == GestureState::CANCELLED) ||
+ (mTapsRegistered >= mMinimumTapsRequired && mTapsRegistered <= mMaximumTapsRequired))
{
- TapGestureEvent event( state );
- EmitTap( time, event );
+ TapGestureEvent event(state);
+ EmitTap(time, event);
}
}
-void TapGestureRecognizer::EmitSingleTap( uint32_t time, const Integration::Point& point )
+void TapGestureRecognizer::EmitSingleTap(uint32_t time, const Integration::Point& point)
{
- TapGestureEvent event( GestureState::STARTED );
- const Vector2& screen( point.GetScreenPosition() );
- Vector2 distanceDelta(std::abs(mTouchPosition.x - screen.x),
+ TapGestureEvent event(GestureState::STARTED);
+ const Vector2& screen(point.GetScreenPosition());
+ Vector2 distanceDelta(std::abs(mTouchPosition.x - screen.x),
std::abs(mTouchPosition.y - screen.y));
- if (distanceDelta.x > MAXIMUM_MOTION_ALLOWED ||
- distanceDelta.y > MAXIMUM_MOTION_ALLOWED )
+ if(distanceDelta.x > MAXIMUM_MOTION_ALLOWED ||
+ distanceDelta.y > MAXIMUM_MOTION_ALLOWED)
{
event.state = GestureState::CANCELLED;
}
mTapsRegistered = 1u;
- EmitTap( time, event );
+ EmitTap(time, event);
}
-void TapGestureRecognizer::EmitTap( uint32_t time, TapGestureEvent& event )
+void TapGestureRecognizer::EmitTap(uint32_t time, TapGestureEvent& event)
{
event.numberOfTaps = mTapsRegistered;
- event.point = mTouchPosition;
- event.time = time;
+ event.point = mTouchPosition;
+ event.time = time;
- ProcessEvent( event );
+ ProcessEvent(event);
}
-void TapGestureRecognizer::ProcessEvent( TapGestureEvent& event )
+void TapGestureRecognizer::ProcessEvent(TapGestureEvent& event)
{
- if( mScene )
+ if(mScene)
{
// Create another handle so the recognizer cannot be destroyed during process function
GestureRecognizerPtr recognizerHandle = this;
#define DALI_INTERNAL_EVENT_EVENTS_TAP_GESTURE_RECOGNIZER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
// EXTERNAL INCLUDES
-#include <cstdint>
-#include <dali/public-api/common/vector-wrapper.h>
#include <dali/integration-api/events/point.h>
-
+#include <dali/public-api/common/vector-wrapper.h>
+#include <cstdint>
// INTERNAL INCLUDES
#include <dali/internal/event/events/gesture-recognizer.h>
namespace Dali
{
-
namespace Integration
{
struct TouchEvent;
class TapGestureRecognizer : public GestureRecognizer
{
public:
-
using Observer = RecognizerObserver<TapGestureEvent>;
/**
~TapGestureRecognizer() override;
public:
-
/**
* @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&)
*/
void Update(const GestureRequest& request) override;
private:
-
/**
* Checks if registered taps are within required bounds and emits tap gesture if they are.
*
* @param[in] state current state of incomplete gesture
* @param[in] time time of this latest touch event
*/
- void EmitGesture( GestureState state, uint32_t time );
+ void EmitGesture(GestureState state, uint32_t time);
/**
* Initialises tap gesture detector for next tap sequence
* @param[in] event registered touch event
* @param[in] point position touch event occurred
*/
- void SetupForTouchDown( const Integration::TouchEvent& event, const Integration::Point& point );
+ void SetupForTouchDown(const Integration::TouchEvent& event, const Integration::Point& point);
/**
* Emit a touch down event for hit testing
*
* @param[in] event registered touch event
*/
- void EmitPossibleState( const Integration::TouchEvent& event );
+ void EmitPossibleState(const Integration::TouchEvent& event);
/**
* Force a touch event sequence to be treated as a single tap
* @param[in] time time of this latest touch event
* @param[in] point position touch event occurred
*/
- void EmitSingleTap( uint32_t time, const Integration::Point& point );
+ void EmitSingleTap(uint32_t time, const Integration::Point& point);
/**
* Emit a tap event
* @param[in] time time of this latest touch event
* @param[in] event registered touch event
*/
- void EmitTap( uint32_t time, TapGestureEvent& event );
+ void EmitTap(uint32_t time, TapGestureEvent& event);
/**
* Send the event for processing
*
* @param[in] tap event for processing
*/
- void ProcessEvent( TapGestureEvent& event );
+ void ProcessEvent(TapGestureEvent& event);
private:
-
// Reference to the gesture processor for this recognizer
Observer& mObserver;
int mMaximumTapsRequired; ///< Maximum number of taps required.
int mTapsRegistered; ///< In current detection, the number of taps registered.
- Vector2 mTouchPosition; ///< The initial touch down position.
- uint32_t mTouchTime; ///< The initial touch down time.
- uint32_t mLastTapTime; ///< Time last tap gesture was registered
-
+ Vector2 mTouchPosition; ///< The initial touch down position.
+ uint32_t mTouchTime; ///< The initial touch down time.
+ uint32_t mLastTapTime; ///< Time last tap gesture was registered
};
} // namespace Internal
} // namespace Dali
-
#endif // DALI_INTERNAL_EVENT_EVENTS_TAP_GESTURE_RECOGNIZER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
-TouchEventPtr TouchEvent::Clone( const TouchEvent& other )
+TouchEventPtr TouchEvent::Clone(const TouchEvent& other)
{
- TouchEventPtr touchEvent( new TouchEvent );
+ TouchEventPtr touchEvent(new TouchEvent);
touchEvent->mPoints = other.mPoints;
- touchEvent->mTime = other.mTime;
+ touchEvent->mTime = other.mTime;
return touchEvent;
}
-int32_t TouchEvent::GetDeviceId( std::size_t point ) const
+int32_t TouchEvent::GetDeviceId(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetDeviceId();
+ return mPoints[point].GetDeviceId();
}
return -1;
}
-PointState::Type TouchEvent::GetState( std::size_t point ) const
+PointState::Type TouchEvent::GetState(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetState();
+ return mPoints[point].GetState();
}
return PointState::FINISHED;
}
-Dali::Actor TouchEvent::GetHitActor( std::size_t point ) const
+Dali::Actor TouchEvent::GetHitActor(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetHitActor();
+ return mPoints[point].GetHitActor();
}
return Dali::Actor();
}
-const Vector2& TouchEvent::GetLocalPosition( std::size_t point ) const
+const Vector2& TouchEvent::GetLocalPosition(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetLocalPosition();
+ return mPoints[point].GetLocalPosition();
}
return Vector2::ZERO;
}
-const Vector2& TouchEvent::GetScreenPosition( std::size_t point ) const
+const Vector2& TouchEvent::GetScreenPosition(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetScreenPosition();
+ return mPoints[point].GetScreenPosition();
}
return Vector2::ZERO;
}
-float TouchEvent::GetRadius( std::size_t point ) const
+float TouchEvent::GetRadius(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetRadius();
+ return mPoints[point].GetRadius();
}
return 0.0f;
}
-const Vector2& TouchEvent::GetEllipseRadius( std::size_t point ) const
+const Vector2& TouchEvent::GetEllipseRadius(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetEllipseRadius();
+ return mPoints[point].GetEllipseRadius();
}
return Vector2::ZERO;
}
-float TouchEvent::GetPressure( std::size_t point ) const
+float TouchEvent::GetPressure(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetPressure();
+ return mPoints[point].GetPressure();
}
return 1.0f;
}
-Degree TouchEvent::GetAngle( std::size_t point ) const
+Degree TouchEvent::GetAngle(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetAngle();
+ return mPoints[point].GetAngle();
}
return Degree();
}
-const Integration::Point& TouchEvent::GetPoint( std::size_t point ) const
+const Integration::Point& TouchEvent::GetPoint(std::size_t point) const
{
- DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" );
- return mPoints[ point ];
+ DALI_ASSERT_DEBUG(point < mPoints.size() && "No point at index");
+ return mPoints[point];
}
-Integration::Point& TouchEvent::GetPoint( std::size_t point )
+Integration::Point& TouchEvent::GetPoint(std::size_t point)
{
- DALI_ASSERT_DEBUG( point < mPoints.size() && "No point at index" );
- return mPoints[ point ];
+ DALI_ASSERT_DEBUG(point < mPoints.size() && "No point at index");
+ return mPoints[point];
}
-Device::Class::Type TouchEvent::GetDeviceClass( std::size_t point ) const
+Device::Class::Type TouchEvent::GetDeviceClass(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetDeviceClass();
+ return mPoints[point].GetDeviceClass();
}
return Device::Class::NONE;
}
-Device::Subclass::Type TouchEvent::GetDeviceSubclass( std::size_t point ) const
+Device::Subclass::Type TouchEvent::GetDeviceSubclass(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetDeviceSubclass();
+ return mPoints[point].GetDeviceSubclass();
}
return Device::Subclass::NONE;
}
-MouseButton::Type TouchEvent::GetMouseButton( std::size_t point ) const
+MouseButton::Type TouchEvent::GetMouseButton(std::size_t point) const
{
- if( point < mPoints.size() )
+ if(point < mPoints.size())
{
- return mPoints[ point ].GetMouseButton();
+ return mPoints[point].GetMouseButton();
}
return MouseButton::INVALID;
}
-void TouchEvent::AddPoint( const Integration::Point& point )
+void TouchEvent::AddPoint(const Integration::Point& point)
{
- mPoints.push_back( point );
+ mPoints.push_back(point);
}
-} // namsespace Internal
+} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_TOUCH_EVENT_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/integration-api/events/point.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/events/point-state.h>
#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/integration-api/events/point.h>
namespace Dali
{
-
class Actor;
struct Vector2;
namespace Internal
{
-
class TouchEvent;
using TouchEventPtr = IntrusivePtr<TouchEvent>;
class TouchEvent : public BaseObject
{
public:
-
// Construction & Destruction
/**
* @brief Constructor
* @param[in] time The time the event occurred
*/
- TouchEvent( unsigned long time )
- : mTime( time )
+ TouchEvent(unsigned long time)
+ : mTime(time)
{
}
* @param[in] other The TouchEvent to clone from.
* @return A new TouchEvent object which has the same touch point data.
*/
- static TouchEventPtr Clone( const TouchEvent& other );
+ static TouchEventPtr Clone(const TouchEvent& other);
- TouchEvent( const TouchEvent& other ) = delete; ///< Deleted copy constructor.
- TouchEvent( TouchEvent&& other ) = delete; ///< Deleted move constructor.
- TouchEvent& operator=( const TouchEvent& other ) = delete; ///< Deleted copy assignment operator.
- TouchEvent& operator=( TouchEvent&& other ) = delete; ///< Deleted move assignment operator.
+ TouchEvent(const TouchEvent& other) = delete; ///< Deleted copy constructor.
+ TouchEvent(TouchEvent&& other) = delete; ///< Deleted move constructor.
+ TouchEvent& operator=(const TouchEvent& other) = delete; ///< Deleted copy assignment operator.
+ TouchEvent& operator=(TouchEvent&& other) = delete; ///< Deleted move assignment operator.
// Getters
/**
* @copydoc Dali::TouchEvent::GetDeviceId()
*/
- int32_t GetDeviceId( std::size_t point ) const;
+ int32_t GetDeviceId(std::size_t point) const;
/**
* @copydoc Dali::TouchEvent::GetGetState()
*/
- PointState::Type GetState( std::size_t point ) const;
+ PointState::Type GetState(std::size_t point) const;
/**
* @copydoc Dali::TouchEvent::GetHitActor()
*/
- Dali::Actor GetHitActor( std::size_t point ) const;
+ Dali::Actor GetHitActor(std::size_t point) const;
/**
* @copydoc Dali::TouchEvent::GetLocalPosition()
*/
- const Vector2& GetLocalPosition( std::size_t point ) const;
+ const Vector2& GetLocalPosition(std::size_t point) const;
/**
* @copydoc Dali::TouchEvent::GetScreenPosition()
*/
- const Vector2& GetScreenPosition( std::size_t point ) const;
+ const Vector2& GetScreenPosition(std::size_t point) const;
/**
* @copydoc Dali::TouchEvent::GetRadius()
*/
- float GetRadius( std::size_t point ) const;
+ float GetRadius(std::size_t point) const;
/**
* @copydoc Dali::TouchEvent::GetEllipseRadius()
*/
- const Vector2& GetEllipseRadius( std::size_t point ) const;
+ const Vector2& GetEllipseRadius(std::size_t point) const;
/**
* @copydoc Dali::TouchEvent::GetPressure()
*/
- float GetPressure( std::size_t point ) const;
+ float GetPressure(std::size_t point) const;
/**
* @copydoc Dali::TouchEvent::GetAngle()
*/
- Degree GetAngle( std::size_t point ) const;
+ Degree GetAngle(std::size_t point) const;
/**
* @brief Returns a const reference to a point at the index requested.
* @return A const reference to the Point at the position requested
* @note point should be less than the value returned by GetPointCount(). Will assert if out of range.
*/
- const Integration::Point& GetPoint( std::size_t point ) const;
+ const Integration::Point& GetPoint(std::size_t point) const;
/**
* @brief Returns a reference to a point at the index requested.
* @return A reference to the Point at the position requested
* @note point should be less than the value returned by GetPointCount(). Will assert if out of range.
*/
- Integration::Point& GetPoint( std::size_t point );
+ Integration::Point& GetPoint(std::size_t point);
/**
* @brief Get the device class the mouse/touch event originated from
*
* @return The device class
*/
- Device::Class::Type GetDeviceClass( std::size_t point ) const;
+ Device::Class::Type GetDeviceClass(std::size_t point) const;
/**
* @brief Get the device subclass the mouse/touch event originated from
*
* @return The device subclass
*/
- Device::Subclass::Type GetDeviceSubclass( std::size_t point ) const;
+ Device::Subclass::Type GetDeviceSubclass(std::size_t point) const;
/**
* @brief Get mouse's button value (ex: right/left button)
*
* @return The value of mouse button
*/
- MouseButton::Type GetMouseButton( std::size_t point ) const;
+ MouseButton::Type GetMouseButton(std::size_t point) const;
// Setters
* @brief Adds a point to this touch event handler.
* @param[in] point The point to add to the touch event handler.
*/
- void AddPoint( const Integration::Point& point );
+ void AddPoint(const Integration::Point& point);
private:
-
/**
* @brief Virtual Destructor
*
~TouchEvent() override = default;
private:
-
- std::vector< Integration::Point > mPoints; ///< Container of the points for this touch event.
- unsigned long mTime{0u}; ///< The time (in ms) that the touch event occurred.
+ std::vector<Integration::Point> mPoints; ///< Container of the points for this touch event.
+ unsigned long mTime{0u}; ///< The time (in ms) that the touch event occurred.
};
} // namespace Internal
// Helpers for public-api forwarding methods
-inline Internal::TouchEvent& GetImplementation( Dali::TouchEvent& touchEvent )
+inline Internal::TouchEvent& GetImplementation(Dali::TouchEvent& touchEvent)
{
- DALI_ASSERT_ALWAYS( touchEvent && "Touch Event handle is empty" );
+ DALI_ASSERT_ALWAYS(touchEvent && "Touch Event handle is empty");
BaseObject& object = touchEvent.GetBaseObject();
- return static_cast< Internal::TouchEvent& >( object );
+ return static_cast<Internal::TouchEvent&>(object);
}
-inline const Internal::TouchEvent& GetImplementation( const Dali::TouchEvent& touchEvent )
+inline const Internal::TouchEvent& GetImplementation(const Dali::TouchEvent& touchEvent)
{
- DALI_ASSERT_ALWAYS( touchEvent && "Touch Event handle is empty" );
+ DALI_ASSERT_ALWAYS(touchEvent && "Touch Event handle is empty");
const BaseObject& object = touchEvent.GetBaseObject();
- return static_cast< const Internal::TouchEvent& >( object );
+ return static_cast<const Internal::TouchEvent&>(object);
}
} // namespace Dali
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#endif
// INTERNAL INCLUDES
-#include <dali/public-api/events/touch-event.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/signals/callback.h>
#include <dali/integration-api/debug.h>
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/events/multi-point-event-util.h>
#include <dali/internal/event/events/touch-event-impl.h>
#include <dali/internal/event/render-tasks/render-task-impl.h>
+#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/signals/callback.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_TOUCH_PROCESSOR" );
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_TOUCH_PROCESSOR");
-const char * TOUCH_POINT_STATE[ 6 ] =
-{
- "DOWN",
- "UP",
- "MOTION",
- "LEAVE",
- "STATIONARY",
- "INTERRUPTED",
+const char* TOUCH_POINT_STATE[6] =
+ {
+ "DOWN",
+ "UP",
+ "MOTION",
+ "LEAVE",
+ "STATIONARY",
+ "INTERRUPTED",
};
#endif // defined(DEBUG_ENABLED)
-Dali::Actor EmitInterceptTouchSignals( Dali::Actor actor, const Dali::TouchEvent& touchEvent )
+Dali::Actor EmitInterceptTouchSignals(Dali::Actor actor, const Dali::TouchEvent& touchEvent)
{
Dali::Actor interceptedActor;
- if( actor )
+ if(actor)
{
- Dali::Actor parent = actor.GetParent();
- if( parent )
- {
- // Recursively deliver events to the actor and its parents for intercept touch event.
- interceptedActor = EmitInterceptTouchSignals( parent, touchEvent );
- }
-
- if( !interceptedActor )
- {
- bool intercepted = false;
- Actor& actorImpl( GetImplementation(actor) );
- if( actorImpl.GetInterceptTouchRequired() )
- {
- intercepted = actorImpl.EmitInterceptTouchEventSignal( touchEvent );
- if( intercepted )
- {
- interceptedActor = Dali::Actor( &actorImpl );
- }
- }
- }
+ Dali::Actor parent = actor.GetParent();
+ if(parent)
+ {
+ // Recursively deliver events to the actor and its parents for intercept touch event.
+ interceptedActor = EmitInterceptTouchSignals(parent, touchEvent);
+ }
+
+ if(!interceptedActor)
+ {
+ bool intercepted = false;
+ Actor& actorImpl(GetImplementation(actor));
+ if(actorImpl.GetInterceptTouchRequired())
+ {
+ intercepted = actorImpl.EmitInterceptTouchEventSignal(touchEvent);
+ if(intercepted)
+ {
+ interceptedActor = Dali::Actor(&actorImpl);
+ }
+ }
+ }
}
return interceptedActor;
/**
* Recursively deliver events to the actor and its parents, until the event is consumed or the stage is reached.
*/
-Dali::Actor EmitTouchSignals( Dali::Actor actor, const Dali::TouchEvent& touchEvent )
+Dali::Actor EmitTouchSignals(Dali::Actor actor, const Dali::TouchEvent& touchEvent)
{
Dali::Actor consumedActor;
- if ( actor )
+ if(actor)
{
- Dali::Actor oldParent( actor.GetParent() );
+ Dali::Actor oldParent(actor.GetParent());
- Actor& actorImpl( GetImplementation(actor) );
+ Actor& actorImpl(GetImplementation(actor));
- bool consumed( false );
+ bool consumed(false);
// Only emit the signal if the actor's touch signal has connections (or derived actor implementation requires touch).
- if ( actorImpl.GetTouchRequired() )
+ if(actorImpl.GetTouchRequired())
{
- consumed = actorImpl.EmitTouchEventSignal( touchEvent );
+ consumed = actorImpl.EmitTouchEventSignal(touchEvent);
}
- if ( consumed )
+ if(consumed)
{
// One of this actor's listeners has consumed the event so set this actor as the consumed actor.
- consumedActor = Dali::Actor( &actorImpl );
+ consumedActor = Dali::Actor(&actorImpl);
}
else
{
// The actor may have been removed/reparented during the signal callbacks.
Dali::Actor parent = actor.GetParent();
- if ( parent &&
- (parent == oldParent) )
+ if(parent &&
+ (parent == oldParent))
{
// One of the actor's parents may consumed the event and they should be set as the consumed actor.
- consumedActor = EmitTouchSignals( parent, touchEvent );
+ consumedActor = EmitTouchSignals(parent, touchEvent);
}
}
}
return consumedActor;
}
-Dali::Actor AllocAndEmitTouchSignals( unsigned long time, Dali::Actor actor, const Integration::Point& point )
+Dali::Actor AllocAndEmitTouchSignals(unsigned long time, Dali::Actor actor, const Integration::Point& point)
{
- TouchEventPtr touchEvent( new TouchEvent( time ) );
- Dali::TouchEvent touchEventHandle( touchEvent.Get() );
+ TouchEventPtr touchEvent(new TouchEvent(time));
+ Dali::TouchEvent touchEventHandle(touchEvent.Get());
- touchEvent->AddPoint( point );
+ touchEvent->AddPoint(point);
- return EmitTouchSignals( actor, touchEventHandle );
+ return EmitTouchSignals(actor, touchEventHandle);
}
-
/**
* Changes the state of the primary point to leave and emits the touch signals
*/
-Dali::Actor EmitTouchSignals( Actor* actor, RenderTask& renderTask, const TouchEventPtr& originalTouchEvent, PointState::Type state )
+Dali::Actor EmitTouchSignals(Actor* actor, RenderTask& renderTask, const TouchEventPtr& originalTouchEvent, PointState::Type state)
{
Dali::Actor consumingActor;
- if( actor )
+ if(actor)
{
- TouchEventPtr touchEventImpl = TouchEvent::Clone( *originalTouchEvent.Get() );
+ TouchEventPtr touchEventImpl = TouchEvent::Clone(*originalTouchEvent.Get());
- Integration::Point& primaryPoint = touchEventImpl->GetPoint( 0 );
+ Integration::Point& primaryPoint = touchEventImpl->GetPoint(0);
const Vector2& screenPosition = primaryPoint.GetScreenPosition();
- Vector2 localPosition;
- actor->ScreenToLocal( renderTask, localPosition.x, localPosition.y, screenPosition.x, screenPosition.y );
+ Vector2 localPosition;
+ actor->ScreenToLocal(renderTask, localPosition.x, localPosition.y, screenPosition.x, screenPosition.y);
- primaryPoint.SetLocalPosition( localPosition );
- primaryPoint.SetHitActor( Dali::Actor( actor ) );
- primaryPoint.SetState( state );
+ primaryPoint.SetLocalPosition(localPosition);
+ primaryPoint.SetHitActor(Dali::Actor(actor));
+ primaryPoint.SetState(state);
- consumingActor = EmitTouchSignals( Dali::Actor(actor), Dali::TouchEvent( touchEventImpl.Get() ) );
+ consumingActor = EmitTouchSignals(Dali::Actor(actor), Dali::TouchEvent(touchEventImpl.Get()));
}
return consumingActor;
* @param[in] scene The scene that this touch is related to
*/
void ParsePrimaryTouchPoint(
- HitTestAlgorithm::Results& hitTestResults,
- ActorObserver& capturingTouchActorObserver,
- const RenderTaskPtr& lastRenderTask,
- const Integration::Point& currentPoint,
- const Internal::Scene& scene )
+ HitTestAlgorithm::Results& hitTestResults,
+ ActorObserver& capturingTouchActorObserver,
+ const RenderTaskPtr& lastRenderTask,
+ const Integration::Point& currentPoint,
+ const Internal::Scene& scene)
{
Actor* capturingTouchActor = capturingTouchActorObserver.GetActor();
// We only set the capturing touch actor when the first touch-started actor captures all touch so if it's set, just use it
- if( capturingTouchActor && lastRenderTask )
+ if(capturingTouchActor && lastRenderTask)
{
- hitTestResults.actor = Dali::Actor( capturingTouchActor );
- hitTestResults.renderTask = lastRenderTask;
+ hitTestResults.actor = Dali::Actor(capturingTouchActor);
+ hitTestResults.renderTask = lastRenderTask;
const Vector2& screenPosition = currentPoint.GetScreenPosition();
- capturingTouchActor->ScreenToLocal( *lastRenderTask, hitTestResults.actorCoordinates.x, hitTestResults.actorCoordinates.y, screenPosition.x, screenPosition.y );
+ capturingTouchActor->ScreenToLocal(*lastRenderTask, hitTestResults.actorCoordinates.x, hitTestResults.actorCoordinates.y, screenPosition.x, screenPosition.y);
}
else
{
- HitTestAlgorithm::HitTest( scene.GetSize(), scene.GetRenderTaskList(), scene.GetLayerList(), currentPoint.GetScreenPosition(), hitTestResults );
+ HitTestAlgorithm::HitTest(scene.GetSize(), scene.GetRenderTaskList(), scene.GetLayerList(), currentPoint.GetScreenPosition(), hitTestResults);
- if( currentPoint.GetState() == PointState::STARTED && hitTestResults.actor )
+ if(currentPoint.GetState() == PointState::STARTED && hitTestResults.actor)
{
// If we've just started touch, then check whether the actor has requested to capture all touch events
- Actor* hitActor = &GetImplementation( hitTestResults.actor );
- if( hitActor->CapturesAllTouchAfterStart() )
+ Actor* hitActor = &GetImplementation(hitTestResults.actor);
+ if(hitActor->CapturesAllTouchAfterStart())
{
- capturingTouchActorObserver.SetActor( hitActor );
+ capturingTouchActorObserver.SetActor(hitActor);
}
}
}
} // unnamed namespace
-TouchEventProcessor::TouchEventProcessor( Scene& scene )
-: mScene( scene ),
- mLastPrimaryHitActor( MakeCallback( this, &TouchEventProcessor::OnObservedActorDisconnected ) ),
+TouchEventProcessor::TouchEventProcessor(Scene& scene)
+: mScene(scene),
+ mLastPrimaryHitActor(MakeCallback(this, &TouchEventProcessor::OnObservedActorDisconnected)),
mLastConsumedActor(),
mCapturingTouchActor(),
mTouchDownConsumedActor(),
mLastRenderTask()
{
- DALI_LOG_TRACE_METHOD( gLogFilter );
+ DALI_LOG_TRACE_METHOD(gLogFilter);
}
TouchEventProcessor::~TouchEventProcessor()
{
- DALI_LOG_TRACE_METHOD( gLogFilter );
+ DALI_LOG_TRACE_METHOD(gLogFilter);
}
-bool TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& event )
+bool TouchEventProcessor::ProcessTouchEvent(const Integration::TouchEvent& event)
{
- DALI_LOG_TRACE_METHOD( gLogFilter );
- DALI_ASSERT_ALWAYS( !event.points.empty() && "Empty TouchEvent sent from Integration\n" );
+ DALI_LOG_TRACE_METHOD(gLogFilter);
+ DALI_ASSERT_ALWAYS(!event.points.empty() && "Empty TouchEvent sent from Integration\n");
PRINT_HIERARCHY(gLogFilter);
// 1) Check if it is an interrupted event - we should inform our last primary hit actor about this
// and emit the stage signal as well.
- if ( event.points[0].GetState() == PointState::INTERRUPTED )
+ if(event.points[0].GetState() == PointState::INTERRUPTED)
{
- Dali::Actor consumingActor;
- Integration::Point currentPoint( event.points[0] );
+ Dali::Actor consumingActor;
+ Integration::Point currentPoint(event.points[0]);
- Actor* lastPrimaryHitActor( mLastPrimaryHitActor.GetActor() );
- if ( lastPrimaryHitActor )
+ Actor* lastPrimaryHitActor(mLastPrimaryHitActor.GetActor());
+ if(lastPrimaryHitActor)
{
- Dali::Actor lastPrimaryHitActorHandle( lastPrimaryHitActor );
- currentPoint.SetHitActor( lastPrimaryHitActorHandle );
+ Dali::Actor lastPrimaryHitActorHandle(lastPrimaryHitActor);
+ currentPoint.SetHitActor(lastPrimaryHitActorHandle);
- consumingActor = AllocAndEmitTouchSignals( event.time, lastPrimaryHitActorHandle, currentPoint );
+ consumingActor = AllocAndEmitTouchSignals(event.time, lastPrimaryHitActorHandle, currentPoint);
}
// If the last consumed actor was different to the primary hit actor then inform it as well (if it has not already been informed).
- Actor* lastConsumedActor( mLastConsumedActor.GetActor() );
- if ( lastConsumedActor &&
- lastConsumedActor != lastPrimaryHitActor &&
- lastConsumedActor != consumingActor )
+ Actor* lastConsumedActor(mLastConsumedActor.GetActor());
+ if(lastConsumedActor &&
+ lastConsumedActor != lastPrimaryHitActor &&
+ lastConsumedActor != consumingActor)
{
- Dali::Actor lastConsumedActorHandle( lastConsumedActor );
- currentPoint.SetHitActor( lastConsumedActorHandle );
- AllocAndEmitTouchSignals( event.time, lastConsumedActorHandle, currentPoint );
+ Dali::Actor lastConsumedActorHandle(lastConsumedActor);
+ currentPoint.SetHitActor(lastConsumedActorHandle);
+ AllocAndEmitTouchSignals(event.time, lastConsumedActorHandle, currentPoint);
}
// Tell the touch-down consuming actor as well, if required
- Actor* touchDownConsumedActor( mTouchDownConsumedActor.GetActor() );
- if ( touchDownConsumedActor &&
- touchDownConsumedActor != lastPrimaryHitActor &&
- touchDownConsumedActor != lastConsumedActor &&
- touchDownConsumedActor != consumingActor )
+ Actor* touchDownConsumedActor(mTouchDownConsumedActor.GetActor());
+ if(touchDownConsumedActor &&
+ touchDownConsumedActor != lastPrimaryHitActor &&
+ touchDownConsumedActor != lastConsumedActor &&
+ touchDownConsumedActor != consumingActor)
{
- Dali::Actor touchDownConsumedActorHandle( touchDownConsumedActor );
+ Dali::Actor touchDownConsumedActorHandle(touchDownConsumedActor);
- currentPoint.SetHitActor( touchDownConsumedActorHandle );
- AllocAndEmitTouchSignals( event.time, touchDownConsumedActorHandle, currentPoint );
+ currentPoint.SetHitActor(touchDownConsumedActorHandle);
+ AllocAndEmitTouchSignals(event.time, touchDownConsumedActorHandle, currentPoint);
}
- mLastPrimaryHitActor.SetActor( nullptr );
- mLastConsumedActor.SetActor( nullptr );
- mCapturingTouchActor.SetActor( nullptr );
- mTouchDownConsumedActor.SetActor( nullptr );
+ mLastPrimaryHitActor.SetActor(nullptr);
+ mLastConsumedActor.SetActor(nullptr);
+ mCapturingTouchActor.SetActor(nullptr);
+ mTouchDownConsumedActor.SetActor(nullptr);
mLastRenderTask.Reset();
- currentPoint.SetHitActor( Dali::Actor() );
+ currentPoint.SetHitActor(Dali::Actor());
- TouchEventPtr touchEventImpl( new TouchEvent( event.time ) );
- Dali::TouchEvent touchEventHandle( touchEventImpl.Get() );
+ TouchEventPtr touchEventImpl(new TouchEvent(event.time));
+ Dali::TouchEvent touchEventHandle(touchEventImpl.Get());
- touchEventImpl->AddPoint( currentPoint );
+ touchEventImpl->AddPoint(currentPoint);
- mScene.EmitTouchedSignal( touchEventHandle );
+ mScene.EmitTouchedSignal(touchEventHandle);
return false; // No need for hit testing & already an interrupted event so just return false
}
// 2) Hit Testing.
- TouchEventPtr touchEventImpl( new TouchEvent( event.time ) );
- Dali::TouchEvent touchEventHandle( touchEventImpl.Get() );
+ TouchEventPtr touchEventImpl(new TouchEvent(event.time));
+ Dali::TouchEvent touchEventHandle(touchEventImpl.Get());
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, "Point(s): %d\n", event.GetPointCount() );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, "Point(s): %d\n", event.GetPointCount());
RenderTaskPtr currentRenderTask;
- bool firstPointParsed = false;
+ bool firstPointParsed = false;
- for ( auto&& currentPoint : event.points )
+ for(auto&& currentPoint : event.points)
{
HitTestAlgorithm::Results hitTestResults;
- if( !firstPointParsed )
+ if(!firstPointParsed)
{
firstPointParsed = true;
- ParsePrimaryTouchPoint( hitTestResults, mCapturingTouchActor, mLastRenderTask, currentPoint, mScene );
+ ParsePrimaryTouchPoint(hitTestResults, mCapturingTouchActor, mLastRenderTask, currentPoint, mScene);
// Only set the currentRenderTask for the primary hit actor.
currentRenderTask = hitTestResults.renderTask;
}
else
{
- HitTestAlgorithm::HitTest( mScene.GetSize(), mScene.GetRenderTaskList(), mScene.GetLayerList(), currentPoint.GetScreenPosition(), hitTestResults );
+ HitTestAlgorithm::HitTest(mScene.GetSize(), mScene.GetRenderTaskList(), mScene.GetLayerList(), currentPoint.GetScreenPosition(), hitTestResults);
}
- Integration::Point newPoint( currentPoint );
- newPoint.SetHitActor( hitTestResults.actor );
- newPoint.SetLocalPosition( hitTestResults.actorCoordinates );
-
- touchEventImpl->AddPoint( newPoint );
+ Integration::Point newPoint(currentPoint);
+ newPoint.SetHitActor(hitTestResults.actor);
+ newPoint.SetLocalPosition(hitTestResults.actorCoordinates);
- DALI_LOG_INFO( gLogFilter, Debug::General, " State(%s), Screen(%.0f, %.0f), HitActor(%p, %s), Local(%.2f, %.2f)\n",
- TOUCH_POINT_STATE[currentPoint.GetState()], currentPoint.GetScreenPosition().x, currentPoint.GetScreenPosition().y,
- ( hitTestResults.actor ? reinterpret_cast< void* >( &hitTestResults.actor.GetBaseObject() ) : NULL ),
- ( hitTestResults.actor ? hitTestResults.actor.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str() : "" ),
- hitTestResults.actorCoordinates.x, hitTestResults.actorCoordinates.y );
+ touchEventImpl->AddPoint(newPoint);
+ DALI_LOG_INFO(gLogFilter, Debug::General, " State(%s), Screen(%.0f, %.0f), HitActor(%p, %s), Local(%.2f, %.2f)\n", TOUCH_POINT_STATE[currentPoint.GetState()], currentPoint.GetScreenPosition().x, currentPoint.GetScreenPosition().y, (hitTestResults.actor ? reinterpret_cast<void*>(&hitTestResults.actor.GetBaseObject()) : NULL), (hitTestResults.actor ? hitTestResults.actor.GetProperty<std::string>(Dali::Actor::Property::NAME).c_str() : ""), hitTestResults.actorCoordinates.x, hitTestResults.actorCoordinates.y);
}
// 3) Recursively deliver events to the actor and its parents, until the event is consumed or the stage is reached.
// Emit the touch signal
Dali::Actor consumedActor;
- if ( currentRenderTask )
+ if(currentRenderTask)
{
// Emit the intercept touch signal
- Dali::Actor interceptedActor = EmitInterceptTouchSignals( touchEventImpl->GetPoint( 0 ).GetHitActor(), touchEventHandle );
- if( interceptedActor )
+ Dali::Actor interceptedActor = EmitInterceptTouchSignals(touchEventImpl->GetPoint(0).GetHitActor(), touchEventHandle);
+ if(interceptedActor)
{
- consumedActor = EmitTouchSignals( interceptedActor, touchEventHandle );
+ consumedActor = EmitTouchSignals(interceptedActor, touchEventHandle);
}
else
{
- consumedActor = EmitTouchSignals( touchEventImpl->GetPoint( 0 ).GetHitActor(), touchEventHandle );
+ consumedActor = EmitTouchSignals(touchEventImpl->GetPoint(0).GetHitActor(), touchEventHandle);
}
consumed = consumedActor ? true : false;
}
- Integration::Point& primaryPoint = touchEventImpl->GetPoint( 0 );
- Dali::Actor primaryHitActor = primaryPoint.GetHitActor();
- PointState::Type primaryPointState = primaryPoint.GetState();
+ Integration::Point& primaryPoint = touchEventImpl->GetPoint(0);
+ Dali::Actor primaryHitActor = primaryPoint.GetHitActor();
+ PointState::Type primaryPointState = primaryPoint.GetState();
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "PrimaryHitActor: (%p) %s\n", primaryHitActor ? reinterpret_cast< void* >( &primaryHitActor.GetBaseObject() ) : NULL, primaryHitActor ? primaryHitActor.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str() : "" );
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "ConsumedActor: (%p) %s\n", consumedActor ? reinterpret_cast< void* >( &consumedActor.GetBaseObject() ) : NULL, consumedActor ? consumedActor.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str() : "" );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "PrimaryHitActor: (%p) %s\n", primaryHitActor ? reinterpret_cast<void*>(&primaryHitActor.GetBaseObject()) : NULL, primaryHitActor ? primaryHitActor.GetProperty<std::string>(Dali::Actor::Property::NAME).c_str() : "");
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "ConsumedActor: (%p) %s\n", consumedActor ? reinterpret_cast<void*>(&consumedActor.GetBaseObject()) : NULL, consumedActor ? consumedActor.GetProperty<std::string>(Dali::Actor::Property::NAME).c_str() : "");
- if ( ( primaryPointState == PointState::DOWN ) &&
- ( touchEventImpl->GetPointCount() == 1 ) &&
- ( consumedActor && consumedActor.GetProperty< bool >( Dali::Actor::Property::CONNECTED_TO_SCENE ) ) )
+ if((primaryPointState == PointState::DOWN) &&
+ (touchEventImpl->GetPointCount() == 1) &&
+ (consumedActor && consumedActor.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE)))
{
- mTouchDownConsumedActor.SetActor( &GetImplementation( consumedActor ) );
+ mTouchDownConsumedActor.SetActor(&GetImplementation(consumedActor));
}
// 4) Check if the last primary hit actor requires a leave event and if it was different to the current primary
// hit actor. Also process the last consumed actor in the same manner.
- Actor* lastPrimaryHitActor( mLastPrimaryHitActor.GetActor() );
- Actor* lastConsumedActor( mLastConsumedActor.GetActor() );
- if( ( primaryPointState == PointState::MOTION ) || ( primaryPointState == PointState::UP ) || ( primaryPointState == PointState::STATIONARY ) )
+ Actor* lastPrimaryHitActor(mLastPrimaryHitActor.GetActor());
+ Actor* lastConsumedActor(mLastConsumedActor.GetActor());
+ if((primaryPointState == PointState::MOTION) || (primaryPointState == PointState::UP) || (primaryPointState == PointState::STATIONARY))
{
- if( mLastRenderTask )
+ if(mLastRenderTask)
{
Dali::Actor leaveEventConsumer;
RenderTask& lastRenderTaskImpl = *mLastRenderTask.Get();
- if( lastPrimaryHitActor &&
- lastPrimaryHitActor != primaryHitActor &&
- lastPrimaryHitActor != consumedActor )
+ if(lastPrimaryHitActor &&
+ lastPrimaryHitActor != primaryHitActor &&
+ lastPrimaryHitActor != consumedActor)
{
- if( lastPrimaryHitActor->IsHittable() && IsActuallySensitive( lastPrimaryHitActor ) )
+ if(lastPrimaryHitActor->IsHittable() && IsActuallySensitive(lastPrimaryHitActor))
{
- if ( lastPrimaryHitActor->GetLeaveRequired() )
+ if(lastPrimaryHitActor->GetLeaveRequired())
{
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "LeaveActor(Hit): (%p) %s\n", reinterpret_cast< void* >( lastPrimaryHitActor ), lastPrimaryHitActor->GetName().data() );
- leaveEventConsumer = EmitTouchSignals( mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, touchEventImpl, PointState::LEAVE );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "LeaveActor(Hit): (%p) %s\n", reinterpret_cast<void*>(lastPrimaryHitActor), lastPrimaryHitActor->GetName().data());
+ leaveEventConsumer = EmitTouchSignals(mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, touchEventImpl, PointState::LEAVE);
}
}
else
{
// At this point mLastPrimaryHitActor was touchable and sensitive in the previous touch event process but is not in the current one.
// An interrupted event is send to allow some actors to go back to their original state (i.e. Button controls)
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "InterruptedActor(Hit): (%p) %s\n", reinterpret_cast< void* >( lastPrimaryHitActor ), lastPrimaryHitActor->GetName().data() );
- leaveEventConsumer = EmitTouchSignals( mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, touchEventImpl, PointState::INTERRUPTED );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "InterruptedActor(Hit): (%p) %s\n", reinterpret_cast<void*>(lastPrimaryHitActor), lastPrimaryHitActor->GetName().data());
+ leaveEventConsumer = EmitTouchSignals(mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, touchEventImpl, PointState::INTERRUPTED);
}
}
// Check if the motion event has been consumed by another actor's listener. In this case, the previously
// consumed actor's listeners may need to be informed (through a leave event).
// Further checks here to ensure we do not signal the same actor twice for the same event.
- if ( lastConsumedActor &&
- lastConsumedActor != consumedActor &&
- lastConsumedActor != lastPrimaryHitActor &&
- lastConsumedActor != primaryHitActor &&
- lastConsumedActor != leaveEventConsumer )
+ if(lastConsumedActor &&
+ lastConsumedActor != consumedActor &&
+ lastConsumedActor != lastPrimaryHitActor &&
+ lastConsumedActor != primaryHitActor &&
+ lastConsumedActor != leaveEventConsumer)
{
- if( lastConsumedActor->IsHittable() && IsActuallySensitive( lastConsumedActor ) )
+ if(lastConsumedActor->IsHittable() && IsActuallySensitive(lastConsumedActor))
{
- if( lastConsumedActor->GetLeaveRequired() )
+ if(lastConsumedActor->GetLeaveRequired())
{
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "LeaveActor(Consume): (%p) %s\n", reinterpret_cast< void* >( lastConsumedActor ), lastConsumedActor->GetName().data() );
- EmitTouchSignals( lastConsumedActor, lastRenderTaskImpl, touchEventImpl, PointState::LEAVE );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "LeaveActor(Consume): (%p) %s\n", reinterpret_cast<void*>(lastConsumedActor), lastConsumedActor->GetName().data());
+ EmitTouchSignals(lastConsumedActor, lastRenderTaskImpl, touchEventImpl, PointState::LEAVE);
}
}
else
{
// At this point mLastConsumedActor was touchable and sensitive in the previous touch event process but is not in the current one.
// An interrupted event is send to allow some actors to go back to their original state (i.e. Button controls)
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "InterruptedActor(Consume): (%p) %s\n", reinterpret_cast< void* >( lastConsumedActor ), lastConsumedActor->GetName().data() );
- EmitTouchSignals( mLastConsumedActor.GetActor(), lastRenderTaskImpl, touchEventImpl, PointState::INTERRUPTED );
+ DALI_LOG_INFO(gLogFilter, Debug::Concise, "InterruptedActor(Consume): (%p) %s\n", reinterpret_cast<void*>(lastConsumedActor), lastConsumedActor->GetName().data());
+ EmitTouchSignals(mLastConsumedActor.GetActor(), lastRenderTaskImpl, touchEventImpl, PointState::INTERRUPTED);
}
}
}
// 5) If our primary point is an Up event, then the primary point (in multi-touch) will change next
// time so set our last primary actor to NULL. Do the same to the last consumed actor as well.
- if ( primaryPointState == PointState::UP )
+ if(primaryPointState == PointState::UP)
{
- mLastPrimaryHitActor.SetActor( nullptr );
- mLastConsumedActor.SetActor( nullptr );
- mCapturingTouchActor.SetActor( nullptr );
+ mLastPrimaryHitActor.SetActor(nullptr);
+ mLastConsumedActor.SetActor(nullptr);
+ mCapturingTouchActor.SetActor(nullptr);
mLastRenderTask.Reset();
}
else
{
// The primaryHitActor may have been removed from the scene so ensure it is still on the scene before setting members.
- if ( primaryHitActor && GetImplementation( primaryHitActor ).OnScene() )
+ if(primaryHitActor && GetImplementation(primaryHitActor).OnScene())
{
- mLastPrimaryHitActor.SetActor( &GetImplementation( primaryHitActor ) );
+ mLastPrimaryHitActor.SetActor(&GetImplementation(primaryHitActor));
// Only observe the consumed actor if we have a primaryHitActor (check if it is still on the scene).
- if ( consumedActor && GetImplementation( consumedActor ).OnScene() )
+ if(consumedActor && GetImplementation(consumedActor).OnScene())
{
- mLastConsumedActor.SetActor( &GetImplementation( consumedActor ) );
+ mLastConsumedActor.SetActor(&GetImplementation(consumedActor));
}
else
{
- mLastConsumedActor.SetActor( nullptr );
+ mLastConsumedActor.SetActor(nullptr);
}
mLastRenderTask = currentRenderTask;
}
else
{
- mLastPrimaryHitActor.SetActor( nullptr );
- mLastConsumedActor.SetActor( nullptr );
- mCapturingTouchActor.SetActor( nullptr );
+ mLastPrimaryHitActor.SetActor(nullptr);
+ mLastConsumedActor.SetActor(nullptr);
+ mCapturingTouchActor.SetActor(nullptr);
mLastRenderTask.Reset();
}
}
// 6) Emit an interrupted event to the touch-down actor if it hasn't consumed the up and
// emit the stage touched event if required.
- if ( touchEventImpl->GetPointCount() == 1 ) // Only want the first touch and the last release
+ if(touchEventImpl->GetPointCount() == 1) // Only want the first touch and the last release
{
- switch ( primaryPointState )
+ switch(primaryPointState)
{
case PointState::UP:
{
- Actor* touchDownConsumedActor( mTouchDownConsumedActor.GetActor() );
- if ( touchDownConsumedActor &&
- touchDownConsumedActor != consumedActor &&
- touchDownConsumedActor != lastPrimaryHitActor &&
- touchDownConsumedActor != lastConsumedActor )
+ Actor* touchDownConsumedActor(mTouchDownConsumedActor.GetActor());
+ if(touchDownConsumedActor &&
+ touchDownConsumedActor != consumedActor &&
+ touchDownConsumedActor != lastPrimaryHitActor &&
+ touchDownConsumedActor != lastConsumedActor)
{
- Dali::Actor touchDownConsumedActorHandle( touchDownConsumedActor );
+ Dali::Actor touchDownConsumedActorHandle(touchDownConsumedActor);
- Integration::Point currentPoint = touchEventImpl->GetPoint( 0 );
- currentPoint.SetHitActor( touchDownConsumedActorHandle );
- currentPoint.SetState( PointState::INTERRUPTED );
+ Integration::Point currentPoint = touchEventImpl->GetPoint(0);
+ currentPoint.SetHitActor(touchDownConsumedActorHandle);
+ currentPoint.SetState(PointState::INTERRUPTED);
- AllocAndEmitTouchSignals( event.time, touchDownConsumedActorHandle, currentPoint );
+ AllocAndEmitTouchSignals(event.time, touchDownConsumedActorHandle, currentPoint);
}
- mTouchDownConsumedActor.SetActor( nullptr );
+ mTouchDownConsumedActor.SetActor(nullptr);
DALI_FALLTHROUGH;
}
case PointState::DOWN:
{
- mScene.EmitTouchedSignal( touchEventHandle );
+ mScene.EmitTouchedSignal(touchEventHandle);
break;
}
return consumed;
}
-void TouchEventProcessor::OnObservedActorDisconnected( Actor* actor )
+void TouchEventProcessor::OnObservedActorDisconnected(Actor* actor)
{
- if ( actor == mLastPrimaryHitActor.GetActor() )
+ if(actor == mLastPrimaryHitActor.GetActor())
{
- Dali::Actor actorHandle( actor );
+ Dali::Actor actorHandle(actor);
Integration::Point point;
- point.SetState( PointState::INTERRUPTED );
- point.SetHitActor( actorHandle );
+ point.SetState(PointState::INTERRUPTED);
+ point.SetHitActor(actorHandle);
- TouchEventPtr touchEventImpl( new TouchEvent );
- touchEventImpl->AddPoint( point );
- Dali::TouchEvent touchEventHandle( touchEventImpl.Get() );
+ TouchEventPtr touchEventImpl(new TouchEvent);
+ touchEventImpl->AddPoint(point);
+ Dali::TouchEvent touchEventHandle(touchEventImpl.Get());
- Dali::Actor eventConsumer = EmitTouchSignals( actorHandle, touchEventHandle );
+ Dali::Actor eventConsumer = EmitTouchSignals(actorHandle, touchEventHandle);
- if ( mLastConsumedActor.GetActor() != eventConsumer )
+ if(mLastConsumedActor.GetActor() != eventConsumer)
{
- EmitTouchSignals( Dali::Actor( mLastConsumedActor.GetActor() ), touchEventHandle );
+ EmitTouchSignals(Dali::Actor(mLastConsumedActor.GetActor()), touchEventHandle);
}
// Do not set mLastPrimaryHitActor to NULL we may be iterating through its observers
- mLastConsumedActor.SetActor( nullptr );
+ mLastConsumedActor.SetActor(nullptr);
mLastRenderTask.Reset();
}
}
#define DALI_INTERNAL_TOUCH_EVENT_PROCESSOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
class Actor;
struct Vector2;
struct Vector4;
namespace Internal
{
-
class Actor;
class Scene;
struct ActorObserver;
class TouchEventProcessor
{
public:
-
/**
* Create an event processor.
* @param[in] scene The scene the event processor belongs to.
*/
- TouchEventProcessor( Scene& scene );
+ TouchEventProcessor(Scene& scene);
/**
* Non-virtual destructor; TouchEventProcessor is not a base class
* @param[in] event The touch event that has occurred.
* @return true if consumed
*/
- bool ProcessTouchEvent( const Integration::TouchEvent& event );
+ bool ProcessTouchEvent(const Integration::TouchEvent& event);
private:
-
// Undefined
TouchEventProcessor(const TouchEventProcessor&);
TouchEventProcessor& operator=(const TouchEventProcessor& rhs);
private:
-
Scene& mScene; ///< Used to deliver touch events
/**
*
* @param[in] actor The actor that has been disconnected.
*/
- void OnObservedActorDisconnected( Actor* actor );
+ void OnObservedActorDisconnected(Actor* actor);
- ActorObserver mLastPrimaryHitActor; ///< Stores the last primary point hit actor
- ActorObserver mLastConsumedActor; ///< Stores the last consumed actor
- ActorObserver mCapturingTouchActor; ///< Stored the actor that captures touch
+ ActorObserver mLastPrimaryHitActor; ///< Stores the last primary point hit actor
+ ActorObserver mLastConsumedActor; ///< Stores the last consumed actor
+ ActorObserver mCapturingTouchActor; ///< Stored the actor that captures touch
ActorObserver mTouchDownConsumedActor; ///< Stores the touch-down consumed actor
- RenderTaskPtr mLastRenderTask; ///< The RenderTask used for the last hit actor
+ RenderTaskPtr mLastRenderTask; ///< The RenderTask used for the last hit actor
};
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace
{
const uint32_t MODIFIER_SHIFT = 0x1;
const uint32_t MODIFIER_CTRL = 0x2;
const uint32_t MODIFIER_ALT = 0x4;
-}
+} // namespace
namespace Internal
{
-
WheelEvent::WheelEvent()
-: mType( Dali::WheelEvent::MOUSE_WHEEL ),
- mDirection( 0 ),
- mModifiers( 0 ),
- mPoint( Vector2::ZERO ),
- mDelta( 0 ),
- mTimeStamp( 0 )
+: mType(Dali::WheelEvent::MOUSE_WHEEL),
+ mDirection(0),
+ mModifiers(0),
+ mPoint(Vector2::ZERO),
+ mDelta(0),
+ mTimeStamp(0)
{
}
-WheelEvent::WheelEvent( Dali::WheelEvent::Type type, int32_t direction, uint32_t modifiers, Vector2 point, int32_t delta, uint32_t timeStamp )
-: mType( type ),
- mDirection( direction ),
- mModifiers( modifiers ),
- mPoint( point ),
- mDelta( delta ),
- mTimeStamp( timeStamp )
+WheelEvent::WheelEvent(Dali::WheelEvent::Type type, int32_t direction, uint32_t modifiers, Vector2 point, int32_t delta, uint32_t timeStamp)
+: mType(type),
+ mDirection(direction),
+ mModifiers(modifiers),
+ mPoint(point),
+ mDelta(delta),
+ mTimeStamp(timeStamp)
{
}
-WheelEventPtr WheelEvent::New( Dali::WheelEvent::Type type, int32_t direction, uint32_t modifiers, Vector2 point, int32_t delta, uint32_t timeStamp )
+WheelEventPtr WheelEvent::New(Dali::WheelEvent::Type type, int32_t direction, uint32_t modifiers, Vector2 point, int32_t delta, uint32_t timeStamp)
{
- WheelEventPtr wheelEvent = new WheelEvent( type, direction, modifiers, point, delta, timeStamp );
+ WheelEventPtr wheelEvent = new WheelEvent(type, direction, modifiers, point, delta, timeStamp);
return wheelEvent;
}
bool WheelEvent::IsShiftModifier() const
{
- return ( ( MODIFIER_SHIFT & mModifiers ) == MODIFIER_SHIFT );
+ return ((MODIFIER_SHIFT & mModifiers) == MODIFIER_SHIFT);
}
bool WheelEvent::IsCtrlModifier() const
{
- return ( ( MODIFIER_CTRL & mModifiers ) == MODIFIER_CTRL );
+ return ((MODIFIER_CTRL & mModifiers) == MODIFIER_CTRL);
}
bool WheelEvent::IsAltModifier() const
{
- return ( ( MODIFIER_ALT & mModifiers ) == MODIFIER_ALT );
+ return ((MODIFIER_ALT & mModifiers) == MODIFIER_ALT);
}
Dali::WheelEvent::Type WheelEvent::GetType() const
return mTimeStamp;
}
-} // namsespace Internal
+} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_WHEEL_EVENT_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
class WheelEvent;
using WheelEventPtr = IntrusivePtr<WheelEvent>;
class WheelEvent : public BaseObject
{
public:
-
// Construction & Destruction
/**
* @param[in] delta The offset of rolling (positive value means roll down or clockwise, and negative value means roll up or counter-clockwise)
* @param[in] timeStamp The time the wheel is being rolled
*/
- WheelEvent( Dali::WheelEvent::Type type, int32_t direction, uint32_t modifiers, Vector2 point, int32_t delta, uint32_t timeStamp );
+ WheelEvent(Dali::WheelEvent::Type type, int32_t direction, uint32_t modifiers, Vector2 point, int32_t delta, uint32_t timeStamp);
/**
* Create a new WheelEvent.
* @param[in] timeStamp The time the wheel is being rolled
* @return A smart-pointer to the newly allocated WheelEvent.
*/
- static WheelEventPtr New( Dali::WheelEvent::Type type, int32_t direction, uint32_t modifiers, Vector2 point, int32_t delta, uint32_t timeStamp );
+ static WheelEventPtr New(Dali::WheelEvent::Type type, int32_t direction, uint32_t modifiers, Vector2 point, int32_t delta, uint32_t timeStamp);
/**
* @copydoc Dali::WheelEvent::IsShiftModifier()
uint32_t GetTime() const;
private:
-
/**
* @brief Destructor
*
// Not copyable or movable
- WheelEvent( const WheelEvent& rhs ) = delete; ///< Deleted copy constructor
- WheelEvent( WheelEvent&& rhs ) = delete; ///< Deleted move constructor
- WheelEvent& operator=( const WheelEvent& rhs ) = delete; ///< Deleted copy assignment operator
- WheelEvent& operator=( WheelEvent&& rhs ) = delete; ///< Deleted move assignment operator
+ WheelEvent(const WheelEvent& rhs) = delete; ///< Deleted copy constructor
+ WheelEvent(WheelEvent&& rhs) = delete; ///< Deleted move constructor
+ WheelEvent& operator=(const WheelEvent& rhs) = delete; ///< Deleted copy assignment operator
+ WheelEvent& operator=(WheelEvent&& rhs) = delete; ///< Deleted move assignment operator
private:
-
- Dali::WheelEvent::Type mType; ///< The type of the event
- int32_t mDirection; ///< The direction in which the wheel is being rolled
- uint32_t mModifiers; ///< Modifier keys pressed during the event
- Vector2 mPoint; ///< The co-ordinates of the cursor relative to the top-left of the screen when the wheel is being rolled.
- int32_t mDelta; ///< The offset of the wheel rolling
- uint32_t mTimeStamp; ///< The time when the wheel is being rolled
+ Dali::WheelEvent::Type mType; ///< The type of the event
+ int32_t mDirection; ///< The direction in which the wheel is being rolled
+ uint32_t mModifiers; ///< Modifier keys pressed during the event
+ Vector2 mPoint; ///< The co-ordinates of the cursor relative to the top-left of the screen when the wheel is being rolled.
+ int32_t mDelta; ///< The offset of the wheel rolling
+ uint32_t mTimeStamp; ///< The time when the wheel is being rolled
};
} // namespace Internal
// Helpers for public-api forwarding methods
-inline Internal::WheelEvent& GetImplementation( Dali::WheelEvent& wheelEvent )
+inline Internal::WheelEvent& GetImplementation(Dali::WheelEvent& wheelEvent)
{
- DALI_ASSERT_ALWAYS( wheelEvent && "Wheel Event handle is empty" );
+ DALI_ASSERT_ALWAYS(wheelEvent && "Wheel Event handle is empty");
BaseObject& object = wheelEvent.GetBaseObject();
- return static_cast< Internal::WheelEvent& >( object );
+ return static_cast<Internal::WheelEvent&>(object);
}
-inline const Internal::WheelEvent& GetImplementation( const Dali::WheelEvent& wheelEvent )
+inline const Internal::WheelEvent& GetImplementation(const Dali::WheelEvent& wheelEvent)
{
- DALI_ASSERT_ALWAYS( wheelEvent && "Wheel Event handle is empty" );
+ DALI_ASSERT_ALWAYS(wheelEvent && "Wheel Event handle is empty");
const BaseObject& object = wheelEvent.GetBaseObject();
- return static_cast< const Internal::WheelEvent& >( object );
+ return static_cast<const Internal::WheelEvent&>(object);
}
} // namespace Dali
#define DALI_INTERNAL_WHEEL_EVENT_PROCESSOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Integration
{
struct WheelEvent;
namespace Internal
{
-
class Scene;
/**
class WheelEventProcessor
{
public:
-
/**
* Create a wheel event processor.
*/
- WheelEventProcessor( Scene& scenes );
+ WheelEventProcessor(Scene& scenes);
/**
* Non-virtual destructor; WheelEventProcessor is not a base class
void ProcessWheelEvent(const Integration::WheelEvent& event);
private:
-
// Undefined
WheelEventProcessor(const WheelEventProcessor&);
WheelEventProcessor& operator=(const WheelEventProcessor& rhs);
private:
-
- Scene& mScene; ///< Used to deliver the wheel events
+ Scene& mScene; ///< Used to deliver the wheel events
};
} // namespace Internal
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstdlib>
// INTERNAL INCLUDES
-#include <dali/internal/common/core-impl.h>
#include <dali/integration-api/debug.h>
+#include <dali/internal/common/core-impl.h>
namespace Dali
{
-
namespace Internal
{
using namespace Dali::Pixel;
-BitmapCompressed::BitmapCompressed( const ResourcePolicy::Discardable discardable )
-: Bitmap( discardable ),
+BitmapCompressed::BitmapCompressed(const ResourcePolicy::Discardable discardable)
+: Bitmap(discardable),
mBufferSize(0)
{
}
DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
}
-void BitmapCompressed::Initialize( Pixel::Format pixelFormat,
- const uint32_t width,
- const uint32_t height,
- const uint32_t bufferSize )
+void BitmapCompressed::Initialize(Pixel::Format pixelFormat,
+ const uint32_t width,
+ const uint32_t height,
+ const uint32_t bufferSize)
{
- Dali::Integration::Bitmap::Initialize( pixelFormat, width, height );
- mBufferSize = bufferSize;
+ Dali::Integration::Bitmap::Initialize(pixelFormat, width, height);
+ mBufferSize = bufferSize;
mAlphaChannelUsed = false; // Default to not using Alpha as we cannot scan the pixels to look for transparent pixels. A follow-up work-item and patch will add an "assume alpha present" flag to ImageAttributes.
}
-Dali::Integration::PixelBuffer* BitmapCompressed::ReserveBufferOfSize( Pixel::Format pixelFormat,
- const uint32_t width,
- const uint32_t height,
- const uint32_t bufferSize )
+Dali::Integration::PixelBuffer* BitmapCompressed::ReserveBufferOfSize(Pixel::Format pixelFormat,
+ const uint32_t width,
+ const uint32_t height,
+ const uint32_t bufferSize)
{
// Sanity check that a not-outrageous amount of data is being passed in (indicating a client error):
DALI_ASSERT_DEBUG(bufferSize < (1U << 27U) && "That is far too much compressed data."); // 128MB of compressed data == unreasonable.
Initialize(pixelFormat, width, height, bufferSize);
- mData = reinterpret_cast< Dali::Integration::PixelBuffer* >( malloc( bufferSize ) );
+ mData = reinterpret_cast<Dali::Integration::PixelBuffer*>(malloc(bufferSize));
return mData;
}
-} //namespace Integration
+} // namespace Internal
} //namespace Dali
#define DALI_INTERNAL_COMPRESSED_BITMAP_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Internal
{
-
class BitmapCompressed;
using BitmapCompressedPtr = IntrusivePtr<BitmapCompressed>;
* Constructor
* @param[in] discardable Flag to tell the bitmap if it can delete the buffer with the pixel data.
*/
- BitmapCompressed( ResourcePolicy::Discardable discardable = ResourcePolicy::OWNED_RETAIN );
+ BitmapCompressed(ResourcePolicy::Discardable discardable = ResourcePolicy::OWNED_RETAIN);
- const Bitmap::CompressedProfile* GetCompressedProfile() const override { return this; }
- Bitmap::CompressedProfile* GetCompressedProfile() override { return this; }
+ const Bitmap::CompressedProfile* GetCompressedProfile() const override
+ {
+ return this;
+ }
+ Bitmap::CompressedProfile* GetCompressedProfile() override
+ {
+ return this;
+ }
private:
/**
* @param[in] bufferSize Buffer cpacity in pixels
*/
void Initialize(Pixel::Format pixelFormat,
- uint32_t width,
- uint32_t height,
- uint32_t bufferSize);
+ uint32_t width,
+ uint32_t height,
+ uint32_t bufferSize);
+
public:
/**
* (Re-)Allocate pixel buffer for the Bitmap. Any previously allocated pixel buffer
* @param[in] bufferSize Buffer size in bytes
* @return pixel buffer pointer
*/
- Dali::Integration::PixelBuffer* ReserveBufferOfSize( Pixel::Format pixelFormat,
- const uint32_t width,
- const uint32_t height,
- const uint32_t numBytes ) override;
+ Dali::Integration::PixelBuffer* ReserveBufferOfSize(Pixel::Format pixelFormat,
+ const uint32_t width,
+ const uint32_t height,
+ const uint32_t numBytes) override;
/**
* Get the pixel buffer size in bytes
/**
* See Dali::Integration::Bitmap::GetReleaseFunction()
*/
- ReleaseFunction GetReleaseFunction() override{ return FREE; }
+ ReleaseFunction GetReleaseFunction() override
+ {
+ return FREE;
+ }
protected:
-
/**
* A reference counted object may only be deleted by calling Unreference()
*/
~BitmapCompressed() override;
private:
-
uint32_t mBufferSize;
- BitmapCompressed(const BitmapCompressed& other); ///< defined private to prevent use
- BitmapCompressed& operator = (const BitmapCompressed& other); ///< defined private to prevent use
+ BitmapCompressed(const BitmapCompressed& other); ///< defined private to prevent use
+ BitmapCompressed& operator=(const BitmapCompressed& other); ///< defined private to prevent use
// Changes scope, should be at end of class
DALI_LOG_OBJECT_STRING_DECLARATION;
};
-} // namespace Integration
+} // namespace Internal
} // namespace Dali
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstdlib>
// INTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
-#include <dali/internal/common/core-impl.h>
#include <dali/integration-api/debug.h>
+#include <dali/internal/common/core-impl.h>
+#include <dali/public-api/object/ref-object.h>
namespace Dali
{
-
namespace Internal
{
using namespace Dali::Pixel;
-
-BitmapPackedPixel::BitmapPackedPixel( ResourcePolicy::Discardable discardable, Dali::Integration::PixelBuffer* pixBuf )
-: Bitmap( discardable, pixBuf ),
+BitmapPackedPixel::BitmapPackedPixel(ResourcePolicy::Discardable discardable, Dali::Integration::PixelBuffer* pixBuf)
+: Bitmap(discardable, pixBuf),
mBufferWidth(0),
mBufferHeight(0),
mBytesPerPixel(0)
}
// use power of two bufferWidth and bufferHeight for better performance
-Dali::Integration::PixelBuffer* BitmapPackedPixel::ReserveBuffer( Pixel::Format pixelFormat,
- uint32_t width,
- uint32_t height,
- uint32_t bufferWidth,
- uint32_t bufferHeight )
+Dali::Integration::PixelBuffer* BitmapPackedPixel::ReserveBuffer(Pixel::Format pixelFormat,
+ uint32_t width,
+ uint32_t height,
+ uint32_t bufferWidth,
+ uint32_t bufferHeight)
{
// delete existing buffer
DeletePixelBuffer();
//allocate buffer
uint32_t bufSize = mBufferWidth * mBufferHeight * mBytesPerPixel;
- mData = reinterpret_cast< Dali::Integration::PixelBuffer* >( malloc( bufSize) );
+ mData = reinterpret_cast<Dali::Integration::PixelBuffer*>(malloc(bufSize));
return mData;
}
-void BitmapPackedPixel::AssignBuffer( Pixel::Format pixelFormat,
- Dali::Integration::PixelBuffer* buffer,
- uint32_t bufferSize,
- uint32_t width,
- uint32_t height,
- uint32_t bufferWidth,
- uint32_t bufferHeight)
+void BitmapPackedPixel::AssignBuffer(Pixel::Format pixelFormat,
+ Dali::Integration::PixelBuffer* buffer,
+ uint32_t bufferSize,
+ uint32_t width,
+ uint32_t height,
+ uint32_t bufferWidth,
+ uint32_t bufferHeight)
{
- DALI_ASSERT_DEBUG( buffer );
+ DALI_ASSERT_DEBUG(buffer);
// delete existing buffer
DeletePixelBuffer();
- Initialize( pixelFormat, width, height, bufferWidth, bufferHeight );
+ Initialize(pixelFormat, width, height, bufferWidth, bufferHeight);
- // make sure the buffer size matches what is being passed in
- DALI_ASSERT_DEBUG( bufferSize == (mBufferWidth * mBufferHeight * mBytesPerPixel))
+ // make sure the buffer size matches what is being passed in
+ DALI_ASSERT_DEBUG(bufferSize == (mBufferWidth * mBufferHeight * mBytesPerPixel))
mData = buffer;
}
if(HasAlphaChannel())
{
- uint8_t* pixelBuffer=GetBuffer();
+ uint8_t* pixelBuffer = GetBuffer();
if(pixelBuffer != nullptr)
{
uint8_t* row = pixelBuffer;
- int32_t byte; int32_t bits;
+ int32_t byte;
+ int32_t bits;
Pixel::GetAlphaOffsetAndMask(mPixelFormat, byte, bits);
int32_t stride = mBufferWidth * mBytesPerPixel;
int32_t pixelsPerRow = mImageWidth;
- for(uint32_t j=0; j<mImageHeight; j++)
+ for(uint32_t j = 0; j < mImageHeight; j++)
{
uint8_t* pixels = row;
- for(int32_t i=0; i<pixelsPerRow; i++)
+ for(int32_t i = 0; i < pixelsPerRow; i++)
{
if((pixels[byte] & bits) != bits)
{
mAlphaChannelUsed = true;
- j=mImageHeight; // break out of outer loop
+ j = mImageHeight; // break out of outer loop
break;
}
- pixels+=mBytesPerPixel;
+ pixels += mBytesPerPixel;
}
row += stride;
}
DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
}
-void BitmapPackedPixel::Initialize( Pixel::Format pixelFormat,
- uint32_t width,
- uint32_t height,
- uint32_t bufferWidth,
- uint32_t bufferHeight)
+void BitmapPackedPixel::Initialize(Pixel::Format pixelFormat,
+ uint32_t width,
+ uint32_t height,
+ uint32_t bufferWidth,
+ uint32_t bufferHeight)
{
Dali::Integration::Bitmap::Initialize(pixelFormat, width, height);
- mBufferWidth = (bufferWidth != 0) ? bufferWidth : width;
- mBufferHeight = (bufferHeight != 0) ? bufferHeight : height;
+ mBufferWidth = (bufferWidth != 0) ? bufferWidth : width;
+ mBufferHeight = (bufferHeight != 0) ? bufferHeight : height;
mBytesPerPixel = Pixel::GetBytesPerPixel(pixelFormat);
DALI_ASSERT_DEBUG(mBufferWidth >= mImageWidth && mBufferHeight >= mImageHeight);
}
uint32_t BitmapPackedPixel::GetBufferStride() const
{
- return mBufferWidth*mBytesPerPixel;
+ return mBufferWidth * mBytesPerPixel;
}
-
-
-} //namespace Integration
+} // namespace Internal
} //namespace Dali
#define DALI_INTERNAL_BITMAP_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Internal
{
-
class BitmapPackedPixel;
using BitmapPackedPixelPtr = IntrusivePtr<BitmapPackedPixel>;
* Constructor
* @param[in] discardable Flag to tell the bitmap if it can delete the buffer with the pixel data.
*/
- BitmapPackedPixel( ResourcePolicy::Discardable discardable = ResourcePolicy::OWNED_RETAIN, Dali::Integration::PixelBuffer* pixBuf = nullptr );
+ BitmapPackedPixel(ResourcePolicy::Discardable discardable = ResourcePolicy::OWNED_RETAIN, Dali::Integration::PixelBuffer* pixBuf = nullptr);
public:
- const Bitmap::PackedPixelsProfile* GetPackedPixelsProfile() const override { return this; }
- Bitmap::PackedPixelsProfile* GetPackedPixelsProfile() override { return this; }
+ const Bitmap::PackedPixelsProfile* GetPackedPixelsProfile() const override
+ {
+ return this;
+ }
+ Bitmap::PackedPixelsProfile* GetPackedPixelsProfile() override
+ {
+ return this;
+ }
/**
* (Re-)Allocate pixel buffer for the Bitmap. Any previously allocated pixel buffer is deleted.
* @return pixel buffer pointer
*/
Dali::Integration::PixelBuffer* ReserveBuffer(Pixel::Format pixelFormat,
- uint32_t width,
- uint32_t height,
- uint32_t bufferWidth = 0,
- uint32_t bufferHeight = 0) override;
+ uint32_t width,
+ uint32_t height,
+ uint32_t bufferWidth = 0,
+ uint32_t bufferHeight = 0) override;
/**
* Assign a pixel buffer. Any previously allocated pixel buffer is deleted.
* @param[in] bufferWidth Buffer width (stride) in pixels
* @param[in] bufferHeight Buffer height in pixels
*/
- void AssignBuffer(Pixel::Format pixelFormat,
- Dali::Integration::PixelBuffer* buffer,
- uint32_t bufferSize,
- uint32_t width,
- uint32_t height,
- uint32_t bufferWidth = 0,
- uint32_t bufferHeight = 0) override;
+ void AssignBuffer(Pixel::Format pixelFormat,
+ Dali::Integration::PixelBuffer* buffer,
+ uint32_t bufferSize,
+ uint32_t width,
+ uint32_t height,
+ uint32_t bufferWidth = 0,
+ uint32_t bufferHeight = 0) override;
/**
* Get the width of the buffer (stride)
/**
* See Dali::Integration::Bitmap::GetReleaseFunction()
*/
- ReleaseFunction GetReleaseFunction() override{ return FREE; }
+ ReleaseFunction GetReleaseFunction() override
+ {
+ return FREE;
+ }
/**
* Get the pixel buffer stride.
void TestForTransparency() override;
protected:
-
/**
* A reference counted object may only be deleted by calling Unreference()
*/
~BitmapPackedPixel() override;
protected:
-
- uint32_t mBufferWidth; ///< Buffer width (stride) in pixels
- uint32_t mBufferHeight; ///< Buffer height in pixels
- uint32_t mBytesPerPixel; ///< Bytes per pixel
+ uint32_t mBufferWidth; ///< Buffer width (stride) in pixels
+ uint32_t mBufferHeight; ///< Buffer height in pixels
+ uint32_t mBytesPerPixel; ///< Bytes per pixel
private:
-
/**
* Initializes internal class members
* @param[in] pixelFormat pixel format
* @param[in] bufferHeight Buffer height in pixels
*/
void Initialize(Pixel::Format pixelFormat,
- uint32_t width,
- uint32_t height,
- uint32_t bufferWidth,
- uint32_t bufferHeight);
-
+ uint32_t width,
+ uint32_t height,
+ uint32_t bufferWidth,
+ uint32_t bufferHeight);
- BitmapPackedPixel(const BitmapPackedPixel& other); ///< defined private to prevent use
- BitmapPackedPixel& operator = (const BitmapPackedPixel& other); ///< defined private to prevent use
+ BitmapPackedPixel(const BitmapPackedPixel& other); ///< defined private to prevent use
+ BitmapPackedPixel& operator=(const BitmapPackedPixel& other); ///< defined private to prevent use
// Changes scope, should be at end of class
DALI_LOG_OBJECT_STRING_DECLARATION;
};
-} // namespace Integration
+} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_CONTEXT_RECOVERY_INTERFACE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* Abstract interface for Context Recovery
*
*/
class ContextRecoveryInterface
{
-
public:
-
/**
* Restore the object after context loss
*/
virtual void RecoverFromContextLoss() = 0;
protected:
-
/**
* Constructor
*/
}
private:
-
// Undefined copy constructor.
- ContextRecoveryInterface( const ContextRecoveryInterface& );
+ ContextRecoveryInterface(const ContextRecoveryInterface&);
// Undefined assignment operator.
- ContextRecoveryInterface& operator=( const ContextRecoveryInterface& );
-
+ ContextRecoveryInterface& operator=(const ContextRecoveryInterface&);
};
-
} // namespace Internal
} // namespace Dali
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
-PixelData::PixelData( uint8_t* buffer,
- uint32_t bufferSize,
- uint32_t width,
- uint32_t height,
- Pixel::Format pixelFormat,
- Dali::PixelData::ReleaseFunction releaseFunction )
-: mBuffer( buffer ),
- mBufferSize( bufferSize ),
- mWidth( width ),
- mHeight( height ),
- mPixelFormat( pixelFormat ),
- mReleaseFunction( releaseFunction )
+PixelData::PixelData(uint8_t* buffer,
+ uint32_t bufferSize,
+ uint32_t width,
+ uint32_t height,
+ Pixel::Format pixelFormat,
+ Dali::PixelData::ReleaseFunction releaseFunction)
+: mBuffer(buffer),
+ mBufferSize(bufferSize),
+ mWidth(width),
+ mHeight(height),
+ mPixelFormat(pixelFormat),
+ mReleaseFunction(releaseFunction)
{
}
PixelData::~PixelData()
{
- if( mBuffer )
+ if(mBuffer)
{
- if( mReleaseFunction == Dali::PixelData::FREE )
+ if(mReleaseFunction == Dali::PixelData::FREE)
{
- free( mBuffer );
+ free(mBuffer);
}
else
{
delete[] mBuffer;
}
}
- }
+}
-PixelDataPtr PixelData::New( uint8_t* buffer,
- uint32_t bufferSize,
- uint32_t width,
- uint32_t height,
- Pixel::Format pixelFormat,
- Dali::PixelData::ReleaseFunction releaseFunction )
+PixelDataPtr PixelData::New(uint8_t* buffer,
+ uint32_t bufferSize,
+ uint32_t width,
+ uint32_t height,
+ Pixel::Format pixelFormat,
+ Dali::PixelData::ReleaseFunction releaseFunction)
{
- return new PixelData( buffer, bufferSize, width, height, pixelFormat, releaseFunction );
+ return new PixelData(buffer, bufferSize, width, height, pixelFormat, releaseFunction);
}
uint32_t PixelData::GetWidth() const
return pixelDataBuffer;
}
+} // namespace Internal
-}// namespace Internal
-
-}// namespace Dali
+} // namespace Dali
#define DALI_INTERNAL_PIXEL_DATA_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/devel-api/images/pixel-data-devel.h>
#include <dali/public-api/images/pixel-data.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/devel-api/images/pixel-data-devel.h>
namespace Dali
{
-
namespace Internal
{
-
class PixelData;
using PixelDataPtr = IntrusivePtr<PixelData>;
class PixelData : public BaseObject
{
public:
-
/**
* @brief Create a PixelData object.
*
* @param [in] pixelFormat The pixel format
* @param [in] releaseFunction The function used to release the memory.
*/
- static PixelDataPtr New( uint8_t* buffer,
- uint32_t bufferSize,
- uint32_t width,
- uint32_t height,
- Pixel::Format pixelFormat,
- Dali::PixelData::ReleaseFunction releaseFunction);
+ static PixelDataPtr New(uint8_t* buffer,
+ uint32_t bufferSize,
+ uint32_t width,
+ uint32_t height,
+ Pixel::Format pixelFormat,
+ Dali::PixelData::ReleaseFunction releaseFunction);
/**
* @brief Constructor.
* @param [in] pixelFormat The pixel format
* @param [in] releaseFunction The function used to release the memory.
*/
- PixelData( uint8_t* buffer,
- uint32_t bufferSize,
- uint32_t width,
- uint32_t height,
- Pixel::Format pixelFormat,
- Dali::PixelData::ReleaseFunction releaseFunction );
+ PixelData(uint8_t* buffer,
+ uint32_t bufferSize,
+ uint32_t width,
+ uint32_t height,
+ Pixel::Format pixelFormat,
+ Dali::PixelData::ReleaseFunction releaseFunction);
protected:
-
/**
* @brief Destructor.
*
~PixelData() override;
public:
-
/**
* Get the width of the buffer in pixels.
* @return The width of the buffer in pixels
DevelPixelData::PixelDataBuffer ReleaseBuffer();
private:
-
/*
* Undefined copy constructor.
*/
/*
* Undefined assignment operator.
*/
- PixelData& operator = (const PixelData& other);
+ PixelData& operator=(const PixelData& other);
private:
-
- uint8_t* mBuffer; ///< The raw pixel data
- uint32_t mBufferSize; ///< Buffer sized in bytes
- uint32_t mWidth; ///< Buffer width in pixels
- uint32_t mHeight; ///< Buffer height in pixels
- Pixel::Format mPixelFormat; ///< Pixel format
- Dali::PixelData::ReleaseFunction mReleaseFunction; ///< Function for releasing memory
+ uint8_t* mBuffer; ///< The raw pixel data
+ uint32_t mBufferSize; ///< Buffer sized in bytes
+ uint32_t mWidth; ///< Buffer width in pixels
+ uint32_t mHeight; ///< Buffer height in pixels
+ Pixel::Format mPixelFormat; ///< Pixel format
+ Dali::PixelData::ReleaseFunction mReleaseFunction; ///< Function for releasing memory
};
} // namespace Internal
/**
* Helper methods for public API
*/
-inline Internal::PixelData& GetImplementation( Dali::PixelData& handle )
+inline Internal::PixelData& GetImplementation(Dali::PixelData& handle)
{
- DALI_ASSERT_ALWAYS( handle && "handle is empty" );
+ DALI_ASSERT_ALWAYS(handle && "handle is empty");
BaseObject& object = handle.GetBaseObject();
- return static_cast<Internal::PixelData&>( object );
+ return static_cast<Internal::PixelData&>(object);
}
-inline const Internal::PixelData& GetImplementation( const Dali::PixelData& handle )
+inline const Internal::PixelData& GetImplementation(const Dali::PixelData& handle)
{
- DALI_ASSERT_ALWAYS( handle && "handle is empty" );
+ DALI_ASSERT_ALWAYS(handle && "handle is empty");
const BaseObject& object = handle.GetBaseObject();
- return static_cast<const Internal::PixelData&>( object );
+ return static_cast<const Internal::PixelData&>(object);
}
} // namespace Dali
#define DALI_DEFAULT_PROPERTY_METADATA_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
struct PropertyDetails
{
- std::string_view name; ///< The name of the property.
- Property::Index enumIndex; ///< Used to check the index is correct within a debug build.
- Property::Type type; ///< The property type.
- bool writable; ///< Whether the property is writable
- bool animatable; ///< Whether the property is animatable.
- bool constraintInput; ///< Whether the property can be used as an input to a constraint.
+ std::string_view name; ///< The name of the property.
+ Property::Index enumIndex; ///< Used to check the index is correct within a debug build.
+ Property::Type type; ///< The property type.
+ bool writable; ///< Whether the property is writable
+ bool animatable; ///< Whether the property is animatable.
+ bool constraintInput; ///< Whether the property can be used as an input to a constraint.
};
/**
#define DALI_INTERNAL_RENDER_TASK_DEFAULTS_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
class Actor;
class CameraActor;
class RenderTaskDefaults
{
public:
-
/**
* Retrieve the default root actor.
* @return The default root actor.
virtual CameraActor& GetDefaultCameraActor() = 0;
protected:
-
/**
* Virtual destructor
*/
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstring> // for strcmp
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/object/type-registry.h>
-#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/actors/camera-actor-impl.h>
+#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/event/common/projection.h>
#include <dali/internal/event/common/property-helper.h>
-#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/event/common/scene-impl.h>
-#include <dali/internal/event/common/projection.h>
+#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/update/nodes/node.h>
#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/object/type-registry.h>
#if defined(DEBUG_ENABLED)
namespace
namespace Dali
{
-
namespace Internal
{
-
namespace // For internal properties
{
-
// Properties
// Name Type writable animatable constraint-input enum for index-checking
DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "viewportPosition", VECTOR2, true, true, true, Dali::RenderTask::Property::VIEWPORT_POSITION )
-DALI_PROPERTY( "viewportSize", VECTOR2, true, true, true, Dali::RenderTask::Property::VIEWPORT_SIZE )
-DALI_PROPERTY( "clearColor", VECTOR4, true, true, true, Dali::RenderTask::Property::CLEAR_COLOR )
-DALI_PROPERTY( "requiresSync", BOOLEAN, true, false, false, Dali::RenderTask::Property::REQUIRES_SYNC )
-DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX, RenderTaskDefaultProperties )
+DALI_PROPERTY("viewportPosition", VECTOR2, true, true, true, Dali::RenderTask::Property::VIEWPORT_POSITION)
+DALI_PROPERTY("viewportSize", VECTOR2, true, true, true, Dali::RenderTask::Property::VIEWPORT_SIZE)
+DALI_PROPERTY("clearColor", VECTOR4, true, true, true, Dali::RenderTask::Property::CLEAR_COLOR)
+DALI_PROPERTY("requiresSync", BOOLEAN, true, false, false, Dali::RenderTask::Property::REQUIRES_SYNC)
+DALI_PROPERTY_TABLE_END(DEFAULT_OBJECT_PROPERTY_START_INDEX, RenderTaskDefaultProperties)
// Signals
const char* const SIGNAL_FINISHED = "finished";
-TypeRegistration mType( typeid( Dali::RenderTask ), typeid( Dali::BaseHandle ), nullptr, RenderTaskDefaultProperties );
+TypeRegistration mType(typeid(Dali::RenderTask), typeid(Dali::BaseHandle), nullptr, RenderTaskDefaultProperties);
-SignalConnectorType signalConnector1( mType, SIGNAL_FINISHED, &RenderTask::DoConnectSignal );
+SignalConnectorType signalConnector1(mType, SIGNAL_FINISHED, &RenderTask::DoConnectSignal);
} // Unnamed namespace
-RenderTaskPtr RenderTask::New( Actor* sourceActor, CameraActor* cameraActor, RenderTaskList& renderTaskList )
+RenderTaskPtr RenderTask::New(Actor* sourceActor, CameraActor* cameraActor, RenderTaskList& renderTaskList)
{
// create scene object first so it's guaranteed to exist for the event side
auto sceneObject = SceneGraph::RenderTask::New();
// pass the pointer to base for message passing
- RenderTaskPtr task( new RenderTask( sceneObject, renderTaskList ) );
+ RenderTaskPtr task(new RenderTask(sceneObject, renderTaskList));
// transfer scene object ownership to update manager
- const SceneGraph::RenderTaskList& parentSceneObject = renderTaskList.GetSceneObject();
- OwnerPointer< SceneGraph::RenderTask > transferOwnership( sceneObject );
- AddTaskMessage( task->GetEventThreadServices(), parentSceneObject, transferOwnership );
+ const SceneGraph::RenderTaskList& parentSceneObject = renderTaskList.GetSceneObject();
+ OwnerPointer<SceneGraph::RenderTask> transferOwnership(sceneObject);
+ AddTaskMessage(task->GetEventThreadServices(), parentSceneObject, transferOwnership);
// Set the default source & camera actors
- task->SetSourceActor( sourceActor );
- task->SetCameraActor( cameraActor );
+ task->SetSourceActor(sourceActor);
+ task->SetCameraActor(cameraActor);
// no need for additional messages as scene objects defaults match ours
return task;
}
-void RenderTask::SetSourceActor( Actor* actor )
+void RenderTask::SetSourceActor(Actor* actor)
{
- mSourceActor.SetActor( actor );
- if ( actor )
+ mSourceActor.SetActor(actor);
+ if(actor)
{
- SetSourceNodeMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), &actor->GetNode() );
+ SetSourceNodeMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), &actor->GetNode());
}
else
{
- SetSourceNodeMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), nullptr );
+ SetSourceNodeMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), nullptr);
}
// set the actor on exclusive container for hit testing
- mRenderTaskList.SetExclusive( this, mExclusive );
+ mRenderTaskList.SetExclusive(this, mExclusive);
}
Actor* RenderTask::GetSourceActor() const
return mSourceActor.GetActor();
}
-void RenderTask::SetExclusive( bool exclusive )
+void RenderTask::SetExclusive(bool exclusive)
{
- if ( mExclusive != exclusive )
+ if(mExclusive != exclusive)
{
mExclusive = exclusive;
- mRenderTaskList.SetExclusive( this, exclusive );
+ mRenderTaskList.SetExclusive(this, exclusive);
// scene object is being used in a separate thread; queue a message to set the value
- SetExclusiveMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), mExclusive );
+ SetExclusiveMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), mExclusive);
}
}
return mExclusive;
}
-void RenderTask::SetInputEnabled( bool enabled )
+void RenderTask::SetInputEnabled(bool enabled)
{
mInputEnabled = enabled;
}
return mInputEnabled;
}
-void RenderTask::SetCameraActor( CameraActor* cameraActor )
+void RenderTask::SetCameraActor(CameraActor* cameraActor)
{
- mCameraActor.SetActor( cameraActor );
- if( cameraActor )
+ mCameraActor.SetActor(cameraActor);
+ if(cameraActor)
{
- SetCameraMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), &cameraActor->GetNode(), cameraActor->GetCamera() );
+ SetCameraMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), &cameraActor->GetNode(), cameraActor->GetCamera());
}
else
{
- SetCameraMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), nullptr, nullptr );
+ SetCameraMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), nullptr, nullptr);
}
// set the actor on exclusive container for hit testing
- mRenderTaskList.SetExclusive( this, mExclusive );
+ mRenderTaskList.SetExclusive(this, mExclusive);
}
CameraActor* RenderTask::GetCameraActor() const
{
- if( mCameraActor.GetActor() )
+ if(mCameraActor.GetActor())
{
- return static_cast< CameraActor* >( mCameraActor.GetActor() );
+ return static_cast<CameraActor*>(mCameraActor.GetActor());
}
return nullptr;
}
-void RenderTask::SetFrameBuffer( FrameBufferPtr frameBuffer )
+void RenderTask::SetFrameBuffer(FrameBufferPtr frameBuffer)
{
mFrameBuffer = frameBuffer;
- Render::FrameBuffer* renderFrameBufferPtr( nullptr );
- if( frameBuffer )
+ Render::FrameBuffer* renderFrameBufferPtr(nullptr);
+ if(frameBuffer)
{
renderFrameBufferPtr = mFrameBuffer->GetRenderObject();
}
- SetFrameBufferMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), renderFrameBufferPtr );
+ SetFrameBufferMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), renderFrameBufferPtr);
}
FrameBuffer* RenderTask::GetFrameBuffer() const
return mFrameBuffer.Get();
}
-void RenderTask::SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction )
+void RenderTask::SetScreenToFrameBufferFunction(ScreenToFrameBufferFunction conversionFunction)
{
mScreenToFrameBufferFunction = conversionFunction;
}
return mScreenToFrameBufferFunction;
}
-void RenderTask::SetScreenToFrameBufferMappingActor( Dali::Actor& mappingActor )
+void RenderTask::SetScreenToFrameBufferMappingActor(Dali::Actor& mappingActor)
{
- mInputMappingActor = WeakHandle<Dali::Actor>( mappingActor );
+ mInputMappingActor = WeakHandle<Dali::Actor>(mappingActor);
}
Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const
{
mViewportPosition = value;
- BakeViewportPositionMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), value );
+ BakeViewportPositionMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), value);
}
Vector2 RenderTask::GetCurrentViewportPosition() const
{
- return GetRenderTaskSceneObject().GetViewportPosition( GetEventThreadServices().GetEventBufferIndex() );
+ return GetRenderTaskSceneObject().GetViewportPosition(GetEventThreadServices().GetEventBufferIndex());
}
void RenderTask::SetViewportSize(const Vector2& value)
{
mViewportSize = value;
- BakeViewportSizeMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), value );
+ BakeViewportSizeMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), value);
}
Vector2 RenderTask::GetCurrentViewportSize() const
{
- return GetRenderTaskSceneObject().GetViewportSize( GetEventThreadServices().GetEventBufferIndex() );
+ return GetRenderTaskSceneObject().GetViewportSize(GetEventThreadServices().GetEventBufferIndex());
}
-void RenderTask::SetViewport( const Viewport& viewport )
+void RenderTask::SetViewport(const Viewport& viewport)
{
- SetViewportPosition( Vector2( static_cast<float>( viewport.x ), static_cast<float>( viewport.y ) ) );
- SetViewportSize( Vector2( static_cast<float>( viewport.width ), static_cast<float>( viewport.height ) ) );
+ SetViewportPosition(Vector2(static_cast<float>(viewport.x), static_cast<float>(viewport.y)));
+ SetViewportSize(Vector2(static_cast<float>(viewport.width), static_cast<float>(viewport.height)));
}
-void RenderTask::GetViewport( Viewport& viewPort ) const
+void RenderTask::GetViewport(Viewport& viewPort) const
{
BufferIndex bufferIndex = GetEventThreadServices().GetEventBufferIndex();
- if( !GetRenderTaskSceneObject().GetViewportEnabled( bufferIndex ) )
+ if(!GetRenderTaskSceneObject().GetViewportEnabled(bufferIndex))
{
Internal::Stage* stage = Internal::Stage::GetCurrent();
- if ( stage )
+ if(stage)
{
- Vector2 size( stage->GetSize() );
- Actor* sourceActor = mSourceActor.GetActor();
- if ( sourceActor && sourceActor->OnScene() )
+ Vector2 size(stage->GetSize());
+ Actor* sourceActor = mSourceActor.GetActor();
+ if(sourceActor && sourceActor->OnScene())
{
Scene& scene = sourceActor->GetScene();
- size = scene.GetSize();
+ size = scene.GetSize();
}
viewPort.x = viewPort.y = 0;
- viewPort.width = static_cast<int32_t>( size.width ); // truncated
- viewPort.height = static_cast<int32_t>( size.height ); // truncated
+ viewPort.width = static_cast<int32_t>(size.width); // truncated
+ viewPort.height = static_cast<int32_t>(size.height); // truncated
}
}
else
{
const Vector2& position = GetRenderTaskSceneObject().GetViewportPosition(bufferIndex);
- const Vector2& size = GetRenderTaskSceneObject().GetViewportSize(bufferIndex);
- viewPort.x = static_cast<int32_t>( position.x ); // truncated
- viewPort.y = static_cast<int32_t>( position.y ); // truncated
- viewPort.width = static_cast<int32_t>( size.width ); // truncated
- viewPort.height = static_cast<int32_t>( size.height ); // truncated
+ const Vector2& size = GetRenderTaskSceneObject().GetViewportSize(bufferIndex);
+ viewPort.x = static_cast<int32_t>(position.x); // truncated
+ viewPort.y = static_cast<int32_t>(position.y); // truncated
+ viewPort.width = static_cast<int32_t>(size.width); // truncated
+ viewPort.height = static_cast<int32_t>(size.height); // truncated
}
}
-void RenderTask::SetClearColor( const Vector4& color )
+void RenderTask::SetClearColor(const Vector4& color)
{
- if ( mClearColor != color )
+ if(mClearColor != color)
{
mClearColor = color;
// scene object is being used in a separate thread; queue a message to set the value
- BakeClearColorMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), color );
+ BakeClearColorMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), color);
}
}
const Vector4& RenderTask::GetClearColor() const
{
- return GetRenderTaskSceneObject().GetClearColor( GetEventThreadServices().GetEventBufferIndex() );
+ return GetRenderTaskSceneObject().GetClearColor(GetEventThreadServices().GetEventBufferIndex());
}
-void RenderTask::SetSyncRequired( bool requiresSync )
+void RenderTask::SetSyncRequired(bool requiresSync)
{
- if( mRequiresSync != requiresSync )
+ if(mRequiresSync != requiresSync)
{
mRequiresSync = requiresSync;
// scene object is being used in a separate thread; queue a message to set the value
- SetSyncRequiredMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), requiresSync );
+ SetSyncRequiredMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), requiresSync);
}
}
return mRequiresSync;
}
-void RenderTask::SetClearEnabled( bool enabled )
+void RenderTask::SetClearEnabled(bool enabled)
{
- if ( mClearEnabled != enabled )
+ if(mClearEnabled != enabled)
{
mClearEnabled = enabled;
// scene object is being used in a separate thread; queue a message to set the value
- SetClearEnabledMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), mClearEnabled );
+ SetClearEnabledMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), mClearEnabled);
}
}
return mClearEnabled;
}
-void RenderTask::SetCullMode( bool mode )
+void RenderTask::SetCullMode(bool mode)
{
- if ( mCullMode != mode )
+ if(mCullMode != mode)
{
mCullMode = mode;
// scene object is being used in a separate thread; queue a message to set the value
- SetCullModeMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), mCullMode );
+ SetCullModeMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), mCullMode);
}
}
return mCullMode;
}
-void RenderTask::SetRefreshRate( uint32_t refreshRate )
+void RenderTask::SetRefreshRate(uint32_t refreshRate)
{
DALI_LOG_TRACE_METHOD_FMT(gLogRender, "this:%p rate:%d\n", this, refreshRate);
DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::SetRefreshRate(this:%p, %d)\n", this, refreshRate);
// Note - even when refreshRate is the same as mRefreshRate, a message should be sent
// sceneObject is being used in a separate thread; queue a message to set the value
- SetRefreshRateMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), refreshRate );
+ SetRefreshRateMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), refreshRate);
}
uint32_t RenderTask::GetRefreshRate() const
return mRefreshRate;
}
-bool RenderTask::IsHittable( Vector2& screenCoords ) const
+bool RenderTask::IsHittable(Vector2& screenCoords) const
{
// True when input is enabled, source & camera actor are valid
- bool inputEnabled( false );
+ bool inputEnabled(false);
- Actor* sourceActor = GetSourceActor();
+ Actor* sourceActor = GetSourceActor();
CameraActor* cameraActor = GetCameraActor();
- if ( mInputEnabled &&
- nullptr != sourceActor &&
- sourceActor->OnScene() &&
- nullptr != cameraActor &&
- cameraActor->OnScene() )
+ if(mInputEnabled &&
+ nullptr != sourceActor &&
+ sourceActor->OnScene() &&
+ nullptr != cameraActor &&
+ cameraActor->OnScene())
{
// If the actors are rendered off-screen, then the screen coordinates must be converted
// and the conversion function will tell us if they are inside or outside
- if ( TranslateCoordinates( screenCoords ) )
+ if(TranslateCoordinates(screenCoords))
{
// This is a suitable render-task for input handling
inputEnabled = true;
return inputEnabled;
}
-bool RenderTask::TranslateCoordinates( Vector2& screenCoords ) const
+bool RenderTask::TranslateCoordinates(Vector2& screenCoords) const
{
// return true for on-screen tasks
- bool inside( true );
+ bool inside(true);
// If the actors are rendered off-screen, then the screen coordinates must be converted
// the function should only be called for offscreen tasks
Dali::Actor mappingActor = GetScreenToFrameBufferMappingActor();
- if( mFrameBuffer && mappingActor )
+ if(mFrameBuffer && mappingActor)
{
- Internal::Actor* inputMappingActor = &GetImplementation( mappingActor );
- CameraActor* localCamera = GetCameraActor();
- StagePtr stage = Stage::GetCurrent();
- if ( stage )
+ Internal::Actor* inputMappingActor = &GetImplementation(mappingActor);
+ CameraActor* localCamera = GetCameraActor();
+ StagePtr stage = Stage::GetCurrent();
+ if(stage)
{
- Vector2 size( stage->GetSize() );
- CameraActor* defaultCamera( &stage->GetDefaultCameraActor() );
- Actor* sourceActor = mSourceActor.GetActor();
- if ( sourceActor && sourceActor->OnScene() )
+ Vector2 size(stage->GetSize());
+ CameraActor* defaultCamera(&stage->GetDefaultCameraActor());
+ Actor* sourceActor = mSourceActor.GetActor();
+ if(sourceActor && sourceActor->OnScene())
{
- Scene& scene = sourceActor->GetScene();
- size = scene.GetSize();
+ Scene& scene = sourceActor->GetScene();
+ size = scene.GetSize();
defaultCamera = &scene.GetDefaultCameraActor();
}
- if( localCamera )
+ if(localCamera)
{
Viewport viewport;
viewport.x = viewport.y = 0;
- viewport.width = static_cast<int32_t>( size.width ); // truncated
- viewport.height = static_cast<int32_t>( size.height ); // truncated
+ viewport.width = static_cast<int32_t>(size.width); // truncated
+ viewport.height = static_cast<int32_t>(size.height); // truncated
float localX, localY;
- inside = inputMappingActor->ScreenToLocal(defaultCamera->GetViewMatrix(), defaultCamera->GetProjectionMatrix(), viewport, localX, localY, screenCoords.x, screenCoords.y);
+ inside = inputMappingActor->ScreenToLocal(defaultCamera->GetViewMatrix(), defaultCamera->GetProjectionMatrix(), viewport, localX, localY, screenCoords.x, screenCoords.y);
Vector3 actorSize = inputMappingActor->GetCurrentSize();
- if( inside && localX >= 0.f && localX <= actorSize.x && localY >= 0.f && localY <= actorSize.y)
+ if(inside && localX >= 0.f && localX <= actorSize.x && localY >= 0.f && localY <= actorSize.y)
{
screenCoords.x = localX;
screenCoords.y = localY;
}
}
}
- else if ( mFrameBuffer && mScreenToFrameBufferFunction )
+ else if(mFrameBuffer && mScreenToFrameBufferFunction)
{
- inside = mScreenToFrameBufferFunction( screenCoords );
+ inside = mScreenToFrameBufferFunction(screenCoords);
}
return inside;
}
-bool RenderTask::WorldToViewport(const Vector3 &position, float& viewportX, float& viewportY) const
+bool RenderTask::WorldToViewport(const Vector3& position, float& viewportX, float& viewportY) const
{
CameraActor* cam = GetCameraActor();
Vector4 viewportPosition;
Viewport viewport;
- GetViewport( viewport );
+ GetViewport(viewport);
bool ok = ProjectFull(pos,
cam->GetViewMatrix(),
cam->GetProjectionMatrix(),
- static_cast<float>( viewport.x ), // truncated
- static_cast<float>( viewport.y ), // truncated
- static_cast<float>( viewport.width ), // truncated
- static_cast<float>( viewport.height ), // truncated
+ static_cast<float>(viewport.x), // truncated
+ static_cast<float>(viewport.y), // truncated
+ static_cast<float>(viewport.width), // truncated
+ static_cast<float>(viewport.height), // truncated
viewportPosition);
if(ok)
{
return ok;
}
-bool RenderTask::ViewportToLocal(Actor* actor, float viewportX, float viewportY, float &localX, float &localY) const
+bool RenderTask::ViewportToLocal(Actor* actor, float viewportX, float viewportY, float& localX, float& localY) const
{
- return actor->ScreenToLocal( *this, localX, localY, viewportX, viewportY );
+ return actor->ScreenToLocal(*this, localX, localY, viewportX, viewportY);
}
const SceneGraph::RenderTask& RenderTask::GetRenderTaskSceneObject() const
{
- return *static_cast<const SceneGraph::RenderTask*>( mUpdateObject );
+ return *static_cast<const SceneGraph::RenderTask*>(mUpdateObject);
}
RenderTaskList& RenderTask::GetRenderTaskList() const
******************************** PROPERTY METHODS **************************
********************************************************************************/
-void RenderTask::SetDefaultProperty( Property::Index index, const Property::Value& property )
+void RenderTask::SetDefaultProperty(Property::Index index, const Property::Value& property)
{
- switch ( index )
+ switch(index)
{
case Dali::RenderTask::Property::VIEWPORT_POSITION:
{
- SetViewportPosition( property.Get<Vector2>() );
+ SetViewportPosition(property.Get<Vector2>());
break;
}
case Dali::RenderTask::Property::VIEWPORT_SIZE:
{
- SetViewportSize( property.Get<Vector2>() );
+ SetViewportSize(property.Get<Vector2>());
break;
}
case Dali::RenderTask::Property::CLEAR_COLOR:
{
- SetClearColor( property.Get<Vector4>() );
+ SetClearColor(property.Get<Vector4>());
break;
}
case Dali::RenderTask::Property::REQUIRES_SYNC:
{
- SetSyncRequired( property.Get<bool>() );
+ SetSyncRequired(property.Get<bool>());
break;
}
default:
{
Property::Value value;
- switch ( index )
+ switch(index)
{
case Dali::RenderTask::Property::VIEWPORT_POSITION:
{
return value;
}
-Property::Value RenderTask::GetDefaultPropertyCurrentValue( Property::Index index ) const
+Property::Value RenderTask::GetDefaultPropertyCurrentValue(Property::Index index) const
{
Property::Value value;
- switch ( index )
+ switch(index)
{
case Dali::RenderTask::Property::VIEWPORT_POSITION:
{
return value;
}
-void RenderTask::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
+void RenderTask::OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType)
{
- switch( animationType )
+ switch(animationType)
{
case Animation::TO:
case Animation::BETWEEN:
{
- switch ( index )
+ switch(index)
{
case Dali::RenderTask::Property::VIEWPORT_POSITION:
{
- value.Get( mViewportPosition );
+ value.Get(mViewportPosition);
break;
}
case Dali::RenderTask::Property::VIEWPORT_SIZE:
{
- value.Get( mViewportSize );
+ value.Get(mViewportSize);
break;
}
case Dali::RenderTask::Property::CLEAR_COLOR:
{
- value.Get( mClearColor );
+ value.Get(mClearColor);
break;
}
case Dali::RenderTask::Property::REQUIRES_SYNC:
case Animation::BY:
{
- switch ( index )
+ switch(index)
{
case Dali::RenderTask::Property::VIEWPORT_POSITION:
{
- AdjustValue< Vector2 >( mViewportPosition, value );
+ AdjustValue<Vector2>(mViewportPosition, value);
break;
}
case Dali::RenderTask::Property::VIEWPORT_SIZE:
{
- AdjustValue< Vector2 >( mViewportSize, value );
+ AdjustValue<Vector2>(mViewportSize, value);
break;
}
case Dali::RenderTask::Property::CLEAR_COLOR:
{
- AdjustValue< Vector4 >( mClearColor, value );
+ AdjustValue<Vector4>(mClearColor, value);
break;
}
case Dali::RenderTask::Property::REQUIRES_SYNC:
}
}
-const SceneGraph::PropertyBase* RenderTask::GetSceneObjectAnimatableProperty( Property::Index index ) const
+const SceneGraph::PropertyBase* RenderTask::GetSceneObjectAnimatableProperty(Property::Index index) const
{
- const SceneGraph::PropertyBase* property( nullptr );
+ const SceneGraph::PropertyBase* property(nullptr);
- switch ( index )
+ switch(index)
{
case Dali::RenderTask::Property::VIEWPORT_POSITION:
{
break;
}
}
- if( !property )
+ if(!property)
{
// not our property, ask base
- property = Object::GetSceneObjectAnimatableProperty( index );
+ property = Object::GetSceneObjectAnimatableProperty(index);
}
return property;
}
-const PropertyInputImpl* RenderTask::GetSceneObjectInputProperty( Property::Index index ) const
+const PropertyInputImpl* RenderTask::GetSceneObjectInputProperty(Property::Index index) const
{
// animatable properties are input as well, Object::GetSceneObjectInputProperty does the same so no need to call it
- return GetSceneObjectAnimatableProperty( index );
+ return GetSceneObjectAnimatableProperty(index);
}
bool RenderTask::HasFinished()
{
- bool finished = false;
- const uint32_t counter = GetRenderTaskSceneObject().GetRenderedOnceCounter();
+ bool finished = false;
+ const uint32_t counter = GetRenderTaskSceneObject().GetRenderedOnceCounter();
- if( mRefreshOnceCounter < counter )
+ if(mRefreshOnceCounter < counter)
{
- finished = true;
+ finished = true;
mRefreshOnceCounter = counter;
}
- DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::HasFinished()=%s SCRT:%p SC\n", finished?"T":"F", &GetRenderTaskSceneObject());
+ DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::HasFinished()=%s SCRT:%p SC\n", finished ? "T" : "F", &GetRenderTaskSceneObject());
return finished;
}
{
DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::EmitSignalFinish(this:%p)\n", this);
- if( !mSignalFinished.Empty() )
+ if(!mSignalFinished.Empty())
{
- Dali::RenderTask handle( this );
- mSignalFinished.Emit(handle );
+ Dali::RenderTask handle(this);
+ mSignalFinished.Emit(handle);
}
}
return mSignalFinished;
}
-bool RenderTask::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool RenderTask::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( true );
- RenderTask* renderTask = static_cast< RenderTask* >(object); // TypeRegistry guarantees that this is the correct type.
+ bool connected(true);
+ RenderTask* renderTask = static_cast<RenderTask*>(object); // TypeRegistry guarantees that this is the correct type.
- if ( 0 == strcmp( signalName.c_str(), SIGNAL_FINISHED ) )
+ if(0 == strcmp(signalName.c_str(), SIGNAL_FINISHED))
{
- renderTask->FinishedSignal().Connect( tracker, functor );
+ renderTask->FinishedSignal().Connect(tracker, functor);
}
else
{
return connected;
}
-RenderTask::RenderTask( const SceneGraph::RenderTask* sceneObject, RenderTaskList& renderTaskList )
-: Object( sceneObject ),
+RenderTask::RenderTask(const SceneGraph::RenderTask* sceneObject, RenderTaskList& renderTaskList)
+: Object(sceneObject),
mSourceActor(),
mCameraActor(),
mInputMappingActor(),
- mRenderTaskList( renderTaskList ),
- mClearColor( Dali::RenderTask::DEFAULT_CLEAR_COLOR ),
- mViewportPosition( Vector2::ZERO ),
- mViewportSize( Vector2::ZERO ),
- mRefreshRate( Dali::RenderTask::DEFAULT_REFRESH_RATE ),
- mRefreshOnceCounter( 0u ),
- mScreenToFrameBufferFunction( Dali::RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION ),
- mExclusive( Dali::RenderTask::DEFAULT_EXCLUSIVE ),
- mInputEnabled( Dali::RenderTask::DEFAULT_INPUT_ENABLED ),
- mClearEnabled( Dali::RenderTask::DEFAULT_CLEAR_ENABLED ),
- mCullMode( Dali::RenderTask::DEFAULT_CULL_MODE ),
- mRequiresSync( false )
+ mRenderTaskList(renderTaskList),
+ mClearColor(Dali::RenderTask::DEFAULT_CLEAR_COLOR),
+ mViewportPosition(Vector2::ZERO),
+ mViewportSize(Vector2::ZERO),
+ mRefreshRate(Dali::RenderTask::DEFAULT_REFRESH_RATE),
+ mRefreshOnceCounter(0u),
+ mScreenToFrameBufferFunction(Dali::RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION),
+ mExclusive(Dali::RenderTask::DEFAULT_EXCLUSIVE),
+ mInputEnabled(Dali::RenderTask::DEFAULT_INPUT_ENABLED),
+ mClearEnabled(Dali::RenderTask::DEFAULT_CLEAR_ENABLED),
+ mCullMode(Dali::RenderTask::DEFAULT_CULL_MODE),
+ mRequiresSync(false)
{
DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::RenderTask(this:%p)\n", this);
// scene object handles observation of source and camera
#define DALI_INTERNAL_RENDER_TASK_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/object/weak-handle.h>
#include <dali/public-api/render-tasks/render-task.h>
+
#include <dali/internal/event/common/object-impl.h>
-#include <dali/internal/event/rendering/frame-buffer-impl.h>
-#include <dali/internal/event/render-tasks/render-task-list-impl.h>
#include <dali/internal/event/events/actor-observer.h>
+#include <dali/internal/event/render-tasks/render-task-list-impl.h>
+#include <dali/internal/event/rendering/frame-buffer-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class Actor;
class CameraActor;
class EventThreadServices;
class RenderTaskList;
class RenderTask;
class Camera;
-}
+} // namespace SceneGraph
using RenderTaskPtr = IntrusivePtr<RenderTask>;
class RenderTask : public Object
{
public:
-
using ScreenToFrameBufferFunction = Dali::RenderTask::ScreenToFrameBufferFunction;
/**
* @param[in] renderTaskList The render task list.
* @return The created render task
*/
- static RenderTaskPtr New( Actor* sourceActor, CameraActor* cameraActor, RenderTaskList& renderTaskList );
+ static RenderTaskPtr New(Actor* sourceActor, CameraActor* cameraActor, RenderTaskList& renderTaskList);
/**
* @copydoc Dali::RenderTask::SetSourceActor()
*/
- void SetSourceActor( Actor* actor );
+ void SetSourceActor(Actor* actor);
/**
* @copydoc Dali::RenderTask::GetSourceActor()
/**
* @copydoc Dali::RenderTask::SetExclusive()
*/
- void SetExclusive( bool exclusive );
+ void SetExclusive(bool exclusive);
/**
* @copydoc Dali::RenderTask::IsExclusive()
/**
* @copydoc Dali::RenderTask::SetInputEnabled()
*/
- void SetInputEnabled( bool enabled );
+ void SetInputEnabled(bool enabled);
/**
* @copydoc Dali::RenderTask::GetInputEnabled()
/**
* @copydoc Dali::RenderTask::SetCameraActor()
*/
- void SetCameraActor( CameraActor* cameraActor );
+ void SetCameraActor(CameraActor* cameraActor);
/**
* @copydoc Dali::RenderTask::GetCameraActor()
/**
* @copydoc Dali::RenderTask::SetFrameBuffer()
*/
- void SetFrameBuffer( FrameBufferPtr frameBuffer );
+ void SetFrameBuffer(FrameBufferPtr frameBuffer);
- /**
+ /**
* @copydoc Dali::RenderTask::GetFrameBuffer
*/
- FrameBuffer* GetFrameBuffer() const;
+ FrameBuffer* GetFrameBuffer() const;
/**
* @copydoc Dali::RenderTask::SetScreenToFrameBufferFunction
*/
- void SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction );
+ void SetScreenToFrameBufferFunction(ScreenToFrameBufferFunction conversionFunction);
/**
* @copydoc Dali::RenderTask::GetScreenToFrameBufferFunction
/**
* copydoc Dali::RenderTask::SetScreenToFrameBufferMappingActor
*/
- void SetScreenToFrameBufferMappingActor( Dali::Actor& mappingActor );
+ void SetScreenToFrameBufferMappingActor(Dali::Actor& mappingActor);
/**
* copydoc Dali::RenderTask::GetScreenToFrameBufferMAppingActor
/**
* @copydoc Dali::RenderTask::SetViewport()
*/
- void SetViewport( const Viewport& viewport );
+ void SetViewport(const Viewport& viewport);
/**
* @param[out] viewPort instance to copy the values into
*/
- void GetViewport( Viewport& viewPort ) const;
+ void GetViewport(Viewport& viewPort) const;
/**
* @copydoc Dali::RenderTask::SetClearColor()
*/
- void SetClearColor( const Vector4& color );
+ void SetClearColor(const Vector4& color);
/**
* @copydoc Dali::RenderTask::GetClearColor()
* Indicate whether GL sync is required for native render target.
* @param[in] requiresSync whether GL sync is required.
*/
- void SetSyncRequired( bool requiresSync );
+ void SetSyncRequired(bool requiresSync);
/**
* Query whether the sync object is required for native render target.
* @return True if the sync object is required, false otherwise.
*/
- bool IsSyncRequired() const;
+ bool IsSyncRequired() const;
/**
* @copydoc Dali::RenderTask::SetClearEnabled()
*/
- void SetClearEnabled( bool enabled );
+ void SetClearEnabled(bool enabled);
/**
* @copydoc Dali::RenderTask::GetClearEnabled()
/**
* @copydoc Dali::RenderTask::SetCullMode()
*/
- void SetCullMode( bool mode );
+ void SetCullMode(bool mode);
/**
* @copydoc Dali::RenderTask::GetCullMode()
/**
* @copydoc Dali::RenderTask::SetRefreshRate()
*/
- void SetRefreshRate( uint32_t refreshRate );
+ void SetRefreshRate(uint32_t refreshRate);
/**
* @copydoc Dali::RenderTask::GetRefreshRate()
* @param[in,out] screenCoords The screen coordinate, which may be converted (for hit-testing actors which are rendered off-screen).
* @return True the render-task can be used for input-handling; otherwise the output parameters are not valid.
*/
- bool IsHittable( Vector2& screenCoords ) const;
+ bool IsHittable(Vector2& screenCoords) const;
/**
* Translates screen coordinates to render task coordinates for offscreen render tasks
* @param[in,out] screenCoords The screen coordinates, which may be converted (for off-screen).
* @return false if the conversion function decides the coordinates are not inside. returns true if there is no conversion function
*/
- bool TranslateCoordinates( Vector2& screenCoords ) const;
+ bool TranslateCoordinates(Vector2& screenCoords) const;
/**
* @copydoc Dali::RenderTask::WorldToViewport()
*/
- bool WorldToViewport(const Vector3 &position, float& viewportX, float& viewportY) const;
+ bool WorldToViewport(const Vector3& position, float& viewportX, float& viewportY) const;
/**
* @copydoc Dali::RenderTask::ViewportToLocal()
*/
- bool ViewportToLocal(Actor* actor, float viewportX, float viewportY, float &localX, float &localY) const;
+ bool ViewportToLocal(Actor* actor, float viewportX, float viewportY, float& localX, float& localY) const;
public: // Used by RenderTaskList, which owns the SceneGraph::RenderTasks
-
/**
* Retrieve the scene-graph RenderTask object.
* @return The scene-graph object
RenderTaskList& GetRenderTaskList() const;
public: // Implementation of Object
-
/**
* @copydoc Dali::Internal::Object::SetDefaultProperty()
*/
/**
* @copydoc Dali::Internal::Object::GetDefaultProperty()
*/
- Property::Value GetDefaultProperty( Property::Index index ) const override;
+ Property::Value GetDefaultProperty(Property::Index index) const override;
/**
* @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
*/
- Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const override;
+ Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
/**
* @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
*/
- void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType ) override;
+ void OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType) override;
/**
* @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
*/
- const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const override;
+ const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty(Property::Index index) const override;
/**
* @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
*/
- const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const override;
+ const PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const override;
public: //signals
-
/**
* Query whether a Finished signal should be emitted for this render-task.
* This should only be called by NotificationManager, before signals are emitted.
* @return True if the signal was connected.
* @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
*/
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
protected:
-
/**
* Constructor.
*
* @param[in] sceneObject The scene graph object
* @param[in] renderTaskList The render task list
*/
- RenderTask( const SceneGraph::RenderTask* sceneObject, RenderTaskList& renderTaskList );
+ RenderTask(const SceneGraph::RenderTask* sceneObject, RenderTaskList& renderTaskList);
/**
* A reference counted object may only be deleted by calling Unreference()
~RenderTask() override;
private: // not copyable
-
- RenderTask() = delete;
- RenderTask( const RenderTask& ) = delete;
- RenderTask& operator=( const RenderTask& ) = delete;
+ RenderTask() = delete;
+ RenderTask(const RenderTask&) = delete;
+ RenderTask& operator=(const RenderTask&) = delete;
private:
-
- ActorObserver mSourceActor; ///< Source actor
- ActorObserver mCameraActor; ///< Camera actor
+ ActorObserver mSourceActor; ///< Source actor
+ ActorObserver mCameraActor; ///< Camera actor
WeakHandle<Dali::Actor> mInputMappingActor; /// used to mapping screen to frame buffer coordinate, not kept alive by rendertask
- RenderTaskList& mRenderTaskList; ///< The render task list
+ RenderTaskList& mRenderTaskList; ///< The render task list
- Vector4 mClearColor; ///< Optional clear color
+ Vector4 mClearColor; ///< Optional clear color
Vector2 mViewportPosition; ///< The cached viewport position
Vector2 mViewportSize; ///< The cached viewport size
uint32_t mRefreshOnceCounter;
- FrameBufferPtr mFrameBuffer;
-
+ FrameBufferPtr mFrameBuffer;
Dali::RenderTask::ScreenToFrameBufferFunction mScreenToFrameBufferFunction; ///< Used to convert screen to frame-buffer coordinates
- bool mExclusive : 1; ///< True if the render-task has exclusive access to the source Nodes.
- bool mInputEnabled : 1; ///< True if the render-task should be considered for input handling.
- bool mClearEnabled : 1; ///< True if the render-task should be clear the color buffer.
- bool mCullMode : 1; ///< True if the render-task's actors should be culled
- bool mRequiresSync : 1; ///< True if the GL sync is required to track the render of.
+ bool mExclusive : 1; ///< True if the render-task has exclusive access to the source Nodes.
+ bool mInputEnabled : 1; ///< True if the render-task should be considered for input handling.
+ bool mClearEnabled : 1; ///< True if the render-task should be clear the color buffer.
+ bool mCullMode : 1; ///< True if the render-task's actors should be culled
+ bool mRequiresSync : 1; ///< True if the GL sync is required to track the render of.
//Signals
- Dali::RenderTask::RenderTaskSignalType mSignalFinished; ///< Signal emmited when the render task has been processed.
+ Dali::RenderTask::RenderTaskSignalType mSignalFinished; ///< Signal emmited when the render task has been processed.
};
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/render-tasks/render-task-list-impl.h>
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
+#include <dali/internal/event/actors/camera-actor-impl.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/event/render-tasks/render-task-defaults.h>
#include <dali/internal/event/render-tasks/render-task-impl.h>
-#include <dali/internal/event/actors/camera-actor-impl.h>
-#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
-#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
#include <dali/internal/update/manager/update-manager.h>
+#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
+#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
+#include <dali/public-api/common/dali-common.h>
using Dali::Internal::SceneGraph::UpdateManager;
{
namespace Internal
{
-
RenderTaskListPtr RenderTaskList::New()
{
RenderTaskListPtr taskList = new RenderTaskList();
RenderTaskPtr RenderTaskList::CreateTask()
{
- return CreateTask( &mDefaults.GetDefaultRootActor(), &mDefaults.GetDefaultCameraActor() );
+ return CreateTask(&mDefaults.GetDefaultRootActor(), &mDefaults.GetDefaultCameraActor());
}
-RenderTaskPtr RenderTaskList::CreateTask( Actor* sourceActor, CameraActor* cameraActor)
+RenderTaskPtr RenderTaskList::CreateTask(Actor* sourceActor, CameraActor* cameraActor)
{
- RenderTaskPtr task = RenderTask::New( sourceActor, cameraActor, *this );
+ RenderTaskPtr task = RenderTask::New(sourceActor, cameraActor, *this);
- mTasks.push_back( task );
+ mTasks.push_back(task);
return task;
}
-void RenderTaskList::RemoveTask( Internal::RenderTask& task )
+void RenderTaskList::RemoveTask(Internal::RenderTask& task)
{
- for ( RenderTaskContainer::iterator iter = mTasks.begin(); mTasks.end() != iter; ++iter )
+ for(RenderTaskContainer::iterator iter = mTasks.begin(); mTasks.end() != iter; ++iter)
{
- RenderTask *ptr = iter->Get();
+ RenderTask* ptr = iter->Get();
- if ( ptr == &task )
+ if(ptr == &task)
{
const SceneGraph::RenderTask& sceneObject = task.GetRenderTaskSceneObject();
// delete the task
- mTasks.erase( iter );
+ mTasks.erase(iter);
// send a message to remove the scene-graph RenderTask
- RemoveTaskMessage( mEventThreadServices, *mSceneObject, sceneObject );
+ RemoveTaskMessage(mEventThreadServices, *mSceneObject, sceneObject);
- for ( auto exclusiveIt = mExclusives.begin(); exclusiveIt != mExclusives.end(); ++exclusiveIt )
+ for(auto exclusiveIt = mExclusives.begin(); exclusiveIt != mExclusives.end(); ++exclusiveIt)
{
- if ( exclusiveIt->renderTaskPtr == ptr )
+ if(exclusiveIt->renderTaskPtr == ptr)
{
- mExclusives.erase( exclusiveIt );
+ mExclusives.erase(exclusiveIt);
break;
}
}
uint32_t RenderTaskList::GetTaskCount() const
{
- return static_cast<uint32_t>( mTasks.size() ); // only 4,294,967,295 render tasks supported
+ return static_cast<uint32_t>(mTasks.size()); // only 4,294,967,295 render tasks supported
}
-RenderTaskPtr RenderTaskList::GetTask( uint32_t index ) const
+RenderTaskPtr RenderTaskList::GetTask(uint32_t index) const
{
- DALI_ASSERT_ALWAYS( ( index < mTasks.size() ) && "RenderTask index out-of-range" );
+ DALI_ASSERT_ALWAYS((index < mTasks.size()) && "RenderTask index out-of-range");
- return mTasks[ index ];
+ return mTasks[index];
}
-void RenderTaskList::SetExclusive( RenderTask* task, bool exclusive )
+void RenderTaskList::SetExclusive(RenderTask* task, bool exclusive)
{
// Check to see if this rendertask has an entry?
- for ( auto exclusiveIt = mExclusives.begin(); exclusiveIt != mExclusives.end(); ++exclusiveIt )
+ for(auto exclusiveIt = mExclusives.begin(); exclusiveIt != mExclusives.end(); ++exclusiveIt)
{
- if ( exclusiveIt->renderTaskPtr == task )
+ if(exclusiveIt->renderTaskPtr == task)
{
- if ( !exclusive )
+ if(!exclusive)
{
- mExclusives.erase( exclusiveIt );
+ mExclusives.erase(exclusiveIt);
break;
}
else
{
- exclusiveIt->actor.SetActor( task->GetSourceActor() );
+ exclusiveIt->actor.SetActor(task->GetSourceActor());
exclusive = false;
break;
}
}
}
- if ( exclusive )
+ if(exclusive)
{
Exclusive exclusiveSlot;
exclusiveSlot.renderTaskPtr = task;
- exclusiveSlot.actor.SetActor( task->GetSourceActor() );
- mExclusives.emplace_back( std::move( exclusiveSlot ) );
+ exclusiveSlot.actor.SetActor(task->GetSourceActor());
+ mExclusives.emplace_back(std::move(exclusiveSlot));
}
}
RenderTaskList::RenderTaskList()
-: mEventThreadServices( EventThreadServices::Get() ),
- mDefaults( *Stage::GetCurrent() ),
- mSceneObject( nullptr )
+: mEventThreadServices(EventThreadServices::Get()),
+ mDefaults(*Stage::GetCurrent()),
+ mSceneObject(nullptr)
{
}
RenderTaskList::~RenderTaskList()
{
- if( EventThreadServices::IsCoreRunning() && mSceneObject )
+ if(EventThreadServices::IsCoreRunning() && mSceneObject)
{
// Remove the render task list using a message to the update manager
- RemoveRenderTaskListMessage( mEventThreadServices.GetUpdateManager(), *mSceneObject );
+ RemoveRenderTaskListMessage(mEventThreadServices.GetUpdateManager(), *mSceneObject);
}
}
// Create a new render task list, Keep a const pointer to the render task list.
mSceneObject = SceneGraph::RenderTaskList::New();
- OwnerPointer< SceneGraph::RenderTaskList > transferOwnership( const_cast< SceneGraph::RenderTaskList* >( mSceneObject ) );
- AddRenderTaskListMessage( mEventThreadServices.GetUpdateManager(), transferOwnership );
+ OwnerPointer<SceneGraph::RenderTaskList> transferOwnership(const_cast<SceneGraph::RenderTaskList*>(mSceneObject));
+ AddRenderTaskListMessage(mEventThreadServices.GetUpdateManager(), transferOwnership);
// set the callback to call us back when tasks are completed
- mSceneObject->SetCompleteNotificationInterface( this );
+ mSceneObject->SetCompleteNotificationInterface(this);
}
void RenderTaskList::NotifyCompleted()
// Since render tasks can be unreferenced during the signal emissions, iterators into render tasks pointers may be invalidated.
// First copy the finished render tasks, then emit signals
- for ( RenderTaskContainer::iterator iter = mTasks.begin(), endIt = mTasks.end(); iter != endIt; ++iter )
+ for(RenderTaskContainer::iterator iter = mTasks.begin(), endIt = mTasks.end(); iter != endIt; ++iter)
{
- if( (*iter)->HasFinished() )
+ if((*iter)->HasFinished())
{
- finishedRenderTasks.push_back( *iter );
+ finishedRenderTasks.push_back(*iter);
}
}
// Now it's safe to emit the signals
- for ( auto&& item : finishedRenderTasks )
+ for(auto&& item : finishedRenderTasks)
{
item->EmitSignalFinish();
}
void RenderTaskList::RecoverFromContextLoss()
{
- for ( auto&& item : mTasks )
+ for(auto&& item : mTasks)
{
// If the render target renders only once to an offscreen, re-render the render task
- if( item->GetRefreshRate() == Dali::RenderTask::REFRESH_ONCE && item->GetFrameBuffer() )
+ if(item->GetRefreshRate() == Dali::RenderTask::REFRESH_ONCE && item->GetFrameBuffer())
{
- item->SetRefreshRate( Dali::RenderTask::REFRESH_ONCE );
+ item->SetRefreshRate(Dali::RenderTask::REFRESH_ONCE);
}
}
}
#define DALI_INTERNAL_RENDER_TASK_LIST_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/render-tasks/render-task-list.h>
+
#include <dali/internal/event/common/complete-notification-interface.h>
-#include <dali/internal/event/render-tasks/render-task-impl.h>
#include <dali/internal/event/events/actor-observer.h>
+#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
{
-
namespace Internal
{
-
class EventThreadServices;
class RenderTaskDefaults;
class Actor;
{
class RenderTaskList;
class UpdateManager;
-}
+} // namespace SceneGraph
/**
* A proxy for the scene-graph RenderTaskList.
class RenderTaskList : public BaseObject, public CompleteNotificationInterface
{
public:
-
- using RenderTaskContainer = std::vector< RenderTaskPtr >;
+ using RenderTaskContainer = std::vector<RenderTaskPtr>;
struct Exclusive
{
- RenderTask* renderTaskPtr; ///< Pointer for comparison with current rendertask.
- ActorObserver actor; ///< For comparison with current actor.
+ RenderTask* renderTaskPtr; ///< Pointer for comparison with current rendertask.
+ ActorObserver actor; ///< For comparison with current actor.
};
- using ExclusivesContainer = std::vector< Exclusive >;
+ using ExclusivesContainer = std::vector<Exclusive>;
/**
* Create a RenderTaskList.
* @param[in] cameraActor The actor from which the scene is viewed for this render task.
* @return A valid handle to a new RenderTask
*/
- RenderTaskPtr CreateTask( Actor* sourceActor, CameraActor* cameraActor);
+ RenderTaskPtr CreateTask(Actor* sourceActor, CameraActor* cameraActor);
/**
* @copydoc Dali::RenderTaskList::RemoveTask()
*/
- void RemoveTask( Internal::RenderTask& task );
+ void RemoveTask(Internal::RenderTask& task);
/**
* @copydoc Dali::RenderTaskList::GetTaskCount()
/**
* @copydoc Dali::RenderTaskList::GetTask()
*/
- RenderTaskPtr GetTask( uint32_t index ) const;
+ RenderTaskPtr GetTask(uint32_t index) const;
/**
* Retrieve the container of render-tasks.
* @param[in] task Pointer to the rendertask.
* @param[in] exclusive If a rendertask is to have exclusive acesss to its source actor.
*/
- void SetExclusive( RenderTask* task, bool exclusive );
+ void SetExclusive(RenderTask* task, bool exclusive);
/**
* @brief Return the list of rendertasks that exclusively own their source actor.
* Queue NotifyFinishedMessage() from update-thread
* @param object pointer to this class instance
*/
- static void NotifyFinished( void* object );
+ static void NotifyFinished(void* object);
/**
* This method refreshes all render tasks that have a frame buffer
const SceneGraph::RenderTaskList& GetSceneObject() const;
protected:
-
/**
* Construct a new RenderTaskList.
*/
void Initialize();
private: // from CompleteNotificationInterface
-
/**
* @copydoc CompleteNotificationInterface::NotifyCompleted()
*/
void NotifyCompleted() override;
private:
-
EventThreadServices& mEventThreadServices;
- RenderTaskDefaults& mDefaults;
+ RenderTaskDefaults& mDefaults;
SceneGraph::RenderTaskList* mSceneObject; ///< Raw-pointer to the scene-graph object; not owned.
- RenderTaskContainer mTasks; ///< Reference counted render-tasks
- ExclusivesContainer mExclusives; ///< List of rendertasks with exclusively owned source actors.
+ RenderTaskContainer mTasks; ///< Reference counted render-tasks
+ ExclusivesContainer mExclusives; ///< List of rendertasks with exclusively owned source actors.
};
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/rendering/frame-buffer-impl.h>
// INTERNAL INCLUDES
-#include <dali/internal/update/manager/update-manager.h>
#include <dali/internal/render/renderers/render-frame-buffer.h>
+#include <dali/internal/update/manager/update-manager.h>
namespace Dali
{
namespace Internal
{
-
-FrameBufferPtr FrameBuffer::New( uint32_t width, uint32_t height, Mask attachments )
+FrameBufferPtr FrameBuffer::New(uint32_t width, uint32_t height, Mask attachments)
{
- FrameBufferPtr frameBuffer( new FrameBuffer( width, height, attachments ) );
+ FrameBufferPtr frameBuffer(new FrameBuffer(width, height, attachments));
frameBuffer->Initialize();
return frameBuffer;
}
return mRenderObject;
}
-FrameBuffer::FrameBuffer( uint32_t width, uint32_t height, Mask attachments )
-: mEventThreadServices( EventThreadServices::Get() ),
- mRenderObject( nullptr ),
- mColor{ nullptr },
- mDepth( nullptr ),
- mStencil( nullptr ),
- mWidth( width ),
- mHeight( height ),
- mAttachments( attachments ),
- mColorAttachmentCount( 0 )
+FrameBuffer::FrameBuffer(uint32_t width, uint32_t height, Mask attachments)
+: mEventThreadServices(EventThreadServices::Get()),
+ mRenderObject(nullptr),
+ mColor{nullptr},
+ mDepth(nullptr),
+ mStencil(nullptr),
+ mWidth(width),
+ mHeight(height),
+ mAttachments(attachments),
+ mColorAttachmentCount(0)
{
}
void FrameBuffer::Initialize()
{
- mRenderObject = new Render::FrameBuffer( mWidth, mHeight, mAttachments );
+ mRenderObject = new Render::FrameBuffer(mWidth, mHeight, mAttachments);
- OwnerPointer< Render::FrameBuffer > transferOwnership( mRenderObject );
- AddFrameBuffer( mEventThreadServices.GetUpdateManager(), transferOwnership );
+ OwnerPointer<Render::FrameBuffer> transferOwnership(mRenderObject);
+ AddFrameBuffer(mEventThreadServices.GetUpdateManager(), transferOwnership);
}
-void FrameBuffer::AttachColorTexture( TexturePtr texture, uint32_t mipmapLevel, uint32_t layer )
+void FrameBuffer::AttachColorTexture(TexturePtr texture, uint32_t mipmapLevel, uint32_t layer)
{
- if( ( texture->GetWidth() / ( 1u << mipmapLevel ) != mWidth ) ||
- ( texture->GetHeight() / ( 1u << mipmapLevel ) != mHeight ) )
+ if((texture->GetWidth() / (1u << mipmapLevel) != mWidth) ||
+ (texture->GetHeight() / (1u << mipmapLevel) != mHeight))
{
- DALI_LOG_ERROR( "Failed to attach color texture to FrameBuffer: Size mismatch \n" );
+ DALI_LOG_ERROR("Failed to attach color texture to FrameBuffer: Size mismatch \n");
}
- else if ( mColorAttachmentCount >= Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS )
+ else if(mColorAttachmentCount >= Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS)
{
- DALI_LOG_ERROR( "Failed to attach color texture to FrameBuffer: Exceeded maximum supported color attachments.\n" );
+ DALI_LOG_ERROR("Failed to attach color texture to FrameBuffer: Exceeded maximum supported color attachments.\n");
}
else
{
mColor[mColorAttachmentCount] = texture;
++mColorAttachmentCount;
- AttachColorTextureToFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel, layer );
+ AttachColorTextureToFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel, layer);
}
}
-void FrameBuffer::AttachDepthTexture( TexturePtr texture, uint32_t mipmapLevel )
+void FrameBuffer::AttachDepthTexture(TexturePtr texture, uint32_t mipmapLevel)
{
- if( ( texture->GetWidth() / ( 1u << mipmapLevel ) != mWidth ) ||
- ( texture->GetHeight() / ( 1u << mipmapLevel ) != mHeight ) )
+ if((texture->GetWidth() / (1u << mipmapLevel) != mWidth) ||
+ (texture->GetHeight() / (1u << mipmapLevel) != mHeight))
{
- DALI_LOG_ERROR( "Failed to attach depth texture to FrameBuffer: Size mismatch \n" );
+ DALI_LOG_ERROR("Failed to attach depth texture to FrameBuffer: Size mismatch \n");
}
else
{
mDepth = texture;
- AttachDepthTextureToFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel );
+ AttachDepthTextureToFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel);
}
}
-void FrameBuffer::AttachDepthStencilTexture( TexturePtr texture, unsigned int mipmapLevel )
+void FrameBuffer::AttachDepthStencilTexture(TexturePtr texture, unsigned int mipmapLevel)
{
- if( ( texture->GetWidth() / ( 1u << mipmapLevel ) != mWidth ) ||
- ( texture->GetHeight() / ( 1u << mipmapLevel ) != mHeight ) )
+ if((texture->GetWidth() / (1u << mipmapLevel) != mWidth) ||
+ (texture->GetHeight() / (1u << mipmapLevel) != mHeight))
{
- DALI_LOG_ERROR( "Failed to attach depth/stencil texture to FrameBuffer: Size mismatch \n" );
+ DALI_LOG_ERROR("Failed to attach depth/stencil texture to FrameBuffer: Size mismatch \n");
}
else
{
mStencil = texture;
- AttachDepthStencilTextureToFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel );
+ AttachDepthStencilTextureToFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject, texture->GetRenderObject(), mipmapLevel);
}
}
Texture* FrameBuffer::GetColorTexture(uint8_t index) const
{
- return ( index >= mColorAttachmentCount ) ? nullptr : mColor[index].Get();
+ return (index >= mColorAttachmentCount) ? nullptr : mColor[index].Get();
}
Texture* FrameBuffer::GetDepthTexture() const
{
- return ( mDepth ) ? mDepth.Get() : nullptr;
+ return (mDepth) ? mDepth.Get() : nullptr;
}
Texture* FrameBuffer::GetDepthStencilTexture() const
{
- return ( mStencil ) ? mStencil.Get() : nullptr;
+ return (mStencil) ? mStencil.Get() : nullptr;
}
-void FrameBuffer::SetSize( uint32_t width, uint32_t height )
+void FrameBuffer::SetSize(uint32_t width, uint32_t height)
{
- mWidth = width;
+ mWidth = width;
mHeight = height;
}
FrameBuffer::~FrameBuffer()
{
- if( EventThreadServices::IsCoreRunning() && mRenderObject )
+ if(EventThreadServices::IsCoreRunning() && mRenderObject)
{
- RemoveFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject );
+ RemoveFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject);
}
}
-
} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_FRAME_BUFFER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
-#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
-#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/rendering/frame-buffer.h>
#include <dali/devel-api/rendering/frame-buffer-devel.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/event/rendering/texture-impl.h>
+#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
+#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/rendering/frame-buffer.h>
namespace Dali
{
class FrameBuffer : public BaseObject
{
public:
-
using Mask = Dali::FrameBuffer::Attachment::Mask;
/**
* @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
* @return A smart-pointer to the newly allocated Texture.
*/
- static FrameBufferPtr New( uint32_t width, uint32_t height, Mask attachments );
+ static FrameBufferPtr New(uint32_t width, uint32_t height, Mask attachments);
/**
* A reference counted object may only be deleted by calling Unreference()
/**
* @copydoc Dali::FrameBuffer::AttachColorTexture()
*/
- void AttachColorTexture( TexturePtr texture, uint32_t mipmapLevel, uint32_t layer );
+ void AttachColorTexture(TexturePtr texture, uint32_t mipmapLevel, uint32_t layer);
/**
* @copydoc Dali::DevelFrameBuffer::AttachDepthTexture()
*/
- void AttachDepthTexture( TexturePtr texture, uint32_t mipmapLevel );
+ void AttachDepthTexture(TexturePtr texture, uint32_t mipmapLevel);
/**
* @copydoc Dali::DevelFrameBuffer::AttachDepthStencilTexture()
*/
- void AttachDepthStencilTexture( TexturePtr texture, uint32_t mipmapLevel );
+ void AttachDepthStencilTexture(TexturePtr texture, uint32_t mipmapLevel);
/**
* @copydoc Dali::FrameBuffer::GetColorTexture()
* @param[in] width The width size
* @param[in] height The height size
*/
- void SetSize( uint32_t width, uint32_t height );
+ void SetSize(uint32_t width, uint32_t height);
private: // implementation
-
/**
* Constructor
* @param[in] width The width of the FrameBuffer
* @param[in] height The height of the FrameBuffer
* @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
*/
- FrameBuffer( uint32_t width, uint32_t height, Mask attachments );
+ FrameBuffer(uint32_t width, uint32_t height, Mask attachments);
/**
* Second stage initialization of the Texture
void Initialize();
protected:
-
private: // unimplemented methods
+ FrameBuffer() = delete;
+ FrameBuffer(const FrameBuffer&) = delete;
+ FrameBuffer& operator=(const FrameBuffer&) = delete;
- FrameBuffer() = delete;
- FrameBuffer( const FrameBuffer& ) = delete;
- FrameBuffer& operator=( const FrameBuffer& ) = delete;
-
-private: // data
-
+private: // data
Internal::EventThreadServices& mEventThreadServices; ///< Used to send messages to the render thread via update thread
Internal::Render::FrameBuffer* mRenderObject; ///< The Render::Texture associated to this texture
- TexturePtr mColor[ Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS ];
+ TexturePtr mColor[Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS];
TexturePtr mDepth;
TexturePtr mStencil;
- uint32_t mWidth;
- uint32_t mHeight;
- Mask mAttachments; ///< Bit-mask of type FrameBuffer::Attachment::Mask
- uint8_t mColorAttachmentCount;
+ uint32_t mWidth;
+ uint32_t mHeight;
+ Mask mAttachments; ///< Bit-mask of type FrameBuffer::Attachment::Mask
+ uint8_t mColorAttachmentCount;
};
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Internal
{
-
GeometryPtr Geometry::New()
{
- GeometryPtr geometry( new Geometry() );
+ GeometryPtr geometry(new Geometry());
geometry->Initialize();
return geometry;
}
-uint32_t Geometry::AddVertexBuffer( VertexBuffer& vertexBuffer )
+uint32_t Geometry::AddVertexBuffer(VertexBuffer& vertexBuffer)
{
- mVertexBuffers.push_back( &vertexBuffer );
- SceneGraph::AttachVertexBufferMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, *vertexBuffer.GetRenderObject() );
- return static_cast<uint32_t>( mVertexBuffers.size() - 1u );
+ mVertexBuffers.push_back(&vertexBuffer);
+ SceneGraph::AttachVertexBufferMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, *vertexBuffer.GetRenderObject());
+ return static_cast<uint32_t>(mVertexBuffers.size() - 1u);
}
uint32_t Geometry::GetNumberOfVertexBuffers() const
{
- return static_cast<uint32_t>( mVertexBuffers.size() );
+ return static_cast<uint32_t>(mVertexBuffers.size());
}
-void Geometry::RemoveVertexBuffer( uint32_t index )
+void Geometry::RemoveVertexBuffer(uint32_t index)
{
- const Render::VertexBuffer& renderVertexBuffer = static_cast<const Render::VertexBuffer&>( *(mVertexBuffers[index]->GetRenderObject()) );
- SceneGraph::RemoveVertexBufferMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, renderVertexBuffer );
+ const Render::VertexBuffer& renderVertexBuffer = static_cast<const Render::VertexBuffer&>(*(mVertexBuffers[index]->GetRenderObject()));
+ SceneGraph::RemoveVertexBufferMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, renderVertexBuffer);
- mVertexBuffers.erase( mVertexBuffers.begin() + index );
+ mVertexBuffers.erase(mVertexBuffers.begin() + index);
}
-void Geometry::SetIndexBuffer( const uint16_t* indices, uint32_t count )
+void Geometry::SetIndexBuffer(const uint16_t* indices, uint32_t count)
{
Dali::Vector<uint16_t> indexData;
- if( indices && count )
+ if(indices && count)
{
- indexData.Resize( count );
- std::copy( indices, indices + count, indexData.Begin() );
+ indexData.Resize(count);
+ std::copy(indices, indices + count, indexData.Begin());
}
- SceneGraph::SetIndexBufferMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, indexData );
+ SceneGraph::SetIndexBufferMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, indexData);
}
-void Geometry::SetType( Dali::Geometry::Type geometryType )
+void Geometry::SetType(Dali::Geometry::Type geometryType)
{
- if( geometryType != mType )
+ if(geometryType != mType)
{
- SceneGraph::SetGeometryTypeMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, geometryType );
+ SceneGraph::SetGeometryTypeMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, geometryType);
mType = geometryType;
}
}
Geometry::Geometry()
-: mEventThreadServices( EventThreadServices::Get() ),
- mRenderObject( nullptr ),
+: mEventThreadServices(EventThreadServices::Get()),
+ mRenderObject(nullptr),
mType(Dali::Geometry::TRIANGLES)
{
}
void Geometry::Initialize()
{
mRenderObject = new Render::Geometry();
- OwnerPointer< Render::Geometry > transferOwnership( mRenderObject );
- AddGeometry( mEventThreadServices.GetUpdateManager(), transferOwnership );
+ OwnerPointer<Render::Geometry> transferOwnership(mRenderObject);
+ AddGeometry(mEventThreadServices.GetUpdateManager(), transferOwnership);
}
Geometry::~Geometry()
{
- if( EventThreadServices::IsCoreRunning() && mRenderObject )
+ if(EventThreadServices::IsCoreRunning() && mRenderObject)
{
- RemoveGeometry( mEventThreadServices.GetUpdateManager(), *mRenderObject );
+ RemoveGeometry(mEventThreadServices.GetUpdateManager(), *mRenderObject);
}
}
#define DALI_INTERNAL_GEOMETRY_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/public-api/common/vector-wrapper.h> // std::vector
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
-#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
-#include <dali/public-api/rendering/geometry.h> // Dali::Geometry
-#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
-#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
-#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
+#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
+#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
+#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
#include <dali/internal/event/rendering/vertex-buffer-impl.h> // Dali::Internal::VertexBuffer
#include <dali/internal/render/renderers/render-geometry.h>
+#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
+#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
+#include <dali/public-api/rendering/geometry.h> // Dali::Geometry
namespace Dali
{
class Geometry : public BaseObject
{
public:
-
/**
* Create a new Geometry.
* @return A smart-pointer to the newly allocated Geometry.
/**
* @copydoc Dali::Geometry::AddVertexBuffer()
*/
- uint32_t AddVertexBuffer( VertexBuffer& vertexBuffer );
+ uint32_t AddVertexBuffer(VertexBuffer& vertexBuffer);
/**
* @copydoc Dali::Geometry::GetNumberOfVertexBuffers()
/**
* @copydoc Dali::Geometry::RemoveVertexBuffer()
*/
- void RemoveVertexBuffer( uint32_t index );
+ void RemoveVertexBuffer(uint32_t index);
/**
* @copydoc Dali::Geometry::SetIndexBuffer()
*/
- void SetIndexBuffer( const uint16_t* indices, uint32_t count );
+ void SetIndexBuffer(const uint16_t* indices, uint32_t count);
/**
* @copydoc Dali::Geometry::SetType()
*/
- void SetType( Dali::Geometry::Type geometryType );
+ void SetType(Dali::Geometry::Type geometryType);
/**
* @copydoc Dali::Geometry::GetType()
const Render::Geometry* GetRenderObject() const;
private: // implementation
-
/**
* Constructor
*/
void Initialize();
protected:
-
/**
* A reference counted object may only be deleted by calling Unreference()
*/
~Geometry() override;
private: // unimplemented methods
- Geometry( const Geometry& );
- Geometry& operator=( const Geometry& );
-
-private: // data
+ Geometry(const Geometry&);
+ Geometry& operator=(const Geometry&);
- EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via update thread
- Render::Geometry* mRenderObject;
+private: // data
+ EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via update thread
+ Render::Geometry* mRenderObject;
std::vector<VertexBufferPtr> mVertexBuffers; ///< Vector of intrusive pointers to vertex buffers
- Dali::Geometry::Type mType; ///< Geometry type (cached)
+ Dali::Geometry::Type mType; ///< Geometry type (cached)
};
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/devel-api/scripting/scripting.h>
-#include <dali/public-api/object/type-registry.h>
-#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
+#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
#include <dali/internal/event/common/property-input-impl.h>
#include <dali/internal/render/renderers/render-geometry.h>
#include <dali/internal/update/manager/update-manager.h>
#include <dali/internal/update/rendering/scene-graph-renderer.h>
+#include <dali/public-api/object/type-registry.h>
namespace Dali
{
namespace Internal
{
-
namespace
{
-
/**
* Properties: |name |type |writable|animatable|constraint-input|enum for index-checking|
*/
DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "depthIndex", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX )
-DALI_PROPERTY( "faceCullingMode", INTEGER, true, false, false, Dali::Renderer::Property::FACE_CULLING_MODE )
-DALI_PROPERTY( "blendMode", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_MODE )
-DALI_PROPERTY( "blendEquationRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_RGB )
-DALI_PROPERTY( "blendEquationAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_ALPHA )
-DALI_PROPERTY( "blendFactorSrcRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB )
-DALI_PROPERTY( "blendFactorDestRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB )
-DALI_PROPERTY( "blendFactorSrcAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA )
-DALI_PROPERTY( "blendFactorDestAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA )
-DALI_PROPERTY( "blendColor", VECTOR4, true, false, false, Dali::Renderer::Property::BLEND_COLOR )
-DALI_PROPERTY( "blendPreMultipliedAlpha", BOOLEAN, true, false, false, Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA )
-DALI_PROPERTY( "indexRangeFirst", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_FIRST )
-DALI_PROPERTY( "indexRangeCount", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_COUNT )
-DALI_PROPERTY( "depthWriteMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_WRITE_MODE )
-DALI_PROPERTY( "depthFunction", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_FUNCTION )
-DALI_PROPERTY( "depthTestMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_TEST_MODE )
-DALI_PROPERTY( "renderMode", INTEGER, true, false, false, Dali::Renderer::Property::RENDER_MODE )
-DALI_PROPERTY( "stencilFunction", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION )
-DALI_PROPERTY( "stencilFunctionMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_MASK )
-DALI_PROPERTY( "stencilFunctionReference", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE )
-DALI_PROPERTY( "stencilMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_MASK )
-DALI_PROPERTY( "stencilOperationOnFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL )
-DALI_PROPERTY( "stencilOperationOnZFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL )
-DALI_PROPERTY( "stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS )
-DALI_PROPERTY( "opacity", FLOAT, true, true, true, Dali::DevelRenderer::Property::OPACITY )
-DALI_PROPERTY( "renderingBehavior", INTEGER, true, false, false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR )
-DALI_PROPERTY( "blendEquation", INTEGER, true, false, false, Dali::DevelRenderer::Property::BLEND_EQUATION )
-DALI_PROPERTY_TABLE_END( DEFAULT_RENDERER_PROPERTY_START_INDEX, RendererDefaultProperties )
+DALI_PROPERTY("depthIndex", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX)
+DALI_PROPERTY("faceCullingMode", INTEGER, true, false, false, Dali::Renderer::Property::FACE_CULLING_MODE)
+DALI_PROPERTY("blendMode", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_MODE)
+DALI_PROPERTY("blendEquationRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_RGB)
+DALI_PROPERTY("blendEquationAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_ALPHA)
+DALI_PROPERTY("blendFactorSrcRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB)
+DALI_PROPERTY("blendFactorDestRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB)
+DALI_PROPERTY("blendFactorSrcAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA)
+DALI_PROPERTY("blendFactorDestAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA)
+DALI_PROPERTY("blendColor", VECTOR4, true, false, false, Dali::Renderer::Property::BLEND_COLOR)
+DALI_PROPERTY("blendPreMultipliedAlpha", BOOLEAN, true, false, false, Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA)
+DALI_PROPERTY("indexRangeFirst", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_FIRST)
+DALI_PROPERTY("indexRangeCount", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_COUNT)
+DALI_PROPERTY("depthWriteMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_WRITE_MODE)
+DALI_PROPERTY("depthFunction", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_FUNCTION)
+DALI_PROPERTY("depthTestMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_TEST_MODE)
+DALI_PROPERTY("renderMode", INTEGER, true, false, false, Dali::Renderer::Property::RENDER_MODE)
+DALI_PROPERTY("stencilFunction", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION)
+DALI_PROPERTY("stencilFunctionMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_MASK)
+DALI_PROPERTY("stencilFunctionReference", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE)
+DALI_PROPERTY("stencilMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_MASK)
+DALI_PROPERTY("stencilOperationOnFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL)
+DALI_PROPERTY("stencilOperationOnZFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL)
+DALI_PROPERTY("stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS)
+DALI_PROPERTY("opacity", FLOAT, true, true, true, Dali::DevelRenderer::Property::OPACITY)
+DALI_PROPERTY("renderingBehavior", INTEGER, true, false, false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR)
+DALI_PROPERTY("blendEquation", INTEGER, true, false, false, Dali::DevelRenderer::Property::BLEND_EQUATION)
+DALI_PROPERTY_TABLE_END(DEFAULT_RENDERER_PROPERTY_START_INDEX, RendererDefaultProperties)
// Property string to enumeration tables:
-DALI_ENUM_TO_STRING_TABLE_BEGIN( FACE_CULLING_MODE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( FaceCullingMode, NONE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( FaceCullingMode, FRONT )
-DALI_ENUM_TO_STRING_WITH_SCOPE( FaceCullingMode, BACK )
-DALI_ENUM_TO_STRING_WITH_SCOPE( FaceCullingMode, FRONT_AND_BACK )
-DALI_ENUM_TO_STRING_TABLE_END( FACE_CULLING_MODE )
-
-DALI_ENUM_TO_STRING_TABLE_BEGIN( BLEND_MODE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendMode, OFF )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendMode, AUTO )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendMode, ON )
-DALI_ENUM_TO_STRING_TABLE_END( BLEND_MODE )
-
-DALI_ENUM_TO_STRING_TABLE_BEGIN( BLEND_EQUATION )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendEquation, ADD )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendEquation, SUBTRACT )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendEquation, REVERSE_SUBTRACT )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, MIN )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, MAX )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, MULTIPLY )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, SCREEN )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, OVERLAY )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, DARKEN )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, LIGHTEN )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, COLOR_DODGE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, COLOR_BURN )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, HARD_LIGHT )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, SOFT_LIGHT )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, DIFFERENCE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, EXCLUSION )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, HUE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, SATURATION )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, COLOR )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, LUMINOSITY )
-DALI_ENUM_TO_STRING_TABLE_END( BLEND_EQUATION )
-
-DALI_ENUM_TO_STRING_TABLE_BEGIN( BLEND_FACTOR )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ZERO )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ONE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, SRC_COLOR )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ONE_MINUS_SRC_COLOR )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, SRC_ALPHA )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ONE_MINUS_SRC_ALPHA )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, DST_ALPHA )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ONE_MINUS_DST_ALPHA )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, DST_COLOR )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ONE_MINUS_DST_COLOR )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, SRC_ALPHA_SATURATE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, CONSTANT_COLOR )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ONE_MINUS_CONSTANT_COLOR )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, CONSTANT_ALPHA )
-DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ONE_MINUS_CONSTANT_ALPHA )
-DALI_ENUM_TO_STRING_TABLE_END( BLEND_FACTOR )
-
-DALI_ENUM_TO_STRING_TABLE_BEGIN( DEPTH_WRITE_MODE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DepthWriteMode, OFF )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DepthWriteMode, AUTO )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DepthWriteMode, ON )
-DALI_ENUM_TO_STRING_TABLE_END( DEPTH_WRITE_MODE )
-
-DALI_ENUM_TO_STRING_TABLE_BEGIN( DEPTH_TEST_MODE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DepthTestMode, OFF )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DepthTestMode, AUTO )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DepthTestMode, ON )
-DALI_ENUM_TO_STRING_TABLE_END( DEPTH_TEST_MODE )
-
-DALI_ENUM_TO_STRING_TABLE_BEGIN( DEPTH_FUNCTION )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, NEVER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, ALWAYS )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, LESS )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, GREATER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, EQUAL )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, NOT_EQUAL )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, LESS_EQUAL )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, GREATER_EQUAL )
-DALI_ENUM_TO_STRING_TABLE_END( DEPTH_FUNCTION )
-
-DALI_ENUM_TO_STRING_TABLE_BEGIN( STENCIL_FUNCTION )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, NEVER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, LESS )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, EQUAL )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, LESS_EQUAL )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, GREATER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, NOT_EQUAL )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, GREATER_EQUAL )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, ALWAYS )
-DALI_ENUM_TO_STRING_TABLE_END( STENCIL_FUNCTION )
-
-DALI_ENUM_TO_STRING_TABLE_BEGIN( RENDER_MODE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, NONE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, AUTO )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, COLOR )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, STENCIL )
-DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, COLOR_STENCIL )
-DALI_ENUM_TO_STRING_TABLE_END( RENDER_MODE )
-
-DALI_ENUM_TO_STRING_TABLE_BEGIN( STENCIL_OPERATION )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, ZERO )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, KEEP )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, REPLACE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, INCREMENT )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, DECREMENT )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, INVERT )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, INCREMENT_WRAP )
-DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, DECREMENT_WRAP )
-DALI_ENUM_TO_STRING_TABLE_END( STENCIL_OPERATION )
-
-DALI_ENUM_TO_STRING_TABLE_BEGIN( RENDERING_BEHAVIOR )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelRenderer::Rendering, IF_REQUIRED )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DevelRenderer::Rendering, CONTINUOUSLY )
-DALI_ENUM_TO_STRING_TABLE_END( RENDERING_BEHAVIOR )
+DALI_ENUM_TO_STRING_TABLE_BEGIN(FACE_CULLING_MODE)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(FaceCullingMode, NONE)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(FaceCullingMode, FRONT)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(FaceCullingMode, BACK)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(FaceCullingMode, FRONT_AND_BACK)
+DALI_ENUM_TO_STRING_TABLE_END(FACE_CULLING_MODE)
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN(BLEND_MODE)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendMode, OFF)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendMode, AUTO)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendMode, ON)
+DALI_ENUM_TO_STRING_TABLE_END(BLEND_MODE)
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN(BLEND_EQUATION)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendEquation, ADD)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendEquation, SUBTRACT)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendEquation, REVERSE_SUBTRACT)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, MIN)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, MAX)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, MULTIPLY)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, SCREEN)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, OVERLAY)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, DARKEN)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, LIGHTEN)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, COLOR_DODGE)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, COLOR_BURN)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, HARD_LIGHT)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, SOFT_LIGHT)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, DIFFERENCE)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, EXCLUSION)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, HUE)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, SATURATION)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, COLOR)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelBlendEquation, LUMINOSITY)
+DALI_ENUM_TO_STRING_TABLE_END(BLEND_EQUATION)
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN(BLEND_FACTOR)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, ZERO)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, ONE)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, SRC_COLOR)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, ONE_MINUS_SRC_COLOR)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, SRC_ALPHA)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, ONE_MINUS_SRC_ALPHA)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, DST_ALPHA)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, ONE_MINUS_DST_ALPHA)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, DST_COLOR)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, ONE_MINUS_DST_COLOR)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, SRC_ALPHA_SATURATE)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, CONSTANT_COLOR)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, ONE_MINUS_CONSTANT_COLOR)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, CONSTANT_ALPHA)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(BlendFactor, ONE_MINUS_CONSTANT_ALPHA)
+DALI_ENUM_TO_STRING_TABLE_END(BLEND_FACTOR)
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN(DEPTH_WRITE_MODE)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DepthWriteMode, OFF)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DepthWriteMode, AUTO)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DepthWriteMode, ON)
+DALI_ENUM_TO_STRING_TABLE_END(DEPTH_WRITE_MODE)
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN(DEPTH_TEST_MODE)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DepthTestMode, OFF)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DepthTestMode, AUTO)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DepthTestMode, ON)
+DALI_ENUM_TO_STRING_TABLE_END(DEPTH_TEST_MODE)
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN(DEPTH_FUNCTION)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DepthFunction, NEVER)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DepthFunction, ALWAYS)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DepthFunction, LESS)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DepthFunction, GREATER)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DepthFunction, EQUAL)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DepthFunction, NOT_EQUAL)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DepthFunction, LESS_EQUAL)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DepthFunction, GREATER_EQUAL)
+DALI_ENUM_TO_STRING_TABLE_END(DEPTH_FUNCTION)
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN(STENCIL_FUNCTION)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilFunction, NEVER)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilFunction, LESS)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilFunction, EQUAL)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilFunction, LESS_EQUAL)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilFunction, GREATER)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilFunction, NOT_EQUAL)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilFunction, GREATER_EQUAL)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilFunction, ALWAYS)
+DALI_ENUM_TO_STRING_TABLE_END(STENCIL_FUNCTION)
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN(RENDER_MODE)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(RenderMode, NONE)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(RenderMode, AUTO)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(RenderMode, COLOR)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(RenderMode, STENCIL)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(RenderMode, COLOR_STENCIL)
+DALI_ENUM_TO_STRING_TABLE_END(RENDER_MODE)
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN(STENCIL_OPERATION)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilOperation, ZERO)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilOperation, KEEP)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilOperation, REPLACE)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilOperation, INCREMENT)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilOperation, DECREMENT)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilOperation, INVERT)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilOperation, INCREMENT_WRAP)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(StencilOperation, DECREMENT_WRAP)
+DALI_ENUM_TO_STRING_TABLE_END(STENCIL_OPERATION)
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN(RENDERING_BEHAVIOR)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelRenderer::Rendering, IF_REQUIRED)
+ DALI_ENUM_TO_STRING_WITH_SCOPE(DevelRenderer::Rendering, CONTINUOUSLY)
+DALI_ENUM_TO_STRING_TABLE_END(RENDERING_BEHAVIOR)
BaseHandle Create()
{
return Dali::BaseHandle();
}
-TypeRegistration mType( typeid( Dali::Renderer ), typeid( Dali::Handle ), Create, RendererDefaultProperties );
+TypeRegistration mType(typeid(Dali::Renderer), typeid(Dali::Handle), Create, RendererDefaultProperties);
} // unnamed namespace
RendererPtr Renderer::New()
{
// create scene object first so it's guaranteed to exist for the event side
- auto sceneObject = SceneGraph::Renderer::New();
- OwnerPointer< SceneGraph::Renderer > transferOwnership( sceneObject );
+ auto sceneObject = SceneGraph::Renderer::New();
+ OwnerPointer<SceneGraph::Renderer> transferOwnership(sceneObject);
// pass the pointer to base for message passing
- RendererPtr rendererPtr( new Renderer( sceneObject ) );
+ RendererPtr rendererPtr(new Renderer(sceneObject));
// transfer scene object ownership to update manager
- EventThreadServices& eventThreadServices = rendererPtr->GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
- AddRendererMessage( updateManager, transferOwnership );
+ EventThreadServices& eventThreadServices = rendererPtr->GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+ AddRendererMessage(updateManager, transferOwnership);
- eventThreadServices.RegisterObject( rendererPtr.Get() );
+ eventThreadServices.RegisterObject(rendererPtr.Get());
return rendererPtr;
}
-void Renderer::SetGeometry( Geometry& geometry )
+void Renderer::SetGeometry(Geometry& geometry)
{
mGeometry = &geometry;
const Render::Geometry* geometrySceneObject = geometry.GetRenderObject();
- SetGeometryMessage( GetEventThreadServices(), GetRendererSceneObject(), *geometrySceneObject );
+ SetGeometryMessage(GetEventThreadServices(), GetRendererSceneObject(), *geometrySceneObject);
}
GeometryPtr Renderer::GetGeometry() const
return mGeometry;
}
-void Renderer::SetTextures( TextureSet& textureSet )
+void Renderer::SetTextures(TextureSet& textureSet)
{
- mTextureSet = &textureSet;
+ mTextureSet = &textureSet;
const SceneGraph::TextureSet* textureSetSceneObject = textureSet.GetTextureSetSceneObject();
- SetTexturesMessage( GetEventThreadServices(), GetRendererSceneObject(), *textureSetSceneObject );
+ SetTexturesMessage(GetEventThreadServices(), GetRendererSceneObject(), *textureSetSceneObject);
}
TextureSetPtr Renderer::GetTextures() const
return mTextureSet;
}
-void Renderer::SetShader( Shader& shader )
+void Renderer::SetShader(Shader& shader)
{
- mShader = &shader;
+ mShader = &shader;
const SceneGraph::Shader& sceneGraphShader = shader.GetShaderSceneObject();
- SceneGraph::SetShaderMessage( GetEventThreadServices(), GetRendererSceneObject(), sceneGraphShader );
+ SceneGraph::SetShaderMessage(GetEventThreadServices(), GetRendererSceneObject(), sceneGraphShader);
}
ShaderPtr Renderer::GetShader() const
return mShader;
}
-void Renderer::SetDepthIndex( int32_t depthIndex )
+void Renderer::SetDepthIndex(int32_t depthIndex)
{
- if ( mDepthIndex != depthIndex )
+ if(mDepthIndex != depthIndex)
{
mDepthIndex = depthIndex;
- SetDepthIndexMessage( GetEventThreadServices(), GetRendererSceneObject(), depthIndex );
+ SetDepthIndexMessage(GetEventThreadServices(), GetRendererSceneObject(), depthIndex);
}
}
return mDepthIndex;
}
-void Renderer::SetBlendMode( BlendMode::Type mode )
+void Renderer::SetBlendMode(BlendMode::Type mode)
{
- if( mBlendMode != mode )
+ if(mBlendMode != mode)
{
mBlendMode = mode;
- SetBlendModeMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendMode );
+ SetBlendModeMessage(GetEventThreadServices(), GetRendererSceneObject(), mBlendMode);
}
}
return mBlendMode;
}
-void Renderer::SetBlendFunc( BlendFactor::Type srcFactorRgba, BlendFactor::Type destFactorRgba )
+void Renderer::SetBlendFunc(BlendFactor::Type srcFactorRgba, BlendFactor::Type destFactorRgba)
{
- mBlendingOptions.SetBlendFunc( srcFactorRgba, destFactorRgba, srcFactorRgba, destFactorRgba );
- SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
+ mBlendingOptions.SetBlendFunc(srcFactorRgba, destFactorRgba, srcFactorRgba, destFactorRgba);
+ SetBlendingOptionsMessage(GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask());
}
-void Renderer::SetBlendFunc( BlendFactor::Type srcFactorRgb,
- BlendFactor::Type destFactorRgb,
- BlendFactor::Type srcFactorAlpha,
- BlendFactor::Type destFactorAlpha )
+void Renderer::SetBlendFunc(BlendFactor::Type srcFactorRgb,
+ BlendFactor::Type destFactorRgb,
+ BlendFactor::Type srcFactorAlpha,
+ BlendFactor::Type destFactorAlpha)
{
- mBlendingOptions.SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
+ mBlendingOptions.SetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
+ SetBlendingOptionsMessage(GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask());
}
-void Renderer::GetBlendFunc( BlendFactor::Type& srcFactorRgb,
- BlendFactor::Type& destFactorRgb,
- BlendFactor::Type& srcFactorAlpha,
- BlendFactor::Type& destFactorAlpha ) const
+void Renderer::GetBlendFunc(BlendFactor::Type& srcFactorRgb,
+ BlendFactor::Type& destFactorRgb,
+ BlendFactor::Type& srcFactorAlpha,
+ BlendFactor::Type& destFactorAlpha) const
{
srcFactorRgb = mBlendingOptions.GetBlendSrcFactorRgb();
destFactorRgb = mBlendingOptions.GetBlendDestFactorRgb();
destFactorAlpha = mBlendingOptions.GetBlendDestFactorAlpha();
}
-void Renderer::SetBlendEquation( DevelBlendEquation::Type equationRgba )
+void Renderer::SetBlendEquation(DevelBlendEquation::Type equationRgba)
{
- mBlendingOptions.SetBlendEquation( equationRgba, equationRgba );
- SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
+ mBlendingOptions.SetBlendEquation(equationRgba, equationRgba);
+ SetBlendingOptionsMessage(GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask());
}
-void Renderer::SetBlendEquation( DevelBlendEquation::Type equationRgb,
- DevelBlendEquation::Type equationAlpha )
+void Renderer::SetBlendEquation(DevelBlendEquation::Type equationRgb,
+ DevelBlendEquation::Type equationAlpha)
{
- if( mBlendingOptions.IsAdvancedBlendEquation( equationRgb ) || mBlendingOptions.IsAdvancedBlendEquation( equationAlpha ) )
+ if(mBlendingOptions.IsAdvancedBlendEquation(equationRgb) || mBlendingOptions.IsAdvancedBlendEquation(equationAlpha))
{
DALI_LOG_ERROR("Advanced blend equation requires to be set by using SetBlendEquation( DevelBlendEquation::Type equationRgba ).");
return;
}
- mBlendingOptions.SetBlendEquation( equationRgb, equationAlpha );
- SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
+ mBlendingOptions.SetBlendEquation(equationRgb, equationAlpha);
+ SetBlendingOptionsMessage(GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask());
}
-void Renderer::GetBlendEquation( DevelBlendEquation::Type& equationRgb,
- DevelBlendEquation::Type& equationAlpha ) const
+void Renderer::GetBlendEquation(DevelBlendEquation::Type& equationRgb,
+ DevelBlendEquation::Type& equationAlpha) const
{
// These are not animatable, the cached values are up-to-date.
equationRgb = mBlendingOptions.GetBlendEquationRgb();
equationAlpha = mBlendingOptions.GetBlendEquationAlpha();
}
-void Renderer::SetIndexedDrawFirstElement( uint32_t firstElement )
+void Renderer::SetIndexedDrawFirstElement(uint32_t firstElement)
{
- if( firstElement != mIndexedDrawFirstElement )
+ if(firstElement != mIndexedDrawFirstElement)
{
mIndexedDrawFirstElement = firstElement;
- SetIndexedDrawFirstElementMessage( GetEventThreadServices(), GetRendererSceneObject(), mIndexedDrawFirstElement );
+ SetIndexedDrawFirstElementMessage(GetEventThreadServices(), GetRendererSceneObject(), mIndexedDrawFirstElement);
}
}
-void Renderer::SetIndexedDrawElementsCount( uint32_t elementsCount )
+void Renderer::SetIndexedDrawElementsCount(uint32_t elementsCount)
{
- if( elementsCount != mIndexedDrawElementCount )
+ if(elementsCount != mIndexedDrawElementCount)
{
mIndexedDrawElementCount = elementsCount;
- SetIndexedDrawElementsCountMessage( GetEventThreadServices(), GetRendererSceneObject(), mIndexedDrawElementCount );
+ SetIndexedDrawElementsCountMessage(GetEventThreadServices(), GetRendererSceneObject(), mIndexedDrawElementCount);
}
}
-
-void Renderer::EnablePreMultipliedAlpha( bool preMultipled )
+void Renderer::EnablePreMultipliedAlpha(bool preMultipled)
{
- if( mPremultipledAlphaEnabled != preMultipled )
+ if(mPremultipledAlphaEnabled != preMultipled)
{
- if( preMultipled )
+ if(preMultipled)
{
- SetBlendFunc( BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA );
+ SetBlendFunc(BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA);
}
else
{
- SetBlendFunc( BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA );
+ SetBlendFunc(BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA);
}
mPremultipledAlphaEnabled = preMultipled;
- SetEnablePreMultipliedAlphaMessage( GetEventThreadServices(), GetRendererSceneObject(), mPremultipledAlphaEnabled );
+ SetEnablePreMultipliedAlphaMessage(GetEventThreadServices(), GetRendererSceneObject(), mPremultipledAlphaEnabled);
}
}
bool Renderer::IsAdvancedBlendEquationApplied() const
{
DevelBlendEquation::Type equationRgb, equationAlpha;
- GetBlendEquation( equationRgb, equationAlpha );
+ GetBlendEquation(equationRgb, equationAlpha);
- if( equationRgb != equationAlpha )
+ if(equationRgb != equationAlpha)
{
return false;
}
- return mBlendingOptions.IsAdvancedBlendEquation( equationRgb );
+ return mBlendingOptions.IsAdvancedBlendEquation(equationRgb);
}
const SceneGraph::Renderer& Renderer::GetRendererSceneObject() const
{
- return static_cast<const SceneGraph::Renderer&>( GetSceneObject() );
+ return static_cast<const SceneGraph::Renderer&>(GetSceneObject());
}
-void Renderer::SetDefaultProperty( Property::Index index,
- const Property::Value& propertyValue )
+void Renderer::SetDefaultProperty(Property::Index index,
+ const Property::Value& propertyValue)
{
- switch( index )
+ switch(index)
{
case Dali::Renderer::Property::DEPTH_INDEX:
{
- SetDepthIndex( propertyValue.Get<int32_t>() );
+ SetDepthIndex(propertyValue.Get<int32_t>());
break;
}
case Dali::Renderer::Property::FACE_CULLING_MODE:
{
FaceCullingMode::Type convertedValue = mFaceCullingMode;
- if( Scripting::GetEnumerationProperty< FaceCullingMode::Type >( propertyValue, FACE_CULLING_MODE_TABLE, FACE_CULLING_MODE_TABLE_COUNT, convertedValue ) )
+ if(Scripting::GetEnumerationProperty<FaceCullingMode::Type>(propertyValue, FACE_CULLING_MODE_TABLE, FACE_CULLING_MODE_TABLE_COUNT, convertedValue))
{
mFaceCullingMode = convertedValue;
- SetFaceCullingModeMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
+ SetFaceCullingModeMessage(GetEventThreadServices(), GetRendererSceneObject(), convertedValue);
}
break;
}
case Dali::Renderer::Property::BLEND_MODE:
{
BlendMode::Type convertedValue = mBlendMode;
- if( Scripting::GetEnumerationProperty< BlendMode::Type >( propertyValue, BLEND_MODE_TABLE, BLEND_MODE_TABLE_COUNT, convertedValue ) )
+ if(Scripting::GetEnumerationProperty<BlendMode::Type>(propertyValue, BLEND_MODE_TABLE, BLEND_MODE_TABLE_COUNT, convertedValue))
{
- SetBlendMode( convertedValue );
+ SetBlendMode(convertedValue);
}
break;
}
{
DevelBlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationRgb();
- if( Scripting::GetEnumerationProperty< DevelBlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) )
+ if(Scripting::GetEnumerationProperty<DevelBlendEquation::Type>(propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue))
{
- mBlendingOptions.SetBlendEquation( convertedValue, convertedValue );
- SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
+ mBlendingOptions.SetBlendEquation(convertedValue, convertedValue);
+ SetBlendingOptionsMessage(GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask());
}
break;
}
{
DevelBlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationRgb();
- if( Scripting::GetEnumerationProperty< DevelBlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) )
+ if(Scripting::GetEnumerationProperty<DevelBlendEquation::Type>(propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue))
{
- if( mBlendingOptions.IsAdvancedBlendEquation( convertedValue ) )
+ if(mBlendingOptions.IsAdvancedBlendEquation(convertedValue))
{
DALI_LOG_ERROR("Advanced blend equation requires to be set by using DevelBlendEquation::BLEND_EQUATION.");
break;
}
DevelBlendEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
- mBlendingOptions.SetBlendEquation( convertedValue, alphaEquation );
- SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
+ mBlendingOptions.SetBlendEquation(convertedValue, alphaEquation);
+ SetBlendingOptionsMessage(GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask());
}
break;
}
{
DevelBlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationAlpha();
- if( Scripting::GetEnumerationProperty< DevelBlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) )
+ if(Scripting::GetEnumerationProperty<DevelBlendEquation::Type>(propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue))
{
- if( mBlendingOptions.IsAdvancedBlendEquation( convertedValue ) )
+ if(mBlendingOptions.IsAdvancedBlendEquation(convertedValue))
{
DALI_LOG_ERROR("Advanced blend equation requires to be set by using DevelBlendEquation::BLEND_EQUATION.");
break;
}
DevelBlendEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb();
- mBlendingOptions.SetBlendEquation( rgbEquation, convertedValue );
- SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
+ mBlendingOptions.SetBlendEquation(rgbEquation, convertedValue);
+ SetBlendingOptionsMessage(GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask());
}
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB:
{
BlendFactor::Type sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha;
- GetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
+ GetBlendFunc(sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha);
- if( Scripting::GetEnumerationProperty< BlendFactor::Type >( propertyValue, BLEND_FACTOR_TABLE, BLEND_FACTOR_TABLE_COUNT, sourceFactorRgb ) )
+ if(Scripting::GetEnumerationProperty<BlendFactor::Type>(propertyValue, BLEND_FACTOR_TABLE, BLEND_FACTOR_TABLE_COUNT, sourceFactorRgb))
{
- SetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
+ SetBlendFunc(sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha);
}
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB:
{
BlendFactor::Type sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha;
- GetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
+ GetBlendFunc(sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha);
- if( Scripting::GetEnumerationProperty< BlendFactor::Type >( propertyValue, BLEND_FACTOR_TABLE, BLEND_FACTOR_TABLE_COUNT, destinationFactorRgb ) )
+ if(Scripting::GetEnumerationProperty<BlendFactor::Type>(propertyValue, BLEND_FACTOR_TABLE, BLEND_FACTOR_TABLE_COUNT, destinationFactorRgb))
{
- SetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
+ SetBlendFunc(sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha);
}
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA:
{
BlendFactor::Type sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha;
- GetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
+ GetBlendFunc(sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha);
- if( Scripting::GetEnumerationProperty< BlendFactor::Type >( propertyValue, BLEND_FACTOR_TABLE, BLEND_FACTOR_TABLE_COUNT, sourceFactorAlpha ) )
+ if(Scripting::GetEnumerationProperty<BlendFactor::Type>(propertyValue, BLEND_FACTOR_TABLE, BLEND_FACTOR_TABLE_COUNT, sourceFactorAlpha))
{
- SetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
+ SetBlendFunc(sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha);
}
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA:
{
BlendFactor::Type sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha;
- GetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
+ GetBlendFunc(sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha);
- if( Scripting::GetEnumerationProperty< BlendFactor::Type >( propertyValue, BLEND_FACTOR_TABLE, BLEND_FACTOR_TABLE_COUNT, destinationFactorAlpha ) )
+ if(Scripting::GetEnumerationProperty<BlendFactor::Type>(propertyValue, BLEND_FACTOR_TABLE, BLEND_FACTOR_TABLE_COUNT, destinationFactorAlpha))
{
- SetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
+ SetBlendFunc(sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha);
}
break;
}
case Dali::Renderer::Property::BLEND_COLOR:
{
Vector4 blendColor;
- if( propertyValue.Get( blendColor ) )
+ if(propertyValue.Get(blendColor))
{
- SetBlendColor( blendColor );
+ SetBlendColor(blendColor);
}
break;
}
case Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA:
{
bool preMultipled;
- if( propertyValue.Get( preMultipled ) )
+ if(propertyValue.Get(preMultipled))
{
- EnablePreMultipliedAlpha( preMultipled );
+ EnablePreMultipliedAlpha(preMultipled);
}
break;
}
case Dali::Renderer::Property::INDEX_RANGE_FIRST:
{
int32_t firstElement;
- if( propertyValue.Get( firstElement ) )
+ if(propertyValue.Get(firstElement))
{
- SetIndexedDrawFirstElement( firstElement );
+ SetIndexedDrawFirstElement(firstElement);
}
break;
}
case Dali::Renderer::Property::INDEX_RANGE_COUNT:
{
int32_t elementsCount;
- if( propertyValue.Get( elementsCount ) )
+ if(propertyValue.Get(elementsCount))
{
- SetIndexedDrawElementsCount( elementsCount );
+ SetIndexedDrawElementsCount(elementsCount);
}
break;
}
case Dali::Renderer::Property::DEPTH_WRITE_MODE:
{
DepthWriteMode::Type convertedValue = mDepthWriteMode;
- if( Scripting::GetEnumerationProperty< DepthWriteMode::Type >( propertyValue, DEPTH_WRITE_MODE_TABLE, DEPTH_WRITE_MODE_TABLE_COUNT, convertedValue ) )
+ if(Scripting::GetEnumerationProperty<DepthWriteMode::Type>(propertyValue, DEPTH_WRITE_MODE_TABLE, DEPTH_WRITE_MODE_TABLE_COUNT, convertedValue))
{
mDepthWriteMode = convertedValue;
- SetDepthWriteModeMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
+ SetDepthWriteModeMessage(GetEventThreadServices(), GetRendererSceneObject(), convertedValue);
}
break;
}
case Dali::Renderer::Property::DEPTH_FUNCTION:
{
DepthFunction::Type convertedValue = mDepthFunction;
- if( Scripting::GetEnumerationProperty< DepthFunction::Type >( propertyValue, DEPTH_FUNCTION_TABLE, DEPTH_FUNCTION_TABLE_COUNT, convertedValue ) )
+ if(Scripting::GetEnumerationProperty<DepthFunction::Type>(propertyValue, DEPTH_FUNCTION_TABLE, DEPTH_FUNCTION_TABLE_COUNT, convertedValue))
{
mDepthFunction = convertedValue;
- SetDepthFunctionMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
+ SetDepthFunctionMessage(GetEventThreadServices(), GetRendererSceneObject(), convertedValue);
}
break;
}
case Dali::Renderer::Property::DEPTH_TEST_MODE:
{
DepthTestMode::Type convertedValue = mDepthTestMode;
- if( Scripting::GetEnumerationProperty< DepthTestMode::Type >( propertyValue, DEPTH_TEST_MODE_TABLE, DEPTH_TEST_MODE_TABLE_COUNT, convertedValue ) )
+ if(Scripting::GetEnumerationProperty<DepthTestMode::Type>(propertyValue, DEPTH_TEST_MODE_TABLE, DEPTH_TEST_MODE_TABLE_COUNT, convertedValue))
{
mDepthTestMode = convertedValue;
- SetDepthTestModeMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
+ SetDepthTestModeMessage(GetEventThreadServices(), GetRendererSceneObject(), convertedValue);
}
break;
}
case Dali::Renderer::Property::RENDER_MODE:
{
RenderMode::Type convertedValue = mStencilParameters.renderMode;
- if( Scripting::GetEnumerationProperty< RenderMode::Type >( propertyValue, RENDER_MODE_TABLE, RENDER_MODE_TABLE_COUNT, convertedValue ) )
+ if(Scripting::GetEnumerationProperty<RenderMode::Type>(propertyValue, RENDER_MODE_TABLE, RENDER_MODE_TABLE_COUNT, convertedValue))
{
mStencilParameters.renderMode = convertedValue;
- SetRenderModeMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
+ SetRenderModeMessage(GetEventThreadServices(), GetRendererSceneObject(), convertedValue);
}
break;
}
case Dali::Renderer::Property::STENCIL_FUNCTION:
{
StencilFunction::Type convertedValue = mStencilParameters.stencilFunction;
- if( Scripting::GetEnumerationProperty< StencilFunction::Type >( propertyValue, STENCIL_FUNCTION_TABLE, STENCIL_FUNCTION_TABLE_COUNT, convertedValue ) )
+ if(Scripting::GetEnumerationProperty<StencilFunction::Type>(propertyValue, STENCIL_FUNCTION_TABLE, STENCIL_FUNCTION_TABLE_COUNT, convertedValue))
{
mStencilParameters.stencilFunction = convertedValue;
- SetStencilFunctionMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
+ SetStencilFunctionMessage(GetEventThreadServices(), GetRendererSceneObject(), convertedValue);
}
break;
}
case Dali::Renderer::Property::STENCIL_FUNCTION_MASK:
{
int32_t stencilFunctionMask;
- if( propertyValue.Get( stencilFunctionMask ) )
+ if(propertyValue.Get(stencilFunctionMask))
{
- if( stencilFunctionMask != mStencilParameters.stencilFunctionMask )
+ if(stencilFunctionMask != mStencilParameters.stencilFunctionMask)
{
mStencilParameters.stencilFunctionMask = stencilFunctionMask;
- SetStencilFunctionMaskMessage( GetEventThreadServices(), GetRendererSceneObject(), stencilFunctionMask );
+ SetStencilFunctionMaskMessage(GetEventThreadServices(), GetRendererSceneObject(), stencilFunctionMask);
}
}
break;
case Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE:
{
int32_t stencilFunctionReference;
- if( propertyValue.Get( stencilFunctionReference ) )
+ if(propertyValue.Get(stencilFunctionReference))
{
- if( stencilFunctionReference != mStencilParameters.stencilFunctionReference )
+ if(stencilFunctionReference != mStencilParameters.stencilFunctionReference)
{
mStencilParameters.stencilFunctionReference = stencilFunctionReference;
- SetStencilFunctionReferenceMessage( GetEventThreadServices(), GetRendererSceneObject(), stencilFunctionReference );
+ SetStencilFunctionReferenceMessage(GetEventThreadServices(), GetRendererSceneObject(), stencilFunctionReference);
}
}
break;
case Dali::Renderer::Property::STENCIL_MASK:
{
int32_t stencilMask;
- if( propertyValue.Get( stencilMask ) )
+ if(propertyValue.Get(stencilMask))
{
- if( stencilMask != mStencilParameters.stencilMask )
+ if(stencilMask != mStencilParameters.stencilMask)
{
mStencilParameters.stencilMask = stencilMask;
- SetStencilMaskMessage( GetEventThreadServices(), GetRendererSceneObject(), stencilMask );
+ SetStencilMaskMessage(GetEventThreadServices(), GetRendererSceneObject(), stencilMask);
}
}
break;
case Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL:
{
StencilOperation::Type convertedValue = mStencilParameters.stencilOperationOnFail;
- if( Scripting::GetEnumerationProperty< StencilOperation::Type >( propertyValue, STENCIL_OPERATION_TABLE, STENCIL_OPERATION_TABLE_COUNT, convertedValue ) )
+ if(Scripting::GetEnumerationProperty<StencilOperation::Type>(propertyValue, STENCIL_OPERATION_TABLE, STENCIL_OPERATION_TABLE_COUNT, convertedValue))
{
mStencilParameters.stencilOperationOnFail = convertedValue;
- SetStencilOperationOnFailMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
+ SetStencilOperationOnFailMessage(GetEventThreadServices(), GetRendererSceneObject(), convertedValue);
}
break;
}
case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL:
{
StencilOperation::Type convertedValue = mStencilParameters.stencilOperationOnZFail;
- if( Scripting::GetEnumerationProperty< StencilOperation::Type >( propertyValue, STENCIL_OPERATION_TABLE, STENCIL_OPERATION_TABLE_COUNT, convertedValue ) )
+ if(Scripting::GetEnumerationProperty<StencilOperation::Type>(propertyValue, STENCIL_OPERATION_TABLE, STENCIL_OPERATION_TABLE_COUNT, convertedValue))
{
mStencilParameters.stencilOperationOnZFail = convertedValue;
- SetStencilOperationOnZFailMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
+ SetStencilOperationOnZFailMessage(GetEventThreadServices(), GetRendererSceneObject(), convertedValue);
}
break;
}
case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS:
{
StencilOperation::Type convertedValue = mStencilParameters.stencilOperationOnZPass;
- if( Scripting::GetEnumerationProperty< StencilOperation::Type >( propertyValue, STENCIL_OPERATION_TABLE, STENCIL_OPERATION_TABLE_COUNT, convertedValue ) )
+ if(Scripting::GetEnumerationProperty<StencilOperation::Type>(propertyValue, STENCIL_OPERATION_TABLE, STENCIL_OPERATION_TABLE_COUNT, convertedValue))
{
mStencilParameters.stencilOperationOnZPass = convertedValue;
- SetStencilOperationOnZPassMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
+ SetStencilOperationOnZPassMessage(GetEventThreadServices(), GetRendererSceneObject(), convertedValue);
}
break;
}
case Dali::DevelRenderer::Property::OPACITY:
{
float opacity;
- if( propertyValue.Get( opacity ) )
+ if(propertyValue.Get(opacity))
{
- if( !Equals( mOpacity, opacity ) )
+ if(!Equals(mOpacity, opacity))
{
mOpacity = opacity;
- BakeOpacityMessage( GetEventThreadServices(), GetRendererSceneObject(), mOpacity );
+ BakeOpacityMessage(GetEventThreadServices(), GetRendererSceneObject(), mOpacity);
}
}
break;
case DevelRenderer::Property::RENDERING_BEHAVIOR:
{
DevelRenderer::Rendering::Type convertedValue = mRenderingBehavior;
- if( Scripting::GetEnumerationProperty< DevelRenderer::Rendering::Type >( propertyValue, RENDERING_BEHAVIOR_TABLE, RENDERING_BEHAVIOR_TABLE_COUNT, convertedValue ) )
+ if(Scripting::GetEnumerationProperty<DevelRenderer::Rendering::Type>(propertyValue, RENDERING_BEHAVIOR_TABLE, RENDERING_BEHAVIOR_TABLE_COUNT, convertedValue))
{
mRenderingBehavior = convertedValue;
- SetRenderingBehaviorMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
+ SetRenderingBehaviorMessage(GetEventThreadServices(), GetRendererSceneObject(), convertedValue);
}
break;
}
}
}
-Property::Value Renderer::GetDefaultProperty( Property::Index index ) const
+Property::Value Renderer::GetDefaultProperty(Property::Index index) const
{
Property::Value value;
- if( ! GetCachedPropertyValue( index, value ) )
+ if(!GetCachedPropertyValue(index, value))
{
// If property value is not stored in the event-side, then it must be a scene-graph only property
- GetCurrentPropertyValue( index, value );
+ GetCurrentPropertyValue(index, value);
}
return value;
}
-Property::Value Renderer::GetDefaultPropertyCurrentValue( Property::Index index ) const
+Property::Value Renderer::GetDefaultPropertyCurrentValue(Property::Index index) const
{
Property::Value value;
- if( ! GetCurrentPropertyValue( index, value ) )
+ if(!GetCurrentPropertyValue(index, value))
{
// If unable to retrieve scene-graph property value, then it must be an event-side only property
- GetCachedPropertyValue( index, value );
+ GetCachedPropertyValue(index, value);
}
return value;
}
-void Renderer::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
+void Renderer::OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType)
{
- switch( animationType )
+ switch(animationType)
{
case Animation::TO:
case Animation::BETWEEN:
{
- switch( index )
+ switch(index)
{
case Dali::DevelRenderer::Property::OPACITY:
{
- value.Get( mOpacity );
+ value.Get(mOpacity);
break;
}
}
case Animation::BY:
{
- switch( index )
+ switch(index)
{
case Dali::DevelRenderer::Property::OPACITY:
{
- AdjustValue< float >( mOpacity, value );
+ AdjustValue<float>(mOpacity, value);
break;
}
}
}
}
-const SceneGraph::PropertyBase* Renderer::GetSceneObjectAnimatableProperty( Property::Index index ) const
+const SceneGraph::PropertyBase* Renderer::GetSceneObjectAnimatableProperty(Property::Index index) const
{
const SceneGraph::PropertyBase* property = nullptr;
- if( index == DevelRenderer::Property::OPACITY )
+ if(index == DevelRenderer::Property::OPACITY)
{
property = &GetRendererSceneObject().mOpacity;
}
- if( !property )
+ if(!property)
{
// not our property, ask base
- property = Object::GetSceneObjectAnimatableProperty( index );
+ property = Object::GetSceneObjectAnimatableProperty(index);
}
return property;
}
-const PropertyInputImpl* Renderer::GetSceneObjectInputProperty( Property::Index index ) const
+const PropertyInputImpl* Renderer::GetSceneObjectInputProperty(Property::Index index) const
{
// reuse animatable property getter, Object::GetSceneObjectInputProperty does the same so no need to call that0
- return GetSceneObjectAnimatableProperty( index );
+ return GetSceneObjectAnimatableProperty(index);
}
-Renderer::Renderer( const SceneGraph::Renderer* sceneObject )
-: Object( sceneObject ),
- mDepthIndex( 0 ),
- mIndexedDrawFirstElement( 0 ),
- mIndexedDrawElementCount( 0 ),
- mStencilParameters( RenderMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ),
+Renderer::Renderer(const SceneGraph::Renderer* sceneObject)
+: Object(sceneObject),
+ mDepthIndex(0),
+ mIndexedDrawFirstElement(0),
+ mIndexedDrawElementCount(0),
+ mStencilParameters(RenderMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP),
mBlendingOptions(),
- mOpacity( 1.0f ),
- mDepthFunction( DepthFunction::LESS ),
- mFaceCullingMode( FaceCullingMode::NONE ),
- mBlendMode( BlendMode::AUTO ),
- mDepthWriteMode( DepthWriteMode::AUTO ),
- mDepthTestMode( DepthTestMode::AUTO ),
- mRenderingBehavior( DevelRenderer::Rendering::IF_REQUIRED ),
- mPremultipledAlphaEnabled( false )
+ mOpacity(1.0f),
+ mDepthFunction(DepthFunction::LESS),
+ mFaceCullingMode(FaceCullingMode::NONE),
+ mBlendMode(BlendMode::AUTO),
+ mDepthWriteMode(DepthWriteMode::AUTO),
+ mDepthTestMode(DepthTestMode::AUTO),
+ mRenderingBehavior(DevelRenderer::Rendering::IF_REQUIRED),
+ mPremultipledAlphaEnabled(false)
{
}
-void Renderer::SetBlendColor( const Vector4& blendColor )
+void Renderer::SetBlendColor(const Vector4& blendColor)
{
- mBlendingOptions.SetBlendColor( blendColor );
- SetBlendColorMessage( GetEventThreadServices(), GetRendererSceneObject(), GetBlendColor() );
+ mBlendingOptions.SetBlendColor(blendColor);
+ SetBlendColorMessage(GetEventThreadServices(), GetRendererSceneObject(), GetBlendColor());
}
const Vector4& Renderer::GetBlendColor() const
{
const Vector4* blendColor = mBlendingOptions.GetBlendColor();
- if( blendColor )
+ if(blendColor)
{
return *blendColor;
}
Renderer::~Renderer()
{
- if( EventThreadServices::IsCoreRunning() )
+ if(EventThreadServices::IsCoreRunning())
{
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
- RemoveRendererMessage( updateManager, GetRendererSceneObject() );
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+ RemoveRendererMessage(updateManager, GetRendererSceneObject());
- eventThreadServices.UnregisterObject( this );
+ eventThreadServices.UnregisterObject(this);
}
}
-bool Renderer::GetCachedPropertyValue( Property::Index index, Property::Value& value ) const
+bool Renderer::GetCachedPropertyValue(Property::Index index, Property::Value& value) const
{
bool valueSet = true;
- switch( index )
+ switch(index)
{
case Dali::Renderer::Property::DEPTH_INDEX:
{
}
case Dali::DevelRenderer::Property::BLEND_EQUATION:
{
- value = static_cast<int32_t>( mBlendingOptions.GetBlendEquationRgb() );
+ value = static_cast<int32_t>(mBlendingOptions.GetBlendEquationRgb());
break;
}
case Dali::Renderer::Property::BLEND_EQUATION_RGB:
{
- value = static_cast<int32_t>( mBlendingOptions.GetBlendEquationRgb() );
+ value = static_cast<int32_t>(mBlendingOptions.GetBlendEquationRgb());
break;
}
case Dali::Renderer::Property::BLEND_EQUATION_ALPHA:
{
- value = static_cast<int32_t>( mBlendingOptions.GetBlendEquationAlpha() );
+ value = static_cast<int32_t>(mBlendingOptions.GetBlendEquationAlpha());
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB:
BlendFactor::Type destFactorRgb;
BlendFactor::Type srcFactorAlpha;
BlendFactor::Type destFactorAlpha;
- GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- value = static_cast<int32_t>( srcFactorRgb );
+ GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
+ value = static_cast<int32_t>(srcFactorRgb);
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB:
BlendFactor::Type destFactorRgb;
BlendFactor::Type srcFactorAlpha;
BlendFactor::Type destFactorAlpha;
- GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- value = static_cast<int32_t>( destFactorRgb );
+ GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
+ value = static_cast<int32_t>(destFactorRgb);
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA:
BlendFactor::Type destFactorRgb;
BlendFactor::Type srcFactorAlpha;
BlendFactor::Type destFactorAlpha;
- GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- value = static_cast<int32_t>( srcFactorAlpha );
+ GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
+ value = static_cast<int32_t>(srcFactorAlpha);
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA:
BlendFactor::Type destFactorRgb;
BlendFactor::Type srcFactorAlpha;
BlendFactor::Type destFactorAlpha;
- GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- value = static_cast<int32_t>( destFactorAlpha );
+ GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
+ value = static_cast<int32_t>(destFactorAlpha);
break;
}
case Dali::Renderer::Property::BLEND_COLOR:
}
case Dali::Renderer::Property::INDEX_RANGE_FIRST:
{
- value = static_cast<int32_t>( mIndexedDrawFirstElement );
+ value = static_cast<int32_t>(mIndexedDrawFirstElement);
break;
}
case Dali::Renderer::Property::INDEX_RANGE_COUNT:
{
- value = static_cast<int32_t>( mIndexedDrawElementCount );
+ value = static_cast<int32_t>(mIndexedDrawElementCount);
break;
}
case Dali::Renderer::Property::DEPTH_WRITE_MODE:
return valueSet;
}
-bool Renderer::GetCurrentPropertyValue( Property::Index index, Property::Value& value ) const
+bool Renderer::GetCurrentPropertyValue(Property::Index index, Property::Value& value) const
{
- bool valueSet = true;
+ bool valueSet = true;
const SceneGraph::Renderer& sceneObject = GetRendererSceneObject();
- switch( index )
+ switch(index)
{
case Dali::Renderer::Property::DEPTH_INDEX:
{
}
case Dali::DevelRenderer::Property::BLEND_EQUATION:
{
- uint32_t bitMask = sceneObject.GetBlendingOptions();
+ uint32_t bitMask = sceneObject.GetBlendingOptions();
BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( bitMask );
- value = static_cast<int32_t>( blendingOptions.GetBlendEquationRgb() );
+ blendingOptions.SetBitmask(bitMask);
+ value = static_cast<int32_t>(blendingOptions.GetBlendEquationRgb());
break;
}
case Dali::Renderer::Property::BLEND_EQUATION_RGB:
{
- uint32_t bitMask = sceneObject.GetBlendingOptions();
+ uint32_t bitMask = sceneObject.GetBlendingOptions();
BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( bitMask );
- value = static_cast<int32_t>( blendingOptions.GetBlendEquationRgb() );
+ blendingOptions.SetBitmask(bitMask);
+ value = static_cast<int32_t>(blendingOptions.GetBlendEquationRgb());
break;
}
case Dali::Renderer::Property::BLEND_EQUATION_ALPHA:
{
- uint32_t bitMask = sceneObject.GetBlendingOptions();
+ uint32_t bitMask = sceneObject.GetBlendingOptions();
BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( bitMask );
- value = static_cast<int32_t>( blendingOptions.GetBlendEquationAlpha() );
+ blendingOptions.SetBitmask(bitMask);
+ value = static_cast<int32_t>(blendingOptions.GetBlendEquationAlpha());
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB:
{
- uint32_t bitMask = sceneObject.GetBlendingOptions();
+ uint32_t bitMask = sceneObject.GetBlendingOptions();
BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( bitMask );
- value = static_cast<int32_t>( blendingOptions.GetBlendSrcFactorRgb() );
+ blendingOptions.SetBitmask(bitMask);
+ value = static_cast<int32_t>(blendingOptions.GetBlendSrcFactorRgb());
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB:
{
- uint32_t bitMask = sceneObject.GetBlendingOptions();
+ uint32_t bitMask = sceneObject.GetBlendingOptions();
BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( bitMask );
- value = static_cast<int32_t>( blendingOptions.GetBlendDestFactorRgb() );
+ blendingOptions.SetBitmask(bitMask);
+ value = static_cast<int32_t>(blendingOptions.GetBlendDestFactorRgb());
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA:
{
- uint32_t bitMask = sceneObject.GetBlendingOptions();
+ uint32_t bitMask = sceneObject.GetBlendingOptions();
BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( bitMask );
- value = static_cast<int32_t>( blendingOptions.GetBlendSrcFactorAlpha() );
+ blendingOptions.SetBitmask(bitMask);
+ value = static_cast<int32_t>(blendingOptions.GetBlendSrcFactorAlpha());
break;
}
case Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA:
{
- uint32_t bitMask = sceneObject.GetBlendingOptions();
+ uint32_t bitMask = sceneObject.GetBlendingOptions();
BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( bitMask );
- value = static_cast<int32_t>( blendingOptions.GetBlendDestFactorAlpha() );
+ blendingOptions.SetBitmask(bitMask);
+ value = static_cast<int32_t>(blendingOptions.GetBlendDestFactorAlpha());
break;
}
case Dali::Renderer::Property::BLEND_COLOR:
}
case Dali::Renderer::Property::INDEX_RANGE_FIRST:
{
- value = static_cast<int32_t>( sceneObject.GetIndexedDrawFirstElement() );
+ value = static_cast<int32_t>(sceneObject.GetIndexedDrawFirstElement());
break;
}
case Dali::Renderer::Property::INDEX_RANGE_COUNT:
{
- value = static_cast<int32_t>( sceneObject.GetIndexedDrawElementsCount() );
+ value = static_cast<int32_t>(sceneObject.GetIndexedDrawElementsCount());
break;
}
case Dali::Renderer::Property::DEPTH_WRITE_MODE:
case Dali::Renderer::Property::STENCIL_FUNCTION:
{
Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
- value = stencilParameters.stencilFunction;
+ value = stencilParameters.stencilFunction;
break;
}
case Dali::Renderer::Property::STENCIL_FUNCTION_MASK:
{
Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
- value = stencilParameters.stencilFunctionMask;
+ value = stencilParameters.stencilFunctionMask;
break;
}
case Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE:
{
Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
- value = stencilParameters.stencilFunctionReference;
+ value = stencilParameters.stencilFunctionReference;
break;
}
case Dali::Renderer::Property::STENCIL_MASK:
{
Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
- value = stencilParameters.stencilMask;
+ value = stencilParameters.stencilMask;
break;
}
case Dali::Renderer::Property::RENDER_MODE:
{
Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
- value = stencilParameters.renderMode;
+ value = stencilParameters.renderMode;
break;
}
case Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL:
{
Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
- value = stencilParameters.stencilOperationOnFail;
+ value = stencilParameters.stencilOperationOnFail;
break;
}
case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL:
{
Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
- value = stencilParameters.stencilOperationOnZFail;
+ value = stencilParameters.stencilOperationOnZFail;
break;
}
case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS:
{
Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
- value = stencilParameters.stencilOperationOnZPass;
+ value = stencilParameters.stencilOperationOnZPass;
break;
}
case Dali::DevelRenderer::Property::OPACITY:
{
- value = sceneObject.GetOpacity( GetEventThreadServices().GetEventBufferIndex() );
+ value = sceneObject.GetOpacity(GetEventThreadServices().GetEventBufferIndex());
break;
}
case Dali::DevelRenderer::Property::RENDERING_BEHAVIOR:
return valueSet;
}
-void Renderer::AddDrawCommand( const Dali::DevelRenderer::DrawCommand& command )
+void Renderer::AddDrawCommand(const Dali::DevelRenderer::DrawCommand& command)
{
if(!mDrawCommands.capacity())
{
mDrawCommands.reserve(8);
}
- mDrawCommands.emplace_back( command );
+ mDrawCommands.emplace_back(command);
- Dali::Internal::SceneGraph::SetDrawCommandsMessage( GetEventThreadServices(),
- GetRendererSceneObject(),
- mDrawCommands.data(),
- uint32_t(mDrawCommands.size())
+ Dali::Internal::SceneGraph::SetDrawCommandsMessage(GetEventThreadServices(),
+ GetRendererSceneObject(),
+ mDrawCommands.data(),
+ uint32_t(mDrawCommands.size())
);
}
-
} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_RENDERER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
-#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
-#include <dali/public-api/rendering/renderer.h> // Dali::Renderer
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/internal/common/blending-options.h>
-#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
-#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
+#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
+#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
+#include <dali/internal/event/rendering/geometry-impl.h> // Dali::Internal::Geometry
#include <dali/internal/event/rendering/texture-set-impl.h> // Dali::Internal::TextureSet
-#include <dali/internal/event/rendering/geometry-impl.h> // Dali::Internal::Geometry
#include <dali/internal/render/renderers/render-renderer.h> // Dali::Render::Renderer::StencilParameters
+#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
+#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
+#include <dali/public-api/rendering/renderer.h> // Dali::Renderer
namespace Dali
{
class Renderer : public Object
{
public:
-
/**
* Create a new Renderer.
* @return A smart-pointer to the newly allocated Renderer.
/**
* @copydoc Dali::Renderer::SetGeometry()
*/
- void SetGeometry( Geometry& geometry );
+ void SetGeometry(Geometry& geometry);
/**
* @copydoc Dali::Renderer::GetGeometry()
/**
* @copydoc Dali::Renderer::SetTextures()
*/
- void SetTextures( TextureSet& textureSet );
+ void SetTextures(TextureSet& textureSet);
/**
* @copydoc Dali::Renderer::GetTextures()
/**
* @copydoc Dali::Renderer::SetShader()
*/
- void SetShader( Shader& shader );
+ void SetShader(Shader& shader);
/**
* @copydoc Dali::Renderer::GetShader()
/**
* @copydoc Dali::Renderer::SetDepthIndex()
*/
- void SetDepthIndex( int32_t depthIndex );
+ void SetDepthIndex(int32_t depthIndex);
/**
* @copydoc Dali::Renderer::GetDepthIndex()
/**
* @copydoc Dali::Renderer::SetBlendMode()
*/
- void SetBlendMode( BlendMode::Type mode );
+ void SetBlendMode(BlendMode::Type mode);
/**
* @copydoc Dali::Renderer::GetBlendMode()
/**
* @copydoc Dali::Renderer::SetBlendFunc()
*/
- void SetBlendFunc( BlendFactor::Type srcFactorRgba, BlendFactor::Type destFactorRgba );
+ void SetBlendFunc(BlendFactor::Type srcFactorRgba, BlendFactor::Type destFactorRgba);
/**
* @copydoc Dali::Renderer::SetBlendFunc()
*/
- void SetBlendFunc( BlendFactor::Type srcFactorRgb, BlendFactor::Type destFactorRgb,
- BlendFactor::Type srcFactorAlpha, BlendFactor::Type destFactorAlpha );
+ void SetBlendFunc(BlendFactor::Type srcFactorRgb, BlendFactor::Type destFactorRgb, BlendFactor::Type srcFactorAlpha, BlendFactor::Type destFactorAlpha);
/**
* @copydoc Dali::Renderer::GetBlendFunc()
*/
- void GetBlendFunc( BlendFactor::Type& srcFactorRgb, BlendFactor::Type& destFactorRgb,
- BlendFactor::Type& srcFactorAlpha, BlendFactor::Type& destFactorAlpha ) const;
+ void GetBlendFunc(BlendFactor::Type& srcFactorRgb, BlendFactor::Type& destFactorRgb, BlendFactor::Type& srcFactorAlpha, BlendFactor::Type& destFactorAlpha) const;
/**
* @brief Set same Blend Equation for the RGB and alpha
*/
- void SetBlendEquation( DevelBlendEquation::Type equationRgba );
+ void SetBlendEquation(DevelBlendEquation::Type equationRgba);
/**
* @brief Set Blend Equation separately for the RGB and alpha
*/
- void SetBlendEquation( DevelBlendEquation::Type equationRgb, DevelBlendEquation::Type equationAlpha );
+ void SetBlendEquation(DevelBlendEquation::Type equationRgb, DevelBlendEquation::Type equationAlpha);
/**
* @brief Get Blend Equation of rgb and alpha
*/
- void GetBlendEquation( DevelBlendEquation::Type& equationRgb, DevelBlendEquation::Type& equationAlpha ) const;
+ void GetBlendEquation(DevelBlendEquation::Type& equationRgb, DevelBlendEquation::Type& equationAlpha) const;
/**
* @copydoc Dali::Renderer::SetIndexedDrawFirstElement
*/
- void SetIndexedDrawFirstElement( uint32_t firstElement );
+ void SetIndexedDrawFirstElement(uint32_t firstElement);
/**
* @copydoc Dali::Renderer::SetIndexedDrawElementsCount
*/
- void SetIndexedDrawElementsCount( uint32_t elementsCount );
+ void SetIndexedDrawElementsCount(uint32_t elementsCount);
/**
* @brief Set whether the Pre-multiplied Alpha Blending is required
*
* @param[in] preMultipled whether alpha is pre-multiplied.
*/
- void EnablePreMultipliedAlpha( bool preMultipled );
+ void EnablePreMultipliedAlpha(bool preMultipled);
/**
* @brief Query whether alpha is pre-multiplied.
const SceneGraph::Renderer& GetRendererSceneObject() const;
public: // Default property extensions from Object
-
/**
* @copydoc Dali::Internal::Object::SetDefaultProperty()
*/
/**
* @copydoc Dali::Internal::Object::GetDefaultProperty()
*/
- Property::Value GetDefaultProperty( Property::Index index ) const override;
+ Property::Value GetDefaultProperty(Property::Index index) const override;
/**
* @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
*/
- Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const override;
+ Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
- /**
+ /**
* @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
*/
- void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType ) override;
+ void OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType) override;
/**
* @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
*/
- const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const override;
+ const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty(Property::Index index) const override;
/**
* @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
*/
- const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const override;
+ const PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const override;
/**
* @brief Adds a draw command to the Renderer.
*
* @param[in] command Valid reference to a DrawCommand objects
*/
- void AddDrawCommand( const Dali::DevelRenderer::DrawCommand& command );
+ void AddDrawCommand(const Dali::DevelRenderer::DrawCommand& command);
private: // implementation
-
/**
* @brief Constructor.
*
* @param sceneObject the scene graph renderer
*/
- Renderer( const SceneGraph::Renderer* sceneObject );
+ Renderer(const SceneGraph::Renderer* sceneObject);
/**
* @brief Sets the blend color.
* @param[in] blendColor The blend color to set.
*/
- void SetBlendColor( const Vector4& blendColor );
+ void SetBlendColor(const Vector4& blendColor);
/**
* @brief Retrieves the blend-color.
* @param[out] value Is set with the cached value of the property if found.
* @return True if value set, false otherwise.
*/
- bool GetCachedPropertyValue( Property::Index index, Property::Value& value ) const;
+ bool GetCachedPropertyValue(Property::Index index, Property::Value& value) const;
/**
* @brief Retrieves the current value of a default property from the scene-graph.
* @param[out] value Is set with the current scene-graph value of the property
* @return True if value set, false otherwise.
*/
- bool GetCurrentPropertyValue( Property::Index index, Property::Value& value ) const;
+ bool GetCurrentPropertyValue(Property::Index index, Property::Value& value) const;
protected:
/**
~Renderer() override;
private: // unimplemented methods
- Renderer( const Renderer& );
- Renderer& operator=( const Renderer& );
-
-private: // data
+ Renderer(const Renderer&);
+ Renderer& operator=(const Renderer&);
- GeometryPtr mGeometry; ///< Intrusive pointer to the geometry used by this renderer
- TextureSetPtr mTextureSet; ///< Intrusive pointer to the texture set used by this renderer
- ShaderPtr mShader; ///< Intrusive pointer to the shader used by this renderer
+private: // data
+ GeometryPtr mGeometry; ///< Intrusive pointer to the geometry used by this renderer
+ TextureSetPtr mTextureSet; ///< Intrusive pointer to the texture set used by this renderer
+ ShaderPtr mShader; ///< Intrusive pointer to the shader used by this renderer
- int32_t mDepthIndex;
+ int32_t mDepthIndex;
- uint32_t mIndexedDrawFirstElement; ///< Offset of first element to draw from bound index buffer
- uint32_t mIndexedDrawElementCount; ///< Number of elements to draw
+ uint32_t mIndexedDrawFirstElement; ///< Offset of first element to draw from bound index buffer
+ uint32_t mIndexedDrawElementCount; ///< Number of elements to draw
- Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options
- BlendingOptions mBlendingOptions; ///< Local copy of blending options bitmask
+ Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options
+ BlendingOptions mBlendingOptions; ///< Local copy of blending options bitmask
- float mOpacity; ///< Local copy of the opacity
- DepthFunction::Type mDepthFunction:4; ///< Local copy of the depth function
- FaceCullingMode::Type mFaceCullingMode:3; ///< Local copy of the mode of face culling
- BlendMode::Type mBlendMode:3; ///< Local copy of the mode of blending
- DepthWriteMode::Type mDepthWriteMode:3; ///< Local copy of the depth write mode
- DepthTestMode::Type mDepthTestMode:3; ///< Local copy of the depth test mode
- DevelRenderer::Rendering::Type mRenderingBehavior:2; ///< The rendering behavior
- bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
+ float mOpacity; ///< Local copy of the opacity
+ DepthFunction::Type mDepthFunction : 4; ///< Local copy of the depth function
+ FaceCullingMode::Type mFaceCullingMode : 3; ///< Local copy of the mode of face culling
+ BlendMode::Type mBlendMode : 3; ///< Local copy of the mode of blending
+ DepthWriteMode::Type mDepthWriteMode : 3; ///< Local copy of the depth write mode
+ DepthTestMode::Type mDepthTestMode : 3; ///< Local copy of the depth test mode
+ DevelRenderer::Rendering::Type mRenderingBehavior : 2; ///< The rendering behavior
+ bool mPremultipledAlphaEnabled : 1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
- std::vector<Dali::DevelRenderer::DrawCommand> mDrawCommands; ///< list of draw commands
+ std::vector<Dali::DevelRenderer::DrawCommand> mDrawCommands; ///< list of draw commands
};
} // namespace Internal
// Helpers for public-api forwarding methods
-inline Internal::Renderer& GetImplementation( Dali::Renderer& handle )
+inline Internal::Renderer& GetImplementation(Dali::Renderer& handle)
{
DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
return static_cast<Internal::Renderer&>(object);
}
-inline const Internal::Renderer& GetImplementation( const Dali::Renderer& handle )
+inline const Internal::Renderer& GetImplementation(const Dali::Renderer& handle)
{
DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/common/stage-impl.h>
-#include <dali/internal/update/manager/update-manager.h>
#include <dali/internal/render/renderers/render-sampler.h>
+#include <dali/internal/update/manager/update-manager.h>
namespace Dali
{
namespace Internal
{
-
-SamplerPtr Sampler::New( )
+SamplerPtr Sampler::New()
{
- SamplerPtr sampler( new Sampler() );
+ SamplerPtr sampler(new Sampler());
sampler->Initialize();
return sampler;
}
-void Sampler::SetFilterMode( Dali::FilterMode::Type minFilter, Dali::FilterMode::Type magFilter )
+void Sampler::SetFilterMode(Dali::FilterMode::Type minFilter, Dali::FilterMode::Type magFilter)
{
- if( nullptr != mRenderObject )
+ if(nullptr != mRenderObject)
{
- SetFilterModeMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, static_cast< unsigned int >( minFilter ), static_cast< unsigned int >( magFilter ) );
+ SetFilterModeMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, static_cast<unsigned int>(minFilter), static_cast<unsigned int>(magFilter));
}
}
-void Sampler::SetWrapMode( Dali::WrapMode::Type rWrap, Dali::WrapMode::Type sWrap, Dali::WrapMode::Type tWrap )
+void Sampler::SetWrapMode(Dali::WrapMode::Type rWrap, Dali::WrapMode::Type sWrap, Dali::WrapMode::Type tWrap)
{
- if( nullptr != mRenderObject )
+ if(nullptr != mRenderObject)
{
- SetWrapModeMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, static_cast< unsigned int >( rWrap ), static_cast< unsigned int >( sWrap ), static_cast< unsigned int >( tWrap ) );
+ SetWrapModeMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, static_cast<unsigned int>(rWrap), static_cast<unsigned int>(sWrap), static_cast<unsigned int>(tWrap));
}
}
return mRenderObject;
}
-
Sampler::Sampler()
-:mEventThreadServices( EventThreadServices::Get() ),
- mRenderObject( nullptr )
+: mEventThreadServices(EventThreadServices::Get()),
+ mRenderObject(nullptr)
{
}
SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager();
mRenderObject = new Render::Sampler();
- OwnerPointer< Render::Sampler > transferOwnership( mRenderObject );
- AddSamplerMessage( updateManager, transferOwnership );
+ OwnerPointer<Render::Sampler> transferOwnership(mRenderObject);
+ AddSamplerMessage(updateManager, transferOwnership);
}
Sampler::~Sampler()
{
- if( EventThreadServices::IsCoreRunning() && mRenderObject )
+ if(EventThreadServices::IsCoreRunning() && mRenderObject)
{
SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager();
- RemoveSamplerMessage( updateManager, *mRenderObject );
+ RemoveSamplerMessage(updateManager, *mRenderObject);
}
}
#define DALI_INTERNAL_SAMPLER_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/event/common/connectable.h> // Dali::Internal::Connectable
+#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
+#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
#include <dali/public-api/actors/sampling.h>
-#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
+#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
-#include <dali/public-api/rendering/sampler.h> // Dali::Sampler
-#include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
-#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
-#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
+#include <dali/public-api/rendering/sampler.h> // Dali::Sampler
namespace Dali
{
class Sampler : public BaseObject
{
public:
-
/**
* Create a new Sampler.
* @return A smart-pointer to the newly allocated Sampler.
*/
- static SamplerPtr New( );
+ static SamplerPtr New();
/**
* @copydoc Dali::Sampler::SetFilterMode()
*/
- void SetFilterMode( Dali::FilterMode::Type minFilter, Dali::FilterMode::Type magFilter );
+ void SetFilterMode(Dali::FilterMode::Type minFilter, Dali::FilterMode::Type magFilter);
/**
* @copydoc Dali::Sampler::SetWrapMode()
*/
- void SetWrapMode( Dali::WrapMode::Type rWrap, Dali::WrapMode::Type sWrap, Dali::WrapMode::Type tWrap );
+ void SetWrapMode(Dali::WrapMode::Type rWrap, Dali::WrapMode::Type sWrap, Dali::WrapMode::Type tWrap);
/**
* Get the render thread sampler
/**
* Second stage initialization
*/
- void Initialize( );
+ void Initialize();
protected:
/**
*/
~Sampler() override;
-private: // data
- EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via the update thread
- Render::Sampler* mRenderObject; ///<Render thread sampler for this sampler
-
+private: // data
+ EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via the update thread
+ Render::Sampler* mRenderObject; ///<Render thread sampler for this sampler
};
} // namespace Internal
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/rendering/shader-impl.h> // Dali::Internal::Shader
// INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/scripting/scripting.h>
#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/event/effects/shader-factory.h>
#include <dali/internal/update/manager/update-manager.h>
+#include <dali/public-api/object/type-registry.h>
namespace Dali
{
namespace Internal
{
-
namespace
{
-
/**
* |name |type |writable|animatable|constraint-input|enum for index-checking|
*/
DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "program", MAP, true, false, false, Dali::Shader::Property::PROGRAM )
-DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX, ShaderDefaultProperties )
+DALI_PROPERTY("program", MAP, true, false, false, Dali::Shader::Property::PROGRAM)
+DALI_PROPERTY_TABLE_END(DEFAULT_ACTOR_PROPERTY_START_INDEX, ShaderDefaultProperties)
Dali::Scripting::StringEnum ShaderHintsTable[] =
- { { "NONE", Dali::Shader::Hint::NONE},
- { "OUTPUT_IS_TRANSPARENT", Dali::Shader::Hint::OUTPUT_IS_TRANSPARENT},
- { "MODIFIES_GEOMETRY", Dali::Shader::Hint::MODIFIES_GEOMETRY}
- };
+ {{"NONE", Dali::Shader::Hint::NONE},
+ {"OUTPUT_IS_TRANSPARENT", Dali::Shader::Hint::OUTPUT_IS_TRANSPARENT},
+ {"MODIFIES_GEOMETRY", Dali::Shader::Hint::MODIFIES_GEOMETRY}};
-const uint32_t ShaderHintsTableSize = static_cast<uint32_t>( sizeof( ShaderHintsTable ) / sizeof( ShaderHintsTable[0] ) );
+const uint32_t ShaderHintsTableSize = static_cast<uint32_t>(sizeof(ShaderHintsTable) / sizeof(ShaderHintsTable[0]));
BaseHandle Create()
{
return Dali::BaseHandle();
}
-TypeRegistration mType( typeid( Dali::Shader ), typeid( Dali::Handle ), Create, ShaderDefaultProperties );
+TypeRegistration mType(typeid(Dali::Shader), typeid(Dali::Handle), Create, ShaderDefaultProperties);
#define TOKEN_STRING(x) (#x)
} // unnamed namespace
-ShaderPtr Shader::New( std::string_view vertexShader,
- std::string_view fragmentShader,
- Dali::Shader::Hint::Value hints )
+ShaderPtr Shader::New(std::string_view vertexShader,
+ std::string_view fragmentShader,
+ Dali::Shader::Hint::Value hints)
{
// create scene object first so it's guaranteed to exist for the event side
- auto sceneObject = new SceneGraph::Shader( hints );
- OwnerPointer< SceneGraph::Shader > transferOwnership( sceneObject );
+ auto sceneObject = new SceneGraph::Shader(hints);
+ OwnerPointer<SceneGraph::Shader> transferOwnership(sceneObject);
// pass the pointer to base for message passing
- ShaderPtr shader( new Shader( sceneObject ) );
+ ShaderPtr shader(new Shader(sceneObject));
// transfer scene object ownership to update manager
- auto&& services = shader->GetEventThreadServices();
+ auto&& services = shader->GetEventThreadServices();
SceneGraph::UpdateManager& updateManager = services.GetUpdateManager();
- AddShaderMessage( updateManager, transferOwnership );
+ AddShaderMessage(updateManager, transferOwnership);
- services.RegisterObject( shader.Get() );
- shader->SetShader( vertexShader, fragmentShader, hints );
+ services.RegisterObject(shader.Get());
+ shader->SetShader(vertexShader, fragmentShader, hints);
return shader;
}
const SceneGraph::Shader& Shader::GetShaderSceneObject() const
{
- return static_cast<const SceneGraph::Shader&>( GetSceneObject() );
+ return static_cast<const SceneGraph::Shader&>(GetSceneObject());
}
-void Shader::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
+void Shader::SetDefaultProperty(Property::Index index, const Property::Value& propertyValue)
{
switch(index)
{
case Dali::Shader::Property::PROGRAM:
{
- if( propertyValue.GetType() == Property::MAP )
+ if(propertyValue.GetType() == Property::MAP)
{
const Dali::Property::Map* map = propertyValue.GetMap();
- if( map )
+ if(map)
{
- std::string vertex;
- std::string fragment;
+ std::string vertex;
+ std::string fragment;
Dali::Shader::Hint::Value hints(Dali::Shader::Hint::NONE);
- if( Property::Value* value = map->Find("vertex") )
+ if(Property::Value* value = map->Find("vertex"))
{
vertex = value->Get<std::string>();
}
- if( Property::Value* value = map->Find("fragment") )
+ if(Property::Value* value = map->Find("fragment"))
{
fragment = value->Get<std::string>();
}
- if( Property::Value* value = map->Find("hints") )
+ if(Property::Value* value = map->Find("hints"))
{
static_cast<void>( // ignore return
- Scripting::GetEnumeration< Dali::Shader::Hint::Value >(value->Get<std::string>().c_str(),
- ShaderHintsTable, ShaderHintsTableSize, hints)
- );
+ Scripting::GetEnumeration<Dali::Shader::Hint::Value>(value->Get<std::string>().c_str(),
+ ShaderHintsTable,
+ ShaderHintsTableSize,
+ hints));
}
- SetShader( vertex, fragment, hints );
+ SetShader(vertex, fragment, hints);
}
}
else
{
- DALI_LOG_WARNING( "Shader program property should be a map\n" );
+ DALI_LOG_WARNING("Shader program property should be a map\n");
}
break;
}
}
}
-Property::Value Shader::GetDefaultProperty( Property::Index index ) const
+Property::Value Shader::GetDefaultProperty(Property::Index index) const
{
Property::Value value;
case Dali::Shader::Property::PROGRAM:
{
Dali::Property::Map map;
- if( mShaderData )
+ if(mShaderData)
{
- map["vertex"] = Property::Value(mShaderData->GetVertexShader());
+ map["vertex"] = Property::Value(mShaderData->GetVertexShader());
map["fragment"] = Property::Value(mShaderData->GetFragmentShader());
- map["hints"] = HintString(mShaderData->GetHints());
+ map["hints"] = HintString(mShaderData->GetHints());
}
value = map;
break;
return value;
}
-Property::Value Shader::GetDefaultPropertyCurrentValue( Property::Index index ) const
+Property::Value Shader::GetDefaultPropertyCurrentValue(Property::Index index) const
{
- return GetDefaultProperty( index ); // Event-side only properties
+ return GetDefaultProperty(index); // Event-side only properties
}
-Shader::Shader( const SceneGraph::Shader* sceneObject )
-: Object( sceneObject ),
- mShaderData( nullptr )
+Shader::Shader(const SceneGraph::Shader* sceneObject)
+: Object(sceneObject),
+ mShaderData(nullptr)
{
}
-void Shader::SetShader( std::string_view vertexSource,
- std::string_view fragmentSource,
- Dali::Shader::Hint::Value hints )
+void Shader::SetShader(std::string_view vertexSource,
+ std::string_view fragmentSource,
+ Dali::Shader::Hint::Value hints)
{
// Try to load a pre-compiled shader binary for the source pair:
- ThreadLocalStorage& tls = ThreadLocalStorage::Get();
- ShaderFactory& shaderFactory = tls.GetShaderFactory();
- size_t shaderHash;
- mShaderData = shaderFactory.Load( vertexSource, fragmentSource, hints, shaderHash );
+ ThreadLocalStorage& tls = ThreadLocalStorage::Get();
+ ShaderFactory& shaderFactory = tls.GetShaderFactory();
+ size_t shaderHash;
+ mShaderData = shaderFactory.Load(vertexSource, fragmentSource, hints, shaderHash);
// Add shader program to scene-object using a message to the UpdateManager
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
- SetShaderProgramMessage( updateManager, GetShaderSceneObject(), mShaderData, (hints & Dali::Shader::Hint::MODIFIES_GEOMETRY) != 0x0 );
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+ SetShaderProgramMessage(updateManager, GetShaderSceneObject(), mShaderData, (hints & Dali::Shader::Hint::MODIFIES_GEOMETRY) != 0x0);
}
Shader::~Shader()
{
- if( EventThreadServices::IsCoreRunning() )
+ if(EventThreadServices::IsCoreRunning())
{
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
- RemoveShaderMessage( updateManager, &GetShaderSceneObject() );
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+ RemoveShaderMessage(updateManager, &GetShaderSceneObject());
- eventThreadServices.UnregisterObject( this );
+ eventThreadServices.UnregisterObject(this);
}
}
#define DALI_INTERNAL_SHADER_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
-#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
-#include <dali/public-api/rendering/shader.h> // Dali::Shader
+#include <dali/internal/common/shader-data.h> // ShaderPtr
#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
-#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
-#include <dali/internal/common/shader-data.h> // ShaderPtr
+#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
+#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
+#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
+#include <dali/public-api/rendering/shader.h> // Dali::Shader
namespace Dali
{
class Shader : public Object
{
public:
-
/**
* @copydoc Dali::Shader::New()
*/
- static ShaderPtr New( std::string_view vertexShader,
- std::string_view fragmentShader,
- Dali::Shader::Hint::Value hints );
+ static ShaderPtr New(std::string_view vertexShader,
+ std::string_view fragmentShader,
+ Dali::Shader::Hint::Value hints);
/**
* Retrieve the scene-graph shader added by this object.
const SceneGraph::Shader& GetShaderSceneObject() const;
public: // Default property extensions from Object
-
/**
* @copydoc Dali::Internal::Object::SetDefaultProperty()
*/
/**
* @copydoc Dali::Internal::Object::GetDefaultProperty()
*/
- Property::Value GetDefaultProperty( Property::Index index ) const override;
+ Property::Value GetDefaultProperty(Property::Index index) const override;
/**
* @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
*/
- Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const override;
+ Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
private: // implementation
-
/**
* Constructor
*
* @param sceneObject the scene object
*/
- Shader( const SceneGraph::Shader* sceneObject );
+ Shader(const SceneGraph::Shader* sceneObject);
/**
* Second stage initialization
*/
- void SetShader( std::string_view vertexShader, std::string_view fragmentShader, Dali::Shader::Hint::Value hints );
+ void SetShader(std::string_view vertexShader, std::string_view fragmentShader, Dali::Shader::Hint::Value hints);
protected:
/**
~Shader() override;
private: // unimplemented methods
-
- Shader() = delete;
- Shader( const Shader& ) = delete;
- Shader& operator=( const Shader& ) = delete;
+ Shader() = delete;
+ Shader(const Shader&) = delete;
+ Shader& operator=(const Shader&) = delete;
private:
-
Internal::ShaderDataPtr mShaderData;
public:
-
/**
* @copydoc Dali::Shader::GetShaderVersionPrefix()
*/
* @copydoc Dali::Shader::GetFragmentShaderPrefix()
*/
static std::string GetFragmentShaderPrefix();
-
};
} // namespace Internal
// Helpers for public-api forwarding methods
-inline Internal::Shader& GetImplementation( Dali::Shader& handle )
+inline Internal::Shader& GetImplementation(Dali::Shader& handle)
{
DALI_ASSERT_ALWAYS(handle && "Shader handle is empty");
return static_cast<Internal::Shader&>(object);
}
-inline const Internal::Shader& GetImplementation( const Dali::Shader& handle )
+inline const Internal::Shader& GetImplementation(const Dali::Shader& handle)
{
DALI_ASSERT_ALWAYS(handle && "Shader handle is empty");
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
size_t prefixIndex = shader.find(Dali::Shader::GetShaderVersionPrefix());
if(fragmentPrefix != nullptr)
{
- modified = true;
+ modified = true;
if(prefixIndex == std::string::npos)
{
fragmentShader = fragmentPrefix;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/rendering/texture-set-impl.h> // Dali::Internal::TextureSet
// INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
#include <dali/internal/update/manager/update-manager.h>
#include <dali/internal/update/rendering/scene-graph-texture-set.h>
+#include <dali/public-api/object/type-registry.h>
namespace Dali
{
namespace Internal
{
-
TextureSetPtr TextureSet::New()
{
- TextureSetPtr textureSet( new TextureSet() );
+ TextureSetPtr textureSet(new TextureSet());
textureSet->Initialize();
return textureSet;
}
-void TextureSet::SetTexture( uint32_t index, TexturePtr texture )
+void TextureSet::SetTexture(uint32_t index, TexturePtr texture)
{
- uint32_t textureCount = static_cast<uint32_t>( mTextures.size() );
- if( index >= textureCount )
+ uint32_t textureCount = static_cast<uint32_t>(mTextures.size());
+ if(index >= textureCount)
{
mTextures.resize(index + 1);
bool samplerExist = true;
- if( mSamplers.size() < index + 1 )
+ if(mSamplers.size() < index + 1)
{
- mSamplers.resize( index + 1 );
+ mSamplers.resize(index + 1);
samplerExist = false;
}
- for( uint32_t i(textureCount); i<=index; ++i )
+ for(uint32_t i(textureCount); i <= index; ++i)
{
mTextures[i] = nullptr;
- if( !samplerExist )
+ if(!samplerExist)
{
mSamplers[i] = nullptr;
}
}
}
- mTextures[index]= texture;
+ mTextures[index] = texture;
Render::Texture* renderTexture(nullptr);
- if( texture )
+ if(texture)
{
renderTexture = texture->GetRenderObject();
}
- SceneGraph::SetTextureMessage( mEventThreadServices, *mSceneObject, index, renderTexture );
+ SceneGraph::SetTextureMessage(mEventThreadServices, *mSceneObject, index, renderTexture);
}
-Texture* TextureSet::GetTexture( uint32_t index ) const
+Texture* TextureSet::GetTexture(uint32_t index) const
{
Texture* result(nullptr);
- if( index < mTextures.size() )
+ if(index < mTextures.size())
{
result = mTextures[index].Get();
}
else
{
- DALI_LOG_ERROR( "Error: Invalid index to TextureSet::GetTexture\n");
+ DALI_LOG_ERROR("Error: Invalid index to TextureSet::GetTexture\n");
}
return result;
}
-void TextureSet::SetSampler( uint32_t index, SamplerPtr sampler )
+void TextureSet::SetSampler(uint32_t index, SamplerPtr sampler)
{
- uint32_t samplerCount = static_cast<uint32_t>( mSamplers.size() );
- if( samplerCount < index + 1 )
+ uint32_t samplerCount = static_cast<uint32_t>(mSamplers.size());
+ if(samplerCount < index + 1)
{
- mSamplers.resize( index + 1 );
- for( uint32_t i = samplerCount; i<=index; ++i )
+ mSamplers.resize(index + 1);
+ for(uint32_t i = samplerCount; i <= index; ++i)
{
mSamplers[i] = nullptr;
}
mSamplers[index] = sampler;
Render::Sampler* renderSampler(nullptr);
- if( sampler )
+ if(sampler)
{
renderSampler = sampler->GetSamplerRenderObject();
}
- SceneGraph::SetSamplerMessage( mEventThreadServices, *mSceneObject, index, renderSampler );
+ SceneGraph::SetSamplerMessage(mEventThreadServices, *mSceneObject, index, renderSampler);
}
-Sampler* TextureSet::GetSampler( uint32_t index ) const
+Sampler* TextureSet::GetSampler(uint32_t index) const
{
Sampler* result(nullptr);
- if( index < mSamplers.size() )
+ if(index < mSamplers.size())
{
result = mSamplers[index].Get();
}
else
{
- DALI_LOG_ERROR( "Error: Invalid index to TextureSet::GetSampler\n");
+ DALI_LOG_ERROR("Error: Invalid index to TextureSet::GetSampler\n");
}
return result;
uint32_t TextureSet::GetTextureCount() const
{
- return static_cast<uint32_t>( mTextures.size() );
+ return static_cast<uint32_t>(mTextures.size());
}
const SceneGraph::TextureSet* TextureSet::GetTextureSetSceneObject() const
}
TextureSet::TextureSet()
-:mEventThreadServices( EventThreadServices::Get() ),
- mSceneObject( nullptr )
+: mEventThreadServices(EventThreadServices::Get()),
+ mSceneObject(nullptr)
{
}
SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager();
mSceneObject = SceneGraph::TextureSet::New();
- OwnerPointer< SceneGraph::TextureSet > transferOwnership( mSceneObject );
- AddTextureSetMessage( updateManager, transferOwnership );
+ OwnerPointer<SceneGraph::TextureSet> transferOwnership(mSceneObject);
+ AddTextureSetMessage(updateManager, transferOwnership);
}
TextureSet::~TextureSet()
{
- if( EventThreadServices::IsCoreRunning() )
+ if(EventThreadServices::IsCoreRunning())
{
SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager();
- RemoveTextureSetMessage( updateManager, *mSceneObject );
+ RemoveTextureSetMessage(updateManager, *mSceneObject);
}
}
#define DALI_INTERNAL_TEXTURE_SET_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/public-api/common/vector-wrapper.h> // std::vector
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
-#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
-#include <dali/public-api/rendering/texture-set.h> // Dali::TextureSet
-#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
+#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
#include <dali/internal/event/rendering/sampler-impl.h> // Dali::Internal::Sampler
-#include <dali/internal/event/rendering/shader-impl.h> // Dali::Internal::Shader
+#include <dali/internal/event/rendering/shader-impl.h> // Dali::Internal::Shader
#include <dali/internal/event/rendering/texture-impl.h> // Dali::Internal::Texture
-
+#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
+#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
+#include <dali/public-api/rendering/texture-set.h> // Dali::TextureSet
namespace Dali
{
class TextureSet;
}
-
class TextureSet;
using TextureSetPtr = IntrusivePtr<TextureSet>;
class TextureSet : public BaseObject
{
public:
-
/**
* @copydoc Dali::TextureSet::New()
*/
/**
* @copydoc Dali::TextureSet::SetTexture()
*/
- void SetTexture( uint32_t index, TexturePtr texture );
+ void SetTexture(uint32_t index, TexturePtr texture);
/**
* @copydoc Dali::TextureSet::GetTexture()
*/
- Texture* GetTexture( uint32_t index ) const;
+ Texture* GetTexture(uint32_t index) const;
/**
* @copydoc Dali::TextureSet::SetSampler()
*/
- void SetSampler( uint32_t index, SamplerPtr sampler );
+ void SetSampler(uint32_t index, SamplerPtr sampler);
/**
* @copydoc Dali::TextureSet::GetSampler()
*/
- Sampler* GetSampler( uint32_t index ) const;
+ Sampler* GetSampler(uint32_t index) const;
/**
* @copydoc Dali::TextureSet::GetTextureCount()
*/
uint32_t GetTextureCount() const;
- /**
+ /**
* @brief Get the TextureSet scene object
*
* @return the texture set scene object
const SceneGraph::TextureSet* GetTextureSetSceneObject() const;
private: // implementation
-
TextureSet();
/**
~TextureSet() override;
private: // unimplemented methods
- TextureSet( const TextureSet& );
- TextureSet& operator=( const TextureSet& );
+ TextureSet(const TextureSet&);
+ TextureSet& operator=(const TextureSet&);
-private: // Data
- EventThreadServices& mEventThreadServices; ///<Used to send messages to the update thread
+private: // Data
+ EventThreadServices& mEventThreadServices; ///<Used to send messages to the update thread
SceneGraph::TextureSet* mSceneObject;
std::vector<SamplerPtr> mSamplers;
std::vector<TexturePtr> mTextures;
} // namespace Internal
// Helpers for public-api forwarding methods
-inline Internal::TextureSet& GetImplementation( Dali::TextureSet& handle )
+inline Internal::TextureSet& GetImplementation(Dali::TextureSet& handle)
{
DALI_ASSERT_ALWAYS(handle && "TextureSet handle is empty");
return static_cast<Internal::TextureSet&>(object);
}
-inline const Internal::TextureSet& GetImplementation( const Dali::TextureSet& handle )
+inline const Internal::TextureSet& GetImplementation(const Dali::TextureSet& handle)
{
DALI_ASSERT_ALWAYS(handle && "TextureSet handle is empty");
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/event/rendering/vertex-buffer-impl.h>
// INTERNAL INCLUDES
-#include <dali/public-api/rendering/vertex-buffer.h>
#include <dali/internal/update/manager/update-manager.h>
+#include <dali/public-api/rendering/vertex-buffer.h>
-#if defined (ANDROID) || defined(WIN32) || defined(__APPLE__)
+#if defined(ANDROID) || defined(WIN32) || defined(__APPLE__)
namespace std
{
- uint64_t _Hash_bytes(const void* bytes, uint64_t size, uint64_t seed)
+uint64_t _Hash_bytes(const void* bytes, uint64_t size, uint64_t seed)
+{
+ for(uint64_t i = 0; i < size; i++)
{
- for (uint64_t i = 0; i < size; i++)
- {
- seed = seed * 31 + reinterpret_cast<const unsigned char*>(bytes)[i];
- }
-
- return seed;
+ seed = seed * 31 + reinterpret_cast<const unsigned char*>(bytes)[i];
}
+
+ return seed;
}
+} // namespace std
#endif
namespace Dali
{
namespace Internal
{
-
namespace
{
-
/**
* Calculate the alignment requirements of a type
*
// Create a structure that forces alignment of the data type
struct TestStructure
{
- char oneChar; ///< Member with sizeof() == 1
+ char oneChar; ///< Member with sizeof() == 1
typename PropertyImplementationType<type>::Type data;
};
- enum { VALUE = offsetof( TestStructure, data ) };
+ enum
+ {
+ VALUE = offsetof(TestStructure, data)
+ };
};
-uint32_t GetPropertyImplementationAlignment( Property::Type& propertyType )
+uint32_t GetPropertyImplementationAlignment(Property::Type& propertyType)
{
uint32_t alignment = 0u;
- switch( propertyType )
+ switch(propertyType)
{
case Property::BOOLEAN:
{
- alignment = PropertyImplementationTypeAlignment< Property::BOOLEAN >::VALUE;
+ alignment = PropertyImplementationTypeAlignment<Property::BOOLEAN>::VALUE;
break;
}
case Property::INTEGER:
{
- alignment = PropertyImplementationTypeAlignment< Property::INTEGER >::VALUE;
+ alignment = PropertyImplementationTypeAlignment<Property::INTEGER>::VALUE;
break;
}
case Property::FLOAT:
{
- alignment = PropertyImplementationTypeAlignment< Property::FLOAT >::VALUE;
+ alignment = PropertyImplementationTypeAlignment<Property::FLOAT>::VALUE;
break;
}
case Property::VECTOR2:
{
- alignment = PropertyImplementationTypeAlignment< Property::VECTOR2 >::VALUE;
+ alignment = PropertyImplementationTypeAlignment<Property::VECTOR2>::VALUE;
break;
}
case Property::VECTOR3:
{
- alignment = PropertyImplementationTypeAlignment< Property::VECTOR3 >::VALUE;
+ alignment = PropertyImplementationTypeAlignment<Property::VECTOR3>::VALUE;
break;
}
case Property::VECTOR4:
{
- alignment = PropertyImplementationTypeAlignment< Property::VECTOR4 >::VALUE;
+ alignment = PropertyImplementationTypeAlignment<Property::VECTOR4>::VALUE;
break;
}
case Property::MATRIX3:
{
- alignment = PropertyImplementationTypeAlignment< Property::MATRIX3 >::VALUE;
+ alignment = PropertyImplementationTypeAlignment<Property::MATRIX3>::VALUE;
break;
}
case Property::MATRIX:
{
- alignment = PropertyImplementationTypeAlignment< Property::MATRIX >::VALUE;
+ alignment = PropertyImplementationTypeAlignment<Property::MATRIX>::VALUE;
break;
}
case Property::RECTANGLE:
{
- alignment = PropertyImplementationTypeAlignment< Property::RECTANGLE >::VALUE;
+ alignment = PropertyImplementationTypeAlignment<Property::RECTANGLE>::VALUE;
break;
}
case Property::ROTATION:
{
- alignment = PropertyImplementationTypeAlignment< Property::ROTATION >::VALUE;
+ alignment = PropertyImplementationTypeAlignment<Property::ROTATION>::VALUE;
break;
}
case Property::NONE:
} // unnamed namespace
-VertexBufferPtr VertexBuffer::New( Dali::Property::Map& format )
+VertexBufferPtr VertexBuffer::New(Dali::Property::Map& format)
{
- DALI_ASSERT_ALWAYS( format.Count() && "Format cannot be empty." );
+ DALI_ASSERT_ALWAYS(format.Count() && "Format cannot be empty.");
- VertexBufferPtr vertexBuffer( new VertexBuffer() );
- vertexBuffer->Initialize( format );
+ VertexBufferPtr vertexBuffer(new VertexBuffer());
+ vertexBuffer->Initialize(format);
return vertexBuffer;
}
-void VertexBuffer::SetData( const void* data, uint32_t size )
+void VertexBuffer::SetData(const void* data, uint32_t size)
{
mSize = size; // size is the number of elements
// create a new DALi vector to store the buffer data
// the heap allocated vector will end up being owned by Render::VertexBuffer
- OwnerPointer< Vector<uint8_t> > bufferCopy = new Dali::Vector<uint8_t>();
- bufferCopy->Resize( bufferSize );
+ OwnerPointer<Vector<uint8_t> > bufferCopy = new Dali::Vector<uint8_t>();
+ bufferCopy->Resize(bufferSize);
// copy the data
- const uint8_t* source = static_cast<const uint8_t*>( data );
- uint8_t* destination = &((*bufferCopy)[0]);
- std::copy( source, source + bufferSize, destination );
+ const uint8_t* source = static_cast<const uint8_t*>(data);
+ uint8_t* destination = &((*bufferCopy)[0]);
+ std::copy(source, source + bufferSize, destination);
// Ownership of the bufferCopy is passed to the message ( uses an owner pointer )
- SceneGraph::SetVertexBufferData( mEventThreadServices.GetUpdateManager(), *mRenderObject, bufferCopy, mSize );
+ SceneGraph::SetVertexBufferData(mEventThreadServices.GetUpdateManager(), *mRenderObject, bufferCopy, mSize);
}
uint32_t VertexBuffer::GetSize() const
VertexBuffer::~VertexBuffer()
{
- if( EventThreadServices::IsCoreRunning() && mRenderObject)
+ if(EventThreadServices::IsCoreRunning() && mRenderObject)
{
- SceneGraph::RemoveVertexBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject );
+ SceneGraph::RemoveVertexBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject);
}
}
VertexBuffer::VertexBuffer()
-: mEventThreadServices( EventThreadServices::Get() ),
- mRenderObject( nullptr ),
- mBufferFormatSize( 0 ),
- mSize( 0 )
+: mEventThreadServices(EventThreadServices::Get()),
+ mRenderObject(nullptr),
+ mBufferFormatSize(0),
+ mSize(0)
{
}
-void VertexBuffer::Initialize( Dali::Property::Map& formatMap )
+void VertexBuffer::Initialize(Dali::Property::Map& formatMap)
{
mRenderObject = new Render::VertexBuffer();
- OwnerPointer< Render::VertexBuffer > transferOwnership( mRenderObject );
- SceneGraph::AddVertexBuffer( mEventThreadServices.GetUpdateManager(), transferOwnership );
+ OwnerPointer<Render::VertexBuffer> transferOwnership(mRenderObject);
+ SceneGraph::AddVertexBuffer(mEventThreadServices.GetUpdateManager(), transferOwnership);
- uint32_t numComponents = static_cast<uint32_t>( formatMap.Count() );
+ uint32_t numComponents = static_cast<uint32_t>(formatMap.Count());
// Create the format
- OwnerPointer< Render::VertexBuffer::Format> format = new Render::VertexBuffer::Format();
- format->components.resize( numComponents );
+ OwnerPointer<Render::VertexBuffer::Format> format = new Render::VertexBuffer::Format();
+ format->components.resize(numComponents);
- uint32_t currentAlignment = 0u;
+ uint32_t currentAlignment = 0u;
uint32_t maxAlignmentRequired = 0u;
- for( uint32_t i = 0u; i < numComponents; ++i )
+ for(uint32_t i = 0u; i < numComponents; ++i)
{
- KeyValuePair component = formatMap.GetKeyValue( i );
+ KeyValuePair component = formatMap.GetKeyValue(i);
// Get the name
if(component.first.type == Property::Key::INDEX)
format->components[i].name = ConstString(component.first.stringKey);
// enums are stored in the map as int
- Property::Type type = Property::Type( component.second.Get<int>() );
+ Property::Type type = Property::Type(component.second.Get<int>());
// Get the size and alignment
- if( ( type == Property::NONE ) ||
- ( type == Property::STRING ) ||
- ( type == Property::ARRAY ) ||
- ( type == Property::MAP ) )
+ if((type == Property::NONE) ||
+ (type == Property::STRING) ||
+ (type == Property::ARRAY) ||
+ (type == Property::MAP))
{
- DALI_ABORT( "Property::Type not supported in VertexBuffer" );
+ DALI_ABORT("Property::Type not supported in VertexBuffer");
}
- uint32_t elementSize = GetPropertyImplementationSize( type );
- uint32_t elementAlignment = GetPropertyImplementationAlignment( type );
+ uint32_t elementSize = GetPropertyImplementationSize(type);
+ uint32_t elementAlignment = GetPropertyImplementationAlignment(type);
// check if current alignment is compatible with new member
- if( uint32_t offset = currentAlignment % elementAlignment )
+ if(uint32_t offset = currentAlignment % elementAlignment)
{
// Not compatible, realign
currentAlignment = currentAlignment + elementSize - offset;
}
// write to the format
- format->components[i].size = elementSize;
+ format->components[i].size = elementSize;
format->components[i].offset = currentAlignment;
- format->components[i].type = type;
+ format->components[i].type = type;
// update offset
currentAlignment += elementSize;
// update max alignment requirement
- if( elementAlignment > maxAlignmentRequired )
+ if(elementAlignment > maxAlignmentRequired)
{
maxAlignmentRequired = elementAlignment;
}
-
}
// Check the alignment for the maxAlignment required to calculate the size of the format
- if( maxAlignmentRequired != 0 )
+ if(maxAlignmentRequired != 0)
{
- if( uint32_t offset = currentAlignment % maxAlignmentRequired )
+ if(uint32_t offset = currentAlignment % maxAlignmentRequired)
{
// Not compatible, realign
currentAlignment = currentAlignment + maxAlignmentRequired - offset;
mBufferFormatSize = format->size;
- SceneGraph::SetVertexBufferFormat(mEventThreadServices.GetUpdateManager(), *mRenderObject, format );
+ SceneGraph::SetVertexBufferFormat(mEventThreadServices.GetUpdateManager(), *mRenderObject, format);
}
-uint32_t GetPropertyImplementationSize( Property::Type& propertyType )
+uint32_t GetPropertyImplementationSize(Property::Type& propertyType)
{
uint32_t size = 0u;
- switch( propertyType )
+ switch(propertyType)
{
case Property::BOOLEAN:
{
- size = sizeof( PropertyImplementationType< Property::BOOLEAN >::Type );
+ size = sizeof(PropertyImplementationType<Property::BOOLEAN>::Type);
break;
}
case Property::INTEGER:
{
- size = sizeof( PropertyImplementationType< Property::INTEGER >::Type );
+ size = sizeof(PropertyImplementationType<Property::INTEGER>::Type);
break;
}
case Property::FLOAT:
{
- size = sizeof( PropertyImplementationType< Property::FLOAT >::Type );
+ size = sizeof(PropertyImplementationType<Property::FLOAT>::Type);
break;
}
case Property::VECTOR2:
{
- size = sizeof( PropertyImplementationType< Property::VECTOR2 >::Type );
+ size = sizeof(PropertyImplementationType<Property::VECTOR2>::Type);
break;
}
case Property::VECTOR3:
{
- size = sizeof( PropertyImplementationType< Property::VECTOR3 >::Type );
+ size = sizeof(PropertyImplementationType<Property::VECTOR3>::Type);
break;
}
case Property::VECTOR4:
{
- size = sizeof( PropertyImplementationType< Property::VECTOR4 >::Type );
+ size = sizeof(PropertyImplementationType<Property::VECTOR4>::Type);
break;
}
case Property::MATRIX3:
{
- size = sizeof( PropertyImplementationType< Property::MATRIX3 >::Type );
+ size = sizeof(PropertyImplementationType<Property::MATRIX3>::Type);
break;
}
case Property::MATRIX:
{
- size = sizeof( PropertyImplementationType< Property::MATRIX >::Type );
+ size = sizeof(PropertyImplementationType<Property::MATRIX>::Type);
break;
}
case Property::RECTANGLE:
{
- size = sizeof( PropertyImplementationType< Property::RECTANGLE >::Type );
+ size = sizeof(PropertyImplementationType<Property::RECTANGLE>::Type);
break;
}
case Property::ROTATION:
{
- size = sizeof( PropertyImplementationType< Property::ROTATION >::Type );
+ size = sizeof(PropertyImplementationType<Property::ROTATION>::Type);
break;
}
case Property::NONE:
return size;
}
-
} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_VERTEX_BUFFER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
+#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/render/renderers/render-vertex-buffer.h>
+#include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
#include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/object/property-map.h> // Dali::Property::Map
-#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/render/renderers/render-vertex-buffer.h>
namespace Dali
{
namespace Internal
{
-
class VertexBuffer;
using VertexBufferPtr = IntrusivePtr<VertexBuffer>;
class VertexBuffer : public BaseObject
{
public:
-
/**
* @copydoc PropertBuffer::New()
*/
- static VertexBufferPtr New( Dali::Property::Map& format );
+ static VertexBufferPtr New(Dali::Property::Map& format);
/**
* @copydoc PropertBuffer::SetData()
*/
- void SetData( const void* data, uint32_t size );
+ void SetData(const void* data, uint32_t size);
/**
* @copydoc PropertBuffer::GetSize()
uint32_t GetSize() const;
public: // Default property extensions from Object
-
/**
* @brief Get the render thread side of the VertexBuffer
*
/**
* Second stage initialization
*/
- void Initialize( Dali::Property::Map& format );
+ void Initialize(Dali::Property::Map& format);
private: // unimplemented methods
- VertexBuffer( const VertexBuffer& );
- VertexBuffer& operator=( const VertexBuffer& );
+ VertexBuffer(const VertexBuffer&);
+ VertexBuffer& operator=(const VertexBuffer&);
-private: // data
- EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via update thread
+private: // data
+ EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via update thread
Render::VertexBuffer* mRenderObject; ///<Render side object
- uint32_t mBufferFormatSize;
- uint32_t mSize; ///< Number of elements in the buffer
+ uint32_t mBufferFormatSize;
+ uint32_t mSize; ///< Number of elements in the buffer
};
/**
* Get the implementation type from a Property::Type
*/
-template<Property::Type type> struct PropertyImplementationType
+template<Property::Type type>
+struct PropertyImplementationType
{
// typedef ... Type; not defined, only support types declared below
};
using Type = Quaternion;
};
-uint32_t GetPropertyImplementationSize( Property::Type& propertyType );
+uint32_t GetPropertyImplementationSize(Property::Type& propertyType);
} // namespace Internal
namespace Dali
{
-
namespace Internal
{
-
-MemoryPoolRelayoutContainer::MemoryPoolRelayoutContainer( MemoryPoolObjectAllocator< RelayoutInfo >& objectAllocator )
-: mAllocator( objectAllocator )
+MemoryPoolRelayoutContainer::MemoryPoolRelayoutContainer(MemoryPoolObjectAllocator<RelayoutInfo>& objectAllocator)
+: mAllocator(objectAllocator)
{
}
MemoryPoolRelayoutContainer::~MemoryPoolRelayoutContainer() = default;
-bool MemoryPoolRelayoutContainer::Contains( const Dali::Actor& actor )
+bool MemoryPoolRelayoutContainer::Contains(const Dali::Actor& actor)
{
- for( RelayoutInfoContainer::Iterator it = mRelayoutInfos.Begin(), itEnd = mRelayoutInfos.End(); it != itEnd; ++it )
+ for(RelayoutInfoContainer::Iterator it = mRelayoutInfos.Begin(), itEnd = mRelayoutInfos.End(); it != itEnd; ++it)
{
RelayoutInfo* info = *it;
- if( info->actor == actor )
+ if(info->actor == actor)
{
return true;
}
return false;
}
-void MemoryPoolRelayoutContainer::Add( const Dali::Actor& actor, const Vector2& size )
+void MemoryPoolRelayoutContainer::Add(const Dali::Actor& actor, const Vector2& size)
{
- if( !Contains( actor ) )
+ if(!Contains(actor))
{
RelayoutInfo* info = mAllocator.Allocate();
- info->actor = actor;
- info->size = size;
+ info->actor = actor;
+ info->size = size;
- mRelayoutInfos.PushBack( info );
+ mRelayoutInfos.PushBack(info);
}
}
void MemoryPoolRelayoutContainer::PopBack()
{
- if( mRelayoutInfos.Size() > 0 )
+ if(mRelayoutInfos.Size() > 0)
{
RelayoutInfoContainer::Iterator back = mRelayoutInfos.End();
back--;
RelayoutInfo* info = *back;
- mAllocator.Destroy( info );
- mRelayoutInfos.Erase( back );
+ mAllocator.Destroy(info);
+ mRelayoutInfos.Erase(back);
}
}
-void MemoryPoolRelayoutContainer::Get( size_t index, Dali::Actor& actorOut, Vector2& sizeOut ) const
+void MemoryPoolRelayoutContainer::Get(size_t index, Dali::Actor& actorOut, Vector2& sizeOut) const
{
- DALI_ASSERT_DEBUG( index < Size() );
+ DALI_ASSERT_DEBUG(index < Size());
- RelayoutInfo* info = mRelayoutInfos[ index ];
- actorOut = info->actor;
- sizeOut = info->size;
+ RelayoutInfo* info = mRelayoutInfos[index];
+ actorOut = info->actor;
+ sizeOut = info->size;
}
size_t MemoryPoolRelayoutContainer::Size() const
return mRelayoutInfos.Size();
}
-void MemoryPoolRelayoutContainer::Reserve( size_t capacity )
+void MemoryPoolRelayoutContainer::Reserve(size_t capacity)
{
- mRelayoutInfos.Reserve( capacity );
+ mRelayoutInfos.Reserve(capacity);
}
void MemoryPoolRelayoutContainer::Clear()
{
- for( size_t i = 0; i < Size(); ++i )
+ for(size_t i = 0; i < Size(); ++i)
{
- RelayoutInfo* info = mRelayoutInfos[ i ];
- mAllocator.Destroy( info );
+ RelayoutInfo* info = mRelayoutInfos[i];
+ mAllocator.Destroy(info);
}
mRelayoutInfos.Clear();
#define DALI_INTERNAL_MEMORY_POOL_RELAYOUT_CONTAINER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-
// INTERNAL INCLUDES
-#include <dali/public-api/size-negotiation/relayout-container.h>
-#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/size-negotiation/relayout-container.h>
#include <dali/internal/common/memory-pool-object-allocator.h>
namespace Dali
{
-
namespace Internal
{
-
/**
* @brief Container to encapsulate information required for relayout.
*
class MemoryPoolRelayoutContainer : public RelayoutContainer
{
public:
-
/**
* Struct to store the relayout information
*/
struct RelayoutInfo
{
- Dali::Actor actor; ///< The actor to relayout
- Vector2 size; ///< The desired size of the actor
+ Dali::Actor actor; ///< The actor to relayout
+ Vector2 size; ///< The desired size of the actor
};
/**
*
* @param objectAllocator A memory pool that can allocate memory for RelayoutInfos
*/
- MemoryPoolRelayoutContainer( MemoryPoolObjectAllocator< RelayoutInfo >& objectAllocator );
+ MemoryPoolRelayoutContainer(MemoryPoolObjectAllocator<RelayoutInfo>& objectAllocator);
/**
* Virtual destructor
* @param actor The actor to relayout
* @param size The size to relayout
*/
- void Add( const Dali::Actor& actor, const Vector2& size ) override;
+ void Add(const Dali::Actor& actor, const Vector2& size) override;
/**
* @brief Remove information from the container
*
* @param index The index of the information to retrieve
*/
- void Get( size_t index, Dali::Actor& actorOut, Vector2& sizeOut ) const;
+ void Get(size_t index, Dali::Actor& actorOut, Vector2& sizeOut) const;
/**
* @brief The count of information in the container
*
* @param capacity The new capacity for the container
*/
- void Reserve( size_t capacity );
+ void Reserve(size_t capacity);
/**
* @brief Reset the container, freeing all memory
* @param actor The actor to search for
* @return Return if the actor was found or not
*/
- bool Contains( const Dali::Actor& actor );
+ bool Contains(const Dali::Actor& actor);
private:
using RelayoutInfoContainer = Vector<RelayoutInfo*>;
- RelayoutInfoContainer mRelayoutInfos; ///< The list of relayout infos
+ RelayoutInfoContainer mRelayoutInfos; ///< The list of relayout infos
- MemoryPoolObjectAllocator< RelayoutInfo >& mAllocator; ///< The memory pool from which the infos are allocated
+ MemoryPoolObjectAllocator<RelayoutInfo>& mAllocator; ///< The memory pool from which the infos are allocated
};
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/integration-api/debug.h>
#include <dali/integration-api/render-controller.h>
-#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/object/object-registry.h>
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/event/common/thread-local-storage.h>
+#include <dali/public-api/object/object-registry.h>
+#include <dali/public-api/object/type-registry.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
#if defined(DEBUG_ENABLED)
-Integration::Log::Filter* gLogFilter( Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_RELAYOUT_CONTROLLER") );
+Integration::Log::Filter* gLogFilter(Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_RELAYOUT_CONTROLLER"));
/**
* Prints out all the children of the given actor when debug is enabled.
* @param[in] actor The actor whose children to print.
* @param[in] level The number of " | " to put in front of the children.
*/
-void PrintChildren( Dali::Actor actor, int level )
+void PrintChildren(Dali::Actor actor, int level)
{
std::ostringstream output;
- for ( int t = 0; t < level; ++t )
+ for(int t = 0; t < level; ++t)
{
output << " | ";
}
output << actor.GetTypeName();
- output << ", " << actor.GetProperty< std::string >( Dali::Actor::Property::NAME );
+ output << ", " << actor.GetProperty<std::string>(Dali::Actor::Property::NAME);
- output << " - Pos: " << actor.GetCurrentProperty< Vector3 >( Dali::Actor::Property::POSITION ) << " Size: " << actor.GetTargetSize();
+ output << " - Pos: " << actor.GetCurrentProperty<Vector3>(Dali::Actor::Property::POSITION) << " Size: " << actor.GetTargetSize();
- output << ", Dirty: (" << ( GetImplementation( actor ).IsLayoutDirty( Dimension::WIDTH ) ? "TRUE" : "FALSE" ) << "," << ( GetImplementation( actor ).IsLayoutDirty( Dimension::HEIGHT ) ? "TRUE" : "FALSE" ) << ")";
- output << ", Negotiated: (" << ( GetImplementation( actor ).IsLayoutNegotiated( Dimension::WIDTH ) ? "TRUE" : "FALSE" ) << "," << ( GetImplementation( actor ).IsLayoutNegotiated( Dimension::HEIGHT ) ? "TRUE" : "FALSE" ) << ")";
- output << ", Enabled: " << ( GetImplementation( actor ).IsRelayoutEnabled() ? "TRUE" : "FALSE" );
+ output << ", Dirty: (" << (GetImplementation(actor).IsLayoutDirty(Dimension::WIDTH) ? "TRUE" : "FALSE") << "," << (GetImplementation(actor).IsLayoutDirty(Dimension::HEIGHT) ? "TRUE" : "FALSE") << ")";
+ output << ", Negotiated: (" << (GetImplementation(actor).IsLayoutNegotiated(Dimension::WIDTH) ? "TRUE" : "FALSE") << "," << (GetImplementation(actor).IsLayoutNegotiated(Dimension::HEIGHT) ? "TRUE" : "FALSE") << ")";
+ output << ", Enabled: " << (GetImplementation(actor).IsRelayoutEnabled() ? "TRUE" : "FALSE");
output << ", (" << actor.GetObjectPtr() << ")" << std::endl;
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, output.str().c_str() );
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, output.str().c_str());
++level;
uint32_t numChildren = actor.GetChildCount();
- for( uint32_t i=0; i<numChildren; ++i )
+ for(uint32_t i = 0; i < numChildren; ++i)
{
- PrintChildren( actor.GetChildAt(i), level );
+ PrintChildren(actor.GetChildAt(i), level);
}
--level;
}
*/
void PrintHierarchy()
{
- if ( gLogFilter->IsEnabledFor( Debug::Verbose ) )
+ if(gLogFilter->IsEnabledFor(Debug::Verbose))
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "---------- ROOT LAYER ----------\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "---------- ROOT LAYER ----------\n");
- PrintChildren( Stage::GetCurrent()->GetRootLayer(), 0 );
+ PrintChildren(Stage::GetCurrent()->GetRootLayer(), 0);
}
}
} // unnamed namespace
-RelayoutController::RelayoutController( Integration::RenderController& controller )
-: mRenderController( controller ),
+RelayoutController::RelayoutController(Integration::RenderController& controller)
+: mRenderController(controller),
mRelayoutInfoAllocator(),
- mSlotDelegate( this ),
- mRelayoutStack( new MemoryPoolRelayoutContainer( mRelayoutInfoAllocator ) ),
- mRelayoutConnection( false ),
- mRelayoutFlag( false ),
- mEnabled( false ),
- mPerformingRelayout( false ),
- mProcessingCoreEvents( false )
+ mSlotDelegate(this),
+ mRelayoutStack(new MemoryPoolRelayoutContainer(mRelayoutInfoAllocator)),
+ mRelayoutConnection(false),
+ mRelayoutFlag(false),
+ mEnabled(false),
+ mPerformingRelayout(false),
+ mProcessingCoreEvents(false)
{
// Make space for 32 controls to avoid having to copy construct a lot in the beginning
- mRelayoutStack->Reserve( 32 );
+ mRelayoutStack->Reserve(32);
}
RelayoutController::~RelayoutController()
return &ThreadLocalStorage::Get().GetRelayoutController();
}
-void RelayoutController::QueueActor( Internal::Actor* actor, RelayoutContainer& actors, Vector2 size )
+void RelayoutController::QueueActor(Internal::Actor* actor, RelayoutContainer& actors, Vector2 size)
{
- if( actor && actor->RelayoutRequired() )
+ if(actor && actor->RelayoutRequired())
{
- Dali::Actor actorHandle = Dali::Actor( actor );
- actors.Add( actorHandle, size );
+ Dali::Actor actorHandle = Dali::Actor(actor);
+ actors.Add(actorHandle, size);
}
}
-void RelayoutController::RequestRelayout( Dali::Actor& actor, Dimension::Type dimension )
+void RelayoutController::RequestRelayout(Dali::Actor& actor, Dimension::Type dimension)
{
- if( !mEnabled )
+ if(!mEnabled)
{
return;
}
- std::vector< Dali::Actor > potentialRedundantSubRoots;
- std::vector< Dali::Actor > topOfSubTreeStack;
+ std::vector<Dali::Actor> potentialRedundantSubRoots;
+ std::vector<Dali::Actor> topOfSubTreeStack;
- topOfSubTreeStack.push_back( actor );
+ topOfSubTreeStack.push_back(actor);
// Propagate on all dimensions
- for( uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i )
+ for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
{
- if( dimension & ( 1 << i ) )
+ if(dimension & (1 << i))
{
// Do the propagation
- PropagateAll( actor, static_cast< Dimension::Type >( 1 << i ), topOfSubTreeStack, potentialRedundantSubRoots );
+ PropagateAll(actor, static_cast<Dimension::Type>(1 << i), topOfSubTreeStack, potentialRedundantSubRoots);
}
}
- while( !topOfSubTreeStack.empty() )
+ while(!topOfSubTreeStack.empty())
{
// Request this actor as head of sub-tree if it is not dependent on a parent that is dirty
Dali::Actor subTreeActor = topOfSubTreeStack.back();
topOfSubTreeStack.pop_back();
Dali::Actor parent = subTreeActor.GetParent();
- if( !parent || !( GetImplementation( subTreeActor ).RelayoutDependentOnParent() && GetImplementation( parent ).RelayoutRequired() ) )
+ if(!parent || !(GetImplementation(subTreeActor).RelayoutDependentOnParent() && GetImplementation(parent).RelayoutRequired()))
{
// Add sub tree root to relayout list
- AddRequest( subTreeActor );
+ AddRequest(subTreeActor);
// Flag request for end of frame
Request();
}
else
{
- potentialRedundantSubRoots.push_back( subTreeActor );
+ potentialRedundantSubRoots.push_back(subTreeActor);
}
}
// Remove any redundant sub-tree heads
- for( auto& subRoot : potentialRedundantSubRoots )
+ for(auto& subRoot : potentialRedundantSubRoots)
{
- RemoveRequest( subRoot );
+ RemoveRequest(subRoot);
}
- if ( !mProcessingCoreEvents )
+ if(!mProcessingCoreEvents)
{
- mRenderController.RequestProcessEventsOnIdle( false );
+ mRenderController.RequestProcessEventsOnIdle(false);
}
}
void RelayoutController::OnApplicationSceneCreated()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "[Internal::RelayoutController::OnApplicationSceneCreated]\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "[Internal::RelayoutController::OnApplicationSceneCreated]\n");
// Open relayout controller to receive relayout requests
mEnabled = true;
Request();
}
-void RelayoutController::RequestRelayoutTree( Dali::Actor& actor )
+void RelayoutController::RequestRelayoutTree(Dali::Actor& actor)
{
- if( !mEnabled )
+ if(!mEnabled)
{
return;
}
// Only set dirty flag if doing relayout and not already marked as dirty
- Actor& actorImpl = GetImplementation( actor );
- if( actorImpl.RelayoutPossible() )
+ Actor& actorImpl = GetImplementation(actor);
+ if(actorImpl.RelayoutPossible())
{
// If parent is not in relayout we are at the top of a new sub-tree
Dali::Actor parent = actor.GetParent();
- if( !parent || !GetImplementation( parent ).IsRelayoutEnabled() )
+ if(!parent || !GetImplementation(parent).IsRelayoutEnabled())
{
- AddRequest( actor );
+ AddRequest(actor);
}
// Set dirty flag on actors that are enabled
- actorImpl.SetLayoutDirty( true );
- actorImpl.SetLayoutNegotiated( false ); // Reset this flag ready for next relayout
+ actorImpl.SetLayoutDirty(true);
+ actorImpl.SetLayoutNegotiated(false); // Reset this flag ready for next relayout
}
// Propagate down to children
- for( uint32_t i = 0; i < actor.GetChildCount(); ++i )
+ for(uint32_t i = 0; i < actor.GetChildCount(); ++i)
{
- Dali::Actor child = actor.GetChildAt( i );
+ Dali::Actor child = actor.GetChildAt(i);
- RequestRelayoutTree( child );
+ RequestRelayoutTree(child);
}
}
-void RelayoutController::PropagateAll( Dali::Actor& actor, Dimension::Type dimension, std::vector< Dali::Actor >& topOfSubTreeStack, std::vector< Dali::Actor >& potentialRedundantSubRoots )
+void RelayoutController::PropagateAll(Dali::Actor& actor, Dimension::Type dimension, std::vector<Dali::Actor>& topOfSubTreeStack, std::vector<Dali::Actor>& potentialRedundantSubRoots)
{
// Only set dirty flag if doing relayout and not already marked as dirty
- Actor& actorImpl = GetImplementation( actor );
- if( actorImpl.RelayoutPossible( dimension ) )
+ Actor& actorImpl = GetImplementation(actor);
+ if(actorImpl.RelayoutPossible(dimension))
{
// Set dirty and negotiated flags
- actorImpl.SetLayoutDirty( true, dimension );
- actorImpl.SetLayoutNegotiated( false, dimension ); // Reset this flag ready for next relayout
+ actorImpl.SetLayoutDirty(true, dimension);
+ actorImpl.SetLayoutNegotiated(false, dimension); // Reset this flag ready for next relayout
// Check for dimension dependecy: width for height/height for width etc
// Check each possible dimension and see if it is dependent on the input one
- for( uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i )
+ for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
{
- Dimension::Type dimensionToCheck = static_cast< Dimension::Type >( 1 << i );
+ Dimension::Type dimensionToCheck = static_cast<Dimension::Type>(1 << i);
- if( actorImpl.RelayoutDependentOnDimension( dimension, dimensionToCheck ) &&
- !actorImpl.IsLayoutDirty( dimensionToCheck ) )
+ if(actorImpl.RelayoutDependentOnDimension(dimension, dimensionToCheck) &&
+ !actorImpl.IsLayoutDirty(dimensionToCheck))
{
- PropagateAll( actor, dimensionToCheck, topOfSubTreeStack, potentialRedundantSubRoots );
+ PropagateAll(actor, dimensionToCheck, topOfSubTreeStack, potentialRedundantSubRoots);
}
}
// Propagate up to parent
Dali::Actor parent = actor.GetParent();
- if( parent )
+ if(parent)
{
- Actor& parentImpl = GetImplementation( parent );
- if( parentImpl.RelayoutDependentOnChildren( dimension ) && !parentImpl.IsLayoutDirty( dimension ) )
+ Actor& parentImpl = GetImplementation(parent);
+ if(parentImpl.RelayoutDependentOnChildren(dimension) && !parentImpl.IsLayoutDirty(dimension))
{
// Store the highest parent reached
bool found = false;
- for( auto&& element : topOfSubTreeStack )
+ for(auto&& element : topOfSubTreeStack)
{
- if( element == parent )
+ if(element == parent)
{
found = true;
break;
}
}
- if( !found )
+ if(!found)
{
- topOfSubTreeStack.push_back( parent );
+ topOfSubTreeStack.push_back(parent);
}
// Propagate up
- PropagateAll( parent, dimension, topOfSubTreeStack, potentialRedundantSubRoots );
+ PropagateAll(parent, dimension, topOfSubTreeStack, potentialRedundantSubRoots);
}
}
// Propagate down to children
- for( unsigned int i = 0, childCount = actor.GetChildCount(); i < childCount; ++i )
+ for(unsigned int i = 0, childCount = actor.GetChildCount(); i < childCount; ++i)
{
- Dali::Actor child = actor.GetChildAt( i );
- Actor& childImpl = GetImplementation( child );
+ Dali::Actor child = actor.GetChildAt(i);
+ Actor& childImpl = GetImplementation(child);
- if( childImpl.IsRelayoutEnabled() && childImpl.RelayoutDependentOnParent( dimension ) )
+ if(childImpl.IsRelayoutEnabled() && childImpl.RelayoutDependentOnParent(dimension))
{
- if( childImpl.IsLayoutDirty( dimension ) )
+ if(childImpl.IsLayoutDirty(dimension))
{
// We have found a child that could potentially have already been collected for relayout
- potentialRedundantSubRoots.push_back( child );
+ potentialRedundantSubRoots.push_back(child);
}
else
{
- PropagateAll( child, dimension, topOfSubTreeStack, potentialRedundantSubRoots );
+ PropagateAll(child, dimension, topOfSubTreeStack, potentialRedundantSubRoots);
}
}
}
}
}
-
-void RelayoutController::PropagateFlags( Dali::Actor& actor, Dimension::Type dimension )
+void RelayoutController::PropagateFlags(Dali::Actor& actor, Dimension::Type dimension)
{
// Only set dirty flag if doing relayout and not already marked as dirty
- Actor& actorImpl = GetImplementation( actor );
- if( actorImpl.IsRelayoutEnabled() )
+ Actor& actorImpl = GetImplementation(actor);
+ if(actorImpl.IsRelayoutEnabled())
{
// Set dirty and negotiated flags
- actorImpl.SetLayoutDirty( true, dimension );
- actorImpl.SetLayoutNegotiated( false, dimension ); // Reset this flag ready for next relayout
+ actorImpl.SetLayoutDirty(true, dimension);
+ actorImpl.SetLayoutNegotiated(false, dimension); // Reset this flag ready for next relayout
// Check for dimension dependecy: width for height/height for width etc
// Check each possible dimension and see if it is dependent on the input one
- for( uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i )
+ for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
{
- Dimension::Type dimensionToCheck = static_cast< Dimension::Type >( 1 << i );
+ Dimension::Type dimensionToCheck = static_cast<Dimension::Type>(1 << i);
- if( actorImpl.RelayoutDependentOnDimension( dimension, dimensionToCheck ) )
+ if(actorImpl.RelayoutDependentOnDimension(dimension, dimensionToCheck))
{
- PropagateFlags( actor, dimensionToCheck );
+ PropagateFlags(actor, dimensionToCheck);
}
}
// Propagate up to parent
Dali::Actor parent = actor.GetParent();
- if( parent )
+ if(parent)
{
- Actor& parentImpl = GetImplementation( parent );
- if( parentImpl.RelayoutDependentOnChildren( dimension ) )
+ Actor& parentImpl = GetImplementation(parent);
+ if(parentImpl.RelayoutDependentOnChildren(dimension))
{
// Propagate up
- PropagateFlags( parent, dimension );
+ PropagateFlags(parent, dimension);
}
}
// Propagate down to children
- for( uint32_t i = 0, childCount = actor.GetChildCount(); i < childCount; ++i )
+ for(uint32_t i = 0, childCount = actor.GetChildCount(); i < childCount; ++i)
{
- Dali::Actor child = actor.GetChildAt( i );
- Actor& childImpl = GetImplementation( child );
+ Dali::Actor child = actor.GetChildAt(i);
+ Actor& childImpl = GetImplementation(child);
- if( childImpl.RelayoutDependentOnParent( dimension ) )
+ if(childImpl.RelayoutDependentOnParent(dimension))
{
- PropagateFlags( child, dimension );
+ PropagateFlags(child, dimension);
}
}
}
}
-void RelayoutController::AddRequest( Dali::Actor& actor )
+void RelayoutController::AddRequest(Dali::Actor& actor)
{
- Internal::Actor* actorPtr = &GetImplementation( actor );
+ Internal::Actor* actorPtr = &GetImplementation(actor);
// Only add the rootActor if it is not already recorded
- auto itr = std::find( mDirtyLayoutSubTrees.begin(), mDirtyLayoutSubTrees.end(), actorPtr );
+ auto itr = std::find(mDirtyLayoutSubTrees.begin(), mDirtyLayoutSubTrees.end(), actorPtr);
- if( itr == mDirtyLayoutSubTrees.end() )
+ if(itr == mDirtyLayoutSubTrees.end())
{
- mDirtyLayoutSubTrees.PushBack( actorPtr );
+ mDirtyLayoutSubTrees.PushBack(actorPtr);
}
}
-void RelayoutController::RemoveRequest( Dali::Actor& actor )
+void RelayoutController::RemoveRequest(Dali::Actor& actor)
{
- Internal::Actor* actorPtr = &GetImplementation( actor );
+ Internal::Actor* actorPtr = &GetImplementation(actor);
- mDirtyLayoutSubTrees.Erase( std::remove( mDirtyLayoutSubTrees.begin(),
- mDirtyLayoutSubTrees.end(),
- actorPtr ),
- mDirtyLayoutSubTrees.end() );
+ mDirtyLayoutSubTrees.Erase(std::remove(mDirtyLayoutSubTrees.begin(),
+ mDirtyLayoutSubTrees.end(),
+ actorPtr),
+ mDirtyLayoutSubTrees.end());
}
void RelayoutController::Request()
{
mRelayoutFlag = true;
- if( !mRelayoutConnection )
+ if(!mRelayoutConnection)
{
- ThreadLocalStorage::Get().GetObjectRegistry().ObjectDestroyedSignal().Connect( mSlotDelegate, &RelayoutController::OnObjectDestroyed );
+ ThreadLocalStorage::Get().GetObjectRegistry().ObjectDestroyedSignal().Connect(mSlotDelegate, &RelayoutController::OnObjectDestroyed);
mRelayoutConnection = true;
}
}
-void RelayoutController::OnObjectDestroyed( const Dali::RefObject* object )
+void RelayoutController::OnObjectDestroyed(const Dali::RefObject* object)
{
// Search for and null the object if found in the following lists
- FindAndZero( mDirtyLayoutSubTrees, object );
+ FindAndZero(mDirtyLayoutSubTrees, object);
}
void RelayoutController::Relayout()
{
// Only do something when requested
- if( mRelayoutFlag )
+ if(mRelayoutFlag)
{
mPerformingRelayout = true;
// 1. Finds all top-level controls from the dirty list and allocate them the size of the scene
// These controls are paired with the parent/scene size and added to the stack.
- for( auto& dirtyActor : mDirtyLayoutSubTrees )
+ for(auto& dirtyActor : mDirtyLayoutSubTrees)
{
// Need to test if actor is valid (could have been deleted and had the pointer cleared)
- if( dirtyActor )
+ if(dirtyActor)
{
// Only negotiate actors that are on the scene
- if( dirtyActor->OnScene() )
+ if(dirtyActor->OnScene())
{
Internal::Actor* parent = dirtyActor->GetParent();
- QueueActor( dirtyActor, *mRelayoutStack, ( parent ) ? Vector2( parent->GetTargetSize() ) : dirtyActor->GetScene().GetSize() );
+ QueueActor(dirtyActor, *mRelayoutStack, (parent) ? Vector2(parent->GetTargetSize()) : dirtyActor->GetScene().GetSize());
}
}
}
mDirtyLayoutSubTrees.Clear();
// 2. Iterate through the stack until it's empty.
- if( mRelayoutStack->Size() > 0 )
+ if(mRelayoutStack->Size() > 0)
{
PRINT_HIERARCHY;
- while( mRelayoutStack->Size() > 0 )
+ while(mRelayoutStack->Size() > 0)
{
Dali::Actor actor;
- Vector2 size;
- mRelayoutStack->Get( mRelayoutStack->Size() - 1, actor, size );
- Actor& actorImpl = GetImplementation( actor );
+ Vector2 size;
+ mRelayoutStack->Get(mRelayoutStack->Size() - 1, actor, size);
+ Actor& actorImpl = GetImplementation(actor);
mRelayoutStack->PopBack();
- if( actorImpl.RelayoutRequired() )
+ if(actorImpl.RelayoutRequired())
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "[Internal::RelayoutController::Relayout] Negotiating %p %s %s (%.2f, %.2f)\n", &actorImpl, actor.GetTypeName().c_str(), actor.GetProperty< std::string >( Dali::Actor::Property::NAME ).c_str(), size.width, size.height );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "[Internal::RelayoutController::Relayout] Negotiating %p %s %s (%.2f, %.2f)\n", &actorImpl, actor.GetTypeName().c_str(), actor.GetProperty<std::string>(Dali::Actor::Property::NAME).c_str(), size.width, size.height);
// 3. Negotiate the size with the current actor. Pass it an empty container which the actor
// has to fill with all the actors it has not done any size negotiation for.
- actorImpl.NegotiateSize( size, *mRelayoutStack );
+ actorImpl.NegotiateSize(size, *mRelayoutStack);
// Reset the flag so that size negotiation will respect the actor's original resize policy
- actorImpl.SetUseAssignedSize( false );
+ actorImpl.SetUseAssignedSize(false);
}
}
// this algorithm needs more optimization as well
}
-void RelayoutController::SetEnabled( bool enabled )
+void RelayoutController::SetEnabled(bool enabled)
{
mEnabled = enabled;
}
return mPerformingRelayout;
}
-void RelayoutController::SetProcessingCoreEvents( bool processingEvents )
+void RelayoutController::SetProcessingCoreEvents(bool processingEvents)
{
mProcessingCoreEvents = processingEvents;
}
-void RelayoutController::FindAndZero( const RawActorList& list, const Dali::RefObject* object )
+void RelayoutController::FindAndZero(const RawActorList& list, const Dali::RefObject* object)
{
// Object has been destroyed so clear it from this list
- for( auto& actor : list )
+ for(auto& actor : list)
{
- if( actor && ( actor == object ) )
+ if(actor && (actor == object))
{
actor = nullptr; // Reset the pointer in the list. We don't want to remove it in case something is iterating over the list.
}
#define DALI_INTERNAL_RELAYOUT_CONTROLLER_IMPL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstdint>
// INTERNAL INCLUDES
+#include <dali/internal/common/memory-pool-object-allocator.h>
+#include <dali/internal/event/size-negotiation/memory-pool-relayout-container.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/size-negotiation/relayout-container.h>
-#include <dali/internal/common/memory-pool-object-allocator.h>
-#include <dali/internal/event/size-negotiation/memory-pool-relayout-container.h>
namespace Dali
{
-
namespace Integration
{
class RenderController;
namespace Internal
{
-
/**
* @brief The relayout controller is responsible for taking request from actors to relayout their sizes.
* The requests are actioned on at the end of the frame where all actors that have made a request are
class RelayoutController : public Dali::BaseObject
{
public:
-
/**
* @brief Constructor.
* We should only create a unique instance.
* @param[in] controller to request a render from the RenderController if core is not processing events.
*/
- RelayoutController( Integration::RenderController& controller );
+ RelayoutController(Integration::RenderController& controller);
/**
* Destructor
* @param[in] actor The actor to request relayout on
* @param[in] dimension The dimension(s) to request the relayout on. Defaults to all dimensions
*/
- void RequestRelayout( Dali::Actor& actor, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
+ void RequestRelayout(Dali::Actor& actor, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
/**
* @brief Request to relayout of all actors in the sub-tree below the given actor.
*
* @param[in] actor The actor to request relayout on
*/
- void RequestRelayoutTree( Dali::Actor& actor );
+ void RequestRelayoutTree(Dali::Actor& actor);
/**
* @brief Force propagate relayout flags through the tree. This is similiar to Request Relayout
* @param[in] actor The actor to propagate from
* @param[in] dimension The dimension to propagate on
*/
- void PropagateFlags( Dali::Actor& actor, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
+ void PropagateFlags(Dali::Actor& actor, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
/**
* @brief Relayouts all actors that have been marked as dirty
*
* @param[in] enabled Flag to indicate whether the controller should be enabled or disabled
*/
- void SetEnabled( bool enabled );
+ void SetEnabled(bool enabled);
/**
* @brief Return true if the relayout controller is currently performing a relayout
*
* @param[in] processingEvents whether core is processing events.
*/
- void SetProcessingCoreEvents( bool processingEvents );
+ void SetProcessingCoreEvents(bool processingEvents);
public: // CALLBACKS
-
/**
* @brief Callback raised after the application creates the scene
*/
*
* @param[in] object The object being destroyed
*/
- void OnObjectDestroyed( const Dali::RefObject* object );
+ void OnObjectDestroyed(const Dali::RefObject* object);
private:
-
- using RawActorList = Dali::Vector< Dali::Internal::Actor* >;
+ using RawActorList = Dali::Vector<Dali::Internal::Actor*>;
/**
* @brief Request for relayout. Relays out whole scene.
*
* @param[in] actor The root of the sub tree to add
*/
- void AddRequest( Dali::Actor& actor );
+ void AddRequest(Dali::Actor& actor);
/**
* @brief Remove actor from request list
*
* @param[in] actor The root of the sub tree to remove
*/
- void RemoveRequest( Dali::Actor& actor );
+ void RemoveRequest(Dali::Actor& actor);
/**
* @brief Disconnect the Relayout() method from the Stage::EventProcessingFinishedSignal().
* @param[in] topOfSubTreeStack The top of the sub tree that this actor is in
* @param[in] potentialRedundantSubRoots Actors collected as potentially already being included in relayout
*/
- void PropagateAll( Dali::Actor& actor, Dimension::Type dimension, std::vector< Dali::Actor >& topOfSubTreeStack, std::vector< Dali::Actor >& potentialRedundantSubRoots );
+ void PropagateAll(Dali::Actor& actor, Dimension::Type dimension, std::vector<Dali::Actor>& topOfSubTreeStack, std::vector<Dali::Actor>& potentialRedundantSubRoots);
/**
* Queue an actor on the relayout container
* @param[in] actors The container to add the actor to
* @param[in] size The size that this actor should be
*/
- void QueueActor( Internal::Actor* actor, RelayoutContainer& actors, Vector2 size );
+ void QueueActor(Internal::Actor* actor, RelayoutContainer& actors, Vector2 size);
/**
* @brief Find the given object in the list and null it out
* @param[in] list The list to search
* @param[in] object The object to search for
*/
- void FindAndZero( const RawActorList& list, const Dali::RefObject* object );
+ void FindAndZero(const RawActorList& list, const Dali::RefObject* object);
// Undefined
RelayoutController(const RelayoutController&) = delete;
RelayoutController& operator=(const RelayoutController&) = delete;
private:
+ Integration::RenderController& mRenderController;
+ MemoryPoolObjectAllocator<MemoryPoolRelayoutContainer::RelayoutInfo> mRelayoutInfoAllocator;
- Integration::RenderController& mRenderController;
- MemoryPoolObjectAllocator< MemoryPoolRelayoutContainer::RelayoutInfo > mRelayoutInfoAllocator;
-
- SlotDelegate< RelayoutController > mSlotDelegate;
-
- RawActorList mDirtyLayoutSubTrees; ///< List of roots of sub trees that are dirty
- MemoryPoolRelayoutContainer* mRelayoutStack; ///< Stack for relayouting
+ SlotDelegate<RelayoutController> mSlotDelegate;
- bool mRelayoutConnection : 1; ///< Whether EventProcessingFinishedSignal signal is connected.
- bool mRelayoutFlag : 1; ///< Relayout flag to avoid unnecessary calls
- bool mEnabled : 1; ///< Initially disabled. Must be enabled at some point.
- bool mPerformingRelayout : 1; ///< The relayout controller is currently performing a relayout
- bool mProcessingCoreEvents : 1; ///< Whether core is processing events.
+ RawActorList mDirtyLayoutSubTrees; ///< List of roots of sub trees that are dirty
+ MemoryPoolRelayoutContainer* mRelayoutStack; ///< Stack for relayouting
+ bool mRelayoutConnection : 1; ///< Whether EventProcessingFinishedSignal signal is connected.
+ bool mRelayoutFlag : 1; ///< Relayout flag to avoid unnecessary calls
+ bool mEnabled : 1; ///< Initially disabled. Must be enabled at some point.
+ bool mPerformingRelayout : 1; ///< The relayout controller is currently performing a relayout
+ bool mProcessingCoreEvents : 1; ///< Whether core is processing events.
};
} // namespace Internal
#define DALI_FRAME_CALLBACK_INTERFACE_IMPL_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
namespace SceneGraph
{
class FrameCallback;
}
-}
+} // namespace Internal
/**
* The Implementation of the FrameCallbackInterface
class FrameCallbackInterface::Impl final
{
public:
-
- Impl() = default; ///< Default constructor.
+ Impl() = default; ///< Default constructor.
~Impl() = default; ///< Default non-virtual destructor.
/**
* Retrieve the Impl of a FrameCallbackInterface.
* @param[in] frameCallback The frame-callb
*/
- static inline Impl& Get( FrameCallbackInterface& frameCallback )
+ static inline Impl& Get(FrameCallbackInterface& frameCallback)
{
return *frameCallback.mImpl;
}
* Links this FrameCallback to the given scene-graph-frame-callback.
* @param[in] sceneGraphObject The scene-graph-frame-callback to link this with.
*/
- void ConnectToSceneGraphObject( Internal::SceneGraph::FrameCallback& sceneGraphObject )
+ void ConnectToSceneGraphObject(Internal::SceneGraph::FrameCallback& sceneGraphObject)
{
mSceneGraphFrameCallback = &sceneGraphObject;
}
*/
void Invalidate()
{
- if( mSceneGraphFrameCallback )
+ if(mSceneGraphFrameCallback)
{
mSceneGraphFrameCallback->Invalidate();
}
}
private:
- Internal::SceneGraph::FrameCallback* mSceneGraphFrameCallback{ nullptr }; ///< Pointer to the scene-graph object, not owned.
+ Internal::SceneGraph::FrameCallback* mSceneGraphFrameCallback{nullptr}; ///< Pointer to the scene-graph object, not owned.
};
} // namespace Dali
#define DALI_INTERNAL_PERFORMANCE_MONITOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
-
-
/**
* @brief PerformanceMonitor.
* Empty stubs should we decided to hook into monitoring counters
class PerformanceMonitor
{
public:
-
/*
* Metric enums
*/
#define PERF_MONITOR_START(x) // start of timed event
#define PERF_MONITOR_END(x) // end of a timed event
#define INCREASE_COUNTER(x) // increase a counter by 1
-#define INCREASE_BY(x,y) // increase a count by x
+#define INCREASE_BY(x, y) // increase a count by x
#define MATH_INCREASE_COUNTER(x) // increase a math counter ( MATRIX_MULTIPLYS, QUATERNION_TO_MATRIX, FLOAT_POINT_MULTIPLY)
-#define MATH_INCREASE_BY(x,y) // increase a math counter by x
+#define MATH_INCREASE_BY(x, y) // increase a math counter by x
#define PERF_MONITOR_NEXT_FRAME() // update started rendering a new frame
} // namespace Internal
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/render/common/render-debug.h>
-#include <dali/internal/render/common/render-list.h>
#include <dali/internal/render/common/render-instruction.h>
+#include <dali/internal/render/common/render-list.h>
#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/render/renderers/render-renderer.h>
#include <dali/internal/update/nodes/scene-graph-layer.h>
+using Dali::Internal::SceneGraph::RenderInstruction;
using Dali::Internal::SceneGraph::RenderItem;
using Dali::Internal::SceneGraph::RenderList;
using Dali::Internal::SceneGraph::RenderListContainer;
-using Dali::Internal::SceneGraph::RenderInstruction;
namespace Dali
{
-
namespace Internal
{
-
namespace Render
{
-
namespace
{
-
// Table for fast look-up of Dali::DepthFunction enum to a GL depth function.
// Note: These MUST be in the same order as Dali::DepthFunction enum.
-const int DaliDepthToGLDepthTable[] = { GL_NEVER, GL_ALWAYS, GL_LESS, GL_GREATER, GL_EQUAL, GL_NOTEQUAL, GL_LEQUAL, GL_GEQUAL };
+const int DaliDepthToGLDepthTable[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_GREATER, GL_EQUAL, GL_NOTEQUAL, GL_LEQUAL, GL_GEQUAL};
// Table for fast look-up of Dali::StencilFunction enum to a GL stencil function.
// Note: These MUST be in the same order as Dali::StencilFunction enum.
-const int DaliStencilFunctionToGL[] = { GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, GL_ALWAYS };
+const int DaliStencilFunctionToGL[] = {GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, GL_ALWAYS};
// Table for fast look-up of Dali::StencilOperation enum to a GL stencil operation.
// Note: These MUST be in the same order as Dali::StencilOperation enum.
-const int DaliStencilOperationToGL[] = { GL_ZERO, GL_KEEP, GL_REPLACE, GL_INCR, GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP };
+const int DaliStencilOperationToGL[] = {GL_ZERO, GL_KEEP, GL_REPLACE, GL_INCR, GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP};
/**
* @brief Find the intersection of two AABB rectangles.
* @param[in] aabbB Rectangle B
* @return The intersection of rectangle A & B (result is a rectangle)
*/
-inline ClippingBox IntersectAABB( const ClippingBox& aabbA, const ClippingBox& aabbB )
+inline ClippingBox IntersectAABB(const ClippingBox& aabbA, const ClippingBox& aabbB)
{
ClippingBox intersectionBox;
// First calculate the largest starting positions in X and Y.
- intersectionBox.x = std::max( aabbA.x, aabbB.x );
- intersectionBox.y = std::max( aabbA.y, aabbB.y );
+ intersectionBox.x = std::max(aabbA.x, aabbB.x);
+ intersectionBox.y = std::max(aabbA.y, aabbB.y);
// Now calculate the smallest ending positions, and take the largest starting
// positions from the result, to get the width and height respectively.
// If the two boxes do not intersect at all, then we need a 0 width and height clipping area.
// We use max here to clamp both width and height to >= 0 for this use-case.
- intersectionBox.width = std::max( std::min( aabbA.x + aabbA.width, aabbB.x + aabbB.width ) - intersectionBox.x, 0 );
- intersectionBox.height = std::max( std::min( aabbA.y + aabbA.height, aabbB.y + aabbB.height ) - intersectionBox.y, 0 );
+ intersectionBox.width = std::max(std::min(aabbA.x + aabbA.width, aabbB.x + aabbB.width) - intersectionBox.x, 0);
+ intersectionBox.height = std::max(std::min(aabbA.y + aabbA.height, aabbB.y + aabbB.height) - intersectionBox.y, 0);
return intersectionBox;
}
* @param[in/out] lastClippingDepth The stencil depth of the last renderer drawn.
* @param[in/out] lastClippingId The clipping ID of the last renderer drawn.
*/
-inline void SetupStencilClipping( const RenderItem& item, Context& context, uint32_t& lastClippingDepth, uint32_t& lastClippingId )
+inline void SetupStencilClipping(const RenderItem& item, Context& context, uint32_t& lastClippingDepth, uint32_t& lastClippingId)
{
- const Dali::Internal::SceneGraph::Node* node = item.mNode;
- const uint32_t clippingId = node->GetClippingId();
+ const Dali::Internal::SceneGraph::Node* node = item.mNode;
+ const uint32_t clippingId = node->GetClippingId();
// If there is no clipping Id, then either we haven't reached a clipping Node yet, or there aren't any.
// Either way we can skip clipping setup for this renderer.
- if( clippingId == 0u )
+ if(clippingId == 0u)
{
// Exit immediately if there are no clipping actions to perform (EG. we have not yet hit a clipping node).
- context.EnableStencilBuffer( false );
+ context.EnableStencilBuffer(false);
return;
}
- context.EnableStencilBuffer( true );
+ context.EnableStencilBuffer(true);
const uint32_t clippingDepth = node->GetClippingDepth();
// Pre-calculate a mask which has all bits set up to and including the current clipping depth.
// EG. If depth is 3, the mask would be "111" in binary.
- const uint32_t currentDepthMask = ( 1u << clippingDepth ) - 1u;
+ const uint32_t currentDepthMask = (1u << clippingDepth) - 1u;
// Are we are writing to the stencil buffer?
- if( item.mNode->GetClippingMode() == Dali::ClippingMode::CLIP_CHILDREN )
+ if(item.mNode->GetClippingMode() == Dali::ClippingMode::CLIP_CHILDREN)
{
// We are writing to the stencil buffer.
// If clipping Id is 1, this is the first clipping renderer within this render-list.
- if( clippingId == 1u )
+ if(clippingId == 1u)
{
// We are enabling the stencil-buffer for the first time within this render list.
// Clear the buffer at this point.
- context.StencilMask( 0xff );
- context.Clear( GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES );
+ context.StencilMask(0xff);
+ context.Clear(GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES);
}
- else if( ( clippingDepth < lastClippingDepth ) ||
- ( ( clippingDepth == lastClippingDepth ) && ( clippingId > lastClippingId ) ) )
+ else if((clippingDepth < lastClippingDepth) ||
+ ((clippingDepth == lastClippingDepth) && (clippingId > lastClippingId)))
{
// The above if() statement tests if we need to clear some (not all) stencil bit-planes.
// We need to do this if either of the following are true:
//
// This calculation takes the new depth to move to, and creates an inverse-mask of that number of consecutive bits.
// This has the effect of clearing everything except the bit-planes up to (and including) our current depth.
- const uint32_t stencilClearMask = ( currentDepthMask >> 1u ) ^ 0xff;
+ const uint32_t stencilClearMask = (currentDepthMask >> 1u) ^ 0xff;
- context.StencilMask( stencilClearMask );
- context.Clear( GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES );
+ context.StencilMask(stencilClearMask);
+ context.Clear(GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES);
}
// We keep track of the last clipping Id and depth so we can determine when we are
// moving back up the scene graph and require some of the stencil bit-planes to be deleted.
lastClippingDepth = clippingDepth;
- lastClippingId = clippingId;
+ lastClippingId = clippingId;
// We only ever write to bit-planes up to the current depth as we may need
// to erase individual bit-planes and revert to a previous clipping area.
// As the mask is made up of contiguous "1" values, we can do this quickly with a bit-shift.
const uint32_t testMask = currentDepthMask >> 1u;
- context.StencilFunc( GL_EQUAL, currentDepthMask, testMask ); // Test against existing stencil bit-planes. All must match up to (but not including) this depth.
- context.StencilMask( currentDepthMask ); // Write to the new stencil bit-plane (the other previous bit-planes are also written to).
- context.StencilOp( GL_KEEP, GL_REPLACE, GL_REPLACE );
+ context.StencilFunc(GL_EQUAL, currentDepthMask, testMask); // Test against existing stencil bit-planes. All must match up to (but not including) this depth.
+ context.StencilMask(currentDepthMask); // Write to the new stencil bit-plane (the other previous bit-planes are also written to).
+ context.StencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
}
else
{
// We are reading from the stencil buffer. Set up the stencil accordingly
// This calculation sets all the bits up to the current depth bit.
// This has the effect of testing that the pixel being written to exists in every bit-plane up to the current depth.
- context.StencilFunc( GL_EQUAL, currentDepthMask, currentDepthMask );
- context.StencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
+ context.StencilFunc(GL_EQUAL, currentDepthMask, currentDepthMask);
+ context.StencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
}
}
* @param[in] depthTestEnabled True if depth testing has been enabled.
* @param[in/out] firstDepthBufferUse Initialize to true on the first call, this method will set it to false afterwards.
*/
-inline void SetupDepthBuffer( const RenderItem& item, Context& context, bool depthTestEnabled, bool& firstDepthBufferUse )
+inline void SetupDepthBuffer(const RenderItem& item, Context& context, bool depthTestEnabled, bool& firstDepthBufferUse)
{
// Set up whether or not to write to the depth buffer.
const DepthWriteMode::Type depthWriteMode = item.mRenderer->GetDepthWriteMode();
// Most common mode (AUTO) is tested first.
- const bool enableDepthWrite = ( ( depthWriteMode == DepthWriteMode::AUTO ) && depthTestEnabled && item.mIsOpaque ) ||
- ( depthWriteMode == DepthWriteMode::ON );
+ const bool enableDepthWrite = ((depthWriteMode == DepthWriteMode::AUTO) && depthTestEnabled && item.mIsOpaque) ||
+ (depthWriteMode == DepthWriteMode::ON);
// Set up whether or not to read from (test) the depth buffer.
const DepthTestMode::Type depthTestMode = item.mRenderer->GetDepthTestMode();
// Most common mode (AUTO) is tested first.
- const bool enableDepthTest = ( ( depthTestMode == DepthTestMode::AUTO ) && depthTestEnabled ) ||
- ( depthTestMode == DepthTestMode::ON );
+ const bool enableDepthTest = ((depthTestMode == DepthTestMode::AUTO) && depthTestEnabled) ||
+ (depthTestMode == DepthTestMode::ON);
// Is the depth buffer in use?
- if( enableDepthWrite || enableDepthTest )
+ if(enableDepthWrite || enableDepthTest)
{
// The depth buffer must be enabled if either reading or writing.
- context.EnableDepthBuffer( true );
+ context.EnableDepthBuffer(true);
// Look-up the GL depth function from the Dali::DepthFunction enum, and set it.
- context.DepthFunc( DaliDepthToGLDepthTable[ item.mRenderer->GetDepthFunction() ] );
+ context.DepthFunc(DaliDepthToGLDepthTable[item.mRenderer->GetDepthFunction()]);
// If this is the first use of the depth buffer this RenderTask, perform a clear.
// Note: We could do this at the beginning of the RenderTask and rely on the
// context cache to ignore the clear if not required, but, we would have to enable
// the depth buffer to do so, which could be a redundant enable.
- if( DALI_UNLIKELY( firstDepthBufferUse ) )
+ if(DALI_UNLIKELY(firstDepthBufferUse))
{
// This is the first time the depth buffer is being written to or read.
firstDepthBufferUse = false;
// Note: The buffer will only be cleared if written to since a previous clear.
- context.DepthMask( true );
- context.Clear( GL_DEPTH_BUFFER_BIT, Context::CHECK_CACHED_VALUES );
+ context.DepthMask(true);
+ context.Clear(GL_DEPTH_BUFFER_BIT, Context::CHECK_CACHED_VALUES);
}
// Set up the depth mask based on our depth write setting.
- context.DepthMask( enableDepthWrite );
+ context.DepthMask(enableDepthWrite);
}
else
{
// The depth buffer is not being used by this renderer, so we must disable it to stop it being tested.
- context.EnableDepthBuffer( false );
+ context.EnableDepthBuffer(false);
}
}
inline void RenderAlgorithms::SetupScissorClipping(const RenderItem& item, Context& context, const RenderInstruction& instruction)
{
// Get the number of child scissors in the stack (do not include layer or root box).
- size_t childStackDepth = mScissorStack.size() - 1u;
- const uint32_t scissorDepth = item.mNode->GetScissorDepth();
- const bool clippingNode = item.mNode->GetClippingMode() == Dali::ClippingMode::CLIP_TO_BOUNDING_BOX;
- bool traversedUpTree = false;
+ size_t childStackDepth = mScissorStack.size() - 1u;
+ const uint32_t scissorDepth = item.mNode->GetScissorDepth();
+ const bool clippingNode = item.mNode->GetClippingMode() == Dali::ClippingMode::CLIP_TO_BOUNDING_BOX;
+ bool traversedUpTree = false;
// If we are using scissor clipping and we are at the same depth (or less), we need to undo previous clips.
// We do this by traversing up the scissor clip stack and then apply the appropriate clip for the current render item.
// So we know if we are at depth 4 and the stackDepth is 5, that we have gone up.
// If the depth is the same then we are effectively part of a different sub-tree from the parent, we must also remove the current clip.
// Note: Stack depth must always be at least 1, as we will have the layer or stage size as the root value.
- if( ( childStackDepth > 0u ) && ( scissorDepth < childStackDepth ) )
+ if((childStackDepth > 0u) && (scissorDepth < childStackDepth))
{
- while( scissorDepth < childStackDepth )
+ while(scissorDepth < childStackDepth)
{
mScissorStack.pop_back();
--childStackDepth;
// We traversed up the tree, we need to apply a new scissor rectangle (unless we are at the root).
traversedUpTree = true;
}
- if( clippingNode && childStackDepth > 0u && childStackDepth == scissorDepth ) // case of sibling clip area
+ if(clippingNode && childStackDepth > 0u && childStackDepth == scissorDepth) // case of sibling clip area
{
mScissorStack.pop_back();
--childStackDepth;
}
// If we are on a clipping node, or we have traveled up the tree and gone back past a clipping node, may need to apply a new scissor clip.
- if( clippingNode || traversedUpTree )
+ if(clippingNode || traversedUpTree)
{
// First, check if we are a clipping node.
- if( clippingNode )
+ if(clippingNode)
{
// This is a clipping node. We generate the AABB for this node and intersect it with the previous intersection further up the tree.
// Get the AABB bounding box for the current render item.
- const ClippingBox scissorBox( item.CalculateViewportSpaceAABB( item.mSize, mViewportRectangle.width, mViewportRectangle.height ) );
+ const ClippingBox scissorBox(item.CalculateViewportSpaceAABB(item.mSize, mViewportRectangle.width, mViewportRectangle.height));
// Get the AABB for the parent item that we must intersect with.
- const ClippingBox& parentBox( mScissorStack.back() );
+ const ClippingBox& parentBox(mScissorStack.back());
// We must reduce the clipping area based on the parents area to allow nested clips. This is a set intersection function.
// We add the new scissor box to the stack so we can return to it if needed.
- mScissorStack.emplace_back( IntersectAABB( parentBox, scissorBox ) );
+ mScissorStack.emplace_back(IntersectAABB(parentBox, scissorBox));
}
// The scissor test is enabled if we have any children on the stack, OR, if there are none but it is a user specified layer scissor box.
// IE. It is not enabled if we are at the top of the stack and the layer does not have a specified clipping box.
- const bool scissorEnabled = ( mScissorStack.size() > 0u ) || mHasLayerScissor;
+ const bool scissorEnabled = (mScissorStack.size() > 0u) || mHasLayerScissor;
// Enable the scissor test based on the above calculation
- context.SetScissorTest( scissorEnabled );
+ context.SetScissorTest(scissorEnabled);
// If scissor is enabled, we use the calculated screen-space coordinates (now in the stack).
- if( scissorEnabled )
+ if(scissorEnabled)
{
- ClippingBox useScissorBox( mScissorStack.back() );
+ ClippingBox useScissorBox(mScissorStack.back());
if(instruction.mFrameBuffer && instruction.GetCamera()->IsYAxisInverted())
{
useScissorBox.y = (instruction.mFrameBuffer->GetHeight() - useScissorBox.height) - useScissorBox.y;
}
- context.Scissor( useScissorBox.x, useScissorBox.y, useScissorBox.width, useScissorBox.height );
+ context.Scissor(useScissorBox.x, useScissorBox.y, useScissorBox.width, useScissorBox.height);
}
}
}
const RenderInstruction& instruction)
{
RenderMode::Type renderMode = RenderMode::AUTO;
- const Renderer *renderer = item.mRenderer;
- if( renderer )
+ const Renderer* renderer = item.mRenderer;
+ if(renderer)
{
renderMode = renderer->GetRenderMode();
}
// Setup the stencil using either the automatic clipping feature, or, the manual per-renderer stencil API.
// Note: This switch is in order of most likely value first.
- switch( renderMode )
+ switch(renderMode)
{
case RenderMode::AUTO:
{
// Turn the color buffer on as we always want to render this renderer, regardless of clipping hierarchy.
- context.ColorMask( true );
+ context.ColorMask(true);
// The automatic clipping feature will manage the scissor and stencil functions, only if stencil buffer is available for the latter.
// As both scissor and stencil clips can be nested, we may be simultaneously traversing up the scissor tree, requiring a scissor to be un-done. Whilst simultaneously adding a new stencil clip.
// Both methods with return rapidly if there is nothing to be done for that type of clipping.
SetupScissorClipping(item, context, instruction);
- if( stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE )
+ if(stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE)
{
- SetupStencilClipping( item, context, lastClippingDepth, lastClippingId );
+ SetupStencilClipping(item, context, lastClippingDepth, lastClippingId);
}
break;
}
// No clipping is performed for these modes.
// Note: We do not turn off scissor clipping as it may be used for the whole layer.
// The stencil buffer will not be used at all, but we only need to disable it if it's available.
- if( stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE )
+ if(stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE)
{
- context.EnableStencilBuffer( false );
+ context.EnableStencilBuffer(false);
}
// Setup the color buffer based on the RenderMode.
- context.ColorMask( renderMode == RenderMode::COLOR );
+ context.ColorMask(renderMode == RenderMode::COLOR);
break;
}
case RenderMode::STENCIL:
case RenderMode::COLOR_STENCIL:
{
- if( stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE )
+ if(stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE)
{
// We are using the low-level Renderer Stencil API.
// The stencil buffer must be enabled for every renderer with stencil mode on, as renderers in between can disable it.
// Note: As the command state is cached, it is only sent when needed.
- context.EnableStencilBuffer( true );
+ context.EnableStencilBuffer(true);
// Setup the color buffer based on the RenderMode.
- context.ColorMask( renderMode == RenderMode::COLOR_STENCIL );
+ context.ColorMask(renderMode == RenderMode::COLOR_STENCIL);
// If this is the first use of the stencil buffer within this RenderList, clear it (this avoids unnecessary clears).
- if( !usedStencilBuffer )
+ if(!usedStencilBuffer)
{
- context.Clear( GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES );
+ context.Clear(GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES);
usedStencilBuffer = true;
}
// Setup the stencil buffer based on the renderers properties.
- context.StencilFunc( DaliStencilFunctionToGL[ renderer->GetStencilFunction() ],
- renderer->GetStencilFunctionReference(),
- renderer->GetStencilFunctionMask() );
- context.StencilOp( DaliStencilOperationToGL[ renderer->GetStencilOperationOnFail() ],
- DaliStencilOperationToGL[ renderer->GetStencilOperationOnZFail() ],
- DaliStencilOperationToGL[ renderer->GetStencilOperationOnZPass() ] );
- context.StencilMask( renderer->GetStencilMask() );
+ context.StencilFunc(DaliStencilFunctionToGL[renderer->GetStencilFunction()],
+ renderer->GetStencilFunctionReference(),
+ renderer->GetStencilFunctionMask());
+ context.StencilOp(DaliStencilOperationToGL[renderer->GetStencilOperationOnFail()],
+ DaliStencilOperationToGL[renderer->GetStencilOperationOnZFail()],
+ DaliStencilOperationToGL[renderer->GetStencilOperationOnZPass()]);
+ context.StencilMask(renderer->GetStencilMask());
}
break;
}
}
}
-inline void RenderAlgorithms::ProcessRenderList( const RenderList& renderList,
- Context& context,
- BufferIndex bufferIndex,
- const Matrix& viewMatrix,
- const Matrix& projectionMatrix,
- Integration::DepthBufferAvailable depthBufferAvailable,
- Integration::StencilBufferAvailable stencilBufferAvailable,
- Vector<GLuint>& boundTextures,
- const RenderInstruction& instruction,
- const Rect<int>& rootClippingRect
- )
+inline void RenderAlgorithms::ProcessRenderList(const RenderList& renderList,
+ Context& context,
+ BufferIndex bufferIndex,
+ const Matrix& viewMatrix,
+ const Matrix& projectionMatrix,
+ Integration::DepthBufferAvailable depthBufferAvailable,
+ Integration::StencilBufferAvailable stencilBufferAvailable,
+ Vector<GLuint>& boundTextures,
+ const RenderInstruction& instruction,
+ const Rect<int>& rootClippingRect)
{
- DALI_PRINT_RENDER_LIST( renderList );
+ DALI_PRINT_RENDER_LIST(renderList);
// Note: The depth buffer is enabled or disabled on a per-renderer basis.
// Here we pre-calculate the value to use if these modes are set to AUTO.
- const bool autoDepthTestMode( ( depthBufferAvailable == Integration::DepthBufferAvailable::TRUE ) &&
- !( renderList.GetSourceLayer()->IsDepthTestDisabled() ) &&
- renderList.HasColorRenderItems() );
+ const bool autoDepthTestMode((depthBufferAvailable == Integration::DepthBufferAvailable::TRUE) &&
+ !(renderList.GetSourceLayer()->IsDepthTestDisabled()) &&
+ renderList.HasColorRenderItems());
const std::size_t count = renderList.Count();
- uint32_t lastClippingDepth( 0u );
- uint32_t lastClippingId( 0u );
- bool usedStencilBuffer( false );
- bool firstDepthBufferUse( true );
+ uint32_t lastClippingDepth(0u);
+ uint32_t lastClippingId(0u);
+ bool usedStencilBuffer(false);
+ bool firstDepthBufferUse(true);
mViewportRectangle = context.GetViewport();
- mHasLayerScissor = false;
+ mHasLayerScissor = false;
// Setup Scissor testing (for both viewport and per-node scissor)
mScissorStack.clear();
// Add root clipping rect (set manually for Render function ny partial update for example)
// on the bottom of the stack
- if (!rootClippingRect.IsEmpty())
+ if(!rootClippingRect.IsEmpty())
{
- context.SetScissorTest( true );
- context.Scissor( rootClippingRect.x, rootClippingRect.y, rootClippingRect.width, rootClippingRect.height );
- mScissorStack.push_back( rootClippingRect );
+ context.SetScissorTest(true);
+ context.Scissor(rootClippingRect.x, rootClippingRect.y, rootClippingRect.width, rootClippingRect.height);
+ mScissorStack.push_back(rootClippingRect);
}
// We are not performing a layer clip and no clipping rect set. Add the viewport as the root scissor rectangle.
- else if (!renderList.IsClipping())
+ else if(!renderList.IsClipping())
{
- context.SetScissorTest( false );
- mScissorStack.push_back( mViewportRectangle );
+ context.SetScissorTest(false);
+ mScissorStack.push_back(mViewportRectangle);
}
- if( renderList.IsClipping() )
+ if(renderList.IsClipping())
{
- context.SetScissorTest( true );
+ context.SetScissorTest(true);
const ClippingBox& layerScissorBox = renderList.GetClippingBox();
- context.Scissor( layerScissorBox.x, layerScissorBox.y, layerScissorBox.width, layerScissorBox.height );
- mScissorStack.push_back( layerScissorBox );
+ context.Scissor(layerScissorBox.x, layerScissorBox.y, layerScissorBox.width, layerScissorBox.height);
+ mScissorStack.push_back(layerScissorBox);
mHasLayerScissor = true;
}
// Loop through all RenderList in the RenderList, set up any prerequisites to render them, then perform the render.
- for( uint32_t index = 0u; index < count; ++index )
+ for(uint32_t index = 0u; index < count; ++index)
{
- const RenderItem& item = renderList.GetItem( index );
+ const RenderItem& item = renderList.GetItem(index);
// Discard renderers outside the root clipping rect
bool skip = true;
- if( !rootClippingRect.IsEmpty() )
+ if(!rootClippingRect.IsEmpty())
{
- auto rect = item.CalculateViewportSpaceAABB( item.mUpdateSize, mViewportRectangle.width, mViewportRectangle.height );
+ auto rect = item.CalculateViewportSpaceAABB(item.mUpdateSize, mViewportRectangle.width, mViewportRectangle.height);
- if(rect.Intersect( rootClippingRect ))
+ if(rect.Intersect(rootClippingRect))
{
skip = false;
}
skip = false;
}
- DALI_PRINT_RENDER_ITEM( item );
+ DALI_PRINT_RENDER_ITEM(item);
// Set up clipping based on both the Renderer and Actor APIs.
// The Renderer API will be used if specified. If AUTO, the Actors automatic clipping feature will be used.
SetupClipping(item, context, usedStencilBuffer, lastClippingDepth, lastClippingId, stencilBufferAvailable, instruction);
- if( DALI_LIKELY( item.mRenderer ) )
+ if(DALI_LIKELY(item.mRenderer))
{
// Set up the depth buffer based on per-renderer flags if depth buffer is available
// If the per renderer flags are set to "ON" or "OFF", they will always override any Layer depth mode or
// draw-mode state, such as Overlays.
// If the flags are set to "AUTO", the behavior then depends on the type of renderer. Overlay Renderers will always
// disable depth testing and writing. Color Renderers will enable them if the Layer does.
- if (depthBufferAvailable == Integration::DepthBufferAvailable::TRUE)
+ if(depthBufferAvailable == Integration::DepthBufferAvailable::TRUE)
{
SetupDepthBuffer(item, context, autoDepthTestMode, firstDepthBufferUse);
}
// iteration must be done and the default behaviour of the renderer will be executed.
// The queues allow to iterate over the same renderer multiple times changing the state of the renderer.
// It is similar to the multi-pass rendering.
- if( !skip )
+ if(!skip)
{
auto const MAX_QUEUE = item.mRenderer->GetDrawCommands().empty() ? 1 : DevelRenderer::RENDER_QUEUE_MAX;
- for (auto queue = 0u; queue < MAX_QUEUE; ++queue)
+ for(auto queue = 0u; queue < MAX_QUEUE; ++queue)
{
// Render the item.
- item.mRenderer->Render(context, bufferIndex, *item.mNode, item.mModelMatrix, item.mModelViewMatrix,
- viewMatrix, projectionMatrix, item.mSize, !item.mIsOpaque, boundTextures, instruction, queue);
+ item.mRenderer->Render(context, bufferIndex, *item.mNode, item.mModelMatrix, item.mModelViewMatrix, viewMatrix, projectionMatrix, item.mSize, !item.mIsOpaque, boundTextures, instruction, queue);
}
}
}
}
RenderAlgorithms::RenderAlgorithms()
- : mViewportRectangle(),
- mHasLayerScissor( false )
+: mViewportRectangle(),
+ mHasLayerScissor(false)
{
}
-void RenderAlgorithms::ProcessRenderInstruction( const RenderInstruction& instruction,
- Context& context,
- BufferIndex bufferIndex,
- Integration::DepthBufferAvailable depthBufferAvailable,
- Integration::StencilBufferAvailable stencilBufferAvailable,
- Vector<GLuint>& boundTextures,
- const Rect<int>& rootClippingRect )
+void RenderAlgorithms::ProcessRenderInstruction(const RenderInstruction& instruction,
+ Context& context,
+ BufferIndex bufferIndex,
+ Integration::DepthBufferAvailable depthBufferAvailable,
+ Integration::StencilBufferAvailable stencilBufferAvailable,
+ Vector<GLuint>& boundTextures,
+ const Rect<int>& rootClippingRect)
{
- DALI_PRINT_RENDER_INSTRUCTION( instruction, bufferIndex );
+ DALI_PRINT_RENDER_INSTRUCTION(instruction, bufferIndex);
- const Matrix* viewMatrix = instruction.GetViewMatrix( bufferIndex );
- const Matrix* projectionMatrix = instruction.GetProjectionMatrix( bufferIndex );
+ const Matrix* viewMatrix = instruction.GetViewMatrix(bufferIndex);
+ const Matrix* projectionMatrix = instruction.GetProjectionMatrix(bufferIndex);
- DALI_ASSERT_DEBUG( viewMatrix );
- DALI_ASSERT_DEBUG( projectionMatrix );
+ DALI_ASSERT_DEBUG(viewMatrix);
+ DALI_ASSERT_DEBUG(projectionMatrix);
- if( viewMatrix && projectionMatrix )
+ if(viewMatrix && projectionMatrix)
{
const RenderListContainer::SizeType count = instruction.RenderListCount();
// Iterate through each render list in order. If a pair of render lists
// are marked as interleaved, then process them together.
- for( RenderListContainer::SizeType index = 0; index < count; ++index )
+ for(RenderListContainer::SizeType index = 0; index < count; ++index)
{
- const RenderList* renderList = instruction.GetRenderList( index );
+ const RenderList* renderList = instruction.GetRenderList(index);
- if( renderList && !renderList->IsEmpty() )
+ if(renderList && !renderList->IsEmpty())
{
- ProcessRenderList( *renderList,
- context,
- bufferIndex,
- *viewMatrix,
- *projectionMatrix,
- depthBufferAvailable,
- stencilBufferAvailable,
- boundTextures,
- instruction, //added for reflection effect
- rootClippingRect );
+ ProcessRenderList(*renderList,
+ context,
+ bufferIndex,
+ *viewMatrix,
+ *projectionMatrix,
+ depthBufferAvailable,
+ stencilBufferAvailable,
+ boundTextures,
+ instruction, //added for reflection effect
+ rootClippingRect);
}
}
}
}
-
} // namespace Render
} // namespace Internal
#define DALI_INTERNAL_RENDER_ALGORITHMS_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
class Context;
{
class RenderInstruction;
struct RenderItem;
-}
+} // namespace SceneGraph
namespace Render
{
-
/**
* @brief The responsibility of the RenderAlgorithms object is to action renders required by a RenderInstruction.
*/
class RenderAlgorithms
{
- public:
-
- /**
+public:
+ /**
* Constructor.
*/
- RenderAlgorithms();
+ RenderAlgorithms();
- /**
+ /**
* Process a render-instruction.
* @param[in] instruction The render-instruction to process.
* @param[in] context The GL context.
* @param[in] stencilBufferAvailable Whether the stencil buffer is available
* @param[in] boundTextures The textures bound for rendering
*/
- void ProcessRenderInstruction( const SceneGraph::RenderInstruction& instruction,
- Context& context,
- BufferIndex bufferIndex,
- Integration::DepthBufferAvailable depthBufferAvailable,
- Integration::StencilBufferAvailable stencilBufferAvailable,
- Vector<GLuint>& boundTextures,
- const Rect<int>& rootClippingRect );
-
- private:
-
- /**
+ void ProcessRenderInstruction(const SceneGraph::RenderInstruction& instruction,
+ Context& context,
+ BufferIndex bufferIndex,
+ Integration::DepthBufferAvailable depthBufferAvailable,
+ Integration::StencilBufferAvailable stencilBufferAvailable,
+ Vector<GLuint>& boundTextures,
+ const Rect<int>& rootClippingRect);
+
+private:
+ /**
* @brief Calculate a 2D AABB (axis aligned bounding box) in screen space.
* The RenderItems dimensions are translated and a Z value of 0 is assumed for this purpose.
* No projection is performed, but rotation on Z is supported.
* @param[in] item The RenderItem to generate an AABB for
* @return The generated AABB in screen space
*/
- inline Dali::ClippingBox CalculateScreenSpaceAABB( const Dali::Internal::SceneGraph::RenderItem& item );
+ inline Dali::ClippingBox CalculateScreenSpaceAABB(const Dali::Internal::SceneGraph::RenderItem& item);
- /**
+ /**
* @brief Perform any scissor clipping related operations based on the current RenderItem.
* This includes:
* - Determining if any action is to be taken (so the method can be exited early if not).
* @param[in] context The current Context
* @param[in] instruction The render-instruction to process.
*/
- inline void SetupScissorClipping(const Dali::Internal::SceneGraph::RenderItem& item, Context& context, const Dali::Internal::SceneGraph::RenderInstruction& instruction);
+ inline void SetupScissorClipping(const Dali::Internal::SceneGraph::RenderItem& item, Context& context, const Dali::Internal::SceneGraph::RenderInstruction& instruction);
- /**
+ /**
* @brief Set up the clipping based on the specified clipping settings.
* @param[in] item The current RenderItem (about to be rendered)
* @param[in] context The context
* @param[in] stencilBufferAvailable Whether the stencil buffer is available
* @param[in] instruction The render-instruction to process.
*/
- inline void SetupClipping(const Dali::Internal::SceneGraph::RenderItem& item,
- Context& context,
- bool& usedStencilBuffer,
- uint32_t& lastClippingDepth,
- uint32_t& lastClippingId,
- Integration::StencilBufferAvailable stencilBufferAvailable,
- const Dali::Internal::SceneGraph::RenderInstruction& instruction);
-
- /**
+ inline void SetupClipping(const Dali::Internal::SceneGraph::RenderItem& item,
+ Context& context,
+ bool& usedStencilBuffer,
+ uint32_t& lastClippingDepth,
+ uint32_t& lastClippingId,
+ Integration::StencilBufferAvailable stencilBufferAvailable,
+ const Dali::Internal::SceneGraph::RenderInstruction& instruction);
+
+ /**
* @brief Process a render-list.
* @param[in] renderList The render-list to process.
* @param[in] context The GL context.
* @param[in] stencilBufferAvailable Whether the stencil buffer is available
* @param[in] boundTextures The textures bound for rendering
*/
- inline void ProcessRenderList( const Dali::Internal::SceneGraph::RenderList& renderList,
- Context& context,
- BufferIndex bufferIndex,
- const Matrix& viewMatrix,
- const Matrix& projectionMatrix,
- Integration::DepthBufferAvailable depthBufferAvailable,
- Integration::StencilBufferAvailable stencilBufferAvailable,
- Vector<GLuint>& boundTextures,
- const Dali::Internal::SceneGraph::RenderInstruction& instruction, // in the case of reflection, things like CullFace need to be adjusted for reflection world
- const Rect<int>& rootClippingRect );
-
- // Prevent copying:
- RenderAlgorithms( RenderAlgorithms& rhs );
- RenderAlgorithms& operator=( const RenderAlgorithms& rhs );
-
-
- // Member variables:
-
- using ScissorStackType = std::vector<Dali::ClippingBox>; ///< The container type used to maintain the applied scissor hierarchy
-
- ScissorStackType mScissorStack; ///< Contains the currently applied scissor hierarchy (so we can undo clips)
- Dali::ClippingBox mViewportRectangle; ///< The viewport dimensions, used to translate AABBs to scissor coordinates
- bool mHasLayerScissor:1; ///< Marks if the currently process render instruction has a layer-based clipping region
+ inline void ProcessRenderList(const Dali::Internal::SceneGraph::RenderList& renderList,
+ Context& context,
+ BufferIndex bufferIndex,
+ const Matrix& viewMatrix,
+ const Matrix& projectionMatrix,
+ Integration::DepthBufferAvailable depthBufferAvailable,
+ Integration::StencilBufferAvailable stencilBufferAvailable,
+ Vector<GLuint>& boundTextures,
+ const Dali::Internal::SceneGraph::RenderInstruction& instruction, // in the case of reflection, things like CullFace need to be adjusted for reflection world
+ const Rect<int>& rootClippingRect);
+
+ // Prevent copying:
+ RenderAlgorithms(RenderAlgorithms& rhs);
+ RenderAlgorithms& operator=(const RenderAlgorithms& rhs);
+
+ // Member variables:
+
+ using ScissorStackType = std::vector<Dali::ClippingBox>; ///< The container type used to maintain the applied scissor hierarchy
+
+ ScissorStackType mScissorStack; ///< Contains the currently applied scissor hierarchy (so we can undo clips)
+ Dali::ClippingBox mViewportRectangle; ///< The viewport dimensions, used to translate AABBs to scissor coordinates
+ bool mHasLayerScissor : 1; ///< Marks if the currently process render instruction has a layer-based clipping region
};
} // namespace Render
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/integration-api/debug.h>
+#include <dali/internal/render/common/render-instruction.h>
#include <dali/internal/render/common/render-item.h>
#include <dali/internal/render/common/render-list.h>
-#include <dali/internal/render/common/render-instruction.h>
#include <dali/internal/update/nodes/node.h>
using Dali::Internal::SceneGraph::Node;
namespace Dali
{
-
namespace Internal
{
-
namespace Render
{
-
// These functions should only be defined if they are being used by the #define in the header.
// Otherwise they will contribute negatively to code coverage.
#ifdef DALI_PRINT_RENDER_INFO
-void PrintFrameStart( BufferIndex bufferIndex )
+void PrintFrameStart(BufferIndex bufferIndex)
{
- DALI_LOG_RENDER_INFO( "RENDER START - bufferIndex: %d\n", bufferIndex );
+ DALI_LOG_RENDER_INFO("RENDER START - bufferIndex: %d\n", bufferIndex);
}
void PrintFrameEnd()
{
- DALI_LOG_RENDER_INFO( "RENDER END\n\n" );
+ DALI_LOG_RENDER_INFO("RENDER END\n\n");
}
-void PrintRenderInstruction( const SceneGraph::RenderInstruction& instruction, BufferIndex index )
+void PrintRenderInstruction(const SceneGraph::RenderInstruction& instruction, BufferIndex index)
{
const char* target = (nullptr != instruction.mFrameBuffer) ? "FrameBuffer" : "Screen";
std::stringstream debugStream;
debugStream << "Rendering to " << target << ", View: " << *(instruction.GetViewMatrix(index)) << " Projection: " << *(instruction.GetProjectionMatrix(index));
- if( instruction.mIsViewportSet )
+ if(instruction.mIsViewportSet)
{
debugStream << " Viewport: " << instruction.mViewport.x << "," << instruction.mViewport.y << " " << instruction.mViewport.width << "x" << instruction.mViewport.height;
}
- if( instruction.mIsClearColorSet )
+ if(instruction.mIsClearColorSet)
{
debugStream << " ClearColor: " << instruction.mClearColor;
}
- std::string debugString( debugStream.str() );
- DALI_LOG_RENDER_INFO( " %s\n", debugString.c_str() );
+ std::string debugString(debugStream.str());
+ DALI_LOG_RENDER_INFO(" %s\n", debugString.c_str());
}
-void PrintRenderList( const RenderList& list )
+void PrintRenderList(const RenderList& list)
{
std::stringstream debugStream;
debugStream << "Rendering items";
- if( list.IsClipping() )
+ if(list.IsClipping())
{
debugStream << ", ClippingBox: " << list.GetClippingBox().x << "," << list.GetClippingBox().y << " " << list.GetClippingBox().width << "x" << list.GetClippingBox().height;
}
- std::string debugString( debugStream.str() );
- DALI_LOG_RENDER_INFO( " %s\n", debugString.c_str() );
+ std::string debugString(debugStream.str());
+ DALI_LOG_RENDER_INFO(" %s\n", debugString.c_str());
}
-void PrintRenderItem( const SceneGraph::RenderItem& item )
+void PrintRenderItem(const SceneGraph::RenderItem& item)
{
std::stringstream debugStream;
debugStream << "Rendering item, ModelView: " << item.mModelViewMatrix;
- std::string debugString( debugStream.str() );
- DALI_LOG_RENDER_INFO( " %s\n", debugString.c_str() );
+ std::string debugString(debugStream.str());
+ DALI_LOG_RENDER_INFO(" %s\n", debugString.c_str());
}
-void PrintRendererCount( unsigned int frameCount, unsigned int rendererCount )
+void PrintRendererCount(unsigned int frameCount, unsigned int rendererCount)
{
- if( frameCount % 120 == 30 ) // Print every 2 seconds reg
+ if(frameCount % 120 == 30) // Print every 2 seconds reg
{
- Debug::LogMessage( Debug::DebugInfo, "Renderer Total # renderers: %u\n", rendererCount );
+ Debug::LogMessage(Debug::DebugInfo, "Renderer Total # renderers: %u\n", rendererCount);
}
}
#endif
-} // Render
+} // namespace Render
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#define DALI_INTERNAL_RENDER_DEBUG_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#define DALI_PRINT_RENDER_START(x) Render::PrintFrameStart(x);
#define DALI_PRINT_RENDER_END() Render::PrintFrameEnd();
-#define DALI_PRINT_RENDER_INSTRUCTION(x,index) Render::PrintRenderInstruction(x,index);
+#define DALI_PRINT_RENDER_INSTRUCTION(x, index) Render::PrintRenderInstruction(x, index);
#define DALI_PRINT_RENDER_LIST(x) Render::PrintRenderList(x);
#define DALI_PRINT_RENDER_ITEM(x) Render::PrintRenderItem(x);
#define DALI_PRINT_RENDER_START(x)
#define DALI_PRINT_RENDER_END()
-#define DALI_PRINT_RENDER_INSTRUCTION(x,index)
+#define DALI_PRINT_RENDER_INSTRUCTION(x, index)
#define DALI_PRINT_RENDER_LIST(x)
#define DALI_PRINT_RENDER_ITEM(x)
//#define DALI_PRINT_RENDERERS 1
#ifdef DALI_PRINT_RENDERERS
-#define DALI_PRINT_RENDERER_COUNT(x, y) Render::PrintRendererCount(x, y)
+#define DALI_PRINT_RENDERER_COUNT(x, y) Render::PrintRendererCount(x, y)
#else // DALI_PRINT_RENDERERS
#define DALI_PRINT_RENDERER_COUNT(x, y)
#endif // DALI_PRINT_RENDERERS
-
namespace Dali
{
-
namespace Internal
{
-
class PropertyInputImpl;
namespace SceneGraph
class RenderInstruction;
struct RenderList;
struct RenderItem;
-}
+} // namespace SceneGraph
namespace Render
{
-
/**
* Print a debug message at the start of the render-thread.
* @param[in] buffer The current render buffer index (previous update buffer)
*/
-void PrintFrameStart( BufferIndex bufferIndex );
+void PrintFrameStart(BufferIndex bufferIndex);
/**
* Print a debug message at the end of the render-thread.
* @param[in] instruction The render-instruction.
* @param[in] index to use
*/
-void PrintRenderInstruction( const SceneGraph::RenderInstruction& instruction, BufferIndex index );
+void PrintRenderInstruction(const SceneGraph::RenderInstruction& instruction, BufferIndex index);
/**
* Print some information about a render-list.
* @param[in] instruction The render-list.
*/
-void PrintRenderList( const SceneGraph::RenderList& list );
+void PrintRenderList(const SceneGraph::RenderList& list);
/**
* Print some information about a render-item.
* @param[in] instruction The render-item.
*/
-void PrintRenderItem( const SceneGraph::RenderItem& item );
+void PrintRenderItem(const SceneGraph::RenderItem& item);
/**
* Print the number of image renderers
* @param[in] frameCount The frame counter
* @param[in] rendererCount The number of image renderers
*/
-void PrintRendererCount( unsigned int frameCount, unsigned int rendererCount );
+void PrintRendererCount(unsigned int frameCount, unsigned int rendererCount);
/**
* Recursively dumps a Node tree.
* @param[in] node The starting node to dump from
* @param[in] indent Optional. Leave unset for default indent (used internally while recursing)
*/
-void DumpNode( const SceneGraph::Node* node, unsigned int indent = 0 );
+void DumpNode(const SceneGraph::Node* node, unsigned int indent = 0);
-} // Render
+} // namespace Render
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#endif // DALI_INTERNAL_RENDER_DEBUG_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
RenderInstructionContainer::RenderInstructionContainer()
: mInstructions{}
{
RenderInstructionContainer::~RenderInstructionContainer() = default;
-void RenderInstructionContainer::ResetAndReserve( BufferIndex bufferIndex, uint32_t capacityRequired )
+void RenderInstructionContainer::ResetAndReserve(BufferIndex bufferIndex, uint32_t capacityRequired)
{
// Only re-allocate if necessary.
- if( mInstructions.size() < capacityRequired )
+ if(mInstructions.size() < capacityRequired)
{
- mInstructions.reserve( capacityRequired );
+ mInstructions.reserve(capacityRequired);
}
mInstructions.clear();
}
-uint32_t RenderInstructionContainer::Count( BufferIndex bufferIndex )
+uint32_t RenderInstructionContainer::Count(BufferIndex bufferIndex)
{
- return static_cast<uint32_t>( mInstructions.size() );
+ return static_cast<uint32_t>(mInstructions.size());
}
-RenderInstruction& RenderInstructionContainer::At( BufferIndex bufferIndex, uint32_t index )
+RenderInstruction& RenderInstructionContainer::At(BufferIndex bufferIndex, uint32_t index)
{
- DALI_ASSERT_DEBUG( index < mInstructions.size() );
+ DALI_ASSERT_DEBUG(index < mInstructions.size());
- return *mInstructions[ index ];
+ return *mInstructions[index];
}
-void RenderInstructionContainer::PushBack( BufferIndex bufferIndex, RenderInstruction* renderInstruction )
+void RenderInstructionContainer::PushBack(BufferIndex bufferIndex, RenderInstruction* renderInstruction)
{
- mInstructions.push_back( renderInstruction );
+ mInstructions.push_back(renderInstruction);
}
-void RenderInstructionContainer::DiscardCurrentInstruction( BufferIndex updateBufferIndex )
+void RenderInstructionContainer::DiscardCurrentInstruction(BufferIndex updateBufferIndex)
{
mInstructions.pop_back();
}
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_CONTAINER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
#include <dali/devel-api/common/owner-container.h>
#include <dali/internal/common/buffer-index.h>
+#include <dali/public-api/common/vector-wrapper.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
class RenderInstruction;
class RenderInstructionContainer
{
public:
-
/**
* Constructor
*/
* @param bufferIndex to reset
* @param capacityRequired in the container
*/
- void ResetAndReserve( BufferIndex bufferIndex, uint32_t capacityRequired );
+ void ResetAndReserve(BufferIndex bufferIndex, uint32_t capacityRequired);
/**
* Return the count of instructions in the container
* @param bufferIndex to use
* @return the count of elements
*/
- uint32_t Count( BufferIndex bufferIndex );
+ uint32_t Count(BufferIndex bufferIndex);
/**
* Get a reference to the instruction at index
* @param bufferIndex to use
* @param index to use
*/
- RenderInstruction& At( BufferIndex bufferIndex, uint32_t index );
+ RenderInstruction& At(BufferIndex bufferIndex, uint32_t index);
/**
* Add an instruction to the end of the container
* @param bufferIndex to use
*/
- void PushBack( BufferIndex index, RenderInstruction* renderInstruction );
+ void PushBack(BufferIndex index, RenderInstruction* renderInstruction);
/**
* Discard an instruction from the end of the container
* @param bufferIndex to use
*/
- void DiscardCurrentInstruction( BufferIndex updateBufferIndex );
+ void DiscardCurrentInstruction(BufferIndex updateBufferIndex);
private:
-
std::vector<RenderInstruction*> mInstructions;
-
};
} // namespace SceneGraph
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/render/common/render-instruction.h>
// INTERNAL INCLUDES
-#include <dali/public-api/common/constants.h> // for Color::BLACK
-#include <dali/internal/render/common/render-tracker.h>
#include <dali/integration-api/debug.h>
+#include <dali/internal/render/common/render-tracker.h>
+#include <dali/public-api/common/constants.h> // for Color::BLACK
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
RenderInstruction::RenderInstruction()
-: mRenderTracker( nullptr ),
+: mRenderTracker(nullptr),
mClearColor(),
- mIsViewportSet( false ),
- mIsClearColorSet( false ),
- mIgnoreRenderToFbo( false ),
- mFrameBuffer( nullptr ),
- mCamera( nullptr ),
- mNextFreeRenderList( 0 )
+ mIsViewportSet(false),
+ mIsClearColorSet(false),
+ mIgnoreRenderToFbo(false),
+ mFrameBuffer(nullptr),
+ mCamera(nullptr),
+ mNextFreeRenderList(0)
{
// reserve 6 lists, which is enough for three layers with opaque and transparent things on
- mRenderLists.Reserve( 6 );
+ mRenderLists.Reserve(6);
}
RenderInstruction::~RenderInstruction()
{ // pointer container releases the renderlists
}
-RenderList& RenderInstruction::GetNextFreeRenderList( size_t capacityRequired )
+RenderList& RenderInstruction::GetNextFreeRenderList(size_t capacityRequired)
{
// check if we have enough lists, we can only be one behind at worst
- if( mRenderLists.Count() <= mNextFreeRenderList )
+ if(mRenderLists.Count() <= mNextFreeRenderList)
{
- mRenderLists.PushBack( new RenderList ); // Push a new empty render list
+ mRenderLists.PushBack(new RenderList); // Push a new empty render list
}
// check capacity of the list and reserve if not big enough
- if( mRenderLists[ mNextFreeRenderList ]->Capacity() < capacityRequired )
+ if(mRenderLists[mNextFreeRenderList]->Capacity() < capacityRequired)
{
- mRenderLists[ mNextFreeRenderList ]->Reserve( capacityRequired );
+ mRenderLists[mNextFreeRenderList]->Reserve(capacityRequired);
}
// return the list mNextFreeRenderList points to and increase by one
- return *mRenderLists[ mNextFreeRenderList++ ];
+ return *mRenderLists[mNextFreeRenderList++];
}
void RenderInstruction::UpdateCompleted()
{
// lets do some housekeeping, remove any lists that were not needed because
// application might have removed a layer permanently
- RenderListContainer::Iterator iter = mRenderLists.Begin();
- RenderListContainer::ConstIterator end = mRenderLists.End();
- for( ;iter != end; ++iter )
+ RenderListContainer::Iterator iter = mRenderLists.Begin();
+ RenderListContainer::ConstIterator end = mRenderLists.End();
+ for(; iter != end; ++iter)
{
// tell the list to do its housekeeping
(*iter)->ReleaseUnusedItems();
}
// release any extra lists
- if( mRenderLists.Count() > mNextFreeRenderList )
+ if(mRenderLists.Count() > mNextFreeRenderList)
{
- mRenderLists.Resize( mNextFreeRenderList );
+ mRenderLists.Resize(mNextFreeRenderList);
}
}
return mNextFreeRenderList;
}
-const RenderList* RenderInstruction::GetRenderList( RenderListContainer::SizeType index ) const
+const RenderList* RenderInstruction::GetRenderList(RenderListContainer::SizeType index) const
{
- DALI_ASSERT_DEBUG( (index < mNextFreeRenderList ) && (index < mRenderLists.Size()) && "Renderlist index out of container bounds" );
+ DALI_ASSERT_DEBUG((index < mNextFreeRenderList) && (index < mRenderLists.Size()) && "Renderlist index out of container bounds");
// Return null if the caller has passed an invalid index:
- if( index >= std::min( mNextFreeRenderList, mRenderLists.Size() ) )
+ if(index >= std::min(mNextFreeRenderList, mRenderLists.Size()))
{
return nullptr;
}
- return mRenderLists[ index ];
+ return mRenderLists[index];
}
-void RenderInstruction::Reset( Camera* camera,
- Render::FrameBuffer* frameBuffer,
- const Viewport* viewport,
- const Vector4* clearColor )
+void RenderInstruction::Reset(Camera* camera,
+ Render::FrameBuffer* frameBuffer,
+ const Viewport* viewport,
+ const Vector4* clearColor)
{
- mCamera = camera;
- mViewport = viewport ? *viewport : Viewport();
- mIsViewportSet = nullptr != viewport;
- mClearColor = clearColor ? *clearColor : Color::BLACK;
- mIsClearColorSet = nullptr != clearColor;
- mRenderTracker = nullptr;
+ mCamera = camera;
+ mViewport = viewport ? *viewport : Viewport();
+ mIsViewportSet = nullptr != viewport;
+ mClearColor = clearColor ? *clearColor : Color::BLACK;
+ mIsClearColorSet = nullptr != clearColor;
+ mRenderTracker = nullptr;
mNextFreeRenderList = 0;
- mFrameBuffer = frameBuffer;
+ mFrameBuffer = frameBuffer;
- RenderListContainer::Iterator iter = mRenderLists.Begin();
- RenderListContainer::ConstIterator end = mRenderLists.End();
- for( ;iter != end; ++iter )
+ RenderListContainer::Iterator iter = mRenderLists.Begin();
+ RenderListContainer::ConstIterator end = mRenderLists.End();
+ for(; iter != end; ++iter)
{
// since mRenderLists is a vector of RenderLists we dont want to clear it
// as it ends up releasing and later reallocating loads of vectors
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/math/matrix.h>
-#include <dali/public-api/math/viewport.h>
-#include <dali/internal/update/render-tasks/scene-graph-camera.h>
#include <dali/internal/render/common/render-list.h>
-#include <dali/internal/render/renderers/render-frame-buffer.h>
#include <dali/internal/render/gl-resources/context.h>
+#include <dali/internal/render/renderers/render-frame-buffer.h>
+#include <dali/internal/update/render-tasks/scene-graph-camera.h>
+#include <dali/public-api/math/matrix.h>
+#include <dali/public-api/math/viewport.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Render
{
class RenderTracker;
namespace SceneGraph
{
-
/**
* A set of rendering instructions consisting of:
* - The list(s) of renderers sorted in the correct rendering order.
class RenderInstruction
{
public:
-
/**
* Default constructor so this can be stored in STL containers
*/
* @param capacityRequired in this list
* @return the renderlist
*/
- RenderList& GetNextFreeRenderList( size_t capacityRequired );
+ RenderList& GetNextFreeRenderList(size_t capacityRequired);
/**
* Inform the RenderInstruction that processing for this frame is complete
* @param index of list to return
* @return pointer to the renderlist, or null if the index is out of bounds.
*/
- const RenderList* GetRenderList( RenderListContainer::SizeType index ) const;
+ const RenderList* GetRenderList(RenderListContainer::SizeType index) const;
/**
* Reset render-instruction
* @param[in] viewport A pointer to a viewport, of NULL.
* @param[in] clearColor A pointer to a color to clear with, or NULL if no clear is required.
*/
- void Reset( Camera* camera,
- Render::FrameBuffer* frameBuffer,
- const Viewport* viewport,
- const Vector4* clearColor );
+ void Reset(Camera* camera,
+ Render::FrameBuffer* frameBuffer,
+ const Viewport* viewport,
+ const Vector4* clearColor);
/**
* Get the view matrix for rendering
* @param index of the rendering side
* @return the view matrix
*/
- const Matrix* GetViewMatrix( BufferIndex index ) const
+ const Matrix* GetViewMatrix(BufferIndex index) const
{
// inlined as this is called once per frame per render instruction
- return &mCamera->GetViewMatrix( index );
+ return &mCamera->GetViewMatrix(index);
}
/**
* @param index of the rendering side
* @return the projection matrix
*/
- const Matrix* GetProjectionMatrix( BufferIndex index ) const
+ const Matrix* GetProjectionMatrix(BufferIndex index) const
{
// inlined as this is called once per frame per render instruction
return &mCamera->GetFinalProjectionMatrix(index);
}
private:
-
// Undefined
RenderInstruction(const RenderInstruction&);
// Undefined
RenderInstruction& operator=(const RenderInstruction& rhs);
-public: // Data
-
- Render::RenderTracker* mRenderTracker; ///< Pointer to an optional tracker object (not owned)
+public: // Data
+ Render::RenderTracker* mRenderTracker; ///< Pointer to an optional tracker object (not owned)
- Viewport mViewport; ///< Optional viewport
- Vector4 mClearColor; ///< Optional color to clear with
- bool mIsViewportSet:1; ///< Flag to determine whether the viewport is set
- bool mIsClearColorSet:1; ///< Flag to determine whether the clearColor is set
- bool mIgnoreRenderToFbo:1; ///< Whether to ignore the render to FBO option (used to measure the performance above 60 fps)
+ Viewport mViewport; ///< Optional viewport
+ Vector4 mClearColor; ///< Optional color to clear with
+ bool mIsViewportSet : 1; ///< Flag to determine whether the viewport is set
+ bool mIsClearColorSet : 1; ///< Flag to determine whether the clearColor is set
+ bool mIgnoreRenderToFbo : 1; ///< Whether to ignore the render to FBO option (used to measure the performance above 60 fps)
Render::FrameBuffer* mFrameBuffer;
-private: // Data
-
- Camera* mCamera; ///< camera that is used
- RenderListContainer mRenderLists; ///< container of all render lists
- RenderListContainer::SizeType mNextFreeRenderList; ///< index for the next free render list
-
+private: // Data
+ Camera* mCamera; ///< camera that is used
+ RenderListContainer mRenderLists; ///< container of all render lists
+ RenderListContainer::SizeType mNextFreeRenderList; ///< index for the next free render list
};
} // namespace SceneGraph
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/render/common/render-item.h>
// INTERNAL INCLUDES
+#include <dali/internal/common/math.h>
#include <dali/internal/common/memory-pool-object-allocator.h>
#include <dali/internal/render/renderers/render-renderer.h>
-#include <dali/internal/common/math.h>
namespace
{
//Memory pool used to allocate new RenderItems. Memory used by this pool will be released when shutting down DALi
Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::RenderItem> gRenderItemPool;
-}
+} // namespace
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
RenderItem* RenderItem::New()
{
- return new ( gRenderItemPool.AllocateRaw() ) RenderItem();
+ return new(gRenderItemPool.AllocateRaw()) RenderItem();
}
RenderItem::RenderItem()
-: mModelMatrix( false ),
- mModelViewMatrix( false ),
- mColor( Vector4::ZERO ),
+: mModelMatrix(false),
+ mModelViewMatrix(false),
+ mColor(Vector4::ZERO),
mSize(),
- mRenderer( nullptr ),
- mNode( nullptr ),
- mTextureSet( nullptr ),
- mDepthIndex( 0 ),
- mIsOpaque( true ),
- mIsUpdated( false )
+ mRenderer(nullptr),
+ mNode(nullptr),
+ mTextureSet(nullptr),
+ mDepthIndex(0),
+ mIsOpaque(true),
+ mIsUpdated(false)
{
}
RenderItem::~RenderItem() = default;
-ClippingBox RenderItem::CalculateViewportSpaceAABB( const Vector3& size, const int viewportWidth, const int viewportHeight ) const
+ClippingBox RenderItem::CalculateViewportSpaceAABB(const Vector3& size, const int viewportWidth, const int viewportHeight) const
{
// Calculate extent vector of the AABB:
const float halfActorX = size.x * 0.5f;
// We place the coords into the array in clockwise order, so we know opposite corners are always i + 2 from corner i.
// We skip the 4th corner here as we can calculate that from the other 3, bypassing matrix multiplication.
// Note: The below transform methods use a fast (2D) matrix multiply (only 4 multiplications are done).
- Vector2 corners[4]{ Transform2D( mModelViewMatrix, -halfActorX, -halfActorY ),
- Transform2D( mModelViewMatrix, halfActorX, -halfActorY ),
- Transform2D( mModelViewMatrix, halfActorX, halfActorY ) };
+ Vector2 corners[4]{Transform2D(mModelViewMatrix, -halfActorX, -halfActorY),
+ Transform2D(mModelViewMatrix, halfActorX, -halfActorY),
+ Transform2D(mModelViewMatrix, halfActorX, halfActorY)};
// As we are dealing with a rectangle, we can do a fast calculation to get the 4th corner from knowing the other 3 (even if rotated).
- corners[3] = Vector2( corners[0] + ( corners[2] - corners[1] ) );
+ corners[3] = Vector2(corners[0] + (corners[2] - corners[1]));
// Calculate the AABB:
// We use knowledge that opposite corners will be the max/min of each other. Doing this reduces the normal 12 branching comparisons to 3.
unsigned int smallestX = 0u;
// Loop 3 times to find the index of the smallest X value.
// Note: We deliberately do NOT unroll the code here as this hampers the compilers output.
- for( unsigned int i = 1u; i < 4u; ++i )
+ for(unsigned int i = 1u; i < 4u; ++i)
{
- if( corners[i].x < corners[smallestX].x )
+ if(corners[i].x < corners[smallestX].x)
{
smallestX = i;
}
// As we are dealing with a rectangle, we can assume opposite corners are the largest.
// So without doing min/max branching, we can fetch the min/max values of all the remaining X/Y coords from this one index.
- Vector4 aabb( corners[smallestX].x, corners[( smallestX + 3u ) % 4].y, corners[( smallestX + 2u ) % 4].x, corners[( smallestX + 1u ) % 4].y );
+ Vector4 aabb(corners[smallestX].x, corners[(smallestX + 3u) % 4].y, corners[(smallestX + 2u) % 4].x, corners[(smallestX + 1u) % 4].y);
// Return the AABB in screen-space pixels (x, y, width, height).
// Note: This is a algebraic simplification of: ( viewport.x - aabb.width ) / 2 - ( ( aabb.width / 2 ) + aabb.x ) per axis.
- Vector4 aabbInScreen( static_cast<float>( viewportWidth ) * 0.5f - aabb.z,
- static_cast<float>( viewportHeight ) * 0.5f - aabb.w,
- static_cast<float>( viewportWidth ) * 0.5f - aabb.x,
- static_cast<float>( viewportHeight ) * 0.5f - aabb.y );
+ Vector4 aabbInScreen(static_cast<float>(viewportWidth) * 0.5f - aabb.z,
+ static_cast<float>(viewportHeight) * 0.5f - aabb.w,
+ static_cast<float>(viewportWidth) * 0.5f - aabb.x,
+ static_cast<float>(viewportHeight) * 0.5f - aabb.y);
- int x = static_cast< int >( floor( aabbInScreen.x ) );
- int y = static_cast< int >( floor( aabbInScreen.y ) );
- int z = static_cast< int >( roundf( aabbInScreen.z ) );
- int w = static_cast< int >( roundf( aabbInScreen.w ) );
+ int x = static_cast<int>(floor(aabbInScreen.x));
+ int y = static_cast<int>(floor(aabbInScreen.y));
+ int z = static_cast<int>(roundf(aabbInScreen.z));
+ int w = static_cast<int>(roundf(aabbInScreen.w));
- return ClippingBox( x, y, z - x, w - y );
+ return ClippingBox(x, y, z - x, w - y);
}
-void RenderItem::operator delete( void* ptr )
+void RenderItem::operator delete(void* ptr)
{
- gRenderItemPool.Free( static_cast<RenderItem*>( ptr ) );
+ gRenderItemPool.Free(static_cast<RenderItem*>(ptr));
}
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_ITEM_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/internal/update/nodes/node.h>
#include <dali/public-api/actors/layer.h>
+#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/math/matrix.h>
-#include <dali/internal/update/nodes/node.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Render
{
class Renderer;
namespace SceneGraph
{
-
/**
* A RenderItem contains all the data needed for rendering
*/
* @param[in] viewportHeight The height of the viewport to calculate for
* @return The AABB coordinates in viewport-space (x, y, width, height)
*/
- ClippingBox CalculateViewportSpaceAABB( const Vector3& size, const int viewportWidth, const int viewportHeight ) const;
+ ClippingBox CalculateViewportSpaceAABB(const Vector3& size, const int viewportWidth, const int viewportHeight) const;
/**
* Overriden delete operator.
* Deletes the RenderItem from its global memory pool
* @param[in] A pointer to the RenderItem to delete.
*/
- void operator delete( void* ptr );
+ void operator delete(void* ptr);
Matrix mModelMatrix;
Matrix mModelViewMatrix;
Vector3 mUpdateSize;
Render::Renderer* mRenderer;
Node* mNode;
- const void* mTextureSet; //< Used for sorting only
+ const void* mTextureSet; //< Used for sorting only
int mDepthIndex;
- bool mIsOpaque:1;
- bool mIsUpdated:1;
+ bool mIsOpaque : 1;
+ bool mIsUpdated : 1;
private:
-
/**
* Private constructor. See RenderItem::New
*/
RenderItem();
// RenderItems should not be copied as they are heavy
- RenderItem( const RenderItem& item );
- RenderItem& operator = ( const RenderItem& item );
-
+ RenderItem(const RenderItem& item);
+ RenderItem& operator=(const RenderItem& item);
};
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstdint>
// INTERNAL INCLUDES
-#include <dali/public-api/math/rect.h>
#include <dali/devel-api/common/owner-container.h>
#include <dali/internal/render/common/render-item.h>
+#include <dali/public-api/math/rect.h>
namespace Dali
{
namespace Internal
{
-
namespace Render
{
class Renderer;
namespace SceneGraph
{
-
class Layer;
using RenderItemContainer = OwnerContainer<RenderItem*>;
struct RenderList
{
public:
-
/**
* Constructor
*/
RenderList()
- : mNextFree( 0 ),
- mClippingBox( nullptr ),
- mSourceLayer( nullptr ),
- mHasColorRenderItems( false )
+ : mNextFree(0),
+ mClippingBox(nullptr),
+ mSourceLayer(nullptr),
+ mHasColorRenderItems(false)
{
}
* Reserve space in the render list
* @param size to reserve
*/
- void Reserve( RenderItemContainer::SizeType size )
+ void Reserve(RenderItemContainer::SizeType size)
{
mNextFree = 0;
- mItems.Reserve( size );
+ mItems.Reserve(size);
}
/**
RenderItem& GetNextFreeItem()
{
// check if we have enough items, we can only be one behind at worst
- if( mItems.Count() <= mNextFree )
+ if(mItems.Count() <= mNextFree)
{
- mItems.PushBack( RenderItem::New() ); // Push a new empty render item
+ mItems.PushBack(RenderItem::New()); // Push a new empty render item
}
// get the item mNextFree points to and increase by one
- RenderItem& item = *mItems[ mNextFree++ ];
+ RenderItem& item = *mItems[mNextFree++];
return item;
}
/**
* Get item at a given position in the list
*/
- RenderItem& GetItem( uint32_t index ) const
+ RenderItem& GetItem(uint32_t index) const
{
- DALI_ASSERT_DEBUG( index < GetCachedItemCount() );
- return *mItems[ index ];
+ DALI_ASSERT_DEBUG(index < GetCachedItemCount());
+ return *mItems[index];
}
/**
* Get renderer from an item in the list
*/
- const Render::Renderer& GetRenderer( uint32_t index ) const
+ const Render::Renderer& GetRenderer(uint32_t index) const
{
- DALI_ASSERT_DEBUG( index < GetCachedItemCount() );
- return *mItems[ index ]->mRenderer;
+ DALI_ASSERT_DEBUG(index < GetCachedItemCount());
+ return *mItems[index]->mRenderer;
}
/**
*/
uint32_t GetCachedItemCount() const
{
- return static_cast<uint32_t>( mItems.Count() );
+ return static_cast<uint32_t>(mItems.Count());
}
/**
*/
void ReuseCachedItems()
{
- mNextFree = static_cast<uint32_t>( mItems.Count() );
+ mNextFree = static_cast<uint32_t>(mItems.Count());
}
/**
*/
bool IsEmpty() const
{
- return ( mNextFree == 0 );
+ return (mNextFree == 0);
}
/**
* @param clipping on/off
* @param box for clipping
*/
- void SetClipping( bool clipping, const ClippingBox& box )
+ void SetClipping(bool clipping, const ClippingBox& box)
{
- if( clipping )
+ if(clipping)
{
delete mClippingBox;
- mClippingBox = new ClippingBox( box );;
+ mClippingBox = new ClippingBox(box);
+ ;
}
}
*/
bool IsClipping() const
{
- return ( nullptr != mClippingBox );
+ return (nullptr != mClippingBox);
}
/**
void ReleaseUnusedItems()
{
// release any non-used RenderItems
- if( mItems.Count() > mNextFree )
+ if(mItems.Count() > mNextFree)
{
- mItems.Resize( mNextFree );
+ mItems.Resize(mNextFree);
}
}
/**
* @param layer The layer these RenderItems originate from
*/
- void SetSourceLayer( Layer* layer )
+ void SetSourceLayer(Layer* layer)
{
mSourceLayer = layer;
}
* Set if the RenderList contains color RenderItems
* @param[in] hasColorRenderItems True if it contains color RenderItems, false otherwise
*/
- void SetHasColorRenderItems( bool hasColorRenderItems )
+ void SetHasColorRenderItems(bool hasColorRenderItems)
{
mHasColorRenderItems = hasColorRenderItems;
}
}
private:
-
/*
* Copy constructor and assignment operator not defined
*/
- RenderList( const RenderList& rhs );
- const RenderList& operator=( const RenderList& rhs );
+ RenderList(const RenderList& rhs);
+ const RenderList& operator=(const RenderList& rhs);
- RenderItemContainer mItems; ///< Each item is a renderer and matrix pair
- uint32_t mNextFree; ///< index for the next free item to use
-
- ClippingBox* mClippingBox; ///< The clipping box, in window coordinates, when clipping is enabled
- Layer* mSourceLayer; ///< The originating layer where the renderers are from
- bool mHasColorRenderItems : 1; ///< True if list contains color render items
+ RenderItemContainer mItems; ///< Each item is a renderer and matrix pair
+ uint32_t mNextFree; ///< index for the next free item to use
+ ClippingBox* mClippingBox; ///< The clipping box, in window coordinates, when clipping is enabled
+ Layer* mSourceLayer; ///< The originating layer where the renderers are from
+ bool mHasColorRenderItems : 1; ///< True if list contains color render items
};
-
} // namespace SceneGraph
} // namespace Internal
clearColor = Dali::RenderTask::DEFAULT_CLEAR_COLOR;
}
- Rect<int32_t> surfaceRect = sceneObject->GetSurfaceRect();
- int32_t surfaceOrientation = sceneObject->GetSurfaceOrientation();
+ Rect<int32_t> surfaceRect = sceneObject->GetSurfaceRect();
+ int32_t surfaceOrientation = sceneObject->GetSurfaceOrientation();
Integration::DepthBufferAvailable depthBufferAvailable = mImpl->depthBufferAvailable;
Integration::StencilBufferAvailable stencilBufferAvailable = mImpl->stencilBufferAvailable;
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_TRACKER_DEBUG_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Render
{
-
#if defined(DEBUG_ENABLED)
Debug::Filter* gRenderTrackerLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_RENDER_TRACKER");
-#define TRACKER_LOG(level) \
+#define TRACKER_LOG(level) \
DALI_LOG_INFO(gRenderTrackerLogFilter, level, "RenderTracker::%s: this:%p\n", __FUNCTION__, this)
#define TRACKER_LOG_FMT(level, format, ...) \
- DALI_LOG_INFO(gRenderTrackerLogFilter, level, "RenderTracker::%s: this:%p " format, __FUNCTION__, this, ## __VA_ARGS__)
+ DALI_LOG_INFO(gRenderTrackerLogFilter, level, "RenderTracker::%s: this:%p " format, __FUNCTION__, this, ##__VA_ARGS__)
#else
#define TRACKER_LOG(level)
#define TRACKER_LOG_FMT(level, format, ...)
#endif
-} // Render
+} // namespace Render
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_TRACKER_DEBUG_H
namespace Dali
{
-
namespace Internal
{
-
namespace Render
{
-
RenderTracker::RenderTracker()
-: mGlSyncAbstraction( nullptr ),
- mSyncObject( nullptr ),
- mSyncTrigger( 0 )
+: mGlSyncAbstraction(nullptr),
+ mSyncObject(nullptr),
+ mSyncTrigger(0)
{
TRACKER_LOG(Debug::Verbose);
}
RenderTracker::~RenderTracker()
{
TRACKER_LOG(Debug::Verbose);
- if( mSyncObject )
+ if(mSyncObject)
{
- mGlSyncAbstraction->DestroySyncObject( mSyncObject );
+ mGlSyncAbstraction->DestroySyncObject(mSyncObject);
mSyncObject = nullptr;
}
}
-void RenderTracker::CreateSyncObject( Integration::GlSyncAbstraction& glSyncAbstraction )
+void RenderTracker::CreateSyncObject(Integration::GlSyncAbstraction& glSyncAbstraction)
{
mGlSyncAbstraction = &glSyncAbstraction;
TRACKER_LOG(Debug::General);
// Destroy any previous sync object
- if( mSyncObject )
+ if(mSyncObject)
{
- mGlSyncAbstraction->DestroySyncObject( mSyncObject );
- mSyncObject = nullptr;
+ mGlSyncAbstraction->DestroySyncObject(mSyncObject);
+ mSyncObject = nullptr;
}
ResetSyncFlag();
mSyncObject = mGlSyncAbstraction->CreateSyncObject();
void RenderTracker::PollSyncObject()
{
- if( mSyncObject && mSyncObject->IsSynced() )
+ if(mSyncObject && mSyncObject->IsSynced())
{
SetSyncFlag();
- mGlSyncAbstraction->DestroySyncObject( mSyncObject );
+ mGlSyncAbstraction->DestroySyncObject(mSyncObject);
mSyncObject = nullptr;
TRACKER_LOG_FMT(Debug::General, " Synced\n");
{
int x = __sync_val_compare_and_swap(&mSyncTrigger, 0xFF, 0x0);
- TRACKER_LOG_FMT(Debug::General, " = %s\n", x!=0?"T":"F");
+ TRACKER_LOG_FMT(Debug::General, " = %s\n", x != 0 ? "T" : "F");
return x != 0;
}
(void)__sync_lock_test_and_set(&mSyncTrigger, 0xFF);
}
-} // Render
+} // namespace Render
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#define DALI_INTERNAL_RENDER_RENDER_TRACKER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Render
{
-
/**
* This class is used to communicate with Fence Sync objects, keeping access solely in
* the RenderThread to avoid having mutual exclusion locks or messages back to the UpdateThread.
/**
* Creates a sync object for this tracker. Will delete any existing sync object.
*/
- void CreateSyncObject( Integration::GlSyncAbstraction& glSyncAbstraction );
+ void CreateSyncObject(Integration::GlSyncAbstraction& glSyncAbstraction);
/**
* Check the GL Sync objects. This is called from Render Thread.
void SetSyncFlag();
private:
-
- Integration::GlSyncAbstraction* mGlSyncAbstraction; // The sync abstraction
- Integration::GlSyncAbstraction::SyncObject* mSyncObject; // Associated sync object
- volatile int mSyncTrigger; // Trigger that update thread can read
-
+ Integration::GlSyncAbstraction* mGlSyncAbstraction; // The sync abstraction
+ Integration::GlSyncAbstraction::SyncObject* mSyncObject; // Associated sync object
+ volatile int mSyncTrigger; // Trigger that update thread can read
};
-} // Render
-
-} // Internal
+} // namespace Render
-} // Dali
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_RENDER_RENDER_TRACKER_H
#define DALI_INTERNAL_SCENE_GRAPH_NODE_DATA_PROVIDER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Internal
{
-
namespace SceneGraph
{
-
class Node;
class Renderer;
class TextureSet;
*/
struct PartialRenderingCacheInfo
{
- Node* node{nullptr}; /// Node associated with the entry
- const Renderer* renderer{nullptr}; /// Renderer object
- const TextureSet* textureSet{nullptr}; /// TextureSet object
- Matrix matrix{}; /// Model-view matrix
- Vector4 color{}; /// Color
- Vector3 size{}; /// Size
- Vector3 updatedSize{}; /// Updated size
- bool isOpaque{}; /// Opacity state
- uint32_t depthIndex{0u}; /// Depth index
+ Node* node{nullptr}; /// Node associated with the entry
+ const Renderer* renderer{nullptr}; /// Renderer object
+ const TextureSet* textureSet{nullptr}; /// TextureSet object
+ Matrix matrix{}; /// Model-view matrix
+ Vector4 color{}; /// Color
+ Vector3 size{}; /// Size
+ Vector3 updatedSize{}; /// Updated size
+ bool isOpaque{}; /// Opacity state
+ uint32_t depthIndex{0u}; /// Depth index
};
/**
*/
bool IsUpdated()
{
- return 0 != memcmp( &mData[0], &mData[1], sizeof(PartialRenderingCacheInfo) );
+ return 0 != memcmp(&mData[0], &mData[1], sizeof(PartialRenderingCacheInfo));
}
/**
mCurrentIndex = static_cast<uint8_t>((~mCurrentIndex) & 1);
}
- PartialRenderingCacheInfo mData[2u]; /// Double-buffered data
- uint8_t mCurrentIndex {0u}; /// Current buffer index
+ PartialRenderingCacheInfo mData[2u]; /// Double-buffered data
+ uint8_t mCurrentIndex{0u}; /// Current buffer index
};
/**
class PartialRenderingDataProvider
{
public:
-
/**
* Constructor
*/
}
protected:
-
PartialRenderingNodeData mPartialRenderingData;
};
class NodeDataProvider : UniformMapDataProvider, public PartialRenderingDataProvider
{
public:
-
/**
* Constructor. Nothing to do as a pure interface.
*/
* @param bufferIndex to use
* @return a reference to the model matrix
*/
- virtual const Matrix& GetModelMatrix( BufferIndex bufferIndex ) const = 0;
+ virtual const Matrix& GetModelMatrix(BufferIndex bufferIndex) const = 0;
/**
* @param bufferIndex to use
* @return a reference to the color
*/
- virtual const Vector4& GetRenderColor( BufferIndex bufferIndex ) const = 0;
+ virtual const Vector4& GetRenderColor(BufferIndex bufferIndex) const = 0;
/**
* @copydoc Dali::Internal::SceneGraph::UniformMapDataProvider::GetUniformMapChanged()
*/
- bool GetUniformMapChanged( BufferIndex bufferIndex ) const override = 0;
+ bool GetUniformMapChanged(BufferIndex bufferIndex) const override = 0;
/**
* @copydoc Dali::Internal::SceneGraph::UniformMapDataProvider::GetUniformMap()
*/
- const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const override = 0;
+ const CollectedUniformMap& GetUniformMap(BufferIndex bufferIndex) const override = 0;
protected:
/**
~NodeDataProvider() override = default;
};
-} // SceneGraph
-} // Internal
-} // Dali
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_SCENE_GRAPH_NODE_DATA_PROVIDER_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 SceneGraph
{
-
-RenderDataProvider::RenderDataProvider( AnimatableProperty< float >& opacity )
-: mUniformMapDataProvider( nullptr ),
- mShader( nullptr ),
- mOpacity( opacity )
+RenderDataProvider::RenderDataProvider(AnimatableProperty<float>& opacity)
+: mUniformMapDataProvider(nullptr),
+ mShader(nullptr),
+ mOpacity(opacity)
{
}
return *mUniformMapDataProvider;
}
-void RenderDataProvider::SetShader( Shader& shader )
+void RenderDataProvider::SetShader(Shader& shader)
{
mShader = &shader;
}
return mTextures;
}
-float RenderDataProvider::GetOpacity( BufferIndex bufferIndex )
+float RenderDataProvider::GetOpacity(BufferIndex bufferIndex)
{
return mOpacity[bufferIndex];
}
-} // SceneGraph
-} // Internal
-} // Dali
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
#define DALI_INTERNAL_SCENE_GRAPH_UNIFORM_MAP_DATA_PROVIDER_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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] bufferIndex The buffer index
* @return true if the uniform map has changed
*/
- virtual bool GetUniformMapChanged( BufferIndex bufferIndex ) const = 0;
+ virtual bool GetUniformMapChanged(BufferIndex bufferIndex) const = 0;
/**
* Get the complete map of uniforms to property value addresses
* @param[in] bufferIndex The bufferIndex
* @return the uniform map
*/
- virtual const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const = 0;
+ virtual const CollectedUniformMap& GetUniformMap(BufferIndex bufferIndex) const = 0;
protected:
/**
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace
{
-
const uint32_t INITIAL_FRAMEBUFFER_STATE = 0u;
}
namespace Internal
{
-
FrameBufferStateCache::FrameBufferStateCache()
-:mCurrentFrameBufferId(0)
+: mCurrentFrameBufferId(0)
{
}
FrameBufferStateCache::~FrameBufferStateCache() = default;
-GLbitfield FrameBufferStateCache::GetClearMask( GLbitfield mask, bool forceClear, bool scissorTestEnabled )
+GLbitfield FrameBufferStateCache::GetClearMask(GLbitfield mask, bool forceClear, bool scissorTestEnabled)
{
- if( scissorTestEnabled )
+ if(scissorTestEnabled)
{
// don't do anything if scissor test is enabled, in the future we could
// potentially keep track of frame buffer size vs scissor test size to see if the entire
// buffer is cleared or not.
return mask;
}
- FrameBufferState* state = GetFrameBufferState( mCurrentFrameBufferId );
- if( !state )
+ FrameBufferState* state = GetFrameBufferState(mCurrentFrameBufferId);
+ if(!state)
{
DALI_LOG_ERROR("FrameBuffer not found %d \n", mCurrentFrameBufferId);
return mask;
}
// if we are forcing the clear operation, then just update the internal cached values
- if( forceClear )
+ if(forceClear)
{
- SetClearState( state, mask );
+ SetClearState(state, mask);
return mask;
}
// use the cached values
- if( mask & GL_COLOR_BUFFER_BIT)
+ if(mask & GL_COLOR_BUFFER_BIT)
{
// check if color buffer is currently clean
- if( state->mState & COLOR_BUFFER_CLEAN )
+ if(state->mState & COLOR_BUFFER_CLEAN)
{
// remove clear color buffer flag from bitmask, no need to clear twice
- mask&= ~GL_COLOR_BUFFER_BIT;
+ mask &= ~GL_COLOR_BUFFER_BIT;
}
}
- if( mask & GL_DEPTH_BUFFER_BIT)
+ if(mask & GL_DEPTH_BUFFER_BIT)
{
// check if depth buffer is currently clean
- if( state->mState & DEPTH_BUFFER_CLEAN )
+ if(state->mState & DEPTH_BUFFER_CLEAN)
{
// remove clear depth buffer flag from bitmask, no need to clear twice
- mask&= ~GL_DEPTH_BUFFER_BIT;
+ mask &= ~GL_DEPTH_BUFFER_BIT;
}
}
- if( mask & GL_STENCIL_BUFFER_BIT)
+ if(mask & GL_STENCIL_BUFFER_BIT)
{
// check if stencil buffer is currently clean
- if( state->mState & STENCIL_BUFFER_CLEAN )
+ if(state->mState & STENCIL_BUFFER_CLEAN)
{
// remove clear stencil buffer flag from bitmask, no need to clear twice
- mask&= ~GL_STENCIL_BUFFER_BIT;
+ mask &= ~GL_STENCIL_BUFFER_BIT;
}
}
// set the clear state based, what's about to be cleared
- SetClearState( state, mask );
+ SetClearState(state, mask);
return mask;
}
-void FrameBufferStateCache::SetCurrentFrameBuffer( GLuint frameBufferId )
+void FrameBufferStateCache::SetCurrentFrameBuffer(GLuint frameBufferId)
{
mCurrentFrameBufferId = frameBufferId;
}
-void FrameBufferStateCache::FrameBuffersDeleted( GLsizei count, const GLuint* const frameBuffers )
+void FrameBufferStateCache::FrameBuffersDeleted(GLsizei count, const GLuint* const frameBuffers)
{
- for( GLsizei i = 0; i < count; ++i )
+ for(GLsizei i = 0; i < count; ++i)
{
- DeleteFrameBuffer( frameBuffers[i] );
+ DeleteFrameBuffer(frameBuffers[i]);
}
}
-void FrameBufferStateCache::FrameBuffersCreated( GLsizei count, const GLuint* const frameBuffers )
+void FrameBufferStateCache::FrameBuffersCreated(GLsizei count, const GLuint* const frameBuffers)
{
- for( GLsizei i = 0; i < count; ++i )
+ for(GLsizei i = 0; i < count; ++i)
{
// check the frame buffer doesn't exist already
GLuint id = frameBuffers[i];
- FrameBufferState* state = GetFrameBufferState( id );
- if( state )
+ FrameBufferState* state = GetFrameBufferState(id);
+ if(state)
{
- DALI_LOG_ERROR("FrameBuffer already exists%d \n", id );
+ DALI_LOG_ERROR("FrameBuffer already exists%d \n", id);
// reset its state
state->mState = INITIAL_FRAMEBUFFER_STATE;
continue;
}
- FrameBufferState newFrameBuffer( frameBuffers[i] );
- mFrameBufferStates.PushBack( newFrameBuffer );
+ FrameBufferState newFrameBuffer(frameBuffers[i]);
+ mFrameBufferStates.PushBack(newFrameBuffer);
}
}
-void FrameBufferStateCache::DrawOperation( bool colorBuffer, bool depthBuffer, bool stencilBuffer )
+void FrameBufferStateCache::DrawOperation(bool colorBuffer, bool depthBuffer, bool stencilBuffer)
{
- FrameBufferState* state = GetFrameBufferState( mCurrentFrameBufferId );
- if( !state )
+ FrameBufferState* state = GetFrameBufferState(mCurrentFrameBufferId);
+ if(!state)
{
// an error will have already been logged by the clear operation
return;
}
- if( colorBuffer )
+ if(colorBuffer)
{
// un-set the clean bit
state->mState &= ~COLOR_BUFFER_CLEAN;
}
- if( depthBuffer )
+ if(depthBuffer)
{
// un-set the clean bit
state->mState &= ~DEPTH_BUFFER_CLEAN;
}
- if( stencilBuffer )
+ if(stencilBuffer)
{
// un-set the clean bit
state->mState &= ~STENCIL_BUFFER_CLEAN;
}
-
}
void FrameBufferStateCache::Reset()
// create the default frame buffer
GLuint id = 0; // 0 == default frame buffer id
- FrameBuffersCreated( 1, &id );
+ FrameBuffersCreated(1, &id);
}
-void FrameBufferStateCache::SetClearState( FrameBufferState* state, GLbitfield mask )
+void FrameBufferStateCache::SetClearState(FrameBufferState* state, GLbitfield mask)
{
- if( mask & GL_COLOR_BUFFER_BIT)
+ if(mask & GL_COLOR_BUFFER_BIT)
{
// set the color buffer to clean
state->mState |= COLOR_BUFFER_CLEAN;
}
- if( mask & GL_DEPTH_BUFFER_BIT)
+ if(mask & GL_DEPTH_BUFFER_BIT)
{
// set the depth buffer to clean
state->mState |= DEPTH_BUFFER_CLEAN;
}
- if( mask & GL_STENCIL_BUFFER_BIT)
+ if(mask & GL_STENCIL_BUFFER_BIT)
{
// set the stencil buffer to clean
state->mState |= STENCIL_BUFFER_CLEAN;
}
}
-FrameBufferStateCache::FrameBufferState* FrameBufferStateCache::GetFrameBufferState( GLuint frameBufferId )
+FrameBufferStateCache::FrameBufferState* FrameBufferStateCache::GetFrameBufferState(GLuint frameBufferId)
{
- for( FrameBufferStateVector::SizeType i = 0; i < mFrameBufferStates.Count(); ++i )
+ for(FrameBufferStateVector::SizeType i = 0; i < mFrameBufferStates.Count(); ++i)
{
FrameBufferState& state = mFrameBufferStates[i];
- if( state.mId == frameBufferId )
+ if(state.mId == frameBufferId)
{
return &state;
}
return nullptr;
}
-void FrameBufferStateCache::DeleteFrameBuffer( GLuint frameBufferId )
+void FrameBufferStateCache::DeleteFrameBuffer(GLuint frameBufferId)
{
- FrameBufferStateVector::Iterator iter = mFrameBufferStates.Begin();
+ FrameBufferStateVector::Iterator iter = mFrameBufferStates.Begin();
FrameBufferStateVector::Iterator endIter = mFrameBufferStates.End();
- for( ; iter != endIter ; ++iter )
+ for(; iter != endIter; ++iter)
{
- if( (*iter).mId == frameBufferId )
- {
- mFrameBufferStates.Erase( iter);
- return;
- }
- }
- DALI_LOG_ERROR("FrameBuffer not found %d \n", frameBufferId);
+ if((*iter).mId == frameBufferId)
+ {
+ mFrameBufferStates.Erase(iter);
+ return;
+ }
+ }
+ DALI_LOG_ERROR("FrameBuffer not found %d \n", frameBufferId);
}
} // namespace Internal
#define DALI_INTERNAL_CONTEXT_FRAME_BUFFER_STATE_CACHE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* @brief Keeps track of color, depth and stencil buffer state within each frame buffer.
* Used to avoid redundant glClear calls.
class FrameBufferStateCache
{
public:
-
-
/**
* @brief Constructor
*/
* @param[in] scissorTestEnabled whether scissor test is enabled
* @return new bitmask to pass to glClear
*/
- GLbitfield GetClearMask( GLbitfield mask, bool forceClear, bool scissorTestEnabled );
+ GLbitfield GetClearMask(GLbitfield mask, bool forceClear, bool scissorTestEnabled);
/**
* @brief Set the current bound frame buffer
* @param[in] frameBufferId frame buffer id
*/
- void SetCurrentFrameBuffer( GLuint frameBufferId );
+ void SetCurrentFrameBuffer(GLuint frameBufferId);
/**
* @brief Called when frame buffers are deleted
* @param[in] count number of frame buffers
* @param[in] framebuffers array of frame buffer ids
*/
- void FrameBuffersDeleted( GLsizei count, const GLuint* const frameBuffers );
+ void FrameBuffersDeleted(GLsizei count, const GLuint* const frameBuffers);
/**
* @brief Called when frame buffers are created
* @param[in] count number of frame buffers
* @param[in] framebuffers array of frame buffer ids
*/
- void FrameBuffersCreated( GLsizei count, const GLuint* const frameBuffers );
+ void FrameBuffersCreated(GLsizei count, const GLuint* const frameBuffers);
/**
* @brief Draw operation performed on the current frame buffer
* @param[in] depthBufferUsed whether the depth buffer is being written to (glDepthMask )
* @param[in] stencilBufferUsed whether the stencil buffer is being written to (glStencilMask )
*/
- void DrawOperation( bool colorBufferUsed, bool depthBufferUsed, bool stencilBufferUsed );
+ void DrawOperation(bool colorBufferUsed, bool depthBufferUsed, bool stencilBufferUsed);
/**
* Reset the cache
void Reset();
private:
-
/**
* Current status of the frame buffer
*/
enum FrameBufferStatus
{
- COLOR_BUFFER_CLEAN = 1 << 0, ///< color buffer clean
- DEPTH_BUFFER_CLEAN = 1 << 1, ///< depth buffer clean
- STENCIL_BUFFER_CLEAN = 1 << 2, ///< stencil buffer clean
+ COLOR_BUFFER_CLEAN = 1 << 0, ///< color buffer clean
+ DEPTH_BUFFER_CLEAN = 1 << 1, ///< depth buffer clean
+ STENCIL_BUFFER_CLEAN = 1 << 2, ///< stencil buffer clean
};
/**
/**
* Constructor
*/
- FrameBufferState( GLuint id )
- :mId( id ),
- mState( 0 )
+ FrameBufferState(GLuint id)
+ : mId(id),
+ mState(0)
{
}
- GLuint mId; ///< Frame buffer id
- unsigned int mState; ///< State, bitmask of FrameBufferStatus flags
+ GLuint mId; ///< Frame buffer id
+ unsigned int mState; ///< State, bitmask of FrameBufferStatus flags
};
using FrameBufferStateVector = Dali::Vector<FrameBufferState>;
* @param[in] pointer to frame buffer state object
* @param[in] mask clear mask
*/
- void SetClearState( FrameBufferState* state, GLbitfield mask );
+ void SetClearState(FrameBufferState* state, GLbitfield mask);
/**
* @brief Helper
* @param[in] frameBufferId frame buffer id
* @return pointer to frame buffer state object ( NULL if it doesn't exist)
*/
- FrameBufferState* GetFrameBufferState( GLuint frameBufferId );
+ FrameBufferState* GetFrameBufferState(GLuint frameBufferId);
/**
* @brief Helper to delete a frame buffer state object
* @param[in] frameBufferId frame buffer id
*/
- void DeleteFrameBuffer( GLuint frameBufferId );
-
- FrameBufferStateCache( const FrameBufferStateCache& ); ///< undefined copy constructor
+ void DeleteFrameBuffer(GLuint frameBufferId);
- FrameBufferStateCache& operator=( const FrameBufferStateCache& ); ///< undefined assignment operator
+ FrameBufferStateCache(const FrameBufferStateCache&); ///< undefined copy constructor
-private: // data
+ FrameBufferStateCache& operator=(const FrameBufferStateCache&); ///< undefined assignment operator
- FrameBufferStateVector mFrameBufferStates; ///< state of the frame buffers
- GLuint mCurrentFrameBufferId; ///< currently bound frame buffer
+private: // data
+ FrameBufferStateVector mFrameBufferStates; ///< state of the frame buffers
+ GLuint mCurrentFrameBufferId; ///< currently bound frame buffer
};
} // namespace Internal
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/render/gl-resources/gl-call-debug.h>
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
#include <dali/integration-api/debug.h>
#include <dali/integration-api/gl-abstraction.h>
#include <dali/integration-api/gl-defines.h>
+#include <dali/public-api/common/dali-common.h>
namespace
{
struct errorStrings
{
const Dali::GLenum errorCode;
- const char* errorString;
+ const char* errorString;
};
errorStrings errors[] =
-{
- { GL_NO_ERROR, "GL_NO_ERROR" },
- { GL_INVALID_ENUM, "GL_INVALID_ENUM" },
- { GL_INVALID_VALUE, "GL_INVALID_VALUE" },
- { GL_INVALID_OPERATION, "GL_INVALID_OPERATION" },
- { GL_OUT_OF_MEMORY, "GL_OUT_OF_MEMORY" }
-};
+ {
+ {GL_NO_ERROR, "GL_NO_ERROR"},
+ {GL_INVALID_ENUM, "GL_INVALID_ENUM"},
+ {GL_INVALID_VALUE, "GL_INVALID_VALUE"},
+ {GL_INVALID_OPERATION, "GL_INVALID_OPERATION"},
+ {GL_OUT_OF_MEMORY, "GL_OUT_OF_MEMORY"}};
-const char* ErrorToString( Dali::GLenum errorCode )
+const char* ErrorToString(Dali::GLenum errorCode)
{
- for( unsigned int i = 0; i < sizeof(errors) / sizeof(errors[0]); ++i)
+ for(unsigned int i = 0; i < sizeof(errors) / sizeof(errors[0]); ++i)
{
- if (errorCode == errors[i].errorCode)
+ if(errorCode == errors[i].errorCode)
{
return errors[i].errorString;
}
return "Unknown Open GLES error";
}
-}
+} // namespace
namespace Dali
{
-
namespace Internal
{
-
#ifdef DEBUG_ENABLED
/// Switch debug level to Concise to disable, General to enable. Note, enabling snapshot logging will do this on the fly.
Debug::Filter* gGlLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_CONTEXT");
#endif // DEBUG_ENABLED
-void CheckGlError( Integration::GlAbstraction& glAbstraction, const char* operation )
+void CheckGlError(Integration::GlAbstraction& glAbstraction, const char* operation)
{
bool foundError = false;
- while( GLint error = glAbstraction.GetError() )
+ while(GLint error = glAbstraction.GetError())
{
- DALI_LOG_ERROR( "glError (0x%x) %s - after %s\n", error, ErrorToString( error ), operation );
+ DALI_LOG_ERROR("glError (0x%x) %s - after %s\n", error, ErrorToString(error), operation);
foundError = true;
}
- DALI_ASSERT_ALWAYS( !foundError && "GL ERROR" ); // if errors are being checked we should assert
+ DALI_ASSERT_ALWAYS(!foundError && "GL ERROR"); // if errors are being checked we should assert
}
-}
+} // namespace Internal
-}
+} // namespace Dali
#define DALI_INTERNAL_GL_CALL_DEBUG_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 glAbstraction to use for error check
* @param operation to be logged
*/
-void CheckGlError( Integration::GlAbstraction& glAbstraction, const char* operation );
+void CheckGlError(Integration::GlAbstraction& glAbstraction, const char* operation);
// wrap gl calls with CHECK_GL e.g. "CHECK_GL( mGlAbstraction, mGlAbstraction.UseProgram(mProgramId) );"
// will LOG any glErrors eg "glError (0x0501) GL_INVALID_VALUE - glBindTexture(textureId)"
// only enable if specifically enabled as it can slow down GL a lot!
#ifdef DALI_GL_ERROR_CHECK
-#define CHECK_GL(c,a) (a); CheckGlError(c,#a)
+#define CHECK_GL(c, a) \
+ (a); \
+ CheckGlError(c, #a)
#else
-#define CHECK_GL(c,a) (a)
+#define CHECK_GL(c, a) (a)
#endif
#ifdef DEBUG_ENABLED
// Don't put guards around here (LOG_INFO has it's own guards)
#define LOG_GL(format, ...) \
- DALI_LOG_INFO(gGlLogFilter, Debug::General, format, ## __VA_ARGS__)
+ DALI_LOG_INFO(gGlLogFilter, Debug::General, format, ##__VA_ARGS__)
-}
+} // namespace Internal
-}
+} // namespace Dali
#endif // DALI_INTERNAL_GL_CALL_DEBUG_H
-
#define DALI_INTERNAL_GL_RESOURCE_OWNER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* Abstract interface for objects which own GL resources.
* These objects must release their GL resources in the render-thread.
class GlResourceOwner
{
public:
-
/**
* Virtual destructor.
*/
* @pre This method can only be called from the render-thread.
*/
virtual void GlCleanup() = 0;
-
};
} // namespace Internal
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
/**
* Helper to get our drawmode enum as GL enum
* @param type to convert
* @return the corresponding GL enum or -1
*/
-inline GLenum ModeAsGlEnum( GpuBuffer::Usage type )
+inline GLenum ModeAsGlEnum(GpuBuffer::Usage type)
{
- GLenum retval( -1 );
- switch( type )
+ GLenum retval(-1);
+ switch(type)
{
- case GpuBuffer::STREAM_DRAW :
+ case GpuBuffer::STREAM_DRAW:
{
retval = GL_STREAM_DRAW;
break;
}
- case GpuBuffer::STATIC_DRAW :
+ case GpuBuffer::STATIC_DRAW:
{
retval = GL_STATIC_DRAW;
break;
}
- case GpuBuffer::DYNAMIC_DRAW :
+ case GpuBuffer::DYNAMIC_DRAW:
{
retval = GL_DYNAMIC_DRAW;
break;
return retval;
}
-}
+} // namespace
-GpuBuffer::GpuBuffer( Context& context )
-: mContext( context ),
- mCapacity( 0 ),
- mSize( 0 ),
- mBufferId( 0 ),
- mBufferCreated( false )
+GpuBuffer::GpuBuffer(Context& context)
+: mContext(context),
+ mCapacity(0),
+ mSize(0),
+ mBufferId(0),
+ mBufferCreated(false)
{
}
GpuBuffer::~GpuBuffer()
{
// If we have a buffer then delete it.
- if (mBufferId)
+ if(mBufferId)
{
// If a buffer object that is currently bound is deleted, the binding reverts to 0
// (the absence of any buffer object, which reverts to client memory usage)
- mContext.DeleteBuffers(1,&mBufferId);
+ mContext.DeleteBuffers(1, &mBufferId);
}
}
* Creates or updates the buffer data depending on whether it
* already exists or not.
*/
-void GpuBuffer::UpdateDataBuffer(Context& context, GLsizeiptr size, const GLvoid *data, Usage usage, Target target)
+void GpuBuffer::UpdateDataBuffer(Context& context, GLsizeiptr size, const GLvoid* data, Usage usage, Target target)
{
- DALI_ASSERT_DEBUG( size > 0 );
+ DALI_ASSERT_DEBUG(size > 0);
mSize = size;
// make sure we have a buffer name/id before uploading
- if (mBufferId == 0)
+ if(mBufferId == 0)
{
- mContext.GenBuffers(1,&mBufferId);
+ mContext.GenBuffers(1, &mBufferId);
DALI_ASSERT_DEBUG(mBufferId);
}
// make sure the buffer is bound, don't perform any checks because size may be zero
if(ARRAY_BUFFER == target)
{
- context.BindArrayBuffer( mBufferId );
+ context.BindArrayBuffer(mBufferId);
}
else if(ELEMENT_ARRAY_BUFFER == target)
{
glTargetEnum = GL_ELEMENT_ARRAY_BUFFER;
- context.BindElementArrayBuffer( mBufferId );
+ context.BindElementArrayBuffer(mBufferId);
}
else if(TRANSFORM_FEEDBACK_BUFFER == target)
{
glTargetEnum = GL_TRANSFORM_FEEDBACK_BUFFER;
- context.BindTransformFeedbackBuffer( mBufferId );
+ context.BindTransformFeedbackBuffer(mBufferId);
}
// if the buffer has already been created, just update the data providing it fits
- if (mBufferCreated )
+ if(mBufferCreated)
{
// if the data will fit in the existing buffer, just update it
- if (size <= mCapacity )
+ if(size <= mCapacity)
{
- context.BufferSubData( glTargetEnum, 0, size, data );
+ context.BufferSubData(glTargetEnum, 0, size, data);
}
else
{
// create a new buffer of the larger size,
// gl should automatically deallocate the old buffer
- context.BufferData( glTargetEnum, size, data, ModeAsGlEnum( usage ) );
+ context.BufferData(glTargetEnum, size, data, ModeAsGlEnum(usage));
mCapacity = size;
}
}
else
{
// create the buffer
- context.BufferData( glTargetEnum, size, data, ModeAsGlEnum( usage ) );
+ context.BufferData(glTargetEnum, size, data, ModeAsGlEnum(usage));
mBufferCreated = true;
- mCapacity = size;
+ mCapacity = size;
}
if(ARRAY_BUFFER == target)
{
- context.BindArrayBuffer( 0 );
+ context.BindArrayBuffer(0);
}
else if(ELEMENT_ARRAY_BUFFER == target)
{
- context.BindElementArrayBuffer( 0 );
+ context.BindElementArrayBuffer(0);
}
else if(TRANSFORM_FEEDBACK_BUFFER == target)
{
- context.BindTransformFeedbackBuffer( 0 );
+ context.BindTransformFeedbackBuffer(0);
}
}
{
DALI_ASSERT_DEBUG(mCapacity);
- if (target == ARRAY_BUFFER)
+ if(target == ARRAY_BUFFER)
{
context.BindArrayBuffer(mBufferId);
}
- else if (target == ELEMENT_ARRAY_BUFFER)
+ else if(target == ELEMENT_ARRAY_BUFFER)
{
context.BindElementArrayBuffer(mBufferId);
}
- else if (target == TRANSFORM_FEEDBACK_BUFFER)
+ else if(target == TRANSFORM_FEEDBACK_BUFFER)
{
context.BindTransformFeedbackBuffer(mBufferId);
}
bool GpuBuffer::BufferIsValid() const
{
- return mBufferCreated && (0 != mCapacity );
+ return mBufferCreated && (0 != mCapacity);
}
void GpuBuffer::GlContextDestroyed()
{
// If the context is destroyed, GL would have released the buffer.
- mCapacity = 0;
- mSize = 0;
- mBufferId = 0;
+ mCapacity = 0;
+ mSize = 0;
+ mBufferId = 0;
mBufferCreated = false;
}
#define DALI_INTERNAL_GPU_BUFFER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* Used to create and update a GPU memory buffer.
*
class GpuBuffer
{
public:
-
/**
* Enum to encapsulate the GL buffer type. This is to avoid having to store a whole int for type
*/
};
public:
-
/**
* constructor
* @param context drawing context
*/
- GpuBuffer( Context& context );
+ GpuBuffer(Context& context);
/**
* Destructor, non virtual as no virtual methods or inheritance
* @param usage How the buffer will be used
* @param target The target buffer to update
*/
- void UpdateDataBuffer(Context& context, GLsizeiptr size, const GLvoid *data, Usage usage, Target target);
+ void UpdateDataBuffer(Context& context, GLsizeiptr size, const GLvoid* data, Usage usage, Target target);
/**
* Bind the buffer object to the target
void GlContextDestroyed();
private:
-
/**
* Perfoms a bind without checking the size of the buffer
* @param bufferId to bind
*/
void BindNoChecks(GLuint bufferId) const;
-private: // Data
-
- Context& mContext; ///< shared context for dali drawing
- GLsizeiptr mCapacity; ///< buffer capacity
- GLsizeiptr mSize; ///< buffer size
- GLuint mBufferId; ///< buffer object name(id)
-
- bool mBufferCreated:1; ///< whether buffer has been created
+private: // Data
+ Context& mContext; ///< shared context for dali drawing
+ GLsizeiptr mCapacity; ///< buffer capacity
+ GLsizeiptr mSize; ///< buffer size
+ GLuint mBufferId; ///< buffer object name(id)
+ bool mBufferCreated : 1; ///< whether buffer has been created
};
} // namespace Internal
#define DALI_INTERNAL_TEXTURE_UNITS_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Internal
{
-
enum TextureUnit
{
TEXTURE_UNIT_IMAGE = 0,
TEXTURE_UNIT_LAST
};
-inline unsigned int TextureUnitAsGLenum( TextureUnit unit )
+inline unsigned int TextureUnitAsGLenum(TextureUnit unit)
{
// GL texture units are #defines in growing order to converting that to index
- return GL_TEXTURE0 + static_cast<unsigned int>( unit );
+ return GL_TEXTURE0 + static_cast<unsigned int>(unit);
}
-}//Internal
+} // namespace Internal
-}//Dali
+} // namespace Dali
#endif // DALI_INTERNAL_TEXTURE_UNITS_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace // unnamed namespace
{
-
static const std::size_t INITIAL_BUFFER_SIZE = 32768;
static const std::size_t MAX_BUFFER_SIZE = 32768;
namespace SceneGraph
{
-
RenderQueue::RenderQueue()
-: container0( nullptr ),
- container1( nullptr )
+: container0(nullptr),
+ container1(nullptr)
{
- container0 = new MessageBuffer( INITIAL_BUFFER_SIZE );
- container1 = new MessageBuffer( INITIAL_BUFFER_SIZE );
+ container0 = new MessageBuffer(INITIAL_BUFFER_SIZE);
+ container1 = new MessageBuffer(INITIAL_BUFFER_SIZE);
}
RenderQueue::~RenderQueue()
{
- if( container0 )
+ if(container0)
{
- for( MessageBuffer::Iterator iter = container0->Begin(); iter.IsValid(); iter.Next() )
+ for(MessageBuffer::Iterator iter = container0->Begin(); iter.IsValid(); iter.Next())
{
- MessageBase* message = reinterpret_cast< MessageBase* >( iter.Get() );
+ MessageBase* message = reinterpret_cast<MessageBase*>(iter.Get());
// Call virtual destructor explictly; since delete will not be called after placement new
message->~MessageBase();
delete container0;
}
- if( container1 )
+ if(container1)
{
- for( MessageBuffer::Iterator iter = container1->Begin(); iter.IsValid(); iter.Next() )
+ for(MessageBuffer::Iterator iter = container1->Begin(); iter.IsValid(); iter.Next())
{
- MessageBase* message = reinterpret_cast< MessageBase* >( iter.Get() );
+ MessageBase* message = reinterpret_cast<MessageBase*>(iter.Get());
// Call virtual destructor explictly; since delete will not be called after placement new
message->~MessageBase();
}
}
-uint32_t* RenderQueue::ReserveMessageSlot( BufferIndex updateBufferIndex, std::size_t size )
+uint32_t* RenderQueue::ReserveMessageSlot(BufferIndex updateBufferIndex, std::size_t size)
{
- MessageBuffer* container = GetCurrentContainer( updateBufferIndex );
+ MessageBuffer* container = GetCurrentContainer(updateBufferIndex);
- return container->ReserveMessageSlot( size );
+ return container->ReserveMessageSlot(size);
}
-void RenderQueue::ProcessMessages( BufferIndex bufferIndex )
+void RenderQueue::ProcessMessages(BufferIndex bufferIndex)
{
- MessageBuffer* container = GetCurrentContainer( bufferIndex );
+ MessageBuffer* container = GetCurrentContainer(bufferIndex);
- for( MessageBuffer::Iterator iter = container->Begin(); iter.IsValid(); iter.Next() )
+ for(MessageBuffer::Iterator iter = container->Begin(); iter.IsValid(); iter.Next())
{
- MessageBase* message = reinterpret_cast< MessageBase* >( iter.Get() );
+ MessageBase* message = reinterpret_cast<MessageBase*>(iter.Get());
- message->Process( bufferIndex );
+ message->Process(bufferIndex);
// Call virtual destructor explictly; since delete will not be called after placement new
message->~MessageBase();
container->Reset();
- LimitBufferCapacity( bufferIndex );
+ LimitBufferCapacity(bufferIndex);
}
-MessageBuffer* RenderQueue::GetCurrentContainer( BufferIndex bufferIndex )
+MessageBuffer* RenderQueue::GetCurrentContainer(BufferIndex bufferIndex)
{
- MessageBuffer* container( nullptr );
+ MessageBuffer* container(nullptr);
/**
* The update-thread queues messages with one container,
* whilst the render-thread is processing the other.
*/
- if ( !bufferIndex )
+ if(!bufferIndex)
{
container = container0;
}
return container;
}
-void RenderQueue::LimitBufferCapacity( BufferIndex bufferIndex )
+void RenderQueue::LimitBufferCapacity(BufferIndex bufferIndex)
{
- if ( !bufferIndex )
+ if(!bufferIndex)
{
- if( MAX_BUFFER_SIZE < container0->GetCapacity() )
+ if(MAX_BUFFER_SIZE < container0->GetCapacity())
{
delete container0;
container0 = nullptr;
- container0 = new MessageBuffer( INITIAL_BUFFER_SIZE );
+ container0 = new MessageBuffer(INITIAL_BUFFER_SIZE);
}
}
else
{
- if( MAX_BUFFER_SIZE < container1->GetCapacity() )
+ if(MAX_BUFFER_SIZE < container1->GetCapacity())
{
delete container1;
container1 = nullptr;
- container1 = new MessageBuffer( INITIAL_BUFFER_SIZE );
+ container1 = new MessageBuffer(INITIAL_BUFFER_SIZE);
}
}
}
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_QUEUE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
class MessageBase;
namespace SceneGraph
{
-
/**
* Allows messages to be queued for RenderManager, during the scene-graph Update.
*/
class RenderQueue
{
public:
-
/**
* Create a new RenderQueue.
*/
* @param[in] size The message size with respect to the size of type "char".
* @return A pointer to the first char allocated for the message.
*/
- uint32_t* ReserveMessageSlot( BufferIndex updateBufferIndex, std::size_t size );
+ uint32_t* ReserveMessageSlot(BufferIndex updateBufferIndex, std::size_t size);
/**
* Process the batch of messages, which were queued in the previous update.
* @pre This message should only be called by RenderManager from within the render-thread.
* @param[in] bufferIndex The previous update buffer index.
*/
- void ProcessMessages( BufferIndex bufferIndex );
+ void ProcessMessages(BufferIndex bufferIndex);
private:
-
/**
* Helper to retrieve the current container.
* The update-thread queues messages with one container, whilst the render-thread is processing the other.
* @param[in] bufferIndex The current buffer index.
* @return The container.
*/
- MessageBuffer* GetCurrentContainer( BufferIndex bufferIndex );
+ MessageBuffer* GetCurrentContainer(BufferIndex bufferIndex);
/**
* Helper to limit the buffer capacity i.e. after a frame when an extreme number of messages have been sent.
* @param[in] bufferIndex The current buffer index.
*/
- void LimitBufferCapacity( BufferIndex bufferIndex );
+ void LimitBufferCapacity(BufferIndex bufferIndex);
// Undefined
- RenderQueue( const RenderQueue& );
+ RenderQueue(const RenderQueue&);
// Undefined
- RenderQueue& operator=( const RenderQueue& rhs );
+ RenderQueue& operator=(const RenderQueue& rhs);
private:
-
MessageBuffer* container0; ///< Messages are queued here when the update buffer index == 0
MessageBuffer* container1; ///< Messages are queued here when the update buffer index == 1
};
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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
{
const GLenum COLOR_ATTACHMENTS[] =
-{
+ {
GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2,
};
}
-FrameBuffer::FrameBuffer( uint32_t width, uint32_t height, Mask attachments )
-: mId( 0u ),
- mTextureId{ 0u },
- mDepthBuffer( attachments & Dali::FrameBuffer::Attachment::DEPTH ),
- mStencilBuffer( attachments & Dali::FrameBuffer::Attachment::STENCIL ),
- mWidth( width ),
- mHeight( height ),
- mColorAttachmentCount( 0u )
+FrameBuffer::FrameBuffer(uint32_t width, uint32_t height, Mask attachments)
+: mId(0u),
+ mTextureId{0u},
+ mDepthBuffer(attachments & Dali::FrameBuffer::Attachment::DEPTH),
+ mStencilBuffer(attachments & Dali::FrameBuffer::Attachment::STENCIL),
+ mWidth(width),
+ mHeight(height),
+ mColorAttachmentCount(0u)
{
}
FrameBuffer::~FrameBuffer() = default;
-void FrameBuffer::Destroy( Context& context )
+void FrameBuffer::Destroy(Context& context)
{
- if( mId )
+ if(mId)
{
- context.DeleteFramebuffers( 1, &mId );
+ context.DeleteFramebuffers(1, &mId);
}
}
void FrameBuffer::Initialize(Context& context)
{
- context.GenFramebuffers( 1, &mId );
- context.BindFramebuffer( GL_FRAMEBUFFER, mId );
+ context.GenFramebuffers(1, &mId);
+ context.BindFramebuffer(GL_FRAMEBUFFER, mId);
- if( mDepthBuffer )
+ if(mDepthBuffer)
{
// Create a depth render target.
- context.GenRenderbuffers( 1, &mDepthBuffer );
- context.BindRenderbuffer( GL_RENDERBUFFER, mDepthBuffer );
- context.RenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, mWidth, mHeight );
- context.FramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepthBuffer );
+ context.GenRenderbuffers(1, &mDepthBuffer);
+ context.BindRenderbuffer(GL_RENDERBUFFER, mDepthBuffer);
+ context.RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, mWidth, mHeight);
+ context.FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepthBuffer);
}
- if( mStencilBuffer )
+ if(mStencilBuffer)
{
// Create a stencil render target.
- context.GenRenderbuffers( 1, &mStencilBuffer );
- context.BindRenderbuffer( GL_RENDERBUFFER, mStencilBuffer );
- context.RenderbufferStorage( GL_RENDERBUFFER, GL_STENCIL_INDEX8, mWidth, mHeight );
- context.FramebufferRenderbuffer( GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mStencilBuffer );
+ context.GenRenderbuffers(1, &mStencilBuffer);
+ context.BindRenderbuffer(GL_RENDERBUFFER, mStencilBuffer);
+ context.RenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, mWidth, mHeight);
+ context.FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mStencilBuffer);
}
- context.BindFramebuffer( GL_FRAMEBUFFER, 0 );
+ context.BindFramebuffer(GL_FRAMEBUFFER, 0);
}
-void FrameBuffer::AttachColorTexture( Context& context, Render::Texture* texture, uint32_t mipmapLevel, uint32_t layer )
+void FrameBuffer::AttachColorTexture(Context& context, Render::Texture* texture, uint32_t mipmapLevel, uint32_t layer)
{
- context.BindFramebuffer( GL_FRAMEBUFFER, mId );
+ context.BindFramebuffer(GL_FRAMEBUFFER, mId);
- const GLuint textureId = texture->GetId();
+ const GLuint textureId = texture->GetId();
mTextureId[mColorAttachmentCount] = textureId;
// Create a color attachment.
const GLenum iAttachment = COLOR_ATTACHMENTS[mColorAttachmentCount];
- if( texture->GetType() == TextureType::TEXTURE_2D )
+ if(texture->GetType() == TextureType::TEXTURE_2D)
{
- context.FramebufferTexture2D( GL_FRAMEBUFFER, iAttachment, texture->GetTarget(), textureId, mipmapLevel );
+ context.FramebufferTexture2D(GL_FRAMEBUFFER, iAttachment, texture->GetTarget(), textureId, mipmapLevel);
}
else
{
- context.FramebufferTexture2D( GL_FRAMEBUFFER, iAttachment, GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer, textureId, mipmapLevel );
+ context.FramebufferTexture2D(GL_FRAMEBUFFER, iAttachment, GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer, textureId, mipmapLevel);
}
++mColorAttachmentCount;
context.DrawBuffers(mColorAttachmentCount, COLOR_ATTACHMENTS);
DALI_ASSERT_DEBUG(context.CheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
- context.BindFramebuffer( GL_FRAMEBUFFER, 0 );
+ context.BindFramebuffer(GL_FRAMEBUFFER, 0);
}
-void FrameBuffer::AttachDepthTexture( Context& context, Render::Texture* texture, uint32_t mipmapLevel )
+void FrameBuffer::AttachDepthTexture(Context& context, Render::Texture* texture, uint32_t mipmapLevel)
{
- context.BindFramebuffer( GL_FRAMEBUFFER, mId );
+ context.BindFramebuffer(GL_FRAMEBUFFER, mId);
// Create a depth attachment.
- if( texture->GetType() == TextureType::TEXTURE_2D )
+ if(texture->GetType() == TextureType::TEXTURE_2D)
{
- context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texture->GetId(), mipmapLevel );
+ context.FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texture->GetId(), mipmapLevel);
}
- context.BindFramebuffer( GL_FRAMEBUFFER, 0 );
+ context.BindFramebuffer(GL_FRAMEBUFFER, 0);
}
-void FrameBuffer::AttachDepthStencilTexture( Context& context, Render::Texture* texture, uint32_t mipmapLevel )
+void FrameBuffer::AttachDepthStencilTexture(Context& context, Render::Texture* texture, uint32_t mipmapLevel)
{
- context.BindFramebuffer( GL_FRAMEBUFFER, mId );
+ context.BindFramebuffer(GL_FRAMEBUFFER, mId);
// Create a depth/stencil attachment.
- if( texture->GetType() == TextureType::TEXTURE_2D )
+ if(texture->GetType() == TextureType::TEXTURE_2D)
{
- context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, texture->GetId(), mipmapLevel );
+ context.FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, texture->GetId(), mipmapLevel);
}
- context.BindFramebuffer( GL_FRAMEBUFFER, 0 );
+ context.BindFramebuffer(GL_FRAMEBUFFER, 0);
}
-void FrameBuffer::Bind( Context& context )
+void FrameBuffer::Bind(Context& context)
{
- context.BindFramebuffer( GL_FRAMEBUFFER, mId );
+ context.BindFramebuffer(GL_FRAMEBUFFER, mId);
}
uint32_t FrameBuffer::GetWidth() const
return mHeight;
}
+} // namespace Render
-} //Render
-
-} //Internal
+} // namespace Internal
-} //Dali
+} // namespace Dali
#define DALI_INTERNAL_RENDER_FRAME_BUFFER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/rendering/frame-buffer.h>
#include <dali/devel-api/rendering/frame-buffer-devel.h>
+#include <dali/integration-api/gl-defines.h>
#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/render/renderers/render-sampler.h>
-#include <dali/integration-api/gl-defines.h>
+#include <dali/public-api/rendering/frame-buffer.h>
namespace Dali
{
class FrameBuffer
{
public:
-
/**
* Constructor
*/
- FrameBuffer( uint32_t width, uint32_t height, Mask attachments );
+ FrameBuffer(uint32_t width, uint32_t height, Mask attachments);
/**
* Destructor
* Creates a FrameBuffer object in the GPU.
* @param[in] context The GL context
*/
- virtual void Initialize( Context& context );
+ virtual void Initialize(Context& context);
/**
* Deletes the framebuffer object from the GPU
* @param[in] context The GL context
*/
- virtual void Destroy( Context& context );
+ virtual void Destroy(Context& context);
/**
* Called by RenderManager to inform the framebuffer that the context has been destroyed
* @brief Bind the framebuffer
* @param[in] context The GL context
*/
- virtual void Bind( Context& context );
+ virtual void Bind(Context& context);
/**
* @brief Get the width of the FrameBuffer
* @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
* @note A maximum of Dali::FrameBuffer::MAX_COLOR_ATTACHMENTS are supported.
*/
- void AttachColorTexture( Context& context, Render::Texture* texture, uint32_t mipmapLevel, uint32_t layer );
+ void AttachColorTexture(Context& context, Render::Texture* texture, uint32_t mipmapLevel, uint32_t layer);
/**
* @brief Attaches a texture for the depth rendering. This API is valid only for frame buffer with DEPTH attachments.
* @param[in] texture The texture that will be used as output when rendering
* @param[in] mipmapLevel The mipmap of the texture to be attached
*/
- void AttachDepthTexture( Context& context, Render::Texture* texture, uint32_t mipmapLevel );
+ void AttachDepthTexture(Context& context, Render::Texture* texture, uint32_t mipmapLevel);
/**
* @brief Attaches a texture for the depth/stencil rendering. This API is valid only for frame buffer with DEPTH_STENCIL attachments.
* @param[in] texture The texture that will be used as output when rendering
* @param[in] mipmapLevel The mipmap of the texture to be attached
*/
- void AttachDepthStencilTexture( Context& context, Render::Texture* texture, uint32_t mipmapLevel );
+ void AttachDepthStencilTexture(Context& context, Render::Texture* texture, uint32_t mipmapLevel);
/**
* @brief Get the number of textures bound to this frame buffer as color attachments.
* @return The number of color attachments.
*/
- uint8_t GetColorAttachmentCount() const { return mColorAttachmentCount; }
+ uint8_t GetColorAttachmentCount() const
+ {
+ return mColorAttachmentCount;
+ }
/**
* @brief Get the id (OpenGL handle) of the texture bound to this frame buffer as color attachment @a index.
* @return The texture id.
*/
- GLuint GetTextureId(uint8_t index) { return mTextureId[index]; };
+ GLuint GetTextureId(uint8_t index)
+ {
+ return mTextureId[index];
+ };
private:
-
/**
* @brief Undefined copy constructor. FrameBuffer cannot be copied
*/
- FrameBuffer( const FrameBuffer& rhs ) = delete;
+ FrameBuffer(const FrameBuffer& rhs) = delete;
/**
* @brief Undefined assignment operator. FrameBuffer cannot be copied
*/
- FrameBuffer& operator=( const FrameBuffer& rhs ) = delete;
+ FrameBuffer& operator=(const FrameBuffer& rhs) = delete;
private:
-
- GLuint mId;
- GLuint mTextureId[ Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS ];
- GLuint mDepthBuffer;
- GLuint mStencilBuffer;
+ GLuint mId;
+ GLuint mTextureId[Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS];
+ GLuint mDepthBuffer;
+ GLuint mStencilBuffer;
uint32_t mWidth;
uint32_t mHeight;
- uint8_t mColorAttachmentCount;
+ uint8_t mColorAttachmentCount;
};
} // namespace Render
} // namespace Dali
-
#endif // DALI_INTERNAL_RENDER_FRAME_BUFFER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Render
{
-
Geometry::Geometry()
: mIndices(),
mIndexBuffer(nullptr),
- mGeometryType( Dali::Geometry::TRIANGLES ),
+ mGeometryType(Dali::Geometry::TRIANGLES),
mIndicesChanged(false),
mHasBeenUpdated(false),
mAttributesChanged(true)
Geometry::~Geometry() = default;
-void Geometry::GlContextCreated( Context& context )
+void Geometry::GlContextCreated(Context& context)
{
}
{
}
-void Geometry::AddVertexBuffer( Render::VertexBuffer* vertexBuffer )
+void Geometry::AddVertexBuffer(Render::VertexBuffer* vertexBuffer)
{
- mVertexBuffers.PushBack( vertexBuffer );
+ mVertexBuffers.PushBack(vertexBuffer);
mAttributesChanged = true;
}
-void Geometry::SetIndexBuffer( Dali::Vector<uint16_t>& indices )
+void Geometry::SetIndexBuffer(Dali::Vector<uint16_t>& indices)
{
- mIndices.Swap( indices );
+ mIndices.Swap(indices);
mIndicesChanged = true;
}
-void Geometry::RemoveVertexBuffer( const Render::VertexBuffer* vertexBuffer )
+void Geometry::RemoveVertexBuffer(const Render::VertexBuffer* vertexBuffer)
{
const auto&& end = mVertexBuffers.End();
- for( auto&& iter = mVertexBuffers.Begin(); iter != end; ++iter )
+ for(auto&& iter = mVertexBuffers.Begin(); iter != end; ++iter)
{
- if( *iter == vertexBuffer )
+ if(*iter == vertexBuffer)
{
//This will delete the gpu buffer associated to the RenderVertexBuffer if there is one
- mVertexBuffers.Remove( iter );
+ mVertexBuffers.Remove(iter);
mAttributesChanged = true;
break;
}
}
}
-void Geometry::GetAttributeLocationFromProgram( Vector<GLint>& attributeLocation, Program& program, BufferIndex bufferIndex ) const
+void Geometry::GetAttributeLocationFromProgram(Vector<GLint>& attributeLocation, Program& program, BufferIndex bufferIndex) const
{
attributeLocation.Clear();
- for( auto&& vertexBuffer : mVertexBuffers )
+ for(auto&& vertexBuffer : mVertexBuffers)
{
const uint32_t attributeCount = vertexBuffer->GetAttributeCount();
- for( uint32_t j = 0; j < attributeCount; ++j )
+ for(uint32_t j = 0; j < attributeCount; ++j)
{
- auto attributeName = vertexBuffer->GetAttributeName( j );
- uint32_t index = program.RegisterCustomAttribute( attributeName );
- GLint location = program.GetCustomAttributeLocation( index );
+ auto attributeName = vertexBuffer->GetAttributeName(j);
+ uint32_t index = program.RegisterCustomAttribute(attributeName);
+ GLint location = program.GetCustomAttributeLocation(index);
- if( -1 == location )
+ if(-1 == location)
{
- DALI_LOG_WARNING( "Attribute not found in the shader: %s\n", attributeName.GetCString() );
+ DALI_LOG_WARNING("Attribute not found in the shader: %s\n", attributeName.GetCString());
}
- attributeLocation.PushBack( location );
+ attributeLocation.PushBack(location);
}
}
}
void Geometry::OnRenderFinished()
{
- mHasBeenUpdated = false;
+ mHasBeenUpdated = false;
mAttributesChanged = false;
}
-void Geometry::Upload( Context& context )
+void Geometry::Upload(Context& context)
{
- if( !mHasBeenUpdated )
+ if(!mHasBeenUpdated)
{
// Update buffers
- if( mIndicesChanged )
+ if(mIndicesChanged)
{
- if( mIndices.Empty() )
+ if(mIndices.Empty())
{
mIndexBuffer = nullptr;
}
else
{
- if ( mIndexBuffer == nullptr )
+ if(mIndexBuffer == nullptr)
{
- mIndexBuffer = new GpuBuffer( context );
+ mIndexBuffer = new GpuBuffer(context);
}
- uint32_t bufferSize = static_cast<uint32_t>( sizeof( uint16_t ) * mIndices.Size() );
- mIndexBuffer->UpdateDataBuffer( context, bufferSize, &mIndices[0], GpuBuffer::STATIC_DRAW, GpuBuffer::ELEMENT_ARRAY_BUFFER );
+ uint32_t bufferSize = static_cast<uint32_t>(sizeof(uint16_t) * mIndices.Size());
+ mIndexBuffer->UpdateDataBuffer(context, bufferSize, &mIndices[0], GpuBuffer::STATIC_DRAW, GpuBuffer::ELEMENT_ARRAY_BUFFER);
}
mIndicesChanged = false;
}
- for( auto&& buffer : mVertexBuffers )
+ for(auto&& buffer : mVertexBuffers)
{
- if( !buffer->Update( context ) )
+ if(!buffer->Update(context))
{
//Vertex buffer is not ready ( Size, data or format has not been specified yet )
return;
}
void Geometry::Draw(
- Context& context,
- BufferIndex bufferIndex,
- Vector<GLint>& attributeLocation,
- uint32_t elementBufferOffset,
- uint32_t elementBufferCount )
+ Context& context,
+ BufferIndex bufferIndex,
+ Vector<GLint>& attributeLocation,
+ uint32_t elementBufferOffset,
+ uint32_t elementBufferCount)
{
//Bind buffers to attribute locations
- uint32_t base = 0u;
- const uint32_t vertexBufferCount = static_cast<uint32_t>( mVertexBuffers.Count() );
- for( uint32_t i = 0; i < vertexBufferCount; ++i )
+ uint32_t base = 0u;
+ const uint32_t vertexBufferCount = static_cast<uint32_t>(mVertexBuffers.Count());
+ for(uint32_t i = 0; i < vertexBufferCount; ++i)
{
- mVertexBuffers[i]->BindBuffer( context, GpuBuffer::ARRAY_BUFFER );
- base += mVertexBuffers[i]->EnableVertexAttributes( context, attributeLocation, base );
+ mVertexBuffers[i]->BindBuffer(context, GpuBuffer::ARRAY_BUFFER);
+ base += mVertexBuffers[i]->EnableVertexAttributes(context, attributeLocation, base);
}
uint32_t numIndices(0u);
intptr_t firstIndexOffset(0u);
- if( mIndexBuffer )
+ if(mIndexBuffer)
{
- numIndices = static_cast<uint32_t>( mIndices.Size() );
+ numIndices = static_cast<uint32_t>(mIndices.Size());
- if( elementBufferOffset != 0u )
+ if(elementBufferOffset != 0u)
{
- elementBufferOffset = (elementBufferOffset >= numIndices ) ? numIndices - 1 : elementBufferOffset;
- firstIndexOffset = elementBufferOffset * sizeof(GLushort);
+ elementBufferOffset = (elementBufferOffset >= numIndices) ? numIndices - 1 : elementBufferOffset;
+ firstIndexOffset = elementBufferOffset * sizeof(GLushort);
numIndices -= elementBufferOffset;
}
- if( elementBufferCount != 0u )
+ if(elementBufferCount != 0u)
{
- numIndices = std::min( elementBufferCount, numIndices );
+ numIndices = std::min(elementBufferCount, numIndices);
}
}
}
//Draw call
- if( mIndexBuffer && geometryGLType != GL_POINTS )
+ if(mIndexBuffer && geometryGLType != GL_POINTS)
{
//Indexed draw call
- mIndexBuffer->Bind( context, GpuBuffer::ELEMENT_ARRAY_BUFFER );
+ mIndexBuffer->Bind(context, GpuBuffer::ELEMENT_ARRAY_BUFFER);
// numIndices truncated, no value loss happening in practice
- context.DrawElements( geometryGLType, static_cast<GLsizei>( numIndices ), GL_UNSIGNED_SHORT, reinterpret_cast<void*>( firstIndexOffset ) );
+ context.DrawElements(geometryGLType, static_cast<GLsizei>(numIndices), GL_UNSIGNED_SHORT, reinterpret_cast<void*>(firstIndexOffset));
}
else
{
//Unindex draw call
GLsizei numVertices(0u);
- if( vertexBufferCount > 0 )
+ if(vertexBufferCount > 0)
{
// truncated, no value loss happening in practice
- numVertices = static_cast<GLsizei>( mVertexBuffers[0]->GetElementCount() );
+ numVertices = static_cast<GLsizei>(mVertexBuffers[0]->GetElementCount());
}
- context.DrawArrays( geometryGLType, 0, numVertices );
+ context.DrawArrays(geometryGLType, 0, numVertices);
}
//Disable attributes
- for( auto&& attribute : attributeLocation )
+ for(auto&& attribute : attributeLocation)
{
- if( attribute != -1 )
+ if(attribute != -1)
{
- context.DisableVertexAttributeArray( static_cast<GLuint>( attribute ) );
+ context.DisableVertexAttributeArray(static_cast<GLuint>(attribute));
}
}
}
-} // namespace SceneGraph
+} // namespace Render
} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_RENDER_GEOMETRY_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-vector.h>
-#include <dali/public-api/rendering/geometry.h>
#include <dali/devel-api/common/owner-container.h>
-#include <dali/internal/common/owner-pointer.h>
-#include <dali/internal/common/buffer-index.h>
-#include <dali/internal/common/owner-pointer.h>
#include <dali/integration-api/gl-abstraction.h>
#include <dali/integration-api/gl-defines.h>
+#include <dali/internal/common/buffer-index.h>
+#include <dali/internal/common/owner-pointer.h>
+#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/rendering/geometry.h>
namespace Dali
{
/**
* Called on Gl Context created
*/
- void GlContextCreated( Context& context );
+ void GlContextCreated(Context& context);
/**
* Called on Gl Context destroyed.
* Adds a property buffer to the geometry
* @param[in] dataProvider The VertexBuffer data provider
*/
- void AddVertexBuffer( Render::VertexBuffer* vertexBuffer );
+ void AddVertexBuffer(Render::VertexBuffer* vertexBuffer);
/**
* Set the data for the index buffer to be used by the geometry
* @param[in] indices A vector containing the indices
*/
- void SetIndexBuffer( Dali::Vector<uint16_t>& indices );
+ void SetIndexBuffer(Dali::Vector<uint16_t>& indices);
/**
* Removes a VertexBuffer from the geometry
* @param[in] vertexBuffer The property buffer to be removed
*/
- void RemoveVertexBuffer( const Render::VertexBuffer* vertexBuffer );
+ void RemoveVertexBuffer(const Render::VertexBuffer* vertexBuffer);
/**
* Gets the attribute locations on the shader for the attributes defined in the geometry RenderBuffers
* @param[in] program The program
* @param[in] bufferIndex The current buffer index
*/
- void GetAttributeLocationFromProgram( Vector<GLint>& attributeLocation, Program& program, BufferIndex bufferIndex ) const;
+ void GetAttributeLocationFromProgram(Vector<GLint>& attributeLocation, Program& program, BufferIndex bufferIndex) const;
/**
* Called from RenderManager to notify the geometry that current rendering pass has finished.
* Sets the geometry type
* @param[in] type The new geometry type
*/
- void SetType( Type type )
+ void SetType(Type type)
{
mGeometryType = type;
}
* Upload the geometry if it has changed
* @param[in] context The GL context
*/
- void Upload( Context& context );
+ void Upload(Context& context);
/**
* Set up the attributes and perform the Draw call corresponding to the geometry type
* @param[in] elementBufferOffset The index of first element to draw if index buffer bound
* @param[in] elementBufferCount Number of elements to draw if index buffer bound, uses whole buffer when 0
*/
- void Draw(Context& context,
- BufferIndex bufferIndex,
+ void Draw(Context& context,
+ BufferIndex bufferIndex,
Vector<GLint>& attributeLocation,
- uint32_t elementBufferOffset,
- uint32_t elementBufferCount );
+ uint32_t elementBufferOffset,
+ uint32_t elementBufferCount);
private:
-
// VertexBuffers
- Vector< Render::VertexBuffer* > mVertexBuffers;
+ Vector<Render::VertexBuffer*> mVertexBuffers;
- Dali::Vector< uint16_t > mIndices;
- OwnerPointer< GpuBuffer > mIndexBuffer;
- Type mGeometryType;
+ Dali::Vector<uint16_t> mIndices;
+ OwnerPointer<GpuBuffer> mIndexBuffer;
+ Type mGeometryType;
// Booleans
bool mIndicesChanged : 1;
#define DALI_INTERNAL_RENDER_RENDERER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/math/matrix.h>
-#include <dali/public-api/math/vector4.h>
-#include <dali/public-api/rendering/texture-set.h>
+#include <dali/integration-api/debug.h>
#include <dali/internal/common/blending-options.h>
#include <dali/internal/common/message.h>
#include <dali/internal/common/type-abstraction-enums.h>
#include <dali/internal/render/gl-resources/gl-resource-owner.h>
#include <dali/internal/render/renderers/render-geometry.h>
#include <dali/internal/update/manager/render-instruction-processor.h>
-#include <dali/integration-api/debug.h>
+#include <dali/public-api/math/matrix.h>
+#include <dali/public-api/math/vector4.h>
+#include <dali/public-api/rendering/texture-set.h>
namespace Dali
{
-
namespace Internal
{
class Context;
class NodeDataProvider;
class RenderInstruction; //for relfection effect
-}
+} // namespace SceneGraph
namespace Render
{
-
/**
* Renderers are used to render meshes
* These objects are used during RenderManager::Render(), so properties modified during
class Renderer : public GlResourceOwner
{
public:
-
/**
* @brief Struct to encapsulate stencil parameters required for control of the stencil buffer.
*/
struct StencilParameters
{
- StencilParameters( RenderMode::Type renderMode, StencilFunction::Type stencilFunction, int stencilFunctionMask,
- int stencilFunctionReference, int stencilMask, StencilOperation::Type stencilOperationOnFail,
- StencilOperation::Type stencilOperationOnZFail, StencilOperation::Type stencilOperationOnZPass )
- : stencilFunctionMask ( stencilFunctionMask ),
- stencilFunctionReference ( stencilFunctionReference ),
- stencilMask ( stencilMask ),
- renderMode ( renderMode ),
- stencilFunction ( stencilFunction ),
- stencilOperationOnFail ( stencilOperationOnFail ),
- stencilOperationOnZFail ( stencilOperationOnZFail ),
- stencilOperationOnZPass ( stencilOperationOnZPass )
+ StencilParameters(RenderMode::Type renderMode, StencilFunction::Type stencilFunction, int stencilFunctionMask, int stencilFunctionReference, int stencilMask, StencilOperation::Type stencilOperationOnFail, StencilOperation::Type stencilOperationOnZFail, StencilOperation::Type stencilOperationOnZPass)
+ : stencilFunctionMask(stencilFunctionMask),
+ stencilFunctionReference(stencilFunctionReference),
+ stencilMask(stencilMask),
+ renderMode(renderMode),
+ stencilFunction(stencilFunction),
+ stencilOperationOnFail(stencilOperationOnFail),
+ stencilOperationOnZFail(stencilOperationOnZFail),
+ stencilOperationOnZPass(stencilOperationOnZPass)
{
}
- int stencilFunctionMask; ///< The stencil function mask
- int stencilFunctionReference; ///< The stencil function reference
- int stencilMask; ///< The stencil mask
- RenderMode::Type renderMode:4; ///< The render mode
- StencilFunction::Type stencilFunction:4; ///< The stencil function
- StencilOperation::Type stencilOperationOnFail:4; ///< The stencil operation for stencil test fail
- StencilOperation::Type stencilOperationOnZFail:4; ///< The stencil operation for depth test fail
- StencilOperation::Type stencilOperationOnZPass:4; ///< The stencil operation for depth test pass
+ int stencilFunctionMask; ///< The stencil function mask
+ int stencilFunctionReference; ///< The stencil function reference
+ int stencilMask; ///< The stencil mask
+ RenderMode::Type renderMode : 4; ///< The render mode
+ StencilFunction::Type stencilFunction : 4; ///< The stencil function
+ StencilOperation::Type stencilOperationOnFail : 4; ///< The stencil operation for stencil test fail
+ StencilOperation::Type stencilOperationOnZFail : 4; ///< The stencil operation for depth test fail
+ StencilOperation::Type stencilOperationOnZPass : 4; ///< The stencil operation for depth test pass
};
/**
* @param[in] depthFunction Depth function
* @param[in] stencilParameters Struct containing all stencil related options
*/
- static Renderer* New( SceneGraph::RenderDataProvider* dataProviders,
- Render::Geometry* geometry,
- uint32_t blendingBitmask,
- const Vector4& blendColor,
- FaceCullingMode::Type faceCullingMode,
- bool preMultipliedAlphaEnabled,
- DepthWriteMode::Type depthWriteMode,
- DepthTestMode::Type depthTestMode,
- DepthFunction::Type depthFunction,
- StencilParameters& stencilParameters );
+ static Renderer* New(SceneGraph::RenderDataProvider* dataProviders,
+ Render::Geometry* geometry,
+ uint32_t blendingBitmask,
+ const Vector4& blendColor,
+ FaceCullingMode::Type faceCullingMode,
+ bool preMultipliedAlphaEnabled,
+ DepthWriteMode::Type depthWriteMode,
+ DepthTestMode::Type depthTestMode,
+ DepthFunction::Type depthFunction,
+ StencilParameters& stencilParameters);
/**
* Constructor.
* @param[in] depthFunction Depth function
* @param[in] stencilParameters Struct containing all stencil related options
*/
- Renderer( SceneGraph::RenderDataProvider* dataProviders,
- Render::Geometry* geometry,
- uint32_t blendingBitmask,
- const Vector4& blendColor,
- FaceCullingMode::Type faceCullingMode,
- bool preMultipliedAlphaEnabled,
- DepthWriteMode::Type depthWriteMode,
- DepthTestMode::Type depthTestMode,
- DepthFunction::Type depthFunction,
- StencilParameters& stencilParameters );
+ Renderer(SceneGraph::RenderDataProvider* dataProviders,
+ Render::Geometry* geometry,
+ uint32_t blendingBitmask,
+ const Vector4& blendColor,
+ FaceCullingMode::Type faceCullingMode,
+ bool preMultipliedAlphaEnabled,
+ DepthWriteMode::Type depthWriteMode,
+ DepthTestMode::Type depthTestMode,
+ DepthFunction::Type depthFunction,
+ StencilParameters& stencilParameters);
/**
* Change the geometry used by the renderer
* @param[in] geometry The new geometry
*/
- void SetGeometry( Render::Geometry* geometry );
+ void SetGeometry(Render::Geometry* geometry);
- void SetDrawCommands( Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size );
+ void SetDrawCommands(Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size);
/**
* @brief Returns a reference to an array of draw commands
* This is called when the renderer is inside render thread
* @param[in] context Context used by the renderer
*/
- void Initialize( Context& context );
+ void Initialize(Context& context);
/**
* Destructor
* Set the face-culling mode.
* @param[in] mode The face-culling mode.
*/
- void SetFaceCullingMode( FaceCullingMode::Type mode );
+ void SetFaceCullingMode(FaceCullingMode::Type mode);
/**
* Set the bitmask for blending options
* @param[in] bitmask A bitmask of blending options.
*/
- void SetBlendingBitMask( uint32_t bitmask );
+ void SetBlendingBitMask(uint32_t bitmask);
/**
* Set the blend color for blending options
* @param[in] blendColor The blend color to pass to GL
*/
- void SetBlendColor( const Vector4& color );
+ void SetBlendColor(const Vector4& color);
/**
* Set the first element index to draw by the indexed draw
* @param[in] firstElement index of first element to draw
*/
- void SetIndexedDrawFirstElement( uint32_t firstElement );
+ void SetIndexedDrawFirstElement(uint32_t firstElement);
/**
* Set the number of elements to draw by the indexed draw
* @param[in] elementsCount number of elements to draw
*/
- void SetIndexedDrawElementsCount( uint32_t elementsCount );
+ void SetIndexedDrawElementsCount(uint32_t elementsCount);
/**
* @brief Set whether the Pre-multiplied Alpha Blending is required
*
* @param[in] preMultipled whether alpha is pre-multiplied.
*/
- void EnablePreMultipliedAlpha( bool preMultipled );
+ void EnablePreMultipliedAlpha(bool preMultipled);
/**
* Sets the depth write mode
* @param[in] depthWriteMode The depth write mode
*/
- void SetDepthWriteMode( DepthWriteMode::Type depthWriteMode );
+ void SetDepthWriteMode(DepthWriteMode::Type depthWriteMode);
/**
* Query the Renderer's depth write mode
* Sets the depth test mode
* @param[in] depthTestMode The depth test mode
*/
- void SetDepthTestMode( DepthTestMode::Type depthTestMode );
+ void SetDepthTestMode(DepthTestMode::Type depthTestMode);
/**
* Query the Renderer's depth test mode
* Sets the depth function
* @param[in] depthFunction The depth function
*/
- void SetDepthFunction( DepthFunction::Type depthFunction );
+ void SetDepthFunction(DepthFunction::Type depthFunction);
/**
* Query the Renderer's depth function
* Sets the render mode
* @param[in] renderMode The render mode
*/
- void SetRenderMode( RenderMode::Type mode );
+ void SetRenderMode(RenderMode::Type mode);
/**
* Gets the render mode
* Sets the stencil function
* @param[in] stencilFunction The stencil function
*/
- void SetStencilFunction( StencilFunction::Type stencilFunction );
+ void SetStencilFunction(StencilFunction::Type stencilFunction);
/**
* Gets the stencil function
* Sets the stencil function mask
* @param[in] stencilFunctionMask The stencil function mask
*/
- void SetStencilFunctionMask( int stencilFunctionMask );
+ void SetStencilFunctionMask(int stencilFunctionMask);
/**
* Gets the stencil function mask
* Sets the stencil function reference
* @param[in] stencilFunctionReference The stencil function reference
*/
- void SetStencilFunctionReference( int stencilFunctionReference );
+ void SetStencilFunctionReference(int stencilFunctionReference);
/**
* Gets the stencil function reference
* Sets the stencil mask
* @param[in] stencilMask The stencil mask
*/
- void SetStencilMask( int stencilMask );
+ void SetStencilMask(int stencilMask);
/**
* Gets the stencil mask
* Sets the stencil operation for when the stencil test fails
* @param[in] stencilOperationOnFail The stencil operation
*/
- void SetStencilOperationOnFail( StencilOperation::Type stencilOperationOnFail );
+ void SetStencilOperationOnFail(StencilOperation::Type stencilOperationOnFail);
/**
* Gets the stencil operation for when the stencil test fails
* Sets the stencil operation for when the depth test fails
* @param[in] stencilOperationOnZFail The stencil operation
*/
- void SetStencilOperationOnZFail( StencilOperation::Type stencilOperationOnZFail );
+ void SetStencilOperationOnZFail(StencilOperation::Type stencilOperationOnZFail);
/**
* Gets the stencil operation for when the depth test fails
* Sets the stencil operation for when the depth test passes
* @param[in] stencilOperationOnZPass The stencil operation
*/
- void SetStencilOperationOnZPass( StencilOperation::Type stencilOperationOnZPass );
+ void SetStencilOperationOnZPass(StencilOperation::Type stencilOperationOnZPass);
/**
* Gets the stencil operation for when the depth test passes
* Called to upload during RenderManager::Render().
* @param[in] context The context used for uploading
*/
- void Upload( Context& context );
+ void Upload(Context& context);
/**
* Called to render during RenderManager::Render().
* @param[in] instruction. for use case like reflection where CullFace needs to be adjusted
*/
- void Render( Context& context,
- BufferIndex bufferIndex,
- const SceneGraph::NodeDataProvider& node,
- const Matrix& modelMatrix,
- const Matrix& modelViewMatrix,
- const Matrix& viewMatrix,
- const Matrix& projectionMatrix,
- const Vector3& size,
- bool blend,
- Vector<GLuint>& boundTextures,
- const Dali::Internal::SceneGraph::RenderInstruction& instruction,
- uint32_t queueIndex );
+ void Render(Context& context,
+ BufferIndex bufferIndex,
+ const SceneGraph::NodeDataProvider& node,
+ const Matrix& modelMatrix,
+ const Matrix& modelViewMatrix,
+ const Matrix& viewMatrix,
+ const Matrix& projectionMatrix,
+ const Vector3& size,
+ bool blend,
+ Vector<GLuint>& boundTextures,
+ const Dali::Internal::SceneGraph::RenderInstruction& instruction,
+ uint32_t queueIndex);
/**
* Write the renderer's sort attributes to the passed in reference
* @param[in] bufferIndex The current update buffer index.
* @param[out] sortAttributes
*/
- void SetSortAttributes( BufferIndex bufferIndex, SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes ) const;
+ void SetSortAttributes(BufferIndex bufferIndex, SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes) const;
/**
* Sets the flag indicating whether shader changed.
*
* @param[in] value True if shader changed
*/
- void SetShaderChanged( bool value );
+ void SetShaderChanged(bool value);
/**
* Check if the renderer attributes/uniforms are updated and returns the flag
bool Updated(BufferIndex bufferIndex, const SceneGraph::NodeDataProvider* node);
private:
-
struct UniformIndexMap;
// Undefined
- Renderer( const Renderer& );
+ Renderer(const Renderer&);
// Undefined
- Renderer& operator=( const Renderer& rhs );
+ Renderer& operator=(const Renderer& rhs);
/**
* Sets blending options
* @param context to use
* @param blend Wheter blending should be enabled or not
*/
- void SetBlending( Context& context, bool blend );
+ void SetBlending(Context& context, bool blend);
/**
* Set the uniforms from properties according to the uniform map
* @param[in] size The size of the renderer
* @param[in] program The shader program on which to set the uniforms.
*/
- void SetUniforms( BufferIndex bufferIndex, const SceneGraph::NodeDataProvider& node, const Vector3& size, Program& program );
+ void SetUniforms(BufferIndex bufferIndex, const SceneGraph::NodeDataProvider& node, const Vector3& size, Program& program);
/**
* Set the program uniform in the map from the mapped property
* @param[in] program The shader program
* @param[in] map The uniform
*/
- void SetUniformFromProperty( BufferIndex bufferIndex, Program& program, UniformIndexMap& map );
+ void SetUniformFromProperty(BufferIndex bufferIndex, Program& program, UniformIndexMap& map);
/**
* Bind the textures and setup the samplers
* @param[in] boundTextures The textures bound for rendering
* @return False if create or bind failed, true if success.
*/
- bool BindTextures( Context& context, Program& program, Vector<GLuint>& boundTextures );
+ bool BindTextures(Context& context, Program& program, Vector<GLuint>& boundTextures);
private:
+ OwnerPointer<SceneGraph::RenderDataProvider> mRenderDataProvider;
- OwnerPointer< SceneGraph::RenderDataProvider > mRenderDataProvider;
-
- Context* mContext;
- Render::Geometry* mGeometry;
+ Context* mContext;
+ Render::Geometry* mGeometry;
struct UniformIndexMap
{
- uint32_t uniformIndex; ///< The index of the cached location in the Program
- const PropertyInputImpl* propertyValue;
+ uint32_t uniformIndex; ///< The index of the cached location in the Program
+ const PropertyInputImpl* propertyValue;
};
using UniformIndexMappings = Dali::Vector<UniformIndexMap>;
- UniformIndexMappings mUniformIndexMap;
- Vector<GLint> mAttributesLocation;
+ UniformIndexMappings mUniformIndexMap;
+ Vector<GLint> mAttributesLocation;
- uint64_t mUniformsHash;
+ uint64_t mUniformsHash;
- StencilParameters mStencilParameters; ///< Struct containing all stencil related options
- BlendingOptions mBlendingOptions; ///< Blending options including blend color, blend func and blend equation
+ StencilParameters mStencilParameters; ///< Struct containing all stencil related options
+ BlendingOptions mBlendingOptions; ///< Blending options including blend color, blend func and blend equation
- uint32_t mIndexedDrawFirstElement; ///< Offset of first element to draw
- uint32_t mIndexedDrawElementsCount; ///< Number of elements to draw
-
- DepthFunction::Type mDepthFunction:4; ///< The depth function
- FaceCullingMode::Type mFaceCullingMode:3; ///< The mode of face culling
- DepthWriteMode::Type mDepthWriteMode:3; ///< The depth write mode
- DepthTestMode::Type mDepthTestMode:3; ///< The depth test mode
- bool mUpdateAttributesLocation:1; ///< Indicates attribute locations have changed
- bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
- bool mShaderChanged:1; ///< Flag indicating the shader changed and uniform maps have to be updated
- bool mUpdated:1;
+ uint32_t mIndexedDrawFirstElement; ///< Offset of first element to draw
+ uint32_t mIndexedDrawElementsCount; ///< Number of elements to draw
+ DepthFunction::Type mDepthFunction : 4; ///< The depth function
+ FaceCullingMode::Type mFaceCullingMode : 3; ///< The mode of face culling
+ DepthWriteMode::Type mDepthWriteMode : 3; ///< The depth write mode
+ DepthTestMode::Type mDepthTestMode : 3; ///< The depth test mode
+ bool mUpdateAttributesLocation : 1; ///< Indicates attribute locations have changed
+ bool mPremultipledAlphaEnabled : 1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
+ bool mShaderChanged : 1; ///< Flag indicating the shader changed and uniform maps have to be updated
+ bool mUpdated : 1;
std::vector<Dali::DevelRenderer::DrawCommand> mDrawCommands; // Devel stuff
};
-} // namespace SceneGraph
+} // namespace Render
} // namespace Internal
#define DALI_INTERNAL_RENDER_SAMPLER_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Render
{
-
struct Sampler
{
using FilterMode = Dali::FilterMode::Type;
* Constructor
*/
Sampler()
- :mMinificationFilter(FilterMode::DEFAULT),
- mMagnificationFilter(FilterMode::DEFAULT),
- mSWrapMode(WrapMode::DEFAULT),
- mTWrapMode(WrapMode::DEFAULT),
- mRWrapMode(WrapMode::DEFAULT)
- {}
+ : mMinificationFilter(FilterMode::DEFAULT),
+ mMagnificationFilter(FilterMode::DEFAULT),
+ mSWrapMode(WrapMode::DEFAULT),
+ mTWrapMode(WrapMode::DEFAULT),
+ mRWrapMode(WrapMode::DEFAULT)
+ {
+ }
/**
* Destructor
bool operator==(const Sampler& rhs) const
{
- return ( ( mMinificationFilter == rhs.mMinificationFilter ) &&
- ( mMagnificationFilter == rhs.mMagnificationFilter ) &&
- ( mSWrapMode == rhs.mSWrapMode ) &&
- ( mTWrapMode == rhs.mTWrapMode ) &&
- ( mRWrapMode == rhs.mRWrapMode ) );
+ return ((mMinificationFilter == rhs.mMinificationFilter) &&
+ (mMagnificationFilter == rhs.mMagnificationFilter) &&
+ (mSWrapMode == rhs.mSWrapMode) &&
+ (mTWrapMode == rhs.mTWrapMode) &&
+ (mRWrapMode == rhs.mRWrapMode));
}
bool operator!=(const Sampler& rhs) const
return !(*this == rhs);
}
- FilterMode mMinificationFilter : 4; ///< The minify filter
- FilterMode mMagnificationFilter : 4; ///< The magnify filter
- WrapMode mSWrapMode : 4; ///< The horizontal wrap mode
- WrapMode mTWrapMode : 4; ///< The vertical wrap mode
- WrapMode mRWrapMode : 4; ///< The vertical wrap mode
+ FilterMode mMinificationFilter : 4; ///< The minify filter
+ FilterMode mMagnificationFilter : 4; ///< The magnify filter
+ WrapMode mSWrapMode : 4; ///< The horizontal wrap mode
+ WrapMode mTWrapMode : 4; ///< The vertical wrap mode
+ WrapMode mRWrapMode : 4; ///< The vertical wrap mode
};
} // namespace Render
} // namespace Dali
-
#endif // DALI_INTERNAL_RENDER_SAMPLER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/render/renderers/render-texture.h>
// EXTERNAL INCLUDES
-#include <math.h> //floor, log2
+#include <math.h> //floor, log2
// INTERNAL INCLUDES
-
namespace Dali
{
namespace Internal
{
namespace Render
{
-
namespace
{
-
// These match the GL specification
const GLint GL_MINIFY_DEFAULT = GL_NEAREST_MIPMAP_LINEAR;
const GLint GL_MAGNIFY_DEFAULT = GL_LINEAR;
-const GLint GL_WRAP_DEFAULT = GL_CLAMP_TO_EDGE;
+const GLint GL_WRAP_DEFAULT = GL_CLAMP_TO_EDGE;
// These are the Dali defaults
const GLint DALI_MINIFY_DEFAULT = GL_LINEAR;
* @param[in] glDefault The filter mode to use if filterMode is NONE.
* @return the equivalent GL filter mode.
*/
-GLint FilterModeToGL( FilterMode::Type filterMode, GLint daliDefault, GLint glDefault )
+GLint FilterModeToGL(FilterMode::Type filterMode, GLint daliDefault, GLint glDefault)
{
- switch( filterMode )
+ switch(filterMode)
{
case FilterMode::NEAREST:
{
* @param[in] defaultWrapMode The mode to use if WrapMode is Default
* @return The equivalent GL wrap mode
*/
-GLint WrapModeToGL( WrapMode::Type wrapMode, GLint defaultWrapMode )
+GLint WrapModeToGL(WrapMode::Type wrapMode, GLint defaultWrapMode)
{
- switch( wrapMode )
+ switch(wrapMode)
{
case WrapMode::CLAMP_TO_EDGE:
{
* @param[out] glInternalFormat The gl internal format.
* @param[out] pixelDataType The data type of the pixel data.
*/
-void PixelFormatToGl( Pixel::Format pixelFormat, GLenum& glFormat, GLint& glInternalFormat, GLenum& pixelDataType )
+void PixelFormatToGl(Pixel::Format pixelFormat, GLenum& glFormat, GLint& glInternalFormat, GLenum& pixelDataType)
{
// Compressed textures have no pixelDataType, so init to an invalid value:
- pixelDataType = -1;
+ pixelDataType = -1;
- switch( pixelFormat )
+ switch(pixelFormat)
{
case Pixel::A8:
{
pixelDataType = GL_UNSIGNED_BYTE;
- glFormat= GL_ALPHA;
+ glFormat = GL_ALPHA;
break;
}
case Pixel::L8:
{
pixelDataType = GL_UNSIGNED_BYTE;
- glFormat= GL_LUMINANCE;
+ glFormat = GL_LUMINANCE;
break;
}
case Pixel::LA88:
{
pixelDataType = GL_UNSIGNED_BYTE;
- glFormat= GL_LUMINANCE_ALPHA;
+ glFormat = GL_LUMINANCE_ALPHA;
break;
}
case Pixel::RGB565:
{
pixelDataType = GL_UNSIGNED_SHORT_5_6_5;
- glFormat= GL_RGB;
+ glFormat = GL_RGB;
break;
}
case Pixel::BGR565:
{
DALI_LOG_ERROR("Pixel format BGR565 is not supported by GLES.\n");
- pixelDataType = GL_UNSIGNED_SHORT_5_6_5;
+ pixelDataType = GL_UNSIGNED_SHORT_5_6_5;
#ifdef _ARCH_ARM_
- glFormat= GL_BGRA_EXT; // alpha is reserved but not used
+ glFormat = GL_BGRA_EXT; // alpha is reserved but not used
#else
- glFormat= GL_RGBA; // alpha is reserved but not used
+ glFormat = GL_RGBA; // alpha is reserved but not used
#endif
break;
}
case Pixel::RGBA4444:
{
pixelDataType = GL_UNSIGNED_SHORT_4_4_4_4;
- glFormat= GL_RGBA;
+ glFormat = GL_RGBA;
break;
}
case Pixel::BGRA4444:
{
DALI_LOG_ERROR("Pixel format BGRA4444 is not supported by GLES.\n");
- pixelDataType = GL_UNSIGNED_SHORT_4_4_4_4;
+ pixelDataType = GL_UNSIGNED_SHORT_4_4_4_4;
#ifdef _ARCH_ARM_
- glFormat= GL_BGRA_EXT; // alpha is reserved but not used
+ glFormat = GL_BGRA_EXT; // alpha is reserved but not used
#else
- glFormat= GL_RGBA; // alpha is reserved but not used
+ glFormat = GL_RGBA; // alpha is reserved but not used
#endif
break;
}
case Pixel::RGBA5551:
{
pixelDataType = GL_UNSIGNED_SHORT_5_5_5_1;
- glFormat= GL_RGBA;
+ glFormat = GL_RGBA;
break;
}
case Pixel::BGRA5551:
{
DALI_LOG_ERROR("Pixel format BGRA5551 is not supported by GLES.\n");
- pixelDataType = GL_UNSIGNED_SHORT_5_5_5_1;
+ pixelDataType = GL_UNSIGNED_SHORT_5_5_5_1;
#ifdef _ARCH_ARM_
- glFormat= GL_BGRA_EXT; // alpha is reserved but not used
+ glFormat = GL_BGRA_EXT; // alpha is reserved but not used
#else
- glFormat= GL_RGBA; // alpha is reserved but not used
+ glFormat = GL_RGBA; // alpha is reserved but not used
#endif
break;
}
case Pixel::RGB888:
{
pixelDataType = GL_UNSIGNED_BYTE;
- glFormat= GL_RGB;
+ glFormat = GL_RGB;
break;
}
case Pixel::RGB8888:
{
pixelDataType = GL_UNSIGNED_BYTE;
- glFormat= GL_RGBA; // alpha is reserved but not used
+ glFormat = GL_RGBA; // alpha is reserved but not used
break;
}
{
pixelDataType = GL_UNSIGNED_BYTE;
#ifdef GL_BGRA_EXT
- glFormat= GL_BGRA_EXT; // alpha is reserved but not used
+ glFormat = GL_BGRA_EXT; // alpha is reserved but not used
#else
- glFormat= GL_RGBA; // alpha is reserved but not used
+ glFormat = GL_RGBA; // alpha is reserved but not used
#endif
- break;
+ break;
}
case Pixel::RGBA8888:
{
pixelDataType = GL_UNSIGNED_BYTE;
- glFormat= GL_RGBA;
+ glFormat = GL_RGBA;
break;
}
{
pixelDataType = GL_UNSIGNED_BYTE;
#ifdef GL_BGRA_EXT
- glFormat= GL_BGRA_EXT; // alpha is reserved but not used
+ glFormat = GL_BGRA_EXT; // alpha is reserved but not used
#else
- glFormat= GL_RGBA; // alpha is reserved but not used
+ glFormat = GL_RGBA; // alpha is reserved but not used
#endif
break;
}
// GLES 2 extension compressed formats:
case Pixel::COMPRESSED_RGB8_ETC1:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB8_ETC1.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB8_ETC1.\n");
glFormat = 0x8D64; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater.
break;
}
case Pixel::COMPRESSED_RGB_PVRTC_4BPPV1:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB_PVRTC_4BPPV1.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB_PVRTC_4BPPV1.\n");
glFormat = 0x8C00; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater.
break;
}
}
case Pixel::COMPRESSED_SIGNED_R11_EAC:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_R11_EAC.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_R11_EAC.\n");
glFormat = GL_COMPRESSED_SIGNED_R11_EAC;
break;
}
case Pixel::COMPRESSED_RG11_EAC:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RG11_EAC.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RG11_EAC.\n");
glFormat = GL_COMPRESSED_RG11_EAC;
break;
}
case Pixel::COMPRESSED_SIGNED_RG11_EAC:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_RG11_EAC.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_RG11_EAC.\n");
glFormat = GL_COMPRESSED_SIGNED_RG11_EAC;
break;
}
case Pixel::COMPRESSED_RGB8_ETC2:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_ETC2.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_ETC2.\n");
glFormat = GL_COMPRESSED_RGB8_ETC2;
break;
}
case Pixel::COMPRESSED_SRGB8_ETC2:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ETC2.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ETC2.\n");
glFormat = GL_COMPRESSED_SRGB8_ETC2;
break;
}
case Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n");
glFormat = GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
break;
}
case Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n");
glFormat = GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;
break;
}
case Pixel::COMPRESSED_RGBA8_ETC2_EAC:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGBA8_ETC2_EAC.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGBA8_ETC2_EAC.\n");
glFormat = GL_COMPRESSED_RGBA8_ETC2_EAC;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ETC2_EAC.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ETC2_EAC.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
break;
}
// GLES 3.1 extension compressed formats:
case Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_4x4_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_4x4_KHR.\n");
glFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR;
break;
}
case Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x4_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x4_KHR.\n");
glFormat = GL_COMPRESSED_RGBA_ASTC_5x4_KHR;
break;
}
case Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x5_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x5_KHR.\n");
glFormat = GL_COMPRESSED_RGBA_ASTC_5x5_KHR;
break;
}
case Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x5_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x5_KHR.\n");
glFormat = GL_COMPRESSED_RGBA_ASTC_6x5_KHR;
break;
}
case Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x6_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x6_KHR.\n");
glFormat = GL_COMPRESSED_RGBA_ASTC_6x6_KHR;
break;
}
case Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x5_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x5_KHR.\n");
glFormat = GL_COMPRESSED_RGBA_ASTC_8x5_KHR;
break;
}
case Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x6_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x6_KHR.\n");
glFormat = GL_COMPRESSED_RGBA_ASTC_8x6_KHR;
break;
}
case Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x8_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x8_KHR.\n");
glFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR;
break;
}
case Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x5_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x5_KHR.\n");
glFormat = GL_COMPRESSED_RGBA_ASTC_10x5_KHR;
break;
}
case Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x6_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x6_KHR.\n");
glFormat = GL_COMPRESSED_RGBA_ASTC_10x6_KHR;
break;
}
case Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x8_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x8_KHR.\n");
glFormat = GL_COMPRESSED_RGBA_ASTC_10x8_KHR;
break;
}
case Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x10_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x10_KHR.\n");
glFormat = GL_COMPRESSED_RGBA_ASTC_10x10_KHR;
break;
}
case Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x10_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x10_KHR.\n");
glFormat = GL_COMPRESSED_RGBA_ASTC_12x10_KHR;
break;
}
case Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x12_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x12_KHR.\n");
glFormat = GL_COMPRESSED_RGBA_ASTC_12x12_KHR;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;
break;
}
case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR.\n" );
+ DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR.\n");
glFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;
break;
}
// GLES 3.0 floating point formats.
case Pixel::RGB16F:
{
- glFormat = GL_RGB;
+ glFormat = GL_RGB;
pixelDataType = GL_HALF_FLOAT;
break;
}
case Pixel::RGB32F:
{
- glFormat = GL_RGB;
+ glFormat = GL_RGB;
pixelDataType = GL_FLOAT;
break;
}
// GLES 3.0 depth and stencil formats
case Pixel::DEPTH_UNSIGNED_INT:
{
- glFormat = GL_DEPTH_COMPONENT;
+ glFormat = GL_DEPTH_COMPONENT;
pixelDataType = GL_UNSIGNED_INT;
break;
}
case Pixel::DEPTH_FLOAT:
{
- glFormat = GL_DEPTH_COMPONENT;
+ glFormat = GL_DEPTH_COMPONENT;
pixelDataType = GL_FLOAT;
break;
}
case Pixel::DEPTH_STENCIL:
{
- glFormat = GL_DEPTH_STENCIL;
+ glFormat = GL_DEPTH_STENCIL;
pixelDataType = GL_UNSIGNED_INT_24_8;
break;
}
case Pixel::INVALID:
{
- DALI_LOG_ERROR( "Invalid pixel format for bitmap\n" );
+ DALI_LOG_ERROR("Invalid pixel format for bitmap\n");
glFormat = 0;
break;
}
}
- switch( pixelFormat )
+ switch(pixelFormat)
{
case Pixel::RGB16F:
case Pixel::RGB32F: // FALL THROUGH
glInternalFormat = glFormat;
}
}
-
}
-
/**
* @brief Whether specified pixel format is compressed.
*
*/
bool IsCompressedFormat(Pixel::Format pixelFormat)
{
- switch (pixelFormat)
+ switch(pixelFormat)
{
case Pixel::L8:
case Pixel::A8:
} //Unnamed namespace
-
-Texture::Texture( Type type, Pixel::Format format, ImageDimensions size )
+Texture::Texture(Type type, Pixel::Format format, ImageDimensions size)
: mNativeImage(),
mSampler(),
- mId( 0 ),
- mTarget( ( type == TextureType::TEXTURE_2D ) ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP ),
- mGlInternalFormat( GL_RGB ),
- mGlFormat( GL_RGB ),
- mPixelDataType( GL_UNSIGNED_BYTE ),
- mWidth( size.GetWidth() ),
- mHeight( size.GetHeight() ),
- mMaxMipMapLevel( 0 ),
- mType( type ),
- mHasAlpha( HasAlpha( format ) ),
- mIsCompressed( IsCompressedFormat( format ) )
+ mId(0),
+ mTarget((type == TextureType::TEXTURE_2D) ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP),
+ mGlInternalFormat(GL_RGB),
+ mGlFormat(GL_RGB),
+ mPixelDataType(GL_UNSIGNED_BYTE),
+ mWidth(size.GetWidth()),
+ mHeight(size.GetHeight()),
+ mMaxMipMapLevel(0),
+ mType(type),
+ mHasAlpha(HasAlpha(format)),
+ mIsCompressed(IsCompressedFormat(format))
{
- PixelFormatToGl( format,
- mGlFormat,
- mGlInternalFormat,
- mPixelDataType );
+ PixelFormatToGl(format,
+ mGlFormat,
+ mGlInternalFormat,
+ mPixelDataType);
}
-Texture::Texture( NativeImageInterfacePtr nativeImageInterface )
-: mNativeImage( nativeImageInterface ),
+Texture::Texture(NativeImageInterfacePtr nativeImageInterface)
+: mNativeImage(nativeImageInterface),
mSampler(),
- mId( 0 ),
- mTarget( GL_TEXTURE_2D ),
- mGlInternalFormat( GL_RGB ),
- mGlFormat( GL_RGB ),
- mPixelDataType( GL_UNSIGNED_BYTE ),
- mWidth( static_cast<uint16_t >( nativeImageInterface->GetWidth() ) ), // ignoring overflow, not happening in practice
- mHeight( static_cast<uint16_t >( nativeImageInterface->GetHeight() ) ), // ignoring overflow, not happening in practice
- mMaxMipMapLevel( 0 ),
- mType( TextureType::TEXTURE_2D ),
- mHasAlpha( nativeImageInterface->RequiresBlending() ),
- mIsCompressed( false )
+ mId(0),
+ mTarget(GL_TEXTURE_2D),
+ mGlInternalFormat(GL_RGB),
+ mGlFormat(GL_RGB),
+ mPixelDataType(GL_UNSIGNED_BYTE),
+ mWidth(static_cast<uint16_t>(nativeImageInterface->GetWidth())), // ignoring overflow, not happening in practice
+ mHeight(static_cast<uint16_t>(nativeImageInterface->GetHeight())), // ignoring overflow, not happening in practice
+ mMaxMipMapLevel(0),
+ mType(TextureType::TEXTURE_2D),
+ mHasAlpha(nativeImageInterface->RequiresBlending()),
+ mIsCompressed(false)
{
}
Texture::~Texture() = default;
-void Texture::Destroy( Context& context )
+void Texture::Destroy(Context& context)
{
- if( mId )
+ if(mId)
{
- context.DeleteTextures( 1, &mId );
+ context.DeleteTextures(1, &mId);
- if( mNativeImage )
+ if(mNativeImage)
{
mNativeImage->DestroyResource();
}
void Texture::Initialize(Context& context)
{
- if( mNativeImage )
+ if(mNativeImage)
{
- if( mNativeImage->CreateResource() )
+ if(mNativeImage->CreateResource())
{
mTarget = mNativeImage->GetTextureTarget();
- context.GenTextures( 1, &mId );
- context.BindTexture( mTarget, mId );
- context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); // We always use tightly packed data
+ context.GenTextures(1, &mId);
+ context.BindTexture(mTarget, mId);
+ context.PixelStorei(GL_UNPACK_ALIGNMENT, 1); // We always use tightly packed data
//Apply default sampling parameters
- context.TexParameteri( mTarget, GL_TEXTURE_MIN_FILTER, DALI_MINIFY_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_MAG_FILTER, DALI_MAGNIFY_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_S, GL_WRAP_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_T, GL_WRAP_DEFAULT );
+ context.TexParameteri(mTarget, GL_TEXTURE_MIN_FILTER, DALI_MINIFY_DEFAULT);
+ context.TexParameteri(mTarget, GL_TEXTURE_MAG_FILTER, DALI_MAGNIFY_DEFAULT);
+ context.TexParameteri(mTarget, GL_TEXTURE_WRAP_S, GL_WRAP_DEFAULT);
+ context.TexParameteri(mTarget, GL_TEXTURE_WRAP_T, GL_WRAP_DEFAULT);
// platform specific implementation decides on what GL extension to use
- if( mNativeImage->TargetTexture() != 0u )
+ if(mNativeImage->TargetTexture() != 0u)
{
- context.DeleteTextures( 1, &mId );
+ context.DeleteTextures(1, &mId);
mNativeImage->DestroyResource();
mId = 0u;
}
else
{
//Create the texture and reserve memory for the first mipmap level.
- context.GenTextures( 1, &mId );
- context.BindTexture( mTarget, mId );
- context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); // We always use tightly packed data
+ context.GenTextures(1, &mId);
+ context.BindTexture(mTarget, mId);
+ context.PixelStorei(GL_UNPACK_ALIGNMENT, 1); // We always use tightly packed data
//Apply default sampling parameters
- context.TexParameteri( mTarget, GL_TEXTURE_MIN_FILTER, DALI_MINIFY_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_MAG_FILTER, DALI_MAGNIFY_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_S, GL_WRAP_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_T, GL_WRAP_DEFAULT );
+ context.TexParameteri(mTarget, GL_TEXTURE_MIN_FILTER, DALI_MINIFY_DEFAULT);
+ context.TexParameteri(mTarget, GL_TEXTURE_MAG_FILTER, DALI_MAGNIFY_DEFAULT);
+ context.TexParameteri(mTarget, GL_TEXTURE_WRAP_S, GL_WRAP_DEFAULT);
+ context.TexParameteri(mTarget, GL_TEXTURE_WRAP_T, GL_WRAP_DEFAULT);
- if( mType == TextureType::TEXTURE_2D )
+ if(mType == TextureType::TEXTURE_2D)
{
- if( !mIsCompressed )
+ if(!mIsCompressed)
{
- context.TexImage2D(GL_TEXTURE_2D, 0, mGlInternalFormat, mWidth, mHeight, 0, mGlFormat, mPixelDataType, nullptr );
+ context.TexImage2D(GL_TEXTURE_2D, 0, mGlInternalFormat, mWidth, mHeight, 0, mGlFormat, mPixelDataType, nullptr);
}
else
{
- context.CompressedTexImage2D(GL_TEXTURE_2D, 0, mGlInternalFormat, mWidth, mHeight, 0, 0, nullptr );
+ context.CompressedTexImage2D(GL_TEXTURE_2D, 0, mGlInternalFormat, mWidth, mHeight, 0, 0, nullptr);
}
}
- else if( mType == TextureType::TEXTURE_CUBE )
+ else if(mType == TextureType::TEXTURE_CUBE)
{
- if( !mIsCompressed )
+ if(!mIsCompressed)
{
- for( uint32_t i(0); i<6; ++i )
+ for(uint32_t i(0); i < 6; ++i)
{
- context.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mGlInternalFormat, mWidth, mHeight, 0, mGlFormat, mPixelDataType, nullptr );
+ context.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mGlInternalFormat, mWidth, mHeight, 0, mGlFormat, mPixelDataType, nullptr);
}
}
else
{
- for( uint32_t i(0); i<6; ++i )
+ for(uint32_t i(0); i < 6; ++i)
{
- context.CompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mGlInternalFormat, mWidth, mHeight, 0, 0, nullptr );
+ context.CompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mGlInternalFormat, mWidth, mHeight, 0, 0, nullptr);
}
}
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_R, GL_WRAP_DEFAULT );
+ context.TexParameteri(mTarget, GL_TEXTURE_WRAP_R, GL_WRAP_DEFAULT);
}
}
}
-void Texture::Upload( Context& context, PixelDataPtr pixelData, const Internal::Texture::UploadParams& params )
+void Texture::Upload(Context& context, PixelDataPtr pixelData, const Internal::Texture::UploadParams& params)
{
- DALI_ASSERT_ALWAYS( mNativeImage == nullptr );
+ DALI_ASSERT_ALWAYS(mNativeImage == nullptr);
//Get pointer to the data of the PixelData object
- uint8_t* buffer( pixelData->GetBuffer() );
+ uint8_t* buffer(pixelData->GetBuffer());
//This buffer is only used if manually converting from RGB to RGBA
- std::vector< uint8_t > tempBuffer;
+ std::vector<uint8_t> tempBuffer;
//Retrieves the pixel data element type, the gl format and gl internal format of the data contained in the PixelData object.
GLenum glFormat;
- GLint glInternalFormat;
+ GLint glInternalFormat;
GLenum pixelDataElementType;
- PixelFormatToGl( pixelData->GetPixelFormat(), glFormat, glInternalFormat, pixelDataElementType );
+ PixelFormatToGl(pixelData->GetPixelFormat(), glFormat, glInternalFormat, pixelDataElementType);
//Get the maximum mipmap level to set GL_TEXTURE_MAX_LEVEL parameter in GLES3x because is not
//necessary to upload all the mipmap levels
- mMaxMipMapLevel = ( mMaxMipMapLevel > params.mipmap ) ? mMaxMipMapLevel : params.mipmap;
+ mMaxMipMapLevel = (mMaxMipMapLevel > params.mipmap) ? mMaxMipMapLevel : params.mipmap;
- const bool isSubImage = ( ( params.xOffset != 0 ) ||
- ( params.yOffset != 0 ) ||
- ( params.width != ( mWidth / ( 1 << params.mipmap ) ) ) ||
- ( params.height != ( mHeight / ( 1 << params.mipmap ) ) ) );
+ const bool isSubImage = ((params.xOffset != 0) ||
+ (params.yOffset != 0) ||
+ (params.width != (mWidth / (1 << params.mipmap))) ||
+ (params.height != (mHeight / (1 << params.mipmap))));
- if( context.TextureRequiresConverting( glFormat, mGlFormat, isSubImage ) )
+ if(context.TextureRequiresConverting(glFormat, mGlFormat, isSubImage))
{
- uint32_t dataSize = static_cast< uint32_t >( params.width ) * params.height;
+ uint32_t dataSize = static_cast<uint32_t>(params.width) * params.height;
//reserve() does not allocate the memory on some systems so can crash if not populated using push_back
- tempBuffer.resize( dataSize * 4u );
- for( uint32_t i = 0u; i < dataSize; ++i )
+ tempBuffer.resize(dataSize * 4u);
+ for(uint32_t i = 0u; i < dataSize; ++i)
{
- tempBuffer[i*4u] = buffer[i*3u];
- tempBuffer[i*4u+1] = buffer[i*3u+1];
- tempBuffer[i*4u+2] = buffer[i*3u+2];
- tempBuffer[i*4u+3] = 0xFF;
+ tempBuffer[i * 4u] = buffer[i * 3u];
+ tempBuffer[i * 4u + 1] = buffer[i * 3u + 1];
+ tempBuffer[i * 4u + 2] = buffer[i * 3u + 2];
+ tempBuffer[i * 4u + 3] = 0xFF;
}
- buffer = &tempBuffer[0];
+ buffer = &tempBuffer[0];
glFormat = mGlFormat; // Set the glFormat to GL_RGBA
}
//Upload data to the texture
- context.BindTexture( mTarget, mId );
- GLenum target( mTarget );
- if( mType == TextureType::TEXTURE_CUBE )
+ context.BindTexture(mTarget, mId);
+ GLenum target(mTarget);
+ if(mType == TextureType::TEXTURE_CUBE)
{
target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + params.layer;
}
- context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
+ context.PixelStorei(GL_UNPACK_ALIGNMENT, 1);
- if( !isSubImage )
+ if(!isSubImage)
{
//Specifying the whole image for the mipmap. We cannot assume that storage for that mipmap has been created so we need to use TexImage2D
- if( !mIsCompressed )
+ if(!mIsCompressed)
{
- context.TexImage2D( target, params.mipmap, mGlInternalFormat, params.width, params.height, 0, glFormat, pixelDataElementType, buffer );
+ context.TexImage2D(target, params.mipmap, mGlInternalFormat, params.width, params.height, 0, glFormat, pixelDataElementType, buffer);
}
else
{
- context.CompressedTexImage2D( target, params.mipmap, mGlInternalFormat, params.width, params.height, 0, static_cast<GLsizei>( pixelData->GetBufferSize() ), buffer );
+ context.CompressedTexImage2D(target, params.mipmap, mGlInternalFormat, params.width, params.height, 0, static_cast<GLsizei>(pixelData->GetBufferSize()), buffer);
}
}
else
{
//Specifying part of the image for the mipmap
- if( !mIsCompressed )
+ if(!mIsCompressed)
{
- context.TexSubImage2D( target, params.mipmap,
- params.xOffset, params.yOffset, params.width, params.height,
- glFormat, pixelDataElementType, buffer );
+ context.TexSubImage2D(target, params.mipmap, params.xOffset, params.yOffset, params.width, params.height, glFormat, pixelDataElementType, buffer);
}
else
{
- context.CompressedTexSubImage2D( target, params.mipmap,
- params.xOffset, params.yOffset, params.width, params.height,
- glFormat, static_cast<GLsizei>( pixelData->GetBufferSize() ), buffer );
+ context.CompressedTexSubImage2D(target, params.mipmap, params.xOffset, params.yOffset, params.width, params.height, glFormat, static_cast<GLsizei>(pixelData->GetBufferSize()), buffer);
}
}
}
-bool Texture::Bind( Context& context, uint32_t textureUnit, Render::Sampler* sampler )
+bool Texture::Bind(Context& context, uint32_t textureUnit, Render::Sampler* sampler)
{
- if( mNativeImage && mId == 0 )
+ if(mNativeImage && mId == 0)
{
- Initialize( context );
+ Initialize(context);
}
- if( mId != 0 )
+ if(mId != 0)
{
- context.BindTextureForUnit( static_cast<TextureUnit>( textureUnit ), mTarget, mId );
- ApplySampler( context, sampler );
+ context.BindTextureForUnit(static_cast<TextureUnit>(textureUnit), mTarget, mId);
+ ApplySampler(context, sampler);
- if( mNativeImage )
+ if(mNativeImage)
{
mNativeImage->PrepareTexture();
}
return false;
}
-void Texture::ApplySampler( Context& context, Render::Sampler* sampler )
+void Texture::ApplySampler(Context& context, Render::Sampler* sampler)
{
Render::Sampler oldSampler = mSampler;
- mSampler = sampler ? *sampler : Sampler();
+ mSampler = sampler ? *sampler : Sampler();
- if( mSampler != oldSampler )
+ if(mSampler != oldSampler)
{
- GLint mode = FilterModeToGL( mSampler.mMinificationFilter, DALI_MINIFY_DEFAULT, GL_MINIFY_DEFAULT );
- if( mode != FilterModeToGL( oldSampler.mMinificationFilter, DALI_MINIFY_DEFAULT, GL_MINIFY_DEFAULT ) )
+ GLint mode = FilterModeToGL(mSampler.mMinificationFilter, DALI_MINIFY_DEFAULT, GL_MINIFY_DEFAULT);
+ if(mode != FilterModeToGL(oldSampler.mMinificationFilter, DALI_MINIFY_DEFAULT, GL_MINIFY_DEFAULT))
{
- context.TexParameteri( mTarget, GL_TEXTURE_MIN_FILTER, mode );
+ context.TexParameteri(mTarget, GL_TEXTURE_MIN_FILTER, mode);
}
- mode = FilterModeToGL( mSampler.mMagnificationFilter, DALI_MAGNIFY_DEFAULT, GL_MAGNIFY_DEFAULT );
- if( mode != FilterModeToGL( oldSampler.mMagnificationFilter, DALI_MAGNIFY_DEFAULT, GL_MAGNIFY_DEFAULT ) )
+ mode = FilterModeToGL(mSampler.mMagnificationFilter, DALI_MAGNIFY_DEFAULT, GL_MAGNIFY_DEFAULT);
+ if(mode != FilterModeToGL(oldSampler.mMagnificationFilter, DALI_MAGNIFY_DEFAULT, GL_MAGNIFY_DEFAULT))
{
- context.TexParameteri( mTarget, GL_TEXTURE_MAG_FILTER, mode );
+ context.TexParameteri(mTarget, GL_TEXTURE_MAG_FILTER, mode);
}
- mode = WrapModeToGL( mSampler.mSWrapMode, GL_WRAP_DEFAULT );
- if( mode != WrapModeToGL( oldSampler.mSWrapMode, GL_WRAP_DEFAULT ) )
+ mode = WrapModeToGL(mSampler.mSWrapMode, GL_WRAP_DEFAULT);
+ if(mode != WrapModeToGL(oldSampler.mSWrapMode, GL_WRAP_DEFAULT))
{
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_S, mode );
+ context.TexParameteri(mTarget, GL_TEXTURE_WRAP_S, mode);
}
- mode = WrapModeToGL( mSampler.mTWrapMode, GL_WRAP_DEFAULT );
- if( mode != WrapModeToGL( oldSampler.mTWrapMode, GL_WRAP_DEFAULT ) )
+ mode = WrapModeToGL(mSampler.mTWrapMode, GL_WRAP_DEFAULT);
+ if(mode != WrapModeToGL(oldSampler.mTWrapMode, GL_WRAP_DEFAULT))
{
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_T, mode );
+ context.TexParameteri(mTarget, GL_TEXTURE_WRAP_T, mode);
}
- if( mType == TextureType::TEXTURE_CUBE )
+ if(mType == TextureType::TEXTURE_CUBE)
{
- mode = WrapModeToGL( mSampler.mRWrapMode, GL_WRAP_DEFAULT );
- if( mode != WrapModeToGL( oldSampler.mRWrapMode, GL_WRAP_DEFAULT ) )
+ mode = WrapModeToGL(mSampler.mRWrapMode, GL_WRAP_DEFAULT);
+ if(mode != WrapModeToGL(oldSampler.mRWrapMode, GL_WRAP_DEFAULT))
{
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_R, mode );
+ context.TexParameteri(mTarget, GL_TEXTURE_WRAP_R, mode);
}
}
if(mMaxMipMapLevel)
{
- context.TexParameteri( mTarget, GL_TEXTURE_MAX_LEVEL, mMaxMipMapLevel );
+ context.TexParameteri(mTarget, GL_TEXTURE_MAX_LEVEL, mMaxMipMapLevel);
}
}
}
return mHasAlpha;
}
-void Texture::GenerateMipmaps( Context& context )
+void Texture::GenerateMipmaps(Context& context)
{
//GL_TEXTURE_MAX_LEVEL does not need to be set when mipmaps are generated by GL
mMaxMipMapLevel = 0;
- context.BindTexture( mTarget, mId );
- context.GenerateMipmap( mTarget );
+ context.BindTexture(mTarget, mId);
+ context.GenerateMipmap(mTarget);
}
-} //Render
+} // namespace Render
-} //Internal
+} // namespace Internal
-} //Dali
+} // namespace Dali
#define DALI_INTERNAL_RENDER_TEXTURE_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
// EXTERNAL INCLUDES
-#include <string>
#include <cstdint> // uint16_t, uint32_t
+#include <string>
// INTERNAL INCLUDES
-#include <dali/public-api/images/image-operations.h> // Dali::ImageDimensions
-#include <dali/public-api/rendering/sampler.h>
-#include <dali/public-api/rendering/texture.h>
+#include <dali/integration-api/gl-defines.h>
#include <dali/internal/event/rendering/texture-impl.h>
#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/render/renderers/render-sampler.h>
-#include <dali/integration-api/gl-defines.h>
+#include <dali/public-api/images/image-operations.h> // Dali::ImageDimensions
+#include <dali/public-api/rendering/sampler.h>
+#include <dali/public-api/rendering/texture.h>
namespace Dali
{
* @param[in] format The format of the pixel data
* @param[in] size The size of the texture
*/
- Texture( Type type, Pixel::Format format, ImageDimensions size );
+ Texture(Type type, Pixel::Format format, ImageDimensions size);
/**
* Constructor from native image
* @param[in] nativeImageInterface The native image
*/
- Texture( NativeImageInterfacePtr nativeImageInterface );
+ Texture(NativeImageInterfacePtr nativeImageInterface);
/**
* Destructor
* Creates the texture and reserves memory for the first mipmap level
* @param[in] context The GL context
*/
- void Initialize( Context& context );
+ void Initialize(Context& context);
/**
* Deletes the texture from the GPU
* @param[in] context The GL context
*/
- void Destroy( Context& context );
+ void Destroy(Context& context);
/**
* Called by RenderManager to inform the texture that the context has been destroyed
* @param[in] pixelData A pixel data object
* @param[in] params Upload parameters. See UploadParams
*/
- void Upload( Context& context, PixelDataPtr pixelData, const Internal::Texture::UploadParams& params );
+ void Upload(Context& context, PixelDataPtr pixelData, const Internal::Texture::UploadParams& params);
/**
* Bind the texture to the given texture unit and applies the given sampler
* @param[in] sampler The sampler to be used with the texture
* @return true if the bind succeeded, false otherwise
*/
- bool Bind( Context& context, uint32_t textureUnit, Render::Sampler* sampler );
+ bool Bind(Context& context, uint32_t textureUnit, Render::Sampler* sampler);
/**
* Auto generates mipmaps for the texture
* @param[in] context The GL context
*/
- void GenerateMipmaps( Context& context );
+ void GenerateMipmaps(Context& context);
/**
* Retrieve wheter the texture has an alpha channel
}
private:
-
/**
* Helper method to apply a sampler to the texture
* @param[in] context The GL context
* @param[in] sampler The sampler
*/
- void ApplySampler( Context& context, Render::Sampler* sampler );
-
- NativeImageInterfacePtr mNativeImage; ///< Pointer to native image
- Render::Sampler mSampler; ///< The current sampler state
- GLuint mId; ///< Id of the texture
- GLuint mTarget; ///< Specifies the target to which the texture is bound.
- GLint mGlInternalFormat; ///< The gl internal format of the pixel data
- GLenum mGlFormat; ///< The gl format of the pixel data
- GLenum mPixelDataType; ///< The data type of the pixel data
- uint16_t mWidth; ///< Width of the texture
- uint16_t mHeight; ///< Height of the texture
- uint16_t mMaxMipMapLevel; ///< Maximum mipmap level
- Type mType:3; ///< Type of the texture
- bool mHasAlpha : 1; ///< Whether the format has an alpha channel
- bool mIsCompressed : 1; ///< Whether the format is compressed
-
+ void ApplySampler(Context& context, Render::Sampler* sampler);
+
+ NativeImageInterfacePtr mNativeImage; ///< Pointer to native image
+ Render::Sampler mSampler; ///< The current sampler state
+ GLuint mId; ///< Id of the texture
+ GLuint mTarget; ///< Specifies the target to which the texture is bound.
+ GLint mGlInternalFormat; ///< The gl internal format of the pixel data
+ GLenum mGlFormat; ///< The gl format of the pixel data
+ GLenum mPixelDataType; ///< The data type of the pixel data
+ uint16_t mWidth; ///< Width of the texture
+ uint16_t mHeight; ///< Height of the texture
+ uint16_t mMaxMipMapLevel; ///< Maximum mipmap level
+ Type mType : 3; ///< Type of the texture
+ bool mHasAlpha : 1; ///< Whether the format has an alpha channel
+ bool mIsCompressed : 1; ///< Whether the format is compressed
};
-
} // namespace Render
} // namespace Internal
} // namespace Dali
-
#endif // DALI_INTERNAL_RENDER_TEXTURE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
+#include <dali/internal/event/rendering/vertex-buffer-impl.h> // Dali::Internal::VertexBuffer
#include <dali/internal/render/renderers/render-vertex-buffer.h>
-#include <dali/internal/event/rendering/vertex-buffer-impl.h> // Dali::Internal::VertexBuffer
namespace
{
-
using Dali::Property;
using Dali::Internal::PropertyImplementationType;
-Dali::GLenum GetPropertyImplementationGlType( Property::Type propertyType )
+Dali::GLenum GetPropertyImplementationGlType(Property::Type propertyType)
{
Dali::GLenum type = GL_BYTE;
- switch( propertyType )
+ switch(propertyType)
{
case Property::NONE:
case Property::STRING:
return type;
}
-Dali::GLint GetPropertyImplementationGlSize( Property::Type propertyType )
+Dali::GLint GetPropertyImplementationGlSize(Property::Type propertyType)
{
Dali::GLint size = 1u;
- switch( propertyType )
+ switch(propertyType)
{
case Property::NONE:
case Property::STRING:
{
namespace Render
{
-
VertexBuffer::VertexBuffer()
-:mFormat(nullptr),
- mData(nullptr),
- mGpuBuffer(nullptr),
- mSize(0),
- mDataChanged(true)
+: mFormat(nullptr),
+ mData(nullptr),
+ mGpuBuffer(nullptr),
+ mSize(0),
+ mDataChanged(true)
{
}
VertexBuffer::~VertexBuffer() = default;
-void VertexBuffer::SetFormat( VertexBuffer::Format* format )
+void VertexBuffer::SetFormat(VertexBuffer::Format* format)
{
- mFormat = format;
+ mFormat = format;
mDataChanged = true;
}
-void VertexBuffer::SetData( Dali::Vector<uint8_t>* data, uint32_t size )
+void VertexBuffer::SetData(Dali::Vector<uint8_t>* data, uint32_t size)
{
- mData = data;
- mSize = size;
+ mData = data;
+ mSize = size;
mDataChanged = true;
}
-bool VertexBuffer::Update( Context& context )
+bool VertexBuffer::Update(Context& context)
{
- if( !mData || !mFormat || !mSize )
+ if(!mData || !mFormat || !mSize)
{
return false;
}
- if( !mGpuBuffer || mDataChanged )
+ if(!mGpuBuffer || mDataChanged)
{
- if ( ! mGpuBuffer )
+ if(!mGpuBuffer)
{
- mGpuBuffer = new GpuBuffer( context );
+ mGpuBuffer = new GpuBuffer(context);
}
// Update the GpuBuffer
- if ( mGpuBuffer )
+ if(mGpuBuffer)
{
- DALI_ASSERT_DEBUG( mSize && "No data in the property buffer!" );
- mGpuBuffer->UpdateDataBuffer( context, GetDataSize(), &((*mData)[0]), GpuBuffer::STATIC_DRAW, GpuBuffer::ARRAY_BUFFER );
+ DALI_ASSERT_DEBUG(mSize && "No data in the property buffer!");
+ mGpuBuffer->UpdateDataBuffer(context, GetDataSize(), &((*mData)[0]), GpuBuffer::STATIC_DRAW, GpuBuffer::ARRAY_BUFFER);
}
mDataChanged = false;
return true;
}
-void VertexBuffer::BindBuffer( Context& context, GpuBuffer::Target target )
+void VertexBuffer::BindBuffer(Context& context, GpuBuffer::Target target)
{
if(mGpuBuffer)
{
}
}
-uint32_t VertexBuffer::EnableVertexAttributes( Context& context, Vector<GLint>& vAttributeLocation, uint32_t locationBase )
+uint32_t VertexBuffer::EnableVertexAttributes(Context& context, Vector<GLint>& vAttributeLocation, uint32_t locationBase)
{
- const uint32_t attributeCount = static_cast<uint32_t>( mFormat->components.size() );
+ const uint32_t attributeCount = static_cast<uint32_t>(mFormat->components.size());
GLsizei elementSize = mFormat->size;
- for( uint32_t i = 0; i < attributeCount; ++i )
+ for(uint32_t i = 0; i < attributeCount; ++i)
{
- GLint attributeLocation = vAttributeLocation[i+locationBase];
- if( attributeLocation != -1 )
+ GLint attributeLocation = vAttributeLocation[i + locationBase];
+ if(attributeLocation != -1)
{
- context.EnableVertexAttributeArray( attributeLocation );
-
- const GLint attributeSize = mFormat->components[i].size;
- uint32_t attributeOffset = mFormat->components[i].offset;
- const Property::Type attributeType = mFormat->components[i].type;
-
- context.VertexAttribPointer( attributeLocation,
- attributeSize / GetPropertyImplementationGlSize(attributeType),
- GetPropertyImplementationGlType(attributeType),
- GL_FALSE, // Not normalized
- elementSize,
- reinterpret_cast< void* >( attributeOffset ) );
+ context.EnableVertexAttributeArray(attributeLocation);
+
+ const GLint attributeSize = mFormat->components[i].size;
+ uint32_t attributeOffset = mFormat->components[i].offset;
+ const Property::Type attributeType = mFormat->components[i].type;
+
+ context.VertexAttribPointer(attributeLocation,
+ attributeSize / GetPropertyImplementationGlSize(attributeType),
+ GetPropertyImplementationGlType(attributeType),
+ GL_FALSE, // Not normalized
+ elementSize,
+ reinterpret_cast<void*>(attributeOffset));
}
}
return attributeCount;
}
-} //Render
-} //Internal
-} //Dali
+} // namespace Render
+} // namespace Internal
+} // namespace Dali
#define DALI_INTERNAL_RENDER_VERTEX_BUFFER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/common/const-string.h>
+#include <dali/internal/common/owner-pointer.h>
+#include <dali/internal/render/gl-resources/gpu-buffer.h>
+#include <dali/internal/render/renderers/render-sampler.h>
#include <dali/public-api/actors/sampling.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/rendering/sampler.h>
-#include <dali/internal/common/owner-pointer.h>
-#include <dali/internal/render/renderers/render-sampler.h>
-#include <dali/internal/render/gl-resources/gpu-buffer.h>
-#include <dali/internal/common/const-string.h>
namespace Dali
{
{
namespace Render
{
-
class VertexBuffer
{
public:
-
struct Component
{
ConstString name;
*
* @param[in] format The format for the VertexBuffer
*/
- void SetFormat( VertexBuffer::Format* format );
+ void SetFormat(VertexBuffer::Format* format);
/**
* @brief Set the data of the VertexBuffer
* @param[in] data The new data of the VertexBuffer
* @param[in] size The new size of the buffer
*/
- void SetData( Dali::Vector<uint8_t>* data, uint32_t size );
+ void SetData(Dali::Vector<uint8_t>* data, uint32_t size);
/**
* @brief Set the number of elements
* @param[in] size The number of elements
*/
- void SetSize( uint32_t size );
+ void SetSize(uint32_t size);
/**
* @brief Bind the property buffer
* @param context The context to bind the the buffer
* @param[in] target The binding point
*/
- void BindBuffer( Context& context, GpuBuffer::Target target );
+ void BindBuffer(Context& context, GpuBuffer::Target target);
/**
* Perform the upload of the buffer only when requiered
* @param[in] context The GL context
*/
- bool Update( Context& context );
+ bool Update(Context& context);
/**
* Enable the vertex attributes for each vertex buffer from the corresponding
* @param[in] vAttributeLocation Vector containing attributes location for current program
* @param[in] locationBase Index in vAttributeLocation corresponding to the first attribute defined by this buffer
*/
- uint32_t EnableVertexAttributes( Context& context, Vector<GLint>& vAttributeLocation, uint32_t locationBase );
+ uint32_t EnableVertexAttributes(Context& context, Vector<GLint>& vAttributeLocation, uint32_t locationBase);
/**
* Get the number of attributes present in the buffer
*/
inline uint32_t GetAttributeCount() const
{
- DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
- return static_cast<uint32_t>( mFormat->components.size() );
+ DALI_ASSERT_DEBUG(mFormat && "Format should be set ");
+ return static_cast<uint32_t>(mFormat->components.size());
}
/**
* @param[in] index The index of the attribute
* @return The name of the attribute
*/
- inline ConstString GetAttributeName( uint32_t index ) const
+ inline ConstString GetAttributeName(uint32_t index) const
{
- DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
+ DALI_ASSERT_DEBUG(mFormat && "Format should be set ");
return mFormat->components[index].name;
}
*/
inline uint32_t GetDataSize() const
{
- DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
+ DALI_ASSERT_DEBUG(mFormat && "Format should be set ");
return mFormat->size * mSize;
}
*/
inline uint32_t GetElementSize() const
{
- DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
+ DALI_ASSERT_DEBUG(mFormat && "Format should be set ");
return mFormat->size;
}
* Retrieve reference to the data storage vector
* @return Reference to the data storage
*/
- inline const Dali::Vector< uint8_t >& GetData() const
+ inline const Dali::Vector<uint8_t>& GetData() const
{
return *mData.Get();
}
* Retrieve data writeable pointer ( direct access to the buffer data )
* @return Pointer to data converted to requested type
*/
- template <typename T>
+ template<typename T>
inline T* GetDataTypedPtr()
{
- Dali::Vector< uint8_t >* data = mData.Release();
- mData = data;
- return reinterpret_cast<T*>( &data->operator[]( 0 ) );
+ Dali::Vector<uint8_t>* data = mData.Release();
+ mData = data;
+ return reinterpret_cast<T*>(&data->operator[](0));
}
inline const VertexBuffer::Format* GetFormat() const
}
private:
- OwnerPointer< VertexBuffer::Format > mFormat; ///< Format of the buffer
- OwnerPointer< Dali::Vector< uint8_t > > mData; ///< Data
- OwnerPointer< GpuBuffer > mGpuBuffer; ///< Pointer to the GpuBuffer associated with this RenderVertexBuffer
+ OwnerPointer<VertexBuffer::Format> mFormat; ///< Format of the buffer
+ OwnerPointer<Dali::Vector<uint8_t> > mData; ///< Data
+ OwnerPointer<GpuBuffer> mGpuBuffer; ///< Pointer to the GpuBuffer associated with this RenderVertexBuffer
- uint32_t mSize; ///< Number of Elements in the buffer
- bool mDataChanged; ///< Flag to know if data has changed in a frame
+ uint32_t mSize; ///< Number of Elements in the buffer
+ bool mDataChanged; ///< Flag to know if data has changed in a frame
};
} // namespace Render
} // namespace Dali
-
#endif // DALI_INTERNAL_RENDER_VERTEX_BUFFER_H
#define DALI_INTERNAL_PROGRAM_CACHE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
class Program;
/**
class ProgramCache
{
public:
-
/**
* Constructor
*/
virtual ~ProgramCache() = default;
public: // API
-
/**
* @return GlAbstraction
*/
* @param shaderHash to use
* @return program
*/
- virtual Program* GetProgram( size_t shaderHash ) = 0;
+ virtual Program* GetProgram(size_t shaderHash) = 0;
/**
* Add a program to cache
* @param shaderHash of the program
* @param program to add
*/
- virtual void AddProgram( size_t shaderHash, Program* program ) = 0;
+ virtual void AddProgram(size_t shaderHash, Program* program) = 0;
/**
* Get currently bound program
* Set the currently bound program
* @param program that is used
*/
- virtual void SetCurrentProgram( Program* program ) = 0;
+ virtual void SetCurrentProgram(Program* program) = 0;
/**
* @return true if program binaries are supported
/**
* @param programData to store/save
*/
- virtual void StoreBinary( Internal::ShaderDataPtr programData ) = 0;
+ virtual void StoreBinary(Internal::ShaderDataPtr programData) = 0;
private: // not implemented as non-copyable
-
- ProgramCache( const ProgramCache& rhs );
- ProgramCache& operator=( const ProgramCache& rhs );
-
+ ProgramCache(const ProgramCache& rhs);
+ ProgramCache& operator=(const ProgramCache& rhs);
};
-
} // namespace Internal
} // namespace Dali
#endif // DALI_INTERNAL_PROGRAM_CACHE_H
-
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/render/shaders/program.h>
// EXTERNAL INCLUDES
-#include <iomanip>
#include <cstring>
+#include <iomanip>
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/common/dali-vector.h>
-#include <dali/public-api/common/constants.h>
#include <dali/integration-api/debug.h>
-#include <dali/internal/common/shader-data.h>
#include <dali/integration-api/gl-defines.h>
+#include <dali/internal/common/shader-data.h>
#include <dali/internal/render/common/performance-monitor.h>
-#include <dali/internal/render/shaders/program-cache.h>
#include <dali/internal/render/gl-resources/gl-call-debug.h>
+#include <dali/internal/render/shaders/program-cache.h>
+#include <dali/public-api/common/constants.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/common/dali-vector.h>
namespace
{
-void LogWithLineNumbers( const char * source )
+void LogWithLineNumbers(const char* source)
{
- uint32_t lineNumber = 0u;
- const char* prev = source;
- const char* ptr = prev;
+ uint32_t lineNumber = 0u;
+ const char* prev = source;
+ const char* ptr = prev;
- while( true )
+ while(true)
{
if(lineNumber > 200u)
{
break;
}
// seek the next end of line or end of text
- while( *ptr!='\n' && *ptr != '\0' )
+ while(*ptr != '\n' && *ptr != '\0')
{
++ptr;
}
- std::string line( prev, ptr-prev );
+ std::string line(prev, ptr - prev);
Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, "%4d %s\n", lineNumber, line.c_str());
- if( *ptr == '\0' )
+ if(*ptr == '\0')
{
break;
}
namespace Dali
{
-
namespace Internal
{
-
// LOCAL STUFF
namespace
{
-
-const char* const gStdAttribs[ Program::ATTRIB_TYPE_LAST ] =
-{
- "aPosition", // ATTRIB_POSITION
- "aTexCoord", // ATTRIB_TEXCOORD
+const char* const gStdAttribs[Program::ATTRIB_TYPE_LAST] =
+ {
+ "aPosition", // ATTRIB_POSITION
+ "aTexCoord", // ATTRIB_TEXCOORD
};
-const char* const gStdUniforms[ Program::UNIFORM_TYPE_LAST ] =
-{
- "uMvpMatrix", // UNIFORM_MVP_MATRIX
- "uModelView", // UNIFORM_MODELVIEW_MATRIX
- "uProjection", // UNIFORM_PROJECTION_MATRIX
- "uModelMatrix", // UNIFORM_MODEL_MATRIX,
- "uViewMatrix", // UNIFORM_VIEW_MATRIX,
- "uNormalMatrix", // UNIFORM_NORMAL_MATRIX
- "uColor", // UNIFORM_COLOR
- "sTexture", // UNIFORM_SAMPLER
- "sTextureRect", // UNIFORM_SAMPLER_RECT
- "sEffect", // UNIFORM_EFFECT_SAMPLER
- "uSize" // UNIFORM_SIZE
+const char* const gStdUniforms[Program::UNIFORM_TYPE_LAST] =
+ {
+ "uMvpMatrix", // UNIFORM_MVP_MATRIX
+ "uModelView", // UNIFORM_MODELVIEW_MATRIX
+ "uProjection", // UNIFORM_PROJECTION_MATRIX
+ "uModelMatrix", // UNIFORM_MODEL_MATRIX,
+ "uViewMatrix", // UNIFORM_VIEW_MATRIX,
+ "uNormalMatrix", // UNIFORM_NORMAL_MATRIX
+ "uColor", // UNIFORM_COLOR
+ "sTexture", // UNIFORM_SAMPLER
+ "sTextureRect", // UNIFORM_SAMPLER_RECT
+ "sEffect", // UNIFORM_EFFECT_SAMPLER
+ "uSize" // UNIFORM_SIZE
};
-} // <unnamed> namespace
+} // namespace
// IMPLEMENTATION
-Program* Program::New( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry )
+Program* Program::New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry)
{
- size_t shaderHash = shaderData->GetHashValue();
- Program* program = cache.GetProgram( shaderHash );
+ size_t shaderHash = shaderData->GetHashValue();
+ Program* program = cache.GetProgram(shaderHash);
- if( nullptr == program )
+ if(nullptr == program)
{
// program not found so create it
- program = new Program( cache, shaderData, modifiesGeometry );
+ program = new Program(cache, shaderData, modifiesGeometry);
program->Load();
- cache.AddProgram( shaderHash, program );
+ cache.AddProgram(shaderHash, program);
}
return program;
void Program::Use()
{
- if ( mLinked )
+ if(mLinked)
{
- if ( this != mCache.GetCurrentProgram() )
+ if(this != mCache.GetCurrentProgram())
{
- LOG_GL( "UseProgram(%d)\n", mProgramId );
- CHECK_GL( mGlAbstraction, mGlAbstraction.UseProgram(mProgramId) );
+ LOG_GL("UseProgram(%d)\n", mProgramId);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.UseProgram(mProgramId));
- mCache.SetCurrentProgram( this );
+ mCache.SetCurrentProgram(this);
}
}
}
bool Program::IsUsed()
{
- return ( this == mCache.GetCurrentProgram() );
+ return (this == mCache.GetCurrentProgram());
}
-GLint Program::GetAttribLocation( AttribType type )
+GLint Program::GetAttribLocation(AttribType type)
{
DALI_ASSERT_DEBUG(type != ATTRIB_UNKNOWN);
- return GetCustomAttributeLocation( type );
+ return GetCustomAttributeLocation(type);
}
-uint32_t Program::RegisterCustomAttribute( ConstString name )
+uint32_t Program::RegisterCustomAttribute(ConstString name)
{
uint32_t index = 0;
// find the value from cache
- for( ;index < static_cast<uint32_t>( mAttributeLocations.size() ); ++index )
+ for(; index < static_cast<uint32_t>(mAttributeLocations.size()); ++index)
{
- if( mAttributeLocations[ index ].first == name )
+ if(mAttributeLocations[index].first == name)
{
// name found so return index
return index;
}
}
// if we get here, index is one past end so push back the new name
- mAttributeLocations.push_back( std::make_pair( name, ATTRIB_UNKNOWN ) );
+ mAttributeLocations.push_back(std::make_pair(name, ATTRIB_UNKNOWN));
return index;
}
-GLint Program::GetCustomAttributeLocation( uint32_t attributeIndex )
+GLint Program::GetCustomAttributeLocation(uint32_t attributeIndex)
{
// debug check that index is within name cache
- DALI_ASSERT_DEBUG( mAttributeLocations.size() > attributeIndex );
+ DALI_ASSERT_DEBUG(mAttributeLocations.size() > attributeIndex);
// check if we have already queried the location of the attribute
- GLint location = mAttributeLocations[ attributeIndex ].second;
+ GLint location = mAttributeLocations[attributeIndex].second;
- if( location == ATTRIB_UNKNOWN )
+ if(location == ATTRIB_UNKNOWN)
{
- location = CHECK_GL( mGlAbstraction, mGlAbstraction.GetAttribLocation( mProgramId, mAttributeLocations[ attributeIndex ].first.GetCString() ) );
+ location = CHECK_GL(mGlAbstraction, mGlAbstraction.GetAttribLocation(mProgramId, mAttributeLocations[attributeIndex].first.GetCString()));
- mAttributeLocations[ attributeIndex ].second = location;
- LOG_GL( "GetAttributeLocation(program=%d,%s) = %d\n", mProgramId, mAttributeLocations[ attributeIndex ].first.GetCString(), mAttributeLocations[ attributeIndex ].second );
+ mAttributeLocations[attributeIndex].second = location;
+ LOG_GL("GetAttributeLocation(program=%d,%s) = %d\n", mProgramId, mAttributeLocations[attributeIndex].first.GetCString(), mAttributeLocations[attributeIndex].second);
}
return location;
}
-
-uint32_t Program::RegisterUniform( ConstString name )
+uint32_t Program::RegisterUniform(ConstString name)
{
uint32_t index = 0;
// find the value from cache
- for( ;index < static_cast<uint32_t>( mUniformLocations.size() ); ++index )
+ for(; index < static_cast<uint32_t>(mUniformLocations.size()); ++index)
{
- if( mUniformLocations[ index ].first == name )
+ if(mUniformLocations[index].first == name)
{
// name found so return index
return index;
}
}
// if we get here, index is one past end so push back the new name
- mUniformLocations.push_back( std::make_pair( name, UNIFORM_NOT_QUERIED ) );
+ mUniformLocations.push_back(std::make_pair(name, UNIFORM_NOT_QUERIED));
return index;
}
-GLint Program::GetUniformLocation( uint32_t uniformIndex )
+GLint Program::GetUniformLocation(uint32_t uniformIndex)
{
// debug check that index is within name cache
- DALI_ASSERT_DEBUG( mUniformLocations.size() > uniformIndex );
+ DALI_ASSERT_DEBUG(mUniformLocations.size() > uniformIndex);
// check if we have already queried the location of the uniform
- GLint location = mUniformLocations[ uniformIndex ].second;
+ GLint location = mUniformLocations[uniformIndex].second;
- if( location == UNIFORM_NOT_QUERIED )
+ if(location == UNIFORM_NOT_QUERIED)
{
- location = CHECK_GL( mGlAbstraction, mGlAbstraction.GetUniformLocation( mProgramId, mUniformLocations[ uniformIndex ].first.GetCString() ) );
+ location = CHECK_GL(mGlAbstraction, mGlAbstraction.GetUniformLocation(mProgramId, mUniformLocations[uniformIndex].first.GetCString()));
- mUniformLocations[ uniformIndex ].second = location;
- LOG_GL( "GetUniformLocation(program=%d,%s) = %d\n", mProgramId, mUniformLocations[ uniformIndex ].first.GetCString(), mUniformLocations[ uniformIndex ].second );
+ mUniformLocations[uniformIndex].second = location;
+ LOG_GL("GetUniformLocation(program=%d,%s) = %d\n", mProgramId, mUniformLocations[uniformIndex].first.GetCString(), mUniformLocations[uniformIndex].second);
}
return location;
*/
struct LocationPosition
{
- GLint uniformLocation; ///< The location of the uniform (used as an identifier)
- int32_t position; ///< the position of the uniform declaration
- LocationPosition( GLint uniformLocation, int32_t position )
- : uniformLocation(uniformLocation), position(position)
+ GLint uniformLocation; ///< The location of the uniform (used as an identifier)
+ int32_t position; ///< the position of the uniform declaration
+ LocationPosition(GLint uniformLocation, int32_t position)
+ : uniformLocation(uniformLocation),
+ position(position)
{
}
};
-bool sortByPosition( LocationPosition a, LocationPosition b )
+bool sortByPosition(LocationPosition a, LocationPosition b)
{
return a.position < b.position;
}
struct StringSize
{
const char* const mString;
- const uint32_t mLength;
+ const uint32_t mLength;
- template <uint32_t kLength>
- constexpr StringSize(const char(&string)[kLength])
+ template<uint32_t kLength>
+ constexpr StringSize(const char (&string)[kLength])
: mString(string),
mLength(kLength - 1) // remove terminating null; N.B. there should be no other null.
- {}
+ {
+ }
operator const char*() const
{
return strncmp(lhs.mString, rhs, lhs.mLength) == 0;
}
-constexpr StringSize UNIFORM{ "uniform" };
-constexpr StringSize SAMPLER_PREFIX{ "sampler" };
+constexpr StringSize UNIFORM{"uniform"};
+constexpr StringSize SAMPLER_PREFIX{"sampler"};
constexpr StringSize SAMPLER_TYPES[] = {
"2D",
"Cube",
- "ExternalOES"
-};
+ "ExternalOES"};
constexpr auto END_SAMPLER_TYPES = SAMPLER_TYPES + std::extent<decltype(SAMPLER_TYPES)>::value;
-}
+} // namespace
void Program::GetActiveSamplerUniforms()
{
GLint numberOfActiveUniforms = -1;
- GLint uniformMaxNameLength=-1;
+ GLint uniformMaxNameLength = -1;
- mGlAbstraction.GetProgramiv( mProgramId, GL_ACTIVE_UNIFORMS, &numberOfActiveUniforms );
- mGlAbstraction.GetProgramiv( mProgramId, GL_ACTIVE_UNIFORM_MAX_LENGTH, &uniformMaxNameLength );
+ mGlAbstraction.GetProgramiv(mProgramId, GL_ACTIVE_UNIFORMS, &numberOfActiveUniforms);
+ mGlAbstraction.GetProgramiv(mProgramId, GL_ACTIVE_UNIFORM_MAX_LENGTH, &uniformMaxNameLength);
- std::vector< std::string > samplerNames;
- std::vector< char > name(uniformMaxNameLength + 1); // Allow for null terminator
- std::vector< LocationPosition > samplerUniformLocations;
+ std::vector<std::string> samplerNames;
+ std::vector<char> name(uniformMaxNameLength + 1); // Allow for null terminator
+ std::vector<LocationPosition> samplerUniformLocations;
{
- int nameLength = -1;
- int number = -1;
- GLenum type = GL_ZERO;
+ int nameLength = -1;
+ int number = -1;
+ GLenum type = GL_ZERO;
- for( int i=0; i<numberOfActiveUniforms; ++i )
+ for(int i = 0; i < numberOfActiveUniforms; ++i)
{
- mGlAbstraction.GetActiveUniform( mProgramId, static_cast< GLuint >( i ), uniformMaxNameLength,
- &nameLength, &number, &type, name.data() );
+ mGlAbstraction.GetActiveUniform(mProgramId, static_cast<GLuint>(i), uniformMaxNameLength, &nameLength, &number, &type, name.data());
- if( type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES )
+ if(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES)
{
- GLuint location = mGlAbstraction.GetUniformLocation( mProgramId, name.data() );
- samplerNames.push_back( name.data() );
+ GLuint location = mGlAbstraction.GetUniformLocation(mProgramId, name.data());
+ samplerNames.push_back(name.data());
samplerUniformLocations.push_back(LocationPosition(location, -1));
}
}
}
//Determine declaration order of each sampler
- char* fragShader = strdup( mProgramData->GetFragmentShader() );
- char* uniform = strstr( fragShader, UNIFORM );
- int samplerPosition = 0;
- while ( uniform )
+ char* fragShader = strdup(mProgramData->GetFragmentShader());
+ char* uniform = strstr(fragShader, UNIFORM);
+ int samplerPosition = 0;
+ while(uniform)
{
- char* outerToken = strtok_r( uniform + UNIFORM.mLength, ";", &uniform );
+ char* outerToken = strtok_r(uniform + UNIFORM.mLength, ";", &uniform);
char* nextPtr = nullptr;
- char* token = strtok_r( outerToken, DELIMITERS, &nextPtr );
- while ( token )
+ char* token = strtok_r(outerToken, DELIMITERS, &nextPtr);
+ while(token)
{
- if ( SAMPLER_PREFIX == token )
+ if(SAMPLER_PREFIX == token)
{
token += SAMPLER_PREFIX.mLength;
- if ( std::find(SAMPLER_TYPES, END_SAMPLER_TYPES, token) != END_SAMPLER_TYPES )
+ if(std::find(SAMPLER_TYPES, END_SAMPLER_TYPES, token) != END_SAMPLER_TYPES)
{
- bool found( false );
- token = strtok_r( nullptr, DELIMITERS, &nextPtr );
- for (uint32_t i=0; i < static_cast<uint32_t>( samplerUniformLocations.size() ); ++i)
+ bool found(false);
+ token = strtok_r(nullptr, DELIMITERS, &nextPtr);
+ for(uint32_t i = 0; i < static_cast<uint32_t>(samplerUniformLocations.size()); ++i)
{
- if ( samplerUniformLocations[i].position == -1 &&
- strncmp(token, samplerNames[i].c_str(), samplerNames[i].size()) == 0 )
+ if(samplerUniformLocations[i].position == -1 &&
+ strncmp(token, samplerNames[i].c_str(), samplerNames[i].size()) == 0)
{
samplerUniformLocations[i].position = samplerPosition++;
- found = true;
+ found = true;
break;
}
}
- if (!found)
+ if(!found)
{
- DALI_LOG_ERROR("Sampler uniform %s declared but not used in the shader\n", token );
+ DALI_LOG_ERROR("Sampler uniform %s declared but not used in the shader\n", token);
}
break;
}
}
- token = strtok_r( nullptr, DELIMITERS, &nextPtr );
+ token = strtok_r(nullptr, DELIMITERS, &nextPtr);
}
- uniform = strstr( uniform, UNIFORM );
+ uniform = strstr(uniform, UNIFORM);
}
- free( fragShader );
+ free(fragShader);
// Re-order according to declaration order in the fragment source.
- uint32_t samplerUniformCount = static_cast<uint32_t>( samplerUniformLocations.size() );
- if( samplerUniformCount > 1 )
+ uint32_t samplerUniformCount = static_cast<uint32_t>(samplerUniformLocations.size());
+ if(samplerUniformCount > 1)
{
- std::sort( samplerUniformLocations.begin(), samplerUniformLocations.end(), sortByPosition);
+ std::sort(samplerUniformLocations.begin(), samplerUniformLocations.end(), sortByPosition);
}
- mSamplerUniformLocations.resize( samplerUniformCount );
- for( uint32_t i=0; i<samplerUniformCount; ++i )
+ mSamplerUniformLocations.resize(samplerUniformCount);
+ for(uint32_t i = 0; i < samplerUniformCount; ++i)
{
mSamplerUniformLocations[i] = samplerUniformLocations[i].uniformLocation;
}
}
-bool Program::GetSamplerUniformLocation( uint32_t index, GLint& location )
+bool Program::GetSamplerUniformLocation(uint32_t index, GLint& location)
{
bool result = false;
- if( index < mSamplerUniformLocations.size() )
+ if(index < mSamplerUniformLocations.size())
{
location = mSamplerUniformLocations[index];
- result = true;
+ result = true;
}
return result;
}
uint32_t Program::GetActiveSamplerCount() const
{
- return static_cast<uint32_t>( mSamplerUniformLocations.size() );
+ return static_cast<uint32_t>(mSamplerUniformLocations.size());
}
-void Program::SetUniform1i( GLint location, GLint value0 )
+void Program::SetUniform1i(GLint location, GLint value0)
{
- DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used
+ DALI_ASSERT_DEBUG(IsUsed()); // should not call this if this program is not used
- if( UNIFORM_UNKNOWN == location )
+ if(UNIFORM_UNKNOWN == location)
{
// From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes
// If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the
}
// check if uniform location fits the cache
- if( location >= MAX_UNIFORM_CACHE_SIZE )
+ if(location >= MAX_UNIFORM_CACHE_SIZE)
{
// not cached, make the gl call
- LOG_GL( "Uniform1i(%d,%d)\n", location, value0 );
- CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform1i( location, value0 ) );
+ LOG_GL("Uniform1i(%d,%d)\n", location, value0);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.Uniform1i(location, value0));
}
else
{
// check if the value is different from what's already been set
- if( value0 != mUniformCacheInt[ location ] )
+ if(value0 != mUniformCacheInt[location])
{
// make the gl call
- LOG_GL( "Uniform1i(%d,%d)\n", location, value0 );
- CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform1i( location, value0 ) );
+ LOG_GL("Uniform1i(%d,%d)\n", location, value0);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.Uniform1i(location, value0));
// update cache
- mUniformCacheInt[ location ] = value0;
+ mUniformCacheInt[location] = value0;
}
}
}
-void Program::SetUniform4i( GLint location, GLint value0, GLint value1, GLint value2, GLint value3 )
+void Program::SetUniform4i(GLint location, GLint value0, GLint value1, GLint value2, GLint value3)
{
- DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used
+ DALI_ASSERT_DEBUG(IsUsed()); // should not call this if this program is not used
- if( UNIFORM_UNKNOWN == location )
+ if(UNIFORM_UNKNOWN == location)
{
// From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes
// If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the
}
// Not caching these as based on current analysis this is not called that often by our shaders
- LOG_GL( "Uniform4i(%d,%d,%d,%d,%d)\n", location, value0, value1, value2, value3 );
- CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform4i( location, value0, value1, value2, value3 ) );
+ LOG_GL("Uniform4i(%d,%d,%d,%d,%d)\n", location, value0, value1, value2, value3);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.Uniform4i(location, value0, value1, value2, value3));
}
-void Program::SetUniform1f( GLint location, GLfloat value0 )
+void Program::SetUniform1f(GLint location, GLfloat value0)
{
- DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used
+ DALI_ASSERT_DEBUG(IsUsed()); // should not call this if this program is not used
- if( UNIFORM_UNKNOWN == location )
+ if(UNIFORM_UNKNOWN == location)
{
// From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes
// If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the
}
// check if uniform location fits the cache
- if( location >= MAX_UNIFORM_CACHE_SIZE )
+ if(location >= MAX_UNIFORM_CACHE_SIZE)
{
// not cached, make the gl call
- LOG_GL( "Uniform1f(%d,%f)\n", location, value0 );
- CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform1f( location, value0 ) );
+ LOG_GL("Uniform1f(%d,%f)\n", location, value0);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.Uniform1f(location, value0));
}
else
{
// check if the same value has already been set, reset if it is different
- if( ( fabsf(value0 - mUniformCacheFloat[ location ]) >= Math::MACHINE_EPSILON_1 ) )
+ if((fabsf(value0 - mUniformCacheFloat[location]) >= Math::MACHINE_EPSILON_1))
{
// make the gl call
- LOG_GL( "Uniform1f(%d,%f)\n", location, value0 );
- CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform1f( location, value0 ) );
+ LOG_GL("Uniform1f(%d,%f)\n", location, value0);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.Uniform1f(location, value0));
// update cache
- mUniformCacheFloat[ location ] = value0;
+ mUniformCacheFloat[location] = value0;
}
}
}
-void Program::SetUniform2f( GLint location, GLfloat value0, GLfloat value1 )
+void Program::SetUniform2f(GLint location, GLfloat value0, GLfloat value1)
{
- DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used
+ DALI_ASSERT_DEBUG(IsUsed()); // should not call this if this program is not used
- if( UNIFORM_UNKNOWN == location )
+ if(UNIFORM_UNKNOWN == location)
{
// From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes
// If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the
}
// check if uniform location fits the cache
- if( location >= MAX_UNIFORM_CACHE_SIZE )
+ if(location >= MAX_UNIFORM_CACHE_SIZE)
{
// not cached, make the gl call
- LOG_GL( "Uniform2f(%d,%f,%f)\n", location, value0, value1 );
- CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform2f( location, value0, value1 ) );
+ LOG_GL("Uniform2f(%d,%f,%f)\n", location, value0, value1);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.Uniform2f(location, value0, value1));
}
else
{
// check if the same value has already been set, reset if it is different
- if( ( fabsf(value0 - mUniformCacheFloat2[ location ][ 0 ]) >= Math::MACHINE_EPSILON_1 )||
- ( fabsf(value1 - mUniformCacheFloat2[ location ][ 1 ]) >= Math::MACHINE_EPSILON_1 ) )
+ if((fabsf(value0 - mUniformCacheFloat2[location][0]) >= Math::MACHINE_EPSILON_1) ||
+ (fabsf(value1 - mUniformCacheFloat2[location][1]) >= Math::MACHINE_EPSILON_1))
{
// make the gl call
- LOG_GL( "Uniform2f(%d,%f,%f)\n", location, value0, value1 );
- CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform2f( location, value0, value1 ) );
+ LOG_GL("Uniform2f(%d,%f,%f)\n", location, value0, value1);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.Uniform2f(location, value0, value1));
// update cache
- mUniformCacheFloat2[ location ][ 0 ] = value0;
- mUniformCacheFloat2[ location ][ 1 ] = value1;
+ mUniformCacheFloat2[location][0] = value0;
+ mUniformCacheFloat2[location][1] = value1;
}
}
}
-void Program::SetSizeUniform3f( GLint location, GLfloat value0, GLfloat value1, GLfloat value2 )
+void Program::SetSizeUniform3f(GLint location, GLfloat value0, GLfloat value1, GLfloat value2)
{
- if( ( fabsf(value0 - mSizeUniformCache.x) >= Math::MACHINE_EPSILON_1 )||
- ( fabsf(value1 - mSizeUniformCache.y) >= Math::MACHINE_EPSILON_1 )||
- ( fabsf(value2 - mSizeUniformCache.z) >= Math::MACHINE_EPSILON_1 ) )
+ if((fabsf(value0 - mSizeUniformCache.x) >= Math::MACHINE_EPSILON_1) ||
+ (fabsf(value1 - mSizeUniformCache.y) >= Math::MACHINE_EPSILON_1) ||
+ (fabsf(value2 - mSizeUniformCache.z) >= Math::MACHINE_EPSILON_1))
{
mSizeUniformCache.x = value0;
mSizeUniformCache.y = value1;
mSizeUniformCache.z = value2;
- SetUniform3f( location, value0, value1, value2 );
+ SetUniform3f(location, value0, value1, value2);
}
}
-void Program::SetUniform3f( GLint location, GLfloat value0, GLfloat value1, GLfloat value2 )
+void Program::SetUniform3f(GLint location, GLfloat value0, GLfloat value1, GLfloat value2)
{
- DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used
+ DALI_ASSERT_DEBUG(IsUsed()); // should not call this if this program is not used
- if( UNIFORM_UNKNOWN == location )
+ if(UNIFORM_UNKNOWN == location)
{
// From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes
// If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the
}
// Not caching these as based on current analysis this is not called that often by our shaders
- LOG_GL( "Uniform3f(%d,%f,%f,%f)\n", location, value0, value1, value2 );
- CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform3f( location, value0, value1, value2 ) );
+ LOG_GL("Uniform3f(%d,%f,%f,%f)\n", location, value0, value1, value2);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.Uniform3f(location, value0, value1, value2));
}
-void Program::SetUniform4f( GLint location, GLfloat value0, GLfloat value1, GLfloat value2, GLfloat value3 )
+void Program::SetUniform4f(GLint location, GLfloat value0, GLfloat value1, GLfloat value2, GLfloat value3)
{
- DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used
+ DALI_ASSERT_DEBUG(IsUsed()); // should not call this if this program is not used
- if( UNIFORM_UNKNOWN == location )
+ if(UNIFORM_UNKNOWN == location)
{
// From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes
// If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the
}
// check if uniform location fits the cache
- if( location >= MAX_UNIFORM_CACHE_SIZE )
+ if(location >= MAX_UNIFORM_CACHE_SIZE)
{
// not cached, make the gl call
- LOG_GL( "Uniform4f(%d,%f,%f,%f,%f)\n", location, value0, value1, value2, value3 );
- CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform4f( location, value0, value1, value2, value3 ) );
+ LOG_GL("Uniform4f(%d,%f,%f,%f,%f)\n", location, value0, value1, value2, value3);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.Uniform4f(location, value0, value1, value2, value3));
}
else
{
// check if the same value has already been set, reset if any component is different
// checking index 3 first because we're often animating alpha (rgba)
- if( ( fabsf(value3 - mUniformCacheFloat4[ location ][ 3 ]) >= Math::MACHINE_EPSILON_1 )||
- ( fabsf(value0 - mUniformCacheFloat4[ location ][ 0 ]) >= Math::MACHINE_EPSILON_1 )||
- ( fabsf(value1 - mUniformCacheFloat4[ location ][ 1 ]) >= Math::MACHINE_EPSILON_1 )||
- ( fabsf(value2 - mUniformCacheFloat4[ location ][ 2 ]) >= Math::MACHINE_EPSILON_1 ) )
+ if((fabsf(value3 - mUniformCacheFloat4[location][3]) >= Math::MACHINE_EPSILON_1) ||
+ (fabsf(value0 - mUniformCacheFloat4[location][0]) >= Math::MACHINE_EPSILON_1) ||
+ (fabsf(value1 - mUniformCacheFloat4[location][1]) >= Math::MACHINE_EPSILON_1) ||
+ (fabsf(value2 - mUniformCacheFloat4[location][2]) >= Math::MACHINE_EPSILON_1))
{
// make the gl call
- LOG_GL( "Uniform4f(%d,%f,%f,%f,%f)\n", location, value0, value1, value2, value3 );
- CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform4f( location, value0, value1, value2, value3 ) );
+ LOG_GL("Uniform4f(%d,%f,%f,%f,%f)\n", location, value0, value1, value2, value3);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.Uniform4f(location, value0, value1, value2, value3));
// update cache
- mUniformCacheFloat4[ location ][ 0 ] = value0;
- mUniformCacheFloat4[ location ][ 1 ] = value1;
- mUniformCacheFloat4[ location ][ 2 ] = value2;
- mUniformCacheFloat4[ location ][ 3 ] = value3;
+ mUniformCacheFloat4[location][0] = value0;
+ mUniformCacheFloat4[location][1] = value1;
+ mUniformCacheFloat4[location][2] = value2;
+ mUniformCacheFloat4[location][3] = value3;
}
}
}
-void Program::SetUniformMatrix4fv( GLint location, GLsizei count, const GLfloat* value )
+void Program::SetUniformMatrix4fv(GLint location, GLsizei count, const GLfloat* value)
{
- DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used
+ DALI_ASSERT_DEBUG(IsUsed()); // should not call this if this program is not used
- if( UNIFORM_UNKNOWN == location )
+ if(UNIFORM_UNKNOWN == location)
{
// From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes
// If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the
// Not caching these calls. Based on current analysis this is called very often
// but with different values (we're using this for MVP matrices)
// NOTE! we never want driver or GPU to transpose
- LOG_GL( "UniformMatrix4fv(%d,%d,GL_FALSE,%x)\n", location, count, value );
- CHECK_GL( mGlAbstraction, mGlAbstraction.UniformMatrix4fv( location, count, GL_FALSE, value ) );
+ LOG_GL("UniformMatrix4fv(%d,%d,GL_FALSE,%x)\n", location, count, value);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.UniformMatrix4fv(location, count, GL_FALSE, value));
}
-void Program::SetUniformMatrix3fv( GLint location, GLsizei count, const GLfloat* value )
+void Program::SetUniformMatrix3fv(GLint location, GLsizei count, const GLfloat* value)
{
- DALI_ASSERT_DEBUG( IsUsed() ); // should not call this if this program is not used
+ DALI_ASSERT_DEBUG(IsUsed()); // should not call this if this program is not used
- if( UNIFORM_UNKNOWN == location )
+ if(UNIFORM_UNKNOWN == location)
{
// From http://www.khronos.org/opengles/sdk/docs/man/xhtml/glUniform.xml : Notes
// If location is equal to UNIFORM_UNKNOWN, the data passed in will be silently ignored and the
return;
}
-
// Not caching these calls. Based on current analysis this is called very often
// but with different values (we're using this for MVP matrices)
// NOTE! we never want driver or GPU to transpose
- LOG_GL( "UniformMatrix3fv(%d,%d,GL_FALSE,%x)\n", location, count, value );
- CHECK_GL( mGlAbstraction, mGlAbstraction.UniformMatrix3fv( location, count, GL_FALSE, value ) );
+ LOG_GL("UniformMatrix3fv(%d,%d,GL_FALSE,%x)\n", location, count, value);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.UniformMatrix3fv(location, count, GL_FALSE, value));
}
void Program::GlContextCreated()
void Program::GlContextDestroyed()
{
- mLinked = false;
- mVertexShaderId = 0;
+ mLinked = false;
+ mVertexShaderId = 0;
mFragmentShaderId = 0;
- mProgramId = 0;
+ mProgramId = 0;
ResetAttribsUniformCache();
}
return mModifiesGeometry;
}
-Program::Program( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry )
-: mCache( cache ),
- mGlAbstraction( mCache.GetGlAbstraction() ),
- mProjectionMatrix( nullptr ),
- mViewMatrix( nullptr ),
- mLinked( false ),
- mVertexShaderId( 0 ),
- mFragmentShaderId( 0 ),
- mProgramId( 0 ),
+Program::Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry)
+: mCache(cache),
+ mGlAbstraction(mCache.GetGlAbstraction()),
+ mProjectionMatrix(nullptr),
+ mViewMatrix(nullptr),
+ mLinked(false),
+ mVertexShaderId(0),
+ mFragmentShaderId(0),
+ mProgramId(0),
mProgramData(shaderData),
- mModifiesGeometry( modifiesGeometry )
+ mModifiesGeometry(modifiesGeometry)
{
// reserve space for standard attributes
- mAttributeLocations.reserve( ATTRIB_TYPE_LAST );
- for( uint32_t i = 0; i < ATTRIB_TYPE_LAST; ++i )
+ mAttributeLocations.reserve(ATTRIB_TYPE_LAST);
+ for(uint32_t i = 0; i < ATTRIB_TYPE_LAST; ++i)
{
- RegisterCustomAttribute( ConstString(gStdAttribs[i]) );
+ RegisterCustomAttribute(ConstString(gStdAttribs[i]));
}
// reserve space for standard uniforms
- mUniformLocations.reserve( UNIFORM_TYPE_LAST );
+ mUniformLocations.reserve(UNIFORM_TYPE_LAST);
// reset built in uniform names in cache
- for( uint32_t i = 0; i < UNIFORM_TYPE_LAST; ++i )
+ for(uint32_t i = 0; i < UNIFORM_TYPE_LAST; ++i)
{
- RegisterUniform( ConstString(gStdUniforms[ i ]) );
+ RegisterUniform(ConstString(gStdUniforms[i]));
}
// reset values
void Program::Load()
{
- DALI_ASSERT_ALWAYS( nullptr != mProgramData.Get() && "Program data is not initialized" );
- DALI_ASSERT_DEBUG( mProgramId == 0 && "mProgramId != 0, so about to leak a GL resource by overwriting it." );
+ DALI_ASSERT_ALWAYS(nullptr != mProgramData.Get() && "Program data is not initialized");
+ DALI_ASSERT_DEBUG(mProgramId == 0 && "mProgramId != 0, so about to leak a GL resource by overwriting it.");
- LOG_GL( "CreateProgram()\n" );
- mProgramId = CHECK_GL( mGlAbstraction, mGlAbstraction.CreateProgram() );
+ LOG_GL("CreateProgram()\n");
+ mProgramId = CHECK_GL(mGlAbstraction, mGlAbstraction.CreateProgram());
GLint linked = GL_FALSE;
const bool binariesSupported = mCache.IsBinarySupported();
// if shader binaries are supported and ShaderData contains compiled bytecode?
- if( binariesSupported && mProgramData->HasBinary() )
+ if(binariesSupported && mProgramData->HasBinary())
{
DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "Program::Load() - Using Compiled Shader, Size = %d\n", mProgramData->GetBufferSize());
- CHECK_GL( mGlAbstraction, mGlAbstraction.ProgramBinary(mProgramId, mCache.ProgramBinaryFormat(), mProgramData->GetBufferData(), static_cast<GLsizei>( mProgramData->GetBufferSize() ) ) ); // truncated
+ CHECK_GL(mGlAbstraction, mGlAbstraction.ProgramBinary(mProgramId, mCache.ProgramBinaryFormat(), mProgramData->GetBufferData(), static_cast<GLsizei>(mProgramData->GetBufferSize()))); // truncated
- CHECK_GL( mGlAbstraction, mGlAbstraction.ValidateProgram(mProgramId) );
+ CHECK_GL(mGlAbstraction, mGlAbstraction.ValidateProgram(mProgramId));
GLint success;
- CHECK_GL( mGlAbstraction, mGlAbstraction.GetProgramiv( mProgramId, GL_VALIDATE_STATUS, &success ) );
+ CHECK_GL(mGlAbstraction, mGlAbstraction.GetProgramiv(mProgramId, GL_VALIDATE_STATUS, &success));
DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "ValidateProgram Status = %d\n", success);
- CHECK_GL( mGlAbstraction, mGlAbstraction.GetProgramiv( mProgramId, GL_LINK_STATUS, &linked ) );
+ CHECK_GL(mGlAbstraction, mGlAbstraction.GetProgramiv(mProgramId, GL_LINK_STATUS, &linked));
- if( GL_FALSE == linked )
+ if(GL_FALSE == linked)
{
DALI_LOG_ERROR("Failed to load program binary \n");
GLint nLength;
- CHECK_GL( mGlAbstraction, mGlAbstraction.GetProgramiv( mProgramId, GL_INFO_LOG_LENGTH, &nLength) );
+ CHECK_GL(mGlAbstraction, mGlAbstraction.GetProgramiv(mProgramId, GL_INFO_LOG_LENGTH, &nLength));
if(nLength > 0)
{
- Dali::Vector< char > szLog;
- szLog.Reserve( nLength ); // Don't call Resize as we don't want to initialise the data, just reserve a buffer
- CHECK_GL( mGlAbstraction, mGlAbstraction.GetProgramInfoLog( mProgramId, nLength, &nLength, szLog.Begin() ) );
- DALI_LOG_ERROR( "Program Link Error: %s\n", szLog.Begin() );
+ Dali::Vector<char> szLog;
+ szLog.Reserve(nLength); // Don't call Resize as we don't want to initialise the data, just reserve a buffer
+ CHECK_GL(mGlAbstraction, mGlAbstraction.GetProgramInfoLog(mProgramId, nLength, &nLength, szLog.Begin()));
+ DALI_LOG_ERROR("Program Link Error: %s\n", szLog.Begin());
}
}
else
{
mLinked = true;
- DALI_LOG_INFO( Debug::Filter::gShader, Debug::General, "Reused binary.\n" );
+ DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "Reused binary.\n");
}
}
// Fall back to compiling and linking the vertex and fragment sources
- if( GL_FALSE == linked )
+ if(GL_FALSE == linked)
{
DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "Program::Load() - Runtime compilation\n");
- if( CompileShader( GL_VERTEX_SHADER, mVertexShaderId, mProgramData->GetVertexShader() ) )
+ if(CompileShader(GL_VERTEX_SHADER, mVertexShaderId, mProgramData->GetVertexShader()))
{
- if( CompileShader( GL_FRAGMENT_SHADER, mFragmentShaderId, mProgramData->GetFragmentShader() ) )
+ if(CompileShader(GL_FRAGMENT_SHADER, mFragmentShaderId, mProgramData->GetFragmentShader()))
{
Link();
- if( binariesSupported && mLinked )
+ if(binariesSupported && mLinked)
{
GLint binaryLength = 0;
GLenum binaryFormat;
- DALI_LOG_INFO( Debug::Filter::gShader, Debug::General, "Compiled and linked.\n\nVS:\n%s\nFS:\n%s\n", mProgramData->GetVertexShader(), mProgramData->GetFragmentShader() );
+ DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "Compiled and linked.\n\nVS:\n%s\nFS:\n%s\n", mProgramData->GetVertexShader(), mProgramData->GetFragmentShader());
- CHECK_GL( mGlAbstraction, mGlAbstraction.GetProgramiv(mProgramId, GL_PROGRAM_BINARY_LENGTH_OES, &binaryLength) );
+ CHECK_GL(mGlAbstraction, mGlAbstraction.GetProgramiv(mProgramId, GL_PROGRAM_BINARY_LENGTH_OES, &binaryLength));
DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "Program::Load() - GL_PROGRAM_BINARY_LENGTH_OES: %d\n", binaryLength);
- if( binaryLength > 0 )
+ if(binaryLength > 0)
{
// Allocate space for the bytecode in ShaderData
mProgramData->AllocateBuffer(binaryLength);
// Copy the bytecode to ShaderData
- CHECK_GL( mGlAbstraction, mGlAbstraction.GetProgramBinary(mProgramId, binaryLength, nullptr, &binaryFormat, mProgramData->GetBufferData()) );
- mCache.StoreBinary( mProgramData );
- DALI_LOG_INFO( Debug::Filter::gShader, Debug::General, "Saved binary.\n" );
+ CHECK_GL(mGlAbstraction, mGlAbstraction.GetProgramBinary(mProgramId, binaryLength, nullptr, &binaryFormat, mProgramData->GetBufferData()));
+ mCache.StoreBinary(mProgramData);
+ DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "Saved binary.\n");
}
}
}
{
FreeShaders();
- if( this == mCache.GetCurrentProgram() )
+ if(this == mCache.GetCurrentProgram())
{
- CHECK_GL( mGlAbstraction, mGlAbstraction.UseProgram(0) );
+ CHECK_GL(mGlAbstraction, mGlAbstraction.UseProgram(0));
- mCache.SetCurrentProgram( nullptr );
+ mCache.SetCurrentProgram(nullptr);
}
- if (mProgramId)
+ if(mProgramId)
{
- LOG_GL( "DeleteProgram(%d)\n", mProgramId );
- CHECK_GL( mGlAbstraction, mGlAbstraction.DeleteProgram( mProgramId ) );
+ LOG_GL("DeleteProgram(%d)\n", mProgramId);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.DeleteProgram(mProgramId));
mProgramId = 0;
}
mLinked = false;
-
}
-bool Program::CompileShader( GLenum shaderType, GLuint& shaderId, const char* src )
+bool Program::CompileShader(GLenum shaderType, GLuint& shaderId, const char* src)
{
- if (!shaderId)
+ if(!shaderId)
{
- LOG_GL( "CreateShader(%d)\n", shaderType );
- shaderId = CHECK_GL( mGlAbstraction, mGlAbstraction.CreateShader( shaderType ) );
- LOG_GL( "AttachShader(%d,%d)\n", mProgramId, shaderId );
- CHECK_GL( mGlAbstraction, mGlAbstraction.AttachShader( mProgramId, shaderId ) );
+ LOG_GL("CreateShader(%d)\n", shaderType);
+ shaderId = CHECK_GL(mGlAbstraction, mGlAbstraction.CreateShader(shaderType));
+ LOG_GL("AttachShader(%d,%d)\n", mProgramId, shaderId);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.AttachShader(mProgramId, shaderId));
}
- LOG_GL( "ShaderSource(%d)\n", shaderId );
- CHECK_GL( mGlAbstraction, mGlAbstraction.ShaderSource(shaderId, 1, &src, nullptr ) );
+ LOG_GL("ShaderSource(%d)\n", shaderId);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.ShaderSource(shaderId, 1, &src, nullptr));
- LOG_GL( "CompileShader(%d)\n", shaderId );
- CHECK_GL( mGlAbstraction, mGlAbstraction.CompileShader( shaderId ) );
+ LOG_GL("CompileShader(%d)\n", shaderId);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.CompileShader(shaderId));
GLint compiled;
- LOG_GL( "GetShaderiv(%d)\n", shaderId );
- CHECK_GL( mGlAbstraction, mGlAbstraction.GetShaderiv( shaderId, GL_COMPILE_STATUS, &compiled ) );
+ LOG_GL("GetShaderiv(%d)\n", shaderId);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.GetShaderiv(shaderId, GL_COMPILE_STATUS, &compiled));
- if (compiled == GL_FALSE)
+ if(compiled == GL_FALSE)
{
DALI_LOG_ERROR("Failed to compile shader\n");
LogWithLineNumbers(src);
GLint nLength;
- mGlAbstraction.GetShaderiv( shaderId, GL_INFO_LOG_LENGTH, &nLength);
+ mGlAbstraction.GetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &nLength);
if(nLength > 0)
{
- Dali::Vector< char > szLog;
- szLog.Reserve( nLength ); // Don't call Resize as we don't want to initialise the data, just reserve a buffer
- mGlAbstraction.GetShaderInfoLog( shaderId, nLength, &nLength, szLog.Begin() );
- DALI_LOG_ERROR( "Shader Compiler Error: %s\n", szLog.Begin() );
+ Dali::Vector<char> szLog;
+ szLog.Reserve(nLength); // Don't call Resize as we don't want to initialise the data, just reserve a buffer
+ mGlAbstraction.GetShaderInfoLog(shaderId, nLength, &nLength, szLog.Begin());
+ DALI_LOG_ERROR("Shader Compiler Error: %s\n", szLog.Begin());
}
- DALI_ASSERT_ALWAYS( 0 && "Shader compilation failure" );
+ DALI_ASSERT_ALWAYS(0 && "Shader compilation failure");
}
return compiled != 0;
void Program::Link()
{
- LOG_GL( "LinkProgram(%d)\n", mProgramId );
- CHECK_GL( mGlAbstraction, mGlAbstraction.LinkProgram( mProgramId ) );
+ LOG_GL("LinkProgram(%d)\n", mProgramId);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.LinkProgram(mProgramId));
GLint linked;
- LOG_GL( "GetProgramiv(%d)\n", mProgramId );
- CHECK_GL( mGlAbstraction, mGlAbstraction.GetProgramiv( mProgramId, GL_LINK_STATUS, &linked ) );
+ LOG_GL("GetProgramiv(%d)\n", mProgramId);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.GetProgramiv(mProgramId, GL_LINK_STATUS, &linked));
- if (linked == GL_FALSE)
+ if(linked == GL_FALSE)
{
DALI_LOG_ERROR("Shader failed to link \n");
GLint nLength;
- mGlAbstraction.GetProgramiv( mProgramId, GL_INFO_LOG_LENGTH, &nLength);
+ mGlAbstraction.GetProgramiv(mProgramId, GL_INFO_LOG_LENGTH, &nLength);
if(nLength > 0)
{
- Dali::Vector< char > szLog;
- szLog.Reserve( nLength ); // Don't call Resize as we don't want to initialise the data, just reserve a buffer
- mGlAbstraction.GetProgramInfoLog( mProgramId, nLength, &nLength, szLog.Begin() );
- DALI_LOG_ERROR( "Shader Link Error: %s\n", szLog.Begin() );
+ Dali::Vector<char> szLog;
+ szLog.Reserve(nLength); // Don't call Resize as we don't want to initialise the data, just reserve a buffer
+ mGlAbstraction.GetProgramInfoLog(mProgramId, nLength, &nLength, szLog.Begin());
+ DALI_LOG_ERROR("Shader Link Error: %s\n", szLog.Begin());
}
- DALI_ASSERT_ALWAYS( 0 && "Shader linking failure" );
+ DALI_ASSERT_ALWAYS(0 && "Shader linking failure");
}
mLinked = linked != GL_FALSE;
void Program::FreeShaders()
{
- if (mVertexShaderId)
+ if(mVertexShaderId)
{
- LOG_GL( "DeleteShader(%d)\n", mVertexShaderId );
- CHECK_GL( mGlAbstraction, mGlAbstraction.DetachShader( mProgramId, mVertexShaderId ) );
- CHECK_GL( mGlAbstraction, mGlAbstraction.DeleteShader( mVertexShaderId ) );
+ LOG_GL("DeleteShader(%d)\n", mVertexShaderId);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.DetachShader(mProgramId, mVertexShaderId));
+ CHECK_GL(mGlAbstraction, mGlAbstraction.DeleteShader(mVertexShaderId));
mVertexShaderId = 0;
}
- if (mFragmentShaderId)
+ if(mFragmentShaderId)
{
- LOG_GL( "DeleteShader(%d)\n", mFragmentShaderId );
- CHECK_GL( mGlAbstraction, mGlAbstraction.DetachShader( mProgramId, mFragmentShaderId ) );
- CHECK_GL( mGlAbstraction, mGlAbstraction.DeleteShader( mFragmentShaderId ) );
+ LOG_GL("DeleteShader(%d)\n", mFragmentShaderId);
+ CHECK_GL(mGlAbstraction, mGlAbstraction.DetachShader(mProgramId, mFragmentShaderId));
+ CHECK_GL(mGlAbstraction, mGlAbstraction.DeleteShader(mFragmentShaderId));
mFragmentShaderId = 0;
}
}
void Program::ResetAttribsUniformCache()
{
// reset attribute locations
- for( uint32_t i = 0; i < mAttributeLocations.size() ; ++i )
+ for(uint32_t i = 0; i < mAttributeLocations.size(); ++i)
{
- mAttributeLocations[ i ].second = ATTRIB_UNKNOWN;
+ mAttributeLocations[i].second = ATTRIB_UNKNOWN;
}
// reset all gl uniform locations
- for( uint32_t i = 0; i < mUniformLocations.size(); ++i )
+ for(uint32_t i = 0; i < mUniformLocations.size(); ++i)
{
// reset gl program locations and names
- mUniformLocations[ i ].second = UNIFORM_NOT_QUERIED;
+ mUniformLocations[i].second = UNIFORM_NOT_QUERIED;
}
mSamplerUniformLocations.clear();
// reset uniform caches
mSizeUniformCache.x = mSizeUniformCache.y = mSizeUniformCache.z = 0.f;
- for( uint32_t i = 0; i < MAX_UNIFORM_CACHE_SIZE; ++i )
+ for(uint32_t i = 0; i < MAX_UNIFORM_CACHE_SIZE; ++i)
{
// GL initializes uniforms to 0
- mUniformCacheInt[ i ] = 0;
- mUniformCacheFloat[ i ] = 0.0f;
- mUniformCacheFloat2[ i ][ 0 ] = 0.0f;
- mUniformCacheFloat2[ i ][ 1 ] = 0.0f;
- mUniformCacheFloat4[ i ][ 0 ] = 0.0f;
- mUniformCacheFloat4[ i ][ 1 ] = 0.0f;
- mUniformCacheFloat4[ i ][ 2 ] = 0.0f;
- mUniformCacheFloat4[ i ][ 3 ] = 0.0f;
+ mUniformCacheInt[i] = 0;
+ mUniformCacheFloat[i] = 0.0f;
+ mUniformCacheFloat2[i][0] = 0.0f;
+ mUniformCacheFloat2[i][1] = 0.0f;
+ mUniformCacheFloat4[i][0] = 0.0f;
+ mUniformCacheFloat4[i][1] = 0.0f;
+ mUniformCacheFloat4[i][2] = 0.0f;
+ mUniformCacheFloat4[i][3] = 0.0f;
}
}
#define DALI_INTERNAL_PROGRAM_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
// EXTERNAL INCLUDES
-#include <string>
#include <cstdint> // int32_t, uint32_t
+#include <string>
// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/object/ref-object.h>
#include <dali/integration-api/gl-abstraction.h>
-#include <dali/internal/common/shader-data.h>
#include <dali/internal/common/const-string.h>
+#include <dali/internal/common/shader-data.h>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/object/ref-object.h>
namespace Dali
{
-
class Matrix;
namespace Integration
{
class GlAbstraction;
class ShaderData;
-}
+} // namespace Integration
namespace Internal
{
-
class ProgramCache;
/**
class Program
{
public:
-
/**
* Size of the uniform cache per program
* GLES specification states that minimum uniform count for fragment shader
enum UniformType
{
UNIFORM_NOT_QUERIED = -2,
- UNIFORM_UNKNOWN = -1,
+ UNIFORM_UNKNOWN = -1,
UNIFORM_MVP_MATRIX,
UNIFORM_MODELVIEW_MATRIX,
UNIFORM_PROJECTION_MATRIX,
* @param[in] modifiesGeometry True if the shader modifies geometry
* @return pointer to the program
*/
- static Program* New( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
+ static Program* New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry);
/**
* Takes this program into use
* @param [in] type of the attribute
* @return the index of the attribute
*/
- GLint GetAttribLocation( AttribType type );
+ GLint GetAttribLocation(AttribType type);
/**
* Register an attribute name in our local cache
* @param [in] name attribute name
* @return the index of the attribute name in local cache
*/
- uint32_t RegisterCustomAttribute( ConstString name );
+ uint32_t RegisterCustomAttribute(ConstString name);
/**
* Gets the location of a pre-registered attribute.
* @param [in] attributeIndex of the attribute in local cache
* @return the index of the attribute in the GL program
*/
- GLint GetCustomAttributeLocation( uint32_t attributeIndex );
+ GLint GetCustomAttributeLocation(uint32_t attributeIndex);
/**
* Register a uniform name in our local cache
* @param [in] name uniform name
* @return the index of the uniform name in local cache
*/
- uint32_t RegisterUniform( ConstString name );
+ uint32_t RegisterUniform(ConstString name);
/**
* Gets the location of a pre-registered uniform.
* @param [in] uniformIndex of the uniform in local cache
* @return the index of the uniform in the GL program
*/
- GLint GetUniformLocation( uint32_t uniformIndex );
+ GLint GetUniformLocation(uint32_t uniformIndex);
/**
* Introspect the newly loaded shader to get the active sampler locations
* @param [out] location The location of the requested sampler
* @return true if the active sampler was found
*/
- bool GetSamplerUniformLocation( uint32_t index, GLint& location );
+ bool GetSamplerUniformLocation(uint32_t index, GLint& location);
/**
* Get the number of active samplers present in the shader
* @param [in] location of uniform
* @param [in] value0 as int
*/
- void SetUniform1i( GLint location, GLint value0 );
+ void SetUniform1i(GLint location, GLint value0);
/**
* Sets the uniform value
* @param [in] value2 as int
* @param [in] value3 as int
*/
- void SetUniform4i( GLint location, GLint value0, GLint value1, GLint value2, GLint value3 );
+ void SetUniform4i(GLint location, GLint value0, GLint value1, GLint value2, GLint value3);
/**
* Sets the uniform value
* @param [in] location of uniform
* @param [in] value0 as float
*/
- void SetUniform1f( GLint location, GLfloat value0 );
+ void SetUniform1f(GLint location, GLfloat value0);
/**
* Sets the uniform value
* @param [in] value0 as float
* @param [in] value1 as float
*/
- void SetUniform2f( GLint location, GLfloat value0, GLfloat value1 );
+ void SetUniform2f(GLint location, GLfloat value0, GLfloat value1);
/**
* Special handling for size as we're using uniform geometry so size is passed on to most programs
* @param [in] value1 as float
* @param [in] value2 as float
*/
- void SetSizeUniform3f( GLint location, GLfloat value0, GLfloat value1, GLfloat value2 );
+ void SetSizeUniform3f(GLint location, GLfloat value0, GLfloat value1, GLfloat value2);
/**
* Sets the uniform value
* @param [in] value1 as float
* @param [in] value2 as float
*/
- void SetUniform3f( GLint location, GLfloat value0, GLfloat value1, GLfloat value2 );
+ void SetUniform3f(GLint location, GLfloat value0, GLfloat value1, GLfloat value2);
/**
* Sets the uniform value
* @param [in] value2 as float
* @param [in] value3 as float
*/
- void SetUniform4f( GLint location, GLfloat value0, GLfloat value1, GLfloat value2, GLfloat value3 );
+ void SetUniform4f(GLint location, GLfloat value0, GLfloat value1, GLfloat value2, GLfloat value3);
/**
* Sets the uniform value as matrix. NOTE! we never want GPU to transpose
* @param [in] count Count of matrices
* @param [in] value values as float pointers
*/
- void SetUniformMatrix4fv( GLint location, GLsizei count, const GLfloat* value );
+ void SetUniformMatrix4fv(GLint location, GLsizei count, const GLfloat* value);
/**
* Sets the uniform value as matrix. NOTE! we never want GPU to transpose
* @param [in] count Count of matrices
* @param [in] value values as float pointers
*/
- void SetUniformMatrix3fv( GLint location, GLsizei count, const GLfloat* value );
+ void SetUniformMatrix3fv(GLint location, GLsizei count, const GLfloat* value);
/**
* Needs to be called when GL context is (re)created
* Set the projection matrix that has currently been sent
* @param matrix to set
*/
- void SetProjectionMatrix( const Matrix* matrix )
+ void SetProjectionMatrix(const Matrix* matrix)
{
mProjectionMatrix = matrix;
}
* Set the projection matrix that has currently been sent
* @param matrix to set
*/
- void SetViewMatrix( const Matrix* matrix )
+ void SetViewMatrix(const Matrix* matrix)
{
mViewMatrix = matrix;
}
}
private: // Implementation
-
/**
* Constructor, private so no direct instantiation
* @param[in] cache where the programs are stored
* @param[in] shaderData A smart pointer to a data structure containing the program source and binary
* @param[in] modifiesGeometry True if the vertex shader changes geometry
*/
- Program( ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry );
+ Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry);
public:
-
/**
* Destructor, non virtual as no virtual methods or inheritance
*/
~Program();
private:
-
- Program(); ///< default constructor, not defined
- Program( const Program& ); ///< copy constructor, not defined
- Program& operator=( const Program& ); ///< assignment operator, not defined
+ Program(); ///< default constructor, not defined
+ Program(const Program&); ///< copy constructor, not defined
+ Program& operator=(const Program&); ///< assignment operator, not defined
/**
* Load the shader, from a precompiled binary if available, else from source code
*/
void ResetAttribsUniformCache();
-private: // Data
-
- ProgramCache& mCache; ///< The program cache
- Integration::GlAbstraction& mGlAbstraction; ///< The OpenGL Abstraction layer
- const Matrix* mProjectionMatrix; ///< currently set projection matrix
- const Matrix* mViewMatrix; ///< currently set view matrix
- bool mLinked; ///< whether the program is linked
- GLuint mVertexShaderId; ///< GL identifier for vertex shader
- GLuint mFragmentShaderId; ///< GL identifier for fragment shader
- GLuint mProgramId; ///< GL identifier for program
- Internal::ShaderDataPtr mProgramData; ///< Shader program source and binary (when compiled & linked or loaded)
+private: // Data
+ ProgramCache& mCache; ///< The program cache
+ Integration::GlAbstraction& mGlAbstraction; ///< The OpenGL Abstraction layer
+ const Matrix* mProjectionMatrix; ///< currently set projection matrix
+ const Matrix* mViewMatrix; ///< currently set view matrix
+ bool mLinked; ///< whether the program is linked
+ GLuint mVertexShaderId; ///< GL identifier for vertex shader
+ GLuint mFragmentShaderId; ///< GL identifier for fragment shader
+ GLuint mProgramId; ///< GL identifier for program
+ Internal::ShaderDataPtr mProgramData; ///< Shader program source and binary (when compiled & linked or loaded)
// location caches
using NameLocationPair = std::pair<ConstString, GLint>;
using Locations = std::vector<NameLocationPair>;
- Locations mAttributeLocations; ///< attribute location cache
- Locations mUniformLocations; ///< uniform location cache
+ Locations mAttributeLocations; ///< attribute location cache
+ Locations mUniformLocations; ///< uniform location cache
std::vector<GLint> mSamplerUniformLocations; ///< sampler uniform location cache
// uniform value caching
- GLint mUniformCacheInt[ MAX_UNIFORM_CACHE_SIZE ]; ///< Value cache for uniforms of single int
- GLfloat mUniformCacheFloat[ MAX_UNIFORM_CACHE_SIZE ]; ///< Value cache for uniforms of single float
- GLfloat mUniformCacheFloat2[ MAX_UNIFORM_CACHE_SIZE ][2]; ///< Value cache for uniforms of two floats
- GLfloat mUniformCacheFloat4[ MAX_UNIFORM_CACHE_SIZE ][4]; ///< Value cache for uniforms of four floats
- Vector3 mSizeUniformCache; ///< Cache value for size uniform
- bool mModifiesGeometry; ///< True if the program changes geometry
-
+ GLint mUniformCacheInt[MAX_UNIFORM_CACHE_SIZE]; ///< Value cache for uniforms of single int
+ GLfloat mUniformCacheFloat[MAX_UNIFORM_CACHE_SIZE]; ///< Value cache for uniforms of single float
+ GLfloat mUniformCacheFloat2[MAX_UNIFORM_CACHE_SIZE][2]; ///< Value cache for uniforms of two floats
+ GLfloat mUniformCacheFloat4[MAX_UNIFORM_CACHE_SIZE][4]; ///< Value cache for uniforms of four floats
+ Vector3 mSizeUniformCache; ///< Cache value for size uniform
+ bool mModifiesGeometry; ///< True if the program changes geometry
};
} // namespace Internal
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/integration-api/debug.h>
-#include <dali/internal/render/queue/render-queue.h>
+#include <dali/internal/common/image-sampler.h>
#include <dali/internal/render/common/render-debug.h>
+#include <dali/internal/render/queue/render-queue.h>
#include <dali/internal/render/shaders/program.h>
-#include <dali/internal/common/image-sampler.h>
-
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
-Shader::Shader( Dali::Shader::Hint::Value& hints )
-: mHints( hints ),
- mProgram( nullptr ),
+Shader::Shader(Dali::Shader::Hint::Value& hints)
+: mHints(hints),
+ mProgram(nullptr),
mConnectionObservers()
{
- AddUniformMapObserver( *this );
+ AddUniformMapObserver(*this);
}
Shader::~Shader()
{
- mConnectionObservers.Destroy( *this );
+ mConnectionObservers.Destroy(*this);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// The following methods are called during RenderManager::Render()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void Shader::SetProgram( Internal::ShaderDataPtr shaderData,
- ProgramCache* programCache,
- bool modifiesGeometry )
+void Shader::SetProgram(Internal::ShaderDataPtr shaderData,
+ ProgramCache* programCache,
+ bool modifiesGeometry)
{
- DALI_LOG_TRACE_METHOD_FMT( Debug::Filter::gShader, "%d\n", shaderData->GetHashValue() );
+ DALI_LOG_TRACE_METHOD_FMT(Debug::Filter::gShader, "%d\n", shaderData->GetHashValue());
- mProgram = Program::New( *programCache, shaderData, modifiesGeometry );
+ mProgram = Program::New(*programCache, shaderData, modifiesGeometry);
// The program cache owns the Program object so we don't need to worry about this raw allocation here.
mConnectionObservers.ConnectionsChanged(*this);
return mProgram;
}
-void Shader::AddConnectionObserver( ConnectionChangePropagator::Observer& observer )
+void Shader::AddConnectionObserver(ConnectionChangePropagator::Observer& observer)
{
mConnectionObservers.Add(observer);
}
-void Shader::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer )
+void Shader::RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer)
{
mConnectionObservers.Remove(observer);
}
-void Shader::UniformMappingsChanged( const UniformMap& mappings )
+void Shader::UniformMappingsChanged(const UniformMap& mappings)
{
// Our uniform map, or that of one of the watched children has changed.
// Inform connected observers.
#define DALI_INTERNAL_SCENE_GRAPH_SHADER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/update/common/property-owner.h>
#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
-
namespace Dali
{
namespace Internal
{
-
class Program;
class ProgramCache;
namespace SceneGraph
{
-
class ConnectionObserver;
class SceneController;
/**
class Shader : public PropertyOwner, public UniformMap::Observer
{
public:
-
/**
* Constructor
* @param hints Shader hints
*/
- Shader( Dali::Shader::Hint::Value& hints );
+ Shader(Dali::Shader::Hint::Value& hints);
/**
* Virtual destructor
* @param[in] hint The hint to check.
* @return True if the given hint is set.
*/
- bool HintEnabled( Dali::Shader::Hint::Value hint ) const
+ bool HintEnabled(Dali::Shader::Hint::Value hint) const
{
return mHints & hint;
}
/**
* @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties
*/
- virtual void ResetDefaultProperties( BufferIndex updateBufferIndex )
+ virtual void ResetDefaultProperties(BufferIndex updateBufferIndex)
{
// no default properties
}
* @param[in] modifiesGeometry True if the vertex shader changes the positions of vertexes such that
* they might exceed the bounding box of vertexes passing through the default transformation.
*/
- void SetProgram( Internal::ShaderDataPtr shaderData,
- ProgramCache* programCache,
- bool modifiesGeometry );
+ void SetProgram(Internal::ShaderDataPtr shaderData,
+ ProgramCache* programCache,
+ bool modifiesGeometry);
/**
* Get the program built for this shader
Program* GetProgram();
public: // Implementation of ConnectionChangePropagator
-
/**
* @copydoc ConnectionChangePropagator::AddObserver
*/
/**
* @copydoc UniformMap::Observer::UniformMappingsChanged
*/
- void UniformMappingsChanged( const UniformMap& mappings ) override;
+ void UniformMappingsChanged(const UniformMap& mappings) override;
private: // Data
+ Dali::Shader::Hint::Value mHints;
- Dali::Shader::Hint::Value mHints;
-
- Program* mProgram;
+ Program* mProgram;
- ConnectionChangePropagator mConnectionObservers;
+ ConnectionChangePropagator mConnectionObservers;
};
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_ACCESSOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
#include <dali/internal/update/common/animatable-property.h>
#include <dali/internal/update/manager/transform-manager-property.h>
+#include <dali/public-api/common/dali-common.h>
namespace Dali
{
-
namespace Internal
{
-
/**
* A wrapper class for getting/setting a property.
* Animators use this instead of accessing properties directly.
*/
-template < typename PropertyType >
+template<typename PropertyType>
class PropertyAccessor
{
public:
-
/**
* Create a property component.
* @param [in] property The property to access.
*/
- PropertyAccessor( SceneGraph::PropertyBase* property )
- : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
+ PropertyAccessor(SceneGraph::PropertyBase* property)
+ : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
{
}
* Read access to the property.
* @param [in] bufferIndex The current update buffer index.
*/
- const PropertyType& Get( BufferIndex bufferIndex ) const
+ const PropertyType& Get(BufferIndex bufferIndex) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Get() mProperty was nullptr" );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyAccessor::Get() mProperty was nullptr");
const SceneGraph::AnimatableProperty<PropertyType>* property = mProperty;
- return property->Get( bufferIndex );
+ return property->Get(bufferIndex);
}
/**
* @copydoc AnimatableProperty<float>::Set()
*/
- void Set( BufferIndex bufferIndex, const PropertyType& value ) const
+ void Set(BufferIndex bufferIndex, const PropertyType& value) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Set() mProperty was nullptr" );
- mProperty->Set( bufferIndex, value );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyAccessor::Set() mProperty was nullptr");
+ mProperty->Set(bufferIndex, value);
}
/**
* @copydoc AnimatableProperty<float>::Bake()
*/
- void Bake( BufferIndex bufferIndex, const PropertyType& value ) const
+ void Bake(BufferIndex bufferIndex, const PropertyType& value) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Bake() mProperty was nullptr" );
- mProperty->Bake( bufferIndex, value );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyAccessor::Bake() mProperty was nullptr");
+ mProperty->Bake(bufferIndex, value);
}
private:
-
// Undefined
- PropertyAccessor() = delete;
+ PropertyAccessor() = delete;
PropertyAccessor(const PropertyAccessor& property) = delete;
PropertyAccessor& operator=(const PropertyAccessor& rhs) = delete;
private:
-
SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
-
};
/**
* A wrapper class for getting/setting a transform manager property
* Animators use this instead of accessing properties directly.
*/
-template <typename T>
+template<typename T>
class TransformManagerPropertyAccessor
{
public:
-
/**
* Create a property component.
* @param [in] property The property to access.
*/
- TransformManagerPropertyAccessor( SceneGraph::PropertyBase* property )
- : mProperty( static_cast< SceneGraph::TransformManagerPropertyHandler<T>* >(property) ) // we know the type
+ TransformManagerPropertyAccessor(SceneGraph::PropertyBase* property)
+ : mProperty(static_cast<SceneGraph::TransformManagerPropertyHandler<T>*>(property)) // we know the type
{
}
* @param [in] bufferIndex The current update buffer index.
* @return The value of the property
*/
- const T& Get( BufferIndex bufferIndex ) const
+ const T& Get(BufferIndex bufferIndex) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Get() mProperty was nullptr" );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyAccessor::Get() mProperty was nullptr");
const SceneGraph::TransformManagerPropertyHandler<T>* property = mProperty;
- return property->Get( bufferIndex );
+ return property->Get(bufferIndex);
}
/**
* @copydoc AnimatableProperty<float>::Set()
*/
- void Set( BufferIndex bufferIndex, const T& value ) const
+ void Set(BufferIndex bufferIndex, const T& value) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Set() mProperty was nullptr" );
- mProperty->Set( bufferIndex, value );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyAccessor::Set() mProperty was nullptr");
+ mProperty->Set(bufferIndex, value);
}
/**
* @copydoc AnimatableProperty<float>::Bake()
*/
- void Bake( BufferIndex bufferIndex, const T& value ) const
+ void Bake(BufferIndex bufferIndex, const T& value) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Bake() mProperty was nullptr" );
- mProperty->Bake( bufferIndex, value );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyAccessor::Bake() mProperty was nullptr");
+ mProperty->Bake(bufferIndex, value);
}
private:
-
// Undefined
- TransformManagerPropertyAccessor() = delete;
+ TransformManagerPropertyAccessor() = delete;
TransformManagerPropertyAccessor(const TransformManagerPropertyAccessor& property) = delete;
TransformManagerPropertyAccessor& operator=(const TransformManagerPropertyAccessor& rhs) = delete;
private:
-
SceneGraph::TransformManagerPropertyHandler<T>* mProperty; ///< The real property
-
};
/**
* A wrapper class for getting/setting a transform manager property component
* Animators use this instead of accessing properties directly.
*/
-template <typename T, uint32_t COMPONENT>
+template<typename T, uint32_t COMPONENT>
class TransformManagerPropertyComponentAccessor
{
public:
-
/**
* Create a property component.
* @param [in] property The property to access.
*/
- TransformManagerPropertyComponentAccessor( SceneGraph::PropertyBase* property )
- : mProperty( static_cast< SceneGraph::TransformManagerPropertyHandler<T>* >(property) ) // we know the type
+ TransformManagerPropertyComponentAccessor(SceneGraph::PropertyBase* property)
+ : mProperty(static_cast<SceneGraph::TransformManagerPropertyHandler<T>*>(property)) // we know the type
{
}
* @param [in] bufferIndex The current update buffer index.
* @return The value of the component of the property
*/
- float Get( BufferIndex bufferIndex ) const
+ float Get(BufferIndex bufferIndex) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Get() mProperty was nullptr" );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyAccessor::Get() mProperty was nullptr");
const SceneGraph::TransformManagerPropertyHandler<T>* property = mProperty;
- return property->GetFloatComponent( COMPONENT );
+ return property->GetFloatComponent(COMPONENT);
}
/**
* @copydoc AnimatableProperty<float>::Set()
*/
- void Set( BufferIndex bufferIndex, float value ) const
+ void Set(BufferIndex bufferIndex, float value) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Set() mProperty was nullptr" );
- mProperty->SetFloatComponent( value, COMPONENT );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyAccessor::Set() mProperty was nullptr");
+ mProperty->SetFloatComponent(value, COMPONENT);
}
/**
* @copydoc AnimatableProperty<float>::Bake()
*/
- void Bake( BufferIndex bufferIndex, float value ) const
+ void Bake(BufferIndex bufferIndex, float value) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyAccessor::Bake() mProperty was nullptr" );
- mProperty->BakeFloatComponent( value, COMPONENT );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyAccessor::Bake() mProperty was nullptr");
+ mProperty->BakeFloatComponent(value, COMPONENT);
}
private:
-
// Undefined
- TransformManagerPropertyComponentAccessor() = delete;
+ TransformManagerPropertyComponentAccessor() = delete;
TransformManagerPropertyComponentAccessor(const TransformManagerPropertyComponentAccessor& property) = delete;
TransformManagerPropertyComponentAccessor& operator=(const TransformManagerPropertyComponentAccessor& rhs) = delete;
private:
-
SceneGraph::TransformManagerPropertyHandler<T>* mProperty; ///< The real property
-
};
} // namespace Internal
#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_COMPONENT_ACCESSOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
#include <dali/internal/update/common/animatable-property.h>
+#include <dali/public-api/common/dali-common.h>
namespace Dali
{
-
namespace Internal
{
-
/**
* A wrapper class for getting/setting a float component of another property.
* Animators use this instead of accessing properties directly.
*/
-template < typename PropertyType >
+template<typename PropertyType>
class PropertyComponentAccessorX
{
public:
-
/**
* Create a property component.
* @param [in] property The property which holds a float component.
*/
- PropertyComponentAccessorX( SceneGraph::PropertyBase* property )
- : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
+ PropertyComponentAccessorX(SceneGraph::PropertyBase* property)
+ : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
{
}
* Read access to the property.
* @param [in] bufferIndex The current update buffer index.
*/
- float Get( BufferIndex bufferIndex ) const
+ float Get(BufferIndex bufferIndex) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorX::Get() mProperty was nullptr" );
- return mProperty->Get( bufferIndex ).x; // X Component only!
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorX::Get() mProperty was nullptr");
+ return mProperty->Get(bufferIndex).x; // X Component only!
}
/**
* @copydoc SceneGraph::AnimatableProperty<float>::Set()
*/
- void Set( BufferIndex bufferIndex, float value ) const
+ void Set(BufferIndex bufferIndex, float value) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorX::Set() mProperty was nullptr" );
- mProperty->SetX( bufferIndex, value );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorX::Set() mProperty was nullptr");
+ mProperty->SetX(bufferIndex, value);
}
/**
* @copydoc SceneGraph::AnimatableProperty<float>::Bake()
*/
- void Bake( BufferIndex bufferIndex, float value ) const
+ void Bake(BufferIndex bufferIndex, float value) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorX::Bake() mProperty was nullptr" );
- mProperty->BakeX( bufferIndex, value );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorX::Bake() mProperty was nullptr");
+ mProperty->BakeX(bufferIndex, value);
}
private:
-
// Undefined
- PropertyComponentAccessorX() = delete;
+ PropertyComponentAccessorX() = delete;
PropertyComponentAccessorX(const PropertyComponentAccessorX& property) = delete;
PropertyComponentAccessorX& operator=(const PropertyComponentAccessorX& rhs) = delete;
private:
-
SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
-
};
/**
* A wrapper class for getting/setting a float component of another property.
* Animators use this instead of accessing properties directly.
*/
-template < typename PropertyType >
+template<typename PropertyType>
class PropertyComponentAccessorY
{
public:
-
/**
* Create a property component.
* @param [in] property The property which holds a float component.
*/
- PropertyComponentAccessorY( SceneGraph::PropertyBase* property )
- : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
+ PropertyComponentAccessorY(SceneGraph::PropertyBase* property)
+ : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
{
}
* Read access to the property.
* @param [in] bufferIndex The current update buffer index.
*/
- float Get( BufferIndex bufferIndex ) const
+ float Get(BufferIndex bufferIndex) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorY::Get() mProperty was nullptr" );
- return mProperty->Get( bufferIndex ).y; // Y Component only!
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorY::Get() mProperty was nullptr");
+ return mProperty->Get(bufferIndex).y; // Y Component only!
}
/**
* @copydoc SceneGraph::AnimatableProperty<float>::Set()
*/
- void Set( BufferIndex bufferIndex, float value ) const
+ void Set(BufferIndex bufferIndex, float value) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorY::Set() mProperty was nullptr" );
- mProperty->SetY( bufferIndex, value );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorY::Set() mProperty was nullptr");
+ mProperty->SetY(bufferIndex, value);
}
/**
* @copydoc SceneGraph::AnimatableProperty<float>::Bake()
*/
- void Bake( BufferIndex bufferIndex, float value ) const
+ void Bake(BufferIndex bufferIndex, float value) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorY::Bake() mProperty was nullptr" );
- mProperty->BakeY( bufferIndex, value );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorY::Bake() mProperty was nullptr");
+ mProperty->BakeY(bufferIndex, value);
}
private:
-
// Undefined
- PropertyComponentAccessorY() = delete;
+ PropertyComponentAccessorY() = delete;
PropertyComponentAccessorY(const PropertyComponentAccessorY& property) = delete;
PropertyComponentAccessorY& operator=(const PropertyComponentAccessorY& rhs) = delete;
private:
-
SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
};
* A wrapper class for getting/setting a float component of another property.
* Animators use this instead of accessing properties directly.
*/
-template < typename PropertyType >
+template<typename PropertyType>
class PropertyComponentAccessorZ
{
public:
-
/**
* Create a property component.
* @param [in] property The property which holds a float component.
*/
- PropertyComponentAccessorZ( SceneGraph::PropertyBase* property )
- : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
+ PropertyComponentAccessorZ(SceneGraph::PropertyBase* property)
+ : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
{
}
* Read access to the property.
* @param [in] bufferIndex The current update buffer index.
*/
- float Get( BufferIndex bufferIndex ) const
+ float Get(BufferIndex bufferIndex) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorZ::Get() mProperty was nullptr" );
- return mProperty->Get( bufferIndex ).z; // Z Component only!
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorZ::Get() mProperty was nullptr");
+ return mProperty->Get(bufferIndex).z; // Z Component only!
}
/**
* @copydoc SceneGraph::AnimatableProperty<float>::Set()
*/
- void Set( BufferIndex bufferIndex, float value ) const
+ void Set(BufferIndex bufferIndex, float value) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorZ::Set() mProperty was nullptr" );
- mProperty->SetZ( bufferIndex, value );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorZ::Set() mProperty was nullptr");
+ mProperty->SetZ(bufferIndex, value);
}
/**
* @copydoc SceneGraph::AnimatableProperty<float>::Bake()
*/
- void Bake( BufferIndex bufferIndex, float value ) const
+ void Bake(BufferIndex bufferIndex, float value) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorZ::Bake() mProperty was nullptr" );
- mProperty->BakeZ( bufferIndex, value );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorZ::Bake() mProperty was nullptr");
+ mProperty->BakeZ(bufferIndex, value);
}
private:
-
// Undefined
- PropertyComponentAccessorZ() = delete;
+ PropertyComponentAccessorZ() = delete;
PropertyComponentAccessorZ(const PropertyComponentAccessorZ& property) = delete;
PropertyComponentAccessorZ& operator=(const PropertyComponentAccessorZ& rhs) = delete;
private:
-
SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
};
* A wrapper class for getting/setting a float component of another property.
* Animators use this instead of accessing properties directly.
*/
-template < typename PropertyType >
+template<typename PropertyType>
class PropertyComponentAccessorW
{
public:
-
/**
* Create a property component.
* @param [in] property The property which holds a float component.
*/
- PropertyComponentAccessorW( SceneGraph::PropertyBase* property )
- : mProperty( static_cast< SceneGraph::AnimatableProperty<PropertyType>* >(property) ) // we know the type
+ PropertyComponentAccessorW(SceneGraph::PropertyBase* property)
+ : mProperty(static_cast<SceneGraph::AnimatableProperty<PropertyType>*>(property)) // we know the type
{
}
* Read access to the property.
* @param [in] bufferIndex The current update buffer index.
*/
- float Get( BufferIndex bufferIndex ) const
+ float Get(BufferIndex bufferIndex) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorW::Get() mProperty was nullptr" );
- return mProperty->Get( bufferIndex ).w; // W Component only!
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorW::Get() mProperty was nullptr");
+ return mProperty->Get(bufferIndex).w; // W Component only!
}
/**
* @copydoc SceneGraph::AnimatableProperty<float>::Set()
*/
- void Set( BufferIndex bufferIndex, float value ) const
+ void Set(BufferIndex bufferIndex, float value) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorW::Set() mProperty was nullptr" );
- mProperty->SetW( bufferIndex, value );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorW::Set() mProperty was nullptr");
+ mProperty->SetW(bufferIndex, value);
}
/**
* @copydoc SceneGraph::AnimatableProperty<float>::Bake()
*/
- void Bake( BufferIndex bufferIndex, float value ) const
+ void Bake(BufferIndex bufferIndex, float value) const
{
- DALI_ASSERT_DEBUG( nullptr != mProperty && "PropertyComponentAccessorW::Bake() mProperty was nullptr" );
- mProperty->BakeW( bufferIndex, value );
+ DALI_ASSERT_DEBUG(nullptr != mProperty && "PropertyComponentAccessorW::Bake() mProperty was nullptr");
+ mProperty->BakeW(bufferIndex, value);
}
private:
-
// Undefined
- PropertyComponentAccessorW() = delete;
+ PropertyComponentAccessorW() = delete;
PropertyComponentAccessorW(const PropertyComponentAccessorW& property) = delete;
PropertyComponentAccessorW& operator=(const PropertyComponentAccessorW& rhs) = delete;
private:
-
SceneGraph::AnimatableProperty<PropertyType>* mProperty; ///< The real property
-
};
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
//Memory pool used to allocate new animations. Memory used by this pool will be released when shutting down DALi
Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::Animation> gAnimationMemoryPool;
-inline void WrapInPlayRange( float& elapsed, const float& playRangeStartSeconds, const float& playRangeEndSeconds)
+inline void WrapInPlayRange(float& elapsed, const float& playRangeStartSeconds, const float& playRangeEndSeconds)
{
- if( elapsed > playRangeEndSeconds )
+ if(elapsed > playRangeEndSeconds)
{
- elapsed = playRangeStartSeconds + fmodf( ( elapsed - playRangeStartSeconds ), ( playRangeEndSeconds - playRangeStartSeconds ) );
+ elapsed = playRangeStartSeconds + fmodf((elapsed - playRangeStartSeconds), (playRangeEndSeconds - playRangeStartSeconds));
}
- else if( elapsed < playRangeStartSeconds )
+ else if(elapsed < playRangeStartSeconds)
{
- elapsed = playRangeEndSeconds - fmodf( ( playRangeStartSeconds - elapsed ), ( playRangeEndSeconds - playRangeStartSeconds ) );
+ elapsed = playRangeEndSeconds - fmodf((playRangeStartSeconds - elapsed), (playRangeEndSeconds - playRangeStartSeconds));
}
}
/// Compares the end times of the animators and if the end time is less, then it is moved earlier in the list. If end times are the same, then no change.
-bool CompareAnimatorEndTimes( const Dali::Internal::SceneGraph::AnimatorBase* lhs, const Dali::Internal::SceneGraph::AnimatorBase* rhs )
+bool CompareAnimatorEndTimes(const Dali::Internal::SceneGraph::AnimatorBase* lhs, const Dali::Internal::SceneGraph::AnimatorBase* rhs)
{
- return ( ( lhs->GetIntervalDelay() + lhs->GetDuration() ) < ( rhs->GetIntervalDelay() + rhs->GetDuration() ) );
+ return ((lhs->GetIntervalDelay() + lhs->GetDuration()) < (rhs->GetIntervalDelay() + rhs->GetDuration()));
}
} // unnamed namespace
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
-Animation* Animation::New( float durationSeconds, float speedFactor, const Vector2& playRange, int32_t loopCount, EndAction endAction, EndAction disconnectAction )
+Animation* Animation::New(float durationSeconds, float speedFactor, const Vector2& playRange, int32_t loopCount, EndAction endAction, EndAction disconnectAction)
{
- return new ( gAnimationMemoryPool.AllocateRawThreadSafe() ) Animation( durationSeconds, speedFactor, playRange, loopCount, endAction, disconnectAction );
+ return new(gAnimationMemoryPool.AllocateRawThreadSafe()) Animation(durationSeconds, speedFactor, playRange, loopCount, endAction, disconnectAction);
}
-Animation::Animation( float durationSeconds, float speedFactor, const Vector2& playRange, int32_t loopCount, Dali::Animation::EndAction endAction, Dali::Animation::EndAction disconnectAction )
-: mPlayRange( playRange ),
- mDurationSeconds( durationSeconds ),
- mDelaySeconds( 0.0f ),
- mElapsedSeconds( playRange.x*mDurationSeconds ),
- mSpeedFactor( speedFactor ),
- mProgressMarker( 0.0f ),
- mPlayedCount( 0 ),
+Animation::Animation(float durationSeconds, float speedFactor, const Vector2& playRange, int32_t loopCount, Dali::Animation::EndAction endAction, Dali::Animation::EndAction disconnectAction)
+: mPlayRange(playRange),
+ mDurationSeconds(durationSeconds),
+ mDelaySeconds(0.0f),
+ mElapsedSeconds(playRange.x * mDurationSeconds),
+ mSpeedFactor(speedFactor),
+ mProgressMarker(0.0f),
+ mPlayedCount(0),
mLoopCount(loopCount),
mCurrentLoop(0),
mEndAction(endAction),
mDisconnectAction(disconnectAction),
mState(Stopped),
- mProgressReachedSignalRequired( false ),
- mAutoReverseEnabled( false ),
- mIsActive{ false }
+ mProgressReachedSignalRequired(false),
+ mAutoReverseEnabled(false),
+ mIsActive{false}
{
}
Animation::~Animation() = default;
-void Animation::operator delete( void* ptr )
+void Animation::operator delete(void* ptr)
{
- gAnimationMemoryPool.FreeThreadSafe( static_cast<Animation*>( ptr ) );
+ gAnimationMemoryPool.FreeThreadSafe(static_cast<Animation*>(ptr));
}
void Animation::SetDuration(float durationSeconds)
mDurationSeconds = durationSeconds;
}
-void Animation::SetProgressNotification( float progress )
+void Animation::SetProgressNotification(float progress)
{
mProgressMarker = progress;
- if ( mProgressMarker > 0.0f )
+ if(mProgressMarker > 0.0f)
{
mProgressReachedSignalRequired = true;
}
void Animation::SetLoopCount(int32_t loopCount)
{
- mLoopCount = loopCount;
+ mLoopCount = loopCount;
mCurrentLoop = 0;
}
void Animation::SetDisconnectAction(Dali::Animation::EndAction action)
{
- if ( mDisconnectAction != action )
+ if(mDisconnectAction != action)
{
mDisconnectAction = action;
- for ( auto&& item : mAnimators )
+ for(auto&& item : mAnimators)
{
- item->SetDisconnectAction( action );
+ item->SetDisconnectAction(action);
}
}
}
-void Animation::SetPlayRange( const Vector2& range )
+void Animation::SetPlayRange(const Vector2& range)
{
mPlayRange = range;
// Make sure mElapsedSeconds is within the new range
- if( mState == Stopped )
+ if(mState == Stopped)
{
// Ensure that the animation starts at the right place
mElapsedSeconds = mPlayRange.x * mDurationSeconds;
// If already past the end of the range, but before end of duration, then clamp will
// ensure that the animation stops on the next update.
// If not yet at the start of the range, clamping will jump to the start
- mElapsedSeconds = Dali::Clamp(mElapsedSeconds, mPlayRange.x*mDurationSeconds , mPlayRange.y*mDurationSeconds );
+ mElapsedSeconds = Dali::Clamp(mElapsedSeconds, mPlayRange.x * mDurationSeconds, mPlayRange.y * mDurationSeconds);
}
}
void Animation::Play()
{
// Sort according to end time with earlier end times coming first, if the end time is the same, then the animators are not moved
- std::stable_sort( mAnimators.Begin(), mAnimators.End(), CompareAnimatorEndTimes );
+ std::stable_sort(mAnimators.Begin(), mAnimators.End(), CompareAnimatorEndTimes);
mState = Playing;
- if ( mSpeedFactor < 0.0f && mElapsedSeconds <= mPlayRange.x*mDurationSeconds )
+ if(mSpeedFactor < 0.0f && mElapsedSeconds <= mPlayRange.x * mDurationSeconds)
{
mElapsedSeconds = mPlayRange.y * mDurationSeconds;
}
- SetAnimatorsActive( true );
+ SetAnimatorsActive(true);
mCurrentLoop = 0;
}
-void Animation::PlayFrom( float progress )
+void Animation::PlayFrom(float progress)
{
// If the animation is already playing this has no effect
// Progress is guaranteed to be in range.
- if( mState != Playing )
+ if(mState != Playing)
{
mElapsedSeconds = progress * mDurationSeconds;
- mState = Playing;
+ mState = Playing;
- SetAnimatorsActive( true );
+ SetAnimatorsActive(true);
mCurrentLoop = 0;
}
}
-void Animation::PlayAfter( float delaySeconds )
+void Animation::PlayAfter(float delaySeconds)
{
- if( mState != Playing )
+ if(mState != Playing)
{
mDelaySeconds = delaySeconds;
- mState = Playing;
+ mState = Playing;
- if ( mSpeedFactor < 0.0f && mElapsedSeconds <= mPlayRange.x*mDurationSeconds )
+ if(mSpeedFactor < 0.0f && mElapsedSeconds <= mPlayRange.x * mDurationSeconds)
{
mElapsedSeconds = mPlayRange.y * mDurationSeconds;
}
- SetAnimatorsActive( true );
+ SetAnimatorsActive(true);
mCurrentLoop = 0;
}
void Animation::Pause()
{
- if (mState == Playing)
+ if(mState == Playing)
{
mState = Paused;
}
void Animation::Bake(BufferIndex bufferIndex, EndAction action)
{
- if( action == Dali::Animation::BAKE_FINAL )
+ if(action == Dali::Animation::BAKE_FINAL)
{
- if( mSpeedFactor > 0.0f )
+ if(mSpeedFactor > 0.0f)
{
- mElapsedSeconds = mPlayRange.y*mDurationSeconds + Math::MACHINE_EPSILON_1; // Force animation to reach it's end
+ mElapsedSeconds = mPlayRange.y * mDurationSeconds + Math::MACHINE_EPSILON_1; // Force animation to reach it's end
}
else
{
- mElapsedSeconds = mPlayRange.x*mDurationSeconds - Math::MACHINE_EPSILON_1; //Force animation to reach it's beginning
+ mElapsedSeconds = mPlayRange.x * mDurationSeconds - Math::MACHINE_EPSILON_1; //Force animation to reach it's beginning
}
}
- UpdateAnimators( bufferIndex, true/*bake the final result*/, true /*animation finished*/ );
+ UpdateAnimators(bufferIndex, true /*bake the final result*/, true /*animation finished*/);
}
-void Animation::SetAnimatorsActive( bool active )
+void Animation::SetAnimatorsActive(bool active)
{
- for ( auto&& item : mAnimators )
+ for(auto&& item : mAnimators)
{
- item->SetActive( active );
+ item->SetActive(active);
}
}
{
bool animationFinished(false);
- if (mState == Playing || mState == Paused)
+ if(mState == Playing || mState == Paused)
{
animationFinished = true; // The actor-thread should be notified of this
- if( mEndAction != Dali::Animation::DISCARD )
+ if(mEndAction != Dali::Animation::DISCARD)
{
- Bake( bufferIndex, mEndAction );
+ Bake(bufferIndex, mEndAction);
// Animators are automatically set to inactive in Bake
}
else
{
- SetAnimatorsActive( false );
+ SetAnimatorsActive(false);
}
// The animation has now been played to completion
mCurrentLoop = 0;
}
- mElapsedSeconds = mPlayRange.x*mDurationSeconds;
- mState = Stopped;
+ mElapsedSeconds = mPlayRange.x * mDurationSeconds;
+ mState = Stopped;
return animationFinished;
}
void Animation::OnDestroy(BufferIndex bufferIndex)
{
- if (mState == Playing || mState == Paused)
+ if(mState == Playing || mState == Paused)
{
- if (mEndAction != Dali::Animation::DISCARD)
+ if(mEndAction != Dali::Animation::DISCARD)
{
- Bake( bufferIndex, mEndAction );
+ Bake(bufferIndex, mEndAction);
// Animators are automatically set to inactive in Bake
}
else
{
- SetAnimatorsActive( false );
+ SetAnimatorsActive(false);
}
}
mState = Destroyed;
}
-void Animation::SetLoopingMode( bool loopingMode )
+void Animation::SetLoopingMode(bool loopingMode)
{
mAutoReverseEnabled = loopingMode;
- for ( auto&& item : mAnimators )
+ for(auto&& item : mAnimators)
{
// Send some variables together to figure out the Animation status
- item->SetSpeedFactor( mSpeedFactor );
- item->SetLoopCount( mLoopCount );
- item->SetLoopingMode( loopingMode );
+ item->SetSpeedFactor(mSpeedFactor);
+ item->SetLoopCount(mLoopCount);
+ item->SetLoopingMode(loopingMode);
}
}
-void Animation::AddAnimator( OwnerPointer<AnimatorBase>& animator )
+void Animation::AddAnimator(OwnerPointer<AnimatorBase>& animator)
{
animator->ConnectToSceneGraph();
- animator->SetDisconnectAction( mDisconnectAction );
+ animator->SetDisconnectAction(mDisconnectAction);
- mAnimators.PushBack( animator.Release() );
+ mAnimators.PushBack(animator.Release());
}
-void Animation::Update( BufferIndex bufferIndex, float elapsedSeconds, bool& looped, bool& finished, bool& progressReached )
+void Animation::Update(BufferIndex bufferIndex, float elapsedSeconds, bool& looped, bool& finished, bool& progressReached)
{
- looped = false;
+ looped = false;
finished = false;
- if (mState == Stopped || mState == Destroyed)
+ if(mState == Stopped || mState == Destroyed)
{
// Short circuit when animation isn't running
return;
}
// The animation must still be applied when Paused/Stopping
- if (mState == Playing)
+ if(mState == Playing)
{
// Sign value of speed factor. It can optimize many arithmetic comparision
- float signSpeedFactor = ( mSpeedFactor < 0.0f ) ? -1.f : 1.f;
+ float signSpeedFactor = (mSpeedFactor < 0.0f) ? -1.f : 1.f;
// If there is delay time before Animation starts, wait the Animation until mDelaySeconds.
- if( mDelaySeconds > 0.0f )
+ if(mDelaySeconds > 0.0f)
{
- float reduceSeconds = fabsf( elapsedSeconds * mSpeedFactor );
- if( reduceSeconds > mDelaySeconds )
+ float reduceSeconds = fabsf(elapsedSeconds * mSpeedFactor);
+ if(reduceSeconds > mDelaySeconds)
{
// add overflowed time to mElapsedSecond.
// If speed factor > 0, add it. if speed factor < 0, subtract it.
}
else
{
- mElapsedSeconds += ( elapsedSeconds * mSpeedFactor );
+ mElapsedSeconds += (elapsedSeconds * mSpeedFactor);
}
const float playRangeStartSeconds = mPlayRange.x * mDurationSeconds;
- const float playRangeEndSeconds = mPlayRange.y * mDurationSeconds;
+ const float playRangeEndSeconds = mPlayRange.y * mDurationSeconds;
// Final reached seconds. It can optimize many arithmetic comparision
- float edgeRangeSeconds = ( mSpeedFactor < 0.0f ) ? playRangeStartSeconds : playRangeEndSeconds;
+ float edgeRangeSeconds = (mSpeedFactor < 0.0f) ? playRangeStartSeconds : playRangeEndSeconds;
// Optimized Factors.
// elapsed > edge --> check if looped
// elapsed >= marker --> check if elapsed reached to marker in normal case
// edge >= marker --> check if elapsed reached to marker in looped case
float elapsedFactor = signSpeedFactor * mElapsedSeconds;
- float edgeFactor = signSpeedFactor * edgeRangeSeconds;
- float markerFactor = signSpeedFactor * mProgressMarker;
+ float edgeFactor = signSpeedFactor * edgeRangeSeconds;
+ float markerFactor = signSpeedFactor * mProgressMarker;
// check it is looped
- looped = ( elapsedFactor > edgeFactor );
+ looped = (elapsedFactor > edgeFactor);
- if( looped )
+ if(looped)
{
- WrapInPlayRange( mElapsedSeconds, playRangeStartSeconds, playRangeEndSeconds );
+ WrapInPlayRange(mElapsedSeconds, playRangeStartSeconds, playRangeEndSeconds);
// Recalculate elapsedFactor here
elapsedFactor = signSpeedFactor * mElapsedSeconds;
- if( mLoopCount != 0 )
+ if(mLoopCount != 0)
{
// Check If this animation is finished
++mCurrentLoop;
- if( mCurrentLoop >= mLoopCount )
+ if(mCurrentLoop >= mLoopCount)
{
- DALI_ASSERT_DEBUG( mCurrentLoop == mLoopCount );
+ DALI_ASSERT_DEBUG(mCurrentLoop == mLoopCount);
finished = true;
// The animation has now been played to completion
// Make elapsed second as edge of range forcely.
mElapsedSeconds = edgeRangeSeconds + signSpeedFactor * Math::MACHINE_EPSILON_10;
- UpdateAnimators(bufferIndex, finished && (mEndAction != Dali::Animation::DISCARD), finished );
+ UpdateAnimators(bufferIndex, finished && (mEndAction != Dali::Animation::DISCARD), finished);
// After update animation, mElapsedSeconds must be begin of value
mElapsedSeconds = playRangeStartSeconds + playRangeEndSeconds - edgeRangeSeconds;
- mState = Stopped;
+ mState = Stopped;
}
}
// when it is on looped state, 2 case to send progress signal.
// (require && range_value >= marker) || << Signal at previous loop
// (marker > 0 && !finished && elaped >= marker) << Signal at current loop
- if( ( mProgressMarker > 0.0f ) && !finished && ( elapsedFactor >= markerFactor ) )
+ if((mProgressMarker > 0.0f) && !finished && (elapsedFactor >= markerFactor))
{
// The application should be notified by NotificationManager, in another thread
- progressReached = true;
+ progressReached = true;
mProgressReachedSignalRequired = false;
}
else
{
- if( mProgressReachedSignalRequired && ( edgeFactor >= markerFactor ) )
+ if(mProgressReachedSignalRequired && (edgeFactor >= markerFactor))
{
progressReached = true;
}
{
// when it is not on looped state, only 1 case to send progress signal.
// (require && elaped >= marker)
- if( mProgressReachedSignalRequired && ( elapsedFactor >= markerFactor ) )
+ if(mProgressReachedSignalRequired && (elapsedFactor >= markerFactor))
{
// The application should be notified by NotificationManager, in another thread
- progressReached = true;
+ progressReached = true;
mProgressReachedSignalRequired = false;
}
}
}
// Already updated when finished. So skip.
- if( !finished )
+ if(!finished)
{
- UpdateAnimators(bufferIndex, false, false );
+ UpdateAnimators(bufferIndex, false, false);
}
}
-void Animation::UpdateAnimators( BufferIndex bufferIndex, bool bake, bool animationFinished )
+void Animation::UpdateAnimators(BufferIndex bufferIndex, bool bake, bool animationFinished)
{
mIsActive[bufferIndex] = false;
- const Vector2 playRange( mPlayRange * mDurationSeconds );
- float elapsedSecondsClamped = Clamp( mElapsedSeconds, playRange.x, playRange.y );
+ const Vector2 playRange(mPlayRange * mDurationSeconds);
+ float elapsedSecondsClamped = Clamp(mElapsedSeconds, playRange.x, playRange.y);
bool cleanup = false;
}
animator->Update(bufferIndex, progress, bake);
- if (animatorDuration > 0.0f && (elapsedSecondsClamped - intervalDelay) <= animatorDuration)
+ if(animatorDuration > 0.0f && (elapsedSecondsClamped - intervalDelay) <= animatorDuration)
{
mIsActive[bufferIndex] = true;
}
#define DALI_INTERNAL_SCENE_GRAPH_ANIMATION_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
/**
* Animations are used to change the properties of scene graph objects, as part of a scene
* managers "update" phase. An animation is a container of Animator objects; the actual setting
class Animation
{
public:
-
using EndAction = Dali::Animation::EndAction;
enum State
* @param[in] disconnectAction The action to perform when the property owner of an animator is disconnected.
* @return A new Animation
*/
- static Animation* New( float durationSeconds, float speedFactor, const Vector2& playRange, int32_t loopCount, EndAction endAction, EndAction disconnectAction );
+ static Animation* New(float durationSeconds, float speedFactor, const Vector2& playRange, int32_t loopCount, EndAction endAction, EndAction disconnectAction);
/**
* Virtual destructor
* Overriden delete operator
* Deletes the animation from its global memory pool
*/
- void operator delete( void* ptr );
+ void operator delete(void* ptr);
/**
* Set the duration of an animation.
* Set the progress marker to trigger notification
* @param[in] progress percent of progress to trigger notification, 0.0f < progress <= 1.0f
*/
- void SetProgressNotification( float progress );
+ void SetProgressNotification(float progress);
/**
* Retrieve the duration of the animation.
*/
float GetCurrentProgress() const
{
- if( mDurationSeconds > 0.0f )
+ if(mDurationSeconds > 0.0f)
{
return mElapsedSeconds / mDurationSeconds;
}
* Sets the progress of the animation.
* @param[in] The new progress as a normalized value between [0,1]
*/
- void SetCurrentProgress( float progress )
+ void SetCurrentProgress(float progress)
{
mElapsedSeconds = mDurationSeconds * progress;
}
* Specifies a speed factor for the animation.
* @param[in] factor A value which will multiply the velocity
*/
- void SetSpeedFactor( float factor )
+ void SetSpeedFactor(float factor)
{
mSpeedFactor = factor;
}
*
* @param[in] range Two values between [0,1] to specify minimum and maximum progress.
*/
- void SetPlayRange( const Vector2& range );
+ void SetPlayRange(const Vector2& range);
/**
* Play the animation.
* Play the animation from a given point
* @param[in] progress A value between [0,1] form where the animation should start playing
*/
- void PlayFrom( float progress );
+ void PlayFrom(float progress);
/**
* @brief Play the animation after a given delay time.
* @param[in] delaySeconds The delay time
*/
- void PlayAfter( float delaySeconds );
+ void PlayAfter(float delaySeconds);
/**
* Pause the animation.
* Animation plays forwards and then restarts from the beginning or runs backwards again.
* @param[in] loopingMode True when the looping mode is AUTO_REVERSE
*/
- void SetLoopingMode( bool loopingMode );
+ void SetLoopingMode(bool loopingMode);
/**
* Add a newly created animator.
* @param[in] propertyOwner The scene-object that owns the animatable property.
* @post The animator is owned by this animation.
*/
- void AddAnimator( OwnerPointer<AnimatorBase>& animator );
+ void AddAnimator(OwnerPointer<AnimatorBase>& animator);
/**
* This causes the animators to change the properties of objects in the scene graph.
* @param[out] finished True if the animation has finished.
* @param[out] progressReached True if progress marker reached
*/
- void Update(BufferIndex bufferIndex, float elapsedSeconds, bool& looped, bool& finished, bool& progressReached );
-
+ void Update(BufferIndex bufferIndex, float elapsedSeconds, bool& looped, bool& finished, bool& progressReached);
protected:
-
/**
* Protected constructor. See New()
*/
- Animation( float durationSeconds, float speedFactor, const Vector2& playRange, int32_t loopCount, EndAction endAction, EndAction disconnectAction );
-
+ Animation(float durationSeconds, float speedFactor, const Vector2& playRange, int32_t loopCount, EndAction endAction, EndAction disconnectAction);
private:
-
/**
* Helper for Update, also used to bake when the animation is stopped or destroyed.
* @param[in] bufferIndex The buffer to update.
* @param[in] bake True if the final result should be baked.
* @param[in] animationFinished True if the animation has finished.
*/
- void UpdateAnimators( BufferIndex bufferIndex, bool bake, bool animationFinished );
+ void UpdateAnimators(BufferIndex bufferIndex, bool bake, bool animationFinished);
/**
* Helper function to bake the result of the animation when it is stopped or
* @param[in] bufferIndex The buffer to update.
* @param[in] action The end action specified.
*/
- void Bake(BufferIndex bufferIndex, EndAction action );
+ void Bake(BufferIndex bufferIndex, EndAction action);
/**
* Helper function to set active state of animators.
* @param[in] active Every animator is set to this state
*/
- void SetAnimatorsActive( bool active );
+ void SetAnimatorsActive(bool active);
// Undefined
Animation(const Animation&);
Animation& operator=(const Animation& rhs);
protected:
-
- OwnerContainer< AnimatorBase* > mAnimators;
+ OwnerContainer<AnimatorBase*> mAnimators;
Vector2 mPlayRange;
float mDelaySeconds;
float mElapsedSeconds;
float mSpeedFactor;
- float mProgressMarker; // Progress marker to trigger a notification
+ float mProgressMarker; // Progress marker to trigger a notification
- int32_t mPlayedCount; // Incremented at end of animation or completion of all loops
- // Never incremented when looping forever. Event thread tracks to signal end.
- int32_t mLoopCount; // N loop setting
- int32_t mCurrentLoop; // Current loop number
+ int32_t mPlayedCount; // Incremented at end of animation or completion of all loops
+ // Never incremented when looping forever. Event thread tracks to signal end.
+ int32_t mLoopCount; // N loop setting
+ int32_t mCurrentLoop; // Current loop number
EndAction mEndAction;
EndAction mDisconnectAction;
State mState;
- bool mProgressReachedSignalRequired; // Flag to indicate the progress marker was hit
- bool mAutoReverseEnabled; // Flag to identify that the looping mode is auto reverse.
- bool mIsActive[2]; // Flag to indicate whether the animation is active in the current frame (which is double buffered)
+ bool mProgressReachedSignalRequired; // Flag to indicate the progress marker was hit
+ bool mAutoReverseEnabled; // Flag to identify that the looping mode is auto reverse.
+ bool mIsActive[2]; // Flag to indicate whether the animation is active in the current frame (which is double buffered)
};
}; //namespace SceneGraph
// value types used by messages
-template <> struct ParameterType< Dali::Animation::EndAction > : public BasicType< Dali::Animation::EndAction > {};
+template<>
+struct ParameterType<Dali::Animation::EndAction> : public BasicType<Dali::Animation::EndAction>
+{
+};
namespace SceneGraph
{
-
// Messages for Animation
-inline void SetDurationMessage( EventThreadServices& eventThreadServices, const Animation& animation, float durationSeconds )
+inline void SetDurationMessage(EventThreadServices& eventThreadServices, const Animation& animation, float durationSeconds)
{
- using LocalType = MessageValue1< Animation, float >;
+ using LocalType = MessageValue1<Animation, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &animation, &Animation::SetDuration, durationSeconds );
+ new(slot) LocalType(&animation, &Animation::SetDuration, durationSeconds);
}
-inline void SetProgressNotificationMessage( EventThreadServices& eventThreadServices, const Animation& animation, float progress )
+inline void SetProgressNotificationMessage(EventThreadServices& eventThreadServices, const Animation& animation, float progress)
{
- using LocalType = MessageValue1< Animation, float >;
+ using LocalType = MessageValue1<Animation, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &animation, &Animation::SetProgressNotification, progress );
+ new(slot) LocalType(&animation, &Animation::SetProgressNotification, progress);
}
-
-inline void SetLoopingMessage( EventThreadServices& eventThreadServices, const Animation& animation, int32_t loopCount )
+inline void SetLoopingMessage(EventThreadServices& eventThreadServices, const Animation& animation, int32_t loopCount)
{
- using LocalType = MessageValue1< Animation, int32_t >;
+ using LocalType = MessageValue1<Animation, int32_t>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &animation, &Animation::SetLoopCount, loopCount );
+ new(slot) LocalType(&animation, &Animation::SetLoopCount, loopCount);
}
-inline void SetEndActionMessage( EventThreadServices& eventThreadServices, const Animation& animation, Dali::Animation::EndAction action )
+inline void SetEndActionMessage(EventThreadServices& eventThreadServices, const Animation& animation, Dali::Animation::EndAction action)
{
- using LocalType = MessageValue1< Animation, Dali::Animation::EndAction >;
+ using LocalType = MessageValue1<Animation, Dali::Animation::EndAction>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &animation, &Animation::SetEndAction, action );
+ new(slot) LocalType(&animation, &Animation::SetEndAction, action);
}
-inline void SetDisconnectActionMessage( EventThreadServices& eventThreadServices, const Animation& animation, Dali::Animation::EndAction action )
+inline void SetDisconnectActionMessage(EventThreadServices& eventThreadServices, const Animation& animation, Dali::Animation::EndAction action)
{
- using LocalType = MessageValue1< Animation, Dali::Animation::EndAction >;
+ using LocalType = MessageValue1<Animation, Dali::Animation::EndAction>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &animation, &Animation::SetDisconnectAction, action );
+ new(slot) LocalType(&animation, &Animation::SetDisconnectAction, action);
}
-inline void SetCurrentProgressMessage( EventThreadServices& eventThreadServices, const Animation& animation, float progress )
+inline void SetCurrentProgressMessage(EventThreadServices& eventThreadServices, const Animation& animation, float progress)
{
- using LocalType = MessageValue1< Animation, float >;
+ using LocalType = MessageValue1<Animation, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &animation, &Animation::SetCurrentProgress, progress );
+ new(slot) LocalType(&animation, &Animation::SetCurrentProgress, progress);
}
-inline void SetSpeedFactorMessage( EventThreadServices& eventThreadServices, const Animation& animation, float factor )
+inline void SetSpeedFactorMessage(EventThreadServices& eventThreadServices, const Animation& animation, float factor)
{
- using LocalType = MessageValue1< Animation, float >;
+ using LocalType = MessageValue1<Animation, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &animation, &Animation::SetSpeedFactor, factor );
+ new(slot) LocalType(&animation, &Animation::SetSpeedFactor, factor);
}
-inline void SetPlayRangeMessage( EventThreadServices& eventThreadServices, const Animation& animation, const Vector2& range )
+inline void SetPlayRangeMessage(EventThreadServices& eventThreadServices, const Animation& animation, const Vector2& range)
{
- using LocalType = MessageValue1< Animation, Vector2 >;
+ using LocalType = MessageValue1<Animation, Vector2>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &animation, &Animation::SetPlayRange, range );
+ new(slot) LocalType(&animation, &Animation::SetPlayRange, range);
}
-inline void PlayAnimationMessage( EventThreadServices& eventThreadServices, const Animation& animation )
+inline void PlayAnimationMessage(EventThreadServices& eventThreadServices, const Animation& animation)
{
- using LocalType = Message< Animation >;
+ using LocalType = Message<Animation>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &animation, &Animation::Play );
+ new(slot) LocalType(&animation, &Animation::Play);
}
-inline void PlayAnimationFromMessage( EventThreadServices& eventThreadServices, const Animation& animation, float progress )
+inline void PlayAnimationFromMessage(EventThreadServices& eventThreadServices, const Animation& animation, float progress)
{
- using LocalType = MessageValue1< Animation, float >;
+ using LocalType = MessageValue1<Animation, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &animation, &Animation::PlayFrom, progress );
+ new(slot) LocalType(&animation, &Animation::PlayFrom, progress);
}
-inline void PauseAnimationMessage( EventThreadServices& eventThreadServices, const Animation& animation )
+inline void PauseAnimationMessage(EventThreadServices& eventThreadServices, const Animation& animation)
{
- using LocalType = Message< Animation >;
+ using LocalType = Message<Animation>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &animation, &Animation::Pause );
+ new(slot) LocalType(&animation, &Animation::Pause);
}
-inline void AddAnimatorMessage( EventThreadServices& eventThreadServices, const Animation& animation, AnimatorBase& animator )
+inline void AddAnimatorMessage(EventThreadServices& eventThreadServices, const Animation& animation, AnimatorBase& animator)
{
- using LocalType = MessageValue1< Animation, OwnerPointer<AnimatorBase> >;
+ using LocalType = MessageValue1<Animation, OwnerPointer<AnimatorBase> >;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- OwnerPointer<AnimatorBase> parameter( &animator );
- new (slot) LocalType( &animation, &Animation::AddAnimator, parameter );
+ OwnerPointer<AnimatorBase> parameter(&animator);
+ new(slot) LocalType(&animation, &Animation::AddAnimator, parameter);
}
-inline void PlayAfterMessage( EventThreadServices& eventThreadServices, const Animation& animation, float delaySeconds )
+inline void PlayAfterMessage(EventThreadServices& eventThreadServices, const Animation& animation, float delaySeconds)
{
- using LocalType = MessageValue1< Animation, float >;
+ using LocalType = MessageValue1<Animation, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &animation, &Animation::PlayAfter, delaySeconds );
+ new(slot) LocalType(&animation, &Animation::PlayAfter, delaySeconds);
}
-inline void SetLoopingModeMessage( EventThreadServices& eventThreadServices, const Animation& animation, bool loopingMode )
+inline void SetLoopingModeMessage(EventThreadServices& eventThreadServices, const Animation& animation, bool loopingMode)
{
- using LocalType = MessageValue1< Animation, bool >;
+ using LocalType = MessageValue1<Animation, bool>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &animation, &Animation::SetLoopingMode, loopingMode );
+ new(slot) LocalType(&animation, &Animation::SetLoopingMode, loopingMode);
}
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_ANIMATOR_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <functional>
// INTERNAL INCLUDES
+#include <dali/devel-api/common/owner-container.h>
+#include <dali/integration-api/debug.h>
+#include <dali/internal/event/animation/key-frames-impl.h>
+#include <dali/internal/event/animation/path-impl.h>
+#include <dali/internal/update/animation/property-accessor.h>
+#include <dali/internal/update/common/property-base.h>
+#include <dali/internal/update/nodes/node.h>
#include <dali/public-api/animation/alpha-function.h>
#include <dali/public-api/animation/animation.h>
#include <dali/public-api/animation/time-period.h>
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/math/quaternion.h>
#include <dali/public-api/math/radian.h>
-#include <dali/devel-api/common/owner-container.h>
-#include <dali/internal/event/animation/key-frames-impl.h>
-#include <dali/internal/event/animation/path-impl.h>
-#include <dali/internal/update/nodes/node.h>
-#include <dali/internal/update/common/property-base.h>
-#include <dali/internal/update/animation/property-accessor.h>
-#include <dali/integration-api/debug.h>
namespace Dali
{
-
namespace Internal
{
-
using Interpolation = Dali::Animation::Interpolation;
-
namespace SceneGraph
{
-
/**
* An abstract base class for Animators, which can be added to scene graph animations.
* Each animator changes a single property of an object in the scene graph.
class AnimatorBase : public PropertyOwner::Observer
{
public:
-
using AlphaFunc = float (*)(float progress); ///< Definition of an alpha function
/**
virtual ~LifecycleObserver() = default;
};
-
/**
* Constructor.
*/
- AnimatorBase( PropertyOwner* propertyOwner,
- AlphaFunction alphaFunction,
- const TimePeriod& timePeriod )
- : mLifecycleObserver( nullptr ),
- mPropertyOwner( propertyOwner ),
- mDurationSeconds( timePeriod.durationSeconds ),
- mIntervalDelaySeconds( timePeriod.delaySeconds ),
- mSpeedFactor( 1.0f ),
- mCurrentProgress( 0.f ),
- mAlphaFunction( alphaFunction ),
- mDisconnectAction( Dali::Animation::BAKE_FINAL ),
- mAnimationPlaying( false ),
- mEnabled( true ),
- mConnectedToSceneGraph( false ),
- mAutoReverseEnabled( false )
+ AnimatorBase(PropertyOwner* propertyOwner,
+ AlphaFunction alphaFunction,
+ const TimePeriod& timePeriod)
+ : mLifecycleObserver(nullptr),
+ mPropertyOwner(propertyOwner),
+ mDurationSeconds(timePeriod.durationSeconds),
+ mIntervalDelaySeconds(timePeriod.delaySeconds),
+ mSpeedFactor(1.0f),
+ mCurrentProgress(0.f),
+ mAlphaFunction(alphaFunction),
+ mDisconnectAction(Dali::Animation::BAKE_FINAL),
+ mAnimationPlaying(false),
+ mEnabled(true),
+ mConnectedToSceneGraph(false),
+ mAutoReverseEnabled(false)
{
}
*/
~AnimatorBase() override
{
- if (mPropertyOwner && mConnectedToSceneGraph)
+ if(mPropertyOwner && mConnectedToSceneGraph)
{
mPropertyOwner->RemoveObserver(*this);
}
- if( mLifecycleObserver != nullptr )
+ if(mLifecycleObserver != nullptr)
{
mLifecycleObserver->ObjectDestroyed();
}
}
- void AddLifecycleObserver( LifecycleObserver& observer )
+ void AddLifecycleObserver(LifecycleObserver& observer)
{
mLifecycleObserver = &observer;
}
- void RemoveLifecycleObserver( LifecycleObserver& observer )
+ void RemoveLifecycleObserver(LifecycleObserver& observer)
{
mLifecycleObserver = nullptr;
}
private: // From PropertyOwner::Observer
-
/**
* @copydoc PropertyOwner::Observer::PropertyOwnerConnected( PropertyOwner& owner )
*/
- void PropertyOwnerConnected( PropertyOwner& owner ) final
+ void PropertyOwnerConnected(PropertyOwner& owner) final
{
mEnabled = true;
}
/**
* @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
*/
- void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner ) final
+ void PropertyOwnerDisconnected(BufferIndex bufferIndex, PropertyOwner& owner) final
{
// If we are active, then bake the value if required
- if ( mAnimationPlaying && mDisconnectAction != Dali::Animation::DISCARD )
+ if(mAnimationPlaying && mDisconnectAction != Dali::Animation::DISCARD)
{
// Bake to target-value if BakeFinal, otherwise bake current value
- Update( bufferIndex, ( mDisconnectAction == Dali::Animation::BAKE ? mCurrentProgress : 1.0f ), true );
+ Update(bufferIndex, (mDisconnectAction == Dali::Animation::BAKE ? mCurrentProgress : 1.0f), true);
}
mEnabled = false;
/**
* @copydoc PropertyOwner::Observer::PropertyOwnerDestroyed( PropertyOwner& owner )
*/
- void PropertyOwnerDestroyed( PropertyOwner& owner ) final
+ void PropertyOwnerDestroyed(PropertyOwner& owner) final
{
mPropertyOwner = nullptr;
}
return mDurationSeconds;
}
- void SetSpeedFactor( float factor )
+ void SetSpeedFactor(float factor)
{
mSpeedFactor = factor;
}
mLoopCount = loopCount;
}
- float SetProgress( float progress )
+ float SetProgress(float progress)
{
float value = 0.0f;
- if( mAutoReverseEnabled )
+ if(mAutoReverseEnabled)
{
- if( mSpeedFactor > 0.0f )
+ if(mSpeedFactor > 0.0f)
{
- value = 1.0f - 2.0f * std::abs( progress - 0.5f );
+ value = 1.0f - 2.0f * std::abs(progress - 0.5f);
}
// Reverse mode
- else if( mSpeedFactor < 0.0f )
+ else if(mSpeedFactor < 0.0f)
{
- value = 2.0f * std::abs( progress - 0.5f );
+ value = 2.0f * std::abs(progress - 0.5f);
}
}
else
* @param[in] Current progress
* @return The progress after the alpha function has been aplied
*/
- float ApplyAlphaFunction( float progress ) const
+ float ApplyAlphaFunction(float progress) const
{
float result = progress;
- AlphaFunction::Mode alphaFunctionMode( mAlphaFunction.GetMode() );
- if( alphaFunctionMode == AlphaFunction::BUILTIN_FUNCTION )
+ AlphaFunction::Mode alphaFunctionMode(mAlphaFunction.GetMode());
+ if(alphaFunctionMode == AlphaFunction::BUILTIN_FUNCTION)
{
switch(mAlphaFunction.GetBuiltinFunction())
{
}
case AlphaFunction::REVERSE:
{
- result = 1.0f-progress;
+ result = 1.0f - progress;
break;
}
case AlphaFunction::EASE_IN_SQUARE:
}
case AlphaFunction::EASE_OUT_SQUARE:
{
- result = 1.0f - (1.0f-progress) * (1.0f-progress);
+ result = 1.0f - (1.0f - progress) * (1.0f - progress);
break;
}
case AlphaFunction::EASE_IN:
}
case AlphaFunction::EASE_OUT:
{
- result = (progress-1.0f) * (progress-1.0f) * (progress-1.0f) + 1.0f;
+ result = (progress - 1.0f) * (progress - 1.0f) * (progress - 1.0f) + 1.0f;
break;
}
case AlphaFunction::EASE_IN_OUT:
{
- result = progress*progress*(3.0f-2.0f*progress);
+ result = progress * progress * (3.0f - 2.0f * progress);
break;
}
case AlphaFunction::EASE_IN_SINE:
{
const float sqrt2 = 1.70158f;
progress -= 1.0f;
- result = 1.0f + progress * progress * ( ( sqrt2 + 1.0f ) * progress + sqrt2 );
+ result = 1.0f + progress * progress * ((sqrt2 + 1.0f) * progress + sqrt2);
break;
}
case AlphaFunction::COUNT:
}
}
}
- else if( alphaFunctionMode == AlphaFunction::CUSTOM_FUNCTION )
+ else if(alphaFunctionMode == AlphaFunction::CUSTOM_FUNCTION)
{
AlphaFunctionPrototype customFunction = mAlphaFunction.GetCustomFunction();
- if( customFunction )
+ if(customFunction)
{
result = customFunction(progress);
}
{
//If progress is very close to 0 or very close to 1 we don't need to evaluate the curve as the result will
//be almost 0 or almost 1 respectively
- if( ( progress > Math::MACHINE_EPSILON_1 ) && ((1.0f - progress) > Math::MACHINE_EPSILON_1) )
+ if((progress > Math::MACHINE_EPSILON_1) && ((1.0f - progress) > Math::MACHINE_EPSILON_1))
{
Dali::Vector4 controlPoints = mAlphaFunction.GetBezierControlPoints();
- static const float tolerance = 0.001f; //10 iteration max
+ static const float tolerance = 0.001f; //10 iteration max
//Perform a binary search on the curve
float lowerBound(0.0f);
float upperBound(1.0f);
float currentT(0.5f);
- float currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT);
- while( fabsf( progress - currentX ) > tolerance )
+ float currentX = EvaluateCubicBezier(controlPoints.x, controlPoints.z, currentT);
+ while(fabsf(progress - currentX) > tolerance)
{
- if( progress > currentX )
+ if(progress > currentX)
{
lowerBound = currentT;
}
{
upperBound = currentT;
}
- currentT = (upperBound+lowerBound)*0.5f;
- currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT);
+ currentT = (upperBound + lowerBound) * 0.5f;
+ currentX = EvaluateCubicBezier(controlPoints.x, controlPoints.z, currentT);
}
- result = EvaluateCubicBezier( controlPoints.y, controlPoints.w, currentT);
+ result = EvaluateCubicBezier(controlPoints.y, controlPoints.w, currentT);
}
}
* Property is only baked if the animator is active.
* @param [in] action The disconnect action.
*/
- void SetDisconnectAction( Dali::Animation::EndAction action )
+ void SetDisconnectAction(Dali::Animation::EndAction action)
{
mDisconnectAction = action;
}
* @post When the animator becomes active, it applies the disconnect-action if the property owner is then disconnected.
* @note When the property owner is disconnected, the active state is set to false.
*/
- void SetActive( bool active )
+ void SetActive(bool active)
{
mAnimationPlaying = active;
}
* @brief Sets the looping mode.
* @param[in] loopingMode True when the looping mode is AUTO_REVERSE
*/
- void SetLoopingMode( bool loopingMode )
+ void SetLoopingMode(bool loopingMode)
{
mAutoReverseEnabled = loopingMode;
}
* @param[in] progress A value from 0 to 1, where 0 is the start of the animation, and 1 is the end point.
* @param[in] bake Bake.
*/
- void Update( BufferIndex bufferIndex, float progress, bool bake )
+ void Update(BufferIndex bufferIndex, float progress, bool bake)
{
- if( mLoopCount >= 0 )
+ if(mLoopCount >= 0)
{
// Update the progress value
- progress = SetProgress( progress );
+ progress = SetProgress(progress);
}
- if( mPropertyOwner )
+ if(mPropertyOwner)
{
- mPropertyOwner->SetUpdated( true );
+ mPropertyOwner->SetUpdated(true);
}
- float alpha = ApplyAlphaFunction( progress );
+ float alpha = ApplyAlphaFunction(progress);
// PropertyType specific part
- DoUpdate( bufferIndex, bake, alpha );
+ DoUpdate(bufferIndex, bake, alpha);
mCurrentProgress = progress;
}
* @param bake whether to bake or not
* @param alpha value from alpha based on progress
*/
- virtual void DoUpdate( BufferIndex bufferIndex, bool bake, float alpha ) = 0;
+ virtual void DoUpdate(BufferIndex bufferIndex, bool bake, float alpha) = 0;
protected:
-
/**
* Helper function to evaluate a cubic bezier curve assuming first point is at 0.0 and last point is at 1.0
* @param[in] p0 First control point of the bezier curve
* @param[in] t A floating point value between 0.0 and 1.0
* @return Value of the curve at progress t
*/
- inline float EvaluateCubicBezier( float p0, float p1, float t ) const
+ inline float EvaluateCubicBezier(float p0, float p1, float t) const
{
- float tSquare = t*t;
- return 3.0f*(1.0f-t)*(1.0f-t)*t*p0 + 3.0f*(1.0f-t)*tSquare*p1 + tSquare*t;
+ float tSquare = t * t;
+ return 3.0f * (1.0f - t) * (1.0f - t) * t * p0 + 3.0f * (1.0f - t) * tSquare * p1 + tSquare * t;
}
LifecycleObserver* mLifecycleObserver;
- PropertyOwner* mPropertyOwner;
+ PropertyOwner* mPropertyOwner;
float mDurationSeconds;
float mIntervalDelaySeconds;
AlphaFunction mAlphaFunction;
int32_t mLoopCount{1};
- Dali::Animation::EndAction mDisconnectAction; ///< EndAction to apply when target object gets disconnected from the stage.
- bool mAnimationPlaying:1; ///< whether disconnect has been applied while it's running.
- bool mEnabled:1; ///< Animator is "enabled" while its target object is valid and on the stage.
- bool mConnectedToSceneGraph:1; ///< True if ConnectToSceneGraph() has been called in update-thread.
- bool mAutoReverseEnabled:1;
+ Dali::Animation::EndAction mDisconnectAction; ///< EndAction to apply when target object gets disconnected from the stage.
+ bool mAnimationPlaying : 1; ///< whether disconnect has been applied while it's running.
+ bool mEnabled : 1; ///< Animator is "enabled" while its target object is valid and on the stage.
+ bool mConnectedToSceneGraph : 1; ///< True if ConnectToSceneGraph() has been called in update-thread.
+ bool mAutoReverseEnabled : 1;
};
/**
AnimatorFunction mAnimatorFunction;
public:
-
/**
* Construct a new property animator.
* @param[in] property The animatable property; only valid while the Animator is attached.
/**
* @copydoc AnimatorBase::DoUpdate( BufferIndex bufferIndex, bool bake, float alpha )
*/
- void DoUpdate( BufferIndex bufferIndex, bool bake, float alpha ) final
+ void DoUpdate(BufferIndex bufferIndex, bool bake, float alpha) final
{
- const PropertyType& current = mPropertyAccessor.Get( bufferIndex );
+ const PropertyType& current = mPropertyAccessor.Get(bufferIndex);
// need to cast the return value in case property is integer
const PropertyType result = static_cast<PropertyType>(mAnimatorFunction(alpha, current));
- if ( bake )
+ if(bake)
{
- mPropertyAccessor.Bake( bufferIndex, result );
+ mPropertyAccessor.Bake(bufferIndex, result);
}
else
{
- mPropertyAccessor.Set( bufferIndex, result );
+ mPropertyAccessor.Set(bufferIndex, result);
}
}
private:
-
/**
* Private constructor; see also Animator::New().
*/
}
// Undefined
- Animator( const Animator& );
+ Animator(const Animator&);
// Undefined
- Animator& operator=( const Animator& );
+ Animator& operator=(const Animator&);
protected:
-
PropertyAccessorType mPropertyAccessor;
-
};
-
-
/**
* An animator for a specific property type PropertyType.
*/
AnimatorFunction mAnimatorFunction;
public:
-
/**
* Construct a new property animator.
* @param[in] property The animatable property; only valid while the Animator is attached.
AlphaFunction alphaFunction,
const TimePeriod& timePeriod)
{
-
// The property was const in the actor-thread, but animators are used in the scene-graph thread.
return new AnimatorTransformProperty(const_cast<PropertyOwner*>(&propertyOwner),
const_cast<PropertyBase*>(&property),
/**
* @copydoc AnimatorBase::DoUpdate( BufferIndex bufferIndex, bool bake, float alpha )
*/
- void DoUpdate( BufferIndex bufferIndex, bool bake, float alpha ) final
+ void DoUpdate(BufferIndex bufferIndex, bool bake, float alpha) final
{
- const PropertyType& current = mPropertyAccessor.Get( bufferIndex );
+ const PropertyType& current = mPropertyAccessor.Get(bufferIndex);
// need to cast the return value in case property is integer
const PropertyType result = static_cast<PropertyType>(mAnimatorFunction(alpha, current));
- if ( bake )
+ if(bake)
{
- mPropertyAccessor.Bake( bufferIndex, result );
+ mPropertyAccessor.Bake(bufferIndex, result);
}
else
{
- mPropertyAccessor.Set( bufferIndex, result );
+ mPropertyAccessor.Set(bufferIndex, result);
}
}
private:
-
/**
* Private constructor; see also Animator::New().
*/
}
// Undefined
- AnimatorTransformProperty() = delete;
- AnimatorTransformProperty( const AnimatorTransformProperty& ) = delete;
- AnimatorTransformProperty& operator=( const AnimatorTransformProperty& ) = delete;
+ AnimatorTransformProperty() = delete;
+ AnimatorTransformProperty(const AnimatorTransformProperty&) = delete;
+ AnimatorTransformProperty& operator=(const AnimatorTransformProperty&) = delete;
protected:
-
PropertyAccessorType mPropertyAccessor;
-
};
} // namespace SceneGraph
float operator()(float alpha, const int32_t& property)
{
// integers need to be correctly rounded
- return roundf(static_cast<float>( property ) + static_cast<float>( mRelative ) * alpha );
+ return roundf(static_cast<float>(property) + static_cast<float>(mRelative) * alpha);
}
int32_t mRelative;
float operator()(float alpha, const int32_t& property)
{
// integers need to be correctly rounded
- return roundf(static_cast<float>( property ) + (static_cast<float>(mTarget - property) * alpha) );
+ return roundf(static_cast<float>(property) + (static_cast<float>(mTarget - property) * alpha));
}
int32_t mTarget;
struct RotateByAngleAxis
{
RotateByAngleAxis(const Radian& angleRadians, const Vector3& axis)
- : mAngleRadians( angleRadians ),
+ : mAngleRadians(angleRadians),
mAxis(axis.x, axis.y, axis.z)
{
}
Quaternion operator()(float alpha, const Quaternion& rotation)
{
- if (alpha > 0.0f)
+ if(alpha > 0.0f)
{
return rotation * Quaternion(mAngleRadians * alpha, mAxis);
}
return rotation;
}
- Radian mAngleRadians;
+ Radian mAngleRadians;
Vector3 mAxis;
};
{
return static_cast<float>(mKeyFrames.GetValue(progress, mInterpolation));
}
- return static_cast<float>( property );
+ return static_cast<float>(property);
}
KeyFrameInteger mKeyFrames;
- Interpolation mInterpolation;
+ Interpolation mInterpolation;
};
struct KeyFrameNumberFunctor
}
KeyFrameNumber mKeyFrames;
- Interpolation mInterpolation;
+ Interpolation mInterpolation;
};
struct KeyFrameVector2Functor
}
KeyFrameVector2 mKeyFrames;
- Interpolation mInterpolation;
+ Interpolation mInterpolation;
};
struct KeyFrameVector3Functor
}
KeyFrameVector3 mKeyFrames;
- Interpolation mInterpolation;
+ Interpolation mInterpolation;
};
struct KeyFrameVector4Functor
}
KeyFrameVector4 mKeyFrames;
- Interpolation mInterpolation;
+ Interpolation mInterpolation;
};
struct KeyFrameQuaternionFunctor
struct PathPositionFunctor
{
- PathPositionFunctor( PathPtr path )
+ PathPositionFunctor(PathPtr path)
: mPath(path)
{
}
Vector3 operator()(float progress, const Vector3& property)
{
Vector3 position(property);
- static_cast<void>( mPath->SamplePosition(progress, position) );
+ static_cast<void>(mPath->SamplePosition(progress, position));
return position;
}
struct PathRotationFunctor
{
- PathRotationFunctor( PathPtr path, const Vector3& forward )
+ PathRotationFunctor(PathPtr path, const Vector3& forward)
: mPath(path),
- mForward( forward )
+ mForward(forward)
{
mForward.Normalize();
}
Quaternion operator()(float progress, const Quaternion& property)
{
Vector3 tangent;
- if( mPath->SampleTangent(progress, tangent) )
+ if(mPath->SampleTangent(progress, tangent))
{
- return Quaternion( mForward, tangent );
+ return Quaternion(mForward, tangent);
}
else
{
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
#ifdef DEBUG_ENABLED
- uint32_t ConstraintBase::mCurrentInstanceCount = 0;
- uint32_t ConstraintBase::mTotalInstanceCount = 0;
+uint32_t ConstraintBase::mCurrentInstanceCount = 0;
+uint32_t ConstraintBase::mTotalInstanceCount = 0;
#endif
-ConstraintBase::ConstraintBase( PropertyOwnerContainer& ownerSet, RemoveAction removeAction )
-: mRemoveAction( removeAction ),
- mFirstApply( true ),
- mDisconnected( true ),
- mObservedOwners( ownerSet ),
- mLifecycleObserver( nullptr )
+ConstraintBase::ConstraintBase(PropertyOwnerContainer& ownerSet, RemoveAction removeAction)
+: mRemoveAction(removeAction),
+ mFirstApply(true),
+ mDisconnected(true),
+ mObservedOwners(ownerSet),
+ mLifecycleObserver(nullptr)
{
#ifdef DEBUG_ENABLED
++mCurrentInstanceCount;
ConstraintBase::~ConstraintBase()
{
- if ( !mDisconnected )
+ if(!mDisconnected)
{
StopObservation();
}
- if( mLifecycleObserver != nullptr )
+ if(mLifecycleObserver != nullptr)
{
mLifecycleObserver->ObjectDestroyed();
}
#define DALI_INTERNAL_SCENE_GRAPH_CONSTRAINT_BASE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/animation/constraint.h>
-#include <dali/public-api/common/dali-common.h>
#include <dali/internal/common/message.h>
#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/update/animation/scene-graph-constraint-declarations.h>
#include <dali/internal/update/common/animatable-property.h>
#include <dali/internal/update/common/property-owner.h>
#include <dali/internal/update/common/scene-graph-buffers.h>
-#include <dali/internal/update/animation/scene-graph-constraint-declarations.h>
+#include <dali/public-api/animation/constraint.h>
+#include <dali/public-api/common/dali-common.h>
namespace Dali
{
-
namespace Internal
{
-
// value types used by messages
-template <> struct ParameterType< Dali::Constraint::RemoveAction >
-: public BasicType< Dali::Constraint::RemoveAction > {};
+template<>
+struct ParameterType<Dali::Constraint::RemoveAction>
+: public BasicType<Dali::Constraint::RemoveAction>
+{
+};
namespace SceneGraph
{
* @param ownerContainer the properties to constraint
* @oparam removeAction perform when removed
*/
- ConstraintBase( PropertyOwnerContainer& ownerContainer, RemoveAction removeAction );
+ ConstraintBase(PropertyOwnerContainer& ownerContainer, RemoveAction removeAction);
/**
* Virtual destructor.
/**
* Property resetter observes the lifecycle of this object
*/
- void AddLifecycleObserver( LifecycleObserver& observer )
+ void AddLifecycleObserver(LifecycleObserver& observer)
{
mLifecycleObserver = &observer;
}
/**
* Property resetter observers the lifecycle of this object
*/
- void RemoveLifecycleObserver( LifecycleObserver& observer )
+ void RemoveLifecycleObserver(LifecycleObserver& observer)
{
mLifecycleObserver = nullptr;
}
/**
* @copydoc Dali::Constraint::SetRemoveAction()
*/
- void SetRemoveAction( RemoveAction action )
+ void SetRemoveAction(RemoveAction action)
{
mRemoveAction = action;
}
* Constrain the associated scene object.
* @param[in] updateBufferIndex The current update buffer index.
*/
- virtual void Apply( BufferIndex updateBufferIndex ) = 0;
+ virtual void Apply(BufferIndex updateBufferIndex) = 0;
/**
* Helper for internal test cases; only available for debug builds.
static uint32_t GetTotalInstanceCount();
private:
-
/**
* Helper to start observing property owners
*/
void StartObservation()
{
- const PropertyOwnerIter end = mObservedOwners.End();
- for( PropertyOwnerIter iter = mObservedOwners.Begin(); end != iter; ++iter )
+ const PropertyOwnerIter end = mObservedOwners.End();
+ for(PropertyOwnerIter iter = mObservedOwners.Begin(); end != iter; ++iter)
{
- (*iter)->AddObserver( *this );
+ (*iter)->AddObserver(*this);
}
}
*/
void StopObservation()
{
- const PropertyOwnerIter end = mObservedOwners.End();
- for( PropertyOwnerIter iter = mObservedOwners.Begin(); end != iter; ++iter )
+ const PropertyOwnerIter end = mObservedOwners.End();
+ for(PropertyOwnerIter iter = mObservedOwners.Begin(); end != iter; ++iter)
{
- (*iter)->RemoveObserver( *this );
+ (*iter)->RemoveObserver(*this);
}
mObservedOwners.Clear();
/**
* @copydoc PropertyOwner::Observer::PropertyOwnerConnected()
*/
- void PropertyOwnerConnected( PropertyOwner& owner ) override
+ void PropertyOwnerConnected(PropertyOwner& owner) override
{
}
/**
* @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected()
*/
- void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner ) override
+ void PropertyOwnerDisconnected(BufferIndex bufferIndex, PropertyOwner& owner) override
{
- if ( !mDisconnected )
+ if(!mDisconnected)
{
// Stop observing property owners
StopObservation();
/**
* @copydoc PropertyOwner::Observer::PropertyOwnerDestroyed()
*/
- void PropertyOwnerDestroyed( PropertyOwner& owner ) override
+ void PropertyOwnerDestroyed(PropertyOwner& owner) override
{
- if ( !mDisconnected )
+ if(!mDisconnected)
{
// Discard pointer to destroyed property owner. Otherwise StopObservation() would crash when trying to remove
//the constraint from the destroyed PropertyOwner's observers list
- PropertyOwnerIter iter = std::find( mObservedOwners.Begin(), mObservedOwners.End(), &owner );
- if( mObservedOwners.End() != iter )
+ PropertyOwnerIter iter = std::find(mObservedOwners.Begin(), mObservedOwners.End(), &owner);
+ if(mObservedOwners.End() != iter)
{
- mObservedOwners.Erase( iter );
+ mObservedOwners.Erase(iter);
}
// Stop observing the rest of property owners
OnDisconnect();
mDisconnected = true;
-
}
}
virtual void OnDisconnect() = 0;
protected:
-
RemoveAction mRemoveAction;
- bool mFirstApply : 1;
+ bool mFirstApply : 1;
bool mDisconnected : 1;
private:
-
- PropertyOwnerContainer mObservedOwners; ///< A set of pointers to each observed object. Not owned.
- LifecycleObserver* mLifecycleObserver; ///< Resetter observers this object
+ PropertyOwnerContainer mObservedOwners; ///< A set of pointers to each observed object. Not owned.
+ LifecycleObserver* mLifecycleObserver; ///< Resetter observers this object
#ifdef DEBUG_ENABLED
- static uint32_t mCurrentInstanceCount; ///< The current number of Constraint instances in existence.
- static uint32_t mTotalInstanceCount; ///< The total number of Constraint instances created during the Dali core lifetime.
+ static uint32_t mCurrentInstanceCount; ///< The current number of Constraint instances in existence.
+ static uint32_t mTotalInstanceCount; ///< The total number of Constraint instances created during the Dali core lifetime.
#endif
};
// Messages for ConstraintBase
-inline void SetRemoveActionMessage( EventThreadServices& eventThreadServices, const ConstraintBase& constraint, Dali::Constraint::RemoveAction removeAction )
+inline void SetRemoveActionMessage(EventThreadServices& eventThreadServices, const ConstraintBase& constraint, Dali::Constraint::RemoveAction removeAction)
{
using LocalType = MessageValue1<ConstraintBase, Dali::Constraint::RemoveAction>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &constraint, &ConstraintBase::SetRemoveAction, removeAction );
+ new(slot) LocalType(&constraint, &ConstraintBase::SetRemoveAction, removeAction);
}
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_CONSTRAINT_DECLARATIONS_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
class ConstraintBase;
-using ConstraintOwnerContainer = OwnerContainer<ConstraintBase *>;
+using ConstraintOwnerContainer = OwnerContainer<ConstraintBase*>;
using ConstraintIter = ConstraintOwnerContainer::Iterator;
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_CONSTRAINT_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/signals/callback.h>
#include <dali/internal/event/animation/property-constraint-ptr.h>
+#include <dali/internal/render/common/performance-monitor.h>
+#include <dali/internal/update/animation/scene-graph-constraint-base.h>
#include <dali/internal/update/common/animatable-property.h>
#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/animation/scene-graph-constraint-base.h>
-#include <dali/internal/render/common/performance-monitor.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/signals/callback.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
/**
* Used to constrain a property of a scene-object.
* The constraint function takes another scene-object property as an input.
*/
-template < class PropertyType, typename PropertyAccessorType >
+template<class PropertyType, typename PropertyAccessorType>
class Constraint : public ConstraintBase
{
public:
-
- using ConstraintFunctionPtr = typename PropertyConstraintPtr< PropertyType >::Type;
+ using ConstraintFunctionPtr = typename PropertyConstraintPtr<PropertyType>::Type;
/**
* Create a new scene-graph constraint.
* @param[in] removeAction Remove action to perform when constraint is removed
* @return A smart-pointer to a newly allocated constraint.
*/
- static ConstraintBase* New( const PropertyBase& targetProperty,
- PropertyOwnerContainer& ownerContainer,
- ConstraintFunctionPtr func,
- RemoveAction removeAction )
+ static ConstraintBase* New(const PropertyBase& targetProperty,
+ PropertyOwnerContainer& ownerContainer,
+ ConstraintFunctionPtr func,
+ RemoveAction removeAction)
{
// Scene-graph thread can edit these objects
- PropertyBase& property = const_cast< PropertyBase& >( targetProperty );
+ PropertyBase& property = const_cast<PropertyBase&>(targetProperty);
- return new Constraint< PropertyType, PropertyAccessorType >( property,
- ownerContainer,
- func,
- removeAction );
+ return new Constraint<PropertyType, PropertyAccessorType>(property,
+ ownerContainer,
+ func,
+ removeAction);
}
/**
/**
* @copydoc Dali::Internal::SceneGraph::ConstraintBase::Apply()
*/
- void Apply( BufferIndex updateBufferIndex ) override
+ void Apply(BufferIndex updateBufferIndex) override
{
- if ( !mDisconnected )
+ if(!mDisconnected)
{
- if ( mFunc->InputsInitialized() )
+ if(mFunc->InputsInitialized())
{
- PropertyType current = mTargetProperty.Get( updateBufferIndex );
- mFunc->Apply( updateBufferIndex, current );
+ PropertyType current = mTargetProperty.Get(updateBufferIndex);
+ mFunc->Apply(updateBufferIndex, current);
// Optionally bake the final value
- if ( Dali::Constraint::BAKE == mRemoveAction )
+ if(Dali::Constraint::BAKE == mRemoveAction)
{
- mTargetProperty.Bake( updateBufferIndex, current );
+ mTargetProperty.Bake(updateBufferIndex, current);
}
else
{
- mTargetProperty.Set( updateBufferIndex, current );
+ mTargetProperty.Set(updateBufferIndex, current);
}
INCREASE_COUNTER(PerformanceMonitor::CONSTRAINTS_APPLIED);
}
private:
-
/**
* @copydoc Dali::Internal::SceneGraph::Constraint::New()
*/
- Constraint( PropertyBase& targetProperty,
- PropertyOwnerContainer& ownerContainer,
- ConstraintFunctionPtr func,
- RemoveAction removeAction )
- : ConstraintBase( ownerContainer, removeAction ),
- mTargetProperty( &targetProperty ),
- mFunc( func )
+ Constraint(PropertyBase& targetProperty,
+ PropertyOwnerContainer& ownerContainer,
+ ConstraintFunctionPtr func,
+ RemoveAction removeAction)
+ : ConstraintBase(ownerContainer, removeAction),
+ mTargetProperty(&targetProperty),
+ mFunc(func)
{
}
// Undefined
- Constraint() = delete;
- Constraint( const Constraint& constraint ) = delete;
- Constraint& operator=( const Constraint& rhs ) = delete;
+ Constraint() = delete;
+ Constraint(const Constraint& constraint) = delete;
+ Constraint& operator=(const Constraint& rhs) = delete;
/**
* @copydoc Dali::Internal::SceneGraph::ConstraintBase::OnDisconnect()
}
protected:
-
PropertyAccessorType mTargetProperty; ///< Raw-pointer to the target property. Not owned.
ConstraintFunctionPtr mFunc;
-
};
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <limits>
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/object/property.h>
-#include <dali/public-api/object/property-input.h>
-#include <dali/public-api/object/property-types.h>
#include <dali/internal/common/message.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/event/common/property-input-impl.h>
#include <dali/internal/update/common/double-buffered.h>
#include <dali/internal/update/common/property-base.h>
#include <dali/internal/update/common/scene-graph-buffers.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/object/property-input.h>
+#include <dali/public-api/object/property-types.h>
+#include <dali/public-api/object/property.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
/**
* Dirty flags record whether an animatable property has changed.
* In the frame following a change, the property is reset to a base value.
static const uint32_t BAKED_FLAG = 0x01; ///< Indicates that the value was Baked during the previous frame
static const uint32_t SET_FLAG = 0x02; ///< Indicates that the value was Set during the previous frame
-template <class T>
+template<class T>
class AnimatableProperty;
/**
class AnimatablePropertyBase : public PropertyBase
{
public:
-
/**
* Constructor, initialize the dirty flag
*/
AnimatablePropertyBase()
: PropertyBase(),
- mDirtyFlags( BAKED_FLAG )
- {}
+ mDirtyFlags(BAKED_FLAG)
+ {
+ }
/**
* Virtual destructor.
~AnimatablePropertyBase() override = default;
protected: // for derived classes
-
/**
* Flag that the property has been Set during the current frame.
*/
}
public: // From PropertyBase
-
/**
* @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
*/
bool IsClean() const override
{
- return ( CLEAN_FLAG == mDirtyFlags );
+ return (CLEAN_FLAG == mDirtyFlags);
}
/**
return true; // Animatable properties are always valid
}
-protected: // so that ResetToBaseValue can set it directly
-
+protected: // so that ResetToBaseValue can set it directly
uint32_t mDirtyFlags; ///< Flag whether value changed during previous 2 frames
-
};
-
/**
* An boolean animatable property of a scene-graph object.
*/
-template <>
+template<>
class AnimatableProperty<bool> : public AnimatablePropertyBase
{
public:
-
/**
* Create an animatable property.
* @param [in] initialValue The initial value of the property.
*/
- AnimatableProperty( bool initialValue )
- : mValue( initialValue ),
- mBaseValue( initialValue )
+ AnimatableProperty(bool initialValue)
+ : mValue(initialValue),
+ mBaseValue(initialValue)
{
}
*/
void ResetToBaseValue(BufferIndex updateBufferIndex) override
{
- if (CLEAN_FLAG != mDirtyFlags)
+ if(CLEAN_FLAG != mDirtyFlags)
{
mValue[updateBufferIndex] = mBaseValue;
- mDirtyFlags = ( mDirtyFlags >> 1 );
+ mDirtyFlags = (mDirtyFlags >> 1);
}
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetBoolean()
*/
- const bool& GetBoolean( BufferIndex bufferIndex ) const override
+ const bool& GetBoolean(BufferIndex bufferIndex) const override
{
- return mValue[ bufferIndex ];
+ return mValue[bufferIndex];
}
/**
void Set(BufferIndex bufferIndex, bool value)
{
// check if the value actually changed to avoid dirtying nodes unnecessarily
- if( mValue[bufferIndex] != value )
+ if(mValue[bufferIndex] != value)
{
mValue[bufferIndex] = value;
{
// check if the value actually changed to avoid dirtying nodes unnecessarily
// false + false does not change value, true + false does not either
- if( delta && !mValue[bufferIndex] )
+ if(delta && !mValue[bufferIndex])
{
mValue[bufferIndex] = delta;
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- bool& Get( BufferIndex bufferIndex )
+ bool& Get(BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const bool& Get( BufferIndex bufferIndex ) const
+ const bool& Get(BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- bool& operator[]( BufferIndex bufferIndex )
+ bool& operator[](BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const bool& operator[]( BufferIndex bufferIndex ) const
+ const bool& operator[](BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
void Bake(BufferIndex bufferIndex, bool value)
{
// bake has to check the base value as current buffer value can be correct by constraint or something else
- if( mBaseValue != value )
+ if(mBaseValue != value)
{
mBaseValue = value;
// It's ok to bake both buffers as render is performed in same thread as update. Reading from event side
// has never been atomically safe.
- mValue[bufferIndex] = value;
- mValue[1-bufferIndex] = value;
+ mValue[bufferIndex] = value;
+ mValue[1 - bufferIndex] = value;
OnBake();
}
void BakeRelative(BufferIndex bufferIndex, bool delta)
{
mValue[bufferIndex] = mValue[bufferIndex] || delta;
- mBaseValue = mValue[bufferIndex];
+ mBaseValue = mValue[bufferIndex];
OnBake();
}
private:
-
// Undefined
AnimatableProperty(const AnimatableProperty& property);
AnimatableProperty& operator=(const AnimatableProperty& rhs);
private:
-
- DoubleBuffered<bool> mValue; ///< The double-buffered property value
- bool mBaseValue; ///< Reset to this base value at the beginning of each frame
-
+ DoubleBuffered<bool> mValue; ///< The double-buffered property value
+ bool mBaseValue; ///< Reset to this base value at the beginning of each frame
};
-
/**
* An integer animatable property of a scene-graph object.
*/
-template <>
+template<>
class AnimatableProperty<int> : public AnimatablePropertyBase
{
public:
-
/**
* Create an animatable property.
* @param [in] initialValue The initial value of the property.
*/
- AnimatableProperty( int initialValue )
- : mValue( initialValue ),
- mBaseValue( initialValue )
+ AnimatableProperty(int initialValue)
+ : mValue(initialValue),
+ mBaseValue(initialValue)
{
}
*/
void ResetToBaseValue(BufferIndex updateBufferIndex) override
{
- if (CLEAN_FLAG != mDirtyFlags)
+ if(CLEAN_FLAG != mDirtyFlags)
{
mValue[updateBufferIndex] = mBaseValue;
- mDirtyFlags = ( mDirtyFlags >> 1 );
+ mDirtyFlags = (mDirtyFlags >> 1);
}
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetInteger()
*/
- const int& GetInteger( BufferIndex bufferIndex ) const override
+ const int& GetInteger(BufferIndex bufferIndex) const override
{
- return mValue[ bufferIndex ];
+ return mValue[bufferIndex];
}
/**
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- int& Get( BufferIndex bufferIndex )
+ int& Get(BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const int& Get( BufferIndex bufferIndex ) const
+ const int& Get(BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- int& operator[]( BufferIndex bufferIndex )
+ int& operator[](BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const int& operator[]( BufferIndex bufferIndex ) const
+ const int& operator[](BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
*/
void Bake(BufferIndex bufferIndex, int value)
{
- mValue[bufferIndex] = value;
- mValue[1-bufferIndex] = value;
- mBaseValue = mValue[bufferIndex];
+ mValue[bufferIndex] = value;
+ mValue[1 - bufferIndex] = value;
+ mBaseValue = mValue[bufferIndex];
OnBake();
}
void BakeRelative(BufferIndex bufferIndex, int delta)
{
mValue[bufferIndex] = mValue[bufferIndex] + delta;
- mBaseValue = mValue[bufferIndex];
+ mBaseValue = mValue[bufferIndex];
OnBake();
}
*/
void SetInitialRelative(const int& delta)
{
- mValue[0] = mValue[0] + delta;
- mValue[1] = mValue[0];
+ mValue[0] = mValue[0] + delta;
+ mValue[1] = mValue[0];
mBaseValue = mValue[0];
}
private:
-
// Undefined
AnimatableProperty(const AnimatableProperty& property);
AnimatableProperty& operator=(const AnimatableProperty& rhs);
private:
-
- DoubleBuffered<int> mValue; ///< The double-buffered property value
- int mBaseValue; ///< Reset to this base value at the beginning of each frame
-
+ DoubleBuffered<int> mValue; ///< The double-buffered property value
+ int mBaseValue; ///< Reset to this base value at the beginning of each frame
};
/**
* An float animatable property of a scene-graph object.
*/
-template <>
+template<>
class AnimatableProperty<float> : public AnimatablePropertyBase
{
public:
-
/**
* Create an animatable property.
* @param [in] initialValue The initial value of the property.
*/
- AnimatableProperty( float initialValue )
- : mValue( initialValue ),
- mBaseValue( initialValue )
+ AnimatableProperty(float initialValue)
+ : mValue(initialValue),
+ mBaseValue(initialValue)
{
}
*/
void ResetToBaseValue(BufferIndex updateBufferIndex) override
{
- if (CLEAN_FLAG != mDirtyFlags)
+ if(CLEAN_FLAG != mDirtyFlags)
{
mValue[updateBufferIndex] = mBaseValue;
- mDirtyFlags = ( mDirtyFlags >> 1 );
+ mDirtyFlags = (mDirtyFlags >> 1);
}
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetFloat()
*/
- const float& GetFloat( BufferIndex bufferIndex ) const override
+ const float& GetFloat(BufferIndex bufferIndex) const override
{
- return mValue[ bufferIndex ];
+ return mValue[bufferIndex];
}
/**
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- float& Get( BufferIndex bufferIndex )
+ float& Get(BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const float& Get( BufferIndex bufferIndex ) const
+ const float& Get(BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- float& operator[]( BufferIndex bufferIndex )
+ float& operator[](BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const float& operator[]( BufferIndex bufferIndex ) const
+ const float& operator[](BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
{
// It's ok to bake both buffers as render is performed in same thread as update. Reading from event side
// has never been atomically safe.
- mValue[bufferIndex] = value;
- mValue[1-bufferIndex] = value;
- mBaseValue = mValue[bufferIndex];
+ mValue[bufferIndex] = value;
+ mValue[1 - bufferIndex] = value;
+ mBaseValue = mValue[bufferIndex];
OnBake();
}
void BakeRelative(BufferIndex bufferIndex, float delta)
{
mValue[bufferIndex] = mValue[bufferIndex] + delta;
- mBaseValue = mValue[bufferIndex];
+ mBaseValue = mValue[bufferIndex];
OnBake();
}
*/
void SetInitialRelative(const float& delta)
{
- mValue[0] = mValue[0] + delta;
- mValue[1] = mValue[0];
+ mValue[0] = mValue[0] + delta;
+ mValue[1] = mValue[0];
mBaseValue = mValue[0];
}
private:
-
// Undefined
AnimatableProperty(const AnimatableProperty& property);
AnimatableProperty& operator=(const AnimatableProperty& rhs);
private:
-
- DoubleBuffered<float> mValue; ///< The double-buffered property value
- float mBaseValue; ///< Reset to this base value at the beginning of each frame
+ DoubleBuffered<float> mValue; ///< The double-buffered property value
+ float mBaseValue; ///< Reset to this base value at the beginning of each frame
};
/**
* An Vector2 animatable property of a scene-graph object.
*/
-template <>
+template<>
class AnimatableProperty<Vector2> : public AnimatablePropertyBase
{
public:
-
/**
* Create an animatable property.
* @param [in] initialValue The initial value of the property.
*/
- AnimatableProperty( const Vector2& initialValue )
- : mValue( initialValue ),
- mBaseValue( initialValue )
+ AnimatableProperty(const Vector2& initialValue)
+ : mValue(initialValue),
+ mBaseValue(initialValue)
{
}
*/
void ResetToBaseValue(BufferIndex updateBufferIndex) override
{
- if (CLEAN_FLAG != mDirtyFlags)
+ if(CLEAN_FLAG != mDirtyFlags)
{
mValue[updateBufferIndex] = mBaseValue;
- mDirtyFlags = ( mDirtyFlags >> 1 );
+ mDirtyFlags = (mDirtyFlags >> 1);
}
}
/**
* @copydoc Dali::PropertyInput::GetVector2()
*/
- const Vector2& GetVector2( BufferIndex bufferIndex ) const override
+ const Vector2& GetVector2(BufferIndex bufferIndex) const override
{
- return mValue[ bufferIndex ];
+ return mValue[bufferIndex];
}
/**
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- Vector2& Get( BufferIndex bufferIndex )
+ Vector2& Get(BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const Vector2& Get( BufferIndex bufferIndex ) const
+ const Vector2& Get(BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- Vector2& operator[]( BufferIndex bufferIndex )
+ Vector2& operator[](BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Vector2& operator[]( BufferIndex bufferIndex ) const
+ const Vector2& operator[](BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
{
// It's ok to bake both buffers as render is performed in same thread as update. Reading from event side
// has never been atomically safe.
- mValue[bufferIndex] = value;
- mValue[1-bufferIndex] = value;
- mBaseValue = value;
+ mValue[bufferIndex] = value;
+ mValue[1 - bufferIndex] = value;
+ mBaseValue = value;
OnBake();
}
*/
void BakeX(BufferIndex bufferIndex, float value)
{
- mValue[bufferIndex].x = value;
- mValue[1-bufferIndex].x = value;
- mBaseValue.x = value;
+ mValue[bufferIndex].x = value;
+ mValue[1 - bufferIndex].x = value;
+ mBaseValue.x = value;
OnBake();
}
*/
void BakeY(BufferIndex bufferIndex, float value)
{
- mValue[bufferIndex].y = value;
- mValue[1-bufferIndex].y = value;
- mBaseValue.y = value;
+ mValue[bufferIndex].y = value;
+ mValue[1 - bufferIndex].y = value;
+ mBaseValue.y = value;
OnBake();
}
}
private:
-
// Undefined
AnimatableProperty(const AnimatableProperty& property);
AnimatableProperty& operator=(const AnimatableProperty& rhs);
private:
-
- DoubleBuffered<Vector2> mValue; ///< The double-buffered property value
- Vector2 mBaseValue; ///< Reset to this base value at the beginning of each frame
-
+ DoubleBuffered<Vector2> mValue; ///< The double-buffered property value
+ Vector2 mBaseValue; ///< Reset to this base value at the beginning of each frame
};
/**
* A Vector3 animatable property of a scene-graph object.
*/
-template <>
+template<>
class AnimatableProperty<Vector3> : public AnimatablePropertyBase
{
public:
-
/**
* Create an animatable property.
*/
* Create an animatable property.
* @param [in] initialValue The initial value of the property.
*/
- AnimatableProperty( const Vector3& initialValue )
- : mValue( initialValue ),
- mBaseValue( initialValue )
+ AnimatableProperty(const Vector3& initialValue)
+ : mValue(initialValue),
+ mBaseValue(initialValue)
{
}
*/
void ResetToBaseValue(BufferIndex updateBufferIndex) override
{
- if (CLEAN_FLAG != mDirtyFlags)
+ if(CLEAN_FLAG != mDirtyFlags)
{
mValue[updateBufferIndex] = mBaseValue;
- mDirtyFlags = ( mDirtyFlags >> 1 );
+ mDirtyFlags = (mDirtyFlags >> 1);
}
}
/**
* @copydoc Dali::PropertyInput::GetVector3()
*/
- const Vector3& GetVector3( BufferIndex bufferIndex ) const override
+ const Vector3& GetVector3(BufferIndex bufferIndex) const override
{
- return mValue[ bufferIndex ];
+ return mValue[bufferIndex];
}
/**
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- Vector3& Get( BufferIndex bufferIndex )
+ Vector3& Get(BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const Vector3& Get( BufferIndex bufferIndex ) const
+ const Vector3& Get(BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- Vector3& operator[]( BufferIndex bufferIndex )
+ Vector3& operator[](BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Vector3& operator[]( BufferIndex bufferIndex ) const
+ const Vector3& operator[](BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
*/
void Bake(BufferIndex bufferIndex, const Vector3& value)
{
- mValue[bufferIndex] = value;
- mValue[1-bufferIndex] = value;
- mBaseValue = value;
+ mValue[bufferIndex] = value;
+ mValue[1 - bufferIndex] = value;
+ mBaseValue = value;
OnBake();
}
*/
void BakeX(BufferIndex bufferIndex, float value)
{
- mValue[bufferIndex].x = value;
- mValue[1-bufferIndex].x = value;
- mBaseValue.x = value;
+ mValue[bufferIndex].x = value;
+ mValue[1 - bufferIndex].x = value;
+ mBaseValue.x = value;
OnBake();
}
*/
void BakeY(BufferIndex bufferIndex, float value)
{
- mValue[bufferIndex].y = value;
- mValue[1-bufferIndex].y = value;
- mBaseValue.y = value;
+ mValue[bufferIndex].y = value;
+ mValue[1 - bufferIndex].y = value;
+ mBaseValue.y = value;
OnBake();
}
*/
void BakeZ(BufferIndex bufferIndex, float value)
{
- mValue[bufferIndex].z = value;
- mValue[1-bufferIndex].z = value;
- mBaseValue.z = value;
+ mValue[bufferIndex].z = value;
+ mValue[1 - bufferIndex].z = value;
+ mBaseValue.z = value;
OnBake();
}
}
private:
-
// Undefined
AnimatableProperty(const AnimatableProperty& property);
AnimatableProperty& operator=(const AnimatableProperty& rhs);
private:
-
- DoubleBuffered<Vector3> mValue; ///< The double-buffered property value
- Vector3 mBaseValue; ///< Reset to this base value at the beginning of each frame
-
+ DoubleBuffered<Vector3> mValue; ///< The double-buffered property value
+ Vector3 mBaseValue; ///< Reset to this base value at the beginning of each frame
};
/**
* A Vector4 animatable property of a scene-graph object.
*/
-template <>
+template<>
class AnimatableProperty<Vector4> : public AnimatablePropertyBase
{
public:
-
/**
* Create an animatable property.
* @param [in] initialValue The initial value of the property.
*/
- AnimatableProperty( const Vector4& initialValue )
- : mValue( initialValue ),
- mBaseValue( initialValue )
+ AnimatableProperty(const Vector4& initialValue)
+ : mValue(initialValue),
+ mBaseValue(initialValue)
{
}
*/
void ResetToBaseValue(BufferIndex updateBufferIndex) override
{
- if (CLEAN_FLAG != mDirtyFlags)
+ if(CLEAN_FLAG != mDirtyFlags)
{
mValue[updateBufferIndex] = mBaseValue;
- mDirtyFlags = ( mDirtyFlags >> 1 );
+ mDirtyFlags = (mDirtyFlags >> 1);
}
}
/**
* @copydoc Dali::PropertyInput::GetVector4()
*/
- const Vector4& GetVector4( BufferIndex bufferIndex ) const override
+ const Vector4& GetVector4(BufferIndex bufferIndex) const override
{
- return mValue[ bufferIndex ];
+ return mValue[bufferIndex];
}
/**
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- Vector4& Get( BufferIndex bufferIndex )
+ Vector4& Get(BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const Vector4& Get( BufferIndex bufferIndex ) const
+ const Vector4& Get(BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- Vector4& operator[]( BufferIndex bufferIndex )
+ Vector4& operator[](BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Vector4& operator[]( BufferIndex bufferIndex ) const
+ const Vector4& operator[](BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
*/
void Bake(BufferIndex bufferIndex, const Vector4& value)
{
- mValue[bufferIndex] = value;
- mValue[1-bufferIndex] = value;
- mBaseValue = mValue[bufferIndex];
+ mValue[bufferIndex] = value;
+ mValue[1 - bufferIndex] = value;
+ mBaseValue = mValue[bufferIndex];
OnBake();
}
*/
void BakeX(BufferIndex bufferIndex, float value)
{
- mValue[bufferIndex].x = value;
- mValue[1-bufferIndex].x = value;
- mBaseValue.x = mValue[bufferIndex].x;
+ mValue[bufferIndex].x = value;
+ mValue[1 - bufferIndex].x = value;
+ mBaseValue.x = mValue[bufferIndex].x;
OnBake();
}
*/
void BakeY(BufferIndex bufferIndex, float value)
{
- mValue[bufferIndex].y = value;
- mValue[1-bufferIndex].y = value;
- mBaseValue.y = mValue[bufferIndex].y;
+ mValue[bufferIndex].y = value;
+ mValue[1 - bufferIndex].y = value;
+ mBaseValue.y = mValue[bufferIndex].y;
OnBake();
}
*/
void BakeZ(BufferIndex bufferIndex, float value)
{
- mValue[bufferIndex].z = value;
- mValue[1-bufferIndex].z = value;
- mBaseValue.z = mValue[bufferIndex].z;
+ mValue[bufferIndex].z = value;
+ mValue[1 - bufferIndex].z = value;
+ mBaseValue.z = mValue[bufferIndex].z;
OnBake();
}
*/
void BakeW(BufferIndex bufferIndex, float value)
{
- mValue[bufferIndex].w = value;
- mValue[1-bufferIndex].w = value;
- mBaseValue.w = mValue[bufferIndex].w;
+ mValue[bufferIndex].w = value;
+ mValue[1 - bufferIndex].w = value;
+ mBaseValue.w = mValue[bufferIndex].w;
OnBake();
}
void BakeRelative(BufferIndex bufferIndex, const Vector4& delta)
{
mValue[bufferIndex] = mValue[bufferIndex] + delta;
- mBaseValue = mValue[bufferIndex];
+ mBaseValue = mValue[bufferIndex];
OnBake();
}
void BakeXRelative(BufferIndex bufferIndex, float delta)
{
mValue[bufferIndex].x = mValue[bufferIndex].x + delta;
- mBaseValue.x = mValue[bufferIndex].x;
+ mBaseValue.x = mValue[bufferIndex].x;
OnBake();
}
void BakeYRelative(BufferIndex bufferIndex, float delta)
{
mValue[bufferIndex].y = mValue[bufferIndex].y + delta;
- mBaseValue.y = mValue[bufferIndex].y;
+ mBaseValue.y = mValue[bufferIndex].y;
OnBake();
}
void BakeZRelative(BufferIndex bufferIndex, float delta)
{
mValue[bufferIndex].z = mValue[bufferIndex].z + delta;
- mBaseValue.z = mValue[bufferIndex].z;
+ mBaseValue.z = mValue[bufferIndex].z;
OnBake();
}
void BakeWRelative(BufferIndex bufferIndex, float delta)
{
mValue[bufferIndex].w = mValue[bufferIndex].w + delta;
- mBaseValue.w = mValue[bufferIndex].w;
+ mBaseValue.w = mValue[bufferIndex].w;
OnBake();
}
}
private:
-
// Undefined
AnimatableProperty(const AnimatableProperty& property);
AnimatableProperty& operator=(const AnimatableProperty& rhs);
private:
-
- DoubleBuffered<Vector4> mValue; ///< The double-buffered property value
- Vector4 mBaseValue; ///< Reset to this base value at the beginning of each frame
-
+ DoubleBuffered<Vector4> mValue; ///< The double-buffered property value
+ Vector4 mBaseValue; ///< Reset to this base value at the beginning of each frame
};
/**
* An Quaternion animatable property of a scene-graph object.
*/
-template <>
+template<>
class AnimatableProperty<Quaternion> : public AnimatablePropertyBase
{
public:
-
/**
* Create an animatable property.
*/
* Create an animatable property.
* @param [in] initialValue The initial value of the property.
*/
- AnimatableProperty( const Quaternion& initialValue )
- : mValue( initialValue ),
- mBaseValue( initialValue )
+ AnimatableProperty(const Quaternion& initialValue)
+ : mValue(initialValue),
+ mBaseValue(initialValue)
{
}
*/
void ResetToBaseValue(BufferIndex updateBufferIndex) override
{
- if (CLEAN_FLAG != mDirtyFlags)
+ if(CLEAN_FLAG != mDirtyFlags)
{
mValue[updateBufferIndex] = mBaseValue;
- mDirtyFlags = ( mDirtyFlags >> 1 );
+ mDirtyFlags = (mDirtyFlags >> 1);
}
}
/**
* @copydoc Dali::PropertyInput::GetQuaternion()
*/
- const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const override
+ const Quaternion& GetQuaternion(BufferIndex bufferIndex) const override
{
- return mValue[ bufferIndex ];
+ return mValue[bufferIndex];
}
/**
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- Quaternion& Get( BufferIndex bufferIndex )
+ Quaternion& Get(BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const Quaternion& Get( BufferIndex bufferIndex ) const
+ const Quaternion& Get(BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- Quaternion& operator[]( BufferIndex bufferIndex )
+ Quaternion& operator[](BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Quaternion& operator[]( BufferIndex bufferIndex ) const
+ const Quaternion& operator[](BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
{
// It's ok to bake both buffers as render is performed in same thread as update. Reading from event side
// has never been atomically safe.
- mValue[bufferIndex] = value;
- mValue[1-bufferIndex] = value;
- mBaseValue = value;
+ mValue[bufferIndex] = value;
+ mValue[1 - bufferIndex] = value;
+ mBaseValue = value;
OnBake();
}
}
private:
-
// Undefined
AnimatableProperty(const AnimatableProperty& property);
AnimatableProperty& operator=(const AnimatableProperty& rhs);
private:
-
- DoubleBuffered<Quaternion> mValue; ///< The double-buffered property value
- Quaternion mBaseValue; ///< Reset to this base value at the beginning of each frame
-
+ DoubleBuffered<Quaternion> mValue; ///< The double-buffered property value
+ Quaternion mBaseValue; ///< Reset to this base value at the beginning of each frame
};
/**
* A Matrix animatable property of a scene-graph object.
*/
-template <>
+template<>
class AnimatableProperty<Matrix> : public AnimatablePropertyBase
{
public:
-
/**
* Create an animatable property.
* @param [in] initialValue The initial value of the property.
*/
- AnimatableProperty( const Matrix& initialValue )
- : mValue( initialValue ),
- mBaseValue( initialValue )
+ AnimatableProperty(const Matrix& initialValue)
+ : mValue(initialValue),
+ mBaseValue(initialValue)
{
}
*/
void ResetToBaseValue(BufferIndex updateBufferIndex) override
{
- if (CLEAN_FLAG != mDirtyFlags)
+ if(CLEAN_FLAG != mDirtyFlags)
{
mValue[updateBufferIndex] = mBaseValue;
- mDirtyFlags = ( mDirtyFlags >> 1 );
+ mDirtyFlags = (mDirtyFlags >> 1);
}
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetMatrix()
*/
- const Matrix& GetMatrix( BufferIndex bufferIndex ) const override
+ const Matrix& GetMatrix(BufferIndex bufferIndex) const override
{
- return mValue[ bufferIndex ];
+ return mValue[bufferIndex];
}
/**
OnSet();
}
-
/**
* Change the property value by a relative amount.
* @param[in] bufferIndex The buffer to write.
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- Matrix& Get( BufferIndex bufferIndex )
+ Matrix& Get(BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const Matrix& Get( BufferIndex bufferIndex ) const
+ const Matrix& Get(BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- Matrix& operator[]( BufferIndex bufferIndex )
+ Matrix& operator[](BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Matrix& operator[]( BufferIndex bufferIndex ) const
+ const Matrix& operator[](BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
{
// It's ok to bake both buffers as render is performed in same thread as update. Reading from event side
// has never been atomically safe.
- mValue[bufferIndex] = value;
- mValue[1-bufferIndex] = value;
- mBaseValue = mValue[bufferIndex];
+ mValue[bufferIndex] = value;
+ mValue[1 - bufferIndex] = value;
+ mBaseValue = mValue[bufferIndex];
OnBake();
}
Matrix temp;
Matrix::Multiply(temp, mValue[bufferIndex], delta);
mValue[bufferIndex] = temp;
- mBaseValue = temp;
+ mBaseValue = temp;
OnBake();
}
private:
-
// Undefined
AnimatableProperty(const AnimatableProperty& property);
AnimatableProperty& operator=(const AnimatableProperty& rhs);
private:
-
- DoubleBuffered<Matrix> mValue; ///< The double-buffered property value
- Matrix mBaseValue; ///< Reset to this base value at the beginning of each frame
-
+ DoubleBuffered<Matrix> mValue; ///< The double-buffered property value
+ Matrix mBaseValue; ///< Reset to this base value at the beginning of each frame
};
/**
* A Matrix3 animatable property of a scene-graph object.
*/
-template <>
+template<>
class AnimatableProperty<Matrix3> : public AnimatablePropertyBase
{
public:
-
/**
* Create an animatable property.
* @param [in] initialValue The initial value of the property.
*/
- AnimatableProperty( const Matrix3& initialValue )
- : mValue( initialValue ),
- mBaseValue( initialValue )
+ AnimatableProperty(const Matrix3& initialValue)
+ : mValue(initialValue),
+ mBaseValue(initialValue)
{
}
*/
void ResetToBaseValue(BufferIndex updateBufferIndex) override
{
- if (CLEAN_FLAG != mDirtyFlags)
+ if(CLEAN_FLAG != mDirtyFlags)
{
mValue[updateBufferIndex] = mBaseValue;
- mDirtyFlags = ( mDirtyFlags >> 1 );
+ mDirtyFlags = (mDirtyFlags >> 1);
}
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetMatrix3()
*/
- const Matrix3& GetMatrix3( BufferIndex bufferIndex ) const override
+ const Matrix3& GetMatrix3(BufferIndex bufferIndex) const override
{
- return mValue[ bufferIndex ];
+ return mValue[bufferIndex];
}
/**
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- Matrix3& Get( BufferIndex bufferIndex )
+ Matrix3& Get(BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const Matrix3& Get( BufferIndex bufferIndex ) const
+ const Matrix3& Get(BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- Matrix3& operator[]( BufferIndex bufferIndex )
+ Matrix3& operator[](BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Matrix3& operator[]( BufferIndex bufferIndex ) const
+ const Matrix3& operator[](BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
{
// It's ok to bake both buffers as render is performed in same thread as update. Reading from event side
// has never been atomically safe.
- mValue[bufferIndex] = value;
- mValue[1-bufferIndex] = value;
- mBaseValue = mValue[bufferIndex];
+ mValue[bufferIndex] = value;
+ mValue[1 - bufferIndex] = value;
+ mBaseValue = mValue[bufferIndex];
OnBake();
}
Matrix3 temp;
Matrix3::Multiply(temp, mValue[bufferIndex], delta);
mValue[bufferIndex] = temp;
- mBaseValue = temp;
+ mBaseValue = temp;
OnBake();
}
private:
-
// Undefined
AnimatableProperty(const AnimatableProperty& property);
AnimatableProperty& operator=(const AnimatableProperty& rhs);
private:
-
- DoubleBuffered<Matrix3> mValue; ///< The double-buffered property value
- Matrix3 mBaseValue; ///< Reset to this base value at the beginning of each frame
-
+ DoubleBuffered<Matrix3> mValue; ///< The double-buffered property value
+ Matrix3 mBaseValue; ///< Reset to this base value at the beginning of each frame
};
} // namespace SceneGraph
// Messages for AnimatableProperty<T>
-template <class T>
-void BakeMessage( EventThreadServices& eventThreadServices,
- const SceneGraph::AnimatableProperty<T>& property,
- typename ParameterType< T >::PassingType newValue )
+template<class T>
+void BakeMessage(EventThreadServices& eventThreadServices,
+ const SceneGraph::AnimatableProperty<T>& property,
+ typename ParameterType<T>::PassingType newValue)
{
using LocalType = MessageDoubleBuffered1<SceneGraph::AnimatableProperty<T>, T>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &property,
- &SceneGraph::AnimatableProperty<T>::Bake,
- newValue );
+ new(slot) LocalType(&property,
+ &SceneGraph::AnimatableProperty<T>::Bake,
+ newValue);
}
-template <class T>
-void BakeRelativeMessage( EventThreadServices& eventThreadServices,
- const SceneGraph::AnimatableProperty<T>& property,
- const T& delta )
+template<class T>
+void BakeRelativeMessage(EventThreadServices& eventThreadServices,
+ const SceneGraph::AnimatableProperty<T>& property,
+ const T& delta)
{
using LocalType = MessageDoubleBuffered1<SceneGraph::AnimatableProperty<T>, const T&>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &property,
- &SceneGraph::AnimatableProperty<T>::BakeRelative,
- delta );
+ new(slot) LocalType(&property,
+ &SceneGraph::AnimatableProperty<T>::BakeRelative,
+ delta);
}
-template <class T>
-void SetXComponentMessage( EventThreadServices& eventThreadServices,
- const SceneGraph::AnimatableProperty<T>& property,
- typename ParameterType< float >::PassingType newValue )
+template<class T>
+void SetXComponentMessage(EventThreadServices& eventThreadServices,
+ const SceneGraph::AnimatableProperty<T>& property,
+ typename ParameterType<float>::PassingType newValue)
{
using LocalType = MessageDoubleBuffered1<SceneGraph::AnimatableProperty<T>, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &property,
- &SceneGraph::AnimatableProperty<T>::BakeX,
- newValue );
+ new(slot) LocalType(&property,
+ &SceneGraph::AnimatableProperty<T>::BakeX,
+ newValue);
}
-template <class T>
-void SetYComponentMessage( EventThreadServices& eventThreadServices,
- const SceneGraph::AnimatableProperty<T>& property,
- typename ParameterType< float >::PassingType newValue )
+template<class T>
+void SetYComponentMessage(EventThreadServices& eventThreadServices,
+ const SceneGraph::AnimatableProperty<T>& property,
+ typename ParameterType<float>::PassingType newValue)
{
using LocalType = MessageDoubleBuffered1<SceneGraph::AnimatableProperty<T>, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &property,
- &SceneGraph::AnimatableProperty<T>::BakeY,
- newValue );
+ new(slot) LocalType(&property,
+ &SceneGraph::AnimatableProperty<T>::BakeY,
+ newValue);
}
-template <class T>
-void SetZComponentMessage( EventThreadServices& eventThreadServices,
- const SceneGraph::AnimatableProperty<T>& property,
- typename ParameterType< float >::PassingType newValue )
+template<class T>
+void SetZComponentMessage(EventThreadServices& eventThreadServices,
+ const SceneGraph::AnimatableProperty<T>& property,
+ typename ParameterType<float>::PassingType newValue)
{
using LocalType = MessageDoubleBuffered1<SceneGraph::AnimatableProperty<T>, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &property,
- &SceneGraph::AnimatableProperty<T>::BakeZ,
- newValue );
+ new(slot) LocalType(&property,
+ &SceneGraph::AnimatableProperty<T>::BakeZ,
+ newValue);
}
-template <class T>
-void SetWComponentMessage( EventThreadServices& eventThreadServices,
- const SceneGraph::AnimatableProperty<T>& property,
- typename ParameterType< float >::PassingType newValue )
+template<class T>
+void SetWComponentMessage(EventThreadServices& eventThreadServices,
+ const SceneGraph::AnimatableProperty<T>& property,
+ typename ParameterType<float>::PassingType newValue)
{
using LocalType = MessageDoubleBuffered1<SceneGraph::AnimatableProperty<T>, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &property,
- &SceneGraph::AnimatableProperty<T>::BakeW,
- newValue );
+ new(slot) LocalType(&property,
+ &SceneGraph::AnimatableProperty<T>::BakeW,
+ newValue);
}
} // namespace Internal
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/update/common/discard-queue.h>
// INTERNAL INCLUDES
-#include <dali/internal/render/gl-resources/gl-resource-owner.h>
#include <dali/internal/common/message.h>
-#include <dali/internal/update/nodes/node.h>
+#include <dali/internal/render/gl-resources/gl-resource-owner.h>
#include <dali/internal/render/queue/render-queue.h>
#include <dali/internal/render/renderers/render-renderer.h>
#include <dali/internal/render/shaders/scene-graph-shader.h>
-#include <dali/internal/update/render-tasks/scene-graph-camera.h>
#include <dali/internal/update/common/scene-graph-scene.h>
+#include <dali/internal/update/nodes/node.h>
+#include <dali/internal/update/render-tasks/scene-graph-camera.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
-DiscardQueue::DiscardQueue( RenderQueue& renderQueue )
-: mRenderQueue( renderQueue ),
+DiscardQueue::DiscardQueue(RenderQueue& renderQueue)
+: mRenderQueue(renderQueue),
mNodeQueue(),
mShaderQueue(),
mRendererQueue(),
DiscardQueue::~DiscardQueue() = default;
-void DiscardQueue::Add( BufferIndex updateBufferIndex, Node* node )
+void DiscardQueue::Add(BufferIndex updateBufferIndex, Node* node)
{
- DALI_ASSERT_DEBUG( NULL != node );
+ DALI_ASSERT_DEBUG(NULL != node);
// The GL resources will now be freed in frame N
// The Update for frame N+1 may occur in parallel with the rendering of frame N
// Queue the node for destruction in frame N+2
- mNodeQueue[ updateBufferIndex ].PushBack( node );
+ mNodeQueue[updateBufferIndex].PushBack(node);
}
-void DiscardQueue::Add( BufferIndex updateBufferIndex, Shader* shader )
+void DiscardQueue::Add(BufferIndex updateBufferIndex, Shader* shader)
{
- DALI_ASSERT_DEBUG( NULL != shader );
+ DALI_ASSERT_DEBUG(NULL != shader);
// Programs are cached for the lifetime of DALi so no need for GL cleanup for shader for now.
// The GL resources will now be freed in frame N
// The Update for frame N+1 may occur in parallel with the rendering of frame N
// Queue the node for destruction in frame N+2
- mShaderQueue[ updateBufferIndex ].PushBack( shader );
+ mShaderQueue[updateBufferIndex].PushBack(shader);
}
-void DiscardQueue::Add( BufferIndex updateBufferIndex, Renderer* renderer )
+void DiscardQueue::Add(BufferIndex updateBufferIndex, Renderer* renderer)
{
- DALI_ASSERT_DEBUG( NULL != renderer );
+ DALI_ASSERT_DEBUG(NULL != renderer);
// The GL resources will now be freed in frame N
// The Update for frame N+1 may occur in parallel with the rendering of frame N
// Queue the node for destruction in frame N+2
- mRendererQueue[ updateBufferIndex ].PushBack( renderer );
+ mRendererQueue[updateBufferIndex].PushBack(renderer);
}
-void DiscardQueue::Add( BufferIndex updateBufferIndex, Camera* camera )
+void DiscardQueue::Add(BufferIndex updateBufferIndex, Camera* camera)
{
- DALI_ASSERT_DEBUG( NULL != camera );
+ DALI_ASSERT_DEBUG(NULL != camera);
- mCameraQueue[ updateBufferIndex ].PushBack( camera );
+ mCameraQueue[updateBufferIndex].PushBack(camera);
}
-void DiscardQueue::Add( BufferIndex updateBufferIndex, Scene* scene )
+void DiscardQueue::Add(BufferIndex updateBufferIndex, Scene* scene)
{
- DALI_ASSERT_DEBUG( NULL != scene );
+ DALI_ASSERT_DEBUG(NULL != scene);
- mSceneQueue[ updateBufferIndex ].PushBack( scene );
+ mSceneQueue[updateBufferIndex].PushBack(scene);
}
-void DiscardQueue::Clear( BufferIndex updateBufferIndex )
+void DiscardQueue::Clear(BufferIndex updateBufferIndex)
{
// Destroy some discarded objects; these should no longer own any GL resources
- mNodeQueue[ updateBufferIndex ].Clear();
- mShaderQueue[ updateBufferIndex ].Clear();
- mRendererQueue[ updateBufferIndex ].Clear();
- mCameraQueue[ updateBufferIndex ].Clear();
- mSceneQueue[ updateBufferIndex ].Clear();
+ mNodeQueue[updateBufferIndex].Clear();
+ mShaderQueue[updateBufferIndex].Clear();
+ mRendererQueue[updateBufferIndex].Clear();
+ mCameraQueue[updateBufferIndex].Clear();
+ mSceneQueue[updateBufferIndex].Clear();
}
} // namespace SceneGraph
#define DALI_INTERNAL_DISCARD_QUEUE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
#include <dali/devel-api/common/owner-container.h>
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/update/nodes/node-declarations.h>
-#include <dali/internal/update/rendering/scene-graph-texture-set.h>
#include <dali/internal/update/rendering/scene-graph-renderer.h>
+#include <dali/internal/update/rendering/scene-graph-texture-set.h>
+#include <dali/public-api/object/ref-object.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
class RenderQueue;
class Shader;
class Camera;
class Scene;
-
/**
* DiscardQueue is used to cleanup nodes & resources when no longer in use.
* Unwanted objects are added here during UpdateManager::Update().
* Create a new DiscardQueue.
* @param[in] renderQueue Used to send GL clean-up messages for the next Render.
*/
- DiscardQueue( RenderQueue& renderQueue );
+ DiscardQueue(RenderQueue& renderQueue);
/**
* Non-virtual destructor; DiscardQueue is not suitable as a base class.
* @param[in] updateBufferIndex The current update buffer index.
* @param[in] node The discarded node; DiscardQueue takes ownership.
*/
- void Add( BufferIndex updateBufferIndex, Node* node );
+ void Add(BufferIndex updateBufferIndex, Node* node);
/**
* Adds an unwanted shader to the discard queue.
* @param[in] bufferIndex The current update buffer index.
* @param[in] shader The shader to queue; DiscardQueue takes ownership.
*/
- void Add( BufferIndex bufferIndex, Shader* shader );
+ void Add(BufferIndex bufferIndex, Shader* shader);
/**
* Adds an unwanted Renderer to the discard queue.
* @param[in] updateBufferIndex The current update buffer index.
* @param[in] renderer The discarded renderer; DiscardQueue takes ownership.
*/
- void Add( BufferIndex updateBufferIndex, Renderer* renderer );
+ void Add(BufferIndex updateBufferIndex, Renderer* renderer);
/**
* Adds an unwanted Camera to the discard queue.
* @param[in] updateBufferIndex The current update buffer index.
* @param[in] camera The discarded renderer; DiscardQueue takes ownership.
*/
- void Add( BufferIndex updateBufferIndex, Camera* camera );
+ void Add(BufferIndex updateBufferIndex, Camera* camera);
/**
* Adds an unwanted Scene to the discard queue.
* @param[in] updateBufferIndex The current update buffer index.
* @param[in] scene The discarded scene; DiscardQueue takes ownership.
*/
- void Add( BufferIndex updateBufferIndex, Scene* scene );
+ void Add(BufferIndex updateBufferIndex, Scene* scene);
/**
* Release the nodes which were queued in the frame N-2.
* @pre This method should be called (once) at the beginning of every Update.
* @param[in] updateBufferIndex The current update buffer index.
*/
- void Clear( BufferIndex updateBufferIndex );
+ void Clear(BufferIndex updateBufferIndex);
private:
-
// Undefined
- DiscardQueue( const DiscardQueue& );
+ DiscardQueue(const DiscardQueue&);
// Undefined
- DiscardQueue& operator=( const DiscardQueue& rhs );
+ DiscardQueue& operator=(const DiscardQueue& rhs);
private:
-
RenderQueue& mRenderQueue; ///< Used to send GL clean-up messages for the next Render.
// Messages are queued here following the current update buffer number
- OwnerContainer< Node* > mNodeQueue[2];
- ShaderQueue mShaderQueue[2];
- RendererQueue mRendererQueue[2];
- CameraQueue mCameraQueue[2];
- SceneQueue mSceneQueue[2];
+ OwnerContainer<Node*> mNodeQueue[2];
+ ShaderQueue mShaderQueue[2];
+ RendererQueue mRendererQueue[2];
+ CameraQueue mCameraQueue[2];
+ SceneQueue mSceneQueue[2];
};
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_DOUBLE_BUFFERED_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
// The number of buffers per scene-graph property
static const unsigned int NUM_SCENE_GRAPH_BUFFERS = 2;
namespace SceneGraph
{
-
/**
* Templated class for a double-buffered value.
*/
-template <typename T>
+template<typename T>
class DoubleBuffered
{
public:
-
DoubleBuffered()
: mValue1(),
mValue2()
{
DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
- return *(&mValue1+i);
+ return *(&mValue1 + i);
}
inline const T& operator[](const BufferIndex i) const
{
DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
- return *(&mValue1+i);
+ return *(&mValue1 + i);
}
private:
-
// Undefined
DoubleBuffered<T>(const DoubleBuffered<T>&);
DoubleBuffered<T>& operator=(const DoubleBuffered<T>& rhs);
private:
-
T mValue1;
T mValue2;
};
* This class takes ownership of the pointers and releases the memory when the pointer
* is no longer used by either buffer
*/
-template <typename T>
-class DoubleBuffered< OwnerPointer< T > >
+template<typename T>
+class DoubleBuffered<OwnerPointer<T> >
{
public:
-
/**
* Class that deals with setting a value
*/
* @brief Assignment operator to that a value that will later
* be set in the correct buffer index of the object referenced by the setter.
*/
- Setter& operator=( T* value )
+ Setter& operator=(T* value)
{
mValue = value;
return *this;
~Setter()
{
- mObject.Set( mIndex, mValue );
+ mObject.Set(mIndex, mValue);
}
private:
- Setter( DoubleBuffered& object,
- BufferIndex i,
- T* value )
- : mObject( object ),
- mIndex( i ),
- mValue( value )
+ Setter(DoubleBuffered& object,
+ BufferIndex i,
+ T* value)
+ : mObject(object),
+ mIndex(i),
+ mValue(value)
{
}
- Setter( const Setter& rhs )
- : mObject( rhs.mObject ),
- mIndex( rhs.mIndex ),
- mValue( rhs.mValue )
+ Setter(const Setter& rhs)
+ : mObject(rhs.mObject),
+ mIndex(rhs.mIndex),
+ mValue(rhs.mValue)
{
}
- DoubleBuffered& mObject; ///< Double-buffered object that will be changed
- const BufferIndex mIndex; ///< Buffer index that will be changed
- T* mValue; ///< Value of the pointer
+ DoubleBuffered& mObject; ///< Double-buffered object that will be changed
+ const BufferIndex mIndex; ///< Buffer index that will be changed
+ T* mValue; ///< Value of the pointer
friend class DoubleBuffered;
};
DoubleBuffered()
- : mValue1( NULL ),
- mValue2( NULL )
+ : mValue1(NULL),
+ mValue2(NULL)
{
}
DoubleBuffered(T* val)
- : mValue1( val ),
- mValue2( val )
+ : mValue1(val),
+ mValue2(val)
{
}
~DoubleBuffered()
{
- if( mValue2 != mValue1 )
+ if(mValue2 != mValue1)
{
delete mValue2;
}
delete mValue1;
}
- void Set( BufferIndex i, T* value )
+ void Set(BufferIndex i, T* value)
{
- T*& current = *(&mValue1 + i);
- T*& previous = *(&mValue1 + 1u-i);
+ T*& current = *(&mValue1 + i);
+ T*& previous = *(&mValue1 + 1u - i);
- if( current != value && current != previous )
+ if(current != value && current != previous)
{
delete current;
}
current = value;
}
- Setter operator[]( BufferIndex i )
+ Setter operator[](BufferIndex i)
{
- return Setter( *this, i, *(&mValue1+i) );
+ return Setter(*this, i, *(&mValue1 + i));
}
- const T* operator[]( BufferIndex i ) const
+ const T* operator[](BufferIndex i) const
{
DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
- return *(&mValue1+i);
+ return *(&mValue1 + i);
}
/**
* Auto-age the property: if it was set the previous frame,
* then copy the value into the current frame's buffer.
*/
- void CopyPrevious( BufferIndex i )
+ void CopyPrevious(BufferIndex i)
{
DALI_ASSERT_DEBUG(i < NUM_SCENE_GRAPH_BUFFERS);
- T*& current = *(&mValue1 + i);
- T*& previous = *(&mValue1 + 1u-i);
+ T*& current = *(&mValue1 + i);
+ T*& previous = *(&mValue1 + 1u - i);
- if( current != previous )
+ if(current != previous)
{
delete current;
}
}
private:
-
// Undefined
DoubleBuffered(const DoubleBuffered&);
DoubleBuffered& operator=(const DoubleBuffered& rhs);
private:
-
T* mValue1;
T* mValue2;
-
};
-
} // namespace SceneGraph
} // namespace Internal
#define DALI_INTERNAL_SCENE_GRAPH_INHERITED_PROPERTY_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/update/common/property-base.h>
#include <dali/internal/update/common/scene-graph-buffers.h>
#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/object/property.h>
+#include <dali/public-api/math/math-utils.h> // Clamp
#include <dali/public-api/object/property-input.h>
#include <dali/public-api/object/property-types.h>
-#include <dali/public-api/math/math-utils.h> // Clamp
+#include <dali/public-api/object/property.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
/**
* An inherited Vector3 property.
*/
class InheritedVector3 : public PropertyInputImpl
{
public:
-
/**
* Create an inherited Vector3.
*/
InheritedVector3()
: mValue(),
- mInheritedFlag( false ),
- mReinheritedFlag( true )
+ mInheritedFlag(false),
+ mReinheritedFlag(true)
{
}
* Create an inherited Vector3.
* @param [in] initialValue The initial value of the property.
*/
- InheritedVector3( const Vector3& initialValue )
- : mValue( initialValue ),
- mInheritedFlag( false ),
- mReinheritedFlag( true )
+ InheritedVector3(const Vector3& initialValue)
+ : mValue(initialValue),
+ mInheritedFlag(false),
+ mReinheritedFlag(true)
{
}
/**
* Called once per Update (only) if the property did not need to be re-inherited.
* @param[in] updateBufferIndex The current update buffer index.
*/
- void CopyPrevious( BufferIndex updateBufferIndex )
+ void CopyPrevious(BufferIndex updateBufferIndex)
{
- if ( mReinheritedFlag )
+ if(mReinheritedFlag)
{
mValue[updateBufferIndex] = mValue[updateBufferIndex ? 0 : 1];
*/
virtual bool IsClean() const
{
- return ( false == mReinheritedFlag );
+ return (false == mReinheritedFlag);
}
/**
/**
* @copydoc Dali::PropertyInput::GetVector3()
*/
- const Vector3& GetVector3( BufferIndex bufferIndex ) const override
+ const Vector3& GetVector3(BufferIndex bufferIndex) const override
{
- return mValue[ bufferIndex ];
+ return mValue[bufferIndex];
}
/**
* @copydoc Dali::PropertyInput::GetConstraintInputVector3()
*/
- const Vector3& GetConstraintInputVector3( BufferIndex bufferIndex ) const override
+ const Vector3& GetConstraintInputVector3(BufferIndex bufferIndex) const override
{
// For inherited properties, constraints work with the value from the previous frame.
// This is because constraints are applied to position etc, before world-position is calculated.
BufferIndex eventBufferIndex = bufferIndex ? 0u : 1u;
- return mValue[ eventBufferIndex ];
+ return mValue[eventBufferIndex];
}
/**
/**
* @copydoc Dali::SceneGraph::PropertyInterface::Get()
*/
- Vector3& Get( BufferIndex bufferIndex )
+ Vector3& Get(BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::PropertyInterface::Get()
*/
- const Vector3& Get( BufferIndex bufferIndex ) const
+ const Vector3& Get(BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Vector3& operator[]( BufferIndex bufferIndex ) const
+ const Vector3& operator[](BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
private:
-
// Undefined
InheritedVector3(const InheritedVector3& property);
InheritedVector3& operator=(const InheritedVector3& rhs);
private:
-
DoubleBuffered<Vector3> mValue; ///< The double-buffered property value
- bool mInheritedFlag :1; ///< Flag whether the value has ever been inherited
- bool mReinheritedFlag :1; ///< Flag whether value was re-inherited in previous frame
+ bool mInheritedFlag : 1; ///< Flag whether the value has ever been inherited
+ bool mReinheritedFlag : 1; ///< Flag whether value was re-inherited in previous frame
};
/**
class InheritedColor : public PropertyInputImpl
{
public:
-
/**
* Create an inherited property.
* @param [in] initialValue The initial value of the property.
*/
- InheritedColor( const Vector4& initialValue )
- : mValue( initialValue ),
- mInheritedFlag( false ),
- mReinheritedFlag( true )
+ InheritedColor(const Vector4& initialValue)
+ : mValue(initialValue),
+ mInheritedFlag(false),
+ mReinheritedFlag(true)
{
}
* Called once per Update (only) if the property did not need to be re-inherited.
* @param[in] updateBufferIndex The current update buffer index.
*/
- void CopyPrevious( BufferIndex updateBufferIndex )
+ void CopyPrevious(BufferIndex updateBufferIndex)
{
- if ( mReinheritedFlag )
+ if(mReinheritedFlag)
{
mValue[updateBufferIndex] = mValue[updateBufferIndex ? 0 : 1];
*/
virtual bool IsClean() const
{
- return ( false == mReinheritedFlag );
+ return (false == mReinheritedFlag);
}
/**
/**
* @copydoc Dali::PropertyInput::GetVector4()
*/
- const Vector4& GetVector4( BufferIndex bufferIndex ) const override
+ const Vector4& GetVector4(BufferIndex bufferIndex) const override
{
- return mValue[ bufferIndex ];
+ return mValue[bufferIndex];
}
/**
* @copydoc Dali::PropertyInput::GetConstraintInputVector4()
*/
- const Vector4& GetConstraintInputVector4( BufferIndex bufferIndex ) const override
+ const Vector4& GetConstraintInputVector4(BufferIndex bufferIndex) const override
{
// For inherited properties, constraints work with the value from the previous frame.
// This is because constraints are applied to position etc, before world-position is calculated.
BufferIndex eventBufferIndex = bufferIndex ? 0u : 1u;
- return mValue[ eventBufferIndex ];
+ return mValue[eventBufferIndex];
}
/**
*/
void Set(BufferIndex bufferIndex, const Vector4& value)
{
- mValue[bufferIndex] = Clamp( value, 0.0f, 1.0f ); // color values are clamped between 0 and 1
+ mValue[bufferIndex] = Clamp(value, 0.0f, 1.0f); // color values are clamped between 0 and 1
// The value has been inherited for the first time
- mInheritedFlag = true;
+ mInheritedFlag = true;
mReinheritedFlag = true;
}
* @param[in] b The new blue value.
* @param[in] a The new alpha value.
*/
- void Set(BufferIndex bufferIndex, float r, float g, float b, float a )
+ void Set(BufferIndex bufferIndex, float r, float g, float b, float a)
{
- mValue[bufferIndex].r = Clamp( r, 0.0f, 1.0f ); // color values are clamped between 0 and 1
- mValue[bufferIndex].g = Clamp( g, 0.0f, 1.0f ); // color values are clamped between 0 and 1
- mValue[bufferIndex].b = Clamp( b, 0.0f, 1.0f ); // color values are clamped between 0 and 1
- mValue[bufferIndex].a = Clamp( a, 0.0f, 1.0f ); // color values are clamped between 0 and 1
+ mValue[bufferIndex].r = Clamp(r, 0.0f, 1.0f); // color values are clamped between 0 and 1
+ mValue[bufferIndex].g = Clamp(g, 0.0f, 1.0f); // color values are clamped between 0 and 1
+ mValue[bufferIndex].b = Clamp(b, 0.0f, 1.0f); // color values are clamped between 0 and 1
+ mValue[bufferIndex].a = Clamp(a, 0.0f, 1.0f); // color values are clamped between 0 and 1
// The value has been inherited for the first time
- mInheritedFlag = true;
+ mInheritedFlag = true;
mReinheritedFlag = true;
}
/**
* @copydoc Dali::SceneGraph::PropertyInterface::Get()
*/
- Vector4& Get( BufferIndex bufferIndex )
+ Vector4& Get(BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::PropertyInterface::Get()
*/
- const Vector4& Get( BufferIndex bufferIndex ) const
+ const Vector4& Get(BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Vector4& operator[]( BufferIndex bufferIndex ) const
+ const Vector4& operator[](BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
private:
-
// Undefined
InheritedColor(const InheritedColor& property);
// Undefined
InheritedColor& operator=(const InheritedColor& rhs);
private:
-
DoubleBuffered<Vector4> mValue; ///< The double-buffered property value
- bool mInheritedFlag :1; ///< Flag whether the value has ever been inherited
- bool mReinheritedFlag :1; ///< Flag whether value was re-inherited in previous frame
+ bool mInheritedFlag : 1; ///< Flag whether the value has ever been inherited
+ bool mReinheritedFlag : 1; ///< Flag whether value was re-inherited in previous frame
};
/**
class InheritedQuaternion : public PropertyInputImpl
{
public:
-
/**
* Create an inherited property.
*/
InheritedQuaternion()
: mValue(),
- mInheritedFlag( false ),
- mReinheritedFlag( true )
+ mInheritedFlag(false),
+ mReinheritedFlag(true)
{
}
* Called once per Update (only) if the property did not need to be re-inherited.
* @param[in] updateBufferIndex The current update buffer index.
*/
- void CopyPrevious( BufferIndex updateBufferIndex )
+ void CopyPrevious(BufferIndex updateBufferIndex)
{
- if ( mReinheritedFlag )
+ if(mReinheritedFlag)
{
mValue[updateBufferIndex] = mValue[updateBufferIndex ? 0 : 1];
*/
virtual bool IsClean() const
{
- return ( false == mReinheritedFlag );
+ return (false == mReinheritedFlag);
}
/**
/**
* @copydoc Dali::PropertyInput::GetQuaternion()
*/
- const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const override
+ const Quaternion& GetQuaternion(BufferIndex bufferIndex) const override
{
- return mValue[ bufferIndex ];
+ return mValue[bufferIndex];
}
/**
* @copydoc Dali::PropertyInput::GetConstraintInputQuaternion()
*/
- const Quaternion& GetConstraintInputQuaternion( BufferIndex bufferIndex ) const override
+ const Quaternion& GetConstraintInputQuaternion(BufferIndex bufferIndex) const override
{
// For inherited properties, constraints work with the value from the previous frame.
// This is because constraints are applied to position etc, before world-position is calculated.
BufferIndex eventBufferIndex = bufferIndex ? 0u : 1u;
- return mValue[ eventBufferIndex ];
+ return mValue[eventBufferIndex];
}
/**
/**
* @copydoc Dali::SceneGraph::PropertyInterface::Get()
*/
- Quaternion& Get( BufferIndex bufferIndex )
+ Quaternion& Get(BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::PropertyInterface::Get()
*/
- const Quaternion& Get( BufferIndex bufferIndex ) const
+ const Quaternion& Get(BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Quaternion& operator[]( BufferIndex bufferIndex ) const
+ const Quaternion& operator[](BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
private:
-
// Undefined
InheritedQuaternion(const InheritedQuaternion& property);
InheritedQuaternion& operator=(const InheritedQuaternion& rhs);
private:
-
DoubleBuffered<Quaternion> mValue; ///< The double-buffered property value
- bool mInheritedFlag :1; ///< Flag whether the value has ever been inherited
- bool mReinheritedFlag :1; ///< Flag whether value was re-inherited in previous frame
+ bool mInheritedFlag : 1; ///< Flag whether the value has ever been inherited
+ bool mReinheritedFlag : 1; ///< Flag whether value was re-inherited in previous frame
};
/**
class InheritedMatrix : public PropertyInputImpl
{
public:
-
/**
* Create an inherited property.
*/
InheritedMatrix()
: mValue(),
- mInheritedFlag( false ),
- mReinheritedFlag( true )
+ mInheritedFlag(false),
+ mReinheritedFlag(true)
{
}
* Called once per Update (only) if the property did not need to be re-inherited.
* @param[in] updateBufferIndex The current update buffer index.
*/
- void CopyPrevious( BufferIndex updateBufferIndex )
+ void CopyPrevious(BufferIndex updateBufferIndex)
{
- if ( mReinheritedFlag )
+ if(mReinheritedFlag)
{
mValue[updateBufferIndex] = mValue[updateBufferIndex ? 0 : 1];
*/
virtual bool IsClean() const
{
- return ( false == mReinheritedFlag );
+ return (false == mReinheritedFlag);
}
/**
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetMatrix()
*/
- const Matrix& GetMatrix( BufferIndex bufferIndex ) const override
+ const Matrix& GetMatrix(BufferIndex bufferIndex) const override
{
- return mValue[ bufferIndex ];
+ return mValue[bufferIndex];
}
/**
* @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix()
*/
- const Matrix& GetConstraintInputMatrix( BufferIndex bufferIndex ) const override
+ const Matrix& GetConstraintInputMatrix(BufferIndex bufferIndex) const override
{
// For inherited properties, constraints work with the value from the previous frame.
// This is because constraints are applied to position etc, before world-position is calculated.
BufferIndex eventBufferIndex = bufferIndex ? 0u : 1u;
- return mValue[ eventBufferIndex ];
+ return mValue[eventBufferIndex];
}
/**
/**
* @copydoc Dali::SceneGraph::PropertyInterface::Get()
*/
- Matrix& Get( BufferIndex bufferIndex )
+ Matrix& Get(BufferIndex bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::PropertyInterface::Get()
*/
- const Matrix& Get( BufferIndex bufferIndex ) const
+ const Matrix& Get(BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Matrix& operator[]( BufferIndex bufferIndex ) const
+ const Matrix& operator[](BufferIndex bufferIndex) const
{
return mValue[bufferIndex];
}
- void SetDirty( BufferIndex bufferIndex )
+ void SetDirty(BufferIndex bufferIndex)
{
mReinheritedFlag = true;
}
private:
-
// Undefined
InheritedMatrix(const InheritedMatrix& property);
InheritedMatrix& operator=(const InheritedMatrix& rhs);
private:
-
DoubleBuffered<Matrix> mValue; ///< The double-buffered property value
- bool mInheritedFlag :1; ///< Flag whether the value has ever been inherited
- bool mReinheritedFlag :1; ///< Flag whether value was re-inherited in previous frame
-
+ bool mInheritedFlag : 1; ///< Flag whether the value has ever been inherited
+ bool mReinheritedFlag : 1; ///< Flag whether value was re-inherited in previous frame
};
} // namespace SceneGraph
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
PropertyBase::PropertyBase() = default;
#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_BASE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cstddef>
// INTERNAL INCLUDES
-#include <dali/public-api/object/property.h>
#include <dali/internal/common/type-abstraction.h>
#include <dali/internal/event/common/property-input-impl.h>
#include <dali/internal/update/common/scene-graph-buffers.h>
+#include <dali/public-api/object/property.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
/**
* Polymorphic base class for scene-graph properties, held by Nodes etc.
*/
class PropertyBase : public PropertyInputImpl
{
public:
-
/**
* Default constructor.
*/
virtual bool IsClean() const = 0;
private:
-
// Undefined
PropertyBase(const PropertyBase& property);
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
+#include <dali/internal/update/common/property-condition-functions.h>
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/math/vector3.h>
#include <dali/public-api/math/vector4.h>
#include <dali/public-api/object/property-input.h>
-#include <dali/internal/update/common/property-condition-functions.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
// LessThan ///////////////////////////////////////////////////////////////////
ConditionFunction LessThan::GetFunction(Property::Type valueType)
return function;
}
-bool LessThan::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool LessThan::EvalBoolean(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float arg0 = arg[0];
return (value.GetBoolean() < arg0);
}
-bool LessThan::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool LessThan::EvalInteger(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
- const int32_t arg0 = static_cast<int32_t>( arg[0] );
+ const int32_t arg0 = static_cast<int32_t>(arg[0]);
return (value.GetInteger() < arg0);
}
-bool LessThan::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool LessThan::EvalFloat(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float arg0 = arg[0];
return (value.GetFloat() < arg0);
}
-bool LessThan::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool LessThan::EvalVector2(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float arg0 = arg[0];
return (value.GetVector2().LengthSquared() < arg0 * arg0);
}
-bool LessThan::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool LessThan::EvalVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float arg0 = arg[0];
return (value.GetVector3().LengthSquared() < arg0 * arg0);
}
-bool LessThan::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool LessThan::EvalVector4(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float arg0 = arg[0];
return (value.GetVector4().LengthSquared() < arg0 * arg0);
}
-bool LessThan::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool LessThan::EvalDefault(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
return false;
}
return function;
}
-bool GreaterThan::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool GreaterThan::EvalBoolean(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float arg0 = arg[0];
return (value.GetBoolean() > arg0);
}
-bool GreaterThan::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool GreaterThan::EvalInteger(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
- const int32_t arg0 = static_cast<int32_t>( arg[0] );
+ const int32_t arg0 = static_cast<int32_t>(arg[0]);
return (value.GetInteger() > arg0);
}
-bool GreaterThan::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool GreaterThan::EvalFloat(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float arg0 = arg[0];
return (value.GetFloat() > arg0);
}
-bool GreaterThan::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool GreaterThan::EvalVector2(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float arg0 = arg[0];
return (value.GetVector2().LengthSquared() > arg0 * arg0);
}
-bool GreaterThan::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool GreaterThan::EvalVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float arg0 = arg[0];
return (value.GetVector3().LengthSquared() > arg0 * arg0);
}
-bool GreaterThan::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool GreaterThan::EvalVector4(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float arg0 = arg[0];
return (value.GetVector4().LengthSquared() > arg0 * arg0);
}
-bool GreaterThan::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool GreaterThan::EvalDefault(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
return false;
}
return function;
}
-bool Inside::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Inside::EvalBoolean(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const bool valueBoolean = value.GetBoolean();
- return ( (valueBoolean > arg[0]) && (valueBoolean < arg[1]) );
+ return ((valueBoolean > arg[0]) && (valueBoolean < arg[1]));
}
-bool Inside::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Inside::EvalInteger(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const int32_t valueInteger = value.GetInteger();
- return ( ( valueInteger > static_cast<int32_t>( arg[0] ) ) && ( valueInteger < static_cast<int32_t>( arg[1] ) ) );
+ return ((valueInteger > static_cast<int32_t>(arg[0])) && (valueInteger < static_cast<int32_t>(arg[1])));
}
-bool Inside::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Inside::EvalFloat(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float valueFloat = value.GetFloat();
- return ( (valueFloat > arg[0]) && (valueFloat < arg[1]) );
+ return ((valueFloat > arg[0]) && (valueFloat < arg[1]));
}
-bool Inside::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Inside::EvalVector2(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float length2 = value.GetVector2().LengthSquared();
- return ( (length2 > arg[0]*arg[0]) && (length2 < arg[1]*arg[1]) );
+ return ((length2 > arg[0] * arg[0]) && (length2 < arg[1] * arg[1]));
}
-bool Inside::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Inside::EvalVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float length2 = value.GetVector3().LengthSquared();
- return ( (length2 > arg[0]*arg[0]) && (length2 < arg[1]*arg[1]) );
+ return ((length2 > arg[0] * arg[0]) && (length2 < arg[1] * arg[1]));
}
-bool Inside::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Inside::EvalVector4(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float length2 = value.GetVector4().LengthSquared();
- return ( (length2 > arg[0]*arg[0]) && (length2 < arg[1]*arg[1]) );
+ return ((length2 > arg[0] * arg[0]) && (length2 < arg[1] * arg[1]));
}
-bool Inside::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Inside::EvalDefault(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
return false;
}
return function;
}
-bool Outside::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Outside::EvalBoolean(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const bool valueBoolean = value.GetBoolean();
- return ( (valueBoolean < arg[0]) || (valueBoolean > arg[1]) );
+ return ((valueBoolean < arg[0]) || (valueBoolean > arg[1]));
}
-bool Outside::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Outside::EvalInteger(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const int32_t valueInteger = value.GetInteger();
- return ( ( valueInteger < static_cast<int32_t>( arg[0] ) ) || ( valueInteger > static_cast<int32_t>( arg[0] ) ) );
+ return ((valueInteger < static_cast<int32_t>(arg[0])) || (valueInteger > static_cast<int32_t>(arg[0])));
}
-bool Outside::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Outside::EvalFloat(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float valueFloat = value.GetFloat();
- return ( (valueFloat < arg[0]) || (valueFloat > arg[1]) );
+ return ((valueFloat < arg[0]) || (valueFloat > arg[1]));
}
-bool Outside::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Outside::EvalVector2(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float length2 = value.GetVector2().LengthSquared();
- return ( (length2 < arg[0]*arg[0]) || (length2 > arg[1]*arg[1]) );
+ return ((length2 < arg[0] * arg[0]) || (length2 > arg[1] * arg[1]));
}
-bool Outside::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Outside::EvalVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float length2 = value.GetVector3().LengthSquared();
- return ( (length2 < arg[0]*arg[0]) || (length2 > arg[1]*arg[1]) );
+ return ((length2 < arg[0] * arg[0]) || (length2 > arg[1] * arg[1]));
}
-bool Outside::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Outside::EvalVector4(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float length2 = value.GetVector4().LengthSquared();
- return ( (length2 < arg[0]*arg[0]) || (length2 > arg[1]*arg[1]) );
+ return ((length2 < arg[0] * arg[0]) || (length2 > arg[1] * arg[1]));
}
-bool Outside::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Outside::EvalDefault(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
return false;
}
#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_CONDITION_FUNCTIONS_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/object/property-value.h>
#include <dali/internal/update/common/scene-graph-property-notification.h>
+#include <dali/public-api/object/property-value.h>
// OTHER CONDITITION INCLUDES
#include <dali/internal/update/common/property-condition-step-functions.h>
namespace Dali
{
-
namespace Internal
{
-
class Object;
class PropertyNotification;
namespace SceneGraph
{
-
// LessThan ///////////////////////////////////////////////////////////////////
/**
*/
class LessThan
{
-
public:
-
/**
* @return function pointer to the correct condition function, based on
* the type of value being examined.
static ConditionFunction GetFunction(Property::Type valueType);
private:
-
/**
* Checks if bool is LessThan
* @param[in] value The value being examined.
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalBoolean(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if integer is LessThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalInteger(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if float is LessThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalFloat(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector2.Length() is LessThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector2(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector3.Length() is LessThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector4.Length() is LessThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector4(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Default check for other types
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
-
+ static bool EvalDefault(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
};
// GreaterThan ////////////////////////////////////////////////////////////////
*/
class GreaterThan
{
-
public:
-
/**
* @returns function pointer to the correct condition function, based on
* the type of value being examined.
static ConditionFunction GetFunction(Property::Type valueType);
private:
-
/**
* Checks if bool is GreaterThan
* @param[in] value The value being examined.
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalBoolean(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if integer is GreaterThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalInteger(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if float is GreaterThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalFloat(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector2.Length() is GreaterThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector2(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector3.Length() is GreaterThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector4.Length() is GreaterThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector4(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Default check for other types.
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
-
+ static bool EvalDefault(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
};
// Inside /////////////////////////////////////////////////////////////////////
*/
class Inside
{
-
public:
-
/**
* @return function pointer to the correct condition function, based on
* the type of value being examined.
static ConditionFunction GetFunction(Property::Type valueType);
private:
-
/**
* Checks if bool is Inside
* @param[in] value The value being examined.
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalBoolean(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if integer is Inside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalInteger(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if float is Inside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalFloat(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector2.Length() is Inside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector2(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector3.Length() is Inside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector4.Length() is Inside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector4(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Default check for other types.
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
-
+ static bool EvalDefault(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
};
// Outside ////////////////////////////////////////////////////////////////////
*/
class Outside
{
-
public:
-
/**
* @return function pointer to the correct condition function, based on
* the type of value being examined.
static ConditionFunction GetFunction(Property::Type valueType);
private:
-
/**
* Checks if bool is Outside
* @param[in] value The value being examined.
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalBoolean(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if integer is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalInteger(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if float is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalFloat(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector2.Length() is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector2(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector3.Length() is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector4.Length() is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector4(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Default check for other types.
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
-
+ static bool EvalDefault(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
};
} // namespace SceneGraph
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
+#include <dali/internal/update/common/property-condition-step-functions.h>
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/math/vector3.h>
#include <dali/public-api/math/vector4.h>
#include <dali/public-api/object/property-input.h>
-#include <dali/internal/update/common/property-condition-step-functions.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
namespace
{
-
-const int32_t ARGINDEX_REF_VALUE = 0;
-const int32_t ARGINDEX_STEP_SIZE = 1;
+const int32_t ARGINDEX_REF_VALUE = 0;
+const int32_t ARGINDEX_STEP_SIZE = 1;
const int32_t ARGINDEX_CURRENT_STEP = 2;
-const int32_t ARGINDEX_FIRST_VALUE = 3;
+const int32_t ARGINDEX_FIRST_VALUE = 3;
const int32_t ARGINDEX_SECOND_VALUE = 4;
-const int32_t ARGINDEX_THIRD_VALUE = 5;
+const int32_t ARGINDEX_THIRD_VALUE = 5;
} // namespace
return function;
}
-ConditionFunction Step::GetCompareFunction( Property::Type valueType )
+ConditionFunction Step::GetCompareFunction(Property::Type valueType)
{
- ConditionFunction function = nullptr;
- if( valueType == Property::VECTOR3 )
- {
- function = EvalAndCompareVector3;
- }
- else
- {
- function = GetFunction( valueType );
- }
+ ConditionFunction function = nullptr;
+ if(valueType == Property::VECTOR3)
+ {
+ function = EvalAndCompareVector3;
+ }
+ else
+ {
+ function = GetFunction(valueType);
+ }
- return function;
+ return function;
}
-bool Step::Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg )
+bool Step::Evaluate(const float propertyValue, PropertyNotification::RawArgumentContainer& arg)
{
- const float refValue = arg[ARGINDEX_REF_VALUE];
- const float step = arg[ARGINDEX_STEP_SIZE];
+ const float refValue = arg[ARGINDEX_REF_VALUE];
+ const float step = arg[ARGINDEX_STEP_SIZE];
const int32_t currentStep = static_cast<int32_t>(arg[ARGINDEX_CURRENT_STEP]);
- const float distance = (propertyValue - refValue);
+ const float distance = (propertyValue - refValue);
// step is actual 1.0f / step so can multiply instead of dividing
const int32_t newStep = static_cast<int32_t>(floorf(distance * step));
- if( newStep != currentStep )
+ if(newStep != currentStep)
{
// in new section
arg[ARGINDEX_CURRENT_STEP] = static_cast<float>(newStep);
return false;
}
-
-bool Step::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Step::EvalInteger(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
- const float propertyValue = static_cast<float>( value.GetInteger() );
- return Evaluate( propertyValue, arg );
+ const float propertyValue = static_cast<float>(value.GetInteger());
+ return Evaluate(propertyValue, arg);
}
-bool Step::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Step::EvalFloat(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float propertyValue = value.GetFloat();
- return Evaluate( propertyValue, arg );
+ return Evaluate(propertyValue, arg);
}
-bool Step::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Step::EvalVector2(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float propertyValue = value.GetVector2().Length();
- return Evaluate( propertyValue, arg );
+ return Evaluate(propertyValue, arg);
}
-bool Step::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Step::EvalVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
float propertyValue = value.GetVector3().Length();
- return Evaluate( propertyValue, arg );
+ return Evaluate(propertyValue, arg);
}
-bool Step::EvalAndCompareVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Step::EvalAndCompareVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
float propertyValue = value.GetVector3().Length();
- bool result = Evaluate( propertyValue, arg );
- if( result == false )
+ bool result = Evaluate(propertyValue, arg);
+ if(result == false)
{
const float step = 1.0f / arg[ARGINDEX_STEP_SIZE];
- if( ( fabsf( arg[ARGINDEX_FIRST_VALUE] - value.GetVector3().x ) > step )
- || ( fabsf( arg[ARGINDEX_SECOND_VALUE] - value.GetVector3().y ) > step )
- || ( fabsf( arg[ARGINDEX_THIRD_VALUE] - value.GetVector3().z ) > step ) )
+ if((fabsf(arg[ARGINDEX_FIRST_VALUE] - value.GetVector3().x) > step) || (fabsf(arg[ARGINDEX_SECOND_VALUE] - value.GetVector3().y) > step) || (fabsf(arg[ARGINDEX_THIRD_VALUE] - value.GetVector3().z) > step))
{
result = true;
}
}
- arg[ARGINDEX_FIRST_VALUE] = value.GetVector3().x;
+ arg[ARGINDEX_FIRST_VALUE] = value.GetVector3().x;
arg[ARGINDEX_SECOND_VALUE] = value.GetVector3().y;
- arg[ARGINDEX_THIRD_VALUE] = value.GetVector3().z;
+ arg[ARGINDEX_THIRD_VALUE] = value.GetVector3().z;
return result;
}
-bool Step::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Step::EvalVector4(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float propertyValue = value.GetVector4().Length();
- return Evaluate( propertyValue, arg );
+ return Evaluate(propertyValue, arg);
}
-bool Step::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Step::EvalDefault(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
return false;
}
#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_CONDITION_STEP_FUNCTIONS_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/object/property-value.h>
#include <dali/internal/update/common/scene-graph-property-notification.h>
+#include <dali/public-api/object/property-value.h>
namespace Dali
{
-
namespace Internal
{
-
class Object;
class PropertyNotification;
namespace SceneGraph
{
-
/**
* Step condition class,
* Checks if a Property has stepped a certain amount from the reference point
*/
class Step
{
-
public:
-
/**
* @return function pointer to the correct condition function, based on
* the type of value being examined.
*/
- static ConditionFunction GetFunction( Property::Type valueType );
+ static ConditionFunction GetFunction(Property::Type valueType);
/**
* @return function pointer to the correct condition function, based on
*
* This function pointer is to compare previous and current components for the swapping case.
*/
- static ConditionFunction GetCompareFunction( Property::Type valueType );
+ static ConditionFunction GetCompareFunction(Property::Type valueType);
private:
-
- static bool Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg );
+ static bool Evaluate(const float propertyValue, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if integer is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalInteger(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if float is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalFloat(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector2.Length() is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector2(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector3.Length() is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector3.Length() is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalAndCompareVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalAndCompareVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector4.Length() is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector4(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Default check for other types.
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalDefault(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
};
} // namespace SceneGraph
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
+#include <dali/internal/update/common/property-condition-variable-step-functions.h>
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/math/vector3.h>
#include <dali/public-api/math/vector4.h>
#include <dali/public-api/object/property-input.h>
-#include <dali/internal/update/common/property-condition-variable-step-functions.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
namespace
{
-
const int32_t ARGINDEX_STEP_INDEX = 0;
-const int32_t ARGINDEX_LIST_SIZE = 1;
+const int32_t ARGINDEX_LIST_SIZE = 1;
const int32_t ARGINDEX_LIST_START = 2;
-}
+} // namespace
-ConditionFunction VariableStep::GetFunction( Property::Type valueType )
+ConditionFunction VariableStep::GetFunction(Property::Type valueType)
{
ConditionFunction function = nullptr;
- switch( valueType )
+ switch(valueType)
{
case Property::INTEGER:
{
return function;
}
-bool VariableStep::Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg )
+bool VariableStep::Evaluate(const float propertyValue, PropertyNotification::RawArgumentContainer& arg)
{
- const int32_t currentIndex = static_cast<int32_t>( arg[ARGINDEX_STEP_INDEX] ); // truncated
- const int32_t numSteps = static_cast<int32_t>( arg[ARGINDEX_LIST_SIZE] ); // truncated
- const float first = arg[ARGINDEX_LIST_START];
- const float last = arg[ARGINDEX_LIST_START + (numSteps - 1)];
- const bool ascending = (last > first) ? true : false;
- int32_t newIndex = currentIndex;
+ const int32_t currentIndex = static_cast<int32_t>(arg[ARGINDEX_STEP_INDEX]); // truncated
+ const int32_t numSteps = static_cast<int32_t>(arg[ARGINDEX_LIST_SIZE]); // truncated
+ const float first = arg[ARGINDEX_LIST_START];
+ const float last = arg[ARGINDEX_LIST_START + (numSteps - 1)];
+ const bool ascending = (last > first) ? true : false;
+ int32_t newIndex = currentIndex;
// avoid loop if property currently not within any of the range values
- if( ascending )
+ if(ascending)
{
- if( propertyValue < first )
+ if(propertyValue < first)
{
newIndex = -1;
}
- else if( propertyValue >= last )
+ else if(propertyValue >= last)
{
newIndex = numSteps - 1;
}
else
{
// increments are in negative direction
- if( propertyValue > first )
+ if(propertyValue > first)
{
newIndex = -1;
}
- else if( propertyValue <= last )
+ else if(propertyValue <= last)
{
newIndex = numSteps - 1;
}
}
int32_t i = 0;
- for( i = 0 ; i < numSteps - 1 ; ++i )
+ for(i = 0; i < numSteps - 1; ++i)
{
const float arg1 = arg[ARGINDEX_LIST_START + i];
const float arg2 = arg[ARGINDEX_LIST_START + (i + 1)];
- if( ascending )
+ if(ascending)
{
- if( ( propertyValue >= arg1 )
- && ( propertyValue < arg2 ) )
+ if((propertyValue >= arg1) && (propertyValue < arg2))
{
newIndex = i;
break;
else
{
// increments are in negative direction
- if( ( propertyValue > arg2 )
- && ( propertyValue <= arg1 ) )
+ if((propertyValue > arg2) && (propertyValue <= arg1))
{
newIndex = i;
break;
}
}
}
- if( newIndex != currentIndex )
+ if(newIndex != currentIndex)
{
// have changed to new step
arg[ARGINDEX_STEP_INDEX] = static_cast<float>(newIndex);
return false;
}
-bool VariableStep::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool VariableStep::EvalInteger(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
- const float propertyValue = static_cast<float>( value.GetInteger() );
- return Evaluate( propertyValue, arg );
+ const float propertyValue = static_cast<float>(value.GetInteger());
+ return Evaluate(propertyValue, arg);
}
-bool VariableStep::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool VariableStep::EvalFloat(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float propertyValue = value.GetFloat();
- return Evaluate( propertyValue, arg );
+ return Evaluate(propertyValue, arg);
}
-bool VariableStep::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool VariableStep::EvalVector2(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float propertyValue = value.GetVector2().LengthSquared();
- return Evaluate( propertyValue, arg );
+ return Evaluate(propertyValue, arg);
}
-bool VariableStep::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool VariableStep::EvalVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
float propertyValue = value.GetVector3().LengthSquared();
- return Evaluate( propertyValue, arg );
+ return Evaluate(propertyValue, arg);
}
-bool VariableStep::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool VariableStep::EvalVector4(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
const float propertyValue = value.GetVector4().LengthSquared();
- return Evaluate( propertyValue, arg );
+ return Evaluate(propertyValue, arg);
}
-bool VariableStep::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool VariableStep::EvalDefault(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg)
{
return false;
}
#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_CONDITION_VARIABLE_STEP_FUNCTIONS_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/object/property-value.h>
#include <dali/internal/update/common/scene-graph-property-notification.h>
+#include <dali/public-api/object/property-value.h>
namespace Dali
{
-
namespace Internal
{
-
class Object;
class PropertyNotification;
namespace SceneGraph
{
-
/**
* VariableStep condition class,
* Uses a list of values, this condition notifies when the Property crosses between different values
*/
class VariableStep
{
-
public:
-
/**
* @return function pointer to the correct condition function, based on
* the type of value being examined.
*/
- static ConditionFunction GetFunction( Property::Type valueType );
+ static ConditionFunction GetFunction(Property::Type valueType);
private:
-
/**
* Helper function used to evaluate our property
*
*
*/
- static bool Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg );
+ static bool Evaluate(const float propertyValue, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if integer is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalInteger(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if float is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalFloat(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector2.Length() is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector2(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector3.Length() is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Checks if Vector4.Length() is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector4(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
/**
* Default check for other types.
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
-
+ static bool EvalDefault(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg);
};
} // namespace SceneGraph
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
// Messages for a property owner
PropertyOwnerMessageBase::PropertyOwnerMessageBase() = default;
#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <string>
// INTERNAL INCLUDES
+#include <dali/internal/common/const-string.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/event/common/property-input-impl.h>
-#include <dali/internal/update/common/property-owner.h>
#include <dali/internal/update/animation/scene-graph-constraint-base.h>
-#include <dali/internal/common/const-string.h>
+#include <dali/internal/update/common/property-owner.h>
namespace Dali
{
class PropertyOwnerMessageBase : public MessageBase
{
public:
-
/**
* Create a message.
*/
~PropertyOwnerMessageBase() override;
private:
-
// Undefined
PropertyOwnerMessageBase(const PropertyOwnerMessageBase&);
PropertyOwnerMessageBase& operator=(const PropertyOwnerMessageBase& rhs);
/**
* Templated message which bakes a property.
*/
-template< typename P >
+template<typename P>
class AnimatablePropertyMessage : public PropertyOwnerMessageBase
{
public:
- using MemberFunction = void ( AnimatableProperty<P>::* )( BufferIndex, typename ParameterType<P>::PassingType );
+ using MemberFunction = void (AnimatableProperty<P>::*)(BufferIndex, typename ParameterType<P>::PassingType);
/**
* Create a message.
* @param[in] member The member function of the object.
* @param[in] value The new value of the property.
*/
- static void Send( EventThreadServices& eventThreadServices,
- const PropertyOwner* sceneObject,
- const AnimatableProperty<P>* property,
- MemberFunction member,
- typename ParameterType< P >::PassingType value )
+ static void Send(EventThreadServices& eventThreadServices,
+ const PropertyOwner* sceneObject,
+ const AnimatableProperty<P>* property,
+ MemberFunction member,
+ typename ParameterType<P>::PassingType value)
{
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( AnimatablePropertyMessage ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(AnimatablePropertyMessage));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) AnimatablePropertyMessage( sceneObject, property, member, value );
+ new(slot) AnimatablePropertyMessage(sceneObject, property, member, value);
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex updateBufferIndex ) override
+ void Process(BufferIndex updateBufferIndex) override
{
- (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
+ (mProperty->*mMemberFunction)(updateBufferIndex, mParam);
}
private:
-
/**
* Create a message.
* @note The property owner is expected to be const in the thread which sends this message.
* @param[in] member The member function of the object.
* @param[in] value The new value of the property.
*/
- AnimatablePropertyMessage( const PropertyOwner* sceneObject,
- const AnimatableProperty<P>* property,
- MemberFunction member,
- typename ParameterType< P >::PassingType value )
+ AnimatablePropertyMessage(const PropertyOwner* sceneObject,
+ const AnimatableProperty<P>* property,
+ MemberFunction member,
+ typename ParameterType<P>::PassingType value)
: PropertyOwnerMessageBase(),
- mSceneObject( const_cast< PropertyOwner* >( sceneObject ) ),
- mProperty( const_cast< AnimatableProperty<P>* >( property ) ),
- mMemberFunction( member ),
- mParam( value )
+ mSceneObject(const_cast<PropertyOwner*>(sceneObject)),
+ mProperty(const_cast<AnimatableProperty<P>*>(property)),
+ mMemberFunction(member),
+ mParam(value)
{
}
private:
-
- PropertyOwner* mSceneObject;
- AnimatableProperty<P>* mProperty;
- MemberFunction mMemberFunction;
- typename ParameterType< P >::HolderType mParam;
+ PropertyOwner* mSceneObject;
+ AnimatableProperty<P>* mProperty;
+ MemberFunction mMemberFunction;
+ typename ParameterType<P>::HolderType mParam;
};
/**
* Templated message which bakes a property.
*/
-template< typename P >
+template<typename P>
class AnimatablePropertyComponentMessage : public PropertyOwnerMessageBase
{
public:
- using MemberFunction = void ( AnimatableProperty<P>::* )( BufferIndex, float );
+ using MemberFunction = void (AnimatableProperty<P>::*)(BufferIndex, float);
/**
* Send a message.
* @param[in] member The member function of the object.
* @param[in] value The new value of the X,Y,Z or W component.
*/
- static void Send( EventThreadServices& eventThreadServices,
- const PropertyOwner* sceneObject,
- const AnimatableProperty<P>* property,
- MemberFunction member,
- float value )
+ static void Send(EventThreadServices& eventThreadServices,
+ const PropertyOwner* sceneObject,
+ const AnimatableProperty<P>* property,
+ MemberFunction member,
+ float value)
{
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( AnimatablePropertyComponentMessage ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(AnimatablePropertyComponentMessage));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) AnimatablePropertyComponentMessage( sceneObject, property, member, value );
+ new(slot) AnimatablePropertyComponentMessage(sceneObject, property, member, value);
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex updateBufferIndex ) override
+ void Process(BufferIndex updateBufferIndex) override
{
- (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
+ (mProperty->*mMemberFunction)(updateBufferIndex, mParam);
}
private:
-
/**
* Create a message.
* @note The scene object is expected to be const in the thread which sends this message.
* @param[in] member The member function of the object.
* @param[in] value The new value of the X,Y,Z or W component.
*/
- AnimatablePropertyComponentMessage( const PropertyOwner* sceneObject,
- const AnimatableProperty<P>* property,
- MemberFunction member,
- float value )
+ AnimatablePropertyComponentMessage(const PropertyOwner* sceneObject,
+ const AnimatableProperty<P>* property,
+ MemberFunction member,
+ float value)
: PropertyOwnerMessageBase(),
- mSceneObject( const_cast< PropertyOwner* >( sceneObject ) ),
- mProperty( const_cast< AnimatableProperty<P>* >( property ) ),
- mMemberFunction( member ),
- mParam( value )
+ mSceneObject(const_cast<PropertyOwner*>(sceneObject)),
+ mProperty(const_cast<AnimatableProperty<P>*>(property)),
+ mMemberFunction(member),
+ mParam(value)
{
}
private:
- PropertyOwner* mSceneObject;
+ PropertyOwner* mSceneObject;
AnimatableProperty<P>* mProperty;
- MemberFunction mMemberFunction;
- float mParam;
+ MemberFunction mMemberFunction;
+ float mParam;
};
-
// Messages for PropertyOwner
-inline void InstallCustomPropertyMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, OwnerPointer<PropertyBase>& property )
+inline void InstallCustomPropertyMessage(EventThreadServices& eventThreadServices, const PropertyOwner& owner, OwnerPointer<PropertyBase>& property)
{
using LocalType = MessageValue1<PropertyOwner, OwnerPointer<PropertyBase> >;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &owner, &PropertyOwner::InstallCustomProperty, property );
+ new(slot) LocalType(&owner, &PropertyOwner::InstallCustomProperty, property);
}
-inline void ApplyConstraintMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, OwnerPointer<ConstraintBase>& constraint )
+inline void ApplyConstraintMessage(EventThreadServices& eventThreadServices, const PropertyOwner& owner, OwnerPointer<ConstraintBase>& constraint)
{
using LocalType = MessageValue1<PropertyOwner, OwnerPointer<ConstraintBase> >;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &owner, &PropertyOwner::ApplyConstraint, constraint );
+ new(slot) LocalType(&owner, &PropertyOwner::ApplyConstraint, constraint);
}
-inline void RemoveConstraintMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, const ConstraintBase& constConstraint )
+inline void RemoveConstraintMessage(EventThreadServices& eventThreadServices, const PropertyOwner& owner, const ConstraintBase& constConstraint)
{
// The update-thread can modify this object.
- ConstraintBase& constraint = const_cast< ConstraintBase& >( constConstraint );
+ ConstraintBase& constraint = const_cast<ConstraintBase&>(constConstraint);
using LocalType = MessageValue1<PropertyOwner, ConstraintBase*>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &owner, &PropertyOwner::RemoveConstraint, &constraint );
+ new(slot) LocalType(&owner, &PropertyOwner::RemoveConstraint, &constraint);
}
inline void AddUniformMapMessage(EventThreadServices& eventThreadServices, const PropertyOwner& owner, UniformPropertyMapping map)
using LocalType = MessageValue1<PropertyOwner, UniformPropertyMapping>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &owner, &PropertyOwner::AddUniformMapping, map );
+ new(slot) LocalType(&owner, &PropertyOwner::AddUniformMapping, map);
}
-inline void RemoveUniformMapMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, ConstString uniformName )
+inline void RemoveUniformMapMessage(EventThreadServices& eventThreadServices, const PropertyOwner& owner, ConstString uniformName)
{
using LocalType = MessageValue1<PropertyOwner, ConstString>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &owner, &PropertyOwner::RemoveUniformMapping, uniformName );
+ new(slot) LocalType(&owner, &PropertyOwner::RemoveUniformMapping, uniformName);
}
-
} // namespace SceneGraph
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <algorithm>
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/internal/update/animation/scene-graph-constraint-base.h>
#include <dali/internal/common/const-string.h>
+#include <dali/internal/update/animation/scene-graph-constraint-base.h>
+#include <dali/public-api/common/dali-common.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
PropertyOwner* PropertyOwner::New()
{
return new PropertyOwner();
void PropertyOwner::AddObserver(Observer& observer)
{
//Check for duplicates in debug builds
- DALI_ASSERT_DEBUG( mObservers.End() == std::find( mObservers.Begin(), mObservers.End(), &observer ) );
+ DALI_ASSERT_DEBUG(mObservers.End() == std::find(mObservers.Begin(), mObservers.End(), &observer));
- mObservers.PushBack( &observer );
+ mObservers.PushBack(&observer);
}
void PropertyOwner::RemoveObserver(Observer& observer)
{
// Find the observer...
- const ConstObserverIter endIter = mObservers.End();
- for( ObserverIter iter = mObservers.Begin(); iter != endIter; ++iter)
+ const ConstObserverIter endIter = mObservers.End();
+ for(ObserverIter iter = mObservers.Begin(); iter != endIter; ++iter)
{
- if( (*iter) == &observer)
+ if((*iter) == &observer)
{
// erase it
mObservers.Erase(iter);
{
// Notification for observers
const ConstObserverIter endIter = mObservers.End();
- for( ConstObserverIter iter = mObservers.Begin(); iter != endIter; ++iter)
+ for(ConstObserverIter iter = mObservers.Begin(); iter != endIter; ++iter)
{
(*iter)->PropertyOwnerDestroyed(*this);
}
// Notification for observers
const ConstObserverIter endIter = mObservers.End();
- for( ConstObserverIter iter = mObservers.Begin(); iter != endIter; ++iter)
+ for(ConstObserverIter iter = mObservers.Begin(); iter != endIter; ++iter)
{
- (*iter)->PropertyOwnerConnected( *this );
+ (*iter)->PropertyOwnerConnected(*this);
}
}
-void PropertyOwner::DisconnectFromSceneGraph( BufferIndex updateBufferIndex )
+void PropertyOwner::DisconnectFromSceneGraph(BufferIndex updateBufferIndex)
{
mIsConnectedToSceneGraph = false;
// Notification for observers
const ConstObserverIter endIter = mObservers.End();
- for( ConstObserverIter iter = mObservers.Begin(); iter != endIter; ++iter)
+ for(ConstObserverIter iter = mObservers.Begin(); iter != endIter; ++iter)
{
- (*iter)->PropertyOwnerDisconnected( updateBufferIndex, *this );
+ (*iter)->PropertyOwnerDisconnected(updateBufferIndex, *this);
}
// Remove all constraints when disconnected from scene-graph
mConstraints.Clear();
}
-void PropertyOwner::InstallCustomProperty( OwnerPointer<PropertyBase>& property )
+void PropertyOwner::InstallCustomProperty(OwnerPointer<PropertyBase>& property)
{
- mCustomProperties.PushBack( property.Release() );
+ mCustomProperties.PushBack(property.Release());
}
-
ConstraintOwnerContainer& PropertyOwner::GetConstraints()
{
return mConstraints;
}
-void PropertyOwner::ApplyConstraint( OwnerPointer<ConstraintBase>& constraint )
+void PropertyOwner::ApplyConstraint(OwnerPointer<ConstraintBase>& constraint)
{
constraint->OnConnect();
- mConstraints.PushBack( constraint.Release() );
+ mConstraints.PushBack(constraint.Release());
}
-void PropertyOwner::RemoveConstraint( ConstraintBase* constraint )
+void PropertyOwner::RemoveConstraint(ConstraintBase* constraint)
{
const ConstraintIter constraintEndIter = mConstraints.End();
- for( ConstraintIter iter = mConstraints.Begin(); constraintEndIter != iter; ++iter )
+ for(ConstraintIter iter = mConstraints.Begin(); constraintEndIter != iter; ++iter)
{
- if ( *iter == constraint )
+ if(*iter == constraint)
{
- mConstraints.Erase( iter );
+ mConstraints.Erase(iter);
return; // We're finished
}
}
mUniformMaps.Add(map);
}
-void PropertyOwner::RemoveUniformMapping( const ConstString& uniformName )
+void PropertyOwner::RemoveUniformMapping(const ConstString& uniformName)
{
- mUniformMaps.Remove( uniformName );
+ mUniformMaps.Remove(uniformName);
}
const UniformMap& PropertyOwner::GetUniformMap() const
return mUniformMaps;
}
-void PropertyOwner::AddUniformMapObserver( UniformMap::Observer& observer )
+void PropertyOwner::AddUniformMapObserver(UniformMap::Observer& observer)
{
- mUniformMaps.AddObserver( observer );
+ mUniformMaps.AddObserver(observer);
}
-void PropertyOwner::RemoveUniformMapObserver( UniformMap::Observer& observer )
+void PropertyOwner::RemoveUniformMapObserver(UniformMap::Observer& observer)
{
- mUniformMaps.RemoveObserver( observer );
+ mUniformMaps.RemoveObserver(observer);
}
-
-
} // namespace SceneGraph
} // namespace Internal
#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-vector.h>
#include <dali/devel-api/common/owner-container.h>
+#include <dali/internal/common/const-string.h>
#include <dali/internal/common/message.h>
+#include <dali/internal/update/animation/scene-graph-constraint-declarations.h>
#include <dali/internal/update/common/property-base.h>
#include <dali/internal/update/common/scene-graph-buffers.h>
#include <dali/internal/update/common/uniform-map.h>
-#include <dali/internal/update/animation/scene-graph-constraint-declarations.h>
-#include <dali/internal/common/const-string.h>
-
+#include <dali/public-api/common/dali-vector.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
class PropertyOwner;
using OwnedPropertyContainer = OwnerContainer<PropertyBase*>;
class PropertyOwner
{
public:
-
class Observer
{
public:
-
/**
* Called when the observable object is connected to the scene graph.
* @param[in] owner A reference to the connected PropertyOwner
*/
- virtual void PropertyOwnerConnected( PropertyOwner& owner ) = 0;
+ virtual void PropertyOwnerConnected(PropertyOwner& owner) = 0;
/**
* Called when the observable object is disconnected from the scene graph.
* @param[in] currentBufferIndex The buffer to reset.
* @param[in] owner A reference to the disconnected PropertyOwner
*/
- virtual void PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner ) = 0;
+ virtual void PropertyOwnerDisconnected(BufferIndex updateBufferIndex, PropertyOwner& owner) = 0;
/**
* Called shortly before the observable object is destroyed.
* @note Cleanup should be done in both this and PropertyOwnerDisconnected as PropertyOwnerDisconnected
* may not be called (i.e. when shutting down).
*/
- virtual void PropertyOwnerDestroyed( PropertyOwner& owner ) = 0;
+ virtual void PropertyOwnerDestroyed(PropertyOwner& owner) = 0;
protected:
-
/**
* Virtual destructor, no deletion through this interface
*/
* This occurs when the object is disconnected from the scene-graph during UpdateManager::Update().
* @param[in] currentBufferIndex The current update buffer.
*/
- void DisconnectFromSceneGraph( BufferIndex updateBufferIndex );
+ void DisconnectFromSceneGraph(BufferIndex updateBufferIndex);
/**
* Install a custom property.
* @post The PropertyOwner takes ownership of the property.
* @param[in] property A pointer to a newly allocated property.
*/
- void InstallCustomProperty( OwnerPointer<PropertyBase>& property );
+ void InstallCustomProperty(OwnerPointer<PropertyBase>& property);
/**
* Retrieve the custom properties owned by the object.
* Apply a constraint.
* @param[in] constraint The constraint to apply.
*/
- void ApplyConstraint( OwnerPointer<ConstraintBase>& constraint );
+ void ApplyConstraint(OwnerPointer<ConstraintBase>& constraint);
/**
* Begin removal of constraints.
* @param[in] constraint The constraint to remove.
*/
- void RemoveConstraint( ConstraintBase* constraint );
+ void RemoveConstraint(ConstraintBase* constraint);
/**
* Retrieve the constraints that are currently applied.
/**
* @copydoc UniformMap::Remove
*/
- virtual void RemoveUniformMapping( const ConstString& uniformName );
+ virtual void RemoveUniformMapping(const ConstString& uniformName);
/**
* Get the mappings table
/**
* @copydoc UniformMap::AddUniformMapObserver
*/
- void AddUniformMapObserver( UniformMap::Observer& observer );
+ void AddUniformMapObserver(UniformMap::Observer& observer);
/**
* @copydoc UniformMap::RemoveUniformMapObserver
*/
- void RemoveUniformMapObserver( UniformMap::Observer& observer );
+ void RemoveUniformMapObserver(UniformMap::Observer& observer);
/**
* Query whether playing an animation is possible or not.
}
protected:
-
/**
* Protected constructor.
*/
PropertyOwner();
private:
-
// Undefined
PropertyOwner(const PropertyOwner&);
PropertyOwner& operator=(const PropertyOwner& rhs);
protected:
-
OwnedPropertyContainer mCustomProperties; ///< Properties provided with InstallCustomProperty()
- UniformMap mUniformMaps; ///< Container of owned uniform maps
- bool mUpdated;
+ UniformMap mUniformMaps; ///< Container of owned uniform maps
+ bool mUpdated;
bool mIsConnectedToSceneGraph;
private:
#define DALI_INTERNAL_SCENEGRAPH_PROPERTY_RESETTER_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
// EXTERNAL INCLDUES
#include <cstdint> // int8_t
-#include <dali/internal/update/animation/scene-graph-animator.h>
-#include <dali/internal/update/animation/scene-graph-constraint-base.h>
#include <dali/internal/update/animation/property-accessor.h>
#include <dali/internal/update/animation/property-component-accessor.h>
+#include <dali/internal/update/animation/scene-graph-animator.h>
+#include <dali/internal/update/animation/scene-graph-constraint-base.h>
#include <dali/internal/update/common/property-owner.h>
namespace Dali
{
namespace SceneGraph
{
-
/**
* Class to reset the watched property to it's base value. Used by UpdateManager to
* reset animating and constrained properties. The derived classes AnimatorResetter and
*/
~PropertyResetterBase() override
{
- if( mPropertyOwner != nullptr )
+ if(mPropertyOwner != nullptr)
{
mPropertyOwner->RemoveObserver(*this);
}
* Reset the property to it's base value if the property owner is still alive and on stage
* @param[in] updateBufferIndex the current buffer index
*/
- void ResetToBaseValue( BufferIndex updateBufferIndex )
+ void ResetToBaseValue(BufferIndex updateBufferIndex)
{
- if( mPropertyOwner != nullptr && mActive )
+ if(mPropertyOwner != nullptr && mActive)
{
// If property-owner has disconnected, start aging.
// We need to reset the property for two frames after disconnection to ensure both
// property values are set appropriately.
- if( mDisconnected )
+ if(mDisconnected)
{
--mActive;
}
- mBaseProperty->ResetToBaseValue( updateBufferIndex );
+ mBaseProperty->ResetToBaseValue(updateBufferIndex);
}
};
*
* @param[in] owner The property owner
*/
- void PropertyOwnerConnected( PropertyOwner& owner ) override
+ void PropertyOwnerConnected(PropertyOwner& owner) override
{
mDisconnected = false;
- mActive = ACTIVE;
+ mActive = ACTIVE;
}
/**
* @param[in] bufferIndex the current buffer index
* @param[in] owner The property owner
*/
- void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner ) override
+ void PropertyOwnerDisconnected(BufferIndex bufferIndex, PropertyOwner& owner) override
{
mDisconnected = true;
}
* Called shortly before the propertyOwner is destroyed
* @param[in] owner The property owner
*/
- void PropertyOwnerDestroyed( PropertyOwner& owner ) override
+ void PropertyOwnerDestroyed(PropertyOwner& owner) override
{
- mDisconnected = true;
+ mDisconnected = true;
mPropertyOwner = nullptr;
// Don't need to wait another frame as the property is being destroyed
- mActive = STOPPED;
+ mActive = STOPPED;
mRunning = STOPPED;
}
virtual bool IsFinished()
{
bool finished = mRunning <= STOPPED;
- if( mRunning == AGING )
+ if(mRunning == AGING)
{
mRunning = STOPPED;
}
}
protected:
-
enum
{
STOPPED = 0,
* @param[in] propertyOwner The property owner storing the base property
* @param[in] baseProperty The base property
*/
- PropertyResetterBase( PropertyOwner* propertyOwner,
- PropertyBase* baseProperty )
- : mPropertyOwner( propertyOwner ),
- mBaseProperty( baseProperty ),
- mRunning( ACTIVE ),
- mActive( ACTIVE ),
- mDisconnected( false )
+ PropertyResetterBase(PropertyOwner* propertyOwner,
+ PropertyBase* baseProperty)
+ : mPropertyOwner(propertyOwner),
+ mBaseProperty(baseProperty),
+ mRunning(ACTIVE),
+ mActive(ACTIVE),
+ mDisconnected(false)
{
}
PropertyOwner* mPropertyOwner; ///< The property owner
- PropertyBase* mBaseProperty; ///< The base property being animated or constrained
- int8_t mRunning; ///< Used to determine if we should finish or not, 2 if running, 1 if aging, 0 if stopped
- int8_t mActive; ///< 2 if active, 1 if aging, 0 if stopped
- bool mDisconnected; ///< True if the property owner has been disconnected
+ PropertyBase* mBaseProperty; ///< The base property being animated or constrained
+ int8_t mRunning; ///< Used to determine if we should finish or not, 2 if running, 1 if aging, 0 if stopped
+ int8_t mActive; ///< 2 if active, 1 if aging, 0 if stopped
+ bool mDisconnected; ///< True if the property owner has been disconnected
};
-
/**
* Specialization of Resetter based on templated modifier type (either Constraint or Animator)
*/
-template< typename ModifierType>
+template<typename ModifierType>
class Resetter : public PropertyResetterBase, public ModifierType::LifecycleObserver
{
public:
-
/**
* New method.
* @param[in] propertyOwner The owner of the property
* @param[in] modifier The scene-graph animator/constraint of the property
* @return the new property resetter
*/
- static PropertyResetterBase* New( const PropertyOwner& propertyOwner,
- const PropertyBase& baseProperty,
- const ModifierType& modifier )
+ static PropertyResetterBase* New(const PropertyOwner& propertyOwner,
+ const PropertyBase& baseProperty,
+ const ModifierType& modifier)
{
- return new Resetter<ModifierType>( const_cast<PropertyOwner*>( &propertyOwner ),
- const_cast<PropertyBase*>( &baseProperty ),
- const_cast<ModifierType*>( &modifier ) );
+ return new Resetter<ModifierType>(const_cast<PropertyOwner*>(&propertyOwner),
+ const_cast<PropertyBase*>(&baseProperty),
+ const_cast<ModifierType*>(&modifier));
}
/**
{
// Disconnect from modifier object. Although this resetter should match the lifecycle of the modifier object,
// there are situations where it is deleted first (e.g. if the property owner is destroyed)
- if( mModifier )
+ if(mModifier)
{
mModifier->RemoveLifecycleObserver(*this);
}
* @param[in] baseProperty The property being animated
* @param[in] modifier The scene-graph animator/constraint of the property
*/
- Resetter( PropertyOwner* propertyOwner,
- PropertyBase* baseProperty,
- ModifierType* modifier )
- : PropertyResetterBase( propertyOwner, baseProperty ),
- mModifier( modifier )
+ Resetter(PropertyOwner* propertyOwner,
+ PropertyBase* baseProperty,
+ ModifierType* modifier)
+ : PropertyResetterBase(propertyOwner, baseProperty),
+ mModifier(modifier)
{
// Track the lifecycle of the modifying object
mModifier->AddLifecycleObserver(*this);
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
BufferIndex SceneGraphBuffers::INITIAL_EVENT_BUFFER_INDEX = 0u;
BufferIndex SceneGraphBuffers::INITIAL_UPDATE_BUFFER_INDEX = 1u;
void SceneGraphBuffers::Swap()
{
- mUpdateBufferIndex = __sync_fetch_and_xor( &mEventBufferIndex, 1 );
+ mUpdateBufferIndex = __sync_fetch_and_xor(&mEventBufferIndex, 1);
}
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_BUFFERS_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
/**
* Node values (position etc.) are double-buffered. A SceneGraphBuffers object
* can be used to keep track of which buffers are being written or read.
class SceneGraphBuffers
{
public:
-
static BufferIndex INITIAL_EVENT_BUFFER_INDEX; // 0
static BufferIndex INITIAL_UPDATE_BUFFER_INDEX; // 1
* Retrieve the current event-buffer index.
* @return The buffer index.
*/
- BufferIndex GetEventBufferIndex() const { return mEventBufferIndex; }
+ BufferIndex GetEventBufferIndex() const
+ {
+ return mEventBufferIndex;
+ }
/**
* Retrieve the current update-buffer index.
* @return The buffer index.
*/
- BufferIndex GetUpdateBufferIndex() const { return mUpdateBufferIndex; }
+ BufferIndex GetUpdateBufferIndex() const
+ {
+ return mUpdateBufferIndex;
+ }
/**
* Swap the Event & Update buffer indices.
void Swap();
private:
-
// Undefined
SceneGraphBuffers(const SceneGraphBuffers&);
SceneGraphBuffers& operator=(const SceneGraphBuffers& rhs);
private:
-
BufferIndex mEventBufferIndex; ///< 0 or 1 (opposite of mUpdateBufferIndex)
BufferIndex mUpdateBufferIndex; ///< 0 or 1 (opposite of mEventBufferIndex)
};
void ConnectionChangePropagator::Add(Observer& observer)
{
bool foundObserver = false;
- for( ObserversIterator iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
+ for(ObserversIterator iter = mObservers.Begin(); iter != mObservers.End(); ++iter)
{
- if( *iter == &observer )
+ if(*iter == &observer)
{
foundObserver = true;
break;
}
}
- if( !foundObserver )
+ if(!foundObserver)
{
- mObservers.PushBack( &observer );
+ mObservers.PushBack(&observer);
}
}
void ConnectionChangePropagator::Remove(Observer& observer)
{
- for( ObserversIterator iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
+ for(ObserversIterator iter = mObservers.Begin(); iter != mObservers.End(); ++iter)
{
- if( *iter == &observer )
+ if(*iter == &observer)
{
mObservers.Erase(iter);
return;
void ConnectionChangePropagator::ConnectionsChanged(PropertyOwner& object)
{
// Inform observers that the object's children have changed
- for( ObserversIterator iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
+ for(ObserversIterator iter = mObservers.Begin(); iter != mObservers.End(); ++iter)
{
Observer* observer = (*iter);
- observer->ConnectionsChanged( object );
+ observer->ConnectionsChanged(object);
}
}
void ConnectionChangePropagator::ConnectedUniformMapChanged()
{
// Inform observers that the object's uniform map has changed
- for( ObserversIterator iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
+ for(ObserversIterator iter = mObservers.Begin(); iter != mObservers.End(); ++iter)
{
Observer* observer = (*iter);
observer->ConnectedUniformMapChanged();
}
}
-void ConnectionChangePropagator::Destroy( PropertyOwner& object )
+void ConnectionChangePropagator::Destroy(PropertyOwner& object)
{
// Inform observers that the object's children have changed
- for( ObserversIterator iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
+ for(ObserversIterator iter = mObservers.Begin(); iter != mObservers.End(); ++iter)
{
Observer* observer = (*iter);
- observer->ObservedObjectDestroyed( object );
+ observer->ObservedObjectDestroyed(object);
}
}
-} // SceneGraph
-} // Internal
-} // Dali
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
/**
* Inform the observer of the object that the object is about to be destroyed
*/
- virtual void ObservedObjectDestroyed(PropertyOwner& object){}
+ virtual void ObservedObjectDestroyed(PropertyOwner& object)
+ {
+ }
protected:
-
/**
* Virtual destructor, no deletion through this interface
*/
* Inform the observers that the object is about to be destroyed
* @param[in] object The connection owner
*/
- void Destroy( PropertyOwner& object );
+ void Destroy(PropertyOwner& object);
private:
using Observers = Dali::Vector<Observer*>;
Observers mObservers;
};
-
-} // SceneGraph
-} // Internal
-} // Dali
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_SCENE_GRAPH_CONNECTION_CHANGE_PROPAGATOR_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
-#include <dali/internal/event/common/object-impl.h>
#include <dali/internal/event/animation/property-constraint.h>
#include <dali/internal/event/animation/property-input-accessor.h>
#include <dali/internal/event/animation/property-input-indexer.h>
+#include <dali/internal/event/common/object-impl.h>
#include <dali/internal/update/common/property-base.h>
+#include <dali/internal/update/common/property-condition-functions.h>
#include <dali/internal/update/common/property-owner.h>
#include <dali/internal/update/common/scene-graph-property-notification.h>
-#include <dali/internal/update/common/property-condition-functions.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
-PropertyNotification* PropertyNotification::New(Object& object,
- Property::Index propertyIndex,
- Property::Type propertyType,
- int componentIndex,
- ConditionType condition,
+PropertyNotification* PropertyNotification::New(Object& object,
+ Property::Index propertyIndex,
+ Property::Type propertyType,
+ int componentIndex,
+ ConditionType condition,
RawArgumentContainer& arguments,
- NotifyMode notifyMode,
- bool compare)
+ NotifyMode notifyMode,
+ bool compare)
{
- return new PropertyNotification( object, propertyIndex, propertyType, componentIndex, condition, arguments, notifyMode, compare );
+ return new PropertyNotification(object, propertyIndex, propertyType, componentIndex, condition, arguments, notifyMode, compare);
}
-
-PropertyNotification::PropertyNotification(Object& object,
- Property::Index propertyIndex,
- Property::Type propertyType,
- int componentIndex,
- ConditionType condition,
+PropertyNotification::PropertyNotification(Object& object,
+ Property::Index propertyIndex,
+ Property::Type propertyType,
+ int componentIndex,
+ ConditionType condition,
RawArgumentContainer& arguments,
- NotifyMode notifyMode,
- bool compare)
+ NotifyMode notifyMode,
+ bool compare)
: mObject(&object),
mPropertyIndex(propertyIndex),
mPropertyType(propertyType),
mConditionType(condition),
mArguments(arguments),
mValid(false),
- mNotifyMode( Dali::PropertyNotification::DISABLED ),
+ mNotifyMode(Dali::PropertyNotification::DISABLED),
mConditionFunction(nullptr)
{
SetNotifyMode(notifyMode);
}
case PropertyCondition::Step:
{
- if( compare == true )
+ if(compare == true)
{
mConditionFunction = Step::GetCompareFunction(mPropertyType);
}
}
}
- mProperty = mObject->GetSceneObjectInputProperty( mPropertyIndex );
+ mProperty = mObject->GetSceneObjectInputProperty(mPropertyIndex);
int internalComponentIndex = mObject->GetPropertyComponentIndex(mPropertyIndex);
- if( internalComponentIndex != Property::INVALID_COMPONENT_INDEX )
+ if(internalComponentIndex != Property::INVALID_COMPONENT_INDEX)
{
// override the one passed in
mComponentIndex = internalComponentIndex;
PropertyNotification::~PropertyNotification() = default;
-bool PropertyNotification::EvalFalse( const Dali::PropertyInput& value, RawArgumentContainer& arg )
+bool PropertyNotification::EvalFalse(const Dali::PropertyInput& value, RawArgumentContainer& arg)
{
return false;
}
-void PropertyNotification::SetNotifyMode( NotifyMode notifyMode )
+void PropertyNotification::SetNotifyMode(NotifyMode notifyMode)
{
mNotifyMode = notifyMode;
}
-bool PropertyNotification::Check( BufferIndex bufferIndex )
+bool PropertyNotification::Check(BufferIndex bufferIndex)
{
bool notifyRequired = false;
- bool currentValid = false;
+ bool currentValid = false;
- if ( Property::INVALID_COMPONENT_INDEX != mComponentIndex )
+ if(Property::INVALID_COMPONENT_INDEX != mComponentIndex)
{
// Evaluate Condition
- const PropertyInputAccessor component( mProperty, mComponentIndex );
- const PropertyInputIndexer< PropertyInputAccessor > input( bufferIndex, &component );
+ const PropertyInputAccessor component(mProperty, mComponentIndex);
+ const PropertyInputIndexer<PropertyInputAccessor> input(bufferIndex, &component);
currentValid = mConditionFunction(input, mArguments);
}
else
{
// Evaluate Condition
- const PropertyInputIndexer< PropertyInputImpl > input( bufferIndex, mProperty );
+ const PropertyInputIndexer<PropertyInputImpl> input(bufferIndex, mProperty);
currentValid = mConditionFunction(input, mArguments);
}
- if( mValid != currentValid
- || ( currentValid && ( ( mConditionType == PropertyCondition::Step )
- || ( mConditionType == PropertyCondition::VariableStep ) ) ) )
+ if(mValid != currentValid || (currentValid && ((mConditionType == PropertyCondition::Step) || (mConditionType == PropertyCondition::VariableStep))))
{
mValid = currentValid;
// means don't notify so notifyRequired stays false
- switch( mNotifyMode )
+ switch(mNotifyMode)
{
case Dali::PropertyNotification::DISABLED:
{
#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/object/property-notification.h>
#include <dali/devel-api/common/owner-container.h>
#include <dali/internal/event/common/property-notification-impl.h>
#include <dali/internal/update/common/property-base.h>
+#include <dali/public-api/object/property-notification.h>
namespace Dali
{
-
namespace Internal
{
-
class Object;
class PropertyNotification;
namespace SceneGraph
{
-
class PropertyNotification;
using PropertyNotificationContainer = OwnerContainer<PropertyNotification*>;
using PropertyNotificationIter = PropertyNotificationContainer::Iterator;
using PropertyNotificationConstIter = PropertyNotificationContainer::ConstIterator;
-using ConditionFunction = bool ( * )( const Dali::PropertyInput&, Dali::Internal::PropertyNotification::RawArgumentContainer& );
+using ConditionFunction = bool (*)(const Dali::PropertyInput&, Dali::Internal::PropertyNotification::RawArgumentContainer&);
/**
* PropertyNotifications are used to inspect properties of scene graph objects, as part of a scene
using NotifyMode = Dali::PropertyNotification::NotifyMode;
using ConditionType = Dali::Internal::PropertyNotification::ConditionType;
using RawArgumentContainer = Dali::Internal::PropertyNotification::RawArgumentContainer;
- using GetPropertyFunction = const void* (*)( const SceneGraph::PropertyBase*, int );
+ using GetPropertyFunction = const void* (*)(const SceneGraph::PropertyBase*, int);
/**
* Construct a new PropertyNotification
* @param[in] compare The flag of comparing the previous and current data.
* @return A new PropertyNotification object.
*/
- static PropertyNotification* New(Object& object,
- Property::Index propertyIndex,
- Property::Type propertyType,
- int componentIndex,
- ConditionType condition,
+ static PropertyNotification* New(Object& object,
+ Property::Index propertyIndex,
+ Property::Type propertyType,
+ int componentIndex,
+ ConditionType condition,
RawArgumentContainer& arguments,
- NotifyMode notifyMode,
- bool compare);
+ NotifyMode notifyMode,
+ bool compare);
/**
* Virtual destructor
*
* @param[in] notifyMode The notification mode setting
*/
- void SetNotifyMode( NotifyMode notifyMode );
+ void SetNotifyMode(NotifyMode notifyMode);
/**
* Check this property notification condition,
* @param[in] bufferIndex The current update buffer index.
* @return Whether the validity of this notification has changed.
*/
- bool Check( BufferIndex bufferIndex );
+ bool Check(BufferIndex bufferIndex);
/**
* Returns the validity of the last condition check
bool GetValidity() const;
protected:
-
/**
* Construct the PropertyNotification
* @param[in] object The event-object for a scene-graph object to inspect.
* @param[in] arguments The arguments which accompany the condition.
* @param[in] notifyMode The notification mode setting
*/
- PropertyNotification(Object& object,
- Property::Index propertyIndex,
- Property::Type propertyType,
- int componentIndex,
- ConditionType condition,
+ PropertyNotification(Object& object,
+ Property::Index propertyIndex,
+ Property::Type propertyType,
+ int componentIndex,
+ ConditionType condition,
RawArgumentContainer& arguments,
- NotifyMode notifyMode,
- bool compare);
+ NotifyMode notifyMode,
+ bool compare);
private:
-
/**
* Checks if bool is LessThan
* @param[in] value The value being examined.
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalFalse( const Dali::PropertyInput& value, Dali::Internal::PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalFalse(const Dali::PropertyInput& value, Dali::Internal::PropertyNotification::RawArgumentContainer& arg);
// Undefined
PropertyNotification(const PropertyNotification&);
PropertyNotification& operator=(const PropertyNotification& rhs);
protected:
-
- Object* mObject; ///< Not owned by the property notification. Valid until ObjectDestroyed() is called.
- Property::Index mPropertyIndex; ///< The index of this property.
- Property::Type mPropertyType; ///< The type of property this is.
- const PropertyInputImpl* mProperty; ///< The scene graph property
- int mComponentIndex; ///< Used for accessing float components of Vector3/4
- ConditionType mConditionType; ///< The ConditionType
- RawArgumentContainer mArguments; ///< The arguments.
- bool mValid; ///< Whether this property notification is currently valid or not.
- NotifyMode mNotifyMode; ///< Whether to notify on invalid and/or valid
- ConditionFunction mConditionFunction; ///< The Condition Function pointer to be evaluated.
+ Object* mObject; ///< Not owned by the property notification. Valid until ObjectDestroyed() is called.
+ Property::Index mPropertyIndex; ///< The index of this property.
+ Property::Type mPropertyType; ///< The type of property this is.
+ const PropertyInputImpl* mProperty; ///< The scene graph property
+ int mComponentIndex; ///< Used for accessing float components of Vector3/4
+ ConditionType mConditionType; ///< The ConditionType
+ RawArgumentContainer mArguments; ///< The arguments.
+ bool mValid; ///< Whether this property notification is currently valid or not.
+ NotifyMode mNotifyMode; ///< Whether to notify on invalid and/or valid
+ ConditionFunction mConditionFunction; ///< The Condition Function pointer to be evaluated.
};
} // namespace SceneGraph
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/update/common/scene-graph-scene.h>
// INTERNAL INCLUDES
-#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
#include <dali/internal/render/gl-resources/context.h>
+#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
namespace Dali
{
{
namespace SceneGraph
{
-
Scene::Scene()
-: mContext( nullptr ),
+: mContext(nullptr),
mFrameRenderedCallbacks(),
mFramePresentedCallbacks(),
- mSkipRendering( false ),
+ mSkipRendering(false),
mSurfaceRect(),
- mSurfaceOrientation( 0 ),
- mSurfaceRectChanged( false )
+ mSurfaceOrientation(0),
+ mSurfaceRectChanged(false)
{
}
mFramePresentedCallbacks.clear();
}
-void Scene::Initialize( Context& context )
+void Scene::Initialize(Context& context)
{
mContext = &context;
}
return mInstructions;
}
-void Scene::AddFrameRenderedCallback( CallbackBase* callback, int32_t frameId )
+void Scene::AddFrameRenderedCallback(CallbackBase* callback, int32_t frameId)
{
- mFrameRenderedCallbacks.push_back( std::make_pair( std::unique_ptr< CallbackBase >( callback ), frameId ) );
+ mFrameRenderedCallbacks.push_back(std::make_pair(std::unique_ptr<CallbackBase>(callback), frameId));
}
-void Scene::AddFramePresentedCallback( CallbackBase* callback, int32_t frameId )
+void Scene::AddFramePresentedCallback(CallbackBase* callback, int32_t frameId)
{
- mFramePresentedCallbacks.push_back( std::make_pair( std::unique_ptr< CallbackBase >( callback ), frameId ) );
+ mFramePresentedCallbacks.push_back(std::make_pair(std::unique_ptr<CallbackBase>(callback), frameId));
}
-void Scene::GetFrameRenderedCallback( Dali::Integration::Scene::FrameCallbackContainer& callbacks )
+void Scene::GetFrameRenderedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks)
{
// Transfer owership of the callbacks
- for( auto&& iter : mFrameRenderedCallbacks )
+ for(auto&& iter : mFrameRenderedCallbacks)
{
- callbacks.push_back( std::make_pair( std::move( iter.first ), iter.second ) );
+ callbacks.push_back(std::make_pair(std::move(iter.first), iter.second));
}
mFrameRenderedCallbacks.clear();
}
-void Scene::GetFramePresentedCallback( Dali::Integration::Scene::FrameCallbackContainer& callbacks )
+void Scene::GetFramePresentedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks)
{
// Transfer owership of the callbacks
- for( auto&& iter : mFramePresentedCallbacks )
+ for(auto&& iter : mFramePresentedCallbacks)
{
- callbacks.push_back( std::make_pair( std::move( iter.first ), iter.second ) );
+ callbacks.push_back(std::make_pair(std::move(iter.first), iter.second));
}
mFramePresentedCallbacks.clear();
}
-void Scene::SetSkipRendering( bool skip )
+void Scene::SetSkipRendering(bool skip)
{
mSkipRendering = skip;
}
return mSkipRendering;
}
-void Scene::SetSurfaceRect( const Rect<int32_t>& rect )
+void Scene::SetSurfaceRect(const Rect<int32_t>& rect)
{
- mSurfaceRect = rect;
+ mSurfaceRect = rect;
mSurfaceRectChanged = true;
}
return mSurfaceRect;
}
-void Scene::SetSurfaceOrientation( int32_t orientation )
+void Scene::SetSurfaceOrientation(int32_t orientation)
{
mSurfaceOrientation = orientation;
}
bool Scene::IsSurfaceRectChanged()
{
bool surfaceRectChanged = mSurfaceRectChanged;
- mSurfaceRectChanged = false;
+ mSurfaceRectChanged = false;
return surfaceRectChanged;
}
-} //SceneGraph
+} // namespace SceneGraph
-} //Internal
+} // namespace Internal
-} //Dali
+} // namespace Dali
#define DALI_INTERNAL_SCENE_GRAPH_SCENE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
class Context;
namespace SceneGraph
class Scene
{
public:
-
/**
* Constructor
* @param[in] surface The render surface
* Creates a scene object in the GPU.
* @param[in] context The GL context
*/
- void Initialize( Context& context );
+ void Initialize(Context& context);
/**
* Gets the context holding the GL state of rendering for the scene
*
* @note Ownership of the callback is passed onto this class.
*/
- void AddFrameRenderedCallback( CallbackBase* callback, int32_t frameId );
+ void AddFrameRenderedCallback(CallbackBase* callback, int32_t frameId);
/**
* @brief Adds a callback that is called when the frame is displayed on the display.
*
* @note Ownership of the callback is passed onto this class.
*/
- void AddFramePresentedCallback( CallbackBase* callback, int32_t frameId );
+ void AddFramePresentedCallback(CallbackBase* callback, int32_t frameId);
/**
* @brief Gets the callback list that is called when the frame rendering is done by the graphics driver.
*
* @param[out] callbacks The callback list
*/
- void GetFrameRenderedCallback( Dali::Integration::Scene::FrameCallbackContainer& callbacks );
+ void GetFrameRenderedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks);
/**
* @brief Gets the callback list that is called when the frame is displayed on the display.
*
* @param[out] callbacks The callback list
*/
- void GetFramePresentedCallback( Dali::Integration::Scene::FrameCallbackContainer& callbacks );
+ void GetFramePresentedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks);
/**
* @brief Sets whether rendering should be skipped or not.
* @param[in] skip true if rendering should be skipped.
*/
- void SetSkipRendering( bool skip );
+ void SetSkipRendering(bool skip);
/**
* @brief Query whether rendering should be skipped or not.
* @param[in] scene The resized scene.
* @param[in] rect The retangle representing the surface.
*/
- void SetSurfaceRect( const Rect<int32_t>& rect );
+ void SetSurfaceRect(const Rect<int32_t>& rect);
/**
* Get the surface rectangle.
* @param[in] scene The rotated scene.
* @param[in] orientation The orientation value representing the surface.
*/
- void SetSurfaceOrientation( int32_t orientation );
+ void SetSurfaceOrientation(int32_t orientation);
/**
* Get the surface orientation.
bool IsSurfaceRectChanged();
private:
-
- Context* mContext; ///< The context holding the GL state of rendering for the scene, not owned
+ Context* mContext; ///< The context holding the GL state of rendering for the scene, not owned
// Render instructions describe what should be rendered during RenderManager::RenderScene()
// Update manager updates instructions for the next frame while we render the current one
- RenderInstructionContainer mInstructions; ///< Render instructions for the scene
+ RenderInstructionContainer mInstructions; ///< Render instructions for the scene
- Dali::Integration::Scene::FrameCallbackContainer mFrameRenderedCallbacks; ///< Frame rendered callbacks
- Dali::Integration::Scene::FrameCallbackContainer mFramePresentedCallbacks; ///< Frame presented callbacks
+ Dali::Integration::Scene::FrameCallbackContainer mFrameRenderedCallbacks; ///< Frame rendered callbacks
+ Dali::Integration::Scene::FrameCallbackContainer mFramePresentedCallbacks; ///< Frame presented callbacks
- bool mSkipRendering; ///< A flag to skip rendering
+ bool mSkipRendering; ///< A flag to skip rendering
- Rect<int32_t> mSurfaceRect; ///< The rectangle of surface which is related ot this scene.
- int32_t mSurfaceOrientation; ///< The orientation of surface which is related of this scene
- bool mSurfaceRectChanged; ///< The flag of surface's rectangle is changed when is resized, moved or rotated.
+ Rect<int32_t> mSurfaceRect; ///< The rectangle of surface which is related ot this scene.
+ int32_t mSurfaceOrientation; ///< The orientation of surface which is related of this scene
+ bool mSurfaceRectChanged; ///< The flag of surface's rectangle is changed when is resized, moved or rotated.
};
/// Messages
-inline void AddFrameRenderedCallbackMessage( EventThreadServices& eventThreadServices, const Scene& scene, const CallbackBase* callback, int32_t frameId )
+inline void AddFrameRenderedCallbackMessage(EventThreadServices& eventThreadServices, const Scene& scene, const CallbackBase* callback, int32_t frameId)
{
using LocalType = MessageValue2<Scene, CallbackBase*, int32_t>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &scene, &Scene::AddFrameRenderedCallback, const_cast< CallbackBase* >( callback ), frameId );
+ new(slot) LocalType(&scene, &Scene::AddFrameRenderedCallback, const_cast<CallbackBase*>(callback), frameId);
}
-inline void AddFramePresentedCallbackMessage( EventThreadServices& eventThreadServices, const Scene& scene, const CallbackBase* callback, int32_t frameId )
+inline void AddFramePresentedCallbackMessage(EventThreadServices& eventThreadServices, const Scene& scene, const CallbackBase* callback, int32_t frameId)
{
using LocalType = MessageValue2<Scene, CallbackBase*, int32_t>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &scene, &Scene::AddFramePresentedCallback, const_cast< CallbackBase* >( callback ), frameId );
+ new(slot) LocalType(&scene, &Scene::AddFramePresentedCallback, const_cast<CallbackBase*>(callback), frameId);
}
-inline void SetSurfaceRectMessage( EventThreadServices& eventThreadServices, const Scene& scene, const Rect<int32_t>& rect )
+inline void SetSurfaceRectMessage(EventThreadServices& eventThreadServices, const Scene& scene, const Rect<int32_t>& rect)
{
using LocalType = MessageValue1<Scene, Rect<int32_t> >;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &scene, &Scene::SetSurfaceRect, rect );
+ new(slot) LocalType(&scene, &Scene::SetSurfaceRect, rect);
}
-inline void SetSurfaceOrientationMessage( EventThreadServices& eventThreadServices, const Scene& scene, int32_t orientation )
+inline void SetSurfaceOrientationMessage(EventThreadServices& eventThreadServices, const Scene& scene, int32_t orientation)
{
using LocalType = MessageValue1<Scene, int32_t>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &scene, &Scene::SetSurfaceOrientation, orientation );
+ new(slot) LocalType(&scene, &Scene::SetSurfaceOrientation, orientation);
}
} // namespace SceneGraph
} // namespace Dali
-
#endif // DALI_INTERNAL_SCENE_GRAPH_SCENE_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 SceneGraph
{
-
-void UniformMap::AddObserver( Observer& observer )
+void UniformMap::AddObserver(Observer& observer)
{
bool foundObserver = false;
- for( ObserversIter iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
+ for(ObserversIter iter = mObservers.Begin(); iter != mObservers.End(); ++iter)
{
- if( *iter == &observer )
+ if(*iter == &observer)
{
foundObserver = true;
break;
}
}
- if( !foundObserver )
+ if(!foundObserver)
{
- mObservers.PushBack( &observer );
+ mObservers.PushBack(&observer);
}
}
-void UniformMap::RemoveObserver( Observer& observer )
+void UniformMap::RemoveObserver(Observer& observer)
{
- for( ObserversIter iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
+ for(ObserversIter iter = mObservers.Begin(); iter != mObservers.End(); ++iter)
{
- if( *iter == &observer )
+ if(*iter == &observer)
{
mObservers.Erase(iter);
return;
void UniformMap::MappingChanged()
{
- for( ObserversIter iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
+ for(ObserversIter iter = mObservers.Begin(); iter != mObservers.End(); ++iter)
{
Observer* observer = (*iter);
- observer->UniformMappingsChanged( *this );
+ observer->UniformMappingsChanged(*this);
}
}
MappingChanged();
}
-void UniformMap::Remove( ConstString uniformName )
+void UniformMap::Remove(ConstString uniformName)
{
auto iter = std::find_if(mUniformMaps.Begin(),
mUniformMaps.End(),
UniformMap::SizeType UniformMap::Count() const
{
- return static_cast<UniformMap::SizeType>( mUniformMaps.Count() );
+ return static_cast<UniformMap::SizeType>(mUniformMaps.Count());
}
-const UniformPropertyMapping& UniformMap::operator[]( UniformMap::SizeType index ) const
+const UniformPropertyMapping& UniformMap::operator[](UniformMap::SizeType index) const
{
return mUniformMaps[index];
}
-} // SceneGraph
-} // Internal
-} // Dali
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
#define DALI_INTERNAL_SCENE_GRAPH_UNIFORM_MAP_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
// EXTERNAL INCLUDES
-#include <string>
#include <cstdint> // uint32_t
+#include <string>
// INTERNAL INCLUDES
#include <dali/devel-api/common/hash.h>
namespace SceneGraph
{
-
/**
* The uniform map is used to map a uniform name to a property value.
*/
UniformPropertyMapping() = default;
const PropertyInputImpl* propertyPtr{nullptr};
- ConstString uniformName;
+ ConstString uniformName;
};
/**
class Observer
{
public:
-
/**
* Inform observer that uniform mappings have been changed
* @param mappings
virtual void UniformMappingsChanged(const UniformMap& mappings) = 0;
protected:
-
/**
* Virtual destructor, no deletion through this interface
*/
/**
* Add an observer that watches for changes in the mappings
*/
- void AddObserver( Observer& observer );
+ void AddObserver(Observer& observer);
/**
* Remove an observer
*/
- void RemoveObserver( Observer& observer );
+ void RemoveObserver(Observer& observer);
/**
* Add a map to the mappings table.
/**
* Remove a map from the mappings table
*/
- void Remove( ConstString uniformName );
+ void Remove(ConstString uniformName);
/**
* Find a property given the uniform name.
* @return The address of the property if it's in the map, or NULL otherwise.
*/
- const PropertyInputImpl* Find( ConstString uniformName );
+ const PropertyInputImpl* Find(ConstString uniformName);
/**
* Get the count of uniforms in the map
* @param[in] index The index of the element to fetch
* @return reference to the element in the map
*/
- const UniformPropertyMapping& operator[]( SizeType index ) const;
+ const UniformPropertyMapping& operator[](SizeType index) const;
private:
/**
Observers mObservers;
};
-
} // namespace SceneGraph
} // namespace Internal
} // namespace Dali
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/update/controllers/render-message-dispatcher.h>
// INTERNAL INCLUDES
+#include <dali/internal/common/message.h>
#include <dali/internal/render/common/render-manager.h>
#include <dali/internal/render/queue/render-queue.h>
#include <dali/internal/render/renderers/render-renderer.h>
-#include <dali/internal/common/message.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
-RenderMessageDispatcher::RenderMessageDispatcher( RenderManager& renderManager, RenderQueue& renderQueue, const SceneGraphBuffers& buffers )
-: mRenderManager( renderManager ),
- mRenderQueue( renderQueue ),
- mBuffers( buffers )
+RenderMessageDispatcher::RenderMessageDispatcher(RenderManager& renderManager, RenderQueue& renderQueue, const SceneGraphBuffers& buffers)
+: mRenderManager(renderManager),
+ mRenderQueue(renderQueue),
+ mBuffers(buffers)
{
}
RenderMessageDispatcher::~RenderMessageDispatcher() = default;
-void RenderMessageDispatcher::AddRenderer( OwnerPointer< Render::Renderer >& renderer )
+void RenderMessageDispatcher::AddRenderer(OwnerPointer<Render::Renderer>& renderer)
{
// Message has ownership of renderer while in transit from update -> render
- typedef MessageValue1< RenderManager, OwnerPointer< Render::Renderer > > DerivedType;
+ typedef MessageValue1<RenderManager, OwnerPointer<Render::Renderer> > DerivedType;
// Reserve some memory inside the render queue
- uint32_t* slot = mRenderQueue.ReserveMessageSlot( mBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mRenderQueue.ReserveMessageSlot(mBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mRenderManager, &RenderManager::AddRenderer, renderer );
+ new(slot) DerivedType(&mRenderManager, &RenderManager::AddRenderer, renderer);
}
-void RenderMessageDispatcher::RemoveRenderer( Render::Renderer& renderer )
+void RenderMessageDispatcher::RemoveRenderer(Render::Renderer& renderer)
{
using DerivedType = MessageValue1<RenderManager, Render::Renderer*>;
// Reserve some memory inside the render queue
- uint32_t* slot = mRenderQueue.ReserveMessageSlot( mBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mRenderQueue.ReserveMessageSlot(mBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mRenderManager, &RenderManager::RemoveRenderer, &renderer );
+ new(slot) DerivedType(&mRenderManager, &RenderManager::RemoveRenderer, &renderer);
}
-void RenderMessageDispatcher::AddRenderTracker( Render::RenderTracker& renderTracker )
+void RenderMessageDispatcher::AddRenderTracker(Render::RenderTracker& renderTracker)
{
using DerivedType = MessageValue1<RenderManager, Render::RenderTracker*>;
// Reserve some memory inside the render queue
- uint32_t* slot = mRenderQueue.ReserveMessageSlot( mBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mRenderQueue.ReserveMessageSlot(mBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mRenderManager, &RenderManager::AddRenderTracker, &renderTracker );
+ new(slot) DerivedType(&mRenderManager, &RenderManager::AddRenderTracker, &renderTracker);
}
-void RenderMessageDispatcher::RemoveRenderTracker( Render::RenderTracker& renderTracker )
+void RenderMessageDispatcher::RemoveRenderTracker(Render::RenderTracker& renderTracker)
{
using DerivedType = MessageValue1<RenderManager, Render::RenderTracker*>;
// Reserve some memory inside the render queue
- uint32_t* slot = mRenderQueue.ReserveMessageSlot( mBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mRenderQueue.ReserveMessageSlot(mBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mRenderManager, &RenderManager::RemoveRenderTracker, &renderTracker );
+ new(slot) DerivedType(&mRenderManager, &RenderManager::RemoveRenderTracker, &renderTracker);
}
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_MESSAGE_DISPATCHER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/update/common/scene-graph-buffers.h>
#include <dali/internal/render/renderers/render-renderer.h>
+#include <dali/internal/update/common/scene-graph-buffers.h>
namespace Dali
{
-
namespace Internal
{
class MessageBase;
namespace SceneGraph
{
-
class RenderManager;
class RenderQueue;
class RenderMessageDispatcher
{
public:
-
/**
* Constructor
*/
- RenderMessageDispatcher( RenderManager& renderManager, RenderQueue& renderQueue, const SceneGraphBuffers& buffers );
+ RenderMessageDispatcher(RenderManager& renderManager, RenderQueue& renderQueue, const SceneGraphBuffers& buffers);
/**
* Destructor
* @param[in] renderer The renderer to add.
* @post renderer ownership is transferred.
*/
- void AddRenderer( OwnerPointer< Render::Renderer >& renderer );
+ void AddRenderer(OwnerPointer<Render::Renderer>& renderer);
/**
* Remove a Renderer.
* @param[in] renderer The renderer to remove.
* @post renderer will be destroyed in the next Render.
*/
- void RemoveRenderer( Render::Renderer& renderer );
+ void RemoveRenderer(Render::Renderer& renderer);
/**
* Add a Render tracker.
* @param[in] renderTracker The render tracker to add.
* @post ownership is transferred
*/
- void AddRenderTracker( Render::RenderTracker& renderTracker );
+ void AddRenderTracker(Render::RenderTracker& renderTracker);
/**
* Remove a Render tracker.
* @param[in] renderTracker The render tracker to add.
* @post render tracker will be destroyed in the next Render pass.
*/
- void RemoveRenderTracker( Render::RenderTracker& renderTracker );
+ void RemoveRenderTracker(Render::RenderTracker& renderTracker);
private:
-
RenderManager& mRenderManager;
- RenderQueue& mRenderQueue;
+ RenderQueue& mRenderQueue;
const SceneGraphBuffers& mBuffers;
};
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
-SceneControllerImpl::SceneControllerImpl( RenderMessageDispatcher& renderMessageDispatcher,
- RenderQueue& renderQueue,
- DiscardQueue& discardQueue )
-: mRenderMessageDispatcher( renderMessageDispatcher ),
- mRenderQueue( renderQueue ),
- mDiscardQueue( discardQueue )
+SceneControllerImpl::SceneControllerImpl(RenderMessageDispatcher& renderMessageDispatcher,
+ RenderQueue& renderQueue,
+ DiscardQueue& discardQueue)
+: mRenderMessageDispatcher(renderMessageDispatcher),
+ mRenderQueue(renderQueue),
+ mDiscardQueue(discardQueue)
{
}
#define DALI_INTERNAL_SCENE_GRAPH_SCENE_CONTROLLER_IMPL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
/**
* concrete implementation of the scene controller interface
*/
-class SceneControllerImpl: public SceneController
+class SceneControllerImpl : public SceneController
{
-
public:
-
/**
* Constructor
* @param[in] rendererDispatcher Used for passing ownership of renderers to the render-thread.
* @param[in] renderQueue The renderQueue
* @param[in] discardQueue The discardQueue
*/
- SceneControllerImpl( RenderMessageDispatcher& renderMessageDispatcher,
- RenderQueue& renderQueue,
- DiscardQueue& discardQueue );
+ SceneControllerImpl(RenderMessageDispatcher& renderMessageDispatcher,
+ RenderQueue& renderQueue,
+ DiscardQueue& discardQueue);
/**
* Destructor
*/
~SceneControllerImpl() override;
-public: // from SceneController
-
+public: // from SceneController
/**
* @copydoc SceneController::GetRenderMessageDispatcher()
*/
- RenderMessageDispatcher& GetRenderMessageDispatcher() override { return mRenderMessageDispatcher; }
+ RenderMessageDispatcher& GetRenderMessageDispatcher() override
+ {
+ return mRenderMessageDispatcher;
+ }
/**
* @copydoc SceneController::GetRenderQueue()
*/
- RenderQueue& GetRenderQueue() override { return mRenderQueue; }
+ RenderQueue& GetRenderQueue() override
+ {
+ return mRenderQueue;
+ }
/**
* @copydoc SceneController::GetDiscardQueue()
*/
- DiscardQueue& GetDiscardQueue() override { return mDiscardQueue; }
+ DiscardQueue& GetDiscardQueue() override
+ {
+ return mDiscardQueue;
+ }
private:
-
// Undefined copy constructor.
- SceneControllerImpl( const SceneControllerImpl& );
+ SceneControllerImpl(const SceneControllerImpl&);
// Undefined assignment operator.
- SceneControllerImpl& operator=( const SceneControllerImpl& );
+ SceneControllerImpl& operator=(const SceneControllerImpl&);
private:
-
- RenderMessageDispatcher& mRenderMessageDispatcher; ///< Used for passing messages to the render-thread
- RenderQueue& mRenderQueue; ///< render queue
- DiscardQueue& mDiscardQueue; ///< discard queue
+ RenderMessageDispatcher& mRenderMessageDispatcher; ///< Used for passing messages to the render-thread
+ RenderQueue& mRenderQueue; ///< render queue
+ DiscardQueue& mDiscardQueue; ///< discard queue
};
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_SCENE_CONTROLLER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
class RenderMessageDispatcher;
class RenderQueue;
class DiscardQueue;
class SceneController
{
public:
-
/**
* Constructor
*/
virtual DiscardQueue& GetDiscardQueue() = 0;
private:
-
// Undefined copy constructor.
- SceneController( const SceneController& );
+ SceneController(const SceneController&);
// Undefined assignment operator.
- SceneController& operator=( const SceneController& );
+ SceneController& operator=(const SceneController&);
};
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_GESTURE_PROPERTIES_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/object/property-types.h>
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/event/common/property-input-impl.h>
+#include <dali/public-api/object/property-types.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
/**
* A template for a read only properties used by Gestures.
*/
-template < class T >
+template<class T>
class GestureProperty : public PropertyInputImpl
{
public:
-
/**
* Create a read-only gesture property.
* @param [in] initialValue The initial value of the property.
*/
- GestureProperty( const T& initialValue )
- : mValue( initialValue ),
- mInputChanged( false )
+ GestureProperty(const T& initialValue)
+ : mValue(initialValue),
+ mInputChanged(false)
{
}
*/
GestureProperty()
: mValue(),
- mInputChanged( false )
+ mInputChanged(false)
{
}
*/
Dali::Property::Type GetType() const override
{
- return Dali::PropertyTypes::Get< T >();
+ return Dali::PropertyTypes::Get<T>();
}
/**
*/
void Set(const T& value)
{
- mValue = value;
+ mValue = value;
mInputChanged = true;
}
}
private:
-
// Undefined
GestureProperty(const GestureProperty& property);
GestureProperty& operator=(const GestureProperty& rhs);
protected:
-
- T mValue; ///< The property value
- bool mInputChanged:1; ///< Whether the property has been modified
+ T mValue; ///< The property value
+ bool mInputChanged : 1; ///< Whether the property has been modified
};
/**
* A read only Vector2 property used by Gestures.
*/
-class GesturePropertyVector2 : public GestureProperty< Vector2 >
+class GesturePropertyVector2 : public GestureProperty<Vector2>
{
public:
-
/**
* Virtual destructor.
*/
/**
* @copydoc Dali::PropertyInput::GetVector2()
*/
- const Vector2& GetVector2( BufferIndex bufferIndex ) const override
+ const Vector2& GetVector2(BufferIndex bufferIndex) const override
{
return mValue;
}
/**
* A read only bool property used by Gestures.
*/
-class GesturePropertyBool : public GestureProperty< bool >
+class GesturePropertyBool : public GestureProperty<bool>
{
public:
-
/**
* Virtual destructor.
*/
/**
* @copydoc Dali::PropertyInput::GetBoolean()
*/
- const bool& GetBoolean( BufferIndex bufferIndex ) const override
+ const bool& GetBoolean(BufferIndex bufferIndex) const override
{
return mValue;
}
namespace Dali
{
-
namespace Internal
{
-
void PanGestureProfiling::PrintData() const
{
- PrintData( mRawData, "RAW" );
- PrintData( mLatestData, "LATEST" );
- PrintData( mAveragedData, "AVERAGED" );
+ PrintData(mRawData, "RAW");
+ PrintData(mLatestData, "LATEST");
+ PrintData(mAveragedData, "AVERAGED");
}
-void PanGestureProfiling::PrintData( const PanPositionContainer& dataContainer, const char * const prefix ) const
+void PanGestureProfiling::PrintData(const PanPositionContainer& dataContainer, const char* const prefix) const
{
const PanPositionContainer::const_iterator endIter = dataContainer.end();
- for ( PanPositionContainer::const_iterator iter = dataContainer.begin(); iter != endIter; ++iter )
+ for(PanPositionContainer::const_iterator iter = dataContainer.begin(); iter != endIter; ++iter)
{
- DALI_LOG_UPDATE_STATUS( "%s, %u, %.2f, %.2f, displacement: %.2f, %.2f, velocity: %.2f, %.2f, state: %d\n", prefix, iter->time, iter->position.x, iter->position.y, iter->displacement.x, iter->displacement.y, iter->velocity.x, iter->velocity.y, iter->state );
+ DALI_LOG_UPDATE_STATUS("%s, %u, %.2f, %.2f, displacement: %.2f, %.2f, velocity: %.2f, %.2f, state: %d\n", prefix, iter->time, iter->position.x, iter->position.y, iter->displacement.x, iter->displacement.y, iter->velocity.x, iter->velocity.y, iter->state);
}
}
#define DALI_INTERNAL_PAN_GESTURE_PROFILING_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/math/vector2.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/events/gesture-enumerations.h>
+#include <dali/public-api/math/vector2.h>
namespace Dali
{
-
namespace Internal
{
-
struct PanGestureProfiling
{
struct Position
{
- Position( unsigned int time, Vector2 position, Vector2 displacement, Vector2 velocity, GestureState state )
- : time( time ), position( position ), displacement( displacement ), velocity( velocity ), state( state )
+ Position(unsigned int time, Vector2 position, Vector2 displacement, Vector2 velocity, GestureState state)
+ : time(time),
+ position(position),
+ displacement(displacement),
+ velocity(velocity),
+ state(state)
{
}
unsigned int time;
- Vector2 position;
- Vector2 displacement;
- Vector2 velocity;
+ Vector2 position;
+ Vector2 displacement;
+ Vector2 velocity;
GestureState state;
};
void PrintData() const;
- void PrintData( const PanPositionContainer& dataContainer, const char * const prefix ) const;
+ void PrintData(const PanPositionContainer& dataContainer, const char* const prefix) const;
void ClearData();
PanPositionContainer mAveragedData;
};
-
} // namespace Internal
} // namespace Dali
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <cmath>
// INTERNAL INCLUDES
-#include <dali/internal/update/gestures/pan-gesture-profiling.h>
#include <dali/integration-api/debug.h>
+#include <dali/internal/update/gestures/pan-gesture-profiling.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
namespace
{
-
// TODO: Experimental - for changing in code only:
-const bool TEST_TUNE_ENABLE_OVERSHOOT_PROTECTION = false;
+const bool TEST_TUNE_ENABLE_OVERSHOOT_PROTECTION = false;
// Internal defaults:
-const int MAX_GESTURE_AGE = 200; ///< maximum age of a gesture before disallowing its use in algorithm TODO: Possibly make this configurable.
-const float ACCELERATION_THRESHOLD = 0.1f; ///< minimum pan velocity change to trigger dynamic change of prediction amount.
-const float OUTPUT_TIME_DIFFERENCE = ( 1000.0f / 60.0f ); ///< This is used to optionally override actual times if they make results worse.
-const float ACCELERATION_SMOOTHING = 0.44f; ///< Smoothes acceleration changes from one frame to another.
-const float ACCELERATION_CAP = 0.0004f;///< Limits acceleration changes from one frame to another.
+const int MAX_GESTURE_AGE = 200; ///< maximum age of a gesture before disallowing its use in algorithm TODO: Possibly make this configurable.
+const float ACCELERATION_THRESHOLD = 0.1f; ///< minimum pan velocity change to trigger dynamic change of prediction amount.
+const float OUTPUT_TIME_DIFFERENCE = (1000.0f / 60.0f); ///< This is used to optionally override actual times if they make results worse.
+const float ACCELERATION_SMOOTHING = 0.44f; ///< Smoothes acceleration changes from one frame to another.
+const float ACCELERATION_CAP = 0.0004f; ///< Limits acceleration changes from one frame to another.
// Defaults for Environment Variables:
// Prediction Mode 1:
-const unsigned int DEFAULT_MAX_PREDICTION_AMOUNT = 32; ///< the upper bound of the range to clamp the prediction interpolation.
-const unsigned int DEFAULT_MIN_PREDICTION_AMOUNT = 0; ///< the lower bound of the range to clamp the prediction interpolation.
-const unsigned int DEFAULT_PREDICTION_AMOUNT_ADJUSTMENT = 2; ///< the amount of prediction interpolation to adjust (in milliseconds) each time when pan velocity changes.
+const unsigned int DEFAULT_MAX_PREDICTION_AMOUNT = 32; ///< the upper bound of the range to clamp the prediction interpolation.
+const unsigned int DEFAULT_MIN_PREDICTION_AMOUNT = 0; ///< the lower bound of the range to clamp the prediction interpolation.
+const unsigned int DEFAULT_PREDICTION_AMOUNT_ADJUSTMENT = 2; ///< the amount of prediction interpolation to adjust (in milliseconds) each time when pan velocity changes.
// Prediction Mode 2:
-const bool DEFAULT_USE_ACTUAL_TIMES = false; ///< Disable to optionally override actual times if they make results worse.
-const int DEFAULT_INTERPOLATION_TIME_RANGE = 255; ///< Time into past history (ms) to use points to interpolate the first point.
-const bool DEFAULT_SCALAR_ONLY_PREDICTION_ENABLED = false; ///< If enabled, prediction is done using velocity alone (no integration or acceleration).
-const bool DEFAULT_TWO_POINT_PREDICTION_ENABLED = true; ///< If enabled, a second interpolated point is predicted and combined with the first to get more stable values.
-const int DEFAULT_TWO_POINT_PAST_INTERPOLATE_TIME = 42; ///< The target time in the past to generate the second interpolated point.
-const float DEFAULT_TWO_POINT_VELOCITY_BIAS = 0.35f; ///< The ratio of first and second interpolated points to use for velocity. 0.0f = 100% of first point. 1.0f = 100% of second point.
-const float DEFAULT_TWO_POINT_ACCELERATION_BIAS = 0.10f; ///< The ratio of first and second interpolated points to use for acceleration. 0.0f = 100% of first point. 1.0f = 100% of second point.
-const int DEFAULT_MULTITAP_SMOOTHING_RANGE = 34; ///< The range in time (ms) of points in the history to smooth the final output against.
+const bool DEFAULT_USE_ACTUAL_TIMES = false; ///< Disable to optionally override actual times if they make results worse.
+const int DEFAULT_INTERPOLATION_TIME_RANGE = 255; ///< Time into past history (ms) to use points to interpolate the first point.
+const bool DEFAULT_SCALAR_ONLY_PREDICTION_ENABLED = false; ///< If enabled, prediction is done using velocity alone (no integration or acceleration).
+const bool DEFAULT_TWO_POINT_PREDICTION_ENABLED = true; ///< If enabled, a second interpolated point is predicted and combined with the first to get more stable values.
+const int DEFAULT_TWO_POINT_PAST_INTERPOLATE_TIME = 42; ///< The target time in the past to generate the second interpolated point.
+const float DEFAULT_TWO_POINT_VELOCITY_BIAS = 0.35f; ///< The ratio of first and second interpolated points to use for velocity. 0.0f = 100% of first point. 1.0f = 100% of second point.
+const float DEFAULT_TWO_POINT_ACCELERATION_BIAS = 0.10f; ///< The ratio of first and second interpolated points to use for acceleration. 0.0f = 100% of first point. 1.0f = 100% of second point.
+const int DEFAULT_MULTITAP_SMOOTHING_RANGE = 34; ///< The range in time (ms) of points in the history to smooth the final output against.
// Prediction Modes 1 & 2.
-const unsigned int DEFAULT_PREDICTION_AMOUNT[2] = { 5, 57 }; ///< how much to interpolate pan position and displacement from last vsync time (in milliseconds)
-const float DEFAULT_SMOOTHING_AMOUNT[2] = { 0.25f, 0.23f }; ///< how much to smooth final result from last vsync time
+const unsigned int DEFAULT_PREDICTION_AMOUNT[2] = {5, 57}; ///< how much to interpolate pan position and displacement from last vsync time (in milliseconds)
+const float DEFAULT_SMOOTHING_AMOUNT[2] = {0.25f, 0.23f}; ///< how much to smooth final result from last vsync time
} // unnamed namespace
const PanGesture::PredictionMode PanGesture::DEFAULT_PREDICTION_MODE = PanGesture::PREDICTION_NONE;
-const int PanGesture::NUM_PREDICTION_MODES = PanGesture::PREDICTION_2 + 1;
+const int PanGesture::NUM_PREDICTION_MODES = PanGesture::PREDICTION_2 + 1;
const PanGesture::SmoothingMode PanGesture::DEFAULT_SMOOTHING_MODE = PanGesture::SMOOTHING_LAST_VALUE;
-const int PanGesture::NUM_SMOOTHING_MODES = PanGesture::SMOOTHING_MULTI_TAP + 1;
+const int PanGesture::NUM_SMOOTHING_MODES = PanGesture::SMOOTHING_MULTI_TAP + 1;
PanGesture* PanGesture::New()
{
delete mProfiling;
}
-void PanGesture::AddGesture( const Internal::PanGesture& gesture )
+void PanGesture::AddGesture(const Internal::PanGesture& gesture)
{
- Dali::Mutex::ScopedLock lock( mMutex );
- mGestures[ mWritePosition ] = gesture;
+ Dali::Mutex::ScopedLock lock(mMutex);
+ mGestures[mWritePosition] = gesture;
// Update our write position.
++mWritePosition;
void PanGesture::RemoveOldHistory(PanInfoHistory& panHistory, unsigned int currentTime, unsigned int maxAge, unsigned int minEvents)
{
PanInfoHistoryConstIter endIter = panHistory.end();
- PanInfoHistoryIter iter = panHistory.begin();
- while( iter != endIter && panHistory.size() > minEvents)
+ PanInfoHistoryIter iter = panHistory.begin();
+ while(iter != endIter && panHistory.size() > minEvents)
{
PanInfo currentGesture = *iter;
- if( currentTime < currentGesture.time + maxAge )
+ if(currentTime < currentGesture.time + maxAge)
{
break;
}
- iter = panHistory.erase(iter);
+ iter = panHistory.erase(iter);
endIter = panHistory.end();
}
// dont want more than 5 previous predictions for smoothing
iter = mPredictionHistory.begin();
- while( mPredictionHistory.size() > 1 && iter != mPredictionHistory.end() )
+ while(mPredictionHistory.size() > 1 && iter != mPredictionHistory.end())
{
iter = mPredictionHistory.erase(iter);
}
{
RemoveOldHistory(panHistory, lastVSyncTime, MAX_GESTURE_AGE, 0);
size_t panHistorySize = panHistory.size();
- if( panHistorySize == 0 )
+ if(panHistorySize == 0)
{
// cant do any prediction without a history
return;
}
- PanInfoHistoryConstIter endIter = panHistory.end();
- PanInfoHistoryIter iter = panHistory.begin();
- Vector2 screenVelocity = gestureOut.screen.velocity;
- Vector2 localVelocity = gestureOut.local.velocity;
- Vector2 screenDisplacement = gestureOut.screen.displacement;
- Vector2 localDisplacement = gestureOut.local.displacement;
-
- bool havePreviousAcceleration = false;
- bool previousVelocity = false;
- float previousAccel = 0.0f;
+ PanInfoHistoryConstIter endIter = panHistory.end();
+ PanInfoHistoryIter iter = panHistory.begin();
+ Vector2 screenVelocity = gestureOut.screen.velocity;
+ Vector2 localVelocity = gestureOut.local.velocity;
+ Vector2 screenDisplacement = gestureOut.screen.displacement;
+ Vector2 localDisplacement = gestureOut.local.displacement;
+
+ bool havePreviousAcceleration = false;
+ bool previousVelocity = false;
+ float previousAccel = 0.0f;
unsigned int lastTime(0);
unsigned int interpolationTime = lastVSyncTime + mCurrentPredictionAmount;
- if( interpolationTime > gestureOut.time ) // Guard against the rare case when gestureOut.time > (lastVSyncTime + mCurrentPredictionAmount)
+ if(interpolationTime > gestureOut.time) // Guard against the rare case when gestureOut.time > (lastVSyncTime + mCurrentPredictionAmount)
{
interpolationTime -= gestureOut.time;
}
interpolationTime = 0u;
}
- while( iter != endIter )
+ while(iter != endIter)
{
PanInfo currentGesture = *iter;
- if( !previousVelocity )
+ if(!previousVelocity)
{
// not yet set a previous velocity
- screenVelocity = currentGesture.screen.velocity;
+ screenVelocity = currentGesture.screen.velocity;
previousVelocity = true;
- lastTime = currentGesture.time;
+ lastTime = currentGesture.time;
++iter;
continue;
}
- float previousValueWeight = ( static_cast<float>( MAX_GESTURE_AGE ) - static_cast<float>(lastVSyncTime - lastTime) ) / static_cast<float>( MAX_GESTURE_AGE );
- float velMag = currentGesture.screen.velocity.Length();
- float velDiff = velMag - screenVelocity.Length();
- float acceleration = 0.0f;
+ float previousValueWeight = (static_cast<float>(MAX_GESTURE_AGE) - static_cast<float>(lastVSyncTime - lastTime)) / static_cast<float>(MAX_GESTURE_AGE);
+ float velMag = currentGesture.screen.velocity.Length();
+ float velDiff = velMag - screenVelocity.Length();
+ float acceleration = 0.0f;
float time(0.f);
- if (currentGesture.time > lastTime) // Guard against invalid timestamps
+ if(currentGesture.time > lastTime) // Guard against invalid timestamps
{
- time = static_cast<float>( currentGesture.time - lastTime );
+ time = static_cast<float>(currentGesture.time - lastTime);
}
- if( time > Math::MACHINE_EPSILON_1 )
+ if(time > Math::MACHINE_EPSILON_1)
{
acceleration = velDiff / time;
}
- float newVelMag = 0.0f;
- int currentInterpolation = interpolationTime;
- if( !havePreviousAcceleration )
+ float newVelMag = 0.0f;
+ int currentInterpolation = interpolationTime;
+ if(!havePreviousAcceleration)
{
- newVelMag = velMag;
+ newVelMag = velMag;
havePreviousAcceleration = true;
}
else
{
- newVelMag = velMag + (((acceleration * (1.0f - previousValueWeight)) + (previousAccel * previousValueWeight)) * static_cast<float>( currentInterpolation ) );
+ newVelMag = velMag + (((acceleration * (1.0f - previousValueWeight)) + (previousAccel * previousValueWeight)) * static_cast<float>(currentInterpolation));
}
float velMod = 1.0f;
- if( velMag > Math::MACHINE_EPSILON_1 )
+ if(velMag > Math::MACHINE_EPSILON_1)
{
velMod = newVelMag / velMag;
}
gestureOut.screen.velocity = currentGesture.screen.velocity * velMod;
- gestureOut.local.velocity = currentGesture.local.velocity * velMod;
- screenDisplacement = gestureOut.screen.displacement + (gestureOut.screen.velocity * static_cast<float>( interpolationTime ) );
- localDisplacement = gestureOut.local.displacement + (gestureOut.local.velocity * static_cast<float>( interpolationTime ) );
- screenVelocity = currentGesture.screen.velocity;
- localVelocity = currentGesture.local.velocity;
- previousAccel = acceleration;
+ gestureOut.local.velocity = currentGesture.local.velocity * velMod;
+ screenDisplacement = gestureOut.screen.displacement + (gestureOut.screen.velocity * static_cast<float>(interpolationTime));
+ localDisplacement = gestureOut.local.displacement + (gestureOut.local.velocity * static_cast<float>(interpolationTime));
+ screenVelocity = currentGesture.screen.velocity;
+ localVelocity = currentGesture.local.velocity;
+ previousAccel = acceleration;
++iter;
}
// gestureOut's position is currently equal to the last event's position and its displacement is equal to last frame's total displacement
// add interpolated distance and position to current
// work out interpolated velocity
- gestureOut.screen.position = (gestureOut.screen.position - gestureOut.screen.displacement) + screenDisplacement;
- gestureOut.local.position = (gestureOut.local.position - gestureOut.local.displacement) + localDisplacement;
+ gestureOut.screen.position = (gestureOut.screen.position - gestureOut.screen.displacement) + screenDisplacement;
+ gestureOut.local.position = (gestureOut.local.position - gestureOut.local.displacement) + localDisplacement;
gestureOut.screen.displacement = screenDisplacement;
- gestureOut.local.displacement = localDisplacement;
+ gestureOut.local.displacement = localDisplacement;
gestureOut.time += interpolationTime;
}
-void PanGesture::BlendPoints( PanInfo& gesture, PanInfo& lastGesture, float blendValue )
+void PanGesture::BlendPoints(PanInfo& gesture, PanInfo& lastGesture, float blendValue)
{
- gesture.screen.position -= ( gesture.screen.position - lastGesture.screen.position ) * 0.5f * ( 1.0f - blendValue );
- gesture.local.position -= ( gesture.local.position - lastGesture.local.position ) * 0.5f * ( 1.0f - blendValue );
+ gesture.screen.position -= (gesture.screen.position - lastGesture.screen.position) * 0.5f * (1.0f - blendValue);
+ gesture.local.position -= (gesture.local.position - lastGesture.local.position) * 0.5f * (1.0f - blendValue);
// Make current displacement relative to previous update-frame now.
gesture.screen.displacement = gesture.screen.position - lastGesture.screen.position;
- gesture.local.displacement = gesture.local.position - lastGesture.local.position;
+ gesture.local.displacement = gesture.local.position - lastGesture.local.position;
// Calculate velocity relative to previous update-frame
- float timeDifference = static_cast<float>( gesture.time - lastGesture.time );
+ float timeDifference = static_cast<float>(gesture.time - lastGesture.time);
gesture.screen.velocity = gesture.screen.displacement / timeDifference;
- gesture.local.velocity = gesture.local.displacement / timeDifference;
+ gesture.local.velocity = gesture.local.displacement / timeDifference;
}
-bool PanGesture::ReadGestures( FrameGestureInfo& info, unsigned int currentTimestamp )
+bool PanGesture::ReadGestures(FrameGestureInfo& info, unsigned int currentTimestamp)
{
unsigned int previousReadPosition = 0;
- bool eventFound = false;
- info.frameGesture = mLastUnmodifiedGesture;
+ bool eventFound = false;
+ info.frameGesture = mLastUnmodifiedGesture;
- while( mReadPosition != mWritePosition )
+ while(mReadPosition != mWritePosition)
{
// Copy the gesture first
- PanInfo currentGesture( mGestures[mReadPosition] );
+ PanInfo currentGesture(mGestures[mReadPosition]);
- if( mProfiling )
+ if(mProfiling)
{
- mProfiling->mRawData.push_back( PanGestureProfiling::Position( currentGesture.time, currentGesture.screen.position, currentGesture.screen.displacement, currentGesture.screen.velocity, currentGesture.state ) );
+ mProfiling->mRawData.push_back(PanGestureProfiling::Position(currentGesture.time, currentGesture.screen.position, currentGesture.screen.displacement, currentGesture.screen.velocity, currentGesture.state));
}
- info.frameGesture.local.position = currentGesture.local.position;
- info.frameGesture.local.velocity = currentGesture.local.velocity;
+ info.frameGesture.local.position = currentGesture.local.position;
+ info.frameGesture.local.velocity = currentGesture.local.velocity;
info.frameGesture.screen.position = currentGesture.screen.position;
info.frameGesture.screen.velocity = currentGesture.screen.velocity;
- if( info.eventsThisFrame > 0 )
+ if(info.eventsThisFrame > 0)
{
info.acceleration = currentGesture.screen.velocity.Length() - mGestures[previousReadPosition].screen.velocity.Length();
}
- if( !eventFound )
+ if(!eventFound)
{
- info.frameGesture.local.displacement = currentGesture.local.displacement;
+ info.frameGesture.local.displacement = currentGesture.local.displacement;
info.frameGesture.screen.displacement = currentGesture.screen.displacement;
- eventFound = true;
+ eventFound = true;
}
else
{
info.frameGesture.time = currentGesture.time;
// add event to history
- mPanHistory.push_back( currentGesture );
- if( currentGesture.state == GestureState::STARTED )
+ mPanHistory.push_back(currentGesture);
+ if(currentGesture.state == GestureState::STARTED)
{
info.justStarted = true;
// clear just finished as we have started new pan
info.justFinished = false;
}
- info.justFinished |= ( currentGesture.state == GestureState::FINISHED || currentGesture.state == GestureState::CANCELLED );
+ info.justFinished |= (currentGesture.state == GestureState::FINISHED || currentGesture.state == GestureState::CANCELLED);
// Update our read position.
previousReadPosition = mReadPosition;
return false;
}
-bool PanGesture::ReadAndResampleGestures( FrameGestureInfo& info, unsigned int currentTimestamp )
+bool PanGesture::ReadAndResampleGestures(FrameGestureInfo& info, unsigned int currentTimestamp)
{
- PanInfo lastReadGesture;
- Dali::Mutex::ScopedLock lock( mMutex );
- while( mReadPosition != mWritePosition )
+ PanInfo lastReadGesture;
+ Dali::Mutex::ScopedLock lock(mMutex);
+ while(mReadPosition != mWritePosition)
{
// Copy the gesture first
lastReadGesture = mGestures[mReadPosition];
- if( mProfiling )
+ if(mProfiling)
{
- mProfiling->mRawData.push_back( PanGestureProfiling::Position( lastReadGesture.time, lastReadGesture.screen.position,
- lastReadGesture.screen.displacement, lastReadGesture.screen.velocity, lastReadGesture.state ) );
+ mProfiling->mRawData.push_back(PanGestureProfiling::Position(lastReadGesture.time, lastReadGesture.screen.position, lastReadGesture.screen.displacement, lastReadGesture.screen.velocity, lastReadGesture.state));
}
info.frameGesture.screen.position += lastReadGesture.screen.position;
info.frameGesture.screen.velocity += lastReadGesture.screen.velocity;
info.frameGesture.local.velocity += lastReadGesture.local.velocity;
- if( lastReadGesture.state == GestureState::STARTED )
+ if(lastReadGesture.state == GestureState::STARTED)
{
// Clear just finished as we have started new pan.
info.justFinished = false;
- info.justStarted = true;
+ info.justStarted = true;
}
else
{
- info.justFinished |= ( lastReadGesture.state == GestureState::FINISHED || lastReadGesture.state == GestureState::CANCELLED );
+ info.justFinished |= (lastReadGesture.state == GestureState::FINISHED || lastReadGesture.state == GestureState::CANCELLED);
}
// Add event to history
- mPanHistory.push_back( lastReadGesture );
+ mPanHistory.push_back(lastReadGesture);
// Update our read position.
++info.eventsThisFrame;
}
bool updateProperties = false;
- if( info.eventsThisFrame > 0 )
+ if(info.eventsThisFrame > 0)
{
// Some events were read this frame.
mTargetGesture = lastReadGesture;
- if( info.eventsThisFrame > 1 )
+ if(info.eventsThisFrame > 1)
{
- const float eventsThisFrame = static_cast<float>( info.eventsThisFrame );
+ const float eventsThisFrame = static_cast<float>(info.eventsThisFrame);
info.frameGesture.screen.position /= eventsThisFrame;
info.frameGesture.local.position /= eventsThisFrame;
info.frameGesture.screen.velocity /= eventsThisFrame;
info.frameGesture.local.velocity /= eventsThisFrame;
info.frameGesture.screen.displacement = info.frameGesture.screen.position - mLastGesture.screen.position;
- info.frameGesture.local.displacement = info.frameGesture.local.position - mLastGesture.local.position;
+ info.frameGesture.local.displacement = info.frameGesture.local.position - mLastGesture.local.position;
mNotAtTarget = true;
}
else
{
info.frameGesture.screen.displacement = lastReadGesture.screen.displacement;
- info.frameGesture.local.displacement = lastReadGesture.local.displacement;
+ info.frameGesture.local.displacement = lastReadGesture.local.displacement;
}
info.frameGesture.time = currentTimestamp;
else
{
// 0 Events this frame.
- if( mNotAtTarget )
+ if(mNotAtTarget)
{
- mNotAtTarget = false;
+ mNotAtTarget = false;
info.frameGesture = mTargetGesture;
- updateProperties = true;
+ updateProperties = true;
}
else
{
return updateProperties;
}
-bool PanGesture::UpdateProperties( unsigned int lastVSyncTime, unsigned int nextVSyncTime )
+bool PanGesture::UpdateProperties(unsigned int lastVSyncTime, unsigned int nextVSyncTime)
{
- if( mPredictionMode == PREDICTION_2 )
+ if(mPredictionMode == PREDICTION_2)
{
// TODO: Have the two prediction modes share more behavior so some parts of mode 2 can
// be used with mode 1 etc. Needs code moving and more importantly testing.
- return NewAlgorithm( lastVSyncTime, nextVSyncTime );
+ return NewAlgorithm(lastVSyncTime, nextVSyncTime);
}
- if( !mInGesture )
+ if(!mInGesture)
{
// clear current pan history
mPanHistory.clear();
}
FrameGestureInfo frameInfo;
- bool updateProperties = false;
+ bool updateProperties = false;
// Read input data.
// If we are using a form of prediction, read all the input as-is.
- if( mPredictionMode != PREDICTION_NONE )
+ if(mPredictionMode != PREDICTION_NONE)
{
// Read input required for prediction algorithms.
- updateProperties = ReadGestures( frameInfo, lastVSyncTime );
+ updateProperties = ReadGestures(frameInfo, lastVSyncTime);
}
else
{
// Read and resample input.
- updateProperties = ReadAndResampleGestures( frameInfo, lastVSyncTime );
+ updateProperties = ReadAndResampleGestures(frameInfo, lastVSyncTime);
}
- PanInfo frameGesture = frameInfo.frameGesture;
+ PanInfo frameGesture = frameInfo.frameGesture;
PanInfo unmodifiedGesture = frameGesture;
// Process input data.
mInGesture |= frameInfo.justStarted;
- if( mInGesture )
+ if(mInGesture)
{
// Profiling.
- if( mProfiling )
+ if(mProfiling)
{
- mProfiling->mLatestData.push_back( PanGestureProfiling::Position( lastVSyncTime, frameGesture.screen.position,
- frameGesture.screen.displacement, frameGesture.screen.velocity, frameGesture.state ) );
+ mProfiling->mLatestData.push_back(PanGestureProfiling::Position(lastVSyncTime, frameGesture.screen.position, frameGesture.screen.displacement, frameGesture.screen.velocity, frameGesture.state));
}
// Perform prediction.
- if( mPredictionMode == PREDICTION_1 )
+ if(mPredictionMode == PREDICTION_1)
{
// Dynamically change the prediction amount according to the pan velocity acceleration.
- if( !frameInfo.justStarted )
+ if(!frameInfo.justStarted)
{
- if( frameInfo.eventsThisFrame <= 1 )
+ if(frameInfo.eventsThisFrame <= 1)
{
frameInfo.acceleration = frameGesture.screen.velocity.Length() - mLastUnmodifiedGesture.screen.velocity.Length();
}
// Ignore tiny velocity fluctuation to avoid unnecessary prediction amount change
- if( fabsf( frameInfo.acceleration ) > ACCELERATION_THRESHOLD )
+ if(fabsf(frameInfo.acceleration) > ACCELERATION_THRESHOLD)
{
- mCurrentPredictionAmount += static_cast<unsigned int>( static_cast<float>( mPredictionAmountAdjustment ) * ( frameInfo.acceleration > Math::MACHINE_EPSILON_0 ? 1.0f : -1.0f ) );
- if( mCurrentPredictionAmount > mMaxPredictionAmount + mPredictionAmountAdjustment ) // Guard against unsigned int overflow
+ mCurrentPredictionAmount += static_cast<unsigned int>(static_cast<float>(mPredictionAmountAdjustment) * (frameInfo.acceleration > Math::MACHINE_EPSILON_0 ? 1.0f : -1.0f));
+ if(mCurrentPredictionAmount > mMaxPredictionAmount + mPredictionAmountAdjustment) // Guard against unsigned int overflow
{
mCurrentPredictionAmount = 0;
}
}
else
{
- if( !mPredictionAmountOverridden )
+ if(!mPredictionAmountOverridden)
{
// If the prediction amount has not been modified, default to the correct amount for this algorithm.
mPredictionAmount = DEFAULT_PREDICTION_AMOUNT[0];
mCurrentPredictionAmount = mPredictionAmount; // Reset the prediction amount for each new gesture
}
- mCurrentPredictionAmount = std::max( mMinPredictionAmount, std::min( mCurrentPredictionAmount, mMaxPredictionAmount ) );
+ mCurrentPredictionAmount = std::max(mMinPredictionAmount, std::min(mCurrentPredictionAmount, mMaxPredictionAmount));
// Calculate the delta of positions before the prediction
Vector2 deltaPosition = frameGesture.screen.position - mLastUnmodifiedGesture.screen.position;
// Make latest gesture equal to current gesture before interpolation
- PredictionMode1( frameInfo.eventsThisFrame, frameGesture, mPanHistory, lastVSyncTime, nextVSyncTime );
+ PredictionMode1(frameInfo.eventsThisFrame, frameGesture, mPanHistory, lastVSyncTime, nextVSyncTime);
// Calculate the delta of positions after the prediction.
Vector2 deltaPredictedPosition = frameGesture.screen.position - mLastGesture.screen.position;
// to give the user's finger a chance to catch up with where we have panned to.
bool overshotXAxis = false;
bool overshotYAxis = false;
- if( (deltaPosition.x > Math::MACHINE_EPSILON_0 && deltaPredictedPosition.x < Math::MACHINE_EPSILON_0 )
- || (deltaPosition.x < Math::MACHINE_EPSILON_0 && deltaPredictedPosition.x > Math::MACHINE_EPSILON_0 ) )
+ if((deltaPosition.x > Math::MACHINE_EPSILON_0 && deltaPredictedPosition.x < Math::MACHINE_EPSILON_0) || (deltaPosition.x < Math::MACHINE_EPSILON_0 && deltaPredictedPosition.x > Math::MACHINE_EPSILON_0))
{
- overshotXAxis = true;
+ overshotXAxis = true;
frameGesture.screen.position.x = mLastGesture.screen.position.x;
}
- if( (deltaPosition.y > Math::MACHINE_EPSILON_0 && deltaPredictedPosition.y < Math::MACHINE_EPSILON_0 )
- || (deltaPosition.y < Math::MACHINE_EPSILON_0 && deltaPredictedPosition.y > Math::MACHINE_EPSILON_0 ) )
+ if((deltaPosition.y > Math::MACHINE_EPSILON_0 && deltaPredictedPosition.y < Math::MACHINE_EPSILON_0) || (deltaPosition.y < Math::MACHINE_EPSILON_0 && deltaPredictedPosition.y > Math::MACHINE_EPSILON_0))
{
- overshotYAxis = true;
+ overshotYAxis = true;
frameGesture.screen.position.y = mLastGesture.screen.position.y;
}
if(overshotXAxis || overshotYAxis)
{
mCurrentPredictionAmount -= mPredictionAmountAdjustment;
- if( mCurrentPredictionAmount > mMaxPredictionAmount + mPredictionAmountAdjustment ) // Guard against unsigned int overflow
+ if(mCurrentPredictionAmount > mMaxPredictionAmount + mPredictionAmountAdjustment) // Guard against unsigned int overflow
{
mCurrentPredictionAmount = 0;
}
- mCurrentPredictionAmount = std::max( mMinPredictionAmount, std::min( mCurrentPredictionAmount, mMaxPredictionAmount ) );
+ mCurrentPredictionAmount = std::max(mMinPredictionAmount, std::min(mCurrentPredictionAmount, mMaxPredictionAmount));
- if( overshotXAxis && !overshotYAxis )
+ if(overshotXAxis && !overshotYAxis)
{
- frameGesture.screen.position.y = ( mLastGesture.screen.position.y + frameGesture.screen.position.y ) * 0.5f;
+ frameGesture.screen.position.y = (mLastGesture.screen.position.y + frameGesture.screen.position.y) * 0.5f;
}
- if( overshotYAxis && !overshotXAxis )
+ if(overshotYAxis && !overshotXAxis)
{
- frameGesture.screen.position.x = ( mLastGesture.screen.position.x + frameGesture.screen.position.x ) * 0.5f;
+ frameGesture.screen.position.x = (mLastGesture.screen.position.x + frameGesture.screen.position.x) * 0.5f;
}
}
}
// Perform smoothing.
- switch( mSmoothingMode )
+ switch(mSmoothingMode)
{
case SMOOTHING_NONE:
case SMOOTHING_MULTI_TAP:
}
case SMOOTHING_LAST_VALUE:
{
- if( !frameInfo.justStarted )
+ if(!frameInfo.justStarted)
{
- if( !mSmoothingAmountOverridden )
+ if(!mSmoothingAmountOverridden)
{
// If the smoothing amount has not been modified, default to the correct amount for this algorithm.
mSmoothingAmount = DEFAULT_SMOOTHING_AMOUNT[0];
}
- BlendPoints( frameGesture, mLastGesture, mSmoothingAmount );
+ BlendPoints(frameGesture, mLastGesture, mSmoothingAmount);
}
break;
}
}
- if( updateProperties )
+ if(updateProperties)
{
// only update properties if event received
// set latest gesture to raw pan info with unchanged time
- mPanning.Set( mInGesture & !frameInfo.justFinished );
- mScreenPosition.Set( frameGesture.screen.position );
- mScreenDisplacement.Set( frameGesture.screen.displacement );
- mScreenVelocity.Set( frameGesture.screen.velocity );
- mLocalPosition.Set( frameGesture.local.position );
- mLocalDisplacement.Set( frameGesture.local.displacement );
- mLocalVelocity.Set( frameGesture.local.velocity );
+ mPanning.Set(mInGesture & !frameInfo.justFinished);
+ mScreenPosition.Set(frameGesture.screen.position);
+ mScreenDisplacement.Set(frameGesture.screen.displacement);
+ mScreenVelocity.Set(frameGesture.screen.velocity);
+ mLocalPosition.Set(frameGesture.local.position);
+ mLocalDisplacement.Set(frameGesture.local.displacement);
+ mLocalVelocity.Set(frameGesture.local.velocity);
}
- if( mProfiling )
+ if(mProfiling)
{
- mProfiling->mAveragedData.push_back( PanGestureProfiling::Position( frameGesture.time, frameGesture.screen.position,
- frameGesture.screen.displacement, frameGesture.screen.velocity, frameGesture.state ) );
+ mProfiling->mAveragedData.push_back(PanGestureProfiling::Position(frameGesture.time, frameGesture.screen.position, frameGesture.screen.displacement, frameGesture.screen.velocity, frameGesture.state));
}
}
- mLastGesture = frameGesture;
+ mLastGesture = frameGesture;
mLastUnmodifiedGesture = unmodifiedGesture;
mInGesture = mInGesture && !frameInfo.justFinished;
- if( mProfiling && frameInfo.justFinished )
+ if(mProfiling && frameInfo.justFinished)
{
mProfiling->PrintData();
mProfiling->ClearData();
void PanGesture::SetPredictionAmount(unsigned int amount)
{
- mPredictionAmount = amount;
+ mPredictionAmount = amount;
mPredictionAmountOverridden = true;
}
void PanGesture::SetSmoothingAmount(float amount)
{
- mSmoothingAmount = amount;
+ mSmoothingAmount = amount;
mSmoothingAmountOverridden = true;
}
-void PanGesture::SetUseActualTimes( bool value )
+void PanGesture::SetUseActualTimes(bool value)
{
mUseActualTimes = value;
}
-void PanGesture::SetInterpolationTimeRange( int value )
+void PanGesture::SetInterpolationTimeRange(int value)
{
mInterpolationTimeRange = value;
}
-void PanGesture::SetScalarOnlyPredictionEnabled( bool value )
+void PanGesture::SetScalarOnlyPredictionEnabled(bool value)
{
mScalarOnlyPredictionEnabled = value;
}
-void PanGesture::SetTwoPointPredictionEnabled( bool value )
+void PanGesture::SetTwoPointPredictionEnabled(bool value)
{
mTwoPointPredictionEnabled = value;
}
-void PanGesture::SetTwoPointInterpolatePastTime( int value )
+void PanGesture::SetTwoPointInterpolatePastTime(int value)
{
mTwoPointPastInterpolateTime = value;
}
-void PanGesture::SetTwoPointVelocityBias( float value )
+void PanGesture::SetTwoPointVelocityBias(float value)
{
mTwoPointVelocityBias = value;
}
-void PanGesture::SetTwoPointAccelerationBias( float value )
+void PanGesture::SetTwoPointAccelerationBias(float value)
{
mTwoPointAccelerationBias = value;
}
-void PanGesture::SetMultitapSmoothingRange( int value )
+void PanGesture::SetMultitapSmoothingRange(int value)
{
mMultiTapSmoothingRange = value;
}
void PanGesture::EnableProfiling()
{
- if( !mProfiling )
+ if(!mProfiling)
{
mProfiling = new PanGestureProfiling();
}
}
-void PanGesture::ResetDefaultProperties( BufferIndex updateBufferIndex )
+void PanGesture::ResetDefaultProperties(BufferIndex updateBufferIndex)
{
mScreenPosition.Reset();
mScreenDisplacement.Reset();
PanGesture::PanGesture()
: mPanning(),
mGestures(),
- mWritePosition( 0 ),
- mReadPosition( 0 ),
- mNotAtTarget( false ),
- mInGesture( false ),
- mPredictionAmountOverridden( false ),
- mSmoothingAmountOverridden( false ),
- mProfiling( nullptr ),
+ mWritePosition(0),
+ mReadPosition(0),
+ mNotAtTarget(false),
+ mInGesture(false),
+ mPredictionAmountOverridden(false),
+ mSmoothingAmountOverridden(false),
+ mProfiling(nullptr),
// Set environment variable defaults:
- mPredictionMode( DEFAULT_PREDICTION_MODE ),
- mPredictionAmount( DEFAULT_PREDICTION_AMOUNT[0] ),
- mCurrentPredictionAmount( DEFAULT_PREDICTION_AMOUNT[0] ),
- mMaxPredictionAmount( DEFAULT_MAX_PREDICTION_AMOUNT ),
- mMinPredictionAmount( DEFAULT_MIN_PREDICTION_AMOUNT ),
- mPredictionAmountAdjustment( DEFAULT_PREDICTION_AMOUNT_ADJUSTMENT ),
- mSmoothingMode( DEFAULT_SMOOTHING_MODE ),
- mSmoothingAmount( DEFAULT_SMOOTHING_AMOUNT[0] ),
- mUseActualTimes( DEFAULT_USE_ACTUAL_TIMES ),
- mInterpolationTimeRange( DEFAULT_INTERPOLATION_TIME_RANGE ),
- mScalarOnlyPredictionEnabled( DEFAULT_SCALAR_ONLY_PREDICTION_ENABLED ),
- mTwoPointPredictionEnabled( DEFAULT_TWO_POINT_PREDICTION_ENABLED ),
- mTwoPointPastInterpolateTime( DEFAULT_TWO_POINT_PAST_INTERPOLATE_TIME ),
- mTwoPointVelocityBias( DEFAULT_TWO_POINT_VELOCITY_BIAS ),
- mTwoPointAccelerationBias( DEFAULT_TWO_POINT_ACCELERATION_BIAS ),
- mMultiTapSmoothingRange( DEFAULT_MULTITAP_SMOOTHING_RANGE )
+ mPredictionMode(DEFAULT_PREDICTION_MODE),
+ mPredictionAmount(DEFAULT_PREDICTION_AMOUNT[0]),
+ mCurrentPredictionAmount(DEFAULT_PREDICTION_AMOUNT[0]),
+ mMaxPredictionAmount(DEFAULT_MAX_PREDICTION_AMOUNT),
+ mMinPredictionAmount(DEFAULT_MIN_PREDICTION_AMOUNT),
+ mPredictionAmountAdjustment(DEFAULT_PREDICTION_AMOUNT_ADJUSTMENT),
+ mSmoothingMode(DEFAULT_SMOOTHING_MODE),
+ mSmoothingAmount(DEFAULT_SMOOTHING_AMOUNT[0]),
+ mUseActualTimes(DEFAULT_USE_ACTUAL_TIMES),
+ mInterpolationTimeRange(DEFAULT_INTERPOLATION_TIME_RANGE),
+ mScalarOnlyPredictionEnabled(DEFAULT_SCALAR_ONLY_PREDICTION_ENABLED),
+ mTwoPointPredictionEnabled(DEFAULT_TWO_POINT_PREDICTION_ENABLED),
+ mTwoPointPastInterpolateTime(DEFAULT_TWO_POINT_PAST_INTERPOLATE_TIME),
+ mTwoPointVelocityBias(DEFAULT_TWO_POINT_VELOCITY_BIAS),
+ mTwoPointAccelerationBias(DEFAULT_TWO_POINT_ACCELERATION_BIAS),
+ mMultiTapSmoothingRange(DEFAULT_MULTITAP_SMOOTHING_RANGE)
{
-
}
// Prediction mode 2 related code and functions follow:
unsigned int eventsThisFrame;
// Copy the events into a linear buffer while holding the mutex.
// This is so the lock is not held while any processing is done.
- Dali::Mutex::ScopedLock lock( mMutex );
- for( eventsThisFrame = 0; mReadPosition != mWritePosition; ++eventsThisFrame )
+ Dali::Mutex::ScopedLock lock(mMutex);
+ for(eventsThisFrame = 0; mReadPosition != mWritePosition; ++eventsThisFrame)
{
- mReadGestures[ eventsThisFrame ] = mGestures[ mReadPosition ];
+ mReadGestures[eventsThisFrame] = mGestures[mReadPosition];
++mReadPosition;
mReadPosition %= PAN_GESTURE_HISTORY;
}
}
// TODO: eventsThisFrame parameter can be removed if we use a smarter container.
-bool PanGesture::InputRateConversion( PanInfo& rateConvertedGesture, unsigned int eventsThisFrame,
- unsigned int currentFrameTime, unsigned int lastFrameTime, bool& justStarted, bool& justFinished )
+bool PanGesture::InputRateConversion(PanInfo& rateConvertedGesture, unsigned int eventsThisFrame, unsigned int currentFrameTime, unsigned int lastFrameTime, bool& justStarted, bool& justFinished)
{
// TODO: Lots of variables on the stack. Needs optimizing.
- PanInfo readGesture;
- PanInfo firstReadGesture;
+ PanInfo readGesture;
+ PanInfo firstReadGesture;
unsigned int eventsKeptThisFrame = 0;
- for( unsigned int readPosition = 0; readPosition < eventsThisFrame; ++readPosition )
+ for(unsigned int readPosition = 0; readPosition < eventsThisFrame; ++readPosition)
{
// Copy the gesture first
- readGesture = mReadGestures[ readPosition ];
+ readGesture = mReadGestures[readPosition];
- if( mProfiling )
+ if(mProfiling)
{
- mProfiling->mRawData.push_back( PanGestureProfiling::Position( readGesture.time, readGesture.screen.position,
- readGesture.screen.displacement, readGesture.screen.velocity, readGesture.state ) );
+ mProfiling->mRawData.push_back(PanGestureProfiling::Position(readGesture.time, readGesture.screen.position, readGesture.screen.displacement, readGesture.screen.velocity, readGesture.state));
}
- if( readGesture.state == GestureState::STARTED )
+ if(readGesture.state == GestureState::STARTED)
{
// Clear pan data.
mPanHistory.clear();
mPredictionHistory.clear();
- mLastAcceleration.local = Vector2::ZERO;
- mLastAcceleration.screen = Vector2::ZERO;
- mLastInterpolatedAcceleration.local = Vector2::ZERO;
+ mLastAcceleration.local = Vector2::ZERO;
+ mLastAcceleration.screen = Vector2::ZERO;
+ mLastInterpolatedAcceleration.local = Vector2::ZERO;
mLastInterpolatedAcceleration.screen = Vector2::ZERO;
- mLastInitialAcceleration.local = Vector2::ZERO;
- mLastInitialAcceleration.screen = Vector2::ZERO;
+ mLastInitialAcceleration.local = Vector2::ZERO;
+ mLastInitialAcceleration.screen = Vector2::ZERO;
PanInfo startInfo;
- mLastGesture = startInfo;
+ mLastGesture = startInfo;
mLastSecondInterpolatedPoint = startInfo;
- mLastPredictedPoint = startInfo;
- mLastFrameReadGesture = startInfo;
- rateConvertedGesture = startInfo;
- firstReadGesture = readGesture;
- eventsKeptThisFrame = 0;
- mNotAtTarget = false;
- justFinished = false;
- justStarted = true;
- mInGesture = true;
-
- if( !mPredictionAmountOverridden )
+ mLastPredictedPoint = startInfo;
+ mLastFrameReadGesture = startInfo;
+ rateConvertedGesture = startInfo;
+ firstReadGesture = readGesture;
+ eventsKeptThisFrame = 0;
+ mNotAtTarget = false;
+ justFinished = false;
+ justStarted = true;
+ mInGesture = true;
+
+ if(!mPredictionAmountOverridden)
{
// If the prediction amount has not been modified, default to the correct amount for this algorithm.
mPredictionAmount = DEFAULT_PREDICTION_AMOUNT[1];
}
else
{
- justFinished |= ( readGesture.state == GestureState::FINISHED || readGesture.state == GestureState::CANCELLED );
+ justFinished |= (readGesture.state == GestureState::FINISHED || readGesture.state == GestureState::CANCELLED);
}
rateConvertedGesture.screen.position += readGesture.screen.position;
}
bool storeGesture = false;
- if( eventsKeptThisFrame > 0 )
+ if(eventsKeptThisFrame > 0)
{
// Some events were read this frame.
- if( eventsKeptThisFrame > 1 )
+ if(eventsKeptThisFrame > 1)
{
- const float eventDivisor = static_cast<float>( eventsKeptThisFrame );
+ const float eventDivisor = static_cast<float>(eventsKeptThisFrame);
rateConvertedGesture.screen.position /= eventDivisor;
rateConvertedGesture.local.position /= eventDivisor;
rateConvertedGesture.screen.velocity /= eventDivisor;
rateConvertedGesture.local.displacement /= eventDivisor;
mTargetGesture = readGesture;
- mNotAtTarget = true;
+ mNotAtTarget = true;
}
else
{
}
rateConvertedGesture.time = currentFrameTime;
- storeGesture = true;
+ storeGesture = true;
}
else
{
// We did not get any event this frame.
// If we just started (or aren't in a gesture), exit.
- if( !mInGesture || justStarted )
+ if(!mInGesture || justStarted)
{
// We cannot guess what the event could be as we have no other events to base the guess from.
return false;
}
// As we are currently in a gesture, we can estimate an event.
- readGesture = mLastFrameReadGesture;
+ readGesture = mLastFrameReadGesture;
readGesture.time = currentFrameTime;
// Take the last event, halve the acceleration, and use that.
const float accelerationDegrade = 2.0f;
- Vector2 degradedAccelerationLocal( mLastAcceleration.local /= accelerationDegrade );
- Vector2 degradedAccelerationScreen( mLastAcceleration.screen /= accelerationDegrade );
+ Vector2 degradedAccelerationLocal(mLastAcceleration.local /= accelerationDegrade);
+ Vector2 degradedAccelerationScreen(mLastAcceleration.screen /= accelerationDegrade);
- float outputTimeGranularity( GetDivisibleTimeDifference( currentFrameTime, lastFrameTime, 1.0f, OUTPUT_TIME_DIFFERENCE ) );
+ float outputTimeGranularity(GetDivisibleTimeDifference(currentFrameTime, lastFrameTime, 1.0f, OUTPUT_TIME_DIFFERENCE));
- readGesture.local.velocity = degradedAccelerationLocal * outputTimeGranularity;
- readGesture.local.displacement = readGesture.local.velocity * outputTimeGranularity;
- readGesture.local.position = mLastFrameReadGesture.local.position + readGesture.local.displacement;
- readGesture.screen.velocity = degradedAccelerationScreen * outputTimeGranularity;
+ readGesture.local.velocity = degradedAccelerationLocal * outputTimeGranularity;
+ readGesture.local.displacement = readGesture.local.velocity * outputTimeGranularity;
+ readGesture.local.position = mLastFrameReadGesture.local.position + readGesture.local.displacement;
+ readGesture.screen.velocity = degradedAccelerationScreen * outputTimeGranularity;
readGesture.screen.displacement = readGesture.screen.velocity * outputTimeGranularity;
- readGesture.screen.position = mLastFrameReadGesture.screen.position + readGesture.screen.displacement;
+ readGesture.screen.position = mLastFrameReadGesture.screen.position + readGesture.screen.displacement;
rateConvertedGesture = readGesture;
- eventsKeptThisFrame = 1;
- storeGesture = true;
+ eventsKeptThisFrame = 1;
+ storeGesture = true;
}
- if( eventsKeptThisFrame > 0 )
+ if(eventsKeptThisFrame > 0)
{
// Store last read gesture.
- readGesture.time = currentFrameTime;
+ readGesture.time = currentFrameTime;
mLastFrameReadGesture = readGesture;
- if( eventsKeptThisFrame > 2 )
+ if(eventsKeptThisFrame > 2)
{
- DALI_LOG_WARNING( "Got events this frame:%d (more than 2 will compromise result)\n", eventsKeptThisFrame );
+ DALI_LOG_WARNING("Got events this frame:%d (more than 2 will compromise result)\n", eventsKeptThisFrame);
}
}
- if( storeGesture )
+ if(storeGesture)
{
// Store final converted result.
- mPanHistory.push_back( rateConvertedGesture );
+ mPanHistory.push_back(rateConvertedGesture);
}
return true;
}
-bool PanGesture::InterpolatePoint( PanInfoHistory& history, unsigned int currentTime, unsigned int targetTime, unsigned int range,
- PanInfo& outPoint, RelativeVectors& acceleration, int outputTimeGranularity, bool eraseUnused )
+bool PanGesture::InterpolatePoint(PanInfoHistory& history, unsigned int currentTime, unsigned int targetTime, unsigned int range, PanInfo& outPoint, RelativeVectors& acceleration, int outputTimeGranularity, bool eraseUnused)
{
- unsigned int maxHistoryTime = targetTime - range;
- unsigned int tapsUsed = 0;
- outPoint.time = targetTime;
- float divisor = 0.0f;
- float accelerationDivisor = 0.0f;
- PanInfoHistoryIter historyBegin = history.begin();
- PanInfoHistoryIter lastIt = history.end();
- bool pointGenerated = false;
- bool havePreviousPoint = false;
- RelativeVectors newAcceleration;
+ unsigned int maxHistoryTime = targetTime - range;
+ unsigned int tapsUsed = 0;
+ outPoint.time = targetTime;
+ float divisor = 0.0f;
+ float accelerationDivisor = 0.0f;
+ PanInfoHistoryIter historyBegin = history.begin();
+ PanInfoHistoryIter lastIt = history.end();
+ bool pointGenerated = false;
+ bool havePreviousPoint = false;
+ RelativeVectors newAcceleration;
// Iterate through point history to perform interpolation.
- for( PanInfoHistoryIter it = historyBegin; it != history.end(); )
+ for(PanInfoHistoryIter it = historyBegin; it != history.end();)
{
unsigned int gestureTime = it->time;
- if( gestureTime < maxHistoryTime )
+ if(gestureTime < maxHistoryTime)
{
// Too far in the past, discard.
// Clean history as we go (if requested).
- if( eraseUnused )
+ if(eraseUnused)
{
- it = history.erase( it );
+ it = history.erase(it);
}
else
{
}
else
{
- float timeDelta( static_cast<float>( abs( int( targetTime - gestureTime ) ) ) );
+ float timeDelta(static_cast<float>(abs(int(targetTime - gestureTime))));
// Handle low time deltas.
- if( timeDelta < 1.0f )
+ if(timeDelta < 1.0f)
{
timeDelta = 1.0f;
}
divisor += 1.0f / timeDelta;
// Acceleration requires a previous point.
- if( havePreviousPoint )
+ if(havePreviousPoint)
{
// Time delta of input.
- float timeDifference( GetDivisibleTimeDifference( it->time, lastIt->time, 1.0f, OUTPUT_TIME_DIFFERENCE ) );
+ float timeDifference(GetDivisibleTimeDifference(it->time, lastIt->time, 1.0f, OUTPUT_TIME_DIFFERENCE));
- newAcceleration.local += ( ( it->local.velocity - lastIt->local.velocity ) / timeDifference ) / timeDelta;
- newAcceleration.screen += ( ( it->screen.velocity - lastIt->screen.velocity ) / timeDifference ) / timeDelta;
+ newAcceleration.local += ((it->local.velocity - lastIt->local.velocity) / timeDifference) / timeDelta;
+ newAcceleration.screen += ((it->screen.velocity - lastIt->screen.velocity) / timeDifference) / timeDelta;
accelerationDivisor += 1.0f / timeDelta;
}
}
// Divide results by their respective divisors.
- if( tapsUsed > 0 )
+ if(tapsUsed > 0)
{
- if( divisor > 0.0f )
+ if(divisor > 0.0f)
{
outPoint.local.position /= divisor;
outPoint.screen.position /= divisor;
outPoint.screen.displacement /= divisor;
}
- if( tapsUsed > 1 )
+ if(tapsUsed > 1)
{
- if( accelerationDivisor > 0.0f )
+ if(accelerationDivisor > 0.0f)
{
newAcceleration.local /= accelerationDivisor;
newAcceleration.screen /= accelerationDivisor;
}
- float accelerationSmoothing( ACCELERATION_SMOOTHING );
- newAcceleration.local = ( acceleration.local * accelerationSmoothing ) + ( newAcceleration.local * ( 1.0f - accelerationSmoothing ) );
- newAcceleration.screen = ( acceleration.screen * accelerationSmoothing ) + ( newAcceleration.screen * ( 1.0f - accelerationSmoothing ) );
+ float accelerationSmoothing(ACCELERATION_SMOOTHING);
+ newAcceleration.local = (acceleration.local * accelerationSmoothing) + (newAcceleration.local * (1.0f - accelerationSmoothing));
+ newAcceleration.screen = (acceleration.screen * accelerationSmoothing) + (newAcceleration.screen * (1.0f - accelerationSmoothing));
}
else
{
// If we just started, last velocity was 0. So difference of zero to current velocity over time gives acceleration of the first point.
- newAcceleration.local = outPoint.local.velocity / static_cast<float>( outputTimeGranularity );
- newAcceleration.screen = outPoint.screen.velocity / static_cast<float>( outputTimeGranularity );
+ newAcceleration.local = outPoint.local.velocity / static_cast<float>(outputTimeGranularity);
+ newAcceleration.screen = outPoint.screen.velocity / static_cast<float>(outputTimeGranularity);
}
pointGenerated = true;
}
- acceleration.local = newAcceleration.local;
+ acceleration.local = newAcceleration.local;
acceleration.screen = newAcceleration.screen;
return pointGenerated;
}
-float PanGesture::GetDivisibleTimeDifference( int timeA, int timeB, float minimumDelta, float overrideDifference )
+float PanGesture::GetDivisibleTimeDifference(int timeA, int timeB, float minimumDelta, float overrideDifference)
{
- float timeDifference( overrideDifference );
- if( mUseActualTimes )
+ float timeDifference(overrideDifference);
+ if(mUseActualTimes)
{
- timeDifference = static_cast<float>( abs( timeA - timeB ) );
- if( timeDifference < minimumDelta )
+ timeDifference = static_cast<float>(abs(timeA - timeB));
+ if(timeDifference < minimumDelta)
{
timeDifference = minimumDelta;
}
return timeDifference;
}
-void PanGesture::LimitAccelerationChange( RelativeVectors& currentAcceleration, RelativeVectors& lastAcceleration, float changeLimit )
+void PanGesture::LimitAccelerationChange(RelativeVectors& currentAcceleration, RelativeVectors& lastAcceleration, float changeLimit)
{
// We don't use the float parameter version of clamp here, as that will create the capping vectors twice in total.
- Vector2 capMinimum( -changeLimit, -changeLimit );
- Vector2 capMaximum( changeLimit, changeLimit );
- Vector2 accelerationDeltaLocal( currentAcceleration.local - lastAcceleration.local );
- Vector2 accelerationDeltaScreen( currentAcceleration.screen - lastAcceleration.screen );
- accelerationDeltaLocal.Clamp( capMinimum, capMaximum );
- accelerationDeltaScreen.Clamp( capMinimum, capMaximum );
- currentAcceleration.local = lastAcceleration.local + accelerationDeltaLocal;
+ Vector2 capMinimum(-changeLimit, -changeLimit);
+ Vector2 capMaximum(changeLimit, changeLimit);
+ Vector2 accelerationDeltaLocal(currentAcceleration.local - lastAcceleration.local);
+ Vector2 accelerationDeltaScreen(currentAcceleration.screen - lastAcceleration.screen);
+ accelerationDeltaLocal.Clamp(capMinimum, capMaximum);
+ accelerationDeltaScreen.Clamp(capMinimum, capMaximum);
+ currentAcceleration.local = lastAcceleration.local + accelerationDeltaLocal;
currentAcceleration.screen = lastAcceleration.screen + accelerationDeltaScreen;
}
-void PanGesture::PredictionMode2( PanInfo& startPoint, RelativeVectors& accelerationToUse,
- PanInfo& predictedPoint, unsigned int currentFrameTime, unsigned int previousFrameTime, bool noPreviousData )
+void PanGesture::PredictionMode2(PanInfo& startPoint, RelativeVectors& accelerationToUse, PanInfo& predictedPoint, unsigned int currentFrameTime, unsigned int previousFrameTime, bool noPreviousData)
{
// Do the prediction (based on mode).
- if( mScalarOnlyPredictionEnabled )
+ if(mScalarOnlyPredictionEnabled)
{
// We are doing scalar based prediction.
// This divisor is to help tuning by giving the scalar only result
// a similar prediction amount to the integrated result.
- float scalarVelocityMultiplier = static_cast<float>( mCurrentPredictionAmount ) / 1.364f;
- predictedPoint.local.position = startPoint.local.position + ( startPoint.local.velocity * scalarVelocityMultiplier );
- predictedPoint.screen.position = startPoint.screen.position + ( startPoint.screen.velocity * scalarVelocityMultiplier );
+ float scalarVelocityMultiplier = static_cast<float>(mCurrentPredictionAmount) / 1.364f;
+ predictedPoint.local.position = startPoint.local.position + (startPoint.local.velocity * scalarVelocityMultiplier);
+ predictedPoint.screen.position = startPoint.screen.position + (startPoint.screen.velocity * scalarVelocityMultiplier);
}
else
{
// We are doing integration based prediction.
- float predictionDelta = static_cast<float>( mCurrentPredictionAmount );
+ float predictionDelta = static_cast<float>(mCurrentPredictionAmount);
- predictedPoint.local.position = startPoint.local.position + ( startPoint.local.velocity * predictionDelta ) +
- ( accelerationToUse.local * ( predictionDelta * predictionDelta * 0.5f ) );
- predictedPoint.screen.position = startPoint.screen.position + ( startPoint.screen.velocity * predictionDelta ) +
- ( accelerationToUse.screen * ( predictionDelta * predictionDelta * 0.5f ) );
+ predictedPoint.local.position = startPoint.local.position + (startPoint.local.velocity * predictionDelta) +
+ (accelerationToUse.local * (predictionDelta * predictionDelta * 0.5f));
+ predictedPoint.screen.position = startPoint.screen.position + (startPoint.screen.velocity * predictionDelta) +
+ (accelerationToUse.screen * (predictionDelta * predictionDelta * 0.5f));
}
// Calculate remaining gesture data from the result.
- float timeDifference( GetDivisibleTimeDifference( currentFrameTime, previousFrameTime, 1.0f, OUTPUT_TIME_DIFFERENCE ) );
- if( noPreviousData )
+ float timeDifference(GetDivisibleTimeDifference(currentFrameTime, previousFrameTime, 1.0f, OUTPUT_TIME_DIFFERENCE));
+ if(noPreviousData)
{
- predictedPoint.local.displacement = predictedPoint.local.position - startPoint.local.position;
+ predictedPoint.local.displacement = predictedPoint.local.position - startPoint.local.position;
predictedPoint.screen.displacement = predictedPoint.screen.position - startPoint.screen.position;
}
else
{
- predictedPoint.local.displacement = predictedPoint.local.position - mLastPredictedPoint.local.position;
+ predictedPoint.local.displacement = predictedPoint.local.position - mLastPredictedPoint.local.position;
predictedPoint.screen.displacement = predictedPoint.screen.position - mLastPredictedPoint.screen.position;
}
- predictedPoint.local.velocity = predictedPoint.local.displacement / timeDifference;
+ predictedPoint.local.velocity = predictedPoint.local.displacement / timeDifference;
predictedPoint.screen.velocity = predictedPoint.screen.displacement / timeDifference;
// TODO: Experimental - not used at run time. Left in code for reference only.
- if( TEST_TUNE_ENABLE_OVERSHOOT_PROTECTION )
+ if(TEST_TUNE_ENABLE_OVERSHOOT_PROTECTION)
{
// Overshoot protection
- if( !noPreviousData )
+ if(!noPreviousData)
{
- if( ( mLastPredictedPoint.local.velocity.x > Math::MACHINE_EPSILON_0 && predictedPoint.local.velocity.x < Math::MACHINE_EPSILON_0 )
- || ( mLastPredictedPoint.local.velocity.x < Math::MACHINE_EPSILON_0 && predictedPoint.local.velocity.x > Math::MACHINE_EPSILON_0 ) )
+ if((mLastPredictedPoint.local.velocity.x > Math::MACHINE_EPSILON_0 && predictedPoint.local.velocity.x < Math::MACHINE_EPSILON_0) || (mLastPredictedPoint.local.velocity.x < Math::MACHINE_EPSILON_0 && predictedPoint.local.velocity.x > Math::MACHINE_EPSILON_0))
{
- predictedPoint.local.position.x = mLastPredictedPoint.local.position.x;
+ predictedPoint.local.position.x = mLastPredictedPoint.local.position.x;
predictedPoint.screen.position.x = mLastPredictedPoint.screen.position.x;
mPredictionHistory.clear();
}
- if( ( mLastPredictedPoint.local.velocity.y > Math::MACHINE_EPSILON_0 && predictedPoint.local.velocity.y < Math::MACHINE_EPSILON_0 )
- || ( mLastPredictedPoint.local.velocity.y < Math::MACHINE_EPSILON_0 && predictedPoint.local.velocity.y > Math::MACHINE_EPSILON_0 ) )
+ if((mLastPredictedPoint.local.velocity.y > Math::MACHINE_EPSILON_0 && predictedPoint.local.velocity.y < Math::MACHINE_EPSILON_0) || (mLastPredictedPoint.local.velocity.y < Math::MACHINE_EPSILON_0 && predictedPoint.local.velocity.y > Math::MACHINE_EPSILON_0))
{
- predictedPoint.local.position.y = mLastPredictedPoint.local.position.y;
+ predictedPoint.local.position.y = mLastPredictedPoint.local.position.y;
predictedPoint.screen.position.y = mLastPredictedPoint.screen.position.y;
mPredictionHistory.clear();
}
// 2) To make it less confusing as there is a function that does prediction alone called PerformPredictionMode2.
// Ultimately we need to combine the old and new code modularly so there is one code path that can optionally run different functions based on configuration.
// At the moment, the differences between the inputs & outputs of these different functions prevent that, but this can be resolved.
-bool PanGesture::NewAlgorithm( unsigned int lastVSyncTime, unsigned int nextVSyncTime )
+bool PanGesture::NewAlgorithm(unsigned int lastVSyncTime, unsigned int nextVSyncTime)
{
- if( !mInGesture )
+ if(!mInGesture)
{
// clear current pan history
mPanHistory.clear();
#### This also populates the pan history.
#########################################################################################*/
- bool justStarted = false;
- bool justFinished = false;
+ bool justStarted = false;
+ bool justFinished = false;
PanInfo rateConvertedGesture;
- if( !InputRateConversion( rateConvertedGesture, eventsThisFrame, nextVSyncTime, lastVSyncTime, justStarted, justFinished ) )
+ if(!InputRateConversion(rateConvertedGesture, eventsThisFrame, nextVSyncTime, lastVSyncTime, justStarted, justFinished))
{
// There's nothing we can do with the input, exit.
return false;
#### If we are in gesture, Get first interpolated point with: target time = current time
#########################################################################################*/
- bool performUpdate = false;
+ bool performUpdate = false;
RelativeVectors currentAcceleration;
- currentAcceleration.local = mLastInitialAcceleration.local;
+ currentAcceleration.local = mLastInitialAcceleration.local;
currentAcceleration.screen = mLastInitialAcceleration.screen;
- if( mInGesture || justStarted )
+ if(mInGesture || justStarted)
{
// Get first interpolated point.
// TODO: Erase time should be maximum of both interpolated point ranges in past.
PanInfo targetPoint;
- float outputTimeGranularity( GetDivisibleTimeDifference( nextVSyncTime, lastVSyncTime, 1.0f, OUTPUT_TIME_DIFFERENCE ) );
- bool pointGenerated = InterpolatePoint( mPanHistory, nextVSyncTime, nextVSyncTime, mInterpolationTimeRange,
- targetPoint, currentAcceleration, static_cast<int>( outputTimeGranularity ), true ); // truncated
- if( pointGenerated )
+ float outputTimeGranularity(GetDivisibleTimeDifference(nextVSyncTime, lastVSyncTime, 1.0f, OUTPUT_TIME_DIFFERENCE));
+ bool pointGenerated = InterpolatePoint(mPanHistory, nextVSyncTime, nextVSyncTime, mInterpolationTimeRange, targetPoint, currentAcceleration, static_cast<int>(outputTimeGranularity), true); // truncated
+ if(pointGenerated)
{
- mLastInitialAcceleration.local = currentAcceleration.local;
+ mLastInitialAcceleration.local = currentAcceleration.local;
mLastInitialAcceleration.screen = currentAcceleration.screen;
- performUpdate = true;
+ performUpdate = true;
}
else
{
- targetPoint = rateConvertedGesture;
- currentAcceleration.local = mLastInitialAcceleration.local;
+ targetPoint = rateConvertedGesture;
+ currentAcceleration.local = mLastInitialAcceleration.local;
currentAcceleration.screen = mLastInitialAcceleration.screen;
// TODO: Potentially do something to substitute lack of generated point (and perform update).
}
#### Limit the change of acceleration of the first interpolated point since last time
#########################################################################################*/
- if( !justStarted )
+ if(!justStarted)
{
- LimitAccelerationChange( currentAcceleration, mLastAcceleration, ACCELERATION_CAP );
+ LimitAccelerationChange(currentAcceleration, mLastAcceleration, ACCELERATION_CAP);
}
- mLastAcceleration.local = currentAcceleration.local;
+ mLastAcceleration.local = currentAcceleration.local;
mLastAcceleration.screen = currentAcceleration.screen;
/*#########################################################################################
#### Get second interpolated point, and blend the resultant velocity and acceleration (optional)
#########################################################################################*/
- PanInfo outPoint;
+ PanInfo outPoint;
RelativeVectors interpolatedAcceleration;
- if( mTwoPointPredictionEnabled )
+ if(mTwoPointPredictionEnabled)
{
// Get second interpolated point with target time = current time - past interpolate time.
- unsigned int pastInterpolateTime = nextVSyncTime - mTwoPointPastInterpolateTime;
- PanInfo outPoint;
+ unsigned int pastInterpolateTime = nextVSyncTime - mTwoPointPastInterpolateTime;
+ PanInfo outPoint;
RelativeVectors interpolatedAcceleration;
- interpolatedAcceleration.local = mLastInterpolatedAcceleration.local;
+ interpolatedAcceleration.local = mLastInterpolatedAcceleration.local;
interpolatedAcceleration.screen = mLastInterpolatedAcceleration.screen;
- if( !InterpolatePoint( mPanHistory, nextVSyncTime, pastInterpolateTime, mTwoPointPastInterpolateTime,
- outPoint, interpolatedAcceleration, static_cast<int>( outputTimeGranularity ), false ) ) // truncated
+ if(!InterpolatePoint(mPanHistory, nextVSyncTime, pastInterpolateTime, mTwoPointPastInterpolateTime, outPoint, interpolatedAcceleration, static_cast<int>(outputTimeGranularity), false)) // truncated
{
- if( justStarted )
+ if(justStarted)
{
outPoint = targetPoint;
}
outPoint = mLastSecondInterpolatedPoint;
}
}
- mLastInterpolatedAcceleration.local = interpolatedAcceleration.local;
+ mLastInterpolatedAcceleration.local = interpolatedAcceleration.local;
mLastInterpolatedAcceleration.screen = interpolatedAcceleration.screen;
- mLastSecondInterpolatedPoint = outPoint;
+ mLastSecondInterpolatedPoint = outPoint;
// Combine the first interpolated point and the second interpolated point.
// by mixing them with the configured amount. This is done for acceleration and velocity.
// It could be optionally done for position too, but this typically is worse as it means we have to predict further ahead.
- float currentVelocityMultiplier( 1.0f - mTwoPointVelocityBias );
- float lastVelocityMultiplier( mTwoPointVelocityBias );
- targetPoint.local.velocity = ( outPoint.local.velocity * lastVelocityMultiplier ) + ( targetPoint.local.velocity * currentVelocityMultiplier );
- targetPoint.screen.velocity = ( outPoint.screen.velocity * lastVelocityMultiplier ) + ( targetPoint.screen.velocity * currentVelocityMultiplier );
- float currentAccelerationMultiplier( 1.0f - mTwoPointAccelerationBias );
- float lastAccelerationMultiplier( mTwoPointAccelerationBias );
- currentAcceleration.local = ( interpolatedAcceleration.local * lastAccelerationMultiplier ) + ( currentAcceleration.local * currentAccelerationMultiplier );
- currentAcceleration.screen = ( interpolatedAcceleration.screen * lastAccelerationMultiplier ) + ( currentAcceleration.screen * currentAccelerationMultiplier );
+ float currentVelocityMultiplier(1.0f - mTwoPointVelocityBias);
+ float lastVelocityMultiplier(mTwoPointVelocityBias);
+ targetPoint.local.velocity = (outPoint.local.velocity * lastVelocityMultiplier) + (targetPoint.local.velocity * currentVelocityMultiplier);
+ targetPoint.screen.velocity = (outPoint.screen.velocity * lastVelocityMultiplier) + (targetPoint.screen.velocity * currentVelocityMultiplier);
+ float currentAccelerationMultiplier(1.0f - mTwoPointAccelerationBias);
+ float lastAccelerationMultiplier(mTwoPointAccelerationBias);
+ currentAcceleration.local = (interpolatedAcceleration.local * lastAccelerationMultiplier) + (currentAcceleration.local * currentAccelerationMultiplier);
+ currentAcceleration.screen = (interpolatedAcceleration.screen * lastAccelerationMultiplier) + (currentAcceleration.screen * currentAccelerationMultiplier);
}
/*#########################################################################################
#########################################################################################*/
PanInfo predictedPoint;
- PredictionMode2( targetPoint, currentAcceleration, predictedPoint, nextVSyncTime, lastVSyncTime, justStarted );
+ PredictionMode2(targetPoint, currentAcceleration, predictedPoint, nextVSyncTime, lastVSyncTime, justStarted);
targetPoint = predictedPoint;
/*#########################################################################################
#########################################################################################*/
// If we are using multi-tap smoothing, keep a history of predicted results.
- if( mSmoothingMode == SMOOTHING_MULTI_TAP )
+ if(mSmoothingMode == SMOOTHING_MULTI_TAP)
{
- mPredictionHistory.push_back( targetPoint );
+ mPredictionHistory.push_back(targetPoint);
}
- if( !justStarted )
+ if(!justStarted)
{
- float outputTimeGranularity( GetDivisibleTimeDifference( nextVSyncTime, lastVSyncTime, 1.0f, OUTPUT_TIME_DIFFERENCE ) );
- if( mSmoothingMode == SMOOTHING_MULTI_TAP )
+ float outputTimeGranularity(GetDivisibleTimeDifference(nextVSyncTime, lastVSyncTime, 1.0f, OUTPUT_TIME_DIFFERENCE));
+ if(mSmoothingMode == SMOOTHING_MULTI_TAP)
{
// Perform Multi-tap Smoothing.
RelativeVectors blank;
- InterpolatePoint( mPredictionHistory, nextVSyncTime, nextVSyncTime, mMultiTapSmoothingRange,
- targetPoint, blank, static_cast<int>( outputTimeGranularity ), true ); // truncated
+ InterpolatePoint(mPredictionHistory, nextVSyncTime, nextVSyncTime, mMultiTapSmoothingRange, targetPoint, blank, static_cast<int>(outputTimeGranularity), true); // truncated
}
else
{
// Perform Single-tap Smoothing.
- if( !mSmoothingAmountOverridden )
+ if(!mSmoothingAmountOverridden)
{
// If the smoothing amount has not been modified, default to the correct amount for this algorithm.
mSmoothingAmount = DEFAULT_SMOOTHING_AMOUNT[1];
}
- BlendPoints( targetPoint, mLastGesture, mSmoothingAmount );
+ BlendPoints(targetPoint, mLastGesture, mSmoothingAmount);
}
/*#########################################################################################
#### Finalize other point data (from position)
#########################################################################################*/
- targetPoint.local.displacement = targetPoint.local.position - mLastGesture.local.position;
- targetPoint.local.velocity = targetPoint.local.displacement / outputTimeGranularity;
+ targetPoint.local.displacement = targetPoint.local.position - mLastGesture.local.position;
+ targetPoint.local.velocity = targetPoint.local.displacement / outputTimeGranularity;
targetPoint.screen.displacement = targetPoint.screen.position - mLastGesture.screen.position;
- targetPoint.screen.velocity = targetPoint.screen.displacement / outputTimeGranularity;
+ targetPoint.screen.velocity = targetPoint.screen.displacement / outputTimeGranularity;
}
/*#########################################################################################
#### (Constraints will automatically react to this)
#########################################################################################*/
- if( performUpdate )
+ if(performUpdate)
{
- mPanning.Set( mInGesture & !justFinished );
- mScreenPosition.Set( targetPoint.screen.position );
- mScreenDisplacement.Set( targetPoint.screen.displacement );
- mScreenVelocity.Set( targetPoint.screen.velocity );
- mLocalPosition.Set( targetPoint.local.position );
- mLocalDisplacement.Set( targetPoint.local.displacement );
- mLocalVelocity.Set( targetPoint.local.velocity );
+ mPanning.Set(mInGesture & !justFinished);
+ mScreenPosition.Set(targetPoint.screen.position);
+ mScreenDisplacement.Set(targetPoint.screen.displacement);
+ mScreenVelocity.Set(targetPoint.screen.velocity);
+ mLocalPosition.Set(targetPoint.local.position);
+ mLocalDisplacement.Set(targetPoint.local.displacement);
+ mLocalVelocity.Set(targetPoint.local.velocity);
mLastGesture = targetPoint;
- if( mProfiling )
+ if(mProfiling)
{
- mProfiling->mAveragedData.push_back( PanGestureProfiling::Position( targetPoint.time, targetPoint.screen.position,
- targetPoint.screen.displacement, targetPoint.screen.velocity, targetPoint.state ) );
+ mProfiling->mAveragedData.push_back(PanGestureProfiling::Position(targetPoint.time, targetPoint.screen.position, targetPoint.screen.displacement, targetPoint.screen.velocity, targetPoint.state));
}
}
}
return performUpdate;
}
-
} // namespace SceneGraph
} // namespace Internal
#define DALI_INTERNAL_SCENE_GRAPH_PAN_GESTURE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/devel-api/threading/mutex.h>
-#include <dali/public-api/common/vector-wrapper.h>
#include <dali/internal/event/events/pan-gesture/pan-gesture-impl.h>
#include <dali/internal/update/common/property-owner.h>
#include <dali/internal/update/gestures/gesture-properties.h>
+#include <dali/public-api/common/vector-wrapper.h>
namespace Dali
{
-
class PanGesture;
namespace Internal
{
-
struct PanGestureProfiling;
namespace SceneGraph
{
-
/**
* The latest pan gesture information is stored in this scene object.
*/
class PanGesture : public PropertyOwner
{
public:
-
enum PredictionMode
{
PREDICTION_NONE = 0,
enum SmoothingMode
{
- SMOOTHING_NONE, // No smoothing.
- SMOOTHING_LAST_VALUE, // Smooth between last value and latest value.
- SMOOTHING_MULTI_TAP, // Uses multitap smoothing, only available with Prediction mode 2.
+ SMOOTHING_NONE, // No smoothing.
+ SMOOTHING_LAST_VALUE, // Smooth between last value and latest value.
+ SMOOTHING_MULTI_TAP, // Uses multitap smoothing, only available with Prediction mode 2.
};
static const PredictionMode DEFAULT_PREDICTION_MODE;
- static const int NUM_PREDICTION_MODES;
+ static const int NUM_PREDICTION_MODES;
static const SmoothingMode DEFAULT_SMOOTHING_MODE;
- static const int NUM_SMOOTHING_MODES;
+ static const int NUM_SMOOTHING_MODES;
// Latest Pan Information
/**
* Assignment operator
*/
- Info& operator=( const Info& rhs )
+ Info& operator=(const Info& rhs)
{
- if( this != &rhs )
+ if(this != &rhs)
{
- velocity = rhs.velocity;
+ velocity = rhs.velocity;
displacement = rhs.displacement;
- position = rhs.position;
+ position = rhs.position;
}
return *this;
* Constructor
*/
PanInfo()
- : time( 0u ),
- state( GestureState::CLEAR ),
- read( true )
+ : time(0u),
+ state(GestureState::CLEAR),
+ read(true)
{
}
/**
* Copy constructor
*/
- PanInfo( const PanInfo& rhs )
- : time( rhs.time ),
- state( rhs.state ),
- local( rhs.local ),
- screen( rhs.screen ),
- read( true )
+ PanInfo(const PanInfo& rhs)
+ : time(rhs.time),
+ state(rhs.state),
+ local(rhs.local),
+ screen(rhs.screen),
+ read(true)
{
}
/**
* Assignment operator
*/
- PanInfo& operator=( const PanInfo& rhs )
+ PanInfo& operator=(const PanInfo& rhs)
{
- if( this != &rhs )
+ if(this != &rhs)
{
- time = rhs.time;
- state = rhs.state;
- local = rhs.local;
+ time = rhs.time;
+ state = rhs.state;
+ local = rhs.local;
screen = rhs.screen;
- read = rhs.read;
+ read = rhs.read;
}
return *this;
* Assignment operator
* @param[in] gesture A Dali::Gesture
*/
- PanInfo& operator=( const Internal::PanGesture& rhs )
+ PanInfo& operator=(const Internal::PanGesture& rhs)
{
- time = rhs.GetTime();
+ time = rhs.GetTime();
state = rhs.GetState();
- local.velocity = rhs.GetVelocity();
+ local.velocity = rhs.GetVelocity();
local.displacement = rhs.GetDisplacement();
- local.position = rhs.GetPosition();
+ local.position = rhs.GetPosition();
- screen.velocity = rhs.GetScreenVelocity();
+ screen.velocity = rhs.GetScreenVelocity();
screen.displacement = rhs.GetScreenDisplacement();
- screen.position = rhs.GetScreenPosition();
+ screen.position = rhs.GetScreenPosition();
return *this;
}
// Data
- unsigned int time;
- GestureState state;
- Info local;
- Info screen;
+ unsigned int time;
+ GestureState state;
+ Info local;
+ Info screen;
volatile bool read;
};
static const unsigned int PAN_GESTURE_HISTORY = 30u;
public:
-
/**
* Create a new PanGesture
*/
* Adds a PanGesture to the internal circular-buffer waiting to be handled by UpdateProperties.
* @param[in] gesture The latest pan gesture.
*/
- void AddGesture( const Internal::PanGesture& gesture );
+ void AddGesture(const Internal::PanGesture& gesture);
/**
* @brief Removes pan events from the history that are older than maxAge, leaving at least minEvents
* @param[in,out] gesture Pass in current gesture, outputs result of blend.
* @param[in] lastGesture Pass in gesture to blend between.
*/
- void BlendPoints( PanInfo& gesture, PanInfo& lastGesture, float blendValue );
+ void BlendPoints(PanInfo& gesture, PanInfo& lastGesture, float blendValue);
/**
* Called by the update manager so that we can update the value of our properties.
* @param[in] nextRenderTime The estimated time of the next render (in milliseconds).
* @return true, if properties were updated.
*/
- bool UpdateProperties( unsigned int lastRenderTime, unsigned int nextRenderTime );
+ bool UpdateProperties(unsigned int lastRenderTime, unsigned int nextRenderTime);
/**
* Retrieves a reference to the panning flag property.
*
* @param[in] value True = use actual times, False = use perfect values
*/
- void SetUseActualTimes( bool value );
+ void SetUseActualTimes(bool value);
/**
* @brief Sets the interpolation time range (ms) of past points to use (with weights) when interpolating.
*
* @param[in] value Time range in ms
*/
- void SetInterpolationTimeRange( int value );
+ void SetInterpolationTimeRange(int value);
/**
* @brief Sets whether to use scalar only prediction, which when enabled, ignores acceleration.
*
* @param[in] value True = use scalar prediction only
*/
- void SetScalarOnlyPredictionEnabled( bool value );
+ void SetScalarOnlyPredictionEnabled(bool value);
/**
* @brief Sets whether to use two point prediction. This combines two interpolated points to get more steady acceleration and velocity values.
*
* @param[in] value True = use two point prediction
*/
- void SetTwoPointPredictionEnabled( bool value );
+ void SetTwoPointPredictionEnabled(bool value);
/**
* @brief Sets the time in the past to interpolate the second point when using two point interpolation.
*
* @param[in] value Time in past in ms
*/
- void SetTwoPointInterpolatePastTime( int value );
+ void SetTwoPointInterpolatePastTime(int value);
/**
* @brief Sets the two point velocity bias. This is the ratio of first and second points to use for velocity.
*
* @param[in] value 0.0f = 100% first point. 1.0f = 100% of second point.
*/
- void SetTwoPointVelocityBias( float value );
+ void SetTwoPointVelocityBias(float value);
/**
* @brief Sets the two point acceleration bias. This is the ratio of first and second points to use for acceleration.
*
* @param[in] value 0.0f = 100% first point. 1.0f = 100% of second point.
*/
- void SetTwoPointAccelerationBias( float value );
+ void SetTwoPointAccelerationBias(float value);
/**
* @brief Sets the range of time (ms) of points in the history to perform multitap smoothing with (if enabled).
*
* @param[in] value Time in past in ms
*/
- void SetMultitapSmoothingRange( int value );
+ void SetMultitapSmoothingRange(int value);
/**
* Called to provide pan-gesture profiling information.
* Reset default properties, custom ones not supported due to this being the only object in scene side
* @param updateBufferIndex index to use
*/
- void ResetDefaultProperties( BufferIndex updateBufferIndex );
+ void ResetDefaultProperties(BufferIndex updateBufferIndex);
private:
-
/**
* Protected constructor.
*/
PanGesture(const PanGesture&);
private:
-
// Struct to keep pairs of local and screen data together.
// TODO: This can encapsulate some functionality also.
using RelativeVectors = struct
* @param[in] lastVSyncTime The time of the last render (in milliseconds)
* @param[in] nextVSyncTime The estimated time of the next render (in milliseconds)
*/
- bool NewAlgorithm( unsigned int lastVSyncTime, unsigned int nextVSyncTime );
+ bool NewAlgorithm(unsigned int lastVSyncTime, unsigned int nextVSyncTime);
/**
* Gets the (absolute) time difference between two times.
* @param[in] minimumDelta The smallest amount the difference can become
* @param[in] overrideDifference The time difference to return if using perfect times
*/
- inline float GetDivisibleTimeDifference( int timeA, int timeB, float minimumDelta, float overrideDifference );
+ inline float GetDivisibleTimeDifference(int timeA, int timeB, float minimumDelta, float overrideDifference);
/**
* This limits the change currentAcceleration can have over lastAcceleration by the specified changeLimit value.
* @param[in] lastAcceleration The acceleration to limit against
* @param[in] changeLimit The maximum change (in either direction)
*/
- void LimitAccelerationChange( RelativeVectors& currentAcceleration, RelativeVectors& lastAcceleration, float changeLimit );
+ void LimitAccelerationChange(RelativeVectors& currentAcceleration, RelativeVectors& lastAcceleration, float changeLimit);
/**
* Reads all events received this frame into a linear buffer.
* @param[out] justStarted Set to true if we are now starting a new gesture
* @param[out] justFinished Set to true if we are now finishing a gesture
*/
- bool InputRateConversion( PanInfo& rateConvertedGesture, unsigned int eventsThisFrame,
- unsigned int currentFrameTime, unsigned int lastFrameTime, bool& justStarted, bool& justFinished );
+ bool InputRateConversion(PanInfo& rateConvertedGesture, unsigned int eventsThisFrame, unsigned int currentFrameTime, unsigned int lastFrameTime, bool& justStarted, bool& justFinished);
/**
* Generates an interpolated point at the specified point in time.
* @param[in] outputTimeGranularity Time difference between output point (typically 60Hz)
* @param[in] eraseUnused Set to true to clean up any history not used by the function
*/
- bool InterpolatePoint( PanInfoHistory& history, unsigned int currentTime, unsigned int targetTime, unsigned int range,
- PanInfo& outPoint, RelativeVectors& acceleration, int outputTimeGranularity, bool eraseUnused );
+ bool InterpolatePoint(PanInfoHistory& history, unsigned int currentTime, unsigned int targetTime, unsigned int range, PanInfo& outPoint, RelativeVectors& acceleration, int outputTimeGranularity, bool eraseUnused);
/**
* Predicts a point in the future, based on the supplied point and acceleration.
* @param[in] previousFrameTime Time of the last rendered frame
* @param[in] noPreviousData Set to true if we are just starting a gesture
*/
- void PredictionMode2( PanInfo& startPoint, RelativeVectors& accelerationToUse,
- PanInfo& predictedPoint, unsigned int currentFrameTime, unsigned int previousFrameTime, bool noPreviousData );
+ void PredictionMode2(PanInfo& startPoint, RelativeVectors& accelerationToUse, PanInfo& predictedPoint, unsigned int currentFrameTime, unsigned int previousFrameTime, bool noPreviousData);
private:
-
// Undefined
PanGesture& operator=(const PanGesture&);
struct FrameGestureInfo
{
PanGesture::PanInfo frameGesture;
- float acceleration;
- unsigned int eventsThisFrame;
- bool justStarted;
- bool justFinished;
+ float acceleration;
+ unsigned int eventsThisFrame;
+ bool justStarted;
+ bool justFinished;
FrameGestureInfo()
- : acceleration( 0.0f ),
- eventsThisFrame( 0 ),
- justStarted( false ),
- justFinished( false )
+ : acceleration(0.0f),
+ eventsThisFrame(0),
+ justStarted(false),
+ justFinished(false)
{
}
};
* @param[out] info Written to with information about gestures read this frame.
* @param[in] currentTimestamp The time of this frame.
*/
- bool ReadGestures( FrameGestureInfo& info, unsigned int currentTimestamp );
+ bool ReadGestures(FrameGestureInfo& info, unsigned int currentTimestamp);
/**
* Reads gestures from input and resamples data, builds history.
* @param[out] info Written to with information about gestures read this frame.
* @param[in] currentTimestamp The time of this frame.
*/
- bool ReadAndResampleGestures( FrameGestureInfo& info, unsigned int currentTimestamp );
+ bool ReadAndResampleGestures(FrameGestureInfo& info, unsigned int currentTimestamp);
private:
-
// Properties
GesturePropertyBool mPanning; ///< panning flag
GesturePropertyVector2 mScreenPosition; ///< screenPosition
GesturePropertyVector2 mLocalDisplacement; ///< localDisplacement
GesturePropertyVector2 mLocalVelocity; ///< localVelocity
- PanInfoHistory mPanHistory;
- PanInfoHistory mPredictionHistory;
- PanInfo mGestures[PAN_GESTURE_HISTORY]; ///< Circular buffer storing the 4 most recent gestures.
- PanInfo mReadGestures[PAN_GESTURE_HISTORY]; ///< Linear buffer storing the most recent gestures (to reduce read lock time).
- PanInfo mLastGesture; ///< The last gesture. (last update frame).
- PanInfo mTargetGesture; ///< The most recent input gesture, if the current used gesture does not match.
- PanInfo mLastUnmodifiedGesture; ///< The last gesture before any processing was done on it.
- PanInfo mLastSecondInterpolatedPoint; ///< Stores the last second interpolated point we generated.
- PanInfo mLastFrameReadGesture; ///< Stores the last gesture read.
- PanInfo mLastPredictedPoint; ///< Stores the last predicted point we generated.
- RelativeVectors mLastAcceleration; ///< Stores the acceleration value from the acceleration limiting last frame.
- RelativeVectors mLastInterpolatedAcceleration; ///< Stores the second interpolated point acceleration value from the last frame.
- RelativeVectors mLastInitialAcceleration; ///< Stores the initial acceleration value from the last frame.
-
- volatile unsigned int mWritePosition; ///< The next PanInfo buffer to write to. (starts at 0).
- unsigned int mReadPosition; ///< The next PanInfo buffer to read. (starts at 0).
- bool mNotAtTarget; ///< Keeps track of if the last gesture used was the most recent received.
- bool mInGesture; ///< True if the gesture is currently being handled i.e. between STARTED <-> FINISHED/CANCELLED.
- bool mPredictionAmountOverridden;
- bool mSmoothingAmountOverridden;
-
- PanGestureProfiling* mProfiling; ///< NULL unless pan-gesture profiling information is required.
- Dali::Mutex mMutex; ///< Mutex to lock access.
+ PanInfoHistory mPanHistory;
+ PanInfoHistory mPredictionHistory;
+ PanInfo mGestures[PAN_GESTURE_HISTORY]; ///< Circular buffer storing the 4 most recent gestures.
+ PanInfo mReadGestures[PAN_GESTURE_HISTORY]; ///< Linear buffer storing the most recent gestures (to reduce read lock time).
+ PanInfo mLastGesture; ///< The last gesture. (last update frame).
+ PanInfo mTargetGesture; ///< The most recent input gesture, if the current used gesture does not match.
+ PanInfo mLastUnmodifiedGesture; ///< The last gesture before any processing was done on it.
+ PanInfo mLastSecondInterpolatedPoint; ///< Stores the last second interpolated point we generated.
+ PanInfo mLastFrameReadGesture; ///< Stores the last gesture read.
+ PanInfo mLastPredictedPoint; ///< Stores the last predicted point we generated.
+ RelativeVectors mLastAcceleration; ///< Stores the acceleration value from the acceleration limiting last frame.
+ RelativeVectors mLastInterpolatedAcceleration; ///< Stores the second interpolated point acceleration value from the last frame.
+ RelativeVectors mLastInitialAcceleration; ///< Stores the initial acceleration value from the last frame.
+
+ volatile unsigned int mWritePosition; ///< The next PanInfo buffer to write to. (starts at 0).
+ unsigned int mReadPosition; ///< The next PanInfo buffer to read. (starts at 0).
+ bool mNotAtTarget; ///< Keeps track of if the last gesture used was the most recent received.
+ bool mInGesture; ///< True if the gesture is currently being handled i.e. between STARTED <-> FINISHED/CANCELLED.
+ bool mPredictionAmountOverridden;
+ bool mSmoothingAmountOverridden;
+
+ PanGestureProfiling* mProfiling; ///< NULL unless pan-gesture profiling information is required.
+ Dali::Mutex mMutex; ///< Mutex to lock access.
// Environment variables:
- PredictionMode mPredictionMode; ///< The pan gesture prediction mode
- unsigned int mPredictionAmount; ///< how far into future to predict in milliseconds
- unsigned int mCurrentPredictionAmount; ///< the current prediction amount used by the prediction algorithm
- unsigned int mMaxPredictionAmount; ///< the maximum prediction amount used by the prediction algorithm
- unsigned int mMinPredictionAmount; ///< the minimum prediction amount used by the prediction algorithm
- unsigned int mPredictionAmountAdjustment; ///< the prediction amount to adjust in milliseconds when pan velocity changes
- SmoothingMode mSmoothingMode; ///< The pan gesture prediction mode
- float mSmoothingAmount; ///< How much smoothing to apply [0.0f,1.0f]
- bool mUseActualTimes; ///< Disable to optionally override actual times if they make results worse.
- int mInterpolationTimeRange; ///< Time into past history (ms) to use points to interpolate the first point.
- bool mScalarOnlyPredictionEnabled; ///< If enabled, prediction is done using velocity alone (no integration or acceleration).
- bool mTwoPointPredictionEnabled; ///< If enabled, a second interpolated point is predicted and combined with the first to get more stable values.
- int mTwoPointPastInterpolateTime; ///< The target time in the past to generate the second interpolated point.
- float mTwoPointVelocityBias; ///< The ratio of first and second interpolated points to use for velocity. 0.0f = 100% of first point. 1.0f = 100% of second point.
- float mTwoPointAccelerationBias; ///< The ratio of first and second interpolated points to use for acceleration. 0.0f = 100% of first point. 1.0f = 100% of second point.
- int mMultiTapSmoothingRange; ///< The range in time (ms) of points in the history to smooth the final output against.
+ PredictionMode mPredictionMode; ///< The pan gesture prediction mode
+ unsigned int mPredictionAmount; ///< how far into future to predict in milliseconds
+ unsigned int mCurrentPredictionAmount; ///< the current prediction amount used by the prediction algorithm
+ unsigned int mMaxPredictionAmount; ///< the maximum prediction amount used by the prediction algorithm
+ unsigned int mMinPredictionAmount; ///< the minimum prediction amount used by the prediction algorithm
+ unsigned int mPredictionAmountAdjustment; ///< the prediction amount to adjust in milliseconds when pan velocity changes
+ SmoothingMode mSmoothingMode; ///< The pan gesture prediction mode
+ float mSmoothingAmount; ///< How much smoothing to apply [0.0f,1.0f]
+ bool mUseActualTimes; ///< Disable to optionally override actual times if they make results worse.
+ int mInterpolationTimeRange; ///< Time into past history (ms) to use points to interpolate the first point.
+ bool mScalarOnlyPredictionEnabled; ///< If enabled, prediction is done using velocity alone (no integration or acceleration).
+ bool mTwoPointPredictionEnabled; ///< If enabled, a second interpolated point is predicted and combined with the first to get more stable values.
+ int mTwoPointPastInterpolateTime; ///< The target time in the past to generate the second interpolated point.
+ float mTwoPointVelocityBias; ///< The ratio of first and second interpolated points to use for velocity. 0.0f = 100% of first point. 1.0f = 100% of second point.
+ float mTwoPointAccelerationBias; ///< The ratio of first and second interpolated points to use for acceleration. 0.0f = 100% of first point. 1.0f = 100% of second point.
+ int mMultiTapSmoothingRange; ///< The range in time (ms) of points in the history to smooth the final output against.
};
} // namespace SceneGraph
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
-FrameCallbackProcessor::FrameCallbackProcessor( UpdateManager& updateManager, TransformManager& transformManager )
+FrameCallbackProcessor::FrameCallbackProcessor(UpdateManager& updateManager, TransformManager& transformManager)
: mFrameCallbacks(),
- mUpdateManager( updateManager ),
- mTransformManager( transformManager ),
- mNodeHierarchyChanged( true )
+ mUpdateManager(updateManager),
+ mTransformManager(transformManager),
+ mNodeHierarchyChanged(true)
{
}
FrameCallbackProcessor::~FrameCallbackProcessor() = default;
-void FrameCallbackProcessor::AddFrameCallback( OwnerPointer< FrameCallback >& frameCallback, const Node* rootNode )
+void FrameCallbackProcessor::AddFrameCallback(OwnerPointer<FrameCallback>& frameCallback, const Node* rootNode)
{
- Node& node = const_cast< Node& >( *rootNode ); // Was sent as const from event thread, we need to be able to use non-const version here.
+ Node& node = const_cast<Node&>(*rootNode); // Was sent as const from event thread, we need to be able to use non-const version here.
- frameCallback->ConnectToSceneGraph( mUpdateManager, mTransformManager, node );
+ frameCallback->ConnectToSceneGraph(mUpdateManager, mTransformManager, node);
- mFrameCallbacks.emplace_back( frameCallback );
+ mFrameCallbacks.emplace_back(frameCallback);
}
-void FrameCallbackProcessor::RemoveFrameCallback( FrameCallbackInterface* frameCallback )
+void FrameCallbackProcessor::RemoveFrameCallback(FrameCallbackInterface* frameCallback)
{
// Find and remove all frame-callbacks that use the given frame-callback-interface
- auto iter = std::remove( mFrameCallbacks.begin(), mFrameCallbacks.end(), frameCallback );
- mFrameCallbacks.erase( iter, mFrameCallbacks.end() );
+ auto iter = std::remove(mFrameCallbacks.begin(), mFrameCallbacks.end(), frameCallback);
+ mFrameCallbacks.erase(iter, mFrameCallbacks.end());
}
-void FrameCallbackProcessor::Update( BufferIndex bufferIndex, float elapsedSeconds )
+void FrameCallbackProcessor::Update(BufferIndex bufferIndex, float elapsedSeconds)
{
// If any of the FrameCallback::Update calls returns false, then they are no longer required & can be removed.
auto iter = std::remove_if(
- mFrameCallbacks.begin(), mFrameCallbacks.end(),
- [ & ]( OwnerPointer< FrameCallback >& frameCallback )
- {
- return ! frameCallback->Update( bufferIndex, elapsedSeconds, mNodeHierarchyChanged );
- }
- );
- mFrameCallbacks.erase( iter, mFrameCallbacks.end() );
+ mFrameCallbacks.begin(), mFrameCallbacks.end(), [&](OwnerPointer<FrameCallback>& frameCallback) {
+ return !frameCallback->Update(bufferIndex, elapsedSeconds, mNodeHierarchyChanged);
+ });
+ mFrameCallbacks.erase(iter, mFrameCallbacks.end());
mNodeHierarchyChanged = false;
}
#define DALI_INTERNAL_SCENE_GRAPH_FRAME_CALLBACK_PROCESSOR_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <memory>
// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/common/owner-pointer.h>
#include <dali/internal/update/manager/scene-graph-frame-callback.h>
#include <dali/internal/update/manager/update-proxy-impl.h>
+#include <dali/public-api/common/vector-wrapper.h>
namespace Dali
{
-
class FrameCallbackInterface;
namespace Internal
{
-
namespace SceneGraph
{
-
class Node;
class TransformManager;
class UpdateManager;
class FrameCallbackProcessor
{
public:
-
/**
* Construct a new FrameCallbackProcessor.
* @param[in] updateManager A reference to the UpdateManager
* @param[in] transformManager A reference to the TransformManager
*/
- FrameCallbackProcessor( UpdateManager& updateManager, TransformManager& transformManager );
+ FrameCallbackProcessor(UpdateManager& updateManager, TransformManager& transformManager);
/**
* Non-virtual Destructor.
// Movable but not copyable
- FrameCallbackProcessor( const FrameCallbackProcessor& ) = delete; ///< Deleted copy constructor.
- FrameCallbackProcessor( FrameCallbackProcessor&& ) = default; ///< Default move constructor.
- FrameCallbackProcessor& operator=( const FrameCallbackProcessor& ) = delete; ///< Deleted copy assignment operator.
- FrameCallbackProcessor& operator=( FrameCallbackProcessor&& ) = delete; ///< Deleted move assignment operator.
+ FrameCallbackProcessor(const FrameCallbackProcessor&) = delete; ///< Deleted copy constructor.
+ FrameCallbackProcessor(FrameCallbackProcessor&&) = default; ///< Default move constructor.
+ FrameCallbackProcessor& operator=(const FrameCallbackProcessor&) = delete; ///< Deleted copy assignment operator.
+ FrameCallbackProcessor& operator=(FrameCallbackProcessor&&) = delete; ///< Deleted move assignment operator.
/**
* Adds an implementation of the FrameCallbackInterface.
* @param[in] frameCallback An OwnerPointer to the SceneGraph FrameCallback object
* @param[in] rootNode A pointer to the root node to apply the FrameCallback to
*/
- void AddFrameCallback( OwnerPointer< FrameCallback >& frameCallback, const Node* rootNode );
+ void AddFrameCallback(OwnerPointer<FrameCallback>& frameCallback, const Node* rootNode);
/**
* Removes the specified implementation of FrameCallbackInterface.
* @param[in] frameCallback A pointer to the implementation of the FrameCallbackInterface to remove.
*/
- void RemoveFrameCallback( FrameCallbackInterface* frameCallback );
+ void RemoveFrameCallback(FrameCallbackInterface* frameCallback);
/**
* Called on Update by the UpdateManager.
* @param[in] bufferIndex The bufferIndex to use
* @param[in] elapsedSeconds Time elapsed time since the last frame (in seconds)
*/
- void Update( BufferIndex bufferIndex, float elapsedSeconds );
+ void Update(BufferIndex bufferIndex, float elapsedSeconds);
/**
* Called by the UpdateManager when the node hierarchy changes.
}
private:
-
- std::vector< OwnerPointer< FrameCallback > > mFrameCallbacks; ///< A container of all the frame-callbacks & accompanying update-proxies.
+ std::vector<OwnerPointer<FrameCallback> > mFrameCallbacks; ///< A container of all the frame-callbacks & accompanying update-proxies.
UpdateManager& mUpdateManager;
#define FREE_LIST_H_
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
/**
* FreeList operates by connecting unused elements of a vector together in a linked list using the
* value of each unused cell as a pointer to the next. When a new element is added, it will be added
* Constructor
*/
FreeList()
- :mData(),
- mFirstFreeIndex(0)
- {}
+ : mData(),
+ mFirstFreeIndex(0)
+ {
+ }
/**
* Destructor
* @param[in] value The value to add
* @return The index where the value has been added
*/
- uint32_t Add( uint32_t value )
+ uint32_t Add(uint32_t value)
{
- const uint32_t size = static_cast<uint32_t>( mData.Size() ); // 4,294,967,295 entries is enough
- if( mData.Empty() || mFirstFreeIndex == size )
+ const uint32_t size = static_cast<uint32_t>(mData.Size()); // 4,294,967,295 entries is enough
+ if(mData.Empty() || mFirstFreeIndex == size)
{
//Make room for another item
- mData.PushBack( size + 1 );
+ mData.PushBack(size + 1);
mFirstFreeIndex = size;
}
//Update first free index
- uint32_t index = mFirstFreeIndex;
+ uint32_t index = mFirstFreeIndex;
mFirstFreeIndex = mData[mFirstFreeIndex];
mData[index] = value;
*
* @param[in] index The index of the element to remove
*/
- void Remove( uint32_t index )
+ void Remove(uint32_t index)
{
- mData[index] = mFirstFreeIndex;
+ mData[index] = mFirstFreeIndex;
mFirstFreeIndex = index;
}
* @param[in] index Index of the element.
* @return Reference to the element for given index.
*/
- uint32_t& operator[]( uint32_t index )
+ uint32_t& operator[](uint32_t index)
{
return mData[index];
}
* @param[in] index Index of the element.
* @return Reference to the element for given index.
*/
- uint32_t operator[]( uint32_t index ) const
+ uint32_t operator[](uint32_t index) const
{
return mData[index];
}
private:
- Dali::Vector< uint32_t > mData; ///< data
- uint32_t mFirstFreeIndex; ///< Index where a new element will be added
+ Dali::Vector<uint32_t> mData; ///< data
+ uint32_t mFirstFreeIndex; ///< Index where a new element will be added
};
-}
-}
+} // namespace Internal
+} // namespace Dali
#endif /* FREE_LIST_H_ */
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/update/manager/render-instruction-processor.h>
// INTERNAL INCLUDES
-#include <dali/public-api/actors/layer.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/event/actors/layer-impl.h> // for the default sorting function
-#include <dali/internal/update/manager/sorted-layers.h>
-#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
-#include <dali/internal/update/rendering/scene-graph-texture-set.h>
+#include <dali/internal/render/common/render-instruction-container.h>
+#include <dali/internal/render/common/render-instruction.h>
#include <dali/internal/render/common/render-item.h>
#include <dali/internal/render/common/render-tracker.h>
-#include <dali/internal/render/common/render-instruction.h>
-#include <dali/internal/render/common/render-instruction-container.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h>
#include <dali/internal/render/renderers/render-renderer.h>
+#include <dali/internal/render/shaders/scene-graph-shader.h>
+#include <dali/internal/update/manager/sorted-layers.h>
#include <dali/internal/update/nodes/scene-graph-layer.h>
+#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
+#include <dali/internal/update/rendering/scene-graph-texture-set.h>
+#include <dali/public-api/actors/layer.h>
namespace
{
#if defined(DEBUG_ENABLED)
Debug::Filter* gRenderListLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_RENDER_LISTS");
#endif
-}
+} // namespace
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
namespace
{
-
/**
* Function which compares render items by shader/textureSet/geometry
* @param[in] lhs Left hand side item
* @param[in] rhs Right hand side item
* @return True if left item is greater than right
*/
-inline bool PartialCompareItems( const RenderInstructionProcessor::SortAttributes& lhs,
- const RenderInstructionProcessor::SortAttributes& rhs )
+inline bool PartialCompareItems(const RenderInstructionProcessor::SortAttributes& lhs,
+ const RenderInstructionProcessor::SortAttributes& rhs)
{
- if( lhs.shader == rhs.shader )
+ if(lhs.shader == rhs.shader)
{
- if( lhs.textureSet == rhs.textureSet )
+ if(lhs.textureSet == rhs.textureSet)
{
return lhs.geometry < rhs.geometry;
}
* @param[in] rhs Right hand side item
* @return True if left item is greater than right
*/
-bool CompareItems( const RenderInstructionProcessor::SortAttributes& lhs, const RenderInstructionProcessor::SortAttributes& rhs )
+bool CompareItems(const RenderInstructionProcessor::SortAttributes& lhs, const RenderInstructionProcessor::SortAttributes& rhs)
{
// @todo Consider replacing all these sortAttributes with a single long int that
// encapsulates the same data (e.g. the middle-order bits of the ptrs).
- if( lhs.renderItem->mDepthIndex == rhs.renderItem->mDepthIndex )
+ if(lhs.renderItem->mDepthIndex == rhs.renderItem->mDepthIndex)
{
- return PartialCompareItems( lhs, rhs );
+ return PartialCompareItems(lhs, rhs);
}
return lhs.renderItem->mDepthIndex < rhs.renderItem->mDepthIndex;
}
* @param[in] rhs Right hand side item
* @return True if left item is greater than right
*/
-bool CompareItems3D( const RenderInstructionProcessor::SortAttributes& lhs, const RenderInstructionProcessor::SortAttributes& rhs )
+bool CompareItems3D(const RenderInstructionProcessor::SortAttributes& lhs, const RenderInstructionProcessor::SortAttributes& rhs)
{
const bool lhsIsOpaque = lhs.renderItem->mIsOpaque;
- if( lhsIsOpaque == rhs.renderItem->mIsOpaque )
+ if(lhsIsOpaque == rhs.renderItem->mIsOpaque)
{
- if( lhsIsOpaque )
+ if(lhsIsOpaque)
{
// If both RenderItems are opaque, sort using shader, then material then geometry.
- return PartialCompareItems( lhs, rhs );
+ return PartialCompareItems(lhs, rhs);
}
else
{
// If both RenderItems are transparent, sort using Z, then shader, then material, then geometry.
- if( Equals( lhs.zValue, rhs.zValue ) )
+ if(Equals(lhs.zValue, rhs.zValue))
{
- return PartialCompareItems( lhs, rhs );
+ return PartialCompareItems(lhs, rhs);
}
return lhs.zValue > rhs.zValue;
}
* @param[in] rhs Right hand side item
* @return True if left item is greater than right
*/
-bool CompareItems3DWithClipping( const RenderInstructionProcessor::SortAttributes& lhs, const RenderInstructionProcessor::SortAttributes& rhs )
+bool CompareItems3DWithClipping(const RenderInstructionProcessor::SortAttributes& lhs, const RenderInstructionProcessor::SortAttributes& rhs)
{
// Items must be sorted in order of clipping first, otherwise incorrect clipping regions could be used.
- if( lhs.renderItem->mNode->mClippingSortModifier == rhs.renderItem->mNode->mClippingSortModifier )
+ if(lhs.renderItem->mNode->mClippingSortModifier == rhs.renderItem->mNode->mClippingSortModifier)
{
- return CompareItems3D( lhs, rhs );
+ return CompareItems3D(lhs, rhs);
}
return lhs.renderItem->mNode->mClippingSortModifier < rhs.renderItem->mNode->mClippingSortModifier;
* @param isLayer3d Whether we are processing a 3D layer or not
* @param cull Whether frustum culling is enabled or not
*/
-inline void AddRendererToRenderList(BufferIndex updateBufferIndex,
- RenderList& renderList,
- Renderable& renderable,
- const Matrix& viewMatrix,
+inline void AddRendererToRenderList(BufferIndex updateBufferIndex,
+ RenderList& renderList,
+ Renderable& renderable,
+ const Matrix& viewMatrix,
SceneGraph::Camera& camera,
- bool isLayer3d,
- bool cull)
+ bool isLayer3d,
+ bool cull)
{
- bool inside(true);
+ bool inside(true);
Node* node = renderable.mNode;
- if (cull && renderable.mRenderer && !renderable.mRenderer->GetShader().HintEnabled(Dali::Shader::Hint::MODIFIES_GEOMETRY))
+ if(cull && renderable.mRenderer && !renderable.mRenderer->GetShader().HintEnabled(Dali::Shader::Hint::MODIFIES_GEOMETRY))
{
const Vector4& boundingSphere = node->GetBoundingSphere();
- inside = (boundingSphere.w > Math::MACHINE_EPSILON_1000) &&
+ inside = (boundingSphere.w > Math::MACHINE_EPSILON_1000) &&
(camera.CheckSphereInFrustum(updateBufferIndex, Vector3(boundingSphere), boundingSphere.w));
}
- if (inside)
+ if(inside)
{
- Renderer::OpacityType opacityType = renderable.mRenderer ? renderable.mRenderer->GetOpacityType( updateBufferIndex, *renderable.mNode ) : Renderer::OPAQUE;
- if (opacityType != Renderer::TRANSPARENT || node->GetClippingMode() == ClippingMode::CLIP_CHILDREN)
+ Renderer::OpacityType opacityType = renderable.mRenderer ? renderable.mRenderer->GetOpacityType(updateBufferIndex, *renderable.mNode) : Renderer::OPAQUE;
+ if(opacityType != Renderer::TRANSPARENT || node->GetClippingMode() == ClippingMode::CLIP_CHILDREN)
{
// Get the next free RenderItem.
RenderItem& item = renderList.GetNextFreeItem();
auto& partialRenderingCacheInfo = node->GetPartialRenderingData().GetCurrentCacheInfo();
- partialRenderingCacheInfo.node = node;
- partialRenderingCacheInfo.isOpaque = (opacityType == Renderer::OPAQUE);
- partialRenderingCacheInfo.renderer = renderable.mRenderer;
- partialRenderingCacheInfo.color = renderable.mNode->GetColor(updateBufferIndex);
+ partialRenderingCacheInfo.node = node;
+ partialRenderingCacheInfo.isOpaque = (opacityType == Renderer::OPAQUE);
+ partialRenderingCacheInfo.renderer = renderable.mRenderer;
+ partialRenderingCacheInfo.color = renderable.mNode->GetColor(updateBufferIndex);
partialRenderingCacheInfo.depthIndex = renderable.mNode->GetDepthIndex();
- if( renderable.mRenderer )
+ if(renderable.mRenderer)
{
partialRenderingCacheInfo.textureSet = renderable.mRenderer->GetTextures();
}
- item.mNode = renderable.mNode;
+ item.mNode = renderable.mNode;
item.mIsOpaque = (opacityType == Renderer::OPAQUE);
- item.mColor = renderable.mNode->GetColor(updateBufferIndex);
+ item.mColor = renderable.mNode->GetColor(updateBufferIndex);
item.mDepthIndex = 0;
- if (!isLayer3d)
+ if(!isLayer3d)
{
item.mDepthIndex = renderable.mNode->GetDepthIndex();
}
- if (DALI_LIKELY(renderable.mRenderer))
+ if(DALI_LIKELY(renderable.mRenderer))
{
- item.mRenderer = &renderable.mRenderer->GetRenderer();
+ item.mRenderer = &renderable.mRenderer->GetRenderer();
item.mTextureSet = renderable.mRenderer->GetTextures();
item.mDepthIndex += renderable.mRenderer->GetDepthIndex();
}
item.mIsUpdated |= isLayer3d;
// Save ModelView matrix onto the item.
- node->GetWorldMatrixAndSize( item.mModelMatrix, item.mSize );
- Matrix::Multiply( item.mModelViewMatrix, item.mModelMatrix, viewMatrix );
+ node->GetWorldMatrixAndSize(item.mModelMatrix, item.mSize);
+ Matrix::Multiply(item.mModelViewMatrix, item.mModelMatrix, viewMatrix);
partialRenderingCacheInfo.matrix = item.mModelViewMatrix;
- partialRenderingCacheInfo.size = item.mSize;
+ partialRenderingCacheInfo.size = item.mSize;
- if (renderable.mNode->GetUpdateSizeHint() == Vector3::ZERO)
+ if(renderable.mNode->GetUpdateSizeHint() == Vector3::ZERO)
{
// RenderItem::CalculateViewportSpaceAABB cannot cope with z transform
// I don't use item.mModelMatrix.GetTransformComponents() for z transform, would be to slow
- if (!isLayer3d && item.mModelMatrix.GetZAxis() == Vector3(0.0f, 0.0f, 1.0f))
+ if(!isLayer3d && item.mModelMatrix.GetZAxis() == Vector3(0.0f, 0.0f, 1.0f))
{
item.mUpdateSize = item.mSize;
}
item.mIsUpdated = partialRenderingData.IsUpdated() || item.mIsUpdated;
partialRenderingData.SwapBuffers();
}
- node->SetCulled( updateBufferIndex, false );
+ node->SetCulled(updateBufferIndex, false);
}
else
{
- node->SetCulled( updateBufferIndex, true );
+ node->SetCulled(updateBufferIndex, true);
}
}
* @param isLayer3d Whether we are processing a 3D layer or not
* @param cull Whether frustum culling is enabled or not
*/
-inline void AddRenderersToRenderList( BufferIndex updateBufferIndex,
- RenderList& renderList,
- RenderableContainer& renderers,
- const Matrix& viewMatrix,
- SceneGraph::Camera& camera,
- bool isLayer3d,
- bool cull )
+inline void AddRenderersToRenderList(BufferIndex updateBufferIndex,
+ RenderList& renderList,
+ RenderableContainer& renderers,
+ const Matrix& viewMatrix,
+ SceneGraph::Camera& camera,
+ bool isLayer3d,
+ bool cull)
{
- DALI_LOG_INFO( gRenderListLogFilter, Debug::Verbose, "AddRenderersToRenderList()\n");
+ DALI_LOG_INFO(gRenderListLogFilter, Debug::Verbose, "AddRenderersToRenderList()\n");
- for( auto&& renderer : renderers )
+ for(auto&& renderer : renderers)
{
- AddRendererToRenderList( updateBufferIndex,
- renderList,
- renderer,
- viewMatrix,
- camera,
- isLayer3d,
- cull);
+ AddRendererToRenderList(updateBufferIndex,
+ renderList,
+ renderer,
+ viewMatrix,
+ camera,
+ isLayer3d,
+ cull);
}
}
* @param renderList that is cached from frame N-1
* @param renderables list of renderables
*/
-inline bool TryReuseCachedRenderers( Layer& layer,
- RenderList& renderList,
- RenderableContainer& renderables )
+inline bool TryReuseCachedRenderers(Layer& layer,
+ RenderList& renderList,
+ RenderableContainer& renderables)
{
- bool retValue = false;
- uint32_t renderableCount = static_cast<uint32_t>( renderables.Size() );
+ bool retValue = false;
+ uint32_t renderableCount = static_cast<uint32_t>(renderables.Size());
// Check that the cached list originates from this layer and that the counts match
- if( ( renderList.GetSourceLayer() == &layer )&&
- ( renderList.GetCachedItemCount() == renderableCount ) )
+ if((renderList.GetSourceLayer() == &layer) &&
+ (renderList.GetCachedItemCount() == renderableCount))
{
// Check that all the same renderers are there. This gives us additional security in avoiding rendering the wrong things.
// Render list is sorted so at this stage renderers may be in different order.
// Therefore we check a combined sum of all renderer addresses.
size_t checkSumNew = 0;
size_t checkSumOld = 0;
- for( uint32_t index = 0; index < renderableCount; ++index )
+ for(uint32_t index = 0; index < renderableCount; ++index)
{
const Render::Renderer& renderer = renderables[index].mRenderer->GetRenderer();
- checkSumNew += reinterpret_cast<std::size_t>( &renderer );
- checkSumOld += reinterpret_cast<std::size_t>( &renderList.GetRenderer( index ) );
+ checkSumNew += reinterpret_cast<std::size_t>(&renderer);
+ checkSumOld += reinterpret_cast<std::size_t>(&renderList.GetRenderer(index));
}
- if( checkSumNew == checkSumOld )
+ if(checkSumNew == checkSumOld)
{
// tell list to reuse its existing items
renderList.ReuseCachedItems();
return retValue;
}
-inline bool SetupRenderList( RenderableContainer& renderables,
- Layer& layer,
- RenderInstruction& instruction,
- bool tryReuseRenderList,
- RenderList** renderList )
+inline bool SetupRenderList(RenderableContainer& renderables,
+ Layer& layer,
+ RenderInstruction& instruction,
+ bool tryReuseRenderList,
+ RenderList** renderList)
{
- *renderList = &( instruction.GetNextFreeRenderList( renderables.Size() ) );
- ( *renderList )->SetClipping( layer.IsClipping(), layer.GetClippingBox() );
- ( *renderList )->SetSourceLayer( &layer );
+ *renderList = &(instruction.GetNextFreeRenderList(renderables.Size()));
+ (*renderList)->SetClipping(layer.IsClipping(), layer.GetClippingBox());
+ (*renderList)->SetSourceLayer(&layer);
// Try to reuse cached RenderItems from last time around.
- return ( tryReuseRenderList && TryReuseCachedRenderers( layer, **renderList, renderables ) );
+ return (tryReuseRenderList && TryReuseCachedRenderers(layer, **renderList, renderables));
}
} // Anonymous namespace.
-
RenderInstructionProcessor::RenderInstructionProcessor()
: mSortingHelper()
{
// Set up a container of comparators for fast run-time selection.
- mSortComparitors.Reserve( 3u );
+ mSortComparitors.Reserve(3u);
- mSortComparitors.PushBack( CompareItems );
- mSortComparitors.PushBack( CompareItems3D );
- mSortComparitors.PushBack( CompareItems3DWithClipping );
+ mSortComparitors.PushBack(CompareItems);
+ mSortComparitors.PushBack(CompareItems3D);
+ mSortComparitors.PushBack(CompareItems3DWithClipping);
}
RenderInstructionProcessor::~RenderInstructionProcessor() = default;
-inline void RenderInstructionProcessor::SortRenderItems( BufferIndex bufferIndex, RenderList& renderList, Layer& layer, bool respectClippingOrder )
+inline void RenderInstructionProcessor::SortRenderItems(BufferIndex bufferIndex, RenderList& renderList, Layer& layer, bool respectClippingOrder)
{
- const uint32_t renderableCount = static_cast<uint32_t>( renderList.Count() );
+ const uint32_t renderableCount = static_cast<uint32_t>(renderList.Count());
// Reserve space if needed.
- const uint32_t oldcapacity = static_cast<uint32_t>( mSortingHelper.size() );
- if( oldcapacity < renderableCount )
+ const uint32_t oldcapacity = static_cast<uint32_t>(mSortingHelper.size());
+ if(oldcapacity < renderableCount)
{
- mSortingHelper.reserve( renderableCount );
+ mSortingHelper.reserve(renderableCount);
// Add real objects (reserve does not construct objects).
- mSortingHelper.insert( mSortingHelper.begin() + oldcapacity,
+ mSortingHelper.insert(mSortingHelper.begin() + oldcapacity,
(renderableCount - oldcapacity),
- RenderInstructionProcessor::SortAttributes() );
+ RenderInstructionProcessor::SortAttributes());
}
else
{
// Clear extra elements from helper, does not decrease capability.
- mSortingHelper.resize( renderableCount );
+ mSortingHelper.resize(renderableCount);
}
// Calculate the sorting value, once per item by calling the layers sort function.
// Using an if and two for-loops rather than if inside for as its better for branch prediction.
- if( layer.UsesDefaultSortFunction() )
+ if(layer.UsesDefaultSortFunction())
{
- for( uint32_t index = 0; index < renderableCount; ++index )
+ for(uint32_t index = 0; index < renderableCount; ++index)
{
- RenderItem& item = renderList.GetItem( index );
+ RenderItem& item = renderList.GetItem(index);
- if( item.mRenderer )
+ if(item.mRenderer)
{
- item.mRenderer->SetSortAttributes( bufferIndex, mSortingHelper[ index ] );
+ item.mRenderer->SetSortAttributes(bufferIndex, mSortingHelper[index]);
}
// texture set
- mSortingHelper[ index ].textureSet = item.mTextureSet;
+ mSortingHelper[index].textureSet = item.mTextureSet;
// The default sorting function should get inlined here.
- mSortingHelper[ index ].zValue = Internal::Layer::ZValue( item.mModelViewMatrix.GetTranslation3() ) - static_cast<float>( item.mDepthIndex );
+ mSortingHelper[index].zValue = Internal::Layer::ZValue(item.mModelViewMatrix.GetTranslation3()) - static_cast<float>(item.mDepthIndex);
// Keep the renderitem pointer in the helper so we can quickly reorder items after sort.
- mSortingHelper[ index ].renderItem = &item;
+ mSortingHelper[index].renderItem = &item;
}
}
else
{
const Dali::Layer::SortFunctionType sortFunction = layer.GetSortFunction();
- for( uint32_t index = 0; index < renderableCount; ++index )
+ for(uint32_t index = 0; index < renderableCount; ++index)
{
- RenderItem& item = renderList.GetItem( index );
+ RenderItem& item = renderList.GetItem(index);
- item.mRenderer->SetSortAttributes( bufferIndex, mSortingHelper[ index ] );
+ item.mRenderer->SetSortAttributes(bufferIndex, mSortingHelper[index]);
// texture set
- mSortingHelper[ index ].textureSet = item.mTextureSet;
-
+ mSortingHelper[index].textureSet = item.mTextureSet;
- mSortingHelper[ index ].zValue = (*sortFunction)( item.mModelViewMatrix.GetTranslation3() ) - static_cast<float>( item.mDepthIndex );
+ mSortingHelper[index].zValue = (*sortFunction)(item.mModelViewMatrix.GetTranslation3()) - static_cast<float>(item.mDepthIndex);
// Keep the RenderItem pointer in the helper so we can quickly reorder items after sort.
- mSortingHelper[ index ].renderItem = &item;
+ mSortingHelper[index].renderItem = &item;
}
}
// 2 is LAYER_3D + Clipping
const unsigned int comparitorIndex = layer.GetBehavior() == Dali::Layer::LAYER_3D ? respectClippingOrder ? 2u : 1u : 0u;
- std::stable_sort( mSortingHelper.begin(), mSortingHelper.end(), mSortComparitors[ comparitorIndex ] );
+ std::stable_sort(mSortingHelper.begin(), mSortingHelper.end(), mSortComparitors[comparitorIndex]);
// Reorder / re-populate the RenderItems in the RenderList to correct order based on the sortinghelper.
- DALI_LOG_INFO( gRenderListLogFilter, Debug::Verbose, "Sorted Transparent List:\n");
+ DALI_LOG_INFO(gRenderListLogFilter, Debug::Verbose, "Sorted Transparent List:\n");
RenderItemContainer::Iterator renderListIter = renderList.GetContainer().Begin();
- for( uint32_t index = 0; index < renderableCount; ++index, ++renderListIter )
+ for(uint32_t index = 0; index < renderableCount; ++index, ++renderListIter)
{
- *renderListIter = mSortingHelper[ index ].renderItem;
- DALI_LOG_INFO( gRenderListLogFilter, Debug::Verbose, " sortedList[%d] = %p\n", index, mSortingHelper[ index ].renderItem->mRenderer);
+ *renderListIter = mSortingHelper[index].renderItem;
+ DALI_LOG_INFO(gRenderListLogFilter, Debug::Verbose, " sortedList[%d] = %p\n", index, mSortingHelper[index].renderItem->mRenderer);
}
}
-void RenderInstructionProcessor::Prepare( BufferIndex updateBufferIndex,
- SortedLayerPointers& sortedLayers,
- RenderTask& renderTask,
- bool cull,
- bool hasClippingNodes,
- RenderInstructionContainer& instructions )
+void RenderInstructionProcessor::Prepare(BufferIndex updateBufferIndex,
+ SortedLayerPointers& sortedLayers,
+ RenderTask& renderTask,
+ bool cull,
+ bool hasClippingNodes,
+ RenderInstructionContainer& instructions)
{
// Retrieve the RenderInstruction buffer from the RenderInstructionContainer
// then populate with instructions.
- RenderInstruction& instruction = renderTask.PrepareRenderInstruction( updateBufferIndex );
- bool viewMatrixHasNotChanged = !renderTask.ViewMatrixUpdated();
- bool isRenderListAdded = false;
- bool isRootLayerDirty = false;
+ RenderInstruction& instruction = renderTask.PrepareRenderInstruction(updateBufferIndex);
+ bool viewMatrixHasNotChanged = !renderTask.ViewMatrixUpdated();
+ bool isRenderListAdded = false;
+ bool isRootLayerDirty = false;
- const Matrix& viewMatrix = renderTask.GetViewMatrix( updateBufferIndex );
- SceneGraph::Camera& camera = renderTask.GetCamera();
+ const Matrix& viewMatrix = renderTask.GetViewMatrix(updateBufferIndex);
+ SceneGraph::Camera& camera = renderTask.GetCamera();
const SortedLayersIter endIter = sortedLayers.end();
- for( SortedLayersIter iter = sortedLayers.begin(); iter != endIter; ++iter )
+ for(SortedLayersIter iter = sortedLayers.begin(); iter != endIter; ++iter)
{
- Layer& layer = **iter;
- const bool tryReuseRenderList( viewMatrixHasNotChanged && layer.CanReuseRenderers( &renderTask.GetCamera() ) );
- const bool isLayer3D = layer.GetBehavior() == Dali::Layer::LAYER_3D;
+ Layer& layer = **iter;
+ const bool tryReuseRenderList(viewMatrixHasNotChanged && layer.CanReuseRenderers(&renderTask.GetCamera()));
+ const bool isLayer3D = layer.GetBehavior() == Dali::Layer::LAYER_3D;
RenderList* renderList = nullptr;
- if( layer.IsRoot() && ( layer.GetDirtyFlags() != NodePropertyFlags::NOTHING ) )
+ if(layer.IsRoot() && (layer.GetDirtyFlags() != NodePropertyFlags::NOTHING))
{
// If root-layer & dirty, i.e. a property has changed or a child has been deleted, then we need to ensure we render once more
isRootLayerDirty = true;
}
- if( !layer.colorRenderables.Empty() )
+ if(!layer.colorRenderables.Empty())
{
RenderableContainer& renderables = layer.colorRenderables;
- if( !SetupRenderList( renderables, layer, instruction, tryReuseRenderList, &renderList ) )
+ if(!SetupRenderList(renderables, layer, instruction, tryReuseRenderList, &renderList))
{
- renderList->SetHasColorRenderItems( true );
- AddRenderersToRenderList( updateBufferIndex,
- *renderList,
- renderables,
- viewMatrix,
- camera,
- isLayer3D,
- cull );
+ renderList->SetHasColorRenderItems(true);
+ AddRenderersToRenderList(updateBufferIndex,
+ *renderList,
+ renderables,
+ viewMatrix,
+ camera,
+ isLayer3D,
+ cull);
// We only use the clipping version of the sort comparitor if any clipping nodes exist within the RenderList.
- SortRenderItems( updateBufferIndex, *renderList, layer, hasClippingNodes );
+ SortRenderItems(updateBufferIndex, *renderList, layer, hasClippingNodes);
}
isRenderListAdded = true;
}
- if( !layer.overlayRenderables.Empty() )
+ if(!layer.overlayRenderables.Empty())
{
RenderableContainer& renderables = layer.overlayRenderables;
- if( !SetupRenderList( renderables, layer, instruction, tryReuseRenderList, &renderList ) )
+ if(!SetupRenderList(renderables, layer, instruction, tryReuseRenderList, &renderList))
{
- renderList->SetHasColorRenderItems( false );
- AddRenderersToRenderList( updateBufferIndex,
- *renderList,
- renderables,
- viewMatrix,
- camera,
- isLayer3D,
- cull );
+ renderList->SetHasColorRenderItems(false);
+ AddRenderersToRenderList(updateBufferIndex,
+ *renderList,
+ renderables,
+ viewMatrix,
+ camera,
+ isLayer3D,
+ cull);
// Clipping hierarchy is irrelevant when sorting overlay items, so we specify using the non-clipping version of the sort comparitor.
- SortRenderItems( updateBufferIndex, *renderList, layer, false );
+ SortRenderItems(updateBufferIndex, *renderList, layer, false);
}
isRenderListAdded = true;
// Inform the render instruction that all renderers have been added and this frame is complete.
instruction.UpdateCompleted();
- if( isRenderListAdded || instruction.mIsClearColorSet || isRootLayerDirty )
+ if(isRenderListAdded || instruction.mIsClearColorSet || isRootLayerDirty)
{
- instructions.PushBack( updateBufferIndex, &instruction );
+ instructions.PushBack(updateBufferIndex, &instruction);
}
}
-} // SceneGraph
+} // namespace SceneGraph
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_PROCESSOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace Render
{
class Geometry;
namespace SceneGraph
{
-
class RenderTracker;
struct RenderItem;
class Shader;
class RenderTask;
class RenderInstructionContainer;
-
/**
* @brief This class handles the sorting and preparation of Renderers for each layer.
*/
class RenderInstructionProcessor
{
public:
-
/**
* @brief Constructor.
*/
struct SortAttributes
{
SortAttributes()
- : renderItem( nullptr ),
- shader( nullptr ),
- textureSet( nullptr ),
- geometry( nullptr ),
- zValue( 0.0f )
+ : renderItem(nullptr),
+ shader(nullptr),
+ textureSet(nullptr),
+ geometry(nullptr),
+ zValue(0.0f)
{
}
- RenderItem* renderItem; ///< The render item that is being sorted (includes depth index)
- const Shader* shader; ///< The shader instance
- const void* textureSet; ///< The textureSet instance
- const Render::Geometry* geometry; ///< The geometry instance
- float zValue; ///< The Z value of the given renderer (either distance from camera, or a custom calculated value)
+ RenderItem* renderItem; ///< The render item that is being sorted (includes depth index)
+ const Shader* shader; ///< The shader instance
+ const void* textureSet; ///< The textureSet instance
+ const Render::Geometry* geometry; ///< The geometry instance
+ float zValue; ///< The Z value of the given renderer (either distance from camera, or a custom calculated value)
};
-
/**
* @brief Sorts and prepares the list of opaque/transparent Renderers for each layer.
* Whilst iterating through each layer, update the RenderItems ModelView matrices
* @param[in] hasClippingNodes Whether any clipping nodes exist within this layer, to optimize sorting if not
* @param[out] instructions The rendering instructions for the next frame.
*/
- void Prepare( BufferIndex updateBufferIndex,
- SortedLayerPointers& sortedLayers,
- RenderTask& renderTask,
- bool cull,
- bool hasClippingNodes,
- RenderInstructionContainer& instructions );
+ void Prepare(BufferIndex updateBufferIndex,
+ SortedLayerPointers& sortedLayers,
+ RenderTask& renderTask,
+ bool cull,
+ bool hasClippingNodes,
+ RenderInstructionContainer& instructions);
private:
-
/**
* Undefine copy and assignment operators.
*/
- RenderInstructionProcessor( const RenderInstructionProcessor& renderInstructionProcessor ); ///< No definition
- RenderInstructionProcessor& operator=( const RenderInstructionProcessor& renderInstructionProcessor ); ///< No definition
+ RenderInstructionProcessor(const RenderInstructionProcessor& renderInstructionProcessor); ///< No definition
+ RenderInstructionProcessor& operator=(const RenderInstructionProcessor& renderInstructionProcessor); ///< No definition
private:
-
/**
* @brief Sort render items
* @param bufferIndex The buffer to read from
* @param layer where the Renderers are from
* @param respectClippingOrder Sort with the correct clipping hierarchy.
*/
- inline void SortRenderItems( BufferIndex bufferIndex, RenderList& renderList, Layer& layer, bool respectClippingOrder );
+ inline void SortRenderItems(BufferIndex bufferIndex, RenderList& renderList, Layer& layer, bool respectClippingOrder);
/// Sort comparitor function pointer type.
- using ComparitorPointer = bool ( * )( const SortAttributes&, const SortAttributes& );
+ using ComparitorPointer = bool (*)(const SortAttributes&, const SortAttributes&);
using SortingHelper = std::vector<SortAttributes>;
- Dali::Vector< ComparitorPointer > mSortComparitors; ///< Contains all sort comparitors, used for quick look-up
- RenderInstructionProcessor::SortingHelper mSortingHelper; ///< Helper used to sort Renderers
-
+ Dali::Vector<ComparitorPointer> mSortComparitors; ///< Contains all sort comparitors, used for quick look-up
+ RenderInstructionProcessor::SortingHelper mSortingHelper; ///< Helper used to sort Renderers
};
-
} // namespace SceneGraph
} // namespace Internal
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/update/manager/render-task-processor.h>
// INTERNAL INCLUDES
-#include <dali/internal/update/manager/sorted-layers.h>
-#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
-#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
-#include <dali/internal/update/nodes/scene-graph-layer.h>
+#include <dali/integration-api/debug.h>
+#include <dali/internal/render/common/render-instruction-container.h>
+#include <dali/internal/render/common/render-instruction.h>
#include <dali/internal/render/common/render-item.h>
#include <dali/internal/render/common/render-tracker.h>
-#include <dali/internal/render/common/render-instruction.h>
-#include <dali/internal/render/common/render-instruction-container.h>
#include <dali/internal/render/renderers/render-renderer.h>
-#include <dali/integration-api/debug.h>
+#include <dali/internal/update/manager/sorted-layers.h>
+#include <dali/internal/update/nodes/scene-graph-layer.h>
+#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
+#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
#if defined(DEBUG_ENABLED)
extern Debug::Filter* gRenderTaskLogFilter;
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
namespace //Unnamed namespace
{
-
// Return false if the node or it's parents are exclusive to another render-task.
-bool CheckExclusivity( const Node& node, const RenderTask& task )
+bool CheckExclusivity(const Node& node, const RenderTask& task)
{
const RenderTask* exclusiveTo = node.GetExclusiveRenderTask();
- if( exclusiveTo )
+ if(exclusiveTo)
{
- return ( exclusiveTo == &task );
+ return (exclusiveTo == &task);
}
const Node* parent = node.GetParent();
- if ( parent )
+ if(parent)
{
- return CheckExclusivity( *parent, task );
+ return CheckExclusivity(*parent, task);
}
// No exclusive flags set.
return true;
}
-Layer* FindLayer( Node& node )
+Layer* FindLayer(Node& node)
{
- Node* currentNode( &node );
- Layer* layer( nullptr );
- while( currentNode )
+ Node* currentNode(&node);
+ Layer* layer(nullptr);
+ while(currentNode)
{
- if( ( layer = currentNode->GetLayer() ) != nullptr )
+ if((layer = currentNode->GetLayer()) != nullptr)
{
return layer;
}
* @param[out] clippingUsed Gets set to true if any clipping nodes have been found
* @return true if rendering should be kept, false otherwise.
*/
-bool AddRenderablesForTask( BufferIndex updateBufferIndex,
- Node& node,
- Layer& currentLayer,
- RenderTask& renderTask,
- int inheritedDrawMode,
- uint32_t& currentClippingId,
- uint32_t clippingDepth,
- uint32_t scissorDepth,
- bool& clippingUsed )
+bool AddRenderablesForTask(BufferIndex updateBufferIndex,
+ Node& node,
+ Layer& currentLayer,
+ RenderTask& renderTask,
+ int inheritedDrawMode,
+ uint32_t& currentClippingId,
+ uint32_t clippingDepth,
+ uint32_t scissorDepth,
+ bool& clippingUsed)
{
bool keepRendering = false;
// Short-circuit for invisible nodes
- if( !node.IsVisible( updateBufferIndex ) )
+ if(!node.IsVisible(updateBufferIndex))
{
return keepRendering;
}
// Check whether node is exclusive to a different render-task
const RenderTask* exclusiveTo = node.GetExclusiveRenderTask();
- if( exclusiveTo && ( exclusiveTo != &renderTask ) )
+ if(exclusiveTo && (exclusiveTo != &renderTask))
{
return keepRendering;
}
// Assume all children go to this layer (if this node is a layer).
Layer* layer = node.GetLayer();
- if( layer )
+ if(layer)
{
// Layers do not inherit the DrawMode from their parents
inheritedDrawMode = node.GetDrawMode();
inheritedDrawMode |= node.GetDrawMode();
}
- DALI_ASSERT_DEBUG( NULL != layer );
+ DALI_ASSERT_DEBUG(NULL != layer);
const uint32_t count = node.GetRendererCount();
// Update the clipping Id and depth for this node (if clipping is enabled).
const Dali::ClippingMode::Type clippingMode = node.GetClippingMode();
- if( DALI_UNLIKELY( clippingMode != ClippingMode::DISABLED ) )
+ if(DALI_UNLIKELY(clippingMode != ClippingMode::DISABLED))
{
- if( DALI_LIKELY( clippingMode == ClippingMode::CLIP_TO_BOUNDING_BOX ) )
+ if(DALI_LIKELY(clippingMode == ClippingMode::CLIP_TO_BOUNDING_BOX))
{
- ++scissorDepth; // This only modifies the local value (which is passed in when the method recurses).
+ ++scissorDepth; // This only modifies the local value (which is passed in when the method recurses).
// If we do not have any renderers, create one to house the scissor operation.
- if( count == 0u )
+ if(count == 0u)
{
- layer->colorRenderables.PushBack( Renderable( &node, nullptr ) );
+ layer->colorRenderables.PushBack(Renderable(&node, nullptr));
}
}
else
{
// We only need clipping Id for stencil clips. This means we can deliberately avoid modifying it for bounding box clips,
// thus allowing bounding box clipping to still detect clip depth changes without turning on the stencil buffer for non-clipped nodes.
- ++currentClippingId; // This modifies the reference passed in as well as the local value, causing the value to be global to the recursion.
- ++clippingDepth; // This only modifies the local value (which is passed in when the method recurses).
+ ++currentClippingId; // This modifies the reference passed in as well as the local value, causing the value to be global to the recursion.
+ ++clippingDepth; // This only modifies the local value (which is passed in when the method recurses).
}
clippingUsed = true;
}
// Set the information in the node.
- node.SetClippingInformation( currentClippingId, clippingDepth, scissorDepth );
+ node.SetClippingInformation(currentClippingId, clippingDepth, scissorDepth);
- RenderableContainer& target = DALI_LIKELY( inheritedDrawMode == DrawMode::NORMAL ) ?
- layer->colorRenderables : layer->overlayRenderables;
- for( uint32_t i = 0; i < count; ++i )
+ RenderableContainer& target = DALI_LIKELY(inheritedDrawMode == DrawMode::NORMAL) ? layer->colorRenderables : layer->overlayRenderables;
+ for(uint32_t i = 0; i < count; ++i)
{
- SceneGraph::Renderer* renderer = node.GetRendererAt( i );
- target.PushBack( Renderable( &node, renderer ) );
+ SceneGraph::Renderer* renderer = node.GetRendererAt(i);
+ target.PushBack(Renderable(&node, renderer));
- keepRendering = keepRendering || ( renderer->GetRenderingBehavior() == DevelRenderer::Rendering::CONTINUOUSLY );
+ keepRendering = keepRendering || (renderer->GetRenderingBehavior() == DevelRenderer::Rendering::CONTINUOUSLY);
}
// Recurse children.
NodeContainer& children = node.GetChildren();
- const NodeIter endIter = children.End();
- for( NodeIter iter = children.Begin(); iter != endIter; ++iter )
+ const NodeIter endIter = children.End();
+ for(NodeIter iter = children.Begin(); iter != endIter; ++iter)
{
Node& child = **iter;
- keepRendering |= AddRenderablesForTask( updateBufferIndex, child, *layer, renderTask, inheritedDrawMode, currentClippingId, clippingDepth, scissorDepth, clippingUsed );
+ keepRendering |= AddRenderablesForTask(updateBufferIndex, child, *layer, renderTask, inheritedDrawMode, currentClippingId, clippingDepth, scissorDepth, clippingUsed);
}
return keepRendering;
* @param[in] processOffscreen Whether the offscreen render tasks are the ones processed. Otherwise it processes the onscreen tasks.
* @return true if rendering should be kept, false otherwise.
*/
-bool ProcessTasks( BufferIndex updateBufferIndex,
- RenderTaskList::RenderTaskContainer& taskContainer,
- Layer& rootNode,
- SortedLayerPointers& sortedLayers,
- RenderInstructionContainer& instructions,
- RenderInstructionProcessor& renderInstructionProcessor,
- bool renderToFboEnabled,
- bool isRenderingToFbo,
- bool processOffscreen )
+bool ProcessTasks(BufferIndex updateBufferIndex,
+ RenderTaskList::RenderTaskContainer& taskContainer,
+ Layer& rootNode,
+ SortedLayerPointers& sortedLayers,
+ RenderInstructionContainer& instructions,
+ RenderInstructionProcessor& renderInstructionProcessor,
+ bool renderToFboEnabled,
+ bool isRenderingToFbo,
+ bool processOffscreen)
{
- uint32_t clippingId = 0u;
- bool hasClippingNodes = false;
+ uint32_t clippingId = 0u;
+ bool hasClippingNodes = false;
bool isFirstRenderTask = true;
- bool keepRendering = false;
- for( RenderTaskList::RenderTaskContainer::Iterator iter = taskContainer.Begin(), endIter = taskContainer.End(); endIter != iter; ++iter )
+ bool keepRendering = false;
+ for(RenderTaskList::RenderTaskContainer::Iterator iter = taskContainer.Begin(), endIter = taskContainer.End(); endIter != iter; ++iter)
{
RenderTask& renderTask = **iter;
- const bool hasFrameBuffer = nullptr != renderTask.GetFrameBuffer();
+ const bool hasFrameBuffer = nullptr != renderTask.GetFrameBuffer();
const bool isDefaultRenderTask = isFirstRenderTask;
- isFirstRenderTask = false;
-
- if( ( !renderToFboEnabled && ( ( !processOffscreen && hasFrameBuffer ) ||
- ( processOffscreen && !hasFrameBuffer ) ) ) ||
- ( renderToFboEnabled && ( ( processOffscreen && !hasFrameBuffer ) ||
- ( isDefaultRenderTask && processOffscreen ) ||
- ( !isDefaultRenderTask && !processOffscreen && hasFrameBuffer ) ) ) ||
- !renderTask.ReadyToRender( updateBufferIndex ) )
+ isFirstRenderTask = false;
+
+ if((!renderToFboEnabled && ((!processOffscreen && hasFrameBuffer) ||
+ (processOffscreen && !hasFrameBuffer))) ||
+ (renderToFboEnabled && ((processOffscreen && !hasFrameBuffer) ||
+ (isDefaultRenderTask && processOffscreen) ||
+ (!isDefaultRenderTask && !processOffscreen && hasFrameBuffer))) ||
+ !renderTask.ReadyToRender(updateBufferIndex))
{
// Skip to next task.
continue;
}
Node* sourceNode = renderTask.GetSourceNode();
- DALI_ASSERT_DEBUG( NULL != sourceNode ); // Otherwise Prepare() should return false
+ DALI_ASSERT_DEBUG(NULL != sourceNode); // Otherwise Prepare() should return false
// Check that the source node is not exclusive to another task.
- if( !CheckExclusivity( *sourceNode, renderTask ) )
+ if(!CheckExclusivity(*sourceNode, renderTask))
{
continue;
}
- Layer* layer = FindLayer( *sourceNode );
- if( !layer )
+ Layer* layer = FindLayer(*sourceNode);
+ if(!layer)
{
// Skip to next task as no layer.
continue;
}
- const uint32_t currentNumberOfInstructions = instructions.Count( updateBufferIndex );
+ const uint32_t currentNumberOfInstructions = instructions.Count(updateBufferIndex);
- if( renderTask.IsRenderRequired() )
+ if(renderTask.IsRenderRequired())
{
- for( auto&& sortedLayer : sortedLayers )
+ for(auto&& sortedLayer : sortedLayers)
{
sortedLayer->ClearRenderables();
}
- keepRendering |= AddRenderablesForTask( updateBufferIndex,
- *sourceNode,
- *layer,
- renderTask,
- sourceNode->GetDrawMode(),
- clippingId,
- 0u,
- 0u,
- hasClippingNodes );
-
- renderInstructionProcessor.Prepare( updateBufferIndex,
- sortedLayers,
- renderTask,
- renderTask.GetCullMode(),
- hasClippingNodes,
- instructions );
+ keepRendering |= AddRenderablesForTask(updateBufferIndex,
+ *sourceNode,
+ *layer,
+ renderTask,
+ sourceNode->GetDrawMode(),
+ clippingId,
+ 0u,
+ 0u,
+ hasClippingNodes);
+
+ renderInstructionProcessor.Prepare(updateBufferIndex,
+ sortedLayers,
+ renderTask,
+ renderTask.GetCullMode(),
+ hasClippingNodes,
+ instructions);
}
- if( !processOffscreen && isDefaultRenderTask && renderToFboEnabled && !isRenderingToFbo && hasFrameBuffer )
+ if(!processOffscreen && isDefaultRenderTask && renderToFboEnabled && !isRenderingToFbo && hasFrameBuffer)
{
// Traverse the instructions of the default render task and mark them to be rendered into the frame buffer.
- const uint32_t count = instructions.Count( updateBufferIndex );
- for( uint32_t index = currentNumberOfInstructions; index < count; ++index )
+ const uint32_t count = instructions.Count(updateBufferIndex);
+ for(uint32_t index = currentNumberOfInstructions; index < count; ++index)
{
- RenderInstruction& instruction = instructions.At( updateBufferIndex, index );
+ RenderInstruction& instruction = instructions.At(updateBufferIndex, index);
instruction.mIgnoreRenderToFbo = true;
}
}
RenderTaskProcessor::~RenderTaskProcessor() = default;
-bool RenderTaskProcessor::Process( BufferIndex updateBufferIndex,
- RenderTaskList& renderTasks,
- Layer& rootNode,
- SortedLayerPointers& sortedLayers,
- RenderInstructionContainer& instructions,
- bool renderToFboEnabled,
- bool isRenderingToFbo )
+bool RenderTaskProcessor::Process(BufferIndex updateBufferIndex,
+ RenderTaskList& renderTasks,
+ Layer& rootNode,
+ SortedLayerPointers& sortedLayers,
+ RenderInstructionContainer& instructions,
+ bool renderToFboEnabled,
+ bool isRenderingToFbo)
{
RenderTaskList::RenderTaskContainer& taskContainer = renderTasks.GetTasks();
- bool keepRendering = false;
+ bool keepRendering = false;
- if( taskContainer.IsEmpty() )
+ if(taskContainer.IsEmpty())
{
// Early-exit if there are no tasks to process
return keepRendering;
// 3) Traverse the scene-graph, filling the lists for the current render-task
// 4) Prepare render-instructions
- DALI_LOG_INFO( gRenderTaskLogFilter, Debug::General, "RenderTaskProcessor::Process() Offscreens first\n" );
+ DALI_LOG_INFO(gRenderTaskLogFilter, Debug::General, "RenderTaskProcessor::Process() Offscreens first\n");
// First process off screen render tasks - we may need the results of these for the on screen renders
- keepRendering = ProcessTasks( updateBufferIndex,
+ keepRendering = ProcessTasks(updateBufferIndex,
+ taskContainer,
+ rootNode,
+ sortedLayers,
+ instructions,
+ mRenderInstructionProcessor,
+ renderToFboEnabled,
+ isRenderingToFbo,
+ true);
+
+ DALI_LOG_INFO(gRenderTaskLogFilter, Debug::General, "RenderTaskProcessor::Process() Onscreen\n");
+
+ // Now that the off screen renders are done we can process on screen render tasks.
+ // Reset the clipping Id for the OnScreen render tasks.
+
+ keepRendering |= ProcessTasks(updateBufferIndex,
taskContainer,
rootNode,
sortedLayers,
mRenderInstructionProcessor,
renderToFboEnabled,
isRenderingToFbo,
- true );
-
- DALI_LOG_INFO( gRenderTaskLogFilter, Debug::General, "RenderTaskProcessor::Process() Onscreen\n" );
-
- // Now that the off screen renders are done we can process on screen render tasks.
- // Reset the clipping Id for the OnScreen render tasks.
-
- keepRendering |= ProcessTasks( updateBufferIndex,
- taskContainer,
- rootNode,
- sortedLayers,
- instructions,
- mRenderInstructionProcessor,
- renderToFboEnabled,
- isRenderingToFbo,
- false );
+ false);
return keepRendering;
}
-} // SceneGraph
+} // namespace SceneGraph
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_PROCESSOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/update/manager/sorted-layers.h>
#include <dali/internal/update/manager/render-instruction-processor.h>
+#include <dali/internal/update/manager/sorted-layers.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
class RenderTaskList;
/**
class RenderTaskProcessor
{
public:
-
/**
* @brief Constructor.
*/
* @param[in] isRenderingToFbo Whether this frame is being rendered into the Frame Buffer Object (used to measure FPS above 60)
* @return true if rendering should be kept, false otherwise.
*/
- bool Process( BufferIndex updateBufferIndex,
- RenderTaskList& renderTasks,
- Layer& rootNode,
- SortedLayerPointers& sortedLayers,
- RenderInstructionContainer& instructions,
- bool renderToFboEnabled,
- bool isRenderingToFbo );
+ bool Process(BufferIndex updateBufferIndex,
+ RenderTaskList& renderTasks,
+ Layer& rootNode,
+ SortedLayerPointers& sortedLayers,
+ RenderInstructionContainer& instructions,
+ bool renderToFboEnabled,
+ bool isRenderingToFbo);
private:
-
/**
* Undefine copy and assignment operators.
*/
- RenderTaskProcessor( const RenderTaskProcessor& renderTaskProcessor ); ///< No definition
- RenderTaskProcessor& operator=( const RenderTaskProcessor& renderTaskProcessor ); ///< No definition
+ RenderTaskProcessor(const RenderTaskProcessor& renderTaskProcessor); ///< No definition
+ RenderTaskProcessor& operator=(const RenderTaskProcessor& renderTaskProcessor); ///< No definition
private:
-
RenderInstructionProcessor mRenderInstructionProcessor; ///< An instance of the RenderInstructionProcessor used to sort and handle the renderers for each layer.
};
-
} // namespace SceneGraph
} // namespace Internal
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
-FrameCallback* FrameCallback::New( FrameCallbackInterface& frameCallbackInterface )
+FrameCallback* FrameCallback::New(FrameCallbackInterface& frameCallbackInterface)
{
- return new FrameCallback( &frameCallbackInterface );
+ return new FrameCallback(&frameCallbackInterface);
}
FrameCallback::~FrameCallback()
{
- if( mUpdateProxy )
+ if(mUpdateProxy)
{
- mUpdateProxy->GetRootNode().RemoveObserver( *this );
+ mUpdateProxy->GetRootNode().RemoveObserver(*this);
}
{
- Mutex::ScopedLock lock( mMutex );
- if( mFrameCallbackInterface )
+ Mutex::ScopedLock lock(mMutex);
+ if(mFrameCallbackInterface)
{
- FrameCallbackInterface::Impl::Get( *mFrameCallbackInterface ).DisconnectFromSceneGraphObject();
+ FrameCallbackInterface::Impl::Get(*mFrameCallbackInterface).DisconnectFromSceneGraphObject();
}
}
}
-void FrameCallback::ConnectToSceneGraph( UpdateManager& updateManager, TransformManager& transformManager, Node& rootNode )
+void FrameCallback::ConnectToSceneGraph(UpdateManager& updateManager, TransformManager& transformManager, Node& rootNode)
{
- mUpdateProxy = std::unique_ptr< UpdateProxy >( new UpdateProxy( updateManager, transformManager, rootNode ) );
- rootNode.AddObserver( *this );
+ mUpdateProxy = std::unique_ptr<UpdateProxy>(new UpdateProxy(updateManager, transformManager, rootNode));
+ rootNode.AddObserver(*this);
}
-bool FrameCallback::Update( BufferIndex bufferIndex, float elapsedSeconds, bool nodeHierarchyChanged )
+bool FrameCallback::Update(BufferIndex bufferIndex, float elapsedSeconds, bool nodeHierarchyChanged)
{
bool continueCalling = false;
- if( mUpdateProxy )
+ if(mUpdateProxy)
{
- mUpdateProxy->SetCurrentBufferIndex( bufferIndex );
+ mUpdateProxy->SetCurrentBufferIndex(bufferIndex);
- if( nodeHierarchyChanged )
+ if(nodeHierarchyChanged)
{
mUpdateProxy->NodeHierarchyChanged();
}
- Mutex::ScopedLock lock( mMutex );
- if( mFrameCallbackInterface )
+ Mutex::ScopedLock lock(mMutex);
+ if(mFrameCallbackInterface)
{
- Dali::UpdateProxy updateProxy( *mUpdateProxy );
- mFrameCallbackInterface->Update( updateProxy, elapsedSeconds );
+ Dali::UpdateProxy updateProxy(*mUpdateProxy);
+ mFrameCallbackInterface->Update(updateProxy, elapsedSeconds);
continueCalling = true;
}
}
void FrameCallback::Invalidate()
{
- Mutex::ScopedLock lock( mMutex );
- if( mFrameCallbackInterface )
+ Mutex::ScopedLock lock(mMutex);
+ if(mFrameCallbackInterface)
{
- FrameCallbackInterface::Impl::Get( *mFrameCallbackInterface ).DisconnectFromSceneGraphObject();
+ FrameCallbackInterface::Impl::Get(*mFrameCallbackInterface).DisconnectFromSceneGraphObject();
mFrameCallbackInterface = nullptr;
}
}
-void FrameCallback::PropertyOwnerDestroyed( PropertyOwner& owner )
+void FrameCallback::PropertyOwnerDestroyed(PropertyOwner& owner)
{
Invalidate();
}
-FrameCallback::FrameCallback( FrameCallbackInterface* frameCallbackInterface )
+FrameCallback::FrameCallback(FrameCallbackInterface* frameCallbackInterface)
: mMutex(),
- mFrameCallbackInterface( frameCallbackInterface )
+ mFrameCallbackInterface(frameCallbackInterface)
{
- if( frameCallbackInterface )
+ if(frameCallbackInterface)
{
- FrameCallbackInterface::Impl::Get( *mFrameCallbackInterface ).ConnectToSceneGraphObject( *this );
+ FrameCallbackInterface::Impl::Get(*mFrameCallbackInterface).ConnectToSceneGraphObject(*this);
}
}
#define DALI_INTERNAL_SCENE_GRAPH_FRAME_CALLBACK_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
class Node;
class TransformManager;
class FrameCallback final : public PropertyOwner::Observer
{
public:
-
/**
* Creates a new FrameCallback.
* @param[in] frameCallbackInterface A reference to the FrameCallbackInterface implementation
* @return A new FrameCallback.
*/
- static FrameCallback* New( FrameCallbackInterface& frameCallbackInterface );
+ static FrameCallback* New(FrameCallbackInterface& frameCallbackInterface);
/**
* Non-virtual Destructor.
* @param[in] transformManager The Transform Manager
* @param[in] rootNode The rootNode of this frame-callback
*/
- void ConnectToSceneGraph( UpdateManager& updateManager, TransformManager& transformManager, Node& rootNode );
+ void ConnectToSceneGraph(UpdateManager& updateManager, TransformManager& transformManager, Node& rootNode);
// Movable but not copyable
- FrameCallback( const FrameCallback& ) = delete; ///< Deleted copy constructor.
- FrameCallback( FrameCallback&& ) = default; ///< Default move constructor.
- FrameCallback& operator=( const FrameCallback& ) = delete; ///< Deleted copy assignment operator.
- FrameCallback& operator=( FrameCallback&& ) = default; ///< Default move assignment operator.
+ FrameCallback(const FrameCallback&) = delete; ///< Deleted copy constructor.
+ FrameCallback(FrameCallback&&) = default; ///< Default move constructor.
+ FrameCallback& operator=(const FrameCallback&) = delete; ///< Deleted copy assignment operator.
+ FrameCallback& operator=(FrameCallback&&) = default; ///< Default move assignment operator.
/**
* Called from the update-thread after the scene has been updated, and is ready to render.
* @param[in] nodeHierarchyChanged Whether the node hierarchy has changed
* @return Whether to continue calling this FrameCallback or not.
*/
- bool Update( BufferIndex bufferIndex, float elapsedSeconds, bool nodeHierarchyChanged );
+ bool Update(BufferIndex bufferIndex, float elapsedSeconds, bool nodeHierarchyChanged);
/**
* Invalidates this FrameCallback and will no longer be associated with the FrameCallbackInterface.
* @param[in] iFace The FrameCallbackInterface pointer to compare with
* @return True if iFace matches our internally stored FrameCallbackInterface.
*/
- inline bool operator==( const FrameCallbackInterface* iFace )
+ inline bool operator==(const FrameCallbackInterface* iFace)
{
return mFrameCallbackInterface == iFace;
}
private:
-
// From PropertyOwner::Observer
/**
* @copydoc PropertyOwner::Observer::PropertyOwnerConnected()
*/
- void PropertyOwnerConnected( PropertyOwner& owner ) override { /* Nothing to do */ }
+ void PropertyOwnerConnected(PropertyOwner& owner) override
+ { /* Nothing to do */
+ }
/**
* @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected()
*/
- void PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner ) override { /* Nothing to do */ }
+ void PropertyOwnerDisconnected(BufferIndex updateBufferIndex, PropertyOwner& owner) override
+ { /* Nothing to do */
+ }
/**
* @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected()
*
* Will use this to disconnect the frame-callback if the accompanying node is destroyed
*/
- void PropertyOwnerDestroyed( PropertyOwner& owner ) override;
+ void PropertyOwnerDestroyed(PropertyOwner& owner) override;
// Construction
* Constructor.
* @param[in] frameCallbackInterface A pointer to the FrameCallbackInterface implementation
*/
- FrameCallback( FrameCallbackInterface* frameCallbackInterface );
+ FrameCallback(FrameCallbackInterface* frameCallbackInterface);
private:
-
- Mutex mMutex;
- std::unique_ptr< UpdateProxy > mUpdateProxy{ nullptr }; ///< A unique pointer to the implementation of the UpdateProxy.
- FrameCallbackInterface* mFrameCallbackInterface;
+ Mutex mMutex;
+ std::unique_ptr<UpdateProxy> mUpdateProxy{nullptr}; ///< A unique pointer to the implementation of the UpdateProxy.
+ FrameCallbackInterface* mFrameCallbackInterface;
};
/**
* @param[in] iFace The FrameCallbackInterface pointer
* @return True if iFace matches the internally stored FrameCallbackInterface.
*/
-inline bool operator==( const OwnerPointer< FrameCallback >& frameCallback, const FrameCallbackInterface* iFace )
+inline bool operator==(const OwnerPointer<FrameCallback>& frameCallback, const FrameCallbackInterface* iFace)
{
return *frameCallback == iFace;
}
#define DALI_INTERNAL_SCENE_GRAPH_SORTED_LAYERS_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
class Layer;
/**
* A container of Layer pointers sorted by depth
*/
-using SortedLayerPointers = std::vector<Layer *>;
+using SortedLayerPointers = std::vector<Layer*>;
using SortedLayersIter = SortedLayerPointers::iterator;
using SortedLayersConstIter = SortedLayerPointers::const_iterator;
#define TRANSFORM_MANAGER_PROPERTY_H_
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
-#include <dali/internal/update/manager/transform-manager.h>
#include <dali/internal/update/common/animatable-property.h>
+#include <dali/internal/update/manager/transform-manager.h>
namespace Dali
{
{
namespace SceneGraph
{
-
-template <typename T>
+template<typename T>
struct TransformManagerPropertyHandler : public AnimatablePropertyBase
{
/**
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- virtual T& Get( BufferIndex bufferIndex ) = 0;
+ virtual T& Get(BufferIndex bufferIndex) = 0;
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- virtual const T& Get( BufferIndex bufferIndex ) const = 0;
+ virtual const T& Get(BufferIndex bufferIndex) const = 0;
/**
* @copydoc Dali::PropertyInput::GetVector3()
*/
- const Vector3& GetVector3( BufferIndex bufferIndex ) const override{ return Vector3::ZERO; }
+ const Vector3& GetVector3(BufferIndex bufferIndex) const override
+ {
+ return Vector3::ZERO;
+ }
/**
* Retrieve a component of property
*/
virtual const float& GetFloatComponent(uint32_t component) const
{
- DALI_ASSERT_DEBUG( 0 && "Invalid call");
+ DALI_ASSERT_DEBUG(0 && "Invalid call");
static const float value = 0.0f;
return value;
* @param[in] value The new value of the component
* @param[in] component The component of the property
*/
- virtual void SetFloatComponent( float value, uint32_t component){}
+ virtual void SetFloatComponent(float value, uint32_t component)
+ {
+ }
/**
* @copydoc Dali::AnimatableProperty::Bake()
* @param[in] value The new value of the component
* @param[in] component The component of the property
*/
- virtual void BakeFloatComponent( float value, uint32_t component){}
+ virtual void BakeFloatComponent(float value, uint32_t component)
+ {
+ }
/**
* @copydoc Dali::AnimatableProperty::BakeX()
*/
- virtual void BakeX(BufferIndex bufferIndex, float value){}
+ virtual void BakeX(BufferIndex bufferIndex, float value)
+ {
+ }
/**
* @copydoc Dali::AnimatableProperty::BakeY()
*/
- virtual void BakeY(BufferIndex bufferIndex, float value){}
+ virtual void BakeY(BufferIndex bufferIndex, float value)
+ {
+ }
/**
* @copydoc Dali::AnimatableProperty::BakeZ()
*/
- virtual void BakeZ(BufferIndex bufferIndex, float value){}
+ virtual void BakeZ(BufferIndex bufferIndex, float value)
+ {
+ }
/**
* @copydoc Dali::AnimatableProperty::BakeRelative()
/**
* @copydoc Dali::AnimatableProperty::ResetToBaseValue()
*/
- void ResetToBaseValue(BufferIndex updateBufferIndex) override{}
+ void ResetToBaseValue(BufferIndex updateBufferIndex) override
+ {
+ }
/**
* @copydoc Dali::AnimatableProperty::IsClean()
*/
- bool IsClean() const override{ return false; }
+ bool IsClean() const override
+ {
+ return false;
+ }
/**
* Initializes the property
* @param[in] transformManager Pointer to the transform manager
* @param[in] Id of the transformation the property is associated with
*/
- void Initialize( TransformManagerData* data)
+ void Initialize(TransformManagerData* data)
{
- DALI_ASSERT_ALWAYS( data != nullptr && data->Manager() != nullptr);
+ DALI_ASSERT_ALWAYS(data != nullptr && data->Manager() != nullptr);
mTxManagerData = data;
}
template<TransformManagerProperty PropertyT>
struct TransformManagerPropertyVector3 final : public TransformManagerPropertyHandler<Vector3>
{
-
TransformManagerPropertyVector3() = default;
Dali::Property::Type GetType() const override
return Dali::PropertyTypes::Get<Vector3>();
}
- Vector3& Get( BufferIndex bufferIndex ) override
+ Vector3& Get(BufferIndex bufferIndex) override
{
- return mTxManagerData->Manager()->GetVector3PropertyValue( mTxManagerData->Id(), PropertyT );
+ return mTxManagerData->Manager()->GetVector3PropertyValue(mTxManagerData->Id(), PropertyT);
}
- const Vector3& Get( BufferIndex bufferIndex ) const override
+ const Vector3& Get(BufferIndex bufferIndex) const override
{
- return mTxManagerData->Manager()->GetVector3PropertyValue( mTxManagerData->Id(), PropertyT );
+ return mTxManagerData->Manager()->GetVector3PropertyValue(mTxManagerData->Id(), PropertyT);
}
- const Vector3& GetVector3( BufferIndex bufferIndex ) const override
+ const Vector3& GetVector3(BufferIndex bufferIndex) const override
{
return Get(bufferIndex);
}
- const float& GetFloatComponent( uint32_t component ) const override
+ const float& GetFloatComponent(uint32_t component) const override
{
- return mTxManagerData->Manager()->GetVector3PropertyComponentValue( mTxManagerData->Id(), PropertyT, component );
+ return mTxManagerData->Manager()->GetVector3PropertyComponentValue(mTxManagerData->Id(), PropertyT, component);
}
void Set(BufferIndex bufferIndex, const Vector3& value) override
{
- mTxManagerData->Manager()->SetVector3PropertyValue( mTxManagerData->Id(), PropertyT, value );
+ mTxManagerData->Manager()->SetVector3PropertyValue(mTxManagerData->Id(), PropertyT, value);
}
void SetComponent(BufferIndex bufferIndex, float value, uint32_t component)
{
- mTxManagerData->Manager()->SetVector3PropertyComponentValue( mTxManagerData->Id(), PropertyT, value, component);
+ mTxManagerData->Manager()->SetVector3PropertyComponentValue(mTxManagerData->Id(), PropertyT, value, component);
}
void BakeComponent(BufferIndex bufferIndex, float value, uint32_t component)
{
- mTxManagerData->Manager()->BakeVector3PropertyComponentValue( mTxManagerData->Id(), PropertyT, value, component);
+ mTxManagerData->Manager()->BakeVector3PropertyComponentValue(mTxManagerData->Id(), PropertyT, value, component);
}
void Bake(BufferIndex bufferIndex, const Vector3& value) override
{
- mTxManagerData->Manager()->BakeVector3PropertyValue(mTxManagerData->Id(), PropertyT, value );
+ mTxManagerData->Manager()->BakeVector3PropertyValue(mTxManagerData->Id(), PropertyT, value);
}
void BakeX(BufferIndex bufferIndex, float value) override
{
- mTxManagerData->Manager()->BakeXVector3PropertyValue(mTxManagerData->Id(), PropertyT, value );
+ mTxManagerData->Manager()->BakeXVector3PropertyValue(mTxManagerData->Id(), PropertyT, value);
}
void BakeY(BufferIndex bufferIndex, float value) override
{
- mTxManagerData->Manager()->BakeYVector3PropertyValue(mTxManagerData->Id(), PropertyT, value );
+ mTxManagerData->Manager()->BakeYVector3PropertyValue(mTxManagerData->Id(), PropertyT, value);
}
void BakeZ(BufferIndex bufferIndex, float value) override
{
- mTxManagerData->Manager()->BakeZVector3PropertyValue(mTxManagerData->Id(), PropertyT, value );
+ mTxManagerData->Manager()->BakeZVector3PropertyValue(mTxManagerData->Id(), PropertyT, value);
}
- void SetFloatComponent( float value, uint32_t component) override
+ void SetFloatComponent(float value, uint32_t component) override
{
- mTxManagerData->Manager()->SetVector3PropertyComponentValue( mTxManagerData->Id(), PropertyT, value, component);
+ mTxManagerData->Manager()->SetVector3PropertyComponentValue(mTxManagerData->Id(), PropertyT, value, component);
}
- void BakeFloatComponent( float value, uint32_t component ) override
+ void BakeFloatComponent(float value, uint32_t component) override
{
- mTxManagerData->Manager()->BakeVector3PropertyComponentValue( mTxManagerData->Id(), PropertyT, value, component);
+ mTxManagerData->Manager()->BakeVector3PropertyComponentValue(mTxManagerData->Id(), PropertyT, value, component);
}
void BakeRelative(BufferIndex bufferIndex, const Vector3& value) override
{
- mTxManagerData->Manager()->BakeRelativeVector3PropertyValue(mTxManagerData->Id(), PropertyT, value );
+ mTxManagerData->Manager()->BakeRelativeVector3PropertyValue(mTxManagerData->Id(), PropertyT, value);
}
void BakeRelativeMultiply(BufferIndex bufferIndex, const Vector3& value) override
{
- mTxManagerData->Manager()->BakeMultiplyVector3PropertyValue(mTxManagerData->Id(), PropertyT, value );
+ mTxManagerData->Manager()->BakeMultiplyVector3PropertyValue(mTxManagerData->Id(), PropertyT, value);
}
};
class TransformManagerPropertyQuaternion final : public TransformManagerPropertyHandler<Quaternion>
{
public:
-
TransformManagerPropertyQuaternion() = default;
Dali::Property::Type GetType() const override
return Dali::PropertyTypes::Get<Quaternion>();
}
- Quaternion& Get( BufferIndex bufferIndex ) override
+ Quaternion& Get(BufferIndex bufferIndex) override
{
- return mTxManagerData->Manager()->GetQuaternionPropertyValue( mTxManagerData->Id() );
+ return mTxManagerData->Manager()->GetQuaternionPropertyValue(mTxManagerData->Id());
}
- const Quaternion& Get( BufferIndex bufferIndex ) const override
+ const Quaternion& Get(BufferIndex bufferIndex) const override
{
- return mTxManagerData->Manager()->GetQuaternionPropertyValue( mTxManagerData->Id() );
+ return mTxManagerData->Manager()->GetQuaternionPropertyValue(mTxManagerData->Id());
}
void Set(BufferIndex bufferIndex, const Quaternion& value) override
{
- return mTxManagerData->Manager()->SetQuaternionPropertyValue( mTxManagerData->Id(), value );
+ return mTxManagerData->Manager()->SetQuaternionPropertyValue(mTxManagerData->Id(), value);
}
void Bake(BufferIndex bufferIndex, const Quaternion& value) override
{
- return mTxManagerData->Manager()->BakeQuaternionPropertyValue( mTxManagerData->Id(), value );
+ return mTxManagerData->Manager()->BakeQuaternionPropertyValue(mTxManagerData->Id(), value);
}
void BakeRelative(BufferIndex bufferIndex, const Quaternion& value) override
{
- return mTxManagerData->Manager()->BakeRelativeQuaternionPropertyValue( mTxManagerData->Id(), value );
+ return mTxManagerData->Manager()->BakeRelativeQuaternionPropertyValue(mTxManagerData->Id(), value);
}
- const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const override
+ const Quaternion& GetQuaternion(BufferIndex bufferIndex) const override
{
return Get(bufferIndex);
}
-
};
/**
class TransformManagerVector3Input : public PropertyInputImpl
{
public:
-
/**
* Create an TransformManagerVector3Input
*/
- TransformManagerVector3Input( TransformManagerProperty property, const Vector3& initialValue )
- :mProperty(property),
- mValue(initialValue)
- {}
+ TransformManagerVector3Input(TransformManagerProperty property, const Vector3& initialValue)
+ : mProperty(property),
+ mValue(initialValue)
+ {
+ }
/**
* Virtual destructor.
*/
void ComputeTransformComponent() const
{
- if( mTxManagerData )
+ if(mTxManagerData)
{
const Matrix& worldMatrix = mTxManagerData->Manager()->GetWorldMatrix(mTxManagerData->Id());
- if( mProperty == TRANSFORM_PROPERTY_WORLD_POSITION )
+ if(mProperty == TRANSFORM_PROPERTY_WORLD_POSITION)
{
mValue = worldMatrix.GetTranslation3();
}
- else if( mProperty == TRANSFORM_PROPERTY_WORLD_SCALE )
+ else if(mProperty == TRANSFORM_PROPERTY_WORLD_SCALE)
{
- Vector3 position;
+ Vector3 position;
Quaternion orientation;
worldMatrix.GetTransformComponents(position, orientation, mValue);
}
/**
* @copydoc Dali::PropertyInput::GetVector3()
*/
- const Vector3& GetVector3( BufferIndex bufferIndex ) const override
+ const Vector3& GetVector3(BufferIndex bufferIndex) const override
{
ComputeTransformComponent();
return mValue;
/**
* @copydoc Dali::PropertyInput::GetConstraintInputVector3()
*/
- const Vector3& GetConstraintInputVector3( BufferIndex bufferIndex ) const override
+ const Vector3& GetConstraintInputVector3(BufferIndex bufferIndex) const override
{
ComputeTransformComponent();
return mValue;
/**
* @copydoc Dali::SceneGraph::PropertyInterface::Get()
*/
- Vector3& Get( BufferIndex bufferIndex )
+ Vector3& Get(BufferIndex bufferIndex)
{
ComputeTransformComponent();
return mValue;
/**
* @copydoc Dali::SceneGraph::PropertyInterface::Get()
*/
- const Vector3& Get( BufferIndex bufferIndex ) const
+ const Vector3& Get(BufferIndex bufferIndex) const
{
ComputeTransformComponent();
return mValue;
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Vector3& operator[]( BufferIndex bufferIndex ) const
+ const Vector3& operator[](BufferIndex bufferIndex) const
{
ComputeTransformComponent();
return mValue;
* @param[in] transformManager Pointer to the transform manager
* @param[in] Id of the transformation the property is associated with
*/
- void Initialize( TransformManagerData* data)
+ void Initialize(TransformManagerData* data)
{
- DALI_ASSERT_ALWAYS( data != nullptr && data->Manager() != nullptr);
+ DALI_ASSERT_ALWAYS(data != nullptr && data->Manager() != nullptr);
mTxManagerData = data;
}
}
private:
-
// Undefined
TransformManagerVector3Input(const TransformManagerVector3Input& property);
TransformManagerVector3Input& operator=(const TransformManagerVector3Input& rhs);
public:
-
- TransformManagerData* mTxManagerData{nullptr};
+ TransformManagerData* mTxManagerData{nullptr};
TransformManagerProperty mProperty;
- mutable Vector3 mValue;
+ mutable Vector3 mValue;
};
/**
class TransformManagerQuaternionInput final : public PropertyInputImpl
{
public:
-
/**
* Constructor
*/
*/
void ComputeTransformComponent() const
{
- if( mTxManagerData )
+ if(mTxManagerData)
{
const Matrix& worldMatrix = mTxManagerData->Manager()->GetWorldMatrix(mTxManagerData->Id());
- Vector3 position, scale;
+ Vector3 position, scale;
worldMatrix.GetTransformComponents(position, mValue, scale);
}
}
/**
* @copydoc Dali::PropertyInput::GetQuaternion()
*/
- const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const override
+ const Quaternion& GetQuaternion(BufferIndex bufferIndex) const override
{
ComputeTransformComponent();
return mValue;
/**
* @copydoc Dali::PropertyInput::GetConstraintInputQuaternion()
*/
- const Quaternion& GetConstraintInputQuaternion( BufferIndex bufferIndex ) const override
+ const Quaternion& GetConstraintInputQuaternion(BufferIndex bufferIndex) const override
{
ComputeTransformComponent();
return mValue;
/**
* @copydoc Dali::SceneGraph::PropertyInterface::Get()
*/
- Quaternion& Get( BufferIndex bufferIndex )
+ Quaternion& Get(BufferIndex bufferIndex)
{
ComputeTransformComponent();
return mValue;
/**
* @copydoc Dali::SceneGraph::PropertyInterface::Get()
*/
- const Quaternion& Get( BufferIndex bufferIndex ) const
+ const Quaternion& Get(BufferIndex bufferIndex) const
{
ComputeTransformComponent();
return mValue;
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Quaternion& operator[]( BufferIndex bufferIndex) const
+ const Quaternion& operator[](BufferIndex bufferIndex) const
{
ComputeTransformComponent();
return mValue;
* @param[in] transformManager Pointer to the transform manager
* @param[in] Id of the transformation the property is associated with
*/
- void Initialize( TransformManagerData* data)
+ void Initialize(TransformManagerData* data)
{
- DALI_ASSERT_ALWAYS( data != nullptr && data->Manager() != nullptr);
+ DALI_ASSERT_ALWAYS(data != nullptr && data->Manager() != nullptr);
mTxManagerData = data;
}
}
private:
-
// Undefined
TransformManagerQuaternionInput(const TransformManagerQuaternionInput& property);
TransformManagerQuaternionInput& operator=(const TransformManagerQuaternionInput& rhs);
public:
-
TransformManagerData* mTxManagerData{nullptr};
- mutable Quaternion mValue;
+ mutable Quaternion mValue;
};
/**
* A Matrix property used as input.
*/
-class TransformManagerMatrixInput final: public PropertyInputImpl
+class TransformManagerMatrixInput final : public PropertyInputImpl
{
public:
-
/**
* Constructor
*/
TransformManagerMatrixInput() = default;
-
/**
* @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
*/
/**
* @copydoc Dali::PropertyInput::GetMatrix()
*/
- const Matrix& GetMatrix( BufferIndex bufferIndex ) const override
+ const Matrix& GetMatrix(BufferIndex bufferIndex) const override
{
- if( mTxManagerData )
+ if(mTxManagerData)
{
return mTxManagerData->Manager()->GetWorldMatrix(mTxManagerData->Id());
}
/**
* @copydoc Dali::PropertyInput::GetConstraintInputMatrix()
*/
- const Matrix& GetConstraintInputMatrix( BufferIndex bufferIndex ) const override
+ const Matrix& GetConstraintInputMatrix(BufferIndex bufferIndex) const override
{
- if( mTxManagerData )
+ if(mTxManagerData)
{
return mTxManagerData->Manager()->GetWorldMatrix(mTxManagerData->Id());
}
/**
* @copydoc Dali::SceneGraph::PropertyInterface::Get()
*/
- Matrix& Get( BufferIndex bufferIndex )
+ Matrix& Get(BufferIndex bufferIndex)
{
- DALI_ASSERT_ALWAYS( mTxManagerData != nullptr );
+ DALI_ASSERT_ALWAYS(mTxManagerData != nullptr);
return mTxManagerData->Manager()->GetWorldMatrix(mTxManagerData->Id());
}
/**
* @copydoc Dali::SceneGraph::PropertyInterface::Get()
*/
- const Matrix& Get( BufferIndex bufferIndex ) const
+ const Matrix& Get(BufferIndex bufferIndex) const
{
- return GetMatrix( bufferIndex );
+ return GetMatrix(bufferIndex);
}
/**
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Matrix& operator[]( BufferIndex bufferIndex ) const
+ const Matrix& operator[](BufferIndex bufferIndex) const
{
- return GetMatrix( bufferIndex );
+ return GetMatrix(bufferIndex);
}
- void Initialize( TransformManagerData* data)
+ void Initialize(TransformManagerData* data)
{
- DALI_ASSERT_ALWAYS( data != nullptr && data->Manager() != nullptr);
+ DALI_ASSERT_ALWAYS(data != nullptr && data->Manager() != nullptr);
mTxManagerData = data;
}
}
private:
-
// Undefined
TransformManagerMatrixInput(const TransformManagerMatrixInput& property);
TransformManagerMatrixInput& operator=(const TransformManagerMatrixInput& rhs);
public:
-
TransformManagerData* mTxManagerData{nullptr};
};
-
} //namespace SceneGraph
} //namespace Internal
} //namespace Dali
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <type_traits>
//INTERNAL INCLUDES
-#include <dali/public-api/common/constants.h>
#include <dali/internal/common/math.h>
+#include <dali/public-api/common/constants.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
namespace
{
//Default values for scale (1.0,1.0,1.0), orientation (Identity) and position (0.0,0.0,0.0)
-static const float gDefaultTransformComponentAnimatableData[] = { 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f };
+static const float gDefaultTransformComponentAnimatableData[] = {1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f};
//Default values for anchor point (CENTER) and parent origin (TOP_LEFT)
-static const float gDefaultTransformComponentStaticData[] = { 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.5f, true };
+static const float gDefaultTransformComponentStaticData[] = {0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.5f, true};
-static_assert( sizeof(gDefaultTransformComponentAnimatableData) == sizeof(TransformComponentAnimatable), "gDefaultTransformComponentAnimatableData should have the same number of floats as specified in TransformComponentAnimatable" );
-static_assert( sizeof(gDefaultTransformComponentStaticData) == sizeof(TransformComponentStatic), "gDefaultTransformComponentStaticData should have the same number of floats as specified in TransformComponentStatic" );
+static_assert(sizeof(gDefaultTransformComponentAnimatableData) == sizeof(TransformComponentAnimatable), "gDefaultTransformComponentAnimatableData should have the same number of floats as specified in TransformComponentAnimatable");
+static_assert(sizeof(gDefaultTransformComponentStaticData) == sizeof(TransformComponentStatic), "gDefaultTransformComponentStaticData should have the same number of floats as specified in TransformComponentStatic");
/**
* @brief Calculates the center position for the transform component
* @param[in] topLeft The top-left coords of the transform
*/
inline void CalculateCenterPosition(
- Vector3& centerPosition,
- const TransformComponentStatic& transformComponentStatic,
+ Vector3& centerPosition,
+ const TransformComponentStatic& transformComponentStatic,
const TransformComponentAnimatable& transformComponentAnimatable,
- const Vector3& size,
- const Vector3& half,
- const Vector3& topLeft )
+ const Vector3& size,
+ const Vector3& half,
+ const Vector3& topLeft)
{
// Calculate the center-point by applying the scale and rotation on the anchor point.
- centerPosition = ( half - transformComponentStatic.mAnchorPoint ) * size * transformComponentAnimatable.mScale;
+ centerPosition = (half - transformComponentStatic.mAnchorPoint) * size * transformComponentAnimatable.mScale;
centerPosition *= transformComponentAnimatable.mOrientation;
// If the position is ignoring the anchor-point, then remove the anchor-point shift from the position.
- if( ! transformComponentStatic.mPositionUsesAnchorPoint )
+ if(!transformComponentStatic.mPositionUsesAnchorPoint)
{
- centerPosition -= ( topLeft - transformComponentStatic.mAnchorPoint ) * size;
+ centerPosition -= (topLeft - transformComponentStatic.mAnchorPoint) * size;
}
}
} // unnamed namespace
TransformManager::TransformManager()
-:mComponentCount(0),
- mReorder(false)
-{}
+: mComponentCount(0),
+ mReorder(false)
+{
+}
TransformManager::~TransformManager() = default;
//Get id for the new component
TransformId id = mIds.Add(mComponentCount);
- if( mTxComponentAnimatable.Size() <= mComponentCount )
+ if(mTxComponentAnimatable.Size() <= mComponentCount)
{
//Make room for another component
mTxComponentAnimatable.PushBack(TransformComponentAnimatable());
mTxComponentStatic.PushBack(TransformComponentStatic());
mInheritanceMode.PushBack(INHERIT_ALL);
mComponentId.PushBack(id);
- mSize.PushBack(Vector3(0.0f,0.0f,0.0f));
+ mSize.PushBack(Vector3(0.0f, 0.0f, 0.0f));
mParent.PushBack(INVALID_TRANSFORM_ID);
mWorld.PushBack(Matrix::IDENTITY);
mLocal.PushBack(Matrix::IDENTITY);
- mBoundingSpheres.PushBack( Vector4(0.0f,0.0f,0.0f,0.0f) );
+ mBoundingSpheres.PushBack(Vector4(0.0f, 0.0f, 0.0f, 0.0f));
mTxComponentAnimatableBaseValue.PushBack(TransformComponentAnimatable());
- mSizeBase.PushBack(Vector3(0.0f,0.0f,0.0f));
+ mSizeBase.PushBack(Vector3(0.0f, 0.0f, 0.0f));
mComponentDirty.PushBack(false);
mLocalMatrixDirty.PushBack(false);
}
else
{
//Set default values
- memcpy( &mTxComponentAnimatable[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof( TransformComponentAnimatable ) );
- memcpy( &mTxComponentStatic[mComponentCount], &gDefaultTransformComponentStaticData, sizeof( TransformComponentStatic ) );
- memcpy( &mTxComponentAnimatableBaseValue[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof( TransformComponentAnimatable ) );
+ memcpy(&mTxComponentAnimatable[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof(TransformComponentAnimatable));
+ memcpy(&mTxComponentStatic[mComponentCount], &gDefaultTransformComponentStaticData, sizeof(TransformComponentStatic));
+ memcpy(&mTxComponentAnimatableBaseValue[mComponentCount], &gDefaultTransformComponentAnimatableData, sizeof(TransformComponentAnimatable));
mInheritanceMode[mComponentCount] = INHERIT_ALL;
- mComponentId[mComponentCount] = id;
- mSize[mComponentCount] = Vector3(0.0f,0.0f,0.0f);
- mParent[mComponentCount] = INVALID_TRANSFORM_ID;
+ mComponentId[mComponentCount] = id;
+ mSize[mComponentCount] = Vector3(0.0f, 0.0f, 0.0f);
+ mParent[mComponentCount] = INVALID_TRANSFORM_ID;
mLocal[mComponentCount].SetIdentity();
mWorld[mComponentCount].SetIdentity();
- mBoundingSpheres[mComponentCount] = Vector4(0.0f,0.0f,0.0f,0.0f);
- mSizeBase[mComponentCount] = Vector3(0.0f,0.0f,0.0f);
- mComponentDirty[mComponentCount] = false;
+ mBoundingSpheres[mComponentCount] = Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ mSizeBase[mComponentCount] = Vector3(0.0f, 0.0f, 0.0f);
+ mComponentDirty[mComponentCount] = false;
mLocalMatrixDirty[mComponentCount] = false;
}
{
//Move the last element to the gap
mComponentCount--;
- TransformId index = mIds[id];
- mTxComponentAnimatable[index] = mTxComponentAnimatable[mComponentCount];
- mTxComponentStatic[index] = mTxComponentStatic[mComponentCount];
- mInheritanceMode[index] = mInheritanceMode[mComponentCount];
- mSize[index] = mSize[mComponentCount];
- mParent[index] = mParent[mComponentCount];
- mWorld[index] = mWorld[mComponentCount];
- mLocal[index] = mLocal[mComponentCount];
+ TransformId index = mIds[id];
+ mTxComponentAnimatable[index] = mTxComponentAnimatable[mComponentCount];
+ mTxComponentStatic[index] = mTxComponentStatic[mComponentCount];
+ mInheritanceMode[index] = mInheritanceMode[mComponentCount];
+ mSize[index] = mSize[mComponentCount];
+ mParent[index] = mParent[mComponentCount];
+ mWorld[index] = mWorld[mComponentCount];
+ mLocal[index] = mLocal[mComponentCount];
mTxComponentAnimatableBaseValue[index] = mTxComponentAnimatableBaseValue[mComponentCount];
- mSizeBase[index] = mSizeBase[mComponentCount];
- mComponentDirty[index] = mComponentDirty[mComponentCount];
- mLocalMatrixDirty[index] = mLocalMatrixDirty[mComponentCount];
- mBoundingSpheres[index] = mBoundingSpheres[mComponentCount];
+ mSizeBase[index] = mSizeBase[mComponentCount];
+ mComponentDirty[index] = mComponentDirty[mComponentCount];
+ mLocalMatrixDirty[index] = mLocalMatrixDirty[mComponentCount];
+ mBoundingSpheres[index] = mBoundingSpheres[mComponentCount];
TransformId lastItemId = mComponentId[mComponentCount];
- mIds[ lastItemId ] = index;
- mComponentId[index] = lastItemId;
- mIds.Remove( id );
+ mIds[lastItemId] = index;
+ mComponentId[index] = lastItemId;
+ mIds.Remove(id);
mReorder = true;
}
-void TransformManager::SetParent( TransformId id, TransformId parentId )
+void TransformManager::SetParent(TransformId id, TransformId parentId)
{
- DALI_ASSERT_ALWAYS( id != parentId );
- TransformId index = mIds[id];
- mParent[ index ] = parentId;
- mComponentDirty[ index ] = true;
- mReorder = true;
+ DALI_ASSERT_ALWAYS(id != parentId);
+ TransformId index = mIds[id];
+ mParent[index] = parentId;
+ mComponentDirty[index] = true;
+ mReorder = true;
}
-const Matrix& TransformManager::GetWorldMatrix( TransformId id ) const
+const Matrix& TransformManager::GetWorldMatrix(TransformId id) const
{
- return mWorld[ mIds[id] ];
+ return mWorld[mIds[id]];
}
-Matrix& TransformManager::GetWorldMatrix( TransformId id )
+Matrix& TransformManager::GetWorldMatrix(TransformId id)
{
- return mWorld[ mIds[id] ];
+ return mWorld[mIds[id]];
}
-void TransformManager::SetInheritPosition( TransformId id, bool inherit )
+void TransformManager::SetInheritPosition(TransformId id, bool inherit)
{
TransformId index = mIds[id];
- if( inherit )
+ if(inherit)
{
- mInheritanceMode[ index ] |= INHERIT_POSITION;
+ mInheritanceMode[index] |= INHERIT_POSITION;
}
else
{
- mInheritanceMode[ index ] &= ~INHERIT_POSITION;
+ mInheritanceMode[index] &= ~INHERIT_POSITION;
}
mComponentDirty[index] = true;
}
-void TransformManager::SetInheritScale( TransformId id, bool inherit )
+void TransformManager::SetInheritScale(TransformId id, bool inherit)
{
TransformId index = mIds[id];
- if( inherit )
+ if(inherit)
{
- mInheritanceMode[ index ] |= INHERIT_SCALE;
+ mInheritanceMode[index] |= INHERIT_SCALE;
}
else
{
- mInheritanceMode[ index ] &= ~INHERIT_SCALE;
+ mInheritanceMode[index] &= ~INHERIT_SCALE;
}
mComponentDirty[index] = true;
}
-void TransformManager::SetInheritOrientation( TransformId id, bool inherit )
+void TransformManager::SetInheritOrientation(TransformId id, bool inherit)
{
TransformId index = mIds[id];
- if( inherit )
+ if(inherit)
{
- mInheritanceMode[ index ] |= INHERIT_ORIENTATION;
+ mInheritanceMode[index] |= INHERIT_ORIENTATION;
}
else
{
- mInheritanceMode[ index ] &= ~INHERIT_ORIENTATION;
+ mInheritanceMode[index] &= ~INHERIT_ORIENTATION;
}
mComponentDirty[index] = true;
void TransformManager::ResetToBaseValue()
{
- if( mComponentCount )
+ if(mComponentCount)
{
- memcpy( &mTxComponentAnimatable[0], &mTxComponentAnimatableBaseValue[0], sizeof(TransformComponentAnimatable)*mComponentCount );
- memcpy( &mSize[0], &mSizeBase[0], sizeof(Vector3)*mComponentCount );
- memset( &mLocalMatrixDirty[0], false, sizeof(bool)*mComponentCount );
+ memcpy(&mTxComponentAnimatable[0], &mTxComponentAnimatableBaseValue[0], sizeof(TransformComponentAnimatable) * mComponentCount);
+ memcpy(&mSize[0], &mSizeBase[0], sizeof(Vector3) * mComponentCount);
+ memset(&mLocalMatrixDirty[0], false, sizeof(bool) * mComponentCount);
}
}
{
bool componentsChanged = false;
- if( mReorder )
+ if(mReorder)
{
//If some transform component has change its parent or has been removed since last update
//we need to reorder the vectors
}
//Iterate through all components to compute its world matrix
- Vector3 centerPosition;
- Vector3 localPosition;
- const Vector3 half( 0.5f,0.5f,0.5f );
- const Vector3 topLeft( 0.0f, 0.0f, 0.5f );
- for( unsigned int i(0); i<mComponentCount; ++i )
+ Vector3 centerPosition;
+ Vector3 localPosition;
+ const Vector3 half(0.5f, 0.5f, 0.5f);
+ const Vector3 topLeft(0.0f, 0.0f, 0.5f);
+ for(unsigned int i(0); i < mComponentCount; ++i)
{
- if( DALI_LIKELY( mInheritanceMode[i] != DONT_INHERIT_TRANSFORM && mParent[i] != INVALID_TRANSFORM_ID ) )
+ if(DALI_LIKELY(mInheritanceMode[i] != DONT_INHERIT_TRANSFORM && mParent[i] != INVALID_TRANSFORM_ID))
{
- const TransformId& parentIndex = mIds[mParent[i] ];
- if( DALI_LIKELY( mInheritanceMode[i] == INHERIT_ALL ) )
+ const TransformId& parentIndex = mIds[mParent[i]];
+ if(DALI_LIKELY(mInheritanceMode[i] == INHERIT_ALL))
{
- if( mComponentDirty[i] || mLocalMatrixDirty[parentIndex])
+ if(mComponentDirty[i] || mLocalMatrixDirty[parentIndex])
{
//Full transform inherited
mLocalMatrixDirty[i] = true;
- CalculateCenterPosition( centerPosition, mTxComponentStatic[ i ], mTxComponentAnimatable[ i ], mSize[ i ], half, topLeft );
- localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + ( mTxComponentStatic[i].mParentOrigin - half ) * mSize[parentIndex];
- mLocal[i].SetTransformComponents( mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition );
+ CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
+ localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + (mTxComponentStatic[i].mParentOrigin - half) * mSize[parentIndex];
+ mLocal[i].SetTransformComponents(mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition);
}
//Update the world matrix
- Matrix::Multiply( mWorld[i], mLocal[i], mWorld[parentIndex]);
+ Matrix::Multiply(mWorld[i], mLocal[i], mWorld[parentIndex]);
}
else
{
//Some components are not inherited
- Vector3 parentPosition, parentScale;
- Quaternion parentOrientation;
+ Vector3 parentPosition, parentScale;
+ Quaternion parentOrientation;
const Matrix& parentMatrix = mWorld[parentIndex];
- parentMatrix.GetTransformComponents( parentPosition, parentOrientation, parentScale );
+ parentMatrix.GetTransformComponents(parentPosition, parentOrientation, parentScale);
Vector3 localScale = mTxComponentAnimatable[i].mScale;
- if( (mInheritanceMode[i] & INHERIT_SCALE) == 0 )
+ if((mInheritanceMode[i] & INHERIT_SCALE) == 0)
{
//Don't inherit scale
localScale /= parentScale;
}
- Quaternion localOrientation( mTxComponentAnimatable[i].mOrientation );
- if( (mInheritanceMode[i] & INHERIT_ORIENTATION) == 0 )
+ Quaternion localOrientation(mTxComponentAnimatable[i].mOrientation);
+ if((mInheritanceMode[i] & INHERIT_ORIENTATION) == 0)
{
//Don't inherit orientation
parentOrientation.Invert();
localOrientation = parentOrientation * mTxComponentAnimatable[i].mOrientation;
}
- if( (mInheritanceMode[i] & INHERIT_POSITION) == 0 )
+ if((mInheritanceMode[i] & INHERIT_POSITION) == 0)
{
//Don't inherit position
- CalculateCenterPosition( centerPosition, mTxComponentStatic[ i ], mTxComponentAnimatable[ i ], mSize[ i ], half, topLeft );
- mLocal[i].SetTransformComponents( localScale, localOrientation, Vector3::ZERO );
- Matrix::Multiply( mWorld[i], mLocal[i], parentMatrix );
- mWorld[i].SetTranslation( mTxComponentAnimatable[i].mPosition + centerPosition );
+ CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
+ mLocal[i].SetTransformComponents(localScale, localOrientation, Vector3::ZERO);
+ Matrix::Multiply(mWorld[i], mLocal[i], parentMatrix);
+ mWorld[i].SetTranslation(mTxComponentAnimatable[i].mPosition + centerPosition);
}
else
{
- CalculateCenterPosition( centerPosition, mTxComponentStatic[ i ], mTxComponentAnimatable[ i ], mSize[ i ], half, topLeft );
- localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + ( mTxComponentStatic[i].mParentOrigin - half ) * mSize[parentIndex];
- mLocal[i].SetTransformComponents( localScale, localOrientation, localPosition );
- Matrix::Multiply( mWorld[i], mLocal[i], parentMatrix );
+ CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
+ localPosition = mTxComponentAnimatable[i].mPosition + centerPosition + (mTxComponentStatic[i].mParentOrigin - half) * mSize[parentIndex];
+ mLocal[i].SetTransformComponents(localScale, localOrientation, localPosition);
+ Matrix::Multiply(mWorld[i], mLocal[i], parentMatrix);
}
mLocalMatrixDirty[i] = true;
}
}
- else //Component has no parent or doesn't inherit transform
+ else //Component has no parent or doesn't inherit transform
{
- CalculateCenterPosition( centerPosition, mTxComponentStatic[ i ], mTxComponentAnimatable[ i ], mSize[ i ], half, topLeft );
+ CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i], mSize[i], half, topLeft);
localPosition = mTxComponentAnimatable[i].mPosition + centerPosition;
- mLocal[i].SetTransformComponents( mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition );
- mWorld[i] = mLocal[i];
+ mLocal[i].SetTransformComponents(mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, localPosition);
+ mWorld[i] = mLocal[i];
mLocalMatrixDirty[i] = true;
}
//Update the bounding sphere
- Vec3 centerToEdge = { mSize[i].Length() * 0.5f, 0.0f, 0.0f };
+ Vec3 centerToEdge = {mSize[i].Length() * 0.5f, 0.0f, 0.0f};
Vec3 centerToEdgeWorldSpace;
- TransformVector3( centerToEdgeWorldSpace, mWorld[i].AsFloat(), centerToEdge );
+ TransformVector3(centerToEdgeWorldSpace, mWorld[i].AsFloat(), centerToEdge);
- mBoundingSpheres[i] = mWorld[i].GetTranslation();
- mBoundingSpheres[i].w = Length( centerToEdgeWorldSpace );
+ mBoundingSpheres[i] = mWorld[i].GetTranslation();
+ mBoundingSpheres[i].w = Length(centerToEdgeWorldSpace);
- componentsChanged = componentsChanged || mComponentDirty[i];
+ componentsChanged = componentsChanged || mComponentDirty[i];
mComponentDirty[i] = false;
}
return componentsChanged;
}
-void TransformManager::SwapComponents( unsigned int i, unsigned int j )
+void TransformManager::SwapComponents(unsigned int i, unsigned int j)
{
- std::swap( mTxComponentAnimatable[i], mTxComponentAnimatable[j] );
- std::swap( mTxComponentStatic[i], mTxComponentStatic[j] );
- std::swap( mInheritanceMode[i], mInheritanceMode[j] );
- std::swap( mSize[i], mSize[j] );
- std::swap( mParent[i], mParent[j] );
- std::swap( mComponentId[i], mComponentId[j] );
- std::swap( mTxComponentAnimatableBaseValue[i], mTxComponentAnimatableBaseValue[j] );
- std::swap( mSizeBase[i], mSizeBase[j] );
- std::swap( mLocal[i], mLocal[j] );
- std::swap( mComponentDirty[i], mComponentDirty[j] );
- std::swap( mBoundingSpheres[i], mBoundingSpheres[j] );
- std::swap( mWorld[i], mWorld[j] );
+ std::swap(mTxComponentAnimatable[i], mTxComponentAnimatable[j]);
+ std::swap(mTxComponentStatic[i], mTxComponentStatic[j]);
+ std::swap(mInheritanceMode[i], mInheritanceMode[j]);
+ std::swap(mSize[i], mSize[j]);
+ std::swap(mParent[i], mParent[j]);
+ std::swap(mComponentId[i], mComponentId[j]);
+ std::swap(mTxComponentAnimatableBaseValue[i], mTxComponentAnimatableBaseValue[j]);
+ std::swap(mSizeBase[i], mSizeBase[j]);
+ std::swap(mLocal[i], mLocal[j]);
+ std::swap(mComponentDirty[i], mComponentDirty[j]);
+ std::swap(mBoundingSpheres[i], mBoundingSpheres[j]);
+ std::swap(mWorld[i], mWorld[j]);
- mIds[ mComponentId[i] ] = i;
- mIds[ mComponentId[j] ] = j;
+ mIds[mComponentId[i]] = i;
+ mIds[mComponentId[j]] = j;
}
void TransformManager::ReorderComponents()
mOrderedComponents.Resize(mComponentCount);
TransformId parentId;
- for( TransformId i = 0; i<mComponentCount; ++i )
+ for(TransformId i = 0; i < mComponentCount; ++i)
{
- mOrderedComponents[i].id = mComponentId[i];
+ mOrderedComponents[i].id = mComponentId[i];
mOrderedComponents[i].level = 0u;
parentId = mParent[i];
- while( parentId != INVALID_TRANSFORM_ID )
+ while(parentId != INVALID_TRANSFORM_ID)
{
mOrderedComponents[i].level++;
- parentId = mParent[ mIds[parentId] ];
+ parentId = mParent[mIds[parentId]];
}
}
- std::stable_sort( mOrderedComponents.Begin(), mOrderedComponents.End());
+ std::stable_sort(mOrderedComponents.Begin(), mOrderedComponents.End());
TransformId previousIndex = 0;
- for( TransformId newIndex = 0; newIndex < mComponentCount-1; ++newIndex )
+ for(TransformId newIndex = 0; newIndex < mComponentCount - 1; ++newIndex)
{
previousIndex = mIds[mOrderedComponents[newIndex].id];
- if( previousIndex != newIndex )
+ if(previousIndex != newIndex)
{
- SwapComponents( previousIndex, newIndex);
+ SwapComponents(previousIndex, newIndex);
}
}
}
-Vector3& TransformManager::GetVector3PropertyValue( TransformId id, TransformManagerProperty property )
+Vector3& TransformManager::GetVector3PropertyValue(TransformId id, TransformManagerProperty property)
{
- switch( property )
+ switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
- TransformId index( mIds[id] );
- return mTxComponentAnimatable[ index ].mPosition;
+ TransformId index(mIds[id]);
+ return mTxComponentAnimatable[index].mPosition;
}
case TRANSFORM_PROPERTY_SCALE:
{
- TransformId index( mIds[id] );
- return mTxComponentAnimatable[ index ].mScale;
+ TransformId index(mIds[id]);
+ return mTxComponentAnimatable[index].mScale;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
- TransformId index( mIds[id] );
- return mTxComponentStatic[ index ].mParentOrigin;
+ TransformId index(mIds[id]);
+ return mTxComponentStatic[index].mParentOrigin;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
- TransformId index( mIds[id] );
- return mTxComponentStatic[ index ].mAnchorPoint;
+ TransformId index(mIds[id]);
+ return mTxComponentStatic[index].mAnchorPoint;
}
case TRANSFORM_PROPERTY_SIZE:
{
- TransformId index( mIds[id] );
- return mSize[ index ];
+ TransformId index(mIds[id]);
+ return mSize[index];
}
default:
{
DALI_ASSERT_ALWAYS(false);
- return mTxComponentAnimatable[ mIds[id] ].mPosition;
+ return mTxComponentAnimatable[mIds[id]].mPosition;
}
}
}
-const Vector3& TransformManager::GetVector3PropertyValue( TransformId id, TransformManagerProperty property ) const
+const Vector3& TransformManager::GetVector3PropertyValue(TransformId id, TransformManagerProperty property) const
{
- switch( property )
+ switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
- return mTxComponentAnimatable[ mIds[id] ].mPosition;
+ return mTxComponentAnimatable[mIds[id]].mPosition;
}
case TRANSFORM_PROPERTY_SCALE:
{
- return mTxComponentAnimatable[ mIds[id] ].mScale;
+ return mTxComponentAnimatable[mIds[id]].mScale;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
- return mTxComponentStatic[ mIds[id] ].mParentOrigin;
+ return mTxComponentStatic[mIds[id]].mParentOrigin;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
- return mTxComponentStatic[ mIds[id] ].mAnchorPoint;
+ return mTxComponentStatic[mIds[id]].mAnchorPoint;
}
case TRANSFORM_PROPERTY_SIZE:
{
- return mSize[ mIds[id] ];
+ return mSize[mIds[id]];
}
default:
{
DALI_ASSERT_ALWAYS(false);
- return mTxComponentAnimatable[ mIds[id] ].mPosition;
+ return mTxComponentAnimatable[mIds[id]].mPosition;
}
}
}
-const float& TransformManager::GetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, unsigned int component ) const
+const float& TransformManager::GetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, unsigned int component) const
{
- switch( property )
+ switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
- return mTxComponentAnimatable[ mIds[id] ].mPosition[component];
+ return mTxComponentAnimatable[mIds[id]].mPosition[component];
}
case TRANSFORM_PROPERTY_SCALE:
{
- return mTxComponentAnimatable[ mIds[id] ].mScale[component];
+ return mTxComponentAnimatable[mIds[id]].mScale[component];
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
- return mTxComponentStatic[ mIds[id] ].mParentOrigin[component];
+ return mTxComponentStatic[mIds[id]].mParentOrigin[component];
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
- return mTxComponentStatic[ mIds[id] ].mAnchorPoint[component];
+ return mTxComponentStatic[mIds[id]].mAnchorPoint[component];
}
case TRANSFORM_PROPERTY_SIZE:
{
- return mSize[ mIds[id] ][component];
+ return mSize[mIds[id]][component];
}
default:
{
DALI_ASSERT_ALWAYS(false);
- return mTxComponentAnimatable[ mIds[id] ].mPosition[component];
+ return mTxComponentAnimatable[mIds[id]].mPosition[component];
}
}
}
-void TransformManager::SetVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
+void TransformManager::SetVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
{
- TransformId index( mIds[id] );
- mComponentDirty[ index ] = true;
+ TransformId index(mIds[id]);
+ mComponentDirty[index] = true;
- switch( property )
+ switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
- mTxComponentAnimatable[ index ].mPosition = value;
+ mTxComponentAnimatable[index].mPosition = value;
break;
}
case TRANSFORM_PROPERTY_SCALE:
{
- mTxComponentAnimatable[ index ].mScale = value;
+ mTxComponentAnimatable[index].mScale = value;
break;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
- mTxComponentStatic[ index ].mParentOrigin = value;
+ mTxComponentStatic[index].mParentOrigin = value;
break;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
- mTxComponentStatic[ index ].mAnchorPoint = value;
+ mTxComponentStatic[index].mAnchorPoint = value;
break;
}
case TRANSFORM_PROPERTY_SIZE:
{
- mSize[ index ] = value;
+ mSize[index] = value;
break;
}
default:
}
}
-void TransformManager::SetVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, float value, unsigned int component )
+void TransformManager::SetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
{
- TransformId index( mIds[id] );
- mComponentDirty[ index ] = true;
+ TransformId index(mIds[id]);
+ mComponentDirty[index] = true;
- switch( property )
+ switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
- mTxComponentAnimatable[ index ].mPosition[component] = value;
+ mTxComponentAnimatable[index].mPosition[component] = value;
break;
}
case TRANSFORM_PROPERTY_SCALE:
{
- mTxComponentAnimatable[ index ].mScale[component] = value;
+ mTxComponentAnimatable[index].mScale[component] = value;
break;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
- mTxComponentStatic[ index ].mParentOrigin[component] = value;
+ mTxComponentStatic[index].mParentOrigin[component] = value;
break;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
- mTxComponentStatic[ index ].mAnchorPoint[component] = value;
+ mTxComponentStatic[index].mAnchorPoint[component] = value;
break;
}
case TRANSFORM_PROPERTY_SIZE:
{
- mSize[ index ][component] = value;
+ mSize[index][component] = value;
break;
}
default:
}
}
-void TransformManager::BakeVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
+void TransformManager::BakeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
{
- TransformId index( mIds[id] );
- mComponentDirty[ index ] = true;
+ TransformId index(mIds[id]);
+ mComponentDirty[index] = true;
- switch( property )
+ switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
- mTxComponentAnimatable[ index ].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = value;
+ mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = value;
break;
}
case TRANSFORM_PROPERTY_SCALE:
{
- mTxComponentAnimatable[ index ].mScale = mTxComponentAnimatableBaseValue[index].mScale = value;
+ mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = value;
break;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
- mTxComponentStatic[ index ].mParentOrigin = value;
+ mTxComponentStatic[index].mParentOrigin = value;
break;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
- mTxComponentStatic[ index ].mAnchorPoint = value;
+ mTxComponentStatic[index].mAnchorPoint = value;
break;
}
case TRANSFORM_PROPERTY_SIZE:
{
- mSize[ index ] = mSizeBase[index] = value;
+ mSize[index] = mSizeBase[index] = value;
break;
}
default:
}
}
-void TransformManager::BakeRelativeVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
+void TransformManager::BakeRelativeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
{
- TransformId index( mIds[id] );
- mComponentDirty[ index ] = true;
+ TransformId index(mIds[id]);
+ mComponentDirty[index] = true;
- switch( property )
+ switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
- mTxComponentAnimatable[ index ].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[ index ].mPosition + value;
+ mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[index].mPosition + value;
break;
}
case TRANSFORM_PROPERTY_SCALE:
{
- mTxComponentAnimatable[ index ].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[ index ].mScale + value;
+ mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[index].mScale + value;
break;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
- mTxComponentStatic[ index ].mParentOrigin = mTxComponentStatic[ index ].mParentOrigin + value;
+ mTxComponentStatic[index].mParentOrigin = mTxComponentStatic[index].mParentOrigin + value;
break;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
- mTxComponentStatic[ index ].mAnchorPoint = mTxComponentStatic[ index ].mAnchorPoint + value;
+ mTxComponentStatic[index].mAnchorPoint = mTxComponentStatic[index].mAnchorPoint + value;
break;
}
case TRANSFORM_PROPERTY_SIZE:
{
- mSize[ index ] = mSizeBase[index] = mSize[ index ] + value;
+ mSize[index] = mSizeBase[index] = mSize[index] + value;
break;
}
default:
}
}
-void TransformManager::BakeMultiplyVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value )
+void TransformManager::BakeMultiplyVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value)
{
- TransformId index( mIds[id] );
- mComponentDirty[ index ] = true;
+ TransformId index(mIds[id]);
+ mComponentDirty[index] = true;
- switch( property )
+ switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
- mTxComponentAnimatable[ index ].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[ index ].mPosition * value;
+ mTxComponentAnimatable[index].mPosition = mTxComponentAnimatableBaseValue[index].mPosition = mTxComponentAnimatable[index].mPosition * value;
break;
}
case TRANSFORM_PROPERTY_SCALE:
{
- mTxComponentAnimatable[ index ].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[ index ].mScale * value;
+ mTxComponentAnimatable[index].mScale = mTxComponentAnimatableBaseValue[index].mScale = mTxComponentAnimatable[index].mScale * value;
break;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
- mTxComponentStatic[ index ].mParentOrigin = mTxComponentStatic[ index ].mParentOrigin * value;
+ mTxComponentStatic[index].mParentOrigin = mTxComponentStatic[index].mParentOrigin * value;
break;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
- mTxComponentStatic[ index ].mAnchorPoint = mTxComponentStatic[ index ].mAnchorPoint * value;
+ mTxComponentStatic[index].mAnchorPoint = mTxComponentStatic[index].mAnchorPoint * value;
break;
}
case TRANSFORM_PROPERTY_SIZE:
{
- mSize[ index ] = mSizeBase[index] = mSize[ index ] * value;
+ mSize[index] = mSizeBase[index] = mSize[index] * value;
break;
}
default:
}
}
-void TransformManager::BakeVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, float value, unsigned int component )
+void TransformManager::BakeVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component)
{
- TransformId index( mIds[id] );
- mComponentDirty[ index ] = true;
+ TransformId index(mIds[id]);
+ mComponentDirty[index] = true;
- switch( property )
+ switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
- mTxComponentAnimatable[ index ].mPosition[component] = mTxComponentAnimatableBaseValue[index].mPosition[component] = value;
+ mTxComponentAnimatable[index].mPosition[component] = mTxComponentAnimatableBaseValue[index].mPosition[component] = value;
break;
}
case TRANSFORM_PROPERTY_SCALE:
{
- mTxComponentAnimatable[ index ].mScale[component] = mTxComponentAnimatableBaseValue[index].mScale[component] = value;
+ mTxComponentAnimatable[index].mScale[component] = mTxComponentAnimatableBaseValue[index].mScale[component] = value;
break;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
- mTxComponentStatic[ index ].mParentOrigin[component] = value;
+ mTxComponentStatic[index].mParentOrigin[component] = value;
break;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
- mTxComponentStatic[ index ].mAnchorPoint[component] = value;
+ mTxComponentStatic[index].mAnchorPoint[component] = value;
break;
}
case TRANSFORM_PROPERTY_SIZE:
{
- mSize[ index ][component] = mSizeBase[index][component] = value;
+ mSize[index][component] = mSizeBase[index][component] = value;
break;
}
default:
}
}
-void TransformManager::BakeXVector3PropertyValue( TransformId id, TransformManagerProperty property, float value )
+void TransformManager::BakeXVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
{
- TransformId index( mIds[id] );
- mComponentDirty[ index ] = true;
+ TransformId index(mIds[id]);
+ mComponentDirty[index] = true;
- switch( property )
+ switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
- mTxComponentAnimatable[ index ].mPosition.x = mTxComponentAnimatableBaseValue[index].mPosition.x = value;
+ mTxComponentAnimatable[index].mPosition.x = mTxComponentAnimatableBaseValue[index].mPosition.x = value;
break;
}
case TRANSFORM_PROPERTY_SCALE:
{
- mTxComponentAnimatable[ index ].mScale.x = mTxComponentAnimatableBaseValue[index].mScale.x = value;
+ mTxComponentAnimatable[index].mScale.x = mTxComponentAnimatableBaseValue[index].mScale.x = value;
break;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
- mTxComponentStatic[ index ].mParentOrigin.x = value;
+ mTxComponentStatic[index].mParentOrigin.x = value;
break;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
- mTxComponentStatic[ index ].mAnchorPoint.x = value;
+ mTxComponentStatic[index].mAnchorPoint.x = value;
break;
}
case TRANSFORM_PROPERTY_SIZE:
{
- mSize[ index ].x = mSizeBase[index].x = value;
+ mSize[index].x = mSizeBase[index].x = value;
break;
}
default:
}
}
-void TransformManager::BakeYVector3PropertyValue( TransformId id, TransformManagerProperty property, float value )
+void TransformManager::BakeYVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
{
- TransformId index( mIds[id] );
- mComponentDirty[ index ] = true;
+ TransformId index(mIds[id]);
+ mComponentDirty[index] = true;
- switch( property )
+ switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
- mTxComponentAnimatable[ index ].mPosition.y = mTxComponentAnimatableBaseValue[index].mPosition.y = value;
+ mTxComponentAnimatable[index].mPosition.y = mTxComponentAnimatableBaseValue[index].mPosition.y = value;
break;
}
case TRANSFORM_PROPERTY_SCALE:
{
- mTxComponentAnimatable[ index ].mScale.y = mTxComponentAnimatableBaseValue[index].mScale.y = value;
+ mTxComponentAnimatable[index].mScale.y = mTxComponentAnimatableBaseValue[index].mScale.y = value;
break;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
- mTxComponentStatic[ index ].mParentOrigin.y = value;
+ mTxComponentStatic[index].mParentOrigin.y = value;
break;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
- mTxComponentStatic[ index ].mAnchorPoint.y = value;
+ mTxComponentStatic[index].mAnchorPoint.y = value;
break;
}
case TRANSFORM_PROPERTY_SIZE:
{
- mSize[ index ].y = mSizeBase[index].y = value;
+ mSize[index].y = mSizeBase[index].y = value;
break;
}
default:
}
}
-void TransformManager::BakeZVector3PropertyValue( TransformId id, TransformManagerProperty property, float value )
+void TransformManager::BakeZVector3PropertyValue(TransformId id, TransformManagerProperty property, float value)
{
- TransformId index( mIds[id] );
- mComponentDirty[ index ] = true;
+ TransformId index(mIds[id]);
+ mComponentDirty[index] = true;
- switch( property )
+ switch(property)
{
case TRANSFORM_PROPERTY_POSITION:
{
- mTxComponentAnimatable[ index ].mPosition.z = mTxComponentAnimatableBaseValue[index].mPosition.z = value;
+ mTxComponentAnimatable[index].mPosition.z = mTxComponentAnimatableBaseValue[index].mPosition.z = value;
break;
}
case TRANSFORM_PROPERTY_SCALE:
{
- mTxComponentAnimatable[ index ].mScale.z = mTxComponentAnimatableBaseValue[index].mScale.z = value;
+ mTxComponentAnimatable[index].mScale.z = mTxComponentAnimatableBaseValue[index].mScale.z = value;
break;
}
case TRANSFORM_PROPERTY_PARENT_ORIGIN:
{
- mTxComponentStatic[ index ].mParentOrigin.z = value;
+ mTxComponentStatic[index].mParentOrigin.z = value;
break;
}
case TRANSFORM_PROPERTY_ANCHOR_POINT:
{
- mTxComponentStatic[ index ].mAnchorPoint.z = value;
+ mTxComponentStatic[index].mAnchorPoint.z = value;
break;
}
case TRANSFORM_PROPERTY_SIZE:
{
- mSize[ index ].z = mSizeBase[index].z = value;
+ mSize[index].z = mSizeBase[index].z = value;
break;
}
default:
}
}
-Quaternion& TransformManager::GetQuaternionPropertyValue( TransformId id )
+Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id)
{
- TransformId index( mIds[id] );
- return mTxComponentAnimatable[ index ].mOrientation;
+ TransformId index(mIds[id]);
+ return mTxComponentAnimatable[index].mOrientation;
}
-const Quaternion& TransformManager::GetQuaternionPropertyValue( TransformId id ) const
+const Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id) const
{
- return mTxComponentAnimatable[ mIds[id] ].mOrientation;
+ return mTxComponentAnimatable[mIds[id]].mOrientation;
}
-void TransformManager::SetQuaternionPropertyValue( TransformId id, const Quaternion& q )
+void TransformManager::SetQuaternionPropertyValue(TransformId id, const Quaternion& q)
{
- TransformId index( mIds[id] );
- mTxComponentAnimatable[ index ].mOrientation = q;
- mComponentDirty[ index ] = true;
+ TransformId index(mIds[id]);
+ mTxComponentAnimatable[index].mOrientation = q;
+ mComponentDirty[index] = true;
}
-void TransformManager::BakeQuaternionPropertyValue( TransformId id, const Quaternion& q )
+void TransformManager::BakeQuaternionPropertyValue(TransformId id, const Quaternion& q)
{
- TransformId index( mIds[id] );
- mTxComponentAnimatable[ index ].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = q;
- mComponentDirty[ index ] = true;
+ TransformId index(mIds[id]);
+ mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = q;
+ mComponentDirty[index] = true;
}
-void TransformManager::BakeRelativeQuaternionPropertyValue( TransformId id, const Quaternion& q )
+void TransformManager::BakeRelativeQuaternionPropertyValue(TransformId id, const Quaternion& q)
{
- TransformId index( mIds[id] );
- mTxComponentAnimatable[ index ].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = mTxComponentAnimatable[ index ].mOrientation * q;
- mComponentDirty[ index ] = true;
+ TransformId index(mIds[id]);
+ mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = mTxComponentAnimatable[index].mOrientation * q;
+ mComponentDirty[index] = true;
}
-const Vector4& TransformManager::GetBoundingSphere( TransformId id ) const
+const Vector4& TransformManager::GetBoundingSphere(TransformId id) const
{
- return mBoundingSpheres[ mIds[id] ];
+ return mBoundingSpheres[mIds[id]];
}
-void TransformManager::GetWorldMatrixAndSize( TransformId id, Matrix& worldMatrix, Vector3& size ) const
+void TransformManager::GetWorldMatrixAndSize(TransformId id, Matrix& worldMatrix, Vector3& size) const
{
TransformId index = mIds[id];
- worldMatrix = mWorld[index];
- size = mSize[index];
+ worldMatrix = mWorld[index];
+ size = mSize[index];
}
-void TransformManager::SetPositionUsesAnchorPoint( TransformId id, bool value )
+void TransformManager::SetPositionUsesAnchorPoint(TransformId id, bool value)
{
- TransformId index( mIds[ id ] );
- mComponentDirty[ index ] = true;
- mTxComponentStatic[ index ].mPositionUsesAnchorPoint = value;
+ TransformId index(mIds[id]);
+ mComponentDirty[index] = true;
+ mTxComponentStatic[index].mPositionUsesAnchorPoint = value;
}
} //namespace SceneGraph
#define DALI_INTERNAL_TRANSFORM_MANAGER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/update/manager/free-list.h>
+#include <dali/public-api/common/constants.h>
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/math/matrix.h>
#include <dali/public-api/math/quaternion.h>
#include <dali/public-api/math/vector3.h>
-#include <dali/public-api/common/constants.h>
-#include <dali/internal/update/manager/free-list.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
/**
* Struct to store the animatable part of a component (Scale, orientation and position)
*/
struct TransformComponentAnimatable
{
TransformComponentAnimatable()
- : mScale( Vector3::ONE ),
- mOrientation( Quaternion::IDENTITY ),
- mPosition( Vector3::ZERO )
+ : mScale(Vector3::ONE),
+ mOrientation(Quaternion::IDENTITY),
+ mPosition(Vector3::ZERO)
{
}
- Vector3 mScale;
+ Vector3 mScale;
Quaternion mOrientation;
- Vector3 mPosition;
+ Vector3 mPosition;
};
/**
struct TransformComponentStatic
{
TransformComponentStatic()
- : mAnchorPoint( AnchorPoint::DEFAULT ),
- mParentOrigin( ParentOrigin::DEFAULT ),
- mPositionUsesAnchorPoint( true )
+ : mAnchorPoint(AnchorPoint::DEFAULT),
+ mParentOrigin(ParentOrigin::DEFAULT),
+ mPositionUsesAnchorPoint(true)
{
}
Vector3 mAnchorPoint;
Vector3 mParentOrigin;
- bool mPositionUsesAnchorPoint;
+ bool mPositionUsesAnchorPoint;
};
enum InheritanceMode
{
- DONT_INHERIT_TRANSFORM = 0,
- INHERIT_POSITION = 1,
- INHERIT_SCALE = 2,
- INHERIT_ORIENTATION = 4,
- INHERIT_ALL = INHERIT_POSITION | INHERIT_SCALE | INHERIT_ORIENTATION,
+ DONT_INHERIT_TRANSFORM = 0,
+ INHERIT_POSITION = 1,
+ INHERIT_SCALE = 2,
+ INHERIT_ORIENTATION = 4,
+ INHERIT_ALL = INHERIT_POSITION | INHERIT_SCALE | INHERIT_ORIENTATION,
};
enum TransformManagerProperty
struct TransformManagerData
{
+ TransformManager* Manager() const
+ {
+ return mManager;
+ }
- TransformManager* Manager() const { return mManager; }
-
- TransformId Id() const { return mId; }
+ TransformId Id() const
+ {
+ return mId;
+ }
TransformManager* mManager{nullptr};
TransformId mId{INVALID_TRANSFORM_ID};
};
-} //SceneGraph
-} //Internal
+} // namespace SceneGraph
+} // namespace Internal
// Allow TransformComponentAnimatable to be treated as a POD type
-template <> struct TypeTraits< Dali::Internal::SceneGraph::TransformComponentAnimatable >: public Dali::BasicTypes< Dali::Internal::SceneGraph::TransformComponentAnimatable > { enum { IS_TRIVIAL_TYPE = true }; };
+template<>
+struct TypeTraits<Dali::Internal::SceneGraph::TransformComponentAnimatable> : public Dali::BasicTypes<Dali::Internal::SceneGraph::TransformComponentAnimatable>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
namespace Internal
{
-
namespace SceneGraph
{
-
/**
* Transform manager computes the local to world transformations
* of all the nodes in the scene. All the transformation data is stored contiguously
class TransformManager
{
public:
-
/**
* Default constructor
*/
* @param[in] id Id of the transform
* @param[in] parentId Id of the new parent
*/
- void SetParent( TransformId id, TransformId parentId );
+ void SetParent(TransformId id, TransformId parentId);
/**
* Gets the world transform matrix of an exisiting transform component
* @param[in] id Id of the transform component
* @return The local to world transformation matrix of the component
*/
- const Matrix& GetWorldMatrix( TransformId id ) const;
+ const Matrix& GetWorldMatrix(TransformId id) const;
/**
* Gets the world transform matrix of an exisiting transform component
* @param[in] id Id of the transform component
* @return The local to world transformation matrix of the component
*/
- Matrix& GetWorldMatrix( TransformId id );
+ Matrix& GetWorldMatrix(TransformId id);
/**
* Checks if the local transform was updated in the last Update
* @param[in] id Id of the transform
* @return true if local matrix changed in the last update, false otherwise
*/
- bool IsLocalMatrixDirty( TransformId id ) const
+ bool IsLocalMatrixDirty(TransformId id) const
{
return mLocalMatrixDirty[mIds[id]];
}
* @param[in] id Id of the transform
* @param[in] inherit True if position is inherited from parent, false otherwise
*/
- void SetInheritPosition( TransformId id, bool inherit );
+ void SetInheritPosition(TransformId id, bool inherit);
/**
* Sets scale inheritance mode.
* @param[in] id Id of the transform
* @param[in] inherit True if scale is inherited from parent, false otherwise
*/
- void SetInheritScale( TransformId id, bool inherit );
+ void SetInheritScale(TransformId id, bool inherit);
/**
* Sets orientation inheritance mode.
* @param[in] id Id of the transform
* @param[in] inherit True if orientation is inherited from parent, false otherwise
*/
- void SetInheritOrientation( TransformId id, bool inherit );
+ void SetInheritOrientation(TransformId id, bool inherit);
/**
* Recomputes all world transform matrices
* @param[in] id Id of the transform component
* @param[in] property The property
*/
- Vector3& GetVector3PropertyValue( TransformId id, TransformManagerProperty property );
+ Vector3& GetVector3PropertyValue(TransformId id, TransformManagerProperty property);
/**
* Get the value of a Vector3 property
* @param[in] id Id of the transform component
* @param[in] property The property
*/
- const Vector3& GetVector3PropertyValue( TransformId id, TransformManagerProperty property ) const;
+ const Vector3& GetVector3PropertyValue(TransformId id, TransformManagerProperty property) const;
/**
* Get the value of a component of Vector3 property
* @param[in] property The property
* param[in] component The component (0,1,2)
*/
- const float& GetVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, uint32_t component ) const;
+ const float& GetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, uint32_t component) const;
/**
* Set the value of a Vector3 property
* @param[in] property The property
* @param[in] value The new value
*/
- void SetVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value );
+ void SetVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value);
/**
* Set the value of a component of a Vector3 property
* @param[in] value The new value
* param[in] component The component (0,1,2)
*/
- void SetVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, float value, uint32_t component );
+ void SetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, uint32_t component);
/**
* Bakes the value of a Vector3 property
* @param[in] property The property
* @param[in] value The new value
*/
- void BakeVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value );
+ void BakeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value);
/**
* Bakes the value of a Vector3 property relative to the current value
* @param[in] property The property
* @param[in] value The new value
*/
- void BakeRelativeVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value );
+ void BakeRelativeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value);
/**
* Bakes the value of a Vector3 property by multiplying the current value and the new value
* @param[in] property The property
* @param[in] value The new value
*/
- void BakeMultiplyVector3PropertyValue( TransformId id, TransformManagerProperty property, const Vector3& value );
+ void BakeMultiplyVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value);
/**
* Bakes the value of a component of Vector3 property
* @param[in] property The property
* @param[in] value The new value
*/
- void BakeVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, float value, uint32_t component );
+ void BakeVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, uint32_t component);
/**
* Bakes the value of the x component of Vector3 property
* @param[in] property The property
* @param[in] value The new value
*/
- void BakeXVector3PropertyValue( TransformId id, TransformManagerProperty property, float value );
+ void BakeXVector3PropertyValue(TransformId id, TransformManagerProperty property, float value);
/**
* Bakes the value of the y component of Vector3 property
* @param[in] property The property
* @param[in] value The new value
*/
- void BakeYVector3PropertyValue( TransformId id, TransformManagerProperty property, float value );
+ void BakeYVector3PropertyValue(TransformId id, TransformManagerProperty property, float value);
/**
* Bakes the value of the z component of Vector3 property
* @param[in] property The property
* @param[in] value The new value
*/
- void BakeZVector3PropertyValue( TransformId id, TransformManagerProperty property, float value );
+ void BakeZVector3PropertyValue(TransformId id, TransformManagerProperty property, float value);
/**
* Get the value of a quaternion property
* @param[in] id Id of the transform component
*/
- Quaternion& GetQuaternionPropertyValue( TransformId id );
+ Quaternion& GetQuaternionPropertyValue(TransformId id);
/**
* Get the value of a quaternion property
* @param[in] id Id of the transform component
*/
- const Quaternion& GetQuaternionPropertyValue( TransformId id ) const;
+ const Quaternion& GetQuaternionPropertyValue(TransformId id) const;
/**
* Set the value of a quaternion property
* @param[in] id Id of the transform component
* @param[in] q The new value
*/
- void SetQuaternionPropertyValue( TransformId id, const Quaternion& q );
+ void SetQuaternionPropertyValue(TransformId id, const Quaternion& q);
/**
* Bake the value of a quaternion property
* @param[in] id Id of the transform component
* @param[in] q The new value
*/
- void BakeQuaternionPropertyValue( TransformId id, const Quaternion& q );
+ void BakeQuaternionPropertyValue(TransformId id, const Quaternion& q);
/**
* Bake the value of a quaternion property relative to its current value
* @param[in] id Id of the transform component
* @param[in] q The new value
*/
- void BakeRelativeQuaternionPropertyValue( TransformId id, const Quaternion& q );
+ void BakeRelativeQuaternionPropertyValue(TransformId id, const Quaternion& q);
/**
* Get the bounding sphere, in world coordinates, of a given component
* @param[in] id Id of the transform component
* @return The world space bounding sphere of the component
*/
- const Vector4& GetBoundingSphere( TransformId id ) const;
+ const Vector4& GetBoundingSphere(TransformId id) const;
/**
* Get the world matrix and size of a given component
* @param[out] The world matrix of the component
* @param[out] size size of the component
*/
- void GetWorldMatrixAndSize( TransformId id, Matrix& worldMatrix, Vector3& size ) const;
+ void GetWorldMatrixAndSize(TransformId id, Matrix& worldMatrix, Vector3& size) const;
/**
* @brief Sets the boolean which states whether the position should use the anchor-point on the given transform component.
* @param[in] id Id of the transform component
* @param[in] value True if the position should use the anchor-point
*/
- void SetPositionUsesAnchorPoint( TransformId id, bool value );
+ void SetPositionUsesAnchorPoint(TransformId id, bool value);
private:
-
//Helper struct to order components
struct SOrderItem
{
- bool operator<(const SOrderItem& item) const {return level < item.level;}
+ bool operator<(const SOrderItem& item) const
+ {
+ return level < item.level;
+ }
- TransformId id;
- uint32_t level;
+ TransformId id;
+ uint32_t level;
};
/**
* @param[in] i Index of a component
* @param[in] j Index of a component
*/
- void SwapComponents( uint32_t i, uint32_t j );
+ void SwapComponents(uint32_t i, uint32_t j);
/**
* Reorders components in hierarchical order so update can iterate sequentially
*/
void ReorderComponents();
- uint32_t mComponentCount; ///< Total number of components
- FreeList mIds; ///< FreeList of Ids
- Vector< TransformComponentAnimatable > mTxComponentAnimatable; ///< Animatable part of the components
- Vector< TransformComponentStatic > mTxComponentStatic; ///< Static part of the components
- Vector< uint32_t > mInheritanceMode; ///< Inheritance mode of the components
- Vector< TransformId > mComponentId; ///< Ids of the components
- Vector< Vector3 > mSize; ///< Size of the components
- Vector< TransformId > mParent; ///< Parent of the components
- Vector< Matrix > mWorld; ///< Local to world transform of the components
- Vector< Matrix > mLocal; ///< Local to parent space transform of the components
- Vector< Vector4 > mBoundingSpheres; ///< Bounding spheres. xyz is the center and w is the radius
- Vector< TransformComponentAnimatable > mTxComponentAnimatableBaseValue; ///< Base values for the animatable part of the components
- Vector< Vector3 > mSizeBase; ///< Base value for the size of the components
- Vector< bool > mComponentDirty; ///< 1u if some of the parts of the component has changed in this frame, 0 otherwise
- Vector< bool > mLocalMatrixDirty; ///< 1u if the local matrix has been updated in this frame, 0 otherwise
- Vector< SOrderItem > mOrderedComponents; ///< Used to reorder components when hierarchy changes
- bool mReorder; ///< Flag to determine if the components have to reordered in the next Update
+ uint32_t mComponentCount; ///< Total number of components
+ FreeList mIds; ///< FreeList of Ids
+ Vector<TransformComponentAnimatable> mTxComponentAnimatable; ///< Animatable part of the components
+ Vector<TransformComponentStatic> mTxComponentStatic; ///< Static part of the components
+ Vector<uint32_t> mInheritanceMode; ///< Inheritance mode of the components
+ Vector<TransformId> mComponentId; ///< Ids of the components
+ Vector<Vector3> mSize; ///< Size of the components
+ Vector<TransformId> mParent; ///< Parent of the components
+ Vector<Matrix> mWorld; ///< Local to world transform of the components
+ Vector<Matrix> mLocal; ///< Local to parent space transform of the components
+ Vector<Vector4> mBoundingSpheres; ///< Bounding spheres. xyz is the center and w is the radius
+ Vector<TransformComponentAnimatable> mTxComponentAnimatableBaseValue; ///< Base values for the animatable part of the components
+ Vector<Vector3> mSizeBase; ///< Base value for the size of the components
+ Vector<bool> mComponentDirty; ///< 1u if some of the parts of the component has changed in this frame, 0 otherwise
+ Vector<bool> mLocalMatrixDirty; ///< 1u if the local matrix has been updated in this frame, 0 otherwise
+ Vector<SOrderItem> mOrderedComponents; ///< Used to reorder components when hierarchy changes
+ bool mReorder; ///< Flag to determine if the components have to reordered in the next Update
};
} //namespace SceneGraph
} //namespace Internal
-
} //namespace Dali
-
#endif // DALI_INTERNAL_TRANSFORM_MANAGER_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <algorithm>
// INTERNAL INCLUDES
+#include <dali/internal/render/renderers/render-renderer.h>
+#include <dali/internal/update/animation/scene-graph-constraint-base.h>
+#include <dali/internal/update/nodes/node.h>
+#include <dali/internal/update/nodes/scene-graph-layer.h>
#include <dali/public-api/actors/draw-mode.h>
#include <dali/public-api/math/matrix.h>
#include <dali/public-api/math/vector3.h>
-#include <dali/internal/update/nodes/node.h>
-#include <dali/internal/update/animation/scene-graph-constraint-base.h>
-#include <dali/internal/update/nodes/scene-graph-layer.h>
-#include <dali/internal/render/renderers/render-renderer.h>
#include <dali/integration-api/debug.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
#if defined(DEBUG_ENABLED)
Debug::Filter* gUpdateFilter = Debug::Filter::New(Debug::Concise, false, "LOG_UPDATE_ALGORITHMS");
#endif
*********************** Apply Constraints ************************************
******************************************************************************/
-
/**
* Constrain the local properties of the PropertyOwner.
* @param propertyOwner to constrain
* @param updateBufferIndex buffer index to use
*/
-void ConstrainPropertyOwner( PropertyOwner& propertyOwner, BufferIndex updateBufferIndex )
+void ConstrainPropertyOwner(PropertyOwner& propertyOwner, BufferIndex updateBufferIndex)
{
ConstraintOwnerContainer& constraints = propertyOwner.GetConstraints();
const ConstraintIter endIter = constraints.End();
- for( ConstraintIter iter = constraints.Begin(); iter != endIter; ++iter )
+ for(ConstraintIter iter = constraints.Begin(); iter != endIter; ++iter)
{
ConstraintBase& constraint = **iter;
- constraint.Apply( updateBufferIndex );
+ constraint.Apply(updateBufferIndex);
}
}
************************** Update node hierarchy *****************************
******************************************************************************/
-inline void UpdateRootNodeOpacity( Layer& rootNode, NodePropertyFlags nodeDirtyFlags, BufferIndex updateBufferIndex )
+inline void UpdateRootNodeOpacity(Layer& rootNode, NodePropertyFlags nodeDirtyFlags, BufferIndex updateBufferIndex)
{
- if ( nodeDirtyFlags & NodePropertyFlags::COLOR )
+ if(nodeDirtyFlags & NodePropertyFlags::COLOR)
{
- rootNode.SetWorldColor( rootNode.GetColor( updateBufferIndex ), updateBufferIndex );
+ rootNode.SetWorldColor(rootNode.GetColor(updateBufferIndex), updateBufferIndex);
}
else
{
// Copy previous value, in case it changed in the previous frame
- rootNode.CopyPreviousWorldColor( updateBufferIndex );
+ rootNode.CopyPreviousWorldColor(updateBufferIndex);
}
}
-inline void UpdateNodeOpacity( Node& node, NodePropertyFlags nodeDirtyFlags, BufferIndex updateBufferIndex )
+inline void UpdateNodeOpacity(Node& node, NodePropertyFlags nodeDirtyFlags, BufferIndex updateBufferIndex)
{
// If opacity needs to be recalculated
- if ( nodeDirtyFlags & NodePropertyFlags::COLOR )
+ if(nodeDirtyFlags & NodePropertyFlags::COLOR)
{
- node.InheritWorldColor( updateBufferIndex );
+ node.InheritWorldColor(updateBufferIndex);
}
else
{
// Copy inherited value, if changed in the previous frame
- node.CopyPreviousWorldColor( updateBufferIndex );
+ node.CopyPreviousWorldColor(updateBufferIndex);
}
}
/**
* This is called recursively for all children of the root Node
*/
-inline NodePropertyFlags UpdateNodes( Node& node,
- NodePropertyFlags parentFlags,
- BufferIndex updateBufferIndex,
- RenderQueue& renderQueue,
- Layer& currentLayer,
- uint32_t inheritedDrawMode )
+inline NodePropertyFlags UpdateNodes(Node& node,
+ NodePropertyFlags parentFlags,
+ BufferIndex updateBufferIndex,
+ RenderQueue& renderQueue,
+ Layer& currentLayer,
+ uint32_t inheritedDrawMode)
{
// Apply constraints to the node
- ConstrainPropertyOwner( node, updateBufferIndex );
+ ConstrainPropertyOwner(node, updateBufferIndex);
// Some dirty flags are inherited from parent
- NodePropertyFlags nodeDirtyFlags = node.GetInheritedDirtyFlags( parentFlags );
+ NodePropertyFlags nodeDirtyFlags = node.GetInheritedDirtyFlags(parentFlags);
NodePropertyFlags cumulativeDirtyFlags = nodeDirtyFlags;
Layer* layer = ¤tLayer;
- Layer* nodeIsLayer( node.GetLayer() );
- if( nodeIsLayer )
+ Layer* nodeIsLayer(node.GetLayer());
+ if(nodeIsLayer)
{
// all childs go to this layer
layer = nodeIsLayer;
// assume layer is clean to begin with
- layer->SetReuseRenderers( updateBufferIndex, true );
+ layer->SetReuseRenderers(updateBufferIndex, true);
// Layers do not inherit the DrawMode from their parents
inheritedDrawMode = DrawMode::NORMAL;
}
- DALI_ASSERT_DEBUG( NULL != layer );
+ DALI_ASSERT_DEBUG(NULL != layer);
- UpdateNodeOpacity( node, nodeDirtyFlags, updateBufferIndex );
+ UpdateNodeOpacity(node, nodeDirtyFlags, updateBufferIndex);
// Draw mode inheritance is treated as or-ing the modes together (as they are a bit-mask).
inheritedDrawMode |= node.GetDrawMode();
- node.PrepareRender( updateBufferIndex );
+ node.PrepareRender(updateBufferIndex);
// if any child node has moved or had its sort modifier changed, layer is not clean and old frame cannot be reused
// also if node has been deleted, dont reuse old render items
- if( nodeDirtyFlags & RenderableUpdateFlags )
+ if(nodeDirtyFlags & RenderableUpdateFlags)
{
- layer->SetReuseRenderers( updateBufferIndex, false );
+ layer->SetReuseRenderers(updateBufferIndex, false);
}
// recurse children
NodeContainer& children = node.GetChildren();
- const NodeIter endIter = children.End();
- for ( NodeIter iter = children.Begin(); iter != endIter; ++iter )
+ const NodeIter endIter = children.End();
+ for(NodeIter iter = children.Begin(); iter != endIter; ++iter)
{
Node& child = **iter;
- cumulativeDirtyFlags |=UpdateNodes( child,
+ cumulativeDirtyFlags |= UpdateNodes(child,
nodeDirtyFlags,
updateBufferIndex,
renderQueue,
*layer,
- inheritedDrawMode );
+ inheritedDrawMode);
}
return cumulativeDirtyFlags;
/**
* The root node is treated separately; it cannot inherit values since it has no parent
*/
-NodePropertyFlags UpdateNodeTree( Layer& rootNode,
- BufferIndex updateBufferIndex,
- RenderQueue& renderQueue )
+NodePropertyFlags UpdateNodeTree(Layer& rootNode,
+ BufferIndex updateBufferIndex,
+ RenderQueue& renderQueue)
{
- DALI_ASSERT_DEBUG( rootNode.IsRoot() );
+ DALI_ASSERT_DEBUG(rootNode.IsRoot());
// Short-circuit for invisible nodes
- if ( DALI_UNLIKELY( !rootNode.IsVisible( updateBufferIndex ) ) ) // almost never ever true
+ if(DALI_UNLIKELY(!rootNode.IsVisible(updateBufferIndex))) // almost never ever true
{
return NodePropertyFlags::NOTHING;
}
// If the root node was not previously visible
BufferIndex previousBuffer = updateBufferIndex ? 0u : 1u;
- if ( DALI_UNLIKELY( !rootNode.IsVisible( previousBuffer ) ) ) // almost never ever true
+ if(DALI_UNLIKELY(!rootNode.IsVisible(previousBuffer))) // almost never ever true
{
// The node was skipped in the previous update; it must recalculate everything
rootNode.SetAllDirtyFlags();
}
- NodePropertyFlags nodeDirtyFlags( rootNode.GetDirtyFlags() );
+ NodePropertyFlags nodeDirtyFlags(rootNode.GetDirtyFlags());
NodePropertyFlags cumulativeDirtyFlags = nodeDirtyFlags;
- UpdateRootNodeOpacity( rootNode, nodeDirtyFlags, updateBufferIndex );
+ UpdateRootNodeOpacity(rootNode, nodeDirtyFlags, updateBufferIndex);
- DrawMode::Type drawMode( rootNode.GetDrawMode() );
+ DrawMode::Type drawMode(rootNode.GetDrawMode());
// recurse children
NodeContainer& children = rootNode.GetChildren();
- const NodeIter endIter = children.End();
- for ( NodeIter iter = children.Begin(); iter != endIter; ++iter )
+ const NodeIter endIter = children.End();
+ for(NodeIter iter = children.Begin(); iter != endIter; ++iter)
{
Node& child = **iter;
- cumulativeDirtyFlags |= UpdateNodes( child,
- nodeDirtyFlags,
- updateBufferIndex,
- renderQueue,
- rootNode,
- drawMode );
+ cumulativeDirtyFlags |= UpdateNodes(child,
+ nodeDirtyFlags,
+ updateBufferIndex,
+ renderQueue,
+ rootNode,
+ drawMode);
}
return cumulativeDirtyFlags;
#define DALI_INTERNAL_SCENE_GRAPH_UPDATE_ALGORITHMS_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
class Layer;
class PropertyOwner;
class RenderQueue;
* @param[in] propertyOwner The PropertyOwner to constrain
* @param[in] updateBufferIndex The current update buffer index.
*/
-void ConstrainPropertyOwner( PropertyOwner& propertyOwner, BufferIndex updateBufferIndex );
+void ConstrainPropertyOwner(PropertyOwner& propertyOwner, BufferIndex updateBufferIndex);
/**
* Update a tree of nodes
* @param[in] renderQueue Used to query messages for the next Render.
* @return The cumulative (ORed) dirty flags for the updated nodes
*/
-NodePropertyFlags UpdateNodeTree( Layer& rootNode,
- BufferIndex updateBufferIndex,
- RenderQueue& renderQueue );
+NodePropertyFlags UpdateNodeTree(Layer& rootNode,
+ BufferIndex updateBufferIndex,
+ RenderQueue& renderQueue);
} // namespace SceneGraph
} // namespace Dali
#endif // DALI_INTERNAL_SCENE_GRAPH_UPDATE_ALGORITHMS_H
-
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/update/manager/update-manager-debug.h>
// EXTERNAL INCLUDES
-#include <sstream>
#include <iomanip>
#include <ios>
+#include <sstream>
// INTERNAL INCLUDES
#include <dali/integration-api/debug.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
#if defined(DEBUG_ENABLED)
static Debug::Filter* gNodeLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_UPDATE_MANAGER");
#endif
/**
* Debug helper function.
*/
-void PrintNodes( const Node& node, BufferIndex updateBufferIndex, int level )
+void PrintNodes(const Node& node, BufferIndex updateBufferIndex, int level)
{
- const Vector3& position = node.GetPosition(updateBufferIndex);
- const Vector3& scale = node.GetScale(updateBufferIndex);
- const Vector3& fullPos = node.GetWorldPosition(updateBufferIndex);
+ const Vector3& position = node.GetPosition(updateBufferIndex);
+ const Vector3& scale = node.GetScale(updateBufferIndex);
+ const Vector3& fullPos = node.GetWorldPosition(updateBufferIndex);
const Quaternion& rotation = node.GetOrientation(updateBufferIndex);
- Vector3 axis;
- Radian angle;
+ Vector3 axis;
+ Radian angle;
rotation.ToAxisAngle(axis, angle);
- std::string nodeName= DALI_LOG_GET_OBJECT_STRING((&node));
+ std::string nodeName = DALI_LOG_GET_OBJECT_STRING((&node));
{
- std::ostringstream oss;
+ std::ostringstream oss;
std::ios_base::fmtflags mask = oss.flags();
mask &= ~std::ios_base::scientific;
- mask |= std::ios_base::fixed;
+ mask |= std::ios_base::fixed;
oss << std::setprecision(2) << std::setiosflags(mask)
- << std::setw(level*2) << std::setfill(' ') << "";
- oss << "Node " << nodeName << " " << &node
+ << std::setw(level * 2) << std::setfill(' ') << "";
+ oss << "Node " << nodeName << " " << &node
<< " Position (" << position.x << ", " << position.y << ", " << position.z << ")"
<< " WorldPosition (" << fullPos.x << ", " << fullPos.y << ", " << fullPos.z << ")"
<< " Orientation (" << Degree(angle).degree << "degrees <" << axis.x << ", " << axis.y << ", " << axis.z << ">)"
}
{
- std::ostringstream oss;
+ std::ostringstream oss;
std::ios_base::fmtflags mask = oss.flags();
mask &= ~std::ios_base::scientific;
- mask |= std::ios_base::fixed;
+ mask |= std::ios_base::fixed;
oss << std::setprecision(2) << std::setiosflags(mask)
- << std::setw(level*2) << std::setfill(' ') << "";
+ << std::setw(level * 2) << std::setfill(' ') << "";
- std::string trafoMatrix = Debug::MatrixToString(node.GetWorldMatrix(updateBufferIndex), 2, level*2);
+ std::string trafoMatrix = Debug::MatrixToString(node.GetWorldMatrix(updateBufferIndex), 2, level * 2);
DALI_LOG_INFO(gNodeLogFilter, Debug::Verbose, "%s\n", trafoMatrix.c_str());
}
++level;
- for ( NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter )
+ for(NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter)
{
PrintNodes(**iter, updateBufferIndex, level);
}
}
-void PrintNodeTree( const Node& node, BufferIndex bufferIndex, std::string indentation )
+void PrintNodeTree(const Node& node, BufferIndex bufferIndex, std::string indentation)
{
std::cout << "Node " << &node
<< " \"" << node.mDebugString << "\""
- << " Origin: " << node.GetParentOrigin()
- << " Anchor: " << node.GetAnchorPoint()
- << " Size: " << node.GetSize(bufferIndex)
- << " Pos: " << node.GetPosition(bufferIndex)
- << " Ori: " << node.GetOrientation(bufferIndex)
- << " Scale: " << node.GetScale(bufferIndex)
- << " Color: " << node.GetColor(bufferIndex)
- << " Visible: " << node.IsVisible(bufferIndex)
- << " World Pos: " << node.GetWorldPosition(bufferIndex)
- << " World Ori: " << node.GetWorldOrientation(bufferIndex)
- << " World Scale: " << node.GetWorldScale(bufferIndex)
- << " World Color: " << node.GetWorldColor(bufferIndex)
+ << " Origin: " << node.GetParentOrigin()
+ << " Anchor: " << node.GetAnchorPoint()
+ << " Size: " << node.GetSize(bufferIndex)
+ << " Pos: " << node.GetPosition(bufferIndex)
+ << " Ori: " << node.GetOrientation(bufferIndex)
+ << " Scale: " << node.GetScale(bufferIndex)
+ << " Color: " << node.GetColor(bufferIndex)
+ << " Visible: " << node.IsVisible(bufferIndex)
+ << " World Pos: " << node.GetWorldPosition(bufferIndex)
+ << " World Ori: " << node.GetWorldOrientation(bufferIndex)
+ << " World Scale: " << node.GetWorldScale(bufferIndex)
+ << " World Color: " << node.GetWorldColor(bufferIndex)
<< " World Matrix: " << node.GetWorldMatrix(bufferIndex)
<< std::endl;
- for ( NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter)
+ for(NodeConstIter iter = node.GetChildren().Begin(); iter != node.GetChildren().End(); ++iter)
{
std::cout << indentation << "|" << std::endl
<< indentation << "---->";
std::string nextIndent = indentation;
- if ( (iter + 1) != node.GetChildren().End() )
+ if((iter + 1) != node.GetChildren().End())
{
nextIndent += "| ";
}
}
}
-} // SceneGraph
+} // namespace SceneGraph
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#endif
#define DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_DEBUG_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <string>
// INTERNAL INCLUDES
-#include <dali/internal/update/nodes/node.h>
#include <dali/integration-api/debug.h>
+#include <dali/internal/update/nodes/node.h>
// Define this to access debug functions for the update manager.
#undef DALI_PRINT_UPDATE_INFO
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
+void PrintNodes(const Node& node, BufferIndex updateBufferIndex, int level);
-void PrintNodes( const Node& node, BufferIndex updateBufferIndex, int level);
-
-void PrintNodeTree( const Node& node, BufferIndex bufferIndex, std::string indentation="" );
+void PrintNodeTree(const Node& node, BufferIndex bufferIndex, std::string indentation = "");
-} // SceneGraph
+} // namespace SceneGraph
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#endif
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/integration-api/core.h>
+#include <dali/internal/event/animation/animation-playlist.h>
#include <dali/internal/event/common/notification-manager.h>
#include <dali/internal/event/common/property-notifier.h>
#include <dali/internal/event/effects/shader-factory.h>
-#include <dali/internal/event/animation/animation-playlist.h>
#include <dali/internal/update/common/discard-queue.h>
#include <dali/internal/update/controllers/render-message-dispatcher.h>
#include <dali/internal/update/controllers/scene-controller-impl.h>
#include <dali/internal/update/manager/frame-callback-processor.h>
#include <dali/internal/update/manager/render-task-processor.h>
+#include <dali/internal/update/manager/transform-manager.h>
#include <dali/internal/update/manager/update-algorithms.h>
#include <dali/internal/update/manager/update-manager-debug.h>
-#include <dali/internal/update/manager/transform-manager.h>
#include <dali/internal/update/nodes/node.h>
#include <dali/internal/update/queue/update-message-queue.h>
// Un-comment to enable node tree debug logging
//#define NODE_TREE_LOGGING 1
-#if ( defined( DEBUG_ENABLED ) && defined( NODE_TREE_LOGGING ) )
-#define SNAPSHOT_NODE_LOGGING \
-const uint32_t FRAME_COUNT_TRIGGER = 16;\
-if( mImpl->frameCounter >= FRAME_COUNT_TRIGGER )\
- {\
- for( auto&& scene : mImpl->scenes )
- {\
- if ( scene && scene->root )\
- {\
- mImpl->frameCounter = 0;\
- PrintNodeTree( *scene->root, mSceneGraphBuffers.GetUpdateBufferIndex(), "" );\
- }\
- }\
- }\
+#if(defined(DEBUG_ENABLED) && defined(NODE_TREE_LOGGING))
+#define SNAPSHOT_NODE_LOGGING \
+ const uint32_t FRAME_COUNT_TRIGGER = 16; \
+ if(mImpl->frameCounter >= FRAME_COUNT_TRIGGER) \
+ { \
+ for(auto&& scene : mImpl->scenes)
+{
+ if(scene && scene->root)
+ {
+ mImpl->frameCounter = 0;
+ PrintNodeTree(*scene->root, mSceneGraphBuffers.GetUpdateBufferIndex(), "");
+ }
+}
+}
mImpl->frameCounter++;
#else
#define SNAPSHOT_NODE_LOGGING
extern Debug::Filter* gRenderTaskLogFilter;
namespace
{
-Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_UPDATE_MANAGER" );
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_UPDATE_MANAGER");
} // unnamed namespace
#endif
-
using namespace Dali::Integration;
using Dali::Internal::Update::MessageQueue;
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
namespace
{
/**
* @param discardQueue to put the object to
* @param updateBufferIndex to use
*/
-template < class T >
-inline void EraseUsingDiscardQueue( OwnerContainer<T*>& container, T* object, DiscardQueue& discardQueue, BufferIndex updateBufferIndex )
+template<class T>
+inline void EraseUsingDiscardQueue(OwnerContainer<T*>& container, T* object, DiscardQueue& discardQueue, BufferIndex updateBufferIndex)
{
- DALI_ASSERT_DEBUG( object && "NULL object not allowed" );
+ DALI_ASSERT_DEBUG(object && "NULL object not allowed");
// need to use the reference version of auto as we need the pointer to the pointer for the Release call below
- for( auto&& iter : container )
+ for(auto&& iter : container)
{
- if ( iter == object )
+ if(iter == object)
{
// Transfer ownership to the discard queue, this keeps the object alive, until the render-thread has finished with it
- discardQueue.Add( updateBufferIndex, container.Release( &iter ) ); // take the address of the reference to a pointer (iter)
- return; // return as we only ever remove one object. Iterators to container are now invalidated as well so cannot continue
+ discardQueue.Add(updateBufferIndex, container.Release(&iter)); // take the address of the reference to a pointer (iter)
+ return; // return as we only ever remove one object. Iterators to container are now invalidated as well so cannot continue
}
}
}
* Descends into node's hierarchy and sorts the children of each child according to their depth-index.
* @param[in] node The node whose hierarchy to descend
*/
-void SortSiblingNodesRecursively( Node& node )
+void SortSiblingNodesRecursively(Node& node)
{
NodeContainer& container = node.GetChildren();
- std::sort( container.Begin(), container.End(),
- []( Node* a, Node* b ) { return a->GetDepthIndex() < b->GetDepthIndex(); } );
+ std::sort(container.Begin(), container.End(), [](Node* a, Node* b) { return a->GetDepthIndex() < b->GetDepthIndex(); });
// Descend tree and sort as well
- for( auto&& iter : container )
+ for(auto&& iter : container)
{
- SortSiblingNodesRecursively( *iter );
+ SortSiblingNodesRecursively(*iter);
}
}
// SceneInfo keeps the root node of the Scene, its scene graph render task list, and the list of Layer pointers sorted by depth
struct SceneInfo
{
- SceneInfo( Layer* root ) ///< Constructor
- : root( root )
+ SceneInfo(Layer* root) ///< Constructor
+ : root(root)
{
}
- ~SceneInfo() = default; ///< Default non-virtual destructor
- SceneInfo( SceneInfo&& rhs ) = default; ///< Move constructor
- SceneInfo& operator=( SceneInfo&& rhs ) = default; ///< Move assignment operator
- SceneInfo& operator=( const SceneInfo& rhs ) = delete; ///< Assignment operator
- SceneInfo( const SceneInfo& rhs ) = delete; ///< Copy constructor
+ ~SceneInfo() = default; ///< Default non-virtual destructor
+ SceneInfo(SceneInfo&& rhs) = default; ///< Move constructor
+ SceneInfo& operator=(SceneInfo&& rhs) = default; ///< Move assignment operator
+ SceneInfo& operator=(const SceneInfo& rhs) = delete; ///< Assignment operator
+ SceneInfo(const SceneInfo& rhs) = delete; ///< Copy constructor
- Layer* root{ nullptr }; ///< Root node (root is a layer). The layer is not stored in the node memory pool.
- OwnerPointer< RenderTaskList > taskList; ///< Scene graph render task list
- SortedLayerPointers sortedLayerList; ///< List of Layer pointers sorted by depth (one list of sorted layers per root)
- OwnerPointer< Scene > scene; ///< Scene graph object of the scene
+ Layer* root{nullptr}; ///< Root node (root is a layer). The layer is not stored in the node memory pool.
+ OwnerPointer<RenderTaskList> taskList; ///< Scene graph render task list
+ SortedLayerPointers sortedLayerList; ///< List of Layer pointers sorted by depth (one list of sorted layers per root)
+ OwnerPointer<Scene> scene; ///< Scene graph object of the scene
};
- Impl( NotificationManager& notificationManager,
- CompleteNotificationInterface& animationPlaylist,
- PropertyNotifier& propertyNotifier,
- DiscardQueue& discardQueue,
- RenderController& renderController,
- RenderManager& renderManager,
- RenderQueue& renderQueue,
- SceneGraphBuffers& sceneGraphBuffers,
- RenderTaskProcessor& renderTaskProcessor )
- : renderMessageDispatcher( renderManager, renderQueue, sceneGraphBuffers ),
- notificationManager( notificationManager ),
+ Impl(NotificationManager& notificationManager,
+ CompleteNotificationInterface& animationPlaylist,
+ PropertyNotifier& propertyNotifier,
+ DiscardQueue& discardQueue,
+ RenderController& renderController,
+ RenderManager& renderManager,
+ RenderQueue& renderQueue,
+ SceneGraphBuffers& sceneGraphBuffers,
+ RenderTaskProcessor& renderTaskProcessor)
+ : renderMessageDispatcher(renderManager, renderQueue, sceneGraphBuffers),
+ notificationManager(notificationManager),
transformManager(),
- animationPlaylist( animationPlaylist ),
- propertyNotifier( propertyNotifier ),
- shaderSaver( nullptr ),
- discardQueue( discardQueue ),
- renderController( renderController ),
- sceneController( nullptr ),
- renderManager( renderManager ),
- renderQueue( renderQueue ),
- renderTaskProcessor( renderTaskProcessor ),
- backgroundColor( Dali::DEFAULT_BACKGROUND_COLOR ),
+ animationPlaylist(animationPlaylist),
+ propertyNotifier(propertyNotifier),
+ shaderSaver(nullptr),
+ discardQueue(discardQueue),
+ renderController(renderController),
+ sceneController(nullptr),
+ renderManager(renderManager),
+ renderQueue(renderQueue),
+ renderTaskProcessor(renderTaskProcessor),
+ backgroundColor(Dali::DEFAULT_BACKGROUND_COLOR),
renderers(),
textureSets(),
shaders(),
- panGestureProcessor( nullptr ),
- messageQueue( renderController, sceneGraphBuffers ),
- frameCallbackProcessor( nullptr ),
- keepRenderingSeconds( 0.0f ),
- nodeDirtyFlags( NodePropertyFlags::TRANSFORM ), // set to TransformFlag to ensure full update the first time through Update()
- frameCounter( 0 ),
- renderingBehavior( DevelStage::Rendering::IF_REQUIRED ),
- animationFinishedDuringUpdate( false ),
- previousUpdateScene( false ),
- renderTaskWaiting( false ),
- renderersAdded( false ),
- renderingRequired( false )
+ panGestureProcessor(nullptr),
+ messageQueue(renderController, sceneGraphBuffers),
+ frameCallbackProcessor(nullptr),
+ keepRenderingSeconds(0.0f),
+ nodeDirtyFlags(NodePropertyFlags::TRANSFORM), // set to TransformFlag to ensure full update the first time through Update()
+ frameCounter(0),
+ renderingBehavior(DevelStage::Rendering::IF_REQUIRED),
+ animationFinishedDuringUpdate(false),
+ previousUpdateScene(false),
+ renderTaskWaiting(false),
+ renderersAdded(false),
+ renderingRequired(false)
{
- sceneController = new SceneControllerImpl( renderMessageDispatcher, renderQueue, discardQueue );
+ sceneController = new SceneControllerImpl(renderMessageDispatcher, renderQueue, discardQueue);
// create first 'dummy' node
nodes.PushBack(nullptr);
~Impl()
{
// Disconnect render tasks from nodes, before destroying the nodes
- for( auto&& scene : scenes )
+ for(auto&& scene : scenes)
{
- if ( scene && scene->taskList )
+ if(scene && scene->taskList)
{
RenderTaskList::RenderTaskContainer& tasks = scene->taskList->GetTasks();
- for ( auto&& task : tasks )
+ for(auto&& task : tasks)
{
- task->SetSourceNode( nullptr );
+ task->SetSourceNode(nullptr);
}
}
}
// UpdateManager owns the Nodes. Although Nodes are pool allocated they contain heap allocated parts
// like custom properties, which get released here
- Vector<Node*>::Iterator iter = nodes.Begin()+1;
+ Vector<Node*>::Iterator iter = nodes.Begin() + 1;
Vector<Node*>::Iterator endIter = nodes.End();
- for(;iter!=endIter;++iter)
+ for(; iter != endIter; ++iter)
{
(*iter)->OnDestroy();
Node::Delete(*iter);
}
- for( auto&& scene : scenes )
+ for(auto&& scene : scenes)
{
- if ( scene && scene->root )
+ if(scene && scene->root)
{
scene->root->OnDestroy();
- Node::Delete( scene->root );
+ Node::Delete(scene->root);
}
}
scenes.clear();
* Lazy init for FrameCallbackProcessor.
* @param[in] updateManager A reference to the update-manager
*/
- FrameCallbackProcessor& GetFrameCallbackProcessor( UpdateManager& updateManager )
+ FrameCallbackProcessor& GetFrameCallbackProcessor(UpdateManager& updateManager)
{
- if( ! frameCallbackProcessor )
+ if(!frameCallbackProcessor)
{
- frameCallbackProcessor = new FrameCallbackProcessor( updateManager, transformManager );
+ frameCallbackProcessor = new FrameCallbackProcessor(updateManager, transformManager);
}
return *frameCallbackProcessor;
}
- SceneGraphBuffers sceneGraphBuffers; ///< Used to keep track of which buffers are being written or read
- RenderMessageDispatcher renderMessageDispatcher; ///< Used for passing messages to the render-thread
- NotificationManager& notificationManager; ///< Queues notification messages for the event-thread.
- TransformManager transformManager; ///< Used to update the transformation matrices of the nodes
- CompleteNotificationInterface& animationPlaylist; ///< Holds handles to all the animations
- PropertyNotifier& propertyNotifier; ///< Provides notification to applications when properties are modified.
- ShaderSaver* shaderSaver; ///< Saves shader binaries.
- DiscardQueue& discardQueue; ///< Nodes are added here when disconnected from the scene-graph.
- RenderController& renderController; ///< render controller
- SceneControllerImpl* sceneController; ///< scene controller
- RenderManager& renderManager; ///< This is responsible for rendering the results of each "update"
- RenderQueue& renderQueue; ///< Used to queue messages for the next render
- RenderTaskProcessor& renderTaskProcessor; ///< Handles RenderTasks and RenderInstrucitons
-
- Vector4 backgroundColor; ///< The glClear color used at the beginning of each frame.
-
- using SceneInfoPtr = std::unique_ptr< SceneInfo >;
- std::vector< SceneInfoPtr > scenes; ///< A container of SceneInfo.
-
- Vector<Node*> nodes; ///< A container of all instantiated nodes
-
- OwnerContainer< Camera* > cameras; ///< A container of cameras
- OwnerContainer< PropertyOwner* > customObjects; ///< A container of owned objects (with custom properties)
-
- OwnerContainer< PropertyResetterBase* > propertyResetters; ///< A container of property resetters
- OwnerContainer< Animation* > animations; ///< A container of owned animations
- PropertyNotificationContainer propertyNotifications; ///< A container of owner property notifications.
- OwnerContainer< Renderer* > renderers; ///< A container of owned renderers
- OwnerContainer< TextureSet* > textureSets; ///< A container of owned texture sets
- OwnerContainer< Shader* > shaders; ///< A container of owned shaders
- OwnerPointer< PanGesture > panGestureProcessor; ///< Owned pan gesture processor; it lives for the lifecycle of UpdateManager
-
- MessageQueue messageQueue; ///< The messages queued from the event-thread
- std::vector<Internal::ShaderDataPtr> renderCompiledShaders; ///< Shaders compiled on Render thread are inserted here for update thread to pass on to event thread.
- std::vector<Internal::ShaderDataPtr> updateCompiledShaders; ///< Shaders to be sent from Update to Event
- Mutex compiledShaderMutex; ///< lock to ensure no corruption on the renderCompiledShaders
-
- OwnerPointer<FrameCallbackProcessor> frameCallbackProcessor; ///< Owned FrameCallbackProcessor, only created if required.
-
- float keepRenderingSeconds; ///< Set via Dali::Stage::KeepRendering
- NodePropertyFlags nodeDirtyFlags; ///< cumulative node dirty flags from previous frame
- uint32_t frameCounter; ///< Frame counter used in debugging to choose which frame to debug and which to ignore.
-
- DevelStage::Rendering renderingBehavior; ///< Set via DevelStage::SetRenderingBehavior
-
- bool animationFinishedDuringUpdate; ///< Flag whether any animations finished during the Update()
- bool previousUpdateScene; ///< True if the scene was updated in the previous frame (otherwise it was optimized out)
- bool renderTaskWaiting; ///< A REFRESH_ONCE render task is waiting to be rendered
- bool renderersAdded; ///< Flag to keep track when renderers have been added to avoid unnecessary processing
- bool renderingRequired; ///< True if required to render the current frame
+ SceneGraphBuffers sceneGraphBuffers; ///< Used to keep track of which buffers are being written or read
+ RenderMessageDispatcher renderMessageDispatcher; ///< Used for passing messages to the render-thread
+ NotificationManager& notificationManager; ///< Queues notification messages for the event-thread.
+ TransformManager transformManager; ///< Used to update the transformation matrices of the nodes
+ CompleteNotificationInterface& animationPlaylist; ///< Holds handles to all the animations
+ PropertyNotifier& propertyNotifier; ///< Provides notification to applications when properties are modified.
+ ShaderSaver* shaderSaver; ///< Saves shader binaries.
+ DiscardQueue& discardQueue; ///< Nodes are added here when disconnected from the scene-graph.
+ RenderController& renderController; ///< render controller
+ SceneControllerImpl* sceneController; ///< scene controller
+ RenderManager& renderManager; ///< This is responsible for rendering the results of each "update"
+ RenderQueue& renderQueue; ///< Used to queue messages for the next render
+ RenderTaskProcessor& renderTaskProcessor; ///< Handles RenderTasks and RenderInstrucitons
+
+ Vector4 backgroundColor; ///< The glClear color used at the beginning of each frame.
+
+ using SceneInfoPtr = std::unique_ptr<SceneInfo>;
+ std::vector<SceneInfoPtr> scenes; ///< A container of SceneInfo.
+
+ Vector<Node*> nodes; ///< A container of all instantiated nodes
+
+ OwnerContainer<Camera*> cameras; ///< A container of cameras
+ OwnerContainer<PropertyOwner*> customObjects; ///< A container of owned objects (with custom properties)
+
+ OwnerContainer<PropertyResetterBase*> propertyResetters; ///< A container of property resetters
+ OwnerContainer<Animation*> animations; ///< A container of owned animations
+ PropertyNotificationContainer propertyNotifications; ///< A container of owner property notifications.
+ OwnerContainer<Renderer*> renderers; ///< A container of owned renderers
+ OwnerContainer<TextureSet*> textureSets; ///< A container of owned texture sets
+ OwnerContainer<Shader*> shaders; ///< A container of owned shaders
+ OwnerPointer<PanGesture> panGestureProcessor; ///< Owned pan gesture processor; it lives for the lifecycle of UpdateManager
+
+ MessageQueue messageQueue; ///< The messages queued from the event-thread
+ std::vector<Internal::ShaderDataPtr> renderCompiledShaders; ///< Shaders compiled on Render thread are inserted here for update thread to pass on to event thread.
+ std::vector<Internal::ShaderDataPtr> updateCompiledShaders; ///< Shaders to be sent from Update to Event
+ Mutex compiledShaderMutex; ///< lock to ensure no corruption on the renderCompiledShaders
+
+ OwnerPointer<FrameCallbackProcessor> frameCallbackProcessor; ///< Owned FrameCallbackProcessor, only created if required.
+
+ float keepRenderingSeconds; ///< Set via Dali::Stage::KeepRendering
+ NodePropertyFlags nodeDirtyFlags; ///< cumulative node dirty flags from previous frame
+ uint32_t frameCounter; ///< Frame counter used in debugging to choose which frame to debug and which to ignore.
+
+ DevelStage::Rendering renderingBehavior; ///< Set via DevelStage::SetRenderingBehavior
+
+ bool animationFinishedDuringUpdate; ///< Flag whether any animations finished during the Update()
+ bool previousUpdateScene; ///< True if the scene was updated in the previous frame (otherwise it was optimized out)
+ bool renderTaskWaiting; ///< A REFRESH_ONCE render task is waiting to be rendered
+ bool renderersAdded; ///< Flag to keep track when renderers have been added to avoid unnecessary processing
+ bool renderingRequired; ///< True if required to render the current frame
private:
-
- Impl( const Impl& ); ///< Undefined
- Impl& operator=( const Impl& ); ///< Undefined
+ Impl(const Impl&); ///< Undefined
+ Impl& operator=(const Impl&); ///< Undefined
};
-UpdateManager::UpdateManager( NotificationManager& notificationManager,
- CompleteNotificationInterface& animationFinishedNotifier,
- PropertyNotifier& propertyNotifier,
- DiscardQueue& discardQueue,
- RenderController& controller,
- RenderManager& renderManager,
- RenderQueue& renderQueue,
- RenderTaskProcessor& renderTaskProcessor )
- : mImpl(nullptr)
-{
- mImpl = new Impl( notificationManager,
- animationFinishedNotifier,
- propertyNotifier,
- discardQueue,
- controller,
- renderManager,
- renderQueue,
- mSceneGraphBuffers,
- renderTaskProcessor );
-
+UpdateManager::UpdateManager(NotificationManager& notificationManager,
+ CompleteNotificationInterface& animationFinishedNotifier,
+ PropertyNotifier& propertyNotifier,
+ DiscardQueue& discardQueue,
+ RenderController& controller,
+ RenderManager& renderManager,
+ RenderQueue& renderQueue,
+ RenderTaskProcessor& renderTaskProcessor)
+: mImpl(nullptr)
+{
+ mImpl = new Impl(notificationManager,
+ animationFinishedNotifier,
+ propertyNotifier,
+ discardQueue,
+ controller,
+ renderManager,
+ renderQueue,
+ mSceneGraphBuffers,
+ renderTaskProcessor);
}
UpdateManager::~UpdateManager()
delete mImpl;
}
-void UpdateManager::InstallRoot( OwnerPointer<Layer>& layer )
+void UpdateManager::InstallRoot(OwnerPointer<Layer>& layer)
{
- DALI_ASSERT_DEBUG( layer->IsLayer() );
- DALI_ASSERT_DEBUG( layer->GetParent() == NULL);
+ DALI_ASSERT_DEBUG(layer->IsLayer());
+ DALI_ASSERT_DEBUG(layer->GetParent() == NULL);
Layer* rootLayer = layer.Release();
- DALI_ASSERT_DEBUG( std::find_if( mImpl->scenes.begin(), mImpl->scenes.end(),
- [rootLayer]( Impl::SceneInfoPtr& scene )
- {
- return scene && scene->root == rootLayer;
- }
- ) == mImpl->scenes.end() && "Root Node already installed" );
+ DALI_ASSERT_DEBUG(std::find_if(mImpl->scenes.begin(), mImpl->scenes.end(), [rootLayer](Impl::SceneInfoPtr& scene) {
+ return scene && scene->root == rootLayer;
+ }) == mImpl->scenes.end() &&
+ "Root Node already installed");
- rootLayer->CreateTransform( &mImpl->transformManager );
+ rootLayer->CreateTransform(&mImpl->transformManager);
rootLayer->SetRoot(true);
- mImpl->scenes.emplace_back( new Impl::SceneInfo( rootLayer ) );
+ mImpl->scenes.emplace_back(new Impl::SceneInfo(rootLayer));
}
-void UpdateManager::UninstallRoot( Layer* layer )
+void UpdateManager::UninstallRoot(Layer* layer)
{
- DALI_ASSERT_DEBUG( layer->IsLayer() );
- DALI_ASSERT_DEBUG( layer->GetParent() == NULL );
+ DALI_ASSERT_DEBUG(layer->IsLayer());
+ DALI_ASSERT_DEBUG(layer->GetParent() == NULL);
- for (auto iter = mImpl->scenes.begin(); iter != mImpl->scenes.end(); ++iter)
+ for(auto iter = mImpl->scenes.begin(); iter != mImpl->scenes.end(); ++iter)
{
- if( (*iter) && (*iter)->root == layer )
+ if((*iter) && (*iter)->root == layer)
{
- mImpl->scenes.erase( iter );
+ mImpl->scenes.erase(iter);
break;
}
}
- mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), layer );
+ mImpl->discardQueue.Add(mSceneGraphBuffers.GetUpdateBufferIndex(), layer);
// Notify the layer about impending destruction
layer->OnDestroy();
}
-void UpdateManager::AddNode( OwnerPointer<Node>& node )
+void UpdateManager::AddNode(OwnerPointer<Node>& node)
{
- DALI_ASSERT_ALWAYS( nullptr == node->GetParent() ); // Should not have a parent yet
+ DALI_ASSERT_ALWAYS(nullptr == node->GetParent()); // Should not have a parent yet
Node* rawNode = node.Release();
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%x] AddNode\n", rawNode );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "[%x] AddNode\n", rawNode);
mImpl->nodes.PushBack(rawNode);
rawNode->CreateTransform(&mImpl->transformManager);
}
-void UpdateManager::ConnectNode( Node* parent, Node* node )
+void UpdateManager::ConnectNode(Node* parent, Node* node)
{
- DALI_ASSERT_ALWAYS( nullptr != parent );
- DALI_ASSERT_ALWAYS( nullptr != node );
- DALI_ASSERT_ALWAYS( nullptr == node->GetParent() ); // Should not have a parent yet
+ DALI_ASSERT_ALWAYS(nullptr != parent);
+ DALI_ASSERT_ALWAYS(nullptr != node);
+ DALI_ASSERT_ALWAYS(nullptr == node->GetParent()); // Should not have a parent yet
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%x] ConnectNode\n", node );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "[%x] ConnectNode\n", node);
- parent->ConnectChild( node );
+ parent->ConnectChild(node);
// Inform the frame-callback-processor, if set, about the node-hierarchy changing
- if( mImpl->frameCallbackProcessor )
+ if(mImpl->frameCallbackProcessor)
{
mImpl->frameCallbackProcessor->NodeHierarchyChanged();
}
}
-void UpdateManager::DisconnectNode( Node* node )
+void UpdateManager::DisconnectNode(Node* node)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%x] DisconnectNode\n", node );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "[%x] DisconnectNode\n", node);
Node* parent = node->GetParent();
- DALI_ASSERT_ALWAYS( nullptr != parent );
- parent->SetDirtyFlag( NodePropertyFlags::CHILD_DELETED ); // make parent dirty so that render items dont get reused
+ DALI_ASSERT_ALWAYS(nullptr != parent);
+ parent->SetDirtyFlag(NodePropertyFlags::CHILD_DELETED); // make parent dirty so that render items dont get reused
- parent->DisconnectChild( mSceneGraphBuffers.GetUpdateBufferIndex(), *node );
+ parent->DisconnectChild(mSceneGraphBuffers.GetUpdateBufferIndex(), *node);
// Inform the frame-callback-processor, if set, about the node-hierarchy changing
- if( mImpl->frameCallbackProcessor )
+ if(mImpl->frameCallbackProcessor)
{
mImpl->frameCallbackProcessor->NodeHierarchyChanged();
}
}
-void UpdateManager::DestroyNode( Node* node )
+void UpdateManager::DestroyNode(Node* node)
{
- DALI_ASSERT_ALWAYS( nullptr != node );
- DALI_ASSERT_ALWAYS( nullptr == node->GetParent() ); // Should have been disconnected
+ DALI_ASSERT_ALWAYS(nullptr != node);
+ DALI_ASSERT_ALWAYS(nullptr == node->GetParent()); // Should have been disconnected
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%x] DestroyNode\n", node );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "[%x] DestroyNode\n", node);
- Vector<Node*>::Iterator iter = mImpl->nodes.Begin()+1;
+ Vector<Node*>::Iterator iter = mImpl->nodes.Begin() + 1;
Vector<Node*>::Iterator endIter = mImpl->nodes.End();
- for(;iter!=endIter;++iter)
+ for(; iter != endIter; ++iter)
{
if((*iter) == node)
{
}
}
- mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), node );
+ mImpl->discardQueue.Add(mSceneGraphBuffers.GetUpdateBufferIndex(), node);
// Notify the Node about impending destruction
node->OnDestroy();
}
-void UpdateManager::AddCamera( OwnerPointer< Camera >& camera )
+void UpdateManager::AddCamera(OwnerPointer<Camera>& camera)
{
- mImpl->cameras.PushBack( camera.Release() ); // takes ownership
+ mImpl->cameras.PushBack(camera.Release()); // takes ownership
}
-void UpdateManager::RemoveCamera( Camera* camera )
+void UpdateManager::RemoveCamera(Camera* camera)
{
// Find the camera and destroy it
- EraseUsingDiscardQueue( mImpl->cameras, camera, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
+ EraseUsingDiscardQueue(mImpl->cameras, camera, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex());
}
-void UpdateManager::AddObject( OwnerPointer<PropertyOwner>& object )
+void UpdateManager::AddObject(OwnerPointer<PropertyOwner>& object)
{
- mImpl->customObjects.PushBack( object.Release() );
+ mImpl->customObjects.PushBack(object.Release());
}
-void UpdateManager::RemoveObject( PropertyOwner* object )
+void UpdateManager::RemoveObject(PropertyOwner* object)
{
- mImpl->customObjects.EraseObject( object );
+ mImpl->customObjects.EraseObject(object);
}
-void UpdateManager::AddRenderTaskList( OwnerPointer<RenderTaskList>& taskList )
+void UpdateManager::AddRenderTaskList(OwnerPointer<RenderTaskList>& taskList)
{
RenderTaskList* taskListPointer = taskList.Release();
- taskListPointer->SetRenderMessageDispatcher( &mImpl->renderMessageDispatcher );
+ taskListPointer->SetRenderMessageDispatcher(&mImpl->renderMessageDispatcher);
mImpl->scenes.back()->taskList = taskListPointer;
}
-void UpdateManager::RemoveRenderTaskList( RenderTaskList* taskList )
+void UpdateManager::RemoveRenderTaskList(RenderTaskList* taskList)
{
- for ( auto&& scene : mImpl->scenes )
+ for(auto&& scene : mImpl->scenes)
{
- if ( scene && scene->taskList == taskList )
+ if(scene && scene->taskList == taskList)
{
scene->taskList.Reset();
break;
}
}
-void UpdateManager::AddScene( OwnerPointer< Scene >& scene )
+void UpdateManager::AddScene(OwnerPointer<Scene>& scene)
{
mImpl->scenes.back()->scene = scene.Release();
// Initialize the context from render manager
- typedef MessageValue1< RenderManager, SceneGraph::Scene* > DerivedType;
+ typedef MessageValue1<RenderManager, SceneGraph::Scene*> DerivedType;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
SceneGraph::Scene& sceneObject = *mImpl->scenes.back()->scene;
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::InitializeScene, &sceneObject );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::InitializeScene, &sceneObject);
}
-void UpdateManager::RemoveScene( Scene* scene )
+void UpdateManager::RemoveScene(Scene* scene)
{
// Initialize the context from render manager
using DerivedType = MessageValue1<RenderManager, SceneGraph::Scene*>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::UninitializeScene, scene );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::UninitializeScene, scene);
- for ( auto&& sceneInfo : mImpl->scenes )
+ for(auto&& sceneInfo : mImpl->scenes)
{
- if ( sceneInfo && sceneInfo->scene && sceneInfo->scene.Get() == scene )
+ if(sceneInfo && sceneInfo->scene && sceneInfo->scene.Get() == scene)
{
- mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), sceneInfo->scene.Release() ); // take the address of the reference to a pointer
+ mImpl->discardQueue.Add(mSceneGraphBuffers.GetUpdateBufferIndex(), sceneInfo->scene.Release()); // take the address of the reference to a pointer
break;
}
}
}
-void UpdateManager::AddAnimation( OwnerPointer< SceneGraph::Animation >& animation )
+void UpdateManager::AddAnimation(OwnerPointer<SceneGraph::Animation>& animation)
{
- mImpl->animations.PushBack( animation.Release() );
+ mImpl->animations.PushBack(animation.Release());
}
-void UpdateManager::StopAnimation( Animation* animation )
+void UpdateManager::StopAnimation(Animation* animation)
{
- DALI_ASSERT_DEBUG( animation && "NULL animation called to stop" );
+ DALI_ASSERT_DEBUG(animation && "NULL animation called to stop");
- bool animationFinished = animation->Stop( mSceneGraphBuffers.GetUpdateBufferIndex() );
+ bool animationFinished = animation->Stop(mSceneGraphBuffers.GetUpdateBufferIndex());
mImpl->animationFinishedDuringUpdate = mImpl->animationFinishedDuringUpdate || animationFinished;
}
-void UpdateManager::RemoveAnimation( Animation* animation )
+void UpdateManager::RemoveAnimation(Animation* animation)
{
- DALI_ASSERT_DEBUG( animation && "NULL animation called to remove" );
+ DALI_ASSERT_DEBUG(animation && "NULL animation called to remove");
- animation->OnDestroy( mSceneGraphBuffers.GetUpdateBufferIndex() );
+ animation->OnDestroy(mSceneGraphBuffers.GetUpdateBufferIndex());
- DALI_ASSERT_DEBUG( animation->GetState() == Animation::Destroyed );
+ DALI_ASSERT_DEBUG(animation->GetState() == Animation::Destroyed);
}
bool UpdateManager::IsAnimationRunning() const
{
// Find any animation that isn't stopped or paused
- for ( auto&& iter : mImpl->animations )
+ for(auto&& iter : mImpl->animations)
{
const Animation::State state = iter->GetState();
- if (state != Animation::Stopped &&
- state != Animation::Paused)
+ if(state != Animation::Stopped &&
+ state != Animation::Paused)
{
return true; // stop iteration as soon as first one is found
}
return false;
}
-void UpdateManager::AddPropertyResetter( OwnerPointer<PropertyResetterBase>& propertyResetter )
+void UpdateManager::AddPropertyResetter(OwnerPointer<PropertyResetterBase>& propertyResetter)
{
propertyResetter->Initialize();
- mImpl->propertyResetters.PushBack( propertyResetter.Release() );
+ mImpl->propertyResetters.PushBack(propertyResetter.Release());
}
-void UpdateManager::AddPropertyNotification( OwnerPointer< PropertyNotification >& propertyNotification )
+void UpdateManager::AddPropertyNotification(OwnerPointer<PropertyNotification>& propertyNotification)
{
- mImpl->propertyNotifications.PushBack( propertyNotification.Release() );
+ mImpl->propertyNotifications.PushBack(propertyNotification.Release());
}
-void UpdateManager::RemovePropertyNotification( PropertyNotification* propertyNotification )
+void UpdateManager::RemovePropertyNotification(PropertyNotification* propertyNotification)
{
- mImpl->propertyNotifications.EraseObject( propertyNotification );
+ mImpl->propertyNotifications.EraseObject(propertyNotification);
}
-void UpdateManager::PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode )
+void UpdateManager::PropertyNotificationSetNotify(PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode)
{
- DALI_ASSERT_DEBUG( propertyNotification && "propertyNotification scene graph object missing" );
- propertyNotification->SetNotifyMode( notifyMode );
+ DALI_ASSERT_DEBUG(propertyNotification && "propertyNotification scene graph object missing");
+ propertyNotification->SetNotifyMode(notifyMode);
}
-void UpdateManager::AddShader( OwnerPointer< Shader >& shader )
+void UpdateManager::AddShader(OwnerPointer<Shader>& shader)
{
- mImpl->shaders.PushBack( shader.Release() );
+ mImpl->shaders.PushBack(shader.Release());
}
-void UpdateManager::RemoveShader( Shader* shader )
+void UpdateManager::RemoveShader(Shader* shader)
{
// Find the shader and destroy it
- EraseUsingDiscardQueue( mImpl->shaders, shader, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
+ EraseUsingDiscardQueue(mImpl->shaders, shader, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex());
}
-void UpdateManager::SetShaderProgram( Shader* shader,
- Internal::ShaderDataPtr shaderData, bool modifiesGeometry )
+void UpdateManager::SetShaderProgram(Shader* shader,
+ Internal::ShaderDataPtr shaderData,
+ bool modifiesGeometry)
{
- if( shaderData )
+ if(shaderData)
{
using DerivedType = MessageValue3<Shader, Internal::ShaderDataPtr, ProgramCache*, bool>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( shader, &Shader::SetProgram, shaderData, mImpl->renderManager.GetProgramCache(), modifiesGeometry );
+ new(slot) DerivedType(shader, &Shader::SetProgram, shaderData, mImpl->renderManager.GetProgramCache(), modifiesGeometry);
}
}
-void UpdateManager::SaveBinary( Internal::ShaderDataPtr shaderData )
+void UpdateManager::SaveBinary(Internal::ShaderDataPtr shaderData)
{
- DALI_ASSERT_DEBUG( shaderData && "No NULL shader data pointers please." );
- DALI_ASSERT_DEBUG( shaderData->GetBufferSize() > 0 && "Shader binary empty so nothing to save." );
+ DALI_ASSERT_DEBUG(shaderData && "No NULL shader data pointers please.");
+ DALI_ASSERT_DEBUG(shaderData->GetBufferSize() > 0 && "Shader binary empty so nothing to save.");
{
// lock as update might be sending previously compiled shaders to event thread
- Mutex::ScopedLock lock( mImpl->compiledShaderMutex );
- mImpl->renderCompiledShaders.push_back( shaderData );
+ Mutex::ScopedLock lock(mImpl->compiledShaderMutex);
+ mImpl->renderCompiledShaders.push_back(shaderData);
}
}
-void UpdateManager::SetShaderSaver( ShaderSaver& upstream )
+void UpdateManager::SetShaderSaver(ShaderSaver& upstream)
{
mImpl->shaderSaver = &upstream;
}
-void UpdateManager::AddRenderer( OwnerPointer< Renderer >& renderer )
+void UpdateManager::AddRenderer(OwnerPointer<Renderer>& renderer)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%x] AddRenderer\n", renderer.Get() );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "[%x] AddRenderer\n", renderer.Get());
- renderer->ConnectToSceneGraph( *mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex() );
- mImpl->renderers.PushBack( renderer.Release() );
+ renderer->ConnectToSceneGraph(*mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex());
+ mImpl->renderers.PushBack(renderer.Release());
mImpl->renderersAdded = true;
}
-void UpdateManager::RemoveRenderer( Renderer* renderer )
+void UpdateManager::RemoveRenderer(Renderer* renderer)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%x] RemoveRenderer\n", renderer );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "[%x] RemoveRenderer\n", renderer);
// Find the renderer and destroy it
- EraseUsingDiscardQueue( mImpl->renderers, renderer, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
+ EraseUsingDiscardQueue(mImpl->renderers, renderer, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex());
// Need to remove the render object as well
- renderer->DisconnectFromSceneGraph( *mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex() );
+ renderer->DisconnectFromSceneGraph(*mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex());
}
-void UpdateManager::SetPanGestureProcessor( PanGesture* panGestureProcessor )
+void UpdateManager::SetPanGestureProcessor(PanGesture* panGestureProcessor)
{
- DALI_ASSERT_DEBUG( NULL != panGestureProcessor );
+ DALI_ASSERT_DEBUG(NULL != panGestureProcessor);
mImpl->panGestureProcessor = panGestureProcessor;
}
-void UpdateManager::AddTextureSet( OwnerPointer< TextureSet >& textureSet )
+void UpdateManager::AddTextureSet(OwnerPointer<TextureSet>& textureSet)
{
- mImpl->textureSets.PushBack( textureSet.Release() );
+ mImpl->textureSets.PushBack(textureSet.Release());
}
-void UpdateManager::RemoveTextureSet( TextureSet* textureSet )
+void UpdateManager::RemoveTextureSet(TextureSet* textureSet)
{
- mImpl->textureSets.EraseObject( textureSet );
+ mImpl->textureSets.EraseObject(textureSet);
}
-uint32_t* UpdateManager::ReserveMessageSlot( uint32_t size, bool updateScene )
+uint32_t* UpdateManager::ReserveMessageSlot(uint32_t size, bool updateScene)
{
- return mImpl->messageQueue.ReserveMessageSlot( size, updateScene );
+ return mImpl->messageQueue.ReserveMessageSlot(size, updateScene);
}
void UpdateManager::EventProcessingStarted()
return mImpl->messageQueue.FlushQueue();
}
-void UpdateManager::ResetProperties( BufferIndex bufferIndex )
+void UpdateManager::ResetProperties(BufferIndex bufferIndex)
{
// Clear the "animations finished" flag; This should be set if any (previously playing) animation is stopped
mImpl->animationFinishedDuringUpdate = false;
// Reset all animating / constrained properties
- std::vector<PropertyResetterBase*>toDelete;
- for( auto&& element : mImpl->propertyResetters )
+ std::vector<PropertyResetterBase*> toDelete;
+ for(auto&& element : mImpl->propertyResetters)
{
- element->ResetToBaseValue( bufferIndex );
- if( element->IsFinished() )
+ element->ResetToBaseValue(bufferIndex);
+ if(element->IsFinished())
{
- toDelete.push_back( element );
+ toDelete.push_back(element);
}
}
// If a resetter is no longer required (the animator or constraint has been removed), delete it.
- for( auto&& elementPtr : toDelete )
+ for(auto&& elementPtr : toDelete)
{
- mImpl->propertyResetters.EraseObject( elementPtr );
+ mImpl->propertyResetters.EraseObject(elementPtr);
}
// Clear all root nodes dirty flags
- for( auto& scene : mImpl->scenes )
+ for(auto& scene : mImpl->scenes)
{
auto root = scene->root;
- root->ResetDirtyFlags( bufferIndex );
+ root->ResetDirtyFlags(bufferIndex);
}
// Clear node dirty flags
- Vector<Node*>::Iterator iter = mImpl->nodes.Begin()+1;
+ Vector<Node*>::Iterator iter = mImpl->nodes.Begin() + 1;
Vector<Node*>::Iterator endIter = mImpl->nodes.End();
- for( ;iter != endIter; ++iter )
+ for(; iter != endIter; ++iter)
{
- (*iter)->ResetDirtyFlags( bufferIndex );
+ (*iter)->ResetDirtyFlags(bufferIndex);
}
}
-bool UpdateManager::ProcessGestures( BufferIndex bufferIndex, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds )
+bool UpdateManager::ProcessGestures(BufferIndex bufferIndex, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds)
{
- bool gestureUpdated( false );
+ bool gestureUpdated(false);
- if( mImpl->panGestureProcessor )
+ if(mImpl->panGestureProcessor)
{
// gesture processor only supports default properties
- mImpl->panGestureProcessor->ResetDefaultProperties( bufferIndex ); // Needs to be done every time as gesture data is written directly to an update-buffer rather than via a message
- gestureUpdated |= mImpl->panGestureProcessor->UpdateProperties( lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds );
+ mImpl->panGestureProcessor->ResetDefaultProperties(bufferIndex); // Needs to be done every time as gesture data is written directly to an update-buffer rather than via a message
+ gestureUpdated |= mImpl->panGestureProcessor->UpdateProperties(lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds);
}
return gestureUpdated;
}
-bool UpdateManager::Animate( BufferIndex bufferIndex, float elapsedSeconds )
+bool UpdateManager::Animate(BufferIndex bufferIndex, float elapsedSeconds)
{
bool animationActive = false;
- auto&& iter = mImpl->animations.Begin();
- bool animationLooped = false;
+ auto&& iter = mImpl->animations.Begin();
+ bool animationLooped = false;
- while ( iter != mImpl->animations.End() )
+ while(iter != mImpl->animations.End())
{
- Animation* animation = *iter;
- bool finished = false;
- bool looped = false;
- bool progressMarkerReached = false;
- animation->Update( bufferIndex, elapsedSeconds, looped, finished, progressMarkerReached );
+ Animation* animation = *iter;
+ bool finished = false;
+ bool looped = false;
+ bool progressMarkerReached = false;
+ animation->Update(bufferIndex, elapsedSeconds, looped, finished, progressMarkerReached);
animationActive = animationActive || animation->IsActive();
- if ( progressMarkerReached )
+ if(progressMarkerReached)
{
- mImpl->notificationManager.QueueMessage( Internal::NotifyProgressReachedMessage( mImpl->animationPlaylist, animation ) );
+ mImpl->notificationManager.QueueMessage(Internal::NotifyProgressReachedMessage(mImpl->animationPlaylist, animation));
}
mImpl->animationFinishedDuringUpdate = mImpl->animationFinishedDuringUpdate || finished;
- animationLooped = animationLooped || looped;
+ animationLooped = animationLooped || looped;
// Remove animations that had been destroyed but were still waiting for an update
- if (animation->GetState() == Animation::Destroyed)
+ if(animation->GetState() == Animation::Destroyed)
{
iter = mImpl->animations.Erase(iter);
}
}
// queue the notification on finished or looped (to update loop count)
- if ( mImpl->animationFinishedDuringUpdate || animationLooped )
+ if(mImpl->animationFinishedDuringUpdate || animationLooped)
{
// The application should be notified by NotificationManager, in another thread
- mImpl->notificationManager.QueueCompleteNotification( &mImpl->animationPlaylist );
+ mImpl->notificationManager.QueueCompleteNotification(&mImpl->animationPlaylist);
}
return animationActive;
}
-void UpdateManager::ConstrainCustomObjects( BufferIndex bufferIndex )
+void UpdateManager::ConstrainCustomObjects(BufferIndex bufferIndex)
{
//Constrain custom objects (in construction order)
- for ( auto&& object : mImpl->customObjects )
+ for(auto&& object : mImpl->customObjects)
{
- ConstrainPropertyOwner( *object, bufferIndex );
+ ConstrainPropertyOwner(*object, bufferIndex);
}
}
-void UpdateManager::ConstrainRenderTasks( BufferIndex bufferIndex )
+void UpdateManager::ConstrainRenderTasks(BufferIndex bufferIndex)
{
// Constrain render-tasks
- for ( auto&& scene : mImpl->scenes )
+ for(auto&& scene : mImpl->scenes)
{
- if ( scene && scene->taskList )
+ if(scene && scene->taskList)
{
RenderTaskList::RenderTaskContainer& tasks = scene->taskList->GetTasks();
- for ( auto&& task : tasks )
+ for(auto&& task : tasks)
{
- ConstrainPropertyOwner( *task, bufferIndex );
+ ConstrainPropertyOwner(*task, bufferIndex);
}
}
}
}
-void UpdateManager::ConstrainShaders( BufferIndex bufferIndex )
+void UpdateManager::ConstrainShaders(BufferIndex bufferIndex)
{
// constrain shaders... (in construction order)
- for ( auto&& shader : mImpl->shaders )
+ for(auto&& shader : mImpl->shaders)
{
- ConstrainPropertyOwner( *shader, bufferIndex );
+ ConstrainPropertyOwner(*shader, bufferIndex);
}
}
-void UpdateManager::ProcessPropertyNotifications( BufferIndex bufferIndex )
+void UpdateManager::ProcessPropertyNotifications(BufferIndex bufferIndex)
{
- for( auto&& notification : mImpl->propertyNotifications )
+ for(auto&& notification : mImpl->propertyNotifications)
{
- bool valid = notification->Check( bufferIndex );
+ bool valid = notification->Check(bufferIndex);
if(valid)
{
- mImpl->notificationManager.QueueMessage( PropertyChangedMessage( mImpl->propertyNotifier, notification, notification->GetValidity() ) );
+ mImpl->notificationManager.QueueMessage(PropertyChangedMessage(mImpl->propertyNotifier, notification, notification->GetValidity()));
}
}
}
void UpdateManager::ForwardCompiledShadersToEventThread()
{
- DALI_ASSERT_DEBUG( (mImpl->shaderSaver != 0) && "shaderSaver should be wired-up during startup." );
- if( mImpl->shaderSaver )
+ DALI_ASSERT_DEBUG((mImpl->shaderSaver != 0) && "shaderSaver should be wired-up during startup.");
+ if(mImpl->shaderSaver)
{
// lock and swap the queues
{
// render might be attempting to send us more binaries at the same time
- Mutex::ScopedLock lock( mImpl->compiledShaderMutex );
- mImpl->renderCompiledShaders.swap( mImpl->updateCompiledShaders );
+ Mutex::ScopedLock lock(mImpl->compiledShaderMutex);
+ mImpl->renderCompiledShaders.swap(mImpl->updateCompiledShaders);
}
- if( mImpl->updateCompiledShaders.size() > 0 )
+ if(mImpl->updateCompiledShaders.size() > 0)
{
ShaderSaver& factory = *mImpl->shaderSaver;
- for( auto&& shader : mImpl->updateCompiledShaders )
+ for(auto&& shader : mImpl->updateCompiledShaders)
{
- mImpl->notificationManager.QueueMessage( ShaderCompiledMessage( factory, shader ) );
+ mImpl->notificationManager.QueueMessage(ShaderCompiledMessage(factory, shader));
}
// we don't need them in update anymore
mImpl->updateCompiledShaders.clear();
}
}
-void UpdateManager::UpdateRenderers( BufferIndex bufferIndex )
+void UpdateManager::UpdateRenderers(BufferIndex bufferIndex)
{
- for( auto&& renderer : mImpl->renderers )
+ for(auto&& renderer : mImpl->renderers)
{
//Apply constraints
- ConstrainPropertyOwner( *renderer, bufferIndex );
+ ConstrainPropertyOwner(*renderer, bufferIndex);
- mImpl->renderingRequired = renderer->PrepareRender( bufferIndex ) || mImpl->renderingRequired;
+ mImpl->renderingRequired = renderer->PrepareRender(bufferIndex) || mImpl->renderingRequired;
}
}
-void UpdateManager::UpdateNodes( BufferIndex bufferIndex )
+void UpdateManager::UpdateNodes(BufferIndex bufferIndex)
{
mImpl->nodeDirtyFlags = NodePropertyFlags::NOTHING;
- for ( auto&& scene : mImpl->scenes )
+ for(auto&& scene : mImpl->scenes)
{
- if ( scene && scene->root )
+ if(scene && scene->root)
{
// Prepare resources, update shaders, for each node
// And add the renderers to the sorted layers. Start from root, which is also a layer
- mImpl->nodeDirtyFlags |= UpdateNodeTree( *scene->root,
+ mImpl->nodeDirtyFlags |= UpdateNodeTree(*scene->root,
bufferIndex,
- mImpl->renderQueue );
+ mImpl->renderQueue);
}
}
}
-uint32_t UpdateManager::Update( float elapsedSeconds,
- uint32_t lastVSyncTimeMilliseconds,
- uint32_t nextVSyncTimeMilliseconds,
- bool renderToFboEnabled,
- bool isRenderingToFbo )
+uint32_t UpdateManager::Update(float elapsedSeconds,
+ uint32_t lastVSyncTimeMilliseconds,
+ uint32_t nextVSyncTimeMilliseconds,
+ bool renderToFboEnabled,
+ bool isRenderingToFbo)
{
const BufferIndex bufferIndex = mSceneGraphBuffers.GetUpdateBufferIndex();
//Clear nodes/resources which were previously discarded
- mImpl->discardQueue.Clear( bufferIndex );
+ mImpl->discardQueue.Clear(bufferIndex);
bool isAnimationRunning = IsAnimationRunning();
//Process Touches & Gestures
- const bool gestureUpdated = ProcessGestures( bufferIndex, lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds );
+ const bool gestureUpdated = ProcessGestures(bufferIndex, lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds);
- bool updateScene = // The scene-graph requires an update if..
- (mImpl->nodeDirtyFlags & RenderableUpdateFlags) || // ..nodes were dirty in previous frame OR
- isAnimationRunning || // ..at least one animation is running OR
- mImpl->messageQueue.IsSceneUpdateRequired() || // ..a message that modifies the scene graph node tree is queued OR
- mImpl->frameCallbackProcessor || // ..a frame callback processor is existed OR
- gestureUpdated; // ..a gesture property was updated
+ bool updateScene = // The scene-graph requires an update if..
+ (mImpl->nodeDirtyFlags & RenderableUpdateFlags) || // ..nodes were dirty in previous frame OR
+ isAnimationRunning || // ..at least one animation is running OR
+ mImpl->messageQueue.IsSceneUpdateRequired() || // ..a message that modifies the scene graph node tree is queued OR
+ mImpl->frameCallbackProcessor || // ..a frame callback processor is existed OR
+ gestureUpdated; // ..a gesture property was updated
bool keepRendererRendering = false;
- mImpl->renderingRequired = false;
+ mImpl->renderingRequired = false;
// Although the scene-graph may not require an update, we still need to synchronize double-buffered
// values if the scene was updated in the previous frame.
- if( updateScene || mImpl->previousUpdateScene )
+ if(updateScene || mImpl->previousUpdateScene)
{
//Reset properties from the previous update
- ResetProperties( bufferIndex );
+ ResetProperties(bufferIndex);
mImpl->transformManager.ResetToBaseValue();
}
// Process the queued scene messages. Note, MessageQueue::FlushQueue may be called
// between calling IsSceneUpdateRequired() above and here, so updateScene should
// be set again
- updateScene |= mImpl->messageQueue.ProcessMessages( bufferIndex );
+ updateScene |= mImpl->messageQueue.ProcessMessages(bufferIndex);
//Forward compiled shader programs to event thread for saving
ForwardCompiledShadersToEventThread();
// Although the scene-graph may not require an update, we still need to synchronize double-buffered
// renderer lists if the scene was updated in the previous frame.
// We should not start skipping update steps or reusing lists until there has been two frames where nothing changes
- if( updateScene || mImpl->previousUpdateScene )
+ if(updateScene || mImpl->previousUpdateScene)
{
//Animate
- bool animationActive = Animate( bufferIndex, elapsedSeconds );
+ bool animationActive = Animate(bufferIndex, elapsedSeconds);
//Constraint custom objects
- ConstrainCustomObjects( bufferIndex );
+ ConstrainCustomObjects(bufferIndex);
//Clear the lists of renderers from the previous update
- for( auto&& scene : mImpl->scenes )
+ for(auto&& scene : mImpl->scenes)
{
- if ( scene )
+ if(scene)
{
- for( auto&& layer : scene->sortedLayerList )
+ for(auto&& layer : scene->sortedLayerList)
{
- if ( layer )
+ if(layer)
{
layer->ClearRenderables();
}
}
// Call the frame-callback-processor if set
- if( mImpl->frameCallbackProcessor )
+ if(mImpl->frameCallbackProcessor)
{
- mImpl->frameCallbackProcessor->Update( bufferIndex, elapsedSeconds );
+ mImpl->frameCallbackProcessor->Update(bufferIndex, elapsedSeconds);
}
//Update node hierarchy, apply constraints and perform sorting / culling.
//This will populate each Layer with a list of renderers which are ready.
- UpdateNodes( bufferIndex );
+ UpdateNodes(bufferIndex);
//Apply constraints to RenderTasks, shaders
- ConstrainRenderTasks( bufferIndex );
- ConstrainShaders( bufferIndex );
+ ConstrainRenderTasks(bufferIndex);
+ ConstrainShaders(bufferIndex);
//Update renderers and apply constraints
- UpdateRenderers( bufferIndex );
+ UpdateRenderers(bufferIndex);
//Update the transformations of all the nodes
- if ( mImpl->transformManager.Update() )
+ if(mImpl->transformManager.Update())
{
mImpl->nodeDirtyFlags |= NodePropertyFlags::TRANSFORM;
}
//Process Property Notifications
- ProcessPropertyNotifications( bufferIndex );
+ ProcessPropertyNotifications(bufferIndex);
//Update cameras
- for( auto&& cameraIterator : mImpl->cameras )
+ for(auto&& cameraIterator : mImpl->cameras)
{
- cameraIterator->Update( bufferIndex );
+ cameraIterator->Update(bufferIndex);
}
//Process the RenderTasks if renderers exist. This creates the instructions for rendering the next frame.
//reset the update buffer index and make sure there is enough room in the instruction container
- if( mImpl->renderersAdded )
+ if(mImpl->renderersAdded)
{
// Calculate how many render tasks we have in total
std::size_t numberOfRenderTasks = 0;
- for (auto&& scene : mImpl->scenes )
+ for(auto&& scene : mImpl->scenes)
{
- if ( scene && scene->taskList )
+ if(scene && scene->taskList)
{
numberOfRenderTasks += scene->taskList->GetTasks().Count();
}
}
std::size_t numberOfRenderInstructions = 0;
- for ( auto&& scene : mImpl->scenes )
+ for(auto&& scene : mImpl->scenes)
{
- if ( scene && scene->root && scene->taskList && scene->scene )
+ if(scene && scene->root && scene->taskList && scene->scene)
{
- scene->scene->GetRenderInstructions().ResetAndReserve( bufferIndex,
- static_cast<uint32_t>( scene->taskList->GetTasks().Count() ) );
+ scene->scene->GetRenderInstructions().ResetAndReserve(bufferIndex,
+ static_cast<uint32_t>(scene->taskList->GetTasks().Count()));
// If there are animations running, only add render instruction if at least one animation is currently active (i.e. not delayed)
// or the nodes are dirty
- if ( !isAnimationRunning || animationActive || mImpl->renderingRequired || (mImpl->nodeDirtyFlags & RenderableUpdateFlags) )
+ if(!isAnimationRunning || animationActive || mImpl->renderingRequired || (mImpl->nodeDirtyFlags & RenderableUpdateFlags))
{
- keepRendererRendering |= mImpl->renderTaskProcessor.Process( bufferIndex,
- *scene->taskList,
- *scene->root,
- scene->sortedLayerList,
- scene->scene->GetRenderInstructions(),
- renderToFboEnabled,
- isRenderingToFbo );
-
- scene->scene->SetSkipRendering( false );
+ keepRendererRendering |= mImpl->renderTaskProcessor.Process(bufferIndex,
+ *scene->taskList,
+ *scene->root,
+ scene->sortedLayerList,
+ scene->scene->GetRenderInstructions(),
+ renderToFboEnabled,
+ isRenderingToFbo);
+
+ scene->scene->SetSkipRendering(false);
}
else
{
- scene->scene->SetSkipRendering( true );
+ scene->scene->SetSkipRendering(true);
}
- numberOfRenderInstructions += scene->scene->GetRenderInstructions().Count( bufferIndex );
+ numberOfRenderInstructions += scene->scene->GetRenderInstructions().Count(bufferIndex);
}
}
- DALI_LOG_INFO( gLogFilter, Debug::General,
- "Update: numberOfRenderTasks(%d), Render Instructions(%d)\n",
- numberOfRenderTasks, numberOfRenderInstructions );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "Update: numberOfRenderTasks(%d), Render Instructions(%d)\n", numberOfRenderTasks, numberOfRenderInstructions);
}
}
- for ( auto&& scene : mImpl->scenes )
+ for(auto&& scene : mImpl->scenes)
{
- if ( scene && scene->root && scene->taskList )
+ if(scene && scene->root && scene->taskList)
{
RenderTaskList::RenderTaskContainer& tasks = scene->taskList->GetTasks();
// check the countdown and notify
- bool doRenderOnceNotify = false;
+ bool doRenderOnceNotify = false;
mImpl->renderTaskWaiting = false;
- for ( auto&& renderTask : tasks )
+ for(auto&& renderTask : tasks)
{
renderTask->UpdateState();
- if( renderTask->IsWaitingToRender() &&
- renderTask->ReadyToRender( bufferIndex ) /*avoid updating forever when source actor is off-stage*/ )
+ if(renderTask->IsWaitingToRender() &&
+ renderTask->ReadyToRender(bufferIndex) /*avoid updating forever when source actor is off-stage*/)
{
mImpl->renderTaskWaiting = true; // keep update/render threads alive
}
- if( renderTask->HasRendered() )
+ if(renderTask->HasRendered())
{
doRenderOnceNotify = true;
}
}
- if( doRenderOnceNotify )
+ if(doRenderOnceNotify)
{
DALI_LOG_INFO(gRenderTaskLogFilter, Debug::General, "Notify a render task has finished\n");
- mImpl->notificationManager.QueueCompleteNotification( scene->taskList->GetCompleteNotificationInterface() );
+ mImpl->notificationManager.QueueCompleteNotification(scene->taskList->GetCompleteNotificationInterface());
}
}
}
mImpl->previousUpdateScene = updateScene;
// Check whether further updates are required
- uint32_t keepUpdating = KeepUpdatingCheck( elapsedSeconds );
+ uint32_t keepUpdating = KeepUpdatingCheck(elapsedSeconds);
- if( keepRendererRendering )
+ if(keepRendererRendering)
{
keepUpdating |= KeepUpdating::STAGE_KEEP_RENDERING;
return keepUpdating;
}
-uint32_t UpdateManager::KeepUpdatingCheck( float elapsedSeconds ) const
+uint32_t UpdateManager::KeepUpdatingCheck(float elapsedSeconds) const
{
// Update the duration set via Stage::KeepRendering()
- if ( mImpl->keepRenderingSeconds > 0.0f )
+ if(mImpl->keepRenderingSeconds > 0.0f)
{
mImpl->keepRenderingSeconds -= elapsedSeconds;
}
// No need to check for renderQueue as there is always a render after update and if that
// render needs another update it will tell the adaptor to call update again
- if ( ( mImpl->renderingBehavior == DevelStage::Rendering::CONTINUOUSLY ) ||
- ( mImpl->keepRenderingSeconds > 0.0f ) )
+ if((mImpl->renderingBehavior == DevelStage::Rendering::CONTINUOUSLY) ||
+ (mImpl->keepRenderingSeconds > 0.0f))
{
keepUpdatingRequest |= KeepUpdating::STAGE_KEEP_RENDERING;
}
- if ( IsAnimationRunning() ||
- mImpl->animationFinishedDuringUpdate )
+ if(IsAnimationRunning() ||
+ mImpl->animationFinishedDuringUpdate)
{
keepUpdatingRequest |= KeepUpdating::ANIMATIONS_RUNNING;
}
- if ( mImpl->renderTaskWaiting )
+ if(mImpl->renderTaskWaiting)
{
keepUpdatingRequest |= KeepUpdating::RENDER_TASK_SYNC;
}
return keepUpdatingRequest;
}
-void UpdateManager::SurfaceReplaced( Scene* scene )
+void UpdateManager::SurfaceReplaced(Scene* scene)
{
using DerivedType = MessageValue1<RenderManager, Scene*>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SurfaceReplaced, scene );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::SurfaceReplaced, scene);
}
-void UpdateManager::KeepRendering( float durationSeconds )
+void UpdateManager::KeepRendering(float durationSeconds)
{
- mImpl->keepRenderingSeconds = std::max( mImpl->keepRenderingSeconds, durationSeconds );
+ mImpl->keepRenderingSeconds = std::max(mImpl->keepRenderingSeconds, durationSeconds);
}
-void UpdateManager::SetRenderingBehavior( DevelStage::Rendering renderingBehavior )
+void UpdateManager::SetRenderingBehavior(DevelStage::Rendering renderingBehavior)
{
mImpl->renderingBehavior = renderingBehavior;
}
mImpl->renderingRequired = true;
}
-void UpdateManager::SetLayerDepths( const SortedLayerPointers& layers, const Layer* rootLayer )
+void UpdateManager::SetLayerDepths(const SortedLayerPointers& layers, const Layer* rootLayer)
{
- for ( auto&& scene : mImpl->scenes )
+ for(auto&& scene : mImpl->scenes)
{
- if ( scene && scene->root == rootLayer )
+ if(scene && scene->root == rootLayer)
{
scene->sortedLayerList = layers;
break;
}
}
-void UpdateManager::SetDepthIndices( OwnerPointer< NodeDepths >& nodeDepths )
+void UpdateManager::SetDepthIndices(OwnerPointer<NodeDepths>& nodeDepths)
{
// note,this vector is already in depth order. It could be used as-is to
// remove sorting in update algorithm. However, it lacks layer boundary markers.
- for( auto&& iter : nodeDepths->nodeDepths )
+ for(auto&& iter : nodeDepths->nodeDepths)
{
- iter.node->SetDepthIndex( iter.sortedDepth );
+ iter.node->SetDepthIndex(iter.sortedDepth);
}
- for ( auto&& scene : mImpl->scenes )
+ for(auto&& scene : mImpl->scenes)
{
- if ( scene )
+ if(scene)
{
// Go through node hierarchy and rearrange siblings according to depth-index
- SortSiblingNodesRecursively( *scene->root );
+ SortSiblingNodesRecursively(*scene->root);
}
}
}
-void UpdateManager::AddFrameCallback( OwnerPointer< FrameCallback >& frameCallback, const Node* rootNode )
+void UpdateManager::AddFrameCallback(OwnerPointer<FrameCallback>& frameCallback, const Node* rootNode)
{
- mImpl->GetFrameCallbackProcessor( *this ).AddFrameCallback( frameCallback, rootNode );
+ mImpl->GetFrameCallbackProcessor(*this).AddFrameCallback(frameCallback, rootNode);
}
-void UpdateManager::RemoveFrameCallback( FrameCallbackInterface* frameCallback )
+void UpdateManager::RemoveFrameCallback(FrameCallbackInterface* frameCallback)
{
- mImpl->GetFrameCallbackProcessor( *this ).RemoveFrameCallback( frameCallback );
+ mImpl->GetFrameCallbackProcessor(*this).RemoveFrameCallback(frameCallback);
}
-void UpdateManager::AddSampler( OwnerPointer< Render::Sampler >& sampler )
+void UpdateManager::AddSampler(OwnerPointer<Render::Sampler>& sampler)
{
// Message has ownership of Sampler while in transit from update to render
using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::Sampler> >;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddSampler, sampler );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AddSampler, sampler);
}
-void UpdateManager::RemoveSampler( Render::Sampler* sampler )
+void UpdateManager::RemoveSampler(Render::Sampler* sampler)
{
using DerivedType = MessageValue1<RenderManager, Render::Sampler*>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveSampler, sampler );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::RemoveSampler, sampler);
}
-void UpdateManager::SetFilterMode( Render::Sampler* sampler, uint32_t minFilterMode, uint32_t magFilterMode )
+void UpdateManager::SetFilterMode(Render::Sampler* sampler, uint32_t minFilterMode, uint32_t magFilterMode)
{
using DerivedType = MessageValue3<RenderManager, Render::Sampler*, uint32_t, uint32_t>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetFilterMode, sampler, minFilterMode, magFilterMode );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::SetFilterMode, sampler, minFilterMode, magFilterMode);
}
-void UpdateManager::SetWrapMode( Render::Sampler* sampler, uint32_t rWrapMode, uint32_t sWrapMode, uint32_t tWrapMode )
+void UpdateManager::SetWrapMode(Render::Sampler* sampler, uint32_t rWrapMode, uint32_t sWrapMode, uint32_t tWrapMode)
{
using DerivedType = MessageValue4<RenderManager, Render::Sampler*, uint32_t, uint32_t, uint32_t>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetWrapMode, sampler, rWrapMode, sWrapMode, tWrapMode );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::SetWrapMode, sampler, rWrapMode, sWrapMode, tWrapMode);
}
-void UpdateManager::AddVertexBuffer( OwnerPointer< Render::VertexBuffer >& vertexBuffer )
+void UpdateManager::AddVertexBuffer(OwnerPointer<Render::VertexBuffer>& vertexBuffer)
{
// Message has ownership of format while in transit from update -> render
using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::VertexBuffer> >;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddVertexBuffer, vertexBuffer );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AddVertexBuffer, vertexBuffer);
}
-void UpdateManager::RemoveVertexBuffer( Render::VertexBuffer* vertexBuffer )
+void UpdateManager::RemoveVertexBuffer(Render::VertexBuffer* vertexBuffer)
{
using DerivedType = MessageValue1<RenderManager, Render::VertexBuffer*>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveVertexBuffer, vertexBuffer );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::RemoveVertexBuffer, vertexBuffer);
}
-void UpdateManager::SetVertexBufferFormat( Render::VertexBuffer* vertexBuffer, OwnerPointer< Render::VertexBuffer::Format>& format )
+void UpdateManager::SetVertexBufferFormat(Render::VertexBuffer* vertexBuffer, OwnerPointer<Render::VertexBuffer::Format>& format)
{
// Message has ownership of format while in transit from update -> render
using DerivedType = MessageValue2<RenderManager, Render::VertexBuffer*, OwnerPointer<Render::VertexBuffer::Format> >;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetVertexBufferFormat, vertexBuffer, format );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::SetVertexBufferFormat, vertexBuffer, format);
}
-void UpdateManager::SetVertexBufferData( Render::VertexBuffer* vertexBuffer, OwnerPointer< Vector<uint8_t> >& data, uint32_t size )
+void UpdateManager::SetVertexBufferData(Render::VertexBuffer* vertexBuffer, OwnerPointer<Vector<uint8_t> >& data, uint32_t size)
{
// Message has ownership of format while in transit from update -> render
using DerivedType = MessageValue3<RenderManager, Render::VertexBuffer*, OwnerPointer<Dali::Vector<uint8_t> >, uint32_t>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetVertexBufferData, vertexBuffer, data, size );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::SetVertexBufferData, vertexBuffer, data, size);
}
-void UpdateManager::AddGeometry( OwnerPointer< Render::Geometry >& geometry )
+void UpdateManager::AddGeometry(OwnerPointer<Render::Geometry>& geometry)
{
// Message has ownership of format while in transit from update -> render
using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::Geometry> >;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddGeometry, geometry );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AddGeometry, geometry);
}
-void UpdateManager::RemoveGeometry( Render::Geometry* geometry )
+void UpdateManager::RemoveGeometry(Render::Geometry* geometry)
{
using DerivedType = MessageValue1<RenderManager, Render::Geometry*>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveGeometry, geometry );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::RemoveGeometry, geometry);
}
-void UpdateManager::SetGeometryType( Render::Geometry* geometry, uint32_t geometryType )
+void UpdateManager::SetGeometryType(Render::Geometry* geometry, uint32_t geometryType)
{
using DerivedType = MessageValue2<RenderManager, Render::Geometry*, uint32_t>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::SetGeometryType, geometry, geometryType );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::SetGeometryType, geometry, geometryType);
}
-void UpdateManager::SetIndexBuffer( Render::Geometry* geometry, Dali::Vector<uint16_t>& indices )
+void UpdateManager::SetIndexBuffer(Render::Geometry* geometry, Dali::Vector<uint16_t>& indices)
{
using DerivedType = IndexBufferMessage<RenderManager>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, geometry, indices );
+ new(slot) DerivedType(&mImpl->renderManager, geometry, indices);
}
-void UpdateManager::RemoveVertexBuffer( Render::Geometry* geometry, Render::VertexBuffer* vertexBuffer )
+void UpdateManager::RemoveVertexBuffer(Render::Geometry* geometry, Render::VertexBuffer* vertexBuffer)
{
using DerivedType = MessageValue2<RenderManager, Render::Geometry*, Render::VertexBuffer*>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveVertexBuffer, geometry, vertexBuffer );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::RemoveVertexBuffer, geometry, vertexBuffer);
}
-void UpdateManager::AttachVertexBuffer( Render::Geometry* geometry, Render::VertexBuffer* vertexBuffer )
+void UpdateManager::AttachVertexBuffer(Render::Geometry* geometry, Render::VertexBuffer* vertexBuffer)
{
using DerivedType = MessageValue2<RenderManager, Render::Geometry*, Render::VertexBuffer*>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AttachVertexBuffer, geometry, vertexBuffer );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AttachVertexBuffer, geometry, vertexBuffer);
}
-void UpdateManager::AddTexture( OwnerPointer< Render::Texture >& texture )
+void UpdateManager::AddTexture(OwnerPointer<Render::Texture>& texture)
{
// Message has ownership of Texture while in transit from update -> render
using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::Texture> >;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddTexture, texture );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AddTexture, texture);
}
-void UpdateManager::RemoveTexture( Render::Texture* texture)
+void UpdateManager::RemoveTexture(Render::Texture* texture)
{
using DerivedType = MessageValue1<RenderManager, Render::Texture*>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveTexture, texture );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::RemoveTexture, texture);
}
-void UpdateManager::UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
+void UpdateManager::UploadTexture(Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params)
{
using DerivedType = MessageValue3<RenderManager, Render::Texture*, PixelDataPtr, Texture::UploadParams>;
// Reserve some memory inside the message queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::UploadTexture, texture, pixelData, params );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::UploadTexture, texture, pixelData, params);
}
-void UpdateManager::GenerateMipmaps( Render::Texture* texture )
+void UpdateManager::GenerateMipmaps(Render::Texture* texture)
{
using DerivedType = MessageValue1<RenderManager, Render::Texture*>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::GenerateMipmaps, texture );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::GenerateMipmaps, texture);
}
-void UpdateManager::AddFrameBuffer( OwnerPointer< Render::FrameBuffer >& frameBuffer )
+void UpdateManager::AddFrameBuffer(OwnerPointer<Render::FrameBuffer>& frameBuffer)
{
using DerivedType = MessageValue1<RenderManager, OwnerPointer<Render::FrameBuffer> >;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddFrameBuffer, frameBuffer );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AddFrameBuffer, frameBuffer);
}
-void UpdateManager::RemoveFrameBuffer( Render::FrameBuffer* frameBuffer)
+void UpdateManager::RemoveFrameBuffer(Render::FrameBuffer* frameBuffer)
{
using DerivedType = MessageValue1<RenderManager, Render::FrameBuffer*>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveFrameBuffer, frameBuffer );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::RemoveFrameBuffer, frameBuffer);
}
-void UpdateManager::AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel, uint32_t layer )
+void UpdateManager::AttachColorTextureToFrameBuffer(Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel, uint32_t layer)
{
using DerivedType = MessageValue4<RenderManager, Render::FrameBuffer*, Render::Texture*, uint32_t, uint32_t>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AttachColorTextureToFrameBuffer, frameBuffer, texture, mipmapLevel, layer );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AttachColorTextureToFrameBuffer, frameBuffer, texture, mipmapLevel, layer);
}
-void UpdateManager::AttachDepthTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel )
+void UpdateManager::AttachDepthTextureToFrameBuffer(Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel)
{
using DerivedType = MessageValue3<RenderManager, Render::FrameBuffer*, Render::Texture*, uint32_t>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AttachDepthTextureToFrameBuffer, frameBuffer, texture, mipmapLevel );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AttachDepthTextureToFrameBuffer, frameBuffer, texture, mipmapLevel);
}
-void UpdateManager::AttachDepthStencilTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel )
+void UpdateManager::AttachDepthStencilTextureToFrameBuffer(Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel)
{
using DerivedType = MessageValue3<RenderManager, Render::FrameBuffer*, Render::Texture*, uint32_t>;
// Reserve some memory inside the render queue
- uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+ uint32_t* slot = mImpl->renderQueue.ReserveMessageSlot(mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof(DerivedType));
// Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AttachDepthStencilTextureToFrameBuffer, frameBuffer, texture, mipmapLevel );
+ new(slot) DerivedType(&mImpl->renderManager, &RenderManager::AttachDepthStencilTextureToFrameBuffer, frameBuffer, texture, mipmapLevel);
}
} // namespace SceneGraph
new(slot) LocalType(&manager, &UpdateManager::SetShaderProgram, const_cast<Shader*>(&shader), shaderData, modifiesGeometry);
}
-inline void SurfaceReplacedMessage( UpdateManager& manager, const SceneGraph::Scene& constScene )
+inline void SurfaceReplacedMessage(UpdateManager& manager, const SceneGraph::Scene& constScene)
{
// The scene-graph thread owns this object so it can safely edit it.
Scene& scene = const_cast<Scene&>(constScene);
new(slot) LocalType(&manager, &UpdateManager::SurfaceReplaced, &scene);
}
-inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
+inline void KeepRenderingMessage(UpdateManager& manager, float durationSeconds)
{
using LocalType = MessageValue1<UpdateManager, float>;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace
{
-
-SceneGraph::Node* FindNodeInSceneGraph( uint32_t id, SceneGraph::Node& node )
+SceneGraph::Node* FindNodeInSceneGraph(uint32_t id, SceneGraph::Node& node)
{
SceneGraph::Node* matchingNode = nullptr;
- if( node.mId == id )
+ if(node.mId == id)
{
matchingNode = &node;
}
else
{
- for( auto&& i : node.GetChildren() )
+ for(auto&& i : node.GetChildren())
{
- matchingNode = FindNodeInSceneGraph( id, *i );
- if( matchingNode )
+ matchingNode = FindNodeInSceneGraph(id, *i);
+ if(matchingNode)
{
break;
}
} // unnamed namespace
-UpdateProxy::UpdateProxy( SceneGraph::UpdateManager& updateManager, SceneGraph::TransformManager& transformManager, SceneGraph::Node& rootNode )
+UpdateProxy::UpdateProxy(SceneGraph::UpdateManager& updateManager, SceneGraph::TransformManager& transformManager, SceneGraph::Node& rootNode)
: mNodeContainer(),
- mLastCachedIdNodePair( { 0u, nullptr } ),
- mCurrentBufferIndex( 0u ),
- mUpdateManager( updateManager ),
- mTransformManager( transformManager ),
- mRootNode( rootNode ),
- mPropertyModifier( nullptr )
+ mLastCachedIdNodePair({0u, nullptr}),
+ mCurrentBufferIndex(0u),
+ mUpdateManager(updateManager),
+ mTransformManager(transformManager),
+ mRootNode(rootNode),
+ mPropertyModifier(nullptr)
{
}
UpdateProxy::~UpdateProxy() = default;
-bool UpdateProxy::GetPosition( uint32_t id, Vector3& position ) const
+bool UpdateProxy::GetPosition(uint32_t id, Vector3& position) const
{
- bool success = false;
- const SceneGraph::Node* node = GetNodeWithId( id );
- if( node )
+ bool success = false;
+ const SceneGraph::Node* node = GetNodeWithId(id);
+ if(node)
{
const SceneGraph::TransformManager& transformManager = mTransformManager; // To ensure we call the const getter
- position = transformManager.GetVector3PropertyValue( node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_POSITION );
- success = true;
+ position = transformManager.GetVector3PropertyValue(node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_POSITION);
+ success = true;
}
return success;
}
-bool UpdateProxy::SetPosition( uint32_t id, const Vector3& position )
+bool UpdateProxy::SetPosition(uint32_t id, const Vector3& position)
{
- bool success = false;
- SceneGraph::Node* node = GetNodeWithId( id );
- if( node )
+ bool success = false;
+ SceneGraph::Node* node = GetNodeWithId(id);
+ if(node)
{
- mTransformManager.SetVector3PropertyValue( node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_POSITION, position );
+ mTransformManager.SetVector3PropertyValue(node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_POSITION, position);
success = true;
}
return success;
}
-bool UpdateProxy::BakePosition( uint32_t id, const Vector3& position )
+bool UpdateProxy::BakePosition(uint32_t id, const Vector3& position)
{
- bool success = false;
- SceneGraph::Node* node = GetNodeWithId( id );
- if( node )
+ bool success = false;
+ SceneGraph::Node* node = GetNodeWithId(id);
+ if(node)
{
- mTransformManager.BakeVector3PropertyValue( node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_POSITION, position );
+ mTransformManager.BakeVector3PropertyValue(node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_POSITION, position);
success = true;
}
return success;
}
-bool UpdateProxy::GetSize( uint32_t id, Vector3& size ) const
+bool UpdateProxy::GetSize(uint32_t id, Vector3& size) const
{
- bool success = false;
- const SceneGraph::Node* node = GetNodeWithId( id );
- if( node )
+ bool success = false;
+ const SceneGraph::Node* node = GetNodeWithId(id);
+ if(node)
{
const SceneGraph::TransformManager& transformManager = mTransformManager; // To ensure we call the const getter
- size = transformManager.GetVector3PropertyValue( node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_SIZE );
- success = true;
+ size = transformManager.GetVector3PropertyValue(node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_SIZE);
+ success = true;
}
return success;
}
-bool UpdateProxy::SetSize( uint32_t id, const Vector3& size )
+bool UpdateProxy::SetSize(uint32_t id, const Vector3& size)
{
- bool success = false;
- SceneGraph::Node* node = GetNodeWithId( id );
- if( node )
+ bool success = false;
+ SceneGraph::Node* node = GetNodeWithId(id);
+ if(node)
{
- mTransformManager.SetVector3PropertyValue( node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_SIZE, size );
+ mTransformManager.SetVector3PropertyValue(node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_SIZE, size);
success = true;
}
return success;
}
-bool UpdateProxy::BakeSize( uint32_t id, const Vector3& size )
+bool UpdateProxy::BakeSize(uint32_t id, const Vector3& size)
{
- bool success = false;
- SceneGraph::Node* node = GetNodeWithId( id );
- if( node )
+ bool success = false;
+ SceneGraph::Node* node = GetNodeWithId(id);
+ if(node)
{
- mTransformManager.BakeVector3PropertyValue( node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_SIZE, size );
+ mTransformManager.BakeVector3PropertyValue(node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_SIZE, size);
success = true;
}
return success;
}
-bool UpdateProxy::GetPositionAndSize( uint32_t id, Vector3& position, Vector3& size ) const
+bool UpdateProxy::GetPositionAndSize(uint32_t id, Vector3& position, Vector3& size) const
{
- bool success = false;
- const SceneGraph::Node* node = GetNodeWithId( id );
- if( node )
+ bool success = false;
+ const SceneGraph::Node* node = GetNodeWithId(id);
+ if(node)
{
const SceneGraph::TransformManager& transformManager = mTransformManager; // To ensure we call the const getter
- position = transformManager.GetVector3PropertyValue( node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_POSITION );
- size = transformManager.GetVector3PropertyValue( node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_SIZE );
- success = true;
+ position = transformManager.GetVector3PropertyValue(node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_POSITION);
+ size = transformManager.GetVector3PropertyValue(node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_SIZE);
+ success = true;
}
return success;
}
-bool UpdateProxy::GetScale( uint32_t id, Vector3& scale ) const
+bool UpdateProxy::GetScale(uint32_t id, Vector3& scale) const
{
- bool success = false;
- const SceneGraph::Node* node = GetNodeWithId( id );
- if( node )
+ bool success = false;
+ const SceneGraph::Node* node = GetNodeWithId(id);
+ if(node)
{
const SceneGraph::TransformManager& transformManager = mTransformManager; // To ensure we call the const getter
- scale = transformManager.GetVector3PropertyValue( node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_SCALE );
- success = true;
+ scale = transformManager.GetVector3PropertyValue(node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_SCALE);
+ success = true;
}
return success;
}
-bool UpdateProxy::SetScale( uint32_t id, const Vector3& scale )
+bool UpdateProxy::SetScale(uint32_t id, const Vector3& scale)
{
- bool success = false;
- SceneGraph::Node* node = GetNodeWithId( id );
- if( node )
+ bool success = false;
+ SceneGraph::Node* node = GetNodeWithId(id);
+ if(node)
{
- mTransformManager.SetVector3PropertyValue( node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_SCALE, scale );
+ mTransformManager.SetVector3PropertyValue(node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_SCALE, scale);
success = true;
}
return success;
}
-bool UpdateProxy::BakeScale( uint32_t id, const Vector3& scale )
+bool UpdateProxy::BakeScale(uint32_t id, const Vector3& scale)
{
- bool success = false;
- SceneGraph::Node* node = GetNodeWithId( id );
- if( node )
+ bool success = false;
+ SceneGraph::Node* node = GetNodeWithId(id);
+ if(node)
{
- mTransformManager.BakeVector3PropertyValue( node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_SCALE, scale );
+ mTransformManager.BakeVector3PropertyValue(node->GetTransformId(), SceneGraph::TRANSFORM_PROPERTY_SCALE, scale);
success = true;
}
return success;
}
-bool UpdateProxy::GetColor( uint32_t id, Vector4& color ) const
+bool UpdateProxy::GetColor(uint32_t id, Vector4& color) const
{
- bool success = false;
- const SceneGraph::Node* node = GetNodeWithId( id );
- if( node )
+ bool success = false;
+ const SceneGraph::Node* node = GetNodeWithId(id);
+ if(node)
{
- color = node->mColor.Get( mCurrentBufferIndex );
+ color = node->mColor.Get(mCurrentBufferIndex);
success = true;
}
return success;
}
-bool UpdateProxy::SetColor( uint32_t id, const Vector4& color )
+bool UpdateProxy::SetColor(uint32_t id, const Vector4& color)
{
- bool success = false;
- SceneGraph::Node* node = GetNodeWithId( id );
- if( node )
+ bool success = false;
+ SceneGraph::Node* node = GetNodeWithId(id);
+ if(node)
{
- node->mColor.Set( mCurrentBufferIndex, color );
- node->SetDirtyFlag( SceneGraph::NodePropertyFlags::COLOR );
- AddResetter( *node, node->mColor );
+ node->mColor.Set(mCurrentBufferIndex, color);
+ node->SetDirtyFlag(SceneGraph::NodePropertyFlags::COLOR);
+ AddResetter(*node, node->mColor);
success = true;
}
return success;
}
-bool UpdateProxy::BakeColor( uint32_t id, const Vector4& color )
+bool UpdateProxy::BakeColor(uint32_t id, const Vector4& color)
{
- bool success = false;
- SceneGraph::Node* node = GetNodeWithId( id );
- if( node )
+ bool success = false;
+ SceneGraph::Node* node = GetNodeWithId(id);
+ if(node)
{
- node->mColor.Bake( mCurrentBufferIndex, color );
+ node->mColor.Bake(mCurrentBufferIndex, color);
success = true;
}
return success;
void UpdateProxy::NodeHierarchyChanged()
{
- mLastCachedIdNodePair = { 0u, nullptr };
+ mLastCachedIdNodePair = {0u, nullptr};
mNodeContainer.clear();
mPropertyModifier.reset();
}
-SceneGraph::Node* UpdateProxy::GetNodeWithId( uint32_t id ) const
+SceneGraph::Node* UpdateProxy::GetNodeWithId(uint32_t id) const
{
SceneGraph::Node* node = nullptr;
// Cache the last accessed node so we don't have to traverse
- if( mLastCachedIdNodePair.node && mLastCachedIdNodePair.id == id )
+ if(mLastCachedIdNodePair.node && mLastCachedIdNodePair.id == id)
{
node = mLastCachedIdNodePair.node;
}
else
{
// Find node in vector
- for( auto&& pair : mNodeContainer )
+ for(auto&& pair : mNodeContainer)
{
- if( pair.id == id )
+ if(pair.id == id)
{
- node = pair.node;
+ node = pair.node;
mLastCachedIdNodePair = pair;
break;
}
}
- if( ! node )
+ if(!node)
{
// Node not in vector, find in scene-graph
- node = FindNodeInSceneGraph( id, mRootNode );
- if( node )
+ node = FindNodeInSceneGraph(id, mRootNode);
+ if(node)
{
- mNodeContainer.push_back( { id, node } );
+ mNodeContainer.push_back({id, node});
mLastCachedIdNodePair = *mNodeContainer.rbegin();
}
}
return node;
}
-void UpdateProxy::AddResetter( SceneGraph::Node& node, SceneGraph::PropertyBase& propertyBase )
+void UpdateProxy::AddResetter(SceneGraph::Node& node, SceneGraph::PropertyBase& propertyBase)
{
- if( ! mPropertyModifier )
+ if(!mPropertyModifier)
{
- mPropertyModifier = PropertyModifierPtr( new PropertyModifier( mUpdateManager ) );
+ mPropertyModifier = PropertyModifierPtr(new PropertyModifier(mUpdateManager));
}
- mPropertyModifier->AddResetter( node, propertyBase );
+ mPropertyModifier->AddResetter(node, propertyBase);
}
} // namespace Internal
#define DALI_INTERNAL_UPDATE_PROXY_IMPL_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <memory>
// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/math/matrix.h>
-#include <dali/public-api/math/vector3.h>
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/update/manager/transform-manager.h>
#include <dali/internal/update/nodes/node.h>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/math/matrix.h>
+#include <dali/public-api/math/vector3.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
class UpdateManager;
class UpdateProxy
{
public:
-
/**
* @brief Constructor.
* @param[in] updateManager Ref to the UpdateManager in order to add property resetters
* @param[in] transformManager Ref to the TransformManager in order to set/get transform properties of nodes
* @param[in] rootNode The root node for this proxy
*/
- UpdateProxy( SceneGraph::UpdateManager& updateManager, SceneGraph::TransformManager& transformManager, SceneGraph::Node& rootNode );
+ UpdateProxy(SceneGraph::UpdateManager& updateManager, SceneGraph::TransformManager& transformManager, SceneGraph::Node& rootNode);
/**
* @brief Destructor.
// Movable but not copyable
- UpdateProxy( const UpdateProxy& ) = delete; ///< Deleted copy constructor.
- UpdateProxy( UpdateProxy&& ) = default; ///< Default move constructor.
- UpdateProxy& operator=( const UpdateProxy& ) = delete; ///< Deleted copy assignment operator.
- UpdateProxy& operator=( UpdateProxy&& ) = delete; ///< Deleted move assignment operator.
+ UpdateProxy(const UpdateProxy&) = delete; ///< Deleted copy constructor.
+ UpdateProxy(UpdateProxy&&) = default; ///< Default move constructor.
+ UpdateProxy& operator=(const UpdateProxy&) = delete; ///< Deleted copy assignment operator.
+ UpdateProxy& operator=(UpdateProxy&&) = delete; ///< Deleted move assignment operator.
/**
* @copydoc Dali::UpdateProxy::GetPosition()
*/
- bool GetPosition( uint32_t id, Vector3& position) const;
+ bool GetPosition(uint32_t id, Vector3& position) const;
/**
* @copydoc Dali::UpdateProxy::SetPosition()
*/
- bool SetPosition( uint32_t id, const Vector3& position );
+ bool SetPosition(uint32_t id, const Vector3& position);
/**
* @copydoc Dali::UpdateProxy::BakePosition()
*/
- bool BakePosition( uint32_t id, const Vector3& position );
+ bool BakePosition(uint32_t id, const Vector3& position);
/**
* @copydoc Dali::UpdateProxy::GetSize()
*/
- bool GetSize( uint32_t id, Vector3& size ) const;
+ bool GetSize(uint32_t id, Vector3& size) const;
/**
* @copydoc Dali::UpdateProxy::SetSize()
*/
- bool SetSize( uint32_t id, const Vector3& size );
+ bool SetSize(uint32_t id, const Vector3& size);
/**
* @copydoc Dali::UpdateProxy::BakeSize()
*/
- bool BakeSize( uint32_t id, const Vector3& size );
+ bool BakeSize(uint32_t id, const Vector3& size);
/**
* @copydoc Dali::UpdateProxy::GetPositionAndSize()
*/
- bool GetPositionAndSize( uint32_t id, Vector3& position, Vector3& size ) const;
+ bool GetPositionAndSize(uint32_t id, Vector3& position, Vector3& size) const;
/**
* @copydoc Dali::UpdateProxy::GetScale()
*/
- bool GetScale( uint32_t id, Vector3& scale ) const;
+ bool GetScale(uint32_t id, Vector3& scale) const;
/**
* @copydoc Dali::UpdateProxy::SetScale()
*/
- bool SetScale( uint32_t id, const Vector3& scale );
+ bool SetScale(uint32_t id, const Vector3& scale);
/**
* @copydoc Dali::UpdateProxy::BakeScale()
*/
- bool BakeScale( uint32_t id, const Vector3& scale );
+ bool BakeScale(uint32_t id, const Vector3& scale);
/**
* @copydoc Dali::UpdateProxy::GetColor()
*/
- bool GetColor( uint32_t id, Vector4& color ) const;
+ bool GetColor(uint32_t id, Vector4& color) const;
/**
* @copydoc Dali::UpdateProxy::SetColor()
*/
- bool SetColor( uint32_t id, const Vector4& color );
+ bool SetColor(uint32_t id, const Vector4& color);
/**
* @copydoc Dali::UpdateProxy::BakeColor()
*/
- bool BakeColor( uint32_t id, const Vector4& color );
+ bool BakeColor(uint32_t id, const Vector4& color);
/**
* @brief Retrieves the root-node used by this class
* @brief Sets the buffer index to use when processing the next callback.
* @param[in] bufferIndex The current buffer index
*/
- void SetCurrentBufferIndex( BufferIndex bufferIndex )
+ void SetCurrentBufferIndex(BufferIndex bufferIndex)
{
mCurrentBufferIndex = bufferIndex;
}
void NodeHierarchyChanged();
private:
-
/**
* @brief Retrieves the node with the specified ID.
* @param[in] id The ID of the node required
* @return A pointer to the required node if found.
* @note This caches the last accessed node.
*/
- SceneGraph::Node* GetNodeWithId( uint32_t id ) const;
+ SceneGraph::Node* GetNodeWithId(uint32_t id) const;
/**
* @brief Adds a property-resetter for non-transform properties so that they can be reset to their base value every frame.
* @param[in] node The node the property belongs to
* @param[in] propertyBase The property itself
*/
- void AddResetter( SceneGraph::Node& node, SceneGraph::PropertyBase& propertyBase );
+ void AddResetter(SceneGraph::Node& node, SceneGraph::PropertyBase& propertyBase);
private:
-
/**
* Structure to store the ID & Node pair
*/
struct IdNodePair
{
- uint32_t id; ///< The ID of the node
+ uint32_t id; ///< The ID of the node
SceneGraph::Node* node; ///< The node itself
};
class PropertyModifier;
- using PropertyModifierPtr = std::unique_ptr< PropertyModifier >;
+ using PropertyModifierPtr = std::unique_ptr<PropertyModifier>;
- mutable std::vector< IdNodePair > mNodeContainer; ///< Used to store cached pointers to already searched for Nodes.
- mutable IdNodePair mLastCachedIdNodePair; ///< Used to cache the last retrieved id-node pair.
- BufferIndex mCurrentBufferIndex;
+ mutable std::vector<IdNodePair> mNodeContainer; ///< Used to store cached pointers to already searched for Nodes.
+ mutable IdNodePair mLastCachedIdNodePair; ///< Used to cache the last retrieved id-node pair.
+ BufferIndex mCurrentBufferIndex;
- SceneGraph::UpdateManager& mUpdateManager; ///< Reference to the Update Manager.
+ SceneGraph::UpdateManager& mUpdateManager; ///< Reference to the Update Manager.
SceneGraph::TransformManager& mTransformManager; ///< Reference to the Transform Manager.
- SceneGraph::Node& mRootNode; ///< The root node of this update proxy.
+ SceneGraph::Node& mRootNode; ///< The root node of this update proxy.
PropertyModifierPtr mPropertyModifier; ///< To ensure non-transform property modifications reset to base values.
};
#define DALI_INTERNAL_UPDATE_PROXY_PROPERTY_MODIFIER_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
class Node;
class PropertyBase;
-}
+} // namespace SceneGraph
/**
* Keeps track of any non-transform manager properties that are modified by the UpdateProxy.
class UpdateProxy::PropertyModifier final
{
public:
-
- using Resetter = SceneGraph::Resetter< PropertyModifier >;
+ using Resetter = SceneGraph::Resetter<PropertyModifier>;
/**
* Observer to determine when the animator is no longer present
class LifecycleObserver
{
public:
-
/**
* Called shortly before the animator is destroyed.
*/
virtual void ObjectDestroyed() = 0;
protected:
-
/**
* Virtual destructor, no deletion through this interface
*/
* Default Constructor.
* @param[in] updateManager A reference to the update-manager
*/
- PropertyModifier( SceneGraph::UpdateManager& updateManager )
+ PropertyModifier(SceneGraph::UpdateManager& updateManager)
: mProperties(),
mLifecycleObservers(),
- mUpdateManager( &updateManager )
+ mUpdateManager(&updateManager)
{
}
*/
~PropertyModifier()
{
- for( auto& observer : mLifecycleObservers )
+ for(auto& observer : mLifecycleObservers)
{
observer->ObjectDestroyed();
}
// Movable but not copyable
- PropertyModifier( const PropertyModifier& ) = delete; ///< Deleted copy constructor.
- PropertyModifier& operator=( const PropertyModifier& ) = delete; ///< Deleted assignment operator.
+ PropertyModifier(const PropertyModifier&) = delete; ///< Deleted copy constructor.
+ PropertyModifier& operator=(const PropertyModifier&) = delete; ///< Deleted assignment operator.
/**
* Move constructor.
*/
- PropertyModifier( PropertyModifier&& other )
- : mProperties( std::move( other.mProperties ) ),
- mLifecycleObservers( std::move( other.mLifecycleObservers ) ),
- mUpdateManager( std::move( other.mUpdateManager ) )
+ PropertyModifier(PropertyModifier&& other)
+ : mProperties(std::move(other.mProperties)),
+ mLifecycleObservers(std::move(other.mLifecycleObservers)),
+ mUpdateManager(std::move(other.mUpdateManager))
{
// Clear other so that it does not remove any resetters unintentionally
other.mLifecycleObservers.clear();
/**
* Move assignment operator.
*/
- PropertyModifier& operator=( PropertyModifier&& other )
+ PropertyModifier& operator=(PropertyModifier&& other)
{
- if( this != &other )
+ if(this != &other)
{
- mProperties = std::move( other.mProperties );
- mLifecycleObservers = std::move( other.mLifecycleObservers );
- mUpdateManager = std::move( other.mUpdateManager );
+ mProperties = std::move(other.mProperties);
+ mLifecycleObservers = std::move(other.mLifecycleObservers);
+ mUpdateManager = std::move(other.mUpdateManager);
// Clear other so that it does not remove any resetters unintentionally
other.mLifecycleObservers.clear();
* Allows Resetter to track the life-cycle of this object.
* @param[in] observer The observer to add.
*/
- void AddLifecycleObserver( LifecycleObserver& observer )
+ void AddLifecycleObserver(LifecycleObserver& observer)
{
- mLifecycleObservers.push_back( &observer );
+ mLifecycleObservers.push_back(&observer);
}
/**
* The Resetter no longer needs to track the life-cycle of this object.
* @param[in] observer The observer that to remove.
*/
- void RemoveLifecycleObserver( LifecycleObserver& observer )
+ void RemoveLifecycleObserver(LifecycleObserver& observer)
{
- std::remove( mLifecycleObservers.begin(), mLifecycleObservers.end(), &observer );
+ std::remove(mLifecycleObservers.begin(), mLifecycleObservers.end(), &observer);
}
/**
* @param[in] node The associated Node
* @param[in] propertyBase The associated PropertyBase
*/
- void AddResetter( SceneGraph::Node& node, SceneGraph::PropertyBase& propertyBase )
+ void AddResetter(SceneGraph::Node& node, SceneGraph::PropertyBase& propertyBase)
{
// Check if we've already added a resetter for this node and property to the update-manager
- NodePropertyPair pair{ &node, &propertyBase };
- if( mUpdateManager &&
- ( mProperties.end() == std::find( mProperties.begin(), mProperties.end(), pair ) ) )
+ NodePropertyPair pair{&node, &propertyBase};
+ if(mUpdateManager &&
+ (mProperties.end() == std::find(mProperties.begin(), mProperties.end(), pair)))
{
// We haven't, add the pair to our container to ensure we don't add it again
// Then create a Resetter which will observe the life of this object
// Finally, add the resetter to the Update-Manager
// When this object is destroyed, the resetter will be informed and will automatically be removed
- mProperties.emplace_back( std::move( pair ) );
- OwnerPointer< SceneGraph::PropertyResetterBase > resetter( Resetter::New( node, propertyBase, *this ) );
- mUpdateManager->AddPropertyResetter( resetter );
+ mProperties.emplace_back(std::move(pair));
+ OwnerPointer<SceneGraph::PropertyResetterBase> resetter(Resetter::New(node, propertyBase, *this));
+ mUpdateManager->AddPropertyResetter(resetter);
}
}
public:
-
/**
* Structure to store the Node & property-base pair
*/
struct NodePropertyPair
{
- SceneGraph::Node* node;
+ SceneGraph::Node* node;
SceneGraph::PropertyBase* propertyBase;
- NodePropertyPair( const NodePropertyPair& ) = delete; ///< Deleted copy constructor.
- NodePropertyPair( NodePropertyPair&& ) = default; ///< Default move constructor.
- NodePropertyPair& operator=( const NodePropertyPair& ) = delete; ///< Deleted assignment operator.
- NodePropertyPair& operator=( NodePropertyPair&& ) = default; ///< Default move assignment operator.
+ NodePropertyPair(const NodePropertyPair&) = delete; ///< Deleted copy constructor.
+ NodePropertyPair(NodePropertyPair&&) = default; ///< Default move constructor.
+ NodePropertyPair& operator=(const NodePropertyPair&) = delete; ///< Deleted assignment operator.
+ NodePropertyPair& operator=(NodePropertyPair&&) = default; ///< Default move assignment operator.
/**
* Comparison operator
*/
- bool operator==( const NodePropertyPair& other )
+ bool operator==(const NodePropertyPair& other)
{
- return ( other.node == node ) &&
- ( other.propertyBase == propertyBase );
+ return (other.node == node) &&
+ (other.propertyBase == propertyBase);
}
};
- std::vector< NodePropertyPair > mProperties;
- std::vector< LifecycleObserver* > mLifecycleObservers;
- SceneGraph::UpdateManager* mUpdateManager;
+ std::vector<NodePropertyPair> mProperties;
+ std::vector<LifecycleObserver*> mLifecycleObservers;
+ SceneGraph::UpdateManager* mUpdateManager;
};
} // namespace Internal
*/
// CLASS HEADER
-#include <dali/internal/update/nodes/node-messages.h>
#include <dali/internal/update/manager/update-manager.h>
+#include <dali/internal/update/nodes/node-messages.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
// Messages for Node
NodePropertyMessageBase::NodePropertyMessageBase(UpdateManager& updateManager)
#define DALI_INTERNAL_SCENE_GRAPH_NODE_MESSAGES_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/internal/common/buffer-index.h>
#include <dali/internal/common/message.h>
-#include <dali/internal/update/nodes/node.h>
#include <dali/internal/update/manager/update-manager.h>
+#include <dali/internal/update/nodes/node.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
// Messages for Node
class NodePropertyMessageBase : public MessageBase
{
public:
-
/**
* Create a message.
*/
~NodePropertyMessageBase() override;
private:
-
// Undefined
NodePropertyMessageBase(const NodePropertyMessageBase&);
NodePropertyMessageBase& operator=(const NodePropertyMessageBase& rhs);
protected:
-
UpdateManager& mUpdateManager;
};
/**
* Templated message which bakes a Node property.
*/
-template< typename P >
+template<typename P>
class NodePropertyMessage : public NodePropertyMessageBase
{
public:
- using MemberFunction = void ( AnimatableProperty<P>::* )( BufferIndex, typename ParameterType<P>::PassingType );
+ using MemberFunction = void (AnimatableProperty<P>::*)(BufferIndex, typename ParameterType<P>::PassingType);
/**
* Create a message.
* @param[in] member The member function of the object.
* @param[in] value The new value of the property.
*/
- static void Send( EventThreadServices& eventThreadServices,
- const Node* node,
- const AnimatableProperty<P>* property,
- MemberFunction member,
- typename ParameterType< P >::PassingType value )
+ static void Send(EventThreadServices& eventThreadServices,
+ const Node* node,
+ const AnimatableProperty<P>* property,
+ MemberFunction member,
+ typename ParameterType<P>::PassingType value)
{
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodePropertyMessage ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(NodePropertyMessage));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) NodePropertyMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
+ new(slot) NodePropertyMessage(eventThreadServices.GetUpdateManager(), node, property, member, value);
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex updateBufferIndex ) override
+ void Process(BufferIndex updateBufferIndex) override
{
- (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
+ (mProperty->*mMemberFunction)(updateBufferIndex, mParam);
}
private:
-
/**
* Create a message.
* @note The node is expected to be const in the thread which sends this message.
* @param[in] member The member function of the object.
* @param[in] value The new value of the property.
*/
- NodePropertyMessage( UpdateManager& updateManager,
- const Node* node,
- const AnimatableProperty<P>* property,
- MemberFunction member,
- typename ParameterType< P >::PassingType value )
- : NodePropertyMessageBase( updateManager ),
- mNode( const_cast< Node* >( node ) ),
- mProperty( const_cast< AnimatableProperty<P>* >( property ) ),
- mMemberFunction( member ),
- mParam( value )
+ NodePropertyMessage(UpdateManager& updateManager,
+ const Node* node,
+ const AnimatableProperty<P>* property,
+ MemberFunction member,
+ typename ParameterType<P>::PassingType value)
+ : NodePropertyMessageBase(updateManager),
+ mNode(const_cast<Node*>(node)),
+ mProperty(const_cast<AnimatableProperty<P>*>(property)),
+ mMemberFunction(member),
+ mParam(value)
{
}
private:
-
- Node* mNode;
- AnimatableProperty<P>* mProperty;
- MemberFunction mMemberFunction;
- typename ParameterType< P >::HolderType mParam;
+ Node* mNode;
+ AnimatableProperty<P>* mProperty;
+ MemberFunction mMemberFunction;
+ typename ParameterType<P>::HolderType mParam;
};
/**
* Templated message which bakes a Node property.
*/
-template< typename P >
+template<typename P>
class NodePropertyComponentMessage : public NodePropertyMessageBase
{
public:
- using MemberFunction = void ( AnimatableProperty<P>::* )( BufferIndex, float );
+ using MemberFunction = void (AnimatableProperty<P>::*)(BufferIndex, float);
/**
* Send a message.
* @param[in] member The member function of the object.
* @param[in] value The new value of the X,Y,Z or W component.
*/
- static void Send( EventThreadServices& eventThreadServices,
- const Node* node,
- const AnimatableProperty<P>* property,
- MemberFunction member,
- float value )
+ static void Send(EventThreadServices& eventThreadServices,
+ const Node* node,
+ const AnimatableProperty<P>* property,
+ MemberFunction member,
+ float value)
{
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodePropertyComponentMessage ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(NodePropertyComponentMessage));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) NodePropertyComponentMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
+ new(slot) NodePropertyComponentMessage(eventThreadServices.GetUpdateManager(), node, property, member, value);
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex updateBufferIndex ) override
+ void Process(BufferIndex updateBufferIndex) override
{
- (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
+ (mProperty->*mMemberFunction)(updateBufferIndex, mParam);
}
private:
-
/**
* Create a message.
* @note The node is expected to be const in the thread which sends this message.
* @param[in] member The member function of the object.
* @param[in] value The new value of the X,Y,Z or W component.
*/
- NodePropertyComponentMessage( UpdateManager& updateManager,
- const Node* node,
- const AnimatableProperty<P>* property,
- MemberFunction member,
- float value )
- : NodePropertyMessageBase( updateManager ),
- mNode( const_cast< Node* >( node ) ),
- mProperty( const_cast< AnimatableProperty<P>* >( property ) ),
- mMemberFunction( member ),
- mParam( value )
+ NodePropertyComponentMessage(UpdateManager& updateManager,
+ const Node* node,
+ const AnimatableProperty<P>* property,
+ MemberFunction member,
+ float value)
+ : NodePropertyMessageBase(updateManager),
+ mNode(const_cast<Node*>(node)),
+ mProperty(const_cast<AnimatableProperty<P>*>(property)),
+ mMemberFunction(member),
+ mParam(value)
{
}
private:
-
- Node* mNode;
+ Node* mNode;
AnimatableProperty<P>* mProperty;
- MemberFunction mMemberFunction;
- float mParam;
+ MemberFunction mMemberFunction;
+ float mParam;
};
-
-template <typename P>
+template<typename P>
class NodeTransformPropertyMessage : public NodePropertyMessageBase
{
public:
- using MemberFunction = void ( TransformManagerPropertyHandler<P>::* )( BufferIndex, const P& );
+ using MemberFunction = void (TransformManagerPropertyHandler<P>::*)(BufferIndex, const P&);
/**
* Create a message.
* @param[in] member The member function of the object.
* @param[in] value The new value of the property.
*/
- static void Send( EventThreadServices& eventThreadServices,
- const Node* node,
- const TransformManagerPropertyHandler<P>* property,
- MemberFunction member,
- const P& value )
+ static void Send(EventThreadServices& eventThreadServices,
+ const Node* node,
+ const TransformManagerPropertyHandler<P>* property,
+ MemberFunction member,
+ const P& value)
{
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodeTransformPropertyMessage ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(NodeTransformPropertyMessage));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) NodeTransformPropertyMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
+ new(slot) NodeTransformPropertyMessage(eventThreadServices.GetUpdateManager(), node, property, member, value);
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex updateBufferIndex ) override
+ void Process(BufferIndex updateBufferIndex) override
{
- (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
+ (mProperty->*mMemberFunction)(updateBufferIndex, mParam);
}
private:
-
/**
* Create a message.
* @note The node is expected to be const in the thread which sends this message.
* @param[in] member The member function of the object.
* @param[in] value The new value of the property.
*/
- NodeTransformPropertyMessage( UpdateManager& updateManager,
- const Node* node,
- const TransformManagerPropertyHandler<P>* property,
- MemberFunction member,
- const P& value )
- : NodePropertyMessageBase( updateManager ),
- mNode( const_cast< Node* >( node ) ),
- mProperty( const_cast< TransformManagerPropertyHandler<P>* >( property ) ),
- mMemberFunction( member ),
- mParam( value )
+ NodeTransformPropertyMessage(UpdateManager& updateManager,
+ const Node* node,
+ const TransformManagerPropertyHandler<P>* property,
+ MemberFunction member,
+ const P& value)
+ : NodePropertyMessageBase(updateManager),
+ mNode(const_cast<Node*>(node)),
+ mProperty(const_cast<TransformManagerPropertyHandler<P>*>(property)),
+ mMemberFunction(member),
+ mParam(value)
{
}
private:
-
- Node* mNode;
+ Node* mNode;
TransformManagerPropertyHandler<P>* mProperty;
- MemberFunction mMemberFunction;
- P mParam;
+ MemberFunction mMemberFunction;
+ P mParam;
};
-
-template <typename P>
+template<typename P>
class NodeTransformComponentMessage : public NodePropertyMessageBase
{
public:
- using MemberFunction = void ( TransformManagerPropertyHandler<P>::* )( BufferIndex, float );
+ using MemberFunction = void (TransformManagerPropertyHandler<P>::*)(BufferIndex, float);
/**
* Send a message.
* @param[in] member The member function of the object.
* @param[in] value The new value of the X,Y,Z or W component.
*/
- static void Send( EventThreadServices& eventThreadServices,
- const Node* node,
- const TransformManagerPropertyHandler<P>* property,
- MemberFunction member,
- float value )
+ static void Send(EventThreadServices& eventThreadServices,
+ const Node* node,
+ const TransformManagerPropertyHandler<P>* property,
+ MemberFunction member,
+ float value)
{
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodeTransformComponentMessage ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(NodeTransformComponentMessage));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) NodeTransformComponentMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
+ new(slot) NodeTransformComponentMessage(eventThreadServices.GetUpdateManager(), node, property, member, value);
}
/**
/**
* @copydoc MessageBase::Process
*/
- void Process( BufferIndex updateBufferIndex ) override
+ void Process(BufferIndex updateBufferIndex) override
{
- (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
+ (mProperty->*mMemberFunction)(updateBufferIndex, mParam);
}
private:
-
/**
* Create a message.
* @note The node is expected to be const in the thread which sends this message.
* @param[in] member The member function of the object.
* @param[in] value The new value of the X,Y,Z or W component.
*/
- NodeTransformComponentMessage( UpdateManager& updateManager,
- const Node* node,
+ NodeTransformComponentMessage(UpdateManager& updateManager,
+ const Node* node,
const TransformManagerPropertyHandler<P>* property,
- MemberFunction member,
- float value )
- : NodePropertyMessageBase( updateManager ),
- mNode( const_cast< Node* >( node ) ),
- mProperty( const_cast< TransformManagerPropertyHandler<P>* >( property ) ),
- mMemberFunction( member ),
- mParam( value )
+ MemberFunction member,
+ float value)
+ : NodePropertyMessageBase(updateManager),
+ mNode(const_cast<Node*>(node)),
+ mProperty(const_cast<TransformManagerPropertyHandler<P>*>(property)),
+ mMemberFunction(member),
+ mParam(value)
{
}
private:
-
- Node* mNode;
+ Node* mNode;
TransformManagerPropertyHandler<P>* mProperty;
- MemberFunction mMemberFunction;
- float mParam;
+ MemberFunction mMemberFunction;
+ float mParam;
};
} // namespace SceneGraph
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/common/internal-constants.h>
#include <dali/internal/common/memory-pool-object-allocator.h>
#include <dali/internal/update/common/discard-queue.h>
-#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/common/constants.h>
+#include <dali/public-api/common/dali-common.h>
namespace
{
int32_t gNodeCount = 0;
// Called when the process is about to exit, Node count should be zero at this point.
-void __attribute__ ((destructor)) ShutDown(void)
+void __attribute__((destructor)) ShutDown(void)
{
-DALI_ASSERT_DEBUG( (gNodeCount == 0) && "Node memory leak");
+ DALI_ASSERT_DEBUG((gNodeCount == 0) && "Node memory leak");
}
#endif
} // Unnamed namespace
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
+const ColorMode Node::DEFAULT_COLOR_MODE(USE_OWN_MULTIPLY_PARENT_ALPHA);
-const ColorMode Node::DEFAULT_COLOR_MODE( USE_OWN_MULTIPLY_PARENT_ALPHA );
-
-uint32_t Node::mNodeCounter = 0; ///< A counter to provide unique node ids, up-to 4 billion
+uint32_t Node::mNodeCounter = 0; ///< A counter to provide unique node ids, up-to 4 billion
Node* Node::New()
{
- return new ( gNodeMemoryPool.AllocateRawThreadSafe() ) Node;
+ return new(gNodeMemoryPool.AllocateRawThreadSafe()) Node;
}
-void Node::Delete( Node* node )
+void Node::Delete(Node* node)
{
// check we have a node not a layer
- if( !node->mIsLayer )
+ if(!node->mIsLayer)
{
// Manually call the destructor
node->~Node();
// Mark the memory it used as free in the memory pool
- gNodeMemoryPool.FreeThreadSafe( node );
+ gNodeMemoryPool.FreeThreadSafe(node);
}
else
{
}
Node::Node()
-: mOrientation(), // Initialized to identity by default
- mVisible( true ),
- mCulled( false ),
- mColor( Color::WHITE ),
- mUpdateSizeHint( Vector3::ZERO ),
- mWorldPosition( TRANSFORM_PROPERTY_WORLD_POSITION, Vector3( 0.0f,0.0f,0.0f ) ), // Zero initialized by default
- mWorldScale( TRANSFORM_PROPERTY_WORLD_SCALE, Vector3( 1.0f,1.0f,1.0f ) ),
- mWorldOrientation(), // Initialized to identity by default
+: mOrientation(), // Initialized to identity by default
+ mVisible(true),
+ mCulled(false),
+ mColor(Color::WHITE),
+ mUpdateSizeHint(Vector3::ZERO),
+ mWorldPosition(TRANSFORM_PROPERTY_WORLD_POSITION, Vector3(0.0f, 0.0f, 0.0f)), // Zero initialized by default
+ mWorldScale(TRANSFORM_PROPERTY_WORLD_SCALE, Vector3(1.0f, 1.0f, 1.0f)),
+ mWorldOrientation(), // Initialized to identity by default
mWorldMatrix(),
- mWorldColor( Color::WHITE ),
- mClippingSortModifier( 0u ),
- mId( ++mNodeCounter ),
- mParent( nullptr ),
- mExclusiveRenderTask( nullptr ),
+ mWorldColor(Color::WHITE),
+ mClippingSortModifier(0u),
+ mId(++mNodeCounter),
+ mParent(nullptr),
+ mExclusiveRenderTask(nullptr),
mChildren(),
- mClippingDepth( 0u ),
- mScissorDepth( 0u ),
- mDepthIndex( 0u ),
- mDirtyFlags( NodePropertyFlags::ALL ),
- mRegenerateUniformMap( 0 ),
- mDrawMode( DrawMode::NORMAL ),
- mColorMode( DEFAULT_COLOR_MODE ),
- mClippingMode( ClippingMode::DISABLED ),
- mIsRoot( false ),
- mIsLayer( false ),
- mPositionUsesAnchorPoint( true )
+ mClippingDepth(0u),
+ mScissorDepth(0u),
+ mDepthIndex(0u),
+ mDirtyFlags(NodePropertyFlags::ALL),
+ mRegenerateUniformMap(0),
+ mDrawMode(DrawMode::NORMAL),
+ mColorMode(DEFAULT_COLOR_MODE),
+ mClippingMode(ClippingMode::DISABLED),
+ mIsRoot(false),
+ mIsLayer(false),
+ mPositionUsesAnchorPoint(true)
{
mUniformMapChanged[0] = 0u;
mUniformMapChanged[1] = 0u;
Node::~Node()
{
- if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
+ if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
{
mTransformManagerData.Manager()->RemoveTransform(mTransformManagerData.Id());
}
return mId;
}
-void Node::CreateTransform( SceneGraph::TransformManager* transformManager )
+void Node::CreateTransform(SceneGraph::TransformManager* transformManager)
{
//Create a new transform
mTransformManagerData.mManager = transformManager;
- mTransformManagerData.mId = transformManager->CreateTransform();
+ mTransformManagerData.mId = transformManager->CreateTransform();
//Initialize all the animatable properties
- mPosition.Initialize( &mTransformManagerData );
- mScale.Initialize( &mTransformManagerData );
- mOrientation.Initialize( &mTransformManagerData );
- mSize.Initialize( &mTransformManagerData );
- mParentOrigin.Initialize( &mTransformManagerData );
- mAnchorPoint.Initialize( &mTransformManagerData );
+ mPosition.Initialize(&mTransformManagerData);
+ mScale.Initialize(&mTransformManagerData);
+ mOrientation.Initialize(&mTransformManagerData);
+ mSize.Initialize(&mTransformManagerData);
+ mParentOrigin.Initialize(&mTransformManagerData);
+ mAnchorPoint.Initialize(&mTransformManagerData);
//Initialize all the input properties
- mWorldPosition.Initialize( &mTransformManagerData );
- mWorldScale.Initialize( &mTransformManagerData );
- mWorldOrientation.Initialize( &mTransformManagerData );
- mWorldMatrix.Initialize( &mTransformManagerData);
+ mWorldPosition.Initialize(&mTransformManagerData);
+ mWorldScale.Initialize(&mTransformManagerData);
+ mWorldOrientation.Initialize(&mTransformManagerData);
+ mWorldMatrix.Initialize(&mTransformManagerData);
//Set whether the position should use the anchor point
- transformManager->SetPositionUsesAnchorPoint( mTransformManagerData.Id(), mPositionUsesAnchorPoint );
+ transformManager->SetPositionUsesAnchorPoint(mTransformManagerData.Id(), mPositionUsesAnchorPoint);
}
void Node::SetRoot(bool isRoot)
void Node::AddUniformMapping(const UniformPropertyMapping& map)
{
- PropertyOwner::AddUniformMapping( map );
+ PropertyOwner::AddUniformMapping(map);
mRegenerateUniformMap = 2;
}
-void Node::RemoveUniformMapping( const ConstString& uniformName )
+void Node::RemoveUniformMapping(const ConstString& uniformName)
{
- PropertyOwner::RemoveUniformMapping( uniformName );
+ PropertyOwner::RemoveUniformMapping(uniformName);
mRegenerateUniformMap = 2;
}
return mIsConnectedToSceneGraph;
}
-void Node::PrepareRender( BufferIndex bufferIndex )
+void Node::PrepareRender(BufferIndex bufferIndex)
{
- if( mRegenerateUniformMap != 0 )
+ if(mRegenerateUniformMap != 0)
{
- if( mRegenerateUniformMap == 2 )
+ if(mRegenerateUniformMap == 2)
{
- CollectedUniformMap& localMap = mCollectedUniformMap[ bufferIndex ];
+ CollectedUniformMap& localMap = mCollectedUniformMap[bufferIndex];
localMap.Resize(0);
- for( UniformMap::SizeType i = 0, count=mUniformMaps.Count(); i<count; ++i )
+ for(UniformMap::SizeType i = 0, count = mUniformMaps.Count(); i < count; ++i)
{
localMap.PushBack(mUniformMaps[i]);
}
}
- else if( mRegenerateUniformMap == 1 )
+ else if(mRegenerateUniformMap == 1)
{
- CollectedUniformMap& localMap = mCollectedUniformMap[ bufferIndex ];
- CollectedUniformMap& oldMap = mCollectedUniformMap[ 1-bufferIndex ];
+ CollectedUniformMap& localMap = mCollectedUniformMap[bufferIndex];
+ CollectedUniformMap& oldMap = mCollectedUniformMap[1 - bufferIndex];
- localMap.Resize( oldMap.Count() );
+ localMap.Resize(oldMap.Count());
CollectedUniformMap::SizeType index = 0;
- for( CollectedUniformMap::Iterator iter = oldMap.Begin(), end = oldMap.End() ; iter != end ; ++iter, ++index )
+ for(CollectedUniformMap::Iterator iter = oldMap.Begin(), end = oldMap.End(); iter != end; ++iter, ++index)
{
localMap[index] = *iter;
}
}
}
-void Node::ConnectChild( Node* childNode )
+void Node::ConnectChild(Node* childNode)
{
- DALI_ASSERT_ALWAYS( this != childNode );
- DALI_ASSERT_ALWAYS( IsRoot() || nullptr != mParent ); // Parent should be connected first
- DALI_ASSERT_ALWAYS( !childNode->IsRoot() && nullptr == childNode->GetParent() ); // Child should be disconnected
+ DALI_ASSERT_ALWAYS(this != childNode);
+ DALI_ASSERT_ALWAYS(IsRoot() || nullptr != mParent); // Parent should be connected first
+ DALI_ASSERT_ALWAYS(!childNode->IsRoot() && nullptr == childNode->GetParent()); // Child should be disconnected
- childNode->SetParent( *this );
+ childNode->SetParent(*this);
// Everything should be reinherited when reconnected to scene-graph
childNode->SetAllDirtyFlags();
// Add the node to the end of the child list.
- mChildren.PushBack( childNode );
+ mChildren.PushBack(childNode);
// Inform property observers of new connection
childNode->ConnectToSceneGraph();
}
-void Node::DisconnectChild( BufferIndex updateBufferIndex, Node& childNode )
+void Node::DisconnectChild(BufferIndex updateBufferIndex, Node& childNode)
{
- DALI_ASSERT_ALWAYS( this != &childNode );
- DALI_ASSERT_ALWAYS( childNode.GetParent() == this );
+ DALI_ASSERT_ALWAYS(this != &childNode);
+ DALI_ASSERT_ALWAYS(childNode.GetParent() == this);
// Find the childNode and remove it
- Node* found( nullptr );
+ Node* found(nullptr);
const NodeIter endIter = mChildren.End();
- for ( NodeIter iter = mChildren.Begin(); iter != endIter; ++iter )
+ for(NodeIter iter = mChildren.Begin(); iter != endIter; ++iter)
{
Node* current = *iter;
- if ( current == &childNode )
+ if(current == &childNode)
{
found = current;
- mChildren.Erase( iter ); // order matters here
- break; // iter is no longer valid
+ mChildren.Erase(iter); // order matters here
+ break; // iter is no longer valid
}
}
- DALI_ASSERT_ALWAYS( nullptr != found );
+ DALI_ASSERT_ALWAYS(nullptr != found);
- found->RecursiveDisconnectFromSceneGraph( updateBufferIndex );
+ found->RecursiveDisconnectFromSceneGraph(updateBufferIndex);
}
-void Node::AddRenderer( Renderer* renderer )
+void Node::AddRenderer(Renderer* renderer)
{
// If it is the first renderer added, make sure the world transform will be calculated
// in the next update as world transform is not computed if node has no renderers.
- if( mRenderer.Empty() )
+ if(mRenderer.Empty())
{
mDirtyFlags |= NodePropertyFlags::TRANSFORM;
}
else
{
// Check that it has not been already added.
- for( auto&& existingRenderer : mRenderer )
+ for(auto&& existingRenderer : mRenderer)
{
- if( existingRenderer == renderer )
+ if(existingRenderer == renderer)
{
// Renderer is already in the list.
return;
}
}
- mRenderer.PushBack( renderer );
+ mRenderer.PushBack(renderer);
}
-void Node::RemoveRenderer( const Renderer* renderer )
+void Node::RemoveRenderer(const Renderer* renderer)
{
- RendererContainer::SizeType rendererCount( mRenderer.Size() );
- for( RendererContainer::SizeType i = 0; i < rendererCount; ++i )
+ RendererContainer::SizeType rendererCount(mRenderer.Size());
+ for(RendererContainer::SizeType i = 0; i < rendererCount; ++i)
{
- if( mRenderer[i] == renderer )
+ if(mRenderer[i] == renderer)
{
- mRenderer.Erase( mRenderer.Begin()+i);
+ mRenderer.Erase(mRenderer.Begin() + i);
return;
}
}
NodePropertyFlags flags = mDirtyFlags;
// Check whether the visible property has changed
- if ( !mVisible.IsClean() )
+ if(!mVisible.IsClean())
{
flags |= NodePropertyFlags::VISIBLE;
}
// Check whether the color property has changed
- if ( !mColor.IsClean() )
+ if(!mColor.IsClean())
{
flags |= NodePropertyFlags::COLOR;
}
return flags;
}
-NodePropertyFlags Node::GetInheritedDirtyFlags( NodePropertyFlags parentFlags ) const
+NodePropertyFlags Node::GetInheritedDirtyFlags(NodePropertyFlags parentFlags) const
{
// Size is not inherited. VisibleFlag is inherited
static const NodePropertyFlags InheritedDirtyFlags = NodePropertyFlags::TRANSFORM | NodePropertyFlags::VISIBLE | NodePropertyFlags::COLOR;
- using UnderlyingType = typename std::underlying_type<NodePropertyFlags>::type;
+ using UnderlyingType = typename std::underlying_type<NodePropertyFlags>::type;
- return static_cast<NodePropertyFlags>( static_cast<UnderlyingType>( mDirtyFlags ) |
- ( static_cast<UnderlyingType>( parentFlags ) & static_cast<UnderlyingType>( InheritedDirtyFlags ) ) );
+ return static_cast<NodePropertyFlags>(static_cast<UnderlyingType>(mDirtyFlags) |
+ (static_cast<UnderlyingType>(parentFlags) & static_cast<UnderlyingType>(InheritedDirtyFlags)));
}
-void Node::ResetDirtyFlags( BufferIndex updateBufferIndex )
+void Node::ResetDirtyFlags(BufferIndex updateBufferIndex)
{
mDirtyFlags = NodePropertyFlags::NOTHING;
}
-void Node::SetParent( Node& parentNode )
+void Node::SetParent(Node& parentNode)
{
DALI_ASSERT_ALWAYS(this != &parentNode);
DALI_ASSERT_ALWAYS(!mIsRoot);
mParent = &parentNode;
- if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
+ if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
{
- mTransformManagerData.Manager()->SetParent( mTransformManagerData.Id(), parentNode.GetTransformId() );
+ mTransformManagerData.Manager()->SetParent(mTransformManagerData.Id(), parentNode.GetTransformId());
}
}
-void Node::RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex )
+void Node::RecursiveDisconnectFromSceneGraph(BufferIndex updateBufferIndex)
{
DALI_ASSERT_ALWAYS(!mIsRoot);
DALI_ASSERT_ALWAYS(mParent != nullptr);
const NodeIter endIter = mChildren.End();
- for ( NodeIter iter = mChildren.Begin(); iter != endIter; ++iter )
+ for(NodeIter iter = mChildren.Begin(); iter != endIter; ++iter)
{
- (*iter)->RecursiveDisconnectFromSceneGraph( updateBufferIndex );
+ (*iter)->RecursiveDisconnectFromSceneGraph(updateBufferIndex);
}
// Animators, Constraints etc. should be disconnected from the child's properties.
- PropertyOwner::DisconnectFromSceneGraph( updateBufferIndex );
+ PropertyOwner::DisconnectFromSceneGraph(updateBufferIndex);
// Remove back-pointer to parent
mParent = nullptr;
// Remove all child pointers
mChildren.Clear();
- if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
+ if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
{
- mTransformManagerData.Manager()->SetParent( mTransformManagerData.Id(), INVALID_TRANSFORM_ID );
+ mTransformManagerData.Manager()->SetParent(mTransformManagerData.Id(), INVALID_TRANSFORM_ID);
}
}
#define DALI_INTERNAL_SCENE_GRAPH_NODE_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/actors/actor-enumerations.h>
-#include <dali/public-api/actors/draw-mode.h>
-#include <dali/public-api/math/quaternion.h>
-#include <dali/public-api/math/math-utils.h>
-#include <dali/public-api/math/vector3.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/common/message.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/render/data-providers/node-data-provider.h>
#include <dali/internal/update/common/animatable-property.h>
+#include <dali/internal/update/common/inherited-property.h>
#include <dali/internal/update/common/property-owner.h>
#include <dali/internal/update/common/scene-graph-buffers.h>
-#include <dali/internal/update/common/inherited-property.h>
-#include <dali/internal/update/manager/transform-manager.h>
#include <dali/internal/update/manager/transform-manager-property.h>
+#include <dali/internal/update/manager/transform-manager.h>
#include <dali/internal/update/nodes/node-declarations.h>
#include <dali/internal/update/rendering/scene-graph-renderer.h>
+#include <dali/public-api/actors/actor-enumerations.h>
+#include <dali/public-api/actors/draw-mode.h>
+#include <dali/public-api/math/math-utils.h>
+#include <dali/public-api/math/quaternion.h>
+#include <dali/public-api/math/vector3.h>
namespace Dali
{
-
namespace Internal
{
-
// Value types used by messages.
-template <> struct ParameterType< ColorMode > : public BasicType< ColorMode > {};
-template <> struct ParameterType< ClippingMode::Type > : public BasicType< ClippingMode::Type > {};
+template<>
+struct ParameterType<ColorMode> : public BasicType<ColorMode>
+{
+};
+template<>
+struct ParameterType<ClippingMode::Type> : public BasicType<ClippingMode::Type>
+{
+};
namespace SceneGraph
{
-
class DiscardQueue;
class Layer;
class RenderTask;
class UpdateManager;
-
// Flags which require the scene renderable lists to be updated
static NodePropertyFlags RenderableUpdateFlags = NodePropertyFlags::TRANSFORM | NodePropertyFlags::CHILD_DELETED;
class Node : public PropertyOwner, public NodeDataProvider
{
public:
-
// Defaults
static const ColorMode DEFAULT_COLOR_MODE;
/**
* Deletes a Node.
*/
- static void Delete( Node* node );
+ static void Delete(Node* node);
/**
* Called during UpdateManager::DestroyNode shortly before Node is destroyed.
{
mUpdated = updated;
- for (Node* child : mChildren)
+ for(Node* child : mChildren)
{
- child->SetUpdated(updated);
+ child->SetUpdated(updated);
}
}
* @param[in] clippingDepth The Clipping Depth of the node to set
* @param[in] scissorDepth The Scissor Clipping Depth of the node to set
*/
- void SetClippingInformation( const uint32_t clippingId, const uint32_t clippingDepth, const uint32_t scissorDepth )
+ void SetClippingInformation(const uint32_t clippingId, const uint32_t clippingDepth, const uint32_t scissorDepth)
{
// We only set up the sort value if we have a stencil clipping depth, IE. At least 1 clipping node has been hit.
// If not, if we traverse down a clipping tree and back up, and there is another
// node on the parent, this will have a non-zero clipping ID that must be ignored
- if( clippingDepth > 0u )
+ if(clippingDepth > 0u)
{
mClippingDepth = clippingDepth;
// The items must be sorted by Clipping ID first (so the ID is kept in the most-significant bits).
// For the same ID, the clipping nodes must be first, so we negate the
// clipping enabled flag and set it as the least significant bit.
- mClippingSortModifier = ( clippingId << 1u ) | ( mClippingMode == ClippingMode::DISABLED ? 1u : 0u );
+ mClippingSortModifier = (clippingId << 1u) | (mClippingMode == ClippingMode::DISABLED ? 1u : 0u);
}
else
{
* Sets the clipping mode for this node.
* @param[in] clippingMode The ClippingMode to set
*/
- void SetClippingMode( const ClippingMode::Type clippingMode )
+ void SetClippingMode(const ClippingMode::Type clippingMode)
{
mClippingMode = clippingMode;
}
* Add a renderer to the node
* @param[in] renderer The renderer added to the node
*/
- void AddRenderer( Renderer* renderer );
+ void AddRenderer(Renderer* renderer);
/**
* Remove a renderer from the node
* @param[in] renderer The renderer to be removed
*/
- void RemoveRenderer( const Renderer* renderer );
+ void RemoveRenderer(const Renderer* renderer);
/*
* Get the renderer at the given index
* @param[in] index
*/
- Renderer* GetRendererAt( uint32_t index ) const
+ Renderer* GetRendererAt(uint32_t index) const
{
return mRenderer[index];
}
*/
uint32_t GetRendererCount() const
{
- return static_cast<uint32_t>( mRenderer.Size() );
+ return static_cast<uint32_t>(mRenderer.Size());
}
// Containment methods
* @pre The childNode is not a root node.
* @param[in] childNode The child to add.
*/
- void ConnectChild( Node* childNode );
+ void ConnectChild(Node* childNode);
/**
* Disconnect a child (& its children) from the scene-graph.
* @param[in] updateBufferIndex The current update buffer index.
* @param[in] childNode The node to disconnect.
*/
- void DisconnectChild( BufferIndex updateBufferIndex, Node& childNode );
+ void DisconnectChild(BufferIndex updateBufferIndex, Node& childNode);
/**
* Retrieve the children a Node.
* Flag that one of the node values has changed in the current frame.
* @param[in] flag The flag to set.
*/
- void SetDirtyFlag( NodePropertyFlags flag )
+ void SetDirtyFlag(NodePropertyFlags flag)
{
mDirtyFlags |= flag;
}
* @param The parentFlags to or with
* @return The inherited dirty flags
*/
- NodePropertyFlags GetInheritedDirtyFlags( NodePropertyFlags parentFlags ) const;
+ NodePropertyFlags GetInheritedDirtyFlags(NodePropertyFlags parentFlags) const;
/**
* Retrieve the parent-origin of the node.
*/
void SetParentOrigin(const Vector3& origin)
{
- mParentOrigin.Set(0,origin );
+ mParentOrigin.Set(0, origin);
}
/**
*/
void SetAnchorPoint(const Vector3& anchor)
{
- mAnchorPoint.Set(0, anchor );
+ mAnchorPoint.Set(0, anchor);
}
/**
*/
const Vector3& GetPosition(BufferIndex bufferIndex) const
{
- if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
+ if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
{
return mPosition.Get(bufferIndex);
}
* Retrieve the position of the node derived from the position of all its parents.
* @return The world position.
*/
- const Vector3& GetWorldPosition( BufferIndex bufferIndex ) const
+ const Vector3& GetWorldPosition(BufferIndex bufferIndex) const
{
return mWorldPosition.Get(bufferIndex);
}
*/
void SetInheritPosition(bool inherit)
{
- if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
+ if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
{
- mTransformManagerData.Manager()->SetInheritPosition( mTransformManagerData.Id(), inherit );
+ mTransformManagerData.Manager()->SetInheritPosition(mTransformManagerData.Id(), inherit);
}
}
*/
const Quaternion& GetOrientation(BufferIndex bufferIndex) const
{
- if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
+ if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
{
return mOrientation.Get(0);
}
* @param[in] bufferIndex The buffer to read from.
* @return The world rotation.
*/
- const Quaternion& GetWorldOrientation( BufferIndex bufferIndex ) const
+ const Quaternion& GetWorldOrientation(BufferIndex bufferIndex) const
{
return mWorldOrientation.Get(0);
}
*/
void SetInheritOrientation(bool inherit)
{
- if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
+ if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
{
- mTransformManagerData.Manager()->SetInheritOrientation(mTransformManagerData.Id(), inherit );
+ mTransformManagerData.Manager()->SetInheritOrientation(mTransformManagerData.Id(), inherit);
}
}
*/
const Vector3& GetScale(BufferIndex bufferIndex) const
{
- if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
+ if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
{
return mScale.Get(0);
}
return Vector3::ONE;
}
-
/**
* Retrieve the scale of the node derived from the scale of all its parents.
* @param[in] bufferIndex The buffer to read from.
* @return The world scale.
*/
- const Vector3& GetWorldScale( BufferIndex bufferIndex ) const
+ const Vector3& GetWorldScale(BufferIndex bufferIndex) const
{
return mWorldScale.Get(0);
}
* Set whether the Node inherits scale.
* @param inherit True if the Node inherits scale.
*/
- void SetInheritScale( bool inherit )
+ void SetInheritScale(bool inherit)
{
- if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
+ if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
{
- mTransformManagerData.Manager()->SetInheritScale(mTransformManagerData.Id(), inherit );
+ mTransformManagerData.Manager()->SetInheritScale(mTransformManagerData.Id(), inherit);
}
}
*/
void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
{
- mWorldColor.Set( updateBufferIndex, color );
+ mWorldColor.Set(updateBufferIndex, color);
}
/**
* @pre The node has a parent.
* @param[in] updateBufferIndex The current update buffer index.
*/
- void InheritWorldColor( BufferIndex updateBufferIndex )
+ void InheritWorldColor(BufferIndex updateBufferIndex)
{
DALI_ASSERT_DEBUG(mParent != NULL);
// default first
- if( mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA )
+ if(mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA)
{
const Vector4& ownColor = mColor[updateBufferIndex];
- mWorldColor.Set( updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a );
+ mWorldColor.Set(updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a);
}
- else if( mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR )
+ else if(mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR)
{
- mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex] );
+ mWorldColor.Set(updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex]);
}
- else if( mColorMode == USE_PARENT_COLOR )
+ else if(mColorMode == USE_PARENT_COLOR)
{
- mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) );
+ mWorldColor.Set(updateBufferIndex, mParent->GetWorldColor(updateBufferIndex));
}
else // USE_OWN_COLOR
{
- mWorldColor.Set( updateBufferIndex, mColor[updateBufferIndex] );
+ mWorldColor.Set(updateBufferIndex, mColor[updateBufferIndex]);
}
}
* does not need to be recalculated in the current frame.
* @param[in] updateBufferIndex The current update buffer index.
*/
- void CopyPreviousWorldColor( BufferIndex updateBufferIndex )
+ void CopyPreviousWorldColor(BufferIndex updateBufferIndex)
{
- mWorldColor.CopyPrevious( updateBufferIndex );
+ mWorldColor.CopyPrevious(updateBufferIndex);
}
/**
* or inherits its parent color.
* @param[in] colorMode The new color mode.
*/
- void SetColorMode( ColorMode colorMode )
+ void SetColorMode(ColorMode colorMode)
{
mColorMode = colorMode;
- SetDirtyFlag( NodePropertyFlags::COLOR );
+ SetDirtyFlag(NodePropertyFlags::COLOR);
}
/**
*/
const Vector3& GetSize(BufferIndex bufferIndex) const
{
- if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
+ if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
{
return mSize.Get(0);
}
*/
const Vector3& GetUpdateSizeHint() const
{
- if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
+ if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
{
return mUpdateSizeHint.Get(0);
}
*/
const Vector4& GetBoundingSphere() const
{
- if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
+ if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
{
- return mTransformManagerData.Manager()->GetBoundingSphere( mTransformManagerData.Id() );
+ return mTransformManagerData.Manager()->GetBoundingSphere(mTransformManagerData.Id());
}
return Vector4::ZERO;
* @param[out] The local to world matrix of the node
* @param[out] size The current size of the node
*/
- void GetWorldMatrixAndSize( Matrix& worldMatrix, Vector3& size ) const
+ void GetWorldMatrixAndSize(Matrix& worldMatrix, Vector3& size) const
{
- if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID )
+ if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID)
{
- mTransformManagerData.Manager()->GetWorldMatrixAndSize( mTransformManagerData.Id(), worldMatrix, size );
+ mTransformManagerData.Manager()->GetWorldMatrixAndSize(mTransformManagerData.Id(), worldMatrix, size);
}
}
bool IsLocalMatrixDirty() const
{
return (mTransformManagerData.Id() != INVALID_TRANSFORM_ID) &&
- (mTransformManagerData.Manager()->IsLocalMatrixDirty( mTransformManagerData.Id() ));
+ (mTransformManagerData.Manager()->IsLocalMatrixDirty(mTransformManagerData.Id()));
}
/**
* @param[in] bufferIndex The buffer to read from.
* @return The world-matrix.
*/
- const Matrix& GetWorldMatrix( BufferIndex bufferIndex ) const
+ const Matrix& GetWorldMatrix(BufferIndex bufferIndex) const
{
return mWorldMatrix.Get(bufferIndex);
}
* Mark the node as exclusive to a single RenderTask.
* @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
*/
- void SetExclusiveRenderTask( RenderTask* renderTask )
+ void SetExclusiveRenderTask(RenderTask* renderTask)
{
mExclusiveRenderTask = renderTask;
}
* Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
* @param[in] drawMode The new draw-mode to use.
*/
- void SetDrawMode( const DrawMode::Type& drawMode )
+ void SetDrawMode(const DrawMode::Type& drawMode)
{
mDrawMode = drawMode;
}
* Equality operator, checks for identity, not values.
* @param[in]
*/
- bool operator==( const Node* rhs ) const
+ bool operator==(const Node* rhs) const
{
- return ( this == rhs );
+ return (this == rhs);
}
/**
* @brief Sets the sibling order of the node
* @param[in] order The new order
*/
- void SetDepthIndex( uint32_t depthIndex )
+ void SetDepthIndex(uint32_t depthIndex)
{
mDepthIndex = depthIndex;
}
* @brief Sets the boolean which states whether the position should use the anchor-point.
* @param[in] positionUsesAnchorPoint True if the position should use the anchor-point
*/
- void SetPositionUsesAnchorPoint( bool positionUsesAnchorPoint )
+ void SetPositionUsesAnchorPoint(bool positionUsesAnchorPoint)
{
- if( mTransformManagerData.Id() != INVALID_TRANSFORM_ID && mPositionUsesAnchorPoint != positionUsesAnchorPoint )
+ if(mTransformManagerData.Id() != INVALID_TRANSFORM_ID && mPositionUsesAnchorPoint != positionUsesAnchorPoint)
{
mPositionUsesAnchorPoint = positionUsesAnchorPoint;
- mTransformManagerData.Manager()->SetPositionUsesAnchorPoint( mTransformManagerData.Id(), mPositionUsesAnchorPoint );
+ mTransformManagerData.Manager()->SetPositionUsesAnchorPoint(mTransformManagerData.Id(), mPositionUsesAnchorPoint);
}
}
* @param[in] bufferIndex The buffer to read from.
* @param[in] culled True if the node is culled.
*/
- void SetCulled( BufferIndex bufferIndex, bool culled )
+ void SetCulled(BufferIndex bufferIndex, bool culled)
{
mCulled[bufferIndex] = culled;
}
* @param[in] bufferIndex The buffer to read from.
* @return True if the node is culled.
*/
- bool IsCulled( BufferIndex bufferIndex ) const
+ bool IsCulled(BufferIndex bufferIndex) const
{
return mCulled[bufferIndex];
}
/**
* @copydoc UniformMap::Remove
*/
- void RemoveUniformMapping( const ConstString& uniformName ) override;
+ void RemoveUniformMapping(const ConstString& uniformName) override;
/**
* @copydoc Dali::Internal::SceneGraph::PropertyOwner::IsAnimationPossible
* This is called by the UpdateManager when an object is due to be rendered in the current frame.
* @param[in] updateBufferIndex The current update buffer index.
*/
- void PrepareRender( BufferIndex bufferIndex );
+ void PrepareRender(BufferIndex bufferIndex);
/**
* Called by UpdateManager when the node is added.
* related to the transformation
* @param[in] transformManager A pointer to the trnasform manager (Owned by UpdateManager)
*/
- void CreateTransform( SceneGraph::TransformManager* transformManager );
+ void CreateTransform(SceneGraph::TransformManager* transformManager);
/**
* Reset dirty flags
*/
- void ResetDirtyFlags( BufferIndex updateBufferIndex );
+ void ResetDirtyFlags(BufferIndex updateBufferIndex);
protected:
-
/**
* Set the parent of a Node.
* @param[in] parentNode the new parent.
*/
- void SetParent( Node& parentNode );
+ void SetParent(Node& parentNode);
protected:
-
/**
* Protected constructor; See also Node::New()
*/
~Node() override;
private: // from NodeDataProvider
-
/**
* @copydoc NodeDataProvider::GetModelMatrix
*/
- const Matrix& GetModelMatrix( BufferIndex bufferIndex ) const override
+ const Matrix& GetModelMatrix(BufferIndex bufferIndex) const override
{
- return GetWorldMatrix( bufferIndex );
+ return GetWorldMatrix(bufferIndex);
}
/**
* @copydoc NodeDataProvider::GetRenderColor
*/
- const Vector4& GetRenderColor( BufferIndex bufferIndex ) const override
+ const Vector4& GetRenderColor(BufferIndex bufferIndex) const override
{
- return GetWorldColor( bufferIndex );
+ return GetWorldColor(bufferIndex);
}
public: // From UniformMapDataProvider
/**
* @copydoc UniformMapDataProvider::GetUniformMapChanged
*/
- bool GetUniformMapChanged( BufferIndex bufferIndex ) const override
+ bool GetUniformMapChanged(BufferIndex bufferIndex) const override
{
return mUniformMapChanged[bufferIndex];
}
/**
* @copydoc UniformMapDataProvider::GetUniformMap
*/
- const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const override
+ const CollectedUniformMap& GetUniformMap(BufferIndex bufferIndex) const override
{
return mCollectedUniformMap[bufferIndex];
}
private:
-
// Undefined
Node(const Node&);
* Disconnected Nodes have no parent or children.
* @param[in] updateBufferIndex The current update buffer index.
*/
- void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex );
+ void RecursiveDisconnectFromSceneGraph(BufferIndex updateBufferIndex);
public: // Default properties
using TransformManagerParentsOrigin = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_PARENT_ORIGIN>;
- using TransformManagerAnchorPoint = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_ANCHOR_POINT>;
- using TransformManagerSize = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_SIZE>;
- using TransformManagerPosition = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_POSITION>;
- using TransformManagerScale = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_SCALE>;
-
+ using TransformManagerAnchorPoint = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_ANCHOR_POINT>;
+ using TransformManagerSize = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_SIZE>;
+ using TransformManagerPosition = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_POSITION>;
+ using TransformManagerScale = TransformManagerPropertyVector3<TRANSFORM_PROPERTY_SCALE>;
TransformManagerData mTransformManagerData;
- TransformManagerParentsOrigin mParentOrigin; ///< Local transform; the position is relative to this. Sets the Transform flag dirty when changed
- TransformManagerAnchorPoint mAnchorPoint; ///< Local transform; local center of rotation. Sets the Transform flag dirty when changed
- TransformManagerSize mSize; ///< Size is provided for layouting
- TransformManagerPosition mPosition; ///< Local transform; distance between parent-origin & anchor-point
- TransformManagerScale mScale; ///< Local transform; scale relative to parent node
- TransformManagerPropertyQuaternion mOrientation; ///< Local transform; rotation relative to parent node
-
- AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
- AnimatableProperty<bool> mCulled; ///< True if the node is culled. This is not animatable. It is just double-buffered.
- AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
- AnimatableProperty<Vector3> mUpdateSizeHint; ///< Update size hint is provided for damaged area calculation. This is not animatable. It is just double-buffered. (Because all these bloody properties are).
-
+ TransformManagerParentsOrigin mParentOrigin; ///< Local transform; the position is relative to this. Sets the Transform flag dirty when changed
+ TransformManagerAnchorPoint mAnchorPoint; ///< Local transform; local center of rotation. Sets the Transform flag dirty when changed
+ TransformManagerSize mSize; ///< Size is provided for layouting
+ TransformManagerPosition mPosition; ///< Local transform; distance between parent-origin & anchor-point
+ TransformManagerScale mScale; ///< Local transform; scale relative to parent node
+ TransformManagerPropertyQuaternion mOrientation; ///< Local transform; rotation relative to parent node
+
+ AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
+ AnimatableProperty<bool> mCulled; ///< True if the node is culled. This is not animatable. It is just double-buffered.
+ AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
+ AnimatableProperty<Vector3> mUpdateSizeHint; ///< Update size hint is provided for damaged area calculation. This is not animatable. It is just double-buffered. (Because all these bloody properties are).
// Inherited properties; read-only from public API
- TransformManagerVector3Input mWorldPosition; ///< Full inherited position
- TransformManagerVector3Input mWorldScale;
- TransformManagerQuaternionInput mWorldOrientation; ///< Full inherited orientation
- TransformManagerMatrixInput mWorldMatrix; ///< Full inherited world matrix
- InheritedColor mWorldColor; ///< Full inherited color
+ TransformManagerVector3Input mWorldPosition; ///< Full inherited position
+ TransformManagerVector3Input mWorldScale;
+ TransformManagerQuaternionInput mWorldOrientation; ///< Full inherited orientation
+ TransformManagerMatrixInput mWorldMatrix; ///< Full inherited world matrix
+ InheritedColor mWorldColor; ///< Full inherited color
- uint32_t mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting
- const uint32_t mId; ///< The Unique ID of the node.
+ uint32_t mClippingSortModifier; ///< Contains bit-packed clipping information for quick access when sorting
+ const uint32_t mId; ///< The Unique ID of the node.
protected:
+ static uint32_t mNodeCounter; ///< count of total nodes, used for unique ids
- static uint32_t mNodeCounter; ///< count of total nodes, used for unique ids
-
- Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
- RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
+ Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
+ RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
- RendererContainer mRenderer; ///< Container of renderers; not owned
+ RendererContainer mRenderer; ///< Container of renderers; not owned
- NodeContainer mChildren; ///< Container of children; not owned
+ NodeContainer mChildren; ///< Container of children; not owned
- CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps of the node
- uint32_t mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame
- uint32_t mClippingDepth; ///< The number of stencil clipping nodes deep this node is
- uint32_t mScissorDepth; ///< The number of scissor clipping nodes deep this node is
+ CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps of the node
+ uint32_t mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame
+ uint32_t mClippingDepth; ///< The number of stencil clipping nodes deep this node is
+ uint32_t mScissorDepth; ///< The number of scissor clipping nodes deep this node is
- uint32_t mDepthIndex; ///< Depth index of the node
+ uint32_t mDepthIndex; ///< Depth index of the node
// flags, compressed to bitfield
- NodePropertyFlags mDirtyFlags; ///< Dirty flags for each of the Node properties
- uint32_t mRegenerateUniformMap:2; ///< Indicate if the uniform map has to be regenerated this frame
- DrawMode::Type mDrawMode:3; ///< How the Node and its children should be drawn
- ColorMode mColorMode:3; ///< Determines whether mWorldColor is inherited, 2 bits is enough
- ClippingMode::Type mClippingMode:3; ///< The clipping mode of this node
- bool mIsRoot:1; ///< True if the node cannot have a parent
- bool mIsLayer:1; ///< True if the node is a layer
- bool mPositionUsesAnchorPoint:1; ///< True if the node should use the anchor-point when calculating the position
+ NodePropertyFlags mDirtyFlags; ///< Dirty flags for each of the Node properties
+ uint32_t mRegenerateUniformMap : 2; ///< Indicate if the uniform map has to be regenerated this frame
+ DrawMode::Type mDrawMode : 3; ///< How the Node and its children should be drawn
+ ColorMode mColorMode : 3; ///< Determines whether mWorldColor is inherited, 2 bits is enough
+ ClippingMode::Type mClippingMode : 3; ///< The clipping mode of this node
+ bool mIsRoot : 1; ///< True if the node cannot have a parent
+ bool mIsLayer : 1; ///< True if the node is a layer
+ bool mPositionUsesAnchorPoint : 1; ///< True if the node should use the anchor-point when calculating the position
// Changes scope, should be at end of class
DALI_LOG_OBJECT_STRING_DECLARATION;
// Messages for Node
-inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
+inline void SetInheritOrientationMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
{
using LocalType = MessageValue1<Node, bool>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &node, &Node::SetInheritOrientation, inherit );
+ new(slot) LocalType(&node, &Node::SetInheritOrientation, inherit);
}
-inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin )
+inline void SetParentOriginMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin)
{
using LocalType = MessageValue1<Node, Vector3>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &node, &Node::SetParentOrigin, origin );
+ new(slot) LocalType(&node, &Node::SetParentOrigin, origin);
}
-inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor )
+inline void SetAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor)
{
using LocalType = MessageValue1<Node, Vector3>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &node, &Node::SetAnchorPoint, anchor );
+ new(slot) LocalType(&node, &Node::SetAnchorPoint, anchor);
}
-inline void SetInheritPositionMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
+inline void SetInheritPositionMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
{
using LocalType = MessageValue1<Node, bool>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &node, &Node::SetInheritPosition, inherit );
+ new(slot) LocalType(&node, &Node::SetInheritPosition, inherit);
}
-inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
+inline void SetInheritScaleMessage(EventThreadServices& eventThreadServices, const Node& node, bool inherit)
{
using LocalType = MessageValue1<Node, bool>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &node, &Node::SetInheritScale, inherit );
+ new(slot) LocalType(&node, &Node::SetInheritScale, inherit);
}
-inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode )
+inline void SetColorModeMessage(EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode)
{
using LocalType = MessageValue1<Node, ColorMode>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &node, &Node::SetColorMode, colorMode );
+ new(slot) LocalType(&node, &Node::SetColorMode, colorMode);
}
-inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode )
+inline void SetDrawModeMessage(EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode)
{
using LocalType = MessageValue1<Node, DrawMode::Type>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &node, &Node::SetDrawMode, drawMode );
+ new(slot) LocalType(&node, &Node::SetDrawMode, drawMode);
}
-inline void AttachRendererMessage( EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer )
+inline void AttachRendererMessage(EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer)
{
using LocalType = MessageValue1<Node, Renderer*>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &node, &Node::AddRenderer, const_cast<Renderer*>( &renderer ) );
+ new(slot) LocalType(&node, &Node::AddRenderer, const_cast<Renderer*>(&renderer));
}
-inline void DetachRendererMessage( EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer )
+inline void DetachRendererMessage(EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer)
{
using LocalType = MessageValue1<Node, const Renderer*>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &node, &Node::RemoveRenderer, &renderer );
+ new(slot) LocalType(&node, &Node::RemoveRenderer, &renderer);
}
-inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Node& node, uint32_t depthIndex )
+inline void SetDepthIndexMessage(EventThreadServices& eventThreadServices, const Node& node, uint32_t depthIndex)
{
using LocalType = MessageValue1<Node, uint32_t>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &node, &Node::SetDepthIndex, depthIndex );
+ new(slot) LocalType(&node, &Node::SetDepthIndex, depthIndex);
}
-inline void SetClippingModeMessage( EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode )
+inline void SetClippingModeMessage(EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode)
{
using LocalType = MessageValue1<Node, ClippingMode::Type>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &node, &Node::SetClippingMode, clippingMode );
+ new(slot) LocalType(&node, &Node::SetClippingMode, clippingMode);
}
-inline void SetPositionUsesAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint )
+inline void SetPositionUsesAnchorPointMessage(EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint)
{
using LocalType = MessageValue1<Node, bool>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &node, &Node::SetPositionUsesAnchorPoint, positionUsesAnchorPoint );
+ new(slot) LocalType(&node, &Node::SetPositionUsesAnchorPoint, positionUsesAnchorPoint);
}
} // namespace SceneGraph
// Template specialisation for OwnerPointer<Node>, because delete is protected
-template <>
+template<>
inline void OwnerPointer<Dali::Internal::SceneGraph::Node>::Reset()
{
- if (mObject != nullptr)
+ if(mObject != nullptr)
{
Dali::Internal::SceneGraph::Node::Delete(mObject);
mObject = nullptr;
} // namespace Internal
// Template specialisations for OwnerContainer<Node*>, because delete is protected
-template <>
-inline void OwnerContainer<Dali::Internal::SceneGraph::Node*>::Delete( Dali::Internal::SceneGraph::Node* pointer )
+template<>
+inline void OwnerContainer<Dali::Internal::SceneGraph::Node*>::Delete(Dali::Internal::SceneGraph::Node* pointer)
{
Dali::Internal::SceneGraph::Node::Delete(pointer);
}
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
// CLASS HEADER
-#include <dali/internal/update/nodes/scene-graph-layer.h>
#include <dali/internal/event/actors/layer-impl.h>
+#include <dali/internal/update/nodes/scene-graph-layer.h>
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
SceneGraph::Layer* Layer::New()
{
// Layers are currently heap allocated, unlike Nodes which are in a memory pool
Layer::Layer()
: Node(),
- mSortFunction( Internal::Layer::ZValue ),
- mClippingBox( 0,0,0,0 ),
- mLastCamera( nullptr ),
- mBehavior( Dali::Layer::LAYER_UI ),
- mIsClipping( false ),
- mDepthTestDisabled( true ),
- mIsDefaultSortFunction( true )
+ mSortFunction(Internal::Layer::ZValue),
+ mClippingBox(0, 0, 0, 0),
+ mLastCamera(nullptr),
+ mBehavior(Dali::Layer::LAYER_UI),
+ mIsClipping(false),
+ mDepthTestDisabled(true),
+ mIsDefaultSortFunction(true)
{
// set a flag the node to say this is a layer
mIsLayer = true;
// layer starts off dirty
- mAllChildTransformsClean[ 0 ] = false;
- mAllChildTransformsClean[ 1 ] = false;
+ mAllChildTransformsClean[0] = false;
+ mAllChildTransformsClean[1] = false;
}
Layer::~Layer() = default;
-void Layer::SetSortFunction( Dali::Layer::SortFunctionType function )
+void Layer::SetSortFunction(Dali::Layer::SortFunctionType function)
{
- if( mSortFunction != function )
+ if(mSortFunction != function)
{
// is a custom sort function used
- if( function != Internal::Layer::ZValue )
+ if(function != Internal::Layer::ZValue)
{
mIsDefaultSortFunction = false;
}
}
// changing the sort function makes the layer dirty
- mAllChildTransformsClean[ 0 ] = false;
- mAllChildTransformsClean[ 1 ] = false;
- mSortFunction = function;
+ mAllChildTransformsClean[0] = false;
+ mAllChildTransformsClean[1] = false;
+ mSortFunction = function;
}
}
mClippingBox.Set(box.x, box.y, box.width, box.height);
}
-void Layer::SetBehavior( Dali::Layer::Behavior behavior )
+void Layer::SetBehavior(Dali::Layer::Behavior behavior)
{
mBehavior = behavior;
}
-void Layer::SetDepthTestDisabled( bool disable )
+void Layer::SetDepthTestDisabled(bool disable)
{
mDepthTestDisabled = disable;
}
#define DALI_INTERNAL_SCENE_GRAPH_LAYER_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/actors/layer.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/update/nodes/node.h>
+#include <dali/public-api/actors/layer.h>
namespace Dali
{
-
namespace Internal
{
-
// value types used by messages
-template <> struct ParameterType< Dali::Layer::SortFunctionType >
-: public BasicType< Dali::Layer::SortFunctionType > {};
-template <> struct ParameterType< Dali::Layer::Behavior >
-: public BasicType< Dali::Layer::Behavior > {};
+template<>
+struct ParameterType<Dali::Layer::SortFunctionType>
+: public BasicType<Dali::Layer::SortFunctionType>
+{
+};
+template<>
+struct ParameterType<Dali::Layer::Behavior>
+: public BasicType<Dali::Layer::Behavior>
+{
+};
namespace SceneGraph
{
struct Renderable
{
Renderable()
- : mNode( nullptr ),
- mRenderer( nullptr )
- {}
+ : mNode(nullptr),
+ mRenderer(nullptr)
+ {
+ }
- Renderable( Node* node, Renderer* renderer )
- : mNode( node ),
- mRenderer( renderer )
- {}
+ Renderable(Node* node, Renderer* renderer)
+ : mNode(node),
+ mRenderer(renderer)
+ {
+ }
- Node* mNode;
+ Node* mNode;
Renderer* mRenderer;
};
* Sets the sort-function of a layer.
* @param [in] function The new sort-function.
*/
- void SetSortFunction( Dali::Layer::SortFunctionType function );
+ void SetSortFunction(Dali::Layer::SortFunctionType function);
/**
* Retrieve the function used to sort semi-transparent geometry in this layer.
* Sets whether clipping is enabled for a layer.
* @param [in] enabled True if clipping is enabled.
*/
- void SetClipping( bool enabled );
+ void SetClipping(bool enabled);
/**
* Query whether clipping is enabled for a layer.
* enabled. The default clipping box is empty (0,0,0,0).
* @param [in] box The clipping box
*/
- void SetClippingBox( const ClippingBox& box );
+ void SetClippingBox(const ClippingBox& box);
/**
* Retrieves the clipping box of a layer, in window coordinates.
* Sets the behavior of the layer
* @param [in] behavior The behavior of the layer
*/
- void SetBehavior( Dali::Layer::Behavior behavior );
+ void SetBehavior(Dali::Layer::Behavior behavior);
/**
* Retrieves the behavior of the layer.
/**
* @copydoc Dali::Layer::SetDepthTestDisabled()
*/
- void SetDepthTestDisabled( bool disable );
+ void SetDepthTestDisabled(bool disable);
/**
* @copydoc Dali::Layer::IsDepthTestDisabled()
* @param[in] updateBufferIndex The current update buffer index.
* @param value to set
*/
- void SetReuseRenderers( BufferIndex updateBufferIndex, bool value )
+ void SetReuseRenderers(BufferIndex updateBufferIndex, bool value)
{
- mAllChildTransformsClean[ updateBufferIndex ] = value;
+ mAllChildTransformsClean[updateBufferIndex] = value;
}
/**
* to use is the same than the one used before ( Otherwise View transform will be different )
*
*/
- bool CanReuseRenderers( Camera* camera )
+ bool CanReuseRenderers(Camera* camera)
{
- bool bReturn( mAllChildTransformsClean[ 0 ] && mAllChildTransformsClean[ 1 ] && camera == mLastCamera );
+ bool bReturn(mAllChildTransformsClean[0] && mAllChildTransformsClean[1] && camera == mLastCamera);
mLastCamera = camera;
return bReturn;
void ClearRenderables();
private:
-
/**
* Private constructor.
* See also Layer::New()
Layer& operator=(const Layer& rhs);
public: // For update-algorithms
-
RenderableContainer colorRenderables;
RenderableContainer overlayRenderables;
private:
+ SortFunctionType mSortFunction; ///< Used to sort semi-transparent geometry
- SortFunctionType mSortFunction; ///< Used to sort semi-transparent geometry
-
- ClippingBox mClippingBox; ///< The clipping box, in window coordinates
- Camera* mLastCamera; ///< Pointer to the last camera that has rendered the layer
-
- Dali::Layer::Behavior mBehavior; ///< The behavior of the layer
+ ClippingBox mClippingBox; ///< The clipping box, in window coordinates
+ Camera* mLastCamera; ///< Pointer to the last camera that has rendered the layer
- bool mAllChildTransformsClean[ 2 ]; ///< True if all child nodes transforms are clean,
- /// double buffered as we need two clean frames before we can reuse N-1 for N+1
- /// this allows us to cache render items when layer is "static"
- bool mIsClipping:1; ///< True when clipping is enabled
- bool mDepthTestDisabled:1; ///< Whether depth test is disabled.
- bool mIsDefaultSortFunction:1; ///< whether the default depth sort function is used
+ Dali::Layer::Behavior mBehavior; ///< The behavior of the layer
+ bool mAllChildTransformsClean[2]; ///< True if all child nodes transforms are clean,
+ /// double buffered as we need two clean frames before we can reuse N-1 for N+1
+ /// this allows us to cache render items when layer is "static"
+ bool mIsClipping : 1; ///< True when clipping is enabled
+ bool mDepthTestDisabled : 1; ///< Whether depth test is disabled.
+ bool mIsDefaultSortFunction : 1; ///< whether the default depth sort function is used
};
// Messages for Layer
* @param[in] layer The layer
* @param[in] function The new sort-function.
*/
-inline void SetSortFunctionMessage( EventThreadServices& eventThreadServices, const Layer& layer, Dali::Layer::SortFunctionType function )
+inline void SetSortFunctionMessage(EventThreadServices& eventThreadServices, const Layer& layer, Dali::Layer::SortFunctionType function)
{
using LocalType = MessageValue1<Layer, Dali::Layer::SortFunctionType>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &layer, &Layer::SetSortFunction, function );
+ new(slot) LocalType(&layer, &Layer::SetSortFunction, function);
}
/**
* @param[in] layer The layer
* @param[in] enabled True if clipping is enabled
*/
-inline void SetClippingMessage( EventThreadServices& eventThreadServices, const Layer& layer, bool enabled )
+inline void SetClippingMessage(EventThreadServices& eventThreadServices, const Layer& layer, bool enabled)
{
using LocalType = MessageValue1<Layer, bool>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &layer, &Layer::SetClipping, enabled );
+ new(slot) LocalType(&layer, &Layer::SetClipping, enabled);
}
/**
* @param[in] layer The layer
* @param[in] clippingbox The clipping box
*/
-inline void SetClippingBoxMessage( EventThreadServices& eventThreadServices, const Layer& layer, const Dali::ClippingBox& clippingbox )
+inline void SetClippingBoxMessage(EventThreadServices& eventThreadServices, const Layer& layer, const Dali::ClippingBox& clippingbox)
{
using LocalType = MessageValue1<Layer, Dali::ClippingBox>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &layer, &Layer::SetClippingBox, clippingbox );
+ new(slot) LocalType(&layer, &Layer::SetClippingBox, clippingbox);
}
/**
* @param[in] layer The layer
* @param[in] behavior The behavior
*/
-inline void SetBehaviorMessage( EventThreadServices& eventThreadServices,
- const Layer& layer,
- Dali::Layer::Behavior behavior )
+inline void SetBehaviorMessage(EventThreadServices& eventThreadServices,
+ const Layer& layer,
+ Dali::Layer::Behavior behavior)
{
using LocalType = MessageValue1<Layer, Dali::Layer::Behavior>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &layer, &Layer::SetBehavior, behavior );
+ new(slot) LocalType(&layer, &Layer::SetBehavior, behavior);
}
/**
* @param[in] layer The layer
* @param[in] disable \e true disables depth test. \e false sets the default behavior.
*/
-inline void SetDepthTestDisabledMessage( EventThreadServices& eventThreadServices, const Layer& layer, bool disable )
+inline void SetDepthTestDisabledMessage(EventThreadServices& eventThreadServices, const Layer& layer, bool disable)
{
using LocalType = MessageValue1<Layer, bool>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &layer, &Layer::SetDepthTestDisabled, disable );
+ new(slot) LocalType(&layer, &Layer::SetDepthTestDisabled, disable);
}
} // namespace SceneGraph
// Template specialisation for OwnerPointer<Layer>, because delete is protected
-template <>
+template<>
inline void OwnerPointer<Dali::Internal::SceneGraph::Layer>::Reset()
{
- if (mObject != nullptr)
+ if(mObject != nullptr)
{
Dali::Internal::SceneGraph::Node::Delete(mObject);
mObject = nullptr;
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/update/queue/update-message-queue.h>
// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
#include <dali/devel-api/threading/mutex.h>
#include <dali/integration-api/render-controller.h>
-#include <dali/internal/common/message.h>
#include <dali/internal/common/message-buffer.h>
+#include <dali/internal/common/message.h>
#include <dali/internal/render/common/performance-monitor.h>
+#include <dali/public-api/common/vector-wrapper.h>
using std::vector;
namespace Dali
{
-
namespace Internal
{
-
namespace // unnamed namespace
{
-
// A message to set Actor::SIZE is 72 bytes on 32bit device
// A buffer of size 32768 would store (32768 - 4) / (72 + 4) = 431 of those messages
-static const std::size_t INITIAL_BUFFER_SIZE = 32768;
-static const std::size_t MAX_BUFFER_CAPACITY = 73728; // Avoid keeping buffers which exceed this
-static const std::size_t MAX_FREE_BUFFER_COUNT = 3; // Allow this number of buffers to be recycled
+static const std::size_t INITIAL_BUFFER_SIZE = 32768;
+static const std::size_t MAX_BUFFER_CAPACITY = 73728; // Avoid keeping buffers which exceed this
+static const std::size_t MAX_FREE_BUFFER_COUNT = 3; // Allow this number of buffers to be recycled
// A queue of message buffers
-typedef vector< MessageBuffer* > MessageBufferQueue;
+typedef vector<MessageBuffer*> MessageBufferQueue;
using MessageBufferIter = MessageBufferQueue::iterator;
using MessageQueueMutex = Dali::Mutex;
namespace Update
{
-
/**
* Private MessageQueue data
*/
struct MessageQueue::Impl
{
- Impl( RenderController& controller, const SceneGraphBuffers& buffers )
+ Impl(RenderController& controller, const SceneGraphBuffers& buffers)
: renderController(controller),
sceneGraphBuffers(buffers),
processingEvents(false),
queueWasEmpty(true),
- sceneUpdateFlag( false ),
- sceneUpdate( 0 ),
+ sceneUpdateFlag(false),
+ sceneUpdate(0),
currentMessageBuffer(nullptr)
{
}
~Impl()
{
// Delete the current buffer
- if( currentMessageBuffer )
+ if(currentMessageBuffer)
{
- DeleteBufferContents( currentMessageBuffer );
+ DeleteBufferContents(currentMessageBuffer);
delete currentMessageBuffer;
}
// Delete the unprocessed buffers
const MessageBufferIter processQueueEndIter = processQueue.end();
- for ( MessageBufferIter iter = processQueue.begin(); iter != processQueueEndIter; ++iter )
+ for(MessageBufferIter iter = processQueue.begin(); iter != processQueueEndIter; ++iter)
{
MessageBuffer* unprocessedBuffer = *iter;
- DeleteBufferContents( unprocessedBuffer );
+ DeleteBufferContents(unprocessedBuffer);
delete unprocessedBuffer;
}
// Delete the recycled buffers
const MessageBufferIter recycleQueueEndIter = recycleQueue.end();
- for ( MessageBufferIter iter = recycleQueue.begin(); iter != recycleQueueEndIter; ++iter )
+ for(MessageBufferIter iter = recycleQueue.begin(); iter != recycleQueueEndIter; ++iter)
{
MessageBuffer* recycledBuffer = *iter;
- DeleteBufferContents( recycledBuffer );
+ DeleteBufferContents(recycledBuffer);
delete recycledBuffer;
}
const MessageBufferIter freeQueueEndIter = freeQueue.end();
- for ( MessageBufferIter iter = freeQueue.begin(); iter != freeQueueEndIter; ++iter )
+ for(MessageBufferIter iter = freeQueue.begin(); iter != freeQueueEndIter; ++iter)
{
MessageBuffer* freeBuffer = *iter;
- DeleteBufferContents( freeBuffer );
+ DeleteBufferContents(freeBuffer);
delete freeBuffer;
}
}
- void DeleteBufferContents( MessageBuffer* buffer )
+ void DeleteBufferContents(MessageBuffer* buffer)
{
- for( MessageBuffer::Iterator iter = buffer->Begin(); iter.IsValid(); iter.Next() )
+ for(MessageBuffer::Iterator iter = buffer->Begin(); iter.IsValid(); iter.Next())
{
- MessageBase* message = reinterpret_cast< MessageBase* >( iter.Get() );
+ MessageBase* message = reinterpret_cast<MessageBase*>(iter.Get());
// Call virtual destructor explictly; since delete will not be called after placement new
message->~MessageBase();
}
}
- RenderController& renderController; ///< render controller
- const SceneGraphBuffers& sceneGraphBuffers; ///< Used to keep track of which buffers are being written or read.
+ RenderController& renderController; ///< render controller
+ const SceneGraphBuffers& sceneGraphBuffers; ///< Used to keep track of which buffers are being written or read.
- bool processingEvents; ///< Whether messages queued will be flushed by core
- bool queueWasEmpty; ///< Flag whether the queue was empty during the Update()
- bool sceneUpdateFlag; ///< true when there is a new message that requires a scene-graph node tree update
- int sceneUpdate; ///< Non zero when there is a message in the queue requiring a scene-graph node tree update
+ bool processingEvents; ///< Whether messages queued will be flushed by core
+ bool queueWasEmpty; ///< Flag whether the queue was empty during the Update()
+ bool sceneUpdateFlag; ///< true when there is a new message that requires a scene-graph node tree update
+ int sceneUpdate; ///< Non zero when there is a message in the queue requiring a scene-graph node tree update
- MessageQueueMutex queueMutex; ///< queueMutex must be locked whilst accessing processQueue or recycleQueue
- MessageBufferQueue processQueue; ///< to process in the next update
- MessageBufferQueue recycleQueue; ///< to recycle MessageBuffers after the messages have been processed
+ MessageQueueMutex queueMutex; ///< queueMutex must be locked whilst accessing processQueue or recycleQueue
+ MessageBufferQueue processQueue; ///< to process in the next update
+ MessageBufferQueue recycleQueue; ///< to recycle MessageBuffers after the messages have been processed
- MessageBuffer* currentMessageBuffer; ///< can be used without locking
- MessageBufferQueue freeQueue; ///< buffers from the recycleQueue; can be used without locking
+ MessageBuffer* currentMessageBuffer; ///< can be used without locking
+ MessageBufferQueue freeQueue; ///< buffers from the recycleQueue; can be used without locking
};
-MessageQueue::MessageQueue( Integration::RenderController& controller, const SceneGraph::SceneGraphBuffers& buffers )
+MessageQueue::MessageQueue(Integration::RenderController& controller, const SceneGraph::SceneGraphBuffers& buffers)
: mImpl(nullptr)
{
- mImpl = new Impl( controller, buffers );
+ mImpl = new Impl(controller, buffers);
}
MessageQueue::~MessageQueue()
}
// Called from event thread
-uint32_t* MessageQueue::ReserveMessageSlot( uint32_t requestedSize, bool updateScene )
+uint32_t* MessageQueue::ReserveMessageSlot(uint32_t requestedSize, bool updateScene)
{
- DALI_ASSERT_DEBUG( 0 != requestedSize );
+ DALI_ASSERT_DEBUG(0 != requestedSize);
- if( updateScene )
+ if(updateScene)
{
mImpl->sceneUpdateFlag = true;
}
- if ( !mImpl->currentMessageBuffer )
+ if(!mImpl->currentMessageBuffer)
{
const MessageBufferIter endIter = mImpl->freeQueue.end();
// Find the largest recycled buffer from freeQueue
MessageBufferIter nextBuffer = endIter;
- for ( MessageBufferIter iter = mImpl->freeQueue.begin(); iter != endIter; ++iter )
+ for(MessageBufferIter iter = mImpl->freeQueue.begin(); iter != endIter; ++iter)
{
- if ( endIter == nextBuffer ||
- (*nextBuffer)->GetCapacity() < (*iter)->GetCapacity() )
+ if(endIter == nextBuffer ||
+ (*nextBuffer)->GetCapacity() < (*iter)->GetCapacity())
{
nextBuffer = iter;
}
}
- if ( endIter != nextBuffer )
+ if(endIter != nextBuffer)
{
// Reuse a recycled buffer from freeQueue
mImpl->currentMessageBuffer = *nextBuffer;
- mImpl->freeQueue.erase( nextBuffer );
+ mImpl->freeQueue.erase(nextBuffer);
}
else
{
- mImpl->currentMessageBuffer = new MessageBuffer( INITIAL_BUFFER_SIZE );
+ mImpl->currentMessageBuffer = new MessageBuffer(INITIAL_BUFFER_SIZE);
}
}
// If we are inside Core::ProcessEvents(), core will automatically flush the queue.
// If we are outside, then we have to request a call to Core::ProcessEvents() on idle.
- if ( false == mImpl->processingEvents )
+ if(false == mImpl->processingEvents)
{
- mImpl->renderController.RequestProcessEventsOnIdle( false );
+ mImpl->renderController.RequestProcessEventsOnIdle(false);
}
- return mImpl->currentMessageBuffer->ReserveMessageSlot( requestedSize );
+ return mImpl->currentMessageBuffer->ReserveMessageSlot(requestedSize);
}
// Called from event thread
bool MessageQueue::FlushQueue()
{
- const bool messagesToProcess = ( nullptr != mImpl->currentMessageBuffer );
+ const bool messagesToProcess = (nullptr != mImpl->currentMessageBuffer);
// If there're messages to flush
- if ( messagesToProcess )
+ if(messagesToProcess)
{
// queueMutex must be locked whilst accessing processQueue or recycleQueue
- MessageQueueMutex::ScopedLock lock( mImpl->queueMutex );
+ MessageQueueMutex::ScopedLock lock(mImpl->queueMutex);
- mImpl->processQueue.push_back( mImpl->currentMessageBuffer );
+ mImpl->processQueue.push_back(mImpl->currentMessageBuffer);
mImpl->currentMessageBuffer = nullptr;
// Grab any recycled MessageBuffers
- while ( !mImpl->recycleQueue.empty() )
+ while(!mImpl->recycleQueue.empty())
{
MessageBuffer* recycled = mImpl->recycleQueue.back();
mImpl->recycleQueue.pop_back();
// Guard against excessive message buffer growth
- if ( MAX_FREE_BUFFER_COUNT < mImpl->freeQueue.size() ||
- MAX_BUFFER_CAPACITY < recycled->GetCapacity() )
+ if(MAX_FREE_BUFFER_COUNT < mImpl->freeQueue.size() ||
+ MAX_BUFFER_CAPACITY < recycled->GetCapacity())
{
delete recycled;
}
else
{
- mImpl->freeQueue.push_back( recycled );
+ mImpl->freeQueue.push_back(recycled);
}
}
- if( mImpl->sceneUpdateFlag )
+ if(mImpl->sceneUpdateFlag)
{
mImpl->sceneUpdate |= 2;
mImpl->sceneUpdateFlag = false;
return messagesToProcess;
}
-bool MessageQueue::ProcessMessages( BufferIndex updateBufferIndex )
+bool MessageQueue::ProcessMessages(BufferIndex updateBufferIndex)
{
PERF_MONITOR_START(PerformanceMonitor::PROCESS_MESSAGES);
// queueMutex must be locked whilst accessing queue
- MessageQueueMutex::ScopedLock lock( mImpl->queueMutex );
+ MessageQueueMutex::ScopedLock lock(mImpl->queueMutex);
const MessageBufferIter processQueueEndIter = mImpl->processQueue.end();
- for ( MessageBufferIter iter = mImpl->processQueue.begin(); iter != processQueueEndIter ; ++iter )
+ for(MessageBufferIter iter = mImpl->processQueue.begin(); iter != processQueueEndIter; ++iter)
{
MessageBuffer* buffer = *iter;
- for( MessageBuffer::Iterator iter = buffer->Begin(); iter.IsValid(); iter.Next() )
+ for(MessageBuffer::Iterator iter = buffer->Begin(); iter.IsValid(); iter.Next())
{
- MessageBase* message = reinterpret_cast< MessageBase* >( iter.Get() );
+ MessageBase* message = reinterpret_cast<MessageBase*>(iter.Get());
- message->Process( updateBufferIndex );
+ message->Process(updateBufferIndex);
// Call virtual destructor explictly; since delete will not be called after placement new
message->~MessageBase();
buffer->Reset();
// Pass back for use in the event-thread
- mImpl->recycleQueue.push_back( buffer );
+ mImpl->recycleQueue.push_back(buffer);
}
mImpl->sceneUpdate >>= 1;
PERF_MONITOR_END(PerformanceMonitor::PROCESS_MESSAGES);
- return ( mImpl->sceneUpdate & 0x01 ); // if it was previously 2, scene graph was updated.
+ return (mImpl->sceneUpdate & 0x01); // if it was previously 2, scene graph was updated.
}
bool MessageQueue::WasEmpty() const
#define DALI_INTERNAL_UPDATE_MESSAGE_QUEUE_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Integration
{
class RenderController;
class SceneGraphBuffers;
}
-
namespace Update
{
-
/**
* Used by UpdateManager to receive messages from the event-thread.
*/
class MessageQueue
{
public:
-
/**
* Create a new UpdateMessageQueue.
* @param[in] renderController After messages are flushed, we request a render from the RenderController.
* @param[in] sceneGraphBuffers Used to keep track of which buffers are being written or read.
*/
- MessageQueue( Integration::RenderController& renderController,
- const SceneGraph::SceneGraphBuffers& sceneGraphBuffers );
+ MessageQueue(Integration::RenderController& renderController,
+ const SceneGraph::SceneGraphBuffers& sceneGraphBuffers);
/**
* Destructor
* @param[in] updateScene If set to true, denotes that the message will cause the scene graph node tree to require an update
* @return A pointer to the first char allocated for the message
*/
- uint32_t* ReserveMessageSlot( uint32_t size, bool updateScene );
+ uint32_t* ReserveMessageSlot(uint32_t size, bool updateScene);
/**
* Flushes the message queue
* @param updateBufferIndex to use
* @return true if the scene graph node tree is updated
*/
- bool ProcessMessages( BufferIndex updateBufferIndex );
+ bool ProcessMessages(BufferIndex updateBufferIndex);
/**
* Query whether the queue was empty this frame.
bool IsSceneUpdateRequired() const;
private:
-
/**
* Helper to call Process and destructor on each queued message
* @param[in] minorQueue The queue to process.
*/
- void ProcessMinorQueue( char* minorQueue );
+ void ProcessMinorQueue(char* minorQueue);
private:
-
// Not copyable:
- MessageQueue() = delete;
- MessageQueue ( const MessageQueue& rhs ) = delete;
- MessageQueue& operator=( const MessageQueue& rhs ) = delete;
+ MessageQueue() = delete;
+ MessageQueue(const MessageQueue& rhs) = delete;
+ MessageQueue& operator=(const MessageQueue& rhs) = delete;
private:
-
struct Impl;
Impl* mImpl;
};
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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/integration-api/debug.h>
+#include <dali/internal/update/nodes/node.h>
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/math/math-utils.h>
-#include <dali/internal/update/nodes/node.h>
namespace // unnamed namespace
{
-const uint32_t UPDATE_COUNT = 2u; // Update projection or view matrix this many frames after a change
+const uint32_t UPDATE_COUNT = 2u; // Update projection or view matrix this many frames after a change
const uint32_t COPY_PREVIOUS_MATRIX = 1u; // Copy view or projection matrix from previous frame
//For reflection and clipping plane
const float REFLECTION_NORMALIZED_DEVICE_COORDINATE_PARAMETER_A = 2.0f;
const float REFLECTION_NORMALIZED_DEVICE_COORDINATE_PARAMETER_D = 1.0f;
-}
+} // namespace
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
namespace
{
-
-template< typename T >
-T Sign( T value )
+template<typename T>
+T Sign(T value)
{
- return T( T(0) < value ) - T( value < T(0) );
+ return T(T(0) < value) - T(value < T(0));
}
void LookAt(Matrix& result, const Vector3& eye, const Vector3& target, const Vector3& up)
void Frustum(Matrix& result, float left, float right, float bottom, float top, float near, float far, bool invertYAxis)
{
float deltaZ = far - near;
- if ((near <= 0.0f) || (far <= 0.0f) || Equals(right, left) || Equals(bottom, top) || (deltaZ <= 0.0f))
+ if((near <= 0.0f) || (far <= 0.0f) || Equals(right, left) || Equals(bottom, top) || (deltaZ <= 0.0f))
{
DALI_LOG_ERROR("Invalid parameters passed into Frustum!\n");
DALI_ASSERT_DEBUG("Invalid parameters passed into Frustum!");
result.SetIdentity();
float* m = result.AsFloat();
- m[0] = -2.0f * near / deltaX;
+ m[0] = -2.0f * near / deltaX;
m[1] = m[2] = m[3] = 0.0f;
m[5] = -2.0f * near / deltaY;
m[4] = m[6] = m[7] = 0.0f;
- m[8] = (right + left) / deltaX;
- m[9] = (top + bottom) / deltaY;
+ m[8] = (right + left) / deltaX;
+ m[9] = (top + bottom) / deltaY;
m[10] = (near + far) / deltaZ;
m[11] = 1.0f;
m[12] = m[13] = m[15] = 0.0f;
}
-void Perspective(Matrix& result, float fovy, float aspect, float near, float far, bool invertYAxis )
+void Perspective(Matrix& result, float fovy, float aspect, float near, float far, bool invertYAxis)
{
- float frustumH = tanf( fovy * 0.5f ) * near;
+ float frustumH = tanf(fovy * 0.5f) * near;
float frustumW = frustumH * aspect;
Frustum(result, -frustumW, frustumW, -frustumH, frustumH, near, far, invertYAxis);
void Orthographic(Matrix& result, float left, float right, float bottom, float top, float near, float far, bool invertYAxis)
{
- if ( Equals(right, left) || Equals(top, bottom) || Equals(far, near) )
+ if(Equals(right, left) || Equals(top, bottom) || Equals(far, near))
{
- DALI_LOG_ERROR( "Cannot create orthographic projection matrix with a zero dimension.\n" );
- DALI_ASSERT_DEBUG( "Cannot create orthographic projection matrix with a zero dimension." );
+ DALI_LOG_ERROR("Cannot create orthographic projection matrix with a zero dimension.\n");
+ DALI_ASSERT_DEBUG("Cannot create orthographic projection matrix with a zero dimension.");
return;
}
float deltaY = invertYAxis ? bottom - top : top - bottom;
float deltaZ = far - near;
- float *m = result.AsFloat();
- m[0] = -2.0f / deltaX;
- m[1] = 0.0f;
- m[2] = 0.0f;
- m[3] = 0.0f;
+ float* m = result.AsFloat();
+ m[0] = -2.0f / deltaX;
+ m[1] = 0.0f;
+ m[2] = 0.0f;
+ m[3] = 0.0f;
m[4] = 0.0f;
m[5] = -2.0f / deltaY;
m[6] = 0.0f;
m[7] = 0.0f;
- m[8] = 0.0f;
- m[9] = 0.0f;
+ m[8] = 0.0f;
+ m[9] = 0.0f;
m[10] = 2.0f / deltaZ;
m[11] = 0.0f;
m[12] = -(right + left) / deltaX;
m[13] = -(top + bottom) / deltaY;
- m[14] = -(near + far) / deltaZ;
+ m[14] = -(near + far) / deltaZ;
m[15] = 1.0f;
}
} // unnamed namespace
-const Dali::Camera::Type Camera::DEFAULT_TYPE( Dali::Camera::FREE_LOOK );
-const Dali::Camera::ProjectionMode Camera::DEFAULT_MODE( Dali::Camera::PERSPECTIVE_PROJECTION );
-const bool Camera::DEFAULT_INVERT_Y_AXIS( false );
-const float Camera::DEFAULT_FIELD_OF_VIEW( 45.0f*(Math::PI/180.0f) );
-const float Camera::DEFAULT_ASPECT_RATIO( 4.0f/3.0f );
-const float Camera::DEFAULT_LEFT_CLIPPING_PLANE(-240.0f);
-const float Camera::DEFAULT_RIGHT_CLIPPING_PLANE(240.0f);
-const float Camera::DEFAULT_TOP_CLIPPING_PLANE(-400.0f);
-const float Camera::DEFAULT_BOTTOM_CLIPPING_PLANE(400.0f);
-const float Camera::DEFAULT_NEAR_CLIPPING_PLANE( 800.0f ); // default height of the screen
-const float Camera::DEFAULT_FAR_CLIPPING_PLANE( DEFAULT_NEAR_CLIPPING_PLANE + 2.f * DEFAULT_NEAR_CLIPPING_PLANE );
-const Vector3 Camera::DEFAULT_TARGET_POSITION( 0.0f, 0.0f, 0.0f );
-
+const Dali::Camera::Type Camera::DEFAULT_TYPE(Dali::Camera::FREE_LOOK);
+const Dali::Camera::ProjectionMode Camera::DEFAULT_MODE(Dali::Camera::PERSPECTIVE_PROJECTION);
+const bool Camera::DEFAULT_INVERT_Y_AXIS(false);
+const float Camera::DEFAULT_FIELD_OF_VIEW(45.0f * (Math::PI / 180.0f));
+const float Camera::DEFAULT_ASPECT_RATIO(4.0f / 3.0f);
+const float Camera::DEFAULT_LEFT_CLIPPING_PLANE(-240.0f);
+const float Camera::DEFAULT_RIGHT_CLIPPING_PLANE(240.0f);
+const float Camera::DEFAULT_TOP_CLIPPING_PLANE(-400.0f);
+const float Camera::DEFAULT_BOTTOM_CLIPPING_PLANE(400.0f);
+const float Camera::DEFAULT_NEAR_CLIPPING_PLANE(800.0f); // default height of the screen
+const float Camera::DEFAULT_FAR_CLIPPING_PLANE(DEFAULT_NEAR_CLIPPING_PLANE + 2.f * DEFAULT_NEAR_CLIPPING_PLANE);
+const Vector3 Camera::DEFAULT_TARGET_POSITION(0.0f, 0.0f, 0.0f);
Camera::Camera()
-: mUpdateViewFlag( UPDATE_COUNT ),
- mUpdateProjectionFlag( UPDATE_COUNT ),
+: mUpdateViewFlag(UPDATE_COUNT),
+ mUpdateProjectionFlag(UPDATE_COUNT),
mProjectionRotation(0),
- mNode( nullptr ),
- mType( DEFAULT_TYPE ),
- mProjectionMode( DEFAULT_MODE ),
- mInvertYAxis( DEFAULT_INVERT_Y_AXIS ),
- mFieldOfView( DEFAULT_FIELD_OF_VIEW ),
- mAspectRatio( DEFAULT_ASPECT_RATIO ),
- mLeftClippingPlane( DEFAULT_LEFT_CLIPPING_PLANE ),
- mRightClippingPlane( DEFAULT_RIGHT_CLIPPING_PLANE ),
- mTopClippingPlane( DEFAULT_TOP_CLIPPING_PLANE ),
- mBottomClippingPlane( DEFAULT_BOTTOM_CLIPPING_PLANE ),
- mNearClippingPlane( DEFAULT_NEAR_CLIPPING_PLANE ),
- mFarClippingPlane( DEFAULT_FAR_CLIPPING_PLANE ),
- mTargetPosition( DEFAULT_TARGET_POSITION ),
+ mNode(nullptr),
+ mType(DEFAULT_TYPE),
+ mProjectionMode(DEFAULT_MODE),
+ mInvertYAxis(DEFAULT_INVERT_Y_AXIS),
+ mFieldOfView(DEFAULT_FIELD_OF_VIEW),
+ mAspectRatio(DEFAULT_ASPECT_RATIO),
+ mLeftClippingPlane(DEFAULT_LEFT_CLIPPING_PLANE),
+ mRightClippingPlane(DEFAULT_RIGHT_CLIPPING_PLANE),
+ mTopClippingPlane(DEFAULT_TOP_CLIPPING_PLANE),
+ mBottomClippingPlane(DEFAULT_BOTTOM_CLIPPING_PLANE),
+ mNearClippingPlane(DEFAULT_NEAR_CLIPPING_PLANE),
+ mFarClippingPlane(DEFAULT_FAR_CLIPPING_PLANE),
+ mTargetPosition(DEFAULT_TARGET_POSITION),
mViewMatrix(),
mProjectionMatrix(),
- mInverseViewProjection( Matrix::IDENTITY ),
+ mInverseViewProjection(Matrix::IDENTITY),
mFinalProjection(Matrix::IDENTITY)
{
}
Camera::~Camera() = default;
-void Camera::SetNode( const Node* node )
+void Camera::SetNode(const Node* node)
{
mNode = node;
}
return mNode;
}
-void Camera::SetType( Dali::Camera::Type type )
+void Camera::SetType(Dali::Camera::Type type)
{
mType = type;
}
-void Camera::SetProjectionMode( Dali::Camera::ProjectionMode mode )
+void Camera::SetProjectionMode(Dali::Camera::ProjectionMode mode)
{
- mProjectionMode = mode;
+ mProjectionMode = mode;
mUpdateProjectionFlag = UPDATE_COUNT;
}
-void Camera::SetInvertYAxis( bool invertYAxis )
+void Camera::SetInvertYAxis(bool invertYAxis)
{
- mInvertYAxis = invertYAxis;
+ mInvertYAxis = invertYAxis;
mUpdateProjectionFlag = UPDATE_COUNT;
}
-void Camera::SetFieldOfView( float fieldOfView )
+void Camera::SetFieldOfView(float fieldOfView)
{
- mFieldOfView = fieldOfView;
+ mFieldOfView = fieldOfView;
mUpdateProjectionFlag = UPDATE_COUNT;
}
-void Camera::SetAspectRatio( float aspectRatio )
+void Camera::SetAspectRatio(float aspectRatio)
{
- mAspectRatio = aspectRatio;
+ mAspectRatio = aspectRatio;
mUpdateProjectionFlag = UPDATE_COUNT;
}
-void Camera::SetLeftClippingPlane( float leftClippingPlane )
+void Camera::SetLeftClippingPlane(float leftClippingPlane)
{
- mLeftClippingPlane = leftClippingPlane;
+ mLeftClippingPlane = leftClippingPlane;
mUpdateProjectionFlag = UPDATE_COUNT;
}
-void Camera::SetRightClippingPlane( float rightClippingPlane )
+void Camera::SetRightClippingPlane(float rightClippingPlane)
{
- mRightClippingPlane = rightClippingPlane;
+ mRightClippingPlane = rightClippingPlane;
mUpdateProjectionFlag = UPDATE_COUNT;
}
-void Camera::SetTopClippingPlane( float topClippingPlane )
+void Camera::SetTopClippingPlane(float topClippingPlane)
{
- mTopClippingPlane = topClippingPlane;
+ mTopClippingPlane = topClippingPlane;
mUpdateProjectionFlag = UPDATE_COUNT;
}
-void Camera::SetBottomClippingPlane( float bottomClippingPlane )
+void Camera::SetBottomClippingPlane(float bottomClippingPlane)
{
- mBottomClippingPlane = bottomClippingPlane;
+ mBottomClippingPlane = bottomClippingPlane;
mUpdateProjectionFlag = UPDATE_COUNT;
}
-void Camera::SetNearClippingPlane( float nearClippingPlane )
+void Camera::SetNearClippingPlane(float nearClippingPlane)
{
- mNearClippingPlane = nearClippingPlane;
+ mNearClippingPlane = nearClippingPlane;
mUpdateProjectionFlag = UPDATE_COUNT;
}
-void Camera::SetFarClippingPlane( float farClippingPlane )
+void Camera::SetFarClippingPlane(float farClippingPlane)
{
- mFarClippingPlane = farClippingPlane;
+ mFarClippingPlane = farClippingPlane;
mUpdateProjectionFlag = UPDATE_COUNT;
}
-void Camera::SetTargetPosition( const Vector3& targetPosition )
+void Camera::SetTargetPosition(const Vector3& targetPosition)
{
mTargetPosition = targetPosition;
mUpdateViewFlag = UPDATE_COUNT;
}
-void VectorReflectedByPlane(Vector4 &out, Vector4 &in, Vector4 &plane)
+void VectorReflectedByPlane(Vector4& out, Vector4& in, Vector4& plane)
{
float d = float(2.0) * plane.Dot(in);
- out.x = static_cast<float>(in.x - plane.x*d);
- out.y = static_cast<float>(in.y - plane.y*d);
- out.z = static_cast<float>(in.z - plane.z*d);
- out.w = static_cast<float>(in.w - plane.w*d);
+ out.x = static_cast<float>(in.x - plane.x * d);
+ out.y = static_cast<float>(in.y - plane.y * d);
+ out.z = static_cast<float>(in.z - plane.z * d);
+ out.w = static_cast<float>(in.w - plane.w * d);
}
-void Camera::AdjustNearPlaneForPerspective( Matrix& perspective, const Vector4& clipPlane )
+void Camera::AdjustNearPlaneForPerspective(Matrix& perspective, const Vector4& clipPlane)
{
- Vector4 q;
- float* v = perspective.AsFloat();
+ Vector4 q;
+ float* v = perspective.AsFloat();
q.x = (Sign(clipPlane.x) + v[8]) / v[0];
q.y = (Sign(clipPlane.y) + v[9]) / v[5];
q.w = (1.0f + v[10]) / v[14];
// Calculate the scaled plane vector
- Vector4 c = clipPlane * (REFLECTION_NORMALIZED_DEVICE_COORDINATE_PARAMETER_A / q.Dot( clipPlane));
+ Vector4 c = clipPlane * (REFLECTION_NORMALIZED_DEVICE_COORDINATE_PARAMETER_A / q.Dot(clipPlane));
// Replace the third row of the projection v
- v[2] = c.x;
- v[6] = c.y;
+ v[2] = c.x;
+ v[6] = c.y;
v[10] = c.z + REFLECTION_NORMALIZED_DEVICE_COORDINATE_PARAMETER_D;
v[14] = c.w;
}
-void Camera::SetReflectByPlane( const Vector4& plane )
+void Camera::SetReflectByPlane(const Vector4& plane)
{
- float* v = mReflectionMtx.AsFloat();
- float _2ab = -2.0f * plane.x * plane.y;
- float _2ac = -2.0f * plane.x * plane.z;
- float _2bc = -2.0f * plane.y * plane.z;
+ float* v = mReflectionMtx.AsFloat();
+ float _2ab = -2.0f * plane.x * plane.y;
+ float _2ac = -2.0f * plane.x * plane.z;
+ float _2bc = -2.0f * plane.y * plane.z;
v[0] = 1.0f - 2.0f * plane.x * plane.x;
v[1] = _2ab;
v[6] = _2bc;
v[7] = 0.0f;
- v[8] = _2ac;
- v[9] = _2bc;
+ v[8] = _2ac;
+ v[9] = _2bc;
v[10] = 1.0f - 2.0f * plane.z * plane.z;
v[11] = 0.0f;
- v[12] = - 2 * plane.x * plane.w;
- v[13] = - 2 * plane.y * plane.w;
- v[14] = - 2 * plane.z * plane.w;
+ v[12] = -2 * plane.x * plane.w;
+ v[13] = -2 * plane.y * plane.w;
+ v[14] = -2 * plane.z * plane.w;
v[15] = 1.0f;
- mUseReflection = true;
+ mUseReflection = true;
mReflectionPlane = plane;
- mUpdateViewFlag = UPDATE_COUNT;
+ mUpdateViewFlag = UPDATE_COUNT;
}
void Camera::RotateProjection(int rotationAngle)
mUpdateViewFlag = UPDATE_COUNT;
}
-const Matrix& Camera::GetProjectionMatrix( BufferIndex bufferIndex ) const
+const Matrix& Camera::GetProjectionMatrix(BufferIndex bufferIndex) const
{
- return mProjectionMatrix[ bufferIndex ];
+ return mProjectionMatrix[bufferIndex];
}
-const Matrix& Camera::GetViewMatrix( BufferIndex bufferIndex ) const
+const Matrix& Camera::GetViewMatrix(BufferIndex bufferIndex) const
{
- return mViewMatrix[ bufferIndex ];
+ return mViewMatrix[bufferIndex];
}
-const Matrix& Camera::GetInverseViewProjectionMatrix( BufferIndex bufferIndex ) const
+const Matrix& Camera::GetInverseViewProjectionMatrix(BufferIndex bufferIndex) const
{
- return mInverseViewProjection[ bufferIndex ];
+ return mInverseViewProjection[bufferIndex];
}
const Matrix& Camera::GetFinalProjectionMatrix(BufferIndex bufferIndex) const
{
- return mFinalProjection[ bufferIndex ];
+ return mFinalProjection[bufferIndex];
}
const PropertyInputImpl* Camera::GetProjectionMatrix() const
return &mViewMatrix;
}
-void Camera::Update( BufferIndex updateBufferIndex )
+void Camera::Update(BufferIndex updateBufferIndex)
{
// if owning node has changes in world position we need to update camera for next 2 frames
- if( mNode->IsLocalMatrixDirty() )
+ if(mNode->IsLocalMatrixDirty())
{
mUpdateViewFlag = UPDATE_COUNT;
}
- if( mNode->GetDirtyFlags() & NodePropertyFlags::VISIBLE )
+ if(mNode->GetDirtyFlags() & NodePropertyFlags::VISIBLE)
{
// If the visibility changes, the projection matrix needs to be re-calculated.
// It may happen the first time an actor is rendered it's rendered only once and becomes invisible,
}
// if either matrix changed, we need to recalculate the inverse matrix for hit testing to work
- uint32_t viewUpdateCount = UpdateViewMatrix( updateBufferIndex );
- uint32_t projectionUpdateCount = UpdateProjection( updateBufferIndex );
+ uint32_t viewUpdateCount = UpdateViewMatrix(updateBufferIndex);
+ uint32_t projectionUpdateCount = UpdateProjection(updateBufferIndex);
// if model or view matrix changed we need to either recalculate the inverse VP or copy previous
- if( viewUpdateCount > COPY_PREVIOUS_MATRIX || projectionUpdateCount > COPY_PREVIOUS_MATRIX )
+ if(viewUpdateCount > COPY_PREVIOUS_MATRIX || projectionUpdateCount > COPY_PREVIOUS_MATRIX)
{
// either has actually changed so recalculate
- Matrix::Multiply( mInverseViewProjection[ updateBufferIndex ], mViewMatrix[ updateBufferIndex ], mProjectionMatrix[ updateBufferIndex ] );
- UpdateFrustum( updateBufferIndex );
+ Matrix::Multiply(mInverseViewProjection[updateBufferIndex], mViewMatrix[updateBufferIndex], mProjectionMatrix[updateBufferIndex]);
+ UpdateFrustum(updateBufferIndex);
// ignore the error, if the view projection is incorrect (non inversible) then you will have tough times anyways
- static_cast< void >( mInverseViewProjection[ updateBufferIndex ].Invert() );
+ static_cast<void>(mInverseViewProjection[updateBufferIndex].Invert());
}
- else if( viewUpdateCount == COPY_PREVIOUS_MATRIX || projectionUpdateCount == COPY_PREVIOUS_MATRIX )
+ else if(viewUpdateCount == COPY_PREVIOUS_MATRIX || projectionUpdateCount == COPY_PREVIOUS_MATRIX)
{
// neither has actually changed, but we might copied previous frames value so need to
// copy the previous inverse and frustum as well
mInverseViewProjection[updateBufferIndex] = mInverseViewProjection[updateBufferIndex ? 0 : 1];
- mFrustum[ updateBufferIndex ] = mFrustum[ updateBufferIndex ? 0 : 1 ];
+ mFrustum[updateBufferIndex] = mFrustum[updateBufferIndex ? 0 : 1];
}
}
return 0u != mUpdateViewFlag;
}
-uint32_t Camera::UpdateViewMatrix( BufferIndex updateBufferIndex )
+uint32_t Camera::UpdateViewMatrix(BufferIndex updateBufferIndex)
{
- uint32_t retval( mUpdateViewFlag );
- if( 0u != mUpdateViewFlag )
+ uint32_t retval(mUpdateViewFlag);
+ if(0u != mUpdateViewFlag)
{
- if( COPY_PREVIOUS_MATRIX == mUpdateViewFlag )
+ if(COPY_PREVIOUS_MATRIX == mUpdateViewFlag)
{
// The projection matrix was updated in the previous frame; copy it
- mViewMatrix.CopyPrevious( updateBufferIndex );
+ mViewMatrix.CopyPrevious(updateBufferIndex);
}
else // UPDATE_COUNT == mUpdateViewFlag
{
- switch( mType )
+ switch(mType)
{
// camera orientation taken from node - i.e. look in abitrary, unconstrained direction
case Dali::Camera::FREE_LOOK:
{
- Matrix& viewMatrix = mViewMatrix.Get( updateBufferIndex );
- viewMatrix = mNode->GetWorldMatrix( updateBufferIndex );
+ Matrix& viewMatrix = mViewMatrix.Get(updateBufferIndex);
+ viewMatrix = mNode->GetWorldMatrix(updateBufferIndex);
- if (mUseReflection)
+ if(mUseReflection)
{
- const Matrix& owningNodeMatrix( mNode->GetWorldMatrix( updateBufferIndex ) );
- Vector3 position{}, scale{};
- Quaternion orientation{};
- owningNodeMatrix.GetTransformComponents( position, orientation, scale );
- mReflectionEye = position;
+ const Matrix& owningNodeMatrix(mNode->GetWorldMatrix(updateBufferIndex));
+ Vector3 position{}, scale{};
+ Quaternion orientation{};
+ owningNodeMatrix.GetTransformComponents(position, orientation, scale);
+ mReflectionEye = position;
mUseReflectionClip = true;
- Matrix& viewMatrix = mViewMatrix.Get( updateBufferIndex );
- Matrix oldViewMatrix( viewMatrix );
+ Matrix& viewMatrix = mViewMatrix.Get(updateBufferIndex);
+ Matrix oldViewMatrix(viewMatrix);
Matrix::Multiply(viewMatrix, oldViewMatrix, mReflectionMtx);
}
viewMatrix.Invert();
- mViewMatrix.SetDirty( updateBufferIndex );
+ mViewMatrix.SetDirty(updateBufferIndex);
break;
}
// camera orientation constrained to look at a target
case Dali::Camera::LOOK_AT_TARGET:
{
- const Matrix& owningNodeMatrix( mNode->GetWorldMatrix( updateBufferIndex ) );
- Vector3 position, scale;
- Quaternion orientation;
- owningNodeMatrix.GetTransformComponents( position, orientation, scale );
- Matrix& viewMatrix = mViewMatrix.Get( updateBufferIndex );
+ const Matrix& owningNodeMatrix(mNode->GetWorldMatrix(updateBufferIndex));
+ Vector3 position, scale;
+ Quaternion orientation;
+ owningNodeMatrix.GetTransformComponents(position, orientation, scale);
+ Matrix& viewMatrix = mViewMatrix.Get(updateBufferIndex);
- if (mUseReflection)
+ if(mUseReflection)
{
- Vector3 up = orientation.Rotate( Vector3::YAXIS );
+ Vector3 up = orientation.Rotate(Vector3::YAXIS);
Vector4 position4 = Vector4(position);
- Vector4 target4 = Vector4(mTargetPosition);
- Vector4 up4 = Vector4(up);
+ Vector4 target4 = Vector4(mTargetPosition);
+ Vector4 up4 = Vector4(up);
Vector4 positionNew;
Vector4 targetNew;
Vector4 upNew;
positionNew3 = Vector3(positionNew);
targetNewVector3 = Vector3(targetNew);
upNew3 = Vector3(upNew);
- LookAt(viewMatrix, positionNew3, targetNewVector3, upNew3 );
+ LookAt(viewMatrix, positionNew3, targetNewVector3, upNew3);
- Matrix oldViewMatrix( viewMatrix );
+ Matrix oldViewMatrix(viewMatrix);
Matrix tmp;
- tmp.SetIdentityAndScale(Vector3(-1.0, 1.0,1.0));
+ tmp.SetIdentityAndScale(Vector3(-1.0, 1.0, 1.0));
Matrix::Multiply(viewMatrix, oldViewMatrix, tmp);
- mReflectionEye = positionNew;
+ mReflectionEye = positionNew;
mUseReflectionClip = true;
}
else
{
- LookAt( viewMatrix, position, mTargetPosition, orientation.Rotate( Vector3::YAXIS ) );
+ LookAt(viewMatrix, position, mTargetPosition, orientation.Rotate(Vector3::YAXIS));
}
- mViewMatrix.SetDirty( updateBufferIndex );
+ mViewMatrix.SetDirty(updateBufferIndex);
break;
}
}
return retval;
}
-void Camera::UpdateFrustum( BufferIndex updateBufferIndex, bool normalize )
+void Camera::UpdateFrustum(BufferIndex updateBufferIndex, bool normalize)
{
-
// Extract the clip matrix planes
Matrix clipMatrix;
- Matrix::Multiply( clipMatrix, mViewMatrix[ updateBufferIndex ], mProjectionMatrix[ updateBufferIndex ] );
+ Matrix::Multiply(clipMatrix, mViewMatrix[updateBufferIndex], mProjectionMatrix[updateBufferIndex]);
- const float* cm = clipMatrix.AsFloat();
- FrustumPlanes& planes = mFrustum[ updateBufferIndex ];
+ const float* cm = clipMatrix.AsFloat();
+ FrustumPlanes& planes = mFrustum[updateBufferIndex];
// Left
- planes.mPlanes[ 0 ].mNormal.x = cm[ 3 ] + cm[ 0 ]; // column 4 + column 1
- planes.mPlanes[ 0 ].mNormal.y = cm[ 7 ] + cm[ 4 ];
- planes.mPlanes[ 0 ].mNormal.z = cm[ 11 ] + cm[ 8 ];
- planes.mPlanes[ 0 ].mDistance = cm[ 15 ] + cm[ 12 ];
+ planes.mPlanes[0].mNormal.x = cm[3] + cm[0]; // column 4 + column 1
+ planes.mPlanes[0].mNormal.y = cm[7] + cm[4];
+ planes.mPlanes[0].mNormal.z = cm[11] + cm[8];
+ planes.mPlanes[0].mDistance = cm[15] + cm[12];
// Right
- planes.mPlanes[ 1 ].mNormal.x = cm[ 3 ] - cm[ 0 ]; // column 4 - column 1
- planes.mPlanes[ 1 ].mNormal.y = cm[ 7 ] - cm[ 4 ];
- planes.mPlanes[ 1 ].mNormal.z = cm[ 11 ] - cm[ 8 ];
- planes.mPlanes[ 1 ].mDistance = cm[ 15 ] - cm[ 12 ];
+ planes.mPlanes[1].mNormal.x = cm[3] - cm[0]; // column 4 - column 1
+ planes.mPlanes[1].mNormal.y = cm[7] - cm[4];
+ planes.mPlanes[1].mNormal.z = cm[11] - cm[8];
+ planes.mPlanes[1].mDistance = cm[15] - cm[12];
// Bottom
- planes.mPlanes[ 2 ].mNormal.x = cm[ 3 ] + cm[ 1 ]; // column 4 + column 2
- planes.mPlanes[ 2 ].mNormal.y = cm[ 7 ] + cm[ 5 ];
- planes.mPlanes[ 2 ].mNormal.z = cm[ 11 ] + cm[ 9 ];
- planes.mPlanes[ 2 ].mDistance = cm[ 15 ] + cm[ 13 ];
+ planes.mPlanes[2].mNormal.x = cm[3] + cm[1]; // column 4 + column 2
+ planes.mPlanes[2].mNormal.y = cm[7] + cm[5];
+ planes.mPlanes[2].mNormal.z = cm[11] + cm[9];
+ planes.mPlanes[2].mDistance = cm[15] + cm[13];
// Top
- planes.mPlanes[ 3 ].mNormal.x = cm[ 3 ] - cm[ 1 ]; // column 4 - column 2
- planes.mPlanes[ 3 ].mNormal.y = cm[ 7 ] - cm[ 5 ];
- planes.mPlanes[ 3 ].mNormal.z = cm[ 11 ] - cm[ 9 ];
- planes.mPlanes[ 3 ].mDistance = cm[ 15 ] - cm[ 13 ];
+ planes.mPlanes[3].mNormal.x = cm[3] - cm[1]; // column 4 - column 2
+ planes.mPlanes[3].mNormal.y = cm[7] - cm[5];
+ planes.mPlanes[3].mNormal.z = cm[11] - cm[9];
+ planes.mPlanes[3].mDistance = cm[15] - cm[13];
// Near
- planes.mPlanes[ 4 ].mNormal.x = cm[ 3 ] + cm[ 2 ]; // column 4 + column 3
- planes.mPlanes[ 4 ].mNormal.y = cm[ 7 ] + cm[ 6 ];
- planes.mPlanes[ 4 ].mNormal.z = cm[ 11 ] + cm[ 10 ];
- planes.mPlanes[ 4 ].mDistance = cm[ 15 ] + cm[ 14 ];
+ planes.mPlanes[4].mNormal.x = cm[3] + cm[2]; // column 4 + column 3
+ planes.mPlanes[4].mNormal.y = cm[7] + cm[6];
+ planes.mPlanes[4].mNormal.z = cm[11] + cm[10];
+ planes.mPlanes[4].mDistance = cm[15] + cm[14];
// Far
- planes.mPlanes[ 5 ].mNormal.x = cm[ 3 ] - cm[ 2 ]; // column 4 - column 3
- planes.mPlanes[ 5 ].mNormal.y = cm[ 7 ] - cm[ 6 ];
- planes.mPlanes[ 5 ].mNormal.z = cm[ 11 ] - cm[ 10 ];
- planes.mPlanes[ 5 ].mDistance = cm[ 15 ] - cm[ 14 ];
+ planes.mPlanes[5].mNormal.x = cm[3] - cm[2]; // column 4 - column 3
+ planes.mPlanes[5].mNormal.y = cm[7] - cm[6];
+ planes.mPlanes[5].mNormal.z = cm[11] - cm[10];
+ planes.mPlanes[5].mDistance = cm[15] - cm[14];
- if ( normalize )
+ if(normalize)
{
- for ( uint32_t i = 0; i < 6; ++i )
+ for(uint32_t i = 0; i < 6; ++i)
{
// Normalize planes to ensure correct bounding distance checking
- Plane& plane = planes.mPlanes[ i ];
- float l = 1.0f / plane.mNormal.Length();
+ Plane& plane = planes.mPlanes[i];
+ float l = 1.0f / plane.mNormal.Length();
plane.mNormal *= l;
plane.mDistance *= l;
- planes.mSign[i] = Vector3( Sign(plane.mNormal.x), Sign(plane.mNormal.y), Sign(plane.mNormal.z) );
+ planes.mSign[i] = Vector3(Sign(plane.mNormal.x), Sign(plane.mNormal.y), Sign(plane.mNormal.z));
}
}
else
{
- for ( uint32_t i = 0; i < 6; ++i )
+ for(uint32_t i = 0; i < 6; ++i)
{
- planes.mSign[i] = Vector3( Sign(planes.mPlanes[ i ].mNormal.x), Sign(planes.mPlanes[ i ].mNormal.y), Sign(planes.mPlanes[ i ].mNormal.z) );
+ planes.mSign[i] = Vector3(Sign(planes.mPlanes[i].mNormal.x), Sign(planes.mPlanes[i].mNormal.y), Sign(planes.mPlanes[i].mNormal.z));
}
}
- mFrustum[ updateBufferIndex ? 0 : 1 ] = planes;
+ mFrustum[updateBufferIndex ? 0 : 1] = planes;
}
-bool Camera::CheckSphereInFrustum( BufferIndex bufferIndex, const Vector3& origin, float radius )
+bool Camera::CheckSphereInFrustum(BufferIndex bufferIndex, const Vector3& origin, float radius)
{
- const FrustumPlanes& planes = mFrustum[ bufferIndex ];
- for ( uint32_t i = 0; i < 6; ++i )
+ const FrustumPlanes& planes = mFrustum[bufferIndex];
+ for(uint32_t i = 0; i < 6; ++i)
{
- if ( ( planes.mPlanes[ i ].mDistance + planes.mPlanes[ i ].mNormal.Dot( origin ) ) < -radius )
+ if((planes.mPlanes[i].mDistance + planes.mPlanes[i].mNormal.Dot(origin)) < -radius)
{
return false;
}
return true;
}
-bool Camera::CheckAABBInFrustum( BufferIndex bufferIndex, const Vector3& origin, const Vector3& halfExtents )
+bool Camera::CheckAABBInFrustum(BufferIndex bufferIndex, const Vector3& origin, const Vector3& halfExtents)
{
- const FrustumPlanes& planes = mFrustum[ bufferIndex ];
- for ( uint32_t i = 0; i < 6; ++i )
+ const FrustumPlanes& planes = mFrustum[bufferIndex];
+ for(uint32_t i = 0; i < 6; ++i)
{
- if( planes.mPlanes[ i ].mNormal.Dot( origin + (halfExtents * planes.mSign[i]) ) > -(planes.mPlanes[ i ].mDistance) )
+ if(planes.mPlanes[i].mNormal.Dot(origin + (halfExtents * planes.mSign[i])) > -(planes.mPlanes[i].mDistance))
{
continue;
}
return true;
}
-uint32_t Camera::UpdateProjection( BufferIndex updateBufferIndex )
+uint32_t Camera::UpdateProjection(BufferIndex updateBufferIndex)
{
- uint32_t retval( mUpdateProjectionFlag );
+ uint32_t retval(mUpdateProjectionFlag);
// Early-exit if no update required
- if ( 0u != mUpdateProjectionFlag )
+ if(0u != mUpdateProjectionFlag)
{
- if ( COPY_PREVIOUS_MATRIX == mUpdateProjectionFlag )
+ if(COPY_PREVIOUS_MATRIX == mUpdateProjectionFlag)
{
// The projection matrix was updated in the previous frame; copy it
- mProjectionMatrix.CopyPrevious( updateBufferIndex );
+ mProjectionMatrix.CopyPrevious(updateBufferIndex);
}
else // UPDATE_COUNT == mUpdateProjectionFlag
{
- switch( mProjectionMode )
+ switch(mProjectionMode)
{
case Dali::Camera::PERSPECTIVE_PROJECTION:
{
- Matrix &projectionMatrix = mProjectionMatrix.Get( updateBufferIndex );
- Perspective( projectionMatrix,
- mFieldOfView,
- mAspectRatio,
- mNearClippingPlane,
- mFarClippingPlane,
- mInvertYAxis );
+ Matrix& projectionMatrix = mProjectionMatrix.Get(updateBufferIndex);
+ Perspective(projectionMatrix,
+ mFieldOfView,
+ mAspectRatio,
+ mNearClippingPlane,
+ mFarClippingPlane,
+ mInvertYAxis);
//need to apply custom clipping plane
- if (mUseReflectionClip)
+ if(mUseReflectionClip)
{
- Matrix& viewMatrix = mViewMatrix.Get( updateBufferIndex );
- Matrix viewInv = viewMatrix;
+ Matrix& viewMatrix = mViewMatrix.Get(updateBufferIndex);
+ Matrix viewInv = viewMatrix;
viewInv.Invert();
viewInv.Transpose();
Dali::Vector4 adjReflectPlane = mReflectionPlane;
- float d = mReflectionPlane.Dot(mReflectionEye);
- if (d < 0)
+ float d = mReflectionPlane.Dot(mReflectionEye);
+ if(d < 0)
{
adjReflectPlane.w = -adjReflectPlane.w;
}
Matrix matZ;
matZ.SetIdentity();
float* vZ = matZ.AsFloat();
- vZ[10] = -vZ[10];
- Matrix::Multiply(projectionMatrix, projectionMatrix , matZ);
+ vZ[10] = -vZ[10];
+ Matrix::Multiply(projectionMatrix, projectionMatrix, matZ);
}
break;
}
case Dali::Camera::ORTHOGRAPHIC_PROJECTION:
{
- Matrix &projectionMatrix = mProjectionMatrix.Get( updateBufferIndex );
- Orthographic( projectionMatrix,
- mLeftClippingPlane, mRightClippingPlane,
- mBottomClippingPlane, mTopClippingPlane,
- mNearClippingPlane, mFarClippingPlane,
- mInvertYAxis );
+ Matrix& projectionMatrix = mProjectionMatrix.Get(updateBufferIndex);
+ Orthographic(projectionMatrix,
+ mLeftClippingPlane,
+ mRightClippingPlane,
+ mBottomClippingPlane,
+ mTopClippingPlane,
+ mNearClippingPlane,
+ mFarClippingPlane,
+ mInvertYAxis);
break;
}
}
#define DALI_INTERNAL_SCENE_GRAPH_CAMERA_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/actors/camera-actor.h>
#include <dali/internal/common/message.h>
#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/update/common/double-buffered.h>
#include <dali/internal/update/common/inherited-property.h>
+#include <dali/public-api/actors/camera-actor.h>
+#include <dali/public-api/math/rect.h>
namespace Dali
{
-
namespace Internal
{
-
// value types used by messages
-template <> struct ParameterType< Dali::Camera::Type >
-: public BasicType< Dali::Camera::Type > {};
-template <> struct ParameterType< Dali::Camera::ProjectionMode >
-: public BasicType< Dali::Camera::ProjectionMode > {};
+template<>
+struct ParameterType<Dali::Camera::Type>
+: public BasicType<Dali::Camera::Type>
+{
+};
+template<>
+struct ParameterType<Dali::Camera::ProjectionMode>
+: public BasicType<Dali::Camera::ProjectionMode>
+{
+};
namespace SceneGraph
{
-
class Node;
class SceneController;
class Camera
{
public:
- static const Dali::Camera::Type DEFAULT_TYPE;
+ static const Dali::Camera::Type DEFAULT_TYPE;
static const Dali::Camera::ProjectionMode DEFAULT_MODE;
- static const bool DEFAULT_INVERT_Y_AXIS;
- static const float DEFAULT_FIELD_OF_VIEW;
- static const float DEFAULT_ASPECT_RATIO;
- static const float DEFAULT_LEFT_CLIPPING_PLANE;
- static const float DEFAULT_RIGHT_CLIPPING_PLANE;
- static const float DEFAULT_TOP_CLIPPING_PLANE;
- static const float DEFAULT_BOTTOM_CLIPPING_PLANE;
- static const float DEFAULT_NEAR_CLIPPING_PLANE;
- static const float DEFAULT_FAR_CLIPPING_PLANE;
- static const Vector2 DEFAULT_STEREO_BIAS;
- static const Vector3 DEFAULT_TARGET_POSITION;
+ static const bool DEFAULT_INVERT_Y_AXIS;
+ static const float DEFAULT_FIELD_OF_VIEW;
+ static const float DEFAULT_ASPECT_RATIO;
+ static const float DEFAULT_LEFT_CLIPPING_PLANE;
+ static const float DEFAULT_RIGHT_CLIPPING_PLANE;
+ static const float DEFAULT_TOP_CLIPPING_PLANE;
+ static const float DEFAULT_BOTTOM_CLIPPING_PLANE;
+ static const float DEFAULT_NEAR_CLIPPING_PLANE;
+ static const float DEFAULT_FAR_CLIPPING_PLANE;
+ static const Vector2 DEFAULT_STEREO_BIAS;
+ static const Vector3 DEFAULT_TARGET_POSITION;
/**
* Plane equation container for a plane of the view frustum
struct Plane
{
Vector3 mNormal;
- float mDistance;
+ float mDistance;
};
/**
*/
struct FrustumPlanes
{
- Plane mPlanes[ 6 ];
- Vector3 mSign[ 6 ];
+ Plane mPlanes[6];
+ Vector3 mSign[6];
};
/**
* Set the node this scene graph camera belongs to.
* @param[in] node The owning node.
*/
- void SetNode( const Node* node );
+ void SetNode(const Node* node);
/**
* Get the node this scene graph camera belongs to.
/**
* @copydoc Dali::Internal::CameraActor::SetType
*/
- void SetType( Dali::Camera::Type type );
+ void SetType(Dali::Camera::Type type);
/**
* @copydoc Dali::Internal::CameraActor::SetInvertYAxis
*/
- void SetInvertYAxis( bool invertYAxis );
+ void SetInvertYAxis(bool invertYAxis);
/**
* Returns whether the Y axis is inverted.
/**
* @copydoc Dali::Internal::CameraActor::SetProjectionMode
*/
- void SetProjectionMode( Dali::Camera::ProjectionMode projectionMode );
+ void SetProjectionMode(Dali::Camera::ProjectionMode projectionMode);
/**
* @copydoc Dali::Internal::CameraActor::SetFieldOfView
*/
- void SetFieldOfView( float fieldOfView );
+ void SetFieldOfView(float fieldOfView);
/**
* @copydoc Dali::Internal::CameraActor::SetAspectRatio
*/
- void SetAspectRatio( float aspectRatio );
+ void SetAspectRatio(float aspectRatio);
- /**
+ /**
* @copydoc Dali::Internal::CameraActor::SetLeftClippingPlane
*/
- void SetLeftClippingPlane( float leftClippingPlane );
+ void SetLeftClippingPlane(float leftClippingPlane);
/**
* @copydoc Dali::Internal::CameraActor::SetRightClippingPlane
*/
- void SetRightClippingPlane( float rightClippingPlane );
+ void SetRightClippingPlane(float rightClippingPlane);
/**
* @copydoc Dali::Internal::CameraActor::SetTopClippingPlane
*/
- void SetTopClippingPlane( float topClippingPlane );
+ void SetTopClippingPlane(float topClippingPlane);
/**
* @copydoc Dali::Internal::CameraActor::SetBottomClippingPlane
*/
- void SetBottomClippingPlane( float bottomClippingPlane );
+ void SetBottomClippingPlane(float bottomClippingPlane);
/**
* @copydoc Dali::Internal::CameraActor::SetNearClippingPlane
*/
- void SetNearClippingPlane( float nearClippingPlane );
+ void SetNearClippingPlane(float nearClippingPlane);
/**
* @copydoc Dali::Internal::CameraActor::SetFarClippingPlane
*/
- void SetFarClippingPlane( float farClippingPlane );
+ void SetFarClippingPlane(float farClippingPlane);
/**
* @copydoc Dali::Internal::CameraActor::RotateProjection
/**
* @copydoc Dali::Internal::CameraActor::SetTarget
*/
- void SetTargetPosition( const Vector3& targetPosition );
+ void SetTargetPosition(const Vector3& targetPosition);
/**
* Sets the reflection plane
* @param[in] plane reflection plane
*/
- void SetReflectByPlane( const Vector4& plane );
+ void SetReflectByPlane(const Vector4& plane);
/**
* Tests whether reflection is used
* @param[in] bufferIndex The buffer to read from.
* @return The view-matrix.
*/
- const Matrix& GetViewMatrix( BufferIndex bufferIndex ) const;
+ const Matrix& GetViewMatrix(BufferIndex bufferIndex) const;
/**
* @brief Check to see if a sphere lies within the view frustum.
*
* @return false if the sphere lies outside of the frustum.
*/
- bool CheckSphereInFrustum( BufferIndex bufferIndex, const Vector3& origin, float radius );
+ bool CheckSphereInFrustum(BufferIndex bufferIndex, const Vector3& origin, float radius);
/**
* @brief Check to see if a bounding box lies within the view frustum.
*
* @return false if the cubeoid lies completely outside of the frustum, true otherwise
*/
- bool CheckAABBInFrustum( BufferIndex bufferIndex, const Vector3& origin, const Vector3& halfExtents );
+ bool CheckAABBInFrustum(BufferIndex bufferIndex, const Vector3& origin, const Vector3& halfExtents);
/**
* Retrieve the projection-matrix; this is double buffered for input handling.
* @param[in] bufferIndex The buffer to read from.
* @return The projection-matrix.
*/
- const Matrix& GetProjectionMatrix( BufferIndex bufferIndex ) const;
+ const Matrix& GetProjectionMatrix(BufferIndex bufferIndex) const;
/**
* Retrieve the inverted view-projection-matrix; this is double buffered for input handling.
* @param[in] bufferIndex The buffer to read from.
* @return The inverse view-projection-matrix.
*/
- const Matrix& GetInverseViewProjectionMatrix( BufferIndex bufferIndex ) const;
+ const Matrix& GetInverseViewProjectionMatrix(BufferIndex bufferIndex) const;
/**
* Retrieve the final projection-matrix; this is double buffered for input handling.
* Called by the render task using the camera
* @param[in] updateBufferIndex The buffer to read from.
*/
- void Update( BufferIndex updateBufferIndex );
+ void Update(BufferIndex updateBufferIndex);
/**
* @return true if the view matrix of camera is updated this or the previous frame
bool ViewMatrixUpdated();
private:
-
/**
* Constructor
*/
* @param[in] bufferIndex The current update buffer index.
* @return count how many frames ago the matrix was changed.
*/
- uint32_t UpdateViewMatrix( BufferIndex updateBufferIndex );
+ uint32_t UpdateViewMatrix(BufferIndex updateBufferIndex);
/**
* Recalculates the projection matrix.
* @param[in] bufferIndex The current update buffer index.
* @return count how many frames ago the matrix was changed.
*/
- uint32_t UpdateProjection( BufferIndex updateBufferIndex );
+ uint32_t UpdateProjection(BufferIndex updateBufferIndex);
private:
-
/**
* @brief Extracts the frustum planes.
*
* @param[in] bufferIndex The current update buffer index.
* @param[in] normalize will normalize plane equation coefficients by default.
*/
- void UpdateFrustum( BufferIndex updateBufferIndex, bool normalize = true );
+ void UpdateFrustum(BufferIndex updateBufferIndex, bool normalize = true);
/**
* Adjust near plane for reflection
* @param perspective Perspective matrix
* @param clipPlane Clipping plane
*/
- void AdjustNearPlaneForPerspective( Matrix& perspective, const Vector4& clipPlane );
-
- uint32_t mUpdateViewFlag; ///< This is non-zero if the view matrix requires an update
- uint32_t mUpdateProjectionFlag; ///< This is non-zero if the projection matrix requires an update
- int mProjectionRotation; ///< The rotaion angle of the projection
- const Node* mNode; ///< The node this scene graph camera belongs to
-
-public: // PROPERTIES
- Dali::Camera::Type mType; // Non-animatable
- Dali::Camera::ProjectionMode mProjectionMode; // Non-animatable
- bool mInvertYAxis; // Non-animatable
-
- float mFieldOfView;
- float mAspectRatio;
- float mLeftClippingPlane;
- float mRightClippingPlane;
- float mTopClippingPlane;
- float mBottomClippingPlane;
- float mNearClippingPlane;
- float mFarClippingPlane;
- Vector3 mTargetPosition;
-
- Dali::Matrix mReflectionMtx;
- Dali::Vector4 mReflectionPlane;
- Dali::Vector4 mReflectionEye;
- bool mUseReflection{ false };
- bool mUseReflectionClip{ false };
-
- InheritedMatrix mViewMatrix; ///< The viewMatrix; this is double buffered for input handling.
- InheritedMatrix mProjectionMatrix; ///< The projectionMatrix; this is double buffered for input handling.
-
- DoubleBuffered< FrustumPlanes > mFrustum; ///< Clipping frustum; double buffered for input handling
- DoubleBuffered< Matrix > mInverseViewProjection; ///< Inverted viewprojection; double buffered for input handling
- DoubleBuffered< Matrix > mFinalProjection; ///< Final projection matrix; double buffered for input handling
-
+ void AdjustNearPlaneForPerspective(Matrix& perspective, const Vector4& clipPlane);
+
+ uint32_t mUpdateViewFlag; ///< This is non-zero if the view matrix requires an update
+ uint32_t mUpdateProjectionFlag; ///< This is non-zero if the projection matrix requires an update
+ int mProjectionRotation; ///< The rotaion angle of the projection
+ const Node* mNode; ///< The node this scene graph camera belongs to
+
+public: // PROPERTIES
+ Dali::Camera::Type mType; // Non-animatable
+ Dali::Camera::ProjectionMode mProjectionMode; // Non-animatable
+ bool mInvertYAxis; // Non-animatable
+
+ float mFieldOfView;
+ float mAspectRatio;
+ float mLeftClippingPlane;
+ float mRightClippingPlane;
+ float mTopClippingPlane;
+ float mBottomClippingPlane;
+ float mNearClippingPlane;
+ float mFarClippingPlane;
+ Vector3 mTargetPosition;
+
+ Dali::Matrix mReflectionMtx;
+ Dali::Vector4 mReflectionPlane;
+ Dali::Vector4 mReflectionEye;
+ bool mUseReflection{false};
+ bool mUseReflectionClip{false};
+
+ InheritedMatrix mViewMatrix; ///< The viewMatrix; this is double buffered for input handling.
+ InheritedMatrix mProjectionMatrix; ///< The projectionMatrix; this is double buffered for input handling.
+
+ DoubleBuffered<FrustumPlanes> mFrustum; ///< Clipping frustum; double buffered for input handling
+ DoubleBuffered<Matrix> mInverseViewProjection; ///< Inverted viewprojection; double buffered for input handling
+ DoubleBuffered<Matrix> mFinalProjection; ///< Final projection matrix; double buffered for input handling
};
// Messages for Camera
-inline void SetTypeMessage( EventThreadServices& eventThreadServices, const Camera& camera, Dali::Camera::Type parameter )
+inline void SetTypeMessage(EventThreadServices& eventThreadServices, const Camera& camera, Dali::Camera::Type parameter)
{
using LocalType = MessageValue1<Camera, Dali::Camera::Type>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &camera, &Camera::SetType, parameter );
+ new(slot) LocalType(&camera, &Camera::SetType, parameter);
}
-inline void SetProjectionModeMessage( EventThreadServices& eventThreadServices, const Camera& camera, Dali::Camera::ProjectionMode parameter )
+inline void SetProjectionModeMessage(EventThreadServices& eventThreadServices, const Camera& camera, Dali::Camera::ProjectionMode parameter)
{
using LocalProjectionMode = MessageValue1<Camera, Dali::Camera::ProjectionMode>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalProjectionMode ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalProjectionMode));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalProjectionMode( &camera, &Camera::SetProjectionMode, parameter );
+ new(slot) LocalProjectionMode(&camera, &Camera::SetProjectionMode, parameter);
}
-inline void SetFieldOfViewMessage( EventThreadServices& eventThreadServices, const Camera& camera, float parameter )
+inline void SetFieldOfViewMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
{
using LocalType = MessageValue1<Camera, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &camera, &Camera::SetFieldOfView, parameter );
+ new(slot) LocalType(&camera, &Camera::SetFieldOfView, parameter);
}
-inline void SetAspectRatioMessage( EventThreadServices& eventThreadServices, const Camera& camera, float parameter )
+inline void SetAspectRatioMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
{
using LocalType = MessageValue1<Camera, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &camera, &Camera::SetAspectRatio, parameter );
+ new(slot) LocalType(&camera, &Camera::SetAspectRatio, parameter);
}
-inline void SetLeftClippingPlaneMessage( EventThreadServices& eventThreadServices, const Camera& camera, float parameter )
+inline void SetLeftClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
{
using LocalType = MessageValue1<Camera, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &camera, &Camera::SetLeftClippingPlane, parameter );
+ new(slot) LocalType(&camera, &Camera::SetLeftClippingPlane, parameter);
}
-inline void SetRightClippingPlaneMessage( EventThreadServices& eventThreadServices, const Camera& camera, float parameter )
+inline void SetRightClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
{
using LocalType = MessageValue1<Camera, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &camera, &Camera::SetRightClippingPlane, parameter );
+ new(slot) LocalType(&camera, &Camera::SetRightClippingPlane, parameter);
}
-inline void SetTopClippingPlaneMessage( EventThreadServices& eventThreadServices, const Camera& camera, float parameter )
+inline void SetTopClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
{
using LocalType = MessageValue1<Camera, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &camera, &Camera::SetTopClippingPlane, parameter );
+ new(slot) LocalType(&camera, &Camera::SetTopClippingPlane, parameter);
}
-inline void SetBottomClippingPlaneMessage( EventThreadServices& eventThreadServices, const Camera& camera, float parameter )
+inline void SetBottomClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
{
using LocalType = MessageValue1<Camera, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &camera, &Camera::SetBottomClippingPlane, parameter );
+ new(slot) LocalType(&camera, &Camera::SetBottomClippingPlane, parameter);
}
-inline void SetNearClippingPlaneMessage( EventThreadServices& eventThreadServices, const Camera& camera, float parameter )
+inline void SetNearClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
{
using LocalType = MessageValue1<Camera, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &camera, &Camera::SetNearClippingPlane, parameter );
+ new(slot) LocalType(&camera, &Camera::SetNearClippingPlane, parameter);
}
-inline void SetFarClippingPlaneMessage( EventThreadServices& eventThreadServices, const Camera& camera, float parameter )
+inline void SetFarClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
{
using LocalType = MessageValue1<Camera, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &camera, &Camera::SetFarClippingPlane, parameter );
+ new(slot) LocalType(&camera, &Camera::SetFarClippingPlane, parameter);
}
-inline void SetTargetPositionMessage( EventThreadServices& eventThreadServices, const Camera& camera, const Vector3& parameter )
+inline void SetTargetPositionMessage(EventThreadServices& eventThreadServices, const Camera& camera, const Vector3& parameter)
{
using LocalType = MessageValue1<Camera, Vector3>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &camera, &Camera::SetTargetPosition, parameter );
+ new(slot) LocalType(&camera, &Camera::SetTargetPosition, parameter);
}
-inline void SetInvertYAxisMessage( EventThreadServices& eventThreadServices, const Camera& camera, bool parameter )
+inline void SetInvertYAxisMessage(EventThreadServices& eventThreadServices, const Camera& camera, bool parameter)
{
using LocalType = MessageValue1<Camera, bool>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &camera, &Camera::SetInvertYAxis, parameter );
+ new(slot) LocalType(&camera, &Camera::SetInvertYAxis, parameter);
}
-inline void RotateProjectionMessage( EventThreadServices& eventThreadServices, const Camera& camera, int parameter )
+inline void RotateProjectionMessage(EventThreadServices& eventThreadServices, const Camera& camera, int parameter)
{
- typedef MessageValue1< Camera, int > LocalType;
+ typedef MessageValue1<Camera, int> LocalType;
// Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &camera, &Camera::RotateProjection, parameter );
+ new(slot) LocalType(&camera, &Camera::RotateProjection, parameter);
}
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_DEBUG_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#if defined(DEBUG_ENABLED)
Debug::Filter* gRenderTaskLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_SCENE_GRAPH_RENDER_TASK");
-#define STATE_STRING(state) \
- (state==RENDER_CONTINUOUSLY?"RenderContinuously": \
- (state==RENDER_ONCE_WAITING_FOR_RESOURCES?"RenderOnceWaiting": \
- (state==RENDERED_ONCE?"RenderedOnce": \
- (state==RENDERED_ONCE_AND_NOTIFIED?"RenderedOnceAndNotified": \
- "Unknown"))))
+#define STATE_STRING(state) \
+ (state == RENDER_CONTINUOUSLY ? "RenderContinuously" : (state == RENDER_ONCE_WAITING_FOR_RESOURCES ? "RenderOnceWaiting" : (state == RENDERED_ONCE ? "RenderedOnce" : (state == RENDERED_ONCE_AND_NOTIFIED ? "RenderedOnceAndNotified" : "Unknown"))))
-#define TASK_LOG(level) \
+#define TASK_LOG(level) \
DALI_LOG_INFO(gRenderTaskLogFilter, level, "SceneGraph::RenderTask::%s: this:%p\n", __FUNCTION__, this)
#define TASK_LOG_FMT(level, format, ...) \
- DALI_LOG_INFO(gRenderTaskLogFilter, level, "SceneGraph::RenderTask::%s: this:%p " format, __FUNCTION__, this, ## __VA_ARGS__)
+ DALI_LOG_INFO(gRenderTaskLogFilter, level, "SceneGraph::RenderTask::%s: this:%p " format, __FUNCTION__, this, ##__VA_ARGS__)
#else
#define TASK_LOG(level)
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 //Unnamed namespace
{
-
//Memory pool used to allocate new RenderTaskLists. Memory used by this pool will be released when shutting down DALi
Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::RenderTaskList> gRenderTaskListMemoryPool;
namespace Dali
{
-
namespace Internal
{
-
namespace SceneGraph
{
-
RenderTaskList* RenderTaskList::New()
{
- return new ( gRenderTaskListMemoryPool.AllocateRawThreadSafe() ) RenderTaskList();
+ return new(gRenderTaskListMemoryPool.AllocateRawThreadSafe()) RenderTaskList();
}
RenderTaskList::RenderTaskList()
-: mNotificationObject( nullptr ),
- mRenderMessageDispatcher( nullptr )
+: mNotificationObject(nullptr),
+ mRenderMessageDispatcher(nullptr)
{
}
RenderTaskList::~RenderTaskList() = default;
-void RenderTaskList::operator delete( void* ptr )
+void RenderTaskList::operator delete(void* ptr)
{
- gRenderTaskListMemoryPool.FreeThreadSafe( static_cast<RenderTaskList*>( ptr ) );
+ gRenderTaskListMemoryPool.FreeThreadSafe(static_cast<RenderTaskList*>(ptr));
}
-void RenderTaskList::SetRenderMessageDispatcher( RenderMessageDispatcher* renderMessageDispatcher )
+void RenderTaskList::SetRenderMessageDispatcher(RenderMessageDispatcher* renderMessageDispatcher)
{
mRenderMessageDispatcher = renderMessageDispatcher;
}
-void RenderTaskList::AddTask( OwnerPointer< RenderTask >& newTask )
+void RenderTaskList::AddTask(OwnerPointer<RenderTask>& newTask)
{
- DALI_ASSERT_DEBUG( newTask != NULL && "SceneGraph RenderTask is null");
- DALI_ASSERT_DEBUG( mRenderMessageDispatcher != NULL && "RenderMessageDispatcher is null");
+ DALI_ASSERT_DEBUG(newTask != NULL && "SceneGraph RenderTask is null");
+ DALI_ASSERT_DEBUG(mRenderMessageDispatcher != NULL && "RenderMessageDispatcher is null");
- newTask->Initialize( *mRenderMessageDispatcher );
+ newTask->Initialize(*mRenderMessageDispatcher);
// mRenderTasks container takes ownership
- mRenderTasks.PushBack( newTask.Release() );
+ mRenderTasks.PushBack(newTask.Release());
}
-void RenderTaskList::RemoveTask( RenderTask* task )
+void RenderTaskList::RemoveTask(RenderTask* task)
{
RenderTaskContainer::ConstIterator end = mRenderTasks.End();
- for ( RenderTaskContainer::Iterator iter = mRenderTasks.Begin(); iter != end; ++iter )
+ for(RenderTaskContainer::Iterator iter = mRenderTasks.Begin(); iter != end; ++iter)
{
- if ( *iter == task )
+ if(*iter == task)
{
// Destroy the task
- mRenderTasks.Erase( iter );
+ mRenderTasks.Erase(iter);
break; // we're finished
}
uint32_t RenderTaskList::GetTaskCount()
{
- return static_cast<uint32_t>( mRenderTasks.Count() );
+ return static_cast<uint32_t>(mRenderTasks.Count());
}
RenderTaskList::RenderTaskContainer& RenderTaskList::GetTasks()
return mRenderTasks;
}
-void RenderTaskList::SetCompleteNotificationInterface( CompleteNotificationInterface* object )
+void RenderTaskList::SetCompleteNotificationInterface(CompleteNotificationInterface* object)
{
-
mNotificationObject = object;
}
CompleteNotificationInterface* RenderTaskList::GetCompleteNotificationInterface()
{
-
return mNotificationObject;
}
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
namespace Internal
{
-
class CompleteNotificationInterface;
namespace SceneGraph
* Overriden delete operator
* Deletes the RenderTaskList from its global memory pool
*/
- void operator delete( void* ptr );
+ void operator delete(void* ptr);
/**
* Set the renderMessageDispatcher to send message.
* @param[in] renderMessageDispatcher The renderMessageDispatcher to send messages.
*/
- void SetRenderMessageDispatcher( RenderMessageDispatcher* renderMessageDispatcher );
+ void SetRenderMessageDispatcher(RenderMessageDispatcher* renderMessageDispatcher);
/**
* Add a new RenderTask to the list.
* @param[in] newTask The RenderTaskList takes ownership of this task.
*/
- void AddTask( OwnerPointer< RenderTask >& newTask );
+ void AddTask(OwnerPointer<RenderTask>& newTask);
/**
* Remove a RenderTask from the list.
* @param[in] task The RenderTaskList will destroy this task.
*/
- void RemoveTask( RenderTask* task );
+ void RemoveTask(RenderTask* task);
/**
* Retrieve the count of RenderTasks.
* Set the notification method to package in the NotifyFinishedMessage
* @param object to store in notification managers queue
*/
- void SetCompleteNotificationInterface( CompleteNotificationInterface* object );
+ void SetCompleteNotificationInterface(CompleteNotificationInterface* object);
/**
* Get the Notification interface for when 1+ render tasks have finished
CompleteNotificationInterface* GetCompleteNotificationInterface();
protected:
-
/**
* Protected constructor. See New()
*/
RenderTaskList();
private:
-
// Undefined
RenderTaskList(const RenderTaskList&);
RenderTaskList& operator=(const RenderTaskList&);
private:
-
- CompleteNotificationInterface* mNotificationObject; ///< object to pass in to the complete notification
- RenderMessageDispatcher* mRenderMessageDispatcher; ///< for sending messages to render thread
- RenderTaskContainer mRenderTasks; ///< A container of owned RenderTasks
-
+ CompleteNotificationInterface* mNotificationObject; ///< object to pass in to the complete notification
+ RenderMessageDispatcher* mRenderMessageDispatcher; ///< for sending messages to render thread
+ RenderTaskContainer mRenderTasks; ///< A container of owned RenderTasks
};
// Messages for RenderTaskList
-inline void AddTaskMessage( EventThreadServices& eventThreadServices, const RenderTaskList& list, OwnerPointer< RenderTask >& task )
+inline void AddTaskMessage(EventThreadServices& eventThreadServices, const RenderTaskList& list, OwnerPointer<RenderTask>& task)
{
// Message has ownership of the RenderTask while in transit from event -> update
using LocalType = MessageValue1<RenderTaskList, OwnerPointer<RenderTask> >;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &list, &RenderTaskList::AddTask, task );
+ new(slot) LocalType(&list, &RenderTaskList::AddTask, task);
}
-inline void RemoveTaskMessage( EventThreadServices& eventThreadServices, const RenderTaskList& list, const RenderTask& constTask )
+inline void RemoveTaskMessage(EventThreadServices& eventThreadServices, const RenderTaskList& list, const RenderTask& constTask)
{
// Scene graph thread can destroy this object.
- RenderTask& task = const_cast< RenderTask& >( constTask );
+ RenderTask& task = const_cast<RenderTask&>(constTask);
using LocalType = MessageValue1<RenderTaskList, RenderTask*>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &list, &RenderTaskList::RemoveTask, &task );
+ new(slot) LocalType(&list, &RenderTaskList::RemoveTask, &task);
}
} // namespace SceneGraph
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
// INTERNAL INCLUDES
-#include <dali/public-api/math/matrix.h>
-#include <dali/internal/update/controllers/render-message-dispatcher.h>
-#include <dali/internal/update/nodes/node.h>
#include <dali/internal/render/common/render-instruction.h>
#include <dali/internal/render/common/render-tracker.h>
+#include <dali/internal/update/controllers/render-message-dispatcher.h>
+#include <dali/internal/update/nodes/node.h>
+#include <dali/public-api/math/matrix.h>
#include <dali/internal/update/render-tasks/scene-graph-render-task-debug.h>
{
namespace Internal
{
-
namespace SceneGraph
{
-
RenderTask* RenderTask::New()
{
return new RenderTask();
RenderTask::~RenderTask()
{
- if ( mSourceNode )
+ if(mSourceNode)
{
- mSourceNode->RemoveObserver( *this );
- if( mExclusive )
+ mSourceNode->RemoveObserver(*this);
+ if(mExclusive)
{
- mSourceNode->SetExclusiveRenderTask( nullptr );
+ mSourceNode->SetExclusiveRenderTask(nullptr);
}
}
- if ( mCameraNode )
+ if(mCameraNode)
{
- mCameraNode->RemoveObserver( *this );
+ mCameraNode->RemoveObserver(*this);
}
- if( mRenderSyncTracker )
+ if(mRenderSyncTracker)
{
- mRenderMessageDispatcher->RemoveRenderTracker( *mRenderSyncTracker );
+ mRenderMessageDispatcher->RemoveRenderTracker(*mRenderSyncTracker);
}
}
-void RenderTask::Initialize( RenderMessageDispatcher& renderMessageDispatcher )
+void RenderTask::Initialize(RenderMessageDispatcher& renderMessageDispatcher)
{
mRenderMessageDispatcher = &renderMessageDispatcher;
}
-void RenderTask::SetSourceNode( Node* node )
+void RenderTask::SetSourceNode(Node* node)
{
// Stop observing the old node (if we were)
- if ( mSourceNode )
+ if(mSourceNode)
{
- mSourceNode->RemoveObserver( *this );
- if( this == mSourceNode->GetExclusiveRenderTask() )
+ mSourceNode->RemoveObserver(*this);
+ if(this == mSourceNode->GetExclusiveRenderTask())
{
- mSourceNode->SetExclusiveRenderTask( nullptr );
+ mSourceNode->SetExclusiveRenderTask(nullptr);
}
}
mSourceNode = node;
- if ( mSourceNode )
+ if(mSourceNode)
{
- mSourceNode->AddObserver( *this );
- if( mExclusive )
+ mSourceNode->AddObserver(*this);
+ if(mExclusive)
{
- mSourceNode->SetExclusiveRenderTask( this );
+ mSourceNode->SetExclusiveRenderTask(this);
}
}
SetActiveStatus();
return mSourceNode;
}
-void RenderTask::SetExclusive( bool exclusive )
+void RenderTask::SetExclusive(bool exclusive)
{
mExclusive = exclusive;
- if ( mSourceNode )
+ if(mSourceNode)
{
- if ( mExclusive )
+ if(mExclusive)
{
- mSourceNode->SetExclusiveRenderTask( this );
+ mSourceNode->SetExclusiveRenderTask(this);
}
- else if ( this == mSourceNode->GetExclusiveRenderTask() )
+ else if(this == mSourceNode->GetExclusiveRenderTask())
{
- mSourceNode->SetExclusiveRenderTask( nullptr );
+ mSourceNode->SetExclusiveRenderTask(nullptr);
}
}
}
return mExclusive;
}
-void RenderTask::SetCamera( Node* cameraNode, Camera* camera )
+void RenderTask::SetCamera(Node* cameraNode, Camera* camera)
{
- if ( mCameraNode )
+ if(mCameraNode)
{
- mCameraNode->RemoveObserver( *this );
+ mCameraNode->RemoveObserver(*this);
}
mCameraNode = cameraNode;
- mCamera = camera;
+ mCamera = camera;
- if ( mCameraNode )
+ if(mCameraNode)
{
- mCameraNode->AddObserver( *this );
+ mCameraNode->AddObserver(*this);
}
SetActiveStatus();
}
-void RenderTask::SetFrameBuffer( Render::FrameBuffer* frameBuffer )
+void RenderTask::SetFrameBuffer(Render::FrameBuffer* frameBuffer)
{
mFrameBuffer = frameBuffer;
}
return mFrameBuffer;
}
-bool RenderTask::QueryViewport( BufferIndex bufferIndex, Viewport& viewport ) const
+bool RenderTask::QueryViewport(BufferIndex bufferIndex, Viewport& viewport) const
{
- if( ! GetViewportEnabled( bufferIndex ) )
+ if(!GetViewportEnabled(bufferIndex))
{
return false;
}
- viewport.x = static_cast<int>( mViewportPosition[bufferIndex].x ); // truncated
- viewport.y = static_cast<int>( mViewportPosition[bufferIndex].y ); // truncated
- viewport.width = static_cast<int>( mViewportSize[bufferIndex].width ); // truncated
- viewport.height = static_cast<int>( mViewportSize[bufferIndex].height ); // truncated
+ viewport.x = static_cast<int>(mViewportPosition[bufferIndex].x); // truncated
+ viewport.y = static_cast<int>(mViewportPosition[bufferIndex].y); // truncated
+ viewport.width = static_cast<int>(mViewportSize[bufferIndex].width); // truncated
+ viewport.height = static_cast<int>(mViewportSize[bufferIndex].height); // truncated
return true;
}
-void RenderTask::SetClearColor( BufferIndex updateBufferIndex, const Vector4& value )
+void RenderTask::SetClearColor(BufferIndex updateBufferIndex, const Vector4& value)
{
- mClearColor.Set( updateBufferIndex, value );
+ mClearColor.Set(updateBufferIndex, value);
}
-const Vector4& RenderTask::GetClearColor( BufferIndex bufferIndex ) const
+const Vector4& RenderTask::GetClearColor(BufferIndex bufferIndex) const
{
return mClearColor[bufferIndex];
}
-void RenderTask::BakeClearColor( BufferIndex updateBufferIndex, const Vector4& value )
+void RenderTask::BakeClearColor(BufferIndex updateBufferIndex, const Vector4& value)
{
- mClearColor.Bake( updateBufferIndex, value );
+ mClearColor.Bake(updateBufferIndex, value);
}
-void RenderTask::SetClearEnabled( bool enabled )
+void RenderTask::SetClearEnabled(bool enabled)
{
mClearEnabled = enabled;
}
return mClearEnabled;
}
-void RenderTask::SetCullMode( bool mode )
+void RenderTask::SetCullMode(bool mode)
{
mCullMode = mode;
}
return mCullMode;
}
-void RenderTask::SetRefreshRate( uint32_t refreshRate )
+void RenderTask::SetRefreshRate(uint32_t refreshRate)
{
DALI_LOG_TRACE_METHOD_FMT(gRenderTaskLogFilter, "this:%p RefreshRate:%d\n", this, refreshRate);
mRefreshRate = refreshRate;
- if( mRefreshRate > 0 )
+ if(mRefreshRate > 0)
{
mState = RENDER_CONTINUOUSLY;
}
else
{
- mState = RENDER_ONCE_WAITING_FOR_RESOURCES;
+ mState = RENDER_ONCE_WAITING_FOR_RESOURCES;
mWaitingToRender = true;
- mNotifyTrigger = false;
+ mNotifyTrigger = false;
}
mFrameCounter = 0u;
return mRefreshRate;
}
-bool RenderTask::ReadyToRender( BufferIndex updateBufferIndex )
+bool RenderTask::ReadyToRender(BufferIndex updateBufferIndex)
{
return mActive;
}
{
bool required = false;
- switch( mState )
+ switch(mState)
{
case RENDER_CONTINUOUSLY:
{
}
}
- TASK_LOG_FMT( Debug::General, " State:%s = %s\n", STATE_STRING(mState), required?"T":"F" );
+ TASK_LOG_FMT(Debug::General, " State:%s = %s\n", STATE_STRING(mState), required ? "T" : "F");
return required;
}
// If render was not required, ignore resourcesFinished.
void RenderTask::UpdateState()
{
- TASK_LOG_FMT( Debug::General, "FC:%d State:%s RR:%d\n", mFrameCounter, STATE_STRING(mState), mRefreshRate );
+ TASK_LOG_FMT(Debug::General, "FC:%d State:%s RR:%d\n", mFrameCounter, STATE_STRING(mState), mRefreshRate);
- switch( mState )
+ switch(mState)
{
case RENDER_CONTINUOUSLY:
{
- if( mRefreshRate != Dali::RenderTask::REFRESH_ALWAYS )
+ if(mRefreshRate != Dali::RenderTask::REFRESH_ALWAYS)
{
- if( mFrameCounter == 0 )
+ if(mFrameCounter == 0)
{
++mFrameCounter; // Only start skipping frames when resources are loaded
}
else // Continue counting to skip frames
{
++mFrameCounter;
- if( mFrameCounter >= mRefreshRate )
+ if(mFrameCounter >= mRefreshRate)
{
mFrameCounter = 0;
}
case RENDERED_ONCE:
{
mWaitingToRender = true;
- mNotifyTrigger = false;
- if( mFrameBuffer )
+ mNotifyTrigger = false;
+ if(mFrameBuffer)
{
- if( !mRenderSyncTracker || (mRenderSyncTracker && mRenderSyncTracker->IsSynced() ))
+ if(!mRenderSyncTracker || (mRenderSyncTracker && mRenderSyncTracker->IsSynced()))
{
mWaitingToRender = false;
- mNotifyTrigger = true;
+ mNotifyTrigger = true;
}
}
else
{
mWaitingToRender = false;
- mNotifyTrigger = true;
+ mNotifyTrigger = true;
}
}
break;
}
- TASK_LOG_FMT( Debug::General, " EXIT FC:%d State:%s Notify:%s\n", mFrameCounter, STATE_STRING(mState), mNotifyTrigger?"T":"F");
+ TASK_LOG_FMT(Debug::General, " EXIT FC:%d State:%s Notify:%s\n", mFrameCounter, STATE_STRING(mState), mNotifyTrigger ? "T" : "F");
}
bool RenderTask::IsWaitingToRender()
{
- TASK_LOG_FMT(Debug::Verbose, " State:%s waiting:%s \n", STATE_STRING(mState), mWaitingToRender?"T":"F");
+ TASK_LOG_FMT(Debug::Verbose, " State:%s waiting:%s \n", STATE_STRING(mState), mWaitingToRender ? "T" : "F");
return mWaitingToRender;
}
bool RenderTask::HasRendered()
{
bool notify = false;
- if( mNotifyTrigger == true )
+ if(mNotifyTrigger == true)
{
++mRenderedOnceCounter;
- mState = RENDERED_ONCE_AND_NOTIFIED;
+ mState = RENDERED_ONCE_AND_NOTIFIED;
mNotifyTrigger = false;
- notify = true;
+ notify = true;
}
- TASK_LOG_FMT(Debug::Verbose, " State:%s hasRendered:%s \n", STATE_STRING(mState), notify?"T":"F");
+ TASK_LOG_FMT(Debug::Verbose, " State:%s hasRendered:%s \n", STATE_STRING(mState), notify ? "T" : "F");
return notify;
}
return mRenderedOnceCounter;
}
-const Matrix& RenderTask::GetViewMatrix( BufferIndex bufferIndex ) const
+const Matrix& RenderTask::GetViewMatrix(BufferIndex bufferIndex) const
{
- DALI_ASSERT_DEBUG( nullptr != mCamera );
+ DALI_ASSERT_DEBUG(nullptr != mCamera);
- return mCamera->GetViewMatrix( bufferIndex );
+ return mCamera->GetViewMatrix(bufferIndex);
}
SceneGraph::Camera& RenderTask::GetCamera() const
{
- DALI_ASSERT_DEBUG( nullptr != mCamera );
+ DALI_ASSERT_DEBUG(nullptr != mCamera);
return *mCamera;
}
-const Matrix& RenderTask::GetProjectionMatrix( BufferIndex bufferIndex ) const
+const Matrix& RenderTask::GetProjectionMatrix(BufferIndex bufferIndex) const
{
- DALI_ASSERT_DEBUG( nullptr != mCamera );
+ DALI_ASSERT_DEBUG(nullptr != mCamera);
- return mCamera->GetProjectionMatrix( bufferIndex );
+ return mCamera->GetProjectionMatrix(bufferIndex);
}
-RenderInstruction& RenderTask::PrepareRenderInstruction( BufferIndex updateBufferIndex )
+RenderInstruction& RenderTask::PrepareRenderInstruction(BufferIndex updateBufferIndex)
{
- DALI_ASSERT_DEBUG( nullptr != mCamera );
+ DALI_ASSERT_DEBUG(nullptr != mCamera);
TASK_LOG(Debug::General);
Viewport viewport;
- bool viewportSet = QueryViewport( updateBufferIndex, viewport );
+ bool viewportSet = QueryViewport(updateBufferIndex, viewport);
- mRenderInstruction[updateBufferIndex].Reset( mCamera,
- GetFrameBuffer(),
- viewportSet ? &viewport : nullptr,
- mClearEnabled ? &GetClearColor( updateBufferIndex ) : nullptr );
+ mRenderInstruction[updateBufferIndex].Reset(mCamera,
+ GetFrameBuffer(),
+ viewportSet ? &viewport : nullptr,
+ mClearEnabled ? &GetClearColor(updateBufferIndex) : nullptr);
- if( mRequiresSync &&
- mRefreshRate == Dali::RenderTask::REFRESH_ONCE )
+ if(mRequiresSync &&
+ mRefreshRate == Dali::RenderTask::REFRESH_ONCE)
{
// create tracker if one doesn't yet exist.
- if( !mRenderSyncTracker )
+ if(!mRenderSyncTracker)
{
mRenderSyncTracker = new Render::RenderTracker();
- mRenderMessageDispatcher->AddRenderTracker( *mRenderSyncTracker );
+ mRenderMessageDispatcher->AddRenderTracker(*mRenderSyncTracker);
}
mRenderInstruction[updateBufferIndex].mRenderTracker = mRenderSyncTracker;
}
bool RenderTask::ViewMatrixUpdated()
{
bool retval = false;
- if( mCamera )
+ if(mCamera)
{
retval = mCamera->ViewMatrixUpdated();
}
return retval;
}
-void RenderTask::SetViewportPosition( BufferIndex updateBufferIndex, const Vector2& value )
+void RenderTask::SetViewportPosition(BufferIndex updateBufferIndex, const Vector2& value)
{
- mViewportPosition.Set( updateBufferIndex, value );
+ mViewportPosition.Set(updateBufferIndex, value);
}
-const Vector2& RenderTask::GetViewportPosition( BufferIndex bufferIndex ) const
+const Vector2& RenderTask::GetViewportPosition(BufferIndex bufferIndex) const
{
return mViewportPosition[bufferIndex];
}
-void RenderTask::BakeViewportPosition( BufferIndex updateBufferIndex, const Vector2& value )
+void RenderTask::BakeViewportPosition(BufferIndex updateBufferIndex, const Vector2& value)
{
- mViewportPosition.Bake( updateBufferIndex, value );
+ mViewportPosition.Bake(updateBufferIndex, value);
}
-void RenderTask::SetViewportSize( BufferIndex updateBufferIndex, const Vector2& value )
+void RenderTask::SetViewportSize(BufferIndex updateBufferIndex, const Vector2& value)
{
- mViewportSize.Set( updateBufferIndex, value );
+ mViewportSize.Set(updateBufferIndex, value);
}
-const Vector2& RenderTask::GetViewportSize( BufferIndex bufferIndex ) const
+const Vector2& RenderTask::GetViewportSize(BufferIndex bufferIndex) const
{
return mViewportSize[bufferIndex];
}
-void RenderTask::BakeViewportSize( BufferIndex updateBufferIndex, const Vector2& value )
+void RenderTask::BakeViewportSize(BufferIndex updateBufferIndex, const Vector2& value)
{
- mViewportSize.Bake( updateBufferIndex, value );
+ mViewportSize.Bake(updateBufferIndex, value);
}
-bool RenderTask::GetViewportEnabled( BufferIndex bufferIndex ) const
+bool RenderTask::GetViewportEnabled(BufferIndex bufferIndex) const
{
if(fabsf(mViewportPosition[bufferIndex].x) > Math::MACHINE_EPSILON_1 ||
fabsf(mViewportPosition[bufferIndex].y) > Math::MACHINE_EPSILON_1 ||
return false;
}
-void RenderTask::SetSyncRequired( bool requiresSync )
+void RenderTask::SetSyncRequired(bool requiresSync)
{
mRequiresSync = requiresSync;
}
-void RenderTask::PropertyOwnerConnected( PropertyOwner& owner )
+void RenderTask::PropertyOwnerConnected(PropertyOwner& owner)
{
// check if we've gone from inactive to active
SetActiveStatus();
}
-void RenderTask::PropertyOwnerDisconnected( BufferIndex /*updateBufferIndex*/, PropertyOwner& owner )
+void RenderTask::PropertyOwnerDisconnected(BufferIndex /*updateBufferIndex*/, PropertyOwner& owner)
{
mActive = false; // if either source or camera disconnected, we're no longer active
}
-void RenderTask::PropertyOwnerDestroyed( PropertyOwner& owner )
+void RenderTask::PropertyOwnerDestroyed(PropertyOwner& owner)
{
- if( static_cast<PropertyOwner*>( mSourceNode ) == &owner )
+ if(static_cast<PropertyOwner*>(mSourceNode) == &owner)
{
mSourceNode = nullptr;
}
- else if( static_cast<PropertyOwner*>( mCameraNode ) == &owner )
+ else if(static_cast<PropertyOwner*>(mCameraNode) == &owner)
{
mCameraNode = nullptr;
}
}
RenderTask::RenderTask()
-: mViewportPosition( Vector2::ZERO),
- mViewportSize( Vector2::ZERO),
- mClearColor( Dali::RenderTask::DEFAULT_CLEAR_COLOR ),
- mRenderMessageDispatcher( nullptr ),
- mRenderSyncTracker( nullptr ),
- mSourceNode( nullptr ),
- mCameraNode( nullptr ),
- mCamera( nullptr ),
+: mViewportPosition(Vector2::ZERO),
+ mViewportSize(Vector2::ZERO),
+ mClearColor(Dali::RenderTask::DEFAULT_CLEAR_COLOR),
+ mRenderMessageDispatcher(nullptr),
+ mRenderSyncTracker(nullptr),
+ mSourceNode(nullptr),
+ mCameraNode(nullptr),
+ mCamera(nullptr),
mFrameBuffer(nullptr),
- mRefreshRate( Dali::RenderTask::DEFAULT_REFRESH_RATE ),
- mFrameCounter( 0u ),
- mRenderedOnceCounter( 0u ),
- mState( (Dali::RenderTask::DEFAULT_REFRESH_RATE == Dali::RenderTask::REFRESH_ALWAYS)
- ? RENDER_CONTINUOUSLY
- : RENDER_ONCE_WAITING_FOR_RESOURCES ),
- mRequiresSync( false ),
- mActive( false ),
- mWaitingToRender( false ),
- mNotifyTrigger( false ),
- mExclusive( Dali::RenderTask::DEFAULT_EXCLUSIVE ),
- mClearEnabled( Dali::RenderTask::DEFAULT_CLEAR_ENABLED ),
- mCullMode( Dali::RenderTask::DEFAULT_CULL_MODE )
+ mRefreshRate(Dali::RenderTask::DEFAULT_REFRESH_RATE),
+ mFrameCounter(0u),
+ mRenderedOnceCounter(0u),
+ mState((Dali::RenderTask::DEFAULT_REFRESH_RATE == Dali::RenderTask::REFRESH_ALWAYS)
+ ? RENDER_CONTINUOUSLY
+ : RENDER_ONCE_WAITING_FOR_RESOURCES),
+ mRequiresSync(false),
+ mActive(false),
+ mWaitingToRender(false),
+ mNotifyTrigger(false),
+ mExclusive(Dali::RenderTask::DEFAULT_EXCLUSIVE),
+ mClearEnabled(Dali::RenderTask::DEFAULT_CLEAR_ENABLED),
+ mCullMode(Dali::RenderTask::DEFAULT_CULL_MODE)
{
}
void RenderTask::SetActiveStatus()
{
// must have a source and camera both connected to scene
- mActive = ( mSourceNode && mSourceNode->ConnectedToScene() &&
- mCameraNode && mCameraNode->ConnectedToScene() && mCamera );
- TASK_LOG_FMT( Debug::General, " Source node(%x) active %d. Frame counter: %d\n", mSourceNode, mSourceNode && mSourceNode->ConnectedToScene(), mFrameCounter );
- TASK_LOG_FMT( Debug::General, " Camera node(%x) active %d\n", mCameraNode, mCameraNode && mCameraNode->ConnectedToScene() );
+ mActive = (mSourceNode && mSourceNode->ConnectedToScene() &&
+ mCameraNode && mCameraNode->ConnectedToScene() && mCamera);
+ TASK_LOG_FMT(Debug::General, " Source node(%x) active %d. Frame counter: %d\n", mSourceNode, mSourceNode && mSourceNode->ConnectedToScene(), mFrameCounter);
+ TASK_LOG_FMT(Debug::General, " Camera node(%x) active %d\n", mCameraNode, mCameraNode && mCameraNode->ConnectedToScene());
}
} // namespace SceneGraph
#define DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/math/viewport.h>
-#include <dali/public-api/render-tasks/render-task.h>
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/common/message.h>
#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/animatable-property.h>
-#include <dali/internal/render/renderers/render-frame-buffer.h>
#include <dali/internal/render/common/render-instruction.h>
+#include <dali/internal/render/renderers/render-frame-buffer.h>
+#include <dali/internal/update/common/animatable-property.h>
+#include <dali/internal/update/common/property-owner.h>
+#include <dali/public-api/math/viewport.h>
+#include <dali/public-api/render-tasks/render-task.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Render
{
class RenderTracker;
class RenderTask : public PropertyOwner, public PropertyOwner::Observer
{
public:
-
enum State : uint8_t
{
RENDER_CONTINUOUSLY, ///< mRefreshRate > 0
* Initialize the render task. Called in update thread
* @param[in] renderMessageDispatcher to send messages to render thread
*/
- void Initialize( RenderMessageDispatcher& renderMessageDispatcher );
+ void Initialize(RenderMessageDispatcher& renderMessageDispatcher);
/**
* Set the nodes to be rendered.
* @param[in] node This node and its children will be rendered.
*/
- void SetSourceNode( Node* node );
+ void SetSourceNode(Node* node);
/**
* Retrieve the source node.
* Set whether the RenderTask has exclusive access to the source nodes.
* @param[in] exclusive True if the source nodes will only be rendered by this render-task.
*/
- void SetExclusive( bool exclusive );
+ void SetExclusive(bool exclusive);
/**
* Query whether the RenderTask has exclusive access to the source actors.
* @param[in] cameraNode that camera is connected with
* @param[in] camera to use.
*/
- void SetCamera( Node* cameraNode, Camera* camera );
+ void SetCamera(Node* cameraNode, Camera* camera);
/**
* Set the frame-buffer used as a render target.
* @param[in] frameBuffer The framebuffer
*/
- void SetFrameBuffer( Render::FrameBuffer* frameBuffer );
+ void SetFrameBuffer(Render::FrameBuffer* frameBuffer);
/**
* Retrieve the resource ID of the frame-buffer.
* @param[in] updateBufferIndex The current update buffer index.
* @param[in] value The value of the property
*/
- void SetViewportPosition( BufferIndex updateBufferIndex, const Vector2& value );
+ void SetViewportPosition(BufferIndex updateBufferIndex, const Vector2& value);
/**
* Get the value of property viewportPosition
* @param[in] bufferIndex The buffer to read from.
* @return the value of the property.
*/
- const Vector2& GetViewportPosition( BufferIndex bufferIndex ) const;
+ const Vector2& GetViewportPosition(BufferIndex bufferIndex) const;
/**
* Bake the value of the property viewportPosition
* @param[in] updateBufferIndex The current update buffer index.
* @param[in] value The new value for property.
*/
- void BakeViewportPosition( BufferIndex updateBufferIndex, const Vector2& value );
+ void BakeViewportPosition(BufferIndex updateBufferIndex, const Vector2& value);
/**
* Set the value of property viewportSize
* @param[in] updateBufferIndex The current update buffer index.
* @param[in] value The value of the property
*/
- void SetViewportSize( BufferIndex updateBufferIndex, const Vector2& value );
+ void SetViewportSize(BufferIndex updateBufferIndex, const Vector2& value);
/**
* Get the value of property viewportSize
* @param[in] bufferIndex The buffer to read from.
* @return the value of the property.
*/
- const Vector2& GetViewportSize( BufferIndex bufferIndex ) const;
+ const Vector2& GetViewportSize(BufferIndex bufferIndex) const;
/**
* Bake the value of the property viewportSize
* @param[in] updateBufferIndex The current update buffer index.
* @param[in] value The new value for property.
*/
- void BakeViewportSize( BufferIndex updateBufferIndex, const Vector2& value );
+ void BakeViewportSize(BufferIndex updateBufferIndex, const Vector2& value);
/**
* Get the value of property viewportEnabled
* @param[in] bufferIndex The buffer to read from.
* @return the value of the property.
*/
- bool GetViewportEnabled( BufferIndex bufferIndex ) const;
+ bool GetViewportEnabled(BufferIndex bufferIndex) const;
/**
* Query whether the optional viewport is set.
* @param[out] viewport The viewport position and size is populated.
* @return true if the viewport has been set
*/
- bool QueryViewport( BufferIndex bufferIndex, Viewport& viewport ) const;
+ bool QueryViewport(BufferIndex bufferIndex, Viewport& viewport) const;
/**
* Set the value of property clearColor
* @param[in] updateBufferIndex The current update buffer index.
* @param[in] value The value of the property
*/
- void SetClearColor( BufferIndex updateBufferIndex, const Vector4& value );
+ void SetClearColor(BufferIndex updateBufferIndex, const Vector4& value);
/**
* Get the value of property clearColor
* @param[in] bufferIndex The buffer to read from.
* @return the value of the property.
*/
- const Vector4& GetClearColor( BufferIndex bufferIndex ) const;
+ const Vector4& GetClearColor(BufferIndex bufferIndex) const;
/**
* Bake the value of the property clearColor
* @param[in] updateBufferIndex The current update buffer index.
* @param[in] value The new value for property.
*/
- void BakeClearColor( BufferIndex updateBufferIndex, const Vector4& value );
+ void BakeClearColor(BufferIndex updateBufferIndex, const Vector4& value);
/**
* @copydoc Dali::RenderTask::SetClearEnabled()
*/
- void SetClearEnabled( bool enabled );
+ void SetClearEnabled(bool enabled);
/**
* @copydoc Dali::RenderTask::GetClearEnabled()
/**
* @copydoc Dali::RenderTask::SetCullMode()
*/
- void SetCullMode( bool mode );
+ void SetCullMode(bool mode);
/**
* @copydoc Dali::RenderTask::GetCullMode()
* Set the refresh-rate of the RenderTask.
* @param[in] refreshRate The new refresh rate.
*/
- void SetRefreshRate( uint32_t refreshRate );
+ void SetRefreshRate(uint32_t refreshRate);
/**
* Retrieve the refresh-rate of the RenderTask.
* @param[in] updateBufferIndex The current update buffer index.
* @return True if the render-task is ready for rendering.
*/
- bool ReadyToRender( BufferIndex updateBufferIndex );
+ bool ReadyToRender(BufferIndex updateBufferIndex);
/**
* True if a render is required. If the current state is RENDER_CONTINUOUSLY, then
* @param[in] bufferIndex The buffer to read from.
* @return The view-matrix.
*/
- const Matrix& GetViewMatrix( BufferIndex bufferIndex ) const;
+ const Matrix& GetViewMatrix(BufferIndex bufferIndex) const;
/**
* @brief Retrieve the camera.
* @param[in] bufferIndex The buffer to read from.
* @return The projection-matrix.
*/
- const Matrix& GetProjectionMatrix( BufferIndex bufferIndex ) const;
+ const Matrix& GetProjectionMatrix(BufferIndex bufferIndex) const;
/**
* Prepares the render-instruction buffer to be populated with instructions.
* @param[in] updateBufferIndex The current update buffer index.
* @return instruction to prepare
*/
- RenderInstruction& PrepareRenderInstruction( BufferIndex updateBufferIndex );
+ RenderInstruction& PrepareRenderInstruction(BufferIndex updateBufferIndex);
/**
* @return true if the view matrix has been updated during this or last frame
* Indicate whether GL sync is required for native render target.
* @param[in] requiresSync whether GL sync is required for native render target
*/
- void SetSyncRequired( bool requiresSync );
+ void SetSyncRequired(bool requiresSync);
/**
* Retrieve the render instruction.
* @param[in] updateBufferIndex The current update buffer index.
* @return The render instruction
*/
- RenderInstruction& GetRenderInstruction( BufferIndex updateBufferIndex )
+ RenderInstruction& GetRenderInstruction(BufferIndex updateBufferIndex)
{
return mRenderInstruction[updateBufferIndex];
}
private: // from PropertyOwner::Observer
-
/**
* @copydoc PropertyOwner::Observer::PropertyOwnerConnected( PropertyOwner& owner )
*/
- void PropertyOwnerConnected( PropertyOwner& owner ) override;
+ void PropertyOwnerConnected(PropertyOwner& owner) override;
/**
* @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner )
*/
- void PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner ) override;
+ void PropertyOwnerDisconnected(BufferIndex updateBufferIndex, PropertyOwner& owner) override;
/**
* @copydoc PropertyOwner::Observer::PropertyOwnerDestroyed( PropertyOwner& owner )
*/
- void PropertyOwnerDestroyed( PropertyOwner& owner ) override;
+ void PropertyOwnerDestroyed(PropertyOwner& owner) override;
private:
-
void SetActiveStatus();
/**
RenderTask(const RenderTask&) = delete;
RenderTask& operator=(const RenderTask&) = delete;
-public: // Animatable Properties
- AnimatableProperty< Vector2 > mViewportPosition; ///< viewportPosition
- AnimatableProperty< Vector2 > mViewportSize; ///< viewportSize
- AnimatableProperty< Vector4 > mClearColor; ///< clearColor
+public: // Animatable Properties
+ AnimatableProperty<Vector2> mViewportPosition; ///< viewportPosition
+ AnimatableProperty<Vector2> mViewportSize; ///< viewportSize
+ AnimatableProperty<Vector4> mClearColor; ///< clearColor
private:
RenderMessageDispatcher* mRenderMessageDispatcher;
- Render::RenderTracker* mRenderSyncTracker;
- Node* mSourceNode;
- Node* mCameraNode;
- SceneGraph::Camera* mCamera;
- Render::FrameBuffer* mFrameBuffer;
+ Render::RenderTracker* mRenderSyncTracker;
+ Node* mSourceNode;
+ Node* mCameraNode;
+ SceneGraph::Camera* mCamera;
+ Render::FrameBuffer* mFrameBuffer;
RenderInstruction mRenderInstruction[2]; ///< Owned double buffered render instruction. (Double buffered because this owns render commands for the currently drawn frame)
- uint32_t mRefreshRate; ///< REFRESH_ONCE, REFRESH_ALWAYS or render every N frames
- uint32_t mFrameCounter; ///< counter for rendering every N frames
- uint32_t mRenderedOnceCounter;///< Incremented whenever state changes to RENDERED_ONCE_AND_NOTIFIED
-
- State mState; ///< Render state.
+ uint32_t mRefreshRate; ///< REFRESH_ONCE, REFRESH_ALWAYS or render every N frames
+ uint32_t mFrameCounter; ///< counter for rendering every N frames
+ uint32_t mRenderedOnceCounter; ///< Incremented whenever state changes to RENDERED_ONCE_AND_NOTIFIED
- bool mRequiresSync:1; ///< Whether sync is needed to track the render
- bool mActive:1; ///< True when the task is active, i.e. has valid source and camera
- bool mWaitingToRender:1;///< True when an render once to FBO is waiting
- bool mNotifyTrigger:1; ///< True if a render once render task has finished renderering
- bool mExclusive:1; ///< Whether the render task has exclusive access to the source actor (node in the scene graph).
- bool mClearEnabled:1; ///< Whether previous results are cleared.
- bool mCullMode:1; ///< Whether renderers should be frustum culled
+ State mState; ///< Render state.
+ bool mRequiresSync : 1; ///< Whether sync is needed to track the render
+ bool mActive : 1; ///< True when the task is active, i.e. has valid source and camera
+ bool mWaitingToRender : 1; ///< True when an render once to FBO is waiting
+ bool mNotifyTrigger : 1; ///< True if a render once render task has finished renderering
+ bool mExclusive : 1; ///< Whether the render task has exclusive access to the source actor (node in the scene graph).
+ bool mClearEnabled : 1; ///< Whether previous results are cleared.
+ bool mCullMode : 1; ///< Whether renderers should be frustum culled
};
// Messages for RenderTask
-inline void SetFrameBufferMessage( EventThreadServices& eventThreadServices, const RenderTask& task, Render::FrameBuffer* frameBuffer )
+inline void SetFrameBufferMessage(EventThreadServices& eventThreadServices, const RenderTask& task, Render::FrameBuffer* frameBuffer)
{
using LocalType = MessageValue1<RenderTask, Render::FrameBuffer*>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &task, &RenderTask::SetFrameBuffer, frameBuffer );
+ new(slot) LocalType(&task, &RenderTask::SetFrameBuffer, frameBuffer);
}
-inline void SetClearColorMessage( EventThreadServices& eventThreadServices, const RenderTask& task, const Vector4& value )
+inline void SetClearColorMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Vector4& value)
{
using LocalType = MessageDoubleBuffered1<RenderTask, Vector4>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &task, &RenderTask::SetClearColor, value );
+ new(slot) LocalType(&task, &RenderTask::SetClearColor, value);
}
-inline void BakeClearColorMessage( EventThreadServices& eventThreadServices, const RenderTask& task, const Vector4& value )
+inline void BakeClearColorMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Vector4& value)
{
using LocalType = MessageDoubleBuffered1<RenderTask, Vector4>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &task, &RenderTask::BakeClearColor, value );
+ new(slot) LocalType(&task, &RenderTask::BakeClearColor, value);
}
-inline void SetClearEnabledMessage( EventThreadServices& eventThreadServices, const RenderTask& task, bool enabled )
+inline void SetClearEnabledMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool enabled)
{
using LocalType = MessageValue1<RenderTask, bool>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &task, &RenderTask::SetClearEnabled, enabled );
+ new(slot) LocalType(&task, &RenderTask::SetClearEnabled, enabled);
}
-inline void SetCullModeMessage( EventThreadServices& eventThreadServices, const RenderTask& task, bool mode )
+inline void SetCullModeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool mode)
{
using LocalType = MessageValue1<RenderTask, bool>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &task, &RenderTask::SetCullMode, mode );
+ new(slot) LocalType(&task, &RenderTask::SetCullMode, mode);
}
-inline void SetRefreshRateMessage( EventThreadServices& eventThreadServices, const RenderTask& task, uint32_t refreshRate )
+inline void SetRefreshRateMessage(EventThreadServices& eventThreadServices, const RenderTask& task, uint32_t refreshRate)
{
using LocalType = MessageValue1<RenderTask, uint32_t>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &task, &RenderTask::SetRefreshRate, refreshRate );
+ new(slot) LocalType(&task, &RenderTask::SetRefreshRate, refreshRate);
}
-inline void SetSourceNodeMessage( EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode )
+inline void SetSourceNodeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode)
{
// Scene graph thread can destroy this object.
- Node* node = const_cast< Node* >( constNode );
+ Node* node = const_cast<Node*>(constNode);
using LocalType = MessageValue1<RenderTask, Node*>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &task, &RenderTask::SetSourceNode, node );
+ new(slot) LocalType(&task, &RenderTask::SetSourceNode, node);
}
-inline void SetCameraMessage( EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode, const Camera* constCamera )
+inline void SetCameraMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode, const Camera* constCamera)
{
using LocalType = MessageValue2<RenderTask, Node*, Camera*>;
- Node* node = const_cast< Node* >( constNode );
- Camera* camera = const_cast< Camera* >( constCamera );
+ Node* node = const_cast<Node*>(constNode);
+ Camera* camera = const_cast<Camera*>(constCamera);
// Reserve memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &task, &RenderTask::SetCamera, node, camera );
+ new(slot) LocalType(&task, &RenderTask::SetCamera, node, camera);
}
-inline void SetExclusiveMessage( EventThreadServices& eventThreadServices, const RenderTask& task, bool exclusive )
+inline void SetExclusiveMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool exclusive)
{
using LocalType = MessageValue1<RenderTask, bool>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &task, &RenderTask::SetExclusive, exclusive );
+ new(slot) LocalType(&task, &RenderTask::SetExclusive, exclusive);
}
-inline void SetSyncRequiredMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool requiresSync )
+inline void SetSyncRequiredMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool requiresSync)
{
using LocalType = MessageValue1<RenderTask, bool>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &task, &RenderTask::SetSyncRequired, requiresSync );
+ new(slot) LocalType(&task, &RenderTask::SetSyncRequired, requiresSync);
}
-inline void BakeViewportPositionMessage( EventThreadServices& eventThreadServices, const RenderTask& task, const Vector2& value )
+inline void BakeViewportPositionMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Vector2& value)
{
using LocalType = MessageDoubleBuffered1<RenderTask, Vector2>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &task, &RenderTask::BakeViewportPosition, value );
+ new(slot) LocalType(&task, &RenderTask::BakeViewportPosition, value);
}
-inline void BakeViewportSizeMessage( EventThreadServices& eventThreadServices, const RenderTask& task, const Vector2& value )
+inline void BakeViewportSizeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Vector2& value)
{
using LocalType = MessageDoubleBuffered1<RenderTask, Vector2>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &task, &RenderTask::BakeViewportSize, value );
+ new(slot) LocalType(&task, &RenderTask::BakeViewportSize, value);
}
} // namespace SceneGraph
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include "scene-graph-renderer.h"
// INTERNAL INCLUDES
+#include <dali/internal/common/blending-options.h>
#include <dali/internal/common/internal-constants.h>
#include <dali/internal/common/memory-pool-object-allocator.h>
-#include <dali/internal/update/controllers/render-message-dispatcher.h>
-#include <dali/internal/update/controllers/scene-controller.h>
-#include <dali/internal/update/nodes/node.h>
-#include <dali/internal/update/rendering/scene-graph-texture-set.h>
#include <dali/internal/render/data-providers/node-data-provider.h>
#include <dali/internal/render/queue/render-queue.h>
#include <dali/internal/render/renderers/render-geometry.h>
#include <dali/internal/render/shaders/program.h>
#include <dali/internal/render/shaders/scene-graph-shader.h>
-#include <dali/internal/common/blending-options.h>
+#include <dali/internal/update/controllers/render-message-dispatcher.h>
+#include <dali/internal/update/controllers/scene-controller.h>
+#include <dali/internal/update/nodes/node.h>
+#include <dali/internal/update/rendering/scene-graph-texture-set.h>
namespace Dali
{
{
namespace // unnamed namespace
{
-
const uint32_t UNIFORM_MAP_READY = 0;
const uint32_t COPY_UNIFORM_MAP = 1;
const uint32_t REGENERATE_UNIFORM_MAP = 2;
//Memory pool used to allocate new renderers. Memory used by this pool will be released when shutting down DALi
MemoryPoolObjectAllocator<Renderer> gRendererMemoryPool;
-void AddMappings( CollectedUniformMap& localMap, const UniformMap& uniformMap )
+void AddMappings(CollectedUniformMap& localMap, const UniformMap& uniformMap)
{
// Iterate thru uniformMap.
// Any maps that aren't in localMap should be added in a single step
newUniformMappings.Clear();
- for( UniformMap::SizeType i = 0, count=uniformMap.Count(); i<count; ++i )
+ for(UniformMap::SizeType i = 0, count = uniformMap.Count(); i < count; ++i)
{
bool found = false;
- for( CollectedUniformMap::Iterator iter = localMap.Begin() ; iter != localMap.End() ; ++iter )
+ for(CollectedUniformMap::Iterator iter = localMap.Begin(); iter != localMap.End(); ++iter)
{
const UniformPropertyMapping& map = (*iter);
if(map.uniformName == uniformMap[i].uniformName)
break;
}
}
- if( !found )
+ if(!found)
{
newUniformMappings.PushBack(uniformMap[i]);
}
}
- if( newUniformMappings.Count() > 0 )
+ if(newUniformMappings.Count() > 0)
{
- localMap.Reserve( localMap.Count() + newUniformMappings.Count() );
+ localMap.Reserve(localMap.Count() + newUniformMappings.Count());
- for( CollectedUniformMap::Iterator iter = newUniformMappings.Begin(),
- end = newUniformMappings.End() ;
- iter != end ;
- ++iter )
+ for(CollectedUniformMap::Iterator iter = newUniformMappings.Begin(),
+ end = newUniformMappings.End();
+ iter != end;
+ ++iter)
{
const UniformPropertyMapping& map = (*iter);
- localMap.PushBack( map );
+ localMap.PushBack(map);
}
}
}
Renderer* Renderer::New()
{
- return new ( gRendererMemoryPool.AllocateRawThreadSafe() ) Renderer();
+ return new(gRendererMemoryPool.AllocateRawThreadSafe()) Renderer();
}
Renderer::Renderer()
-: mSceneController( nullptr ),
- mRenderer( nullptr ),
- mTextureSet( nullptr ),
- mGeometry( nullptr ),
- mShader( nullptr ),
- mRenderDataProvider( nullptr ),
- mBlendColor( nullptr ),
- mStencilParameters( RenderMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ),
- mIndexedDrawFirstElement( 0u ),
- mIndexedDrawElementsCount( 0u ),
- mBlendBitmask( 0u ),
- mRegenerateUniformMap( 0u ),
- mResendFlag( 0u ),
- mDepthFunction( DepthFunction::LESS ),
- mFaceCullingMode( FaceCullingMode::NONE ),
- mBlendMode( BlendMode::AUTO ),
- mDepthWriteMode( DepthWriteMode::AUTO ),
- mDepthTestMode( DepthTestMode::AUTO ),
- mRenderingBehavior( DevelRenderer::Rendering::IF_REQUIRED ),
- mPremultipledAlphaEnabled( false ),
- mOpacity( 1.0f ),
- mDepthIndex( 0 )
+: mSceneController(nullptr),
+ mRenderer(nullptr),
+ mTextureSet(nullptr),
+ mGeometry(nullptr),
+ mShader(nullptr),
+ mRenderDataProvider(nullptr),
+ mBlendColor(nullptr),
+ mStencilParameters(RenderMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP),
+ mIndexedDrawFirstElement(0u),
+ mIndexedDrawElementsCount(0u),
+ mBlendBitmask(0u),
+ mRegenerateUniformMap(0u),
+ mResendFlag(0u),
+ mDepthFunction(DepthFunction::LESS),
+ mFaceCullingMode(FaceCullingMode::NONE),
+ mBlendMode(BlendMode::AUTO),
+ mDepthWriteMode(DepthWriteMode::AUTO),
+ mDepthTestMode(DepthTestMode::AUTO),
+ mRenderingBehavior(DevelRenderer::Rendering::IF_REQUIRED),
+ mPremultipledAlphaEnabled(false),
+ mOpacity(1.0f),
+ mDepthIndex(0)
{
mUniformMapChanged[0] = false;
mUniformMapChanged[1] = false;
// Observe our own PropertyOwner's uniform map
- AddUniformMapObserver( *this );
+ AddUniformMapObserver(*this);
}
Renderer::~Renderer()
{
- if( mTextureSet )
+ if(mTextureSet)
{
- mTextureSet->RemoveObserver( this );
+ mTextureSet->RemoveObserver(this);
mTextureSet = nullptr;
}
- if( mShader )
+ if(mShader)
{
- mShader->RemoveConnectionObserver( *this );
+ mShader->RemoveConnectionObserver(*this);
mShader = nullptr;
}
}
-void Renderer::operator delete( void* ptr )
+void Renderer::operator delete(void* ptr)
{
- gRendererMemoryPool.FreeThreadSafe( static_cast<Renderer*>( ptr ) );
+ gRendererMemoryPool.FreeThreadSafe(static_cast<Renderer*>(ptr));
}
-
-bool Renderer::PrepareRender( BufferIndex updateBufferIndex )
+bool Renderer::PrepareRender(BufferIndex updateBufferIndex)
{
- if( mRegenerateUniformMap == UNIFORM_MAP_READY )
+ if(mRegenerateUniformMap == UNIFORM_MAP_READY)
{
mUniformMapChanged[updateBufferIndex] = false;
}
else
{
- if( mRegenerateUniformMap == REGENERATE_UNIFORM_MAP)
+ if(mRegenerateUniformMap == REGENERATE_UNIFORM_MAP)
{
- CollectedUniformMap& localMap = mCollectedUniformMap[ updateBufferIndex ];
+ CollectedUniformMap& localMap = mCollectedUniformMap[updateBufferIndex];
localMap.Clear();
const UniformMap& rendererUniformMap = PropertyOwner::GetUniformMap();
localMap.Reserve(size);
- AddMappings( localMap, rendererUniformMap );
+ AddMappings(localMap, rendererUniformMap);
- if( mShader )
+ if(mShader)
{
- AddMappings( localMap, mShader->GetUniformMap() );
+ AddMappings(localMap, mShader->GetUniformMap());
}
}
- else if( mRegenerateUniformMap == COPY_UNIFORM_MAP )
+ else if(mRegenerateUniformMap == COPY_UNIFORM_MAP)
{
// Copy old map into current map
- CollectedUniformMap& localMap = mCollectedUniformMap[ updateBufferIndex ];
- CollectedUniformMap& oldMap = mCollectedUniformMap[ 1-updateBufferIndex ];
+ CollectedUniformMap& localMap = mCollectedUniformMap[updateBufferIndex];
+ CollectedUniformMap& oldMap = mCollectedUniformMap[1 - updateBufferIndex];
- localMap.Resize( oldMap.Count() );
+ localMap.Resize(oldMap.Count());
- uint32_t index=0;
- for( CollectedUniformMap::Iterator iter = oldMap.Begin(), end = oldMap.End() ; iter != end ; ++iter, ++index )
+ uint32_t index = 0;
+ for(CollectedUniformMap::Iterator iter = oldMap.Begin(), end = oldMap.End(); iter != end; ++iter, ++index)
{
localMap[index] = *iter;
}
bool rendererUpdated = mUniformMapChanged[updateBufferIndex] || mResendFlag || mRenderingBehavior == DevelRenderer::Rendering::CONTINUOUSLY;
- if( mResendFlag != 0 )
+ if(mResendFlag != 0)
{
- if( mResendFlag & RESEND_GEOMETRY )
+ if(mResendFlag & RESEND_GEOMETRY)
{
- typedef MessageValue1< Render::Renderer, Render::Geometry* > DerivedType;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetGeometry, mGeometry );
+ typedef MessageValue1<Render::Renderer, Render::Geometry*> DerivedType;
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetGeometry, mGeometry);
}
- if( mResendFlag & RESEND_DRAW_COMMANDS )
+ if(mResendFlag & RESEND_DRAW_COMMANDS)
{
using DerivedType = MessageValue2<Render::Renderer, Dali::DevelRenderer::DrawCommand*, uint32_t>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetDrawCommands, mDrawCommands.data(), mDrawCommands.size() );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetDrawCommands, mDrawCommands.data(), mDrawCommands.size());
}
- if( mResendFlag & RESEND_FACE_CULLING_MODE )
+ if(mResendFlag & RESEND_FACE_CULLING_MODE)
{
using DerivedType = MessageValue1<Render::Renderer, FaceCullingMode::Type>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetFaceCullingMode, mFaceCullingMode );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetFaceCullingMode, mFaceCullingMode);
}
- if( mResendFlag & RESEND_BLEND_BIT_MASK )
+ if(mResendFlag & RESEND_BLEND_BIT_MASK)
{
using DerivedType = MessageValue1<Render::Renderer, uint32_t>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetBlendingBitMask, mBlendBitmask );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetBlendingBitMask, mBlendBitmask);
}
- if( mResendFlag & RESEND_BLEND_COLOR )
+ if(mResendFlag & RESEND_BLEND_COLOR)
{
using DerivedType = MessageValue1<Render::Renderer, Vector4>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetBlendColor, GetBlendColor() );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetBlendColor, GetBlendColor());
}
- if( mResendFlag & RESEND_PREMULTIPLIED_ALPHA )
+ if(mResendFlag & RESEND_PREMULTIPLIED_ALPHA)
{
using DerivedType = MessageValue1<Render::Renderer, bool>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::EnablePreMultipliedAlpha, mPremultipledAlphaEnabled );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::EnablePreMultipliedAlpha, mPremultipledAlphaEnabled);
}
- if( mResendFlag & RESEND_INDEXED_DRAW_FIRST_ELEMENT )
+ if(mResendFlag & RESEND_INDEXED_DRAW_FIRST_ELEMENT)
{
using DerivedType = MessageValue1<Render::Renderer, uint32_t>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetIndexedDrawFirstElement, mIndexedDrawFirstElement );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetIndexedDrawFirstElement, mIndexedDrawFirstElement);
}
- if( mResendFlag & RESEND_INDEXED_DRAW_ELEMENTS_COUNT )
+ if(mResendFlag & RESEND_INDEXED_DRAW_ELEMENTS_COUNT)
{
using DerivedType = MessageValue1<Render::Renderer, uint32_t>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetIndexedDrawElementsCount, mIndexedDrawElementsCount );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetIndexedDrawElementsCount, mIndexedDrawElementsCount);
}
- if( mResendFlag & RESEND_DEPTH_WRITE_MODE )
+ if(mResendFlag & RESEND_DEPTH_WRITE_MODE)
{
using DerivedType = MessageValue1<Render::Renderer, DepthWriteMode::Type>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetDepthWriteMode, mDepthWriteMode );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetDepthWriteMode, mDepthWriteMode);
}
- if( mResendFlag & RESEND_DEPTH_TEST_MODE )
+ if(mResendFlag & RESEND_DEPTH_TEST_MODE)
{
using DerivedType = MessageValue1<Render::Renderer, DepthTestMode::Type>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetDepthTestMode, mDepthTestMode );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetDepthTestMode, mDepthTestMode);
}
- if( mResendFlag & RESEND_DEPTH_FUNCTION )
+ if(mResendFlag & RESEND_DEPTH_FUNCTION)
{
using DerivedType = MessageValue1<Render::Renderer, DepthFunction::Type>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetDepthFunction, mDepthFunction );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetDepthFunction, mDepthFunction);
}
- if( mResendFlag & RESEND_RENDER_MODE )
+ if(mResendFlag & RESEND_RENDER_MODE)
{
using DerivedType = MessageValue1<Render::Renderer, RenderMode::Type>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetRenderMode, mStencilParameters.renderMode );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetRenderMode, mStencilParameters.renderMode);
}
- if( mResendFlag & RESEND_STENCIL_FUNCTION )
+ if(mResendFlag & RESEND_STENCIL_FUNCTION)
{
using DerivedType = MessageValue1<Render::Renderer, StencilFunction::Type>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilFunction, mStencilParameters.stencilFunction );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetStencilFunction, mStencilParameters.stencilFunction);
}
- if( mResendFlag & RESEND_STENCIL_FUNCTION_MASK )
+ if(mResendFlag & RESEND_STENCIL_FUNCTION_MASK)
{
using DerivedType = MessageValue1<Render::Renderer, int>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilFunctionMask, mStencilParameters.stencilFunctionMask );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetStencilFunctionMask, mStencilParameters.stencilFunctionMask);
}
- if( mResendFlag & RESEND_STENCIL_FUNCTION_REFERENCE )
+ if(mResendFlag & RESEND_STENCIL_FUNCTION_REFERENCE)
{
using DerivedType = MessageValue1<Render::Renderer, int>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilFunctionReference, mStencilParameters.stencilFunctionReference );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetStencilFunctionReference, mStencilParameters.stencilFunctionReference);
}
- if( mResendFlag & RESEND_STENCIL_MASK )
+ if(mResendFlag & RESEND_STENCIL_MASK)
{
using DerivedType = MessageValue1<Render::Renderer, int>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilMask, mStencilParameters.stencilMask );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetStencilMask, mStencilParameters.stencilMask);
}
- if( mResendFlag & RESEND_STENCIL_OPERATION_ON_FAIL )
+ if(mResendFlag & RESEND_STENCIL_OPERATION_ON_FAIL)
{
using DerivedType = MessageValue1<Render::Renderer, StencilOperation::Type>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilOperationOnFail, mStencilParameters.stencilOperationOnFail );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetStencilOperationOnFail, mStencilParameters.stencilOperationOnFail);
}
- if( mResendFlag & RESEND_STENCIL_OPERATION_ON_Z_FAIL )
+ if(mResendFlag & RESEND_STENCIL_OPERATION_ON_Z_FAIL)
{
using DerivedType = MessageValue1<Render::Renderer, StencilOperation::Type>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilOperationOnZFail, mStencilParameters.stencilOperationOnZFail );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetStencilOperationOnZFail, mStencilParameters.stencilOperationOnZFail);
}
- if( mResendFlag & RESEND_STENCIL_OPERATION_ON_Z_PASS )
+ if(mResendFlag & RESEND_STENCIL_OPERATION_ON_Z_PASS)
{
using DerivedType = MessageValue1<Render::Renderer, StencilOperation::Type>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetStencilOperationOnZPass, mStencilParameters.stencilOperationOnZPass );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetStencilOperationOnZPass, mStencilParameters.stencilOperationOnZPass);
}
- if( mResendFlag & RESEND_SHADER )
+ if(mResendFlag & RESEND_SHADER)
{
using DerivedType = MessageValue1<Render::Renderer, bool>;
- uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetShaderChanged, true );
+ uint32_t* slot = mSceneController->GetRenderQueue().ReserveMessageSlot(updateBufferIndex, sizeof(DerivedType));
+ new(slot) DerivedType(mRenderer, &Render::Renderer::SetShaderChanged, true);
}
mResendFlag = 0;
return rendererUpdated;
}
-void Renderer::SetTextures( TextureSet* textureSet )
+void Renderer::SetTextures(TextureSet* textureSet)
{
- DALI_ASSERT_DEBUG( textureSet != NULL && "Texture set pointer is NULL" );
+ DALI_ASSERT_DEBUG(textureSet != NULL && "Texture set pointer is NULL");
- if( mTextureSet )
+ if(mTextureSet)
{
mTextureSet->RemoveObserver(this);
}
mTextureSet = textureSet;
- mTextureSet->AddObserver( this );
+ mTextureSet->AddObserver(this);
mRegenerateUniformMap = REGENERATE_UNIFORM_MAP;
UpdateTextureSet();
}
-void Renderer::SetShader( Shader* shader )
+void Renderer::SetShader(Shader* shader)
{
- DALI_ASSERT_DEBUG( shader != NULL && "Shader pointer is NULL" );
+ DALI_ASSERT_DEBUG(shader != NULL && "Shader pointer is NULL");
- if( mShader )
+ if(mShader)
{
mShader->RemoveConnectionObserver(*this);
}
mShader = shader;
- mShader->AddConnectionObserver( *this );
+ mShader->AddConnectionObserver(*this);
mRegenerateUniformMap = REGENERATE_UNIFORM_MAP;
mResendFlag |= RESEND_GEOMETRY | RESEND_SHADER;
- if( mRenderDataProvider )
+ if(mRenderDataProvider)
{
mRenderDataProvider->mShader = mShader;
}
}
-void Renderer::SetGeometry( Render::Geometry* geometry )
+void Renderer::SetGeometry(Render::Geometry* geometry)
{
- DALI_ASSERT_DEBUG( geometry != NULL && "Geometry pointer is NULL");
+ DALI_ASSERT_DEBUG(geometry != NULL && "Geometry pointer is NULL");
mGeometry = geometry;
- if( mRenderer )
+ if(mRenderer)
{
mResendFlag |= RESEND_GEOMETRY;
}
}
-void Renderer::SetDepthIndex( int depthIndex )
+void Renderer::SetDepthIndex(int depthIndex)
{
mDepthIndex = depthIndex;
}
-void Renderer::SetFaceCullingMode( FaceCullingMode::Type faceCullingMode )
+void Renderer::SetFaceCullingMode(FaceCullingMode::Type faceCullingMode)
{
mFaceCullingMode = faceCullingMode;
mResendFlag |= RESEND_FACE_CULLING_MODE;
return mFaceCullingMode;
}
-void Renderer::SetBlendMode( BlendMode::Type blendingMode )
+void Renderer::SetBlendMode(BlendMode::Type blendingMode)
{
mBlendMode = blendingMode;
}
return mBlendMode;
}
-void Renderer::SetBlendingOptions( uint32_t options )
+void Renderer::SetBlendingOptions(uint32_t options)
{
- if( mBlendBitmask != options)
+ if(mBlendBitmask != options)
{
mBlendBitmask = options;
mResendFlag |= RESEND_BLEND_BIT_MASK;
return mBlendBitmask;
}
-void Renderer::SetBlendColor( const Vector4& blendColor )
+void Renderer::SetBlendColor(const Vector4& blendColor)
{
- if( blendColor == Color::TRANSPARENT )
+ if(blendColor == Color::TRANSPARENT)
{
mBlendColor = nullptr;
}
else
{
- if( !mBlendColor )
+ if(!mBlendColor)
{
- mBlendColor = new Vector4( blendColor );
+ mBlendColor = new Vector4(blendColor);
}
else
{
Vector4 Renderer::GetBlendColor() const
{
- if( mBlendColor )
+ if(mBlendColor)
{
return *mBlendColor;
}
return Color::TRANSPARENT;
}
-void Renderer::SetIndexedDrawFirstElement( uint32_t firstElement )
+void Renderer::SetIndexedDrawFirstElement(uint32_t firstElement)
{
mIndexedDrawFirstElement = firstElement;
mResendFlag |= RESEND_INDEXED_DRAW_FIRST_ELEMENT;
return mIndexedDrawFirstElement;
}
-void Renderer::SetIndexedDrawElementsCount( uint32_t elementsCount )
+void Renderer::SetIndexedDrawElementsCount(uint32_t elementsCount)
{
mIndexedDrawElementsCount = elementsCount;
mResendFlag |= RESEND_INDEXED_DRAW_ELEMENTS_COUNT;
return mIndexedDrawElementsCount;
}
-void Renderer::EnablePreMultipliedAlpha( bool preMultipled )
+void Renderer::EnablePreMultipliedAlpha(bool preMultipled)
{
mPremultipledAlphaEnabled = preMultipled;
mResendFlag |= RESEND_PREMULTIPLIED_ALPHA;
return mPremultipledAlphaEnabled;
}
-void Renderer::SetDepthWriteMode( DepthWriteMode::Type depthWriteMode )
+void Renderer::SetDepthWriteMode(DepthWriteMode::Type depthWriteMode)
{
mDepthWriteMode = depthWriteMode;
mResendFlag |= RESEND_DEPTH_WRITE_MODE;
return mDepthWriteMode;
}
-void Renderer::SetDepthTestMode( DepthTestMode::Type depthTestMode )
+void Renderer::SetDepthTestMode(DepthTestMode::Type depthTestMode)
{
mDepthTestMode = depthTestMode;
mResendFlag |= RESEND_DEPTH_TEST_MODE;
return mDepthTestMode;
}
-void Renderer::SetDepthFunction( DepthFunction::Type depthFunction )
+void Renderer::SetDepthFunction(DepthFunction::Type depthFunction)
{
mDepthFunction = depthFunction;
mResendFlag |= RESEND_DEPTH_FUNCTION;
return mDepthFunction;
}
-void Renderer::SetRenderMode( RenderMode::Type mode )
+void Renderer::SetRenderMode(RenderMode::Type mode)
{
mStencilParameters.renderMode = mode;
mResendFlag |= RESEND_RENDER_MODE;
}
-void Renderer::SetStencilFunction( StencilFunction::Type stencilFunction )
+void Renderer::SetStencilFunction(StencilFunction::Type stencilFunction)
{
mStencilParameters.stencilFunction = stencilFunction;
mResendFlag |= RESEND_STENCIL_FUNCTION;
}
-void Renderer::SetStencilFunctionMask( int stencilFunctionMask )
+void Renderer::SetStencilFunctionMask(int stencilFunctionMask)
{
mStencilParameters.stencilFunctionMask = stencilFunctionMask;
mResendFlag |= RESEND_STENCIL_FUNCTION_MASK;
}
-void Renderer::SetStencilFunctionReference( int stencilFunctionReference )
+void Renderer::SetStencilFunctionReference(int stencilFunctionReference)
{
mStencilParameters.stencilFunctionReference = stencilFunctionReference;
mResendFlag |= RESEND_STENCIL_FUNCTION_REFERENCE;
}
-void Renderer::SetStencilMask( int stencilMask )
+void Renderer::SetStencilMask(int stencilMask)
{
mStencilParameters.stencilMask = stencilMask;
mResendFlag |= RESEND_STENCIL_MASK;
}
-void Renderer::SetStencilOperationOnFail( StencilOperation::Type stencilOperationOnFail )
+void Renderer::SetStencilOperationOnFail(StencilOperation::Type stencilOperationOnFail)
{
mStencilParameters.stencilOperationOnFail = stencilOperationOnFail;
mResendFlag |= RESEND_STENCIL_OPERATION_ON_FAIL;
}
-void Renderer::SetStencilOperationOnZFail( StencilOperation::Type stencilOperationOnZFail )
+void Renderer::SetStencilOperationOnZFail(StencilOperation::Type stencilOperationOnZFail)
{
mStencilParameters.stencilOperationOnZFail = stencilOperationOnZFail;
mResendFlag |= RESEND_STENCIL_OPERATION_ON_Z_FAIL;
}
-void Renderer::SetStencilOperationOnZPass( StencilOperation::Type stencilOperationOnZPass )
+void Renderer::SetStencilOperationOnZPass(StencilOperation::Type stencilOperationOnZPass)
{
mStencilParameters.stencilOperationOnZPass = stencilOperationOnZPass;
mResendFlag |= RESEND_STENCIL_OPERATION_ON_Z_PASS;
return mStencilParameters;
}
-void Renderer::BakeOpacity( BufferIndex updateBufferIndex, float opacity )
+void Renderer::BakeOpacity(BufferIndex updateBufferIndex, float opacity)
{
- mOpacity.Bake( updateBufferIndex, opacity );
+ mOpacity.Bake(updateBufferIndex, opacity);
}
-float Renderer::GetOpacity( BufferIndex updateBufferIndex ) const
+float Renderer::GetOpacity(BufferIndex updateBufferIndex) const
{
return mOpacity[updateBufferIndex];
}
-void Renderer::SetRenderingBehavior( DevelRenderer::Rendering::Type renderingBehavior )
+void Renderer::SetRenderingBehavior(DevelRenderer::Rendering::Type renderingBehavior)
{
mRenderingBehavior = renderingBehavior;
}
}
//Called when SceneGraph::Renderer is added to update manager ( that happens when an "event-thread renderer" is created )
-void Renderer::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
+void Renderer::ConnectToSceneGraph(SceneController& sceneController, BufferIndex bufferIndex)
{
mRegenerateUniformMap = REGENERATE_UNIFORM_MAP;
- mSceneController = &sceneController;
+ mSceneController = &sceneController;
- mRenderDataProvider = new RenderDataProvider( mOpacity );
+ mRenderDataProvider = new RenderDataProvider(mOpacity);
mRenderDataProvider->mUniformMapDataProvider = this;
- mRenderer = Render::Renderer::New( mRenderDataProvider, mGeometry, mBlendBitmask, GetBlendColor(), static_cast< FaceCullingMode::Type >( mFaceCullingMode ),
- mPremultipledAlphaEnabled, mDepthWriteMode, mDepthTestMode, mDepthFunction, mStencilParameters );
+ mRenderer = Render::Renderer::New(mRenderDataProvider, mGeometry, mBlendBitmask, GetBlendColor(), static_cast<FaceCullingMode::Type>(mFaceCullingMode), mPremultipledAlphaEnabled, mDepthWriteMode, mDepthTestMode, mDepthFunction, mStencilParameters);
- OwnerPointer< Render::Renderer > transferOwnership( mRenderer );
- mSceneController->GetRenderMessageDispatcher().AddRenderer( transferOwnership );
+ OwnerPointer<Render::Renderer> transferOwnership(mRenderer);
+ mSceneController->GetRenderMessageDispatcher().AddRenderer(transferOwnership);
}
//Called just before destroying the scene-graph renderer ( when the "event-thread renderer" is no longer referenced )
-void Renderer::DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
+void Renderer::DisconnectFromSceneGraph(SceneController& sceneController, BufferIndex bufferIndex)
{
//Remove renderer from RenderManager
- if( mRenderer )
+ if(mRenderer)
{
- mSceneController->GetRenderMessageDispatcher().RemoveRenderer( *mRenderer );
+ mSceneController->GetRenderMessageDispatcher().RemoveRenderer(*mRenderer);
mRenderer = nullptr;
}
- mSceneController = nullptr;
+ mSceneController = nullptr;
mRenderDataProvider = nullptr;
}
void Renderer::UpdateTextureSet()
{
- if( mRenderDataProvider )
+ if(mRenderDataProvider)
{
- if( mTextureSet )
+ if(mTextureSet)
{
uint32_t textureCount = mTextureSet->GetTextureCount();
- mRenderDataProvider->mTextures.resize( textureCount );
- mRenderDataProvider->mSamplers.resize( textureCount );
- for( uint32_t i = 0; i<textureCount; ++i )
+ mRenderDataProvider->mTextures.resize(textureCount);
+ mRenderDataProvider->mSamplers.resize(textureCount);
+ for(uint32_t i = 0; i < textureCount; ++i)
{
mRenderDataProvider->mTextures[i] = mTextureSet->GetTexture(i);
mRenderDataProvider->mSamplers[i] = mTextureSet->GetTextureSampler(i);
return *mRenderer;
}
-const CollectedUniformMap& Renderer::GetUniformMap( BufferIndex bufferIndex ) const
+const CollectedUniformMap& Renderer::GetUniformMap(BufferIndex bufferIndex) const
{
return mCollectedUniformMap[bufferIndex];
}
-Renderer::OpacityType Renderer::GetOpacityType( BufferIndex updateBufferIndex, const Node& node ) const
+Renderer::OpacityType Renderer::GetOpacityType(BufferIndex updateBufferIndex, const Node& node) const
{
Renderer::OpacityType opacityType = Renderer::OPAQUE;
- switch( mBlendMode )
+ switch(mBlendMode)
{
case BlendMode::ON: // If the renderer should always be use blending
{
- float alpha = node.GetWorldColor( updateBufferIndex ).a * mOpacity[updateBufferIndex];
- if( alpha <= FULLY_TRANSPARENT )
+ float alpha = node.GetWorldColor(updateBufferIndex).a * mOpacity[updateBufferIndex];
+ if(alpha <= FULLY_TRANSPARENT)
{
opacityType = Renderer::TRANSPARENT;
}
break;
}
- bool shaderRequiresBlending( mShader->HintEnabled( Dali::Shader::Hint::OUTPUT_IS_TRANSPARENT ) );
- if( shaderRequiresBlending || ( mTextureSet && mTextureSet->HasAlpha() ) )
+ bool shaderRequiresBlending(mShader->HintEnabled(Dali::Shader::Hint::OUTPUT_IS_TRANSPARENT));
+ if(shaderRequiresBlending || (mTextureSet && mTextureSet->HasAlpha()))
{
opacityType = Renderer::TRANSLUCENT;
}
// renderer should determine opacity using the actor color
- float alpha = node.GetWorldColor( updateBufferIndex ).a * mOpacity[updateBufferIndex];
- if( alpha <= FULLY_TRANSPARENT )
+ float alpha = node.GetWorldColor(updateBufferIndex).a * mOpacity[updateBufferIndex];
+ if(alpha <= FULLY_TRANSPARENT)
{
opacityType = Renderer::TRANSPARENT;
}
- else if( alpha <= FULLY_OPAQUE )
+ else if(alpha <= FULLY_OPAQUE)
{
opacityType = Renderer::TRANSLUCENT;
}
UpdateTextureSet();
}
-void Renderer::ConnectionsChanged( PropertyOwner& object )
+void Renderer::ConnectionsChanged(PropertyOwner& object)
{
// One of our child objects has changed it's connections. Ensure the uniform
// map gets regenerated during PrepareRender
mRegenerateUniformMap = REGENERATE_UNIFORM_MAP;
}
-void Renderer::UniformMappingsChanged( const UniformMap& mappings )
+void Renderer::UniformMappingsChanged(const UniformMap& mappings)
{
// The mappings are either from PropertyOwner base class, or the Actor
mRegenerateUniformMap = REGENERATE_UNIFORM_MAP;
void Renderer::ObservedObjectDestroyed(PropertyOwner& owner)
{
- if( reinterpret_cast<PropertyOwner*>(mShader) == &owner )
+ if(reinterpret_cast<PropertyOwner*>(mShader) == &owner)
{
mShader = nullptr;
}
}
-void Renderer::SetDrawCommands( Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size )
+void Renderer::SetDrawCommands(Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size)
{
mDrawCommands.clear();
- mDrawCommands.insert( mDrawCommands.end(), pDrawCommands, pDrawCommands+size );
+ mDrawCommands.insert(mDrawCommands.end(), pDrawCommands, pDrawCommands + size);
mResendFlag |= RESEND_DRAW_COMMANDS;
}
#define DALI_INTERNAL_SCENE_GRAPH_RENDERER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
* limitations under the License.
*/
-#include <dali/public-api/rendering/geometry.h>
-#include <dali/public-api/rendering/renderer.h> // Dali::Renderer
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/internal/common/blending-options.h>
#include <dali/internal/common/type-abstraction-enums.h>
#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/uniform-map.h>
-#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
-#include <dali/internal/update/common/animatable-property.h>
#include <dali/internal/render/data-providers/render-data-provider.h>
#include <dali/internal/render/renderers/render-renderer.h>
+#include <dali/internal/update/common/animatable-property.h>
+#include <dali/internal/update/common/property-owner.h>
+#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
+#include <dali/internal/update/common/uniform-map.h>
+#include <dali/public-api/rendering/geometry.h>
+#include <dali/public-api/rendering/renderer.h> // Dali::Renderer
namespace Dali
{
-
namespace Internal
{
-
namespace Render
{
class Renderer;
class Geometry;
-}
+} // namespace Render
namespace SceneGraph
{
class TextureSet;
class Geometry;
-class Renderer : public PropertyOwner,
- public UniformMapDataProvider,
- public UniformMap::Observer,
- public ConnectionChangePropagator::Observer
+class Renderer : public PropertyOwner,
+ public UniformMapDataProvider,
+ public UniformMap::Observer,
+ public ConnectionChangePropagator::Observer
{
public:
-
enum OpacityType
{
OPAQUE,
* Overriden delete operator
* Deletes the renderer from its global memory pool
*/
- void operator delete( void* ptr );
+ void operator delete(void* ptr);
/**
* Set the texture set for the renderer
* @param[in] textureSet The texture set this renderer will use
*/
- void SetTextures( TextureSet* textureSet );
+ void SetTextures(TextureSet* textureSet);
/**
* Returns current texture set object
* Set the shader for the renderer
* @param[in] shader The shader this renderer will use
*/
- void SetShader( Shader* shader );
+ void SetShader(Shader* shader);
/**
* Get the shader used by this renderer
* Set the geometry for the renderer
* @param[in] geometry The geometry this renderer will use
*/
- void SetGeometry( Render::Geometry* geometry );
+ void SetGeometry(Render::Geometry* geometry);
/**
* Set the depth index
* @param[in] depthIndex the new depth index to use
*/
- void SetDepthIndex( int depthIndex );
+ void SetDepthIndex(int depthIndex);
/**
* @brief Get the depth index
* Set the face culling mode
* @param[in] faceCullingMode to use
*/
- void SetFaceCullingMode( FaceCullingMode::Type faceCullingMode );
+ void SetFaceCullingMode(FaceCullingMode::Type faceCullingMode);
/**
* Get face culling mode
* Set the blending mode
* @param[in] blendingMode to use
*/
- void SetBlendMode( BlendMode::Type blendingMode );
+ void SetBlendMode(BlendMode::Type blendingMode);
/**
* Get the blending mode
* Set the blending options. This should only be called from the update thread.
* @param[in] options A bitmask of blending options.
*/
- void SetBlendingOptions( uint32_t options );
+ void SetBlendingOptions(uint32_t options);
/**
* Get the blending options
* Set the blend color for blending operation
* @param blendColor to pass to GL
*/
- void SetBlendColor( const Vector4& blendColor );
+ void SetBlendColor(const Vector4& blendColor);
/**
* Get the blending color
* Set the index of first element for indexed draw
* @param[in] firstElement index of first element to draw
*/
- void SetIndexedDrawFirstElement( uint32_t firstElement );
+ void SetIndexedDrawFirstElement(uint32_t firstElement);
/**
* Get the index of first element for indexed draw
* Set the number of elements to draw by indexed draw
* @param[in] elementsCount number of elements to draw
*/
- void SetIndexedDrawElementsCount( uint32_t elementsCount );
+ void SetIndexedDrawElementsCount(uint32_t elementsCount);
/**
* Get the number of elements to draw by indexed draw
* @brief Set whether the Pre-multiplied Alpha Blending is required
* @param[in] preMultipled whether alpha is pre-multiplied.
*/
- void EnablePreMultipliedAlpha( bool preMultipled );
+ void EnablePreMultipliedAlpha(bool preMultipled);
/**
* @brief Query whether alpha is pre-multiplied.
* Sets the depth buffer write mode
* @param[in] depthWriteMode The depth buffer write mode
*/
- void SetDepthWriteMode( DepthWriteMode::Type depthWriteMode );
+ void SetDepthWriteMode(DepthWriteMode::Type depthWriteMode);
/**
* Get the depth buffer write mode
* Sets the depth buffer test mode
* @param[in] depthTestMode The depth buffer test mode
*/
- void SetDepthTestMode( DepthTestMode::Type depthTestMode );
+ void SetDepthTestMode(DepthTestMode::Type depthTestMode);
/**
* Get the depth buffer test mode
* Sets the depth function
* @param[in] depthFunction The depth function
*/
- void SetDepthFunction( DepthFunction::Type depthFunction );
+ void SetDepthFunction(DepthFunction::Type depthFunction);
/**
* Get the depth function
* Sets the render mode
* @param[in] mode The render mode
*/
- void SetRenderMode( RenderMode::Type mode );
+ void SetRenderMode(RenderMode::Type mode);
/**
* Sets the stencil function
* @param[in] stencilFunction The stencil function
*/
- void SetStencilFunction( StencilFunction::Type stencilFunction );
+ void SetStencilFunction(StencilFunction::Type stencilFunction);
/**
* Sets the stencil function mask
* @param[in] stencilFunctionMask The stencil function mask
*/
- void SetStencilFunctionMask( int stencilFunctionMask );
+ void SetStencilFunctionMask(int stencilFunctionMask);
/**
* Sets the stencil function reference
* @param[in] stencilFunctionReference The stencil function reference
*/
- void SetStencilFunctionReference( int stencilFunctionReference );
+ void SetStencilFunctionReference(int stencilFunctionReference);
/**
* Sets the stencil mask
* @param[in] stencilMask The stencil mask
*/
- void SetStencilMask( int stencilMask );
+ void SetStencilMask(int stencilMask);
/**
* Sets the stencil operation for when the stencil test fails
* @param[in] stencilOperationOnFail The stencil operation
*/
- void SetStencilOperationOnFail( StencilOperation::Type stencilOperationOnFail );
+ void SetStencilOperationOnFail(StencilOperation::Type stencilOperationOnFail);
/**
* Sets the stencil operation for when the depth test fails
* @param[in] stencilOperationOnZFail The stencil operation
*/
- void SetStencilOperationOnZFail( StencilOperation::Type stencilOperationOnZFail );
+ void SetStencilOperationOnZFail(StencilOperation::Type stencilOperationOnZFail);
/**
* Sets the stencil operation for when the depth test passes
* @param[in] stencilOperationOnZPass The stencil operation
*/
- void SetStencilOperationOnZPass( StencilOperation::Type stencilOperationOnZPass );
+ void SetStencilOperationOnZPass(StencilOperation::Type stencilOperationOnZPass);
/**
* Gets the stencil parameters
* @param[in] updateBufferIndex The current update buffer index.
* @param[in] opacity The opacity
*/
- void BakeOpacity( BufferIndex updateBufferIndex, float opacity );
+ void BakeOpacity(BufferIndex updateBufferIndex, float opacity);
/**
* Gets the opacity
* @param[in] bufferIndex The buffer to read from.
* @return The opacity
*/
- float GetOpacity( BufferIndex updateBufferIndex ) const;
+ float GetOpacity(BufferIndex updateBufferIndex) const;
/**
* Sets the rendering behavior
* @param[in] renderingBehavior The rendering behavior required.
*/
- void SetRenderingBehavior( DevelRenderer::Rendering::Type renderingBehavior );
+ void SetRenderingBehavior(DevelRenderer::Rendering::Type renderingBehavior);
/**
* Gets the rendering behavior
* @param[in] updateBufferIndex The current update buffer index.
* @return Whether this renderer has been updated in the current frame
*/
- bool PrepareRender( BufferIndex updateBufferIndex );
+ bool PrepareRender(BufferIndex updateBufferIndex);
/**
* Retrieve the Render thread renderer
* @param[in] updateBufferIndex The current update buffer index.
* @return OPAQUE if fully opaque, TRANSPARENT if fully transparent and TRANSLUCENT if in between
*/
- OpacityType GetOpacityType( BufferIndex updateBufferIndex, const Node& node ) const;
+ OpacityType GetOpacityType(BufferIndex updateBufferIndex, const Node& node) const;
/**
* Called by the TextureSet to notify to the renderer that it has changed
* @param[in] sceneController The scene controller - used for sending messages to render thread
* @param[in] bufferIndex The current buffer index - used for sending messages to render thread
*/
- void ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
+ void ConnectToSceneGraph(SceneController& sceneController, BufferIndex bufferIndex);
/**
* Disconnect the object from the scene graph
* @param[in] sceneController The scene controller - used for sending messages to render thread
* @param[in] bufferIndex The current buffer index - used for sending messages to render thread
*/
- void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
+ void DisconnectFromSceneGraph(SceneController& sceneController, BufferIndex bufferIndex);
public: // Implementation of ConnectionChangePropagator
/**
/**
* @copydoc UniformMap::Observer::UniformMappingsChanged
*/
- void UniformMappingsChanged( const UniformMap& mappings ) override;
+ void UniformMappingsChanged(const UniformMap& mappings) override;
public: // ConnectionChangePropagator::Observer
-
/**
* @copydoc ConnectionChangePropagator::ConnectionsChanged
*/
- void ConnectionsChanged( PropertyOwner& owner ) override;
+ void ConnectionsChanged(PropertyOwner& owner) override;
/**
* @copydoc ConnectionChangePropagator::ConnectedUniformMapChanged
*/
- void ConnectedUniformMapChanged( ) override;
+ void ConnectedUniformMapChanged() override;
/**
* @copydoc ConnectionChangePropagator::ConnectedUniformMapChanged
/**
* @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
*/
- virtual void ResetDefaultProperties( BufferIndex updateBufferIndex ){};
+ virtual void ResetDefaultProperties(BufferIndex updateBufferIndex){};
public: // From UniformMapDataProvider
-
/**
* @copydoc UniformMapDataProvider::GetUniformMapChanged
*/
- bool GetUniformMapChanged( BufferIndex bufferIndex ) const override{ return mUniformMapChanged[bufferIndex];}
+ bool GetUniformMapChanged(BufferIndex bufferIndex) const override
+ {
+ return mUniformMapChanged[bufferIndex];
+ }
/**
* @copydoc UniformMapDataProvider::GetUniformMap
*/
- const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const override;
+ const CollectedUniformMap& GetUniformMap(BufferIndex bufferIndex) const override;
- void SetDrawCommands( Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size );
+ void SetDrawCommands(Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size);
private:
-
/**
* Protected constructor; See also Renderer::New()
*/
void UpdateTextureSet();
private:
-
- CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps collected by the renderer
-
- SceneController* mSceneController; ///< Used for initializing renderers
- Render::Renderer* mRenderer; ///< Raw pointer to the renderer (that's owned by RenderManager)
- TextureSet* mTextureSet; ///< The texture set this renderer uses. (Not owned)
- Render::Geometry* mGeometry; ///< The geometry this renderer uses. (Not owned)
- Shader* mShader; ///< The shader this renderer uses. (Not owned)
- RenderDataProvider* mRenderDataProvider; ///< The render data provider
- OwnerPointer< Vector4 > mBlendColor; ///< The blend color for blending operation
-
- Dali::Internal::Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options
-
- uint32_t mIndexedDrawFirstElement; ///< first element index to be drawn using indexed draw
- uint32_t mIndexedDrawElementsCount; ///< number of elements to be drawn using indexed draw
- uint32_t mBlendBitmask; ///< The bitmask of blending options
- uint32_t mRegenerateUniformMap; ///< 2 if the map should be regenerated, 1 if it should be copied.
- uint32_t mResendFlag; ///< Indicate whether data should be resent to the renderer
-
- DepthFunction::Type mDepthFunction:4; ///< Local copy of the depth function
- FaceCullingMode::Type mFaceCullingMode:3; ///< Local copy of the mode of face culling
- BlendMode::Type mBlendMode:3; ///< Local copy of the mode of blending
- DepthWriteMode::Type mDepthWriteMode:3; ///< Local copy of the depth write mode
- DepthTestMode::Type mDepthTestMode:3; ///< Local copy of the depth test mode
- DevelRenderer::Rendering::Type mRenderingBehavior:2; ///< The rendering behavior
- bool mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame
- bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
+ CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps collected by the renderer
+
+ SceneController* mSceneController; ///< Used for initializing renderers
+ Render::Renderer* mRenderer; ///< Raw pointer to the renderer (that's owned by RenderManager)
+ TextureSet* mTextureSet; ///< The texture set this renderer uses. (Not owned)
+ Render::Geometry* mGeometry; ///< The geometry this renderer uses. (Not owned)
+ Shader* mShader; ///< The shader this renderer uses. (Not owned)
+ RenderDataProvider* mRenderDataProvider; ///< The render data provider
+ OwnerPointer<Vector4> mBlendColor; ///< The blend color for blending operation
+
+ Dali::Internal::Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options
+
+ uint32_t mIndexedDrawFirstElement; ///< first element index to be drawn using indexed draw
+ uint32_t mIndexedDrawElementsCount; ///< number of elements to be drawn using indexed draw
+ uint32_t mBlendBitmask; ///< The bitmask of blending options
+ uint32_t mRegenerateUniformMap; ///< 2 if the map should be regenerated, 1 if it should be copied.
+ uint32_t mResendFlag; ///< Indicate whether data should be resent to the renderer
+
+ DepthFunction::Type mDepthFunction : 4; ///< Local copy of the depth function
+ FaceCullingMode::Type mFaceCullingMode : 3; ///< Local copy of the mode of face culling
+ BlendMode::Type mBlendMode : 3; ///< Local copy of the mode of blending
+ DepthWriteMode::Type mDepthWriteMode : 3; ///< Local copy of the depth write mode
+ DepthTestMode::Type mDepthTestMode : 3; ///< Local copy of the depth test mode
+ DevelRenderer::Rendering::Type mRenderingBehavior : 2; ///< The rendering behavior
+ bool mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame
+ bool mPremultipledAlphaEnabled : 1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
std::vector<Dali::DevelRenderer::DrawCommand> mDrawCommands;
public:
-
- AnimatableProperty< float > mOpacity; ///< The opacity value
- int32_t mDepthIndex; ///< Used only in PrepareRenderInstructions
-
+ AnimatableProperty<float> mOpacity; ///< The opacity value
+ int32_t mDepthIndex; ///< Used only in PrepareRenderInstructions
};
-
/// Messages
-inline void SetTexturesMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, const TextureSet& textureSet )
+inline void SetTexturesMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const TextureSet& textureSet)
{
using LocalType = MessageValue1<Renderer, TextureSet*>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &renderer, &Renderer::SetTextures, const_cast<TextureSet*>(&textureSet) );
+ new(slot) LocalType(&renderer, &Renderer::SetTextures, const_cast<TextureSet*>(&textureSet));
}
-inline void SetGeometryMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, const Render::Geometry& geometry )
+inline void SetGeometryMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const Render::Geometry& geometry)
{
using LocalType = MessageValue1<Renderer, Render::Geometry*>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &renderer, &Renderer::SetGeometry, const_cast<Render::Geometry*>(&geometry) );
+ new(slot) LocalType(&renderer, &Renderer::SetGeometry, const_cast<Render::Geometry*>(&geometry));
}
-inline void SetShaderMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, const Shader& shader )
+inline void SetShaderMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const Shader& shader)
{
using LocalType = MessageValue1<Renderer, Shader*>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &renderer, &Renderer::SetShader, const_cast<Shader*>( &shader ) );
+ new(slot) LocalType(&renderer, &Renderer::SetShader, const_cast<Shader*>(&shader));
}
-inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int depthIndex )
+inline void SetDepthIndexMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int depthIndex)
{
using LocalType = MessageValue1<Renderer, int>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &renderer, &Renderer::SetDepthIndex, depthIndex );
+ new(slot) LocalType(&renderer, &Renderer::SetDepthIndex, depthIndex);
}
-inline void SetFaceCullingModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, FaceCullingMode::Type faceCullingMode )
+inline void SetFaceCullingModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, FaceCullingMode::Type faceCullingMode)
{
using LocalType = MessageValue1<Renderer, FaceCullingMode::Type>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetFaceCullingMode, faceCullingMode );
+ new(slot) LocalType(&renderer, &Renderer::SetFaceCullingMode, faceCullingMode);
}
-inline void SetBlendModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, BlendMode::Type blendingMode )
+inline void SetBlendModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, BlendMode::Type blendingMode)
{
using LocalType = MessageValue1<Renderer, BlendMode::Type>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetBlendMode, blendingMode );
+ new(slot) LocalType(&renderer, &Renderer::SetBlendMode, blendingMode);
}
-inline void SetBlendingOptionsMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t options )
+inline void SetBlendingOptionsMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t options)
{
using LocalType = MessageValue1<Renderer, uint32_t>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetBlendingOptions, options );
+ new(slot) LocalType(&renderer, &Renderer::SetBlendingOptions, options);
}
-inline void SetBlendColorMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, const Vector4& blendColor )
+inline void SetBlendColorMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const Vector4& blendColor)
{
using LocalType = MessageValue1<Renderer, Vector4>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetBlendColor, blendColor );
+ new(slot) LocalType(&renderer, &Renderer::SetBlendColor, blendColor);
}
-inline void SetIndexedDrawFirstElementMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t firstElement )
+inline void SetIndexedDrawFirstElementMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t firstElement)
{
using LocalType = MessageValue1<Renderer, uint32_t>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetIndexedDrawFirstElement, firstElement );
+ new(slot) LocalType(&renderer, &Renderer::SetIndexedDrawFirstElement, firstElement);
}
-inline void SetIndexedDrawElementsCountMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t elementsCount )
+inline void SetIndexedDrawElementsCountMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t elementsCount)
{
using LocalType = MessageValue1<Renderer, uint32_t>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetIndexedDrawElementsCount, elementsCount );
+ new(slot) LocalType(&renderer, &Renderer::SetIndexedDrawElementsCount, elementsCount);
}
-inline void SetEnablePreMultipliedAlphaMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, bool preMultiplied )
+inline void SetEnablePreMultipliedAlphaMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, bool preMultiplied)
{
using LocalType = MessageValue1<Renderer, bool>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::EnablePreMultipliedAlpha, preMultiplied );
+ new(slot) LocalType(&renderer, &Renderer::EnablePreMultipliedAlpha, preMultiplied);
}
-inline void SetDepthWriteModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DepthWriteMode::Type depthWriteMode )
+inline void SetDepthWriteModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DepthWriteMode::Type depthWriteMode)
{
using LocalType = MessageValue1<Renderer, DepthWriteMode::Type>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetDepthWriteMode, depthWriteMode );
+ new(slot) LocalType(&renderer, &Renderer::SetDepthWriteMode, depthWriteMode);
}
-inline void SetDepthTestModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DepthTestMode::Type depthTestMode )
+inline void SetDepthTestModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DepthTestMode::Type depthTestMode)
{
using LocalType = MessageValue1<Renderer, DepthTestMode::Type>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetDepthTestMode, depthTestMode );
+ new(slot) LocalType(&renderer, &Renderer::SetDepthTestMode, depthTestMode);
}
-inline void SetDepthFunctionMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DepthFunction::Type depthFunction )
+inline void SetDepthFunctionMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DepthFunction::Type depthFunction)
{
using LocalType = MessageValue1<Renderer, DepthFunction::Type>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetDepthFunction, depthFunction );
+ new(slot) LocalType(&renderer, &Renderer::SetDepthFunction, depthFunction);
}
-inline void SetRenderModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, RenderMode::Type mode )
+inline void SetRenderModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, RenderMode::Type mode)
{
using LocalType = MessageValue1<Renderer, RenderMode::Type>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetRenderMode, mode );
+ new(slot) LocalType(&renderer, &Renderer::SetRenderMode, mode);
}
-inline void SetStencilFunctionMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilFunction::Type stencilFunction )
+inline void SetStencilFunctionMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilFunction::Type stencilFunction)
{
using LocalType = MessageValue1<Renderer, StencilFunction::Type>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetStencilFunction, stencilFunction );
+ new(slot) LocalType(&renderer, &Renderer::SetStencilFunction, stencilFunction);
}
-inline void SetStencilFunctionMaskMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int mask )
+inline void SetStencilFunctionMaskMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int mask)
{
using LocalType = MessageValue1<Renderer, int>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetStencilFunctionMask, mask );
+ new(slot) LocalType(&renderer, &Renderer::SetStencilFunctionMask, mask);
}
-inline void SetStencilFunctionReferenceMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilFunctionReference )
+inline void SetStencilFunctionReferenceMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilFunctionReference)
{
using LocalType = MessageValue1<Renderer, int>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetStencilFunctionReference, stencilFunctionReference );
+ new(slot) LocalType(&renderer, &Renderer::SetStencilFunctionReference, stencilFunctionReference);
}
-inline void SetStencilMaskMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilMask )
+inline void SetStencilMaskMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilMask)
{
using LocalType = MessageValue1<Renderer, int>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetStencilMask, stencilMask );
+ new(slot) LocalType(&renderer, &Renderer::SetStencilMask, stencilMask);
}
-inline void SetStencilOperationOnFailMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation )
+inline void SetStencilOperationOnFailMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation)
{
using LocalType = MessageValue1<Renderer, StencilOperation::Type>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetStencilOperationOnFail, stencilOperation );
+ new(slot) LocalType(&renderer, &Renderer::SetStencilOperationOnFail, stencilOperation);
}
-inline void SetStencilOperationOnZFailMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation )
+inline void SetStencilOperationOnZFailMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation)
{
using LocalType = MessageValue1<Renderer, StencilOperation::Type>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetStencilOperationOnZFail, stencilOperation );
+ new(slot) LocalType(&renderer, &Renderer::SetStencilOperationOnZFail, stencilOperation);
}
-inline void SetStencilOperationOnZPassMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation )
+inline void SetStencilOperationOnZPassMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation)
{
using LocalType = MessageValue1<Renderer, StencilOperation::Type>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetStencilOperationOnZPass, stencilOperation );
+ new(slot) LocalType(&renderer, &Renderer::SetStencilOperationOnZPass, stencilOperation);
}
-inline void BakeOpacityMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, float opacity )
+inline void BakeOpacityMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, float opacity)
{
using LocalType = MessageDoubleBuffered1<Renderer, float>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::BakeOpacity, opacity );
+ new(slot) LocalType(&renderer, &Renderer::BakeOpacity, opacity);
}
-inline void SetRenderingBehaviorMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DevelRenderer::Rendering::Type renderingBehavior )
+inline void SetRenderingBehaviorMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DevelRenderer::Rendering::Type renderingBehavior)
{
- using LocalType = MessageValue1< Renderer, DevelRenderer::Rendering::Type >;
+ using LocalType = MessageValue1<Renderer, DevelRenderer::Rendering::Type>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetRenderingBehavior, renderingBehavior );
+ new(slot) LocalType(&renderer, &Renderer::SetRenderingBehavior, renderingBehavior);
}
-inline void SetDrawCommandsMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size )
+inline void SetDrawCommandsMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size)
{
using LocalType = MessageValue2<Renderer, Dali::DevelRenderer::DrawCommand*, uint32_t>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
- new (slot) LocalType( &renderer, &Renderer::SetDrawCommands, pDrawCommands, size );
+ new(slot) LocalType(&renderer, &Renderer::SetDrawCommands, pDrawCommands, size);
}
-
} // namespace SceneGraph
} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_SCENE_GRAPH_TEXTURE_SET_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/rendering/texture-set.h>
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/common/message.h>
#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/public-api/rendering/texture-set.h>
namespace Dali
{
namespace Internal
{
-
namespace Render
{
struct Sampler;
class Texture;
-}
+} // namespace Render
namespace SceneGraph
{
class Renderer;
class TextureSet
{
public:
-
/**
* Construct a new TextureSet.
*/
* Overriden delete operator
* Deletes the texture set from its global memory pool
*/
- void operator delete( void* ptr );
+ void operator delete(void* ptr);
/**
* Set the sampler to be used by the texture at position "index"
* @param[in] index The index of the texture
* @param[in] sampler The sampler to be used by the texture
*/
- void SetSampler( uint32_t index, Render::Sampler* sampler );
+ void SetSampler(uint32_t index, Render::Sampler* sampler);
/**
* Set the texture at position "index"
* @param[in] index The index of the texture
* @param[in] texture The texture
*/
- void SetTexture( uint32_t index, Render::Texture* texture );
+ void SetTexture(uint32_t index, Render::Texture* texture);
/**
* Return whether any texture in the texture set has an alpha channel
*
* @param[in] renderer The renderer using the TextureSet
*/
- void AddObserver( Renderer* renderer );
+ void AddObserver(Renderer* renderer);
/**
* Removes a renderer from the TextureSet renderers list
*
* @param[in] renderer The renderer no longer using the TextureSet
*/
- void RemoveObserver( Renderer* renderer );
+ void RemoveObserver(Renderer* renderer);
/**
* Get the sampler of a texture in the TextureSet
* @param[in] index The index of the texture in the textures array
* @return the sampler used by the texture
*/
- Render::Sampler* GetTextureSampler( uint32_t index )
+ Render::Sampler* GetTextureSampler(uint32_t index)
{
return mSamplers[index];
}
*/
uint32_t GetTextureCount()
{
- return static_cast<uint32_t>( mTextures.Size() );
+ return static_cast<uint32_t>(mTextures.Size());
}
/**
* @param[in] index The index of the texture in the textures array
* @return the pointer to the Texture in that position
*/
- Render::Texture* GetTexture( uint32_t index )
+ Render::Texture* GetTexture(uint32_t index)
{
return mTextures[index];
}
private:
-
/**
* Protected constructor; See also TextureSet::New()
*/
*/
void NotifyChangeToRenderers();
-private: // Data
-
- Vector< Render::Sampler* > mSamplers; ///< List of samplers used by each texture. Not owned
- Vector< Render::Texture* > mTextures; ///< List of Textures. Not owned
- Vector<Renderer*> mRenderers; ///< List of renderers using the TextureSet
- bool mHasAlpha; ///< if any of the textures has an alpha channel
+private: // Data
+ Vector<Render::Sampler*> mSamplers; ///< List of samplers used by each texture. Not owned
+ Vector<Render::Texture*> mTextures; ///< List of Textures. Not owned
+ Vector<Renderer*> mRenderers; ///< List of renderers using the TextureSet
+ bool mHasAlpha; ///< if any of the textures has an alpha channel
};
-inline void SetTextureMessage( EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, Render::Texture* texture )
+inline void SetTextureMessage(EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, Render::Texture* texture)
{
using LocalType = MessageValue2<TextureSet, uint32_t, Render::Texture*>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &textureSet, &TextureSet::SetTexture, index, texture );
+ new(slot) LocalType(&textureSet, &TextureSet::SetTexture, index, texture);
}
-inline void SetSamplerMessage( EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, Render::Sampler* sampler )
+inline void SetSamplerMessage(EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, Render::Sampler* sampler)
{
using LocalType = MessageValue2<TextureSet, uint32_t, Render::Sampler*>;
// Reserve some memory inside the message queue
- uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &textureSet, &TextureSet::SetSampler, index, sampler );
+ new(slot) LocalType(&textureSet, &TextureSet::SetSampler, index, sampler);
}
} // namespace SceneGraph
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
#include <dali/public-api/math/radian.h>
#include <dali/public-api/math/vector2.h>
+#include <dali/internal/common/const-string.h>
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/actors/layer-impl.h>
#include <dali/internal/event/animation/constraint-impl.h>
#include <dali/internal/event/rendering/renderer-impl.h>
#include <dali/internal/event/size-negotiation/relayout-controller-impl.h>
-#include <dali/internal/common/const-string.h>
namespace Dali
{
#define DALI_CUSTOM_ACTOR_IMPL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
ACTOR_BEHAVIOUR_DEFAULT = 0, ///< Use to provide default behaviour (size negotiation is on, event callbacks are not called). @SINCE_1_2_10
DISABLE_SIZE_NEGOTIATION = 1 << 0, ///< True if control does not need size negotiation, i.e. it can be skipped in the algorithm @SINCE_1_0.0
- NOT_IN_USE_1 = 1<<1,
- NOT_IN_USE_2 = 1<<2,
- NOT_IN_USE_3 = 1<<3,
+ NOT_IN_USE_1 = 1 << 1,
+ NOT_IN_USE_2 = 1 << 2,
+ NOT_IN_USE_3 = 1 << 3,
LAST_ACTOR_FLAG ///< Special marker for last actor flag @SINCE_1_0.0
};
#define DALI_CONSTANTS_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
// Subset of X11 Colors (CSS colors)
// https://www.w3.org/TR/css-color-3
-static constexpr Vector4 ALICE_BLUE(240.0f, 248.0f/255.0f, 1.0f, 1.0f); //#F0F8FF
-static constexpr Vector4 ANTIQUE_WHITE(250.0f, 235.0f/255.0f, 215.0f/255.0f, 1.0f); //#FAEBD7
-static constexpr Vector4 AQUA(1.0f, 1.0f, 1.0f, 1.0f); //#00FFFF
-static constexpr Vector4 AQUA_MARINE(127.0f/255.0f, 1.0f, 212.0f/255.0f, 1.0f); //#7FFFD4
-static constexpr Vector4 AZURE(240.0f, 1.0f, 1.0f, 1.0f); //#F0FFFF
-static constexpr Vector4 BEIGE(245.0f/255.0f, 245.0f/255.0f, 220.0f, 1.0f); //#F5F5DC
-static constexpr Vector4 BISQUE(1.0f, 228.0f/255.0f, 196.0f/255.0f, 1.0f); //#FFE4C4
-static constexpr Vector4 BLACK(0.0f, 0.0f, 0.0f, 1.0f); //#000000
-static constexpr Vector4 BLANCHE_DALMOND(1.0f, 235.0f/255.0f, 205.0f/255.0f, 1.0f); //#FFEBCD
-static constexpr Vector4 BLUE(0.0f, 0.0f, 1.0f, 1.0f); //#0000FF
-static constexpr Vector4 BLUE_VIOLET(138.0f/255.0f, 43.0f/255.0f, 226.0f/255.0f, 1.0f); //#8A2BE2
-static constexpr Vector4 BROWN(165.0f/255.0f, 42.0f/255.0f, 42.0f/255.0f, 1.0f); //#A52A2A
-static constexpr Vector4 BURLY_WOOD(222.0f/255.0f, 184.0f/255.0f, 135.0f/255.0f, 1.0f); //#DEB887
-static constexpr Vector4 CADET_BLUE(95.0f/255.0f, 158.0f/255.0f, 160.0f, 1.0f); //#5F9EA0
-static constexpr Vector4 CHARTREUSE(127.0f/255.0f, 1.0f, 0.0f, 1.0f); //#7FFF00
-static constexpr Vector4 CHOCOLATE(210.0f, 105.0f/255.0f, 30.0f, 1.0f); //#D2691E
-static constexpr Vector4 CORAL(1.0f, 127.0f/255.0f, 80.0f, 1.0f); //#FF7F50
-static constexpr Vector4 CORNFLOWER_BLUE(100.0f, 149.0f/255.0f, 237.0f/255.0f, 1.0f); //#6495ED
-static constexpr Vector4 CORNSILK(1.0f, 248.0f/255.0f, 220.0f, 1.0f); //#FFF8DC
-static constexpr Vector4 CRIMSON(220.0f, 20.0f, 60.0f, 1.0f); //#DC143C
-static constexpr Vector4 CYAN(0.0f, 1.0f, 1.0f, 1.0f); //#00FFFF
-static constexpr Vector4 DARK_BLUE(0.0f, 0.0f, 139.0f/255.0f, 1.0f); //#00008B
-static constexpr Vector4 DARK_CYAN(0.0f, 139.0f/255.0f, 139.0f/255.0f, 1.0f); //#008B8B
-static constexpr Vector4 DARK_GOLDENROD(184.0f/255.0f, 134.0f/255.0f, 11.0f/255.0f, 1.0f); //#B8860B
-static constexpr Vector4 DARK_GRAY(169.0f/255.0f, 169.0f/255.0f, 169.0f/255.0f, 1.0f); //#A9A9A9
-static constexpr Vector4 DARK_GREEN(0.0f, 100.0f, 0.0f, 1.0f); //#006400
-static constexpr Vector4 DARK_GREY(169.0f/255.0f, 169.0f/255.0f, 169.0f/255.0f, 1.0f); //#A9A9A9
-static constexpr Vector4 DARK_KHAKI(189.0f/255.0f, 183.0f/255.0f, 107.0f/255.0f, 1.0f); //#BDB76B
-static constexpr Vector4 DARK_MAGENTA(139.0f/255.0f, 0.0f, 139.0f/255.0f, 1.0f); //#8B008B
-static constexpr Vector4 DARK_OLIVE_GREEN(85.0f/255.0f, 107.0f/255.0f, 47.0f/255.0f, 1.0f); //#556B2F
-static constexpr Vector4 DARK_ORANGE(1.0f, 140.0f, 0.0f, 1.0f); //#FF8C00
-static constexpr Vector4 DARK_ORCHID(153.0f/255.0f, 50.0f, 204.0f/255.0f, 1.0f); //#9932CC
-static constexpr Vector4 DARK_RED(139.0f/255.0f, 0.0f, 0.0f, 1.0f); //#8B0000
-static constexpr Vector4 DARK_SALMON(233.0f/255.0f, 150.0f, 122.0f/255.0f, 1.0f); //#E9967A
-static constexpr Vector4 DARK_SEA_GREEN(143.0f/255.0f, 188.0f/255.0f, 143.0f/255.0f, 1.0f); //#8FBC8F
-static constexpr Vector4 DARK_SLATE_BLUE(72.0f/255.0f, 61.0f/255.0f, 139.0f/255.0f, 1.0f); //#483D8B
-static constexpr Vector4 DARK_SLATE_GRAY(47.0f/255.0f, 79.0f/255.0f, 79.0f/255.0f, 1.0f); //#2F4F4F
-static constexpr Vector4 DARK_SLATE_GREY(47.0f/255.0f, 79.0f/255.0f, 79.0f/255.0f, 1.0f); //#2F4F4F
-static constexpr Vector4 DARK_TURQUOISE(0.0f, 206.0f/255.0f, 209.0f/255.0f, 1.0f); //#00CED1
-static constexpr Vector4 DARK_VIOLET(148.0f/255.0f, 0.0f, 211.0f/255.0f, 1.0f); //#9400D3
-static constexpr Vector4 DEEP_PINK(1.0f, 20.0f, 147.0f/255.0f, 1.0f); //#FF1493
-static constexpr Vector4 DEEP_SKY_BLUE(0.0f, 191.0f/255.0f, 1.0f, 1.0f); //#00BFFF
-static constexpr Vector4 DIM_GRAY(105.0f/255.0f, 105.0f/255.0f, 105.0f/255.0f, 1.0f); //#696969
-static constexpr Vector4 DIM_GREY(105.0f/255.0f, 105.0f/255.0f, 105.0f/255.0f, 1.0f); //#696969
-static constexpr Vector4 DODGER_BLUE(30.0f, 144.0f/255.0f, 1.0f, 1.0f); //#1E90FF
-static constexpr Vector4 FIRE_BRICK(178.0f/255.0f, 34.0f/255.0f, 34.0f/255.0f, 1.0f); //#B22222
-static constexpr Vector4 FLORAL_WHITE(1.0f, 250.0f, 240.0f, 1.0f); //#FFFAF0
-static constexpr Vector4 FOREST_GREEN(34.0f/255.0f, 139.0f/255.0f, 34.0f/255.0f, 1.0f); //#228B22
-static constexpr Vector4 FUCHSIA(1.0f, 0.0f, 1.0f, 1.0f); //#FF00FF
-static constexpr Vector4 GAINSBORO(220.0f, 220.0f, 220.0f, 1.0f); //#DCDCDC
-static constexpr Vector4 GHOST_WHITE(248.0f/255.0f, 248.0f/255.0f, 1.0f, 1.0f); //#F8F8FF
-static constexpr Vector4 GOLD(1.0f, 215.0f/255.0f, 0.0f, 1.0f); //#FFD700
-static constexpr Vector4 GOLDEN_ROD(218.0f/255.0f, 165.0f/255.0f, 32.0f/255.0f, 1.0f); //#DAA520
-static constexpr Vector4 GRAY(190.0f/255.0f, 190.0f/255.0f, 190.0f/255.0f, 1.0f); //#BEBEBE
-static constexpr Vector4 GREEN(0.0f, 1.0f, 0.0f, 1.0f); //#00FF00
-static constexpr Vector4 GREEN_YELLOW(173.0f/255.0f, 1.0f, 47.0f/255.0f, 1.0f); //#ADFF2F
-static constexpr Vector4 GREY(128.0f/255.0f, 128.0f/255.0f, 128.0f/255.0f, 1.0f); //#808080
-static constexpr Vector4 HONEYDEW(240.0f, 1.0f, 240.0f, 1.0f); //#F0FFF0
-static constexpr Vector4 HOT_PINK(1.0f, 105.0f/255.0f, 180.0f, 1.0f); //#FF69B4
-static constexpr Vector4 INDIANRED(205.0f/255.0f, 92.0f/255.0f, 92.0f/255.0f, 1.0f); //#CD5C5C
-static constexpr Vector4 INDIGO(75.0f/255.0f, 0.0f, 130.0f, 1.0f); //#4B0082
-static constexpr Vector4 IVORY(1.0f, 1.0f, 240.0f, 1.0f); //#FFFFF0
-static constexpr Vector4 KHAKI(240.0f, 230.0f, 140.0f, 1.0f); //#F0E68C
-static constexpr Vector4 LAVENDER(230.0f, 230.0f, 250.0f, 1.0f); //#E6E6FA
-static constexpr Vector4 LAVENDER_BLUSH(1.0f, 240.0f, 245.0f/255.0f, 1.0f); //#FFF0F5
-static constexpr Vector4 LAWN_GREEN(124.0f/255.0f, 252.0f/255.0f, 0.0f, 1.0f); //#7CFC00
-static constexpr Vector4 LEMON_CHIFFON(1.0f, 250.0f, 205.0f/255.0f, 1.0f); //#FFFACD
-static constexpr Vector4 LIGHT_BLUE(173.0f/255.0f, 216.0f/255.0f, 230.0f, 1.0f); //#ADD8E6
-static constexpr Vector4 LIGHT_CORAL(240.0f, 128.0f/255.0f, 128.0f/255.0f, 1.0f); //#F08080
-static constexpr Vector4 LIGHT_CYAN(224.0f/255.0f, 1.0f, 1.0f, 1.0f); //#E0FFFF
-static constexpr Vector4 LIGHT_GOLDEN_ROD_YELLOW(250.0f, 250.0f, 210.0f, 1.0f); //#FAFAD2
-static constexpr Vector4 LIGHT_GRAY(211.0f/255.0f, 211.0f/255.0f, 211.0f/255.0f, 1.0f); //#D3D3D3
-static constexpr Vector4 LIGHT_GREEN(144.0f/255.0f, 238.0f/255.0f, 144.0f/255.0f, 1.0f); //#90EE90
-static constexpr Vector4 LIGHT_GREY(211.0f/255.0f, 211.0f/255.0f, 211.0f/255.0f, 1.0f); //#D3D3D3
-static constexpr Vector4 LIGHT_PINK(1.0f, 182.0f/255.0f, 193.0f/255.0f, 1.0f); //#FFB6C1
-static constexpr Vector4 LIGHT_SALMON(1.0f, 160.0f, 122.0f/255.0f, 1.0f); //#FFA07A
-static constexpr Vector4 LIGHT_SEA_GREEN(32.0f/255.0f, 178.0f/255.0f, 170.0f, 1.0f); //#20B2AA
-static constexpr Vector4 LIGHT_SKY_BLUE(135.0f/255.0f, 206.0f/255.0f, 250.0f, 1.0f); //#87CEFA
-static constexpr Vector4 LIGHT_SLATE_GRAY(119.0f/255.0f, 136.0f/255.0f, 153.0f/255.0f, 1.0f); //#778899
-static constexpr Vector4 LIGHT_SLATE_GREY(119.0f/255.0f, 136.0f/255.0f, 153.0f/255.0f, 1.0f); //#778899
-static constexpr Vector4 LIGHT_STEEL_BLUE(176.0f/255.0f, 196.0f/255.0f, 222.0f/255.0f, 1.0f); //#B0C4DE
-static constexpr Vector4 LIGHT_YELLOW(1.0f, 1.0f, 224.0f/255.0f, 1.0f); //#FFFFE0
-static constexpr Vector4 LIME(0.0f, 1.0f, 0.0f, 1.0f); //#00FF00
-static constexpr Vector4 LIME_GREEN(50.0f, 205.0f/255.0f, 50.0f, 1.0f); //#32CD32
-static constexpr Vector4 LINEN(250.0f, 240.0f, 230.0f, 1.0f); //#FAF0E6
-static constexpr Vector4 MAGENTA(1.0f, 0.0f, 1.0f, 1.0f); //#FF00FF
-static constexpr Vector4 MAROON(176.0f/255.0f, 48.0f/255.0f, 96.0f/255.0f, 1.0f); //#B03060
-static constexpr Vector4 MEDIUM_AQUA_MARINE(102.0f/255.0f, 205.0f/255.0f, 170.0f, 1.0f); //#66CDAA
-static constexpr Vector4 MEDIUM_BLUE(0.0f, 0.0f, 205.0f/255.0f, 1.0f); //#0000CD
-static constexpr Vector4 MEDIUM_ORCHID(186.0f/255.0f, 85.0f/255.0f, 211.0f/255.0f, 1.0f); //#BA55D3
-static constexpr Vector4 MEDIUM_PURPLE(147.0f/255.0f, 112.0f/255.0f, 219.0f/255.0f, 1.0f); //#9370DB
-static constexpr Vector4 MEDIUM_SEA_GREEN(60.0f, 179.0f/255.0f, 113.0f/255.0f, 1.0f); //#3CB371
-static constexpr Vector4 MEDIUM_SLATE_BLUE(123.0f/255.0f, 104.0f/255.0f, 238.0f/255.0f, 1.0f); //#7B68EE
-static constexpr Vector4 MEDIUM_SPRING_GREEN(0.0f, 250.0f, 154.0f/255.0f, 1.0f); //#00FA9A
-static constexpr Vector4 MEDIUM_TURQUOISE(72.0f/255.0f, 209.0f/255.0f, 204.0f/255.0f, 1.0f); //#48D1CC
-static constexpr Vector4 MEDIUM_VIOLETRED(199.0f/255.0f, 21.0f/255.0f, 133.0f/255.0f, 1.0f); //#C71585
-static constexpr Vector4 MIDNIGHT_BLUE(25.0f/255.0f, 25.0f/255.0f, 112.0f/255.0f, 1.0f); //#191970
-static constexpr Vector4 MINT_CREAM(245.0f/255.0f, 1.0f, 250.0f, 1.0f); //#F5FFFA
-static constexpr Vector4 MISTY_ROSE(1.0f, 228.0f/255.0f, 225.0f/255.0f, 1.0f); //#FFE4E1
-static constexpr Vector4 MOCCASIN(1.0f, 228.0f/255.0f, 181.0f/255.0f, 1.0f); //#FFE4B5
-static constexpr Vector4 NAVAJO_WHITE(1.0f, 222.0f/255.0f, 173.0f/255.0f, 1.0f); //#FFDEAD
-static constexpr Vector4 NAVY(0.0f, 0.0f, 128.0f/255.0f, 1.0f); //#000080
-static constexpr Vector4 OLD_LACE(253.0f/255.0f, 245.0f/255.0f, 230.0f, 1.0f); //#FDF5E6
-static constexpr Vector4 OLIVE(128.0f/255.0f, 128.0f/255.0f, 0.0f, 1.0f); //#808000
-static constexpr Vector4 OLIVE_DRAB(107.0f/255.0f, 142.0f/255.0f, 35.0f/255.0f, 1.0f); //#6B8E23
-static constexpr Vector4 ORANGE(1.0f, 165.0f/255.0f, 0.0f, 1.0f); //#FFA500
-static constexpr Vector4 ORANGE_RED(1.0f, 69.0f/255.0f, 0.0f, 1.0f); //#FF4500
-static constexpr Vector4 ORCHID(218.0f/255.0f, 112.0f/255.0f, 214.0f/255.0f, 1.0f); //#DA70D6
-static constexpr Vector4 PALE_GOLDEN_ROD(238.0f/255.0f, 232.0f/255.0f, 170.0f, 1.0f); //#EEE8AA
-static constexpr Vector4 PALE_GREEN(152.0f/255.0f, 251.0f/255.0f, 152.0f/255.0f, 1.0f); //#98FB98
-static constexpr Vector4 PALE_TURQUOISE(175.0f/255.0f, 238.0f/255.0f, 238.0f/255.0f, 1.0f); //#AFEEEE
-static constexpr Vector4 PALE_VIOLET_RED(219.0f/255.0f, 112.0f/255.0f, 147.0f/255.0f, 1.0f); //#DB7093
-static constexpr Vector4 PAPAYA_WHIP(1.0f, 239.0f/255.0f, 213.0f/255.0f, 1.0f); //#FFEFD5
-static constexpr Vector4 PEACH_PUFF(1.0f, 218.0f/255.0f, 185.0f/255.0f, 1.0f); //#FFDAB9
-static constexpr Vector4 PERU(205.0f/255.0f, 133.0f/255.0f, 63.0f/255.0f, 1.0f); //#CD853F
-static constexpr Vector4 PINK(1.0f, 192.0f/255.0f, 203.0f/255.0f, 1.0f); //#FFC0CB
-static constexpr Vector4 PLUM(221.0f/255.0f, 160.0f, 221.0f/255.0f, 1.0f); //#DDA0DD
-static constexpr Vector4 POWDER_BLUE(176.0f/255.0f, 224.0f/255.0f, 230.0f, 1.0f); //#B0E0E6
-static constexpr Vector4 PURPLE(160.0f/255.0f, 32.0f, 240.0f/255.0f, 1.0f); //#A020F0
-static constexpr Vector4 RED(1.0f, 0.0f, 0.0f, 1.0f); //#FF0000
-static constexpr Vector4 ROSY_BROWN(188.0f/255.0f, 143.0f/255.0f, 143.0f/255.0f, 1.0f); //#BC8F8F
-static constexpr Vector4 ROYAL_BLUE(65.0f/255.0f, 105.0f/255.0f, 225.0f/255.0f, 1.0f); //#4169E1
-static constexpr Vector4 SADDLE_BROWN(139.0f/255.0f, 69.0f/255.0f, 19.0f/255.0f, 1.0f); //#8B4513
-static constexpr Vector4 SALMON(250.0f, 128.0f/255.0f, 114.0f/255.0f, 1.0f); //#FA8072
-static constexpr Vector4 SANDY_BROWN(244.0f/255.0f, 164.0f/255.0f, 96.0f/255.0f, 1.0f); //#F4A460
-static constexpr Vector4 SEA_GREEN(46.0f/255.0f, 139.0f/255.0f, 87.0f/255.0f, 1.0f); //#2E8B57
-static constexpr Vector4 SEA_SHELL(1.0f, 245.0f/255.0f, 238.0f/255.0f, 1.0f); //#FFF5EE
-static constexpr Vector4 SIENNA(160.0f, 82.0f/255.0f, 45.0f/255.0f, 1.0f); //#A0522D
-static constexpr Vector4 SILVER(192.0f/255.0f, 192.0f/255.0f, 192.0f/255.0f, 1.0f); //#C0C0C0
-static constexpr Vector4 SKY_BLUE(135.0f/255.0f, 206.0f/255.0f, 235.0f/255.0f, 1.0f); //#87CEEB
-static constexpr Vector4 SLATE_BLUE(106.0f/255.0f, 90.0f, 205.0f/255.0f, 1.0f); //#6A5ACD
-static constexpr Vector4 SLATE_GRAY(112.0f/255.0f, 128.0f/255.0f, 144.0f/255.0f, 1.0f); //#708090
-static constexpr Vector4 SLATE_GREY(112.0f/255.0f, 128.0f/255.0f, 144.0f/255.0f, 1.0f); //#708090
-static constexpr Vector4 SNOW(1.0f, 250.0f, 250.0f, 1.0f); //#FFFAFA
-static constexpr Vector4 SPRING_GREEN(0.0f, 1.0f, 127.0f/255.0f, 1.0f); //#00FF7F
-static constexpr Vector4 STEEL_BLUE(70.0f, 130.0f, 180.0f, 1.0f); //#4682B4
-static constexpr Vector4 TAN(210.0f, 180.0f, 140.0f, 1.0f); //#D2B48C
-static constexpr Vector4 TEAL(0.0f, 128.0f/255.0f, 128.0f/255.0f, 1.0f); //#008080
-static constexpr Vector4 THISTLE(216.0f/255.0f, 191.0f/255.0f, 216.0f/255.0f, 1.0f); //#D8BFD8
-static constexpr Vector4 TOMATO(1.0f, 99.0f/255.0f, 71.0f/255.0f, 1.0f); //#FF6347
-static constexpr Vector4 TRANSPARENT(0.0f, 0.0f, 0.0f, 0.0f); //#000000
-static constexpr Vector4 TURQUOISE(64.0f/255.0f, 224.0f/255.0f, 208.0f/255.0f, 1.0f); //#40E0D0
-static constexpr Vector4 VIOLET(238.0f/255.0f, 130.0f, 238.0f/255.0f, 1.0f); //#EE82EE
-static constexpr Vector4 WHEAT(245.0f/255.0f, 222.0f/255.0f, 179.0f/255.0f, 1.0f); //#F5DEB3
-static constexpr Vector4 WHITE(1.0f, 1.0f, 1.0f, 1.0f); //#FFFFFF
-static constexpr Vector4 WHITE_SMOKE(245.0f/255.0f, 245.0f/255.0f, 245.0f/255.0f, 1.0f); //#F5F5F5
-static constexpr Vector4 YELLOW(1.0f, 1.0f, 0.0f, 1.0f); //#FFFF00
-static constexpr Vector4 YELLOW_GREEN(154.0f/255.0f, 205.0f/255.0f, 50.0f, 1.0f); //#9ACD32
+static constexpr Vector4 ALICE_BLUE(240.0f, 248.0f / 255.0f, 1.0f, 1.0f); //#F0F8FF
+static constexpr Vector4 ANTIQUE_WHITE(250.0f, 235.0f / 255.0f, 215.0f / 255.0f, 1.0f); //#FAEBD7
+static constexpr Vector4 AQUA(1.0f, 1.0f, 1.0f, 1.0f); //#00FFFF
+static constexpr Vector4 AQUA_MARINE(127.0f / 255.0f, 1.0f, 212.0f / 255.0f, 1.0f); //#7FFFD4
+static constexpr Vector4 AZURE(240.0f, 1.0f, 1.0f, 1.0f); //#F0FFFF
+static constexpr Vector4 BEIGE(245.0f / 255.0f, 245.0f / 255.0f, 220.0f, 1.0f); //#F5F5DC
+static constexpr Vector4 BISQUE(1.0f, 228.0f / 255.0f, 196.0f / 255.0f, 1.0f); //#FFE4C4
+static constexpr Vector4 BLACK(0.0f, 0.0f, 0.0f, 1.0f); //#000000
+static constexpr Vector4 BLANCHE_DALMOND(1.0f, 235.0f / 255.0f, 205.0f / 255.0f, 1.0f); //#FFEBCD
+static constexpr Vector4 BLUE(0.0f, 0.0f, 1.0f, 1.0f); //#0000FF
+static constexpr Vector4 BLUE_VIOLET(138.0f / 255.0f, 43.0f / 255.0f, 226.0f / 255.0f, 1.0f); //#8A2BE2
+static constexpr Vector4 BROWN(165.0f / 255.0f, 42.0f / 255.0f, 42.0f / 255.0f, 1.0f); //#A52A2A
+static constexpr Vector4 BURLY_WOOD(222.0f / 255.0f, 184.0f / 255.0f, 135.0f / 255.0f, 1.0f); //#DEB887
+static constexpr Vector4 CADET_BLUE(95.0f / 255.0f, 158.0f / 255.0f, 160.0f, 1.0f); //#5F9EA0
+static constexpr Vector4 CHARTREUSE(127.0f / 255.0f, 1.0f, 0.0f, 1.0f); //#7FFF00
+static constexpr Vector4 CHOCOLATE(210.0f, 105.0f / 255.0f, 30.0f, 1.0f); //#D2691E
+static constexpr Vector4 CORAL(1.0f, 127.0f / 255.0f, 80.0f, 1.0f); //#FF7F50
+static constexpr Vector4 CORNFLOWER_BLUE(100.0f, 149.0f / 255.0f, 237.0f / 255.0f, 1.0f); //#6495ED
+static constexpr Vector4 CORNSILK(1.0f, 248.0f / 255.0f, 220.0f, 1.0f); //#FFF8DC
+static constexpr Vector4 CRIMSON(220.0f, 20.0f, 60.0f, 1.0f); //#DC143C
+static constexpr Vector4 CYAN(0.0f, 1.0f, 1.0f, 1.0f); //#00FFFF
+static constexpr Vector4 DARK_BLUE(0.0f, 0.0f, 139.0f / 255.0f, 1.0f); //#00008B
+static constexpr Vector4 DARK_CYAN(0.0f, 139.0f / 255.0f, 139.0f / 255.0f, 1.0f); //#008B8B
+static constexpr Vector4 DARK_GOLDENROD(184.0f / 255.0f, 134.0f / 255.0f, 11.0f / 255.0f, 1.0f); //#B8860B
+static constexpr Vector4 DARK_GRAY(169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f); //#A9A9A9
+static constexpr Vector4 DARK_GREEN(0.0f, 100.0f, 0.0f, 1.0f); //#006400
+static constexpr Vector4 DARK_GREY(169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f); //#A9A9A9
+static constexpr Vector4 DARK_KHAKI(189.0f / 255.0f, 183.0f / 255.0f, 107.0f / 255.0f, 1.0f); //#BDB76B
+static constexpr Vector4 DARK_MAGENTA(139.0f / 255.0f, 0.0f, 139.0f / 255.0f, 1.0f); //#8B008B
+static constexpr Vector4 DARK_OLIVE_GREEN(85.0f / 255.0f, 107.0f / 255.0f, 47.0f / 255.0f, 1.0f); //#556B2F
+static constexpr Vector4 DARK_ORANGE(1.0f, 140.0f, 0.0f, 1.0f); //#FF8C00
+static constexpr Vector4 DARK_ORCHID(153.0f / 255.0f, 50.0f, 204.0f / 255.0f, 1.0f); //#9932CC
+static constexpr Vector4 DARK_RED(139.0f / 255.0f, 0.0f, 0.0f, 1.0f); //#8B0000
+static constexpr Vector4 DARK_SALMON(233.0f / 255.0f, 150.0f, 122.0f / 255.0f, 1.0f); //#E9967A
+static constexpr Vector4 DARK_SEA_GREEN(143.0f / 255.0f, 188.0f / 255.0f, 143.0f / 255.0f, 1.0f); //#8FBC8F
+static constexpr Vector4 DARK_SLATE_BLUE(72.0f / 255.0f, 61.0f / 255.0f, 139.0f / 255.0f, 1.0f); //#483D8B
+static constexpr Vector4 DARK_SLATE_GRAY(47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f); //#2F4F4F
+static constexpr Vector4 DARK_SLATE_GREY(47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f); //#2F4F4F
+static constexpr Vector4 DARK_TURQUOISE(0.0f, 206.0f / 255.0f, 209.0f / 255.0f, 1.0f); //#00CED1
+static constexpr Vector4 DARK_VIOLET(148.0f / 255.0f, 0.0f, 211.0f / 255.0f, 1.0f); //#9400D3
+static constexpr Vector4 DEEP_PINK(1.0f, 20.0f, 147.0f / 255.0f, 1.0f); //#FF1493
+static constexpr Vector4 DEEP_SKY_BLUE(0.0f, 191.0f / 255.0f, 1.0f, 1.0f); //#00BFFF
+static constexpr Vector4 DIM_GRAY(105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f); //#696969
+static constexpr Vector4 DIM_GREY(105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f); //#696969
+static constexpr Vector4 DODGER_BLUE(30.0f, 144.0f / 255.0f, 1.0f, 1.0f); //#1E90FF
+static constexpr Vector4 FIRE_BRICK(178.0f / 255.0f, 34.0f / 255.0f, 34.0f / 255.0f, 1.0f); //#B22222
+static constexpr Vector4 FLORAL_WHITE(1.0f, 250.0f, 240.0f, 1.0f); //#FFFAF0
+static constexpr Vector4 FOREST_GREEN(34.0f / 255.0f, 139.0f / 255.0f, 34.0f / 255.0f, 1.0f); //#228B22
+static constexpr Vector4 FUCHSIA(1.0f, 0.0f, 1.0f, 1.0f); //#FF00FF
+static constexpr Vector4 GAINSBORO(220.0f, 220.0f, 220.0f, 1.0f); //#DCDCDC
+static constexpr Vector4 GHOST_WHITE(248.0f / 255.0f, 248.0f / 255.0f, 1.0f, 1.0f); //#F8F8FF
+static constexpr Vector4 GOLD(1.0f, 215.0f / 255.0f, 0.0f, 1.0f); //#FFD700
+static constexpr Vector4 GOLDEN_ROD(218.0f / 255.0f, 165.0f / 255.0f, 32.0f / 255.0f, 1.0f); //#DAA520
+static constexpr Vector4 GRAY(190.0f / 255.0f, 190.0f / 255.0f, 190.0f / 255.0f, 1.0f); //#BEBEBE
+static constexpr Vector4 GREEN(0.0f, 1.0f, 0.0f, 1.0f); //#00FF00
+static constexpr Vector4 GREEN_YELLOW(173.0f / 255.0f, 1.0f, 47.0f / 255.0f, 1.0f); //#ADFF2F
+static constexpr Vector4 GREY(128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f); //#808080
+static constexpr Vector4 HONEYDEW(240.0f, 1.0f, 240.0f, 1.0f); //#F0FFF0
+static constexpr Vector4 HOT_PINK(1.0f, 105.0f / 255.0f, 180.0f, 1.0f); //#FF69B4
+static constexpr Vector4 INDIANRED(205.0f / 255.0f, 92.0f / 255.0f, 92.0f / 255.0f, 1.0f); //#CD5C5C
+static constexpr Vector4 INDIGO(75.0f / 255.0f, 0.0f, 130.0f, 1.0f); //#4B0082
+static constexpr Vector4 IVORY(1.0f, 1.0f, 240.0f, 1.0f); //#FFFFF0
+static constexpr Vector4 KHAKI(240.0f, 230.0f, 140.0f, 1.0f); //#F0E68C
+static constexpr Vector4 LAVENDER(230.0f, 230.0f, 250.0f, 1.0f); //#E6E6FA
+static constexpr Vector4 LAVENDER_BLUSH(1.0f, 240.0f, 245.0f / 255.0f, 1.0f); //#FFF0F5
+static constexpr Vector4 LAWN_GREEN(124.0f / 255.0f, 252.0f / 255.0f, 0.0f, 1.0f); //#7CFC00
+static constexpr Vector4 LEMON_CHIFFON(1.0f, 250.0f, 205.0f / 255.0f, 1.0f); //#FFFACD
+static constexpr Vector4 LIGHT_BLUE(173.0f / 255.0f, 216.0f / 255.0f, 230.0f, 1.0f); //#ADD8E6
+static constexpr Vector4 LIGHT_CORAL(240.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f); //#F08080
+static constexpr Vector4 LIGHT_CYAN(224.0f / 255.0f, 1.0f, 1.0f, 1.0f); //#E0FFFF
+static constexpr Vector4 LIGHT_GOLDEN_ROD_YELLOW(250.0f, 250.0f, 210.0f, 1.0f); //#FAFAD2
+static constexpr Vector4 LIGHT_GRAY(211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f); //#D3D3D3
+static constexpr Vector4 LIGHT_GREEN(144.0f / 255.0f, 238.0f / 255.0f, 144.0f / 255.0f, 1.0f); //#90EE90
+static constexpr Vector4 LIGHT_GREY(211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f); //#D3D3D3
+static constexpr Vector4 LIGHT_PINK(1.0f, 182.0f / 255.0f, 193.0f / 255.0f, 1.0f); //#FFB6C1
+static constexpr Vector4 LIGHT_SALMON(1.0f, 160.0f, 122.0f / 255.0f, 1.0f); //#FFA07A
+static constexpr Vector4 LIGHT_SEA_GREEN(32.0f / 255.0f, 178.0f / 255.0f, 170.0f, 1.0f); //#20B2AA
+static constexpr Vector4 LIGHT_SKY_BLUE(135.0f / 255.0f, 206.0f / 255.0f, 250.0f, 1.0f); //#87CEFA
+static constexpr Vector4 LIGHT_SLATE_GRAY(119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f); //#778899
+static constexpr Vector4 LIGHT_SLATE_GREY(119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f); //#778899
+static constexpr Vector4 LIGHT_STEEL_BLUE(176.0f / 255.0f, 196.0f / 255.0f, 222.0f / 255.0f, 1.0f); //#B0C4DE
+static constexpr Vector4 LIGHT_YELLOW(1.0f, 1.0f, 224.0f / 255.0f, 1.0f); //#FFFFE0
+static constexpr Vector4 LIME(0.0f, 1.0f, 0.0f, 1.0f); //#00FF00
+static constexpr Vector4 LIME_GREEN(50.0f, 205.0f / 255.0f, 50.0f, 1.0f); //#32CD32
+static constexpr Vector4 LINEN(250.0f, 240.0f, 230.0f, 1.0f); //#FAF0E6
+static constexpr Vector4 MAGENTA(1.0f, 0.0f, 1.0f, 1.0f); //#FF00FF
+static constexpr Vector4 MAROON(176.0f / 255.0f, 48.0f / 255.0f, 96.0f / 255.0f, 1.0f); //#B03060
+static constexpr Vector4 MEDIUM_AQUA_MARINE(102.0f / 255.0f, 205.0f / 255.0f, 170.0f, 1.0f); //#66CDAA
+static constexpr Vector4 MEDIUM_BLUE(0.0f, 0.0f, 205.0f / 255.0f, 1.0f); //#0000CD
+static constexpr Vector4 MEDIUM_ORCHID(186.0f / 255.0f, 85.0f / 255.0f, 211.0f / 255.0f, 1.0f); //#BA55D3
+static constexpr Vector4 MEDIUM_PURPLE(147.0f / 255.0f, 112.0f / 255.0f, 219.0f / 255.0f, 1.0f); //#9370DB
+static constexpr Vector4 MEDIUM_SEA_GREEN(60.0f, 179.0f / 255.0f, 113.0f / 255.0f, 1.0f); //#3CB371
+static constexpr Vector4 MEDIUM_SLATE_BLUE(123.0f / 255.0f, 104.0f / 255.0f, 238.0f / 255.0f, 1.0f); //#7B68EE
+static constexpr Vector4 MEDIUM_SPRING_GREEN(0.0f, 250.0f, 154.0f / 255.0f, 1.0f); //#00FA9A
+static constexpr Vector4 MEDIUM_TURQUOISE(72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f); //#48D1CC
+static constexpr Vector4 MEDIUM_VIOLETRED(199.0f / 255.0f, 21.0f / 255.0f, 133.0f / 255.0f, 1.0f); //#C71585
+static constexpr Vector4 MIDNIGHT_BLUE(25.0f / 255.0f, 25.0f / 255.0f, 112.0f / 255.0f, 1.0f); //#191970
+static constexpr Vector4 MINT_CREAM(245.0f / 255.0f, 1.0f, 250.0f, 1.0f); //#F5FFFA
+static constexpr Vector4 MISTY_ROSE(1.0f, 228.0f / 255.0f, 225.0f / 255.0f, 1.0f); //#FFE4E1
+static constexpr Vector4 MOCCASIN(1.0f, 228.0f / 255.0f, 181.0f / 255.0f, 1.0f); //#FFE4B5
+static constexpr Vector4 NAVAJO_WHITE(1.0f, 222.0f / 255.0f, 173.0f / 255.0f, 1.0f); //#FFDEAD
+static constexpr Vector4 NAVY(0.0f, 0.0f, 128.0f / 255.0f, 1.0f); //#000080
+static constexpr Vector4 OLD_LACE(253.0f / 255.0f, 245.0f / 255.0f, 230.0f, 1.0f); //#FDF5E6
+static constexpr Vector4 OLIVE(128.0f / 255.0f, 128.0f / 255.0f, 0.0f, 1.0f); //#808000
+static constexpr Vector4 OLIVE_DRAB(107.0f / 255.0f, 142.0f / 255.0f, 35.0f / 255.0f, 1.0f); //#6B8E23
+static constexpr Vector4 ORANGE(1.0f, 165.0f / 255.0f, 0.0f, 1.0f); //#FFA500
+static constexpr Vector4 ORANGE_RED(1.0f, 69.0f / 255.0f, 0.0f, 1.0f); //#FF4500
+static constexpr Vector4 ORCHID(218.0f / 255.0f, 112.0f / 255.0f, 214.0f / 255.0f, 1.0f); //#DA70D6
+static constexpr Vector4 PALE_GOLDEN_ROD(238.0f / 255.0f, 232.0f / 255.0f, 170.0f, 1.0f); //#EEE8AA
+static constexpr Vector4 PALE_GREEN(152.0f / 255.0f, 251.0f / 255.0f, 152.0f / 255.0f, 1.0f); //#98FB98
+static constexpr Vector4 PALE_TURQUOISE(175.0f / 255.0f, 238.0f / 255.0f, 238.0f / 255.0f, 1.0f); //#AFEEEE
+static constexpr Vector4 PALE_VIOLET_RED(219.0f / 255.0f, 112.0f / 255.0f, 147.0f / 255.0f, 1.0f); //#DB7093
+static constexpr Vector4 PAPAYA_WHIP(1.0f, 239.0f / 255.0f, 213.0f / 255.0f, 1.0f); //#FFEFD5
+static constexpr Vector4 PEACH_PUFF(1.0f, 218.0f / 255.0f, 185.0f / 255.0f, 1.0f); //#FFDAB9
+static constexpr Vector4 PERU(205.0f / 255.0f, 133.0f / 255.0f, 63.0f / 255.0f, 1.0f); //#CD853F
+static constexpr Vector4 PINK(1.0f, 192.0f / 255.0f, 203.0f / 255.0f, 1.0f); //#FFC0CB
+static constexpr Vector4 PLUM(221.0f / 255.0f, 160.0f, 221.0f / 255.0f, 1.0f); //#DDA0DD
+static constexpr Vector4 POWDER_BLUE(176.0f / 255.0f, 224.0f / 255.0f, 230.0f, 1.0f); //#B0E0E6
+static constexpr Vector4 PURPLE(160.0f / 255.0f, 32.0f, 240.0f / 255.0f, 1.0f); //#A020F0
+static constexpr Vector4 RED(1.0f, 0.0f, 0.0f, 1.0f); //#FF0000
+static constexpr Vector4 ROSY_BROWN(188.0f / 255.0f, 143.0f / 255.0f, 143.0f / 255.0f, 1.0f); //#BC8F8F
+static constexpr Vector4 ROYAL_BLUE(65.0f / 255.0f, 105.0f / 255.0f, 225.0f / 255.0f, 1.0f); //#4169E1
+static constexpr Vector4 SADDLE_BROWN(139.0f / 255.0f, 69.0f / 255.0f, 19.0f / 255.0f, 1.0f); //#8B4513
+static constexpr Vector4 SALMON(250.0f, 128.0f / 255.0f, 114.0f / 255.0f, 1.0f); //#FA8072
+static constexpr Vector4 SANDY_BROWN(244.0f / 255.0f, 164.0f / 255.0f, 96.0f / 255.0f, 1.0f); //#F4A460
+static constexpr Vector4 SEA_GREEN(46.0f / 255.0f, 139.0f / 255.0f, 87.0f / 255.0f, 1.0f); //#2E8B57
+static constexpr Vector4 SEA_SHELL(1.0f, 245.0f / 255.0f, 238.0f / 255.0f, 1.0f); //#FFF5EE
+static constexpr Vector4 SIENNA(160.0f, 82.0f / 255.0f, 45.0f / 255.0f, 1.0f); //#A0522D
+static constexpr Vector4 SILVER(192.0f / 255.0f, 192.0f / 255.0f, 192.0f / 255.0f, 1.0f); //#C0C0C0
+static constexpr Vector4 SKY_BLUE(135.0f / 255.0f, 206.0f / 255.0f, 235.0f / 255.0f, 1.0f); //#87CEEB
+static constexpr Vector4 SLATE_BLUE(106.0f / 255.0f, 90.0f, 205.0f / 255.0f, 1.0f); //#6A5ACD
+static constexpr Vector4 SLATE_GRAY(112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f); //#708090
+static constexpr Vector4 SLATE_GREY(112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f); //#708090
+static constexpr Vector4 SNOW(1.0f, 250.0f, 250.0f, 1.0f); //#FFFAFA
+static constexpr Vector4 SPRING_GREEN(0.0f, 1.0f, 127.0f / 255.0f, 1.0f); //#00FF7F
+static constexpr Vector4 STEEL_BLUE(70.0f, 130.0f, 180.0f, 1.0f); //#4682B4
+static constexpr Vector4 TAN(210.0f, 180.0f, 140.0f, 1.0f); //#D2B48C
+static constexpr Vector4 TEAL(0.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f); //#008080
+static constexpr Vector4 THISTLE(216.0f / 255.0f, 191.0f / 255.0f, 216.0f / 255.0f, 1.0f); //#D8BFD8
+static constexpr Vector4 TOMATO(1.0f, 99.0f / 255.0f, 71.0f / 255.0f, 1.0f); //#FF6347
+static constexpr Vector4 TRANSPARENT(0.0f, 0.0f, 0.0f, 0.0f); //#000000
+static constexpr Vector4 TURQUOISE(64.0f / 255.0f, 224.0f / 255.0f, 208.0f / 255.0f, 1.0f); //#40E0D0
+static constexpr Vector4 VIOLET(238.0f / 255.0f, 130.0f, 238.0f / 255.0f, 1.0f); //#EE82EE
+static constexpr Vector4 WHEAT(245.0f / 255.0f, 222.0f / 255.0f, 179.0f / 255.0f, 1.0f); //#F5DEB3
+static constexpr Vector4 WHITE(1.0f, 1.0f, 1.0f, 1.0f); //#FFFFFF
+static constexpr Vector4 WHITE_SMOKE(245.0f / 255.0f, 245.0f / 255.0f, 245.0f / 255.0f, 1.0f); //#F5F5F5
+static constexpr Vector4 YELLOW(1.0f, 1.0f, 0.0f, 1.0f); //#FFFF00
+static constexpr Vector4 YELLOW_GREEN(154.0f / 255.0f, 205.0f / 255.0f, 50.0f, 1.0f); //#9ACD32
} // namespace Color
#define DALI_VECTOR_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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] vector The vector
* @param[in] value The value to be removed.
*/
-template <class T, class U>
+template<class T, class U>
inline void Erase(Dali::Vector<T>& vector, const U& value)
{
auto begin = vector.Begin();
- auto end = vector.End();
+ auto end = vector.End();
vector.Erase(std::remove(begin, end, value), end);
}
* @param[in] vector The vector
* @param[in] predicate The predicate
*/
-template <class T, class Predicate>
+template<class T, class Predicate>
inline void EraseIf(Dali::Vector<T>& vector, Predicate predicate)
{
auto begin = vector.Begin();
- auto end = vector.End();
+ auto end = vector.End();
vector.Erase(std::remove_if(begin, end, predicate), end);
}
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
struct Property::Value::Impl
{
template<typename... Args>
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
RefObject::RefObject()
: mCount(0)
{
void RefObject::Unreference()
{
- if( (--mCount) == 0 )
+ if((--mCount) == 0)
{
delete this;
}
#define DALI_REF_OBJECT_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
// EXTERNAL INCLUDES
-#include <cstdint> // uint32_t
#include <atomic>
+#include <cstdint> // uint32_t
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
RefObject& operator=(const RefObject& rhs);
private:
- std::atomic_uint32_t mCount {0u}; ///< Reference count
+ std::atomic_uint32_t mCount{0u}; ///< Reference count
};
/**
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
Shader Shader::New(std::string_view vertexShader,
std::string_view fragmentShader,
- Hint::Value hints)
+ Hint::Value hints)
{
Internal::ShaderPtr renderer = Internal::Shader::New(vertexShader, fragmentShader, hints);
return Shader(renderer.Get());
#define DALI_SHADER_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
static Shader New(std::string_view vertexShader,
std::string_view fragmentShader,
- Hint::Value hints = Hint::NONE);
+ Hint::Value hints = Hint::NONE);
/**
* @brief Default constructor, creates an empty handle.
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
DALI_ABORT("Callback lost in SlotDisconnected()");
}
-
int32_t BaseSignal::FindCallback(CallbackBase* callback) const noexcept
{
int32_t index(INVALID_CALLBACK_INDEX);
void BaseSignal::DeleteConnection(std::size_t connectionIndex)
{
-
if(mEmittingFlag)
{
// IMPORTANT - do not remove from items from mSignalConnections, reset instead.
#define DALI_BASE_SIGNAL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
BaseSignal& operator=(BaseSignal&&) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25
private:
- std::vector<SignalConnection> mSignalConnections; ///< Array of connections
- uint32_t mNullConnections{0}; ///< Empty Connections in the array.
+ std::vector<SignalConnection> mSignalConnections; ///< Array of connections
+ uint32_t mNullConnections{0}; ///< Empty Connections in the array.
bool mEmittingFlag{false}; ///< Used to guard against nested Emit() calls
};
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
CallbackBase::CallbackBase(void* object, MemberFunction function, Dispatcher dispatcher)
: mMemberFunction(function)
{
- mImpl.mObjectPointer = object;
- mImpl.mMemberFunctionDispatcher = dispatcher;
- mImpl.mDestructorDispatcher = nullptr; // object is not owned
+ mImpl.mObjectPointer = object;
+ mImpl.mMemberFunctionDispatcher = dispatcher;
+ mImpl.mDestructorDispatcher = nullptr; // object is not owned
}
CallbackBase::CallbackBase(void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor)
: mMemberFunction(function)
{
- mImpl.mObjectPointer = object;
- mImpl.mMemberFunctionDispatcher = dispatcher;
- mImpl.mDestructorDispatcher = destructor; // object is owned
+ mImpl.mObjectPointer = object;
+ mImpl.mMemberFunctionDispatcher = dispatcher;
+ mImpl.mDestructorDispatcher = destructor; // object is owned
}
void CallbackBase::Reset()
#define DALI_CALLBACK_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
// convert function type
using Function = R (*)(Args...);
- returnVal = (*(reinterpret_cast<Function>(callback.mFunction)))(args...);
+ returnVal = (*(reinterpret_cast<Function>(callback.mFunction)))(args...);
}
return returnVal;
CallbackBase(Function function);
protected: // Constructors for deriving classes
-
-
/**
* @brief Member function.
* @SINCE_1_0.0
*/
inline bool operator==(const CallbackBase& lhs, const CallbackBase& rhs)
{
- if (lhs.mFunction == rhs.mFunction &&
- lhs.mImpl.mObjectPointer == rhs.mImpl.mObjectPointer)
+ if(lhs.mFunction == rhs.mFunction &&
+ lhs.mImpl.mObjectPointer == rhs.mImpl.mObjectPointer)
{
return true;
}
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
// Tell the signal that the slot is disconnected
connection.GetSlotObserver()->SlotDisconnected(connection.GetCallback());
-
}
mConnections.Clear();
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
SlotConnection::SlotConnection(SlotObserver* slotObserver, CallbackBase* callback)
: mSlotObserver(slotObserver),
mCallback(callback)
#define DALI_SIGNAL_SLOT_CONNECTIONS_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @{
*/
-
/**
* @brief Slot connection is the connection information held by a connection tracker.
*
#define DALI_DOC_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
* @}
*/
-#endif /* DALI_DOC_H */
+#endif /* DALI_DOC_H */
namespace // unnamed namespace start
{
-
const int gExampleConstant = 0;
void ExampleNonMemberFunction()
{
}
-} // unnamed namespace end
+} // namespace
namespace Dali
{
-
namespace Internal
{
-
ExampleClass::ExampleClass()
{
}
#define DALI_INTERNAL_EXAMPLE_CLASS_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 Dali
{
-
// Forward declarations for the Dali namespace
class XXXX;
namespace Internal
{
-
// Forward declarations for the Dali::Internal namespace
class YYYY;
class ExampleClass : public ExampleBaseClass
{
public: // Types
-
typedef std::list<XXXX> ExampleContainer;
enum ExampleEnum
};
public: // Construction
-
/**
* Create an ExampleClass.
*/
virtual ~ExampleClass();
public: // Public members
-
/**
* Set the name of an ExampleClass.
* @pre TODO - Edit this example comment.
* @return The name of the example class.
* @post TODO - Edit this example comment.
*/
- std::string GetName() const { return mName; }
+ std::string GetName() const
+ {
+ return mName;
+ }
protected: // Protected members
-
/**
* Example helper method, which is accessible by derived classes.
* @param [in] exampleParam An an example parameter.
void HelperMember(ExampleEnum exampleParam);
private: // Private members
-
/**
* Undefined copy constructor; declaring this prevents accidental copying.
* @param[in] A reference to the ExampleClass to copy.
virtual void OnNameSet() = 0;
protected: // Protected data
-
ExampleContainer mContainer;
private: // Private data
-
std::string mName;
};
} // namespace Dali
#endif // DALI_INTERNAL_EXAMPLE_CLASS_H
-