Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into iss2433-lua-bindings-generator-new

Conflicts:
	tools/tolua/cocos2dx.ini
This commit is contained in:
samuele3hu 2013-08-30 15:21:59 +08:00
commit 8f338cc209
32 changed files with 229 additions and 103 deletions

View File

@ -574,7 +574,8 @@ Developers:
Fixing a bug that observers with the same target and name but different sender are the same observer in NotificationCenter. Fixing a bug that observers with the same target and name but different sender are the same observer in NotificationCenter.
xbruce xbruce
Fixing a bug that crash appears when extending cc.ScrollView in JS Fixing a bug that crash appears when extending cc.ScrollView in JS.
Fixing a bug that cc.registerTargettedDelegate doesn't support pure js object as its target.
Retired Core Developers: Retired Core Developers:
WenSheng Yang WenSheng Yang

View File

@ -37,7 +37,7 @@ NS_CC_BEGIN
Action::Action() Action::Action()
:_originalTarget(NULL) :_originalTarget(NULL)
,_target(NULL) ,_target(NULL)
,_tag(kActionTagInvalid) ,_tag(Action::INVALID_TAG)
{ {
} }

View File

@ -33,11 +33,6 @@ THE SOFTWARE.
NS_CC_BEGIN NS_CC_BEGIN
enum {
//! Default tag
kActionTagInvalid = -1,
};
/** /**
* @addtogroup actions * @addtogroup actions
* @{ * @{
@ -49,6 +44,9 @@ enum {
class CC_DLL Action : public Object, public Clonable class CC_DLL Action : public Object, public Clonable
{ {
public: public:
/// Default tag used for all the actions
static const int INVALID_TAG = -1;
Action(void); Action(void);
virtual ~Action(void); virtual ~Action(void);

View File

@ -2065,7 +2065,7 @@ void Animate::startWithTarget(Node *target)
if (_animation->getRestoreOriginalFrame()) if (_animation->getRestoreOriginalFrame())
{ {
_origFrame = pSprite->displayFrame(); _origFrame = pSprite->getDisplayFrame();
_origFrame->retain(); _origFrame->retain();
} }
_nextFrame = 0; _nextFrame = 0;

View File

@ -265,9 +265,9 @@ void ActionManager::removeAction(Action *pAction)
} }
} }
void ActionManager::removeActionByTag(unsigned int tag, Object *target) void ActionManager::removeActionByTag(int tag, Object *target)
{ {
CCASSERT((int)tag != kActionTagInvalid, ""); CCASSERT(tag != Action::INVALID_TAG, "");
CCASSERT(target != NULL, ""); CCASSERT(target != NULL, "");
tHashElement *pElement = NULL; tHashElement *pElement = NULL;
@ -293,9 +293,9 @@ void ActionManager::removeActionByTag(unsigned int tag, Object *target)
// XXX: Passing "const O *" instead of "const O&" because HASH_FIND_IT requries the address of a pointer // XXX: Passing "const O *" instead of "const O&" because HASH_FIND_IT requries the address of a pointer
// and, it is not possible to get the address of a reference // and, it is not possible to get the address of a reference
Action* ActionManager::getActionByTag(unsigned int tag, const Object *target) const Action* ActionManager::getActionByTag(int tag, const Object *target) const
{ {
CCASSERT((int)tag != kActionTagInvalid, ""); CCASSERT(tag != Action::INVALID_TAG, "");
tHashElement *pElement = NULL; tHashElement *pElement = NULL;
HASH_FIND_INT(_targets, &target, pElement); HASH_FIND_INT(_targets, &target, pElement);

View File

@ -83,12 +83,12 @@ public:
void removeAction(Action *pAction); void removeAction(Action *pAction);
/** Removes an action given its tag and the target */ /** Removes an action given its tag and the target */
void removeActionByTag(unsigned int tag, Object *target); void removeActionByTag(int tag, Object *target);
/** Gets an action given its tag an a target /** Gets an action given its tag an a target
@return the Action the with the given tag @return the Action the with the given tag
*/ */
Action* getActionByTag(unsigned int tag, const Object *target) const; Action* getActionByTag(int tag, const Object *target) const;
/** Returns the numbers of actions that are running in a certain target. /** Returns the numbers of actions that are running in a certain target.
* Composable actions are counted as 1 action. Example: * Composable actions are counted as 1 action. Example:

View File

@ -83,7 +83,7 @@ Node::Node(void)
, _children(NULL) , _children(NULL)
, _parent(NULL) , _parent(NULL)
// "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true // "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true
, _tag(kNodeTagInvalid) , _tag(Node::INVALID_TAG)
// userData is always inited as nil // userData is always inited as nil
, _userData(NULL) , _userData(NULL)
, _userObject(NULL) , _userObject(NULL)
@ -530,7 +530,7 @@ void Node::childrenAlloc(void)
Node* Node::getChildByTag(int aTag) Node* Node::getChildByTag(int aTag)
{ {
CCASSERT( aTag != kNodeTagInvalid, "Invalid tag"); CCASSERT( aTag != Node::INVALID_TAG, "Invalid tag");
if(_children && _children->count() > 0) if(_children && _children->count() > 0)
{ {
@ -613,11 +613,6 @@ void Node::removeChild(Node* child, bool cleanup /* = true */)
return; return;
} }
// if ( _children->containsObject(child) )
// {
// this->detachChild(child,cleanup);
// }
int index = _children->getIndexOfObject(child); int index = _children->getIndexOfObject(child);
if( index != CC_INVALID_INDEX ) if( index != CC_INVALID_INDEX )
this->detachChild( child, index, cleanup ); this->detachChild( child, index, cleanup );
@ -625,7 +620,7 @@ void Node::removeChild(Node* child, bool cleanup /* = true */)
void Node::removeChildByTag(int tag, bool cleanup/* = true */) void Node::removeChildByTag(int tag, bool cleanup/* = true */)
{ {
CCASSERT( tag != kNodeTagInvalid, "Invalid tag"); CCASSERT( tag != Node::INVALID_TAG, "Invalid tag");
Node *child = this->getChildByTag(tag); Node *child = this->getChildByTag(tag);
@ -859,8 +854,7 @@ void Node::transform()
kmMat4 transfrom4x4; kmMat4 transfrom4x4;
// Convert 3x3 into 4x4 matrix // Convert 3x3 into 4x4 matrix
AffineTransform tmpAffine = this->getNodeToParentTransform(); CGAffineToGL(this->getNodeToParentTransform(), transfrom4x4.mat);
CGAffineToGL(&tmpAffine, transfrom4x4.mat);
// Update Z vertex manually // Update Z vertex manually
transfrom4x4.mat[14] = _vertexZ; transfrom4x4.mat[14] = _vertexZ;
@ -976,13 +970,13 @@ void Node::stopAction(Action* action)
void Node::stopActionByTag(int tag) void Node::stopActionByTag(int tag)
{ {
CCASSERT( tag != kActionTagInvalid, "Invalid tag"); CCASSERT( tag != Action::INVALID_TAG, "Invalid tag");
_actionManager->removeActionByTag(tag, this); _actionManager->removeActionByTag(tag, this);
} }
Action * Node::getActionByTag(int tag) Action * Node::getActionByTag(int tag)
{ {
CCASSERT( tag != kActionTagInvalid, "Invalid tag"); CCASSERT( tag != Action::INVALID_TAG, "Invalid tag");
return _actionManager->getActionByTag(tag, this); return _actionManager->getActionByTag(tag, this);
} }
@ -1101,7 +1095,7 @@ void Node::update(float fDelta)
} }
} }
AffineTransform Node::getNodeToParentTransform() const const AffineTransform& Node::getNodeToParentTransform() const
{ {
if (_transformDirty) if (_transformDirty)
{ {
@ -1184,7 +1178,7 @@ void Node::setAdditionalTransform(const AffineTransform& additionalTransform)
_additionalTransformDirty = true; _additionalTransformDirty = true;
} }
AffineTransform Node::getParentToNodeTransform() const const AffineTransform& Node::getParentToNodeTransform() const
{ {
if ( _inverseDirty ) { if ( _inverseDirty ) {
_inverse = AffineTransformInvert(this->getNodeToParentTransform()); _inverse = AffineTransformInvert(this->getNodeToParentTransform());

View File

@ -58,10 +58,6 @@ class ComponentContainer;
* @{ * @{
*/ */
enum {
kNodeTagInvalid = -1,
};
enum { enum {
kNodeOnEnter, kNodeOnEnter,
kNodeOnExit, kNodeOnExit,
@ -128,6 +124,9 @@ enum {
class CC_DLL Node : public Object class CC_DLL Node : public Object
{ {
public: public:
/// Default tag used for all the nodes
static const int INVALID_TAG = -1;
/// @{ /// @{
/// @name Constructor, Distructor and Initializers /// @name Constructor, Distructor and Initializers
@ -1153,7 +1152,7 @@ public:
* Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates. * Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
* The matrix is in Pixels. * The matrix is in Pixels.
*/ */
virtual AffineTransform getNodeToParentTransform() const; virtual const AffineTransform& getNodeToParentTransform() const;
/** @deprecated use getNodeToParentTransform() instead */ /** @deprecated use getNodeToParentTransform() instead */
CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform nodeToParentTransform() const { return getNodeToParentTransform(); } CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform nodeToParentTransform() const { return getNodeToParentTransform(); }
@ -1162,7 +1161,7 @@ public:
* Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates. * Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
* The matrix is in Pixels. * The matrix is in Pixels.
*/ */
virtual AffineTransform getParentToNodeTransform() const; virtual const AffineTransform& getParentToNodeTransform() const;
/** @deprecated Use getParentToNodeTransform() instead */ /** @deprecated Use getParentToNodeTransform() instead */
CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform parentToNodeTransform() const { return getParentToNodeTransform(); } CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform parentToNodeTransform() const { return getParentToNodeTransform(); }

View File

@ -936,8 +936,8 @@ CC_DEPRECATED_ATTRIBUTE typedef TransitionScene::Orientation tOrientation;
CC_DEPRECATED_ATTRIBUTE const int kCCPrioritySystem = Scheduler::PRIORITY_SYSTEM; CC_DEPRECATED_ATTRIBUTE const int kCCPrioritySystem = Scheduler::PRIORITY_SYSTEM;
CC_DEPRECATED_ATTRIBUTE const int kCCPriorityNonSystemMin = Scheduler::PRIORITY_NON_SYSTEM_MIN; CC_DEPRECATED_ATTRIBUTE const int kCCPriorityNonSystemMin = Scheduler::PRIORITY_NON_SYSTEM_MIN;
CC_DEPRECATED_ATTRIBUTE const int kCCActionTagInvalid = kActionTagInvalid; CC_DEPRECATED_ATTRIBUTE const int kCCActionTagInvalid = Action::INVALID_TAG;
CC_DEPRECATED_ATTRIBUTE const int kCCNodeTagInvalid = kNodeTagInvalid; CC_DEPRECATED_ATTRIBUTE const int kCCNodeTagInvalid = Node::INVALID_TAG;
CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnEnter = kNodeOnEnter; CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnEnter = kNodeOnEnter;
CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnExit = kNodeOnExit; CC_DEPRECATED_ATTRIBUTE const int kCCNodeOnExit = kNodeOnExit;

View File

@ -99,7 +99,7 @@ To enabled set it to 1. Disabled by default.
Default value: 0.1f Default value: 0.1f
*/ */
#ifndef CC_DIRECTOR_STATS_INTERVAL #ifndef CC_DIRECTOR_STATS_INTERVAL
#define CC_DIRECTOR_STATS_INTERVAL (2.0f) #define CC_DIRECTOR_STATS_INTERVAL (0.1f)
#endif #endif
/** @def CC_DIRECTOR_FPS_POSITION /** @def CC_DIRECTOR_FPS_POSITION

View File

@ -118,9 +118,9 @@ struct Color4F
{} {}
explicit Color4F(const Color3B &color3B) explicit Color4F(const Color3B &color3B)
: r(color3B.r) : r(color3B.r / 255.0f)
, g(color3B.g) , g(color3B.g / 255.0f)
, b(color3B.b) , b(color3B.b / 255.0f)
, a(1.f) , a(1.f)
{} {}

View File

@ -218,13 +218,13 @@ kmMat4* const kmMat4Multiply(kmMat4* pOut, const kmMat4* pM1, const kmMat4* pM2)
{ {
#if defined(__ARM_NEON__) #if defined(__ARM_NEON__)
float mat[16]; float *mat = pOut->mat;
// Invert column-order with row-order // Invert column-order with row-order
NEON_Matrix4Mul( &pM2->mat[0], &pM1->mat[0], &mat[0] ); NEON_Matrix4Mul( &pM2->mat[0], &pM1->mat[0], &mat[0] );
#else #else
float mat[16]; float *mat = pOut->mat;
const float *m1 = pM1->mat, *m2 = pM2->mat; const float *m1 = pM1->mat, *m2 = pM2->mat;
@ -250,8 +250,6 @@ kmMat4* const kmMat4Multiply(kmMat4* pOut, const kmMat4* pM1, const kmMat4* pM2)
#endif #endif
memcpy(pOut->mat, mat, sizeof(float)*16);
return pOut; return pOut;
} }

View File

@ -1004,7 +1004,7 @@ bool Sprite::isFrameDisplayed(SpriteFrame *frame) const
frame->getOffset().equals(_unflippedOffsetPositionFromCenter)); frame->getOffset().equals(_unflippedOffsetPositionFromCenter));
} }
SpriteFrame* Sprite::displayFrame(void) SpriteFrame* Sprite::getDisplayFrame()
{ {
return SpriteFrame::createWithTexture(_texture, return SpriteFrame::createWithTexture(_texture,
CC_RECT_POINTS_TO_PIXELS(_rect), CC_RECT_POINTS_TO_PIXELS(_rect),
@ -1013,7 +1013,7 @@ SpriteFrame* Sprite::displayFrame(void)
CC_SIZE_POINTS_TO_PIXELS(_contentSize)); CC_SIZE_POINTS_TO_PIXELS(_contentSize));
} }
SpriteBatchNode* Sprite::getBatchNode(void) SpriteBatchNode* Sprite::getBatchNode()
{ {
return _batchNode; return _batchNode;
} }

View File

@ -329,10 +329,13 @@ public:
*/ */
virtual bool isFrameDisplayed(SpriteFrame *pFrame) const; virtual bool isFrameDisplayed(SpriteFrame *pFrame) const;
/** @deprecated Use getDisplayFrame() instead */
CC_DEPRECATED_ATTRIBUTE virtual SpriteFrame* displayFrame() { return getDisplayFrame(); };
/** /**
* Returns the current displayed frame. * Returns the current displayed frame.
*/ */
virtual SpriteFrame* displayFrame(void); virtual SpriteFrame* getDisplayFrame();
/// @} End of frames methods /// @} End of frames methods

View File

@ -151,17 +151,20 @@ void ProfilingBeginTimingBlock(const char *timerName)
timer->numberOfCalls++; timer->numberOfCalls++;
// should be the last instruction in order to be more reliable
timer->_startTime = chrono::high_resolution_clock::now(); timer->_startTime = chrono::high_resolution_clock::now();
} }
void ProfilingEndTimingBlock(const char *timerName) void ProfilingEndTimingBlock(const char *timerName)
{ {
// should be the 1st instruction in order to be more reliable
auto now = chrono::high_resolution_clock::now();
Profiler* p = Profiler::getInstance(); Profiler* p = Profiler::getInstance();
ProfilingTimer* timer = (ProfilingTimer*)p->_activeTimers->objectForKey(timerName); ProfilingTimer* timer = (ProfilingTimer*)p->_activeTimers->objectForKey(timerName);
CCASSERT(timer, "CCProfilingTimer not found"); CCASSERT(timer, "CCProfilingTimer not found");
auto now = chrono::high_resolution_clock::now();
int duration = chrono::duration_cast<chrono::microseconds>(now - timer->_startTime).count(); int duration = chrono::duration_cast<chrono::microseconds>(now - timer->_startTime).count();
@ -170,7 +173,6 @@ void ProfilingEndTimingBlock(const char *timerName)
timer->_averageTime2 = timer->totalTime / timer->numberOfCalls; timer->_averageTime2 = timer->totalTime / timer->numberOfCalls;
timer->maxTime = MAX( timer->maxTime, duration); timer->maxTime = MAX( timer->maxTime, duration);
timer->minTime = MIN( timer->minTime, duration); timer->minTime = MIN( timer->minTime, duration);
} }
void ProfilingResetTimingBlock(const char *timerName) void ProfilingResetTimingBlock(const char *timerName)

View File

@ -28,7 +28,7 @@ THE SOFTWARE.
namespace cocos2d { namespace cocos2d {
void CGAffineToGL(const AffineTransform *t, GLfloat *m) void CGAffineToGL(const AffineTransform& t, GLfloat *m)
{ {
// | m[0] m[4] m[8] m[12] | | m11 m21 m31 m41 | | a c 0 tx | // | m[0] m[4] m[8] m[12] | | m11 m21 m31 m41 | | a c 0 tx |
// | m[1] m[5] m[9] m[13] | | m12 m22 m32 m42 | | b d 0 ty | // | m[1] m[5] m[9] m[13] | | m12 m22 m32 m42 | | b d 0 ty |
@ -37,8 +37,8 @@ void CGAffineToGL(const AffineTransform *t, GLfloat *m)
m[2] = m[3] = m[6] = m[7] = m[8] = m[9] = m[11] = m[14] = 0.0f; m[2] = m[3] = m[6] = m[7] = m[8] = m[9] = m[11] = m[14] = 0.0f;
m[10] = m[15] = 1.0f; m[10] = m[15] = 1.0f;
m[0] = t->a; m[4] = t->c; m[12] = t->tx; m[0] = t.a; m[4] = t.c; m[12] = t.tx;
m[1] = t->b; m[5] = t->d; m[13] = t->ty; m[1] = t.b; m[5] = t.d; m[13] = t.ty;
} }
void GLToCGAffine(const GLfloat *m, AffineTransform *t) void GLToCGAffine(const GLfloat *m, AffineTransform *t)

View File

@ -34,7 +34,7 @@ namespace cocos2d {
struct AffineTransform; struct AffineTransform;
void CGAffineToGL(const AffineTransform *t, GLfloat *m); void CGAffineToGL(const AffineTransform &t, GLfloat *m);
void GLToCGAffine(const GLfloat *m, AffineTransform *t); void GLToCGAffine(const GLfloat *m, AffineTransform *t);
}//namespace cocos2d }//namespace cocos2d

View File

@ -323,7 +323,7 @@ Dictionary *Armature::getBoneDic()
return _boneDic; return _boneDic;
} }
AffineTransform Armature::getNodeToParentTransform() const const AffineTransform& Armature::getNodeToParentTransform() const
{ {
if (_transformDirty) if (_transformDirty)
{ {

View File

@ -150,7 +150,7 @@ public:
virtual void visit() override; virtual void visit() override;
virtual void update(float dt) override; virtual void update(float dt) override;
virtual void draw() override; virtual void draw() override;
virtual AffineTransform getNodeToParentTransform() const override; virtual const AffineTransform& getNodeToParentTransform() const override;
/** This boundingBox will calculate all bones' boundingBox every time */ /** This boundingBox will calculate all bones' boundingBox every time */
virtual Rect getBoundingBox() const override; virtual Rect getBoundingBox() const override;
inline void setBlendFunc(const BlendFunc& blendFunc) override { _blendFunc = blendFunc; } inline void setBlendFunc(const BlendFunc& blendFunc) override { _blendFunc = blendFunc; }

View File

@ -342,7 +342,7 @@ void PhysicsSprite::setRotation(float fRotation)
} }
// returns the transform matrix according the Chipmunk Body values // returns the transform matrix according the Chipmunk Body values
AffineTransform PhysicsSprite::getNodeToParentTransform() const const AffineTransform& PhysicsSprite::getNodeToParentTransform() const
{ {
// Although scale is not used by physics engines, it is calculated just in case // Although scale is not used by physics engines, it is calculated just in case
// the sprite is animated (scaled up/down) using actions. // the sprite is animated (scaled up/down) using actions.

View File

@ -111,7 +111,7 @@ public:
virtual void setPosition(const Point &position) override; virtual void setPosition(const Point &position) override;
virtual float getRotation() const override; virtual float getRotation() const override;
virtual void setRotation(float fRotation) override; virtual void setRotation(float fRotation) override;
virtual AffineTransform getNodeToParentTransform() const override; virtual const AffineTransform& getNodeToParentTransform() const override;
protected: protected:
const Point& getPosFromPhysics() const; const Point& getPosFromPhysics() const;

View File

@ -10,7 +10,7 @@
#include "ComponentsTest/ComponentsTestScene.h" #include "ComponentsTest/ComponentsTestScene.h"
#include "ArmatureTest/ArmatureScene.h" #include "ArmatureTest/ArmatureScene.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#include "NetworkTest/WebSocketTest.h" #include "NetworkTest/WebSocketTest.h"
#include "NetworkTest/SocketIOTest.h" #include "NetworkTest/SocketIOTest.h"
#endif #endif
@ -59,7 +59,7 @@ static struct {
{ "HttpClientTest", [](Object *sender){ runHttpClientTest();} { "HttpClientTest", [](Object *sender){ runHttpClientTest();}
}, },
#endif #endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
{ "WebSocketTest", [](Object *sender){ runWebSocketTest();} { "WebSocketTest", [](Object *sender){ runWebSocketTest();}
}, },
{ "SocketIOTest", [](Object *sender){ runSocketIOTest();} { "SocketIOTest", [](Object *sender){ runSocketIOTest();}

View File

@ -71,6 +71,7 @@ static std::function<Layer*()> createFunctions[] =
CL(TTFFontShadowAndStroke), CL(TTFFontShadowAndStroke),
// should be moved to another test // should be moved to another test
CL(Atlas1), CL(Atlas1),
CL(LabelBMFontCrashTest),
}; };
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
@ -1611,3 +1612,36 @@ void LabelBMFontBounds::draw()
}; };
DrawPrimitives::drawPoly(vertices, 4, true); DrawPrimitives::drawPoly(vertices, 4, true);
} }
// LabelBMFontCrashTest
void LabelBMFontCrashTest::onEnter()
{
AtlasDemo::onEnter();
auto winSize = Director::getInstance()->getWinSize();
//Create a label and add it
auto label1 = new LabelBMFont();
label1->initWithString("test", "fonts/bitmapFontTest2.fnt");
this->addChild(label1);
// Visit will call draw where the function "ccGLBindVAO(m_uVAOname);" will be invoked.
label1->visit();
// Remove this label
label1->removeFromParentAndCleanup(true);
label1->release();
// Create a new label and add it (then crashes)
auto label2 = LabelBMFont::create("test 2", "fonts/bitmapFontTest.fnt");
label2->setPosition(Point(winSize.width/2, winSize.height/2));
this->addChild(label2);
}
std::string LabelBMFontCrashTest::title()
{
return "LabelBMFont Crash Test";
}
std::string LabelBMFontCrashTest::subtitle()
{
return "Should not crash.";
}

View File

@ -350,6 +350,13 @@ public:
private: private:
}; };
class LabelBMFontCrashTest : public AtlasDemo
{
public:
virtual void onEnter();
virtual std::string title();
virtual std::string subtitle();
};
// we don't support linebreak mode // we don't support linebreak mode

View File

@ -43,6 +43,8 @@ static std::function<NodeChildrenMainScene*()> createFunctions[] =
CL(RemoveSpriteSheet), CL(RemoveSpriteSheet),
CL(ReorderSpriteSheet), CL(ReorderSpriteSheet),
CL(SortAllChildrenSpriteSheet), CL(SortAllChildrenSpriteSheet),
CL(VisitSceneGraph),
}; };
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
@ -147,7 +149,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
updateQuantityLabel(); updateQuantityLabel();
updateQuantityOfNodes(); updateQuantityOfNodes();
updateProfilerName();
CC_PROFILER_PURGE_ALL(); CC_PROFILER_PURGE_ALL();
}); });
decrease->setColor(Color3B(0,200,20)); decrease->setColor(Color3B(0,200,20));
@ -158,7 +160,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
updateQuantityLabel(); updateQuantityLabel();
updateQuantityOfNodes(); updateQuantityOfNodes();
updateProfilerName();
CC_PROFILER_PURGE_ALL(); CC_PROFILER_PURGE_ALL();
}); });
increase->setColor(Color3B(0,200,20)); increase->setColor(Color3B(0,200,20));
@ -179,6 +181,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
updateQuantityLabel(); updateQuantityLabel();
updateQuantityOfNodes(); updateQuantityOfNodes();
updateProfilerName();
} }
std::string NodeChildrenMainScene::title() std::string NodeChildrenMainScene::title()
@ -204,6 +207,17 @@ void NodeChildrenMainScene::updateQuantityLabel()
} }
} }
const char * NodeChildrenMainScene::profilerName()
{
return _profilerName;
}
void NodeChildrenMainScene::updateProfilerName()
{
snprintf(_profilerName, sizeof(_profilerName)-1, "%s(%d)", testName(), quantityOfNodes);
}
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
// //
// IterateSpriteSheet // IterateSpriteSheet
@ -253,7 +267,7 @@ void IterateSpriteSheet::initWithQuantityOfNodes(unsigned int nNodes)
scheduleUpdate(); scheduleUpdate();
} }
const char* IterateSpriteSheet::profilerName() const char* IterateSpriteSheet::testName()
{ {
return "none"; return "none";
} }
@ -290,7 +304,7 @@ std::string IterateSpriteSheetForLoop::subtitle()
return "Iterate children using C++11 range-based for loop. See console"; return "Iterate children using C++11 range-based for loop. See console";
} }
const char* IterateSpriteSheetForLoop::profilerName() const char* IterateSpriteSheetForLoop::testName()
{ {
return "Iterator: C++11 for loop"; return "Iterator: C++11 for loop";
} }
@ -328,7 +342,7 @@ std::string IterateSpriteSheetCArray::subtitle()
return "Iterate children using C Array API. See console"; return "Iterate children using C Array API. See console";
} }
const char* IterateSpriteSheetCArray::profilerName() const char* IterateSpriteSheetCArray::testName()
{ {
return "Iterator: CC_ARRAY_FOREACH"; return "Iterator: CC_ARRAY_FOREACH";
} }
@ -366,7 +380,7 @@ std::string IterateSpriteSheetIterator::subtitle()
return "Iterate children using begin() / end(). See console"; return "Iterate children using begin() / end(). See console";
} }
const char* IterateSpriteSheetIterator::profilerName() const char* IterateSpriteSheetIterator::testName()
{ {
return "Iterator: begin(), end()"; return "Iterator: begin(), end()";
} }
@ -407,12 +421,9 @@ std::string CallFuncsSpriteSheetForEach::subtitle()
return "Using 'std::for_each()'. See console"; return "Using 'std::for_each()'. See console";
} }
const char* CallFuncsSpriteSheetForEach::profilerName() const char* CallFuncsSpriteSheetForEach::testName()
{ {
static char _name[256]; return "Map: std::for_each";
snprintf(_name, sizeof(_name)-1, "Map: std::for_each(%d)", quantityOfNodes);
return _name;
} }
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
@ -443,11 +454,9 @@ std::string CallFuncsSpriteSheetCMacro::subtitle()
return "Using 'arrayMakeObjectsPerformSelector'. See console"; return "Using 'arrayMakeObjectsPerformSelector'. See console";
} }
const char* CallFuncsSpriteSheetCMacro::profilerName() const char* CallFuncsSpriteSheetCMacro::testName()
{ {
static char _name[256]; return "Map: arrayMakeObjectsPerformSelector";
snprintf(_name, sizeof(_name)-1, "Map: arrayMakeObjectsPerformSelector(%d)", quantityOfNodes);
return _name;
} }
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
// //
@ -497,7 +506,7 @@ void AddRemoveSpriteSheet::updateQuantityOfNodes()
currentQuantityOfNodes = quantityOfNodes; currentQuantityOfNodes = quantityOfNodes;
} }
const char* AddRemoveSpriteSheet::profilerName() const char* AddRemoveSpriteSheet::testName()
{ {
return "none"; return "none";
} }
@ -560,7 +569,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";
} }
const char* AddSpriteSheet::profilerName() const char* AddSpriteSheet::testName()
{ {
return "add sprites"; return "add sprites";
} }
@ -625,7 +634,7 @@ std::string GetSpriteSheet::subtitle()
return "Get sprites using getChildByTag(). See console"; return "Get sprites using getChildByTag(). See console";
} }
const char* GetSpriteSheet::profilerName() const char* GetSpriteSheet::testName()
{ {
return "get sprites"; return "get sprites";
} }
@ -681,7 +690,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";
} }
const char* RemoveSpriteSheet::profilerName() const char* RemoveSpriteSheet::testName()
{ {
return "remove sprites"; return "remove sprites";
} }
@ -744,7 +753,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";
} }
const char* ReorderSpriteSheet::profilerName() const char* ReorderSpriteSheet::testName()
{ {
return "reorder sprites"; return "reorder sprites";
} }
@ -809,11 +818,74 @@ std::string SortAllChildrenSpriteSheet::subtitle()
return "Calls sortOfChildren(). See console"; return "Calls sortOfChildren(). See console";
} }
const char* SortAllChildrenSpriteSheet::profilerName() const char* SortAllChildrenSpriteSheet::testName()
{ {
return "sort all children"; return "sort all children";
} }
////////////////////////////////////////////////////////
//
// VisitSceneGraph
//
////////////////////////////////////////////////////////
void VisitSceneGraph::initWithQuantityOfNodes(unsigned int nodes)
{
NodeChildrenMainScene::initWithQuantityOfNodes(nodes);
scheduleUpdate();
}
void VisitSceneGraph::updateQuantityOfNodes()
{
auto s = Director::getInstance()->getWinSize();
// increase nodes
if( currentQuantityOfNodes < quantityOfNodes )
{
for(int i = 0; i < (quantityOfNodes-currentQuantityOfNodes); i++)
{
auto node = Node::create();
this->addChild(node);
node->setVisible(true);
node->setPosition(Point(-1000,-1000));
node->setTag(1000 + currentQuantityOfNodes + i );
}
}
// decrease nodes
else if ( currentQuantityOfNodes > quantityOfNodes )
{
for(int i = 0; i < (currentQuantityOfNodes-quantityOfNodes); i++)
{
this->removeChildByTag(1000 + currentQuantityOfNodes - i -1 );
}
}
currentQuantityOfNodes = quantityOfNodes;
}
void VisitSceneGraph::update(float dt)
{
CC_PROFILER_START( this->profilerName() );
this->visit();
CC_PROFILER_STOP( this->profilerName() );
}
std::string VisitSceneGraph::title()
{
return "K - Performance of visiting the scene graph";
}
std::string VisitSceneGraph::subtitle()
{
return "calls visit() on scene graph. See console";
}
const char* VisitSceneGraph::testName()
{
return "visit scene graph";
}
///----------------------------------------
void runNodeChildrenTest() void runNodeChildrenTest()
{ {
auto scene = createFunctions[g_curCase](); auto scene = createFunctions[g_curCase]();

View File

@ -24,11 +24,18 @@ public:
virtual std::string subtitle(); virtual std::string subtitle();
virtual void updateQuantityOfNodes() = 0; virtual void updateQuantityOfNodes() = 0;
const char* profilerName();
void updateProfilerName();
// for the profiler
virtual const char* testName() = 0;
void updateQuantityLabel(); void updateQuantityLabel();
int getQuantityOfNodes() { return quantityOfNodes; } int getQuantityOfNodes() { return quantityOfNodes; }
protected: protected:
char _profilerName[256];
int lastRenderedCount; int lastRenderedCount;
int quantityOfNodes; int quantityOfNodes;
int currentQuantityOfNodes; int currentQuantityOfNodes;
@ -41,7 +48,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 const char* profilerName(); virtual const char* testName();
protected: protected:
SpriteBatchNode *batchNode; SpriteBatchNode *batchNode;
@ -54,7 +61,7 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual const char* profilerName(); virtual const char* testName();
}; };
class IterateSpriteSheetIterator : public IterateSpriteSheet class IterateSpriteSheetIterator : public IterateSpriteSheet
@ -64,7 +71,7 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual const char* profilerName(); virtual const char* testName();
}; };
class IterateSpriteSheetCArray : public IterateSpriteSheet class IterateSpriteSheetCArray : public IterateSpriteSheet
@ -74,7 +81,7 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual const char* profilerName(); virtual const char* testName();
}; };
class AddRemoveSpriteSheet : public NodeChildrenMainScene class AddRemoveSpriteSheet : public NodeChildrenMainScene
@ -84,7 +91,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 const char* profilerName(); virtual const char* testName();
protected: protected:
SpriteBatchNode *batchNode; SpriteBatchNode *batchNode;
@ -103,7 +110,7 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual const char* profilerName(); virtual const char* testName();
}; };
class CallFuncsSpriteSheetCMacro : public IterateSpriteSheet class CallFuncsSpriteSheetCMacro : public IterateSpriteSheet
@ -113,7 +120,7 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual const char* profilerName(); virtual const char* testName();
}; };
/// ///
@ -125,7 +132,7 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual const char* profilerName(); virtual const char* testName();
}; };
class GetSpriteSheet : public AddRemoveSpriteSheet class GetSpriteSheet : public AddRemoveSpriteSheet
@ -135,7 +142,7 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual const char* profilerName(); virtual const char* testName();
}; };
class RemoveSpriteSheet : public AddRemoveSpriteSheet class RemoveSpriteSheet : public AddRemoveSpriteSheet
@ -145,7 +152,7 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual const char* profilerName(); virtual const char* testName();
}; };
class ReorderSpriteSheet : public AddRemoveSpriteSheet class ReorderSpriteSheet : public AddRemoveSpriteSheet
@ -155,7 +162,7 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual const char* profilerName(); virtual const char* testName();
}; };
class SortAllChildrenSpriteSheet : public AddRemoveSpriteSheet class SortAllChildrenSpriteSheet : public AddRemoveSpriteSheet
@ -165,7 +172,19 @@ public:
virtual std::string title(); virtual std::string title();
virtual std::string subtitle(); virtual std::string subtitle();
virtual const char* profilerName(); virtual const char* testName();
};
class VisitSceneGraph : public NodeChildrenMainScene
{
public:
void initWithQuantityOfNodes(unsigned int nodes) override;
virtual void update(float dt) override;
void updateQuantityOfNodes() override;
virtual std::string title() override;
virtual std::string subtitle() override;
virtual const char* testName() override;
}; };
void runNodeChildrenTest(); void runNodeChildrenTest();

View File

@ -1 +1 @@
27494a13c3cc6a7f31b43439297899a79bda0a02 a9fdccd58c6cf8ce3cb5d00ea294ef9ff216d439

@ -1 +1 @@
Subproject commit bd70d439fec3629bf0acab52e5c059031c2d1372 Subproject commit 5fce1da1cf990641a428a562b366deaafbdc9668

View File

@ -1 +1 @@
1a67569d3ade0153cccbfa71ca5ac5355d03fbd4 966bc5a37a3c925e207d93e66c4913f05ba3bbb7

View File

@ -214,6 +214,7 @@ private:
typedef std::map<JSObject*, JSTouchDelegate*> TouchDelegateMap; typedef std::map<JSObject*, JSTouchDelegate*> TouchDelegateMap;
typedef std::pair<JSObject*, JSTouchDelegate*> TouchDelegatePair; typedef std::pair<JSObject*, JSTouchDelegate*> TouchDelegatePair;
static TouchDelegateMap sTouchDelegateMap; static TouchDelegateMap sTouchDelegateMap;
bool _needUnroot;
}; };

View File

@ -36,7 +36,7 @@ classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.*
# functions from all classes. # functions from all classes.
skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule], skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule],
Sprite::[getQuad displayFrame getBlendFunc ^setPosition$ setBlendFunc setSpriteBatchNode getSpriteBatchNode], Sprite::[getQuad getBlendFunc ^setPosition$ setBlendFunc],
SpriteBatchNode::[getBlendFunc setBlendFunc], SpriteBatchNode::[getBlendFunc setBlendFunc],
MotionStreak::[getBlendFunc setBlendFunc draw update], MotionStreak::[getBlendFunc setBlendFunc draw update],
AtlasNode::[getBlendFunc setBlendFunc], AtlasNode::[getBlendFunc setBlendFunc],
@ -44,7 +44,7 @@ skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject .
LayerColor::[getBlendFunc setBlendFunc], LayerColor::[getBlendFunc setBlendFunc],
ParticleSystem::[getBlendFunc setBlendFunc], ParticleSystem::[getBlendFunc setBlendFunc],
DrawNode::[getBlendFunc setBlendFunc drawPolygon listenBackToForeground], DrawNode::[getBlendFunc setBlendFunc drawPolygon listenBackToForeground],
Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getClassTypeInfo], Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection],
Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased], Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased],
Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns], Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns],
MenuItem.*::[create setCallback initWithCallback], MenuItem.*::[create setCallback initWithCallback],
@ -99,8 +99,7 @@ skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject .
TextureCache::[addPVRTCImage], TextureCache::[addPVRTCImage],
Timer::[getSelector createWithScriptHandler], Timer::[getSelector createWithScriptHandler],
*::[copyWith.* onEnter.* onExit.* ^description$ getObjectType], *::[copyWith.* onEnter.* onExit.* ^description$ getObjectType],
FileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$ getClassTypeInfo], FileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$],
SimpleAudioEngine::[getClassTypeInfo],
Application::[^application.* ^run$], Application::[^application.* ^run$],
Camera::[getEyeXYZ getCenterXYZ getUpXYZ], Camera::[getEyeXYZ getCenterXYZ getUpXYZ],
ccFontDefinition::[*] ccFontDefinition::[*]

View File

@ -36,7 +36,7 @@ classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.*
# functions from all classes. # functions from all classes.
skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule getPosition$], skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule getPosition$],
Sprite::[getQuad displayFrame getBlendFunc ^setPosition$ setBlendFunc setSpriteBatchNode getSpriteBatchNode], Sprite::[getQuad getBlendFunc ^setPosition$ setBlendFunc],
SpriteBatchNode::[getBlendFunc setBlendFunc], SpriteBatchNode::[getBlendFunc setBlendFunc],
MotionStreak::[getBlendFunc setBlendFunc draw update], MotionStreak::[getBlendFunc setBlendFunc draw update],
AtlasNode::[getBlendFunc setBlendFunc], AtlasNode::[getBlendFunc setBlendFunc],
@ -44,7 +44,7 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS
LayerColor::[getBlendFunc setBlendFunc], LayerColor::[getBlendFunc setBlendFunc],
ParticleSystem::[getBlendFunc setBlendFunc], ParticleSystem::[getBlendFunc setBlendFunc],
DrawNode::[getBlendFunc setBlendFunc drawPolygon listenBackToForeground], DrawNode::[getBlendFunc setBlendFunc drawPolygon listenBackToForeground],
Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getClassTypeInfo], Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection],
Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased], Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased],
Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns], Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns],
MenuItem.*::[create setCallback initWithCallback], MenuItem.*::[create setCallback initWithCallback],
@ -98,8 +98,7 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS
TextureCache::[addPVRTCImage], TextureCache::[addPVRTCImage],
Timer::[getSelector createWithScriptHandler], Timer::[getSelector createWithScriptHandler],
*::[copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate], *::[copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate],
FileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$ getClassTypeInfo], FileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$],
SimpleAudioEngine::[getClassTypeInfo],
Application::[^application.* ^run$], Application::[^application.* ^run$],
Camera::[getEyeXYZ getCenterXYZ getUpXYZ], Camera::[getEyeXYZ getCenterXYZ getUpXYZ],
ccFontDefinition::[*], ccFontDefinition::[*],