mirror of https://github.com/axmolengine/axmol.git
Update Sprite::getQuad() to return const reference (#1260)
This commit is contained in:
parent
ce590c24a0
commit
6bc2deeba8
|
@ -141,7 +141,7 @@ public:
|
|||
|
||||
if (_textureAtlas)
|
||||
{
|
||||
_textureAtlas->updateQuad(&_quad, _atlasIndex);
|
||||
_textureAtlas->updateQuad(_quad, _atlasIndex);
|
||||
}
|
||||
|
||||
_recursiveDirty = false;
|
||||
|
@ -176,7 +176,7 @@ public:
|
|||
_quad.tl.colors = color4;
|
||||
_quad.tr.colors = color4;
|
||||
|
||||
_textureAtlas->updateQuad(&_quad, _atlasIndex);
|
||||
_textureAtlas->updateQuad(_quad, _atlasIndex);
|
||||
}
|
||||
|
||||
void setVisible(bool visible) override
|
||||
|
@ -2388,7 +2388,7 @@ void Label::updateColor()
|
|||
quads[index].br.colors = color4;
|
||||
quads[index].tl.colors = color4;
|
||||
quads[index].tr.colors = color4;
|
||||
textureAtlas->updateQuad(&quads[index], index);
|
||||
textureAtlas->updateQuad(quads[index], index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ void LabelAtlas::updateColor()
|
|||
quads[index].br.colors = color4;
|
||||
quads[index].tl.colors = color4;
|
||||
quads[index].tr.colors = color4;
|
||||
_textureAtlas->updateQuad(&quads[index], index);
|
||||
_textureAtlas->updateQuad(quads[index], index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -265,7 +265,7 @@ void LayerGradient::updateColor()
|
|||
if (_renderMode == RenderMode::QUAD_BATCHNODE)
|
||||
{
|
||||
if (_atlasIndex != INDEX_NOT_INITIALIZED)
|
||||
_textureAtlas->updateQuad(&_quad, _atlasIndex);
|
||||
_textureAtlas->updateQuad(_quad, _atlasIndex);
|
||||
else
|
||||
// no need to set it recursively
|
||||
// update dirty_, don't update recursiveDirty_
|
||||
|
|
|
@ -241,10 +241,10 @@ void ProgressTimer::updateColor()
|
|||
|
||||
if (!_vertexData.empty())
|
||||
{
|
||||
const Color4B& sc = _sprite->getQuad().tl.colors;
|
||||
for (int i = 0; i < _vertexData.size(); ++i)
|
||||
const auto& sc = _sprite->getQuad().tl.colors;
|
||||
for (auto& d : _vertexData)
|
||||
{
|
||||
_vertexData[i].colors = sc;
|
||||
d.colors = sc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1041,7 +1041,7 @@ void Sprite::updateTransform()
|
|||
|
||||
// MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
|
||||
if (_textureAtlas)
|
||||
_textureAtlas->updateQuad(&_quad, _atlasIndex);
|
||||
_textureAtlas->updateQuad(_quad, _atlasIndex);
|
||||
|
||||
_recursiveDirty = false;
|
||||
setDirty(false);
|
||||
|
@ -1509,7 +1509,7 @@ void Sprite::updateColor()
|
|||
if (_renderMode == RenderMode::QUAD_BATCHNODE)
|
||||
{
|
||||
if (_atlasIndex != INDEX_NOT_INITIALIZED)
|
||||
_textureAtlas->updateQuad(&_quad, _atlasIndex);
|
||||
_textureAtlas->updateQuad(_quad, _atlasIndex);
|
||||
else
|
||||
// no need to set it recursively
|
||||
// update dirty_, don't update recursiveDirty_
|
||||
|
|
|
@ -393,7 +393,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
V3F_C4B_T2F_Quad getQuad() const { return _quad; }
|
||||
const V3F_C4B_T2F_Quad& getQuad() const { return _quad; }
|
||||
|
||||
/**
|
||||
* Returns whether or not the texture rectangle is rotated.
|
||||
|
|
|
@ -604,8 +604,8 @@ void SpriteBatchNode::appendChild(Sprite* sprite)
|
|||
|
||||
sprite->setAtlasIndex(index);
|
||||
|
||||
V3F_C4B_T2F_Quad quad = sprite->getQuad();
|
||||
_textureAtlas->insertQuad(&quad, index);
|
||||
auto&& quad = sprite->getQuad();
|
||||
_textureAtlas->insertQuad(quad, index);
|
||||
|
||||
// add children recursively
|
||||
auto& children = sprite->getChildren();
|
||||
|
@ -723,8 +723,8 @@ void SpriteBatchNode::insertQuadFromSprite(Sprite* sprite, ssize_t index)
|
|||
sprite->setBatchNode(this);
|
||||
sprite->setAtlasIndex(static_cast<unsigned int>(index));
|
||||
|
||||
V3F_C4B_T2F_Quad quad = sprite->getQuad();
|
||||
_textureAtlas->insertQuad(&quad, index);
|
||||
auto&& quad = sprite->getQuad();
|
||||
_textureAtlas->insertQuad(quad, index);
|
||||
|
||||
// FIXME:: updateTransform will update the textureAtlas too, using updateQuad.
|
||||
// FIXME:: so, it should be AFTER the insertQuad
|
||||
|
|
|
@ -204,18 +204,18 @@ void TextureAtlas::setupIndices()
|
|||
|
||||
// TextureAtlas - Update, Insert, Move & Remove
|
||||
|
||||
void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad* quad, ssize_t index)
|
||||
void TextureAtlas::updateQuad(const V3F_C4B_T2F_Quad& quad, ssize_t index)
|
||||
{
|
||||
AXASSERT(index >= 0 && index < _capacity, "updateQuadWithTexture: Invalid index");
|
||||
|
||||
_totalQuads = MAX(index + 1, _totalQuads);
|
||||
|
||||
_quads[index] = *quad;
|
||||
_quads[index] = quad;
|
||||
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad* quad, ssize_t index)
|
||||
void TextureAtlas::insertQuad(const V3F_C4B_T2F_Quad& quad, ssize_t index)
|
||||
{
|
||||
AXASSERT(index >= 0 && index < _capacity, "insertQuadWithTexture: Invalid index");
|
||||
|
||||
|
@ -232,7 +232,7 @@ void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad* quad, ssize_t index)
|
|||
memmove(&_quads[index + 1], &_quads[index], sizeof(_quads[0]) * remaining);
|
||||
}
|
||||
|
||||
_quads[index] = *quad;
|
||||
_quads[index] = quad;
|
||||
|
||||
_dirty = true;
|
||||
}
|
||||
|
|
|
@ -111,14 +111,14 @@ public:
|
|||
@param index Index must be between 0 and the atlas capacity - 1.
|
||||
@since v0.8
|
||||
*/
|
||||
void updateQuad(V3F_C4B_T2F_Quad* quad, ssize_t index);
|
||||
void updateQuad(const V3F_C4B_T2F_Quad& quad, ssize_t index);
|
||||
|
||||
/** Inserts a Quad (texture, vertex and color) at a certain index.
|
||||
@param quad Quad that are going to be rendered.
|
||||
@param index Index must be between 0 and the atlas capacity - 1.
|
||||
@since v0.8
|
||||
*/
|
||||
void insertQuad(V3F_C4B_T2F_Quad* quad, ssize_t index);
|
||||
void insertQuad(const V3F_C4B_T2F_Quad& quad, ssize_t index);
|
||||
|
||||
/** Inserts a c array of quads at a given index.
|
||||
@param quads Quad that are going to be rendered.
|
||||
|
|
|
@ -202,7 +202,7 @@ void Skin::updateTransform()
|
|||
// MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
|
||||
if (_textureAtlas)
|
||||
{
|
||||
_textureAtlas->updateQuad(&_quad, _textureAtlas->getTotalQuads());
|
||||
_textureAtlas->updateQuad(_quad, _textureAtlas->getTotalQuads());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue