Removing rendering backend
[platform/core/uifw/dali-core.git] / dali / internal / update / rendering / 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) 2018 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/update/render-tasks/scene-graph-camera.h>
25 #include <dali/internal/update/rendering/render-list.h>
26 #include <dali/internal/update/rendering/scene-graph-frame-buffer.h>
27
28 namespace Dali
29 {
30 namespace Internal
31 {
32 namespace SceneGraph
33 {
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, or null if the index is out of bounds.
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] camera to use to get view and projection matrices.
89    * @param[in] offscreenId A resource Id of an off-screen render target, or 0
90    * @param[in] viewport A pointer to a viewport, of NULL.
91    * @param[in] clearColor A pointer to a color to clear with, or NULL if no clear is required.
92    */
93   void Reset( Camera* camera,
94               SceneGraph::FrameBuffer* frameBuffer,
95               const Viewport* viewport,
96               const Vector4* clearColor );
97
98   /**
99    * Get the view matrix for rendering
100    * @param index of the rendering side
101    * @return the view matrix
102    */
103   const Matrix* GetViewMatrix( BufferIndex index ) const
104   {
105     // inlined as this is called once per frame per render instruction
106     return &mCamera->GetViewMatrix( index );
107   }
108
109   /**
110    * Get the projection matrix for rendering
111    * @param index of the rendering side
112    * @return the projection matrix
113    */
114   const Matrix* GetProjectionMatrix( BufferIndex index ) const
115   {
116     // inlined as this is called once per frame per render instruction
117     return &mCamera->GetProjectionMatrix( index );
118   }
119
120 private:
121
122   // Undefined
123   RenderInstruction(const RenderInstruction&);
124   // Undefined
125   RenderInstruction& operator=(const RenderInstruction& rhs);
126
127 public: // Data
128
129   Viewport mViewport;                   ///< Optional viewport
130   Vector4  mClearColor;                 ///< Optional color to clear with
131   bool     mIsViewportSet:1;            ///< Flag to determine whether the viewport is set
132   bool     mIsClearColorSet:1;          ///< Flag to determine whether the clearColor is set
133   bool     mIgnoreRenderToFbo:1;        ///< Whether to ignore the render to FBO option (used to measure the performance above 60 fps)
134
135   SceneGraph::FrameBuffer* mFrameBuffer;
136
137 private: // Data
138
139   Camera* mCamera;  ///< camera that is used
140   RenderListContainer mRenderLists;     ///< container of all render lists
141   RenderListContainer::SizeType mNextFreeRenderList;     ///< index for the next free render list
142
143 };
144
145 } // namespace SceneGraph
146
147 } // namespace Internal
148
149 } // namespace Dali
150
151 #endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_INSTRUCTION_H