[3.0] Remove/move experimental features
[platform/core/uifw/dali-core.git] / dali / internal / event / effects / shader-effect-impl.h
index 690d779..0ee4e07 100644 (file)
 
 // INTERNAL INCLUDES
 #include <dali/public-api/images/image.h>
-#include <dali/public-api/shader-effects/shader-effect.h>
+#include <dali/devel-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/proxy-object.h>
-#include <dali/internal/event/resources/resource-ticket.h>
-#include <dali/internal/render/shaders/shader.h>
-
+#include <dali/internal/event/common/object-impl.h>
+#include <dali/internal/event/rendering/shader-impl.h>
 
 namespace Dali
 {
@@ -33,27 +32,16 @@ namespace Dali
 namespace Internal
 {
 
-namespace SceneGraph
-{
-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
-  {
-    DOESNT_MODIFY_GEOMETRY,
-    MODIFIES_GEOMETRY
-  };
-
   /**
    * Create a new ShaderEffect with no programs
    * @param hints GeometryHints to define the geometry of the rendered object
@@ -74,147 +62,220 @@ public:
                    UniformCoordinateType uniformCoordinateType );
 
   /**
-   * @copydoc Dali::ShaderEffect::AttachExtension()
-   */
-  void AttachExtension( Dali::ShaderEffect::Extension *object );
-
-  /**
-   * @copydoc Dali::ShaderEffect::GetExtension()
-   */
-  Dali::ShaderEffect::Extension& GetExtension();
-
-  /**
-   * @copydoc Dali::ShaderEffect::GetExtension() const
-   */
-  const Dali::ShaderEffect::Extension& GetExtension() const;
-
-  /**
    * Add a GeometryType specific default program to this ShaderEffect
    * @param[in] geometryType    The GeometryType rendered by the shader program
    * @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 Connect( ActorPtr actor );
+
+  /**
+   * @brief Notify ShaderEffect that an Actor is no longer using it.
+   *
+   * @param[in] actor The Actor that is disconnecting from this ShaderEffect
+   */
+  void Disconnect( ActorPtr actor );
+
+public:
+
+  /**
+   * Returns the shader for this ShaderEffect
+   *
+   * @return Returns the shader for this ShaderEffect
+   */
+  ShaderPtr GetShader() const { return mShader; }
+
+  /**
+   * Returns the geometry grid size.
+   *
+   * @param[in] size The pixel area size.
+   * @return Returns the geometry grid size
+   */
+  Vector2 GetGridSize( const Vector2& size );
+
+  /**
+   * Returns the effect image for this ShaderEffect
+   *
+   * @return Returns the effect image for this ShaderEffect
+   */
+  Dali::Image GetEffectImage() const { return mEffectImage; }
+
+public: //  override property functions from Object
+
+  /**
+   * @copydoc Dali::Handle::GetPropertyCount()
+   */
+  virtual unsigned int GetPropertyCount() const;
+
+  /**
+   * @copydoc Dali::Handle::GetPropertyName()
    */
-  void SendProgramMessage( GeometryType geometryType, ShaderSubTypes subType,
-                           const std::string& vertexSource, const std::string& fragmentSource,
-                           bool modifiesGeometry );
+  virtual std::string GetPropertyName( Property::Index index ) const;
 
   /**
-   * Notify ShaderEffect that it's being used by an Actor.
+   * @copydoc Dali::Handle::GetPropertyIndex()
    */
-  void Connect();
+  virtual Property::Index GetPropertyIndex( const std::string& name ) const;
 
   /**
-   * Notify ShaderEffect that an Actor is no longer using it.
+   * @copydoc Dali::Handle::IsPropertyWritable()
    */
-  void Disconnect();
+  virtual bool IsPropertyWritable( Property::Index index ) const;
 
-public: // Default property extensions from ProxyObject
+  /**
+   * @copydoc Dali::Handle::IsPropertyAnimatable()
+   */
+  virtual bool IsPropertyAnimatable( Property::Index index ) const;
+
+  /**
+   * @copydoc Dali::Handle::IsPropertyAConstraintInput()
+   */
+  virtual bool IsPropertyAConstraintInput( Property::Index index ) const;
+
+  /**
+   * @copydoc Dali::Handle::GetPropertyType()
+   */
+  virtual Property::Type GetPropertyType( Property::Index index ) const;
+
+  /**
+   * @copydoc Dali::Handle::SetProperty()
+   */
+  virtual void SetProperty( Property::Index index, const Property::Value& propertyValue );
+
+  /**
+   * @copydoc Dali::Handle::GetProperty()
+   */
+  virtual Property::Value GetProperty( Property::Index index ) const;
+
+  /**
+   * @copydoc Dali::Handle::GetPropertyIndices()
+   */
+  virtual void GetPropertyIndices( Property::IndexContainer& indices ) const;
+
+  /**
+   * @copydoc Dali::Handle::RegisterProperty()
+   */
+  virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue );
+
+  /**
+   * @copydoc Dali::Handle::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode)
+   */
+  virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode );
+
+  /**
+   * @copydoc Dali::Handle::AddPropertyNotification()
+   */
+  virtual Dali::PropertyNotification AddPropertyNotification( Property::Index index,
+                                                              int componentIndex,
+                                                              const Dali::PropertyCondition& condition );
+
+  /**
+   * @copydoc Dali::Handle::RemovePropertyNotification()
+   */
+  virtual void RemovePropertyNotification( Dali::PropertyNotification propertyNotification );
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::IsSceneObjectRemovable()
+   * @copydoc Dali::Handle::RemovePropertyNotifications()
    */
-  virtual bool IsSceneObjectRemovable() const;
+  virtual void RemovePropertyNotifications();
 
+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 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;
 
+  /**
+   * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
+   */
+  virtual int GetPropertyComponentIndex( Property::Index index ) const;
+
 protected:
 
   /**
    * Protected constructor.
+   * @param[in] hints Geometry hints
    */
-  ShaderEffect( SceneGraph::UpdateManager& updateManager, Dali::ShaderEffect::GeometryHints hints );
+  ShaderEffect( Dali::ShaderEffect::GeometryHints hints );
 
   /**
    * A reference counted object may only be deleted by calling Unreference()
@@ -228,15 +289,11 @@ private:
   ShaderEffect& operator=( const ShaderEffect& rhs );
 
 private: // Data
-
-  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
-  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
+  ShaderPtr               mShader;                        ///< The shader pointer
+  Dali::Image             mEffectImage;                   ///< The Client-side handle to the effect image
+  float                   mGridDensity;                  ///< The grid denisty
+  Dali::ShaderEffect::GeometryHints  mGeometryHints;     ///< shader geometry hints for building the geometry
 
 };