1 #ifndef __DALI_INTERNAL_RENDERABLE_ATTACHMENT_H__
2 #define __DALI_INTERNAL_RENDERABLE_ATTACHMENT_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/actors/renderable-actor.h>
23 #include <dali/public-api/actors/blending.h>
24 #include <dali/internal/common/blending-options.h>
25 #include <dali/internal/common/image-sampler.h>
26 #include <dali/internal/event/actor-attachments/actor-attachment-impl.h>
27 #include <dali/internal/event/effects/shader-declarations.h>
37 class RenderableAttachment;
41 * An base class for renderable actor attachments
43 class RenderableAttachment : public ActorAttachment
48 * Set the depth-sort modifier for the renderable.
49 * This modifies the back-to-front distance calculation, when rendering with transparency.
50 * This is useful for ordering transparent objects that are positioned close to each other.
51 * @param[in] modifier The depth-sort modifier.
53 void SetSortModifier(float modifier);
56 * From Renderable; Retrieve the depth-sort modifier for the renderable.
57 * @return The depth-sort modifier.
59 float GetSortModifier() const;
62 * Set the face-culling mode for this attachment.
63 * @param[in] mode The culling mode.
65 void SetCullFace(CullFaceMode mode);
68 * Retrieve the face-culling mode for this attachment.
69 * @return mode The culling mode.
71 CullFaceMode GetCullFace() const;
74 * @copydoc Dali::RenderableActor::SetBlendMode()
76 void SetBlendMode( BlendingMode::Type mode );
79 * @copydoc Dali::RenderableActor::GetBlendMode()
81 BlendingMode::Type GetBlendMode() const;
84 * @copydoc Dali::RenderableActor::SetBlendFunc()
86 void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
87 BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
90 * @copydoc Dali::RenderableActor::GetBlendFunc()
92 void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
93 BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
96 * @copydoc Dali::RenderableActor::SetBlendEquation()
98 void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
101 * @copydoc Dali::RenderableActor::GetBlendEquation()
103 void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
106 * @copydoc Dali::RenderableActor::SetBlendColor()
108 void SetBlendColor( const Vector4& color );
111 * @copydoc Dali::RenderableActor::GetBlendColor()
113 const Vector4& GetBlendColor() const;
116 * @copydoc Dali::RenderableActor::SetFilterMode()
118 void SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter );
121 * @copydoc Dali::RenderableActor::GetFilterMode()
123 void GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const;
126 * @copydoc Dali::RenderableActor::SetShaderEffect
128 void SetShaderEffect(ShaderEffect& effect);
131 * @copydoc Dali::RenderableActor::GetShaderEffect
133 ShaderEffectPtr GetShaderEffect() const;
136 * @copydoc Dali::RenderableActor::RemoveShaderEffect
138 void RemoveShaderEffect();
143 * Protected constructor; only base classes are instantiatable.
144 * @param[in] stage Used to send messages to scene-graph.
146 RenderableAttachment( Stage& stage );
149 * A reference counted object may only be deleted by calling Unreference()
151 virtual ~RenderableAttachment();
156 RenderableAttachment(const RenderableAttachment&);
159 RenderableAttachment& operator=(const RenderableAttachment& rhs);
162 * Helper for getting the scene-graph renderable attachment.
163 * @return The scene object.
165 const SceneGraph::RenderableAttachment& GetSceneAttachment() const;
168 * @copydoc Dali::Internal::ActorAttachment::OnStageConnection()
170 virtual void OnStageConnection();
173 * @copydoc Dali::Internal::ActorAttachment::OnStageDisconnection()
175 virtual void OnStageDisconnection();
178 * For derived classes, chained from OnStageConnection()
180 virtual void OnStageConnection2() = 0;
183 * For derived classes, chained from OnStageDisconnection()
185 virtual void OnStageDisconnection2() = 0;
188 * For derived classes to provide a corresponding scene-graph object
189 * @return The scene-object.
191 virtual const SceneGraph::RenderableAttachment& GetSceneObject() const = 0;
193 private: // Data, cached for actor-thread getters
195 ShaderEffectPtr mShaderEffect; ///< Optional referenced shader effect
196 BlendingOptions mBlendingOptions;
197 unsigned int mSamplerBitfield;
199 CullFaceMode mCullFaceMode:3; ///< cullface mode, 3 bits enough for 4 values
200 BlendingMode::Type mBlendingMode:2; ///< blending mode, 2 bits enough for 3 values
205 } // namespace Internal
209 #endif // __DALI_INTERNAL_RENDERABLE_ATTACHMENT_H__