Changed ImageActor and to use new renderers and removed ImageAttachement.
[platform/core/uifw/dali-core.git] / dali / internal / event / effects / shader-effect-impl.h
index d69ced1..2443804 100644 (file)
 // INTERNAL INCLUDES
 #include <dali/public-api/images/image.h>
 #include <dali/public-api/shader-effects/shader-effect.h>
+#include <dali/internal/event/actors/actor-impl.h>
 #include <dali/internal/event/effects/shader-declarations.h>
 #include <dali/internal/event/common/object-impl.h>
 #include <dali/internal/event/resources/resource-ticket.h>
-#include <dali/internal/render/shaders/shader.h>
-
+#include <dali/internal/render/shaders/scene-graph-shader.h>
 
 namespace Dali
 {
@@ -48,12 +48,15 @@ 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
@@ -74,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
@@ -94,43 +96,56 @@ 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;}
+
+  /**
+   * Returns the fragment shader for this ShaderEffect
+   *
+   * @return Returns the fragment shader for this ShaderEffect
+   */
+  const std::string& GetFragmentShader() const {return mFragmentSource;}
+
+  /**
+   * Returns the fragment shader for this ShaderEffect
+   *
+   * @return Returns the fragment shader for this ShaderEffect
+   */
+  Dali::Image GetEffectImage() const {return mEffectImage;}
 
 public: // Default property extensions from Object
 
@@ -185,11 +200,6 @@ public: // Default property extensions from Object
   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
 
   /**
-   * @copydoc Dali::Internal::Object::NotifyScenePropertyInstalled()
-   */
-  virtual void NotifyScenePropertyInstalled( const SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
-
-  /**
    * @copydoc Dali::Internal::Object::GetSceneObject()
    */
   virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
@@ -225,15 +235,18 @@ private:
   ShaderEffect& operator=( const ShaderEffect& rhs );
 
 private: // Data
-  EventThreadServices& mEventThreadServices; ///< Event thread services, for sending messages
-  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
-  IntrusivePtr<Dali::ShaderEffect::Extension> mExtension;
-  std::vector<ResourceTicketPtr>  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
-  Dali::Vector< UniformCoordinateType > mCoordinateTypes; ///< cached to avoid sending tons of unnecessary messages
+  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
 
+  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