1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDERER_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_RENDERER_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/math/matrix.h>
23 #include <dali/public-api/math/vector4.h>
24 #include <dali/internal/common/blending-options.h>
25 #include <dali/internal/common/message.h>
26 #include <dali/internal/render/gl-resources/gl-resource-owner.h>
27 #include <dali/internal/update/common/double-buffered.h>
28 #include <dali/internal/render/renderers/scene-graph-renderer-declarations.h>
29 #include <dali/integration-api/debug.h>
30 #include <dali/internal/common/type-abstraction-enums.h>
42 class SceneController;
45 class RenderDataProvider;
48 * Renderers are used to render images, text, & meshes etc.
49 * These objects are used during RenderManager::Render(), so properties modified during
50 * the Update must either be double-buffered, or set via a message added to the RenderQueue.
52 class Renderer : public GlResourceOwner
57 * Second-phase construction.
58 * This is called when the renderer is inside render thread
59 * @param[in] context to use
60 * @param[in] textureCache to use
62 void Initialize( Context& context, TextureCache& textureCache );
70 * Set the Shader used to render.
71 * @param[in] shader The shader used to render.
73 void SetShader( Shader* shader );
76 * Set whether the ImageRenderer should use blending
77 * @param[in] useBlend True if blending should be used.
79 void SetUseBlend( bool useBlend );
82 * Set the blending options.
83 * @param[in] options A bitmask of blending options.
85 void SetBlendingOptions( unsigned int options );
88 * Set the blend color.
89 * @param[in] color The new blend-color.
91 void SetBlendColor( const Vector4& color );
94 * Set the face-culling mode.
95 * @param[in] mode The face-culling mode.
97 void SetCullFace( CullFaceMode mode );
100 * Query whether the derived type of Renderer requires depth testing.
101 * @return True if the renderer requires depth testing.
103 virtual bool RequiresDepthTest() const = 0;
106 * Called to render during RenderManager::Render().
107 * @param[in] bufferIndex The index of the previous update buffer.
108 * @param[in] modelViewMatrix The model-view matrix.
109 * @param[in] viewMatrix The view matrix.
110 * @param[in] projectionMatrix The projection matrix.
111 * @param[in] frametime The elapsed time between the last two updates.
113 void Render( BufferIndex bufferIndex,
114 const Matrix& modelViewMatrix,
115 const Matrix& viewMatrix,
116 const Matrix& projectionMatrix,
122 * Protected constructor; only derived classes can be instantiated.
123 * @param dataprovider for rendering
125 Renderer( RenderDataProvider& dataprovider );
130 Renderer( const Renderer& );
133 Renderer& operator=( const Renderer& rhs );
136 * Checks if renderer's resources are ready to be used.
138 * @return \e true if they are. Otherwise \e false.
140 virtual bool CheckResources() = 0;
143 * Called from Render; implemented in derived classes.
144 * @param[in] bufferIndex The index of the previous update buffer.
145 * @param[in] modelViewMatrix The model-view matrix.
146 * @param[in] modelMatrix The model matrix.
147 * @param[in] viewMatrix The view matrix.
148 * @param[in] projectionMatrix The projection matrix.
149 * @param[in] color to use
151 virtual void DoRender( BufferIndex bufferIndex, const Matrix& modelViewMatrix, const Matrix& modelMatrix, const Matrix& viewMatrix, const Matrix& projectionMatrix, const Vector4& color ) = 0;
155 RenderDataProvider& mDataProvider;
157 TextureCache* mTextureCache;
162 BlendingOptions mBlendingOptions;
163 bool mUseBlend:1; ///< True if blending should be enabled, 1 bit is enough
164 CullFaceMode mCullFaceMode:3; ///< cullface enum, 3 bits is enough
168 } // namespace SceneGraph
170 } // namespace Internal
174 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDERER_H__