Changes in `visit()` were done in order to do it
in a robust and fast way.
This commit is contained in:
Ricardo Quesada 2014-05-30 16:42:05 -07:00
Родитель a69a98776d
Коммит 1b8d0d88df
113 изменённых файлов: 577 добавлений и 432 удалений

Просмотреть файл

@ -1,6 +1,8 @@
cocos2d-x-3.2 ???
[NEW] Node: added setter/getter for NormalizedPosition(). Allows to set positions in normalized values (between 0 and 1)
[NEW] Scene: Added createWithSize() method
[NEW] TextureCache: added unbindImageAsync() and unbindAllImageAsync()
[FIX] Application.mk: not output debug message in releae mode on Android
[FIX] Cocos2dxGLSurfaceView.java: prevent flickering when opening another activity
[FIX] Image: Set jpeg save quality to 90

Просмотреть файл

@ -133,7 +133,7 @@ void AtlasNode::updateAtlasValues()
}
// AtlasNode - draw
void AtlasNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void AtlasNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_quadCommand.init(
_globalZOrder,

Просмотреть файл

@ -69,7 +69,7 @@ public:
// Overrides
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual Texture2D* getTexture() const override;
virtual void setTexture(Texture2D *texture) override;
virtual bool isOpacityModifyRGB() const override;

Просмотреть файл

@ -203,15 +203,12 @@ void ClippingNode::drawFullScreenQuadClearStencil()
}
void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
if(!_visible)
return;
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
uint32_t flags = processParentFlags(parentTransform, parentFlags);
// IMPORTANT:
// To ease the migration to v3.0, we still support the Mat4 stack,
@ -249,7 +246,7 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool p
#endif
}
_stencil->visit(renderer, _modelViewTransform, dirty);
_stencil->visit(renderer, _modelViewTransform, flags);
_afterDrawStencilCmd.init(_globalZOrder);
_afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this);
@ -266,19 +263,19 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool p
auto node = _children.at(i);
if ( node && node->getLocalZOrder() < 0 )
node->visit(renderer, _modelViewTransform, dirty);
node->visit(renderer, _modelViewTransform, flags);
else
break;
}
// self draw
this->draw(renderer, _modelViewTransform, dirty);
this->draw(renderer, _modelViewTransform, flags);
for(auto it=_children.cbegin()+i; it != _children.cend(); ++it)
(*it)->visit(renderer, _modelViewTransform, dirty);
(*it)->visit(renderer, _modelViewTransform, flags);
}
else
{
this->draw(renderer, _modelViewTransform, dirty);
this->draw(renderer, _modelViewTransform, flags);
}
_afterVisitCmd.init(_globalZOrder);

Просмотреть файл

@ -95,7 +95,7 @@ public:
* @lua NA
*/
virtual void onExit() override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
CC_CONSTRUCTOR_ACCESS:
ClippingNode();

Просмотреть файл

@ -205,14 +205,14 @@ bool DrawNode::init()
return true;
}
void DrawNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void DrawNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void DrawNode::onDraw(const Mat4 &transform, bool transformUpdated)
void DrawNode::onDraw(const Mat4 &transform, uint32_t flags)
{
auto glProgram = getGLProgram();
glProgram->use();

Просмотреть файл

@ -89,10 +89,10 @@ public:
*/
void setBlendFunc(const BlendFunc &blendFunc);
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
// Overrides
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
CC_CONSTRUCTOR_ACCESS:
DrawNode();

Просмотреть файл

@ -877,14 +877,14 @@ void Label::drawShadowWithoutBlur()
setColor(oldColor);
}
void Label::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void Label::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
// Don't do calculate the culling if the transform was not updated
_insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
_insideBounds = (flags & PARENT_DIRTY_MASK) ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
if(_insideBounds) {
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
}
@ -1019,7 +1019,7 @@ void Label::updateFont()
_systemFontDirty = false;
}
void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
void Label::drawTextSprite(Renderer *renderer, uint32_t parentFlags)
{
if (_fontDefinition._fontFillColor != _textColor)
{
@ -1044,12 +1044,12 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
}
if (_shadowNode)
{
_shadowNode->visit(renderer, _modelViewTransform, parentTransformUpdated);
_shadowNode->visit(renderer, _modelViewTransform, parentFlags);
}
_textSprite->visit(renderer, _modelViewTransform, parentTransformUpdated);
_textSprite->visit(renderer, _modelViewTransform, parentFlags);
}
void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
if (! _visible || _originalUTF8String.empty())
{
@ -1064,9 +1064,9 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTr
updateContent();
}
bool dirty = parentTransformUpdated || _transformUpdated;
uint32_t flags = processParentFlags(parentTransform, parentFlags);
if (_shadowEnabled && _shadowBlurRadius <= 0 && (_shadowDirty || dirty))
if (_shadowEnabled && _shadowBlurRadius <= 0 && (_shadowDirty || (flags & PARENT_DIRTY_MASK)))
{
_position.x += _shadowOffset.width;
_position.y += _shadowOffset.height;
@ -1081,12 +1081,6 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTr
_shadowDirty = false;
}
if(dirty)
{
_modelViewTransform = transform(parentTransform);
}
_transformUpdated = false;
// IMPORTANT:
// To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it
@ -1099,11 +1093,11 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTr
if (_textSprite)
{
drawTextSprite(renderer,dirty);
drawTextSprite(renderer, flags);
}
else
{
draw(renderer, _modelViewTransform, dirty);
draw(renderer, _modelViewTransform, flags);
}
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);

Просмотреть файл

@ -237,8 +237,8 @@ public:
virtual Rect getBoundingBox() const override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
CC_DEPRECATED_ATTRIBUTE static Label* create(const std::string& text, const std::string& font, float fontSize,
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
@ -298,7 +298,7 @@ protected:
void drawShadowWithoutBlur();
void drawTextSprite(Renderer *renderer, bool parentTransformUpdated);
void drawTextSprite(Renderer *renderer, uint32_t parentFlags);
void createSpriteWithFontDefinition();

Просмотреть файл

@ -249,7 +249,7 @@ void LabelAtlas::updateColor()
//CCLabelAtlas - draw
#if CC_LABELATLAS_DEBUG_DRAW
void LabelAtlas::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void LabelAtlas::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
AtlasNode::draw(renderer, transform, transformUpdated);

Просмотреть файл

@ -84,7 +84,7 @@ public:
virtual std::string getDescription() const override;
#if CC_LABELATLAS_DEBUG_DRAW
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
#endif
protected:

Просмотреть файл

@ -207,7 +207,7 @@ Rect LabelBMFont::getBoundingBox() const
return _label->getBoundingBox();
}
#if CC_LABELBMFONT_DEBUG_DRAW
void LabelBMFont::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void LabelBMFont::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
Node::draw(renderer, transform, transformUpdated);

Просмотреть файл

@ -124,7 +124,7 @@ public:
virtual std::string getDescription() const override;
#if CC_LABELBMFONT_DEBUG_DRAW
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
#endif
private:

Просмотреть файл

@ -262,14 +262,14 @@ void LabelTTF::setFlippedY(bool flippedY)
}
}
void LabelTTF::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void LabelTTF::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
if (_contentDirty)
{
this->setContentSize(_renderLabel->getContentSize());
_contentDirty = false;
}
Node::visit(renderer,parentTransform,parentTransformUpdated);
Node::visit(renderer,parentTransform, parentFlags);
}
const Size& LabelTTF::getContentSize() const

Просмотреть файл

@ -150,7 +150,7 @@ public:
* @lua NA
*/
virtual std::string getDescription() const override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
virtual const Size& getContentSize() const override;
protected:
Label* _renderLabel;

Просмотреть файл

@ -75,16 +75,9 @@ Layer::~Layer()
bool Layer::init()
{
bool ret = false;
do
{
Director * director;
CC_BREAK_IF(!(director = Director::getInstance()));
this->setContentSize(director->getWinSize());
// success
ret = true;
} while(0);
return ret;
Director * director = Director::getInstance();
setContentSize(director->getWinSize());
return true;
}
Layer *Layer::create()
@ -584,10 +577,10 @@ void LayerColor::updateColor()
}
}
void LayerColor::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void LayerColor::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
for(int i = 0; i < 4; ++i)
@ -600,7 +593,7 @@ void LayerColor::draw(Renderer *renderer, const Mat4 &transform, bool transformU
}
}
void LayerColor::onDraw(const Mat4& transform, bool transformUpdated)
void LayerColor::onDraw(const Mat4& transform, uint32_t flags)
{
getGLProgram()->use();
getGLProgram()->setUniformsForBuiltins(transform);

Просмотреть файл

@ -270,7 +270,7 @@ public:
//
// Overrides
//
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual void setContentSize(const Size & var) override;
/** BlendFunction. Conforms to BlendProtocol protocol */
@ -299,7 +299,7 @@ CC_CONSTRUCTOR_ACCESS:
bool initWithColor(const Color4B& color);
protected:
void onDraw(const Mat4& transform, bool transformUpdated);
void onDraw(const Mat4& transform, uint32_t flags);
virtual void updateColor() override;

Просмотреть файл

@ -374,7 +374,7 @@ void MotionStreak::reset()
_nuPoints = 0;
}
void MotionStreak::onDraw(const Mat4 &transform, bool transformUpdated)
void MotionStreak::onDraw(const Mat4 &transform, uint32_t flags)
{
getGLProgram()->use();
getGLProgram()->setUniformsForBuiltins(transform);
@ -404,12 +404,12 @@ void MotionStreak::onDraw(const Mat4 &transform, bool transformUpdated)
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _nuPoints*2);
}
void MotionStreak::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void MotionStreak::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
if(_nuPoints <= 1)
return;
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}

Просмотреть файл

@ -85,7 +85,7 @@ public:
* @js NA
* @lua NA
*/
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
/**
* @js NA
* @lua NA
@ -120,7 +120,7 @@ CC_CONSTRUCTOR_ACCESS:
protected:
//renderer callback
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
bool _fastMode;
bool _startingPositionInitialized;

Просмотреть файл

@ -121,6 +121,7 @@ Node::Node(void)
, _realColor(Color3B::WHITE)
, _cascadeColorEnabled(false)
, _cascadeOpacityEnabled(false)
, _usingNormalizedPosition(false)
{
// set default scheduler and actionManager
Director *director = Director::getInstance();
@ -423,6 +424,7 @@ void Node::setPosition(const Vec2& position)
_position = position;
_transformUpdated = _transformDirty = _inverseDirty = true;
_usingNormalizedPosition = false;
#if CC_USE_PHYSICS
if (_physicsBody != nullptr && !_physicsBody->_positionResetTag)
@ -498,6 +500,23 @@ void Node::setPositionZ(float positionZ)
setGlobalZOrder(positionZ);
}
/// position getter
const Vec2& Node::getNormalizedPosition() const
{
return _normalizedPosition;
}
/// position setter
void Node::setNormalizedPosition(const Vec2& position)
{
if (_normalizedPosition.equals(position))
return;
_normalizedPosition = position;
_usingNormalizedPosition = true;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
ssize_t Node::getChildrenCount() const
{
return _children.size();
@ -561,7 +580,7 @@ void Node::setContentSize(const Size & size)
_contentSize = size;
_anchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
_transformUpdated = _transformDirty = _inverseDirty = true;
_transformUpdated = _transformDirty = _inverseDirty = _contentSizeDirty = true;
}
}
@ -943,7 +962,7 @@ void Node::draw()
draw(renderer, _modelViewTransform, true);
}
void Node::draw(Renderer* renderer, const Mat4 &transform, bool transformUpdated)
void Node::draw(Renderer* renderer, const Mat4 &transform, uint32_t flags)
{
}
@ -954,7 +973,30 @@ void Node::visit()
visit(renderer, parentTransform, true);
}
void Node::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
uint32_t Node::processParentFlags(const Mat4& parentTransform, uint32_t parentFlags)
{
uint32_t flags = parentFlags;
flags |= (_transformUpdated ? PARENT_TRANSFORM_DIRTY : 0);
flags |= (_contentSizeDirty ? PARENT_CONTENT_SIZE_DIRTY : 0);
if(_usingNormalizedPosition && (flags & PARENT_CONTENT_SIZE_DIRTY)) {
CCASSERT(_parent, "setNormalizedPosition() doesn't work with orphan nodes");
auto s = _parent->getContentSize();
_position.x = _normalizedPosition.x * s.width;
_position.y = _normalizedPosition.y * s.height;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
if(flags & PARENT_DIRTY_MASK)
_modelViewTransform = this->transform(parentTransform);
_transformUpdated = false;
_contentSizeDirty = false;
return flags;
}
void Node::visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
// quick return if not visible. children won't be drawn.
if (!_visible)
@ -962,17 +1004,12 @@ void Node::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTra
return;
}
bool dirty = _transformUpdated || parentTransformUpdated;
if(dirty)
_modelViewTransform = this->transform(parentTransform);
_transformUpdated = false;
uint32_t flags = processParentFlags(parentTransform, parentFlags);
// IMPORTANT:
// To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
@ -987,19 +1024,19 @@ void Node::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTra
auto node = _children.at(i);
if ( node && node->_localZOrder < 0 )
node->visit(renderer, _modelViewTransform, dirty);
node->visit(renderer, _modelViewTransform, flags);
else
break;
}
// self draw
this->draw(renderer, _modelViewTransform, dirty);
this->draw(renderer, _modelViewTransform, flags);
for(auto it=_children.cbegin()+i; it != _children.cend(); ++it)
(*it)->visit(renderer, _modelViewTransform, dirty);
(*it)->visit(renderer, _modelViewTransform, flags);
}
else
{
this->draw(renderer, _modelViewTransform, dirty);
this->draw(renderer, _modelViewTransform, flags);
}
// reset for next frame

Просмотреть файл

@ -107,6 +107,12 @@ public:
/// Default tag used for all the nodes
static const int INVALID_TAG = -1;
enum {
PARENT_TRANSFORM_DIRTY = (1 << 0),
PARENT_CONTENT_SIZE_DIRTY = (1 << 1),
PARENT_DIRTY_MASK = (PARENT_TRANSFORM_DIRTY | PARENT_CONTENT_SIZE_DIRTY),
};
/// @{
/// @name Constructor, Destructor and Initializers
@ -283,6 +289,19 @@ public:
* @param position The position (x,y) of the node in OpenGL coordinates
*/
virtual void setPosition(const Vec2 &position);
/** Sets the position (x,y) using values between 0 and 1.
The positions in pixels is calculated like the following:
@code
// pseudo code
void setNormalizedPosition(Vec2 pos) {
Size s = getParent()->getContentSize();
_position = pos * s;
}
@endcode
*/
virtual void setNormalizedPosition(const Vec2 &position);
/**
* Gets the position (x,y) of the node in its parent's coordinate system.
*
@ -294,6 +313,10 @@ public:
* @endcode
*/
virtual const Vec2& getPosition() const;
/** returns the normalized position */
virtual const Vec2& getNormalizedPosition() const;
/**
* Sets the position (x,y) of the node in its parent's coordinate system.
*
@ -923,13 +946,13 @@ public:
* AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE
* But if you enable any other GL state, you should disable it after drawing your node.
*/
virtual void draw(Renderer *renderer, const Mat4& transform, bool transformUpdated);
virtual void draw(Renderer *renderer, const Mat4& transform, uint32_t flags);
virtual void draw() final;
/**
* Visits this node's children and draw them recursively.
*/
virtual void visit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated);
virtual void visit(Renderer *renderer, const Mat4& parentTransform, uint32_t parentFlags);
virtual void visit() final;
@ -1362,6 +1385,7 @@ protected:
Vec2 convertToWindowSpace(const Vec2& nodePoint) const;
Mat4 transform(const Mat4 &parentTransform);
uint32_t processParentFlags(const Mat4& parentTransform, uint32_t parentFlags);
virtual void updateCascadeOpacity();
virtual void disableCascadeOpacity();
@ -1387,6 +1411,8 @@ protected:
Vec2 _position; ///< position of the node
float _positionZ; ///< OpenGL real Z position
Vec2 _normalizedPosition;
bool _usingNormalizedPosition;
float _skewX; ///< skew angle on x-axis
float _skewY; ///< skew angle on y-axis
@ -1395,6 +1421,7 @@ protected:
Vec2 _anchorPoint; ///< anchor point normalized (NOT in points)
Size _contentSize; ///< untransformed size of the node
bool _contentSizeDirty; ///< whether or not the contentSize is dirty
Mat4 _modelViewTransform; ///< ModelView transform of the Node.

Просмотреть файл

@ -82,7 +82,7 @@ void NodeGrid::onGridEndDraw()
}
}
void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
// quick return if not visible. children won't be drawn.
if (!_visible)
@ -94,7 +94,7 @@ void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, bool paren
renderer->addCommand(&_groupCommand);
renderer->pushGroup(_groupCommand.getRenderQueueID());
bool dirty = parentTransformUpdated || _transformUpdated;
bool dirty = (parentFlags & PARENT_TRANSFORM_DIRTY) || _transformUpdated;
if(dirty)
_modelViewTransform = this->transform(parentTransform);
_transformUpdated = false;

Просмотреть файл

@ -54,7 +54,7 @@ public:
void setTarget(Node *target);
// overrides
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
protected:
NodeGrid();

Просмотреть файл

@ -145,7 +145,7 @@ The positions are updated at visit because:
- using a timer is not guaranteed that it will called after all the positions were updated
- overriding "draw" will only precise if the children have a z > 0
*/
void ParallaxNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void ParallaxNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
// Vec2 pos = position_;
// Vec2 pos = [self convertToWorldSpace:Vec2::ZERO];
@ -161,7 +161,7 @@ void ParallaxNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool p
}
_lastPosition = pos;
}
Node::visit(renderer, parentTransform, parentTransformUpdated);
Node::visit(renderer, parentTransform, parentFlags);
}
NS_CC_END

Просмотреть файл

@ -67,7 +67,7 @@ public:
virtual void addChild(Node * child, int zOrder, int tag) override;
virtual void removeChild(Node* child, bool cleanup) override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
protected:
/** Adds a child to the container with a z-order, a parallax ratio and a position offset

Просмотреть файл

@ -121,7 +121,7 @@ bool ParticleBatchNode::initWithFile(const std::string& fileImage, int capacity)
// override visit.
// Don't call visit on it's children
void ParticleBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void ParticleBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
// CAREFUL:
// This visit is almost identical to Node#visit
@ -135,20 +135,16 @@ void ParticleBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, b
return;
}
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
uint32_t flags = processParentFlags(parentTransform, parentFlags);
// IMPORTANT:
// To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
draw(renderer, _modelViewTransform, dirty);
draw(renderer, _modelViewTransform, flags);
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
}
@ -383,7 +379,7 @@ void ParticleBatchNode::removeAllChildrenWithCleanup(bool doCleanup)
_textureAtlas->removeAllQuads();
}
void ParticleBatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void ParticleBatchNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
CC_PROFILER_START("CCParticleBatchNode - draw");

Просмотреть файл

@ -91,13 +91,13 @@ public:
inline void setTextureAtlas(TextureAtlas* atlas) { _textureAtlas = atlas; };
// Overrides
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
using Node::addChild;
virtual void addChild(Node * child, int zOrder, int tag) override;
virtual void removeChild(Node* child, bool cleanup) override;
virtual void reorderChild(Node * child, int zOrder) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual Texture2D* getTexture(void) const override;
virtual void setTexture(Texture2D *texture) override;
/**

Просмотреть файл

@ -368,7 +368,7 @@ void ParticleSystemQuad::postStep()
}
// overriding draw method
void ParticleSystemQuad::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void ParticleSystemQuad::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
CCASSERT( _particleIdx == 0 || _particleIdx == _particleCount, "Abnormal error in particle quad");
//quad command

Просмотреть файл

@ -106,7 +106,7 @@ public:
* @js NA
* @lua NA
*/
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
/**
* @js NA

Просмотреть файл

@ -500,7 +500,7 @@ Vec2 ProgressTimer::boundaryTexCoord(char index)
return Vec2::ZERO;
}
void ProgressTimer::onDraw(const Mat4 &transform, bool transformUpdated)
void ProgressTimer::onDraw(const Mat4 &transform, uint32_t flags)
{
getGLProgram()->use();
@ -551,13 +551,13 @@ void ProgressTimer::onDraw(const Mat4 &transform, bool transformUpdated)
}
}
void ProgressTimer::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void ProgressTimer::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
if( ! _vertexData || ! _sprite)
return;
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}

Просмотреть файл

@ -111,7 +111,7 @@ public:
inline Vec2 getBarChangeRate() const { return _barChangeRate; }
// Overrides
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual void setAnchorPoint(const Vec2& anchorPoint) override;
virtual void setColor(const Color3B &color) override;
virtual const Color3B& getColor() const override;
@ -133,7 +133,7 @@ CC_CONSTRUCTOR_ACCESS:
bool initWithSprite(Sprite* sp);
protected:
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
Tex2F textureCoordFromAlphaPoint(Vec2 alpha);
Vec2 vertexFromAlphaPoint(Vec2 alpha);

Просмотреть файл

@ -383,7 +383,7 @@ void RenderTexture::clearStencil(int stencilValue)
glClearStencil(stencilClearValue);
}
void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
// override visit.
// Don't call visit on its children
@ -392,22 +392,17 @@ void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, bool
return;
}
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
uint32_t flags = processParentFlags(parentTransform, parentFlags);
Director* director = Director::getInstance();
// IMPORTANT:
// To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
_sprite->visit(renderer, _modelViewTransform, dirty);
draw(renderer, _modelViewTransform, dirty);
_sprite->visit(renderer, _modelViewTransform, flags);
draw(renderer, _modelViewTransform, flags);
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
@ -654,7 +649,7 @@ void RenderTexture::onClearDepth()
glClearDepth(depthClearValue);
}
void RenderTexture::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void RenderTexture::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
if (_autoDraw)
{
@ -672,7 +667,7 @@ void RenderTexture::draw(Renderer *renderer, const Mat4 &transform, bool transfo
for(const auto &child: _children)
{
if (child != _sprite)
child->visit(renderer, transform, transformUpdated);
child->visit(renderer, transform, flags);
}
//End will pop the current render group

Просмотреть файл

@ -153,8 +153,8 @@ public:
};
// Overrides
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
//flag: use stack matrix computed from scene hierarchy or generate new modelView and projection matrix
void setKeepMatrix(bool keepMatrix);

Просмотреть файл

@ -53,19 +53,17 @@ Scene::~Scene()
bool Scene::init()
{
bool ret = false;
do
{
Director * director;
CC_BREAK_IF( ! (director = Director::getInstance()) );
this->setContentSize(director->getWinSize());
// success
ret = true;
} while (0);
return ret;
auto size = Director::getInstance()->getWinSize();
return initWithSize(size);
}
Scene *Scene::create()
bool Scene::initWithSize(const Size& size)
{
setContentSize(size);
return true;
}
Scene* Scene::create()
{
Scene *ret = new Scene();
if (ret && ret->init())
@ -80,6 +78,21 @@ Scene *Scene::create()
}
}
Scene* Scene::createWithSize(const Size& size)
{
Scene *ret = new Scene();
if (ret && ret->initWithSize(size))
{
ret->autorelease();
return ret;
}
else
{
CC_SAFE_DELETE(ret);
return nullptr;
}
}
std::string Scene::getDescription() const
{
return StringUtils::format("<Scene | tag = %d>", _tag);
@ -106,7 +119,7 @@ void Scene::update(float delta)
}
}
Scene *Scene::createWithPhysics()
Scene* Scene::createWithPhysics()
{
Scene *ret = new Scene();
if (ret && ret->initWithPhysics())

Просмотреть файл

@ -54,6 +54,9 @@ public:
/** creates a new Scene object */
static Scene *create();
/** creates a new Scene object with a predefined Size */
static Scene *createWithSize(const Size& size);
// Overrides
virtual Scene *getScene() override;
@ -64,7 +67,8 @@ CC_CONSTRUCTOR_ACCESS:
Scene();
virtual ~Scene();
virtual bool init() override;
bool init();
bool initWithSize(const Size& size);
protected:
friend class Node;

Просмотреть файл

@ -585,10 +585,10 @@ void Sprite::updateTransform(void)
// draw
void Sprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void Sprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
// Don't do calculate the culling if the transform was not updated
_insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
_insideBounds = (flags & PARENT_DIRTY_MASK) ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
if(_insideBounds)
{

Просмотреть файл

@ -420,7 +420,7 @@ public:
virtual void setAnchorPoint(const Vec2& anchor) override;
virtual void ignoreAnchorPointForPosition(bool value) override;
virtual void setVisible(bool bVisible) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual void setOpacityModifyRGB(bool modify) override;
virtual bool isOpacityModifyRGB(void) const override;
/// @}

Просмотреть файл

@ -132,7 +132,7 @@ SpriteBatchNode::~SpriteBatchNode()
// override visit
// don't call visit on it's children
void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
CC_PROFILER_START_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit");
@ -150,20 +150,16 @@ void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, boo
sortAllChildren();
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
uint32_t flags = processParentFlags(parentTransform, parentFlags);
// IMPORTANT:
// To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
draw(renderer, _modelViewTransform, dirty);
draw(renderer, _modelViewTransform, flags);
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
setOrderOfArrival(0);
@ -356,7 +352,7 @@ void SpriteBatchNode::reorderBatch(bool reorder)
_reorderChildDirty=reorder;
}
void SpriteBatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void SpriteBatchNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
// Optimization: Fast Dispatch
if( _textureAtlas->getTotalQuads() == 0 )

Просмотреть файл

@ -134,7 +134,7 @@ public:
*/
virtual const BlendFunc& getBlendFunc() const override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
using Node::addChild;
virtual void addChild(Node * child, int zOrder, int tag) override;
@ -143,7 +143,7 @@ public:
virtual void removeChild(Node *child, bool cleanup) override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void sortAllChildren() override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual std::string getDescription() const override;
/** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array.

Просмотреть файл

@ -263,13 +263,13 @@ void TextFieldTTF::setTextColor(const Color4B &color)
Label::setTextColor(_colorText);
}
void TextFieldTTF::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void TextFieldTTF::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
if (_delegate && _delegate->onVisit(this,renderer,parentTransform,parentTransformUpdated))
if (_delegate && _delegate->onVisit(this,renderer,parentTransform,parentFlags))
{
return;
}
Label::visit(renderer,parentTransform,parentTransformUpdated);
Label::visit(renderer,parentTransform,parentFlags);
}
const Color4B& TextFieldTTF::getColorSpaceHolder()

Просмотреть файл

@ -86,7 +86,7 @@ public:
/**
@brief If the sender doesn't want to draw, return true.
*/
virtual bool onVisit(TextFieldTTF * sender,Renderer *renderer, const Mat4 &transform, bool transformUpdated)
virtual bool onVisit(TextFieldTTF * sender,Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
CC_UNUSED_PARAM(sender);
return false;
@ -165,7 +165,7 @@ public:
virtual void setSecureTextEntry(bool value);
virtual bool isSecureTextEntry();
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
protected:
//////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -103,16 +103,16 @@ void TransitionScene::sceneOrder()
_isInSceneOnTop = true;
}
void TransitionScene::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void TransitionScene::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
Scene::draw(renderer, transform, transformUpdated);
Scene::draw(renderer, transform, flags);
if( _isInSceneOnTop ) {
_outScene->visit(renderer, transform, transformUpdated);
_inScene->visit(renderer, transform, transformUpdated);
_outScene->visit(renderer, transform, flags);
_inScene->visit(renderer, transform, flags);
} else {
_inScene->visit(renderer, transform, transformUpdated);
_outScene->visit(renderer, transform, transformUpdated);
_inScene->visit(renderer, transform, flags);
_outScene->visit(renderer, transform, flags);
}
}
@ -1261,7 +1261,7 @@ TransitionCrossFade* TransitionCrossFade::create(float t, Scene* scene)
return nullptr;
}
void TransitionCrossFade::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void TransitionCrossFade::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
// override draw since both scenes (textures) are rendered in 1 scene
}
@ -1410,19 +1410,19 @@ void TransitionTurnOffTiles::onExit()
TransitionScene::onExit();
}
void TransitionTurnOffTiles::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void TransitionTurnOffTiles::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
Scene::draw(renderer, transform, transformUpdated);
Scene::draw(renderer, transform, flags);
if( _isInSceneOnTop )
{
_outSceneProxy->visit(renderer, transform, transformUpdated);
_inScene->visit(renderer, transform, transformUpdated);
_outSceneProxy->visit(renderer, transform, flags);
_inScene->visit(renderer, transform, flags);
}
else
{
_inScene->visit(renderer, transform, transformUpdated);
_outSceneProxy->visit(renderer, transform, transformUpdated);
_inScene->visit(renderer, transform, flags);
_outSceneProxy->visit(renderer, transform, flags);
}
}
@ -1490,10 +1490,10 @@ void TransitionSplitCols::switchTargetToInscene()
_gridProxy->setTarget(_inScene);
}
void TransitionSplitCols::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void TransitionSplitCols::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
Scene::draw(renderer, transform, transformUpdated);
_gridProxy->visit(renderer, transform, transformUpdated);
Scene::draw(renderer, transform, flags);
_gridProxy->visit(renderer, transform, flags);
}
void TransitionSplitCols::onExit()
@ -1606,19 +1606,19 @@ void TransitionFadeTR::onExit()
TransitionScene::onExit();
}
void TransitionFadeTR::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void TransitionFadeTR::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
Scene::draw(renderer, transform, transformUpdated);
Scene::draw(renderer, transform, flags);
if( _isInSceneOnTop )
{
_outSceneProxy->visit(renderer, transform, transformUpdated);
_inScene->visit(renderer, transform, transformUpdated);
_outSceneProxy->visit(renderer, transform, flags);
_inScene->visit(renderer, transform, flags);
}
else
{
_inScene->visit(renderer, transform, transformUpdated);
_outSceneProxy->visit(renderer, transform, transformUpdated);
_inScene->visit(renderer, transform, flags);
_outSceneProxy->visit(renderer, transform, flags);
}
}

Просмотреть файл

@ -91,7 +91,7 @@ public:
//
// Overrides
//
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual void onEnter() override;
virtual void onExit() override;
virtual void cleanup() override;
@ -613,7 +613,7 @@ public :
* @js NA
* @lua NA
*/
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
/**
* @js NA
* @lua NA
@ -651,7 +651,7 @@ public :
virtual void onEnter() override;
virtual void onExit() override;
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
protected:
TransitionTurnOffTiles();
@ -684,7 +684,7 @@ public:
virtual void onEnter() override;
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
virtual void onExit() override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
protected:
TransitionSplitCols();
virtual ~TransitionSplitCols();
@ -735,7 +735,7 @@ public:
virtual void onEnter() override;
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
virtual void onExit() override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
protected:
TransitionFadeTR();
virtual ~TransitionFadeTR();

Просмотреть файл

@ -92,27 +92,27 @@ void TransitionPageTurn::onDisablePolygonOffset()
glPolygonOffset(0, 0);
}
void TransitionPageTurn::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void TransitionPageTurn::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
Scene::draw(renderer, transform, transformUpdated);
Scene::draw(renderer, transform, flags);
if( _isInSceneOnTop ) {
_outSceneProxy->visit(renderer, transform, transformUpdated);
_outSceneProxy->visit(renderer, transform, flags);
_enableOffsetCmd.init(_globalZOrder);
_enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this);
renderer->addCommand(&_enableOffsetCmd);
_inSceneProxy->visit(renderer, transform, transformUpdated);
_inSceneProxy->visit(renderer, transform, flags);
_disableOffsetCmd.init(_globalZOrder);
_disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this);
renderer->addCommand(&_disableOffsetCmd);
} else {
_inSceneProxy->visit(renderer, transform, transformUpdated);
_inSceneProxy->visit(renderer, transform, flags);
_enableOffsetCmd.init(_globalZOrder);
_enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this);
renderer->addCommand(&_enableOffsetCmd);
_outSceneProxy->visit(renderer, transform, transformUpdated);
_outSceneProxy->visit(renderer, transform, flags);
_disableOffsetCmd.init(_globalZOrder);
_disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this);

Просмотреть файл

@ -72,7 +72,7 @@ public:
//
// Overrides
//
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
/**
* Creates a base transition with duration and incoming scene.

Просмотреть файл

@ -230,7 +230,7 @@ void Sprite3D::setTexture(Texture2D* texture)
}
}
void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
GLProgramState* programstate = getGLProgramState();
Color4F color(getDisplayedColor());

Просмотреть файл

@ -67,7 +67,7 @@ protected:
//.mtl file should at the same directory with the same name if exist
bool loadFromObj(const std::string& path);
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual GLProgram* getDefaultGLProgram(bool textured = true);

Просмотреть файл

@ -92,7 +92,8 @@ Director* Director::getInstance()
{
if (!s_SharedDirector)
{
s_SharedDirector = new DisplayLinkDirector();
s_SharedDirector = new (std::nothrow) DisplayLinkDirector();
CCASSERT(s_SharedDirector, "FATAL: Not enough memory");
s_SharedDirector->init();
}
@ -1091,9 +1092,9 @@ void Director::showStats()
Mat4 identity = Mat4::IDENTITY;
_drawnVerticesLabel->visit(_renderer, identity, false);
_drawnBatchesLabel->visit(_renderer, identity, false);
_FPSLabel->visit(_renderer, identity, false);
_drawnVerticesLabel->visit(_renderer, identity, 0);
_drawnBatchesLabel->visit(_renderer, identity, 0);
_FPSLabel->visit(_renderer, identity, 0);
}
}

Просмотреть файл

@ -378,7 +378,7 @@ void Armature::update(float dt)
_armatureTransformDirty = false;
}
void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
if (_parentBone == nullptr && _batchNode == nullptr)
{
@ -408,17 +408,17 @@ void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, bool tra
{
skin->setBlendFunc(bone->getBlendFunc());
}
skin->draw(renderer, transform, transformUpdated);
skin->draw(renderer, transform, flags);
}
break;
case CS_DISPLAY_ARMATURE:
{
node->draw(renderer, transform, transformUpdated);
node->draw(renderer, transform, flags);
}
break;
default:
{
node->visit(renderer, transform, transformUpdated);
node->visit(renderer, transform, flags);
// CC_NODE_DRAW_SETUP();
}
break;
@ -426,7 +426,7 @@ void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, bool tra
}
else if(Node *node = dynamic_cast<Node *>(object))
{
node->visit(renderer, transform, transformUpdated);
node->visit(renderer, transform, flags);
// CC_NODE_DRAW_SETUP();
}
}
@ -445,7 +445,7 @@ void Armature::onExit()
}
void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
// quick return if not visible. children won't be drawn.
if (!_visible)
@ -453,10 +453,7 @@ void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, b
return;
}
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
uint32_t flags = processParentFlags(parentTransform, parentFlags);
// IMPORTANT:
// To ease the migration to v3.0, we still support the Mat4 stack,
@ -468,7 +465,7 @@ void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, b
sortAllChildren();
draw(renderer, _modelViewTransform, dirty);
draw(renderer, _modelViewTransform, flags);
// reset for next frame
_orderOfArrival = 0;

Просмотреть файл

@ -157,8 +157,8 @@ public:
* @js NA
* @lua NA
*/
virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override;
virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, uint32_t parentFlags) override;
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override;
virtual void update(float dt) override;
virtual void onEnter() override;

Просмотреть файл

@ -101,7 +101,7 @@ void BatchNode::removeChild(Node* child, bool cleanup)
Node::removeChild(child, cleanup);
}
void BatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void BatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
// quick return if not visible. children won't be drawn.
if (!_visible)
@ -109,21 +109,17 @@ void BatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool pare
return;
}
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
uint32_t flags = processParentFlags(parentTransform, parentFlags);
// IMPORTANT:
// To ease the migration to v3.0, we still support the Mat4 stack,
// but it is deprecated and your code should not rely on it
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
sortAllChildren();
draw(renderer, _modelViewTransform, dirty);
draw(renderer, _modelViewTransform, flags);
// reset for next frame
_orderOfArrival = 0;
@ -131,7 +127,7 @@ void BatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool pare
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
}
void BatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void BatchNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
if (_children.empty())
{
@ -152,14 +148,14 @@ void BatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUp
pushed = true;
}
armature->visit(renderer, transform, transformUpdated);
armature->visit(renderer, transform, flags);
}
else
{
renderer->popGroup();
pushed = false;
((Node *)object)->visit(renderer, transform, transformUpdated);
((Node *)object)->visit(renderer, transform, flags);
}
}
}

Просмотреть файл

@ -56,8 +56,8 @@ public:
virtual void addChild(cocos2d::Node *pChild, int zOrder) override;
virtual void addChild(cocos2d::Node *pChild, int zOrder, int tag) override;
virtual void removeChild(cocos2d::Node* child, bool cleanup) override;
virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override;
virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, uint32_t parentFlags) override;
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override;
protected:
void generateGroupCommand();

Просмотреть файл

@ -219,7 +219,7 @@ Mat4 Skin::getNodeToWorldTransformAR() const
return TransformConcat( _bone->getArmature()->getNodeToWorldTransform(),displayTransform);
}
void Skin::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void Skin::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
Mat4 mv = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);

Просмотреть файл

@ -54,7 +54,7 @@ public:
cocos2d::Mat4 getNodeToWorldTransform() const override;
cocos2d::Mat4 getNodeToWorldTransformAR() const;
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override;
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override;
/**
* @js NA

Просмотреть файл

@ -125,15 +125,15 @@ void Skeleton::update (float deltaTime) {
spSkeleton_update(skeleton, deltaTime * timeScale);
}
void Skeleton::draw(cocos2d::Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void Skeleton::draw(cocos2d::Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void Skeleton::onDraw(const Mat4 &transform, bool transformUpdated)
void Skeleton::onDraw(const Mat4 &transform, uint32_t flags)
{
getGLProgram()->use();
getGLProgram()->setUniformsForBuiltins(transform);

Просмотреть файл

@ -67,8 +67,8 @@ public:
virtual ~Skeleton ();
virtual void update (float deltaTime) override;
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override;
void onDraw(const cocos2d::Mat4 &transform, bool transformUpdated);
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override;
void onDraw(const cocos2d::Mat4 &transform, uint32_t flags);
void onEnter() override;
void onExit() override;
virtual cocos2d::Rect getBoundingBox () const override;

Просмотреть файл

@ -45,7 +45,7 @@ void GLNode::draw(Renderer *renderer, const cocos2d::Mat4& transform, bool trans
renderer->addCommand(&_renderCmd);
}
void GLNode::onDraw(const cocos2d::Mat4 &transform, bool transformUpdated)
void GLNode::onDraw(const cocos2d::Mat4 &transform, uint32_t flags)
{
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::GL_NODE_DRAW);
if (0 != handler)

Просмотреть файл

@ -42,7 +42,7 @@ public:
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4& transform, bool transformUpdated) override;
protected:
cocos2d::CustomCommand _renderCmd;
void onDraw(const cocos2d::Mat4 &transform, bool transformUpdated);
void onDraw(const cocos2d::Mat4 &transform, uint32_t flags);
};
TOLUA_API int tolua_opengl_open(lua_State* tolua_S);

Просмотреть файл

@ -268,7 +268,7 @@ void ProtectedNode::reorderProtectedChild(cocos2d::Node *child, int localZOrder)
child->_setLocalZOrder(localZOrder);
}
void ProtectedNode::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void ProtectedNode::visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
// quick return if not visible. children won't be drawn.
if (!_visible)
@ -276,11 +276,7 @@ void ProtectedNode::visit(Renderer* renderer, const Mat4 &parentTransform, bool
return;
}
bool dirty = _transformUpdated || parentTransformUpdated;
if(dirty)
_modelViewTransform = this->transform(parentTransform);
_transformUpdated = false;
uint32_t flags = processParentFlags(parentTransform, parentFlags);
// IMPORTANT:
// To ease the migration to v3.0, we still support the Mat4 stack,
@ -304,7 +300,7 @@ void ProtectedNode::visit(Renderer* renderer, const Mat4 &parentTransform, bool
auto node = _children.at(i);
if ( node && node->getLocalZOrder() < 0 )
node->visit(renderer, _modelViewTransform, dirty);
node->visit(renderer, _modelViewTransform, flags);
else
break;
}
@ -314,7 +310,7 @@ void ProtectedNode::visit(Renderer* renderer, const Mat4 &parentTransform, bool
auto node = _protectedChildren.at(j);
if ( node && node->getLocalZOrder() < 0 )
node->visit(renderer, _modelViewTransform, dirty);
node->visit(renderer, _modelViewTransform, flags);
else
break;
}
@ -322,16 +318,16 @@ void ProtectedNode::visit(Renderer* renderer, const Mat4 &parentTransform, bool
//
// draw self
//
this->draw(renderer, _modelViewTransform, dirty);
this->draw(renderer, _modelViewTransform, flags);
//
// draw children and protectedChildren zOrder >= 0
//
for(auto it=_protectedChildren.cbegin()+j; it != _protectedChildren.cend(); ++it)
(*it)->visit(renderer, _modelViewTransform, dirty);
(*it)->visit(renderer, _modelViewTransform, flags);
for(auto it=_children.cbegin()+i; it != _children.cend(); ++it)
(*it)->visit(renderer, _modelViewTransform, dirty);
(*it)->visit(renderer, _modelViewTransform, flags);
// reset for next frame
_orderOfArrival = 0;

Просмотреть файл

@ -127,7 +127,7 @@ public:
/// @} end of Children and Parent
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool transformUpdated) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
virtual void cleanup() override;

Просмотреть файл

@ -183,7 +183,7 @@ bool Layout::isClippingEnabled()const
return _clippingEnabled;
}
void Layout::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void Layout::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
if (!_visible)
{
@ -195,10 +195,10 @@ void Layout::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentT
switch (_clippingType)
{
case ClippingType::STENCIL:
stencilClippingVisit(renderer, parentTransform, parentTransformUpdated);
stencilClippingVisit(renderer, parentTransform, parentFlags);
break;
case ClippingType::SCISSOR:
scissorClippingVisit(renderer, parentTransform, parentTransformUpdated);
scissorClippingVisit(renderer, parentTransform, parentFlags);
break;
default:
break;
@ -206,7 +206,7 @@ void Layout::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentT
}
else
{
ProtectedNode::visit(renderer, parentTransform, parentTransformUpdated);
ProtectedNode::visit(renderer, parentTransform, parentFlags);
}
doLayout();
}
@ -217,15 +217,12 @@ void Layout::sortAllChildren()
doLayout();
}
void Layout::stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void Layout::stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
if(!_visible)
return;
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = transform(parentTransform);
_transformUpdated = false;
uint32_t flags = processParentFlags(parentTransform, parentFlags);
// IMPORTANT:
// To ease the migration to v3.0, we still support the Mat4 stack,
@ -245,7 +242,7 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransfor
_beforeVisitCmdStencil.func = CC_CALLBACK_0(Layout::onBeforeVisitStencil, this);
renderer->addCommand(&_beforeVisitCmdStencil);
_clippingStencil->visit(renderer, _modelViewTransform, dirty);
_clippingStencil->visit(renderer, _modelViewTransform, flags);
_afterDrawStencilCmd.init(_globalZOrder);
_afterDrawStencilCmd.func = CC_CALLBACK_0(Layout::onAfterDrawStencil, this);
@ -265,7 +262,7 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransfor
auto node = _children.at(i);
if ( node && node->getLocalZOrder() < 0 )
node->visit(renderer, _modelViewTransform, dirty);
node->visit(renderer, _modelViewTransform, flags);
else
break;
}
@ -275,7 +272,7 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransfor
auto node = _protectedChildren.at(j);
if ( node && node->getLocalZOrder() < 0 )
node->visit(renderer, _modelViewTransform, dirty);
node->visit(renderer, _modelViewTransform, flags);
else
break;
}
@ -283,16 +280,16 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransfor
//
// draw self
//
this->draw(renderer, _modelViewTransform, dirty);
this->draw(renderer, _modelViewTransform, flags);
//
// draw children and protectedChildren zOrder >= 0
//
for(auto it=_protectedChildren.cbegin()+j; it != _protectedChildren.cend(); ++it)
(*it)->visit(renderer, _modelViewTransform, dirty);
(*it)->visit(renderer, _modelViewTransform, flags);
for(auto it=_children.cbegin()+i; it != _children.cend(); ++it)
(*it)->visit(renderer, _modelViewTransform, dirty);
(*it)->visit(renderer, _modelViewTransform, flags);
_afterVisitCmdStencil.init(_globalZOrder);
@ -375,13 +372,13 @@ void Layout::onAfterVisitScissor()
glDisable(GL_SCISSOR_TEST);
}
void Layout::scissorClippingVisit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated)
void Layout::scissorClippingVisit(Renderer *renderer, const Mat4& parentTransform, uint32_t parentFlags)
{
_beforeVisitCmdScissor.init(_globalZOrder);
_beforeVisitCmdScissor.func = CC_CALLBACK_0(Layout::onBeforeVisitScissor, this);
renderer->addCommand(&_beforeVisitCmdScissor);
ProtectedNode::visit(renderer, parentTransform, parentTransformUpdated);
ProtectedNode::visit(renderer, parentTransform, parentFlags);
_afterVisitCmdScissor.init(_globalZOrder);
_afterVisitCmdScissor.func = CC_CALLBACK_0(Layout::onAfterVisitScissor, this);

Просмотреть файл

@ -241,7 +241,7 @@ public:
*/
virtual void addChild(Node* child, int zOrder, int tag) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
virtual void removeChild(Node* child, bool cleanup = true) override;
@ -321,8 +321,8 @@ protected:
virtual void copySpecialProperties(Widget* model) override;
virtual void copyClonedWidgetChildren(Widget* model) override;
void stencilClippingVisit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated);
void scissorClippingVisit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated);
void stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags);
void scissorClippingVisit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags);
void setStencilClippingSize(const Size& size);
const Rect& getClippingRect();

Просмотреть файл

@ -447,12 +447,12 @@ void RichText::pushToContainer(cocos2d::Node *renderer)
_elementRenders[_elementRenders.size()-1]->pushBack(renderer);
}
void RichText::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void RichText::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
if (_enabled)
{
formatText();
Widget::visit(renderer, parentTransform, parentTransformUpdated);
Widget::visit(renderer, parentTransform, parentFlags);
}
}

Просмотреть файл

@ -102,7 +102,7 @@ public:
void pushBackElement(RichElement* element);
void removeElement(int index);
void removeElement(RichElement* element);
virtual void visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
void setVerticalSpace(float space);
virtual void setAnchorPoint(const Vec2 &pt);
virtual const Size& getVirtualRendererSize() const override;

Просмотреть файл

@ -312,7 +312,7 @@ void VideoPlayer::setURL(const std::string& videoUrl)
[((UIVideoViewWrapperIos*)_videoView) setURL:(int)_videoSource :_videoURL];
}
void VideoPlayer::draw(Renderer* renderer, const Mat4 &transform, bool transformUpdated)
void VideoPlayer::draw(Renderer* renderer, const Mat4 &transform, uint32_t flags)
{
cocos2d::ui::Widget::draw(renderer,transform,transformUpdated);

Просмотреть файл

@ -225,12 +225,12 @@ void Widget::onExit()
ProtectedNode::onExit();
}
void Widget::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void Widget::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
if (_visible)
{
adaptRenderers();
ProtectedNode::visit(renderer, parentTransform, parentTransformUpdated);
ProtectedNode::visit(renderer, parentTransform, parentFlags);
}
}

Просмотреть файл

@ -237,7 +237,7 @@ public:
*/
virtual Widget* getChildByName(const std::string& name) const;
virtual void visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
/**
* Sets the touch event target/selector of the menu item

Просмотреть файл

@ -764,14 +764,14 @@ void Scale9Sprite::setInsetBottom(float insetBottom)
this->updateCapInset();
}
void Scale9Sprite::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void Scale9Sprite::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
if(this->_positionsAreDirty)
{
this->updatePositions();
this->_positionsAreDirty = false;
}
Node::visit(renderer, parentTransform, parentTransformUpdated);
Node::visit(renderer, parentTransform, parentFlags);
}
void Scale9Sprite::setColor(const Color3B& color)

Просмотреть файл

@ -261,7 +261,7 @@ public:
* @js NA
* @lua NA
*/
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
virtual void setOpacityModifyRGB(bool bValue) override;
virtual bool isOpacityModifyRGB(void) const override;
virtual void setOpacity(GLubyte opacity) override;

Просмотреть файл

@ -318,9 +318,9 @@ void EditBox::setAnchorPoint(const Vec2& anchorPoint)
}
}
void EditBox::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void EditBox::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
ControlButton::visit(renderer, parentTransform, parentTransformUpdated);
ControlButton::visit(renderer, parentTransform, parentFlags);
if (_editBoxImpl != NULL)
{
_editBoxImpl->visit();

Просмотреть файл

@ -379,7 +379,7 @@ public:
* @js NA
* @lua NA
*/
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
/**
* @js NA
* @lua NA

Просмотреть файл

@ -553,7 +553,7 @@ void ScrollView::onAfterDraw()
}
}
void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
// quick return if not visible
if (!isVisible())
@ -561,10 +561,7 @@ void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, bool par
return;
}
bool dirty = parentTransformUpdated || _transformUpdated;
if(dirty)
_modelViewTransform = this->transform(parentTransform);
_transformUpdated = false;
uint32_t flags = processParentFlags(parentTransform, parentFlags);
// IMPORTANT:
// To ease the migration to v3.0, we still support the Mat4 stack,
@ -586,7 +583,7 @@ void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, bool par
Node *child = _children.at(i);
if ( child->getLocalZOrder() < 0 )
{
child->visit(renderer, _modelViewTransform, dirty);
child->visit(renderer, _modelViewTransform, flags);
}
else
{
@ -595,19 +592,19 @@ void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, bool par
}
// this draw
this->draw(renderer, _modelViewTransform, dirty);
this->draw(renderer, _modelViewTransform, flags);
// draw children zOrder >= 0
for( ; i < _children.size(); i++ )
{
Node *child = _children.at(i);
child->visit(renderer, _modelViewTransform, dirty);
child->visit(renderer, _modelViewTransform, flags);
}
}
else
{
this->draw(renderer, _modelViewTransform, dirty);
this->draw(renderer, _modelViewTransform, flags);
}
this->afterDraw();

Просмотреть файл

@ -225,7 +225,7 @@ public:
* @js NA
* @lua NA
*/
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
using Node::addChild;
virtual void addChild(Node * child, int zOrder, int tag) override;

Просмотреть файл

@ -182,7 +182,7 @@ static void DrawConstraint(cpConstraint *constraint, DrawNode *renderer)
// implementation of PhysicsDebugNode
void PhysicsDebugNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void PhysicsDebugNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
if (! _spacePtr)
{
@ -195,7 +195,7 @@ void PhysicsDebugNode::draw(Renderer *renderer, const Mat4 &transform, bool tran
cpSpaceEachShape(_spacePtr, (cpSpaceShapeIteratorFunc)DrawShape, this);
cpSpaceEachConstraint(_spacePtr, (cpSpaceConstraintIteratorFunc)DrawConstraint, this);
DrawNode::draw(renderer, transform, transformUpdated);
DrawNode::draw(renderer, transform, flags);
#endif
}

Просмотреть файл

@ -61,7 +61,7 @@ public:
void setSpace(cpSpace *space);
// Overrides
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
protected:
cpSpace *_spacePtr;

Просмотреть файл

@ -397,14 +397,14 @@ const Mat4& PhysicsSprite::getNodeToParentTransform() const
return _transform;
}
void PhysicsSprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void PhysicsSprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
if (isDirty())
{
syncPhysicsTransform();
}
Sprite::draw(renderer, _transform, transformUpdated);
Sprite::draw(renderer, _transform, flags);
}
NS_CC_EXT_END

Просмотреть файл

@ -116,7 +116,7 @@ public:
virtual void syncPhysicsTransform() const;
virtual const Mat4& getNodeToParentTransform() const override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
protected:
const Vec2& getPosFromPhysics() const;

Просмотреть файл

@ -1350,15 +1350,15 @@ void ActionFollow::onEnter()
this->runAction(Follow::create(_grossini, Rect(0, 0, s.width * 2 - 100, s.height)));
}
void ActionFollow::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void ActionFollow::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ActionFollow::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(ActionFollow::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void ActionFollow::onDraw(const Mat4 &transform, bool transformUpdated)
void ActionFollow::onDraw(const Mat4 &transform, uint32_t flags)
{
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
@ -1664,9 +1664,9 @@ ActionCatmullRomStacked::~ActionCatmullRomStacked()
CC_SAFE_RELEASE(_array2);
}
void ActionCatmullRomStacked::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void ActionCatmullRomStacked::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
ActionsDemo::draw(renderer, transform, transformUpdated);
ActionsDemo::draw(renderer, transform, flags);
// move to 50,50 since the "by" path will start at 50,50
Director* director = Director::getInstance();
@ -1684,11 +1684,11 @@ void ActionCatmullRomStacked::draw(Renderer *renderer, const Mat4 &transform, bo
_modelViewMV2 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void ActionCatmullRomStacked::onDraw(const Mat4 &transform, bool transformUpdated)
void ActionCatmullRomStacked::onDraw(const Mat4 &transform, uint32_t flags)
{
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
@ -1784,9 +1784,9 @@ ActionCardinalSplineStacked::~ActionCardinalSplineStacked()
CC_SAFE_RELEASE(_array);
}
void ActionCardinalSplineStacked::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void ActionCardinalSplineStacked::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
ActionsDemo::draw(renderer, transform, transformUpdated);
ActionsDemo::draw(renderer, transform, flags);
// move to 50,50 since the "by" path will start at 50,50
Director* director = Director::getInstance();
@ -1814,11 +1814,11 @@ void ActionCardinalSplineStacked::draw(Renderer *renderer, const Mat4 &transform
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ActionCardinalSplineStacked::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(ActionCardinalSplineStacked::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void ActionCardinalSplineStacked::onDraw(const Mat4 &transform, bool transformUpdated)
void ActionCardinalSplineStacked::onDraw(const Mat4 &transform, uint32_t flags)
{
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
@ -2198,9 +2198,9 @@ ActionCatmullRom::~ActionCatmullRom()
_array2->release();
}
void ActionCatmullRom::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void ActionCatmullRom::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
ActionsDemo::draw(renderer, transform, transformUpdated);
ActionsDemo::draw(renderer, transform, flags);
// move to 50,50 since the "by" path will start at 50,50
Director* director = Director::getInstance();
@ -2218,12 +2218,12 @@ void ActionCatmullRom::draw(Renderer *renderer, const Mat4 &transform, bool tran
_modelViewMV2 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void ActionCatmullRom::onDraw(const Mat4 &transform, bool transformUpdated)
void ActionCatmullRom::onDraw(const Mat4 &transform, uint32_t flags)
{
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
@ -2303,9 +2303,9 @@ ActionCardinalSpline::~ActionCardinalSpline()
_array->release();
}
void ActionCardinalSpline::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void ActionCardinalSpline::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
ActionsDemo::draw(renderer, transform, transformUpdated);
ActionsDemo::draw(renderer, transform, flags);
// move to 50,50 since the "by" path will start at 50,50
Director* director = Director::getInstance();
@ -2331,11 +2331,11 @@ void ActionCardinalSpline::draw(Renderer *renderer, const Mat4 &transform, bool
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(ActionCardinalSpline::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(ActionCardinalSpline::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void ActionCardinalSpline::onDraw(const Mat4 &transform, bool transformUpdated)
void ActionCardinalSpline::onDraw(const Mat4 &transform, uint32_t flags)
{
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");

Просмотреть файл

@ -379,11 +379,11 @@ public:
CREATE_FUNC(ActionFollow);
virtual void onEnter() override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual std::string subtitle() const override;
protected:
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
CustomCommand _customCommand;
};
@ -454,13 +454,13 @@ public:
CREATE_FUNC(ActionCatmullRomStacked);
virtual ~ActionCatmullRomStacked();
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
//cached data and callback
Mat4 _modelViewMV1;
@ -476,13 +476,13 @@ public:
CREATE_FUNC(ActionCardinalSplineStacked);
virtual ~ActionCardinalSplineStacked();
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated);
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags);
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
Mat4 _modelViewMV1;
Mat4 _modelViewMV2;
@ -584,12 +584,12 @@ public:
~ActionCatmullRom();
virtual void onEnter() override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual std::string subtitle() const override;
virtual std::string title() const override;
protected:
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
Mat4 _modelViewMV1;
Mat4 _modelViewMV2;
@ -606,12 +606,12 @@ public:
~ActionCardinalSpline();
virtual void onEnter() override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual std::string subtitle() const override;
virtual std::string title() const override;
protected:
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
PointArray *_array;
Mat4 _modelViewMV1;

Просмотреть файл

@ -137,14 +137,14 @@ void Box2DTestLayer::createResetButton()
}
void Box2DTestLayer::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void Box2DTestLayer::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
//
// IMPORTANT:
// This is only for debug purposes
// It is recommend to disable it
//
Layer::draw(renderer, transform, transformUpdated);
Layer::draw(renderer, transform, flags);
#if CC_ENABLE_BOX2D_INTEGRATION
GL::enableVertexAttribs( cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION );

Просмотреть файл

@ -17,7 +17,7 @@ public:
void initPhysics();
void createResetButton();
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
void addNewSpriteAtPosition(Vec2 p);
void update(float dt);

Просмотреть файл

@ -202,16 +202,16 @@ std::string Box2DView::title() const
return std::string(m_entry->name);
}
void Box2DView::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void Box2DView::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
Layer::draw(renderer, transform, transformUpdated);
Layer::draw(renderer, transform, flags);
_customCmd.init(_globalZOrder);
_customCmd.func = CC_CALLBACK_0(Box2DView::onDraw, this, transform, transformUpdated);
_customCmd.func = CC_CALLBACK_0(Box2DView::onDraw, this, transform, flags);
renderer->addCommand(&_customCmd);
}
void Box2DView::onDraw(const Mat4 &transform, bool transformUpdated)
void Box2DView::onDraw(const Mat4 &transform, uint32_t flags)
{
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");

Просмотреть файл

@ -42,7 +42,7 @@ public:
bool initWithEntryID(int entryId);
std::string title() const;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
// virtual void registerWithTouchDispatcher();
bool onTouchBegan(Touch* touch, Event* event);
@ -55,7 +55,7 @@ public:
static Box2DView* viewWithEntryID(int entryId);
protected:
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
CustomCommand _customCmd;
};

Просмотреть файл

@ -601,7 +601,7 @@ void RawStencilBufferTest::setup()
Director::getInstance()->setAlphaBlending(true);
}
void RawStencilBufferTest::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void RawStencilBufferTest::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
auto winPoint = Vec2(Director::getInstance()->getWinSize());
@ -641,7 +641,7 @@ void RawStencilBufferTest::draw(Renderer *renderer, const Mat4 &transform, bool
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_modelViewTransform = this->transform(transform);
_spritesStencil.at(i)->visit(renderer, _modelViewTransform, transformUpdated);
_spritesStencil.at(i)->visit(renderer, _modelViewTransform, flags);
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
iter->init(_globalZOrder);
@ -651,7 +651,7 @@ void RawStencilBufferTest::draw(Renderer *renderer, const Mat4 &transform, bool
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
_modelViewTransform = this->transform(transform);
_sprites.at(i)->visit(renderer, _modelViewTransform, transformUpdated);
_sprites.at(i)->visit(renderer, _modelViewTransform, flags);
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
}

Просмотреть файл

@ -153,7 +153,7 @@ public:
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void setup();
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual void setupStencilForClippingOnPlane(GLint plane);
virtual void setupStencilForDrawingOnPlane(GLint plane);

Просмотреть файл

@ -114,17 +114,16 @@ DrawPrimitivesTest::DrawPrimitivesTest()
{
}
void DrawPrimitivesTest::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void DrawPrimitivesTest::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void DrawPrimitivesTest::onDraw(const Mat4 &transform, bool transformUpdated)
void DrawPrimitivesTest::onDraw(const Mat4 &transform, uint32_t flags)
{
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform);

Просмотреть файл

@ -27,10 +27,10 @@ public:
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
protected:
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
CustomCommand _customCommand;
};

Просмотреть файл

@ -842,7 +842,7 @@ void TestColliderDetector::onExit()
ArmatureTestLayer::onExit();
}
void TestColliderDetector::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void TestColliderDetector::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
Director* director = Director::getInstance();
@ -1065,14 +1065,14 @@ void TestColliderDetector::update(float delta)
}
}
}
void TestColliderDetector::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void TestColliderDetector::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(TestColliderDetector::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(TestColliderDetector::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void TestColliderDetector::onDraw(const Mat4 &transform, bool transformUpdated)
void TestColliderDetector::onDraw(const Mat4 &transform, uint32_t flags)
{
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
@ -1106,15 +1106,15 @@ std::string TestBoundingBox::title() const
{
return "Test BoundingBox";
}
void TestBoundingBox::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void TestBoundingBox::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(TestBoundingBox::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(TestBoundingBox::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void TestBoundingBox::onDraw(const Mat4 &transform, bool transformUpdated)
void TestBoundingBox::onDraw(const Mat4 &transform, uint32_t flags)
{
getGLProgram()->use();
getGLProgram()->setUniformsForBuiltins(transform);

Просмотреть файл

@ -211,7 +211,7 @@ public:
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual void update(float delta);
void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex);
@ -270,8 +270,8 @@ public:
virtual void onEnter() override;
virtual std::string title() const override;
virtual void update(float delta);
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
void onDraw(const Mat4 &transform, bool transformUpdated);
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
void onDraw(const Mat4 &transform, uint32_t flags);
void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex);
@ -293,13 +293,13 @@ class TestBoundingBox : public ArmatureTestLayer
public:
virtual void onEnter() override;
virtual std::string title() const override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
cocostudio::Armature *armature;
Rect rect;
protected:
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
CustomCommand _customCommand;
};

Просмотреть файл

@ -194,9 +194,9 @@ void SceneEditorTestLayer::backCallback(Ref *pSender)
s->release();
}
void SceneEditorTestLayer::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void SceneEditorTestLayer::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
Layer::draw(renderer, transform, transformUpdated);
Layer::draw(renderer, transform, flags);
}

Просмотреть файл

@ -43,7 +43,7 @@ public:
virtual void nextCallback(cocos2d::Ref* pSender);
virtual void backCallback(cocos2d::Ref* pSender);
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
protected:
MenuItemImage *restartItem;

Просмотреть файл

@ -2,9 +2,9 @@
USING_NS_CC;
void CustomTableViewCell::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void CustomTableViewCell::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
TableViewCell::draw(renderer, transform, transformUpdated);
TableViewCell::draw(renderer, transform, flags);
// draw bounding box
// auto pos = getPosition();
// auto size = Size(178, 200);

Просмотреть файл

@ -7,7 +7,7 @@
class CustomTableViewCell : public cocos2d::extension::TableViewCell
{
public:
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override;
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override;
};
#endif /* __CUSTOMTABELVIEWCELL_H__ */

Просмотреть файл

@ -213,14 +213,14 @@ Atlas1::~Atlas1()
_textureAtlas->release();
}
void Atlas1::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void Atlas1::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(Atlas1::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(Atlas1::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void Atlas1::onDraw(const Mat4 &transform, bool transformUpdated)
void Atlas1::onDraw(const Mat4 &transform, uint32_t flags)
{
getGLProgram()->use();
getGLProgram()->setUniformsForBuiltins(transform);
@ -532,14 +532,14 @@ Atlas4::Atlas4()
schedule( schedule_selector(Atlas4::step), 0.1f);
}
void Atlas4::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void Atlas4::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(Atlas4::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(Atlas4::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void Atlas4::onDraw(const Mat4 &transform, bool transformUpdated)
void Atlas4::onDraw(const Mat4 &transform, uint32_t flags)
{
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
@ -1660,14 +1660,14 @@ std::string LabelBMFontBounds::subtitle() const
return "You should see string enclosed by a box";
}
void LabelBMFontBounds::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void LabelBMFontBounds::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void LabelBMFontBounds::onDraw(const Mat4 &transform, bool transformUpdated)
void LabelBMFontBounds::onDraw(const Mat4 &transform, uint32_t flags)
{
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");

Просмотреть файл

@ -41,9 +41,9 @@ public:
~Atlas1();
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
protected:
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
protected:
CustomCommand _customCommand;
};
@ -108,12 +108,12 @@ public:
Atlas4();
virtual void step(float dt);
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
protected:
CustomCommand _customCommand;
};
@ -383,11 +383,11 @@ public:
LabelBMFontBounds();
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
private:
LabelBMFont *label1;
CustomCommand _customCommand;

Просмотреть файл

@ -309,15 +309,15 @@ LabelFNTSpriteActions::LabelFNTSpriteActions()
schedule( schedule_selector(LabelFNTSpriteActions::step), 0.1f);
}
void LabelFNTSpriteActions::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void LabelFNTSpriteActions::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_renderCmd.init(_globalZOrder);
_renderCmd.func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this, transform, transformUpdated);
_renderCmd.func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this, transform, flags);
renderer->addCommand(&_renderCmd);
}
void LabelFNTSpriteActions::onDraw(const Mat4 &transform, bool transformUpdated)
void LabelFNTSpriteActions::onDraw(const Mat4 &transform, uint32_t flags)
{
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
@ -908,14 +908,14 @@ std::string LabelFNTBounds::subtitle() const
return "You should see string enclosed by a box";
}
void LabelFNTBounds::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void LabelFNTBounds::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_renderCmd.init(_globalZOrder);
_renderCmd.func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this, transform, transformUpdated);
_renderCmd.func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this, transform, flags);
renderer->addCommand(&_renderCmd);
}
void LabelFNTBounds::onDraw(const Mat4 &transform, bool transformUpdated)
void LabelFNTBounds::onDraw(const Mat4 &transform, uint32_t flags)
{
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
@ -1533,7 +1533,7 @@ LabelTTFOldNew::LabelTTFOldNew()
label2->setPosition(Vec2(s.width/2, delta * 2));
}
void LabelTTFOldNew::onDraw(const Mat4 &transform, bool transformUpdated)
void LabelTTFOldNew::onDraw(const Mat4 &transform, uint32_t flags)
{
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
@ -1577,10 +1577,10 @@ void LabelTTFOldNew::onDraw(const Mat4 &transform, bool transformUpdated)
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
}
void LabelTTFOldNew::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void LabelTTFOldNew::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_renderCmd.init(_globalZOrder);
_renderCmd.func = CC_CALLBACK_0(LabelTTFOldNew::onDraw, this, transform, transformUpdated);
_renderCmd.func = CC_CALLBACK_0(LabelTTFOldNew::onDraw, this, transform, flags);
renderer->addCommand(&_renderCmd);
}

Просмотреть файл

@ -58,14 +58,14 @@ public:
LabelFNTSpriteActions();
virtual void step(float dt);
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:
CustomCommand _renderCmd;
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
};
class LabelFNTPadding : public AtlasDemoNew
@ -224,13 +224,13 @@ public:
LabelFNTBounds();
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:
CustomCommand _renderCmd;
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
Label *label1;
};
@ -430,14 +430,14 @@ public:
LabelTTFOldNew();
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:
CustomCommand _renderCmd;
void onDraw(const Mat4 &transform, bool transformUpdated);
void onDraw(const Mat4 &transform, uint32_t flags);
};
class LabelTTFLargeText : public AtlasDemoNew

Просмотреть файл

@ -17,7 +17,7 @@ public:
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
}
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
DrawPrimitives::setDrawColor4B(_touchColor.r, _touchColor.g, _touchColor.b, 255);
glLineWidth(10);

Просмотреть файл

@ -231,7 +231,7 @@ protected:
public:
static SpriteInGroupCommand* create(const std::string& filename);
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
};
SpriteInGroupCommand* SpriteInGroupCommand::create(const std::string &filename)
@ -242,13 +242,13 @@ SpriteInGroupCommand* SpriteInGroupCommand::create(const std::string &filename)
return sprite;
}
void SpriteInGroupCommand::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void SpriteInGroupCommand::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
CCASSERT(renderer, "Render is null");
_spriteWrapperCommand.init(_globalZOrder);
renderer->addCommand(&_spriteWrapperCommand);
renderer->pushGroup(_spriteWrapperCommand.getRenderQueueID());
Sprite::draw(renderer, transform, transformUpdated);
Sprite::draw(renderer, transform, flags);
renderer->popGroup();
}

Просмотреть файл

@ -72,6 +72,8 @@ static std::function<Layer*()> createFunctions[] =
CL(NodeOpaqueTest),
CL(NodeNonOpaqueTest),
CL(NodeGlobalZValueTest),
CL(NodeNormalizedPositionTest1),
CL(NodeNormalizedPositionTest2),
};
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
@ -993,22 +995,22 @@ public:
sprite->setGLProgramState(shaderState);
return sprite;
}
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
void onDraw(const Mat4 &transform, bool transformUpdated);
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
void onDraw(const Mat4 &transform, uint32_t flags);
protected:
CustomCommand _customCommand;
};
void MySprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
void MySprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this, transform, transformUpdated);
_customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void MySprite::onDraw(const Mat4 &transform, bool transformUpdated)
void MySprite::onDraw(const Mat4 &transform, uint32_t flags)
{
getGLProgram()->use();
getGLProgram()->setUniformsForBuiltins(transform);
@ -1087,6 +1089,7 @@ std::string CameraTest1::subtitle() const
{
return "Both images should rotate with a 3D effect";
}
//------------------------------------------------------------------
//
// CameraTest2
@ -1143,6 +1146,81 @@ std::string CameraTest2::subtitle() const
return "Both images should look the same";
}
//------------------------------------------------------------------
//
// NodeNormalizedPositionTest1
//
//------------------------------------------------------------------
NodeNormalizedPositionTest1::NodeNormalizedPositionTest1()
{
Sprite *sprites[5];
Vec2 positions[] = { {0,0}, {0,1}, {0.5,0.5}, {1,0}, {1,1} };
for(int i=0; i<5; i++) {
sprites[i] = Sprite::create("Images/grossini.png");
sprites[i]->setNormalizedPosition(positions[i]);
addChild(sprites[i]);
}
}
std::string NodeNormalizedPositionTest1::title() const
{
return "setNormalizedPositon()";
}
std::string NodeNormalizedPositionTest1::subtitle() const
{
return "5 sprites: One in the center, the others on the corners";
}
//------------------------------------------------------------------
//
// NodeNormalizedPositionTest2
//
//------------------------------------------------------------------
NodeNormalizedPositionTest2::NodeNormalizedPositionTest2()
: _accum(0)
{
Sprite *sprites[5];
Vec2 positions[] = { {0,0}, {0,1}, {0.5,0.5}, {1,0}, {1,1} };
for(int i=0; i<5; i++) {
sprites[i] = Sprite::create("Images/grossini.png");
sprites[i]->setNormalizedPosition(positions[i]);
addChild(sprites[i]);
}
scheduleUpdate();
setContentSize( Director::getInstance()->getWinSize());
_copyContentSize = getContentSize();
// setAnchorPoint(Vec2(0.5,0.5));
// setNormalizedPosition(Vec2(0.5,0.5));
}
std::string NodeNormalizedPositionTest2::title() const
{
return "setNormalizedPositon() #2";
}
std::string NodeNormalizedPositionTest2::subtitle() const
{
return "5 sprites: One in the center, the others on the corners of its parents";
}
void NodeNormalizedPositionTest2::update(float dt)
{
_accum += dt;
// for 5 seconds
float norm = sinf(_accum);
Size s = Size(_copyContentSize.width*norm, _copyContentSize.height*norm);
setContentSize(s);
CCLOG("s: %f,%f", s.width, s.height);
}
///
/// main
///

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше