bool Actor::ScreenToLocal( float& localX, float& localY, float screenX, float screenY ) const
{
// only valid when on-stage
- if( OnStage() )
+ StagePtr stage = Stage::GetCurrent();
+ if( stage && OnStage() )
{
- const RenderTaskList& taskList = Stage::GetCurrent()->GetRenderTaskList();
+ const RenderTaskList& taskList = stage->GetRenderTaskList();
Vector2 converted( screenX, screenY );
if( Size::ZERO == size )
{
- if( Stage::IsInstalled() )
+ StagePtr stage = Stage::GetCurrent();
+ if( stage )
{
- const Size& stageSize = Stage::GetCurrent()->GetSize();
+ const Size& stageSize = stage->GetSize();
width = stageSize.width;
height = stageSize.height;
// Convert mClippingBox to GL based coordinates (from bottom-left)
ClippingBox clippingBox( mClippingBox );
- clippingBox.y = Stage::GetCurrent()->GetSize().height - clippingBox.y - clippingBox.height;
- // layerNode is being used in a separate thread; queue a message to set the value
- SetClippingBoxMessage( GetEventThreadServices(), GetSceneLayerOnStage(), clippingBox );
+ StagePtr stage = Stage::GetCurrent();
+ if( stage )
+ {
+ clippingBox.y = stage->GetSize().height - clippingBox.y - clippingBox.height;
+
+ // layerNode is being used in a separate thread; queue a message to set the value
+ SetClippingBoxMessage( GetEventThreadServices(), GetSceneLayerOnStage(), clippingBox );
+ }
}
}
{
Stage* stage = Stage::GetCurrent();
- AnimationPlaylist& playlist = stage->GetAnimationPlaylist();
-
- if( durationSeconds < 0.0f )
+ if( stage )
{
- DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
- durationSeconds = 0.0f;
- }
+ AnimationPlaylist& playlist = stage->GetAnimationPlaylist();
+
+ if( durationSeconds < 0.0f )
+ {
+ DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
+ durationSeconds = 0.0f;
+ }
- AnimationPtr animation = new Animation( *stage, playlist, durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, DEFAULT_ALPHA_FUNCTION );
+ AnimationPtr animation = new Animation( *stage, playlist, durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, DEFAULT_ALPHA_FUNCTION );
- // Second-phase construction
- animation->Initialize();
+ // Second-phase construction
+ animation->Initialize();
- return animation;
+ return animation;
+ }
+ else
+ {
+ return NULL;
+ }
}
Animation::Animation( EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha )
UpdateManager& updateManager = tls.GetUpdateManager();
- PropertyNotificationManager& propertyNotificationManager = Stage::GetCurrent()->GetPropertyNotificationManager();
-
- PropertyNotificationPtr propertyNotification = new PropertyNotification(updateManager,
- propertyNotificationManager,
- target,
- componentIndex,
- condition);
-
- return propertyNotification;
+ StagePtr stage = Stage::GetCurrent();
+ if( stage )
+ {
+ PropertyNotificationManager& propertyNotificationManager = stage->GetPropertyNotificationManager();
+ PropertyNotificationPtr propertyNotification = new PropertyNotification(updateManager,
+ propertyNotificationManager,
+ target,
+ componentIndex,
+ condition);
+ return propertyNotification;
+ }
+ else
+ {
+ return NULL;
+ }
}
PropertyNotification::PropertyNotification( UpdateManager& updateManager,
{
Stage* stage = Stage::GetCurrent();
- ShaderEffectPtr shaderEffect( new ShaderEffect( *stage, hints ) );
- shaderEffect->RegisterObject();
-
- return shaderEffect;
+ if( stage )
+ {
+ ShaderEffectPtr shaderEffect( new ShaderEffect( *stage, hints ) );
+ shaderEffect->RegisterObject();
+ return shaderEffect;
+ }
+ else
+ {
+ return NULL;
+ }
}
ShaderEffect::ShaderEffect( EventThreadServices& eventThreadServices, Dali::ShaderEffect::GeometryHints hints )
/**
* Hit test a RenderTask
*/
-bool HitTestRenderTask( LayerList& layers,
+bool HitTestRenderTask( Stage& stage,
+ LayerList& layers,
RenderTask& renderTask,
Vector2 screenCoordinates,
Results& results,
bool stencilOnLayer = false;
bool stencilHit = false;
bool layerConsumesHit = false;
- const Vector2& stageSize = Stage::GetCurrent()->GetSize();
+
+ const Vector2& stageSize = stage.GetSize();
for (int i=layers.GetLayerCount()-1; i>=0 && !(hit.actor); --i)
{
*
* @return true if we have a hit, false otherwise
*/
-bool HitTestForEachRenderTask( LayerList& layers,
+bool HitTestForEachRenderTask( Stage& stage,
+ LayerList& layers,
RenderTaskList& taskList,
const Vector2& screenCoordinates,
Results& results,
}
}
- if ( HitTestRenderTask( layers, renderTask, screenCoordinates, results, hitCheck ) )
+ if ( HitTestRenderTask( stage, layers, renderTask, screenCoordinates, results, hitCheck ) )
{
// Return true when an actor is hit (or layer in our render-task consumes the hit)
return true; // don't bother checking off screen tasks
continue;
}
- if ( HitTestRenderTask( layers, renderTask, screenCoordinates, results, hitCheck ) )
+ if ( HitTestRenderTask( stage, layers, renderTask, screenCoordinates, results, hitCheck ) )
{
// Return true when an actor is hit (or a layer in our render-task consumes the hit)
return true;
Results hitTestResults;
HitTestFunctionWrapper hitTestFunctionWrapper( func );
- if ( HitTestForEachRenderTask( layerList, taskList, screenCoordinates, hitTestResults, hitTestFunctionWrapper ) )
+ if ( HitTestForEachRenderTask( stage, layerList, taskList, screenCoordinates, hitTestResults, hitTestFunctionWrapper ) )
{
results.actor = hitTestResults.actor;
results.actorCoordinates = hitTestResults.actorCoordinates;
RenderTaskList& overlayTaskList = systemOverlay->GetOverlayRenderTasks();
LayerList& overlayLayerList = systemOverlay->GetLayerList();
- wasHit = HitTestForEachRenderTask( overlayLayerList, overlayTaskList, screenCoordinates, results, hitTestInterface );
+ wasHit = HitTestForEachRenderTask( stage, overlayLayerList, overlayTaskList, screenCoordinates, results, hitTestInterface );
}
// Hit-test the regular on-stage actors
RenderTaskList& taskList = stage.GetRenderTaskList();
LayerList& layerList = stage.GetLayerList();
- wasHit = HitTestForEachRenderTask( layerList, taskList, screenCoordinates, results, hitTestInterface );
+ wasHit = HitTestForEachRenderTask( stage, layerList, taskList, screenCoordinates, results, hitTestInterface );
}
return wasHit;
}
Results hitTestResults;
HitTestFunctionWrapper hitTestFunctionWrapper( func );
- if ( HitTestRenderTask( stage.GetLayerList(), renderTask, screenCoordinates, hitTestResults, hitTestFunctionWrapper ) )
+ if ( HitTestRenderTask( stage, stage.GetLayerList(), renderTask, screenCoordinates, hitTestResults, hitTestFunctionWrapper ) )
{
results.actor = hitTestResults.actor;
results.actorCoordinates = hitTestResults.actorCoordinates;
Stage* stage = Stage::GetCurrent();
- // Create the event object
- AnimatableMeshPtr animatableMeshPtr( new AnimatableMesh( *stage, sceneObject, mesh, meshData.GetVertexCount() ) );
-
- return animatableMeshPtr;
+ if( stage )
+ {
+ // Create the event object
+ AnimatableMeshPtr animatableMeshPtr( new AnimatableMesh( *stage, sceneObject, mesh, meshData.GetVertexCount() ) );
+ return animatableMeshPtr;
+ }
+ else
+ {
+ return NULL;
+ }
}
AnimatableMesh::~AnimatableMesh()
{
CameraActor* localCamera = GetCameraActor();
StagePtr stage = Stage::GetCurrent();
- CameraActor& defaultCamera = stage->GetDefaultCameraActor();
- if( localCamera )
+ if( stage )
{
- Viewport viewport;
- Vector2 size( stage->GetSize() );
- viewport.x = viewport.y = 0;
- viewport.width = size.width;
- viewport.height = size.height;
-
- float localX, localY;
- inside = mMappingConnector.mActor->ScreenToLocal(defaultCamera.GetViewMatrix(), defaultCamera.GetProjectionMatrix(), viewport, localX, localY, screenCoords.x, screenCoords.y);
- Vector3 actorSize = mMappingConnector.mActor->GetCurrentSize();
- if( inside && localX >= 0.f && localX <= actorSize.x && localY >= 0.f && localY <= actorSize.y)
+ CameraActor& defaultCamera = stage->GetDefaultCameraActor();
+ if( localCamera )
{
- screenCoords.x = localX;
- screenCoords.y = localY;
+ Viewport viewport;
+ Vector2 size( stage->GetSize() );
+ viewport.x = viewport.y = 0;
+ viewport.width = size.width;
+ viewport.height = size.height;
+
+ float localX, localY;
+ inside = mMappingConnector.mActor->ScreenToLocal(defaultCamera.GetViewMatrix(), defaultCamera.GetProjectionMatrix(), viewport, localX, localY, screenCoords.x, screenCoords.y);
+ Vector3 actorSize = mMappingConnector.mActor->GetCurrentSize();
+ if( inside && localX >= 0.f && localX <= actorSize.x && localY >= 0.f && localY <= actorSize.y)
+ {
+ screenCoords.x = localX;
+ screenCoords.y = localY;
+ }
+ else
+ {
+ inside = false;
+ }
}
else
{
inside = false;
}
}
- else
- {
- inside = false;
- }
}
else if ( mFrameBufferImage && mScreenToFrameBufferFunction )
{