mirror of https://github.com/axmolengine/axmol.git
[Mac] fix memory leaks
This commit is contained in:
parent
a25b1b3f2f
commit
09b0d9c843
|
@ -59,13 +59,10 @@ static id s_sharedDirectorCaller;
|
||||||
-(void) dealloc
|
-(void) dealloc
|
||||||
{
|
{
|
||||||
s_sharedDirectorCaller = nil;
|
s_sharedDirectorCaller = nil;
|
||||||
NSLog(@"~~ delete CCDirectorCaller");
|
NSLog(@"cocos2d: deallocing CCDirectorCaller %@", self);
|
||||||
if (displayLink) {
|
if (displayLink) {
|
||||||
CVDisplayLinkRelease(displayLink);
|
CVDisplayLinkRelease(displayLink);
|
||||||
}
|
}
|
||||||
if (renderTimer) {
|
|
||||||
[renderTimer release];
|
|
||||||
}
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Copyright (c) 2010 cocos2d-x.org
|
Copyright (c) 2010 cocos2d-x.org
|
||||||
|
|
||||||
http://www.cocos2d-x.org
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __CC_EGLVIEW_MAC_H__
|
#ifndef __CC_EGLVIEW_MAC_H__
|
||||||
#define __CC_EGLVIEW_MAC_H__
|
#define __CC_EGLVIEW_MAC_H__
|
||||||
|
@ -28,7 +28,8 @@ THE SOFTWARE.
|
||||||
#include "platform/CCCommon.h"
|
#include "platform/CCCommon.h"
|
||||||
#include "platform/CCEGLViewProtocol.h"
|
#include "platform/CCEGLViewProtocol.h"
|
||||||
|
|
||||||
namespace cocos2d {
|
NS_CC_BEGIN
|
||||||
|
|
||||||
class CCSet;
|
class CCSet;
|
||||||
class CCTouch;
|
class CCTouch;
|
||||||
class CCSize;
|
class CCSize;
|
||||||
|
@ -36,22 +37,25 @@ class CCSize;
|
||||||
class CC_DLL CCEGLView : public CCEGLViewProtocol
|
class CC_DLL CCEGLView : public CCEGLViewProtocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CCEGLView();
|
static CCEGLView* sharedOpenGLView(void);
|
||||||
virtual ~CCEGLView();
|
static void purgeSharedOpenGLView(void);
|
||||||
|
|
||||||
bool isOpenGLReady();
|
virtual ~CCEGLView(void);
|
||||||
|
|
||||||
|
virtual bool isOpenGLReady(void);
|
||||||
virtual bool setContentScaleFactor(float contentScaleFactor);
|
virtual bool setContentScaleFactor(float contentScaleFactor);
|
||||||
void end();
|
virtual void end();
|
||||||
void swapBuffers();
|
virtual void swapBuffers(void);
|
||||||
|
|
||||||
void setIMEKeyboardState(bool bOpen);
|
virtual void setIMEKeyboardState(bool bOpen);
|
||||||
|
virtual void setMultiTouchMask(bool mask);
|
||||||
|
|
||||||
void setMultiTouchMask(bool mask);
|
private:
|
||||||
|
static CCEGLView* s_sharedView;
|
||||||
static CCEGLView* sharedOpenGLView();
|
|
||||||
|
|
||||||
|
CCEGLView(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of namespace cocos2d
|
NS_CC_END // end of namespace cocos2d
|
||||||
|
|
||||||
#endif // end of __CC_EGLVIEW_MAC_H__
|
#endif // end of __CC_EGLVIEW_MAC_H__
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Copyright (c) 2010 cocos2d-x.org
|
Copyright (c) 2010 cocos2d-x.org
|
||||||
|
|
||||||
http://www.cocos2d-x.org
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "CCEGLView.h"
|
#include "CCEGLView.h"
|
||||||
#include "EAGLView.h"
|
#include "EAGLView.h"
|
||||||
#include "CCDirectorCaller.h"
|
#include "CCDirectorCaller.h"
|
||||||
|
@ -28,19 +28,40 @@ THE SOFTWARE.
|
||||||
#include "CCTouch.h"
|
#include "CCTouch.h"
|
||||||
#include "CCTouchDispatcher.h"
|
#include "CCTouchDispatcher.h"
|
||||||
|
|
||||||
namespace cocos2d {
|
NS_CC_BEGIN
|
||||||
|
|
||||||
CCEGLView::CCEGLView()
|
CCEGLView* CCEGLView::s_sharedView = NULL;
|
||||||
|
|
||||||
|
CCEGLView* CCEGLView::sharedOpenGLView(void)
|
||||||
|
{
|
||||||
|
if (!s_sharedView)
|
||||||
|
{
|
||||||
|
s_sharedView = new CCEGLView();
|
||||||
|
}
|
||||||
|
return s_sharedView;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCEGLView::purgeSharedOpenGLView(void)
|
||||||
|
{
|
||||||
|
if (s_sharedView)
|
||||||
|
{
|
||||||
|
delete s_sharedView;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CCEGLView::CCEGLView(void)
|
||||||
{
|
{
|
||||||
m_obScreenSize.width = m_obDesignResolutionSize.width = [[EAGLView sharedEGLView] getWidth];
|
m_obScreenSize.width = m_obDesignResolutionSize.width = [[EAGLView sharedEGLView] getWidth];
|
||||||
m_obScreenSize.height = m_obDesignResolutionSize.height = [[EAGLView sharedEGLView] getHeight];
|
m_obScreenSize.height = m_obDesignResolutionSize.height = [[EAGLView sharedEGLView] getHeight];
|
||||||
}
|
}
|
||||||
|
|
||||||
CCEGLView::~CCEGLView()
|
CCEGLView::~CCEGLView(void)
|
||||||
{
|
{
|
||||||
|
CCLOG("cocos2d: deallocing CCEGLView %0x", this);
|
||||||
|
s_sharedView = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCEGLView::isOpenGLReady()
|
bool CCEGLView::isOpenGLReady(void)
|
||||||
{
|
{
|
||||||
return [EAGLView sharedEGLView] != NULL;
|
return [EAGLView sharedEGLView] != NULL;
|
||||||
}
|
}
|
||||||
|
@ -50,14 +71,14 @@ bool CCEGLView::setContentScaleFactor(float contentScaleFactor)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCEGLView::end()
|
void CCEGLView::end(void)
|
||||||
{
|
{
|
||||||
[[CCDirectorCaller sharedDirectorCaller] end];
|
[[CCDirectorCaller sharedDirectorCaller] end];
|
||||||
|
|
||||||
// destroy EAGLView
|
// destroy EAGLView
|
||||||
[[EAGLView sharedEGLView] removeFromSuperview];
|
[[EAGLView sharedEGLView] removeFromSuperview];
|
||||||
|
|
||||||
// _exit(0);
|
purgeSharedOpenGLView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCEGLView::swapBuffers()
|
void CCEGLView::swapBuffers()
|
||||||
|
@ -83,10 +104,4 @@ void CCEGLView::setMultiTouchMask(bool mask)
|
||||||
//glView.multipleTouchEnabled = mask ? YES : NO;
|
//glView.multipleTouchEnabled = mask ? YES : NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCEGLView* CCEGLView::sharedOpenGLView()
|
NS_CC_END // end of namespace cocos2d;
|
||||||
{
|
|
||||||
static CCEGLView instance;
|
|
||||||
return &instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end of namespace cocos2d;
|
|
||||||
|
|
Loading…
Reference in New Issue