/*---------------------------------------------------------------------------* Project: NintendoWare File: lyt_Drawer.cpp Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. 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. $Revision: 24746 $ *---------------------------------------------------------------------------*/ #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