Cleaning up the property framework; removal of duplicate methods and incorrect assers
[platform/core/uifw/dali-core.git] / dali / internal / event / effects / shader-effect-impl.h
index fcd62df..2faee40 100644 (file)
  */
 
 // INTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/images/image.h>
 #include <dali/public-api/shader-effects/shader-effect.h>
 #include <dali/internal/event/effects/shader-declarations.h>
 #include <dali/internal/event/common/proxy-object.h>
-#include <dali/internal/render/shaders/uniform-meta.h>
 #include <dali/internal/event/resources/resource-ticket.h>
 #include <dali/internal/render/shaders/shader.h>
 
@@ -34,8 +33,6 @@ namespace Dali
 namespace Internal
 {
 
-class ShaderFactory;
-
 namespace SceneGraph
 {
 class UpdateManager;
@@ -49,75 +46,20 @@ class UpdateManager;
 class ShaderEffect : public ProxyObject
 {
 public:
-
   typedef Dali::ShaderEffect::UniformCoordinateType UniformCoordinateType;
 
-  /**
-   * Create a new ShaderEffect with no programs
-   * @param hints GeometryHints to define the geometry of the rendered object
-   * @return A smart-pointer to a newly allocated shader effect.
-   */
-  static ShaderEffectPtr New(Dali::ShaderEffect::GeometryHints hints = Dali::ShaderEffect::HINT_NONE);
+  enum GeometryState
+  {
+    DOESNT_MODIFY_GEOMETRY,
+    MODIFIES_GEOMETRY
+  };
 
   /**
-   * Create a new ShaderEffect
-   * @param vertexShader code for the effect. If empty, the default version will be used
-   * @param fragmentShader code for the effect. If empty, the default version will be used
-   * @param type GeometryType
-   * @param hints GeometryHints to define the geometry of the rendered object
-   * @return A smart-pointer to a newly allocated shader effect.
-   */
-  static ShaderEffectPtr New( const std::string& vertexShader,
-                              const std::string& fragmentShader,
-                              GeometryType type,
-                              Dali::ShaderEffect::GeometryHints hints );
-  /**
-   * Create a new ShaderEffect
-   * @param vertexShaderPrefix code for the effect. It will be inserted before the default uniforms.
-   * @param vertexShader code for the effect. If empty, the default version will be used
-   * @param fragmentShaderPrefix code for the effect. It will be inserted before the default uniforms.
-   * @param fragmentShader code for the effect. If empty, the default version will be used
-   * @param type GeometryType
+   * Create a new ShaderEffect with no programs
    * @param hints GeometryHints to define the geometry of the rendered object
    * @return A smart-pointer to a newly allocated shader effect.
    */
-  static ShaderEffectPtr NewWithPrefix( const std::string& vertexShaderPrefix,
-                                        const std::string& vertexShader,
-                                        const std::string& fragmentShaderPrefix,
-                                        const std::string& fragmentShader,
-                                        GeometryType type,
-                                        Dali::ShaderEffect::GeometryHints hints );
-
-  /**
-   * Create a new ShaderEffect.
-   * If you pass in an empty string in the following arguments, the default version will be used instead.
-   * @param imageVertexShader code for the effect.
-   * @param imageFragmentShader code for the effect.
-   * @param textVertexShader code for the effect.
-   * @param textFragmentShader code for the effect.
-   * @param texturedMeshVertexShader code for the effect.
-   * @param texturedMeshFragmentShader code for the effect.
-   * @param meshVertexShader code for the effect.
-   * @param meshFragmentShader code for the effect.
-   * @param hints GeometryHints to define the geometry of the rendered object
-   * @return A handle to a shader effect
-   */
-  static ShaderEffectPtr New( const std::string& imageVertexShader,
-                              const std::string& imageFragmentShader,
-                              const std::string& textVertexShader,
-                              const std::string& textFragmentShader,
-                              const std::string& texturedMeshVertexShader,
-                              const std::string& texturedMeshFragmentShader,
-                              const std::string& meshVertexShader,
-                              const std::string& meshFragmentShader,
-                              Dali::ShaderEffect::GeometryHints hints );
-
-  /**
-   * Creates object with data from the property value map
-   * @param [in] map The property value map with fields such as 'vertex-filename' '..'
-   * @return a pointer to a newly created object.
-   */
-  static ShaderEffectPtr New( const Property::Value& map );
+  static ShaderEffectPtr New( Dali::ShaderEffect::GeometryHints hints = Dali::ShaderEffect::HINT_NONE );
 
   /**
    * @copydoc Dali::ShaderEffect::SetEffectImage
@@ -146,39 +88,39 @@ public:
    */
   const Dali::ShaderEffect::Extension& GetExtension() const;
 
-  enum FixedVertexShader
-  {
-    FLEXIBLE,
-    FIXED,
-  };
-
   /**
    * Add a GeometryType specific default program to this ShaderEffect
    * @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
    */
-  void SetProgram( GeometryType geometryType, ShaderSubTypes subType,
-                   const std::string& vertexSource, const std::string& fragmentSource,
-                   FixedVertexShader fixedVertexShader=FLEXIBLE);
+  void SetPrograms( GeometryType geometryType, const std::string& vertexSource, const std::string& fragmentSource );
 
   /**
    * Add a GeometryType specific 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] subType         The subtype, one of ShaderSubTypes.
    * @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
-   * @param[in] fixedVertexShader True if this shader doesn't change the vertices
    */
-  void SetProgram( GeometryType geometryType, ShaderSubTypes subType,
-                   const std::string& vertexPrefix, const std::string& fragmentPrefix,
-                   const std::string& vertexSource, const std::string& fragmentSource,
-                   FixedVertexShader fixedVertexShader=FLEXIBLE);
+  void SetPrograms( GeometryType geometryType,
+                    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
+   */
+  void SendProgramMessage( GeometryType geometryType, ShaderSubTypes subType,
+                           const std::string& vertexSource, const std::string& fragmentSource,
+                           bool modifiesGeometry );
 
   /**
    * Notify ShaderEffect that it's being used by an Actor.
@@ -193,11 +135,6 @@ public:
 public: // Default property extensions from ProxyObject
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::IsSceneObjectRemovable()
-   */
-  virtual bool IsSceneObjectRemovable() const;
-
-  /**
    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
    */
   virtual unsigned int GetDefaultPropertyCount() const;
@@ -210,7 +147,7 @@ public: // Default property extensions from ProxyObject
   /**
    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
    */
-  virtual const std::string& GetDefaultPropertyName( Property::Index index ) const;
+  virtual const char* GetDefaultPropertyName( Property::Index index ) const;
 
   /**
    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
@@ -248,9 +185,9 @@ public: // Default property extensions from ProxyObject
   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
 
   /**
-   * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
+   * @copydoc Dali::Internal::ProxyObject::NotifyScenePropertyInstalled()
    */
-  virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
+  virtual void NotifyScenePropertyInstalled( const SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
 
   /**
    * @copydoc Dali::Internal::ProxyObject::GetSceneObject()
@@ -272,7 +209,7 @@ protected:
   /**
    * Protected constructor.
    */
-  ShaderEffect( SceneGraph::UpdateManager& updateManager, ShaderFactory& shaderFactory, SceneGraph::Shader& sceneObject );
+  ShaderEffect( SceneGraph::UpdateManager& updateManager, Dali::ShaderEffect::GeometryHints hints );
 
   /**
    * A reference counted object may only be deleted by calling Unreference()
@@ -285,28 +222,17 @@ private:
   ShaderEffect( const ShaderEffect& );
   ShaderEffect& operator=( const ShaderEffect& rhs );
 
-  void OnImageLoaded( Dali::Image image ); ///< just a helper for image loaded callback
-
 private: // Data
 
-  SceneGraph::UpdateManager& mUpdateManager;            ///< reference to the update manager
-  ShaderFactory& mShaderFactory;                        ///< reference to the shader factory
-
-  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
-
+  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<ResourceTicketPtr>  mTickets;             ///< Collection of shader program tickets
-
-  unsigned int  mConnectionCount;                       ///< number of on-stage ImageActors using this shader effect
-
-  // Default properties
-  typedef std::map<std::string, Property::Index> DefaultPropertyLookup;
-  static DefaultPropertyLookup* mDefaultPropertyLookup;
 };
 
 } // namespace Internal