Merge "[Tizen][ATSPI] Adds support for enumeration in Property::Value" into tizen
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / render-instruction-processor.cpp
index edb03f0..983b799 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -162,7 +162,7 @@ inline void AddRendererToRenderList( BufferIndex updateBufferIndex,
   bool inside( true );
   const Node* node = renderable.mNode;
 
-  if( cull && !renderable.mRenderer->GetShader().HintEnabled( Dali::Shader::Hint::MODIFIES_GEOMETRY ) )
+  if( cull && renderable.mRenderer && !renderable.mRenderer->GetShader().HintEnabled( Dali::Shader::Hint::MODIFIES_GEOMETRY ) )
   {
     const Vector4& boundingSphere = node->GetBoundingSphere();
     inside = ( boundingSphere.w > Math::MACHINE_EPSILON_1000 ) &&
@@ -171,20 +171,30 @@ inline void AddRendererToRenderList( BufferIndex updateBufferIndex,
 
   if( inside )
   {
-    Renderer::Opacity opacity = renderable.mRenderer->GetOpacity( updateBufferIndex, *renderable.mNode );
-    if( opacity != Renderer::TRANSPARENT )
+    Renderer::OpacityType opacityType = renderable.mRenderer ? renderable.mRenderer->GetOpacityType( updateBufferIndex, *renderable.mNode ) : Renderer::OPAQUE;
+    if( opacityType != Renderer::TRANSPARENT || node->GetClippingMode() == ClippingMode::CLIP_CHILDREN )
     {
       // Get the next free RenderItem.
       RenderItem& item = renderList.GetNextFreeItem();
-      item.mRenderer = &renderable.mRenderer->GetRenderer();
+
       item.mNode = renderable.mNode;
-      item.mTextureSet = renderable.mRenderer->GetTextures();
-      item.mIsOpaque = ( opacity == Renderer::OPAQUE );
-      item.mDepthIndex = renderable.mRenderer->GetDepthIndex();
+      item.mIsOpaque = ( opacityType == Renderer::OPAQUE );
+      item.mDepthIndex = 0;
+
+      if(!isLayer3d)
+      {
+        item.mDepthIndex = renderable.mNode->GetDepthIndex();
+      }
 
-      if( !isLayer3d )
+      if( DALI_LIKELY( renderable.mRenderer ) )
       {
-        item.mDepthIndex += renderable.mNode->GetDepthIndex();
+        item.mRenderer =   &renderable.mRenderer->GetRenderer();
+        item.mTextureSet =  renderable.mRenderer->GetTextures();
+        item.mDepthIndex += renderable.mRenderer->GetDepthIndex();
+      }
+      else
+      {
+        item.mRenderer = nullptr;
       }
 
       // Save ModelView matrix onto the item.
@@ -327,7 +337,10 @@ inline void RenderInstructionProcessor::SortRenderItems( BufferIndex bufferIndex
     {
       RenderItem& item = renderList.GetItem( index );
 
-      item.mRenderer->SetSortAttributes( bufferIndex, mSortingHelper[ index ] );
+      if( item.mRenderer )
+      {
+        item.mRenderer->SetSortAttributes( bufferIndex, mSortingHelper[ index ] );
+      }
 
       // texture set
       mSortingHelper[ index ].textureSet = item.mTextureSet;
@@ -389,6 +402,7 @@ void RenderInstructionProcessor::Prepare( BufferIndex updateBufferIndex,
   RenderInstruction& instruction = instructions.GetNextInstruction( updateBufferIndex );
   renderTask.PrepareRenderInstruction( instruction, updateBufferIndex );
   bool viewMatrixHasNotChanged = !renderTask.ViewMatrixUpdated();
+  bool isRenderListAdded = false;
 
   const Matrix& viewMatrix = renderTask.GetViewMatrix( updateBufferIndex );
   SceneGraph::Camera& camera = renderTask.GetCamera();
@@ -419,6 +433,8 @@ void RenderInstructionProcessor::Prepare( BufferIndex updateBufferIndex,
         // We only use the clipping version of the sort comparitor if any clipping nodes exist within the RenderList.
         SortRenderItems( updateBufferIndex, *renderList, layer, hasClippingNodes );
       }
+
+      isRenderListAdded = true;
     }
 
     if( !layer.overlayRenderables.Empty() )
@@ -439,13 +455,19 @@ void RenderInstructionProcessor::Prepare( BufferIndex updateBufferIndex,
         // Clipping hierarchy is irrelevant when sorting overlay items, so we specify using the non-clipping version of the sort comparitor.
         SortRenderItems( updateBufferIndex, *renderList, layer, false );
       }
+
+      isRenderListAdded = true;
     }
   }
 
   // Inform the render instruction that all renderers have been added and this frame is complete.
   instruction.UpdateCompleted();
-}
 
+  if( !isRenderListAdded && !instruction.mIsClearColorSet )
+  {
+    instructions.DiscardCurrentInstruction( updateBufferIndex );
+  }
+}
 
 } // SceneGraph