|
@@ -8,11 +8,22 @@ namespace BansheeEngine
|
|
|
RenderWindowManager::RenderWindowManager()
|
|
RenderWindowManager::RenderWindowManager()
|
|
|
:mWindowInFocus(nullptr), mNewWindowInFocus(nullptr)
|
|
:mWindowInFocus(nullptr), mNewWindowInFocus(nullptr)
|
|
|
{
|
|
{
|
|
|
- Platform::onWindowFocusReceived.connect(std::bind(&RenderWindowManager::windowFocusReceived, this, _1));
|
|
|
|
|
- Platform::onWindowFocusLost.connect(std::bind(&RenderWindowManager::windowFocusLost, this, _1));
|
|
|
|
|
Platform::onMouseLeftWindow.connect(std::bind(&RenderWindowManager::windowMouseLeft, this, _1));
|
|
Platform::onMouseLeftWindow.connect(std::bind(&RenderWindowManager::windowMouseLeft, this, _1));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ RenderWindowManager::~RenderWindowManager()
|
|
|
|
|
+ {
|
|
|
|
|
+ for (auto& dirtyPropertyEntry : mDirtyProperties)
|
|
|
|
|
+ {
|
|
|
|
|
+ DirtyPropertyData& dirtyPropertyData = dirtyPropertyEntry.second;
|
|
|
|
|
+
|
|
|
|
|
+ if (dirtyPropertyEntry.second.data != nullptr)
|
|
|
|
|
+ bs_delete(dirtyPropertyEntry.second.data);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ mDirtyProperties.clear();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
RenderWindowPtr RenderWindowManager::create(RENDER_WINDOW_DESC& desc, RenderWindowPtr parentWindow)
|
|
RenderWindowPtr RenderWindowManager::create(RENDER_WINDOW_DESC& desc, RenderWindowPtr parentWindow)
|
|
|
{
|
|
{
|
|
|
RenderWindowPtr renderWindow = createImpl(desc, parentWindow);
|
|
RenderWindowPtr renderWindow = createImpl(desc, parentWindow);
|
|
@@ -29,7 +40,7 @@ namespace BansheeEngine
|
|
|
return renderWindow;
|
|
return renderWindow;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- void RenderWindowManager::windowDestroyed(RenderWindow* window)
|
|
|
|
|
|
|
+ void RenderWindowManager::notifyWindowDestroyed(RenderWindow* window)
|
|
|
{
|
|
{
|
|
|
{
|
|
{
|
|
|
BS_LOCK_MUTEX(mWindowMutex);
|
|
BS_LOCK_MUTEX(mWindowMutex);
|
|
@@ -46,29 +57,43 @@ namespace BansheeEngine
|
|
|
if(iterFind2 != mMovedOrResizedWindows.end())
|
|
if(iterFind2 != mMovedOrResizedWindows.end())
|
|
|
mMovedOrResizedWindows.erase(iterFind2);
|
|
mMovedOrResizedWindows.erase(iterFind2);
|
|
|
|
|
|
|
|
|
|
+ auto iterFind3 = mDirtyProperties.find(window);
|
|
|
|
|
+ if (iterFind3 != mDirtyProperties.end())
|
|
|
|
|
+ {
|
|
|
|
|
+ if (iterFind3->second.data != nullptr)
|
|
|
|
|
+ bs_delete(iterFind3->second.data);
|
|
|
|
|
+
|
|
|
|
|
+ mDirtyProperties.erase(iterFind3);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
mCoreToNonCoreMap.erase(window->getCore().get());
|
|
mCoreToNonCoreMap.erase(window->getCore().get());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- void RenderWindowManager::windowFocusReceived(RenderWindowCore* coreWindow)
|
|
|
|
|
|
|
+ void RenderWindowManager::notifyFocusReceived(RenderWindowCore* coreWindow)
|
|
|
{
|
|
{
|
|
|
- coreWindow->_windowFocusReceived();
|
|
|
|
|
RenderWindow* window = getNonCore(coreWindow);
|
|
RenderWindow* window = getNonCore(coreWindow);
|
|
|
|
|
|
|
|
BS_LOCK_MUTEX(mWindowMutex);
|
|
BS_LOCK_MUTEX(mWindowMutex);
|
|
|
mNewWindowInFocus = window;
|
|
mNewWindowInFocus = window;
|
|
|
|
|
+
|
|
|
|
|
+ setDirtyProperties(coreWindow);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- void RenderWindowManager::windowFocusLost(RenderWindowCore* window)
|
|
|
|
|
|
|
+ void RenderWindowManager::notifyFocusLost(RenderWindowCore* coreWindow)
|
|
|
{
|
|
{
|
|
|
- window->_windowFocusLost();
|
|
|
|
|
|
|
+ RenderWindow* window = getNonCore(coreWindow);
|
|
|
|
|
|
|
|
BS_LOCK_MUTEX(mWindowMutex);
|
|
BS_LOCK_MUTEX(mWindowMutex);
|
|
|
mNewWindowInFocus = nullptr;
|
|
mNewWindowInFocus = nullptr;
|
|
|
|
|
+
|
|
|
|
|
+ setDirtyProperties(coreWindow);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- void RenderWindowManager::windowMovedOrResized(RenderWindow* window)
|
|
|
|
|
|
|
+ void RenderWindowManager::notifyMovedOrResized(RenderWindowCore* coreWindow)
|
|
|
{
|
|
{
|
|
|
|
|
+ RenderWindow* window = getNonCore(coreWindow);
|
|
|
|
|
+
|
|
|
bool isValidWindow = false;
|
|
bool isValidWindow = false;
|
|
|
{
|
|
{
|
|
|
BS_LOCK_MUTEX(mWindowMutex);
|
|
BS_LOCK_MUTEX(mWindowMutex);
|
|
@@ -83,8 +108,37 @@ namespace BansheeEngine
|
|
|
|
|
|
|
|
auto iterFind = std::find(begin(mMovedOrResizedWindows), end(mMovedOrResizedWindows), window);
|
|
auto iterFind = std::find(begin(mMovedOrResizedWindows), end(mMovedOrResizedWindows), window);
|
|
|
|
|
|
|
|
- if(iterFind == end(mMovedOrResizedWindows))
|
|
|
|
|
|
|
+ if (iterFind == end(mMovedOrResizedWindows))
|
|
|
mMovedOrResizedWindows.push_back(window);
|
|
mMovedOrResizedWindows.push_back(window);
|
|
|
|
|
+
|
|
|
|
|
+ setDirtyProperties(coreWindow);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void RenderWindowManager::notifyPropertiesDirty(RenderWindowCore* coreWindow)
|
|
|
|
|
+ {
|
|
|
|
|
+ RenderWindow* window = getNonCore(coreWindow);
|
|
|
|
|
+
|
|
|
|
|
+ BS_LOCK_MUTEX(mWindowMutex);
|
|
|
|
|
+ setDirtyProperties(coreWindow);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void RenderWindowManager::setDirtyProperties(RenderWindowCore* coreWindow)
|
|
|
|
|
+ {
|
|
|
|
|
+ RenderWindow* window = getNonCore(coreWindow);
|
|
|
|
|
+
|
|
|
|
|
+ auto iterFind = mDirtyProperties.find(window);
|
|
|
|
|
+ if (iterFind != mDirtyProperties.end())
|
|
|
|
|
+ {
|
|
|
|
|
+ if (iterFind->second.data != nullptr)
|
|
|
|
|
+ bs_delete(iterFind->second.data);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ mDirtyProperties[window] = DirtyPropertyData();
|
|
|
|
|
+ DirtyPropertyData& dirtyPropertyData = mDirtyProperties[window];
|
|
|
|
|
+ dirtyPropertyData.size = coreWindow->getSyncData(nullptr);
|
|
|
|
|
+ dirtyPropertyData.data = (UINT8*)bs_alloc(dirtyPropertyData.size);
|
|
|
|
|
+
|
|
|
|
|
+ coreWindow->getSyncData(dirtyPropertyData.data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void RenderWindowManager::windowMouseLeft(RenderWindowCore* coreWindow)
|
|
void RenderWindowManager::windowMouseLeft(RenderWindowCore* coreWindow)
|
|
@@ -113,6 +167,19 @@ namespace BansheeEngine
|
|
|
|
|
|
|
|
mouseLeftWindows = mMouseLeftWindows;
|
|
mouseLeftWindows = mMouseLeftWindows;
|
|
|
mMouseLeftWindows.clear();
|
|
mMouseLeftWindows.clear();
|
|
|
|
|
+
|
|
|
|
|
+ for (auto& dirtyPropertyEntry : mDirtyProperties)
|
|
|
|
|
+ {
|
|
|
|
|
+ RenderWindow* window = dirtyPropertyEntry.first;
|
|
|
|
|
+ DirtyPropertyData& dirtyPropertyData = dirtyPropertyEntry.second;
|
|
|
|
|
+
|
|
|
|
|
+ window->setSyncData(dirtyPropertyData.data, dirtyPropertyData.size);
|
|
|
|
|
+
|
|
|
|
|
+ if (dirtyPropertyEntry.second.data != nullptr)
|
|
|
|
|
+ bs_delete(dirtyPropertyEntry.second.data);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ mDirtyProperties.clear();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(mWindowInFocus != newWinInFocus)
|
|
if(mWindowInFocus != newWinInFocus)
|