Merge branch 'develop' into newRenderer

Conflicts:
	cocos/2d/CCGLProgram.h
	cocos/2d/CCLabelTTF.h
This commit is contained in:
Ricardo Quesada 2013-12-12 14:41:42 -08:00
commit 61cc365d9e
42 changed files with 161 additions and 44 deletions

View File

@ -50,7 +50,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
std::string description() const; virtual std::string description() const;
/** returns a clone of action */ /** returns a clone of action */
virtual Action* clone() const = 0; virtual Action* clone() const = 0;

View File

@ -44,7 +44,7 @@ Camera::~Camera(void)
{ {
} }
const char* Camera::description(void) const std::string Camera::getDescription() const
{ {
return String::createWithFormat("<Camera | center = (%.2f,%.2f,%.2f)>", _centerX, _centerY, _centerZ)->getCString(); return String::createWithFormat("<Camera | center = (%.2f,%.2f,%.2f)>", _centerX, _centerY, _centerZ)->getCString();
} }

View File

@ -83,7 +83,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
const char* description() const; virtual std::string getDescription() const;
/** sets the dirty value */ /** sets the dirty value */
inline void setDirty(bool value) { _dirty = value; } inline void setDirty(bool value) { _dirty = value; }

View File

@ -154,7 +154,7 @@ bool GLProgram::initWithVertexShaderFilename(const char* vShaderFilename, const
return initWithVertexShaderByteArray(vertexSource, fragmentSource); return initWithVertexShaderByteArray(vertexSource, fragmentSource);
} }
const char* GLProgram::description() const std::string GLProgram::getDescription() const
{ {
return String::createWithFormat("<GLProgram = " return String::createWithFormat("<GLProgram = "
CC_FORMAT_PRINTF_SIZE_T CC_FORMAT_PRINTF_SIZE_T

View File

@ -230,7 +230,8 @@ public:
private: private:
bool updateUniformLocation(GLint location, const GLvoid* data, unsigned int bytes); bool updateUniformLocation(GLint location, const GLvoid* data, unsigned int bytes);
const char* description() const; virtual std::string getDescription() const;
bool compileShader(GLuint * shader, GLenum type, const GLchar* source); bool compileShader(GLuint * shader, GLenum type, const GLchar* source);
std::string logForOpenGLObject(GLuint object, GLInfoFunction infoFunc, GLLogFunction logFunc) const; std::string logForOpenGLObject(GLuint object, GLInfoFunction infoFunc, GLLogFunction logFunc) const;

View File

@ -736,5 +736,10 @@ void Label::setCascadeColorEnabled(bool cascadeColorEnabled)
_cascadeColorEnabled = cascadeColorEnabled; _cascadeColorEnabled = cascadeColorEnabled;
} }
std::string Label::getDescription() const
{
return StringUtils::format("<Label | Tag = %d, Label = '%s'>", _tag, cc_utf16_to_utf8(_currentUTF16String,-1,NULL,NULL));
}
NS_CC_END NS_CC_END

View File

@ -116,6 +116,8 @@ public:
virtual const std::string& getString() const override { static std::string _ret("not implemented"); return _ret; } virtual const std::string& getString() const override { static std::string _ret("not implemented"); return _ret; }
void addChild(Node * child, int zOrder=0, int tag=0) override; void addChild(Node * child, int zOrder=0, int tag=0) override;
virtual std::string getDescription() const override;
private: private:
/** /**
* @js NA * @js NA

View File

@ -225,4 +225,9 @@ void LabelAtlas::draw()
} }
#endif #endif
std::string LabelAtlas::getDescription() const
{
return StringUtils::format("<LabelAtlas | Tag = %d, Label = '%s'>", _tag, _string.c_str());
}
NS_CC_END NS_CC_END

View File

@ -90,6 +90,7 @@ public:
virtual void setString(const std::string &label) override; virtual void setString(const std::string &label) override;
virtual const std::string& getString(void) const override; virtual const std::string& getString(void) const override;
virtual std::string getDescription() const override;
#if CC_LABELATLAS_DEBUG_DRAW #if CC_LABELATLAS_DEBUG_DRAW
virtual void draw() override; virtual void draw() override;

View File

@ -1204,6 +1204,10 @@ const std::string& LabelBMFont::getFntFile() const
return _fntFile; return _fntFile;
} }
std::string LabelBMFont::getDescription() const
{
return StringUtils::format("<LabelBMFont | Tag = %d, Label = '%s'>", _tag, _initialStringUTF8.c_str());
}
//LabelBMFont - Debug draw //LabelBMFont - Debug draw
#if CC_LABELBMFONT_DEBUG_DRAW #if CC_LABELBMFONT_DEBUG_DRAW

View File

@ -260,16 +260,18 @@ public:
void setFntFile(const std::string& fntFile); void setFntFile(const std::string& fntFile);
const std::string& getFntFile() const; const std::string& getFntFile() const;
virtual std::string getDescription() const override;
#if CC_LABELBMFONT_DEBUG_DRAW #if CC_LABELBMFONT_DEBUG_DRAW
virtual void draw(); virtual void draw();
#endif // CC_LABELBMFONT_DEBUG_DRAW #endif // CC_LABELBMFONT_DEBUG_DRAW
private: protected:
char * atlasNameFromFntFile(const std::string& fntFile); char * atlasNameFromFntFile(const std::string& fntFile);
int kerningAmountForFirst(unsigned short first, unsigned short second); int kerningAmountForFirst(unsigned short first, unsigned short second);
float getLetterPosXLeft( Sprite* characterSprite ); float getLetterPosXLeft( Sprite* characterSprite );
float getLetterPosXRight( Sprite* characterSprite ); float getLetterPosXRight( Sprite* characterSprite );
protected:
virtual void setString(unsigned short *newString, bool needUpdateLabel); virtual void setString(unsigned short *newString, bool needUpdateLabel);
// string to render // string to render
unsigned short* _string; unsigned short* _string;

View File

@ -185,9 +185,9 @@ const std::string& LabelTTF::getString() const
return _string; return _string;
} }
std::string LabelTTF::description() const std::string LabelTTF::getDescription() const
{ {
return StringUtils::format("<LabelTTF | FontName = %s, FontSize = %.1f>", _fontName.c_str(), _fontSize); return StringUtils::format("<LabelTTF | FontName = %s, FontSize = %.1f, Label = '%s'>", _fontName.c_str(), _fontSize, _string.c_str());
} }
TextHAlignment LabelTTF::getHorizontalAlignment() const TextHAlignment LabelTTF::getHorizontalAlignment() const

View File

@ -66,11 +66,6 @@ public:
* @lua NA * @lua NA
*/ */
virtual ~LabelTTF(); virtual ~LabelTTF();
/**
* @js NA
* @lua NA
*/
std::string description() const;
/** creates a LabelTTF with a font name and font size in points /** creates a LabelTTF with a font name and font size in points
@since v2.0.1 @since v2.0.1
@ -162,9 +157,14 @@ public:
const std::string& getFontName() const; const std::string& getFontName() const;
void setFontName(const std::string& fontName); void setFontName(const std::string& fontName);
private: /**
bool updateTexture(); * @js NA
* @lua NA
*/
virtual std::string getDescription() const override;
protected: protected:
bool updateTexture();
/** set the text definition for this label */ /** set the text definition for this label */
void _updateWithTextDefinition(const FontDefinition& textDefinition, bool mustUpdateTexture = true); void _updateWithTextDefinition(const FontDefinition& textDefinition, bool mustUpdateTexture = true);
@ -197,8 +197,6 @@ protected:
/** font tint */ /** font tint */
Color3B _textFillColor; Color3B _textFillColor;
}; };

View File

@ -407,6 +407,12 @@ void Layer::onTouchesCancelled(const std::vector<Touch*>& touches, Event *unused
CC_UNUSED_PARAM(unused_event); CC_UNUSED_PARAM(unused_event);
} }
std::string Layer::getDescription() const
{
return StringUtils::format("<Layer | Tag = %d>", _tag);
}
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#pragma GCC diagnostic warning "-Wdeprecated-declarations" #pragma GCC diagnostic warning "-Wdeprecated-declarations"
#elif _MSC_VER >= 1400 //vs 2005 or higher #elif _MSC_VER >= 1400 //vs 2005 or higher
@ -549,6 +555,11 @@ void LayerRGBA::setCascadeColorEnabled(bool cascadeColorEnabled)
_cascadeColorEnabled = cascadeColorEnabled; _cascadeColorEnabled = cascadeColorEnabled;
} }
std::string LayerRGBA::getDescription() const
{
return StringUtils::format("<LayerRGBA | Tag = %d>", _tag);
}
/// LayerColor /// LayerColor
LayerColor::LayerColor() LayerColor::LayerColor()
@ -735,6 +746,11 @@ void LayerColor::setOpacity(GLubyte opacity)
updateColor(); updateColor();
} }
std::string LayerColor::getDescription() const
{
return StringUtils::format("<LayerColor | Tag = %d>", _tag);
}
// //
// LayerGradient // LayerGradient
// //
@ -922,6 +938,11 @@ void LayerGradient::setCompressedInterpolation(bool compress)
updateColor(); updateColor();
} }
std::string LayerGradient::getDescription() const
{
return StringUtils::format("<LayerGradient | Tag = %d>", _tag);
}
/// MultiplexLayer /// MultiplexLayer
LayerMultiplex::LayerMultiplex() LayerMultiplex::LayerMultiplex()
@ -1060,4 +1081,9 @@ void LayerMultiplex::switchToAndReleaseMe(int n)
this->addChild(_layers.at(n)); this->addChild(_layers.at(n));
} }
std::string LayerMultiplex::getDescription() const
{
return StringUtils::format("<LayerMultiplex | Tag = %d, Layers = %d", _tag, _children.size());
}
NS_CC_END NS_CC_END

View File

@ -157,6 +157,9 @@ public:
CC_DEPRECATED_ATTRIBUTE virtual void keyBackClicked() final {}; CC_DEPRECATED_ATTRIBUTE virtual void keyBackClicked() final {};
CC_DEPRECATED_ATTRIBUTE virtual void keyMenuClicked() final {}; CC_DEPRECATED_ATTRIBUTE virtual void keyMenuClicked() final {};
// Overrides
virtual std::string getDescription() const override;
protected: protected:
Layer(); Layer();
virtual ~Layer(); virtual ~Layer();
@ -214,10 +217,12 @@ public:
virtual void updateDisplayedColor(const Color3B& parentColor) override; virtual void updateDisplayedColor(const Color3B& parentColor) override;
virtual bool isCascadeColorEnabled() const override; virtual bool isCascadeColorEnabled() const override;
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override; virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override;
virtual std::string getDescription() const override;
virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);} virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);}
virtual bool isOpacityModifyRGB() const override { return false; } virtual bool isOpacityModifyRGB() const override { return false; }
protected: protected:
LayerRGBA(); LayerRGBA();
virtual ~LayerRGBA(); virtual ~LayerRGBA();
@ -286,6 +291,8 @@ public:
*/ */
virtual void setBlendFunc(const BlendFunc& blendFunc) override; virtual void setBlendFunc(const BlendFunc& blendFunc) override;
virtual std::string getDescription() const override;
protected: protected:
LayerColor(); LayerColor();
virtual ~LayerColor(); virtual ~LayerColor();
@ -384,6 +391,8 @@ public:
/** Returns the directional vector used for the gradient */ /** Returns the directional vector used for the gradient */
const Point& getVector() const; const Point& getVector() const;
virtual std::string getDescription() const override;
protected: protected:
virtual void updateColor() override; virtual void updateColor() override;
@ -445,6 +454,8 @@ public:
*/ */
void switchToAndReleaseMe(int n); void switchToAndReleaseMe(int n);
virtual std::string getDescription() const override;
protected: protected:
/** /**

View File

@ -29,6 +29,7 @@ THE SOFTWARE.
#include "CCStdC.h" #include "CCStdC.h"
#include "CCInteger.h" #include "CCInteger.h"
#include "CCEventListenerTouch.h" #include "CCEventListenerTouch.h"
#include "CCString.h"
#include <vector> #include <vector>
#include <stdarg.h> #include <stdarg.h>
@ -567,4 +568,9 @@ MenuItem* Menu::getItemForTouch(Touch *touch)
return NULL; return NULL;
} }
std::string Menu::getDescription() const
{
return StringUtils::format("<Menu | Tag = %d>", _tag);
}
NS_CC_END NS_CC_END

View File

@ -119,6 +119,8 @@ public:
virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);} virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);}
virtual bool isOpacityModifyRGB(void) const override { return false;} virtual bool isOpacityModifyRGB(void) const override { return false;}
virtual std::string getDescription() const override;
protected: protected:
/** /**
* @js ctor * @js ctor

View File

@ -163,6 +163,10 @@ void MenuItem::setCallback(const ccMenuCallback& callback)
_callback = callback; _callback = callback;
} }
std::string MenuItem::getDescription() const
{
return StringUtils::format("<MenuItem | tag = %d>", _tag);
}
// //
//CCMenuItemLabel //CCMenuItemLabel

View File

@ -94,6 +94,9 @@ public:
*/ */
CC_DEPRECATED_ATTRIBUTE void setTarget(Object *rec, SEL_MenuHandler selector); CC_DEPRECATED_ATTRIBUTE void setTarget(Object *rec, SEL_MenuHandler selector);
virtual std::string getDescription() const override;
protected: protected:
/** /**
* @js ctor * @js ctor

View File

@ -582,7 +582,7 @@ void Node::cleanup()
} }
std::string Node::description() const std::string Node::getDescription() const
{ {
return StringUtils::format("<Node | Tag = %d", _tag); return StringUtils::format("<Node | Tag = %d", _tag);
} }

View File

@ -152,11 +152,11 @@ public:
/** /**
* Gets the description string. It makes debugging easier. * Gets the description string. It makes debugging easier.
* @return A string terminated with '\0' * @return A string
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
std::string description(void) const; virtual std::string getDescription() const;
/// @} end of initializers /// @} end of initializers

View File

@ -673,4 +673,9 @@ ParticleSystemQuad * ParticleSystemQuad::create() {
return NULL; return NULL;
} }
std::string ParticleSystemQuad::getDescription() const
{
return StringUtils::format("<ParticleSystemQuad | Tag = %d, Total Particles = %d>", _tag, _totalParticles);
}
NS_CC_END NS_CC_END

View File

@ -120,6 +120,8 @@ public:
*/ */
virtual void setTotalParticles(int tp) override; virtual void setTotalParticles(int tp) override;
virtual std::string getDescription() const override;
protected: protected:
/** /**
* @js ctor * @js ctor

View File

@ -90,7 +90,7 @@ void Profiler::displayTimers()
for (auto iter = _activeTimers.begin(); iter != _activeTimers.end(); ++iter) for (auto iter = _activeTimers.begin(); iter != _activeTimers.end(); ++iter)
{ {
ProfilingTimer* timer = iter->second; ProfilingTimer* timer = iter->second;
log("%s", timer->description()); log("%s", timer->getDescription().c_str());
} }
} }
@ -117,7 +117,7 @@ ProfilingTimer::~ProfilingTimer(void)
} }
const char* ProfilingTimer::description() const std::string ProfilingTimer::getDescription() const
{ {
static char s_desciption[512] = {0}; static char s_desciption[512] = {0};

View File

@ -119,7 +119,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
const char* description(void) const; virtual std::string getDescription() const;
/** /**
* @js NA * @js NA
* @lua NA * @lua NA

View File

@ -78,6 +78,11 @@ Scene *Scene::create()
} }
} }
std::string Scene::getDescription() const
{
return StringUtils::format("<Scene | tag = %d>", _tag);
}
#ifdef CC_USE_PHYSICS #ifdef CC_USE_PHYSICS
Scene *Scene::createWithPhysics() Scene *Scene::createWithPhysics()
{ {

View File

@ -66,6 +66,7 @@ public:
virtual void addChild(Node* child, int zOrder) override; virtual void addChild(Node* child, int zOrder) override;
virtual void addChild(Node* child, int zOrder, int tag) override; virtual void addChild(Node* child, int zOrder, int tag) override;
virtual void update(float delta) override; virtual void update(float delta) override;
virtual std::string getDescription() const override;
protected: protected:
bool initWithPhysics(); bool initWithPhysics();

View File

@ -1234,4 +1234,14 @@ void Sprite::updateBlendFunc(void)
} }
} }
std::string Sprite::getDescription() const
{
int texture_id = -1;
if( _batchNode )
texture_id = _batchNode->getTextureAtlas()->getTexture()->getName();
else
texture_id = _texture->getName();
return StringUtils::format("<Sprite | Tag = %d, TextureID = %d>", _tag, texture_id );
}
NS_CC_END NS_CC_END

View File

@ -392,6 +392,8 @@ public:
inline const BlendFunc& getBlendFunc() const override { return _blendFunc; } inline const BlendFunc& getBlendFunc() const override { return _blendFunc; }
/// @} /// @}
virtual std::string getDescription() const override;
/// @{ /// @{
/// @name Functions inherited from Node /// @name Functions inherited from Node
virtual void setScaleX(float scaleX) override; virtual void setScaleX(float scaleX) override;

View File

@ -701,4 +701,9 @@ SpriteBatchNode * SpriteBatchNode::addSpriteWithoutQuad(Sprite*child, int z, int
return this; return this;
} }
std::string SpriteBatchNode::getDescription() const
{
return StringUtils::format("<SpriteBatchNode | tag = %d>", _tag);
}
NS_CC_END NS_CC_END

View File

@ -163,6 +163,7 @@ public:
virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void sortAllChildren() override; virtual void sortAllChildren() override;
virtual void draw(void) override; virtual void draw(void) override;
virtual std::string getDescription() const override;
protected: protected:
/** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array. /** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array.

View File

@ -704,5 +704,11 @@ int TMXLayer::getVertexZForPos(const Point& pos)
return ret; return ret;
} }
std::string TMXLayer::getDescription() const
{
return StringUtils::format("<TMXLayer | tag = %d, size = %d,%d>", (int)_tag,_mapTileSize.width, (int)_mapTileSize.height);
}
NS_CC_END NS_CC_END

View File

@ -188,7 +188,7 @@ public:
virtual void addChild(Node * child, int zOrder, int tag) override; virtual void addChild(Node * child, int zOrder, int tag) override;
// super method // super method
void removeChild(Node* child, bool cleanup) override; void removeChild(Node* child, bool cleanup) override;
virtual std::string getDescription() const override;
private: private:
Point getPositionForIsoAt(const Point& pos); Point getPositionForIsoAt(const Point& pos);

View File

@ -244,6 +244,11 @@ Value TMXTiledMap::getPropertiesForGID(int GID) const
return Value(); return Value();
} }
std::string TMXTiledMap::getDescription() const
{
return StringUtils::format("<TMXTiledMap | Tag = %d, Layers = %d", _tag, _children.size());
}
NS_CC_END NS_CC_END

View File

@ -169,6 +169,8 @@ public:
_properties = properties; _properties = properties;
}; };
virtual std::string getDescription() const override;
protected: protected:
/** /**
* @js ctor * @js ctor

View File

@ -671,7 +671,7 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat
} }
const char* Texture2D::description(void) const std::string Texture2D::getDescription() const
{ {
return String::createWithFormat("<Texture2D | Name = %u | Dimensions = %ld x %ld | Coordinates = (%.2f, %.2f)>", _name, (long)_pixelsWide, (long)_pixelsHigh, _maxS, _maxT)->getCString(); return String::createWithFormat("<Texture2D | Name = %u | Dimensions = %ld x %ld | Coordinates = (%.2f, %.2f)>", _name, (long)_pixelsWide, (long)_pixelsHigh, _maxS, _maxT)->getCString();
} }

View File

@ -200,7 +200,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
const char* description(void) const; virtual std::string getDescription() const;
/** These functions are needed to create mutable textures /** These functions are needed to create mutable textures
* @js NA * @js NA

View File

@ -222,7 +222,7 @@ void TextureAtlas::listenBackToForeground(Object *obj)
_dirty = true; _dirty = true;
} }
const char* TextureAtlas::description() const std::string TextureAtlas::getDescription() const
{ {
return String::createWithFormat("<TextureAtlas | totalQuads = %d>", _totalQuads)->getCString(); return String::createWithFormat("<TextureAtlas | totalQuads = %d>", _totalQuads)->getCString();
} }

View File

@ -194,7 +194,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
const char* description() const; virtual std::string getDescription() const;
/** Gets the quantity of quads that are going to be drawn */ /** Gets the quantity of quads that are going to be drawn */
int getTotalQuads() const; int getTotalQuads() const;

View File

@ -87,7 +87,7 @@ void TextureCache::purgeSharedTextureCache()
{ {
} }
const char* TextureCache::description() const std::string TextureCache::getDescription() const
{ {
return String::createWithFormat("<TextureCache | Number of textures = %lu>", _textures.size() )->getCString(); return String::createWithFormat("<TextureCache | Number of textures = %lu>", _textures.size() )->getCString();
} }

View File

@ -96,7 +96,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
const char* description(void) const; virtual std::string getDescription() const;
// Dictionary* snapshotTextures(); // Dictionary* snapshotTextures();

View File

@ -69,23 +69,26 @@ static ssize_t mydprintf(int sock, const char *format, ...)
return write(sock, buf, strlen(buf)); return write(sock, buf, strlen(buf));
} }
static void printSceneGraph(int fd, Node* node, int level) static int printSceneGraph(int fd, Node* node, int level)
{ {
int total = 1;
for(int i=0; i<level; ++i) for(int i=0; i<level; ++i)
write(fd, "-", 1); write(fd, "-", 1);
mydprintf(fd, " %s: z=%d, tag=%d\n", node->description().c_str(), node->getZOrder(), node->getTag()); mydprintf(fd, " %s\n", node->getDescription().c_str());
for(const auto& child: node->getChildren()) for(const auto& child: node->getChildren())
printSceneGraph(fd, child, level+1); total += printSceneGraph(fd, child, level+1);
return total;
} }
static void printSceneGraphBoot(int fd) static void printSceneGraphBoot(int fd)
{ {
write(fd,"\n",1); write(fd,"\n",1);
auto scene = Director::getInstance()->getRunningScene(); auto scene = Director::getInstance()->getRunningScene();
printSceneGraph(fd, scene, 0); int total = printSceneGraph(fd, scene, 0);
write(fd,"\n",1); mydprintf(fd, "Total Nodes: %d\n", total);
} }