const RenderItem& item = renderList.GetItem( index );
DALI_PRINT_RENDER_ITEM( item );
- Renderer& renderer = item.GetRenderer();
- DepthWriteMode::Type depthWriteMode = renderer.GetDepthWriteMode();
- context.DepthMask( ( depthWriteMode == DepthWriteMode::AUTO && item.IsOpaque() ) ||
+ DepthWriteMode::Type depthWriteMode = item.mRenderer->GetDepthWriteMode();
+ context.DepthMask( ( depthWriteMode == DepthWriteMode::AUTO && item.mIsOpaque ) ||
( depthWriteMode == DepthWriteMode::ON ) );
- renderer.Render( context, textureCache, bufferIndex, item.GetNode(), defaultShader, item.GetModelViewMatrix(), viewMatrix, projectionMatrix, item.GetSize(), !item.IsOpaque() );
+ item.mRenderer->Render( context, textureCache, bufferIndex, *item.mNode, defaultShader,
+ item.mModelMatrix, item.mModelViewMatrix, viewMatrix, projectionMatrix, item.mSize, !item.mIsOpaque );
}
}
else
{
const RenderItem& item = renderList.GetItem( index );
DALI_PRINT_RENDER_ITEM( item );
- item.GetRenderer().Render( context, textureCache, bufferIndex, item.GetNode(), defaultShader, item.GetModelViewMatrix(), viewMatrix, projectionMatrix, item.GetSize(), !item.IsOpaque() );
+ item.mRenderer->Render( context, textureCache, bufferIndex, *item.mNode, defaultShader,
+ item.mModelMatrix, item.mModelViewMatrix, viewMatrix, projectionMatrix, item.mSize, !item.mIsOpaque );
}
}
}
const RenderItem& item = renderList.GetItem( index );
DALI_PRINT_RENDER_ITEM( item );
- item.GetRenderer().Render( context, textureCache, bufferIndex, item.GetNode(), defaultShader, item.GetModelViewMatrix(), viewMatrix, projectionMatrix, item.GetSize(), !item.IsOpaque() );
+ item.mRenderer->Render( context, textureCache, bufferIndex, *item.mNode, defaultShader,
+ item.mModelMatrix, item.mModelViewMatrix, viewMatrix, projectionMatrix, item.mSize, !item.mIsOpaque );
}
}
void PrintRenderItem( const SceneGraph::RenderItem& item )
{
std::stringstream debugStream;
- debugStream << "Rendering item, ModelView: " << item.GetModelViewMatrix();
+ debugStream << "Rendering item, ModelView: " << item.mModelViewMatrix;
std::string debugString( debugStream.str() );
DALI_LOG_RENDER_INFO( " %s\n", debugString.c_str() );
{
class RenderInstruction;
struct RenderList;
-class RenderItem;
+struct RenderItem;
}
namespace Render
}
RenderItem::RenderItem()
-: mModelViewMatrix( false ),
+: mModelMatrix( false ),
+ mModelViewMatrix( false ),
+ mSize(),
mRenderer( NULL ),
mNode( NULL ),
mDepthIndex( 0 ),
gRenderItemPool.Free( static_cast<RenderItem*>( ptr ) );
}
-void RenderItem::Reset()
-{
- mRenderer = NULL;
-}
-
-void RenderItem::SetRenderer( Render::Renderer* renderer )
-{
- mRenderer = renderer;
-}
-
-void RenderItem::SetNode( Node* node )
-{
- mNode = node;
-}
-
-Render::Renderer& RenderItem::GetRenderer() const
-{
- return *mRenderer;
-}
-
-Matrix& RenderItem::GetModelViewMatrix()
-{
- return mModelViewMatrix;
-}
-
-const Matrix& RenderItem::GetModelViewMatrix() const
-{
- return mModelViewMatrix;
-}
-
-void RenderItem::SetDepthIndex( int depthIndex )
-{
- mDepthIndex = depthIndex;
-}
-
-void RenderItem::SetIsOpaque( bool isOpaque )
-{
- mIsOpaque = isOpaque;
-}
-
} // namespace SceneGraph
} // namespace Internal
namespace SceneGraph
{
-class RenderItem;
-
-typedef std::vector< RenderItem > RendererItemContainer;
-
/**
- * A render-item is a renderer & modelView matrix pair.
+ * A RenderItem contains all the data needed for rendering
*/
-class RenderItem
+struct RenderItem
{
-public:
-
/**
* Construct a new RenderItem
*/
*/
void operator delete( void* ptr );
- /**
- * Reset the render-item.
- */
- void Reset();
-
- /**
- * Retrieve the renderer.
- * @return The renderer.
- */
- Render::Renderer& GetRenderer() const;
-
- /**
- * Set the renderer
- * @param[in] renderer The renderer
- */
- void SetRenderer( Render::Renderer* renderer );
-
- /**
- * Set the node
- * @param[in] node The node
- */
- void SetNode( Node* node );
-
- /**
- * Retrieve the node
- * @return The node
- */
- const Node& GetNode() const
- {
- return *mNode;
- }
- /**
- * Retrieve the modelView matrix.
- * @return The modelView matrix.
- */
- Matrix& GetModelViewMatrix();
-
- /**
- * Retrieve the modelView matrix.
- * @return The modelView matrix.
- */
- const Matrix& GetModelViewMatrix() const;
-
- /**
- * Retrieve the depth index
- */
- int GetDepthIndex() const
- {
- return mDepthIndex;
- }
-
- /**
- * Set the depth index
- */
- void SetDepthIndex( int depthIndex );
- /**
- * Set if the RenderItem is opaque
- * @param[in] isOpaque true if the RenderItem is opaque, false otherwise
- */
- void SetIsOpaque( bool isOpaque );
-
- /**
- * Check if the RenderItem is opaque
- * @return True if it is opaque, false otherwise
- */
- bool IsOpaque() const
- {
- return mIsOpaque;
- }
-
- /**
- * Retrives the size of the render item
- * @return The size of the render item
- */
- const Vector3& GetSize() const
- {
- return mSize;
- }
-
- /**
- * Retrives the size of the render item
- * @return The size of the render item
- */
- Vector3& GetSize()
- {
- return mSize;
- }
+ Matrix mModelMatrix;
+ Matrix mModelViewMatrix;
+ Vector3 mSize;
+ Render::Renderer* mRenderer;
+ Node* mNode;
+ int mDepthIndex;
+ bool mIsOpaque:1;
private:
// RenderItems should not be copied as they are heavy
RenderItem( const RenderItem& item );
RenderItem& operator = ( const RenderItem& item );
-
- Matrix mModelViewMatrix;
- Vector3 mSize;
- Render::Renderer* mRenderer;
- Node* mNode;
- int mDepthIndex;
- bool mIsOpaque:1;
};
} // namespace SceneGraph
class Layer;
-
-class RenderItem;
typedef OwnerContainer< RenderItem* > RenderItemContainer;
struct RenderList;
}
// get the item mNextFree points to and increase by one
RenderItem& item = *mItems[ mNextFree++ ];
- item.Reset();
return item;
}
const Render::Renderer& GetRenderer( RenderItemContainer::SizeType index ) const
{
DALI_ASSERT_DEBUG( index < GetCachedItemCount() );
- return mItems[ index ]->GetRenderer();
+ return *mItems[ index ]->mRenderer;
}
/**
BufferIndex bufferIndex,
const SceneGraph::NodeDataProvider& node,
SceneGraph::Shader& defaultShader,
+ const Matrix& modelMatrix,
const Matrix& modelViewMatrix,
const Matrix& viewMatrix,
const Matrix& projectionMatrix,
// Only set up and draw if we have textures and they are all valid
// set projection and view matrix if program has not yet received them yet this frame
- SetMatrices( *program, node.GetModelMatrix( bufferIndex ), viewMatrix, projectionMatrix, modelViewMatrix );
+ SetMatrices( *program, modelMatrix, viewMatrix, projectionMatrix, modelViewMatrix );
// set color uniform
GLint loc = program->GetUniformLocation( Program::UNIFORM_COLOR );
BufferIndex bufferIndex,
const SceneGraph::NodeDataProvider& node,
SceneGraph::Shader& defaultShader,
+ const Matrix& modelMatrix,
const Matrix& modelViewMatrix,
const Matrix& viewMatrix,
const Matrix& projectionMatrix,
{
// Get the next free RenderItem
RenderItem& item = renderList.GetNextFreeItem();
- item.SetRenderer( &renderable.mRenderer->GetRenderer() );
- item.SetNode( renderable.mNode );
- item.SetIsOpaque( opacity == Renderer::OPAQUE );
+ item.mRenderer = &renderable.mRenderer->GetRenderer();
+ item.mNode = renderable.mNode;
+ item.mIsOpaque = (opacity == Renderer::OPAQUE);
if( isLayer3d )
{
- item.SetDepthIndex( renderable.mRenderer->GetDepthIndex() );
+ item.mDepthIndex = renderable.mRenderer->GetDepthIndex();
}
else
{
- item.SetDepthIndex( renderable.mRenderer->GetDepthIndex() + static_cast<int>( renderable.mNode->GetDepth() ) * Dali::Layer::TREE_DEPTH_MULTIPLIER );
+ item.mDepthIndex = renderable.mRenderer->GetDepthIndex() + static_cast<int>( renderable.mNode->GetDepth() ) * Dali::Layer::TREE_DEPTH_MULTIPLIER;
}
// save MV matrix onto the item
- const Matrix& worldMatrix = renderable.mNode->GetWorldMatrixAndSize( item.GetSize() );
- Matrix::Multiply( item.GetModelViewMatrix(), worldMatrix, viewMatrix );
+ renderable.mNode->GetWorldMatrixAndSize( item.mModelMatrix, item.mSize );
+ Matrix::Multiply( item.mModelViewMatrix, item.mModelMatrix, viewMatrix );
}
}
}
*/
bool CompareItems( const RendererWithSortAttributes& lhs, const RendererWithSortAttributes& rhs )
{
- if( lhs.renderItem->GetDepthIndex() == rhs.renderItem->GetDepthIndex() )
+ if( lhs.renderItem->mDepthIndex == rhs.renderItem->mDepthIndex )
{
if( lhs.shader == rhs.shader )
{
}
return lhs.shader < rhs.shader;
}
- return lhs.renderItem->GetDepthIndex() < rhs.renderItem->GetDepthIndex();
+ return lhs.renderItem->mDepthIndex < rhs.renderItem->mDepthIndex;
}
/**
* Function which sorts the render items by Z function, then
*/
bool CompareItems3D( const RendererWithSortAttributes& lhs, const RendererWithSortAttributes& rhs )
{
- bool lhsIsOpaque = lhs.renderItem->IsOpaque();
- if( lhsIsOpaque == rhs.renderItem->IsOpaque())
+ bool lhsIsOpaque = lhs.renderItem->mIsOpaque;
+ if( lhsIsOpaque == rhs.renderItem->mIsOpaque )
{
if( lhsIsOpaque )
{
{
RenderItem& item = renderList.GetItem( index );
- item.GetRenderer().SetSortAttributes( bufferIndex, sortingHelper[ index ] );
+ item.mRenderer->SetSortAttributes( bufferIndex, sortingHelper[ index ] );
// the default sorting function should get inlined here
- sortingHelper[ index ].zValue = Internal::Layer::ZValue( item.GetModelViewMatrix().GetTranslation3() ) - item.GetDepthIndex();
+ sortingHelper[ index ].zValue = Internal::Layer::ZValue( item.mModelViewMatrix.GetTranslation3() ) - item.mDepthIndex;
// keep the renderitem pointer in the helper so we can quickly reorder items after sort
sortingHelper[ index ].renderItem = &item;
{
RenderItem& item = renderList.GetItem( index );
- item.GetRenderer().SetSortAttributes( bufferIndex, sortingHelper[ index ] );
- sortingHelper[ index ].zValue = (*sortFunction)( item.GetModelViewMatrix().GetTranslation3() ) - item.GetDepthIndex();
+ item.mRenderer->SetSortAttributes( bufferIndex, sortingHelper[ index ] );
+ sortingHelper[ index ].zValue = (*sortFunction)( item.mModelViewMatrix.GetTranslation3() ) - item.mDepthIndex;
// keep the renderitem pointer in the helper so we can quickly reorder items after sort
sortingHelper[ index ].renderItem = &item;
for( unsigned int index = 0; index < renderableCount; ++index, ++renderListIter )
{
*renderListIter = sortingHelper[ index ].renderItem;
- DALI_LOG_INFO( gRenderListLogFilter, Debug::Verbose, " sortedList[%d] = %p\n", index, &sortingHelper[ index ].renderItem->GetRenderer() );
+ DALI_LOG_INFO( gRenderListLogFilter, Debug::Verbose, " sortedList[%d] = %p\n", index, sortingHelper[ index ].renderItem->mRenderer);
}
}
// depth buffering
if ( ( renderList.Count() == 1 ) &&
(( renderList.GetRenderer( 0 ).GetDepthWriteMode() == DepthWriteMode::OFF ) ||
- ( renderList.GetRenderer( 0 ).GetDepthWriteMode() == DepthWriteMode::AUTO && !renderList.GetItem(0).IsOpaque() )))
+ ( renderList.GetRenderer( 0 ).GetDepthWriteMode() == DepthWriteMode::AUTO && !renderList.GetItem(0).mIsOpaque )))
{
//Nothing to do here
}
namespace SceneGraph
{
class RenderTracker;
-class RenderItem;
+struct RenderItem;
class Shader;
/**
return mBoundingSpheres[ mIds[id] ];
}
-const Matrix& TransformManager::GetWorldMatrixAndSize( TransformId id, Vector3& size ) const
+void TransformManager::GetWorldMatrixAndSize( TransformId id, Matrix& worldMatrix, Vector3& size ) const
{
unsigned int index = mIds[id];
+ worldMatrix = mWorld[index];
size = mSize[index];
- return mWorld[index];
}
} //namespace SceneGraph
/**
* Get the world matrix and size of a given component
* @param[in] id Id of the transform component
+ * @param[out] The world matrix of the component
* @param[out] size size of the component
- * @return The world matrix of the component
*/
- const Matrix& GetWorldMatrixAndSize( TransformId id, Vector3& size ) const;
+ void GetWorldMatrixAndSize( TransformId id, Matrix& worldMatrix, Vector3& size ) const;
private:
/**
* Retrieve world matrix and size of the node
- *
+ * @param[out] The local to world matrix of the node
* @param[out] size The current size of the node
- * @return The local to world matrix of the node
*/
- const Matrix& GetWorldMatrixAndSize( Vector3& size ) const
+ void GetWorldMatrixAndSize( Matrix& worldMatrix, Vector3& size ) const
{
if( mTransformId != INVALID_TRANSFORM_ID )
{
- return mTransformManager->GetWorldMatrixAndSize( mTransformId, size );
+ mTransformManager->GetWorldMatrixAndSize( mTransformId, worldMatrix, size );
}
- return Matrix::IDENTITY;
}
/**