--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics 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/actor-attachments/renderer-attachment-impl.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/update/node-attachments/scene-graph-renderer-attachment.h>
+#include <dali/internal/event/common/stage-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+RendererAttachmentPtr RendererAttachment::New( Stage& stage, const SceneGraph::Node& parentNode, Renderer& renderer )
+{
+ RendererAttachmentPtr attachment( new RendererAttachment( stage ) );
+
+ // Transfer object ownership of scene-object to message
+ SceneGraph::RendererAttachment* sceneObject = CreateSceneObject();
+ AttachToNodeMessage( stage.GetUpdateManager(), parentNode, sceneObject );
+
+ // Keep raw pointer for message passing
+ attachment->mSceneObject = sceneObject;
+
+ return attachment;
+}
+
+RendererAttachment::RendererAttachment( Stage& stage )
+: RenderableAttachment(stage),
+ mSceneObject(NULL)
+{
+}
+
+RendererAttachment::~RendererAttachment()
+{
+}
+
+SceneGraph::RendererAttachment* RendererAttachment::CreateSceneObject()
+{
+ return SceneGraph::RendererAttachment::New();
+}
+
+const SceneGraph::RendererAttachment& RendererAttachment::GetSceneObject() const
+{
+ DALI_ASSERT_DEBUG( mSceneObject != NULL );
+ return *mSceneObject;
+}
+
+
+void RendererAttachment::OnStageConnection2()
+{
+ mRendererConnector.OnStageConnect();
+}
+
+void RendererAttachment::OnStageDisconnection2()
+{
+ mRendererConnector.OnStageDisconnect();
+}
+
+
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_RENDERER_ATTACHMENT_H
+#define DALI_INTERNAL_RENDERER_ATTACHMENT_H
+
+/*
+ * Copyright (c) 2015 Samsung Electronics 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-connector.h>
+#include <dali/internal/event/actors/renderer-impl.h>
+#include <dali/internal/event/actor-attachments/renderable-attachment-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace SceneGraph
+{
+class Node;
+class RendererAttachment;
+}
+
+class RendererAttachment;
+typedef IntrusivePtr<RendererAttachment> RendererAttachmentPtr;
+
+/**
+ * An attachment for rendering renderers.
+ */
+class RendererAttachment : public RenderableAttachment
+{
+public:
+
+ /**
+ * Create a new RendererAttachment.
+ * @param[in] stage The stage to use for messaging
+ * @param[in] parentNode The node to attach a scene-object to.
+ * @poaram[in] renderer The renderer for this attachment
+ * @return A smart-pointer to the newly allocated RendererAttachment.
+ */
+ static RendererAttachmentPtr New( Stage& stage, const SceneGraph::Node& parentNode, Renderer& renderer );
+
+ /**
+ * Get the renderer
+ *
+ * @return The renderer
+ */
+ Renderer& GetRenderer()
+ {
+ return *mRendererConnector.Get();
+ }
+
+private:
+
+ /**
+ * First stage construction of a RendererAttachment.
+ * @param[in] stage Used to send messages to scene-graph.
+ */
+ RendererAttachment(Stage& stage);
+
+ /**
+ * Creates the corresponding scene-graph RendererAttachment.
+ * @return A newly allocated scene object.
+ */
+ static SceneGraph::RendererAttachment* CreateSceneObject();
+
+ /**
+ * @copydoc Dali::Internal::RenderableAttachment::GetSceneObject()
+ */
+ virtual const SceneGraph::RendererAttachment& GetSceneObject() const;
+
+ /**
+ * @copydoc Dali::Internal::RenderableAttachment::OnStageConnection2()
+ */
+ virtual void OnStageConnection2();
+
+ /**
+ * @copydoc Dali::Internal::RenderableAttachment::OnStageDisconnection2()
+ */
+ virtual void OnStageDisconnection2();
+
+protected:
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~RendererAttachment();
+
+private:
+ const SceneGraph::RendererAttachment* mSceneObject; ///< Not owned
+
+ ObjectConnector<Renderer> mRendererConnector;
+};
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_RENDERER_ATTACHMENT_H
#include <dali/internal/event/common/property-helper.h>
#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/event/actor-attachments/actor-attachment-impl.h>
+#include <dali/internal/event/actor-attachments/renderer-attachment-impl.h>
#include <dali/internal/event/animation/constraint-impl.h>
#include <dali/internal/event/common/projection.h>
#include <dali/internal/update/common/animatable-property.h>
return Vector3( 0.0f, 0.0f, 0.0f );
}
+unsigned int Actor::AddRenderer( Renderer& renderer )
+{
+ //TODO: MESH_REWORK : Check this
+ //TODO: MESH_REWORK : Add support for multiple renderers
+ if ( ! mAttachment )
+ {
+ mAttachment = RendererAttachment::New( *mStage, *mNode, renderer );
+ }
+
+ return 0;
+}
+
+unsigned int Actor::GetRendererCount() const
+{
+ //TODO: MESH_REWORK : Check this
+ //TODO: MESH_REWORK : Add support for multiple renderers
+ RendererAttachment* attachment = dynamic_cast<RendererAttachment*>(mAttachment.Get());
+ return attachment ? 1u : 0u;
+}
+
+Renderer& Actor::GetRendererAt( unsigned int index )
+{
+ //TODO: MESH_REWORK : Check this
+ //TODO: MESH_REWORK : Add support for multiple renderers
+ DALI_ASSERT_DEBUG( index == 0 && "Only one renderer is supported." );
+
+ //TODO: MESH_REWORK : Temporary code
+ RendererAttachment* attachment = dynamic_cast<RendererAttachment*>(mAttachment.Get());
+ DALI_ASSERT_ALWAYS( attachment && "Actor doesn't have a renderer" );
+
+ return attachment->GetRenderer();
+}
+
+void Actor::RemoveRenderer( Renderer& renderer )
+{
+ //TODO: MESH_REWORK : Check this
+ //TODO: MESH_REWORK : Add support for multiple renderers
+ mAttachment = NULL;
+}
+
+void Actor::RemoveRenderer( unsigned int index )
+{
+ //TODO: MESH_REWORK : Check this
+ //TODO: MESH_REWORK : Add support for multiple renderers
+ mAttachment = NULL;
+}
#ifdef DYNAMICS_SUPPORT
#include <dali/internal/event/common/object-impl.h>
#include <dali/internal/event/common/stage-def.h>
#include <dali/internal/event/actors/actor-declarations.h>
+#include <dali/internal/event/actors/renderer-impl.h>
#include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
#include <dali/internal/update/nodes/node-declarations.h>
class ActorGestureData;
class Animation;
class RenderTask;
+class Renderer;
struct DynamicsData;
typedef IntrusivePtr<Actor> ActorPtr;
*/
const Vector4& GetCurrentWorldColor() const;
+ /**
+ * @copydoc Dali::Actor::AddRenderer()
+ */
+ unsigned int AddRenderer( Renderer& renderer );
+
+ /**
+ * @copydoc Dali::Actor::GetRendererCount()
+ */
+ unsigned int GetRendererCount() const;
+
+ /**
+ * @copydoc Dali::Actor::GetRendererAt()
+ */
+ Renderer& GetRendererAt( unsigned int index );
+
+ /**
+ * @copydoc Dali::Actor::RemoveRenderer()
+ */
+ void RemoveRenderer( Renderer& renderer );
+
+ /**
+ * @copydoc Dali::Actor::RemoveRenderer()
+ */
+ void RemoveRenderer( unsigned int index );
+
#ifdef DYNAMICS_SUPPORT
// Dynamics
mConnectionCount (0),
mGeometryHints( hints )
{
- mSceneObject = new Shader( hints );
+ mSceneObject = new SceneGraph::Shader( hints );
DALI_ASSERT_DEBUG( NULL != mSceneObject );
// Transfer shader ownership to a scene message
$(internal_src_dir)/event/actor-attachments/camera-attachment-impl.cpp \
$(internal_src_dir)/event/actor-attachments/image-attachment-impl.cpp \
$(internal_src_dir)/event/actor-attachments/renderable-attachment-impl.cpp \
+ $(internal_src_dir)/event/actor-attachments/renderer-attachment-impl.cpp \
$(internal_src_dir)/event/actor-attachments/text-attachment-impl.cpp \
$(internal_src_dir)/event/actors/actor-impl.cpp \
$(internal_src_dir)/event/actors/custom-actor-internal.cpp \
$(internal_src_dir)/event/common/type-registry-impl.cpp \
$(internal_src_dir)/event/effects/material-impl.cpp \
$(internal_src_dir)/event/effects/sampler-impl.cpp \
- $(internal_src_dir)/event/effects/shader-impl.cpp \
$(internal_src_dir)/event/effects/shader-effect-impl.cpp \
$(internal_src_dir)/event/effects/shader-factory.cpp \
+ $(internal_src_dir)/event/effects/shader-impl.cpp \
$(internal_src_dir)/event/events/actor-gesture-data.cpp \
$(internal_src_dir)/event/events/actor-observer.cpp \
$(internal_src_dir)/event/events/event-processor.cpp \
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/actors/layer-impl.h>
+#include <dali/internal/event/actors/renderer-impl.h>
#include <dali/internal/event/actor-attachments/actor-attachment-impl.h>
#include <dali/internal/event/animation/constraint-impl.h>
return GetImplementation(*this).OffStageSignal();
}
+unsigned int Actor::AddRenderer( Renderer& renderer )
+{
+ return GetImplementation(*this).AddRenderer( GetImplementation( renderer ) );
+}
+
+unsigned int Actor::GetRendererCount() const
+{
+ return GetImplementation(*this).GetRendererCount();
+}
+
+Renderer Actor::GetRendererAt( unsigned int index )
+{
+ return Renderer( &GetImplementation(*this).GetRendererAt( index ) );
+}
+
+void Actor::RemoveRenderer( Renderer& renderer )
+{
+ GetImplementation(*this).RemoveRenderer( GetImplementation( renderer ) );
+}
+
+void Actor::RemoveRenderer( unsigned int index )
+{
+ GetImplementation(*this).RemoveRenderer( index );
+}
+
DynamicsBody Actor::EnableDynamics(DynamicsBodyConfig bodyConfig)
{
#ifdef DYNAMICS_SUPPORT
#include <dali/public-api/object/handle.h>
#include <dali/public-api/object/property-index-ranges.h>
#include <dali/public-api/signals/dali-signal.h>
-
namespace Dali
{
}
class Actor;
+class Renderer;
class Animation;
class Constraint;
struct Degree;
*/
OffStageSignalType& OffStageSignal();
+public: // Renderer
+
+ /**
+ * @brief Add a renderer to this actor.
+ *
+ * @pre The renderer must be initialized.
+ *
+ * @param[in] renderer Renderer to add to the actor
+ * @return The index of the Renderer that was added
+ */
+ unsigned int AddRenderer( Renderer& renderer );
+
+ /**
+ * @brief Get the number of renderers on this actor.
+ *
+ * @return the number of renderers on this actor
+ */
+ unsigned int GetRendererCount() const;
+
+ /**
+ * @brief Get a Renderer by index.
+ *
+ * @pre The index must be between 0 and GetRendererCount()-1
+ *
+ * @param[in] renderer Renderer to add to the actor
+ * @return The renderer at the specified index
+ */
+ Renderer GetRendererAt( unsigned int index );
+
+ /**
+ * @brief Remove an renderer from the actor.
+ *
+ * @param[in] renderer Handle to the renderer that is to be removed
+ */
+ void RemoveRenderer( Renderer& renderer );
+
+ /**
+ * @brief Remove an renderer from the actor by index.
+ *
+ * @pre The index must be between 0 and GetRendererCount()-1
+ *
+ * @param[in] index Index of the renderer that is to be removed
+ */
+ void RemoveRenderer( unsigned int index );
+
public: // Dynamics
/**
namespace Dali
{
-Renderer Renderer::New( Geometry geometry, Material material )
+Renderer Renderer::New( Geometry& geometry, Material& material )
{
Internal::RendererPtr renderer = Internal::Renderer::New( );
return Renderer( renderer.Get() );
return *this;
}
-void Renderer::SetGeometry( Geometry geometry )
+void Renderer::SetGeometry( Geometry& geometry )
{
GetImplementation(*this).SetGeometry( GetImplementation(geometry) );
}
-void Renderer::SetMaterial( Material material )
+void Renderer::SetMaterial( Material& material )
{
GetImplementation(*this).SetMaterial( GetImplementation(material) );
}
* @param[in] geometry Geometry to be used by this renderer
* @param[in] material Material to be used by this renderer
*/
- static Renderer New( Geometry geometry, Material material );
+ static Renderer New( Geometry& geometry, Material& material );
/**
* @brief Default constructor, creates an empty handle
*
* @param[in] geometry The geometry to be used by this renderer
*/
- void SetGeometry( Geometry geometry );
+ void SetGeometry( Geometry& geometry );
/**
* @brief Sets the material to be used by this renderer
*
* @param[in] material The material to be used by this renderer
*/
- void SetMaterial( Material material );
+ void SetMaterial( Material& material );
/**
* @brief Set the depth index of this renderer
return *this;
}
-std::size_t Geometry::AddVertexBuffer( PropertyBuffer vertexBuffer )
+std::size_t Geometry::AddVertexBuffer( PropertyBuffer& vertexBuffer )
{
return GetImplementation(*this).AddVertexBuffer( GetImplementation( vertexBuffer ) );
}
GetImplementation(*this).RemoveVertexBuffer( index );
}
-void Geometry::SetIndexBuffer( PropertyBuffer indexBuffer )
+void Geometry::SetIndexBuffer( PropertyBuffer& indexBuffer )
{
GetImplementation(*this).SetIndexBuffer( GetImplementation( indexBuffer ) );
}
* @return Index of the newly added buffer, can be used with RemoveVertexBuffer to remove
* this buffer if no longer required
*/
- std::size_t AddVertexBuffer( PropertyBuffer vertexBuffer );
+ std::size_t AddVertexBuffer( PropertyBuffer& vertexBuffer );
/**
* @brief Retrieve the number of vertex buffers that have been added to this geometry
*
* @param[in] indexBuffer PropertyBuffer to be used as a source of indices for the geometry
*/
- void SetIndexBuffer( PropertyBuffer indexBuffer );
+ void SetIndexBuffer( PropertyBuffer& indexBuffer );
/**
* @brief Set the type of primitives this geometry contains
*
* @param [in] pointer A pointer to a newly allocated Geometry
*/
- explicit DALI_INTERNAL Geometry(Internal::Geometry* pointer);
+ explicit DALI_INTERNAL Geometry( Internal::Geometry* pointer );
};
} //namespace Dali
*
* @param [in] pointer A pointer to a newly allocated PropertyBuffer
*/
- explicit DALI_INTERNAL PropertyBuffer(Internal::PropertyBuffer* pointer);
+ explicit DALI_INTERNAL PropertyBuffer( Internal::PropertyBuffer* pointer );
};
} // namespace Dali
Material Material::New( Shader shader )
{
+ // TODO: MESH_REWORK
Internal::MaterialPtr material = Internal::Material::New();
return Material( material.Get() );
}
{
}
-Material& Material::operator=( Material& handle )
+Material& Material::operator=( const Material& handle )
{
BaseHandle::operator=( handle );
return *this;
}
-void Material::SetShader( Shader shader )
+void Material::SetShader( Shader& shader )
{
GetImplementation(*this).SetShader( GetImplementation( shader ) );
}
-void Material::AddSampler( Sampler sampler )
+void Material::AddSampler( Sampler& sampler )
{
GetImplementation(*this).AddSampler( GetImplementation( sampler ) );
}
*
* @param[in] handle Handle to an object
*/
- Material& operator=( Material& handle );
+ Material& operator=( const Material& handle );
/**
* @brief Sets the Shader used by this material
*
* @param[in] shader Handle to a shader
*/
- void SetShader( Shader shader );
+ void SetShader( Shader& shader );
/**
* @brief Add a sampler to this material
*
* param[in] sampler The sampler to add to this material
*/
- void AddSampler( Sampler sampler );
+ void AddSampler( Sampler& sampler );
/**
* @brief Get the number of samplers
*
* @param [in] pointer A pointer to a newly allocated Material
*/
- explicit DALI_INTERNAL Material(Internal::Material* pointer);
+ explicit DALI_INTERNAL Material( Internal::Material* pointer );
};
} //namespace Dali
namespace Dali
{
-Sampler Sampler::New( const std::string& uniformName )
+Sampler Sampler::New( Image& image, const std::string& uniformName )
{
+ //TODO: MESH_REWORK
Internal::SamplerPtr sampler = Internal::Sampler::New();
return Sampler( sampler.Get() );
}
GetImplementation(*this).SetUniformName( name );
}
-void Sampler::SetImage( Image image )
+void Sampler::SetImage( Image& image )
{
GetImplementation(*this).SetImage( GetImplementation( image ) );
}
/**
* @brief Creates a new Sampler object
*
+ * @param[in] image Image used by this sampler
* @param[in] uniformName String with the name of the uniform
*/
- static Sampler New( const std::string& uniformName );
+ static Sampler New( Image& image, const std::string& uniformName );
/**
* @brief Default constructor, creates an empty handle
*
* @param[in] image Image used by this sampler
*/
- void SetImage( Image image );
+ void SetImage( Image& image );
/**
* @brief Set the filter modes for this sampler
* and MAGNIFICATION_FILTER
*
* @param[in] minFilter The minification filter that will be used
- * @param[in] minFilter The magnification filter that will be used
+ * @param[in] magFilter The magnification filter that will be used
*/
void SetFilterMode( FilterMode minFilter, FilterMode magFilter );
*
* @param [in] pointer A pointer to a newly allocated Sampler
*/
- explicit DALI_INTERNAL Sampler(Internal::Sampler* pointer);
+ explicit DALI_INTERNAL Sampler( Internal::Sampler* pointer );
};
} //namespace Dali