#include <dali/internal/render/common/render-list.h>
#include <dali/internal/render/common/render-instruction.h>
#include <dali/internal/render/gl-resources/context.h>
-#include <dali/internal/render/renderers/scene-graph-renderer.h>
+#include <dali/internal/render/renderers/render-renderer.h>
using Dali::Internal::SceneGraph::RenderItem;
using Dali::Internal::SceneGraph::RenderList;
{
/**
- * Process a render-list.
- * @param[in] renderList The render-list to process.
- * @param[in] context The GL context.
- * @param[in] defaultShader The default shader to use.
- * @param[in] buffer The current render buffer index (previous update buffer)
- * @param[in] frameTime The elapsed time between the last two updates.
- * @param[in] viewMatrix The view matrix from the appropriate camera.
- * @param[in] projectionMatrix The projection matrix from the appropriate camera.
- * @param[in] cullMode True if the renderers should be subjected to clipspace culling
+ * Sets up the scissor test if required.
+ * @param[in] renderList The render list from which to get the clipping flag
+ * @param[in] context The context
*/
-inline void ProcessRenderList( const RenderList& renderList,
- Context& context,
- SceneGraph::Shader& defaultShader,
- BufferIndex bufferIndex,
- float frameTime,
- const Matrix& viewMatrix,
- const Matrix& projectionMatrix,
- bool cullMode )
+inline void SetScissorTest( const RenderList& renderList, Context& context )
{
- DALI_PRINT_RENDER_LIST( renderList );
-
// Scissor testing
if( renderList.IsClipping() )
{
{
context.SetScissorTest( false );
}
+}
+/**
+ * Sets the render flags for depth testing and stencil buffer
+ *
+ * @param[in] renderList The render list from which to get the render flags
+ * @param[in] context The context
+ */
+inline void SetRenderFlags( const RenderList& renderList, Context& context )
+{
const unsigned int renderFlags = renderList.GetFlags();
- bool setDepthTest = ( ( renderFlags & RenderList::DEPTH_TEST ) != 0u );
- bool depthMask = ( ( renderFlags & RenderList::DEPTH_WRITE ) != 0u );
-
- GLbitfield clearMask = ( renderFlags & RenderList::DEPTH_CLEAR ) ? GL_DEPTH_BUFFER_BIT : 0u;
+ if( ( renderFlags & RenderList::DEPTH_BUFFER_ENABLED ) != 0u )
+ {
+ //Enable depth testing
+ context.EnableDepthBuffer( true );
+ }
+ else
+ {
+ //Disable depth test and depth write
+ context.EnableDepthBuffer( false );
+ context.DepthMask( false );
+ }
- context.SetDepthTest( setDepthTest );
- context.DepthMask( depthMask );
+ GLbitfield clearMask = ( renderFlags & RenderList::DEPTH_CLEAR ) ? GL_DEPTH_BUFFER_BIT : 0u;
- // Stencil testing, writing, and clearing...
- const bool enableStencilTest( renderFlags & RenderList::STENCIL_TEST );
+ // Stencil enabled, writing, and clearing...
+ const bool enableStencilBuffer( renderFlags & RenderList::STENCIL_BUFFER_ENABLED );
const bool enableStencilWrite( renderFlags & RenderList::STENCIL_WRITE );
-
- context.SetStencilTest( enableStencilTest );
-
- if( enableStencilTest )
+ context.EnableStencilBuffer( enableStencilBuffer );
+ if( enableStencilBuffer )
{
context.StencilFunc( (enableStencilWrite ? GL_ALWAYS : GL_EQUAL), 1, 0xFF );
context.StencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
// Clear depth and/or stencil buffer.
if( clearMask )
{
- context.Clear( clearMask );
+ // only clear if the depth and/or stencil buffer have been written to after a previous clear
+ context.Clear( clearMask, Context::CHECK_CACHED_VALUES );
}
+}
- size_t count = renderList.Count();
- for ( size_t index = 0; index < count; ++index )
+
+/**
+ * Process a render-list.
+ * @param[in] renderList The render-list to process.
+ * @param[in] context The GL context.
+ * @param[in] defaultShader The default shader to use.
+ * @param[in] buffer The current render buffer index (previous update buffer)
+ * @param[in] viewMatrix The view matrix from the appropriate camera.
+ * @param[in] projectionMatrix The projection matrix from the appropriate camera.
+ */
+inline void ProcessRenderList(
+ const RenderList& renderList,
+ Context& context,
+ SceneGraph::TextureCache& textureCache,
+ SceneGraph::Shader& defaultShader,
+ BufferIndex bufferIndex,
+ const Matrix& viewMatrix,
+ const Matrix& projectionMatrix )
+{
+ DALI_PRINT_RENDER_LIST( renderList );
+
+ SetScissorTest( renderList, context );
+ SetRenderFlags( renderList, context );
+
+ if( renderList.HasColorRenderItems() )
{
- const RenderItem& item = renderList.GetItem( index );
+ bool depthBufferEnabled = ( ( renderList.GetFlags() & RenderList::DEPTH_BUFFER_ENABLED ) != 0u );
+ size_t count = renderList.Count();
- DALI_PRINT_RENDER_ITEM( item );
+ if( depthBufferEnabled )
+ {
+ for ( size_t index = 0; index < count; ++index )
+ {
+ const RenderItem& item = renderList.GetItem( index );
+ DALI_PRINT_RENDER_ITEM( item );
- SceneGraph::Renderer* renderer = const_cast< SceneGraph::Renderer* >( item.GetRenderer() );
- const Matrix& modelViewMatrix = item.GetModelViewMatrix();
+ DepthWriteMode::Type depthWriteMode = item.mRenderer->GetDepthWriteMode();
+ context.DepthMask( ( depthWriteMode == DepthWriteMode::AUTO && item.mIsOpaque ) ||
+ ( depthWriteMode == DepthWriteMode::ON ) );
+
+ item.mRenderer->Render( context, textureCache, bufferIndex, *item.mNode, defaultShader,
+ item.mModelMatrix, item.mModelViewMatrix, viewMatrix, projectionMatrix, item.mSize, !item.mIsOpaque );
+ }
+ }
+ else
+ {
+ for ( size_t index = 0; index < count; ++index )
+ {
+ const RenderItem& item = renderList.GetItem( index );
+ DALI_PRINT_RENDER_ITEM( item );
+ item.mRenderer->Render( context, textureCache, bufferIndex, *item.mNode, defaultShader,
+ item.mModelMatrix, item.mModelViewMatrix, viewMatrix, projectionMatrix, item.mSize, !item.mIsOpaque );
+ }
+ }
+ }
+ else
+ {
+ size_t count = renderList.Count();
+ for ( size_t index = 0; index < count; ++index )
+ {
+ const RenderItem& item = renderList.GetItem( index );
+ DALI_PRINT_RENDER_ITEM( item );
+
+ item.mRenderer->Render( context, textureCache, bufferIndex, *item.mNode, defaultShader,
+ item.mModelMatrix, item.mModelViewMatrix, viewMatrix, projectionMatrix, item.mSize, !item.mIsOpaque );
+ }
- renderer->Render( bufferIndex, defaultShader, modelViewMatrix, viewMatrix, projectionMatrix, frameTime, cullMode );
}
}
void ProcessRenderInstruction( const RenderInstruction& instruction,
Context& context,
+ SceneGraph::TextureCache& textureCache,
SceneGraph::Shader& defaultShader,
- BufferIndex bufferIndex,
- float frameTime )
+ BufferIndex bufferIndex )
{
DALI_PRINT_RENDER_INSTRUCTION( instruction, bufferIndex );
NULL != projectionMatrix )
{
const RenderListContainer::SizeType count = instruction.RenderListCount();
+
+ // Iterate through each render list in order. If a pair of render lists
+ // are marked as interleaved, then process them together.
for( RenderListContainer::SizeType index = 0; index < count; ++index )
{
const RenderList* renderList = instruction.GetRenderList( index );
if( renderList &&
!renderList->IsEmpty() )
{
- ProcessRenderList( *renderList, context, defaultShader, bufferIndex, frameTime, *viewMatrix, *projectionMatrix, instruction.mCullMode );
+ ProcessRenderList( *renderList, context, textureCache, defaultShader, bufferIndex, *viewMatrix, *projectionMatrix );
}
}
}