updated to latest version of Angle to fix memory leak when switching apps

This commit is contained in:
Dale Stammen 2014-06-12 16:35:24 -07:00
parent b0bc971523
commit 29b9da34ea
4 changed files with 23 additions and 26 deletions

View File

@ -56,14 +56,12 @@ IDrawingSurfaceBackgroundContentProvider^ Direct3DInterop::CreateContentProvider
// Interface With Direct3DContentProvider // Interface With Direct3DContentProvider
HRESULT Direct3DInterop::Connect(_In_ IDrawingSurfaceRuntimeHostNative* host, _In_ ID3D11Device1* device) HRESULT Direct3DInterop::Connect(_In_ IDrawingSurfaceRuntimeHostNative* host, _In_ ID3D11Device1* device)
{ {
//m_renderer->SetDevice(device);
return S_OK; return S_OK;
} }
void Direct3DInterop::Disconnect() void Direct3DInterop::Disconnect()
{ {
std::lock_guard<std::mutex> guard(mRenderingMutex); m_renderer->Disconnect();
m_renderer->Disconnect();
} }
// IDrawingSurfaceManipulationHandler // IDrawingSurfaceManipulationHandler
@ -143,8 +141,6 @@ HRESULT Direct3DInterop::PrepareResources(_In_ const LARGE_INTEGER* presentTarge
HRESULT Direct3DInterop::Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceContext1* context, _In_ ID3D11RenderTargetView* renderTargetView) HRESULT Direct3DInterop::Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceContext1* context, _In_ ID3D11RenderTargetView* renderTargetView)
{ {
std::lock_guard<std::mutex> guard(mRenderingMutex);
m_renderer->UpdateDevice(device, context, renderTargetView); m_renderer->UpdateDevice(device, context, renderTargetView);
#if 0 #if 0
if(mCurrentOrientation != WindowOrientation) if(mCurrentOrientation != WindowOrientation)

View File

@ -87,8 +87,6 @@ private:
Windows::Graphics::Display::DisplayOrientations mCurrentOrientation; Windows::Graphics::Display::DisplayOrientations mCurrentOrientation;
std::mutex mRenderingMutex;
Cocos2dEventDelegate^ m_delegate; Cocos2dEventDelegate^ m_delegate;
Cocos2dMessageBoxDelegate^ m_messageBoxDelegate; Cocos2dMessageBoxDelegate^ m_messageBoxDelegate;
Cocos2dEditBoxDelegate^ m_editBoxDelegate; Cocos2dEditBoxDelegate^ m_editBoxDelegate;

View File

@ -24,6 +24,7 @@ THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "DirectXBase.h" #include "DirectXBase.h"
#include "DirectXHelper.h"
using namespace DirectX; using namespace DirectX;
using namespace Microsoft::WRL; using namespace Microsoft::WRL;
@ -167,12 +168,12 @@ void DirectXBase::Render()
void DirectXBase::CloseAngle() void DirectXBase::CloseAngle()
{ {
eglMakeCurrent(NULL, NULL, NULL, NULL);
if(m_eglDisplay && m_eglSurface) if(m_eglPhoneWindow != nullptr)
{ {
eglDestroySurface(m_eglDisplay, m_eglSurface); m_eglPhoneWindow->Update(nullptr, nullptr, nullptr);
m_eglSurface = nullptr; }
}
if(m_eglDisplay && m_eglContext) if(m_eglDisplay && m_eglContext)
{ {
@ -180,18 +181,17 @@ void DirectXBase::CloseAngle()
m_eglContext = nullptr; m_eglContext = nullptr;
} }
if(m_eglDisplay) if(m_eglDisplay && m_eglSurface)
{
eglDestroySurface(m_eglDisplay, m_eglSurface);
m_eglSurface = nullptr;
}
if(m_eglDisplay)
{ {
eglTerminate(m_eglDisplay); eglTerminate(m_eglDisplay);
m_eglDisplay = nullptr; m_eglDisplay = nullptr;
} }
if(m_eglPhoneWindow != nullptr)
{
m_eglPhoneWindow->Update(nullptr, nullptr, nullptr);
}
eglMakeCurrent(NULL, NULL, NULL, NULL);
if(m_device) if(m_device)
{ {
@ -199,11 +199,8 @@ void DirectXBase::CloseAngle()
m_device = nullptr; m_device = nullptr;
} }
#if 0
m_eglPhoneWindow = nullptr; m_eglPhoneWindow = nullptr;
m_eglWindow = nullptr; m_eglWindow = nullptr;
#endif // 0
m_bAngleInitialized = false; m_bAngleInitialized = false;
} }
@ -262,10 +259,12 @@ bool DirectXBase::InitializeAngle(ID3D11Device1* d3dDevice, ID3D11DeviceContext1
m_eglPhoneWindow->Update(d3dDevice, d3dContext, d3dRenderTargetView); m_eglPhoneWindow->Update(d3dDevice, d3dContext, d3dRenderTargetView);
ComPtr<IUnknown> u;
HRESULT r = m_eglPhoneWindow.As(&u);
if(m_eglWindow == nullptr) if(m_eglWindow == nullptr)
{ DX::ThrowIfFailed( { DX::ThrowIfFailed(
CreateWinrtEglWindow(m_eglPhoneWindow.Get(), featureLevel, m_eglWindow.GetAddressOf()) CreateWinrtEglWindow(u.Get(), featureLevel, m_eglWindow.GetAddressOf())
); );
} }

View File

@ -27,8 +27,12 @@ THE SOFTWARE.
#include <d3d11_1.h> #include <d3d11_1.h>
#include <DirectXMath.h> #include <DirectXMath.h>
#include "DirectXHelper.h" #include "EGL/egl.h"
#include "CCGL.h" #include "EGL/eglext.h"
#include "EGL/eglplatform.h"
#include "GLES2/gl2.h"
#include "GLES2/gl2ext.h"
#include "winrtangle.h"
// Helper class that initializes DirectX APIs for 3D rendering. // Helper class that initializes DirectX APIs for 3D rendering.
ref class DirectXBase abstract ref class DirectXBase abstract