/*---------------------------------------------------------------------------* Project: NintendoWare File: lyt_Drawer.cpp Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo and/or its licensed developers and are protected by national and international copyright laws. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. The content herein is highly confidential and should be handled accordingly. $Revision: 31311 $ *---------------------------------------------------------------------------*/ #include "precompiled.h" #include #include #include #include #include #include #ifdef NW_LYT_DRAWER_ENABLE namespace nw { namespace lyt { //---------------------------------------------------------- // Drawer void Drawer::Draw( const Layout* pLayout, DrawInfo& drawInfo ) { if ( pLayout == NULL ) { return; } if ( pLayout->GetRootPane() == NULL || pLayout->GetRootPane()->IsVisible() == false ) return; pLayout->GetRootPane()->MakeUniformData( &drawInfo, this ); } void Drawer::Draw( const Pane* pPane, DrawInfo& drawInfo ) { if ( pPane == NULL ) { return; } if ( pPane->IsVisible() ) { pPane->MakeUniformData( &drawInfo, this ); } } void Drawer::DrawBegin( const DrawInfo& drawInfo ) { u32 flag = 0; DrawBegin(flag); Base::SetProjectionMtx(drawInfo.GetProjectionMtx()); } void Drawer::DrawBegin(u32 flag) { m_ActiveTexureNum = 0; m_TexCoordNum = 0; m_PrevTexObj = 0; m_CurrentTexEnvType = TEX_ENV_TYPE_NUM; m_IsBlendDefault = true; SetUpTextures( NULL, false ); Base::DrawBegin(flag); } void Drawer::DrawEnd(u32 flag) { FlushBuffer(); Base::DrawEnd(flag); } Drawer::Drawer() : m_PrevTexObj(0), m_ActiveTexureNum(0), m_TexCoordNum(0), m_IsBlendDefault(true), m_AlphaTestEnable(false), m_CurrentTexEnvType(TEX_ENV_TYPE_NUM) #if ! defined(NW_RELEASE) , m_PreviousTexEnvType(TEX_ENV_TYPE_NUM) #endif { } Drawer::Drawer( GraphicsResource& graphicsResource ) { this->Initialize( graphicsResource ); } void Drawer::Initialize( GraphicsResource& graphicsResource, void* vertexBuffer ) { const u32 cmdBufSize = GetCommandBufferSize( graphicsResource.GetRectShaderBinary(), graphicsResource.GetRectShaderBinarySize()); const u32 allocSize = cmdBufSize + (vertexBuffer == NULL ? GetVertexBufferSize(): 0); void* commandBuffer = Layout::AllocDeviceMemory(allocSize, 4); NW_NULL_ASSERT(commandBuffer); if (vertexBuffer == NULL) { Base::Initialize( commandBuffer, graphicsResource.GetRectShaderBinary(), graphicsResource.GetRectShaderBinarySize()); } else { Base::Initialize( vertexBuffer, commandBuffer, graphicsResource.GetRectShaderBinary(), graphicsResource.GetRectShaderBinarySize()); } } void Drawer::Finalize() { void *const comamndBuffer = m_CommandBuffer; Base::Finalize(); Layout::FreeDeviceMemory(comamndBuffer); } } // namespace lyt } // namespace nw #endif