From 4cd2b2f7dd608637dc84091f3c54c2c6b0211cad Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Thu, 4 Jul 2013 18:14:58 -0400 Subject: [PATCH] Fix #303 --- .../pfGameGUIMgr/pfGUIControlMod.cpp | 23 ++++++++++++------- .../plMessage/plDeviceRecreateMsg.h | 13 ++++++++++- .../PubUtilLib/plPipeline/DX/plDXPipeline.cpp | 6 ++--- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.cpp b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.cpp index 865bf184..0ca70560 100644 --- a/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.cpp +++ b/Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGUIControlMod.cpp @@ -56,6 +56,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnMessage/plRefMsg.h" #include "pnMessage/plEnableMsg.h" #include "pfMessage/pfGameGUIMsg.h" +#include "plMessage/plDeviceRecreateMsg.h" #include "pnSceneObject/plDrawInterface.h" #include "pnSceneObject/plCoordinateInterface.h" #include "pnSceneObject/plAudioInterface.h" @@ -572,14 +573,16 @@ plProfile_CreateTimer("Gui", "RenderSetup", GUITime); bool pfGUIControlMod::MsgReceive( plMessage *msg ) { plRenderMsg* rend = plRenderMsg::ConvertNoRef( msg ); + plDeviceRecreateMsg* device = plDeviceRecreateMsg::ConvertNoRef(msg); + if (rend || device) { + plPipeline* pipe = rend ? rend->Pipeline() : device->Pipeline(); - if( rend ) - { plProfile_BeginLap(GUITime, this->GetKey()->GetUoid().GetObjectName().c_str()); - // Only need it once - if( ISetUpDynTextMap( rend->Pipeline() ) ) - plgDispatch::Dispatch()->UnRegisterForExactType( plRenderMsg::Index(), GetKey() ); + ISetUpDynTextMap(pipe); plProfile_EndLap(GUITime, this->GetKey()->GetUoid().GetObjectName().c_str()); + + if (rend) + plgDispatch::Dispatch()->UnRegisterForExactType(plRenderMsg::Index(), GetKey()); return true; } @@ -591,12 +594,16 @@ bool pfGUIControlMod::MsgReceive( plMessage *msg ) if( refMsg->GetContext() & ( plRefMsg::kOnCreate | plRefMsg::kOnRequest | plRefMsg::kOnReplace ) ) { fDynTextMap = plDynamicTextMap::ConvertNoRef( refMsg->GetRef() ); - // Register for a render msg so we can leech the material when we finally - // have a pipeline to work with + + // These tell us when we need to (re-)initialize the DTM plgDispatch::Dispatch()->RegisterForExactType( plRenderMsg::Index(), GetKey() ); + plgDispatch::Dispatch()->RegisterForExactType( plDeviceRecreateMsg::Index(), GetKey() ); } else - fDynTextMap = nil; + { + fDynTextMap = nullptr; + plgDispatch::Dispatch()->UnRegisterForExactType( plDeviceRecreateMsg::Index(), GetKey() ); + } return true; } else if( refMsg->fType == kRefDynTextLayer ) diff --git a/Sources/Plasma/PubUtilLib/plMessage/plDeviceRecreateMsg.h b/Sources/Plasma/PubUtilLib/plMessage/plDeviceRecreateMsg.h index 1f11b8c6..6b7316bb 100644 --- a/Sources/Plasma/PubUtilLib/plMessage/plDeviceRecreateMsg.h +++ b/Sources/Plasma/PubUtilLib/plMessage/plDeviceRecreateMsg.h @@ -51,15 +51,26 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnMessage/plMessage.h" +class plPipeline; + class plDeviceRecreateMsg : public plMessage { + plPipeline* fPipe; + public: - plDeviceRecreateMsg() : plMessage( nil, nil, nil ) { SetBCastFlag( kBCastByExactType ); } + plDeviceRecreateMsg(plPipeline* pipe=nullptr) + : plMessage(nullptr, nullptr, nullptr), fPipe(pipe) + { + SetBCastFlag(kBCastByExactType); + } + ~plDeviceRecreateMsg() {} CLASSNAME_REGISTER( plDeviceRecreateMsg ); GETINTERFACE_ANY( plDeviceRecreateMsg, plMessage ); + plPipeline* Pipeline() const { return fPipe; } + // IO void Read(hsStream* stream, hsResMgr* mgr) { plMessage::IMsgRead( stream, mgr ); } void Write(hsStream* stream, hsResMgr* mgr) { plMessage::IMsgWrite( stream, mgr ); } diff --git a/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp b/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp index 31de130a..b116d1ef 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp @@ -2264,7 +2264,7 @@ bool plDXPipeline::IResetDevice() /// Broadcast a message letting everyone know that we were recreated and that /// all device-specific stuff needs to be recreated - plDeviceRecreateMsg* clean = new plDeviceRecreateMsg(); + plDeviceRecreateMsg* clean = new plDeviceRecreateMsg(this); plgDispatch::MsgSend(clean); } fDevWasLost = true; @@ -2533,7 +2533,7 @@ void plDXPipeline::Resize( uint32_t width, uint32_t height ) /// Broadcast a message letting everyone know that we were recreated and that /// all device-specific stuff needs to be recreated - plDeviceRecreateMsg* clean = new plDeviceRecreateMsg(); + plDeviceRecreateMsg* clean = new plDeviceRecreateMsg(this); plgDispatch::MsgSend(clean); } @@ -3815,7 +3815,7 @@ bool plDXPipeline::BeginRender() { /// Broadcast a message letting everyone know that we were recreated and that /// all device-specific stuff needs to be recreated -// plDeviceRecreateMsg* clean = new plDeviceRecreateMsg(); +// plDeviceRecreateMsg* clean = new plDeviceRecreateMsg(this); // plgDispatch::MsgSend(clean); fDevWasLost = false;