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,13 +56,11 @@ IDrawingSurfaceBackgroundContentProvider^ Direct3DInterop::CreateContentProvider
// Interface With Direct3DContentProvider
HRESULT Direct3DInterop::Connect(_In_ IDrawingSurfaceRuntimeHostNative* host, _In_ ID3D11Device1* device)
{
//m_renderer->SetDevice(device);
return S_OK;
}
void Direct3DInterop::Disconnect()
{
std::lock_guard<std::mutex> guard(mRenderingMutex);
m_renderer->Disconnect();
}
@ -143,8 +141,6 @@ HRESULT Direct3DInterop::PrepareResources(_In_ const LARGE_INTEGER* presentTarge
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);
#if 0
if(mCurrentOrientation != WindowOrientation)

View File

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

View File

@ -24,6 +24,7 @@ THE SOFTWARE.
****************************************************************************/
#include "DirectXBase.h"
#include "DirectXHelper.h"
using namespace DirectX;
using namespace Microsoft::WRL;
@ -167,11 +168,11 @@ void DirectXBase::Render()
void DirectXBase::CloseAngle()
{
eglMakeCurrent(NULL, NULL, NULL, NULL);
if(m_eglDisplay && m_eglSurface)
if(m_eglPhoneWindow != nullptr)
{
eglDestroySurface(m_eglDisplay, m_eglSurface);
m_eglSurface = nullptr;
m_eglPhoneWindow->Update(nullptr, nullptr, nullptr);
}
if(m_eglDisplay && m_eglContext)
@ -180,30 +181,26 @@ void DirectXBase::CloseAngle()
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);
m_eglDisplay = nullptr;
}
if(m_eglPhoneWindow != nullptr)
{
m_eglPhoneWindow->Update(nullptr, nullptr, nullptr);
}
eglMakeCurrent(NULL, NULL, NULL, NULL);
if(m_device)
{
m_device->Release();
m_device = nullptr;
}
#if 0
m_eglPhoneWindow = nullptr;
m_eglWindow = nullptr;
#endif // 0
m_bAngleInitialized = false;
}
@ -262,10 +259,12 @@ bool DirectXBase::InitializeAngle(ID3D11Device1* d3dDevice, ID3D11DeviceContext1
m_eglPhoneWindow->Update(d3dDevice, d3dContext, d3dRenderTargetView);
ComPtr<IUnknown> u;
HRESULT r = m_eglPhoneWindow.As(&u);
if(m_eglWindow == nullptr)
{ 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 <DirectXMath.h>
#include "DirectXHelper.h"
#include "CCGL.h"
#include "EGL/egl.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.
ref class DirectXBase abstract