Merge pull request #2257 from dumganhar/master

Fixing compilation errors when CC_ENABLE_PROFILERS is enabled.
This commit is contained in:
James Chen 2013-03-24 20:58:46 -07:00
commit 15d56f7f65
4 changed files with 37 additions and 71 deletions

View File

@ -203,9 +203,9 @@ It should work same as apples CFSwapInt32LittleToHost(..)
#define CC_PROFILER_STOP_CATEGORY(__cat__, __name__) do{ if(__cat__) CCProfilingEndTimingBlock(__name__); } while(0) #define CC_PROFILER_STOP_CATEGORY(__cat__, __name__) do{ if(__cat__) CCProfilingEndTimingBlock(__name__); } while(0)
#define CC_PROFILER_RESET_CATEGORY(__cat__, __name__) do{ if(__cat__) CCProfilingResetTimingBlock(__name__); } while(0) #define CC_PROFILER_RESET_CATEGORY(__cat__, __name__) do{ if(__cat__) CCProfilingResetTimingBlock(__name__); } while(0)
#define CC_PROFILER_START_INSTANCE(__id__, __name__) do{ CCProfilingBeginTimingBlock( [NSString stringWithFormat:@"%08X - %@", __id__, __name__] ); } while(0) #define CC_PROFILER_START_INSTANCE(__id__, __name__) do{ CCProfilingBeginTimingBlock( CCString::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0)
#define CC_PROFILER_STOP_INSTANCE(__id__, __name__) do{ CCProfilingEndTimingBlock( [NSString stringWithFormat:@"%08X - %@", __id__, __name__] ); } while(0) #define CC_PROFILER_STOP_INSTANCE(__id__, __name__) do{ CCProfilingEndTimingBlock( CCString::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0)
#define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do{ CCProfilingResetTimingBlock( [NSString stringWithFormat:@"%08X - %@", __id__, __name__] ); } while(0) #define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do{ CCProfilingResetTimingBlock( CCString::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0)
#else #else

View File

@ -42,6 +42,7 @@
#include "support/zip_support/ZipUtils.h" #include "support/zip_support/ZipUtils.h"
#include "platform/CCFileUtils.h" #include "platform/CCFileUtils.h"
#include "kazmath/GL/matrix.h" #include "kazmath/GL/matrix.h"
#include "support/CCProfiling.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -402,7 +403,7 @@ void CCParticleBatchNode::removeAllChildrenWithCleanup(bool doCleanup)
void CCParticleBatchNode::draw(void) void CCParticleBatchNode::draw(void)
{ {
CC_PROFILER_STOP("CCParticleBatchNode - draw"); CC_PROFILER_START("CCParticleBatchNode - draw");
if( m_pTextureAtlas->getTotalQuads() == 0 ) if( m_pTextureAtlas->getTotalQuads() == 0 )
{ {

View File

@ -165,10 +165,7 @@ void NodeChildrenMainScene::updateQuantityLabel()
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
IterateSpriteSheet::~IterateSpriteSheet() IterateSpriteSheet::~IterateSpriteSheet()
{ {
#if CC_ENABLE_PROFILERS
CCProfiler::releaseTimer(_profilingTimer);
_profilingTimer = NULL;
#endif
} }
void IterateSpriteSheet::updateQuantityOfNodes() void IterateSpriteSheet::updateQuantityOfNodes()
@ -206,14 +203,10 @@ void IterateSpriteSheet::initWithQuantityOfNodes(unsigned int nNodes)
NodeChildrenMainScene::initWithQuantityOfNodes(nNodes); NodeChildrenMainScene::initWithQuantityOfNodes(nNodes);
#if CC_ENABLE_PROFILERS
_profilingTimer = CCProfiler::timerWithName(profilerName().c_str(), this);
#endif
scheduleUpdate(); scheduleUpdate();
} }
std::string IterateSpriteSheet::profilerName() const char* IterateSpriteSheet::profilerName()
{ {
return "none"; return "none";
} }
@ -229,9 +222,7 @@ void IterateSpriteSheetFastEnum::update(float dt)
CCArray* pChildren = batchNode->getChildren(); CCArray* pChildren = batchNode->getChildren();
CCObject* pObject = NULL; CCObject* pObject = NULL;
#if CC_ENABLE_PROFILERS CC_PROFILER_START_INSTANCE(this, this->profilerName());
CCProfilingBeginTimingBlock(_profilingTimer);
#endif
CCARRAY_FOREACH(pChildren, pObject) CCARRAY_FOREACH(pChildren, pObject)
{ {
@ -239,9 +230,7 @@ void IterateSpriteSheetFastEnum::update(float dt)
pSprite->setVisible(false); pSprite->setVisible(false);
} }
#if CC_ENABLE_PROFILERS CC_PROFILER_STOP_INSTANCE(this, this->profilerName());
CCProfilingEndTimingBlock(_profilingTimer);
#endif
} }
std::string IterateSpriteSheetFastEnum::title() std::string IterateSpriteSheetFastEnum::title()
@ -254,7 +243,7 @@ std::string IterateSpriteSheetFastEnum::subtitle()
return "Iterate children using Fast Enum API. See console"; return "Iterate children using Fast Enum API. See console";
} }
std::string IterateSpriteSheetFastEnum::profilerName() const char* IterateSpriteSheetFastEnum::profilerName()
{ {
return "iter fast enum"; return "iter fast enum";
} }
@ -270,9 +259,7 @@ void IterateSpriteSheetCArray::update(float dt)
CCArray* pChildren = batchNode->getChildren(); CCArray* pChildren = batchNode->getChildren();
CCObject* pObject = NULL; CCObject* pObject = NULL;
#if CC_ENABLE_PROFILERS CC_PROFILER_START(this->profilerName());
CCProfilingBeginTimingBlock(_profilingTimer);
#endif
CCARRAY_FOREACH(pChildren, pObject) CCARRAY_FOREACH(pChildren, pObject)
{ {
@ -280,9 +267,7 @@ void IterateSpriteSheetCArray::update(float dt)
pSprite->setVisible(false); pSprite->setVisible(false);
} }
#if CC_ENABLE_PROFILERS CC_PROFILER_STOP(this->profilerName());
CCProfilingEndTimingBlock(_profilingTimer);
#endif
} }
@ -296,7 +281,7 @@ std::string IterateSpriteSheetCArray::subtitle()
return "Iterate children using C Array API. See console"; return "Iterate children using C Array API. See console";
} }
std::string IterateSpriteSheetCArray::profilerName() const char* IterateSpriteSheetCArray::profilerName()
{ {
return "iter c-array"; return "iter c-array";
} }
@ -308,10 +293,7 @@ std::string IterateSpriteSheetCArray::profilerName()
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
AddRemoveSpriteSheet::~AddRemoveSpriteSheet() AddRemoveSpriteSheet::~AddRemoveSpriteSheet()
{ {
#if CC_ENABLE_PROFILERS
CCProfiler::releaseTimer(_profilingTimer);
_profilingTimer = NULL; _profilingTimer = NULL;
#endif
} }
void AddRemoveSpriteSheet::initWithQuantityOfNodes(unsigned int nNodes) void AddRemoveSpriteSheet::initWithQuantityOfNodes(unsigned int nNodes)
@ -321,10 +303,6 @@ void AddRemoveSpriteSheet::initWithQuantityOfNodes(unsigned int nNodes)
NodeChildrenMainScene::initWithQuantityOfNodes(nNodes); NodeChildrenMainScene::initWithQuantityOfNodes(nNodes);
#if CC_ENABLE_PROFILERS
_profilingTimer = CCProfiler::timerWithName(profilerName().c_str(), this);
#endif
scheduleUpdate(); scheduleUpdate();
} }
@ -356,7 +334,7 @@ void AddRemoveSpriteSheet::updateQuantityOfNodes()
currentQuantityOfNodes = quantityOfNodes; currentQuantityOfNodes = quantityOfNodes;
} }
std::string AddRemoveSpriteSheet::profilerName() const char* AddRemoveSpriteSheet::profilerName()
{ {
return "none"; return "none";
} }
@ -388,18 +366,16 @@ void AddSpriteSheet::update(float dt)
} }
// add them with random Z (very important!) // add them with random Z (very important!)
#if CC_ENABLE_PROFILERS CC_PROFILER_START( this->profilerName() );
CCProfilingBeginTimingBlock(_profilingTimer);
#endif
for( int i=0; i < totalToAdd;i++ ) for( int i=0; i < totalToAdd;i++ )
{ {
batchNode->addChild((CCNode*) (sprites->objectAtIndex(i)), zs[i], kTagBase+i); batchNode->addChild((CCNode*) (sprites->objectAtIndex(i)), zs[i], kTagBase+i);
} }
#if CC_ENABLE_PROFILERS batchNode->sortAllChildren();
CCProfilingEndTimingBlock(_profilingTimer);
#endif CC_PROFILER_STOP(this->profilerName());
// remove them // remove them
for( int i=0;i < totalToAdd;i++) for( int i=0;i < totalToAdd;i++)
@ -421,7 +397,7 @@ std::string AddSpriteSheet::subtitle()
return "Adds %10 of total sprites with random z. See console"; return "Adds %10 of total sprites with random z. See console";
} }
std::string AddSpriteSheet::profilerName() const char* AddSpriteSheet::profilerName()
{ {
return "add sprites"; return "add sprites";
} }
@ -456,18 +432,14 @@ void RemoveSpriteSheet::update(float dt)
} }
// remove them // remove them
#if CC_ENABLE_PROFILERS CC_PROFILER_START( this->profilerName() );
CCProfilingBeginTimingBlock(_profilingTimer);
#endif
for( int i=0;i < totalToAdd;i++) for( int i=0;i < totalToAdd;i++)
{ {
batchNode->removeChildByTag(kTagBase+i, true); batchNode->removeChildByTag(kTagBase+i, true);
} }
#if CC_ENABLE_PROFILERS CC_PROFILER_STOP( this->profilerName() );
CCProfilingEndTimingBlock(_profilingTimer);
#endif
} }
} }
@ -481,7 +453,7 @@ std::string RemoveSpriteSheet::subtitle()
return "Remove %10 of total sprites placed randomly. See console"; return "Remove %10 of total sprites placed randomly. See console";
} }
std::string RemoveSpriteSheet::profilerName() const char* RemoveSpriteSheet::profilerName()
{ {
return "remove sprites"; return "remove sprites";
} }
@ -515,12 +487,10 @@ void ReorderSpriteSheet::update(float dt)
batchNode->addChild((CCNode*) (sprites->objectAtIndex(i)), CCRANDOM_MINUS1_1() * 50, kTagBase+i); batchNode->addChild((CCNode*) (sprites->objectAtIndex(i)), CCRANDOM_MINUS1_1() * 50, kTagBase+i);
} }
// [batchNode sortAllChildren]; batchNode->sortAllChildren();
// reorder them // reorder them
#if CC_ENABLE_PROFILERS CC_PROFILER_START( this->profilerName() );
CCProfilingBeginTimingBlock(_profilingTimer);
#endif
for( int i=0;i < totalToAdd;i++) for( int i=0;i < totalToAdd;i++)
{ {
@ -528,9 +498,8 @@ void ReorderSpriteSheet::update(float dt)
batchNode->reorderChild(pNode, CCRANDOM_MINUS1_1() * 50); batchNode->reorderChild(pNode, CCRANDOM_MINUS1_1() * 50);
} }
#if CC_ENABLE_PROFILERS batchNode->sortAllChildren();
CCProfilingEndTimingBlock(_profilingTimer); CC_PROFILER_STOP( this->profilerName() );
#endif
// remove them // remove them
for( int i=0;i < totalToAdd;i++) for( int i=0;i < totalToAdd;i++)
@ -550,7 +519,7 @@ std::string ReorderSpriteSheet::subtitle()
return "Reorder %10 of total sprites placed randomly. See console"; return "Reorder %10 of total sprites placed randomly. See console";
} }
std::string ReorderSpriteSheet::profilerName() const char* ReorderSpriteSheet::profilerName()
{ {
return "reorder sprites"; return "reorder sprites";
} }

View File

@ -38,14 +38,10 @@ public:
virtual void updateQuantityOfNodes(); virtual void updateQuantityOfNodes();
virtual void initWithQuantityOfNodes(unsigned int nNodes); virtual void initWithQuantityOfNodes(unsigned int nNodes);
virtual void update(float dt) = 0; virtual void update(float dt) = 0;
virtual std::string profilerName(); virtual const char* profilerName();
protected: protected:
CCSpriteBatchNode *batchNode; CCSpriteBatchNode *batchNode;
#if CC_ENABLE_PROFILERS
CCProfilingTimer *_profilingTimer;
#endif
}; };
class IterateSpriteSheetFastEnum : public IterateSpriteSheet class IterateSpriteSheetFastEnum : public IterateSpriteSheet
@ -55,7 +51,7 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual std::string profilerName(); virtual const char* profilerName();
}; };
class IterateSpriteSheetCArray : public IterateSpriteSheet class IterateSpriteSheetCArray : public IterateSpriteSheet
@ -65,7 +61,7 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual std::string profilerName(); virtual const char* profilerName();
}; };
class AddRemoveSpriteSheet : public NodeChildrenMainScene class AddRemoveSpriteSheet : public NodeChildrenMainScene
@ -75,7 +71,7 @@ public:
virtual void updateQuantityOfNodes(); virtual void updateQuantityOfNodes();
virtual void initWithQuantityOfNodes(unsigned int nNodes); virtual void initWithQuantityOfNodes(unsigned int nNodes);
virtual void update(float dt) = 0; virtual void update(float dt) = 0;
virtual std::string profilerName(); virtual const char* profilerName();
protected: protected:
CCSpriteBatchNode *batchNode; CCSpriteBatchNode *batchNode;
@ -92,7 +88,7 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual std::string profilerName(); virtual const char* profilerName();
}; };
class RemoveSpriteSheet : public AddRemoveSpriteSheet class RemoveSpriteSheet : public AddRemoveSpriteSheet
@ -102,7 +98,7 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual std::string profilerName(); virtual const char* profilerName();
}; };
class ReorderSpriteSheet : public AddRemoveSpriteSheet class ReorderSpriteSheet : public AddRemoveSpriteSheet
@ -112,7 +108,7 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual std::string profilerName(); virtual const char* profilerName();
}; };
void runNodeChildrenTest(); void runNodeChildrenTest();