Pass stage from actor to attachment to avoid unnecessary calls to Stage::GetCurrent() 78/35378/7 submit/tizen/20150217.020310
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 12 Feb 2015 19:36:02 +0000 (19:36 +0000)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Mon, 16 Feb 2015 16:27:24 +0000 (08:27 -0800)
Change-Id: I05563d82c46bf85d29b81b9e3135dc108aad8535

dali/internal/event/actor-attachments/image-attachment-impl.cpp
dali/internal/event/actor-attachments/image-attachment-impl.h
dali/internal/event/actor-attachments/mesh-attachment-impl.cpp
dali/internal/event/actor-attachments/mesh-attachment-impl.h
dali/internal/event/actor-attachments/text-attachment-impl.cpp
dali/internal/event/actor-attachments/text-attachment-impl.h
dali/internal/event/actors/image-actor-impl.cpp
dali/internal/event/actors/mesh-actor-impl.cpp
dali/internal/event/actors/text-actor-impl.cpp

index 6962bdb..04b04e0 100644 (file)
@@ -29,15 +29,13 @@ namespace Dali
 namespace Internal
 {
 
-ImageAttachmentPtr ImageAttachment::New( const SceneGraph::Node& parentNode )
+ImageAttachmentPtr ImageAttachment::New( Stage& stage, const SceneGraph::Node& parentNode )
 {
-  StagePtr stage = Stage::GetCurrent();
-
-  ImageAttachmentPtr attachment( new ImageAttachment( *stage ) );
+  ImageAttachmentPtr attachment( new ImageAttachment( stage ) );
 
   // Transfer object ownership of scene-object to message
   SceneGraph::ImageAttachment* sceneObject = CreateSceneObject();
-  AttachToNodeMessage( stage->GetUpdateManager(), parentNode, sceneObject );
+  AttachToNodeMessage( stage.GetUpdateManager(), parentNode, sceneObject );
 
   // Keep raw pointer for message passing
   attachment->mSceneObject = sceneObject;
index 5e216cd..965ebbf 100644 (file)
@@ -39,7 +39,6 @@ class Node;
 
 /**
  * An attachment for rendering images in various ways.
- * The default geometry scaling mode is ScaleToFill.
  */
 class ImageAttachment : public RenderableAttachment
 {
@@ -50,10 +49,11 @@ public:
 
   /**
    * Create a new ImageAttachment.
+   * @param[in] stage The stage to use for messaging
    * @param[in] parentNode The node to attach a scene-object to.
    * @return A smart-pointer to the newly allocated ImageAttachment.
    */
-  static ImageAttachmentPtr New( const SceneGraph::Node& parentNode );
+  static ImageAttachmentPtr New( Stage& stage, const SceneGraph::Node& parentNode );
 
   /**
    * Sets image rendered by the attachment.
@@ -135,7 +135,6 @@ private:
   /**
    * First stage construction of a ImageAttachment.
    * @param[in] stage Used to send messages to scene-graph.
-   * @param[in] image A pointer to the image to display or NULL to not render anything.
    */
   ImageAttachment(Stage& stage);
 
index 65a253b..36cc8d2 100644 (file)
@@ -34,15 +34,13 @@ namespace Dali
 namespace Internal
 {
 
-MeshAttachmentPtr MeshAttachment::New( const SceneGraph::Node& parentNode )
+MeshAttachmentPtr MeshAttachment::New( Stage& stage, const SceneGraph::Node& parentNode )
 {
-  StagePtr stage = Stage::GetCurrent();
-
-  MeshAttachmentPtr attachment( new MeshAttachment( *stage ) );
+  MeshAttachmentPtr attachment( new MeshAttachment( stage ) );
 
   // Transfer object ownership of scene-object to message
   SceneGraph::MeshAttachment* sceneObject = SceneGraph::MeshAttachment::New();
-  AttachToNodeMessage( stage->GetUpdateManager(), parentNode, sceneObject );
+  AttachToNodeMessage( stage.GetUpdateManager(), parentNode, sceneObject );
 
   // Keep raw pointer for message passing
   attachment->mSceneObject = sceneObject;
index a23a88e..d979bd1 100644 (file)
@@ -62,11 +62,12 @@ public:
 
   /**
    * Create an initialised MeshAttachment.
+   * @param[in] stage The stage to use for messaging
    * @param[in] parentNode The node to attach a scene-object to.
    * This will not be displayed until a mesh is added with SetMesh().
    * @return A handle to a newly allocated Dali resource.
    */
-  static MeshAttachmentPtr New( const SceneGraph::Node& parentNode );
+  static MeshAttachmentPtr New( Stage& stage, const SceneGraph::Node& parentNode );
 
   /**
    * Set the mesh to be rendererd by this attachment
index 97ee7ad..366cbdf 100644 (file)
@@ -31,11 +31,9 @@ namespace Dali
 namespace Internal
 {
 
-TextAttachmentPtr TextAttachment::New( const SceneGraph::Node& parentNode, const Integration::TextArray& text, FontPointer font )
+TextAttachmentPtr TextAttachment::New( Stage& stage, const SceneGraph::Node& parentNode, const Integration::TextArray& text, FontPointer font )
 {
-  StagePtr stage = Stage::GetCurrent();
-
-  TextAttachmentPtr attachment( new TextAttachment( *stage ) );
+  TextAttachmentPtr attachment( new TextAttachment( stage ) );
 
   // Second-phase construction
 
@@ -45,7 +43,7 @@ TextAttachmentPtr TextAttachment::New( const SceneGraph::Node& parentNode, const
   // Transfer object ownership of scene-object to message
   SceneGraph::TextAttachment* sceneObject = SceneGraph::TextAttachment::New();
 
-  AttachToNodeMessage( stage->GetUpdateManager(), parentNode, sceneObject );
+  AttachToNodeMessage( stage.GetUpdateManager(), parentNode, sceneObject );
 
   // Keep raw pointer for message passing
   attachment->mSceneObject = sceneObject;
index de16ee8..eec38ae 100644 (file)
@@ -54,12 +54,13 @@ public:
 
   /**
    * Create a new TextAttachment.
+   * @param[in] stage The stage to use for messaging
    * @param[in] parentNode The node to attach a scene-object to.
    * @param [in] text The text which will be displayed.
    * @param [in] font The font which will be used for the text.
    * @return A smart-pointer to the newly allocated TextAttachment.
    */
-  static TextAttachmentPtr New( const SceneGraph::Node& parentNode, const Integration::TextArray& text, FontPointer font );
+  static TextAttachmentPtr New( Stage& stage, const SceneGraph::Node& parentNode, const Integration::TextArray& text, FontPointer font );
 
   /**
    * Set the text label displayed by the attachment
index c9d4ff7..550596f 100644 (file)
@@ -97,7 +97,7 @@ ImageActorPtr ImageActor::New()
   actor->Initialize();
 
   // Create the attachment
-  actor->mImageAttachment = ImageAttachment::New( *actor->mNode );
+  actor->mImageAttachment = ImageAttachment::New( *actor->mStage, *actor->mNode );
   actor->Attach( *actor->mImageAttachment );
 
   return actor;
index 74bef56..5da1d8a 100644 (file)
@@ -55,7 +55,7 @@ MeshActorPtr MeshActor::New()
   actor->Initialize();
 
   // Create the attachment
-  actor->mMeshAttachment = MeshAttachment::New( *actor->mNode );
+  actor->mMeshAttachment = MeshAttachment::New( *actor->mStage, *actor->mNode );
   actor->Attach(*actor->mMeshAttachment);
   actor->SetCullFace( Dali::CullBack );
 
@@ -89,15 +89,9 @@ MeshActorPtr MeshActor::New(Dali::AnimatableMesh mesh)
 
 MeshActorPtr MeshActor::New(ModelDataPtr modelData, Dali::Entity entity)
 {
-  MeshActorPtr actor(new MeshActor());
-  // Second-phase construction
-  actor->Initialize();
+  MeshActorPtr actor = MeshActor::New();
 
-  // Create the attachment
-  actor->mMeshAttachment = MeshAttachment::New( *actor->mNode );
-  actor->Attach(*actor->mMeshAttachment);
   actor->SetName(entity.GetName());
-  actor->SetCullFace( Dali::CullBack );
 
   DALI_ASSERT_ALWAYS(entity.NumberOfMeshes() == 1 && "Dali does not support multiple meshes per node in the model");
 
index 1238da3..f4fcbed 100644 (file)
@@ -144,7 +144,7 @@ TextActorPtr TextActor::New( const Integration::TextArray& utfCodes, const TextA
   actor->Initialize();
 
   //create the attachment
-  actor->mTextAttachment = TextAttachment::New( *actor->mNode, Integration::TextArray(), fontPtr );
+  actor->mTextAttachment = TextAttachment::New( *actor->mStage, *actor->mNode, Integration::TextArray(), fontPtr );
   actor->Attach(*actor->mTextAttachment);
 
   // Note: SetTextStyle() MUST be called before SetText(), to ensure