[Tizen] Implement partial update
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-algorithms.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/render/common/render-algorithms.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/render/common/render-debug.h>
23 #include <dali/internal/render/common/render-list.h>
24 #include <dali/internal/render/common/render-instruction.h>
25 #include <dali/internal/render/gl-resources/context.h>
26 #include <dali/internal/render/renderers/render-renderer.h>
27 #include <dali/internal/update/nodes/scene-graph-layer.h>
28
29 using Dali::Internal::SceneGraph::RenderItem;
30 using Dali::Internal::SceneGraph::RenderList;
31 using Dali::Internal::SceneGraph::RenderListContainer;
32 using Dali::Internal::SceneGraph::RenderInstruction;
33
34 namespace Dali
35 {
36
37 namespace Internal
38 {
39
40 namespace Render
41 {
42
43 namespace
44 {
45
46 // Table for fast look-up of Dali::DepthFunction enum to a GL depth function.
47 // Note: These MUST be in the same order as Dali::DepthFunction enum.
48 const int DaliDepthToGLDepthTable[]  = { GL_NEVER, GL_ALWAYS, GL_LESS, GL_GREATER, GL_EQUAL, GL_NOTEQUAL, GL_LEQUAL, GL_GEQUAL };
49
50 // Table for fast look-up of Dali::StencilFunction enum to a GL stencil function.
51 // Note: These MUST be in the same order as Dali::StencilFunction enum.
52 const int DaliStencilFunctionToGL[]  = { GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, GL_ALWAYS };
53
54 // Table for fast look-up of Dali::StencilOperation enum to a GL stencil operation.
55 // Note: These MUST be in the same order as Dali::StencilOperation enum.
56 const int DaliStencilOperationToGL[] = { GL_ZERO, GL_KEEP, GL_REPLACE, GL_INCR, GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP };
57
58 /**
59  * @brief Find the intersection of two AABB rectangles.
60  * This is a logical AND operation. IE. The intersection is the area overlapped by both rectangles.
61  * @param[in]     aabbA                  Rectangle A
62  * @param[in]     aabbB                  Rectangle B
63  * @return                               The intersection of rectangle A & B (result is a rectangle)
64  */
65 inline ClippingBox IntersectAABB( const ClippingBox& aabbA, const ClippingBox& aabbB )
66 {
67   ClippingBox intersectionBox;
68
69   // First calculate the largest starting positions in X and Y.
70   intersectionBox.x = std::max( aabbA.x, aabbB.x );
71   intersectionBox.y = std::max( aabbA.y, aabbB.y );
72
73   // Now calculate the smallest ending positions, and take the largest starting
74   // positions from the result, to get the width and height respectively.
75   // If the two boxes do not intersect at all, then we need a 0 width and height clipping area.
76   // We use max here to clamp both width and height to >= 0 for this use-case.
77   intersectionBox.width =  std::max( std::min( aabbA.x + aabbA.width,  aabbB.x + aabbB.width  ) - intersectionBox.x, 0 );
78   intersectionBox.height = std::max( std::min( aabbA.y + aabbA.height, aabbB.y + aabbB.height ) - intersectionBox.y, 0 );
79
80   return intersectionBox;
81 }
82
83 /**
84  * @brief Set up the stencil and color buffer for automatic clipping (StencilMode::AUTO).
85  * @param[in]     item                     The current RenderItem about to be rendered
86  * @param[in]     context                  The context
87  * @param[in/out] lastClippingDepth        The stencil depth of the last renderer drawn.
88  * @param[in/out] lastClippingId           The clipping ID of the last renderer drawn.
89  */
90 inline void SetupStencilClipping( const RenderItem& item, Context& context, uint32_t& lastClippingDepth, uint32_t& lastClippingId )
91 {
92   const Dali::Internal::SceneGraph::Node* node = item.mNode;
93   const uint32_t clippingId = node->GetClippingId();
94   // If there is no clipping Id, then either we haven't reached a clipping Node yet, or there aren't any.
95   // Either way we can skip clipping setup for this renderer.
96   if( clippingId == 0u )
97   {
98     // Exit immediately if there are no clipping actions to perform (EG. we have not yet hit a clipping node).
99     context.EnableStencilBuffer( false );
100     return;
101   }
102
103   context.EnableStencilBuffer( true );
104
105   const uint32_t clippingDepth = node->GetClippingDepth();
106
107   // Pre-calculate a mask which has all bits set up to and including the current clipping depth.
108   // EG. If depth is 3, the mask would be "111" in binary.
109   const uint32_t currentDepthMask = ( 1u << clippingDepth ) - 1u;
110
111   // Are we are writing to the stencil buffer?
112   if( item.mNode->GetClippingMode() == Dali::ClippingMode::CLIP_CHILDREN )
113   {
114     // We are writing to the stencil buffer.
115     // If clipping Id is 1, this is the first clipping renderer within this render-list.
116     if( clippingId == 1u )
117     {
118       // We are enabling the stencil-buffer for the first time within this render list.
119       // Clear the buffer at this point.
120       context.StencilMask( 0xff );
121       context.Clear( GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES );
122     }
123     else if( ( clippingDepth < lastClippingDepth ) ||
124            ( ( clippingDepth == lastClippingDepth ) && ( clippingId > lastClippingId ) ) )
125     {
126       // The above if() statement tests if we need to clear some (not all) stencil bit-planes.
127       // We need to do this if either of the following are true:
128       //   1) We traverse up the scene-graph to a previous stencil depth
129       //   2) We are at the same stencil depth but the clipping Id has increased.
130       //
131       // This calculation takes the new depth to move to, and creates an inverse-mask of that number of consecutive bits.
132       // This has the effect of clearing everything except the bit-planes up to (and including) our current depth.
133       const uint32_t stencilClearMask = ( currentDepthMask >> 1u ) ^ 0xff;
134
135       context.StencilMask( stencilClearMask );
136       context.Clear( GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES );
137     }
138
139     // We keep track of the last clipping Id and depth so we can determine when we are
140     // moving back up the scene graph and require some of the stencil bit-planes to be deleted.
141     lastClippingDepth = clippingDepth;
142     lastClippingId = clippingId;
143
144     // We only ever write to bit-planes up to the current depth as we may need
145     // to erase individual bit-planes and revert to a previous clipping area.
146     // Our reference value for testing (in StencilFunc) is written to to the buffer, but we actually
147     // want to test a different value. IE. All the bit-planes up to but not including the current depth.
148     // So we use the Mask parameter of StencilFunc to mask off the top bit-plane when testing.
149     // Here we create our test mask to innore the top bit of the reference test value.
150     // As the mask is made up of contiguous "1" values, we can do this quickly with a bit-shift.
151     const uint32_t testMask = currentDepthMask >> 1u;
152
153     context.StencilFunc( GL_EQUAL, currentDepthMask, testMask ); // Test against existing stencil bit-planes. All must match up to (but not including) this depth.
154     context.StencilMask( currentDepthMask );                     // Write to the new stencil bit-plane (the other previous bit-planes are also written to).
155     context.StencilOp( GL_KEEP, GL_REPLACE, GL_REPLACE );
156   }
157   else
158   {
159     // We are reading from the stencil buffer. Set up the stencil accordingly
160     // This calculation sets all the bits up to the current depth bit.
161     // This has the effect of testing that the pixel being written to exists in every bit-plane up to the current depth.
162     context.StencilFunc( GL_EQUAL, currentDepthMask, 0xff );
163     context.StencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
164   }
165 }
166
167 /**
168  * @brief Sets up the depth buffer for reading and writing based on the current render item.
169  * The items read and write mode are used if specified.
170  *  - If AUTO is selected for reading, the decision will be based on the Layer Behavior.
171  *  - If AUTO is selected for writing, the decision will be based on the items opacity.
172  * @param[in]     item                The RenderItem to set up the depth buffer for.
173  * @param[in]     context             The context used to execute GL commands.
174  * @param[in]     depthTestEnabled    True if depth testing has been enabled.
175  * @param[in/out] firstDepthBufferUse Initialize to true on the first call, this method will set it to false afterwards.
176  */
177 inline void SetupDepthBuffer( const RenderItem& item, Context& context, bool depthTestEnabled, bool& firstDepthBufferUse )
178 {
179   // Set up whether or not to write to the depth buffer.
180   const DepthWriteMode::Type depthWriteMode = item.mRenderer->GetDepthWriteMode();
181   // Most common mode (AUTO) is tested first.
182   const bool enableDepthWrite = ( ( depthWriteMode == DepthWriteMode::AUTO ) && depthTestEnabled && item.mIsOpaque ) ||
183                                 ( depthWriteMode == DepthWriteMode::ON );
184
185   // Set up whether or not to read from (test) the depth buffer.
186   const DepthTestMode::Type depthTestMode = item.mRenderer->GetDepthTestMode();
187   // Most common mode (AUTO) is tested first.
188   const bool enableDepthTest = ( ( depthTestMode == DepthTestMode::AUTO ) && depthTestEnabled ) ||
189                                ( depthTestMode == DepthTestMode::ON );
190
191   // Is the depth buffer in use?
192   if( enableDepthWrite || enableDepthTest )
193   {
194     // The depth buffer must be enabled if either reading or writing.
195     context.EnableDepthBuffer( true );
196
197     // Look-up the GL depth function from the Dali::DepthFunction enum, and set it.
198     context.DepthFunc( DaliDepthToGLDepthTable[ item.mRenderer->GetDepthFunction() ] );
199
200     // If this is the first use of the depth buffer this RenderTask, perform a clear.
201     // Note: We could do this at the beginning of the RenderTask and rely on the
202     // context cache to ignore the clear if not required, but, we would have to enable
203     // the depth buffer to do so, which could be a redundant enable.
204     if( DALI_UNLIKELY( firstDepthBufferUse ) )
205     {
206       // This is the first time the depth buffer is being written to or read.
207       firstDepthBufferUse = false;
208
209       // Note: The buffer will only be cleared if written to since a previous clear.
210       context.DepthMask( true );
211       context.Clear( GL_DEPTH_BUFFER_BIT, Context::CHECK_CACHED_VALUES );
212     }
213
214     // Set up the depth mask based on our depth write setting.
215     context.DepthMask( enableDepthWrite );
216   }
217   else
218   {
219     // The depth buffer is not being used by this renderer, so we must disable it to stop it being tested.
220     context.EnableDepthBuffer( false );
221   }
222 }
223
224 } // Unnamed namespace
225
226
227 /**
228  * @brief This method is responsible for making decisions on when to apply and unapply scissor clipping, and what rectangular dimensions should be used.
229  * A stack of scissor clips at each depth of clipping is maintained, so it can be applied and unapplied.
230  * As the clips are hierarchical, this RenderItems AABB is clipped against the current "active" scissor bounds via an intersection operation.
231  * @param[in]     item                     The current RenderItem about to be rendered
232  * @param[in]     context                  The context
233  */
234 inline void RenderAlgorithms::SetupScissorClipping( const RenderItem& item, Context& context, int orientation )
235 {
236   // Get the number of child scissors in the stack (do not include layer or root box).
237   size_t childStackDepth = mScissorStack.size() - 1u;
238   const uint32_t scissorDepth = item.mNode->GetScissorDepth();
239   const bool clippingNode = item.mNode->GetClippingMode() == Dali::ClippingMode::CLIP_TO_BOUNDING_BOX;
240   bool traversedUpTree = false;
241
242   // If we are using scissor clipping and we are at the same depth (or less), we need to undo previous clips.
243   // We do this by traversing up the scissor clip stack and then apply the appropriate clip for the current render item.
244   // To know this, we use clippingDepth. This value is set on *every* node, but only increased as clipping nodes are hit depth-wise.
245   // So we know if we are at depth 4 and the stackDepth is 5, that we have gone up.
246   // If the depth is the same then we are effectively part of a different sub-tree from the parent, we must also remove the current clip.
247   // Note: Stack depth must always be at least 1, as we will have the layer or stage size as the root value.
248   if( ( childStackDepth > 0u ) && ( scissorDepth < childStackDepth ) )
249   {
250     while( scissorDepth < childStackDepth )
251     {
252       mScissorStack.pop_back();
253       --childStackDepth;
254     }
255
256     // We traversed up the tree, we need to apply a new scissor rectangle (unless we are at the root).
257     traversedUpTree = true;
258   }
259   if( clippingNode && childStackDepth > 0u && childStackDepth == scissorDepth ) // case of sibling clip area
260   {
261     mScissorStack.pop_back();
262     --childStackDepth;
263   }
264
265   // If we are on a clipping node, or we have traveled up the tree and gone back past a clipping node, may need to apply a new scissor clip.
266   if( clippingNode || traversedUpTree )
267   {
268     // First, check if we are a clipping node.
269     if( clippingNode )
270     {
271       // This is a clipping node. We generate the AABB for this node and intersect it with the previous intersection further up the tree.
272
273       // Get the AABB bounding box for the current render item.
274       const ClippingBox scissorBox( item.CalculateViewportSpaceAABB( mViewportRectangle.width, mViewportRectangle.height ) );
275
276       // Get the AABB for the parent item that we must intersect with.
277       const ClippingBox& parentBox( mScissorStack.back() );
278
279       // We must reduce the clipping area based on the parents area to allow nested clips. This is a set intersection function.
280       // We add the new scissor box to the stack so we can return to it if needed.
281       mScissorStack.emplace_back( IntersectAABB( parentBox, scissorBox ) );
282     }
283
284     // The scissor test is enabled if we have any children on the stack, OR, if there are none but it is a user specified layer scissor box.
285     // IE. It is not enabled if we are at the top of the stack and the layer does not have a specified clipping box.
286     const bool scissorEnabled = ( mScissorStack.size() > 0u ) || mHasLayerScissor;
287
288     // Enable the scissor test based on the above calculation
289     context.SetScissorTest( scissorEnabled );
290
291     // If scissor is enabled, we use the calculated screen-space coordinates (now in the stack).
292     if( scissorEnabled )
293     {
294       ClippingBox useScissorBox( mScissorStack.back() );
295       GLint x = useScissorBox.x;
296       GLint y = useScissorBox.y;
297       if( orientation == 90 )
298       {
299         x = mViewportRectangle.height - (useScissorBox.y + useScissorBox.height);
300         y = useScissorBox.x;
301         context.Scissor( x, y, useScissorBox.height, useScissorBox.width );
302       }
303       else if( orientation == 180 )
304       {
305         x = mViewportRectangle.width - (useScissorBox.x + useScissorBox.width);
306         y = mViewportRectangle.height - (useScissorBox.y + useScissorBox.height);
307         context.Scissor( x, y, useScissorBox.width, useScissorBox.height );
308       }
309       else if( orientation == 270 )
310       {
311         x = useScissorBox.y;
312         y = mViewportRectangle.width - (useScissorBox.x + useScissorBox.width);
313         context.Scissor( x, y, useScissorBox.height, useScissorBox.width );
314       }
315       else
316       {
317         context.Scissor( x, y, useScissorBox.width, useScissorBox.height );
318       }
319     }
320   }
321 }
322
323 inline void RenderAlgorithms::SetupClipping( const RenderItem& item,
324                                              Context& context,
325                                              bool& usedStencilBuffer,
326                                              uint32_t& lastClippingDepth,
327                                              uint32_t& lastClippingId,
328                                              Integration::StencilBufferAvailable stencilBufferAvailable,
329                                              int orientation )
330 {
331   RenderMode::Type renderMode = RenderMode::AUTO;
332   const Renderer *renderer = item.mRenderer;
333   if( renderer )
334   {
335     renderMode = renderer->GetRenderMode();
336   }
337
338   // Setup the stencil using either the automatic clipping feature, or, the manual per-renderer stencil API.
339   // Note: This switch is in order of most likely value first.
340   switch( renderMode )
341   {
342     case RenderMode::AUTO:
343     {
344       // Turn the color buffer on as we always want to render this renderer, regardless of clipping hierarchy.
345       context.ColorMask( true );
346
347       // The automatic clipping feature will manage the scissor and stencil functions, only if stencil buffer is available for the latter.
348       // As both scissor and stencil clips can be nested, we may be simultaneously traversing up the scissor tree, requiring a scissor to be un-done. Whilst simultaneously adding a new stencil clip.
349       // We process both based on our current and old clipping depths for each mode.
350       // Both methods with return rapidly if there is nothing to be done for that type of clipping.
351       SetupScissorClipping( item, context, orientation );
352
353       if( stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE )
354       {
355         SetupStencilClipping( item, context, lastClippingDepth, lastClippingId );
356       }
357       break;
358     }
359
360     case RenderMode::NONE:
361     case RenderMode::COLOR:
362     {
363       // No clipping is performed for these modes.
364       // Note: We do not turn off scissor clipping as it may be used for the whole layer.
365       // The stencil buffer will not be used at all, but we only need to disable it if it's available.
366       if( stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE )
367       {
368         context.EnableStencilBuffer( false );
369       }
370
371       // Setup the color buffer based on the RenderMode.
372       context.ColorMask( renderMode == RenderMode::COLOR );
373       break;
374     }
375
376     case RenderMode::STENCIL:
377     case RenderMode::COLOR_STENCIL:
378     {
379       if( stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE )
380       {
381         // We are using the low-level Renderer Stencil API.
382         // The stencil buffer must be enabled for every renderer with stencil mode on, as renderers in between can disable it.
383         // Note: As the command state is cached, it is only sent when needed.
384         context.EnableStencilBuffer( true );
385
386         // Setup the color buffer based on the RenderMode.
387         context.ColorMask( renderMode == RenderMode::COLOR_STENCIL );
388
389         // If this is the first use of the stencil buffer within this RenderList, clear it (this avoids unnecessary clears).
390         if( !usedStencilBuffer )
391         {
392           context.Clear( GL_STENCIL_BUFFER_BIT, Context::CHECK_CACHED_VALUES );
393           usedStencilBuffer = true;
394         }
395
396         // Setup the stencil buffer based on the renderers properties.
397         context.StencilFunc( DaliStencilFunctionToGL[ renderer->GetStencilFunction() ],
398             renderer->GetStencilFunctionReference(),
399             renderer->GetStencilFunctionMask() );
400         context.StencilOp( DaliStencilOperationToGL[ renderer->GetStencilOperationOnFail() ],
401             DaliStencilOperationToGL[ renderer->GetStencilOperationOnZFail() ],
402             DaliStencilOperationToGL[ renderer->GetStencilOperationOnZPass() ] );
403         context.StencilMask( renderer->GetStencilMask() );
404       }
405       break;
406     }
407   }
408 }
409
410 inline void RenderAlgorithms::ProcessRenderList( const RenderList& renderList,
411                                                  Context& context,
412                                                  BufferIndex bufferIndex,
413                                                  const Matrix& viewMatrix,
414                                                  const Matrix& projectionMatrix,
415                                                  Integration::DepthBufferAvailable depthBufferAvailable,
416                                                  Integration::StencilBufferAvailable stencilBufferAvailable,
417                                                  Vector<GLuint>& boundTextures,
418                                                  int orientation,
419                                                  Dali::ClippingBox& scissorBox )
420 {
421   DALI_PRINT_RENDER_LIST( renderList );
422
423   // Note: The depth buffer is enabled or disabled on a per-renderer basis.
424   // Here we pre-calculate the value to use if these modes are set to AUTO.
425   const bool autoDepthTestMode(  ( depthBufferAvailable == Integration::DepthBufferAvailable::TRUE ) &&
426                                 !( renderList.GetSourceLayer()->IsDepthTestDisabled() ) &&
427                                  renderList.HasColorRenderItems() );
428   const std::size_t count = renderList.Count();
429   uint32_t lastClippingDepth( 0u );
430   uint32_t lastClippingId( 0u );
431   bool usedStencilBuffer( false );
432   bool firstDepthBufferUse( true );
433   mViewportRectangle = context.GetViewport();
434   mHasLayerScissor = false;
435
436   if( orientation == 90 || orientation == 270 )
437   {
438     int temp = mViewportRectangle.width;
439     mViewportRectangle.width = mViewportRectangle.height;
440     mViewportRectangle.height = temp;
441   }
442
443   // Setup Scissor testing (for both viewport and per-node scissor)
444   mScissorStack.clear();
445   if( renderList.IsClipping() )
446   {
447     context.SetScissorTest( true );
448     const ClippingBox& layerScissorBox = renderList.GetClippingBox();
449     GLint x = layerScissorBox.x;
450     GLint y = layerScissorBox.y;
451
452     if( orientation == 90 )
453     {
454       x = mViewportRectangle.height - (layerScissorBox.y + layerScissorBox.height);
455       y = layerScissorBox.x;
456       context.Scissor( x, y, layerScissorBox.height, layerScissorBox.width );
457     }
458     else if( orientation == 180 )
459     {
460       x = mViewportRectangle.width - (layerScissorBox.x + layerScissorBox.width);
461       y = mViewportRectangle.height - (layerScissorBox.y + layerScissorBox.height);
462       context.Scissor( x, y, layerScissorBox.width, layerScissorBox.height );
463     }
464     else if( orientation == 270 )
465     {
466       x = layerScissorBox.y;
467       y = mViewportRectangle.width - (layerScissorBox.x + layerScissorBox.width);
468       context.Scissor( x, y, layerScissorBox.height, layerScissorBox.width );
469     }
470     else
471     {
472       context.Scissor( x, y, layerScissorBox.width, layerScissorBox.height );
473     }
474
475     mScissorStack.push_back( layerScissorBox );
476     mHasLayerScissor = true;
477   }
478   else if ( !scissorBox.IsEmpty() )
479   {
480     context.SetScissorTest( true );
481     context.Scissor( scissorBox.x, scissorBox.y, scissorBox.width, scissorBox.height );
482     mScissorStack.push_back( scissorBox );
483   }
484   else
485   {
486     // We are not performing a layer clip. Add the viewport as the root scissor rectangle.
487     context.SetScissorTest( false );
488     mScissorStack.push_back( mViewportRectangle );
489   }
490
491   // Loop through all RenderList in the RenderList, set up any prerequisites to render them, then perform the render.
492   for( uint32_t index = 0u; index < count; ++index )
493   {
494     const RenderItem& item = renderList.GetItem( index );
495     DALI_PRINT_RENDER_ITEM( item );
496
497     // Set up clipping based on both the Renderer and Actor APIs.
498     // The Renderer API will be used if specified. If AUTO, the Actors automatic clipping feature will be used.
499     SetupClipping( item, context, usedStencilBuffer, lastClippingDepth, lastClippingId, stencilBufferAvailable, orientation );
500
501     if( DALI_LIKELY( item.mRenderer ) )
502     {
503       // Set up the depth buffer based on per-renderer flags if depth buffer is available
504       // If the per renderer flags are set to "ON" or "OFF", they will always override any Layer depth mode or
505       // draw-mode state, such as Overlays.
506       // If the flags are set to "AUTO", the behavior then depends on the type of renderer. Overlay Renderers will always
507       // disable depth testing and writing. Color Renderers will enable them if the Layer does.
508       if( depthBufferAvailable == Integration::DepthBufferAvailable::TRUE )
509       {
510         SetupDepthBuffer( item, context, autoDepthTestMode, firstDepthBufferUse );
511       }
512
513       // Render the item.
514       item.mRenderer->Render( context, bufferIndex, *item.mNode, item.mModelMatrix, item.mModelViewMatrix,
515                               viewMatrix, projectionMatrix, item.mSize, !item.mIsOpaque, boundTextures );
516     }
517   }
518 }
519
520 RenderAlgorithms::RenderAlgorithms()
521   : mViewportRectangle(),
522     mHasLayerScissor( false )
523 {
524 }
525
526 void RenderAlgorithms::ProcessRenderInstruction( const RenderInstruction& instruction,
527                                                  Context& context,
528                                                  BufferIndex bufferIndex,
529                                                  Integration::DepthBufferAvailable depthBufferAvailable,
530                                                  Integration::StencilBufferAvailable stencilBufferAvailable,
531                                                  Vector<GLuint>& boundTextures,
532                                                  int orientation,
533                                                  Dali::ClippingBox& scissorBox )
534 {
535   DALI_PRINT_RENDER_INSTRUCTION( instruction, bufferIndex );
536
537   const Matrix* viewMatrix       = instruction.GetViewMatrix( bufferIndex );
538   const Matrix* projectionMatrix = instruction.GetProjectionMatrix( bufferIndex );
539
540   DALI_ASSERT_DEBUG( viewMatrix );
541   DALI_ASSERT_DEBUG( projectionMatrix );
542
543   if( viewMatrix && projectionMatrix )
544   {
545     const RenderListContainer::SizeType count = instruction.RenderListCount();
546
547     // Iterate through each render list in order. If a pair of render lists
548     // are marked as interleaved, then process them together.
549     for( RenderListContainer::SizeType index = 0; index < count; ++index )
550     {
551       const RenderList* renderList = instruction.GetRenderList( index );
552
553       if( renderList && !renderList->IsEmpty() )
554       {
555         ProcessRenderList( *renderList,
556                             context,
557                             bufferIndex,
558                            *viewMatrix,
559                            *projectionMatrix,
560                             depthBufferAvailable,
561                             stencilBufferAvailable,
562                             boundTextures,
563                             orientation,
564                             scissorBox );
565       }
566     }
567   }
568 }
569
570
571 } // namespace Render
572
573 } // namespace Internal
574
575 } // namespace Dali