License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-instruction.h
1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/math/matrix.h>
23 #include <dali/public-api/math/viewport.h>
24 #include <dali/internal/render/common/render-list.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 namespace SceneGraph
33 {
34 class RenderTracker;
35
36 /**
37  * A set of rendering instructions consisting of:
38  * - The list(s) of renderers sorted in the correct rendering order.
39  * - The camera related matrices to use when rendering.
40  * - An optional off-screen render target.
41  * There is one RenderInstruction per RenderTarget, all renderers of all layers
42  * get collated onto the single list of lists (mRenderLists)
43  */
44 class RenderInstruction
45 {
46 public:
47
48   /**
49    * Default constructor so this can be stored in STL containers
50    */
51   RenderInstruction();
52
53   /**
54    * Destructor
55    */
56   ~RenderInstruction();
57
58   /**
59    * Get the next free Renderlist
60    * @param capacityRequired in this list
61    * @return the renderlist
62    */
63   RenderList& GetNextFreeRenderList( size_t capacityRequired );
64
65   /**
66    * Inform the RenderInstruction that processing for this frame is complete
67    * This method should only be called from Update thread
68    */
69   void UpdateCompleted();
70
71   /**
72    * @return the count of active Renderlists
73    */
74   RenderListContainer::SizeType RenderListCount() const;
75
76   /**
77    * Return the renderlist at given index
78    * @pre index is inside the valid range of initialized lists
79    * @param index of list to return
80    * @return pointer to the renderlist
81    */
82   const RenderList* GetRenderList( RenderListContainer::SizeType index ) const;
83
84   /**
85    * Reset render-instruction
86    * render-lists are cleared but not released, while matrices and other settings reset in
87    * preparation for building a set of instructions for the renderer.
88    *
89    * @param[in] viewMatrix The view matrix.
90    * @param[in] projectionMatrix The projection matrix.
91    * @param[in] offscreenId A resource Id of an off-screen render target, or 0
92    * @param[in] viewport A pointer to a viewport, of NULL.
93    * @param[in] clearColor A pointer to a color to clear with, or NULL if no clear is required.
94    */
95   void Reset( const Matrix* viewMatrix,
96               const Matrix* projectionMatrix,
97               unsigned int offscreenId,
98               const Viewport* viewport,
99               const Vector4* clearColor );
100
101 private:
102
103   // Undefined
104   RenderInstruction(const RenderInstruction&);
105   // Undefined
106   RenderInstruction& operator=(const RenderInstruction& rhs);
107
108 public: // Data, TODO hide these
109
110   const Matrix* mViewMatrix;            ///< Pointer to a View Matrix (owned by camera)
111   const Matrix* mProjectionMatrix;      ///< Pointer to a Projection Matrix (owned by camera)
112   RenderTracker* mRenderTracker;        ///< Pointer to an optional tracker object (not owned)
113
114   Viewport mViewport;                   ///< Optional viewport
115   Vector4  mClearColor;                 ///< Optional color to clear with
116   bool     mIsViewportSet:1;            ///< Flag to determine whether the viewport is set
117   bool     mIsClearColorSet:1;          ///< Flag to determine whether the clear-color is set
118
119   unsigned int mOffscreenTextureId;     ///< Optional offscreen target
120
121 private: // Data
122
123   RenderListContainer mRenderLists;     ///< container of all render lists
124   RenderListContainer::SizeType mNextFreeRenderList;     ///< index for the next free render list
125
126 };
127
128 } // namespace SceneGraph
129
130 } // namespace Internal
131
132 } // namespace Dali
133
134 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_H__