From 00c8cadc279f62f710f90e6c5dce33c580b055b4 Mon Sep 17 00:00:00 2001 From: Ferran Sole Date: Fri, 22 May 2015 12:26:53 +0100 Subject: [PATCH] Added getters in Renderer to get material and geometry, and in Material to get samplers Change-Id: Ib290d16ff63fe35cb1d7925e153c4ee6bfc6bee1 --- dali/internal/event/actors/renderer-impl.cpp | 10 ++++++++++ dali/internal/event/actors/renderer-impl.h | 10 ++++++++++ dali/internal/event/effects/material-impl.cpp | 5 +++++ dali/internal/event/effects/material-impl.h | 5 +++++ dali/public-api/actors/renderer.cpp | 12 ++++++++++++ dali/public-api/actors/renderer.h | 14 ++++++++++++++ dali/public-api/shader-effects/material.cpp | 6 ++++++ dali/public-api/shader-effects/material.h | 10 ++++++++++ 8 files changed, 72 insertions(+) diff --git a/dali/internal/event/actors/renderer-impl.cpp b/dali/internal/event/actors/renderer-impl.cpp index 3085c6a..0c83a08 100644 --- a/dali/internal/event/actors/renderer-impl.cpp +++ b/dali/internal/event/actors/renderer-impl.cpp @@ -60,6 +60,11 @@ void Renderer::SetGeometry( Geometry& geometry ) SetGeometryMessage( GetEventThreadServices(), *mSceneObject, *geometrySceneObject ); } +Geometry* Renderer::GetGeometry() const +{ + return mGeometryConnector.Get().Get(); +} + void Renderer::SetMaterial( Material& material ) { mMaterialConnector.Set( material, OnStage() ); @@ -67,6 +72,11 @@ void Renderer::SetMaterial( Material& material ) SetMaterialMessage( GetEventThreadServices(), *mSceneObject, *materialSceneObject ); } +Material* Renderer::GetMaterial() const +{ + return mMaterialConnector.Get().Get(); +} + void Renderer::SetDepthIndex( int depthIndex ) { SetDepthIndexMessage( GetEventThreadServices(), *mSceneObject, depthIndex ); diff --git a/dali/internal/event/actors/renderer-impl.h b/dali/internal/event/actors/renderer-impl.h index 64fa58c..f02a3ac 100644 --- a/dali/internal/event/actors/renderer-impl.h +++ b/dali/internal/event/actors/renderer-impl.h @@ -59,11 +59,21 @@ public: void SetGeometry( Geometry& geometry ); /** + * @copydoc Dali::Renderer::GetGeometry() + */ + Geometry* GetGeometry() const; + + /** * @copydoc Dali::Renderer::SetMaterial() */ void SetMaterial( Material& material ); /** + * @copydoc Dali::Renderer::GetMaterial() + */ + Material* GetMaterial() const; + + /** * @copydoc Dali::Renderer::SetDepthIndex() */ void SetDepthIndex( int depthIndex ); diff --git a/dali/internal/event/effects/material-impl.cpp b/dali/internal/event/effects/material-impl.cpp index ecfd1fd..a769c1e 100644 --- a/dali/internal/event/effects/material-impl.cpp +++ b/dali/internal/event/effects/material-impl.cpp @@ -90,6 +90,11 @@ void Material::RemoveSampler( std::size_t index ) mSamplerConnectors.erase( mSamplerConnectors.begin() + index ); } +Sampler* Material::GetSamplerAt( unsigned int index ) const +{ + return mSamplerConnectors[index].Get().Get(); +} + void Material::SetFaceCullingMode( Dali::Material::FaceCullingMode cullingMode ) { if( NULL != mSceneObject ) diff --git a/dali/internal/event/effects/material-impl.h b/dali/internal/event/effects/material-impl.h index 48392c2..7691a43 100644 --- a/dali/internal/event/effects/material-impl.h +++ b/dali/internal/event/effects/material-impl.h @@ -80,6 +80,11 @@ public: void RemoveSampler( std::size_t index ); /** + * @copydoc Dali::Material::GetSamplerAt() + */ + Sampler* GetSamplerAt( unsigned int index ) const; + + /** * @copydoc Dali::Material::SetFaceCullingMode() */ void SetFaceCullingMode( Dali::Material::FaceCullingMode cullingMode ); diff --git a/dali/public-api/actors/renderer.cpp b/dali/public-api/actors/renderer.cpp index 2af1722..e9705f3 100644 --- a/dali/public-api/actors/renderer.cpp +++ b/dali/public-api/actors/renderer.cpp @@ -62,12 +62,24 @@ void Renderer::SetGeometry( Geometry& geometry ) GetImplementation(*this).SetGeometry( GetImplementation(geometry) ); } +Geometry Renderer::GetGeometry() const +{ + Internal::Geometry* geometryPtr( GetImplementation(*this).GetGeometry() ); + return Dali::Geometry( geometryPtr ); +} + void Renderer::SetMaterial( Material& material ) { DALI_ASSERT_ALWAYS( material && "Material handle not initialized" ); GetImplementation(*this).SetMaterial( GetImplementation(material) ); } +Material Renderer::GetMaterial() const +{ + Internal::Material* materialPtr( GetImplementation(*this).GetMaterial() ); + return Dali::Material( materialPtr ); +} + void Renderer::SetDepthIndex( int depthIndex ) { GetImplementation(*this).SetDepthIndex( depthIndex ); diff --git a/dali/public-api/actors/renderer.h b/dali/public-api/actors/renderer.h index 758b361..e718fb2 100644 --- a/dali/public-api/actors/renderer.h +++ b/dali/public-api/actors/renderer.h @@ -103,6 +103,13 @@ public: void SetGeometry( Geometry& geometry ); /** + * @brief Gets the geometry used by this renderer + * + * @return The geometry used by the renderer + */ + Geometry GetGeometry() const; + + /** * @brief Sets the material to be used by this renderer * * @param[in] material The material to be used by this renderer @@ -110,6 +117,13 @@ public: void SetMaterial( Material& material ); /** + * @brief Gets the material used by this renderer + * + * @return The material used by the renderer + */ + Material GetMaterial() const; + + /** * @brief Set the depth index of this renderer * * Renderer with higher depth indices are rendered in front of other renderers with smaller values diff --git a/dali/public-api/shader-effects/material.cpp b/dali/public-api/shader-effects/material.cpp index 3a13458..c5ac258 100644 --- a/dali/public-api/shader-effects/material.cpp +++ b/dali/public-api/shader-effects/material.cpp @@ -81,6 +81,12 @@ void Material::RemoveSampler( std::size_t index ) GetImplementation(*this).RemoveSampler( index ); } +Sampler Material::GetSamplerAt( unsigned int index ) const +{ + Internal::Sampler* samplerPtr( GetImplementation(*this).GetSamplerAt(index) ); + return Dali::Sampler( samplerPtr ); +} + void Material::SetFaceCullingMode( FaceCullingMode cullingMode ) { GetImplementation(*this).SetFaceCullingMode( cullingMode ); diff --git a/dali/public-api/shader-effects/material.h b/dali/public-api/shader-effects/material.h index b6bcbe9..f5c21f7 100644 --- a/dali/public-api/shader-effects/material.h +++ b/dali/public-api/shader-effects/material.h @@ -155,6 +155,16 @@ public: void RemoveSampler( std::size_t index ); /** + * @brief Get the sampler at the given index for this material + * + * The index must be between 0 and GetNumberOfSamplers()-1 + * + * @param[in] index The index of the sampler + * @return The sampler at that index + */ + Sampler GetSamplerAt( unsigned int index ) const; + + /** * @brief Set the culling mode for this material * * Calling this function sets the properties CULLING_MODE -- 2.7.4