mirror of https://github.com/axmolengine/axmol.git
replace long with int or ssize_t
This commit is contained in:
parent
87f94ee874
commit
b67d567a79
|
@ -43,7 +43,7 @@ NS_CC_BEGIN;
|
|||
* Implementation of PointArray
|
||||
*/
|
||||
|
||||
PointArray* PointArray::create(unsigned int capacity)
|
||||
PointArray* PointArray::create(int capacity)
|
||||
{
|
||||
PointArray* pointArray = new PointArray();
|
||||
if (pointArray)
|
||||
|
@ -63,7 +63,7 @@ PointArray* PointArray::create(unsigned int capacity)
|
|||
}
|
||||
|
||||
|
||||
bool PointArray::initWithCapacity(unsigned int capacity)
|
||||
bool PointArray::initWithCapacity(int capacity)
|
||||
{
|
||||
_controlPoints = new vector<Point*>();
|
||||
|
||||
|
@ -126,19 +126,19 @@ void PointArray::addControlPoint(Point controlPoint)
|
|||
_controlPoints->push_back(new Point(controlPoint.x, controlPoint.y));
|
||||
}
|
||||
|
||||
void PointArray::insertControlPoint(Point &controlPoint, unsigned int index)
|
||||
void PointArray::insertControlPoint(Point &controlPoint, int index)
|
||||
{
|
||||
Point *temp = new Point(controlPoint.x, controlPoint.y);
|
||||
_controlPoints->insert(_controlPoints->begin() + index, temp);
|
||||
}
|
||||
|
||||
Point PointArray::getControlPointAtIndex(unsigned int index)
|
||||
Point PointArray::getControlPointAtIndex(int index)
|
||||
{
|
||||
index = MIN(_controlPoints->size()-1, MAX(index, 0));
|
||||
return *(_controlPoints->at(index));
|
||||
}
|
||||
|
||||
void PointArray::replaceControlPoint(cocos2d::Point &controlPoint, unsigned int index)
|
||||
void PointArray::replaceControlPoint(cocos2d::Point &controlPoint, int index)
|
||||
{
|
||||
|
||||
Point *temp = _controlPoints->at(index);
|
||||
|
@ -146,7 +146,7 @@ void PointArray::replaceControlPoint(cocos2d::Point &controlPoint, unsigned int
|
|||
temp->y = controlPoint.y;
|
||||
}
|
||||
|
||||
void PointArray::removeControlPointAtIndex(unsigned int index)
|
||||
void PointArray::removeControlPointAtIndex(int index)
|
||||
{
|
||||
vector<Point*>::iterator iter = _controlPoints->begin() + index;
|
||||
Point* pRemovedPoint = *iter;
|
||||
|
@ -154,9 +154,9 @@ void PointArray::removeControlPointAtIndex(unsigned int index)
|
|||
delete pRemovedPoint;
|
||||
}
|
||||
|
||||
unsigned int PointArray::count() const
|
||||
int PointArray::count() const
|
||||
{
|
||||
return _controlPoints->size();
|
||||
return static_cast<int>(_controlPoints->size());
|
||||
}
|
||||
|
||||
PointArray* PointArray::reverse() const
|
||||
|
@ -177,11 +177,11 @@ PointArray* PointArray::reverse() const
|
|||
|
||||
void PointArray::reverseInline()
|
||||
{
|
||||
unsigned long l = _controlPoints->size();
|
||||
auto l = _controlPoints->size();
|
||||
Point *p1 = nullptr;
|
||||
Point *p2 = nullptr;
|
||||
int x, y;
|
||||
for (unsigned int i = 0; i < l/2; ++i)
|
||||
for (int i = 0; i < l/2; ++i)
|
||||
{
|
||||
p1 = _controlPoints->at(i);
|
||||
p2 = _controlPoints->at(l-i-1);
|
||||
|
@ -291,7 +291,7 @@ CardinalSplineTo* CardinalSplineTo::clone() const
|
|||
|
||||
void CardinalSplineTo::update(float time)
|
||||
{
|
||||
unsigned int p;
|
||||
ssize_t p;
|
||||
float lt;
|
||||
|
||||
// eg.
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
/** creates and initializes a Points array with capacity
|
||||
* @js NA
|
||||
*/
|
||||
static PointArray* create(unsigned int capacity);
|
||||
static PointArray* create(int capacity);
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
/** initializes a Catmull Rom config with a capacity hint
|
||||
* @js NA
|
||||
*/
|
||||
bool initWithCapacity(unsigned int capacity);
|
||||
bool initWithCapacity(int capacity);
|
||||
|
||||
/** appends a control point
|
||||
* @js NA
|
||||
|
@ -87,27 +87,27 @@ public:
|
|||
/** inserts a controlPoint at index
|
||||
* @js NA
|
||||
*/
|
||||
void insertControlPoint(Point &controlPoint, unsigned int index);
|
||||
void insertControlPoint(Point &controlPoint, int index);
|
||||
|
||||
/** replaces an existing controlPoint at index
|
||||
* @js NA
|
||||
*/
|
||||
void replaceControlPoint(Point &controlPoint, unsigned int index);
|
||||
void replaceControlPoint(Point &controlPoint, int index);
|
||||
|
||||
/** get the value of a controlPoint at a given index
|
||||
* @js NA
|
||||
*/
|
||||
Point getControlPointAtIndex(unsigned int index);
|
||||
Point getControlPointAtIndex(int index);
|
||||
|
||||
/** deletes a control point at a given index
|
||||
* @js NA
|
||||
*/
|
||||
void removeControlPointAtIndex(unsigned int index);
|
||||
void removeControlPointAtIndex(int index);
|
||||
|
||||
/** returns the number of objects of the control point array
|
||||
* @js NA
|
||||
*/
|
||||
unsigned int count() const;
|
||||
int count() const;
|
||||
|
||||
/** returns a new copy of the array reversed. User is responsible for releasing this copy
|
||||
* @js NA
|
||||
|
|
|
@ -203,14 +203,14 @@ Sequence* Sequence::create(const Vector<FiniteTimeAction*>& arrayOfActions)
|
|||
Sequence* pRet = NULL;
|
||||
do
|
||||
{
|
||||
long count = arrayOfActions.size();
|
||||
auto count = arrayOfActions.size();
|
||||
CC_BREAK_IF(count == 0);
|
||||
|
||||
auto prev = arrayOfActions.at(0);
|
||||
|
||||
if (count > 1)
|
||||
{
|
||||
for (long i = 1; i < count; ++i)
|
||||
for (int i = 1; i < count; ++i)
|
||||
{
|
||||
prev = createWithTwoActions(prev, arrayOfActions.at(i));
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ Spawn* Spawn::create(const Vector<FiniteTimeAction*>& arrayOfActions)
|
|||
Spawn* pRet = NULL;
|
||||
do
|
||||
{
|
||||
long count = arrayOfActions.size();
|
||||
auto count = arrayOfActions.size();
|
||||
CC_BREAK_IF(count == 0);
|
||||
auto prev = arrayOfActions.at(0);
|
||||
if (count > 1)
|
||||
|
@ -2097,7 +2097,7 @@ void Animate::update(float t)
|
|||
}
|
||||
|
||||
auto frames = _animation->getFrames();
|
||||
long numberOfFrames = frames.size();
|
||||
auto numberOfFrames = frames.size();
|
||||
SpriteFrame *frameToDisplay = NULL;
|
||||
|
||||
for( int i=_nextFrame; i < numberOfFrames; i++ ) {
|
||||
|
|
|
@ -87,7 +87,7 @@ void ActionManager::actionAllocWithHashElement(tHashElement *element)
|
|||
|
||||
}
|
||||
|
||||
void ActionManager::removeActionAtIndex(long index, tHashElement *element)
|
||||
void ActionManager::removeActionAtIndex(int index, tHashElement *element)
|
||||
{
|
||||
Action *action = (Action*)element->actions->arr[index];
|
||||
|
||||
|
@ -253,7 +253,7 @@ void ActionManager::removeAction(Action *action)
|
|||
HASH_FIND_PTR(_targets, &target, element);
|
||||
if (element)
|
||||
{
|
||||
long i = ccArrayGetIndexOfObject(element->actions, action);
|
||||
auto i = ccArrayGetIndexOfObject(element->actions, action);
|
||||
if (i != CC_INVALID_INDEX)
|
||||
{
|
||||
removeActionAtIndex(i, element);
|
||||
|
@ -275,8 +275,8 @@ void ActionManager::removeActionByTag(int tag, Object *target)
|
|||
|
||||
if (element)
|
||||
{
|
||||
long limit = element->actions->num;
|
||||
for (long i = 0; i < limit; ++i)
|
||||
auto limit = element->actions->num;
|
||||
for (int i = 0; i < limit; ++i)
|
||||
{
|
||||
Action *action = (Action*)element->actions->arr[i];
|
||||
|
||||
|
@ -304,8 +304,8 @@ Action* ActionManager::getActionByTag(int tag, const Object *target) const
|
|||
{
|
||||
if (element->actions != NULL)
|
||||
{
|
||||
long limit = element->actions->num;
|
||||
for (long i = 0; i < limit; ++i)
|
||||
auto limit = element->actions->num;
|
||||
for (int i = 0; i < limit; ++i)
|
||||
{
|
||||
Action *action = (Action*)element->actions->arr[i];
|
||||
|
||||
|
@ -327,7 +327,7 @@ Action* ActionManager::getActionByTag(int tag, const Object *target) const
|
|||
|
||||
// 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
|
||||
long ActionManager::getNumberOfRunningActionsInTarget(const Object *target) const
|
||||
int ActionManager::getNumberOfRunningActionsInTarget(const Object *target) const
|
||||
{
|
||||
tHashElement *element = NULL;
|
||||
HASH_FIND_PTR(_targets, &target, element);
|
||||
|
|
|
@ -102,10 +102,10 @@ public:
|
|||
* - If you are running 1 Sequence of 7 actions, it will return 1.
|
||||
* - If you are running 7 Sequences of 2 actions, it will return 7.
|
||||
*/
|
||||
long getNumberOfRunningActionsInTarget(const Object *target) const;
|
||||
int getNumberOfRunningActionsInTarget(const Object *target) const;
|
||||
|
||||
/** @deprecated use getNumberOfRunningActionsInTarget() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE inline unsigned int numberOfRunningActionsInTarget(Object *target) const { return getNumberOfRunningActionsInTarget(target); }
|
||||
CC_DEPRECATED_ATTRIBUTE inline int numberOfRunningActionsInTarget(Object *target) const { return getNumberOfRunningActionsInTarget(target); }
|
||||
|
||||
/** Pauses the target: all running actions and newly added actions will be paused.
|
||||
*/
|
||||
|
@ -126,7 +126,7 @@ public:
|
|||
protected:
|
||||
// declared in ActionManager.m
|
||||
|
||||
void removeActionAtIndex(long index, struct _hashElement *pElement);
|
||||
void removeActionAtIndex(int index, struct _hashElement *pElement);
|
||||
void deleteHashElement(struct _hashElement *pElement);
|
||||
void actionAllocWithHashElement(struct _hashElement *pElement);
|
||||
void update(float dt);
|
||||
|
|
|
@ -61,7 +61,7 @@ AtlasNode::~AtlasNode()
|
|||
CC_SAFE_RELEASE(_textureAtlas);
|
||||
}
|
||||
|
||||
AtlasNode * AtlasNode::create(const std::string& tile, long tileWidth, long tileHeight, long itemsToRender)
|
||||
AtlasNode * AtlasNode::create(const std::string& tile, int tileWidth, int tileHeight, int itemsToRender)
|
||||
{
|
||||
AtlasNode * pRet = new AtlasNode();
|
||||
if (pRet->initWithTileFile(tile, tileWidth, tileHeight, itemsToRender))
|
||||
|
@ -73,14 +73,14 @@ AtlasNode * AtlasNode::create(const std::string& tile, long tileWidth, long tile
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool AtlasNode::initWithTileFile(const std::string& tile, long tileWidth, long tileHeight, long itemsToRender)
|
||||
bool AtlasNode::initWithTileFile(const std::string& tile, int tileWidth, int tileHeight, int itemsToRender)
|
||||
{
|
||||
CCASSERT(tile.size() > 0, "file size should not be empty");
|
||||
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(tile);
|
||||
return initWithTexture(texture, tileWidth, tileHeight, itemsToRender);
|
||||
}
|
||||
|
||||
bool AtlasNode::initWithTexture(Texture2D* texture, long tileWidth, long tileHeight, long itemsToRender)
|
||||
bool AtlasNode::initWithTexture(Texture2D* texture, int tileWidth, int tileHeight, int itemsToRender)
|
||||
{
|
||||
_itemWidth = tileWidth;
|
||||
_itemHeight = tileHeight;
|
||||
|
@ -245,12 +245,12 @@ TextureAtlas * AtlasNode::getTextureAtlas() const
|
|||
return _textureAtlas;
|
||||
}
|
||||
|
||||
long AtlasNode::getQuadsToDraw() const
|
||||
int AtlasNode::getQuadsToDraw() const
|
||||
{
|
||||
return _quadsToDraw;
|
||||
}
|
||||
|
||||
void AtlasNode::setQuadsToDraw(long uQuadsToDraw)
|
||||
void AtlasNode::setQuadsToDraw(int uQuadsToDraw)
|
||||
{
|
||||
_quadsToDraw = uQuadsToDraw;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ class CC_DLL AtlasNode : public NodeRGBA, public TextureProtocol
|
|||
{
|
||||
public:
|
||||
/** creates a AtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/
|
||||
static AtlasNode * create(const std::string& filename, long tileWidth, long tileHeight, long itemsToRender);
|
||||
static AtlasNode * create(const std::string& filename, int tileWidth, int tileHeight, int itemsToRender);
|
||||
|
||||
/** updates the Atlas (indexed vertex array).
|
||||
* Shall be overridden in subclasses
|
||||
|
@ -62,8 +62,8 @@ public:
|
|||
void setTextureAtlas(TextureAtlas* textureAtlas);
|
||||
TextureAtlas* getTextureAtlas() const;
|
||||
|
||||
void setQuadsToDraw(long quadsToDraw);
|
||||
long getQuadsToDraw() const;
|
||||
void setQuadsToDraw(int quadsToDraw);
|
||||
int getQuadsToDraw() const;
|
||||
|
||||
|
||||
// Overrides
|
||||
|
@ -95,10 +95,10 @@ protected:
|
|||
virtual ~AtlasNode();
|
||||
|
||||
/** initializes an AtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/
|
||||
bool initWithTileFile(const std::string& tile, long tileWidth, long tileHeight, long itemsToRender);
|
||||
bool initWithTileFile(const std::string& tile, int tileWidth, int tileHeight, int itemsToRender);
|
||||
|
||||
/** initializes an AtlasNode with a texture the width and height of each item measured in points and the quantity of items to render*/
|
||||
bool initWithTexture(Texture2D* texture, long tileWidth, long tileHeight, long itemsToRender);
|
||||
bool initWithTexture(Texture2D* texture, int tileWidth, int tileHeight, int itemsToRender);
|
||||
|
||||
void calculateMaxItems();
|
||||
void updateBlendFunc();
|
||||
|
@ -108,14 +108,14 @@ protected:
|
|||
void setIgnoreContentScaleFactor(bool bIgnoreContentScaleFactor);
|
||||
|
||||
//! chars per row
|
||||
long _itemsPerRow;
|
||||
int _itemsPerRow;
|
||||
//! chars per column
|
||||
long _itemsPerColumn;
|
||||
int _itemsPerColumn;
|
||||
|
||||
//! width of each char
|
||||
long _itemWidth;
|
||||
int _itemWidth;
|
||||
//! height of each char
|
||||
long _itemHeight;
|
||||
int _itemHeight;
|
||||
|
||||
Color3B _colorUnmodified;
|
||||
|
||||
|
@ -125,7 +125,7 @@ protected:
|
|||
BlendFunc _blendFunc;
|
||||
|
||||
// quads to draw
|
||||
long _quadsToDraw;
|
||||
int _quadsToDraw;
|
||||
// color uniform
|
||||
GLint _uniformColor;
|
||||
// This varible is only used for LabelAtlas FPS display. So plz don't modify its value.
|
||||
|
|
|
@ -857,7 +857,7 @@ void Director::calculateMPF()
|
|||
}
|
||||
|
||||
// returns the FPS image data pointer and len
|
||||
void Director::getFPSImageData(unsigned char** datapointer, long* length)
|
||||
void Director::getFPSImageData(unsigned char** datapointer, ssize_t* length)
|
||||
{
|
||||
// XXX fixed me if it should be used
|
||||
*datapointer = cc_fps_images_png;
|
||||
|
@ -880,7 +880,7 @@ void Director::createStatsLabel()
|
|||
Texture2D::PixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat();
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
|
||||
unsigned char *data = nullptr;
|
||||
long dataLength = 0;
|
||||
ssize_t dataLength = 0;
|
||||
getFPSImageData(&data, &dataLength);
|
||||
|
||||
Image* image = new Image();
|
||||
|
|
|
@ -379,7 +379,7 @@ protected:
|
|||
void showStats();
|
||||
void createStatsLabel();
|
||||
void calculateMPF();
|
||||
void getFPSImageData(unsigned char** datapointer, long* length);
|
||||
void getFPSImageData(unsigned char** datapointer, ssize_t* length);
|
||||
|
||||
/** calculates delta time since last time it was called */
|
||||
void calculateDeltaTime();
|
||||
|
|
|
@ -142,7 +142,7 @@ DrawNode* DrawNode::create()
|
|||
return pRet;
|
||||
}
|
||||
|
||||
void DrawNode::ensureCapacity(long count)
|
||||
void DrawNode::ensureCapacity(int count)
|
||||
{
|
||||
CCASSERT(count>=0, "capacity must be >= 0");
|
||||
|
||||
|
@ -338,7 +338,7 @@ void DrawNode::drawSegment(const Point &from, const Point &to, float radius, con
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void DrawNode::drawPolygon(Point *verts, long count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor)
|
||||
void DrawNode::drawPolygon(Point *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor)
|
||||
{
|
||||
CCASSERT(count >= 0, "invalid count value");
|
||||
|
||||
|
@ -346,7 +346,7 @@ void DrawNode::drawPolygon(Point *verts, long count, const Color4F &fillColor, f
|
|||
struct ExtrudeVerts* extrude = (struct ExtrudeVerts*)malloc(sizeof(struct ExtrudeVerts)*count);
|
||||
memset(extrude, 0, sizeof(struct ExtrudeVerts)*count);
|
||||
|
||||
for (long i = 0; i < count; i++)
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Vertex2F v0 = __v2f(verts[(i-1+count)%count]);
|
||||
Vertex2F v1 = __v2f(verts[i]);
|
||||
|
@ -362,15 +362,15 @@ void DrawNode::drawPolygon(Point *verts, long count, const Color4F &fillColor, f
|
|||
|
||||
bool outline = (borderColor.a > 0.0 && borderWidth > 0.0);
|
||||
|
||||
unsigned int triangle_count = 3*count - 2;
|
||||
unsigned int vertex_count = 3*triangle_count;
|
||||
auto triangle_count = 3*count - 2;
|
||||
auto vertex_count = 3*triangle_count;
|
||||
ensureCapacity(vertex_count);
|
||||
|
||||
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
||||
V2F_C4B_T2F_Triangle *cursor = triangles;
|
||||
|
||||
float inset = (outline == false ? 0.5 : 0.0);
|
||||
for (long i = 0; i < count-2; i++)
|
||||
for (int i = 0; i < count-2; i++)
|
||||
{
|
||||
Vertex2F v0 = v2fsub(__v2f(verts[0 ]), v2fmult(extrude[0 ].offset, inset));
|
||||
Vertex2F v1 = v2fsub(__v2f(verts[i+1]), v2fmult(extrude[i+1].offset, inset));
|
||||
|
@ -385,9 +385,9 @@ void DrawNode::drawPolygon(Point *verts, long count, const Color4F &fillColor, f
|
|||
*cursor++ = tmp;
|
||||
}
|
||||
|
||||
for(long i = 0; i < count; i++)
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
long j = (i+1)%count;
|
||||
int j = (i+1)%count;
|
||||
Vertex2F v0 = __v2f(verts[i]);
|
||||
Vertex2F v1 = __v2f(verts[j]);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
* In lua:local drawPolygon(local pointTable,local tableCount,local fillColor,local width,local borderColor)
|
||||
* @endcode
|
||||
*/
|
||||
void drawPolygon(Point *verts, long count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor);
|
||||
void drawPolygon(Point *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor);
|
||||
|
||||
/** Clear the geometry in the node's buffer. */
|
||||
void clear();
|
||||
|
@ -92,13 +92,13 @@ protected:
|
|||
virtual ~DrawNode();
|
||||
virtual bool init();
|
||||
|
||||
void ensureCapacity(long count);
|
||||
void ensureCapacity(int count);
|
||||
void render();
|
||||
|
||||
GLuint _vao;
|
||||
GLuint _vbo;
|
||||
|
||||
long _bufferCapacity;
|
||||
int _bufferCapacity;
|
||||
GLsizei _bufferCount;
|
||||
V2F_C4B_T2F *_buffer;
|
||||
|
||||
|
|
|
@ -189,10 +189,10 @@ EventDispatcher::~EventDispatcher()
|
|||
|
||||
void EventDispatcher::visitTarget(Node* node)
|
||||
{
|
||||
long i = 0;
|
||||
int i = 0;
|
||||
auto& children = node->getChildren();
|
||||
|
||||
long childrenCount = children.size();
|
||||
auto childrenCount = children.size();
|
||||
|
||||
if(childrenCount > 0)
|
||||
{
|
||||
|
@ -491,7 +491,7 @@ void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners, s
|
|||
auto fixedPriorityListeners = listeners->getFixedPriorityListeners();
|
||||
auto sceneGraphPriorityListeners = listeners->getSceneGraphPriorityListeners();
|
||||
|
||||
long i = 0;
|
||||
int i = 0;
|
||||
// priority < 0
|
||||
if (fixedPriorityListeners)
|
||||
{
|
||||
|
@ -527,7 +527,7 @@ void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners, s
|
|||
if (!shouldStopPropagation)
|
||||
{
|
||||
// priority > 0
|
||||
for (; i < static_cast<long>(fixedPriorityListeners->size()); ++i)
|
||||
for (; i < fixedPriorityListeners->size(); ++i)
|
||||
{
|
||||
auto l = fixedPriorityListeners->at(i);
|
||||
|
||||
|
@ -976,7 +976,7 @@ void EventDispatcher::sortEventListenersOfFixedPriority(EventListener::ListenerI
|
|||
});
|
||||
|
||||
// FIXME: Should use binary search
|
||||
long index = 0;
|
||||
int index = 0;
|
||||
for (auto& listener : *fixedlisteners)
|
||||
{
|
||||
if (listener->getFixedPriority() >= 0)
|
||||
|
|
|
@ -136,12 +136,12 @@ private:
|
|||
|
||||
inline std::vector<EventListener*>* getFixedPriorityListeners() const { return _fixedListeners; };
|
||||
inline std::vector<EventListener*>* getSceneGraphPriorityListeners() const { return _sceneGraphListeners; };
|
||||
inline long getGt0Index() const { return _gt0Index; };
|
||||
inline void setGt0Index(long index) { _gt0Index = index; };
|
||||
inline int getGt0Index() const { return _gt0Index; };
|
||||
inline void setGt0Index(int index) { _gt0Index = index; };
|
||||
private:
|
||||
std::vector<EventListener*>* _fixedListeners;
|
||||
std::vector<EventListener*>* _sceneGraphListeners;
|
||||
long _gt0Index;
|
||||
int _gt0Index;
|
||||
};
|
||||
|
||||
/** Adds event listener with item */
|
||||
|
|
|
@ -99,7 +99,7 @@ bool FontFreeType::createFontObject(const std::string &fontName, int fontSize)
|
|||
{
|
||||
FT_Face face;
|
||||
|
||||
long len = 0;
|
||||
ssize_t len = 0;
|
||||
_ttfData = FileUtils::getInstance()->getFileData(fontName.c_str(), "rb", &len);
|
||||
if (!_ttfData)
|
||||
return false;
|
||||
|
|
|
@ -113,13 +113,13 @@ bool GridBase::initWithSize(const Size& gridSize)
|
|||
Director *pDirector = Director::getInstance();
|
||||
Size s = pDirector->getWinSizeInPixels();
|
||||
|
||||
unsigned long POTWide = ccNextPOT((unsigned int)s.width);
|
||||
unsigned long POTHigh = ccNextPOT((unsigned int)s.height);
|
||||
auto POTWide = ccNextPOT((unsigned int)s.width);
|
||||
auto POTHigh = ccNextPOT((unsigned int)s.height);
|
||||
|
||||
// we only use rgba8888
|
||||
Texture2D::PixelFormat format = Texture2D::PixelFormat::RGBA8888;
|
||||
|
||||
long dataLen = POTWide * POTHigh * 4;
|
||||
auto dataLen = POTWide * POTHigh * 4;
|
||||
void *data = calloc(dataLen, 1);
|
||||
if (! data)
|
||||
{
|
||||
|
|
|
@ -95,7 +95,7 @@ public:
|
|||
|
||||
protected:
|
||||
bool _active;
|
||||
long _reuseGrid;
|
||||
int _reuseGrid;
|
||||
Size _gridSize;
|
||||
Texture2D *_texture;
|
||||
Point _step;
|
||||
|
|
|
@ -640,7 +640,7 @@ void Label::updateDisplayedOpacity(GLubyte parentOpacity)
|
|||
});
|
||||
|
||||
V3F_C4B_T2F_Quad *quads = _textureAtlas->getQuads();
|
||||
long count = _textureAtlas->getTotalQuads();
|
||||
auto count = _textureAtlas->getTotalQuads();
|
||||
Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity );
|
||||
if (_isOpacityModifyRGB)
|
||||
{
|
||||
|
@ -706,7 +706,7 @@ void Label::updateDisplayedColor(const Color3B& parentColor)
|
|||
});
|
||||
|
||||
V3F_C4B_T2F_Quad *quads = _textureAtlas->getQuads();
|
||||
long count = _textureAtlas->getTotalQuads();
|
||||
auto count = _textureAtlas->getTotalQuads();
|
||||
Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity );
|
||||
|
||||
// special opacity for premultiplied textures
|
||||
|
|
|
@ -42,7 +42,7 @@ NS_CC_BEGIN
|
|||
|
||||
//CCLabelAtlas - Creation & Init
|
||||
|
||||
LabelAtlas* LabelAtlas::create(const std::string& string, const std::string& charMapFile, long itemWidth, long itemHeight, long startCharMap)
|
||||
LabelAtlas* LabelAtlas::create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
|
||||
{
|
||||
LabelAtlas *pRet = new LabelAtlas();
|
||||
if(pRet && pRet->initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap))
|
||||
|
@ -54,13 +54,13 @@ LabelAtlas* LabelAtlas::create(const std::string& string, const std::string& cha
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool LabelAtlas::initWithString(const std::string& string, const std::string& charMapFile, long itemWidth, long itemHeight, long startCharMap)
|
||||
bool LabelAtlas::initWithString(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
|
||||
{
|
||||
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(charMapFile);
|
||||
return initWithString(string, texture, itemWidth, itemHeight, startCharMap);
|
||||
}
|
||||
|
||||
bool LabelAtlas::initWithString(const std::string& string, Texture2D* texture, long itemWidth, long itemHeight, long startCharMap)
|
||||
bool LabelAtlas::initWithString(const std::string& string, Texture2D* texture, int itemWidth, int itemHeight, int startCharMap)
|
||||
{
|
||||
if (AtlasNode::initWithTexture(texture, itemWidth, itemHeight, string.size()))
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ bool LabelAtlas::initWithString(const std::string& theString, const std::string&
|
|||
//CCLabelAtlas - Atlas generation
|
||||
void LabelAtlas::updateAtlasValues()
|
||||
{
|
||||
size_t n = _string.length();
|
||||
auto n = _string.length();
|
||||
|
||||
const unsigned char *s = (unsigned char*)_string.c_str();
|
||||
|
||||
|
@ -127,9 +127,9 @@ void LabelAtlas::updateAtlasValues()
|
|||
itemHeightInPixels = _itemHeight;
|
||||
}
|
||||
|
||||
CCASSERT( static_cast<long>(n) <= _textureAtlas->getCapacity(), "updateAtlasValues: Invalid String length");
|
||||
CCASSERT(n <= _textureAtlas->getCapacity(), "updateAtlasValues: Invalid String length");
|
||||
V3F_C4B_T2F_Quad* quads = _textureAtlas->getQuads();
|
||||
for(long i = 0; i < static_cast<long>(n); i++) {
|
||||
for(int i = 0; i < n; i++) {
|
||||
|
||||
unsigned char a = s[i] - _mapStartChar;
|
||||
float row = (float) (a % _itemsPerRow);
|
||||
|
@ -177,8 +177,8 @@ void LabelAtlas::updateAtlasValues()
|
|||
}
|
||||
if (n > 0 ){
|
||||
_textureAtlas->setDirty(true);
|
||||
long totalQuads = _textureAtlas->getTotalQuads();
|
||||
if (static_cast<long>(n) > totalQuads) {
|
||||
auto totalQuads = _textureAtlas->getTotalQuads();
|
||||
if (n > totalQuads) {
|
||||
_textureAtlas->increaseTotalQuadsWith(n - totalQuads);
|
||||
}
|
||||
}
|
||||
|
@ -187,8 +187,8 @@ void LabelAtlas::updateAtlasValues()
|
|||
//CCLabelAtlas - LabelProtocol
|
||||
void LabelAtlas::setString(const std::string &label)
|
||||
{
|
||||
size_t len = label.size();
|
||||
if (static_cast<long>(len) > _textureAtlas->getTotalQuads())
|
||||
auto len = label.size();
|
||||
if (len > _textureAtlas->getTotalQuads())
|
||||
{
|
||||
_textureAtlas->resizeCapacity(len);
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ void LabelAtlas::setString(const std::string &label)
|
|||
|
||||
this->setContentSize(s);
|
||||
|
||||
_quadsToDraw = len;
|
||||
_quadsToDraw = static_cast<int>(len);
|
||||
}
|
||||
|
||||
const std::string& LabelAtlas::getString(void) const
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
}
|
||||
|
||||
/** creates the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
|
||||
static LabelAtlas * create(const std::string& string, const std::string& charMapFile, long itemWidth, long itemHeight, long startCharMap);
|
||||
static LabelAtlas * create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
|
||||
|
||||
/** creates the LabelAtlas with a string and a configuration file
|
||||
@since v2.0
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
static LabelAtlas* create(const std::string& string, const std::string& fntFile);
|
||||
|
||||
/** initializes the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
|
||||
bool initWithString(const std::string& string, const std::string& charMapFile, long itemWidth, long itemHeight, long startCharMap);
|
||||
bool initWithString(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
|
||||
|
||||
/** initializes the LabelAtlas with a string and a configuration file
|
||||
@since v2.0
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
bool initWithString(const std::string& string, const std::string& fntFile);
|
||||
|
||||
/** initializes the LabelAtlas with a string, a texture, the width and height in points of each element and the starting char of the atlas */
|
||||
bool initWithString(const std::string& string, Texture2D* texture, long itemWidth, long itemHeight, long startCharMap);
|
||||
bool initWithString(const std::string& string, Texture2D* texture, int itemWidth, int itemHeight, int startCharMap);
|
||||
|
||||
// super methods
|
||||
virtual void updateAtlasValues();
|
||||
|
@ -99,7 +99,7 @@ protected:
|
|||
// string to render
|
||||
std::string _string;
|
||||
// the first char in the charmap
|
||||
long _mapStartChar;
|
||||
int _mapStartChar;
|
||||
};
|
||||
|
||||
// end of GUI group
|
||||
|
|
|
@ -267,8 +267,8 @@ void CCBMFontConfiguration::parseImageFileName(std::string line, const std::stri
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// page ID. Sanity check
|
||||
long index = line.find('=')+1;
|
||||
long index2 = line.find(' ', index);
|
||||
auto index = line.find('=')+1;
|
||||
auto index2 = line.find(' ', index);
|
||||
std::string value = line.substr(index, index2-index);
|
||||
CCASSERT(atoi(value.c_str()) == 0, "LabelBMFont file could not be found");
|
||||
// file
|
||||
|
@ -288,8 +288,8 @@ void CCBMFontConfiguration::parseInfoArguments(std::string line)
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// padding
|
||||
long index = line.find("padding=");
|
||||
long index2 = line.find(' ', index);
|
||||
auto index = line.find("padding=");
|
||||
auto index2 = line.find(' ', index);
|
||||
std::string value = line.substr(index, index2-index);
|
||||
sscanf(value.c_str(), "padding=%d,%d,%d,%d", &_padding.top, &_padding.right, &_padding.bottom, &_padding.left);
|
||||
CCLOG("cocos2d: padding: %d,%d,%d,%d", _padding.left, _padding.top, _padding.right, _padding.bottom);
|
||||
|
@ -303,8 +303,8 @@ void CCBMFontConfiguration::parseCommonArguments(std::string line)
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Height
|
||||
long index = line.find("lineHeight=");
|
||||
long index2 = line.find(' ', index);
|
||||
auto index = line.find("lineHeight=");
|
||||
auto index2 = line.find(' ', index);
|
||||
std::string value = line.substr(index, index2-index);
|
||||
sscanf(value.c_str(), "lineHeight=%d", &_commonHeight);
|
||||
// scaleW. sanity check
|
||||
|
@ -334,8 +334,8 @@ void CCBMFontConfiguration::parseCharacterDefinition(std::string line, ccBMFontD
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Character ID
|
||||
long index = line.find("id=");
|
||||
long index2 = line.find(' ', index);
|
||||
auto index = line.find("id=");
|
||||
auto index2 = line.find(' ', index);
|
||||
std::string value = line.substr(index, index2-index);
|
||||
sscanf(value.c_str(), "id=%u", &characterDefinition->charID);
|
||||
|
||||
|
@ -385,8 +385,8 @@ void CCBMFontConfiguration::parseKerningEntry(std::string line)
|
|||
|
||||
// first
|
||||
int first;
|
||||
long index = line.find("first=");
|
||||
long index2 = line.find(' ', index);
|
||||
auto index = line.find("first=");
|
||||
auto index2 = line.find(' ', index);
|
||||
std::string value = line.substr(index, index2-index);
|
||||
sscanf(value.c_str(), "first=%d", &first);
|
||||
|
||||
|
|
|
@ -310,13 +310,13 @@ void MenuItemLabel::setEnabled(bool enabled)
|
|||
//CCMenuItemAtlasFont
|
||||
//
|
||||
|
||||
MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const std::string& charMapFile, long itemWidth, long itemHeight, char startCharMap)
|
||||
MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap)
|
||||
{
|
||||
return MenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap, (const ccMenuCallback&)nullptr);
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
MenuItemAtlasFont * MenuItemAtlasFont::create(const char* value, const char* charMapFile, long itemWidth, long itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector)
|
||||
MenuItemAtlasFont * MenuItemAtlasFont::create(const char* value, const char* charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector)
|
||||
{
|
||||
MenuItemAtlasFont *ret = new MenuItemAtlasFont();
|
||||
ret->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap, target, selector);
|
||||
|
@ -324,7 +324,7 @@ MenuItemAtlasFont * MenuItemAtlasFont::create(const char* value, const char* cha
|
|||
return ret;
|
||||
}
|
||||
|
||||
MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const std::string& charMapFile, long itemWidth, long itemHeight, char startCharMap, const ccMenuCallback& callback)
|
||||
MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback)
|
||||
{
|
||||
MenuItemAtlasFont *ret = new MenuItemAtlasFont();
|
||||
ret->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap, callback);
|
||||
|
@ -333,14 +333,14 @@ MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const st
|
|||
}
|
||||
|
||||
// XXX: deprecated
|
||||
bool MenuItemAtlasFont::initWithString(const char* value, const char* charMapFile, long itemWidth, long itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector)
|
||||
bool MenuItemAtlasFont::initWithString(const char* value, const char* charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector)
|
||||
{
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
return initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap, std::bind(selector,target, std::placeholders::_1) );
|
||||
}
|
||||
|
||||
bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, long itemWidth, long itemHeight, char startCharMap, const ccMenuCallback& callback)
|
||||
bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback)
|
||||
{
|
||||
CCASSERT( value.size() != 0, "value length must be greater than 0");
|
||||
LabelAtlas *label = new LabelAtlas();
|
||||
|
@ -357,12 +357,12 @@ bool MenuItemAtlasFont::initWithString(const std::string& value, const std::stri
|
|||
//CCMenuItemFont
|
||||
//
|
||||
|
||||
void MenuItemFont::setFontSize(long s)
|
||||
void MenuItemFont::setFontSize(int s)
|
||||
{
|
||||
_globalFontSize = s;
|
||||
}
|
||||
|
||||
long MenuItemFont::getFontSize()
|
||||
int MenuItemFont::getFontSize()
|
||||
{
|
||||
return _globalFontSize;
|
||||
}
|
||||
|
@ -449,13 +449,13 @@ void MenuItemFont::recreateLabel()
|
|||
this->setLabel(label);
|
||||
}
|
||||
|
||||
void MenuItemFont::setFontSizeObj(long s)
|
||||
void MenuItemFont::setFontSizeObj(int s)
|
||||
{
|
||||
_fontSize = s;
|
||||
recreateLabel();
|
||||
}
|
||||
|
||||
long MenuItemFont::getFontSizeObj() const
|
||||
int MenuItemFont::getFontSizeObj() const
|
||||
{
|
||||
return _fontSize;
|
||||
}
|
||||
|
|
|
@ -212,11 +212,11 @@ class CC_DLL MenuItemAtlasFont : public MenuItemLabel
|
|||
{
|
||||
public:
|
||||
/** creates a menu item from a string and atlas with a target/selector */
|
||||
static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, long itemWidth, long itemHeight, char startCharMap);
|
||||
static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap);
|
||||
/** creates a menu item from a string and atlas. Use it with MenuItemToggle */
|
||||
CC_DEPRECATED_ATTRIBUTE static MenuItemAtlasFont* create(const char* value, const char* charMapFile, long itemWidth, long itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector);
|
||||
CC_DEPRECATED_ATTRIBUTE static MenuItemAtlasFont* create(const char* value, const char* charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector);
|
||||
/** creates a menu item from a string and atlas. Use it with MenuItemToggle */
|
||||
static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, long itemWidth, long itemHeight, char startCharMap, const ccMenuCallback& callback);
|
||||
static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback);
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -230,9 +230,9 @@ protected:
|
|||
virtual ~MenuItemAtlasFont(){}
|
||||
|
||||
/** initializes a menu item from a string and atlas with a target/selector */
|
||||
CC_DEPRECATED_ATTRIBUTE bool initWithString(const char *value, const char *charMapFile, long itemWidth, long itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector);
|
||||
CC_DEPRECATED_ATTRIBUTE bool initWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, Object* target, SEL_MenuHandler selector);
|
||||
/** initializes a menu item from a string and atlas with a target/selector */
|
||||
bool initWithString(const std::string& value, const std::string& charMapFile, long itemWidth, long itemHeight, char startCharMap, const ccMenuCallback& callback);
|
||||
bool initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback);
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(MenuItemAtlasFont);
|
||||
|
@ -253,10 +253,10 @@ public:
|
|||
static MenuItemFont * create(const std::string& value, const ccMenuCallback& callback);
|
||||
|
||||
/** set default font size */
|
||||
static void setFontSize(long size);
|
||||
static void setFontSize(int size);
|
||||
/** get default font size */
|
||||
static long getFontSize();
|
||||
CC_DEPRECATED_ATTRIBUTE static unsigned int fontSize() { return MenuItemFont::getFontSize(); };
|
||||
static int getFontSize();
|
||||
CC_DEPRECATED_ATTRIBUTE static int fontSize() { return MenuItemFont::getFontSize(); };
|
||||
/** set the default font name */
|
||||
static void setFontName(const std::string& name);
|
||||
/** get the default font name */
|
||||
|
@ -268,13 +268,13 @@ public:
|
|||
* so change the name to setFontSizeObj
|
||||
* @js setFontSize
|
||||
*/
|
||||
void setFontSizeObj(long size);
|
||||
void setFontSizeObj(int size);
|
||||
|
||||
/** get font size
|
||||
* @js getFontSize
|
||||
*/
|
||||
long getFontSizeObj() const;
|
||||
CC_DEPRECATED_ATTRIBUTE unsigned int fontSizeObj() const { return getFontSizeObj(); };
|
||||
int getFontSizeObj() const;
|
||||
CC_DEPRECATED_ATTRIBUTE int fontSizeObj() const { return getFontSizeObj(); };
|
||||
|
||||
/** set the font name
|
||||
* c++ can not overload static and non-static member functions with the same parameter types
|
||||
|
@ -309,7 +309,7 @@ protected:
|
|||
|
||||
void recreateLabel();
|
||||
|
||||
long _fontSize;
|
||||
int _fontSize;
|
||||
std::string _fontName;
|
||||
|
||||
private:
|
||||
|
|
|
@ -395,7 +395,7 @@ void Node::setPositionY(float y)
|
|||
setPosition(Point(_position.x, y));
|
||||
}
|
||||
|
||||
long Node::getChildrenCount() const
|
||||
int Node::getChildrenCount() const
|
||||
{
|
||||
return _children.size();
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ void Node::removeChild(Node* child, bool cleanup /* = true */)
|
|||
return;
|
||||
}
|
||||
|
||||
long index = _children.getIndex(child);
|
||||
auto index = _children.getIndex(child);
|
||||
if( index != CC_INVALID_INDEX )
|
||||
this->detachChild( child, index, cleanup );
|
||||
}
|
||||
|
@ -741,7 +741,7 @@ void Node::removeAllChildrenWithCleanup(bool cleanup)
|
|||
|
||||
}
|
||||
|
||||
void Node::detachChild(Node *child, long childIndex, bool doCleanup)
|
||||
void Node::detachChild(Node *child, int childIndex, bool doCleanup)
|
||||
{
|
||||
// IMPORTANT:
|
||||
// -1st do onExit
|
||||
|
@ -852,7 +852,7 @@ void Node::visit()
|
|||
}
|
||||
|
||||
this->transform();
|
||||
long i = 0;
|
||||
int i = 0;
|
||||
|
||||
if(!_children.empty())
|
||||
{
|
||||
|
@ -1055,7 +1055,7 @@ Action * Node::getActionByTag(int tag)
|
|||
return _actionManager->getActionByTag(tag, this);
|
||||
}
|
||||
|
||||
long Node::getNumberOfRunningActions() const
|
||||
int Node::getNumberOfRunningActions() const
|
||||
{
|
||||
return _actionManager->getNumberOfRunningActionsInTarget(this);
|
||||
}
|
||||
|
|
|
@ -621,7 +621,7 @@ public:
|
|||
*
|
||||
* @return The amount of children.
|
||||
*/
|
||||
long getChildrenCount() const;
|
||||
int getChildrenCount() const;
|
||||
|
||||
/**
|
||||
* Sets the parent node
|
||||
|
@ -1042,10 +1042,10 @@ public:
|
|||
*
|
||||
* @return The number of actions that are running plus the ones that are schedule to run
|
||||
*/
|
||||
long getNumberOfRunningActions() const;
|
||||
int getNumberOfRunningActions() const;
|
||||
|
||||
/** @deprecated Use getNumberOfRunningActions() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE unsigned int numberOfRunningActions() const { return getNumberOfRunningActions(); };
|
||||
CC_DEPRECATED_ATTRIBUTE int numberOfRunningActions() const { return getNumberOfRunningActions(); };
|
||||
|
||||
/// @} end of Actions
|
||||
|
||||
|
@ -1402,7 +1402,7 @@ protected:
|
|||
void insertChild(Node* child, int z);
|
||||
|
||||
/// Removes a child, call child->onExit(), do cleanup, remove it from children array.
|
||||
void detachChild(Node *child, long index, bool doCleanup);
|
||||
void detachChild(Node *child, int index, bool doCleanup);
|
||||
|
||||
/// Convert cocos2d coordinates to UI windows coordinate.
|
||||
Point convertToWindowSpace(const Point& nodePoint) const;
|
||||
|
|
|
@ -177,7 +177,7 @@ void ParticleBatchNode::addChild(Node * aChild, int zOrder, int tag)
|
|||
CCASSERT( _blendFunc.src == child->getBlendFunc().src && _blendFunc.dst == child->getBlendFunc().dst, "Can't add a ParticleSystem that uses a different blending function");
|
||||
|
||||
//no lazy sorting, so don't call super addChild, call helper instead
|
||||
long pos = addChildHelper(child,zOrder,tag);
|
||||
auto pos = addChildHelper(child,zOrder,tag);
|
||||
|
||||
//get new atlasIndex
|
||||
int atlasIndex = 0;
|
||||
|
@ -202,7 +202,7 @@ void ParticleBatchNode::addChild(Node * aChild, int zOrder, int tag)
|
|||
// XXX research whether lazy sorting + freeing current quads and calloc a new block with size of capacity would be faster
|
||||
// XXX or possibly using vertexZ for reordering, that would be fastest
|
||||
// this helper is almost equivalent to Node's addChild, but doesn't make use of the lazy sorting
|
||||
long ParticleBatchNode::addChildHelper(ParticleSystem* child, int z, int aTag)
|
||||
int ParticleBatchNode::addChildHelper(ParticleSystem* child, int z, int aTag)
|
||||
{
|
||||
CCASSERT( child != NULL, "Argument must be non-nil");
|
||||
CCASSERT( child->getParent() == NULL, "child already added. It can't be added again");
|
||||
|
@ -210,7 +210,7 @@ long ParticleBatchNode::addChildHelper(ParticleSystem* child, int z, int aTag)
|
|||
_children.reserve(4);
|
||||
|
||||
//don't use a lazy insert
|
||||
long pos = searchNewPositionInChildrenForZ(z);
|
||||
auto pos = searchNewPositionInChildrenForZ(z);
|
||||
|
||||
_children.insert(pos, child);
|
||||
|
||||
|
@ -244,7 +244,7 @@ void ParticleBatchNode::reorderChild(Node * aChild, int zOrder)
|
|||
// no reordering if only 1 child
|
||||
if (!_children.empty())
|
||||
{
|
||||
long newIndex = 0, oldIndex = 0;
|
||||
int newIndex = 0, oldIndex = 0;
|
||||
|
||||
getCurrentIndex(&oldIndex, &newIndex, child, zOrder);
|
||||
|
||||
|
@ -285,15 +285,15 @@ void ParticleBatchNode::reorderChild(Node * aChild, int zOrder)
|
|||
child->_setZOrder(zOrder);
|
||||
}
|
||||
|
||||
void ParticleBatchNode::getCurrentIndex(long* oldIndex, long* newIndex, Node* child, int z)
|
||||
void ParticleBatchNode::getCurrentIndex(int* oldIndex, int* newIndex, Node* child, int z)
|
||||
{
|
||||
bool foundCurrentIdx = false;
|
||||
bool foundNewIdx = false;
|
||||
|
||||
int minusOne = 0;
|
||||
long count = _children.size();
|
||||
auto count = _children.size();
|
||||
|
||||
for( long i=0; i < count; i++ )
|
||||
for( int i=0; i < count; i++ )
|
||||
{
|
||||
Node* pNode = _children.at(i);
|
||||
|
||||
|
@ -330,17 +330,17 @@ void ParticleBatchNode::getCurrentIndex(long* oldIndex, long* newIndex, Node* ch
|
|||
|
||||
if( ! foundNewIdx )
|
||||
{
|
||||
*newIndex = count;
|
||||
*newIndex = static_cast<int>(count);
|
||||
}
|
||||
|
||||
*newIndex += minusOne;
|
||||
}
|
||||
|
||||
long ParticleBatchNode::searchNewPositionInChildrenForZ(int z)
|
||||
int ParticleBatchNode::searchNewPositionInChildrenForZ(int z)
|
||||
{
|
||||
long count = _children.size();
|
||||
auto count = _children.size();
|
||||
|
||||
for( long i=0; i < count; i++ )
|
||||
for( int i=0; i < count; i++ )
|
||||
{
|
||||
Node *child = _children.at(i);
|
||||
if (child->getZOrder() > z)
|
||||
|
@ -348,7 +348,7 @@ long ParticleBatchNode::searchNewPositionInChildrenForZ(int z)
|
|||
return i;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
return static_cast<int>(count);
|
||||
}
|
||||
|
||||
// override removeChild:
|
||||
|
@ -376,7 +376,7 @@ void ParticleBatchNode::removeChild(Node* aChild, bool cleanup)
|
|||
updateAllAtlasIndexes();
|
||||
}
|
||||
|
||||
void ParticleBatchNode::removeChildAtIndex(unsigned int index, bool doCleanup)
|
||||
void ParticleBatchNode::removeChildAtIndex(int index, bool doCleanup)
|
||||
{
|
||||
removeChild(_children.at(index), doCleanup);
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ void ParticleBatchNode::draw(void)
|
|||
|
||||
|
||||
|
||||
void ParticleBatchNode::increaseAtlasCapacityTo(long quantity)
|
||||
void ParticleBatchNode::increaseAtlasCapacityTo(int quantity)
|
||||
{
|
||||
CCLOG("cocos2d: ParticleBatchNode: resizing TextureAtlas capacity from [%lu] to [%lu].",
|
||||
(long)_textureAtlas->getCapacity(),
|
||||
|
@ -426,7 +426,7 @@ void ParticleBatchNode::increaseAtlasCapacityTo(long quantity)
|
|||
}
|
||||
|
||||
//sets a 0'd quad into the quads array
|
||||
void ParticleBatchNode::disableParticle(unsigned int particleIndex)
|
||||
void ParticleBatchNode::disableParticle(int particleIndex)
|
||||
{
|
||||
V3F_C4B_T2F_Quad* quad = &((_textureAtlas->getQuads())[particleIndex]);
|
||||
quad->br.vertices.x = quad->br.vertices.y = quad->tr.vertices.x = quad->tr.vertices.y = quad->tl.vertices.x = quad->tl.vertices.y = quad->bl.vertices.x = quad->bl.vertices.y = 0.0f;
|
||||
|
@ -462,7 +462,7 @@ void ParticleBatchNode::insertChild(ParticleSystem* system, int index)
|
|||
//rebuild atlas indexes
|
||||
void ParticleBatchNode::updateAllAtlasIndexes()
|
||||
{
|
||||
unsigned int index = 0;
|
||||
int index = 0;
|
||||
|
||||
_children.forEach([&index](Node* child){
|
||||
ParticleSystem* partiSys = static_cast<ParticleSystem*>(child);
|
||||
|
@ -473,7 +473,7 @@ void ParticleBatchNode::updateAllAtlasIndexes()
|
|||
|
||||
// ParticleBatchNode - CocosNodeTexture protocol
|
||||
|
||||
void ParticleBatchNode::updateBlendFunc(void)
|
||||
void ParticleBatchNode::updateBlendFunc()
|
||||
{
|
||||
if( ! _textureAtlas->getTexture()->hasPremultipliedAlpha())
|
||||
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||
|
@ -490,7 +490,7 @@ void ParticleBatchNode::setTexture(Texture2D* texture)
|
|||
}
|
||||
}
|
||||
|
||||
Texture2D* ParticleBatchNode::getTexture(void) const
|
||||
Texture2D* ParticleBatchNode::getTexture() const
|
||||
{
|
||||
return _textureAtlas->getTexture();
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ void ParticleBatchNode::setBlendFunc(const BlendFunc &blendFunc)
|
|||
_blendFunc = blendFunc;
|
||||
}
|
||||
// returns the blending function used for the texture
|
||||
const BlendFunc& ParticleBatchNode::getBlendFunc(void) const
|
||||
const BlendFunc& ParticleBatchNode::getBlendFunc() const
|
||||
{
|
||||
return _blendFunc;
|
||||
}
|
||||
|
|
|
@ -91,11 +91,11 @@ public:
|
|||
/** Inserts a child into the ParticleBatchNode */
|
||||
void insertChild(ParticleSystem* system, int index);
|
||||
|
||||
void removeChildAtIndex(unsigned int index, bool doCleanup);
|
||||
void removeChildAtIndex(int index, bool doCleanup);
|
||||
void removeAllChildrenWithCleanup(bool doCleanup);
|
||||
|
||||
/** disables a particle by inserting a 0'd quad into the texture atlas */
|
||||
void disableParticle(unsigned int particleIndex);
|
||||
void disableParticle(int particleIndex);
|
||||
|
||||
/** Gets the texture atlas used for drawing the quads */
|
||||
inline TextureAtlas* getTextureAtlas() const { return _textureAtlas; };
|
||||
|
@ -129,10 +129,10 @@ public:
|
|||
|
||||
private:
|
||||
void updateAllAtlasIndexes();
|
||||
void increaseAtlasCapacityTo(long quantity);
|
||||
long searchNewPositionInChildrenForZ(int z);
|
||||
void getCurrentIndex(long* oldIndex, long* newIndex, Node* child, int z);
|
||||
long addChildHelper(ParticleSystem* child, int z, int aTag);
|
||||
void increaseAtlasCapacityTo(int quantity);
|
||||
int searchNewPositionInChildrenForZ(int z);
|
||||
void getCurrentIndex(int* oldIndex, int* newIndex, Node* child, int z);
|
||||
int addChildHelper(ParticleSystem* child, int z, int aTag);
|
||||
void updateBlendFunc(void);
|
||||
/** the texture atlas used for drawing the quads */
|
||||
TextureAtlas* _textureAtlas;
|
||||
|
|
|
@ -385,7 +385,7 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string&
|
|||
std::string textureData = dictionary["textureImageData"].asString();
|
||||
CCASSERT(!textureData.empty(), "");
|
||||
|
||||
long dataLen = textureData.size();
|
||||
auto dataLen = textureData.size();
|
||||
if (dataLen != 0)
|
||||
{
|
||||
// if it fails, try to get it from the base64-gzipped data
|
||||
|
|
|
@ -198,8 +198,8 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat
|
|||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO);
|
||||
|
||||
// textures must be power of two squared
|
||||
long powW = 0;
|
||||
long powH = 0;
|
||||
int powW = 0;
|
||||
int powH = 0;
|
||||
|
||||
if (Configuration::getInstance()->supportsNPOT())
|
||||
{
|
||||
|
@ -212,7 +212,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat
|
|||
powH = ccNextPOT(h);
|
||||
}
|
||||
|
||||
long dataLen = (long)(powW * powH * 4);
|
||||
auto dataLen = powW * powH * 4;
|
||||
data = malloc(dataLen);
|
||||
CC_BREAK_IF(! data);
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, int capacity
|
|||
* creation with File Image
|
||||
*/
|
||||
|
||||
SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, long capacity/* = DEFAULT_CAPACITY*/)
|
||||
SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, int capacity/* = DEFAULT_CAPACITY*/)
|
||||
{
|
||||
SpriteBatchNode *batchNode = new SpriteBatchNode();
|
||||
batchNode->initWithFile(fileImage, capacity);
|
||||
|
@ -76,7 +76,7 @@ SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, long capacity/*
|
|||
/*
|
||||
* init with Texture2D
|
||||
*/
|
||||
bool SpriteBatchNode::initWithTexture(Texture2D *tex, long capacity)
|
||||
bool SpriteBatchNode::initWithTexture(Texture2D *tex, int capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0, "Capacity must be >= 0");
|
||||
|
||||
|
@ -110,7 +110,7 @@ bool SpriteBatchNode::init()
|
|||
/*
|
||||
* init with FileImage
|
||||
*/
|
||||
bool SpriteBatchNode::initWithFile(const char* fileImage, long capacity)
|
||||
bool SpriteBatchNode::initWithFile(const char* fileImage, int capacity)
|
||||
{
|
||||
Texture2D *texture2D = Director::getInstance()->getTextureCache()->addImage(fileImage);
|
||||
return initWithTexture(texture2D, capacity);
|
||||
|
@ -291,7 +291,7 @@ void SpriteBatchNode::sortAllChildren()
|
|||
void SpriteBatchNode::updateAtlasIndex(Sprite* sprite, int* curIndex)
|
||||
{
|
||||
auto& array = sprite->getChildren();
|
||||
long count = array.size();
|
||||
auto count = array.size();
|
||||
|
||||
int oldIndex = 0;
|
||||
|
||||
|
@ -406,7 +406,7 @@ void SpriteBatchNode::increaseAtlasCapacity(void)
|
|||
// if we're going beyond the current TextureAtlas's capacity,
|
||||
// all the previously initialized sprites will need to redo their texture coords
|
||||
// this is likely computationally expensive
|
||||
long quantity = (_textureAtlas->getCapacity() + 1) * 4 / 3;
|
||||
auto quantity = (_textureAtlas->getCapacity() + 1) * 4 / 3;
|
||||
|
||||
CCLOG("cocos2d: SpriteBatchNode: resizing TextureAtlas capacity from [%lu] to [%lu].",
|
||||
_textureAtlas->getCapacity(),
|
||||
|
@ -483,7 +483,7 @@ int SpriteBatchNode::lowestAtlasIndexInChild(Sprite *sprite)
|
|||
int SpriteBatchNode::atlasIndexForChild(Sprite *sprite, int nZ)
|
||||
{
|
||||
auto& siblings = sprite->getParent()->getChildren();
|
||||
long childIndex = siblings.getIndex(sprite);
|
||||
auto childIndex = siblings.getIndex(sprite);
|
||||
|
||||
// ignore parent Z if parent is spriteSheet
|
||||
bool ignoreParent = (SpriteBatchNode*)(sprite->getParent()) == this;
|
||||
|
@ -551,7 +551,7 @@ void SpriteBatchNode::appendChild(Sprite* sprite)
|
|||
}
|
||||
|
||||
_descendants.push_back(sprite);
|
||||
long index = _descendants.size()-1;
|
||||
auto index = _descendants.size()-1;
|
||||
|
||||
sprite->setAtlasIndex(index);
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
The capacity will be increased in 33% in runtime if it run out of space.
|
||||
The file will be loaded using the TextureMgr.
|
||||
*/
|
||||
static SpriteBatchNode* create(const char* fileImage, long capacity = DEFAULT_CAPACITY);
|
||||
static SpriteBatchNode* create(const char* fileImage, int capacity = DEFAULT_CAPACITY);
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
|
@ -88,14 +88,14 @@ public:
|
|||
/** initializes a SpriteBatchNode with a texture2d and capacity of children.
|
||||
The capacity will be increased in 33% in runtime if it run out of space.
|
||||
*/
|
||||
bool initWithTexture(Texture2D *tex, long capacity);
|
||||
bool initWithTexture(Texture2D *tex, int capacity);
|
||||
/** initializes a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
|
||||
The capacity will be increased in 33% in runtime if it run out of space.
|
||||
The file will be loaded using the TextureMgr.
|
||||
* @js init
|
||||
* @lua init
|
||||
*/
|
||||
bool initWithFile(const char* fileImage, long capacity);
|
||||
bool initWithFile(const char* fileImage, int capacity);
|
||||
bool init();
|
||||
|
||||
/** returns the TextureAtlas object */
|
||||
|
|
|
@ -119,9 +119,9 @@ static bool _PVRHaveAlphaPremultiplied = false;
|
|||
//conventer function
|
||||
|
||||
// IIIIIIII -> RRRRRRRRGGGGGGGGGBBBBBBBB
|
||||
void Texture2D::convertI8ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertI8ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i=0; i < dataLen; ++i)
|
||||
for (ssize_t i=0; i < dataLen; ++i)
|
||||
{
|
||||
*outData++ = data[i]; //R
|
||||
*outData++ = data[i]; //G
|
||||
|
@ -130,9 +130,9 @@ void Texture2D::convertI8ToRGB888(const unsigned char* data, long dataLen, unsig
|
|||
}
|
||||
|
||||
// IIIIIIIIAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBB
|
||||
void Texture2D::convertAI88ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertAI88ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
{
|
||||
*outData++ = data[i]; //R
|
||||
*outData++ = data[i]; //G
|
||||
|
@ -141,9 +141,9 @@ void Texture2D::convertAI88ToRGB888(const unsigned char* data, long dataLen, uns
|
|||
}
|
||||
|
||||
// IIIIIIII -> RRRRRRRRGGGGGGGGGBBBBBBBBAAAAAAAA
|
||||
void Texture2D::convertI8ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertI8ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0; i < dataLen; ++i)
|
||||
for (ssize_t i = 0; i < dataLen; ++i)
|
||||
{
|
||||
*outData++ = data[i]; //R
|
||||
*outData++ = data[i]; //G
|
||||
|
@ -153,9 +153,9 @@ void Texture2D::convertI8ToRGBA8888(const unsigned char* data, long dataLen, uns
|
|||
}
|
||||
|
||||
// IIIIIIIIAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA
|
||||
void Texture2D::convertAI88ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertAI88ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
{
|
||||
*outData++ = data[i]; //R
|
||||
*outData++ = data[i]; //G
|
||||
|
@ -165,7 +165,7 @@ void Texture2D::convertAI88ToRGBA8888(const unsigned char* data, long dataLen, u
|
|||
}
|
||||
|
||||
// IIIIIIII -> RRRRRGGGGGGBBBBB
|
||||
void Texture2D::convertI8ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertI8ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0; i < dataLen; ++i)
|
||||
|
@ -177,10 +177,10 @@ void Texture2D::convertI8ToRGB565(const unsigned char* data, long dataLen, unsig
|
|||
}
|
||||
|
||||
// IIIIIIIIAAAAAAAA -> RRRRRGGGGGGBBBBB
|
||||
void Texture2D::convertAI88ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertAI88ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
{
|
||||
*out16++ = (data[i] & 0x00F8) << 8 //R
|
||||
| (data[i] & 0x00FC) << 3 //G
|
||||
|
@ -189,10 +189,10 @@ void Texture2D::convertAI88ToRGB565(const unsigned char* data, long dataLen, uns
|
|||
}
|
||||
|
||||
// IIIIIIII -> RRRRGGGGBBBBAAAA
|
||||
void Texture2D::convertI8ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertI8ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0; i < dataLen; ++i)
|
||||
for (ssize_t i = 0; i < dataLen; ++i)
|
||||
{
|
||||
*out16++ = (data[i] & 0x00F0) << 8 //R
|
||||
| (data[i] & 0x00F0) << 4 //G
|
||||
|
@ -202,10 +202,10 @@ void Texture2D::convertI8ToRGBA4444(const unsigned char* data, long dataLen, uns
|
|||
}
|
||||
|
||||
// IIIIIIIIAAAAAAAA -> RRRRGGGGBBBBAAAA
|
||||
void Texture2D::convertAI88ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertAI88ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
{
|
||||
*out16++ = (data[i] & 0x00F0) << 8 //R
|
||||
| (data[i] & 0x00F0) << 4 //G
|
||||
|
@ -215,7 +215,7 @@ void Texture2D::convertAI88ToRGBA4444(const unsigned char* data, long dataLen, u
|
|||
}
|
||||
|
||||
// IIIIIIII -> RRRRRGGGGGBBBBBA
|
||||
void Texture2D::convertI8ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertI8ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0; i < dataLen; ++i)
|
||||
|
@ -228,10 +228,10 @@ void Texture2D::convertI8ToRGB5A1(const unsigned char* data, long dataLen, unsig
|
|||
}
|
||||
|
||||
// IIIIIIIIAAAAAAAA -> RRRRRGGGGGBBBBBA
|
||||
void Texture2D::convertAI88ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertAI88ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
{
|
||||
*out16++ = (data[i] & 0x00F8) << 8 //R
|
||||
| (data[i] & 0x00F8) << 3 //G
|
||||
|
@ -241,10 +241,10 @@ void Texture2D::convertAI88ToRGB5A1(const unsigned char* data, long dataLen, uns
|
|||
}
|
||||
|
||||
// IIIIIIII -> IIIIIIIIAAAAAAAA
|
||||
void Texture2D::convertI8ToAI88(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertI8ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0; i < dataLen; ++i)
|
||||
for (ssize_t i = 0; i < dataLen; ++i)
|
||||
{
|
||||
*out16++ = 0xFF00 //A
|
||||
| data[i]; //I
|
||||
|
@ -252,27 +252,27 @@ void Texture2D::convertI8ToAI88(const unsigned char* data, long dataLen, unsigne
|
|||
}
|
||||
|
||||
// IIIIIIIIAAAAAAAA -> AAAAAAAA
|
||||
void Texture2D::convertAI88ToA8(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertAI88ToA8(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 1; i < dataLen; i += 2)
|
||||
for (ssize_t i = 1; i < dataLen; i += 2)
|
||||
{
|
||||
*outData++ = data[i]; //A
|
||||
}
|
||||
}
|
||||
|
||||
// IIIIIIIIAAAAAAAA -> IIIIIIII
|
||||
void Texture2D::convertAI88ToI8(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertAI88ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
{
|
||||
*outData++ = data[i]; //R
|
||||
}
|
||||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA
|
||||
void Texture2D::convertRGB888ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGB888ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
for (ssize_t i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
{
|
||||
*outData++ = data[i]; //R
|
||||
*outData++ = data[i + 1]; //G
|
||||
|
@ -282,9 +282,9 @@ void Texture2D::convertRGB888ToRGBA8888(const unsigned char* data, long dataLen,
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBB
|
||||
void Texture2D::convertRGBA8888ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGBA8888ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
for (ssize_t i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
{
|
||||
*outData++ = data[i]; //R
|
||||
*outData++ = data[i + 1]; //G
|
||||
|
@ -293,10 +293,10 @@ void Texture2D::convertRGBA8888ToRGB888(const unsigned char* data, long dataLen,
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGGBBBBB
|
||||
void Texture2D::convertRGB888ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGB888ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
for (ssize_t i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
{
|
||||
*out16++ = (data[i] & 0x00F8) << 8 //R
|
||||
| (data[i + 1] & 0x00FC) << 3 //G
|
||||
|
@ -305,10 +305,10 @@ void Texture2D::convertRGB888ToRGB565(const unsigned char* data, long dataLen, u
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRRGGGGGGBBBBB
|
||||
void Texture2D::convertRGBA8888ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGBA8888ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
for (ssize_t i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
{
|
||||
*out16++ = (data[i] & 0x00F8) << 8 //R
|
||||
| (data[i + 1] & 0x00FC) << 3 //G
|
||||
|
@ -317,36 +317,36 @@ void Texture2D::convertRGBA8888ToRGB565(const unsigned char* data, long dataLen,
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBB -> IIIIIIII
|
||||
void Texture2D::convertRGB888ToI8(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGB888ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
for (ssize_t i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
{
|
||||
*outData++ = (data[i] * 299 + data[i + 1] * 587 + data[i + 2] * 114 + 500) / 1000; //I = (R*299 + G*587 + B*114 + 500) / 1000
|
||||
}
|
||||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> IIIIIIII
|
||||
void Texture2D::convertRGBA8888ToI8(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGBA8888ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
for (ssize_t i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
{
|
||||
*outData++ = (data[i] * 299 + data[i + 1] * 587 + data[i + 2] * 114 + 500) / 1000; //I = (R*299 + G*587 + B*114 + 500) / 1000
|
||||
}
|
||||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> AAAAAAAA
|
||||
void Texture2D::convertRGBA8888ToA8(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGBA8888ToA8(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen -3; i < l; i += 4)
|
||||
for (ssize_t i = 0, l = dataLen -3; i < l; i += 4)
|
||||
{
|
||||
*outData++ = data[i + 3]; //A
|
||||
}
|
||||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBB -> IIIIIIIIAAAAAAAA
|
||||
void Texture2D::convertRGB888ToAI88(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGB888ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
for (ssize_t i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
{
|
||||
*outData++ = (data[i] * 299 + data[i + 1] * 587 + data[i + 2] * 114 + 500) / 1000; //I = (R*299 + G*587 + B*114 + 500) / 1000
|
||||
*outData++ = 0xFF;
|
||||
|
@ -355,9 +355,9 @@ void Texture2D::convertRGB888ToAI88(const unsigned char* data, long dataLen, uns
|
|||
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> IIIIIIIIAAAAAAAA
|
||||
void Texture2D::convertRGBA8888ToAI88(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGBA8888ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
for (ssize_t i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
{
|
||||
*outData++ = (data[i] * 299 + data[i + 1] * 587 + data[i + 2] * 114 + 500) / 1000; //I = (R*299 + G*587 + B*114 + 500) / 1000
|
||||
*outData++ = data[i + 3];
|
||||
|
@ -365,10 +365,10 @@ void Texture2D::convertRGBA8888ToAI88(const unsigned char* data, long dataLen, u
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRGGGGBBBBAAAA
|
||||
void Texture2D::convertRGB888ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGB888ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
for (ssize_t i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
{
|
||||
*out16++ = ((data[i] & 0x00F0) << 8 //R
|
||||
| (data[i + 1] & 0x00F0) << 4 //G
|
||||
|
@ -378,10 +378,10 @@ void Texture2D::convertRGB888ToRGBA4444(const unsigned char* data, long dataLen,
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRGGGGBBBBAAAA
|
||||
void Texture2D::convertRGBA8888ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGBA8888ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
for (ssize_t i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
{
|
||||
*out16++ = (data[i] & 0x00F0) << 8 //R
|
||||
| (data[i + 1] & 0x00F0) << 4 //G
|
||||
|
@ -391,10 +391,10 @@ void Texture2D::convertRGBA8888ToRGBA4444(const unsigned char* data, long dataLe
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGBBBBBA
|
||||
void Texture2D::convertRGB888ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGB888ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (long i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
for (ssize_t i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
{
|
||||
*out16++ = (data[i] & 0x00F8) << 8 //R
|
||||
| (data[i + 1] & 0x00F8) << 3 //G
|
||||
|
@ -404,10 +404,10 @@ void Texture2D::convertRGB888ToRGB5A1(const unsigned char* data, long dataLen, u
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGBBBBBA
|
||||
void Texture2D::convertRGBA8888ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGBA8888ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (long i = 0, l = dataLen - 2; i < l; i += 4)
|
||||
for (ssize_t i = 0, l = dataLen - 2; i < l; i += 4)
|
||||
{
|
||||
*out16++ = (data[i] & 0x00F8) << 8 //R
|
||||
| (data[i + 1] & 0x00F8) << 3 //G
|
||||
|
@ -451,12 +451,12 @@ Texture2D::PixelFormat Texture2D::getPixelFormat() const
|
|||
return _pixelFormat;
|
||||
}
|
||||
|
||||
long Texture2D::getPixelsWide() const
|
||||
int Texture2D::getPixelsWide() const
|
||||
{
|
||||
return _pixelsWide;
|
||||
}
|
||||
|
||||
long Texture2D::getPixelsHigh() const
|
||||
int Texture2D::getPixelsHigh() const
|
||||
{
|
||||
return _pixelsHigh;
|
||||
}
|
||||
|
@ -529,14 +529,14 @@ bool Texture2D::hasPremultipliedAlpha() const
|
|||
return _hasPremultipliedAlpha;
|
||||
}
|
||||
|
||||
bool Texture2D::initWithData(const void *data, long dataLen, Texture2D::PixelFormat pixelFormat, long pixelsWide, long pixelsHigh, const Size& contentSize)
|
||||
bool Texture2D::initWithData(const void *data, ssize_t dataLen, Texture2D::PixelFormat pixelFormat, int pixelsWide, int pixelsHigh, const Size& contentSize)
|
||||
{
|
||||
CCASSERT(dataLen>0 && pixelsWide>0 && pixelsHigh>0, "Invalid size");
|
||||
|
||||
//if data has no mipmaps, we will consider it has only one mipmap
|
||||
MipmapInfo mipmap;
|
||||
mipmap.address = (unsigned char*)data;
|
||||
mipmap.len = dataLen;
|
||||
mipmap.len = static_cast<int>(dataLen);
|
||||
return initWithMipmaps(&mipmap, 1, pixelFormat, pixelsWide, pixelsHigh);
|
||||
|
||||
//update information
|
||||
|
@ -546,7 +546,7 @@ bool Texture2D::initWithData(const void *data, long dataLen, Texture2D::PixelFor
|
|||
|
||||
}
|
||||
|
||||
bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat pixelFormat, long pixelsWide, long pixelsHigh)
|
||||
bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat pixelFormat, int pixelsWide, int pixelsHigh)
|
||||
{
|
||||
//the pixelFormat must be a certain value
|
||||
CCASSERT(pixelFormat != PixelFormat::NONE && pixelFormat != PixelFormat::AUTO, "the \"pixelFormat\" param must be a certain value!");
|
||||
|
@ -622,8 +622,8 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat
|
|||
CHECK_GL_ERROR_DEBUG(); // clean possible GL error
|
||||
|
||||
// Specify OpenGL texture image
|
||||
long width = pixelsWide;
|
||||
long height = pixelsHigh;
|
||||
int width = pixelsWide;
|
||||
int height = pixelsHigh;
|
||||
|
||||
for (int i = 0; i < mipmapsNum; ++i)
|
||||
{
|
||||
|
@ -742,7 +742,7 @@ bool Texture2D::initWithImage(Image *image, PixelFormat format)
|
|||
}
|
||||
|
||||
unsigned char* outTempData = NULL;
|
||||
int outTempDataLen = 0;
|
||||
ssize_t outTempDataLen = 0;
|
||||
|
||||
pixelFormat = convertDataToFormat(tempData, tempDataLen, renderFormat, pixelFormat, &outTempData, &outTempDataLen);
|
||||
|
||||
|
@ -774,7 +774,7 @@ bool Texture2D::initWithImage(Image *image, PixelFormat format)
|
|||
}
|
||||
}
|
||||
|
||||
Texture2D::PixelFormat Texture2D::convertI8ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
Texture2D::PixelFormat Texture2D::convertI8ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
|
@ -823,7 +823,7 @@ Texture2D::PixelFormat Texture2D::convertI8ToFormat(const unsigned char* data, l
|
|||
return format;
|
||||
}
|
||||
|
||||
Texture2D::PixelFormat Texture2D::convertAI88ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
Texture2D::PixelFormat Texture2D::convertAI88ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
|
@ -878,7 +878,7 @@ Texture2D::PixelFormat Texture2D::convertAI88ToFormat(const unsigned char* data,
|
|||
return format;
|
||||
}
|
||||
|
||||
Texture2D::PixelFormat Texture2D::convertRGB888ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
Texture2D::PixelFormat Texture2D::convertRGB888ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
|
@ -926,7 +926,7 @@ Texture2D::PixelFormat Texture2D::convertRGB888ToFormat(const unsigned char* dat
|
|||
return format;
|
||||
}
|
||||
|
||||
Texture2D::PixelFormat Texture2D::convertRGBA8888ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
Texture2D::PixelFormat Texture2D::convertRGBA8888ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen)
|
||||
{
|
||||
|
||||
switch (format)
|
||||
|
@ -998,7 +998,7 @@ rgb(2) -> 1235678
|
|||
rgba(1) -> 12345678
|
||||
|
||||
*/
|
||||
Texture2D::PixelFormat Texture2D::convertDataToFormat(const unsigned char* data, long dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
Texture2D::PixelFormat Texture2D::convertDataToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, ssize_t* outDataLen)
|
||||
{
|
||||
switch (originFormat)
|
||||
{
|
||||
|
@ -1243,7 +1243,7 @@ void Texture2D::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied)
|
|||
|
||||
void Texture2D::generateMipmap()
|
||||
{
|
||||
CCASSERT( static_cast<unsigned long>(_pixelsWide) == ccNextPOT(_pixelsWide) && static_cast<unsigned long>(_pixelsHigh) == ccNextPOT(_pixelsHigh), "Mipmap texture only works in POT textures");
|
||||
CCASSERT(_pixelsWide == ccNextPOT(_pixelsWide) && _pixelsHigh == ccNextPOT(_pixelsHigh), "Mipmap texture only works in POT textures");
|
||||
GL::bindTexture2D( _name );
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
_hasMipmaps = true;
|
||||
|
@ -1256,8 +1256,8 @@ bool Texture2D::hasMipmaps() const
|
|||
|
||||
void Texture2D::setTexParameters(const TexParams &texParams)
|
||||
{
|
||||
CCASSERT( (static_cast<unsigned long>(_pixelsWide) == ccNextPOT(_pixelsWide) || texParams.wrapS == GL_CLAMP_TO_EDGE) &&
|
||||
(static_cast<unsigned long>(_pixelsHigh) == ccNextPOT(_pixelsHigh) || texParams.wrapT == GL_CLAMP_TO_EDGE),
|
||||
CCASSERT((_pixelsWide == ccNextPOT(_pixelsWide) || texParams.wrapS == GL_CLAMP_TO_EDGE) &&
|
||||
(_pixelsHigh == ccNextPOT(_pixelsHigh) || texParams.wrapT == GL_CLAMP_TO_EDGE),
|
||||
"GL_CLAMP_TO_EDGE should be used in NPOT dimensions");
|
||||
|
||||
GL::bindTexture2D( _name );
|
||||
|
|
|
@ -217,10 +217,10 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool initWithData(const void *data, long dataLen, Texture2D::PixelFormat pixelFormat, long pixelsWide, long pixelsHigh, const Size& contentSize);
|
||||
bool initWithData(const void *data, ssize_t dataLen, Texture2D::PixelFormat pixelFormat, int pixelsWide, int pixelsHigh, const Size& contentSize);
|
||||
|
||||
/** Initializes with mipmaps */
|
||||
bool initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, Texture2D::PixelFormat pixelFormat, long pixelsWide, long pixelsHigh);
|
||||
bool initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, Texture2D::PixelFormat pixelFormat, int pixelsWide, int pixelsHigh);
|
||||
|
||||
/**
|
||||
Drawing extensions to make it easy to draw basic quads using a Texture2D object.
|
||||
|
@ -327,10 +327,10 @@ public:
|
|||
Texture2D::PixelFormat getPixelFormat() const;
|
||||
|
||||
/** Gets the width of the texture in pixels */
|
||||
long getPixelsWide() const;
|
||||
int getPixelsWide() const;
|
||||
|
||||
/** Gets the height of the texture in pixels */
|
||||
long getPixelsHigh() const;
|
||||
int getPixelsHigh() const;
|
||||
|
||||
/** Gets the texture name */
|
||||
GLuint getName() const;
|
||||
|
@ -361,56 +361,56 @@ private:
|
|||
Convert the format to the format param you specified, if the format is PixelFormat::Automatic, it will detect it automatically and convert to the closest format for you.
|
||||
It will return the converted format to you. if the outData != data, you must delete it manually.
|
||||
*/
|
||||
static PixelFormat convertDataToFormat(const unsigned char* data, long dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
static PixelFormat convertDataToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, ssize_t* outDataLen);
|
||||
|
||||
static PixelFormat convertI8ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
static PixelFormat convertAI88ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
static PixelFormat convertRGB888ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
static PixelFormat convertRGBA8888ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
static PixelFormat convertI8ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen);
|
||||
static PixelFormat convertAI88ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen);
|
||||
static PixelFormat convertRGB888ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen);
|
||||
static PixelFormat convertRGBA8888ToFormat(const unsigned char* data, ssize_t dataLen, PixelFormat format, unsigned char** outData, ssize_t* outDataLen);
|
||||
|
||||
//I8 to XXX
|
||||
static void convertI8ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertI8ToAI88(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertI8ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
|
||||
//AI88 to XXX
|
||||
static void convertAI88ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertAI88ToA8(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertAI88ToI8(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertAI88ToA8(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertAI88ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
|
||||
//RGB888 to XXX
|
||||
static void convertRGB888ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToI8(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToAI88(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToRGBA8888(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
|
||||
//RGBA8888 to XXX
|
||||
static void convertRGBA8888ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToI8(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToA8(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToAI88(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToRGB888(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToRGB565(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToI8(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToA8(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToAI88(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToRGBA4444(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToRGB5A1(const unsigned char* data, ssize_t dataLen, unsigned char* outData);
|
||||
|
||||
protected:
|
||||
/** pixel format of the texture */
|
||||
Texture2D::PixelFormat _pixelFormat;
|
||||
|
||||
/** width in pixels */
|
||||
long _pixelsWide;
|
||||
int _pixelsWide;
|
||||
|
||||
/** height in pixels */
|
||||
long _pixelsHigh;
|
||||
int _pixelsHigh;
|
||||
|
||||
/** texture name */
|
||||
GLuint _name;
|
||||
|
|
|
@ -74,12 +74,12 @@ TextureAtlas::~TextureAtlas()
|
|||
#endif
|
||||
}
|
||||
|
||||
long TextureAtlas::getTotalQuads() const
|
||||
int TextureAtlas::getTotalQuads() const
|
||||
{
|
||||
return _totalQuads;
|
||||
}
|
||||
|
||||
long TextureAtlas::getCapacity() const
|
||||
int TextureAtlas::getCapacity() const
|
||||
{
|
||||
return _capacity;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ void TextureAtlas::setQuads(V3F_C4B_T2F_Quad* quads)
|
|||
|
||||
// TextureAtlas - alloc & init
|
||||
|
||||
TextureAtlas * TextureAtlas::create(const char* file, long capacity)
|
||||
TextureAtlas * TextureAtlas::create(const char* file, int capacity)
|
||||
{
|
||||
TextureAtlas * textureAtlas = new TextureAtlas();
|
||||
if(textureAtlas && textureAtlas->initWithFile(file, capacity))
|
||||
|
@ -122,7 +122,7 @@ TextureAtlas * TextureAtlas::create(const char* file, long capacity)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, long capacity)
|
||||
TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, int capacity)
|
||||
{
|
||||
TextureAtlas * textureAtlas = new TextureAtlas();
|
||||
if (textureAtlas && textureAtlas->initWithTexture(texture, capacity))
|
||||
|
@ -134,7 +134,7 @@ TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, long capacity
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool TextureAtlas::initWithFile(const char * file, long capacity)
|
||||
bool TextureAtlas::initWithFile(const char * file, int capacity)
|
||||
{
|
||||
// retained in property
|
||||
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(file);
|
||||
|
@ -150,7 +150,7 @@ bool TextureAtlas::initWithFile(const char * file, long capacity)
|
|||
}
|
||||
}
|
||||
|
||||
bool TextureAtlas::initWithTexture(Texture2D *texture, long capacity)
|
||||
bool TextureAtlas::initWithTexture(Texture2D *texture, int capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0, "Capacity must be >= 0");
|
||||
|
||||
|
@ -224,7 +224,7 @@ void TextureAtlas::listenBackToForeground(Object *obj)
|
|||
|
||||
const char* TextureAtlas::description() const
|
||||
{
|
||||
return String::createWithFormat("<TextureAtlas | totalQuads = %ld>", _totalQuads)->getCString();
|
||||
return String::createWithFormat("<TextureAtlas | totalQuads = %d>", _totalQuads)->getCString();
|
||||
}
|
||||
|
||||
|
||||
|
@ -317,7 +317,7 @@ void TextureAtlas::mapBuffers()
|
|||
|
||||
// TextureAtlas - Update, Insert, Move & Remove
|
||||
|
||||
void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, long index)
|
||||
void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, int index)
|
||||
{
|
||||
CCASSERT( index >= 0 && index < _capacity, "updateQuadWithTexture: Invalid index");
|
||||
|
||||
|
@ -330,7 +330,7 @@ void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, long index)
|
|||
|
||||
}
|
||||
|
||||
void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, long index)
|
||||
void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, int index)
|
||||
{
|
||||
CCASSERT( index>=0 && index<_capacity, "insertQuadWithTexture: Invalid index");
|
||||
|
||||
|
@ -338,7 +338,7 @@ void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, long index)
|
|||
CCASSERT( _totalQuads <= _capacity, "invalid totalQuads");
|
||||
|
||||
// issue #575. index can be > totalQuads
|
||||
long remaining = (_totalQuads-1) - index;
|
||||
auto remaining = (_totalQuads-1) - index;
|
||||
|
||||
// last object doesn't need to be moved
|
||||
if( remaining > 0)
|
||||
|
@ -354,7 +354,7 @@ void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, long index)
|
|||
|
||||
}
|
||||
|
||||
void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, long index, long amount)
|
||||
void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount)
|
||||
{
|
||||
CCASSERT(index>=0 && amount>=0 && index+amount<=_capacity, "insertQuadWithTexture: Invalid index + amount");
|
||||
|
||||
|
@ -363,7 +363,7 @@ void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, long index, long amount)
|
|||
CCASSERT( _totalQuads <= _capacity, "invalid totalQuads");
|
||||
|
||||
// issue #575. index can be > totalQuads
|
||||
long remaining = (_totalQuads-1) - index - amount;
|
||||
auto remaining = (_totalQuads-1) - index - amount;
|
||||
|
||||
// last object doesn't need to be moved
|
||||
if( remaining > 0)
|
||||
|
@ -373,9 +373,9 @@ void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, long index, long amount)
|
|||
}
|
||||
|
||||
|
||||
long max = index + amount;
|
||||
auto max = index + amount;
|
||||
int j = 0;
|
||||
for (long i = index; i < max ; i++)
|
||||
for (int i = index; i < max ; i++)
|
||||
{
|
||||
_quads[index] = quads[j];
|
||||
index++;
|
||||
|
@ -385,7 +385,7 @@ void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, long index, long amount)
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void TextureAtlas::insertQuadFromIndex(long oldIndex, long newIndex)
|
||||
void TextureAtlas::insertQuadFromIndex(int oldIndex, int newIndex)
|
||||
{
|
||||
CCASSERT( newIndex >= 0 && newIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
|
||||
CCASSERT( oldIndex >= 0 && oldIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
|
||||
|
@ -396,9 +396,9 @@ void TextureAtlas::insertQuadFromIndex(long oldIndex, long newIndex)
|
|||
}
|
||||
// because it is ambiguous in iphone, so we implement abs ourselves
|
||||
// unsigned int howMany = abs( oldIndex - newIndex);
|
||||
long howMany = (oldIndex - newIndex) > 0 ? (oldIndex - newIndex) : (newIndex - oldIndex);
|
||||
long dst = oldIndex;
|
||||
long src = oldIndex + 1;
|
||||
auto howMany = (oldIndex - newIndex) > 0 ? (oldIndex - newIndex) : (newIndex - oldIndex);
|
||||
auto dst = oldIndex;
|
||||
auto src = oldIndex + 1;
|
||||
if( oldIndex > newIndex)
|
||||
{
|
||||
dst = newIndex+1;
|
||||
|
@ -414,11 +414,11 @@ void TextureAtlas::insertQuadFromIndex(long oldIndex, long newIndex)
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void TextureAtlas::removeQuadAtIndex(long index)
|
||||
void TextureAtlas::removeQuadAtIndex(int index)
|
||||
{
|
||||
CCASSERT( index>=0 && index<_totalQuads, "removeQuadAtIndex: Invalid index");
|
||||
|
||||
long remaining = (_totalQuads-1) - index;
|
||||
auto remaining = (_totalQuads-1) - index;
|
||||
|
||||
// last object doesn't need to be moved
|
||||
if( remaining )
|
||||
|
@ -433,11 +433,11 @@ void TextureAtlas::removeQuadAtIndex(long index)
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void TextureAtlas::removeQuadsAtIndex(long index, long amount)
|
||||
void TextureAtlas::removeQuadsAtIndex(int index, int amount)
|
||||
{
|
||||
CCASSERT(index>=0 && amount>=0 && index+amount<=_totalQuads, "removeQuadAtIndex: index + amount out of bounds");
|
||||
|
||||
long remaining = (_totalQuads) - (index + amount);
|
||||
auto remaining = (_totalQuads) - (index + amount);
|
||||
|
||||
_totalQuads -= amount;
|
||||
|
||||
|
@ -455,14 +455,14 @@ void TextureAtlas::removeAllQuads()
|
|||
}
|
||||
|
||||
// TextureAtlas - Resize
|
||||
bool TextureAtlas::resizeCapacity(long newCapacity)
|
||||
bool TextureAtlas::resizeCapacity(int newCapacity)
|
||||
{
|
||||
CCASSERT(newCapacity>=0, "capacity >= 0");
|
||||
if( newCapacity == _capacity )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
long oldCapactiy = _capacity;
|
||||
auto oldCapactiy = _capacity;
|
||||
// update capacity and totolQuads
|
||||
_totalQuads = MIN(_totalQuads, newCapacity);
|
||||
_capacity = newCapacity;
|
||||
|
@ -529,13 +529,13 @@ bool TextureAtlas::resizeCapacity(long newCapacity)
|
|||
return true;
|
||||
}
|
||||
|
||||
void TextureAtlas::increaseTotalQuadsWith(long amount)
|
||||
void TextureAtlas::increaseTotalQuadsWith(int amount)
|
||||
{
|
||||
CCASSERT(amount>=0, "amount >= 0");
|
||||
_totalQuads += amount;
|
||||
}
|
||||
|
||||
void TextureAtlas::moveQuadsFromIndex(long oldIndex, long amount, long newIndex)
|
||||
void TextureAtlas::moveQuadsFromIndex(int oldIndex, int amount, int newIndex)
|
||||
{
|
||||
CCASSERT(oldIndex>=0 && amount>=0 && newIndex>=0, "values must be >= 0");
|
||||
CCASSERT(newIndex + amount <= _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
|
||||
|
@ -567,7 +567,7 @@ void TextureAtlas::moveQuadsFromIndex(long oldIndex, long amount, long newIndex)
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void TextureAtlas::moveQuadsFromIndex(long index, long newIndex)
|
||||
void TextureAtlas::moveQuadsFromIndex(int index, int newIndex)
|
||||
{
|
||||
CCASSERT(index>=0 && newIndex>=0, "values must be >= 0");
|
||||
CCASSERT(newIndex + (_totalQuads - index) <= _capacity, "moveQuadsFromIndex move is out of bounds");
|
||||
|
@ -575,14 +575,14 @@ void TextureAtlas::moveQuadsFromIndex(long index, long newIndex)
|
|||
memmove(_quads + newIndex,_quads + index, (_totalQuads - index) * sizeof(_quads[0]));
|
||||
}
|
||||
|
||||
void TextureAtlas::fillWithEmptyQuadsFromIndex(long index, long amount)
|
||||
void TextureAtlas::fillWithEmptyQuadsFromIndex(int index, int amount)
|
||||
{
|
||||
CCASSERT(index>=0 && amount>=0, "values must be >= 0");
|
||||
V3F_C4B_T2F_Quad quad;
|
||||
memset(&quad, 0, sizeof(quad));
|
||||
|
||||
long to = index + amount;
|
||||
for (long i = index ; i < to ; i++)
|
||||
auto to = index + amount;
|
||||
for (int i = index ; i < to ; i++)
|
||||
{
|
||||
_quads[i] = quad;
|
||||
}
|
||||
|
@ -595,13 +595,13 @@ void TextureAtlas::drawQuads()
|
|||
this->drawNumberOfQuads(_totalQuads, 0);
|
||||
}
|
||||
|
||||
void TextureAtlas::drawNumberOfQuads(long numberOfQuads)
|
||||
void TextureAtlas::drawNumberOfQuads(int numberOfQuads)
|
||||
{
|
||||
CCASSERT(numberOfQuads>=0, "numberOfQuads must be >= 0");
|
||||
this->drawNumberOfQuads(numberOfQuads, 0);
|
||||
}
|
||||
|
||||
void TextureAtlas::drawNumberOfQuads(long numberOfQuads, long start)
|
||||
void TextureAtlas::drawNumberOfQuads(int numberOfQuads, int start)
|
||||
{
|
||||
CCASSERT(numberOfQuads>=0 && start>=0, "numberOfQuads and start must be >= 0");
|
||||
|
||||
|
|
|
@ -59,13 +59,13 @@ public:
|
|||
/** creates a TextureAtlas with an filename and with an initial capacity for Quads.
|
||||
* The TextureAtlas capacity can be increased in runtime.
|
||||
*/
|
||||
static TextureAtlas* create(const char* file , long capacity);
|
||||
static TextureAtlas* create(const char* file , int capacity);
|
||||
|
||||
/** creates a TextureAtlas with a previously initialized Texture2D object, and
|
||||
* with an initial capacity for n Quads.
|
||||
* The TextureAtlas capacity can be increased in runtime.
|
||||
*/
|
||||
static TextureAtlas* createWithTexture(Texture2D *texture, long capacity);
|
||||
static TextureAtlas* createWithTexture(Texture2D *texture, int capacity);
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
*
|
||||
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
|
||||
*/
|
||||
bool initWithFile(const char* file, long capacity);
|
||||
bool initWithFile(const char* file, int capacity);
|
||||
|
||||
/** initializes a TextureAtlas with a previously initialized Texture2D object, and
|
||||
* with an initial capacity for Quads.
|
||||
|
@ -89,43 +89,43 @@ public:
|
|||
*
|
||||
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
|
||||
*/
|
||||
bool initWithTexture(Texture2D *texture, long capacity);
|
||||
bool initWithTexture(Texture2D *texture, int capacity);
|
||||
|
||||
/** updates a Quad (texture, vertex and color) at a certain index
|
||||
* index must be between 0 and the atlas capacity - 1
|
||||
@since v0.8
|
||||
*/
|
||||
void updateQuad(V3F_C4B_T2F_Quad* quad, long index);
|
||||
void updateQuad(V3F_C4B_T2F_Quad* quad, int index);
|
||||
|
||||
/** Inserts a Quad (texture, vertex and color) at a certain index
|
||||
index must be between 0 and the atlas capacity - 1
|
||||
@since v0.8
|
||||
*/
|
||||
void insertQuad(V3F_C4B_T2F_Quad* quad, long index);
|
||||
void insertQuad(V3F_C4B_T2F_Quad* quad, int index);
|
||||
|
||||
/** Inserts a c array of quads at a given index
|
||||
index must be between 0 and the atlas capacity - 1
|
||||
this method doesn't enlarge the array when amount + index > totalQuads
|
||||
@since v1.1
|
||||
*/
|
||||
void insertQuads(V3F_C4B_T2F_Quad* quads, long index, long amount);
|
||||
void insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount);
|
||||
|
||||
/** Removes the quad that is located at a certain index and inserts it at a new index
|
||||
This operation is faster than removing and inserting in a quad in 2 different steps
|
||||
@since v0.7.2
|
||||
*/
|
||||
void insertQuadFromIndex(long fromIndex, long newIndex);
|
||||
void insertQuadFromIndex(int fromIndex, int newIndex);
|
||||
|
||||
/** removes a quad at a given index number.
|
||||
The capacity remains the same, but the total number of quads to be drawn is reduced in 1
|
||||
@since v0.7.2
|
||||
*/
|
||||
void removeQuadAtIndex(long index);
|
||||
void removeQuadAtIndex(int index);
|
||||
|
||||
/** removes a amount of quads starting from index
|
||||
@since 1.1
|
||||
*/
|
||||
void removeQuadsAtIndex(long index, long amount);
|
||||
void removeQuadsAtIndex(int index, int amount);
|
||||
/** removes all Quads.
|
||||
The TextureAtlas capacity remains untouched. No memory is freed.
|
||||
The total number of quads to be drawn will be 0
|
||||
|
@ -138,19 +138,19 @@ public:
|
|||
* It returns true if the resize was successful.
|
||||
* If it fails to resize the capacity it will return false with a new capacity of 0.
|
||||
*/
|
||||
bool resizeCapacity(long capacity);
|
||||
bool resizeCapacity(int capacity);
|
||||
|
||||
/**
|
||||
Used internally by ParticleBatchNode
|
||||
don't use this unless you know what you're doing
|
||||
@since 1.1
|
||||
*/
|
||||
void increaseTotalQuadsWith(long amount);
|
||||
void increaseTotalQuadsWith(int amount);
|
||||
|
||||
/** Moves an amount of quads from oldIndex at newIndex
|
||||
@since v1.1
|
||||
*/
|
||||
void moveQuadsFromIndex(long oldIndex, long amount, long newIndex);
|
||||
void moveQuadsFromIndex(int oldIndex, int amount, int newIndex);
|
||||
|
||||
/**
|
||||
Moves quads from index till totalQuads to the newIndex
|
||||
|
@ -158,26 +158,26 @@ public:
|
|||
This method doesn't enlarge the array if newIndex + quads to be moved > capacity
|
||||
@since 1.1
|
||||
*/
|
||||
void moveQuadsFromIndex(long index, long newIndex);
|
||||
void moveQuadsFromIndex(int index, int newIndex);
|
||||
|
||||
/**
|
||||
Ensures that after a realloc quads are still empty
|
||||
Used internally by ParticleBatchNode
|
||||
@since 1.1
|
||||
*/
|
||||
void fillWithEmptyQuadsFromIndex(long index, long amount);
|
||||
void fillWithEmptyQuadsFromIndex(int index, int amount);
|
||||
|
||||
/** draws n quads
|
||||
* n can't be greater than the capacity of the Atlas
|
||||
*/
|
||||
void drawNumberOfQuads(long n);
|
||||
void drawNumberOfQuads(int n);
|
||||
|
||||
/** draws n quads from an index (offset).
|
||||
n + start can't be greater than the capacity of the atlas
|
||||
|
||||
@since v1.0
|
||||
*/
|
||||
void drawNumberOfQuads(long numberOfQuads, long start);
|
||||
void drawNumberOfQuads(int numberOfQuads, int start);
|
||||
|
||||
/** draws all the Atlas's Quads
|
||||
*/
|
||||
|
@ -197,10 +197,10 @@ public:
|
|||
const char* description() const;
|
||||
|
||||
/** Gets the quantity of quads that are going to be drawn */
|
||||
long getTotalQuads() const;
|
||||
int getTotalQuads() const;
|
||||
|
||||
/** Gets the quantity of quads that can be stored with the current texture atlas size */
|
||||
long getCapacity() const;
|
||||
int getCapacity() const;
|
||||
|
||||
/** Gets the texture of the texture atlas */
|
||||
Texture2D* getTexture() const;
|
||||
|
@ -226,9 +226,9 @@ protected:
|
|||
GLuint _buffersVBO[2]; //0: vertex 1: indices
|
||||
bool _dirty; //indicates whether or not the array buffer of the VBO needs to be updated
|
||||
/** quantity of quads that are going to be drawn */
|
||||
long _totalQuads;
|
||||
int _totalQuads;
|
||||
/** quantity of quads that can be stored with the current texture atlas size */
|
||||
long _capacity;
|
||||
int _capacity;
|
||||
/** Texture of the texture atlas */
|
||||
Texture2D* _texture;
|
||||
/** Quads that are going to be rendered */
|
||||
|
|
|
@ -446,7 +446,7 @@ void TextureCache::dumpCachedTextureInfo() const
|
|||
Texture2D* tex = it->second;
|
||||
unsigned int bpp = tex->getBitsPerPixelForFormat();
|
||||
// Each texture takes up width * height * bytesPerPixel bytes.
|
||||
long bytes = tex->getPixelsWide() * tex->getPixelsHigh() * bpp / 8;
|
||||
auto bytes = tex->getPixelsWide() * tex->getPixelsHigh() * bpp / 8;
|
||||
totalBytes += bytes;
|
||||
count++;
|
||||
log("cocos2d: \"%s\" rc=%lu id=%lu %lu x %lu @ %ld bpp => %lu KB",
|
||||
|
@ -607,7 +607,7 @@ void VolatileTextureMgr::reloadAllTextures()
|
|||
case VolatileTexture::kImageFile:
|
||||
{
|
||||
Image* image = new Image();
|
||||
long size = 0;
|
||||
ssize_t size = 0;
|
||||
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(vt->_fileName.c_str(), "rb", &size);
|
||||
|
||||
if (image && image->initWithImageData(pBuffer, size))
|
||||
|
|
|
@ -58,7 +58,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLEle
|
|||
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument();
|
||||
*doc = xmlDoc;
|
||||
//CCFileData data(UserDefault::getInstance()->getXMLFilePath().c_str(),"rt");
|
||||
long nSize;
|
||||
ssize_t nSize;
|
||||
char* pXmlBuffer = (char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &nSize);
|
||||
//const char* pXmlBuffer = (const char*)data.getBuffer();
|
||||
if(NULL == pXmlBuffer)
|
||||
|
|
|
@ -73,7 +73,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDoc
|
|||
{
|
||||
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument();
|
||||
*doc = xmlDoc;
|
||||
long size;
|
||||
ssize_t size;
|
||||
char* pXmlBuffer = (char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &size);
|
||||
//const char* pXmlBuffer = (const char*)data.getBuffer();
|
||||
if(NULL == pXmlBuffer)
|
||||
|
@ -420,11 +420,11 @@ Data* UserDefault::getDataForKey(const char* pKey, Data* defaultValue)
|
|||
else
|
||||
{
|
||||
unsigned char *bytes = {0};
|
||||
unsigned long size = 0;
|
||||
int size = 0;
|
||||
|
||||
if (data.length > 0) {
|
||||
bytes = (unsigned char*)data.bytes;
|
||||
size = data.length;
|
||||
size = static_cast<int>(data.length);
|
||||
}
|
||||
Data *ret = new Data(bytes, size);
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDoc
|
|||
{
|
||||
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument();
|
||||
*doc = xmlDoc;
|
||||
long size;
|
||||
ssize_t size;
|
||||
char* pXmlBuffer = (char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &size);
|
||||
//const char* pXmlBuffer = (const char*)data.getBuffer();
|
||||
if(NULL == pXmlBuffer)
|
||||
|
|
|
@ -591,7 +591,7 @@ bool ZipFile::fileExists(const std::string &fileName) const
|
|||
return ret;
|
||||
}
|
||||
|
||||
unsigned char *ZipFile::getFileData(const std::string &fileName, long *size)
|
||||
unsigned char *ZipFile::getFileData(const std::string &fileName, ssize_t *size)
|
||||
{
|
||||
unsigned char * buffer = NULL;
|
||||
if (size)
|
||||
|
|
|
@ -264,7 +264,7 @@ namespace cocos2d
|
|||
*
|
||||
* @since v2.0.5
|
||||
*/
|
||||
unsigned char *getFileData(const std::string &fileName, long *size);
|
||||
unsigned char *getFileData(const std::string &fileName, ssize_t *size);
|
||||
|
||||
private:
|
||||
/** Internal data like zip file pointer / file list array and so on */
|
||||
|
|
|
@ -28,10 +28,10 @@ THE SOFTWARE.
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
const long CC_INVALID_INDEX = -1;
|
||||
const int CC_INVALID_INDEX = -1;
|
||||
|
||||
/** Allocates and initializes a new array with specified capacity */
|
||||
ccArray* ccArrayNew(long capacity)
|
||||
ccArray* ccArrayNew(int capacity)
|
||||
{
|
||||
if (capacity == 0)
|
||||
capacity = 7;
|
||||
|
@ -68,13 +68,13 @@ void ccArrayDoubleCapacity(ccArray *arr)
|
|||
arr->arr = newArr;
|
||||
}
|
||||
|
||||
void ccArrayEnsureExtraCapacity(ccArray *arr, long extra)
|
||||
void ccArrayEnsureExtraCapacity(ccArray *arr, int extra)
|
||||
{
|
||||
while (arr->max < arr->num + extra)
|
||||
{
|
||||
CCLOG("cocos2d: ccCArray: resizing ccArray capacity from [%lu] to [%lu].",
|
||||
(long) arr->max,
|
||||
(long) arr->max*2);
|
||||
CCLOG("cocos2d: ccCArray: resizing ccArray capacity from [%d] to [%d].",
|
||||
arr->max,
|
||||
arr->max*2);
|
||||
|
||||
ccArrayDoubleCapacity(arr);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ void ccArrayEnsureExtraCapacity(ccArray *arr, long extra)
|
|||
|
||||
void ccArrayShrink(ccArray *arr)
|
||||
{
|
||||
long newSize = 0;
|
||||
int newSize = 0;
|
||||
|
||||
//only resize when necessary
|
||||
if (arr->max > arr->num && !(arr->num==0 && arr->max==1))
|
||||
|
@ -104,13 +104,13 @@ void ccArrayShrink(ccArray *arr)
|
|||
}
|
||||
|
||||
/** Returns index of first occurrence of object, CC_INVALID_INDEX if object not found. */
|
||||
long ccArrayGetIndexOfObject(ccArray *arr, Object* object)
|
||||
int ccArrayGetIndexOfObject(ccArray *arr, Object* object)
|
||||
{
|
||||
const long arrNum = arr->num;
|
||||
const auto arrNum = arr->num;
|
||||
Object** ptr = arr->arr;
|
||||
for(long i = 0; i < arrNum; ++i, ++ptr)
|
||||
for (int i = 0; i < arrNum; ++i, ++ptr)
|
||||
{
|
||||
if( *ptr == object )
|
||||
if (*ptr == object)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ void ccArrayAppendObjectWithResize(ccArray *arr, Object* object)
|
|||
enough capacity. */
|
||||
void ccArrayAppendArray(ccArray *arr, ccArray *plusArr)
|
||||
{
|
||||
for(long i = 0; i < plusArr->num; i++)
|
||||
for (int i = 0; i < plusArr->num; i++)
|
||||
{
|
||||
ccArrayAppendObject(arr, plusArr->arr[i]);
|
||||
}
|
||||
|
@ -157,15 +157,15 @@ void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr)
|
|||
}
|
||||
|
||||
/** Inserts an object at index */
|
||||
void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, long index)
|
||||
void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, int index)
|
||||
{
|
||||
CCASSERT(index<=arr->num, "Invalid index. Out of bounds");
|
||||
CCASSERT(object != NULL, "Invalid parameter!");
|
||||
|
||||
ccArrayEnsureExtraCapacity(arr, 1);
|
||||
|
||||
long remaining = arr->num - index;
|
||||
if( remaining > 0)
|
||||
int remaining = arr->num - index;
|
||||
if (remaining > 0)
|
||||
{
|
||||
memmove((void *)&arr->arr[index+1], (void *)&arr->arr[index], sizeof(Object*) * remaining );
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, long index)
|
|||
}
|
||||
|
||||
/** Swaps two objects */
|
||||
void ccArraySwapObjectsAtIndexes(ccArray *arr, long index1, long index2)
|
||||
void ccArraySwapObjectsAtIndexes(ccArray *arr, int index1, int index2)
|
||||
{
|
||||
CCASSERT(index1>=0 && index1 < arr->num, "(1) Invalid index. Out of bounds");
|
||||
CCASSERT(index2>=0 && index2 < arr->num, "(2) Invalid index. Out of bounds");
|
||||
|
@ -190,7 +190,7 @@ void ccArraySwapObjectsAtIndexes(ccArray *arr, long index1, long index2)
|
|||
/** Removes all objects from arr */
|
||||
void ccArrayRemoveAllObjects(ccArray *arr)
|
||||
{
|
||||
while( arr->num > 0 )
|
||||
while (arr->num > 0)
|
||||
{
|
||||
(arr->arr[--arr->num])->release();
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ void ccArrayRemoveAllObjects(ccArray *arr)
|
|||
|
||||
/** Removes object at specified index and pushes back all subsequent objects.
|
||||
Behavior undefined if index outside [0, num-1]. */
|
||||
void ccArrayRemoveObjectAtIndex(ccArray *arr, long index, bool bReleaseObj/* = true*/)
|
||||
void ccArrayRemoveObjectAtIndex(ccArray *arr, int index, bool bReleaseObj/* = true*/)
|
||||
{
|
||||
CCASSERT(arr && arr->num > 0 && index>=0 && index < arr->num, "Invalid index. Out of bounds");
|
||||
if (bReleaseObj)
|
||||
|
@ -208,7 +208,7 @@ void ccArrayRemoveObjectAtIndex(ccArray *arr, long index, bool bReleaseObj/* = t
|
|||
|
||||
arr->num--;
|
||||
|
||||
long remaining = arr->num - index;
|
||||
int remaining = arr->num - index;
|
||||
if(remaining>0)
|
||||
{
|
||||
memmove((void *)&arr->arr[index], (void *)&arr->arr[index+1], remaining * sizeof(Object*));
|
||||
|
@ -218,16 +218,16 @@ void ccArrayRemoveObjectAtIndex(ccArray *arr, long index, bool bReleaseObj/* = t
|
|||
/** Removes object at specified index and fills the gap with the last object,
|
||||
thereby avoiding the need to push back subsequent objects.
|
||||
Behavior undefined if index outside [0, num-1]. */
|
||||
void ccArrayFastRemoveObjectAtIndex(ccArray *arr, long index)
|
||||
void ccArrayFastRemoveObjectAtIndex(ccArray *arr, int index)
|
||||
{
|
||||
CC_SAFE_RELEASE(arr->arr[index]);
|
||||
long last = --arr->num;
|
||||
auto last = --arr->num;
|
||||
arr->arr[index] = arr->arr[last];
|
||||
}
|
||||
|
||||
void ccArrayFastRemoveObject(ccArray *arr, Object* object)
|
||||
{
|
||||
long index = ccArrayGetIndexOfObject(arr, object);
|
||||
auto index = ccArrayGetIndexOfObject(arr, object);
|
||||
if (index != CC_INVALID_INDEX)
|
||||
{
|
||||
ccArrayFastRemoveObjectAtIndex(arr, index);
|
||||
|
@ -238,7 +238,7 @@ void ccArrayFastRemoveObject(ccArray *arr, Object* object)
|
|||
found the function has no effect. */
|
||||
void ccArrayRemoveObject(ccArray *arr, Object* object, bool bReleaseObj/* = true*/)
|
||||
{
|
||||
long index = ccArrayGetIndexOfObject(arr, object);
|
||||
auto index = ccArrayGetIndexOfObject(arr, object);
|
||||
if (index != CC_INVALID_INDEX)
|
||||
{
|
||||
ccArrayRemoveObjectAtIndex(arr, index, bReleaseObj);
|
||||
|
@ -249,7 +249,7 @@ void ccArrayRemoveObject(ccArray *arr, Object* object, bool bReleaseObj/* = true
|
|||
first matching instance in arr will be removed. */
|
||||
void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr)
|
||||
{
|
||||
for(long i = 0; i < minusArr->num; i++)
|
||||
for (int i = 0; i < minusArr->num; i++)
|
||||
{
|
||||
ccArrayRemoveObject(arr, minusArr->arr[i]);
|
||||
}
|
||||
|
@ -259,12 +259,11 @@ void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr)
|
|||
matching instances in arr will be removed. */
|
||||
void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr)
|
||||
{
|
||||
long back = 0;
|
||||
long i = 0;
|
||||
int back = 0;
|
||||
|
||||
for( i = 0; i < arr->num; i++)
|
||||
for (int i = 0; i < arr->num; i++)
|
||||
{
|
||||
if( ccArrayContainsObject(minusArr, arr->arr[i]) )
|
||||
if (ccArrayContainsObject(minusArr, arr->arr[i]))
|
||||
{
|
||||
CC_SAFE_RELEASE(arr->arr[i]);
|
||||
back++;
|
||||
|
@ -282,16 +281,16 @@ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr)
|
|||
// #pragma mark ccCArray for Values (c structures)
|
||||
|
||||
/** Allocates and initializes a new C array with specified capacity */
|
||||
ccCArray* ccCArrayNew(long capacity)
|
||||
ccCArray* ccCArrayNew(int capacity)
|
||||
{
|
||||
if (capacity == 0)
|
||||
{
|
||||
capacity = 7;
|
||||
}
|
||||
|
||||
ccCArray *arr = (ccCArray*)malloc( sizeof(ccCArray) );
|
||||
ccCArray *arr = (ccCArray*)malloc(sizeof(ccCArray));
|
||||
arr->num = 0;
|
||||
arr->arr = (void**)malloc( capacity * sizeof(void*) );
|
||||
arr->arr = (void**)malloc(capacity * sizeof(void*));
|
||||
arr->max = capacity;
|
||||
|
||||
return arr;
|
||||
|
@ -300,7 +299,7 @@ ccCArray* ccCArrayNew(long capacity)
|
|||
/** Frees C array after removing all remaining values. Silently ignores NULL arr. */
|
||||
void ccCArrayFree(ccCArray *arr)
|
||||
{
|
||||
if( arr == NULL )
|
||||
if (arr == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -317,15 +316,15 @@ void ccCArrayDoubleCapacity(ccCArray *arr)
|
|||
}
|
||||
|
||||
/** Increases array capacity such that max >= num + extra. */
|
||||
void ccCArrayEnsureExtraCapacity(ccCArray *arr, long extra)
|
||||
void ccCArrayEnsureExtraCapacity(ccCArray *arr, int extra)
|
||||
{
|
||||
ccArrayEnsureExtraCapacity((ccArray*)arr,extra);
|
||||
}
|
||||
|
||||
/** Returns index of first occurrence of value, CC_INVALID_INDEX if value not found. */
|
||||
long ccCArrayGetIndexOfValue(ccCArray *arr, void* value)
|
||||
int ccCArrayGetIndexOfValue(ccCArray *arr, void* value)
|
||||
{
|
||||
for(long i = 0; i < arr->num; i++)
|
||||
for(int i = 0; i < arr->num; i++)
|
||||
{
|
||||
if( arr->arr[i] == value )
|
||||
return i;
|
||||
|
@ -340,11 +339,11 @@ bool ccCArrayContainsValue(ccCArray *arr, void* value)
|
|||
}
|
||||
|
||||
/** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */
|
||||
void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, long index)
|
||||
void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, int index)
|
||||
{
|
||||
CCASSERT( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index");
|
||||
|
||||
long remaining = arr->num - index;
|
||||
auto remaining = arr->num - index;
|
||||
// make sure it has enough capacity
|
||||
if (arr->num + 1 == arr->max)
|
||||
{
|
||||
|
@ -385,7 +384,7 @@ void ccCArrayAppendValueWithResize(ccCArray *arr, void* value)
|
|||
enough capacity. */
|
||||
void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr)
|
||||
{
|
||||
for( long i = 0; i < plusArr->num; i++)
|
||||
for( int i = 0; i < plusArr->num; i++)
|
||||
{
|
||||
ccCArrayAppendValue(arr, plusArr->arr[i]);
|
||||
}
|
||||
|
@ -408,9 +407,9 @@ void ccCArrayRemoveAllValues(ccCArray *arr)
|
|||
Behavior undefined if index outside [0, num-1].
|
||||
@since v0.99.4
|
||||
*/
|
||||
void ccCArrayRemoveValueAtIndex(ccCArray *arr, long index)
|
||||
void ccCArrayRemoveValueAtIndex(ccCArray *arr, int index)
|
||||
{
|
||||
for( long last = --arr->num; index < last; index++)
|
||||
for( int last = --arr->num; index < last; index++)
|
||||
{
|
||||
arr->arr[index] = arr->arr[index + 1];
|
||||
}
|
||||
|
@ -421,9 +420,9 @@ void ccCArrayRemoveValueAtIndex(ccCArray *arr, long index)
|
|||
Behavior undefined if index outside [0, num-1].
|
||||
@since v0.99.4
|
||||
*/
|
||||
void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, long index)
|
||||
void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, int index)
|
||||
{
|
||||
long last = --arr->num;
|
||||
auto last = --arr->num;
|
||||
arr->arr[index] = arr->arr[last];
|
||||
}
|
||||
|
||||
|
@ -432,7 +431,7 @@ void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, long index)
|
|||
*/
|
||||
void ccCArrayRemoveValue(ccCArray *arr, void* value)
|
||||
{
|
||||
long index = ccCArrayGetIndexOfValue(arr, value);
|
||||
auto index = ccCArrayGetIndexOfValue(arr, value);
|
||||
if (index != CC_INVALID_INDEX)
|
||||
{
|
||||
ccCArrayRemoveValueAtIndex(arr, index);
|
||||
|
@ -444,7 +443,7 @@ void ccCArrayRemoveValue(ccCArray *arr, void* value)
|
|||
*/
|
||||
void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr)
|
||||
{
|
||||
for(long i = 0; i < minusArr->num; i++)
|
||||
for(int i = 0; i < minusArr->num; i++)
|
||||
{
|
||||
ccCArrayRemoveValue(arr, minusArr->arr[i]);
|
||||
}
|
||||
|
@ -455,9 +454,9 @@ void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr)
|
|||
*/
|
||||
void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr)
|
||||
{
|
||||
long back = 0;
|
||||
int back = 0;
|
||||
|
||||
for(long i = 0; i < arr->num; i++)
|
||||
for(int i = 0; i < arr->num; i++)
|
||||
{
|
||||
if( ccCArrayContainsValue(minusArr, arr->arr[i]) )
|
||||
{
|
||||
|
|
|
@ -51,20 +51,20 @@ THE SOFTWARE.
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
extern const long CC_INVALID_INDEX;
|
||||
extern const int CC_INVALID_INDEX;
|
||||
|
||||
// Easy integration
|
||||
#define CCARRAYDATA_FOREACH(__array__, __object__) \
|
||||
__object__=__array__->arr[0]; for(long i=0, num=__array__->num; i<num; i++, __object__=__array__->arr[i]) \
|
||||
__object__=__array__->arr[0]; for(int i=0, num=__array__->num; i<num; i++, __object__=__array__->arr[i]) \
|
||||
|
||||
|
||||
typedef struct _ccArray {
|
||||
long num, max;
|
||||
int num, max;
|
||||
Object** arr;
|
||||
} ccArray;
|
||||
|
||||
/** Allocates and initializes a new array with specified capacity */
|
||||
ccArray* ccArrayNew(long capacity);
|
||||
ccArray* ccArrayNew(int capacity);
|
||||
|
||||
/** Frees array after removing all remaining objects. Silently ignores nil arr. */
|
||||
void ccArrayFree(ccArray*& arr);
|
||||
|
@ -73,13 +73,13 @@ void ccArrayFree(ccArray*& arr);
|
|||
void ccArrayDoubleCapacity(ccArray *arr);
|
||||
|
||||
/** Increases array capacity such that max >= num + extra. */
|
||||
void ccArrayEnsureExtraCapacity(ccArray *arr, long extra);
|
||||
void ccArrayEnsureExtraCapacity(ccArray *arr, int extra);
|
||||
|
||||
/** shrinks the array so the memory footprint corresponds with the number of items */
|
||||
void ccArrayShrink(ccArray *arr);
|
||||
|
||||
/** Returns index of first occurrence of object, NSNotFound if object not found. */
|
||||
long ccArrayGetIndexOfObject(ccArray *arr, Object* object);
|
||||
int ccArrayGetIndexOfObject(ccArray *arr, Object* object);
|
||||
|
||||
/** Returns a Boolean value that indicates whether object is present in array. */
|
||||
bool ccArrayContainsObject(ccArray *arr, Object* object);
|
||||
|
@ -98,22 +98,22 @@ void ccArrayAppendArray(ccArray *arr, ccArray *plusArr);
|
|||
void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr);
|
||||
|
||||
/** Inserts an object at index */
|
||||
void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, long index);
|
||||
void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, int index);
|
||||
|
||||
/** Swaps two objects */
|
||||
void ccArraySwapObjectsAtIndexes(ccArray *arr, long index1, long index2);
|
||||
void ccArraySwapObjectsAtIndexes(ccArray *arr, int index1, int index2);
|
||||
|
||||
/** Removes all objects from arr */
|
||||
void ccArrayRemoveAllObjects(ccArray *arr);
|
||||
|
||||
/** Removes object at specified index and pushes back all subsequent objects.
|
||||
Behavior undefined if index outside [0, num-1]. */
|
||||
void ccArrayRemoveObjectAtIndex(ccArray *arr, long index, bool bReleaseObj = true);
|
||||
void ccArrayRemoveObjectAtIndex(ccArray *arr, int index, bool bReleaseObj = true);
|
||||
|
||||
/** Removes object at specified index and fills the gap with the last object,
|
||||
thereby avoiding the need to push back subsequent objects.
|
||||
Behavior undefined if index outside [0, num-1]. */
|
||||
void ccArrayFastRemoveObjectAtIndex(ccArray *arr, long index);
|
||||
void ccArrayFastRemoveObjectAtIndex(ccArray *arr, int index);
|
||||
|
||||
void ccArrayFastRemoveObject(ccArray *arr, Object* object);
|
||||
|
||||
|
@ -133,12 +133,12 @@ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr);
|
|||
// #pragma mark ccCArray for Values (c structures)
|
||||
|
||||
typedef struct _ccCArray {
|
||||
long num, max;
|
||||
int num, max;
|
||||
void** arr;
|
||||
} ccCArray;
|
||||
|
||||
/** Allocates and initializes a new C array with specified capacity */
|
||||
ccCArray* ccCArrayNew(long capacity);
|
||||
ccCArray* ccCArrayNew(int capacity);
|
||||
|
||||
/** Frees C array after removing all remaining values. Silently ignores nil arr. */
|
||||
void ccCArrayFree(ccCArray *arr);
|
||||
|
@ -147,16 +147,16 @@ void ccCArrayFree(ccCArray *arr);
|
|||
void ccCArrayDoubleCapacity(ccCArray *arr);
|
||||
|
||||
/** Increases array capacity such that max >= num + extra. */
|
||||
void ccCArrayEnsureExtraCapacity(ccCArray *arr, long extra);
|
||||
void ccCArrayEnsureExtraCapacity(ccCArray *arr, int extra);
|
||||
|
||||
/** Returns index of first occurrence of value, NSNotFound if value not found. */
|
||||
long ccCArrayGetIndexOfValue(ccCArray *arr, void* value);
|
||||
int ccCArrayGetIndexOfValue(ccCArray *arr, void* value);
|
||||
|
||||
/** Returns a Boolean value that indicates whether value is present in the C array. */
|
||||
bool ccCArrayContainsValue(ccCArray *arr, void* value);
|
||||
|
||||
/** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */
|
||||
void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, long index);
|
||||
void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, int index);
|
||||
|
||||
/** Appends an value. Behavior undefined if array doesn't have enough capacity. */
|
||||
void ccCArrayAppendValue(ccCArray *arr, void* value);
|
||||
|
@ -178,14 +178,14 @@ void ccCArrayRemoveAllValues(ccCArray *arr);
|
|||
Behavior undefined if index outside [0, num-1].
|
||||
@since v0.99.4
|
||||
*/
|
||||
void ccCArrayRemoveValueAtIndex(ccCArray *arr, long index);
|
||||
void ccCArrayRemoveValueAtIndex(ccCArray *arr, int index);
|
||||
|
||||
/** Removes value at specified index and fills the gap with the last value,
|
||||
thereby avoiding the need to push back subsequent values.
|
||||
Behavior undefined if index outside [0, num-1].
|
||||
@since v0.99.4
|
||||
*/
|
||||
void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, long index);
|
||||
void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, int index);
|
||||
|
||||
/** Searches for the first occurrence of value and removes it. If value is not found the function has no effect.
|
||||
@since v0.99.4
|
||||
|
|
|
@ -25,7 +25,7 @@ THE SOFTWARE.
|
|||
|
||||
namespace cocos2d {
|
||||
|
||||
unsigned long ccNextPOT(unsigned long x)
|
||||
int ccNextPOT(int x)
|
||||
{
|
||||
x = x - 1;
|
||||
x = x | (x >> 1);
|
||||
|
|
|
@ -43,7 +43,7 @@ Examples:
|
|||
@since v0.99.5
|
||||
*/
|
||||
|
||||
unsigned long ccNextPOT( unsigned long value );
|
||||
int ccNextPOT(int value);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace {
|
|||
static Touch* g_touches[EventTouch::MAX_TOUCHES] = { NULL };
|
||||
static unsigned int g_indexBitsUsed = 0;
|
||||
// System touch pointer ID (It may not be ascending order number) <-> Ascending order number from 0
|
||||
static std::map<long, int> g_touchIdReorderMap;
|
||||
static std::map<int, int> g_touchIdReorderMap;
|
||||
|
||||
static int getUnUsedIndex()
|
||||
{
|
||||
|
@ -198,9 +198,9 @@ const std::string& EGLViewProtocol::getViewName() const
|
|||
return _viewName;
|
||||
}
|
||||
|
||||
void EGLViewProtocol::handleTouchesBegin(int num, long ids[], float xs[], float ys[])
|
||||
void EGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[])
|
||||
{
|
||||
long id = 0;
|
||||
int id = 0;
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
int nUnusedIndex = 0;
|
||||
|
@ -248,9 +248,9 @@ void EGLViewProtocol::handleTouchesBegin(int num, long ids[], float xs[], float
|
|||
dispatcher->dispatchEvent(&touchEvent);
|
||||
}
|
||||
|
||||
void EGLViewProtocol::handleTouchesMove(int num, long ids[], float xs[], float ys[])
|
||||
void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys[])
|
||||
{
|
||||
long id = 0;
|
||||
int id = 0;
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
EventTouch touchEvent;
|
||||
|
@ -296,9 +296,9 @@ void EGLViewProtocol::handleTouchesMove(int num, long ids[], float xs[], float y
|
|||
dispatcher->dispatchEvent(&touchEvent);
|
||||
}
|
||||
|
||||
void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, long ids[], float xs[], float ys[])
|
||||
void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[])
|
||||
{
|
||||
long id = 0;
|
||||
int id = 0;
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
EventTouch touchEvent;
|
||||
|
@ -356,12 +356,12 @@ void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode
|
|||
}
|
||||
}
|
||||
|
||||
void EGLViewProtocol::handleTouchesEnd(int num, long ids[], float xs[], float ys[])
|
||||
void EGLViewProtocol::handleTouchesEnd(int num, int ids[], float xs[], float ys[])
|
||||
{
|
||||
handleTouchesOfEndOrCancel(EventTouch::EventCode::ENDED, num, ids, xs, ys);
|
||||
}
|
||||
|
||||
void EGLViewProtocol::handleTouchesCancel(int num, long ids[], float xs[], float ys[])
|
||||
void EGLViewProtocol::handleTouchesCancel(int num, int ids[], float xs[], float ys[])
|
||||
{
|
||||
handleTouchesOfEndOrCancel(EventTouch::EventCode::CANCELLED, num, ids, xs, ys);
|
||||
}
|
||||
|
|
|
@ -135,10 +135,10 @@ public:
|
|||
const std::string& getViewName() const;
|
||||
|
||||
/** Touch events are handled by default; if you want to customize your handlers, please override these functions: */
|
||||
virtual void handleTouchesBegin(int num, long ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesMove(int num, long ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesEnd(int num, long ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesCancel(int num, long ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesBegin(int num, int ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesMove(int num, int ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesEnd(int num, int ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesCancel(int num, int ids[], float xs[], float ys[]);
|
||||
|
||||
/**
|
||||
* Get the opengl view port rectangle.
|
||||
|
@ -157,7 +157,7 @@ public:
|
|||
|
||||
|
||||
protected:
|
||||
void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, long ids[], float xs[], float ys[]);
|
||||
void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]);
|
||||
|
||||
EGLTouchDelegate* _delegate;
|
||||
|
||||
|
|
|
@ -492,7 +492,7 @@ void FileUtils::purgeCachedEntries()
|
|||
_fullPathCache.clear();
|
||||
}
|
||||
|
||||
unsigned char* FileUtils::getFileData(const char* filename, const char* mode, long *size)
|
||||
unsigned char* FileUtils::getFileData(const char* filename, const char* mode, ssize_t *size)
|
||||
{
|
||||
unsigned char * buffer = nullptr;
|
||||
CCASSERT(filename != nullptr && size != nullptr && mode != nullptr, "Invalid parameters.");
|
||||
|
@ -522,7 +522,7 @@ unsigned char* FileUtils::getFileData(const char* filename, const char* mode, lo
|
|||
return buffer;
|
||||
}
|
||||
|
||||
unsigned char* FileUtils::getFileDataFromZip(const char* zipFilePath, const char* filename, long *size)
|
||||
unsigned char* FileUtils::getFileDataFromZip(const char* zipFilePath, const char* filename, ssize_t *size)
|
||||
{
|
||||
unsigned char * buffer = nullptr;
|
||||
unzFile pFile = nullptr;
|
||||
|
@ -548,7 +548,7 @@ unsigned char* FileUtils::getFileDataFromZip(const char* zipFilePath, const char
|
|||
CC_BREAK_IF(UNZ_OK != nRet);
|
||||
|
||||
buffer = (unsigned char*)malloc(FileInfo.uncompressed_size);
|
||||
int CC_UNUSED nSize = unzReadCurrentFile(pFile, buffer, FileInfo.uncompressed_size);
|
||||
int CC_UNUSED nSize = unzReadCurrentFile(pFile, buffer, static_cast<unsigned>(FileInfo.uncompressed_size));
|
||||
CCASSERT(nSize == 0 || nSize == (int)FileInfo.uncompressed_size, "the file size is wrong");
|
||||
|
||||
*size = FileInfo.uncompressed_size;
|
||||
|
@ -756,7 +756,7 @@ void FileUtils::loadFilenameLookupDictionaryFromFile(const std::string &filename
|
|||
int version = metadata["version"].asInt();
|
||||
if (version != 1)
|
||||
{
|
||||
CCLOG("cocos2d: ERROR: Invalid filenameLookup dictionary version: %ld. Filename: %s", (long)version, filename.c_str());
|
||||
CCLOG("cocos2d: ERROR: Invalid filenameLookup dictionary version: %d. Filename: %s", version, filename.c_str());
|
||||
return;
|
||||
}
|
||||
setFilenameLookupDictionary( dict["filenames"].asValueMap());
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
* @return Upon success, a pointer to the data is returned, otherwise NULL.
|
||||
* @warning Recall: you are responsible for calling free() on any Non-NULL pointer returned.
|
||||
*/
|
||||
virtual unsigned char* getFileData(const char* filename, const char* mode, long *size);
|
||||
virtual unsigned char* getFileData(const char* filename, const char* mode, ssize_t *size);
|
||||
|
||||
/**
|
||||
* Gets resource file data from a zip file.
|
||||
|
@ -94,7 +94,7 @@ public:
|
|||
* @return Upon success, a pointer to the data is returned, otherwise NULL.
|
||||
* @warning Recall: you are responsible for calling free() on any Non-NULL pointer returned.
|
||||
*/
|
||||
virtual unsigned char* getFileDataFromZip(const char* zipFilePath, const char* filename, long *size);
|
||||
virtual unsigned char* getFileDataFromZip(const char* zipFilePath, const char* filename, ssize_t *size);
|
||||
|
||||
|
||||
/** Returns the fullpath for a given filename.
|
||||
|
|
|
@ -121,10 +121,10 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool initWithImageData(const unsigned char * data, long dataLen);
|
||||
bool initWithImageData(const unsigned char * data, ssize_t dataLen);
|
||||
|
||||
// @warning kFmtRawData only support RGBA8888
|
||||
bool initWithRawData(const unsigned char * data, long dataLen, long width, long height, long bitsPerComponent, bool preMulti = false);
|
||||
bool initWithRawData(const unsigned char * data, ssize_t dataLen, int width, int height, int bitsPerComponent, bool preMulti = false);
|
||||
|
||||
/**
|
||||
@brief Create image with specified string.
|
||||
|
@ -175,9 +175,9 @@ public:
|
|||
|
||||
// Getters
|
||||
inline unsigned char * getData() { return _data; }
|
||||
inline int getDataLen() { return _dataLen; }
|
||||
inline ssize_t getDataLen() { return _dataLen; }
|
||||
inline Format getFileType() {return _fileType; }
|
||||
inline Texture2D::PixelFormat getRenderFormat() { return _renderFormat; }
|
||||
inline Texture2D::PixelFormat getRenderFormat() { return _renderFormat; }
|
||||
inline int getWidth() { return _width; }
|
||||
inline int getHeight() { return _height; }
|
||||
inline bool isPremultipliedAlpha() { return _preMulti; }
|
||||
|
@ -198,16 +198,16 @@ public:
|
|||
bool saveToFile(const std::string &filename, bool isToRGB = true);
|
||||
|
||||
protected:
|
||||
bool initWithJpgData(const unsigned char * data, int dataLen);
|
||||
bool initWithPngData(const unsigned char * data, int dataLen);
|
||||
bool initWithTiffData(const unsigned char * data, int dataLen);
|
||||
bool initWithWebpData(const unsigned char * data, int dataLen);
|
||||
bool initWithPVRData(const unsigned char * data, int dataLen);
|
||||
bool initWithPVRv2Data(const unsigned char * data, int dataLen);
|
||||
bool initWithPVRv3Data(const unsigned char * data, int dataLen);
|
||||
bool initWithETCData(const unsigned char * data, int dataLen);
|
||||
bool initWithS3TCData(const unsigned char * data, int dataLen);
|
||||
bool initWithATITCData(const unsigned char *data, int dataLen);
|
||||
bool initWithJpgData(const unsigned char * data, ssize_t dataLen);
|
||||
bool initWithPngData(const unsigned char * data, ssize_t dataLen);
|
||||
bool initWithTiffData(const unsigned char * data, ssize_t dataLen);
|
||||
bool initWithWebpData(const unsigned char * data, ssize_t dataLen);
|
||||
bool initWithPVRData(const unsigned char * data, ssize_t dataLen);
|
||||
bool initWithPVRv2Data(const unsigned char * data, ssize_t dataLen);
|
||||
bool initWithPVRv3Data(const unsigned char * data, ssize_t dataLen);
|
||||
bool initWithETCData(const unsigned char * data, ssize_t dataLen);
|
||||
bool initWithS3TCData(const unsigned char * data, ssize_t dataLen);
|
||||
bool initWithATITCData(const unsigned char *data, ssize_t dataLen);
|
||||
typedef struct sImageTGA tImageTGA;
|
||||
bool initWithTGAData(tImageTGA* tgaData);
|
||||
|
||||
|
@ -221,7 +221,7 @@ private:
|
|||
*/
|
||||
static const int MIPMAP_MAX = 16;
|
||||
unsigned char *_data;
|
||||
int _dataLen;
|
||||
ssize_t _dataLen;
|
||||
int _width;
|
||||
int _height;
|
||||
Format _fileType;
|
||||
|
@ -248,15 +248,15 @@ private:
|
|||
*/
|
||||
bool initWithImageFileThreadSafe(const char *fullpath);
|
||||
|
||||
Format detectFormat(const unsigned char * data, int dataLen);
|
||||
bool isPng(const unsigned char * data, int dataLen);
|
||||
bool isJpg(const unsigned char * data, int dataLen);
|
||||
bool isTiff(const unsigned char * data, int dataLen);
|
||||
bool isWebp(const unsigned char * data, int dataLen);
|
||||
bool isPvr(const unsigned char * data, int dataLen);
|
||||
bool isEtc(const unsigned char * data, int dataLen);
|
||||
bool isS3TC(const unsigned char * data,int dataLen);
|
||||
bool isATITC(const unsigned char *data, int dataLen);
|
||||
Format detectFormat(const unsigned char * data, ssize_t dataLen);
|
||||
bool isPng(const unsigned char * data, ssize_t dataLen);
|
||||
bool isJpg(const unsigned char * data, ssize_t dataLen);
|
||||
bool isTiff(const unsigned char * data, ssize_t dataLen);
|
||||
bool isWebp(const unsigned char * data, ssize_t dataLen);
|
||||
bool isPvr(const unsigned char * data, ssize_t dataLen);
|
||||
bool isEtc(const unsigned char * data, ssize_t dataLen);
|
||||
bool isS3TC(const unsigned char * data,ssize_t dataLen);
|
||||
bool isATITC(const unsigned char *data, ssize_t dataLen);
|
||||
};
|
||||
|
||||
// end of platform group
|
||||
|
|
|
@ -420,7 +420,7 @@ bool Image::initWithImageFile(const char * strPath)
|
|||
|
||||
SDL_FreeSurface(iSurf);
|
||||
#else
|
||||
long bufferLen = 0;
|
||||
ssize_t bufferLen = 0;
|
||||
unsigned char* buffer = FileUtils::getInstance()->getFileData(_filePath.c_str(), "rb", &bufferLen);
|
||||
|
||||
if (buffer != nullptr && bufferLen > 0)
|
||||
|
@ -437,7 +437,7 @@ bool Image::initWithImageFile(const char * strPath)
|
|||
bool Image::initWithImageFileThreadSafe(const char *fullpath)
|
||||
{
|
||||
bool ret = false;
|
||||
long dataLen = 0;
|
||||
ssize_t dataLen = 0;
|
||||
_filePath = fullpath;
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
FileUtilsAndroid *fileUitls = (FileUtilsAndroid*)FileUtils::getInstance();
|
||||
|
@ -453,7 +453,7 @@ bool Image::initWithImageFileThreadSafe(const char *fullpath)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Image::initWithImageData(const unsigned char * data, long dataLen)
|
||||
bool Image::initWithImageData(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
|
@ -462,7 +462,7 @@ bool Image::initWithImageData(const unsigned char * data, long dataLen)
|
|||
CC_BREAK_IF(! data || dataLen <= 0);
|
||||
|
||||
unsigned char* unpackedData = nullptr;
|
||||
int unpackedLen = 0;
|
||||
ssize_t unpackedLen = 0;
|
||||
|
||||
//detecgt and unzip the compress file
|
||||
if (ZipUtils::isCCZBuffer(data, dataLen))
|
||||
|
@ -535,7 +535,7 @@ bool Image::initWithImageData(const unsigned char * data, long dataLen)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Image::isPng(const unsigned char * data, int dataLen)
|
||||
bool Image::isPng(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
if (dataLen <= 8)
|
||||
{
|
||||
|
@ -548,13 +548,13 @@ bool Image::isPng(const unsigned char * data, int dataLen)
|
|||
}
|
||||
|
||||
|
||||
bool Image::isEtc(const unsigned char * data, int dataLen)
|
||||
bool Image::isEtc(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
return etc1_pkm_is_valid((etc1_byte*)data) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
bool Image::isS3TC(const unsigned char * data, int dataLen)
|
||||
bool Image::isS3TC(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
|
||||
S3TCTexHeader *header = (S3TCTexHeader *)data;
|
||||
|
@ -567,7 +567,7 @@ bool Image::isS3TC(const unsigned char * data, int dataLen)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Image::isATITC(const unsigned char *data, int dataLen)
|
||||
bool Image::isATITC(const unsigned char *data, ssize_t dataLen)
|
||||
{
|
||||
ATITCTexHeader *header = (ATITCTexHeader *)data;
|
||||
|
||||
|
@ -579,7 +579,7 @@ bool Image::isATITC(const unsigned char *data, int dataLen)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Image::isJpg(const unsigned char * data, int dataLen)
|
||||
bool Image::isJpg(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
if (dataLen <= 4)
|
||||
{
|
||||
|
@ -591,7 +591,7 @@ bool Image::isJpg(const unsigned char * data, int dataLen)
|
|||
return memcmp(data, JPG_SOI, 2) == 0;
|
||||
}
|
||||
|
||||
bool Image::isTiff(const unsigned char * data, int dataLen)
|
||||
bool Image::isTiff(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
if (dataLen <= 4)
|
||||
{
|
||||
|
@ -605,7 +605,7 @@ bool Image::isTiff(const unsigned char * data, int dataLen)
|
|||
(memcmp(data, TIFF_MM, 2) == 0 && *(static_cast<const unsigned char*>(data) + 2) == 0 && *(static_cast<const unsigned char*>(data) + 3) == 42);
|
||||
}
|
||||
|
||||
bool Image::isWebp(const unsigned char * data, int dataLen)
|
||||
bool Image::isWebp(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
if (dataLen <= 12)
|
||||
{
|
||||
|
@ -619,7 +619,7 @@ bool Image::isWebp(const unsigned char * data, int dataLen)
|
|||
&& memcmp(static_cast<const unsigned char*>(data) + 8, WEBP_WEBP, 4) == 0;
|
||||
}
|
||||
|
||||
bool Image::isPvr(const unsigned char * data, int dataLen)
|
||||
bool Image::isPvr(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
if (static_cast<size_t>(dataLen) < sizeof(PVRv2TexHeader) || static_cast<size_t>(dataLen) < sizeof(PVRv3TexHeader))
|
||||
{
|
||||
|
@ -632,7 +632,7 @@ bool Image::isPvr(const unsigned char * data, int dataLen)
|
|||
return memcmp(&headerv2->pvrTag, gPVRTexIdentifier, strlen(gPVRTexIdentifier)) == 0 || CC_SWAP_INT32_BIG_TO_HOST(headerv3->version) == 0x50565203;
|
||||
}
|
||||
|
||||
Image::Format Image::detectFormat(const unsigned char * data, int dataLen)
|
||||
Image::Format Image::detectFormat(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
if (isPng(data, dataLen))
|
||||
{
|
||||
|
@ -744,7 +744,7 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
bool Image::initWithJpgData(const unsigned char * data, int dataLen)
|
||||
bool Image::initWithJpgData(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
/* these are standard libjpeg structures for reading(decompression) */
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
|
@ -841,7 +841,7 @@ bool Image::initWithJpgData(const unsigned char * data, int dataLen)
|
|||
return bRet;
|
||||
}
|
||||
|
||||
bool Image::initWithPngData(const unsigned char * data, int dataLen)
|
||||
bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
// length of bytes to check if it is a valid png file
|
||||
#define PNGSIGSIZE 8
|
||||
|
@ -1085,7 +1085,7 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
bool Image::initWithTiffData(const unsigned char * data, int dataLen)
|
||||
bool Image::initWithTiffData(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
|
@ -1179,7 +1179,7 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
bool Image::initWithPVRv2Data(const unsigned char * data, int dataLen)
|
||||
bool Image::initWithPVRv2Data(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
int dataLength = 0, dataOffset = 0, dataSize = 0;
|
||||
int blockSize = 0, widthBlocks = 0, heightBlocks = 0;
|
||||
|
@ -1305,7 +1305,7 @@ bool Image::initWithPVRv2Data(const unsigned char * data, int dataLen)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Image::initWithPVRv3Data(const unsigned char * data, int dataLen)
|
||||
bool Image::initWithPVRv3Data(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
if (static_cast<size_t>(dataLen) < sizeof(PVRv3TexHeader))
|
||||
{
|
||||
|
@ -1414,7 +1414,7 @@ bool Image::initWithPVRv3Data(const unsigned char * data, int dataLen)
|
|||
}
|
||||
|
||||
dataSize = widthBlocks * heightBlocks * ((blockSize * it->second.bpp) / 8);
|
||||
int packetLength = _dataLen - dataOffset;
|
||||
auto packetLength = _dataLen - dataOffset;
|
||||
packetLength = packetLength > dataSize ? dataSize : packetLength;
|
||||
|
||||
_mipmaps[i].address = _data + dataOffset;
|
||||
|
@ -1431,7 +1431,7 @@ bool Image::initWithPVRv3Data(const unsigned char * data, int dataLen)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Image::initWithETCData(const unsigned char * data, int dataLen)
|
||||
bool Image::initWithETCData(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
const etc1_byte* header = static_cast<const etc1_byte*>(data);
|
||||
|
||||
|
@ -1575,7 +1575,7 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
bool Image::initWithS3TCData(const unsigned char * data, int dataLen)
|
||||
bool Image::initWithS3TCData(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
|
||||
const uint32_t FOURCC_DXT1 = makeFourCC('D', 'X', 'T', '1');
|
||||
|
@ -1697,7 +1697,7 @@ bool Image::initWithS3TCData(const unsigned char * data, int dataLen)
|
|||
}
|
||||
|
||||
|
||||
bool Image::initWithATITCData(const unsigned char *data, int dataLen)
|
||||
bool Image::initWithATITCData(const unsigned char *data, ssize_t dataLen)
|
||||
{
|
||||
/* load the .ktx file */
|
||||
ATITCTexHeader *header = (ATITCTexHeader *)data;
|
||||
|
@ -1826,12 +1826,12 @@ bool Image::initWithATITCData(const unsigned char *data, int dataLen)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Image::initWithPVRData(const unsigned char * data, int dataLen)
|
||||
bool Image::initWithPVRData(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
return initWithPVRv2Data(data, dataLen) || initWithPVRv3Data(data, dataLen);
|
||||
}
|
||||
|
||||
bool Image::initWithWebpData(const unsigned char * data, int dataLen)
|
||||
bool Image::initWithWebpData(const unsigned char * data, ssize_t dataLen)
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
|
@ -1866,7 +1866,7 @@ bool Image::initWithWebpData(const unsigned char * data, int dataLen)
|
|||
return bRet;
|
||||
}
|
||||
|
||||
bool Image::initWithRawData(const unsigned char * data, long dataLen, long width, long height, long bitsPerComponent, bool preMulti)
|
||||
bool Image::initWithRawData(const unsigned char * data, ssize_t dataLen, int width, int height, int bitsPerComponent, bool preMulti)
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
|
|
|
@ -114,7 +114,7 @@ bool SAXParser::parse(const char* pXMLData, size_t uDataLength)
|
|||
bool SAXParser::parse(const char *pszFile)
|
||||
{
|
||||
bool ret = false;
|
||||
long size = 0;
|
||||
ssize_t size = 0;
|
||||
char* pBuffer = (char*)FileUtils::getInstance()->getFileData(pszFile, "rt", &size);
|
||||
if (pBuffer != NULL && size > 0)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ NS_CC_BEGIN
|
|||
|
||||
std::list<std::function<void(void)>>* ThreadHelper::_callbackList = new std::list<std::function<void(void)>>();
|
||||
std::mutex* ThreadHelper::_mutex = new std::mutex;
|
||||
long ThreadHelper::_callbackNumberPerFrame = 5;
|
||||
int ThreadHelper::_callbackNumberPerFrame = 5;
|
||||
|
||||
|
||||
void* ThreadHelper::createAutoreleasePool()
|
||||
|
@ -56,7 +56,7 @@ void ThreadHelper::doCallback()
|
|||
{
|
||||
_mutex->lock();
|
||||
auto iter = _callbackList->begin();
|
||||
long i = 0;
|
||||
int i = 0;
|
||||
while (iter != _callbackList->end())
|
||||
{
|
||||
auto f = *iter;
|
||||
|
@ -75,7 +75,7 @@ void ThreadHelper::doCallback()
|
|||
_mutex->unlock();
|
||||
}
|
||||
|
||||
void ThreadHelper::setCallbackNumberPerFrame(long callbackNumberPerFrame)
|
||||
void ThreadHelper::setCallbackNumberPerFrame(int callbackNumberPerFrame)
|
||||
{
|
||||
_callbackNumberPerFrame = callbackNumberPerFrame;
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
* @lua NA
|
||||
@since v3.0
|
||||
*/
|
||||
static void setCallbackNumberPerFrame(long callbackNumberPerFrame);
|
||||
static void setCallbackNumberPerFrame(int callbackNumberPerFrame);
|
||||
|
||||
private:
|
||||
// This function will be call by Director to call some call back function on gl thread
|
||||
|
@ -81,7 +81,7 @@ private:
|
|||
static std::list<std::function<void(void)>> *_callbackList;
|
||||
static std::mutex *_mutex;
|
||||
// How many callback functions invoked per frame
|
||||
static long _callbackNumberPerFrame;
|
||||
static int _callbackNumberPerFrame;
|
||||
};
|
||||
|
||||
// end of platform group
|
||||
|
|
|
@ -130,17 +130,17 @@ bool FileUtilsAndroid::isAbsolutePath(const std::string& strPath) const
|
|||
}
|
||||
|
||||
|
||||
unsigned char* FileUtilsAndroid::getFileData(const char* filename, const char* mode, long * size)
|
||||
unsigned char* FileUtilsAndroid::getFileData(const char* filename, const char* mode, ssize_t * size)
|
||||
{
|
||||
return doGetFileData(filename, mode, size, false);
|
||||
}
|
||||
|
||||
unsigned char* FileUtilsAndroid::getFileDataForAsync(const char* filename, const char* pszMode, long * pSize)
|
||||
unsigned char* FileUtilsAndroid::getFileDataForAsync(const char* filename, const char* pszMode, ssize_t * pSize)
|
||||
{
|
||||
return doGetFileData(filename, pszMode, pSize, true);
|
||||
}
|
||||
|
||||
unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* mode, long * size, bool forAsync)
|
||||
unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* mode, ssize_t * size, bool forAsync)
|
||||
{
|
||||
unsigned char * data = 0;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
/* override funtions */
|
||||
bool init();
|
||||
virtual unsigned char* getFileData(const char* filename, const char* mode, long * size);
|
||||
virtual unsigned char* getFileData(const char* filename, const char* mode, ssize_t * size);
|
||||
|
||||
virtual std::string getWritablePath() const;
|
||||
virtual bool isFileExist(const std::string& strFilePath) const;
|
||||
|
@ -64,10 +64,10 @@ public:
|
|||
/** This function is android specific. It is used for TextureCache::addImageAsync().
|
||||
Don't use it in your codes.
|
||||
*/
|
||||
unsigned char* getFileDataForAsync(const char* filename, const char* mode, long * size);
|
||||
unsigned char* getFileDataForAsync(const char* filename, const char* mode, ssize_t * size);
|
||||
|
||||
private:
|
||||
unsigned char* doGetFileData(const char* filename, const char* mode, long * size, bool forAsync);
|
||||
unsigned char* doGetFileData(const char* filename, const char* mode, ssize_t * size, bool forAsync);
|
||||
static AAssetManager* assetmanager;
|
||||
};
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ static void engine_term_display(struct engine* engine) {
|
|||
/*
|
||||
* Get X, Y positions and ID's for all pointers
|
||||
*/
|
||||
static void getTouchPos(AInputEvent *event, long ids[], float xs[], float ys[]) {
|
||||
static void getTouchPos(AInputEvent *event, int ids[], float xs[], float ys[]) {
|
||||
int pointerCount = AMotionEvent_getPointerCount(event);
|
||||
for(int i = 0; i < pointerCount; ++i) {
|
||||
ids[i] = AMotionEvent_getPointerId(event, i);
|
||||
|
@ -325,11 +325,10 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
|
||||
LOG_EVENTS_DEBUG("Event: Action DOWN x=%f y=%f pointerID=%d\n",
|
||||
xP, yP, pointerId);
|
||||
long pId = pointerId;
|
||||
float x = xP;
|
||||
float y = yP;
|
||||
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, &pId, &x, &y);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, &pointerId, &x, &y);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
@ -344,11 +343,10 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
|
||||
LOG_EVENTS_DEBUG("Event: Action POINTER DOWN x=%f y=%f pointerID=%d\n",
|
||||
xP, yP, pointerId);
|
||||
long pId = pointerId;
|
||||
float x = xP;
|
||||
float y = yP;
|
||||
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, &pId, &x, &y);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, &pointerId, &x, &y);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
@ -357,7 +355,7 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
{
|
||||
LOG_EVENTS_DEBUG("AMOTION_EVENT_ACTION_MOVE");
|
||||
int pointerCount = AMotionEvent_getPointerCount(event);
|
||||
long ids[pointerCount];
|
||||
int ids[pointerCount];
|
||||
float xs[pointerCount], ys[pointerCount];
|
||||
getTouchPos(event, ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(pointerCount, ids, xs, ys);
|
||||
|
@ -373,11 +371,10 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
float yP = AMotionEvent_getY(event,0);
|
||||
LOG_EVENTS_DEBUG("Event: Action UP x=%f y=%f pointerID=%d\n",
|
||||
xP, yP, pointerId);
|
||||
long pId = pointerId;
|
||||
float x = xP;
|
||||
float y = yP;
|
||||
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, &pId, &x, &y);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, &pointerId, &x, &y);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
@ -391,11 +388,10 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
float yP = AMotionEvent_getY(event,pointerIndex);
|
||||
LOG_EVENTS_DEBUG("Event: Action POINTER UP x=%f y=%f pointerID=%d\n",
|
||||
xP, yP, pointerIndex);
|
||||
long pId = pointerId;
|
||||
float x = xP;
|
||||
float y = yP;
|
||||
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, &pId, &x, &y);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, &pointerId, &x, &y);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
@ -404,7 +400,7 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
{
|
||||
LOG_EVENTS_DEBUG("AMOTION_EVENT_ACTION_CANCEL");
|
||||
int pointerCount = AMotionEvent_getPointerCount(event);
|
||||
long ids[pointerCount];
|
||||
int ids[pointerCount];
|
||||
float xs[pointerCount], ys[pointerCount];
|
||||
getTouchPos(event, ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesCancel(pointerCount, ids, xs, ys);
|
||||
|
|
|
@ -28,7 +28,7 @@ NS_CC_BEGIN
|
|||
|
||||
std::list<std::function<void(void)>>* ThreadHelper::_callbackList = new std::list<std::function<void(void)>>();
|
||||
std::mutex* ThreadHelper::_mutex = new std::mutex;
|
||||
long ThreadHelper::_callbackNumberPerFrame = 5;
|
||||
int ThreadHelper::_callbackNumberPerFrame = 5;
|
||||
|
||||
void* ThreadHelper::createAutoreleasePool()
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ void ThreadHelper::doCallback()
|
|||
{
|
||||
_mutex->lock();
|
||||
auto iter = _callbackList->begin();
|
||||
long i = 0;
|
||||
int i = 0;
|
||||
while (iter != _callbackList->end())
|
||||
{
|
||||
auto f = *iter;
|
||||
|
@ -72,7 +72,7 @@ void ThreadHelper::doCallback()
|
|||
_mutex->unlock();
|
||||
}
|
||||
|
||||
void ThreadHelper::setCallbackNumberPerFrame(long callbackNumberPerFrame)
|
||||
void ThreadHelper::setCallbackNumberPerFrame(int callbackNumberPerFrame)
|
||||
{
|
||||
_callbackNumberPerFrame = callbackNumberPerFrame;
|
||||
}
|
||||
|
|
|
@ -413,7 +413,7 @@ static CCEAGLView *__view = 0;
|
|||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
++i;
|
||||
}
|
||||
cocos2d::EGLView::getInstance()->handleTouchesBegin(i, (long*)ids, xs, ys);
|
||||
cocos2d::EGLView::getInstance()->handleTouchesBegin(i, (int*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
|
@ -433,7 +433,7 @@ static CCEAGLView *__view = 0;
|
|||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
++i;
|
||||
}
|
||||
cocos2d::EGLView::getInstance()->handleTouchesMove(i, (long*)ids, xs, ys);
|
||||
cocos2d::EGLView::getInstance()->handleTouchesMove(i, (int*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
|
@ -454,7 +454,7 @@ static CCEAGLView *__view = 0;
|
|||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
++i;
|
||||
}
|
||||
cocos2d::EGLView::getInstance()->handleTouchesEnd(i, (long*)ids, xs, ys);
|
||||
cocos2d::EGLView::getInstance()->handleTouchesEnd(i, (int*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
|
@ -475,7 +475,7 @@ static CCEAGLView *__view = 0;
|
|||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
++i;
|
||||
}
|
||||
cocos2d::EGLView::getInstance()->handleTouchesCancel(i, (long*)ids, xs, ys);
|
||||
cocos2d::EGLView::getInstance()->handleTouchesCancel(i, (int*)ids, xs, ys);
|
||||
}
|
||||
|
||||
#pragma mark - UIView - Responder
|
||||
|
|
|
@ -186,7 +186,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
|
|||
s_captured = true;
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
|
||||
{
|
||||
long id = 0;
|
||||
int id = 0;
|
||||
eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
|
|||
s_captured = false;
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
|
||||
{
|
||||
long id = 0;
|
||||
int id = 0;
|
||||
eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
|
|||
{
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY)))
|
||||
{
|
||||
long id = 0;
|
||||
int id = 0;
|
||||
eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
|
|||
s_captured = true;
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
|
||||
{
|
||||
long id = 0;
|
||||
int id = 0;
|
||||
eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
|
|||
s_captured = false;
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
|
||||
{
|
||||
long id = 0;
|
||||
int id = 0;
|
||||
eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
|
|||
{
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY)))
|
||||
{
|
||||
long id = 0;
|
||||
int id = 0;
|
||||
eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -335,7 +335,7 @@ static CCEAGLView *view;
|
|||
xs[0] = x / frameZoomFactor_;
|
||||
ys[0] = y / frameZoomFactor_;
|
||||
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, (long*)ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, (int*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)mouseMoved:(NSEvent *)theEvent
|
||||
|
@ -359,7 +359,7 @@ static CCEAGLView *view;
|
|||
xs[0] = x / frameZoomFactor_;
|
||||
ys[0] = y / frameZoomFactor_;
|
||||
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(1, (long*)ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(1, (int*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)mouseUp:(NSEvent *)theEvent
|
||||
|
@ -378,7 +378,7 @@ static CCEAGLView *view;
|
|||
xs[0] = x / frameZoomFactor_;
|
||||
ys[0] = y / frameZoomFactor_;
|
||||
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, (long*)ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, (int*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)rightMouseDown:(NSEvent *)theEvent {
|
||||
|
|
|
@ -303,7 +303,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
|
|||
s_captured = true;
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
|
||||
{
|
||||
long id = 0;
|
||||
int id = 0;
|
||||
eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
|
|||
s_captured = false;
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
|
||||
{
|
||||
long id = 0;
|
||||
int id = 0;
|
||||
eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
|
|||
{
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY)))
|
||||
{
|
||||
long id = 0;
|
||||
int id = 0;
|
||||
eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
Data::Data(unsigned char *pBytes, const unsigned long nSize)
|
||||
Data::Data(unsigned char *pBytes, ssize_t nSize)
|
||||
{
|
||||
_size = nSize;
|
||||
_bytes = new unsigned char[_size];
|
||||
|
@ -53,7 +53,7 @@ unsigned char* Data::getBytes() const
|
|||
return _bytes;
|
||||
}
|
||||
|
||||
unsigned long Data::getSize() const
|
||||
ssize_t Data::getSize() const
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Data(unsigned char *pBytes, const unsigned long nSize);
|
||||
Data(unsigned char *pBytes, const ssize_t nSize);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static Data* create(unsigned char *pBytes, const unsigned long nSize)
|
||||
static Data* create(unsigned char *pBytes, const ssize_t nSize)
|
||||
{
|
||||
Data* pRet = new Data(pBytes, nSize);
|
||||
if (pRet)
|
||||
|
@ -70,7 +70,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
unsigned long getSize() const;
|
||||
ssize_t getSize() const;
|
||||
|
||||
/** override functions
|
||||
* @js NA
|
||||
|
@ -80,7 +80,7 @@ public:
|
|||
|
||||
private:
|
||||
unsigned char* _bytes;
|
||||
unsigned long _size;
|
||||
ssize_t _size;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
CCLOGINFO("In the default constructor of Map!");
|
||||
}
|
||||
|
||||
explicit Map<K, V>(long capacity)
|
||||
explicit Map<K, V>(int capacity)
|
||||
: _data()
|
||||
{
|
||||
CCLOGINFO("In the constructor with capacity of Map!");
|
||||
|
@ -73,7 +73,7 @@ public:
|
|||
}
|
||||
|
||||
/** Sets capacity of current array */
|
||||
void reserve(long capacity)
|
||||
void reserve(int capacity)
|
||||
{
|
||||
_data.reserve(capacity);
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ String* String::create(const std::string& str)
|
|||
return ret;
|
||||
}
|
||||
|
||||
String* String::createWithData(const unsigned char* data, unsigned long nLen)
|
||||
String* String::createWithData(const unsigned char* data, int nLen)
|
||||
{
|
||||
String* ret = NULL;
|
||||
if (data != NULL)
|
||||
|
@ -255,11 +255,11 @@ String* String::createWithFormat(const char* format, ...)
|
|||
|
||||
String* String::createWithContentsOfFile(const char* filename)
|
||||
{
|
||||
long size = 0;
|
||||
ssize_t size = 0;
|
||||
unsigned char* data = 0;
|
||||
String* ret = NULL;
|
||||
data = FileUtils::getInstance()->getFileData(filename, "rb", &size);
|
||||
ret = String::createWithData(data, size);
|
||||
ret = String::createWithData(data, static_cast<int>(size));
|
||||
free(data);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ public:
|
|||
* it means that you needn't do a release operation unless you retain it.
|
||||
* @js NA
|
||||
*/
|
||||
static String* createWithData(const unsigned char* pData, unsigned long nLen);
|
||||
static String* createWithData(const unsigned char* pData, int nLen);
|
||||
|
||||
/** create a string with a file,
|
||||
* @return A String pointer which is an autorelease object pointer,
|
||||
|
|
|
@ -287,7 +287,7 @@ Spawn * ActionNode::refreshActionProperty()
|
|||
}
|
||||
|
||||
Vector<FiniteTimeAction*> cSequenceArray;
|
||||
long frameCount = cArray->count();
|
||||
auto frameCount = cArray->count();
|
||||
for (int i = 0; i < frameCount; i++)
|
||||
{
|
||||
ActionFrame* frame = (ActionFrame*)(cArray->getObjectAtIndex(i));
|
||||
|
|
|
@ -285,7 +285,7 @@ Atlas* Atlas_readAtlas (const char* begin, int length, const char* dir) {
|
|||
Atlas* Atlas_readAtlasFile (const char* path) {
|
||||
int dirLength;
|
||||
char *dir;
|
||||
int length;
|
||||
ssize_t length;
|
||||
const char* data;
|
||||
|
||||
Atlas* atlas = 0;
|
||||
|
|
|
@ -232,7 +232,7 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S
|
|||
}
|
||||
|
||||
SkeletonData* SkeletonJson_readSkeletonDataFile (SkeletonJson* self, const char* path) {
|
||||
int length;
|
||||
ssize_t length;
|
||||
SkeletonData* skeletonData;
|
||||
const char* json = _Util_readFile(path, &length);
|
||||
if (!json) {
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace spine {
|
|||
|
||||
void _AtlasPage_createTexture (AtlasPage* self, const char* path);
|
||||
void _AtlasPage_disposeTexture (AtlasPage* self);
|
||||
char* _Util_readFile (const char* path, int* length);
|
||||
char* _Util_readFile (const char* path, ssize_t* length);
|
||||
|
||||
/*
|
||||
* Internal API available for extension:
|
||||
|
|
|
@ -46,8 +46,8 @@ void _AtlasPage_disposeTexture (AtlasPage* self) {
|
|||
((TextureAtlas*)self->rendererObject)->release();
|
||||
}
|
||||
|
||||
char* _Util_readFile (const char* path, int* length) {
|
||||
long size;
|
||||
char* _Util_readFile (const char* path, ssize_t* length) {
|
||||
ssize_t size;
|
||||
char* data = reinterpret_cast<char*>(FileUtils::getInstance()->getFileData(
|
||||
FileUtils::getInstance()->fullPathForFilename(path).c_str(), "r", &size));
|
||||
*length = size;
|
||||
|
|
|
@ -42,7 +42,7 @@ static std::mutex s_responseQueueMutex;
|
|||
static std::mutex s_SleepMutex;
|
||||
static std::condition_variable s_SleepCondition;
|
||||
|
||||
static unsigned long s_asyncRequestCount = 0;
|
||||
static int s_asyncRequestCount = 0;
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
typedef int int32_t;
|
||||
|
|
|
@ -45,7 +45,7 @@ typedef Point Vect;
|
|||
|
||||
typedef struct PhysicsContactData
|
||||
{
|
||||
static const long POINT_MAX = 4;
|
||||
static const int POINT_MAX = 4;
|
||||
Point points[POINT_MAX];
|
||||
int count;
|
||||
Point normal;
|
||||
|
|
|
@ -597,7 +597,7 @@ void PhysicsShapePolygon::getPoints(Point* outPoints) const
|
|||
PhysicsHelper::cpvs2points(((cpPolyShape*)shape)->verts, outPoints, ((cpPolyShape*)shape)->numVerts);
|
||||
}
|
||||
|
||||
long PhysicsShapePolygon::getPointsCount() const
|
||||
int PhysicsShapePolygon::getPointsCount() const
|
||||
{
|
||||
return ((cpPolyShape*)_info->getShapes().front())->numVerts;
|
||||
}
|
||||
|
@ -712,7 +712,7 @@ Point PhysicsShapeEdgePolygon::getCenter()
|
|||
return _center;
|
||||
}
|
||||
|
||||
long PhysicsShapeEdgePolygon::getPointsCount() const
|
||||
int PhysicsShapeEdgePolygon::getPointsCount() const
|
||||
{
|
||||
return _info->getShapes().size() + 1;
|
||||
}
|
||||
|
@ -773,7 +773,7 @@ Point PhysicsShapeEdgeChain::getCenter()
|
|||
return _center;
|
||||
}
|
||||
|
||||
long PhysicsShapeEdgeChain::getPointsCount() const
|
||||
int PhysicsShapeEdgeChain::getPointsCount() const
|
||||
{
|
||||
return _info->getShapes().size() + 1;
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ public:
|
|||
|
||||
Point getPoint(int i) const;
|
||||
void getPoints(Point* outPoints) const;
|
||||
long getPointsCount() const;
|
||||
int getPointsCount() const;
|
||||
virtual Point getCenter() override;
|
||||
protected:
|
||||
bool init(const Point* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Point& offset = Point::ZERO);
|
||||
|
@ -250,7 +250,7 @@ public:
|
|||
static PhysicsShapeEdgeBox* create(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 0, const Point& offset = Point::ZERO);
|
||||
virtual Point getOffset() override { return _offset; }
|
||||
void getPoints(const Point* outPoints) const;
|
||||
long getPointsCount() const;
|
||||
int getPointsCount() const;
|
||||
|
||||
protected:
|
||||
bool init(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1, const Point& offset = Point::ZERO);
|
||||
|
@ -272,7 +272,7 @@ public:
|
|||
static PhysicsShapeEdgePolygon* create(const Point* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);
|
||||
virtual Point getCenter() override;
|
||||
void getPoints(Point* outPoints) const;
|
||||
long getPointsCount() const;
|
||||
int getPointsCount() const;
|
||||
|
||||
protected:
|
||||
bool init(const Point* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);
|
||||
|
@ -294,7 +294,7 @@ public:
|
|||
static PhysicsShapeEdgeChain* create(const Point* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);
|
||||
virtual Point getCenter() override;
|
||||
void getPoints(Point* outPoints) const;
|
||||
long getPointsCount() const;
|
||||
int getPointsCount() const;
|
||||
|
||||
protected:
|
||||
bool init(const Point* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);
|
||||
|
|
|
@ -83,11 +83,11 @@ typedef PhysicsRectQueryCallbackFunc PhysicsPointQueryCallbackFunc;
|
|||
class PhysicsWorld
|
||||
{
|
||||
public:
|
||||
static const long DEBUGDRAW_NONE = 0x00;
|
||||
static const long DEBUGDRAW_SHAPE = 0x01;
|
||||
static const long DEBUGDRAW_JOINT = 0x02;
|
||||
static const long DEBUGDRAW_CONTACT = 0x04;
|
||||
static const long DEBUGDRAW_ALL = DEBUGDRAW_SHAPE | DEBUGDRAW_JOINT | DEBUGDRAW_CONTACT;
|
||||
static const int DEBUGDRAW_NONE = 0x00;
|
||||
static const int DEBUGDRAW_SHAPE = 0x01;
|
||||
static const int DEBUGDRAW_JOINT = 0x02;
|
||||
static const int DEBUGDRAW_CONTACT = 0x04;
|
||||
static const int DEBUGDRAW_ALL = DEBUGDRAW_SHAPE | DEBUGDRAW_JOINT | DEBUGDRAW_CONTACT;
|
||||
|
||||
public:
|
||||
/** Adds a joint to the physics world.*/
|
||||
|
|
Loading…
Reference in New Issue