X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali%2Finternal%2Fevent%2Feffects%2Fshader-effect-impl.h;h=0ee4e07a4ac3aceb98c55d921296d07342c84e0b;hb=refs%2Fchanges%2F90%2F87990%2F6;hp=1ab4755638cf4f0ac1653ba30691250f62b8e30a;hpb=e124f6ebe78f401b1e47eaa85ab9104bc1fe2856;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 1ab4755..0ee4e07 100644 --- a/dali/internal/event/effects/shader-effect-impl.h +++ b/dali/internal/event/effects/shader-effect-impl.h @@ -1,31 +1,30 @@ #ifndef __DALI_INTERNAL_SHADER_EFFECT_H__ #define __DALI_INTERNAL_SHADER_EFFECT_H__ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // INTERNAL INCLUDES -#include -#include +#include +#include +#include #include -#include -#include -#include -#include - +#include +#include namespace Dali { @@ -33,22 +32,14 @@ namespace Dali namespace Internal { -class ShaderFactory; - -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; /** @@ -56,213 +47,235 @@ public: * @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); + static ShaderEffectPtr New( Dali::ShaderEffect::GeometryHints hints = Dali::ShaderEffect::HINT_NONE ); /** - * 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. + * @copydoc Dali::ShaderEffect::SetEffectImage */ - 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 - * @param hints GeometryHints to define the geometry of the rendered object - * @return A smart-pointer to a newly allocated shader effect. + void SetEffectImage( Dali::Image image ); + + /** + * @copydoc Dali::ShaderEffect::SetUniform( const std::string& name, Property::Value value, UniformCoordinateType uniformCoordinateType ) */ - 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 + void SetUniform( const std::string& name, + Property::Value value, + UniformCoordinateType uniformCoordinateType ); + + /** + * 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 */ - 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 ); + void SetPrograms( const std::string& vertexSource, const std::string& fragmentSource ); /** - * 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. + * 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] 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 */ - static ShaderEffectPtr New( const Property::Value& map ); + void SetPrograms( const std::string& vertexPrefix, const std::string& fragmentPrefix, + const std::string& vertexSource, const std::string& fragmentSource ); /** - * @copydoc Dali::ShaderEffect::SetEffectImage + * @brief Notify ShaderEffect that it's being used by an Actor. + * + * @param[in] actor The Actor that is connecting to this ShaderEffect */ - void SetEffectImage( Dali::Image image ); + void Connect( ActorPtr actor ); /** - * @copydoc Dali::ShaderEffect::SetUniform( const std::string& name, Property::Value value, UniformCoordinateType uniformCoordinateType ) + * @brief Notify ShaderEffect that an Actor is no longer using it. + * + * @param[in] actor The Actor that is disconnecting from this ShaderEffect */ - void SetUniform( const std::string& name, - Property::Value value, - UniformCoordinateType uniformCoordinateType ); + void Disconnect( ActorPtr actor ); + +public: /** - * @copydoc Dali::ShaderEffect::AttachExtension() + * Returns the shader for this ShaderEffect + * + * @return Returns the shader for this ShaderEffect */ - void AttachExtension( Dali::ShaderEffect::Extension *object ); + ShaderPtr GetShader() const { return mShader; } /** - * @copydoc Dali::ShaderEffect::GetExtension() + * Returns the geometry grid size. + * + * @param[in] size The pixel area size. + * @return Returns the geometry grid size */ - Dali::ShaderEffect::Extension& GetExtension(); + Vector2 GetGridSize( const Vector2& size ); /** - * @copydoc Dali::ShaderEffect::GetExtension() const + * Returns the effect image for this ShaderEffect + * + * @return Returns the effect image for this ShaderEffect */ - const Dali::ShaderEffect::Extension& GetExtension() const; + Dali::Image GetEffectImage() const { return mEffectImage; } + +public: // override property functions from Object /** - * 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 + * @copydoc Dali::Handle::GetPropertyCount() */ - void SetProgram( GeometryType geometryType, ShaderSubTypes subType, - const std::string& vertexSource, const std::string& fragmentSource ); + virtual unsigned int GetPropertyCount() const; /** - * 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 + * @copydoc Dali::Handle::GetPropertyName() + */ + virtual std::string GetPropertyName( Property::Index index ) const; + + /** + * @copydoc Dali::Handle::GetPropertyIndex() + */ + virtual Property::Index GetPropertyIndex( const std::string& name ) const; + + /** + * @copydoc Dali::Handle::IsPropertyWritable() + */ + virtual bool IsPropertyWritable( Property::Index index ) const; + + /** + * @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() */ - void SetProgram( GeometryType geometryType, ShaderSubTypes subType, - const std::string& vertexPrefix, const std::string& fragmentPrefix, - const std::string& vertexSource, const std::string& fragmentSource ); + virtual void SetProperty( Property::Index index, const Property::Value& propertyValue ); /** - * Notify ShaderEffect that it's being used by an Actor. + * @copydoc Dali::Handle::GetProperty() */ - void Connect(); + virtual Property::Value GetProperty( Property::Index index ) const; /** - * Notify ShaderEffect that an Actor is no longer using it. + * @copydoc Dali::Handle::GetPropertyIndices() */ - void Disconnect(); + virtual void GetPropertyIndices( Property::IndexContainer& indices ) const; -public: // Default property extensions from ProxyObject + /** + * @copydoc Dali::Handle::RegisterProperty() + */ + virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue ); /** - * @copydoc Dali::Internal::ProxyObject::IsSceneObjectRemovable() + * @copydoc Dali::Handle::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode) */ - virtual bool IsSceneObjectRemovable() const; + virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode ); /** - * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount() + * @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::Handle::RemovePropertyNotifications() + */ + virtual void RemovePropertyNotifications(); + +public: // Default property extensions from Object + /** + * @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; + /** + * @copydoc Dali::Internal::Object::GetPropertyComponentIndex() + */ + virtual int GetPropertyComponentIndex( Property::Index index ) const; + protected: /** * Protected constructor. + * @param[in] hints Geometry hints */ - ShaderEffect( SceneGraph::UpdateManager& updateManager, ShaderFactory& shaderFactory, SceneGraph::Shader& sceneObject ); + ShaderEffect( Dali::ShaderEffect::GeometryHints hints ); /** * A reference counted object may only be deleted by calling Unreference() @@ -275,28 +288,13 @@ private: ShaderEffect( const ShaderEffect& ); ShaderEffect& operator=( const ShaderEffect& rhs ); - void OnImageLoaded( Dali::Image image ); ///< just a helper for image loaded callback - private: // Data + 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 - 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 - - IntrusivePtr mExtension; - - std::vector mTickets; ///< Collection of shader program tickets - - unsigned int mConnectionCount; ///< number of on-stage ImageActors using this shader effect - - // Default properties - typedef std::map DefaultPropertyLookup; - static DefaultPropertyLookup* mDefaultPropertyLookup; }; } // namespace Internal