X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Feffects%2Fshader-effect-impl.h;h=2443804f7a4153eaa83b972f0996a935f7e502d4;hb=refs%2Fchanges%2F42%2F51642%2F3;hp=828e3c1a88ef1b285f672a70a57f6794c3ce0291;hpb=2a9893f1203708a7b5b55c9f91a4002e9a98a04f;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/effects/shader-effect-impl.h b/dali/internal/event/effects/shader-effect-impl.h index 828e3c1..2443804 100644 --- a/dali/internal/event/effects/shader-effect-impl.h +++ b/dali/internal/event/effects/shader-effect-impl.h @@ -19,14 +19,13 @@ */ // INTERNAL INCLUDES -#include +#include #include +#include #include -#include -#include +#include #include -#include - +#include namespace Dali { @@ -40,21 +39,24 @@ class UpdateManager; } /** - * An abstract base class for a shader effect proxy. + * An abstract base class for a shader effect object. * The corresponding scene-graph object is a collection of shader programs, * which can apply the same effect to different geometry types. */ -class ShaderEffect : public ProxyObject +class ShaderEffect : public Object { public: typedef Dali::ShaderEffect::UniformCoordinateType UniformCoordinateType; - enum GeometryState + struct Uniform { - DOESNT_MODIFY_GEOMETRY, - MODIFIES_GEOMETRY + std::string mName; + Property::Index mIndex; + Property::Value mValue; }; + typedef std::vector< Uniform > UniformArray; + /** * Create a new ShaderEffect with no programs * @param hints GeometryHints to define the geometry of the rendered object @@ -75,19 +77,18 @@ public: UniformCoordinateType uniformCoordinateType ); /** - * @copydoc Dali::ShaderEffect::AttachExtension() - */ - void AttachExtension( Dali::ShaderEffect::Extension *object ); - - /** - * @copydoc Dali::ShaderEffect::GetExtension() + * Returns the uniforms set for the shaders + * + * @return Returns and array of uniforms set for the shaders */ - Dali::ShaderEffect::Extension& GetExtension(); + const UniformArray& GetUniforms() {return mUniforms;} /** - * @copydoc Dali::ShaderEffect::GetExtension() const + * Returns the GeometryHints used + * + * @return Returns the GeometryHints used */ - const Dali::ShaderEffect::Extension& GetExtension() const; + Dali::ShaderEffect::GeometryHints GetGeometryHints() const {return mGeometryHints;} /** * Add a GeometryType specific default program to this ShaderEffect @@ -95,118 +96,121 @@ public: * @param[in] vertexSource The source code for the vertex shader * @param[in] fragmentSource The source code for the fragment shader */ - void SetPrograms( GeometryType geometryType, const std::string& vertexSource, const std::string& fragmentSource ); + void SetPrograms( const std::string& vertexSource, const std::string& fragmentSource ); /** - * Add a GeometryType specific default program to this ShaderEffect. + * Add a default program to this ShaderEffect. * This overload allows the optional prefixing for both the vertex and fragment shader. * A useful prefix may be shader \#defines for conditional compilation. - * @param[in] geometryType The GeometryType rendered by the shader program * @param[in] vertexPrefix The prefix source code for the vertex shader * @param[in] fragmentPrefix The prefix source code for the fragment shader * @param[in] vertexSource The source code for the vertex shader * @param[in] fragmentSource The source code for the fragment shader */ - void SetPrograms( GeometryType geometryType, - const std::string& vertexPrefix, const std::string& fragmentPrefix, + void SetPrograms( const std::string& vertexPrefix, const std::string& fragmentPrefix, const std::string& vertexSource, const std::string& fragmentSource ); /** - * Send shader program to scene-graph object. - * @param[in] geometryType The GeometryType rendered by the shader program - * @param[in] subType The subtype, one of ShaderSubTypes. - * @param[in] vertexSource The source code for the vertex shader - * @param[in] fragmentSource The source code for the fragment shader - * @param[in] modifiesGeometry True if the shader modifies geometry + * @brief Notify ShaderEffect that it's being used by an Actor. + * + * @param[in] actor The Actor that is connecting to this ShaderEffect */ - void SendProgramMessage( GeometryType geometryType, ShaderSubTypes subType, - const std::string& vertexSource, const std::string& fragmentSource, - bool modifiesGeometry ); + void Connect( ActorPtr actor ); /** - * Notify ShaderEffect that it's being used by an Actor. + * @brief Notify ShaderEffect that an Actor is no longer using it. + * + * @param[in] actor The Actor that is disconnecting from this ShaderEffect */ - void Connect(); + void Disconnect( ActorPtr actor ); + +public: /** - * Notify ShaderEffect that an Actor is no longer using it. + * Returns the vertex shader for this ShaderEffect + * + * @return Returns the vertex shader for this ShaderEffect */ - void Disconnect(); + const std::string& GetVertexShader() const {return mVertexSource;} -public: // Default property extensions from ProxyObject + /** + * Returns the fragment shader for this ShaderEffect + * + * @return Returns the fragment shader for this ShaderEffect + */ + const std::string& GetFragmentShader() const {return mFragmentSource;} /** - * @copydoc Dali::Internal::ProxyObject::IsSceneObjectRemovable() + * Returns the fragment shader for this ShaderEffect + * + * @return Returns the fragment shader for this ShaderEffect */ - virtual bool IsSceneObjectRemovable() const; + Dali::Image GetEffectImage() const {return mEffectImage;} + +public: // Default property extensions from Object /** - * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount() + * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() */ virtual unsigned int GetDefaultPropertyCount() const; /** - * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices() + * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() */ virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; /** - * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName() + * @copydoc Dali::Internal::Object::GetDefaultPropertyName() */ - virtual const std::string& GetDefaultPropertyName( Property::Index index ) const; + virtual const char* GetDefaultPropertyName( Property::Index index ) const; /** - * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() + * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() */ virtual Property::Index GetDefaultPropertyIndex( const std::string& name ) const; /** - * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable() + * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() */ virtual bool IsDefaultPropertyWritable( Property::Index index ) const; /** - * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable() + * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() */ virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const; /** - * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput() + * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() */ virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; /** - * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType() + * @copydoc Dali::Internal::Object::GetDefaultPropertyType() */ virtual Property::Type GetDefaultPropertyType( Property::Index index ) const; /** - * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty() + * @copydoc Dali::Internal::Object::SetDefaultProperty() */ virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ); /** - * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty() + * @copydoc Dali::Internal::Object::GetDefaultProperty() */ virtual Property::Value GetDefaultProperty( Property::Index index ) const; /** - * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty() - */ - virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index ); - - /** - * @copydoc Dali::Internal::ProxyObject::GetSceneObject() + * @copydoc Dali::Internal::Object::GetSceneObject() */ virtual const SceneGraph::PropertyOwner* GetSceneObject() const; /** - * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty() + * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty() */ virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const; /** - * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty() + * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty() */ virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const; @@ -214,8 +218,10 @@ protected: /** * Protected constructor. + * @param[in] eventThreadServices the interface to use for sending messages to the update thread + * @param[in] hints Geometry hints */ - ShaderEffect( SceneGraph::UpdateManager& updateManager, Dali::ShaderEffect::GeometryHints hints ); + ShaderEffect( EventThreadServices& eventThreadServices, Dali::ShaderEffect::GeometryHints hints ); /** * A reference counted object may only be deleted by calling Unreference() @@ -229,19 +235,18 @@ private: ShaderEffect& operator=( const ShaderEffect& rhs ); private: // Data + std::vector< ActorPtr > mConnectedActors; ///< The array of actors that are currently connected to this ShaderEffect + UniformArray mUniforms; ///< The array of uniforms set for this ShaderEffect + + std::string mVertexSource; ///< The vertex shader source + std::string mFragmentSource; ///< The fragment shader source + + EventThreadServices& mEventThreadServices; ///< Event thread services, for sending messages + SceneGraph::Shader* mSceneObject; ///< Pointer to the scene shader, should not be changed on this thread - SceneGraph::UpdateManager& mUpdateManager;///< reference to the update manager - SceneGraph::Shader* mSceneObject; ///< pointer to the scene shader, should not be changed on this thread - Dali::Image mImage; ///< Client-side handle for the effect image - CustomUniformMetaLookup mCustomMetadata; ///< Used for accessing metadata for custom Shader properties - IntrusivePtr mExtension; - std::vector mTickets; ///< Collection of shader program tickets - unsigned int mConnectionCount; ///< number of on-stage ImageActors using this shader effect - Dali::ShaderEffect::GeometryHints mGeometryHints; ///< shader geometry hints for building the geometry - - // Default properties - typedef std::map DefaultPropertyLookup; - static DefaultPropertyLookup* mDefaultPropertyLookup; + Dali::Image mEffectImage; ///< The Client-side handle to the effect image + Dali::ShaderEffect::GeometryHints mGeometryHints; ///< shader geometry hints for building the geometry + float mGridDensity; ///< The grid denisty }; } // namespace Internal