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