END_TEST;
}
-int UtcDaliAnimationPlayOffStageP(void)
+int UtcDaliAnimationPlayOffStageDiscardP(void)
{
// Test that an animation can be played, when the actor is off-stage.
// When the actor is added to the stage, it should appear at the current position
Actor actor = Actor::New();
Vector3 basePosition(Vector3::ZERO);
DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
- // Not added to the stage!
+ // Not added to the stage yet!
// Build the animation
float durationSeconds(1.0f);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*off-stage*/, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(20,20,20), TEST_LOCATION );
+
+ // Add to the stage
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(40,40,40)/*on-stage*/, TEST_LOCATION );
+
+ // Remove from the stage
+ Stage::GetCurrent().Remove(actor);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position as disconnect behaviour is discard*/, TEST_LOCATION );
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+ application.Render(0);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO, TEST_LOCATION );
+
+ // Add to the stage
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(80,80,80), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+
+
+ application.Render(0);
+ DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayOffStageBakeFinalP(void)
+{
+ // Test that an animation can be played, when the actor is off-stage.
+ // When the actor is added to the stage, it should appear at the current position
+ // i.e. where it would have been anyway, if on-stage from the beginning.
+
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Vector3 basePosition(Vector3::ZERO);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
+ // Not added to the stage!
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ Vector3 targetPosition(100.0f, 100.0f, 100.0f);
+ animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(20,20,20), TEST_LOCATION );
// Add to the stage
Stage::GetCurrent().Add(actor);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- Vector3 expectedPosition(basePosition + (targetPosition - basePosition)*0.4f);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition/*on-stage*/, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(40,40,40)/*on-stage*/, TEST_LOCATION );
// Remove from the stage
Stage::GetCurrent().Remove(actor);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3::ZERO/*back to start position*/, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition /*bake final*/, TEST_LOCATION );
+
+ // Add to the stage
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition /*bake final removed the */, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
+
+ // We did expect the animation to finish
+ application.SendNotification();
+ finishCheck.CheckSignalReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION );
+
+ // Check that nothing has changed after a couple of buffer swaps
+ application.Render(0);
+ DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+
+ application.Render(0);
+ DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliAnimationPlayOffStageBakeP(void)
+{
+ // Test that an animation can be played, when the actor is off-stage.
+ // When the actor is added to the stage, it should appear at the current position
+ // i.e. where it would have been anyway, if on-stage from the beginning.
+
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Vector3 basePosition(Vector3::ZERO);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), basePosition, TEST_LOCATION );
+ // Not added to the stage!
+
+ // Build the animation
+ float durationSeconds(1.0f);
+ Animation animation = Animation::New(durationSeconds);
+ animation.SetDisconnectAction( Animation::Bake );
+ Vector3 targetPosition(100.0f, 100.0f, 100.0f);
+ animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR);
+
+ // Start the animation
+ animation.Play();
+
+ bool signalReceived(false);
+ AnimationFinishCheck finishCheck(signalReceived);
+ animation.FinishedSignal().Connect(&application, finishCheck);
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 20% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(20,20,20), TEST_LOCATION );
// Add to the stage
Stage::GetCurrent().Add(actor);
application.SendNotification();
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 40% progress */);
+
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(40,40,40)/*on-stage*/, TEST_LOCATION );
+
+ // Remove from the stage
+ Stage::GetCurrent().Remove(actor); // baked here
+
+ application.SendNotification();
+ // this render is a no-op in this case as animator is disabled while off stage
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 60% progress */);
+ // We didn't expect the animation to finish yet
+ application.SendNotification();
+ finishCheck.CheckSignalNotReceived();
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(40,40,40) /*baked value*/, TEST_LOCATION );
+
+ // Add back to the stage
+ Stage::GetCurrent().Add(actor);
+
+ application.SendNotification();
application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 80% progress */);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(88,88,88) /* animation restarted at 40,40,40 + 80%*60 */, TEST_LOCATION );
+ application.Render(static_cast<unsigned int>(0.0f) );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(88,88,88) /*baked value*/, TEST_LOCATION );
+ application.Render(static_cast<unsigned int>(0.0f) );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(88,88,88) /*baked value*/, TEST_LOCATION );
+
+ // Remove from the stage
+ Stage::GetCurrent().Remove(actor); // baked here
+
+ application.SendNotification();
+ // this render is a no-op in this case as animator is disabled while off stage
+ application.Render(static_cast<unsigned int>(durationSeconds*200.0f)/* 100% progress */);
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(88,88,88) /*baked value*/, TEST_LOCATION );
+ application.Render(static_cast<unsigned int>(0.0f) );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(88,88,88) /*baked value*/, TEST_LOCATION );
+ application.Render(static_cast<unsigned int>(0.0f) );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(88,88,88) /*baked value*/, TEST_LOCATION );
+
+ // Add back to the stage
+ Stage::GetCurrent().Add(actor);
// We didn't expect the animation to finish yet
application.SendNotification();
finishCheck.CheckSignalNotReceived();
- expectedPosition = Vector3(basePosition + (targetPosition - basePosition)*0.8f);
- DALI_TEST_EQUALS( actor.GetCurrentPosition(), expectedPosition, TEST_LOCATION );
+ DALI_TEST_EQUALS( actor.GetCurrentPosition(), Vector3(88,88,88) , TEST_LOCATION );
application.SendNotification();
application.Render(static_cast<unsigned int>(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/);
// Check that nothing has changed after a couple of buffer swaps
application.Render(0);
DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
+
application.Render(0);
DALI_TEST_EQUALS( targetPosition, actor.GetCurrentPosition(), TEST_LOCATION );
END_TEST;
DALI_TEST_ASSERTION(
{
animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN), targetParentOrigin );
- }, "IsPropertyAnimatable( index )" );
+ }, "Property is not animatable" );
END_TEST;
}
DALI_TEST_ASSERTION(
{
animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_X), targetX );
- }, "IsPropertyAnimatable( index )" );
+ }, "Property is not animatable" );
END_TEST;
}
DALI_TEST_ASSERTION(
{
animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Y), targetY );
- }, "IsPropertyAnimatable( index )" );
+ }, "Property is not animatable" );
END_TEST;
}
DALI_TEST_ASSERTION(
{
animation.AnimateTo( Property(actor, Actor::Property::PARENT_ORIGIN_Z), targetZ );
- }, "IsPropertyAnimatable( index )" );
+ }, "Property is not animatable" );
END_TEST;
}
DALI_TEST_ASSERTION(
{
animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT), targetAnchorPoint);
- }, "IsPropertyAnimatable( index )" );
+ }, "Property is not animatable" );
END_TEST;
}
DALI_TEST_ASSERTION(
{
animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_X), targetX );
- }, "IsPropertyAnimatable( index )" );
+ }, "Property is not animatable" );
END_TEST;
}
DALI_TEST_ASSERTION(
{
animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Y), targetY );
- }, "IsPropertyAnimatable( index )" );
+ }, "Property is not animatable" );
END_TEST;
}
DALI_TEST_ASSERTION(
{
animation.AnimateTo( Property(actor, Actor::Property::ANCHOR_POINT_Z), targetZ );
- }, "IsPropertyAnimatable( index )" );
+ }, "Property is not animatable" );
END_TEST;
}
END_TEST;
}
+
+int UtcDaliLinearConstrainerDetectorRegisterProperty(void)
+{
+ TestApplication application;
+
+ Dali::LinearConstrainer constrainer = Dali::LinearConstrainer::New();
+
+ Property::Index index = constrainer.RegisterProperty( "sceneProperty", 0 );
+ DALI_TEST_EQUALS( index, (Property::Index)PROPERTY_CUSTOM_START_INDEX, TEST_LOCATION );
+ DALI_TEST_EQUALS( constrainer.GetProperty< int32_t >( index ), 0, TEST_LOCATION );
+
+ constrainer.SetProperty( index, -123 );
+ DALI_TEST_EQUALS( constrainer.GetProperty< int32_t >( index ), -123, TEST_LOCATION );
+
+ using Dali::Animation;
+ Animation animation = Animation::New( 1.0f );
+ animation.AnimateTo( Property( constrainer, index ), 99 );
+
+ DALI_TEST_EQUALS( constrainer.GetProperty< int32_t >( index ), -123, TEST_LOCATION );
+ // Start the animation
+ animation.Play();
+
+ application.SendNotification();
+ application.Render( 1000 /* 100% progress */);
+ DALI_TEST_EQUALS( constrainer.GetProperty< int32_t >( index ), 99, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliPathConstrainerDetectorRegisterProperty(void)
+{
+ TestApplication application;
+
+ Dali::PathConstrainer constrainer = Dali::PathConstrainer::New();
+
+ Property::Index index = constrainer.RegisterProperty( "pathProperty", Vector2() );
+ DALI_TEST_EQUALS( index, (Property::Index)PROPERTY_CUSTOM_START_INDEX, TEST_LOCATION );
+ DALI_TEST_EQUALS( constrainer.GetProperty< Vector2 >( index ), Vector2(), TEST_LOCATION );
+
+ constrainer.SetProperty( index, Vector2(1,2) );
+ DALI_TEST_EQUALS( constrainer.GetProperty< Vector2 >( index ), Vector2(1,2), TEST_LOCATION );
+
+ using Dali::Animation;
+ Animation animation = Animation::New( 1.0f );
+ animation.AnimateTo( Property( constrainer, index ), Vector2(3,4) );
+
+ DALI_TEST_EQUALS( constrainer.GetProperty< Vector2 >( index ), Vector2(1,2), TEST_LOCATION );
+ // Start the animation
+ animation.Play();
+
+ application.SendNotification();
+ application.Render( 1000 /* 100% progress */);
+ DALI_TEST_EQUALS( constrainer.GetProperty< Vector2 >( index ), Vector2(3,4), TEST_LOCATION );
+
+ END_TEST;
+}
END_TEST;
}
+
+int UtcDaliGestureDetectorRegisterProperty(void)
+{
+ TestApplication application;
+
+ GestureDetector detector = PinchGestureDetector::New();
+
+ Property::Index index = detector.RegisterProperty( "sceneProperty", 0 );
+ DALI_TEST_EQUALS( index, (Property::Index)PROPERTY_CUSTOM_START_INDEX, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetProperty< int32_t >( index ), 0, TEST_LOCATION );
+
+ detector.SetProperty( index, -123 );
+ DALI_TEST_EQUALS( detector.GetProperty< int32_t >( index ), -123, TEST_LOCATION );
+
+ using Dali::Animation;
+ Animation animation = Animation::New( 1.0f );
+ animation.AnimateTo( Property( detector, index ), 99 );
+
+ DALI_TEST_EQUALS( detector.GetProperty< int32_t >( index ), -123, TEST_LOCATION );
+ // Start the animation
+ animation.Play();
+
+ application.SendNotification();
+ application.Render( 1000 /* 100% progress */);
+ DALI_TEST_EQUALS( detector.GetProperty< int32_t >( index ), 99, TEST_LOCATION );
+
+ END_TEST;
+}
END_TEST;
}
+
+int UtcDaliPanGestureDetectorRegisterProperty(void)
+{
+ TestApplication application;
+
+ GestureDetector detector = PanGestureDetector::New();
+
+ Property::Index index = detector.RegisterProperty( "sceneProperty", 0 );
+ DALI_TEST_EQUALS( index, (Property::Index)PROPERTY_CUSTOM_START_INDEX, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetProperty< int32_t >( index ), 0, TEST_LOCATION );
+ detector.SetProperty( index, -99 );
+
+ using Dali::Animation;
+ Animation animation = Animation::New( 1.0f );
+ animation.AnimateTo( Property( detector, index ), 99 );
+ DALI_TEST_EQUALS( detector.GetProperty< int32_t >( index ), -99, TEST_LOCATION );
+
+ // create another pan gesture
+ GestureDetector detector2 = PanGestureDetector::New();
+ DALI_TEST_EQUALS( detector2.GetProperty< int32_t >( index ), 0, TEST_LOCATION );
+
+ // Start the animation
+ animation.Play();
+ application.SendNotification();
+ application.Render( 500 /* 50% progress */);
+ DALI_TEST_EQUALS( detector.GetCurrentProperty< int32_t >( index ), 0 /*half way*/, TEST_LOCATION );
+
+ // register another pan gesture value
+ Property::Index index2 = detector2.RegisterProperty( "sceneProperty2", 12 );
+ DALI_TEST_EQUALS( index2, (Property::Index)PROPERTY_CUSTOM_START_INDEX, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector2.GetProperty< int32_t >( index2 ), 12, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector2.GetCurrentProperty< int32_t >( index2 ), 12, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( detector.GetProperty< int32_t >( index ), 99 /*target*/, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetCurrentProperty< int32_t >( index ), 0, TEST_LOCATION );
+
+ Animation animation2 = Animation::New( 1.0f );
+ animation2.AnimateTo( Property( detector2, index2 ), -99 );
+ // Start the animation
+ animation2.Play();
+ application.SendNotification();
+ application.Render( 1000 /* 100% more progress */);
+
+ DALI_TEST_EQUALS( detector2.GetProperty< int32_t >( index2 ), -99, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector2.GetCurrentProperty< int32_t >( index2 ), -99, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( detector.GetProperty< int32_t >( index ), 99, TEST_LOCATION );
+ DALI_TEST_EQUALS( detector.GetCurrentProperty< int32_t >( index ), 99, TEST_LOCATION );
+
+ END_TEST;
+}
+
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics 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 UtcDaliPathRegisterProperty(void)
+{
+ TestApplication application;
+
+ Dali::Path path = Dali::Path::New();
+
+ Property::Index index = path.RegisterProperty( "sceneProperty", 0.f );
+ DALI_TEST_EQUALS( index, (Property::Index)PROPERTY_CUSTOM_START_INDEX, TEST_LOCATION );
+ DALI_TEST_EQUALS( path.GetProperty< float >( index ), 0.f, TEST_LOCATION );
+
+ path.SetProperty( index, -1 );
+ DALI_TEST_EQUALS( path.GetProperty< float >( index ), -1.f, TEST_LOCATION );
+
+ using Dali::Animation;
+ Animation animation = Animation::New( 1.0f );
+ animation.AnimateTo( Property( path, index ), 100.f );
+
+ DALI_TEST_EQUALS( path.GetProperty< float >( index ), -1.f, TEST_LOCATION );
+ // Start the animation
+ animation.Play();
+
+ application.SendNotification();
+ application.Render( 1000 /* 100% progress */);
+ DALI_TEST_EQUALS( path.GetProperty< float >( index ), 100.0f, TEST_LOCATION );
+
+ END_TEST;
+}
+
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
+ // change shader program
+ Property::Map map;
+ map["vertex"] = VertexSource;
+ map["fragment"] = FragmentSource;
+ map["hints"] = "MODIFIES_GEOMETRY";
+ shader.SetProperty( Shader::Property::PROGRAM, Property::Value(map) );
+ application.SendNotification();
+ application.Render(100);
+
+ // register another custom property as well
+ Property::Index customIndex = shader.RegisterProperty( "uCustom", Vector3(1,2,3) );
+ DALI_TEST_EQUALS( shader.GetProperty<Vector3>( customIndex ), Vector3(1,2,3), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(100);
+
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+ DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
+
+ Vector3 customValue;
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector3>( "uCustom", customValue ) );
+ DALI_TEST_EQUALS( customValue, Vector3(1,2,3), TEST_LOCATION );
END_TEST;
}
map["hints"] = hintSet;
shader.SetProperty( Shader::Property::PROGRAM, Property::Value(map) );
+ // register a custom property as well
+ Property::Index customIndex = shader.RegisterProperty( "custom", Vector3(1,2,3) );
+ DALI_TEST_EQUALS( shader.GetProperty<Vector3>( customIndex ), Vector3(1,2,3), TEST_LOCATION );
Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
DALI_TEST_CHECK( value.GetType() == Property::MAP);
value = shader.GetCurrentProperty( Shader::Property::PROGRAM );
DALI_TEST_CHECK( value.GetType() == Property::MAP);
outMap = value.GetMap();
+ // check that changing the shader did not cause us to loose custom property
+ DALI_TEST_EQUALS( shader.GetProperty<Vector3>( customIndex ), Vector3(1,2,3), TEST_LOCATION );
+ using Dali::Animation;
+ Animation animation = Animation::New( 0.1f );
+ animation.AnimateTo( Property( shader, customIndex ), Vector3(4,5,6) );
+ animation.Play();
+ application.SendNotification();
+ application.Render(100);
+ DALI_TEST_EQUALS( shader.GetProperty<Vector3>( customIndex ), Vector3(4,5,6), TEST_LOCATION );
v = (*outMap)["vertex"].Get<std::string>();
f = (*outMap)["fragment"].Get<std::string>();
Dali::RenderTask CreateTask( Dali::RenderTaskList& taskList, Dali::Actor& sourceActor, Dali::CameraActor& cameraActor)
{
- return GetImplementation(taskList).CreateTask( &GetImplementation( sourceActor), &GetImplementation(cameraActor) );
+ return RenderTask( GetImplementation(taskList).CreateTask( &GetImplementation( sourceActor), &GetImplementation(cameraActor) ).Get() );
}
} // namespace RenderTaskList
${CMAKE_CURRENT_SOURCE_DIR}/event/images/resource-image-impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/event/images/native-image-impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/event/images/pixel-data-impl.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/event/object/custom-object-internal.cpp
${CMAKE_CURRENT_SOURCE_DIR}/event/render-tasks/render-task-impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/event/render-tasks/render-task-list-impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/event/rendering/frame-buffer-impl.cpp
mName = name;
// ATTENTION: string for debug purposes is not thread safe.
- DALI_LOG_SET_OBJECT_STRING( const_cast< SceneGraph::Node* >( &mNode ), name );
+ DALI_LOG_SET_OBJECT_STRING( const_cast< SceneGraph::Node* >( &GetNode() ), name );
}
uint32_t Actor::GetId() const
{
- return mNode.GetId();
+ return GetNode().GetId();
}
bool Actor::OnStage() const
void Actor::SetParentOrigin( const Vector3& origin )
{
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SetParentOriginMessage( GetEventThreadServices(), mNode, origin );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SetParentOriginMessage( GetEventThreadServices(), GetNode(), origin );
// Cache for event-thread access
if( !mParentOrigin )
void Actor::SetAnchorPoint( const Vector3& anchor )
{
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SetAnchorPointMessage( GetEventThreadServices(), mNode, anchor );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SetAnchorPointMessage( GetEventThreadServices(), GetNode(), anchor );
// Cache for event-thread access
if( !mAnchorPoint )
{
mTargetPosition = position;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, position );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, position );
}
void Actor::SetX( float x )
{
mTargetPosition.x = x;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, x );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, x );
}
void Actor::SetY( float y )
{
mTargetPosition.y = y;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, y );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, y );
}
void Actor::SetZ( float z )
{
mTargetPosition.z = z;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, z );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, z );
}
void Actor::TranslateBy( const Vector3& distance )
{
mTargetPosition += distance;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeRelative, distance );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeRelative, distance );
}
const Vector3& Actor::GetCurrentPosition() const
{
- // mNode is being used in a separate thread; copy the value from the previous update
- return mNode.GetPosition(GetEventThreadServices().GetEventBufferIndex());
+ // node is being used in a separate thread; copy the value from the previous update
+ return GetNode().GetPosition(GetEventThreadServices().GetEventBufferIndex());
}
const Vector3& Actor::GetTargetPosition() const
const Vector3& Actor::GetCurrentWorldPosition() const
{
- // mNode is being used in a separate thread; copy the value from the previous update
- return mNode.GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
+ // node is being used in a separate thread; copy the value from the previous update
+ return GetNode().GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
}
const Vector2 Actor::GetCurrentScreenPosition() const
StagePtr stage = Stage::GetCurrent();
if( stage && OnStage() )
{
- Vector3 worldPosition = mNode.GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
- Vector3 cameraPosition = stage->GetDefaultCameraActor().mNode.GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
+ Vector3 worldPosition = GetNode().GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
+ Vector3 cameraPosition = stage->GetDefaultCameraActor().GetNode().GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
worldPosition -= cameraPosition;
Vector3 actorSize = GetCurrentSize() * GetCurrentWorldScale();
{
// this flag is not animatable so keep the value
mPositionInheritanceMode = mode;
- // mNode is being used in a separate thread; queue a message to set the value
- SetInheritPositionMessage( GetEventThreadServices(), mNode, mode == INHERIT_PARENT_POSITION );
+ // node is being used in a separate thread; queue a message to set the value
+ SetInheritPositionMessage( GetEventThreadServices(), GetNode(), mode == INHERIT_PARENT_POSITION );
}
PositionInheritanceMode Actor::GetPositionInheritanceMode() const
{
if( mInheritPosition != inherit )
{
- // non animateable so keep local copy
+ // non animatable so keep local copy
mInheritPosition = inherit;
- SetInheritPositionMessage( GetEventThreadServices(), mNode, inherit );
+ SetInheritPositionMessage( GetEventThreadServices(), GetNode(), inherit );
}
}
{
mTargetOrientation = orientation;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformPropertyMessage<Quaternion>::Send( GetEventThreadServices(), &mNode, &mNode.mOrientation, &SceneGraph::TransformManagerPropertyHandler<Quaternion>::Bake, orientation );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformPropertyMessage<Quaternion>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mOrientation, &SceneGraph::TransformManagerPropertyHandler<Quaternion>::Bake, orientation );
}
void Actor::RotateBy( const Radian& angle, const Vector3& axis )
{
mTargetOrientation *= Quaternion( relativeRotation );
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformPropertyMessage<Quaternion>::Send( GetEventThreadServices(), &mNode, &mNode.mOrientation, &SceneGraph::TransformManagerPropertyHandler<Quaternion>::BakeRelative, relativeRotation );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformPropertyMessage<Quaternion>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mOrientation, &SceneGraph::TransformManagerPropertyHandler<Quaternion>::BakeRelative, relativeRotation );
}
const Quaternion& Actor::GetCurrentOrientation() const
{
- // mNode is being used in a separate thread; copy the value from the previous update
- return mNode.GetOrientation(GetEventThreadServices().GetEventBufferIndex());
+ // node is being used in a separate thread; copy the value from the previous update
+ return GetNode().GetOrientation(GetEventThreadServices().GetEventBufferIndex());
}
const Quaternion& Actor::GetCurrentWorldOrientation() const
{
- // mNode is being used in a separate thread; copy the value from the previous update
- return mNode.GetWorldOrientation( GetEventThreadServices().GetEventBufferIndex() );
+ // node is being used in a separate thread; copy the value from the previous update
+ return GetNode().GetWorldOrientation( GetEventThreadServices().GetEventBufferIndex() );
}
void Actor::SetScale( float scale )
{
mTargetScale = scale;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, scale );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, scale );
}
void Actor::SetScaleX( float x )
{
mTargetScale.x = x;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, x );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, x );
}
void Actor::SetScaleY( float y )
{
mTargetScale.y = y;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, y );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, y );
}
void Actor::SetScaleZ( float z )
{
mTargetScale.z = z;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, z );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, z );
}
void Actor::ScaleBy(const Vector3& relativeScale)
{
mTargetScale *= relativeScale;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeRelativeMultiply, relativeScale );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeRelativeMultiply, relativeScale );
}
const Vector3& Actor::GetCurrentScale() const
{
- // mNode is being used in a separate thread; copy the value from the previous update
- return mNode.GetScale(GetEventThreadServices().GetEventBufferIndex());
+ // node is being used in a separate thread; copy the value from the previous update
+ return GetNode().GetScale(GetEventThreadServices().GetEventBufferIndex());
}
const Vector3& Actor::GetCurrentWorldScale() const
{
- // mNode is being used in a separate thread; copy the value from the previous update
- return mNode.GetWorldScale( GetEventThreadServices().GetEventBufferIndex() );
+ // node is being used in a separate thread; copy the value from the previous update
+ return GetNode().GetWorldScale( GetEventThreadServices().GetEventBufferIndex() );
}
void Actor::SetInheritScale( bool inherit )
{
if( mInheritScale != inherit )
{
- // non animateable so keep local copy
+ // non animatable so keep local copy
mInheritScale = inherit;
- // mNode is being used in a separate thread; queue a message to set the value
- SetInheritScaleMessage( GetEventThreadServices(), mNode, inherit );
+ // node is being used in a separate thread; queue a message to set the value
+ SetInheritScaleMessage( GetEventThreadServices(), GetNode(), inherit );
}
}
Matrix Actor::GetCurrentWorldMatrix() const
{
- return mNode.GetWorldMatrix(0);
+ return GetNode().GetWorldMatrix(0);
}
void Actor::SetVisible( bool visible )
bool Actor::IsVisible() const
{
- // mNode is being used in a separate thread; copy the value from the previous update
- return mNode.IsVisible( GetEventThreadServices().GetEventBufferIndex() );
+ // node is being used in a separate thread; copy the value from the previous update
+ return GetNode().IsVisible( GetEventThreadServices().GetEventBufferIndex() );
}
void Actor::SetOpacity( float opacity )
{
mTargetColor.a = opacity;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, &mNode.mColor, &AnimatableProperty<Vector4>::BakeW, opacity );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeW, opacity );
}
float Actor::GetCurrentOpacity() const
{
- // mNode is being used in a separate thread; copy the value from the previous update
- return mNode.GetOpacity(GetEventThreadServices().GetEventBufferIndex());
+ // node is being used in a separate thread; copy the value from the previous update
+ return GetNode().GetOpacity(GetEventThreadServices().GetEventBufferIndex());
}
ClippingMode::Type Actor::GetClippingMode() const
const Vector4& Actor::GetCurrentWorldColor() const
{
- return mNode.GetWorldColor( GetEventThreadServices().GetEventBufferIndex() );
+ return GetNode().GetWorldColor( GetEventThreadServices().GetEventBufferIndex() );
}
void Actor::SetColor( const Vector4& color )
{
mTargetColor = color;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodePropertyMessage<Vector4>::Send( GetEventThreadServices(), &mNode, &mNode.mColor, &AnimatableProperty<Vector4>::Bake, color );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodePropertyMessage<Vector4>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::Bake, color );
}
void Actor::SetColorRed( float red )
{
mTargetColor.r = red;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, &mNode.mColor, &AnimatableProperty<Vector4>::BakeX, red );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeX, red );
}
void Actor::SetColorGreen( float green )
{
mTargetColor.g = green;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, &mNode.mColor, &AnimatableProperty<Vector4>::BakeY, green );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeY, green );
}
void Actor::SetColorBlue( float blue )
{
mTargetColor.b = blue;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, &mNode.mColor, &AnimatableProperty<Vector4>::BakeZ, blue );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeZ, blue );
}
const Vector4& Actor::GetCurrentColor() const
{
- // mNode is being used in a separate thread; copy the value from the previous update
- return mNode.GetColor(GetEventThreadServices().GetEventBufferIndex());
+ // node is being used in a separate thread; copy the value from the previous update
+ return GetNode().GetColor(GetEventThreadServices().GetEventBufferIndex());
}
void Actor::SetInheritOrientation( bool inherit )
{
if( mInheritOrientation != inherit )
{
- // non animateable so keep local copy
+ // non animatable so keep local copy
mInheritOrientation = inherit;
- // mNode is being used in a separate thread; queue a message to set the value
- SetInheritOrientationMessage( GetEventThreadServices(), mNode, inherit );
+ // node is being used in a separate thread; queue a message to set the value
+ SetInheritOrientationMessage( GetEventThreadServices(), GetNode(), inherit );
}
}
void Actor::SetColorMode( ColorMode colorMode )
{
- // non animateable so keep local copy
+ // non animatable so keep local copy
mColorMode = colorMode;
- // mNode is being used in a separate thread; queue a message to set the value
- SetColorModeMessage( GetEventThreadServices(), mNode, colorMode );
+ // node is being used in a separate thread; queue a message to set the value
+ SetColorModeMessage( GetEventThreadServices(), GetNode(), colorMode );
}
ColorMode Actor::GetColorMode() const
{
mTargetSize = size;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, mTargetSize );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformPropertyMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, mTargetSize );
// Notification for derived classes
mInsideOnSizeSet = true;
{
mTargetSize.width = width;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, width );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, width );
}
RelayoutRequest();
{
mTargetSize.height = height;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, height );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, height );
}
RelayoutRequest();
{
mTargetSize.depth = depth;
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, &mNode.mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, depth );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodeTransformComponentMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, depth );
}
Vector3 Actor::GetTargetSize() const
const Vector3& Actor::GetCurrentSize() const
{
- // mNode is being used in a separate thread; copy the value from the previous update
- return mNode.GetSize( GetEventThreadServices().GetEventBufferIndex() );
+ // node is being used in a separate thread; copy the value from the previous update
+ return GetNode().GetSize( GetEventThreadServices().GetEventBufferIndex() );
}
Vector3 Actor::GetNaturalSize() const
uint32_t index = static_cast<uint32_t>( mRenderers->size() ); // 4,294,967,295 renderers per actor
RendererPtr rendererPtr = RendererPtr( &renderer );
mRenderers->push_back( rendererPtr );
- AddRendererMessage( GetEventThreadServices(), mNode, renderer.GetRendererSceneObject() );
+ AttachRendererMessage( GetEventThreadServices(), GetNode(), renderer.GetRendererSceneObject() );
return index;
}
if( (*iter).Get() == &renderer )
{
mRenderers->erase( iter );
- RemoveRendererMessage( GetEventThreadServices(), mNode, renderer.GetRendererSceneObject() );
+ DetachRendererMessage( GetEventThreadServices(), GetNode(), renderer.GetRendererSceneObject() );
break;
}
}
if( index < GetRendererCount() )
{
RendererPtr renderer = ( *mRenderers )[ index ];
- RemoveRendererMessage( GetEventThreadServices(), mNode, renderer.Get()->GetRendererSceneObject() );
+ DetachRendererMessage( GetEventThreadServices(), GetNode(), renderer.Get()->GetRendererSceneObject() );
mRenderers->erase( mRenderers->begin()+index );
}
}
mDrawMode = drawMode;
if( drawMode != DrawMode::STENCIL )
{
- // mNode is being used in a separate thread; queue a message to set the value
- SetDrawModeMessage( GetEventThreadServices(), mNode, drawMode );
+ // node is being used in a separate thread; queue a message to set the value
+ SetDrawModeMessage( GetEventThreadServices(), GetNode(), drawMode );
}
}
uint32_t taskCount = taskList.GetTaskCount();
for( uint32_t i = taskCount; i > 0; --i )
{
- Dali::RenderTask task = taskList.GetTask( i - 1 );
- if( ScreenToLocal( Dali::GetImplementation( task ), localX, localY, screenX, screenY ) )
+ RenderTaskPtr task = taskList.GetTask( i - 1 );
+ if( ScreenToLocal( *task, localX, localY, screenX, screenY ) )
{
// found a task where this conversion was ok so return
return true;
// Get the ModelView matrix
Matrix modelView;
- Matrix::Multiply( modelView, mNode.GetWorldMatrix(0), viewMatrix );
+ Matrix::Multiply( modelView, GetNode().GetWorldMatrix(0), viewMatrix );
// Calculate the inverted ModelViewProjection matrix; this will be used for 2 unprojects
Matrix invertedMvp( false/*don't init*/);
BufferIndex bufferIndex( GetEventThreadServices().GetEventBufferIndex() );
// Transforms the ray to the local reference system. As the test is against a sphere, only the translation and scale are needed.
- const Vector3& translation( mNode.GetWorldPosition( bufferIndex ) );
+ const Vector3& translation( GetNode().GetWorldPosition( bufferIndex ) );
Vector3 rayOriginLocal( rayOrigin.x - translation.x, rayOrigin.y - translation.y, rayOrigin.z - translation.z );
// Compute the radius is not needed, square radius it's enough.
- const Vector3& size( mNode.GetSize( bufferIndex ) );
+ const Vector3& size( GetNode().GetSize( bufferIndex ) );
// Scale the sphere.
- const Vector3& scale( mNode.GetWorldScale( bufferIndex ) );
+ const Vector3& scale( GetNode().GetWorldScale( bufferIndex ) );
const float width = size.width * scale.width;
const float height = size.height * scale.height;
Matrix invModelMatrix( false/*don't init*/);
BufferIndex bufferIndex( GetEventThreadServices().GetEventBufferIndex() );
- invModelMatrix = mNode.GetWorldMatrix(0);
+ invModelMatrix = GetNode().GetWorldMatrix(0);
invModelMatrix.Invert();
Vector4 rayOriginLocal( invModelMatrix * rayOrigin );
// Ray travels distance * rayDirLocal to intersect with plane.
distance = a / b;
- const Vector3& size = mNode.GetSize( bufferIndex );
+ const Vector3& size = GetNode().GetSize( bufferIndex );
hitPointLocal.x = rayOriginLocal.x + rayDirLocal.x * distance + size.x * 0.5f;
hitPointLocal.y = rayOriginLocal.y + rayDirLocal.y * distance + size.y * 0.5f;
}
Actor::Actor( DerivedType derivedType, const SceneGraph::Node& node )
-: mParent( NULL ),
+: Object( &node ),
+ mParent( NULL ),
mChildren( NULL ),
mRenderers( NULL ),
- mNode( node ),
mParentOrigin( NULL ),
mAnchorPoint( NULL ),
mRelayoutData( NULL ),
// Guard to allow handle destruction after Core has been destroyed
if( EventThreadServices::IsCoreRunning() )
{
- DestroyNodeMessage( GetEventThreadServices().GetUpdateManager(), mNode );
+ DestroyNodeMessage( GetEventThreadServices().GetUpdateManager(), GetNode() );
GetEventThreadServices().UnregisterObject( this );
}
DALI_ASSERT_DEBUG( mParent != NULL);
// Reparent Node in next Update
- ConnectNodeMessage( GetEventThreadServices().GetUpdateManager(), mParent->mNode, mNode );
+ ConnectNodeMessage( GetEventThreadServices().GetUpdateManager(), mParent->GetNode(), GetNode() );
// Request relayout on all actors that are added to the scenegraph
RelayoutRequest();
void Actor::RecursiveDisconnectFromStage( ActorContainer& disconnectionList )
{
- DALI_ASSERT_ALWAYS( OnStage() );
+ // need to change state first so that internals relying on IsOnStage() inside OnStageDisconnectionInternal() get the correct value
+ mIsOnStage = false;
// Recursively disconnect children
if( mChildren )
OnStageDisconnectionInternal();
DisconnectFromSceneGraph();
-
- mIsOnStage = false;
}
/**
if( OnStage() )
{
- if( IsRoot() || mNode.GetParent() )
+ if( IsRoot() || GetNode().GetParent() )
{
connected = true;
}
void Actor::DepthTraverseActorTree( OwnerPointer<SceneGraph::NodeDepths>& sceneGraphNodeDepths, int32_t& depthIndex )
{
mSortedDepth = depthIndex * DevelLayer::SIBLING_ORDER_MULTIPLIER;
- sceneGraphNodeDepths->Add( const_cast<SceneGraph::Node*>( &mNode ), mSortedDepth );
+ sceneGraphNodeDepths->Add( const_cast<SceneGraph::Node*>( &GetNode() ), mSortedDepth );
// Create/add to children of this node
if( mChildren )
if( Scripting::GetEnumerationProperty< ClippingMode::Type >( property, CLIPPING_MODE_TABLE, CLIPPING_MODE_TABLE_COUNT, convertedValue ) )
{
mClippingMode = convertedValue;
- SetClippingModeMessage( GetEventThreadServices(), mNode, mClippingMode );
+ SetClippingModeMessage( GetEventThreadServices(), GetNode(), mClippingMode );
}
break;
}
if( property.Get( value ) && value != mPositionUsesAnchorPoint )
{
mPositionUsesAnchorPoint = value;
- SetPositionUsesAnchorPointMessage( GetEventThreadServices(), mNode, mPositionUsesAnchorPoint );
+ SetPositionUsesAnchorPointMessage( GetEventThreadServices(), GetNode(), mPositionUsesAnchorPoint );
}
break;
}
DALI_ASSERT_DEBUG( NULL != property );
// property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<bool>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<bool>::Bake, value.Get<bool>() );
+ SceneGraph::NodePropertyMessage<bool>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<bool>::Bake, value.Get<bool>() );
break;
}
DALI_ASSERT_DEBUG( NULL != property );
// property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<int>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<int>::Bake, value.Get<int>() );
+ SceneGraph::NodePropertyMessage<int>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<int>::Bake, value.Get<int>() );
break;
}
DALI_ASSERT_DEBUG( NULL != property );
// property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<float>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<float>::Bake, value.Get<float>() );
+ SceneGraph::NodePropertyMessage<float>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<float>::Bake, value.Get<float>() );
break;
}
// property is being used in a separate thread; queue a message to set the property
if(entry.componentIndex == 0)
{
- SceneGraph::NodePropertyComponentMessage<Vector2>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector2>::BakeX, value.Get<float>() );
+ SceneGraph::NodePropertyComponentMessage<Vector2>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<Vector2>::BakeX, value.Get<float>() );
}
else if(entry.componentIndex == 1)
{
- SceneGraph::NodePropertyComponentMessage<Vector2>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector2>::BakeY, value.Get<float>() );
+ SceneGraph::NodePropertyComponentMessage<Vector2>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<Vector2>::BakeY, value.Get<float>() );
}
else
{
- SceneGraph::NodePropertyMessage<Vector2>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector2>::Bake, value.Get<Vector2>() );
+ SceneGraph::NodePropertyMessage<Vector2>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<Vector2>::Bake, value.Get<Vector2>() );
}
break;
// property is being used in a separate thread; queue a message to set the property
if(entry.componentIndex == 0)
{
- SceneGraph::NodePropertyComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector3>::BakeX, value.Get<float>() );
+ SceneGraph::NodePropertyComponentMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<Vector3>::BakeX, value.Get<float>() );
}
else if(entry.componentIndex == 1)
{
- SceneGraph::NodePropertyComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector3>::BakeY, value.Get<float>() );
+ SceneGraph::NodePropertyComponentMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<Vector3>::BakeY, value.Get<float>() );
}
else if(entry.componentIndex == 2)
{
- SceneGraph::NodePropertyComponentMessage<Vector3>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector3>::BakeZ, value.Get<float>() );
+ SceneGraph::NodePropertyComponentMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<Vector3>::BakeZ, value.Get<float>() );
}
else
{
- SceneGraph::NodePropertyMessage<Vector3>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector3>::Bake, value.Get<Vector3>() );
+ SceneGraph::NodePropertyMessage<Vector3>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<Vector3>::Bake, value.Get<Vector3>() );
}
break;
// property is being used in a separate thread; queue a message to set the property
if(entry.componentIndex == 0)
{
- SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector4>::BakeX, value.Get<float>() );
+ SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<Vector4>::BakeX, value.Get<float>() );
}
else if(entry.componentIndex == 1)
{
- SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector4>::BakeY, value.Get<float>() );
+ SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<Vector4>::BakeY, value.Get<float>() );
}
else if(entry.componentIndex == 2)
{
- SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector4>::BakeZ, value.Get<float>() );
+ SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<Vector4>::BakeZ, value.Get<float>() );
}
else if(entry.componentIndex == 3)
{
- SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector4>::BakeW, value.Get<float>() );
+ SceneGraph::NodePropertyComponentMessage<Vector4>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<Vector4>::BakeW, value.Get<float>() );
}
else
{
- SceneGraph::NodePropertyMessage<Vector4>::Send( GetEventThreadServices(), &mNode, property, &AnimatableProperty<Vector4>::Bake, value.Get<Vector4>() );
+ SceneGraph::NodePropertyMessage<Vector4>::Send( GetEventThreadServices(), &GetNode(), property, &AnimatableProperty<Vector4>::Bake, value.Get<Vector4>() );
}
break;
DALI_ASSERT_DEBUG( NULL != property );
// property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<Quaternion>::Send( GetEventThreadServices(), &mNode, property,&AnimatableProperty<Quaternion>::Bake, value.Get<Quaternion>() );
+ SceneGraph::NodePropertyMessage<Quaternion>::Send( GetEventThreadServices(), &GetNode(), property,&AnimatableProperty<Quaternion>::Bake, value.Get<Quaternion>() );
break;
}
DALI_ASSERT_DEBUG( NULL != property );
// property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<Matrix>::Send( GetEventThreadServices(), &mNode, property,&AnimatableProperty<Matrix>::Bake, value.Get<Matrix>() );
+ SceneGraph::NodePropertyMessage<Matrix>::Send( GetEventThreadServices(), &GetNode(), property,&AnimatableProperty<Matrix>::Bake, value.Get<Matrix>() );
break;
}
DALI_ASSERT_DEBUG( NULL != property );
// property is being used in a separate thread; queue a message to set the property
- SceneGraph::NodePropertyMessage<Matrix3>::Send( GetEventThreadServices(), &mNode, property,&AnimatableProperty<Matrix3>::Bake, value.Get<Matrix3>() );
+ SceneGraph::NodePropertyMessage<Matrix3>::Send( GetEventThreadServices(), &GetNode(), property,&AnimatableProperty<Matrix3>::Bake, value.Get<Matrix3>() );
break;
}
}
}
-const SceneGraph::PropertyOwner* Actor::GetPropertyOwner() const
-{
- return &mNode;
-}
-
-const SceneGraph::PropertyOwner* Actor::GetSceneObject() const
-{
- // This method should only return an object connected to the scene-graph
- return OnStage() ? &mNode : NULL;
-}
-
const PropertyBase* Actor::GetSceneObjectAnimatableProperty( Property::Index index ) const
{
- DALI_ASSERT_ALWAYS( IsPropertyAnimatable( index ) && "Property is not animatable" );
-
const PropertyBase* property( NULL );
- // This method should only return a property of an object connected to the scene-graph
- if( !OnStage() )
- {
- return property;
- }
-
- 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" );
-
- property = animatable->GetSceneGraphProperty();
- }
- 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" );
-
- property = custom->GetSceneGraphProperty();
- }
- else
+ switch( index )
{
- switch( index )
+ case Dali::Actor::Property::SIZE: // FALLTHROUGH
+ case Dali::Actor::Property::SIZE_WIDTH: // FALLTHROUGH
+ case Dali::Actor::Property::SIZE_HEIGHT: // FALLTHROUGH
+ case Dali::Actor::Property::SIZE_DEPTH:
{
- case Dali::Actor::Property::SIZE: // FALLTHROUGH
- case Dali::Actor::Property::SIZE_WIDTH: // FALLTHROUGH
- case Dali::Actor::Property::SIZE_HEIGHT: // FALLTHROUGH
- case Dali::Actor::Property::SIZE_DEPTH:
- {
- property = &mNode.mSize;
- break;
- }
- case Dali::Actor::Property::POSITION: // FALLTHROUGH
- case Dali::Actor::Property::POSITION_X: // FALLTHROUGH
- case Dali::Actor::Property::POSITION_Y: // FALLTHROUGH
- case Dali::Actor::Property::POSITION_Z:
- {
- property = &mNode.mPosition;
- break;
- }
- case Dali::Actor::Property::ORIENTATION:
- {
- property = &mNode.mOrientation;
- break;
- }
- case Dali::Actor::Property::SCALE: // FALLTHROUGH
- case Dali::Actor::Property::SCALE_X: // FALLTHROUGH
- case Dali::Actor::Property::SCALE_Y: // FALLTHROUGH
- case Dali::Actor::Property::SCALE_Z:
- {
- property = &mNode.mScale;
- break;
- }
- case Dali::Actor::Property::VISIBLE:
- {
- property = &mNode.mVisible;
- break;
- }
- case Dali::Actor::Property::COLOR: // FALLTHROUGH
- case Dali::Actor::Property::COLOR_RED: // FALLTHROUGH
- case Dali::Actor::Property::COLOR_GREEN: // FALLTHROUGH
- case Dali::Actor::Property::COLOR_BLUE: // FALLTHROUGH
- case Dali::Actor::Property::COLOR_ALPHA: // FALLTHROUGH
- case Dali::DevelActor::Property::OPACITY:
- {
- property = &mNode.mColor;
- break;
- }
- default:
- {
- break;
- }
+ property = &GetNode().mSize;
+ break;
+ }
+ case Dali::Actor::Property::POSITION: // FALLTHROUGH
+ case Dali::Actor::Property::POSITION_X: // FALLTHROUGH
+ case Dali::Actor::Property::POSITION_Y: // FALLTHROUGH
+ case Dali::Actor::Property::POSITION_Z:
+ {
+ property = &GetNode().mPosition;
+ break;
+ }
+ case Dali::Actor::Property::ORIENTATION:
+ {
+ property = &GetNode().mOrientation;
+ break;
+ }
+ case Dali::Actor::Property::SCALE: // FALLTHROUGH
+ case Dali::Actor::Property::SCALE_X: // FALLTHROUGH
+ case Dali::Actor::Property::SCALE_Y: // FALLTHROUGH
+ case Dali::Actor::Property::SCALE_Z:
+ {
+ property = &GetNode().mScale;
+ break;
+ }
+ case Dali::Actor::Property::VISIBLE:
+ {
+ property = &GetNode().mVisible;
+ break;
+ }
+ case Dali::Actor::Property::COLOR: // FALLTHROUGH
+ case Dali::Actor::Property::COLOR_RED: // FALLTHROUGH
+ case Dali::Actor::Property::COLOR_GREEN: // FALLTHROUGH
+ case Dali::Actor::Property::COLOR_BLUE: // FALLTHROUGH
+ case Dali::Actor::Property::COLOR_ALPHA: // FALLTHROUGH
+ case Dali::DevelActor::Property::OPACITY:
+ {
+ property = &GetNode().mColor;
+ break;
+ }
+ default:
+ {
+ break;
}
}
+ if( !property )
+ {
+ // not our property, ask base
+ property = Object::GetSceneObjectAnimatableProperty( index );
+ }
return property;
}
{
const PropertyInputImpl* property( NULL );
- // This method should only return a property of an object connected to the scene-graph
- if( !OnStage() )
- {
- return property;
- }
-
- 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" );
-
- property = animatable->GetSceneGraphProperty();
- }
- 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" );
- property = custom->GetSceneGraphProperty();
- }
- else
+ switch( index )
{
- switch( index )
+ case Dali::Actor::Property::PARENT_ORIGIN: // FALLTHROUGH
+ case Dali::Actor::Property::PARENT_ORIGIN_X: // FALLTHROUGH
+ case Dali::Actor::Property::PARENT_ORIGIN_Y: // FALLTHROUGH
+ case Dali::Actor::Property::PARENT_ORIGIN_Z:
{
- case Dali::Actor::Property::PARENT_ORIGIN: // FALLTHROUGH
- case Dali::Actor::Property::PARENT_ORIGIN_X: // FALLTHROUGH
- case Dali::Actor::Property::PARENT_ORIGIN_Y: // FALLTHROUGH
- case Dali::Actor::Property::PARENT_ORIGIN_Z:
- {
- property = &mNode.mParentOrigin;
- break;
- }
- case Dali::Actor::Property::ANCHOR_POINT: // FALLTHROUGH
- case Dali::Actor::Property::ANCHOR_POINT_X: // FALLTHROUGH
- case Dali::Actor::Property::ANCHOR_POINT_Y: // FALLTHROUGH
- case Dali::Actor::Property::ANCHOR_POINT_Z:
- {
- property = &mNode.mAnchorPoint;
- break;
- }
- case Dali::Actor::Property::SIZE: // FALLTHROUGH
- case Dali::Actor::Property::SIZE_WIDTH: // FALLTHROUGH
- case Dali::Actor::Property::SIZE_HEIGHT: // FALLTHROUGH
- case Dali::Actor::Property::SIZE_DEPTH:
- {
- property = &mNode.mSize;
- break;
- }
- case Dali::Actor::Property::POSITION: // FALLTHROUGH
- case Dali::Actor::Property::POSITION_X: // FALLTHROUGH
- case Dali::Actor::Property::POSITION_Y: // FALLTHROUGH
- case Dali::Actor::Property::POSITION_Z:
- {
- property = &mNode.mPosition;
- break;
- }
- case Dali::Actor::Property::WORLD_POSITION: // FALLTHROUGH
- case Dali::Actor::Property::WORLD_POSITION_X: // FALLTHROUGH
- case Dali::Actor::Property::WORLD_POSITION_Y: // FALLTHROUGH
- case Dali::Actor::Property::WORLD_POSITION_Z:
- {
- property = &mNode.mWorldPosition;
- break;
- }
- case Dali::Actor::Property::ORIENTATION:
- {
- property = &mNode.mOrientation;
- break;
- }
- case Dali::Actor::Property::WORLD_ORIENTATION:
- {
- property = &mNode.mWorldOrientation;
- break;
- }
- case Dali::Actor::Property::SCALE: // FALLTHROUGH
- case Dali::Actor::Property::SCALE_X: // FALLTHROUGH
- case Dali::Actor::Property::SCALE_Y: // FALLTHROUGH
- case Dali::Actor::Property::SCALE_Z:
- {
- property = &mNode.mScale;
- break;
- }
- case Dali::Actor::Property::WORLD_SCALE:
- {
- property = &mNode.mWorldScale;
- break;
- }
- case Dali::Actor::Property::VISIBLE:
- {
- property = &mNode.mVisible;
- break;
- }
- case Dali::Actor::Property::COLOR: // FALLTHROUGH
- case Dali::Actor::Property::COLOR_RED: // FALLTHROUGH
- case Dali::Actor::Property::COLOR_GREEN: // FALLTHROUGH
- case Dali::Actor::Property::COLOR_BLUE: // FALLTHROUGH
- case Dali::Actor::Property::COLOR_ALPHA: // FALLTHROUGH
- case Dali::DevelActor::Property::OPACITY:
- {
- property = &mNode.mColor;
- break;
- }
- case Dali::Actor::Property::WORLD_COLOR:
- {
- property = &mNode.mWorldColor;
- break;
- }
- case Dali::Actor::Property::WORLD_MATRIX:
- {
- property = &mNode.mWorldMatrix;
- break;
- }
- case Dali::DevelActor::Property::CULLED:
- {
- property = &mNode.mCulled;
- break;
- }
- default:
- {
- break;
- }
+ property = &GetNode().mParentOrigin;
+ break;
+ }
+ case Dali::Actor::Property::ANCHOR_POINT: // FALLTHROUGH
+ case Dali::Actor::Property::ANCHOR_POINT_X: // FALLTHROUGH
+ case Dali::Actor::Property::ANCHOR_POINT_Y: // FALLTHROUGH
+ case Dali::Actor::Property::ANCHOR_POINT_Z:
+ {
+ property = &GetNode().mAnchorPoint;
+ break;
}
+ case Dali::Actor::Property::WORLD_POSITION: // FALLTHROUGH
+ case Dali::Actor::Property::WORLD_POSITION_X: // FALLTHROUGH
+ case Dali::Actor::Property::WORLD_POSITION_Y: // FALLTHROUGH
+ case Dali::Actor::Property::WORLD_POSITION_Z:
+ {
+ property = &GetNode().mWorldPosition;
+ break;
+ }
+ case Dali::Actor::Property::WORLD_ORIENTATION:
+ {
+ property = &GetNode().mWorldOrientation;
+ break;
+ }
+ case Dali::Actor::Property::WORLD_SCALE:
+ {
+ property = &GetNode().mWorldScale;
+ break;
+ }
+ case Dali::Actor::Property::WORLD_COLOR:
+ {
+ property = &GetNode().mWorldColor;
+ break;
+ }
+ case Dali::Actor::Property::WORLD_MATRIX:
+ {
+ property = &GetNode().mWorldMatrix;
+ break;
+ }
+ case Dali::DevelActor::Property::CULLED:
+ {
+ property = &GetNode().mCulled;
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ if( !property )
+ {
+ // reuse animatable property getter as animatable properties are inputs as well
+ // animatable property chains back to Object::GetSceneObjectInputProperty() so all properties get covered
+ property = GetSceneObjectAnimatableProperty( index );
}
return property;
}
-int Actor::GetPropertyComponentIndex( Property::Index index ) const
+int32_t Actor::GetPropertyComponentIndex( Property::Index index ) const
{
- int componentIndex( Property::INVALID_COMPONENT_INDEX );
+ int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
- if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ switch( index )
{
- // check whether the animatable property is registered already, if not then register one.
- AnimatablePropertyMetadata* animatableProperty = GetSceneAnimatableProperty( index, nullptr );
- if( animatableProperty )
+ case Dali::Actor::Property::PARENT_ORIGIN_X:
+ case Dali::Actor::Property::ANCHOR_POINT_X:
+ case Dali::Actor::Property::SIZE_WIDTH:
+ case Dali::Actor::Property::POSITION_X:
+ case Dali::Actor::Property::WORLD_POSITION_X:
+ case Dali::Actor::Property::SCALE_X:
+ case Dali::Actor::Property::COLOR_RED:
{
- componentIndex = animatableProperty->componentIndex;
+ componentIndex = 0;
+ break;
}
- }
- else
- {
- switch( index )
- {
- case Dali::Actor::Property::PARENT_ORIGIN_X:
- case Dali::Actor::Property::ANCHOR_POINT_X:
- case Dali::Actor::Property::SIZE_WIDTH:
- case Dali::Actor::Property::POSITION_X:
- case Dali::Actor::Property::WORLD_POSITION_X:
- case Dali::Actor::Property::SCALE_X:
- case Dali::Actor::Property::COLOR_RED:
- {
- componentIndex = 0;
- break;
- }
- case Dali::Actor::Property::PARENT_ORIGIN_Y:
- case Dali::Actor::Property::ANCHOR_POINT_Y:
- case Dali::Actor::Property::SIZE_HEIGHT:
- case Dali::Actor::Property::POSITION_Y:
- case Dali::Actor::Property::WORLD_POSITION_Y:
- case Dali::Actor::Property::SCALE_Y:
- case Dali::Actor::Property::COLOR_GREEN:
- {
- componentIndex = 1;
- break;
- }
+ case Dali::Actor::Property::PARENT_ORIGIN_Y:
+ case Dali::Actor::Property::ANCHOR_POINT_Y:
+ case Dali::Actor::Property::SIZE_HEIGHT:
+ case Dali::Actor::Property::POSITION_Y:
+ case Dali::Actor::Property::WORLD_POSITION_Y:
+ case Dali::Actor::Property::SCALE_Y:
+ case Dali::Actor::Property::COLOR_GREEN:
+ {
+ componentIndex = 1;
+ break;
+ }
- case Dali::Actor::Property::PARENT_ORIGIN_Z:
- case Dali::Actor::Property::ANCHOR_POINT_Z:
- case Dali::Actor::Property::SIZE_DEPTH:
- case Dali::Actor::Property::POSITION_Z:
- case Dali::Actor::Property::WORLD_POSITION_Z:
- case Dali::Actor::Property::SCALE_Z:
- case Dali::Actor::Property::COLOR_BLUE:
- {
- componentIndex = 2;
- break;
- }
+ case Dali::Actor::Property::PARENT_ORIGIN_Z:
+ case Dali::Actor::Property::ANCHOR_POINT_Z:
+ case Dali::Actor::Property::SIZE_DEPTH:
+ case Dali::Actor::Property::POSITION_Z:
+ case Dali::Actor::Property::WORLD_POSITION_Z:
+ case Dali::Actor::Property::SCALE_Z:
+ case Dali::Actor::Property::COLOR_BLUE:
+ {
+ componentIndex = 2;
+ break;
+ }
- case Dali::Actor::Property::COLOR_ALPHA:
- case Dali::DevelActor::Property::OPACITY:
- {
- componentIndex = 3;
- break;
- }
+ case Dali::Actor::Property::COLOR_ALPHA:
+ case Dali::DevelActor::Property::OPACITY:
+ {
+ componentIndex = 3;
+ break;
+ }
- default:
- {
- // Do nothing
- break;
- }
+ default:
+ {
+ // Do nothing
+ break;
}
}
+ if( Property::INVALID_COMPONENT_INDEX == componentIndex )
+ {
+ // ask base
+ componentIndex = Object::GetPropertyComponentIndex( index );
+ }
return componentIndex;
}
OnStage() )
{
// Disconnect the Node & its children from the scene-graph.
- DisconnectNodeMessage( GetEventThreadServices().GetUpdateManager(), mNode );
+ DisconnectNodeMessage( GetEventThreadServices().GetUpdateManager(), GetNode() );
// Instruct each actor to discard pointers to the scene-graph
DisconnectFromStage();
case DevelActor::Property::CULLED:
{
- value = mNode.IsCulled( GetEventThreadServices().GetEventBufferIndex() );
+ value = GetNode().IsCulled( GetEventThreadServices().GetEventBufferIndex() );
break;
}
{
if( sendMessage == SendMessage::TRUE )
{
- // mNode is being used in a separate thread; queue a message to set the value & base value
- SceneGraph::NodePropertyMessage<bool>::Send( GetEventThreadServices(), &mNode, &mNode.mVisible, &AnimatableProperty<bool>::Bake, visible );
+ // node is being used in a separate thread; queue a message to set the value & base value
+ SceneGraph::NodePropertyMessage<bool>::Send( GetEventThreadServices(), &GetNode(), &GetNode().mVisible, &AnimatableProperty<bool>::Bake, visible );
}
mVisible = visible;
virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
/**
- * @copydoc Dali::Internal::Object::GetPropertyOwner()
- */
- virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
* @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
*/
virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
/**
* @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
*/
- virtual int GetPropertyComponentIndex( Property::Index index ) const;
+ virtual int32_t GetPropertyComponentIndex( Property::Index index ) const;
/**
* Retrieve the actor's node.
*/
const SceneGraph::Node& GetNode() const
{
- return mNode;
+ return *static_cast<const SceneGraph::Node*>( mUpdateObject );
}
/**
ActorContainer* mChildren; ///< Container of referenced actors, lazily initialized
RendererContainer* mRenderers; ///< Renderer container
- const SceneGraph::Node& mNode; ///< Not owned
Vector3* mParentOrigin; ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable
Vector3* mAnchorPoint; ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable
SceneGraph::Camera* sceneGraphCamera = SceneGraph::Camera::New();
// Store a pointer to this camera node inside the scene-graph camera.
- sceneGraphCamera->SetNode( &mNode );
+ sceneGraphCamera->SetNode( &GetNode() );
mSceneObject = sceneGraphCamera;
OwnerPointer< SceneGraph::Camera > sceneGraphCameraOwner( sceneGraphCamera );
{
// Build a picking ray in the world reference system.
// ray starts from the camera world position
- rayOrigin = mNode.GetWorldMatrix(0).GetTranslation();
+ rayOrigin = GetNode().GetWorldMatrix(0).GetTranslation();
rayOrigin.w = 1.0f;
// Transform the touch point from the screen coordinate system to the world coordinates system.
return ret;
}
-const SceneGraph::PropertyBase* CameraActor::GetSceneObjectAnimatableProperty( Property::Index index ) const
-{
- DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );
-
- const SceneGraph::PropertyBase* property( NULL );
-
- // This method should only return a property of an object connected to the scene-graph
- if ( !OnStage() )
- {
- return property;
- }
-
- // let actor handle animatable properties, we have no animatable properties
- if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
- {
- property = Actor::GetSceneObjectAnimatableProperty(index);
- }
-
- return property;
-}
-
const PropertyInputImpl* CameraActor::GetSceneObjectInputProperty( Property::Index index ) const
{
const PropertyInputImpl* property( NULL );
- // This method should only return a property of an object connected to the scene-graph
- if ( !OnStage() )
+ switch( index )
{
- return property;
+ case Dali::CameraActor::Property::PROJECTION_MATRIX:
+ {
+ property = mSceneObject->GetProjectionMatrix();
+ break;
+ }
+ case Dali::CameraActor::Property::VIEW_MATRIX:
+ {
+ property = mSceneObject->GetViewMatrix();
+ break;
+ }
+ // no default on purpose as we chain method up to actor
}
-
- // if its an actor default property or a custom property (actor already handles custom properties)
- if( ( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) || ( index >= DEFAULT_PROPERTY_MAX_COUNT ) )
+ if( !property )
{
property = Actor::GetSceneObjectInputProperty( index );
}
- else
- {
- switch( index )
- {
- case Dali::CameraActor::Property::PROJECTION_MATRIX:
- {
- property = mSceneObject->GetProjectionMatrix();
- break;
- }
- case Dali::CameraActor::Property::VIEW_MATRIX:
- {
- property = mSceneObject->GetViewMatrix();
- break;
- }
- default:
- DALI_LOG_WARNING("Not an input property (%d)\n", index);
- break;
- }
- }
return property;
}
virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
/**
- * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
- /**
* @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
*/
virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
#define __DALI_INTERNAL_CUSTOM_ACTOR_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* @copydoc Internal::Actor::OnStageConnectionExternal
*/
- virtual void OnStageConnectionExternal( int depth )
+ virtual void OnStageConnectionExternal( int32_t depth )
{
mImpl->OnStageConnection( depth );
}
const SceneGraph::Layer& Layer::GetSceneLayerOnStage() const
{
- return dynamic_cast< const SceneGraph::Layer& >( mNode );
+ return static_cast< const SceneGraph::Layer& >( GetNode() ); // we know our node is a layer node
}
void Layer::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
DALI_ASSERT_ALWAYS( mParent == NULL && "AnimationConnector already has a parent" );
mParent = &parent;
- if( mObject && mObject->GetSceneObject() )
+ if( mObject )
{
CreateAnimator();
}
DALI_ASSERT_DEBUG( mParent != NULL );
//Get the PropertyOwner the animator is going to animate
- const SceneGraph::PropertyOwner* propertyOwner = mObject->GetSceneObject();
+ const SceneGraph::PropertyOwner& propertyOwner = mObject->GetSceneObject();
// Get SceneGraph::BaseProperty
const SceneGraph::PropertyBase* baseProperty = mObject->GetSceneObjectAnimatableProperty( mPropertyIndex );
+ DALI_ASSERT_ALWAYS( baseProperty && "Property is not animatable" );
OwnerPointer<SceneGraph::PropertyResetterBase> resetter;
// Check if property is a component of another property
- const int componentIndex = mObject->GetPropertyComponentIndex( mPropertyIndex );
+ const int32_t componentIndex = mObject->GetPropertyComponentIndex( mPropertyIndex );
if( componentIndex != Property::INVALID_COMPONENT_INDEX )
{
mComponentIndex = componentIndex;
{
if( baseProperty->IsTransformManagerProperty() )
{
- mAnimator = SceneGraph::AnimatorTransformProperty< PropertyType,TransformManagerPropertyAccessor<PropertyType> >::New( *propertyOwner, *baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+ mAnimator = SceneGraph::AnimatorTransformProperty< PropertyType,TransformManagerPropertyAccessor<PropertyType> >::New( propertyOwner, *baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
// Don't reset transform manager properties - TransformManager will do it more efficiently
}
else
else
{
// Create the animator and resetter
- mAnimator = AnimatorType::New( *propertyOwner, *animatableProperty, mAnimatorFunction,
+ mAnimator = AnimatorType::New( propertyOwner, *animatableProperty, mAnimatorFunction,
mAlphaFunction, mTimePeriod );
- resetter = SceneGraph::AnimatorResetter::New( *propertyOwner, *baseProperty, *mAnimator );
+ resetter = SceneGraph::AnimatorResetter::New( propertyOwner, *baseProperty, *mAnimator );
}
}
else
{
case 0:
{
- mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector2> >::New( *propertyOwner,
+ mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector2> >::New( propertyOwner,
*animatableProperty,
mAnimatorFunction,
mAlphaFunction,
}
case 1:
{
- mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector2> >::New( *propertyOwner,
+ mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector2> >::New( propertyOwner,
*animatableProperty,
mAnimatorFunction,
mAlphaFunction,
if( mAnimator != nullptr )
{
- resetter = SceneGraph::AnimatorResetter::New( *propertyOwner, *baseProperty, *mAnimator );
+ resetter = SceneGraph::AnimatorResetter::New( propertyOwner, *baseProperty, *mAnimator );
}
}
{
if( mComponentIndex == 0 )
{
- mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,0> >::New( *propertyOwner, *baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+ mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,0> >::New( propertyOwner, *baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
}
else if( mComponentIndex == 1 )
{
- mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,1> >::New( *propertyOwner, *baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+ mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,1> >::New( propertyOwner, *baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
}
else if( mComponentIndex == 2 )
{
- mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,2> >::New( *propertyOwner, *baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+ mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,2> >::New( propertyOwner, *baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
}
}
else
{
case 0:
{
- mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector3> >::New( *propertyOwner,
+ mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector3> >::New( propertyOwner,
*animatableProperty,
mAnimatorFunction,
mAlphaFunction,
}
case 1:
{
- mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector3> >::New( *propertyOwner,
+ mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector3> >::New( propertyOwner,
*animatableProperty,
mAnimatorFunction,
mAlphaFunction,
}
case 2:
{
- mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorZ<Vector3> >::New( *propertyOwner,
+ mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorZ<Vector3> >::New( propertyOwner,
*animatableProperty,
mAnimatorFunction,
mAlphaFunction,
if( mAnimator != nullptr )
{
- resetter = SceneGraph::AnimatorResetter::New( *propertyOwner, *baseProperty, *mAnimator );
+ resetter = SceneGraph::AnimatorResetter::New( propertyOwner, *baseProperty, *mAnimator );
}
}
}
{
case 0:
{
- mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector4> >::New( *propertyOwner,
+ mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector4> >::New( propertyOwner,
*animatableProperty,
mAnimatorFunction,
mAlphaFunction,
}
case 1:
{
- mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector4> >::New( *propertyOwner,
+ mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector4> >::New( propertyOwner,
*animatableProperty,
mAnimatorFunction,
mAlphaFunction,
}
case 2:
{
- mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorZ<Vector4> >::New( *propertyOwner,
+ mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorZ<Vector4> >::New( propertyOwner,
*animatableProperty,
mAnimatorFunction,
mAlphaFunction,
}
case 3:
{
- mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorW<Vector4> >::New( *propertyOwner,
+ mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorW<Vector4> >::New( propertyOwner,
*animatableProperty,
mAnimatorFunction,
mAlphaFunction,
}
if( mAnimator != nullptr )
{
- resetter = SceneGraph::AnimatorResetter::New( *propertyOwner, *baseProperty, *mAnimator );
+ resetter = SceneGraph::AnimatorResetter::New( propertyOwner, *baseProperty, *mAnimator );
}
}
}
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
Constrainer::Constrainer()
-:Object()
+:Object( nullptr ) // we don't have our own scene object
{
}
*/
virtual ~Constrainer();
-public: // Object methods
-
- /**
- * @copydoc Dali::Internal::Object::SetDefaultProperty()
- */
- virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ){}
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultProperty()
- */
- virtual Property::Value GetDefaultProperty( Property::Index index ) const{return Property::Value();}
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
- */
- virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const{return Property::Value();}
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const{return 0;}
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const{return 0;}
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
- */
- virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const{return 0;}
-
public: // Object::Observer methods
/**
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// Guard against constraint sending messages during core destruction
if( Stage::IsInstalled() )
{
- const SceneGraph::PropertyOwner* propertyOwner = mTargetObject ? mTargetObject->GetSceneObject() : NULL;
-
- if ( propertyOwner &&
- mSceneGraphConstraint )
+ if( mTargetObject && mSceneGraphConstraint )
{
+ 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 = NULL;
}
// An input property owning source has been deleted, need to tell the scene-graph-constraint owner to remove it
if ( &object != mTargetObject )
{
- const SceneGraph::PropertyOwner* propertyOwner = mTargetObject ? mTargetObject->GetSceneObject() : NULL;
-
- if( propertyOwner )
+ if( mTargetObject )
{
+ const SceneGraph::PropertyOwner& propertyOwner = mTargetObject->GetSceneObject();
// Remove from scene-graph
- RemoveConstraintMessage( GetEventThreadServices(), *propertyOwner, *(mSceneGraphConstraint) );
+ RemoveConstraintMessage( GetEventThreadServices(), propertyOwner, *(mSceneGraphConstraint) );
}
}
// Guard against double connections
DALI_ASSERT_DEBUG( NULL == mSceneGraphConstraint );
- // Short-circuit until the target scene-object exists
- SceneGraph::PropertyOwner* targetObject = const_cast< SceneGraph::PropertyOwner* >( mTargetObject->GetSceneObject() );
- if ( NULL == targetObject )
- {
- return;
- }
+ 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 ) );
func,
mRemoveAction );
// Connect the resetter
- resetter = SceneGraph::ConstraintResetter::New( *targetObject, *targetProperty, *mSceneGraphConstraint );
+ resetter = SceneGraph::ConstraintResetter::New( targetObject, *targetProperty, *mSceneGraphConstraint );
}
OwnerPointer< SceneGraph::ConstraintBase > transferOwnership( const_cast< SceneGraph::ConstraintBase* >( mSceneGraphConstraint ) );
- ApplyConstraintMessage( GetEventThreadServices(), *targetObject, transferOwnership );
+ ApplyConstraintMessage( GetEventThreadServices(), targetObject, transferOwnership );
if( resetter != nullptr )
{
{
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() );
- // The property owner will not exist, if the target object is off-stage
- if( NULL != owner )
- {
- 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( NULL != inputProperty && "Constraint source property does not exist" );
- }
+ // The scene-object property should exist, when the property owner exists
+ DALI_ASSERT_ALWAYS( NULL != inputProperty && "Constraint source property does not exist" );
}
else if ( LOCAL_PROPERTY == source.sourceType )
{
{
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() );
- // The property owner will not exist, if the parent object is off-stage
- if ( NULL != owner )
- {
- 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( NULL != inputProperty && "Constraint source property does not exist" );
- }
+ // The scene-object property should exist, when the property owner exists
+ DALI_ASSERT_ALWAYS( NULL != inputProperty && "Constraint source property does not exist" );
}
}
DALI_ASSERT_DEBUG( NULL == mSceneGraphConstraint );
// Short-circuit until the target scene-object exists
- SceneGraph::PropertyOwner* targetObject = const_cast< SceneGraph::PropertyOwner* >( mTargetObject->GetSceneObject() );
- if ( NULL == targetObject )
- {
- return;
- }
+ 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 ) );
typedef SceneGraph::Constraint< float, PropertyAccessor<float> > SceneGraphConstraint;
mSceneGraphConstraint = SceneGraphConstraint::New( *targetProperty, propertyOwners, func, mRemoveAction );
- resetter = SceneGraph::ConstraintResetter::New( *targetObject, *targetProperty, *mSceneGraphConstraint );
+ resetter = SceneGraph::ConstraintResetter::New( targetObject, *targetProperty, *mSceneGraphConstraint );
}
else
{
}
if( mSceneGraphConstraint )
{
- resetter = SceneGraph::ConstraintResetter::New( *targetObject, *targetProperty, *mSceneGraphConstraint );
+ resetter = SceneGraph::ConstraintResetter::New( targetObject, *targetProperty, *mSceneGraphConstraint );
}
}
else if ( PropertyTypes::Get< Vector3 >() == targetProperty->GetType() )
}
if( mSceneGraphConstraint )
{
- resetter = SceneGraph::ConstraintResetter::New( *targetObject, *targetProperty, *mSceneGraphConstraint );
+ resetter = SceneGraph::ConstraintResetter::New( targetObject, *targetProperty, *mSceneGraphConstraint );
}
}
}
if( mSceneGraphConstraint )
{
- resetter = SceneGraph::ConstraintResetter::New( *targetObject, *targetProperty, *mSceneGraphConstraint );
+ resetter = SceneGraph::ConstraintResetter::New( targetObject, *targetProperty, *mSceneGraphConstraint );
}
}
}
if( mSceneGraphConstraint )
{
OwnerPointer< SceneGraph::ConstraintBase > transferOwnership( const_cast< SceneGraph::ConstraintBase* >( mSceneGraphConstraint ) );
- ApplyConstraintMessage( GetEventThreadServices(), *targetObject, transferOwnership );
+ ApplyConstraintMessage( GetEventThreadServices(), targetObject, transferOwnership );
}
if( resetter != nullptr )
{
{
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() );
// The property owner will not exist, if the target object is off-stage
- if( NULL != owner )
- {
- 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( NULL != inputProperty && "Constraint source property does not exist" );
- }
+ // The scene-object property should exist, when the property owner exists
+ DALI_ASSERT_ALWAYS( NULL != inputProperty && "Constraint source property does not exist" );
}
else if ( LOCAL_PROPERTY == source.sourceType )
{
{
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() );
// The property owner will not exist, if the parent object is off-stage
- if ( NULL != owner )
- {
- 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( NULL != inputProperty && "Constraint source property does not exist" );
- }
+ // The scene-object property should exist, when the property owner exists
+ DALI_ASSERT_ALWAYS( NULL != inputProperty && "Constraint source property does not exist" );
}
}
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
Path::Path()
-: Object()
+: Object( nullptr ) // we don't have our own scene object
{
}
return Property::Value();
}
-Property::Value Path::GetDefaultPropertyCurrentValue( Property::Index index ) const
-{
- return GetDefaultProperty( index ); // Event-side only properties
-}
-
void Path::SetDefaultProperty(Property::Index index, const Property::Value& propertyValue)
{
const Property::Array* array = propertyValue.GetArray();
mControlPoint.PushBack( point );
}
-unsigned int Path::GetNumberOfSegments() const
+uint32_t Path::GetNumberOfSegments() const
{
- return static_cast<unsigned int>( (mPoint.Size()>1) ? mPoint.Size()-1 : 0 );
+ return static_cast<uint32_t>( (mPoint.Size()>1) ? mPoint.Size()-1 : 0 );
}
void Path::GenerateControlPoints( float curvature )
{
- unsigned int numSegments = GetNumberOfSegments();
+ uint32_t numSegments = GetNumberOfSegments();
DALI_ASSERT_ALWAYS( numSegments > 0 && "Need at least 1 segment to generate control points" ); // need at least 1 segment
mControlPoint.Resize( numSegments * 2);
//Generate two control points for each segment
- for( unsigned int i(0); i<numSegments; ++i )
+ for( uint32_t i(0); i<numSegments; ++i )
{
//Segment end-points
Vector3 p1 = mPoint[i];
}
}
-void Path::FindSegmentAndProgress( float t, unsigned int& segment, float& tLocal ) const
+void Path::FindSegmentAndProgress( float t, uint32_t& segment, float& tLocal ) const
{
//Find segment and local progress
- unsigned int numSegs = GetNumberOfSegments();
+ uint32_t numSegs = GetNumberOfSegments();
if( t <= 0.0f || numSegs == 0 )
{
}
else
{
- segment = static_cast<unsigned int>( t * 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 );
if( PathIsComplete(mPoint, mControlPoint) )
{
- unsigned int segment;
+ uint32_t segment;
float tLocal;
FindSegmentAndProgress( t, segment, tLocal );
if( PathIsComplete(mPoint, mControlPoint) )
{
- unsigned int segment;
+ uint32_t segment;
float tLocal;
FindSegmentAndProgress( t, segment, tLocal );
if( PathIsComplete(mPoint, mControlPoint) )
{
- unsigned int segment;
+ uint32_t segment;
float tLocal;
FindSegmentAndProgress( t, segment, tLocal );
return done;
}
-Vector3& Path::GetPoint( size_t index )
+Vector3& Path::GetPoint( uint32_t index )
{
DALI_ASSERT_ALWAYS( index < mPoint.Size() && "Path: Point index out of bounds" );
return mPoint[index];
}
-Vector3& Path::GetControlPoint( size_t index )
+Vector3& Path::GetControlPoint( uint32_t index )
{
DALI_ASSERT_ALWAYS( index < mControlPoint.Size() && "Path: Control Point index out of bounds" );
return mControlPoint[index];
}
-size_t Path::GetPointCount() const
+uint32_t Path::GetPointCount() const
{
- return mPoint.Size();
+ return static_cast<uint32_t>( mPoint.Size() );
}
void Path::ClearPoints()
#define __DALI_INTERNAL_PATH_H__
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
virtual ~Path();
private:
- /**
- * @copydoc Dali::Internal::Object::Observer::SceneObjectAdded()
- */
- virtual void SceneObjectAdded(Object& object){}
-
- /**
- * @copydoc Dali::Internal::Object::Observer::SceneObjectAdded()
- */
- virtual void SceneObjectRemoved(Object& object){}
-
- /**
- * @copydoc Dali::Internal::Object::Observer::ObjectDestroyed()
- */
- virtual void ObjectDestroyed(Object& object){}
/**
* @copydoc Dali::Internal::Object::SetDefaultProperty()
*/
virtual Property::Value GetDefaultProperty( Property::Index index ) const;
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
- */
- virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const{ return NULL; }
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const{ return NULL; }
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
- */
- virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const{ return NULL; }
-
public:
/**
/**
* @copydoc Dali::Path::GetPoint
*/
- Vector3& GetPoint( size_t index );
+ Vector3& GetPoint( uint32_t index );
/**
* @copydoc Dali::Path::GetControlPoint
*/
- Vector3& GetControlPoint( size_t index );
+ Vector3& GetControlPoint( uint32_t index );
/**
* @copydoc Dali::Path::GetPointCount
*/
- size_t GetPointCount() const;
+ uint32_t GetPointCount() const;
/**
* Clears the points of the path
* @param[out] tLocal Local progress in the segment
*
*/
- void FindSegmentAndProgress( float t, unsigned int& 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
*/
- unsigned int GetNumberOfSegments() const;
+ uint32_t GetNumberOfSegments() const;
Dali::Vector<Vector3> mPoint; ///< Interpolation points
Dali::Vector<Vector3> mControlPoint; ///< Control points
+++ /dev/null
-#ifndef DALI_INTERNAL_OBJECT_IMPL_HELPER_H
-#define DALI_INTERNAL_OBJECT_IMPL_HELPER_H
-
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDEs
-#include <cstring>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/property.h> // Dali::Property
-#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/update/common/animatable-property.h>
-#include <dali/internal/update/common/property-owner-messages.h>
-#include <dali/internal/update/manager/update-manager.h>
-
-namespace Dali
-{
-namespace Internal
-{
-class PropertyMetadata;
-class AnimatablePropertyMetadata;
-class CustomPropertyMetadata;
-class PropertyInputImpl;
-
-namespace SceneGraph
-{
-
-class PropertyBase;
-class PropertyOwner;
-
-} // namespace SceneGraph
-
-// methods needed as parameters
-using FindAnimatablePropertyMethod = AnimatablePropertyMetadata* (Object::*)(Property::Index index) const;
-using FindCustomPropertyMethod = CustomPropertyMetadata* (Object::*)(Property::Index index) const;
-
-/**
- * Helper utilities to be used by class that implement Object
- */
-namespace ObjectImplHelper
-{
- // Get the (animatable) scene graph property. (All registered scene graph properties are animatable)
- inline const SceneGraph::PropertyBase* GetRegisteredSceneGraphProperty( const Object* object,
- FindAnimatablePropertyMethod findAnimatablePropertyMethod,
- FindCustomPropertyMethod findCustomPropertyMethod,
- Property::Index index )
- {
- const SceneGraph::PropertyBase* property = NULL;
- if ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX && index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX )
- {
- AnimatablePropertyMetadata* animatable = (object->*findAnimatablePropertyMethod)( index );
- 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 ) )
- {
- CustomPropertyMetadata* custom = (object->*findCustomPropertyMethod)( index );
- DALI_ASSERT_ALWAYS( custom && "Property index is invalid" );
- property = custom->GetSceneGraphProperty();
- }
- return property;
- }
-
- inline void SetSceneGraphProperty( EventThreadServices& eventThreadServices,
- const Object* object,
- Property::Index index,
- const PropertyMetadata& entry,
- const Property::Value& value )
- {
- const SceneGraph::PropertyOwner* sceneObject = object->GetSceneObject();
-
- switch ( entry.GetType() )
- {
- case Property::BOOLEAN:
- {
- const SceneGraph::AnimatableProperty<bool>* property = dynamic_cast< const SceneGraph::AnimatableProperty<bool>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
-
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::AnimatablePropertyMessage<bool>::Send( eventThreadServices, sceneObject, property, &SceneGraph::AnimatableProperty<bool>::Bake, value.Get<bool>() );
-
- break;
- }
-
- case Property::FLOAT:
- {
- const SceneGraph::AnimatableProperty<float>* property = dynamic_cast< const SceneGraph::AnimatableProperty<float>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
-
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::AnimatablePropertyMessage<float>::Send( eventThreadServices, sceneObject, property, &SceneGraph::AnimatableProperty<float>::Bake, value.Get<float>() );
-
- break;
- }
-
- case Property::INTEGER:
- {
- const SceneGraph::AnimatableProperty<int>* property = dynamic_cast< const SceneGraph::AnimatableProperty<int>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
-
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::AnimatablePropertyMessage<int>::Send( eventThreadServices, sceneObject, property, &SceneGraph::AnimatableProperty<int>::Bake, value.Get<int>() );
-
- break;
- }
-
- case Property::VECTOR2:
- {
- const SceneGraph::AnimatableProperty<Vector2>* property = dynamic_cast< const SceneGraph::AnimatableProperty<Vector2>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
-
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::AnimatablePropertyMessage<Vector2>::Send( eventThreadServices, sceneObject, property, &SceneGraph::AnimatableProperty<Vector2>::Bake, value.Get<Vector2>() );
-
- break;
- }
-
- case Property::VECTOR3:
- {
- const SceneGraph::AnimatableProperty<Vector3>* property = dynamic_cast< const SceneGraph::AnimatableProperty<Vector3>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
-
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::AnimatablePropertyMessage<Vector3>::Send( eventThreadServices, sceneObject, property, &SceneGraph::AnimatableProperty<Vector3>::Bake, value.Get<Vector3>() );
-
- break;
- }
-
- case Property::VECTOR4:
- {
- const SceneGraph::AnimatableProperty<Vector4>* property = dynamic_cast< const SceneGraph::AnimatableProperty<Vector4>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
-
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::AnimatablePropertyMessage<Vector4>::Send( eventThreadServices, sceneObject, property, &SceneGraph::AnimatableProperty<Vector4>::Bake, value.Get<Vector4>() );
-
- break;
- }
-
- case Property::ROTATION:
- {
- const SceneGraph::AnimatableProperty<Quaternion>* property = dynamic_cast< const SceneGraph::AnimatableProperty<Quaternion>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
-
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::AnimatablePropertyMessage<Quaternion>::Send( eventThreadServices, sceneObject, property,&SceneGraph::AnimatableProperty<Quaternion>::Bake, value.Get<Quaternion>() );
-
- break;
- }
-
- case Property::MATRIX:
- {
- const SceneGraph::AnimatableProperty<Matrix>* property = dynamic_cast< const SceneGraph::AnimatableProperty<Matrix>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
-
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::AnimatablePropertyMessage<Matrix>::Send( eventThreadServices, sceneObject, property,&SceneGraph::AnimatableProperty<Matrix>::Bake, value.Get<Matrix>() );
-
- break;
- }
-
- case Property::MATRIX3:
- {
- const SceneGraph::AnimatableProperty<Matrix3>* property = dynamic_cast< const SceneGraph::AnimatableProperty<Matrix3>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
-
- // property is being used in a separate thread; queue a message to set the property
- SceneGraph::AnimatablePropertyMessage<Matrix3>::Send( eventThreadServices, sceneObject, property, &SceneGraph::AnimatableProperty<Matrix3>::Bake, value.Get<Matrix3>() );
-
- break;
- }
-
- default:
- {
- // ignore non-scene-graph types
- }
- }
- }
-};
-
-
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // DALI_INTERNAL_OBJECT_IMPL_HELPER_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/internal/event/animation/constraint-impl.h>
namespace // unnamed namespace
{
-const int 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" );
} // unnamed namespace
-Object::Object()
-: mEventThreadServices( *Stage::GetCurrent() ),
- mTypeInfo( NULL ),
- mConstraints( NULL ),
- mPropertyNotifications( NULL )
+IntrusivePtr<Object> Object::New()
{
+ return new Object( nullptr ); // no scene object by default
}
void Object::AddObserver(Observer& observer)
}
}
-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" );
else
{
// Otherwise register the property
-
if( Property::ANIMATABLE == accessMode )
{
index = RegisterSceneGraphProperty( name, key, PROPERTY_CUSTOM_START_INDEX + static_cast<Property::Index>( mCustomProperties.Count() ), propertyValue );
}
else
{
- PropertyMetadata* propertyMetadata = NULL;
+ PropertyMetadata* propertyMetadata = nullptr;
if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
{
propertyMetadata = FindAnimatableProperty( index );
const PropertyInputImpl* propertyPtr = GetSceneObjectInputProperty( propertyIndex );
// Check instead for newly registered properties
- if( propertyPtr == NULL )
+ if( propertyPtr == nullptr )
{
PropertyMetadata* animatable = FindAnimatableProperty( propertyIndex );
- if( animatable != NULL )
+ if( animatable )
{
propertyPtr = animatable->GetSceneGraphProperty();
}
}
- if( propertyPtr == NULL )
+ if( propertyPtr == nullptr )
{
PropertyMetadata* custom = FindCustomProperty( propertyIndex );
- if( custom != NULL )
+ if( custom )
{
propertyPtr = custom->GetSceneGraphProperty();
}
}
- if( propertyPtr != NULL )
+ if( propertyPtr )
{
- const SceneGraph::PropertyOwner* sceneObject = GetPropertyOwner();
+ const SceneGraph::PropertyOwner& sceneObject = GetSceneObject();
- if( sceneObject != NULL )
- {
- OwnerPointer< SceneGraph::UniformPropertyMapping > map = new SceneGraph::UniformPropertyMapping( uniformName, propertyPtr );
- // Message takes ownership of Uniform map (and will delete it after copy)
- AddUniformMapMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), *sceneObject, map );
- }
- else
- {
- DALI_ASSERT_ALWAYS(0 && "MESH_REWORK - Need to store property whilst off-stage" );
- }
+ OwnerPointer< SceneGraph::UniformPropertyMapping > map = new SceneGraph::UniformPropertyMapping( uniformName, propertyPtr );
+ // Message takes ownership of Uniform map (and will delete it after copy)
+ AddUniformMapMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), sceneObject, map );
}
}
-void Object::RemoveUniformMapping( const std::string& uniformName )
+void Object::RemoveUniformMapping( const std::string& uniformName ) const
{
- const SceneGraph::PropertyOwner* sceneObject = GetSceneObject();
- RemoveUniformMapMessage( GetEventThreadServices(), *sceneObject, uniformName);
+ const SceneGraph::PropertyOwner& sceneObject = GetSceneObject();
+ RemoveUniformMapMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), sceneObject, uniformName);
}
void Object::ApplyConstraint( ConstraintBase& constraint )
void Object::RemoveConstraint( ConstraintBase& constraint )
{
- // NULL if the Constraint sources are destroyed before Constraint::Apply()
+ // nullptr if the Constraint sources are destroyed before Constraint::Apply()
if( mConstraints )
{
ConstraintIter it( std::find( mConstraints->begin(), mConstraints->end(), Dali::Constraint( &constraint ) ) );
// guard against constraint sending messages during core destruction
if( mConstraints && Stage::IsInstalled() )
{
- // If we have nothing in the scene-graph, just clear constraint containers
- const SceneGraph::PropertyOwner* propertyOwner = GetSceneObject();
- if ( NULL != propertyOwner )
+ for ( auto&& item : *mConstraints )
{
- const auto endIter = mConstraints->end();
- for ( auto iter = mConstraints->begin(); endIter != iter; ++iter )
- {
- GetImplementation( *iter ).RemoveInternal();
- }
+ GetImplementation( item ).RemoveInternal();
}
delete mConstraints;
- mConstraints = NULL;
+ mConstraints = nullptr;
}
}
if ( mConstraints->empty() )
{
delete mConstraints;
- mConstraints = NULL;
+ mConstraints = nullptr;
}
}
}
mTypeInfo = typeInfo;
}
+const SceneGraph::PropertyOwner& Object::GetSceneObject() const
+{
+ if( !mUpdateObject )
+ {
+ auto sceneObject = SceneGraph::PropertyOwner::New();
+ OwnerPointer< SceneGraph::PropertyOwner > transferOwnership( sceneObject );
+ mUpdateObject = sceneObject;
+ AddObjectMessage( const_cast<EventThreadServices&>( GetEventThreadServices() ).GetUpdateManager(), transferOwnership );
+ }
+ DALI_ASSERT_DEBUG( mUpdateObject && "there must always be a scene object" );
+ return *mUpdateObject;
+}
+
+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 )
+ {
+ 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 ) )
+ {
+ 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
+{
+ // reuse animatable version as they are inputs as well
+ return GetSceneObjectAnimatableProperty( index );
+}
+
int32_t Object::GetPropertyComponentIndex( Property::Index index ) const
{
int32_t componentIndex = Property::INVALID_COMPONENT_INDEX;
- const TypeInfo* typeInfo( GetTypeInfo() );
- if ( typeInfo )
+ 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 )
+ {
+ componentIndex = animatableProperty->componentIndex;
+ }
+ }
+ if( Property::INVALID_COMPONENT_INDEX == componentIndex )
{
- componentIndex = typeInfo->GetComponentIndex(index);
+ const TypeInfo* typeInfo( GetTypeInfo() );
+ if ( typeInfo )
+ {
+ componentIndex = typeInfo->GetComponentIndex(index);
+ }
}
return componentIndex;
return mPropertySetSignal;
}
+Object::Object( const SceneGraph::PropertyOwner* sceneObject )
+: mEventThreadServices( *Stage::GetCurrent() ),
+ mUpdateObject( sceneObject ),
+ mTypeInfo( nullptr ),
+ mConstraints( nullptr ),
+ mPropertyNotifications( nullptr )
+{
+}
+
Object::~Object()
{
// Notification for observers
- for( auto iter = mObservers.Begin(), endIter = mObservers.End(); iter != endIter; ++iter)
+ for( auto&& item : mObservers )
{
- (*iter)->ObjectDestroyed(*this);
+ item->ObjectDestroyed( *this );
}
-
delete mConstraints;
delete mPropertyNotifications;
+
+ // Guard to allow handle destruction after Core has been destroyed
+ if( Stage::IsInstalled() )
+ {
+ if( nullptr != mUpdateObject )
+ {
+ RemoveObjectMessage( GetEventThreadServices().GetUpdateManager(), mUpdateObject );
+ }
+ }
}
void Object::OnSceneObjectAdd()
{
// Notification for observers
- for( auto iter = mObservers.Begin(), endIter = mObservers.End(); iter != endIter; ++iter)
+ for( auto&& item : mObservers )
{
- (*iter)->SceneObjectAdded(*this);
+ item->SceneObjectAdded(*this);
}
// enable property notifications in scene graph
void Object::OnSceneObjectRemove()
{
// Notification for observers
- for( auto iter = mObservers.Begin(), endIter = mObservers.End(); iter != endIter; ++iter )
+ for( auto&& item : mObservers )
{
- (*iter)->SceneObjectRemoved(*this);
+ item->SceneObjectRemoved(*this);
}
// disable property notifications in scene graph
CustomPropertyMetadata* Object::FindCustomProperty( Property::Index index ) const
{
- CustomPropertyMetadata* property( NULL );
+ CustomPropertyMetadata* property = nullptr;
if ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) )
{
for ( std::size_t arrayIndex = 0; arrayIndex < mCustomProperties.Count(); arrayIndex++ )
}
else
{
- int arrayIndex = index - PROPERTY_CUSTOM_START_INDEX;
+ int32_t arrayIndex = index - PROPERTY_CUSTOM_START_INDEX;
if( arrayIndex >= 0 )
{
- if( arrayIndex < static_cast<int>( 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 ]);
}
return property;
}
}
- return NULL;
+ return nullptr;
}
-Property::Index Object::RegisterSceneGraphProperty(const std::string& name, Property::Index key, Property::Index index, const Property::Value& propertyValue) const
+Property::Index Object::RegisterSceneGraphProperty( const std::string& name, Property::Index key, Property::Index index, const Property::Value& propertyValue ) const
{
// Create a new property
Dali::Internal::OwnerPointer<PropertyBase> newProperty;
case Property::INTEGER:
{
- newProperty = new AnimatableProperty<int>( propertyValue.Get<int>() );
+ newProperty = new AnimatableProperty<int32_t>( propertyValue.Get<int32_t>() );
break;
}
}
}
- // get the scene property owner from derived class
- const SceneGraph::PropertyOwner* scenePropertyOwner = GetPropertyOwner();
- // we can only pass properties to scene graph side if there is a scene object
- if( scenePropertyOwner )
+ // get the scene property owner
+ const SceneGraph::PropertyOwner& scenePropertyOwner = GetSceneObject();
+ // keep a local pointer to the property as the OwnerPointer will pass its copy to the message
+ const PropertyBase* property = newProperty.Get();
+ if(index >= PROPERTY_CUSTOM_START_INDEX)
{
- // keep a local pointer to the property as the OwnerPointer will pass its copy to the message
- 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, propertyValue, property ) );
- }
- else
- {
- mAnimatableProperties.PushBack( new AnimatablePropertyMetadata( index, propertyValue, property ) );
- }
-
- // queue a message to add the property
- InstallCustomPropertyMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), *scenePropertyOwner, newProperty ); // Message takes ownership
-
- return index;
+ mCustomProperties.PushBack( new CustomPropertyMetadata( name, key, propertyValue, property ) );
}
else
{
- // property was orphaned and killed so return invalid index
- return Property::INVALID_INDEX;
+ mAnimatableProperties.PushBack( new AnimatablePropertyMetadata( index, propertyValue, property ) );
}
+
+ // queue a message to add the property
+ InstallCustomPropertyMessage( const_cast<EventThreadServices&>(GetEventThreadServices()), scenePropertyOwner, newProperty ); // Message takes ownership
+
+ return index;
}
void Object::RegisterAnimatableProperty( const TypeInfo& typeInfo,
}
}
+void Object::SetDefaultProperty( Property::Index index, const Property::Value& property )
+{
+ // do nothing
+}
+
+Property::Value Object::GetDefaultProperty(Property::Index index) const
+{
+ return Property::Value();
+}
+
+Property::Value Object::GetDefaultPropertyCurrentValue( Property::Index index ) const
+{
+ return GetDefaultProperty( index );
+}
+
void Object::EnablePropertyNotifications()
{
if( mPropertyNotifications )
case Property::BOOLEAN:
{
const AnimatableProperty<bool>* property = static_cast< const AnimatableProperty<bool>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ DALI_ASSERT_DEBUG( property );
value = (*property)[ bufferIndex ];
break;
case Property::INTEGER:
{
- const AnimatableProperty<int>* property = static_cast< const AnimatableProperty<int>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ const AnimatableProperty<int32_t>* property = static_cast< const AnimatableProperty<int32_t>* >( entry.GetSceneGraphProperty() );
+ DALI_ASSERT_DEBUG( property );
value = (*property)[ bufferIndex ];
break;
case Property::FLOAT:
{
const AnimatableProperty<float>* property = static_cast< const AnimatableProperty<float>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ DALI_ASSERT_DEBUG( property );
value = (*property)[ bufferIndex ];
break;
case Property::VECTOR2:
{
const AnimatableProperty<Vector2>* property = static_cast< const AnimatableProperty<Vector2>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ DALI_ASSERT_DEBUG( property );
if(entry.componentIndex == 0)
{
case Property::VECTOR3:
{
const AnimatableProperty<Vector3>* property = static_cast< const AnimatableProperty<Vector3>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ DALI_ASSERT_DEBUG( property );
if(entry.componentIndex == 0)
{
case Property::VECTOR4:
{
const AnimatableProperty<Vector4>* property = static_cast< const AnimatableProperty<Vector4>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ DALI_ASSERT_DEBUG( property );
if(entry.componentIndex == 0)
{
case Property::MATRIX:
{
const AnimatableProperty<Matrix>* property = static_cast< const AnimatableProperty<Matrix>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ DALI_ASSERT_DEBUG( property );
value = (*property)[ bufferIndex ];
break;
case Property::MATRIX3:
{
const AnimatableProperty<Matrix3>* property = static_cast< const AnimatableProperty<Matrix3>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ DALI_ASSERT_DEBUG( property );
value = (*property)[ bufferIndex ];
break;
case Property::ROTATION:
{
const AnimatableProperty<Quaternion>* property = static_cast< const AnimatableProperty<Quaternion>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ DALI_ASSERT_DEBUG( property );
value = (*property)[ bufferIndex ];
break;
case Property::BOOLEAN:
{
const AnimatableProperty<bool>* property = dynamic_cast< const AnimatableProperty<bool>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ 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>() );
case Property::INTEGER:
{
- const AnimatableProperty<int>* property = dynamic_cast< const AnimatableProperty<int>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != 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<int>( GetEventThreadServices(), *property, value.Get<int>() );
+ 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( NULL != property );
+ 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>() );
case Property::VECTOR2:
{
const AnimatableProperty<Vector2>* property = dynamic_cast< const AnimatableProperty<Vector2>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ DALI_ASSERT_DEBUG( property );
// property is being used in a separate thread; queue a message to set the property
if(entry.componentIndex == 0)
case Property::VECTOR3:
{
const AnimatableProperty<Vector3>* property = dynamic_cast< const AnimatableProperty<Vector3>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ DALI_ASSERT_DEBUG( property );
// property is being used in a separate thread; queue a message to set the property
if(entry.componentIndex == 0)
case Property::VECTOR4:
{
const AnimatableProperty<Vector4>* property = dynamic_cast< const AnimatableProperty<Vector4>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ DALI_ASSERT_DEBUG( property );
// property is being used in a separate thread; queue a message to set the property
if(entry.componentIndex == 0)
case Property::ROTATION:
{
const AnimatableProperty<Quaternion>* property = dynamic_cast< const AnimatableProperty<Quaternion>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ 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>() );
case Property::MATRIX:
{
const AnimatableProperty<Matrix>* property = dynamic_cast< const AnimatableProperty<Matrix>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ 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>() );
case Property::MATRIX3:
{
const AnimatableProperty<Matrix3>* property = dynamic_cast< const AnimatableProperty<Matrix3>* >( entry.GetSceneGraphProperty() );
- DALI_ASSERT_DEBUG( NULL != property );
+ 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>() );
class PropertyOwner;
}
-typedef std::vector< Dali::Constraint > ConstraintContainer;
-typedef ConstraintContainer::iterator ConstraintIter;
-typedef ConstraintContainer::const_iterator ConstraintConstIter;
-
+using ConstraintContainer = std::vector< Dali::Constraint >;
+using ConstraintIter = ConstraintContainer::iterator;
+using ConstraintConstIter = ConstraintContainer::const_iterator;
/**
* A base class for objects which optionally provide properties.
* An object for a property-owning object in the scene-graph.
* This provides an interface for observing the addition/removal of scene-objects.
*
- * The concrete derived class is responsible for:
- * 1) Adding & removing an object from the scene-graph. The OnSceneObjectAdd() and OnSceneObjectRemove()
- * methods should be called by the derived class, to trigger observer callbacks.
- * 3) Implementing the GetSceneObject() methods, used to access the scene-object.
- * 4) Providing access to properties stored by the scene-graph object. These should match the properties
- * reported by the base Dali::Internal::Object methods.
- *
+ * The derived class should either:
+ * a) Create their own scene-graph object and pass it to Object constructor.
+ * b) pass nullptr to Object constructor, in this case Object will create default scene object for property handling
*/
class Object : public Dali::BaseObject
{
public:
- typedef Dali::Handle::Capability Capability;
+ using Capability = Dali::Handle::Capability;
class Observer
{
};
/**
- * Constructor.
+ * Creates a new object
+ *
+ * @return an smart pointer to the object
*/
- Object();
+ static IntrusivePtr<Object> New();
/**
* Add an observer to the object.
/******************************** Uniform Mappings ********************************/
/**
- * @copydoc Dali::Handle::AddUniformMapping()
+ * Adds uniform mapping for given property
+ * @param propertyIndex index of the property
+ * @param uniformName name of the uniform (same as property name)
*/
void AddUniformMapping( Property::Index propertyIndex, const std::string& uniformName ) const;
/**
- * @copydoc Dali::Handle::RemoveUniformMapping( )
+ * Removes uniform mapping for given property
+ * @param uniformName name of the uniform (same as property name)
*/
- void RemoveUniformMapping( const std::string& uniformName );
+ void RemoveUniformMapping( const std::string& uniformName ) const;
/******************************** Constraints ********************************/
return PROPERTY_CUSTOM_START_INDEX;
}
- /******************** To be overridden by deriving classes ********************/
-
/**
* Retrieve the scene-graph object added by this object.
- * @return A pointer to the object, or NULL if no object has been added to the scene-graph.
+ * @return reference to the scene-graph object, it will always exist
*/
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const = 0;
+ const SceneGraph::PropertyOwner& GetSceneObject() const;
+
+ /******************** Can be overridden by deriving classes ********************/
/**
* Retrieve an animatable property owned by the scene-graph object.
* @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 = 0;
+ 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 = 0;
+ virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
/**
* Query whether the property is a component of a scene-graph property.
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 );
+
+ /**
* A reference counted object may only be deleted by calling Unreference()
*/
virtual ~Object();
virtual Object* GetParentObject() const
{
// By default the Object does not have a parent
- return NULL;
+ return nullptr;
};
/**
* @param [in] value The value of the property.
* @return The index of the registered property or Property::INVALID_INDEX if registration failed.
*/
- Property::Index RegisterSceneGraphProperty(const std::string& name, Property::Index key, Property::Index index, const Property::Value& propertyValue) const;
+ Property::Index RegisterSceneGraphProperty( const std::string& name, Property::Index key, Property::Index index, const Property::Value& propertyValue ) const;
/**
* Registers animatable scene property
* @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 ) = 0;
+ 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 = 0;
+ 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 = 0;
+ 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.
virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type propertyChangeType )
{ }
- /**
- * @todo this is virtual so that for now actor can override it,
- * it needs to be removed and only have GetSceneObject but that requires changing actor and constraint logic
- * Retrieve the scene-graph object added by this object.
- * @return A pointer to the object, or NULL if no object has been added to the scene-graph.
- */
- virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const
- {
- return GetSceneObject();
- }
-
private:
+ // no default, copy or assignment
+ Object() = delete;
Object(const Object& rhs) = delete;
Object& operator=(const Object& rhs) = delete;
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
mutable OwnerContainer<PropertyMetadata*> mAnimatableProperties; ///< Used for accessing animatable Node properties
- mutable TypeInfo const * 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.
using PropertyNotificationContainer = std::vector< Dali::PropertyNotification >;
PropertyNotificationContainer* mPropertyNotifications; ///< Container of owned property notifications.
DevelHandle::PropertySetSignalType mPropertySetSignal;
+
};
} // namespace Internal
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
case Property::RECTANGLE:
{
- Rect<int> convertedValue;
+ Rect<int32_t> convertedValue;
if( propertyValue.Get( convertedValue ) )
{
value = convertedValue;
case Property::INTEGER:
{
- int convertedValue;
+ int32_t convertedValue;
if( propertyValue.Get( convertedValue ) )
{
value = convertedValue;
/**
* @brief The value of this property used to read/write by the event thread.
*
- * If a component index, then refers to the value in the PropertyMetatdata of the base property
+ * If this PropertyMetadata is for property component, then refers to the value in the PropertyMetadata of the base property
* to ensure the components are kept in sync with the overall value on the event thread.
- * Otherwise, this just refers to the storedValue.
+ * Otherwise, this refers to mStoredValue.
*/
Property::Value& value;
private:
- Property::Value mStoredValue; ///< The stored property value used to read/write by the event thread
+ 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
};
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
}
- // Check if target scene-object already present, and if so create our notification
- // scene-object
- const SceneGraph::PropertyOwner* object = mObject->GetSceneObject();
- if (object)
- {
- CreateSceneObject();
- }
+ // all objects always have scene object
+ CreateSceneObject();
}
// Connect to the property notification manager
// if single render task to screen then set its viewport parameters
if( 1 == mRenderTaskList->GetTaskCount() )
{
- Dali::RenderTask defaultRenderTask = mRenderTaskList->GetTask( 0u );
+ RenderTaskPtr defaultRenderTask = mRenderTaskList->GetTask( 0u );
- if(!defaultRenderTask.GetTargetFrameBuffer())
+ if(!defaultRenderTask->GetTargetFrameBuffer())
{
- defaultRenderTask.SetViewport( Viewport( 0, 0, static_cast<int32_t>( width ), static_cast<int32_t>( height ) ) ); // truncated
+ defaultRenderTask->SetViewport( Viewport( 0, 0, static_cast<int32_t>( width ), static_cast<int32_t>( height ) ) ); // truncated
}
}
Dali::Texture texture = Dali::Texture::New( Dali::TextureType::TEXTURE_2D, Dali::Pixel::RGB888, static_cast<uint32_t>( width ), static_cast<uint32_t>( height ) );
frameBuffer.AttachColorTexture( texture );
- Dali::RenderTask defaultRenderTask = mRenderTaskList->GetTask( 0u );
- defaultRenderTask.SetFrameBuffer( frameBuffer );
+ RenderTaskPtr defaultRenderTask = mRenderTaskList->GetTask( 0u );
+ defaultRenderTask->SetFrameBuffer( &GetImplementation( frameBuffer ) );
}
}
}
return basePropertyIndex;
}
-int TypeInfo::GetComponentIndex( Property::Index index ) const
+int32_t TypeInfo::GetComponentIndex( Property::Index index ) const
{
int componentIndex = Property::INVALID_COMPONENT_INDEX;
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics 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
{
-GestureDetector::GestureDetector(Gesture::Type type)
-: mType(type),
- mGestureEventProcessor(ThreadLocalStorage::Get().GetGestureEventProcessor())
+GestureDetector::GestureDetector(Gesture::Type type, const SceneGraph::PropertyOwner* sceneObject )
+: Object( sceneObject ),
+ mType( type ),
+ mGestureEventProcessor( ThreadLocalStorage::Get().GetGestureEventProcessor() )
{
}
}
}
-void GestureDetector::SetDefaultProperty( Property::Index index, const Property::Value& property )
-{
- // None of our properties should be settable from Public API
-}
-
-Property::Value GestureDetector::GetDefaultProperty(Property::Index index) const
-{
- return Property::Value();
-}
-
-Property::Value GestureDetector::GetDefaultPropertyCurrentValue( Property::Index index ) const
-{
- return Property::Value();
-}
-
-const SceneGraph::PropertyOwner* GestureDetector::GetSceneObject() const
-{
- return NULL;
-}
-
-const SceneGraph::PropertyBase* GestureDetector::GetSceneObjectAnimatableProperty( Property::Index index ) const
-{
- return NULL;
-}
-
-const PropertyInputImpl* GestureDetector::GetSceneObjectInputProperty( Property::Index index ) const
-{
- return NULL;
-}
-
} // namespace Internal
} // namespace Dali
#define __DALI_INTERNAL_GESTURE_DETECTOR_H__
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* 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(Gesture::Type mType);
+ GestureDetector(Gesture::Type type, const SceneGraph::PropertyOwner* sceneObject = nullptr );
/**
* A reference counted object may only be deleted by calling Unreference()
private:
// Undefined
- GestureDetector(const GestureDetector&);
-
- // Undefined
- GestureDetector& operator=(const GestureDetector& rhs);
+ GestureDetector() = delete;
+ GestureDetector(const GestureDetector&) = delete;
+ GestureDetector& operator=(const GestureDetector& rhs) = delete;
/**
* @copydoc Dali::Internal::Object::Observer::SceneObjectAdded()
*/
virtual void OnActorDestroyed(Object& object) = 0;
-private: // Default property extensions from Object
-
- /**
- * @copydoc Dali::Internal::Object::SetDefaultProperty()
- */
- virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultProperty()
- */
- virtual Property::Value GetDefaultProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
- */
- virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
- */
- virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
-
protected:
Gesture::Type mType; ///< The gesture detector will detect this type of gesture.
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
mPanGestureProcessor.SetMultitapSmoothingRange( value );
}
+const PanGestureProcessor& GestureEventProcessor::GetPanGestureProcessor()
+{
+ return mPanGestureProcessor;
+}
} // namespace Internal
#define __DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H__
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
void SetPanGestureMultitapSmoothingRange( int value );
+public: // needed for PanGesture
+
+ /**
+ * @return the pan gesture processor
+ */
+ const PanGestureProcessor& GetPanGestureProcessor();
+
private:
// Undefined
if( hit.actor )
{
- results.renderTask = Dali::RenderTask( &renderTask );
+ results.renderTask = RenderTaskPtr( &renderTask );
results.actor = Dali::Actor( hit.actor );
results.actorCoordinates = hit.hitPosition;
for( RenderTaskList::RenderTaskContainer::reverse_iterator iter = tasks.rbegin(); endIter != iter; ++iter )
{
- RenderTask& renderTask = GetImplementation( *iter );
- bool isOffscreenRenderTask = ( iter->GetTargetFrameBuffer() || iter->GetFrameBuffer() );
+ RenderTask& renderTask = *iter->Get();
+ bool isOffscreenRenderTask = ( renderTask.GetTargetFrameBuffer() || renderTask.GetFrameBuffer() );
if( (onScreen && isOffscreenRenderTask) || (!onScreen && !isOffscreenRenderTask) )
{
// Skip to next task
#define DALI_INTERNAL_HIT_TEST_ALGORITHM_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics 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/public-api/render-tasks/render-task.h>
+#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
{
struct Results
{
- Dali::RenderTask renderTask; ///< The render-task displaying the actor.
- Dali::Actor actor; ///< The hit actor.
- Vector2 actorCoordinates; ///< The actor coordinates.
- Vector4 rayOrigin; ///< The point of origin of the ray.
- Vector4 rayDirection; ///< The direction vector of the ray.
+ RenderTaskPtr renderTask; ///< The render-task displaying the actor.
+ Dali::Actor actor; ///< The hit actor.
+ Vector2 actorCoordinates; ///< The actor coordinates.
+ Vector4 rayOrigin; ///< The point of origin of the ray.
+ Vector4 rayDirection; ///< The direction vector of the ray.
};
/**
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics 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_LOG_INFO( gLogFilter, Debug::Concise, "\n" );
DALI_LOG_INFO( gLogFilter, Debug::General, "Point(s): %d\n", event.GetPointCount() );
- Dali::RenderTask currentRenderTask;
+ RenderTaskPtr currentRenderTask;
for ( Integration::PointContainerConstIterator iter = event.points.begin(), beginIter = event.points.begin(), endIter = event.points.end(); iter != endIter; ++iter )
{
if ( mLastRenderTask )
{
Dali::Actor leaveEventConsumer;
- RenderTask& lastRenderTaskImpl( GetImplementation( mLastRenderTask ) );
+ RenderTask& lastRenderTaskImpl = *mLastRenderTask.Get();
if( lastPrimaryHitActor &&
lastPrimaryHitActor != primaryHitActor &&
#define __DALI_INTERNAL_HOVER_EVENT_PROCESSOR_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics 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/render-tasks/render-task.h>
#include <dali/internal/event/events/actor-observer.h>
+#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
{
ActorObserver mLastPrimaryHitActor; ///< Stores the last primary point hit actor
ActorObserver mLastConsumedActor; ///< Stores the last consumed actor
ActorObserver mHoverStartConsumedActor; ///< Stores the hover-start consumed actor
- Dali::RenderTask mLastRenderTask; ///< The RenderTask used for the last hit actor
+ RenderTaskPtr mLastRenderTask; ///< The RenderTask used for the last hit actor
};
} // namespace Internal
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics 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 ( !mCurrentEmitters.empty() )
{
Vector2 actorCoords;
- RenderTask& renderTaskImpl( GetImplementation( mCurrentRenderTask ) );
+ RenderTask& renderTaskImpl = *mCurrentRenderTask.Get();
currentGesturedActor->ScreenToLocal( renderTaskImpl, actorCoords.x, actorCoords.y, longPressEvent.point.x, longPressEvent.point.y );
EmitLongPressSignal( currentGesturedActor, mCurrentEmitters, longPressEvent, actorCoords );
#define __DALI_INTERNAL_LONG_PRESS_GESTURE_EVENT_PROCESSOR_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics 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/render-tasks/render-task.h>
#include <dali/internal/event/events/long-press-gesture-detector-impl.h>
#include <dali/internal/event/events/gesture-processor.h>
+#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
{
LongPressGestureDetectorContainer mGestureDetectors;
GestureDetectorContainer mCurrentEmitters;
- Dali::RenderTask mCurrentRenderTask;
+ RenderTaskPtr mCurrentRenderTask;
- unsigned int mMinTouchesRequired;
- unsigned int mMaxTouchesRequired;
+ uint32_t mMinTouchesRequired;
+ uint32_t mMaxTouchesRequired;
const Integration::LongPressGestureEvent* mCurrentLongPressEvent; ///< Pointer to current longPressEvent, used when calling ProcessAndEmit()
};
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
PanGestureDetectorPtr PanGestureDetector::New()
{
- return new PanGestureDetector;
-}
-
-PanGestureDetector::PanGestureDetector()
-: GestureDetector(Gesture::Pan),
- mMinimumTouches(1),
- mMaximumTouches(1),
- mSceneObject(NULL)
-{
-}
-
-PanGestureDetector::~PanGestureDetector()
-{
+ const SceneGraph::PanGesture& sceneObject = ThreadLocalStorage::Get().GetGestureEventProcessor().GetPanGestureProcessor().GetSceneObject();
+ return new PanGestureDetector( sceneObject );
}
void PanGestureDetector::SetMinimumTouchesRequired(unsigned int minimum)
}
}
-void PanGestureDetector::SetSceneObject( const SceneGraph::PanGesture* object )
-{
- mSceneObject = object;
-}
-
bool PanGestureDetector::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
{
bool connected( true );
ThreadLocalStorage::Get().GetGestureEventProcessor().SetGestureProperties( pan );
}
+PanGestureDetector::PanGestureDetector( const SceneGraph::PanGesture& sceneObject )
+: GestureDetector(Gesture::Pan, &sceneObject ),
+ mMinimumTouches(1),
+ mMaximumTouches(1)
+{
+}
+
+PanGestureDetector::~PanGestureDetector()
+{
+}
+
+const SceneGraph::PanGesture& PanGestureDetector::GetPanGestureSceneObject() const
+{
+ return static_cast<const SceneGraph::PanGesture&>( GetSceneObject() );
+}
+
void PanGestureDetector::OnActorAttach(Actor& actor)
{
// Do nothing
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;
{
case Dali::PanGestureDetector::Property::SCREEN_POSITION:
{
- if(mSceneObject)
- {
- value = mSceneObject->GetScreenPositionProperty().Get();
- }
- else
- {
- value = Vector2();
- }
+ value = GetPanGestureSceneObject().GetScreenPositionProperty().Get();
break;
}
case Dali::PanGestureDetector::Property::SCREEN_DISPLACEMENT:
{
- if(mSceneObject)
- {
- value = mSceneObject->GetScreenDisplacementProperty().Get();
- }
- else
- {
- value = Vector2();
- }
+ value = GetPanGestureSceneObject().GetScreenDisplacementProperty().Get();
break;
}
case Dali::PanGestureDetector::Property::SCREEN_VELOCITY:
{
- if(mSceneObject)
- {
- value = mSceneObject->GetScreenVelocityProperty().Get();
- }
- else
- {
- value = Vector2();
- }
+ value = GetPanGestureSceneObject().GetScreenVelocityProperty().Get();
break;
}
case Dali::PanGestureDetector::Property::LOCAL_POSITION:
{
- if(mSceneObject)
- {
- value = mSceneObject->GetLocalPositionProperty().Get();
- }
- else
- {
- value = Vector2();
- }
+ value = GetPanGestureSceneObject().GetLocalPositionProperty().Get();
break;
}
case Dali::PanGestureDetector::Property::LOCAL_DISPLACEMENT:
{
- if(mSceneObject)
- {
- value = mSceneObject->GetLocalDisplacementProperty().Get();
- }
- else
- {
- value = Vector2();
- }
+ value = GetPanGestureSceneObject().GetLocalDisplacementProperty().Get();
break;
}
case Dali::PanGestureDetector::Property::LOCAL_VELOCITY:
{
- if(mSceneObject)
- {
- value = mSceneObject->GetLocalVelocityProperty().Get();
- }
- else
- {
- value = Vector2();
- }
+ value = GetPanGestureSceneObject().GetLocalVelocityProperty().Get();
break;
}
case Dali::PanGestureDetector::Property::PANNING:
{
- if(mSceneObject)
- {
- value = mSceneObject->GetPanningProperty().Get();
- }
- else
- {
- value = false;
- }
+ value = GetPanGestureSceneObject().GetPanningProperty().Get();
break;
}
return value;
}
-const SceneGraph::PropertyOwner* PanGestureDetector::GetSceneObject() const
-{
- // This method should only return an object connected to the scene-graph
- return mSceneObject;
-}
-
-const SceneGraph::PropertyBase* PanGestureDetector::GetSceneObjectAnimatableProperty( Property::Index index ) const
-{
- DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );
-
- // None of our properties are animatable
- return NULL;
-}
-
const PropertyInputImpl* PanGestureDetector::GetSceneObjectInputProperty( Property::Index index ) const
{
- const PropertyInputImpl* property( NULL );
-
- // This method should only return a property of an object connected to the scene-graph
- if ( !mSceneObject )
- {
- return property;
- }
+ const PropertyInputImpl* property = nullptr;
- 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" );
- property = custom->GetSceneGraphProperty();
- }
- else
+ switch ( index )
{
- switch ( index )
+ case Dali::PanGestureDetector::Property::SCREEN_POSITION:
{
- case Dali::PanGestureDetector::Property::SCREEN_POSITION:
- {
- property = &mSceneObject->GetScreenPositionProperty();
- break;
- }
-
- case Dali::PanGestureDetector::Property::SCREEN_DISPLACEMENT:
- {
- property = &mSceneObject->GetScreenDisplacementProperty();
- break;
- }
+ property = &GetPanGestureSceneObject().GetScreenPositionProperty();
+ break;
+ }
- case Dali::PanGestureDetector::Property::SCREEN_VELOCITY:
- {
- property = &mSceneObject->GetScreenVelocityProperty();
- break;
- }
+ case Dali::PanGestureDetector::Property::SCREEN_DISPLACEMENT:
+ {
+ property = &GetPanGestureSceneObject().GetScreenDisplacementProperty();
+ break;
+ }
- case Dali::PanGestureDetector::Property::LOCAL_POSITION:
- {
- property = &mSceneObject->GetLocalPositionProperty();
- break;
- }
+ case Dali::PanGestureDetector::Property::SCREEN_VELOCITY:
+ {
+ property = &GetPanGestureSceneObject().GetScreenVelocityProperty();
+ break;
+ }
- case Dali::PanGestureDetector::Property::LOCAL_DISPLACEMENT:
- {
- property = &mSceneObject->GetLocalDisplacementProperty();
- break;
- }
+ case Dali::PanGestureDetector::Property::LOCAL_POSITION:
+ {
+ property = &GetPanGestureSceneObject().GetLocalPositionProperty();
+ break;
+ }
- case Dali::PanGestureDetector::Property::LOCAL_VELOCITY:
- {
- property = &mSceneObject->GetLocalVelocityProperty();
- break;
- }
+ case Dali::PanGestureDetector::Property::LOCAL_DISPLACEMENT:
+ {
+ property = &GetPanGestureSceneObject().GetLocalDisplacementProperty();
+ break;
+ }
- case Dali::PanGestureDetector::Property::PANNING:
- {
- property = &mSceneObject->GetPanningProperty();
- break;
- }
+ case Dali::PanGestureDetector::Property::LOCAL_VELOCITY:
+ {
+ property = &GetPanGestureSceneObject().GetLocalVelocityProperty();
+ break;
+ }
- default:
- break;
+ case Dali::PanGestureDetector::Property::PANNING:
+ {
+ property = &GetPanGestureSceneObject().GetPanningProperty();
+ break;
}
+
+ default:
+ break;
+ }
+ if( !property )
+ {
+ // not our property, ask base
+ property = Object::GetSceneObjectInputProperty( index );
}
return property;
#define __DALI_INTERNAL_PAN_GESTURE_DETECTOR_H__
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics 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 PanGestureDetectorPtr New();
- /**
- * Construct a new PanGestureDetector.
- */
- PanGestureDetector();
-
public:
/**
*/
void EmitPanGestureSignal(Dali::Actor actor, const PanGesture& pan);
- /**
- * Called by the PanGestureProcessor to set the scene object.
- * @param[in] object The scene object.
- */
- void SetSceneObject( const SceneGraph::PanGesture* object );
-
public: // Signals
/**
protected:
/**
+ * Construct a new PanGestureDetector.
+ * @param sceneObject the scene object
+ */
+ PanGestureDetector( const SceneGraph::PanGesture& sceneObject );
+
+ /**
* A reference counted object may only be deleted by calling Unreference()
*/
virtual ~PanGestureDetector();
private:
// Undefined
- PanGestureDetector(const PanGestureDetector&);
+ PanGestureDetector() = delete;
+ PanGestureDetector(const PanGestureDetector&) = delete;
+ PanGestureDetector& operator=(const PanGestureDetector& rhs) = delete;
- // Undefined
- PanGestureDetector& operator=(const PanGestureDetector& rhs);
+ /**
+ * @return the pan gesture scene object
+ */
+ const SceneGraph::PanGesture& GetPanGestureSceneObject() const;
// From GestureDetector
virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
/**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
- /**
* @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
*/
virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
AngleContainer mAngleContainer; ///< A container of all angles allowed for pan to occur.
- const SceneGraph::PanGesture* mSceneObject; ///< Not owned
-
};
} // namespace Internal
if ( !outsideTouchesRangeEmitters.empty() || !mCurrentPanEmitters.empty() )
{
- currentGesturedActor->ScreenToLocal( GetImplementation( mCurrentRenderTask ), actorCoords.x, actorCoords.y, panEvent.currentPosition.x, panEvent.currentPosition.y );
+ currentGesturedActor->ScreenToLocal( *mCurrentRenderTask.Get(), actorCoords.x, actorCoords.y, panEvent.currentPosition.x, panEvent.currentPosition.y );
// EmitPanSignal checks whether we have a valid actor and whether the container we are passing in has emitters before it emits the pan.
EmitPanSignal( currentGesturedActor, outsideTouchesRangeEmitters, panEvent, actorCoords, Gesture::Finished, mCurrentRenderTask);
mGestureDetectors.push_back(gestureDetector);
- // Set the pan scene object on the gesture detector
- gestureDetector->SetSceneObject( mSceneObject );
-
if (firstRegistration)
{
mMinTouchesRequired = gestureDetector->GetMinimumTouchesRequired();
mSceneObject->SetMultitapSmoothingRange( value );
}
+const SceneGraph::PanGesture& PanGestureProcessor::GetSceneObject() const
+{
+ return *mSceneObject;
+}
+
void PanGestureProcessor::UpdateDetection()
{
DALI_ASSERT_DEBUG(!mGestureDetectors.empty());
const Integration::PanGestureEvent& panEvent,
Vector2 localCurrent,
Gesture::State state,
- Dali::RenderTask renderTask )
+ RenderTaskPtr renderTask )
{
if ( actor && !gestureDetectors.empty() )
{
pan.screenPosition = panEvent.currentPosition;
pan.position = localCurrent;
- RenderTask& renderTaskImpl( GetImplementation( renderTask ) );
+ RenderTask& renderTaskImpl( *renderTask.Get() );
Vector2 localPrevious;
actor->ScreenToLocal( renderTaskImpl, localPrevious.x, localPrevious.y, panEvent.previousPosition.x, panEvent.previousPosition.y );
{
// It does, calculate the angle of the pan in local actor coordinates and ensures it fits
// the detector's criteria.
- RenderTask& renderTaskImpl( GetImplementation( mCurrentRenderTask ) );
+ RenderTask& renderTaskImpl = *mCurrentRenderTask.Get();
Vector2 startPosition, currentPosition;
actor->ScreenToLocal( renderTaskImpl, startPosition.x, startPosition.y, mPossiblePanPosition.x, mPossiblePanPosition.y );
mCurrentPanEmitters.clear();
ResetActor();
- actor->ScreenToLocal( GetImplementation(mCurrentRenderTask), actorCoordinates.x, actorCoordinates.y, mCurrentPanEvent->currentPosition.x, mCurrentPanEvent->currentPosition.y );
+ actor->ScreenToLocal( *mCurrentRenderTask.Get(), actorCoordinates.x, actorCoordinates.y, mCurrentPanEvent->currentPosition.x, mCurrentPanEvent->currentPosition.y );
EmitPanSignal( actor, gestureDetectors, *mCurrentPanEvent, actorCoordinates, mCurrentPanEvent->state, mCurrentRenderTask );
#define __DALI_INTERNAL_PAN_GESTURE_EVENT_PROCESSOR_H__
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics 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/render-tasks/render-task.h>
#include <dali/internal/event/events/pan-gesture-detector-impl.h>
#include <dali/internal/event/events/gesture-processor.h>
+#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
{
*/
void SetMultitapSmoothingRange( int value );
+public: // for PanGestureDetector
+
+ /**
+ * @return the pan gesture scene object
+ */
+ const SceneGraph::PanGesture& GetSceneObject() const;
+
private:
// Undefined
const Integration::PanGestureEvent& panEvent,
Vector2 localCurrent,
Gesture::State state,
- Dali::RenderTask renderTask );
+ RenderTaskPtr renderTask );
// GestureProcessor overrides
Integration::GestureManager& mGestureManager;
PanGestureDetectorContainer mGestureDetectors;
GestureDetectorContainer mCurrentPanEmitters;
- Dali::RenderTask mCurrentRenderTask;
+ RenderTaskPtr mCurrentRenderTask;
Vector2 mPossiblePanPosition;
- unsigned int mMinTouchesRequired;
- unsigned int mMaxTouchesRequired;
+ 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.
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics 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 ( !mCurrentPinchEmitters.empty() )
{
Vector2 actorCoords;
- RenderTask& renderTaskImpl( GetImplementation(mCurrentRenderTask) );
+ RenderTask& renderTaskImpl( *mCurrentRenderTask.Get() );
currentGesturedActor->ScreenToLocal( renderTaskImpl, actorCoords.x, actorCoords.y, pinchEvent.centerPoint.x, pinchEvent.centerPoint.y );
EmitPinchSignal( currentGesturedActor, mCurrentPinchEmitters, pinchEvent, actorCoords );
#define __DALI_INTERNAL_PINCH_GESTURE_EVENT_PROCESSOR_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics 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/render-tasks/render-task.h>
#include <dali/internal/event/events/pinch-gesture-detector-impl.h>
#include <dali/internal/event/events/gesture-processor.h>
+#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
{
Integration::GestureManager& mGestureManager;
PinchGestureDetectorContainer mGestureDetectors;
GestureDetectorContainer mCurrentPinchEmitters;
- Dali::RenderTask mCurrentRenderTask;
+ RenderTaskPtr mCurrentRenderTask;
const Integration::PinchGestureEvent* mCurrentPinchEvent; ///< Pointer to current PinchEvent, used when calling ProcessAndEmit()
};
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics 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_LOG_INFO( gLogFilter, Debug::Concise, "\n" );
DALI_LOG_INFO( gLogFilter, Debug::General, "Point(s): %d\n", event.GetPointCount() );
- Dali::RenderTask currentRenderTask;
+ RenderTaskPtr currentRenderTask;
for ( Integration::PointContainerConstIterator iter = event.points.begin(), beginIter = event.points.begin(), endIter = event.points.end(); iter != endIter; ++iter )
{
if ( mLastRenderTask )
{
Dali::Actor leaveEventConsumer;
- RenderTask& lastRenderTaskImpl( GetImplementation( mLastRenderTask ) );
+ RenderTask& lastRenderTaskImpl = *mLastRenderTask.Get();
if( lastPrimaryHitActor &&
lastPrimaryHitActor != primaryHitActor &&
#define __DALI_INTERNAL_TOUCH_EVENT_PROCESSOR_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics 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/render-tasks/render-task.h>
#include <dali/internal/event/events/actor-observer.h>
+#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
{
ActorObserver mLastPrimaryHitActor; ///< Stores the last primary point hit actor
ActorObserver mLastConsumedActor; ///< Stores the last consumed actor
ActorObserver mTouchDownConsumedActor; ///< Stores the touch-down consumed actor
- Dali::RenderTask mLastRenderTask; ///< The RenderTask used for the last hit actor
+ RenderTaskPtr mLastRenderTask; ///< The RenderTask used for the last hit actor
};
} // namespace Internal
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/object/custom-object-internal.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/common/stage-impl.h>
-#include <dali/internal/update/common/animatable-property.h>
-#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/manager/update-manager.h>
-#include <dali/internal/update/animation/scene-graph-constraint-base.h>
-
-using Dali::Internal::SceneGraph::PropertyOwner;
-using Dali::Internal::SceneGraph::PropertyBase;
-using Dali::Internal::SceneGraph::UpdateManager;
-using Dali::Internal::SceneGraph::AnimatableProperty;
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-CustomObject* CustomObject::New()
-{
- return new CustomObject();
-}
-
-const SceneGraph::PropertyOwner* CustomObject::GetSceneObject() const
-{
- return mUpdateObject;
-}
-
-const PropertyBase* CustomObject::GetSceneObjectAnimatableProperty( Property::Index index ) const
-{
- CustomPropertyMetadata* custom = FindCustomProperty( index );
- DALI_ASSERT_ALWAYS( custom && "Property index is invalid" );
- return custom->GetSceneGraphProperty();
-}
-
-const PropertyInputImpl* CustomObject::GetSceneObjectInputProperty( Property::Index index ) const
-{
- return GetSceneObjectAnimatableProperty( index );
-}
-
-void CustomObject::SetDefaultProperty( Property::Index index, const Property::Value& property )
-{
- // do nothing
-}
-
-Property::Value CustomObject::GetDefaultProperty(Property::Index index) const
-{
- return Property::Value();
-}
-
-Property::Value CustomObject::GetDefaultPropertyCurrentValue( Property::Index index ) const
-{
- return Property::Value();
-}
-
-CustomObject::~CustomObject()
-{
- // Guard to allow handle destruction after Core has been destroyed
- if( Stage::IsInstalled() )
- {
- if( NULL != mUpdateObject )
- {
- RemoveObjectMessage( GetEventThreadServices().GetUpdateManager(), mUpdateObject );
- mUpdateObject = NULL; // object is about to be destroyed
- }
- }
-}
-
-CustomObject::CustomObject()
-{
- mUpdateObject = PropertyOwner::New();
-
- OwnerPointer< PropertyOwner > transferOwnership( mUpdateObject );
- AddObjectMessage( GetEventThreadServices().GetUpdateManager(), transferOwnership );
-}
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_CUSTOM_OBJECT_H__
-#define __DALI_INTERNAL_CUSTOM_OBJECT_H__
-
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/common/object-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace SceneGraph
-{
-class PropertyOwner;
-}
-
-class CustomObject : public Object
-{
-public:
-
- /**
- * Create a new custom object.
- * @return A pointer to the newly allocated object.
- */
- static CustomObject* New();
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
- */
- virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::SetDefaultProperty()
- */
- virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultProperty()
- */
- virtual Property::Value GetDefaultProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
- */
- virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
-
-protected:
-
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~CustomObject();
-
- /**
- * Private constructor; see also CustomObject::New()
- */
- CustomObject();
-
- // Undefined
- CustomObject(const CustomObject&);
-
- // Undefined
- CustomObject& operator=(const CustomObject& rhs);
-
-protected:
-
- SceneGraph::PropertyOwner* mUpdateObject;
-};
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_CUSTOM_OBJECT_H__
} // Unnamed namespace
-RenderTask* RenderTask::New()
+RenderTaskPtr RenderTask::New( Actor* sourceActor, CameraActor* cameraActor, SceneGraph::RenderTaskList& parentSceneObject )
{
- RenderTask* task( new RenderTask() );
+ // create scene object first so it's guaranteed to exist for the event side
+ auto sceneObject = SceneGraph::RenderTask::New();
+ OwnerPointer< SceneGraph::RenderTask > transferOwnership( sceneObject );
+ // pass the pointer to base for message passing
+ RenderTaskPtr task( new RenderTask( sceneObject ) );
+ // transfer scene object ownership to update manager
+ AddTaskMessage( task->GetEventThreadServices(), parentSceneObject, transferOwnership );
+ // Set the default source & camera actors
+ task->SetSourceActor( sourceActor );
+ task->SetCameraActor( cameraActor );
+
+ // no need for additional messages as scene objects defaults match ours
return task;
}
void RenderTask::SetSourceActor( Actor* actor )
{
+ mSourceActor = actor;
+ if ( mSourceActor )
+ {
+ SetSourceNodeMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), &mSourceActor->GetNode() );
+ }
+ else
+ {
+ SetSourceNodeMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), nullptr );
+ }
+ // set the actor on exclusive container for hit testing
const Stage* stage = Stage::GetCurrent();
if ( stage )
{
stage->GetRenderTaskList().SetExclusive( this, mExclusive );
}
- mSourceConnector.SetActor( actor );
}
Actor* RenderTask::GetSourceActor() const
{
- return mSourceConnector.mActor;
+ return mSourceActor;
}
void RenderTask::SetExclusive( bool exclusive )
stage->GetRenderTaskList().SetExclusive( this, exclusive );
}
- if ( mSceneObject )
- {
- // mSceneObject is being used in a separate thread; queue a message to set the value
- SetExclusiveMessage( GetEventThreadServices(), *mSceneObject, mExclusive );
- }
+ // scene object is being used in a separate thread; queue a message to set the value
+ SetExclusiveMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), mExclusive );
}
}
void RenderTask::SetCameraActor( CameraActor* cameraActor )
{
- if( cameraActor )
+ mCameraActor = cameraActor;
+ if( mCameraActor )
{
- mCameraConnector.mCamera = cameraActor->GetCamera();
+ SetCameraMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), &mCameraActor->GetNode(), mCameraActor->GetCamera() );
}
else
{
- mCameraConnector.mCamera = NULL;
+ SetCameraMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), nullptr, nullptr );
}
- mCameraConnector.SetActor( cameraActor );
}
CameraActor* RenderTask::GetCameraActor() const
{
- // camera connector can only point to camera actor
- return static_cast< CameraActor* >( mCameraConnector.mActor );
+ return mCameraActor;
}
void RenderTask::SetTargetFrameBuffer( FrameBufferImagePtr image )
renderFrameBufferPtr = mFrameBuffer->GetRenderObject();
}
- SetFrameBufferMessage( GetEventThreadServices(), *mSceneObject, renderFrameBufferPtr );
+ SetFrameBufferMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), renderFrameBufferPtr );
}
FrameBuffer* RenderTask::GetFrameBuffer() const
return mScreenToFrameBufferFunction;
}
-void RenderTask::SetScreenToFrameBufferMappingActor( Actor* mappingActor )
+void RenderTask::SetScreenToFrameBufferMappingActor( Dali::Actor& mappingActor )
{
- mMappingConnector.SetActor( mappingActor );
+ mInputMappingActor = WeakHandle<Dali::Actor>( mappingActor );
}
-Actor* RenderTask::GetScreenToFrameBufferMappingActor() const
+Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const
{
- return mMappingConnector.mActor;
+ return mInputMappingActor.GetHandle();
}
void RenderTask::SetViewportPosition(const Vector2& value)
{
mViewportPosition = value;
- BakeViewportPositionMessage( GetEventThreadServices(), *mSceneObject, value );
+ BakeViewportPositionMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), value );
}
Vector2 RenderTask::GetCurrentViewportPosition() const
{
- return mSceneObject->GetViewportPosition( GetEventThreadServices().GetEventBufferIndex() );
+ return GetRenderTaskSceneObject().GetViewportPosition( GetEventThreadServices().GetEventBufferIndex() );
}
void RenderTask::SetViewportSize(const Vector2& value)
{
mViewportSize = value;
- BakeViewportSizeMessage( GetEventThreadServices(), *mSceneObject, value );
+ BakeViewportSizeMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), value );
}
Vector2 RenderTask::GetCurrentViewportSize() const
{
- return mSceneObject->GetViewportSize( GetEventThreadServices().GetEventBufferIndex() );
+ return GetRenderTaskSceneObject().GetViewportSize( GetEventThreadServices().GetEventBufferIndex() );
}
void RenderTask::SetViewport( const Viewport& viewport )
{
BufferIndex bufferIndex = GetEventThreadServices().GetEventBufferIndex();
- if(!mSceneObject->GetViewportEnabled( bufferIndex ))
+ if( !GetRenderTaskSceneObject().GetViewportEnabled( bufferIndex ) )
{
if ( mFrameBufferImage )
{
}
else
{
- const Vector2& position = mSceneObject->GetViewportPosition(bufferIndex);
- const Vector2& size = mSceneObject->GetViewportSize(bufferIndex);
+ 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
{
mClearColor = color;
- if ( mSceneObject )
- {
- // mSceneObject is being used in a separate thread; queue a message to set the value
- BakeClearColorMessage( GetEventThreadServices(), *mSceneObject, color );
- }
+ // scene object is being used in a separate thread; queue a message to set the value
+ BakeClearColorMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), color );
}
}
const Vector4& RenderTask::GetClearColor() const
{
- return mSceneObject->GetClearColor( GetEventThreadServices().GetEventBufferIndex() );
+ return GetRenderTaskSceneObject().GetClearColor( GetEventThreadServices().GetEventBufferIndex() );
}
void RenderTask::SetSyncRequired( bool requiresSync )
{
mRequiresSync = requiresSync;
- if( mSceneObject )
- {
- // mSceneObject is being used in a separate thread; queue a message to set the value
- SetSyncRequiredMessage( GetEventThreadServices(), *mSceneObject, requiresSync );
- }
+ // scene object is being used in a separate thread; queue a message to set the value
+ SetSyncRequiredMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), requiresSync );
}
}
{
mClearEnabled = enabled;
- if ( mSceneObject )
- {
- // mSceneObject is being used in a separate thread; queue a message to set the value
- SetClearEnabledMessage( GetEventThreadServices(), *mSceneObject, mClearEnabled );
- }
+ // scene object is being used in a separate thread; queue a message to set the value
+ SetClearEnabledMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), mClearEnabled );
}
}
{
mCullMode = mode;
- if ( mSceneObject )
- {
- // mSceneObject is being used in a separate thread; queue a message to set the value
- SetCullModeMessage( GetEventThreadServices(), *mSceneObject, mCullMode );
- }
+ // scene object is being used in a separate thread; queue a message to set the value
+ SetCullModeMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), mCullMode );
}
}
// Note - even when refreshRate is the same as mRefreshRate, a message should be sent
- if ( mSceneObject )
- {
- // mSceneObject is being used in a separate thread; queue a message to set the value
- SetRefreshRateMessage( GetEventThreadServices(), *mSceneObject, refreshRate );
- }
+ // sceneObject is being used in a separate thread; queue a message to set the value
+ SetRefreshRateMessage( GetEventThreadServices(), GetRenderTaskSceneObject(), refreshRate );
}
uint32_t RenderTask::GetRefreshRate() const
CameraActor* cameraActor = GetCameraActor();
if ( mInputEnabled &&
- NULL != sourceActor &&
+ nullptr != sourceActor &&
sourceActor->OnStage() &&
- NULL != cameraActor &&
+ nullptr != cameraActor &&
cameraActor->OnStage() )
{
// If the actors are rendered off-screen, then the screen coordinates must be converted
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
- if( mFrameBufferImage && mMappingConnector.mActor )
+ Dali::Actor mappingActor = GetScreenToFrameBufferMappingActor();
+
+ if( mFrameBufferImage && mappingActor )
{
+ Internal::Actor* inputMappingActor = &GetImplementation( mappingActor );
CameraActor* localCamera = GetCameraActor();
StagePtr stage = Stage::GetCurrent();
if( stage )
viewport.height = static_cast<int32_t>( size.height ); // truncated
float localX, localY;
- inside = mMappingConnector.mActor->ScreenToLocal(defaultCamera.GetViewMatrix(), defaultCamera.GetProjectionMatrix(), viewport, localX, localY, screenCoords.x, screenCoords.y);
- Vector3 actorSize = mMappingConnector.mActor->GetCurrentSize();
+ 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)
{
screenCoords.x = localX;
return actor->ScreenToLocal( *this, localX, localY, viewportX, viewportY );
}
-SceneGraph::RenderTask* RenderTask::CreateSceneObject()
-{
- // This should only be called once, with no existing scene-object
- DALI_ASSERT_DEBUG( NULL == mSceneObject );
-
- // Keep the raw-pointer until DiscardSceneObject is called
- mSceneObject = SceneGraph::RenderTask::New();
-
- // Send messages to set other properties that may have changed since last time we were on stage
- SetExclusiveMessage( GetEventThreadServices(), *mSceneObject, mExclusive );
- SetClearColorMessage( GetEventThreadServices(), *mSceneObject, mClearColor );
- SetClearEnabledMessage( GetEventThreadServices(), *mSceneObject, mClearEnabled );
- SetCullModeMessage( GetEventThreadServices(), *mSceneObject, mCullMode );
- SetRefreshRateMessage( GetEventThreadServices(), *mSceneObject, mRefreshRate );
- SetSyncRequiredMessage( GetEventThreadServices(), *mSceneObject, mRequiresSync );
- SetFrameBuffer( mFrameBuffer );
-
- // Caller takes ownership
- return mSceneObject;
-}
-
-SceneGraph::RenderTask* RenderTask::GetRenderTaskSceneObject()
-{
- return mSceneObject;
-}
-
-void RenderTask::DiscardSceneObject()
+const SceneGraph::RenderTask& RenderTask::GetRenderTaskSceneObject() const
{
- // mSceneObject is not owned; throw away the raw-pointer
- mSceneObject = NULL;
+ return *static_cast<const SceneGraph::RenderTask*>( mUpdateObject );
}
/********************************************************************************
}
}
-const SceneGraph::PropertyOwner* RenderTask::GetSceneObject() const
-{
- return mSceneObject;
-}
-
const SceneGraph::PropertyBase* RenderTask::GetSceneObjectAnimatableProperty( Property::Index index ) const
{
- DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );
-
const SceneGraph::PropertyBase* property( NULL );
- // This method should only return a property which is part of the scene-graph
- if( mSceneObject != NULL )
+ switch ( index )
{
- switch ( index )
+ case Dali::RenderTask::Property::VIEWPORT_POSITION:
{
- case Dali::RenderTask::Property::VIEWPORT_POSITION:
- property = &mSceneObject->mViewportPosition;
- break;
-
- case Dali::RenderTask::Property::VIEWPORT_SIZE:
- property = &mSceneObject->mViewportSize;
- break;
-
- case Dali::RenderTask::Property::CLEAR_COLOR:
- property = &mSceneObject->mClearColor;
- break;
-
- default:
- break;
+ property = &GetRenderTaskSceneObject().mViewportPosition;
+ break;
+ }
+ case Dali::RenderTask::Property::VIEWPORT_SIZE:
+ {
+ property = &GetRenderTaskSceneObject().mViewportSize;
+ break;
}
+ case Dali::RenderTask::Property::CLEAR_COLOR:
+ {
+ property = &GetRenderTaskSceneObject().mClearColor;
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ if( !property )
+ {
+ // not our property, ask base
+ property = Object::GetSceneObjectAnimatableProperty( index );
}
return property;
const PropertyInputImpl* RenderTask::GetSceneObjectInputProperty( Property::Index index ) const
{
- const PropertyInputImpl* property( NULL );
- if( mSceneObject != NULL )
- {
- switch ( index )
- {
- case Dali::RenderTask::Property::VIEWPORT_POSITION:
- property = &mSceneObject->mViewportPosition;
- break;
-
- case Dali::RenderTask::Property::VIEWPORT_SIZE:
- property = &mSceneObject->mViewportSize;
- break;
-
- case Dali::RenderTask::Property::CLEAR_COLOR:
- property = &mSceneObject->mClearColor;
- break;
-
- default:
- break;
- }
- }
-
- return property;
+ // animatable properties are input as well, Object::GetSceneObjectInputProperty does the same so no need to call it
+ return GetSceneObjectAnimatableProperty( index );
}
bool RenderTask::HasFinished()
{
bool finished = false;
- const uint32_t counter = mSceneObject->GetRenderedOnceCounter();
+ const uint32_t counter = GetRenderTaskSceneObject().GetRenderedOnceCounter();
if( mRefreshOnceCounter < counter )
{
mRefreshOnceCounter = counter;
}
- DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::HasFinished()=%s SCRT:%p SC\n", finished?"T":"F", mSceneObject);
+ DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::HasFinished()=%s SCRT:%p SC\n", finished?"T":"F", &GetRenderTaskSceneObject());
return finished;
}
return connected;
}
-RenderTask::RenderTask()
-: mSceneObject( NULL ),
- mSourceConnector( Connector::SOURCE_CONNECTOR, *this ),
- mCameraConnector( Connector::CAMERA_CONNECTOR, *this ),
- mMappingConnector( Connector::MAPPING_CONNECTOR, *this ),
+RenderTask::RenderTask( const SceneGraph::RenderTask* sceneObject )
+: Object( sceneObject ),
+ mSourceActor( nullptr ),
+ mCameraActor( nullptr ),
+ mInputMappingActor(),
mClearColor( Dali::RenderTask::DEFAULT_CLEAR_COLOR ),
mViewportPosition( Vector2::ZERO ),
mViewportSize( Vector2::ZERO ),
mRequiresSync( false )
{
DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::RenderTask(this:%p)\n", this);
+ // scene object handles observation of source and camera
}
RenderTask::~RenderTask()
{
DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::~RenderTask(this:%p)\n", this);
-}
-
-// Helper class for connecting Nodes to the scene-graph RenderTask
-
-RenderTask::Connector::Connector( Type type, RenderTask& renderTask )
-: mType( type ),
- mRenderTask( renderTask ),
- mActor( NULL ),
- mCamera( NULL )
-{
-}
-
-RenderTask::Connector::~Connector()
-{
- SetActor( NULL );
-}
-
-void RenderTask::Connector::SetActor( Actor* actor )
-{
- if ( mActor != actor )
- {
- if ( mActor )
- {
- mActor->RemoveObserver( *this );
- }
-
- mActor = actor;
-
- if ( mActor )
- {
- mActor->AddObserver( *this );
- }
-
- UpdateRenderTask();
- }
-}
-
-void RenderTask::Connector::SceneObjectAdded( Object& object )
-{
- UpdateRenderTask();
-}
-
-void RenderTask::Connector::SceneObjectRemoved( Object& object )
-{
- UpdateRenderTask();
-}
-
-void RenderTask::Connector::ObjectDestroyed( Object& object )
-{
- if ( SOURCE_CONNECTOR == mType )
- {
- const Stage* stage = Stage::GetCurrent();
- if ( stage )
- {
- stage->GetRenderTaskList().SetExclusive( &mRenderTask, false );
- }
- }
-
- mActor = NULL;
- mCamera = NULL; // only meaningful for the camera connector but no simple way to distinguish
-
- UpdateRenderTask();
-}
-
-void RenderTask::Connector::UpdateRenderTask()
-{
- // Guard to allow handle destruction after Core has been destroyed
- if( Internal::Stage::IsInstalled() &&
- mRenderTask.mSceneObject )
- {
- const SceneGraph::Node* node( NULL );
-
- // Check whether a Node exists in the scene-graph
- if ( NULL != mActor )
- {
- const SceneGraph::PropertyOwner* object = mActor->GetSceneObject();
- if ( NULL != object )
- {
- // actors only point to nodes as their scene objects
- node = static_cast< const SceneGraph::Node* >( object );
- }
- }
-
- //the mapping node is not used in the scene graph
- if ( SOURCE_CONNECTOR == mType )
- {
- SetSourceNodeMessage( mRenderTask.GetEventThreadServices(), *(mRenderTask.mSceneObject), node );
- }
- else if( CAMERA_CONNECTOR == mType )
- {
- SetCameraMessage( mRenderTask.GetEventThreadServices(), *(mRenderTask.mSceneObject), node, mCamera );
- }
- }
+ // scene object deletion is handled by our parent
+ // scene object handles observation of source and camera
}
} // namespace Internal
// INTERNAL INCLUDES
#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/images/frame-buffer-image-impl.h>
#include <dali/internal/event/common/object-impl.h>
namespace SceneGraph
{
+class RenderTaskList;
class RenderTask;
class Camera;
}
+using RenderTaskPtr = IntrusivePtr<RenderTask>;
+
class RenderTask : public Object
{
public:
- typedef Dali::RenderTask::ScreenToFrameBufferFunction ScreenToFrameBufferFunction;
+ using ScreenToFrameBufferFunction = Dali::RenderTask::ScreenToFrameBufferFunction;
/**
* Creates a new RenderTask.
*/
- static RenderTask* New();
+ static RenderTaskPtr New( Actor* sourceActor, CameraActor* cameraActor, SceneGraph::RenderTaskList& parentSceneObject );
/**
* @copydoc Dali::RenderTask::SetSourceActor()
/**
* copydoc Dali::RenderTask::SetScreenToFrameBufferMappingActor
*/
- void SetScreenToFrameBufferMappingActor( Actor* mappingActor );
+ void SetScreenToFrameBufferMappingActor( Dali::Actor& mappingActor );
/**
* copydoc Dali::RenderTask::GetScreenToFrameBufferMAppingActor
*/
- Actor* GetScreenToFrameBufferMappingActor() const;
+ Dali::Actor GetScreenToFrameBufferMappingActor() const;
/**
* @copydoc Dali::RenderTask::SetViewportPosition
public: // Used by RenderTaskList, which owns the SceneGraph::RenderTasks
/**
- * Create the scene-graph RenderTask object.
- * @pre CreateSceneObject has not already been called.
- * @return A newly allocated scene-graph object; the caller takes ownership.
- */
- SceneGraph::RenderTask* CreateSceneObject();
-
- /**
* Retrieve the scene-graph RenderTask object.
- * @return The scene-graph object, or NULL if this has been discarded.
- */
- SceneGraph::RenderTask* GetRenderTaskSceneObject();
-
- /**
- * Discard the scene-graph RenderTask object.
+ * @return The scene-graph object
*/
- void DiscardSceneObject();
+ const SceneGraph::RenderTask& GetRenderTaskSceneObject() const;
public: // Implementation of Object
virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
/**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
* @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
*/
virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
protected:
/**
- * Construct a new RenderTask.
+ * Constructor.
+ *
+ * @param sceneObject the scene graph object
*/
- RenderTask();
+ RenderTask( const SceneGraph::RenderTask* sceneObject );
/**
* A reference counted object may only be deleted by calling Unreference()
*/
virtual ~RenderTask();
- /**
- * Helper class for connecting Nodes to the scene-graph RenderTask
- */
- class Connector : public Object::Observer
- {
- public:
-
- enum Type
- {
- SOURCE_CONNECTOR,
- CAMERA_CONNECTOR,
- MAPPING_CONNECTOR
- };
-
- /**
- * Create the helper class
- */
- Connector( Type type, RenderTask& renderTask );
+private: // not copyable
- /**
- * Non-virtual destructor; not suitable as a base object.
- */
- ~Connector();
-
- /**
- * Set the actor to be observed.
- * @param[in] actor The actor to be observed.
- */
- void SetActor( Actor* actor );
-
- /**
- * Update the scene-graph RenderTask with a new source/camera Node.
- */
- void UpdateRenderTask();
-
- public: // From Object::Observer
-
- /**
- * @copydoc Dali::Internal::Object::Observer::SceneObjectAdded
- */
- virtual void SceneObjectAdded( Object& object );
-
- /**
- * @copydoc Dali::Internal::Object::Observer::SceneObjectAdded
- */
- virtual void SceneObjectRemoved( Object& object );
-
- /**
- * @copydoc Dali::Internal::Object::Observer::ObjectDestroyed
- */
- virtual void ObjectDestroyed( Object& object );
-
- private:
-
- // Undefined
- Connector(const Connector&);
-
- // Undefined
- Connector& operator=(const Connector& rhs);
-
- public:
-
- const Type mType;
-
- RenderTask& mRenderTask;
-
- Actor* mActor; ///< Raw-pointer to the actor; not owned.
- const SceneGraph::Camera* mCamera; ///< Raw-pointer to camera scene-graph object; not owned.
- };
+ RenderTask() = delete;
+ RenderTask( const RenderTask& ) = delete;
+ RenderTask& operator=( const RenderTask& ) = delete;
private:
- SceneGraph::RenderTask* mSceneObject; ///< Raw-pointer to the scene-graph object; not owned.
-
- Connector mSourceConnector; ///< Responsible for connecting/disconnecting source Nodes
- Connector mCameraConnector; ///< Responsible for connecting/disconnecting camera Nodes
- Connector mMappingConnector; /// Responsible for connecting/disconnecting actor node, which used to mapping screen to frame buffer coordinate
+ Actor* mSourceActor; ///< Source actor, we cannot keep the actor alive so raw pointer.
+ CameraActor* mCameraActor; ///< Camera actor, we cannot keep the actor alive so raw pointer.
+ WeakHandle<Dali::Actor> mInputMappingActor; /// used to mapping screen to frame buffer coordinate, not kept alive by rendertask
Vector4 mClearColor; ///< Optional clear color
return taskList;
}
-Dali::RenderTask RenderTaskList::CreateTask()
+RenderTaskPtr RenderTaskList::CreateTask()
{
return CreateTask( &mDefaults.GetDefaultRootActor(), &mDefaults.GetDefaultCameraActor() );
}
-Dali::RenderTask RenderTaskList::CreateTask( Actor* sourceActor, CameraActor* cameraActor)
+RenderTaskPtr RenderTaskList::CreateTask( Actor* sourceActor, CameraActor* cameraActor)
{
- RenderTask* taskImpl = RenderTask::New();
+ RenderTaskPtr task = RenderTask::New( sourceActor, cameraActor, *mSceneObject );
- Dali::RenderTask newTask( taskImpl );
- mTasks.push_back( newTask );
+ mTasks.push_back( task );
- if ( mSceneObject )
- {
- SceneGraph::RenderTask* sceneObject = taskImpl->CreateSceneObject();
-
- OwnerPointer< SceneGraph::RenderTask > transferOwnership( sceneObject );
- AddTaskMessage( mEventThreadServices, *mSceneObject, transferOwnership );
- }
-
- // Set the default source & camera actors
- taskImpl->SetSourceActor( sourceActor );
- taskImpl->SetCameraActor( cameraActor );
-
- return newTask;
+ return task;
}
-void RenderTaskList::RemoveTask( Dali::RenderTask task )
+void RenderTaskList::RemoveTask( Internal::RenderTask& task )
{
for ( RenderTaskContainer::iterator iter = mTasks.begin(); mTasks.end() != iter; ++iter )
{
- if ( *iter == task )
+ if ( iter->Get() == &task )
{
- RenderTask& taskImpl = GetImplementation( task );
- if ( mSceneObject )
- {
- SceneGraph::RenderTask* sceneObject = taskImpl.GetRenderTaskSceneObject();
- DALI_ASSERT_DEBUG( NULL != sceneObject );
-
- // Send a message to remove the scene-graph RenderTask
- RemoveTaskMessage( mEventThreadServices, *mSceneObject, *sceneObject );
-
- // The scene-graph RenderTask will be destroyed soon; discard the raw-pointer
- taskImpl.DiscardSceneObject();
- }
+ const SceneGraph::RenderTask& sceneObject = task.GetRenderTaskSceneObject();
+ // delete the task
mTasks.erase( iter );
+ // send a message to remove the scene-graph RenderTask
+ RemoveTaskMessage( mEventThreadServices, *mSceneObject, sceneObject );
for ( Vector< Exclusive >::Iterator exclusiveIt = mExclusives.Begin(); exclusiveIt != mExclusives.End(); ++exclusiveIt )
{
- if ( exclusiveIt->renderTaskPtr == &taskImpl )
+ if ( exclusiveIt->renderTaskPtr == iter->Get() )
{
mExclusives.Erase( exclusiveIt );
break;
return static_cast<uint32_t>( mTasks.size() ); // only 4,294,967,295 render tasks supported
}
-Dali::RenderTask RenderTaskList::GetTask( uint32_t index ) const
+RenderTaskPtr RenderTaskList::GetTask( uint32_t index ) const
{
DALI_ASSERT_ALWAYS( ( index < mTasks.size() ) && "RenderTask index out-of-range" );
- return mTasks[index];
+ return mTasks[ index ];
}
void RenderTaskList::SetExclusive( RenderTask* task, bool exclusive )
RenderTaskList::RenderTaskList()
: mEventThreadServices( *Stage::GetCurrent() ),
mDefaults( *Stage::GetCurrent() ),
- mSceneObject( NULL )
+ mSceneObject( nullptr )
{
}
RenderTaskList::~RenderTaskList()
{
- if( EventThreadServices::IsCoreRunning() )
+ if( EventThreadServices::IsCoreRunning() && mSceneObject )
{
- DestroySceneObject();
+ // Remove the render task list using a message to the update manager
+ RemoveRenderTaskListMessage( mEventThreadServices.GetUpdateManager(), *mSceneObject );
}
}
void RenderTaskList::Initialize()
{
- // This should only be called once, with no existing scene-object
- DALI_ASSERT_DEBUG( NULL == mSceneObject );
-
- CreateSceneObject();
-
- // set the callback to call us back when tasks are completed
- mSceneObject->SetCompleteNotificationInterface( this );
-}
-
-void RenderTaskList::CreateSceneObject()
-{
- DALI_ASSERT_DEBUG( mSceneObject == NULL );
-
// 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 );
-}
-void RenderTaskList::DestroySceneObject()
-{
- if ( mSceneObject != NULL )
- {
- // Remove the render task list using a message to the update manager
- RemoveRenderTaskListMessage( mEventThreadServices.GetUpdateManager(), *mSceneObject );
- mSceneObject = NULL;
- }
+ // set the callback to call us back when tasks are completed
+ mSceneObject->SetCompleteNotificationInterface( this );
}
void RenderTaskList::NotifyCompleted()
{
DALI_LOG_TRACE_METHOD(gLogRenderList);
- std::vector< Dali::RenderTask > finishedRenderTasks;
+ RenderTaskContainer finishedRenderTasks;
// 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 ( std::vector<Dali::RenderTask>::iterator it = mTasks.begin(), endIt = mTasks.end(); it != endIt; ++it )
+ for ( RenderTaskContainer::iterator iter = mTasks.begin(), endIt = mTasks.end(); iter != endIt; ++iter )
{
- Dali::RenderTask& renderTask( *it );
-
- if( GetImplementation( renderTask ).HasFinished() )
+ if( (*iter)->HasFinished() )
{
- finishedRenderTasks.push_back( Dali::RenderTask( renderTask ) );
+ finishedRenderTasks.push_back( *iter );
}
}
// Now it's safe to emit the signals
- for ( std::vector<Dali::RenderTask>::iterator it = finishedRenderTasks.begin(), endIt = finishedRenderTasks.end(); it != endIt; ++it )
+ for ( auto&& item : finishedRenderTasks )
{
- Dali::RenderTask& handle( *it );
-
- GetImplementation(handle).EmitSignalFinish();
+ item->EmitSignalFinish();
}
}
void RenderTaskList::RecoverFromContextLoss()
{
- for ( RenderTaskContainer::iterator iter = mTasks.begin(); mTasks.end() != iter; ++iter )
+ for ( auto&& item : mTasks )
{
- Dali::RenderTask task = *iter;
-
// If the render target renders only once to an offscreen, re-render the render task
- if( task.GetRefreshRate() == Dali::RenderTask::REFRESH_ONCE && task.GetTargetFrameBuffer() )
+ if( item->GetRefreshRate() == Dali::RenderTask::REFRESH_ONCE && item->GetTargetFrameBuffer() )
{
- task.SetRefreshRate( Dali::RenderTask::REFRESH_ONCE );
+ item->SetRefreshRate( Dali::RenderTask::REFRESH_ONCE );
}
}
}
#define __DALI_INTERNAL_RENDER_TASK_LIST_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics 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/base-object.h>
-#include <dali/public-api/render-tasks/render-task.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>
namespace Dali
{
class CameraActor;
class RenderTaskList;
-typedef IntrusivePtr<RenderTaskList> RenderTaskListPtr;
+using RenderTaskListPtr = IntrusivePtr<RenderTaskList>;
namespace SceneGraph
{
{
public:
- typedef std::vector< Dali::RenderTask > RenderTaskContainer;
+ using RenderTaskContainer = std::vector< RenderTaskPtr >;
struct Exclusive
{
/**
* @copydoc Dali::RenderTaskList::CreateTask()
*/
- Dali::RenderTask CreateTask();
+ RenderTaskPtr CreateTask();
/**
* @brief Creates a new RenderTask.
* @param[in] cameraActor The actor from which the scene is viewed for this render task.
* @return A valid handle to a new RenderTask
*/
- Dali::RenderTask CreateTask( Actor* sourceActor, CameraActor* cameraActor);
+ RenderTaskPtr CreateTask( Actor* sourceActor, CameraActor* cameraActor);
/**
* @copydoc Dali::RenderTaskList::RemoveTask()
*/
- void RemoveTask( Dali::RenderTask task );
+ void RemoveTask( Internal::RenderTask& task );
/**
* @copydoc Dali::RenderTaskList::GetTaskCount()
/**
* @copydoc Dali::RenderTaskList::GetTask()
*/
- Dali::RenderTask GetTask( uint32_t index ) const;
+ RenderTaskPtr GetTask( uint32_t index ) const;
/**
* Retrieve the container of render-tasks.
*/
void Initialize();
- /**
- * Helper to create a scene-graph render task list
- */
- void CreateSceneObject();
-
- /**
- * Helper to destroy a scene-graph render task list
- */
- void DestroySceneObject();
-
private: // from CompleteNotificationInterface
/**
#include <dali/devel-api/scripting/scripting.h>
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
#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>
RendererPtr Renderer::New()
{
- RendererPtr rendererPtr( new Renderer() );
- rendererPtr->Initialize();
+ // create scene object first so it's guaranteed to exist for the event side
+ auto sceneObject = SceneGraph::Renderer::New();
+ OwnerPointer< SceneGraph::Renderer > transferOwnership( sceneObject );
+ // pass the pointer to base for message passing
+ 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.RegisterObject( rendererPtr.Get() );
return rendererPtr;
}
mGeometry = &geometry;
const Render::Geometry* geometrySceneObject = geometry.GetRenderObject();
- SetGeometryMessage( GetEventThreadServices(), *mSceneObject, *geometrySceneObject );
+ SetGeometryMessage( GetEventThreadServices(), GetRendererSceneObject(), *geometrySceneObject );
}
-Geometry* Renderer::GetGeometry() const
+GeometryPtr Renderer::GetGeometry() const
{
- return mGeometry.Get();
+ return mGeometry;
}
void Renderer::SetTextures( TextureSet& textureSet )
{
mTextureSet = &textureSet;
const SceneGraph::TextureSet* textureSetSceneObject = textureSet.GetTextureSetSceneObject();
- SetTexturesMessage( GetEventThreadServices(), *mSceneObject, *textureSetSceneObject );
+ SetTexturesMessage( GetEventThreadServices(), GetRendererSceneObject(), *textureSetSceneObject );
}
-TextureSet* Renderer::GetTextures() const
+TextureSetPtr Renderer::GetTextures() const
{
- return mTextureSet.Get();
+ return mTextureSet;
}
void Renderer::SetShader( Shader& shader )
{
mShader = &shader;
- SceneGraph::Shader& sceneGraphShader = *shader.GetShaderSceneObject();
- SceneGraph::SetShaderMessage( GetEventThreadServices(), *mSceneObject, sceneGraphShader );
+ const SceneGraph::Shader& sceneGraphShader = shader.GetShaderSceneObject();
+ SceneGraph::SetShaderMessage( GetEventThreadServices(), GetRendererSceneObject(), sceneGraphShader );
}
-Shader* Renderer::GetShader() const
+ShaderPtr Renderer::GetShader() const
{
- return mShader.Get();
+ return mShader;
}
-void Renderer::SetDepthIndex( int depthIndex )
+void Renderer::SetDepthIndex( int32_t depthIndex )
{
if ( mDepthIndex != depthIndex )
{
mDepthIndex = depthIndex;
- SetDepthIndexMessage( GetEventThreadServices(), *mSceneObject, depthIndex );
+ SetDepthIndexMessage( GetEventThreadServices(), GetRendererSceneObject(), depthIndex );
}
}
-int Renderer::GetDepthIndex() const
+int32_t Renderer::GetDepthIndex() const
{
return mDepthIndex;
}
{
mBlendMode = mode;
- SetBlendModeMessage( GetEventThreadServices(), *mSceneObject, mBlendMode );
+ SetBlendModeMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendMode );
}
}
void Renderer::SetBlendFunc( BlendFactor::Type srcFactorRgba, BlendFactor::Type destFactorRgba )
{
mBlendingOptions.SetBlendFunc( srcFactorRgba, destFactorRgba, srcFactorRgba, destFactorRgba );
- SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
+ SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
}
void Renderer::SetBlendFunc( BlendFactor::Type srcFactorRgb,
BlendFactor::Type destFactorAlpha )
{
mBlendingOptions.SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
+ SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
}
void Renderer::GetBlendFunc( BlendFactor::Type& srcFactorRgb,
void Renderer::SetBlendEquation( BlendEquation::Type equationRgba )
{
mBlendingOptions.SetBlendEquation( equationRgba, equationRgba );
- SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
+ SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
}
void Renderer::SetBlendEquation( BlendEquation::Type equationRgb,
BlendEquation::Type equationAlpha )
{
mBlendingOptions.SetBlendEquation( equationRgb, equationAlpha );
- SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
+ SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
}
void Renderer::GetBlendEquation( BlendEquation::Type& equationRgb,
if( firstElement != mIndexedDrawFirstElement )
{
mIndexedDrawFirstElement = firstElement;
- SetIndexedDrawFirstElementMessage( GetEventThreadServices(), *mSceneObject, mIndexedDrawFirstElement );
+ SetIndexedDrawFirstElementMessage( GetEventThreadServices(), GetRendererSceneObject(), mIndexedDrawFirstElement );
}
}
if( elementsCount != mIndexedDrawElementCount )
{
mIndexedDrawElementCount = elementsCount;
- SetIndexedDrawElementsCountMessage( GetEventThreadServices(), *mSceneObject, mIndexedDrawElementCount );
+ SetIndexedDrawElementsCountMessage( GetEventThreadServices(), GetRendererSceneObject(), mIndexedDrawElementCount );
}
}
SetBlendFunc( BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA );
}
mPremultipledAlphaEnabled = preMultipled;
- SetEnablePreMultipliedAlphaMessage( GetEventThreadServices(), *mSceneObject, mPremultipledAlphaEnabled );
+ SetEnablePreMultipliedAlphaMessage( GetEventThreadServices(), GetRendererSceneObject(), mPremultipledAlphaEnabled );
}
}
return mPremultipledAlphaEnabled;
}
-SceneGraph::Renderer* Renderer::GetRendererSceneObject()
+const SceneGraph::Renderer& Renderer::GetRendererSceneObject() const
{
- return mSceneObject;
+ return static_cast<const SceneGraph::Renderer&>( GetSceneObject() );
}
void Renderer::SetDefaultProperty( Property::Index index,
{
case Dali::Renderer::Property::DEPTH_INDEX:
{
- SetDepthIndex( propertyValue.Get<int>() );
+ SetDepthIndex( propertyValue.Get<int32_t>() );
break;
}
case Dali::Renderer::Property::FACE_CULLING_MODE:
if( Scripting::GetEnumerationProperty< FaceCullingMode::Type >( propertyValue, FACE_CULLING_MODE_TABLE, FACE_CULLING_MODE_TABLE_COUNT, convertedValue ) )
{
mFaceCullingMode = convertedValue;
- SetFaceCullingModeMessage( GetEventThreadServices(), *mSceneObject, convertedValue );
+ SetFaceCullingModeMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
}
break;
}
{
BlendEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
mBlendingOptions.SetBlendEquation( convertedValue, alphaEquation );
- SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
+ SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
}
break;
}
{
BlendEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb();
mBlendingOptions.SetBlendEquation( rgbEquation, convertedValue );
- SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
+ SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
}
break;
}
}
case Dali::Renderer::Property::INDEX_RANGE_FIRST:
{
- int firstElement;
+ int32_t firstElement;
if( propertyValue.Get( firstElement ) )
{
SetIndexedDrawFirstElement( firstElement );
}
case Dali::Renderer::Property::INDEX_RANGE_COUNT:
{
- int elementsCount;
+ int32_t elementsCount;
if( propertyValue.Get( elementsCount ) )
{
SetIndexedDrawElementsCount( elementsCount );
if( Scripting::GetEnumerationProperty< DepthWriteMode::Type >( propertyValue, DEPTH_WRITE_MODE_TABLE, DEPTH_WRITE_MODE_TABLE_COUNT, convertedValue ) )
{
mDepthWriteMode = convertedValue;
- SetDepthWriteModeMessage( GetEventThreadServices(), *mSceneObject, convertedValue );
+ SetDepthWriteModeMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
}
break;
}
if( Scripting::GetEnumerationProperty< DepthFunction::Type >( propertyValue, DEPTH_FUNCTION_TABLE, DEPTH_FUNCTION_TABLE_COUNT, convertedValue ) )
{
mDepthFunction = convertedValue;
- SetDepthFunctionMessage( GetEventThreadServices(), *mSceneObject, convertedValue );
+ SetDepthFunctionMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
}
break;
}
if( Scripting::GetEnumerationProperty< DepthTestMode::Type >( propertyValue, DEPTH_TEST_MODE_TABLE, DEPTH_TEST_MODE_TABLE_COUNT, convertedValue ) )
{
mDepthTestMode = convertedValue;
- SetDepthTestModeMessage( GetEventThreadServices(), *mSceneObject, convertedValue );
+ SetDepthTestModeMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
}
break;
}
if( Scripting::GetEnumerationProperty< RenderMode::Type >( propertyValue, RENDER_MODE_TABLE, RENDER_MODE_TABLE_COUNT, convertedValue ) )
{
mStencilParameters.renderMode = convertedValue;
- SetRenderModeMessage( GetEventThreadServices(), *mSceneObject, convertedValue );
+ SetRenderModeMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
}
break;
}
if( Scripting::GetEnumerationProperty< StencilFunction::Type >( propertyValue, STENCIL_FUNCTION_TABLE, STENCIL_FUNCTION_TABLE_COUNT, convertedValue ) )
{
mStencilParameters.stencilFunction = convertedValue;
- SetStencilFunctionMessage( GetEventThreadServices(), *mSceneObject, convertedValue );
+ SetStencilFunctionMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
}
break;
}
case Dali::Renderer::Property::STENCIL_FUNCTION_MASK:
{
- int stencilFunctionMask;
+ int32_t stencilFunctionMask;
if( propertyValue.Get( stencilFunctionMask ) )
{
if( stencilFunctionMask != mStencilParameters.stencilFunctionMask )
{
mStencilParameters.stencilFunctionMask = stencilFunctionMask;
- SetStencilFunctionMaskMessage( GetEventThreadServices(), *mSceneObject, stencilFunctionMask );
+ SetStencilFunctionMaskMessage( GetEventThreadServices(), GetRendererSceneObject(), stencilFunctionMask );
}
}
break;
}
case Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE:
{
- int stencilFunctionReference;
+ int32_t stencilFunctionReference;
if( propertyValue.Get( stencilFunctionReference ) )
{
if( stencilFunctionReference != mStencilParameters.stencilFunctionReference )
{
mStencilParameters.stencilFunctionReference = stencilFunctionReference;
- SetStencilFunctionReferenceMessage( GetEventThreadServices(), *mSceneObject, stencilFunctionReference );
+ SetStencilFunctionReferenceMessage( GetEventThreadServices(), GetRendererSceneObject(), stencilFunctionReference );
}
}
break;
}
case Dali::Renderer::Property::STENCIL_MASK:
{
- int stencilMask;
+ int32_t stencilMask;
if( propertyValue.Get( stencilMask ) )
{
if( stencilMask != mStencilParameters.stencilMask )
{
mStencilParameters.stencilMask = stencilMask;
- SetStencilMaskMessage( GetEventThreadServices(), *mSceneObject, stencilMask );
+ SetStencilMaskMessage( GetEventThreadServices(), GetRendererSceneObject(), stencilMask );
}
}
break;
if( Scripting::GetEnumerationProperty< StencilOperation::Type >( propertyValue, STENCIL_OPERATION_TABLE, STENCIL_OPERATION_TABLE_COUNT, convertedValue ) )
{
mStencilParameters.stencilOperationOnFail = convertedValue;
- SetStencilOperationOnFailMessage( GetEventThreadServices(), *mSceneObject, convertedValue );
+ SetStencilOperationOnFailMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
}
break;
}
if( Scripting::GetEnumerationProperty< StencilOperation::Type >( propertyValue, STENCIL_OPERATION_TABLE, STENCIL_OPERATION_TABLE_COUNT, convertedValue ) )
{
mStencilParameters.stencilOperationOnZFail = convertedValue;
- SetStencilOperationOnZFailMessage( GetEventThreadServices(), *mSceneObject, convertedValue );
+ SetStencilOperationOnZFailMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
}
break;
}
if( Scripting::GetEnumerationProperty< StencilOperation::Type >( propertyValue, STENCIL_OPERATION_TABLE, STENCIL_OPERATION_TABLE_COUNT, convertedValue ) )
{
mStencilParameters.stencilOperationOnZPass = convertedValue;
- SetStencilOperationOnZPassMessage( GetEventThreadServices(), *mSceneObject, convertedValue );
+ SetStencilOperationOnZPassMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
}
break;
}
if( !Equals( mOpacity, opacity ) )
{
mOpacity = opacity;
- BakeOpacityMessage( GetEventThreadServices(), *mSceneObject, mOpacity );
+ BakeOpacityMessage( GetEventThreadServices(), GetRendererSceneObject(), mOpacity );
}
}
break;
}
}
-void Renderer::SetSceneGraphProperty( Property::Index index,
- const PropertyMetadata& entry,
- const Property::Value& value )
-{
- ObjectImplHelper::SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
- OnPropertySet(index, value);
-}
-
Property::Value Renderer::GetDefaultProperty( Property::Index index ) const
{
Property::Value value;
}
}
-const SceneGraph::PropertyOwner* Renderer::GetPropertyOwner() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyOwner* Renderer::GetSceneObject() const
-{
- return mSceneObject;
-}
-
const SceneGraph::PropertyBase* Renderer::GetSceneObjectAnimatableProperty( Property::Index index ) const
{
- DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );
const SceneGraph::PropertyBase* property = NULL;
- property = ObjectImplHelper::GetRegisteredSceneGraphProperty( this,
- &Renderer::FindAnimatableProperty,
- &Renderer::FindCustomProperty,
- index );
-
+ if( index == DevelRenderer::Property::OPACITY )
+ {
+ property = &GetRendererSceneObject().mOpacity;
+ }
if( !property )
{
- if( index == DevelRenderer::Property::OPACITY )
- {
- property = &mSceneObject->mOpacity;
- }
+ // not our property, ask base
+ property = Object::GetSceneObjectAnimatableProperty( index );
}
return property;
const PropertyInputImpl* Renderer::GetSceneObjectInputProperty( Property::Index index ) const
{
- const PropertyInputImpl* property = NULL;
-
- const SceneGraph::PropertyBase* baseProperty = ObjectImplHelper::GetRegisteredSceneGraphProperty( this,
- &Renderer::FindAnimatableProperty,
- &Renderer::FindCustomProperty,
- index );
- property = static_cast<const PropertyInputImpl*>( baseProperty );
-
- return property;
-}
-
-int Renderer::GetPropertyComponentIndex( Property::Index index ) const
-{
- return Property::INVALID_COMPONENT_INDEX;
+ // reuse animatable property getter, Object::GetSceneObjectInputProperty does the same so no need to call that0
+ return GetSceneObjectAnimatableProperty( index );
}
-Renderer::Renderer()
-: mSceneObject(NULL ),
+Renderer::Renderer( const SceneGraph::Renderer* sceneObject )
+: Object( sceneObject ),
mDepthIndex( 0 ),
mIndexedDrawFirstElement( 0 ),
mIndexedDrawElementCount( 0 ),
{
}
-void Renderer::Initialize()
-{
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
-
- mSceneObject = SceneGraph::Renderer::New();
- OwnerPointer< SceneGraph::Renderer > transferOwnership( mSceneObject );
- AddRendererMessage( updateManager, transferOwnership );
-
- eventThreadServices.RegisterObject( this );
-}
-
void Renderer::SetBlendColor( const Vector4& blendColor )
{
mBlendingOptions.SetBlendColor( blendColor );
- SetBlendColorMessage( GetEventThreadServices(), *mSceneObject, GetBlendColor() );
+ SetBlendColorMessage( GetEventThreadServices(), GetRendererSceneObject(), GetBlendColor() );
}
const Vector4& Renderer::GetBlendColor() const
{
EventThreadServices& eventThreadServices = GetEventThreadServices();
SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
- RemoveRendererMessage( updateManager, *mSceneObject );
+ RemoveRendererMessage( updateManager, GetRendererSceneObject() );
eventThreadServices.UnregisterObject( this );
}
bool Renderer::GetCurrentPropertyValue( Property::Index index, Property::Value& value ) const
{
bool valueSet = true;
+ const SceneGraph::Renderer& sceneObject = GetRendererSceneObject();
switch( index )
{
case Dali::Renderer::Property::DEPTH_INDEX:
{
- value = mSceneObject->GetDepthIndex();
+ value = sceneObject.GetDepthIndex();
break;
}
case Dali::Renderer::Property::FACE_CULLING_MODE:
{
- value = mSceneObject->GetFaceCullingMode();
+ value = sceneObject.GetFaceCullingMode();
break;
}
case Dali::Renderer::Property::BLEND_MODE:
{
- value = mSceneObject->GetBlendMode();
+ value = sceneObject.GetBlendMode();
break;
}
case Dali::Renderer::Property::BLEND_EQUATION_RGB:
{
- uint32_t bitMask = mSceneObject->GetBlendingOptions();
+ uint32_t bitMask = sceneObject.GetBlendingOptions();
BlendingOptions blendingOptions;
blendingOptions.SetBitmask( bitMask );
value = static_cast<int32_t>( blendingOptions.GetBlendEquationRgb() );
}
case Dali::Renderer::Property::BLEND_EQUATION_ALPHA:
{
- uint32_t bitMask = mSceneObject->GetBlendingOptions();
+ uint32_t bitMask = sceneObject.GetBlendingOptions();
BlendingOptions blendingOptions;
blendingOptions.SetBitmask( bitMask );
value = static_cast<int32_t>( blendingOptions.GetBlendEquationAlpha() );
}
case Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB:
{
- uint32_t bitMask = mSceneObject->GetBlendingOptions();
+ uint32_t bitMask = sceneObject.GetBlendingOptions();
BlendingOptions blendingOptions;
blendingOptions.SetBitmask( bitMask );
value = static_cast<int32_t>( blendingOptions.GetBlendSrcFactorRgb() );
}
case Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB:
{
- uint32_t bitMask = mSceneObject->GetBlendingOptions();
+ uint32_t bitMask = sceneObject.GetBlendingOptions();
BlendingOptions blendingOptions;
blendingOptions.SetBitmask( bitMask );
value = static_cast<int32_t>( blendingOptions.GetBlendDestFactorRgb() );
}
case Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA:
{
- uint32_t bitMask = mSceneObject->GetBlendingOptions();
+ uint32_t bitMask = sceneObject.GetBlendingOptions();
BlendingOptions blendingOptions;
blendingOptions.SetBitmask( bitMask );
value = static_cast<int32_t>( blendingOptions.GetBlendSrcFactorAlpha() );
}
case Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA:
{
- uint32_t bitMask = mSceneObject->GetBlendingOptions();
+ uint32_t bitMask = sceneObject.GetBlendingOptions();
BlendingOptions blendingOptions;
blendingOptions.SetBitmask( bitMask );
value = static_cast<int32_t>( blendingOptions.GetBlendDestFactorAlpha() );
}
case Dali::Renderer::Property::BLEND_COLOR:
{
- value = mSceneObject->GetBlendColor();
+ value = sceneObject.GetBlendColor();
break;
}
case Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA:
{
- value = mSceneObject->IsPreMultipliedAlphaEnabled();
+ value = sceneObject.IsPreMultipliedAlphaEnabled();
break;
}
case Dali::Renderer::Property::INDEX_RANGE_FIRST:
{
- value = static_cast<int>( mSceneObject->GetIndexedDrawFirstElement() );
+ value = static_cast<int32_t>( sceneObject.GetIndexedDrawFirstElement() );
break;
}
case Dali::Renderer::Property::INDEX_RANGE_COUNT:
{
- value = static_cast<int>( mSceneObject->GetIndexedDrawElementsCount() );
+ value = static_cast<int32_t>( sceneObject.GetIndexedDrawElementsCount() );
break;
}
case Dali::Renderer::Property::DEPTH_WRITE_MODE:
{
- value = mSceneObject->GetDepthWriteMode();
+ value = sceneObject.GetDepthWriteMode();
break;
}
case Dali::Renderer::Property::DEPTH_FUNCTION:
{
- value = mSceneObject->GetDepthFunction();
+ value = sceneObject.GetDepthFunction();
break;
}
case Dali::Renderer::Property::DEPTH_TEST_MODE:
{
- value = mSceneObject->GetDepthTestMode();
+ value = sceneObject.GetDepthTestMode();
break;
}
case Dali::Renderer::Property::STENCIL_FUNCTION:
{
- Render::Renderer::StencilParameters stencilParameters = mSceneObject->GetStencilParameters();
+ Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
value = stencilParameters.stencilFunction;
break;
}
case Dali::Renderer::Property::STENCIL_FUNCTION_MASK:
{
- Render::Renderer::StencilParameters stencilParameters = mSceneObject->GetStencilParameters();
+ Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
value = stencilParameters.stencilFunctionMask;
break;
}
case Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE:
{
- Render::Renderer::StencilParameters stencilParameters = mSceneObject->GetStencilParameters();
+ Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
value = stencilParameters.stencilFunctionReference;
break;
}
case Dali::Renderer::Property::STENCIL_MASK:
{
- Render::Renderer::StencilParameters stencilParameters = mSceneObject->GetStencilParameters();
+ Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
value = stencilParameters.stencilMask;
break;
}
case Dali::Renderer::Property::RENDER_MODE:
{
- Render::Renderer::StencilParameters stencilParameters = mSceneObject->GetStencilParameters();
+ Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
value = stencilParameters.renderMode;
break;
}
case Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL:
{
- Render::Renderer::StencilParameters stencilParameters = mSceneObject->GetStencilParameters();
+ Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
value = stencilParameters.stencilOperationOnFail;
break;
}
case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL:
{
- Render::Renderer::StencilParameters stencilParameters = mSceneObject->GetStencilParameters();
+ Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
value = stencilParameters.stencilOperationOnZFail;
break;
}
case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS:
{
- Render::Renderer::StencilParameters stencilParameters = mSceneObject->GetStencilParameters();
+ Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
value = stencilParameters.stencilOperationOnZPass;
break;
}
case Dali::DevelRenderer::Property::OPACITY:
{
- value = mSceneObject->GetOpacity( GetEventThreadServices().GetEventBufferIndex() );
+ value = sceneObject.GetOpacity( GetEventThreadServices().GetEventBufferIndex() );
break;
}
default:
}
} // namespace Internal
+
} // namespace Dali
/**
* @copydoc Dali::Renderer::GetGeometry()
*/
- Geometry* GetGeometry() const;
+ GeometryPtr GetGeometry() const;
/**
* @copydoc Dali::Renderer::SetTextures()
/**
* @copydoc Dali::Renderer::GetTextures()
*/
- TextureSet* GetTextures() const;
+ TextureSetPtr GetTextures() const;
/**
* @copydoc Dali::Renderer::SetShader()
/**
* @copydoc Dali::Renderer::GetShader()
*/
- Shader* GetShader() const;
+ ShaderPtr GetShader() const;
/**
* @copydoc Dali::Renderer::SetDepthIndex()
*/
- void SetDepthIndex( int depthIndex );
+ void SetDepthIndex( int32_t depthIndex );
/**
* @copydoc Dali::Renderer::GetDepthIndex()
*/
- int GetDepthIndex() const;
+ int32_t GetDepthIndex() const;
- /**
- * @copydoc Dali::Renderer::SetBlendMode()
- */
- void SetBlendMode( BlendMode::Type mode );
+ /**
+ * @copydoc Dali::Renderer::SetBlendMode()
+ */
+ void SetBlendMode( BlendMode::Type mode );
- /**
- * @copydoc Dali::Renderer::GetBlendMode()
- */
- BlendMode::Type GetBlendMode() const;
+ /**
+ * @copydoc Dali::Renderer::GetBlendMode()
+ */
+ BlendMode::Type GetBlendMode() const;
- /**
- * @copydoc Dali::Renderer::SetBlendFunc()
- */
- void SetBlendFunc( BlendFactor::Type srcFactorRgba, BlendFactor::Type destFactorRgba );
+ /**
+ * @copydoc Dali::Renderer::SetBlendFunc()
+ */
+ 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 );
+ /**
+ * @copydoc Dali::Renderer::SetBlendFunc()
+ */
+ 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;
+ /**
+ * @copydoc Dali::Renderer::GetBlendFunc()
+ */
+ void GetBlendFunc( BlendFactor::Type& srcFactorRgb, BlendFactor::Type& destFactorRgb,
+ BlendFactor::Type& srcFactorAlpha, BlendFactor::Type& destFactorAlpha ) const;
- /**
- * @copydoc Dali::Renderer::SetBlendEquation()
- */
- void SetBlendEquation( BlendEquation::Type equationRgba );
+ /**
+ * @copydoc Dali::Renderer::SetBlendEquation()
+ */
+ void SetBlendEquation( BlendEquation::Type equationRgba );
- /**
- * @copydoc Dali::Renderer::SetBlendEquation()
- */
- void SetBlendEquation( BlendEquation::Type equationRgb, BlendEquation::Type equationAlpha );
+ /**
+ * @copydoc Dali::Renderer::SetBlendEquation()
+ */
+ void SetBlendEquation( BlendEquation::Type equationRgb, BlendEquation::Type equationAlpha );
- /**
- * @copydoc Dali::Renderer::GetBlendEquation()
- */
- void GetBlendEquation( BlendEquation::Type& equationRgb, BlendEquation::Type& equationAlpha ) const;
+ /**
+ * @copydoc Dali::Renderer::GetBlendEquation()
+ */
+ void GetBlendEquation( BlendEquation::Type& equationRgb, BlendEquation::Type& equationAlpha ) const;
- /**
- * @copydoc Dali::Renderer::SetIndexedDrawFirstElement
- */
- void SetIndexedDrawFirstElement( uint32_t firstElement );
+ /**
+ * @copydoc Dali::Renderer::SetIndexedDrawFirstElement
+ */
+ void SetIndexedDrawFirstElement( uint32_t firstElement );
- /**
- * @copydoc Dali::Renderer::SetIndexedDrawElementsCount
- */
- void SetIndexedDrawElementsCount( uint32_t elementsCount );
+ /**
+ * @copydoc Dali::Renderer::SetIndexedDrawElementsCount
+ */
+ 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 );
+ /**
+ * @brief Set whether the Pre-multiplied Alpha Blending is required
+ *
+ * @param[in] preMultipled whether alpha is pre-multiplied.
+ */
+ void EnablePreMultipliedAlpha( bool preMultipled );
- /**
- * @brief Query whether alpha is pre-multiplied.
- *
- * @return True is alpha is pre-multiplied, false otherwise.
- */
- bool IsPreMultipliedAlphaEnabled() const;
+ /**
+ * @brief Query whether alpha is pre-multiplied.
+ *
+ * @return True is alpha is pre-multiplied, false otherwise.
+ */
+ bool IsPreMultipliedAlphaEnabled() const;
- /**
- * @brief Get the scene graph object
- *
- * @return the scene object
- */
- SceneGraph::Renderer* GetRendererSceneObject();
+ /**
+ * @brief Get the scene graph object
+ *
+ * @return the scene object
+ */
+ const SceneGraph::Renderer& GetRendererSceneObject() const;
public: // Default property extensions from Object
virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
/**
- * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
- */
- virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
-
- /**
* @copydoc Dali::Internal::Object::GetDefaultProperty()
*/
virtual Property::Value GetDefaultProperty( Property::Index index ) const;
virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType );
/**
- * @copydoc Dali::Internal::Object::GetPropertyOwner()
- */
- virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
* @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
*/
virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
*/
virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
- /**
- * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
- */
- virtual int GetPropertyComponentIndex( Property::Index index ) const;
-
private: // implementation
/**
- * @brief Default constructor.
+ * @brief Constructor.
+ *
+ * @param sceneObject the scene graph renderer
*/
- Renderer();
-
- /**
- * @brief Initializes the Renderer.
- */
- void Initialize();
+ Renderer( const SceneGraph::Renderer* sceneObject );
/**
* @brief Sets the blend color.
Renderer& operator=( const Renderer& );
private: // data
- SceneGraph::Renderer* mSceneObject;
- GeometryPtr mGeometry; ///< Connector that holds the geometry used by this renderer
- TextureSetPtr mTextureSet; ///< Connector that holds the texture set used by this renderer
- ShaderPtr mShader; ///< Connector that holds the shader used by this renderer
-
- int mDepthIndex;
-
- 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
-
- 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
- bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
+
+ 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;
+
+ 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
+
+ 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
+ bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
};
} // namespace Internal
// INTERNAL INCLUDES
#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/scripting/scripting.h>
-#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
#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>
return Property::Value(s);
}
-
} // unnamed namespace
ShaderPtr Shader::New( const std::string& vertexShader,
const std::string& fragmentShader,
Dali::Shader::Hint::Value hints )
{
- ShaderPtr shader( new Shader() );
- shader->Initialize( vertexShader, fragmentShader, hints );
- return shader;
-}
+ // 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 );
+ // pass the pointer to base for message passing
+ ShaderPtr shader( new Shader( sceneObject ) );
+ // transfer scene object ownership to update manager
+ auto&& services = shader->GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = services.GetUpdateManager();
+ AddShaderMessage( updateManager, transferOwnership );
-const SceneGraph::Shader* Shader::GetShaderSceneObject() const
-{
- return mSceneObject;
+ services.RegisterObject( shader.Get() );
+ shader->SetShader( vertexShader, fragmentShader, hints );
+
+ return shader;
}
-SceneGraph::Shader* Shader::GetShaderSceneObject()
+const SceneGraph::Shader& Shader::GetShaderSceneObject() const
{
- return mSceneObject;
+ 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)
{
);
}
- Initialize(vertex, fragment, hints );
+ SetShader( vertex, fragment, hints );
}
}
else
}
}
-void Shader::SetSceneGraphProperty( Property::Index index,
- const PropertyMetadata& entry,
- const Property::Value& value )
-{
- ObjectImplHelper::SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
- OnPropertySet(index, value);
-}
-
Property::Value Shader::GetDefaultProperty( Property::Index index ) const
{
Property::Value value;
return GetDefaultProperty( index ); // Event-side only properties
}
-const SceneGraph::PropertyOwner* Shader::GetPropertyOwner() const
-{
- return mSceneObject;
-}
-
-const SceneGraph::PropertyOwner* Shader::GetSceneObject() const
+Shader::Shader( const SceneGraph::Shader* sceneObject )
+: Object( sceneObject ),
+ mShaderData( nullptr )
{
- return mSceneObject;
}
-const SceneGraph::PropertyBase* Shader::GetSceneObjectAnimatableProperty( Property::Index index ) const
+void Shader::SetShader( const std::string& vertexSource,
+ const std::string& fragmentSource,
+ Dali::Shader::Hint::Value hints )
{
- DALI_ASSERT_ALWAYS( IsPropertyAnimatable( index ) && "Property is not animatable" );
- const SceneGraph::PropertyBase* property = NULL;
-
- property = ObjectImplHelper::GetRegisteredSceneGraphProperty( this,
- &Shader::FindAnimatableProperty,
- &Shader::FindCustomProperty,
- index );
-
- if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
- {
- DALI_ASSERT_ALWAYS( 0 && "Property is not animatable" );
- }
-
- return property;
-}
-
-const PropertyInputImpl* Shader::GetSceneObjectInputProperty( Property::Index index ) const
-{
- PropertyMetadata* property = NULL;
-
- if( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && // Child properties are also stored as custom properties
- ( index <= PROPERTY_CUSTOM_MAX_INDEX ) )
- {
- property = FindCustomProperty( index );
- }
- else if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
- {
- property = FindAnimatableProperty( index );
- }
-
- DALI_ASSERT_ALWAYS( property && "property index is invalid" );
- return property->GetSceneGraphProperty();
-}
-
-int Shader::GetPropertyComponentIndex( Property::Index index ) const
-{
- return Property::INVALID_COMPONENT_INDEX;
-}
-
-Shader::Shader()
- : mSceneObject( NULL ),
- mShaderData( NULL )
-{
-}
-
-void Shader::Initialize(
- const std::string& vertexSource,
- const std::string& fragmentSource,
- Dali::Shader::Hint::Value hints )
-{
- EventThreadServices& eventThreadServices = GetEventThreadServices();
- SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
- mSceneObject = new SceneGraph::Shader( hints );
-
- OwnerPointer< SceneGraph::Shader > transferOwnership( mSceneObject );
- AddShaderMessage( updateManager, transferOwnership );
-
- // Try to load a precompiled shader binary for the source pair:
+ // 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 );
// Add shader program to scene-object using a message to the UpdateManager
- SetShaderProgramMessage( updateManager, *mSceneObject, mShaderData, (hints & Dali::Shader::Hint::MODIFIES_GEOMETRY) != 0x0 );
- eventThreadServices.RegisterObject( this );
+ EventThreadServices& eventThreadServices = GetEventThreadServices();
+ SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+ SetShaderProgramMessage( updateManager, GetShaderSceneObject(), mShaderData, (hints & Dali::Shader::Hint::MODIFIES_GEOMETRY) != 0x0 );
}
Shader::~Shader()
{
EventThreadServices& eventThreadServices = GetEventThreadServices();
SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
- RemoveShaderMessage( updateManager, *mSceneObject);
+ RemoveShaderMessage( updateManager, &GetShaderSceneObject() );
eventThreadServices.UnregisterObject( this );
}
Dali::Shader::Hint::Value hints );
/**
- * @brief Get the shader scene object
- *
- * @return the shader scene object
- */
- const SceneGraph::Shader* GetShaderSceneObject() const;
-
- /**
* Retrieve the scene-graph shader added by this object.
* @return A pointer to the shader.
*/
- SceneGraph::Shader* GetShaderSceneObject();
+ const SceneGraph::Shader& GetShaderSceneObject() const;
public: // Default property extensions from Object
virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
/**
- * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
- */
- virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
-
- /**
* @copydoc Dali::Internal::Object::GetDefaultProperty()
*/
virtual Property::Value GetDefaultProperty( Property::Index index ) const;
*/
virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
- /**
- * @copydoc Dali::Internal::Object::GetPropertyOwner()
- */
- virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObject()
- */
- virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
- */
- virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
- /**
- * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
- */
- virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
+private: // implementation
/**
- * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
+ * Constructor
+ *
+ * @param sceneObject the scene object
*/
- virtual int GetPropertyComponentIndex( Property::Index index ) const;
-
-private: // implementation
- Shader();
+ Shader( const SceneGraph::Shader* sceneObject );
/**
* Second stage initialization
*/
- void Initialize( const std::string& vertexShader, const std::string& fragmentShader, Dali::Shader::Hint::Value hints );
+ void SetShader( const std::string& vertexShader, const std::string& fragmentShader, Dali::Shader::Hint::Value hints );
protected:
/**
virtual ~Shader();
private: // unimplemented methods
- Shader( const Shader& );
- Shader& operator=( const Shader& );
+
+ Shader() = delete;
+ Shader( const Shader& ) = delete;
+ Shader& operator=( const Shader& ) = delete;
private:
- SceneGraph::Shader* mSceneObject;
+
Internal::ShaderDataPtr mShaderData;
+
};
} // namespace Internal
$(internal_src_dir)/event/images/resource-image-impl.cpp \
$(internal_src_dir)/event/images/native-image-impl.cpp \
$(internal_src_dir)/event/images/pixel-data-impl.cpp \
- $(internal_src_dir)/event/object/custom-object-internal.cpp \
$(internal_src_dir)/event/render-tasks/render-task-impl.cpp \
$(internal_src_dir)/event/render-tasks/render-task-list-impl.cpp \
$(internal_src_dir)/event/rendering/frame-buffer-impl.cpp \
mLoopCount(1),
mAlphaFunction(AlphaFunction::DEFAULT),
mDisconnectAction(Dali::Animation::BakeFinal),
- mActive(false),
+ mAnimationPlaying(false),
mEnabled(true),
mConnectedToSceneGraph(false),
mAutoReverseEnabled( false )
*/
void SetActive( bool active )
{
- mActive = active;
- }
-
- /**
- * Retrieve whether the animator has been set to active or not.
- * @return The active state.
- */
- bool GetActive() const
- {
- return mActive;
+ mAnimationPlaying = active;
}
/**
AlphaFunction mAlphaFunction;
Dali::Animation::EndAction mDisconnectAction; ///< EndAction to apply when target object gets disconnected from the stage.
- bool mActive:1; ///< Animator is "active" while it's running.
+ 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;
virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
{
// If we are active, then bake the value if required
- if ( mActive && 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 );
}
- mActive = false;
mEnabled = false;
}
virtual void PropertyOwnerDisconnected( BufferIndex bufferIndex, PropertyOwner& owner )
{
// If we are active, then bake the value if required
- if ( mActive && 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 );
}
- mActive = false;
mEnabled = false;
}
using AnimatorFunctionBase::operator();
float operator()(float alpha, const int32_t& property)
{
- return truncf(static_cast<float>( property ) + static_cast<float>( mRelative ) * alpha + 0.5f );
+ // integers need to be correctly rounded
+ return roundf(static_cast<float>( property ) + static_cast<float>( mRelative ) * alpha );
}
int32_t mRelative;
using AnimatorFunctionBase::operator();
float operator()(float alpha, const int32_t& property)
{
- return truncf(static_cast<float>( property ) + (static_cast<float>(mTarget - property) * alpha) + 0.5f);
+ // integers need to be correctly rounded
+ return roundf(static_cast<float>( property ) + (static_cast<float>(mTarget - property) * alpha) );
}
int32_t mTarget;
namespace
{
/**
- * Helper to reset animate-able objects to base values
- * @param container to iterate over
- * @param updateBufferIndex to use
- */
-template< class T >
-inline void ResetToBaseValues( OwnerContainer<T*>& container, BufferIndex updateBufferIndex )
-{
- // Reset animatable properties to base values
- // use reference to avoid extra copies of the iterator
- for( auto&& iter : container )
- {
- iter->ResetToBaseValues( updateBufferIndex );
- }
-}
-
-/**
* Helper to Erase an object from OwnerContainer using discard queue
* @param container to remove from
* @param object to remove
mImpl->cameras.PushBack( camera.Release() ); // takes ownership
}
-void UpdateManager::RemoveCamera( const Camera* camera )
+void UpdateManager::RemoveCamera( Camera* camera )
{
// Find the camera and destroy it
- EraseUsingDiscardQueue( mImpl->cameras, const_cast<Camera*>( camera ), mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
+ EraseUsingDiscardQueue( mImpl->cameras, camera, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
}
void UpdateManager::AddObject( OwnerPointer<PropertyOwner>& object )
* Remove a camera from scene
* @param[in] camera to remove
*/
- void RemoveCamera( const Camera* camera );
+ void RemoveCamera( Camera* camera );
/**
* Add a newly created object.
inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
{
- typedef MessageValue1< UpdateManager, const Camera* > LocalType;
+ typedef MessageValue1< UpdateManager, Camera* > LocalType;
// Reserve some memory inside the message queue
uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, camera );
+ new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, const_cast<Camera*>( camera ) );
}
inline void AddObjectMessage( UpdateManager& manager, OwnerPointer<PropertyOwner>& object )
new (slot) LocalType( &manager, &UpdateManager::AddObject, object );
}
-inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object )
+inline void RemoveObjectMessage( UpdateManager& manager, const PropertyOwner* object )
{
typedef MessageValue1< UpdateManager, PropertyOwner* > LocalType;
uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &UpdateManager::RemoveObject, object );
+ new (slot) LocalType( &manager, &UpdateManager::RemoveObject, const_cast<PropertyOwner*>( object ) );
}
inline void AddAnimationMessage( UpdateManager& manager, OwnerPointer< SceneGraph::Animation >& animation )
}
// The render thread can safely change the Shader
-inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader )
+inline void RemoveShaderMessage( UpdateManager& manager, const Shader* shader )
{
typedef MessageValue1< UpdateManager, Shader* > LocalType;
uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &UpdateManager::RemoveShader, &shader );
+ new (slot) LocalType( &manager, &UpdateManager::RemoveShader, const_cast<Shader*>( shader ) );
}
inline void SetShaderProgramMessage( UpdateManager& manager,
- Shader& shader,
+ const Shader& shader,
Internal::ShaderDataPtr shaderData,
bool modifiesGeometry )
{
uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, shaderData, modifiesGeometry );
+ new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, const_cast<Shader*>( &shader ), shaderData, modifiesGeometry );
}
inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
new (slot) LocalType( &manager, &UpdateManager::AddRenderer, object );
}
-inline void RemoveRendererMessage( UpdateManager& manager, Renderer& object )
+inline void RemoveRendererMessage( UpdateManager& manager, const Renderer& object )
{
typedef MessageValue1< UpdateManager, Renderer* > LocalType;
// Reserve some memory inside the message queue
uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
// Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &UpdateManager::RemoveRenderer, &object );
+ new (slot) LocalType( &manager, &UpdateManager::RemoveRenderer, const_cast<Renderer*>( &object ) );
}
// The render thread can safely change the Shader
mRenderer.PushBack( renderer );
}
-void Node::RemoveRenderer( Renderer* renderer )
+void Node::RemoveRenderer( const Renderer* renderer )
{
RendererContainer::SizeType rendererCount( mRenderer.Size() );
for( RendererContainer::SizeType i = 0; i < rendererCount; ++i )
* Remove a renderer from the node
* @param[in] renderer The renderer to be removed
*/
- void RemoveRenderer( Renderer* renderer );
+ void RemoveRenderer( const Renderer* renderer );
/*
* Get the renderer at the given index
}
/**
+ * @return true if the node is connected to SceneGraph
+ */
+ bool ConnectedToScene()
+ {
+ return IsRoot() || GetParent();
+ }
+
+ /**
* Connect a node to the scene-graph.
* @pre A node cannot be added to itself.
* @pre The parent node is connected to the scene-graph.
new (slot) LocalType( &node, &Node::SetDrawMode, drawMode );
}
-inline void AddRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
+inline void AttachRendererMessage( EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer )
{
typedef MessageValue1< Node, Renderer* > 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, renderer );
+ new (slot) LocalType( &node, &Node::AddRenderer, const_cast<Renderer*>( &renderer ) );
}
-inline void RemoveRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
+inline void DetachRendererMessage( EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer )
{
- typedef MessageValue1< Node, Renderer* > LocalType;
+ typedef MessageValue1< Node, const Renderer* > LocalType;
// Reserve some memory inside the message queue
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 )
RenderTask::~RenderTask()
{
- // Remove exclusive flag from source node
- if( mExclusive )
+ if ( mSourceNode )
{
- if( mSourceNode && (this == mSourceNode->GetExclusiveRenderTask() ) )
+ mSourceNode->RemoveObserver( *this );
+ if( mExclusive )
{
- mSourceNode->SetExclusiveRenderTask( NULL );
+ mSourceNode->SetExclusiveRenderTask( nullptr );
}
}
+ if ( mCameraNode )
+ {
+ mCameraNode->RemoveObserver( *this );
+ }
if( mRenderSyncTracker )
{
mRenderMessageDispatcher->RemoveRenderTracker( *mRenderSyncTracker );
void RenderTask::SetSourceNode( Node* node )
{
- // Remove exclusive flag from the old node, if necessary
- if ( mSourceNode &&
- this == mSourceNode->GetExclusiveRenderTask() )
+ // Stop observing the old node (if we were)
+ if ( mSourceNode )
{
- mSourceNode->SetExclusiveRenderTask( NULL );
+ mSourceNode->RemoveObserver( *this );
+ if( this == mSourceNode->GetExclusiveRenderTask() )
+ {
+ mSourceNode->SetExclusiveRenderTask( nullptr );
+ }
}
mSourceNode = node;
- if ( mSourceNode && mExclusive )
+ if ( mSourceNode )
{
- mSourceNode->SetExclusiveRenderTask( this );
+ mSourceNode->AddObserver( *this );
+ if( mExclusive )
+ {
+ mSourceNode->SetExclusiveRenderTask( this );
+ }
}
+ SetActiveStatus();
}
Node* RenderTask::GetSourceNode() const
}
else if ( this == mSourceNode->GetExclusiveRenderTask() )
{
- mSourceNode->SetExclusiveRenderTask( NULL );
+ mSourceNode->SetExclusiveRenderTask( nullptr );
}
}
}
void RenderTask::SetCamera( Node* cameraNode, Camera* camera )
{
+ if ( mCameraNode )
+ {
+ mCameraNode->RemoveObserver( *this );
+ }
+
mCameraNode = cameraNode;
mCamera = camera;
+
+ if ( mCameraNode )
+ {
+ mCameraNode->AddObserver( *this );
+ }
+ SetActiveStatus();
}
void RenderTask::SetFrameBuffer( Render::FrameBuffer* frameBuffer )
bool RenderTask::ReadyToRender( BufferIndex updateBufferIndex )
{
- // If the source node of the render task is invisible we should still render
- // We want the render task to complete and possible clear colors to happen
-
- // Check the source node.
- if( NULL == mSourceNode ||
- ( !mSourceNode->IsRoot() && NULL == mSourceNode->GetParent() ) )
- {
- TASK_LOG_FMT( Debug::General, " Source actor not on stage. Frame counter: %d\n", mFrameCounter );
-
- // The source node is missing or disconnected.
- return false;
- }
-
- // Check camera node
- if( NULL == mCameraNode ||
- NULL == mCameraNode->GetParent() ||
- NULL == mCamera )
- {
- // The camera node is missing or disconnected.
- TASK_LOG_FMT(Debug::General, " =F No Camera FC:%d\n", mFrameCounter );
- return false;
- }
-
- return true;
+ return mActive;
}
bool RenderTask::IsRenderRequired()
return mRenderedOnceCounter;
}
-
const Matrix& RenderTask::GetViewMatrix( BufferIndex bufferIndex ) const
{
- DALI_ASSERT_DEBUG( NULL != mCamera );
+ DALI_ASSERT_DEBUG( nullptr != mCamera );
return mCamera->GetViewMatrix( bufferIndex );
}
SceneGraph::Camera& RenderTask::GetCamera() const
{
- DALI_ASSERT_DEBUG( NULL != mCamera );
+ DALI_ASSERT_DEBUG( nullptr != mCamera );
return *mCamera;
}
const Matrix& RenderTask::GetProjectionMatrix( BufferIndex bufferIndex ) const
{
- DALI_ASSERT_DEBUG( NULL != mCamera );
+ DALI_ASSERT_DEBUG( nullptr != mCamera );
return mCamera->GetProjectionMatrix( bufferIndex );
}
void RenderTask::PrepareRenderInstruction( RenderInstruction& instruction, BufferIndex updateBufferIndex )
{
- DALI_ASSERT_DEBUG( NULL != mCamera );
+ DALI_ASSERT_DEBUG( nullptr != mCamera );
TASK_LOG(Debug::General);
instruction.Reset( mCamera,
GetFrameBuffer(),
- viewportSet ? &viewport : NULL,
- mClearEnabled ? &GetClearColor( updateBufferIndex ) : NULL );
+ viewportSet ? &viewport : nullptr,
+ mClearEnabled ? &GetClearColor( updateBufferIndex ) : nullptr );
if( mRequiresSync &&
mRefreshRate == Dali::RenderTask::REFRESH_ONCE )
else
{
// no sync needed, texture FBOs are "ready" the same frame they are rendered to
- instruction.mRenderTracker = NULL;
+ instruction.mRenderTracker = nullptr;
}
}
mRequiresSync = requiresSync;
}
+void RenderTask::PropertyOwnerConnected( PropertyOwner& owner )
+{
+ // check if we've gone from inactive to active
+ SetActiveStatus();
+}
+
+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 )
+{
+ if( static_cast<PropertyOwner*>( mSourceNode ) == &owner )
+ {
+ mSourceNode = nullptr;
+ }
+ else if( static_cast<PropertyOwner*>( mCameraNode ) == &owner )
+ {
+ mCameraNode = nullptr;
+ }
+}
RenderTask::RenderTask()
: mViewportPosition( Vector2::ZERO),
mViewportSize( Vector2::ZERO),
mClearColor( Dali::RenderTask::DEFAULT_CLEAR_COLOR ),
- mRenderMessageDispatcher( NULL ),
- mRenderSyncTracker( NULL ),
- mSourceNode( NULL ),
- mCameraNode( NULL ),
- mCamera( NULL ),
+ mRenderMessageDispatcher( nullptr ),
+ mRenderSyncTracker( nullptr ),
+ mSourceNode( nullptr ),
+ mCameraNode( nullptr ),
+ mCamera( nullptr ),
mFrameBuffer(0),
+ 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 ),
- mState( (Dali::RenderTask::DEFAULT_REFRESH_RATE == Dali::RenderTask::REFRESH_ALWAYS)
- ? RENDER_CONTINUOUSLY
- : RENDER_ONCE_WAITING_FOR_RESOURCES ),
- mRefreshRate( Dali::RenderTask::DEFAULT_REFRESH_RATE ),
- mFrameCounter( 0u ),
- mRenderedOnceCounter( 0u ),
- mRequiresSync( false )
+ 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() );
}
} // namespace SceneGraph
/**
* RenderTasks describe how the Dali scene should be rendered.
*/
-class RenderTask : public PropertyOwner
+class RenderTask : public PropertyOwner, public PropertyOwner::Observer
{
public:
- enum State
+ enum State : uint8_t
{
RENDER_CONTINUOUSLY, ///< mRefreshRate > 0
RENDER_ONCE_WAITING_FOR_RESOURCES, ///< mRefreshRate = REFRESH_ONCE
*/
void SetSyncRequired( bool requiresSync );
+private: // from PropertyOwner::Observer
+
+ /**
+ * @copydoc PropertyOwner::Observer::PropertyOwnerConnected( PropertyOwner& owner )
+ */
+ void PropertyOwnerConnected( PropertyOwner& owner );
+
+ /**
+ * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner )
+ */
+ void PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner );
+
+ /**
+ * @copydoc PropertyOwner::Observer::PropertyOwnerDestroyed( PropertyOwner& owner )
+ */
+ void PropertyOwnerDestroyed( PropertyOwner& owner );
+
private:
+ void SetActiveStatus();
+
/**
- * Protected constructor.
+ * Constructor.
*/
RenderTask();
// Undefined
- RenderTask(const RenderTask&);
-
- // Undefined
- RenderTask& operator=(const RenderTask&);
-
+ RenderTask(const RenderTask&) = delete;
+ RenderTask& operator=(const RenderTask&) = delete;
public: // Animatable Properties
AnimatableProperty< Vector2 > mViewportPosition; ///< viewportPosition
SceneGraph::Camera* mCamera;
Render::FrameBuffer* mFrameBuffer;
- 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 implementation).
- bool mClearEnabled: 1; ///< Whether previous results are cleared.
- bool mCullMode: 1; ///< Whether renderers should be frustum culled
+ 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
+ State mState; ///< Render state.
- uint32_t mRenderedOnceCounter; ///< Incremented whenever state changes to RENDERED_ONCE_AND_NOTIFIED
- bool mRequiresSync; ///< Whether sync is needed to track the render
+ 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, RenderTask& task, Render::FrameBuffer* frameBuffer )
+inline void SetFrameBufferMessage( EventThreadServices& eventThreadServices, const RenderTask& task, Render::FrameBuffer* frameBuffer )
{
typedef MessageValue1< RenderTask, Render::FrameBuffer*> LocalType;
new (slot) LocalType( &task, &RenderTask::SetFrameBuffer, frameBuffer );
}
-inline void SetClearColorMessage( EventThreadServices& eventThreadServices, RenderTask& task, const Vector4& value )
+inline void SetClearColorMessage( EventThreadServices& eventThreadServices, const RenderTask& task, const Vector4& value )
{
typedef MessageDoubleBuffered1< RenderTask, Vector4 > LocalType;
new (slot) LocalType( &task, &RenderTask::BakeClearColor, value );
}
-inline void SetClearEnabledMessage( EventThreadServices& eventThreadServices, RenderTask& task, bool enabled )
+inline void SetClearEnabledMessage( EventThreadServices& eventThreadServices, const RenderTask& task, bool enabled )
{
typedef MessageValue1< RenderTask, bool > LocalType;
new (slot) LocalType( &task, &RenderTask::SetClearEnabled, enabled );
}
-inline void SetCullModeMessage( EventThreadServices& eventThreadServices, RenderTask& task, bool mode )
+inline void SetCullModeMessage( EventThreadServices& eventThreadServices, const RenderTask& task, bool mode )
{
typedef MessageValue1< RenderTask, bool > LocalType;
new (slot) LocalType( &task, &RenderTask::SetCullMode, mode );
}
-inline void SetRefreshRateMessage( EventThreadServices& eventThreadServices, RenderTask& task, uint32_t refreshRate )
+inline void SetRefreshRateMessage( EventThreadServices& eventThreadServices, const RenderTask& task, uint32_t refreshRate )
{
typedef MessageValue1< RenderTask, uint32_t > LocalType;
new (slot) LocalType( &task, &RenderTask::SetRefreshRate, refreshRate );
}
-inline void SetSourceNodeMessage( EventThreadServices& eventThreadServices, 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 );
new (slot) LocalType( &task, &RenderTask::SetSourceNode, node );
}
-inline void SetCameraMessage( EventThreadServices& eventThreadServices, RenderTask& task, const Node* constNode, const Camera* constCamera )
+inline void SetCameraMessage( EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode, const Camera* constCamera )
{
typedef MessageValue2< RenderTask, Node*, Camera* > LocalType;
new (slot) LocalType( &task, &RenderTask::SetCamera, node, camera );
}
-inline void SetExclusiveMessage( EventThreadServices& eventThreadServices, RenderTask& task, bool exclusive )
+inline void SetExclusiveMessage( EventThreadServices& eventThreadServices, const RenderTask& task, bool exclusive )
{
typedef MessageValue1< RenderTask, bool > LocalType;
new (slot) LocalType( &task, &RenderTask::SetExclusive, exclusive );
}
-inline void SetSyncRequiredMessage(EventThreadServices& eventThreadServices, RenderTask& task, bool requiresSync )
+inline void SetSyncRequiredMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool requiresSync )
{
typedef MessageValue1< RenderTask, bool > LocalType;
public:
AnimatableProperty< float > mOpacity; ///< The opacity value
- int mDepthIndex; ///< Used only in PrepareRenderInstructions
+ int32_t mDepthIndex; ///< Used only in PrepareRenderInstructions
};
new (slot) LocalType( &renderer, &Renderer::SetGeometry, const_cast<Render::Geometry*>(&geometry) );
}
-inline void SetShaderMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, Shader& shader )
+inline void SetShaderMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, const Shader& shader )
{
typedef MessageValue1< Renderer, Shader* > 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, &shader );
+ new (slot) LocalType( &renderer, &Renderer::SetShader, const_cast<Shader*>( &shader ) );
}
inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int depthIndex )
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Vector3& Path::GetPoint( size_t index )
{
- return GetImplementation(*this).GetPoint(index);
+ return GetImplementation(*this).GetPoint( static_cast<uint32_t>( index ) );
}
Vector3& Path::GetControlPoint( size_t index )
{
- return GetImplementation(*this).GetControlPoint(index);
+ return GetImplementation(*this).GetControlPoint( static_cast<uint32_t>( index ) );
}
size_t Path::GetPointCount() const
#include <dali/public-api/object/property-notification.h>
#include <dali/internal/event/animation/constraint-impl.h>
#include <dali/internal/event/common/object-impl.h>
-#include <dali/internal/event/object/custom-object-internal.h>
#include <dali/integration-api/debug.h>
namespace Dali
Handle Handle::New()
{
- return Handle( Internal::CustomObject::New() );
+ return Handle( Internal::Object::New().Get() );
}
Handle::~Handle()
Property::Value Handle::GetCurrentProperty( Property::Index index ) const
{
- return GetImplementation( *this ).GetCurrentProperty( index );
+ return GetImplementation(*this).GetCurrentProperty( index );
}
void Handle::GetPropertyIndices( Property::IndexContainer& indices ) const
RenderTask RenderTaskList::CreateTask()
{
- return GetImplementation(*this).CreateTask();
+ return RenderTask( GetImplementation(*this).CreateTask().Get() );
}
void RenderTaskList::RemoveTask( RenderTask task )
{
- GetImplementation(*this).RemoveTask( task );
+ if( task ) // don't crash if called with empty task handle
+ {
+ GetImplementation(*this).RemoveTask( GetImplementation( task ) );
+ }
}
uint32_t RenderTaskList::GetTaskCount() const
RenderTask RenderTaskList::GetTask( uint32_t index ) const
{
- return GetImplementation(*this).GetTask( index );
+ return RenderTask( GetImplementation(*this).GetTask( index ).Get() );
}
RenderTaskList::RenderTaskList( Internal::RenderTaskList* internal )
void RenderTask::SetScreenToFrameBufferMappingActor( Dali::Actor mappingActor )
{
- // NULL handle is allowed
- Internal::Actor* actorImpl( NULL );
- if ( mappingActor )
- {
- actorImpl = &GetImplementation( mappingActor );
- }
-
- GetImplementation(*this).SetScreenToFrameBufferMappingActor( actorImpl );
+ GetImplementation(*this).SetScreenToFrameBufferMappingActor( mappingActor );
}
Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const
{
- return Dali::Actor(GetImplementation(*this).GetScreenToFrameBufferMappingActor());
+ return GetImplementation(*this).GetScreenToFrameBufferMappingActor();
}
void RenderTask::SetViewportPosition( Vector2 position )
Geometry Renderer::GetGeometry() const
{
- Internal::Geometry* geometryPtr( GetImplementation(*this).GetGeometry() );
- return Dali::Geometry( geometryPtr );
+ return Dali::Geometry( GetImplementation(*this).GetGeometry().Get() );
}
void Renderer::SetTextures( TextureSet& textureSet )
TextureSet Renderer::GetTextures() const
{
- Internal::TextureSet* textureSet( GetImplementation(*this).GetTextures() );
- return Dali::TextureSet( textureSet );
+ return Dali::TextureSet( GetImplementation(*this).GetTextures().Get() );
}
void Renderer::SetShader( Shader& shader )
Shader Renderer::GetShader() const
{
- Internal::Shader* shaderPtr( GetImplementation(*this).GetShader() );
- return Dali::Shader( shaderPtr );
+ return Dali::Shader( GetImplementation(*this).GetShader().Get() );
}
Renderer::Renderer( Internal::Renderer* pointer )