remove sortChildren of Layout

This commit is contained in:
andyque 2014-06-03 18:31:14 +08:00
parent 2d866de146
commit 652c214374
2 changed files with 17 additions and 10 deletions

View File

@ -189,7 +189,10 @@ void Layout::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentT
{ {
return; return;
} }
doLayout();
adaptRenderers(); adaptRenderers();
if (_clippingEnabled) if (_clippingEnabled)
{ {
switch (_clippingType) switch (_clippingType)
@ -208,15 +211,9 @@ void Layout::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentT
{ {
ProtectedNode::visit(renderer, parentTransform, parentTransformUpdated); ProtectedNode::visit(renderer, parentTransform, parentTransformUpdated);
} }
doLayout();
}
void Layout::sortAllChildren()
{
Widget::sortAllChildren();
doLayout();
} }
void Layout::stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) void Layout::stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
{ {
if(!_visible) if(!_visible)
@ -327,10 +324,20 @@ void Layout::onBeforeVisitStencil()
glStencilFunc(GL_NEVER, mask_layer, mask_layer); glStencilFunc(GL_NEVER, mask_layer, mask_layer);
glStencilOp(GL_ZERO, GL_KEEP, GL_KEEP); glStencilOp(GL_ZERO, GL_KEEP, GL_KEEP);
this->drawFullScreenQuadClearStencil();
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP);
}
void Layout::drawFullScreenQuadClearStencil()
{
Director* director = Director::getInstance(); Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack"); CCASSERT(nullptr != director, "Director is null when seting matrix stack");
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
@ -338,8 +345,6 @@ void Layout::onBeforeVisitStencil()
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
glStencilFunc(GL_NEVER, mask_layer, mask_layer);
glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP);
} }
void Layout::onAfterDrawStencil() void Layout::onAfterDrawStencil()

View File

@ -260,7 +260,6 @@ public:
*/ */
virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void sortAllChildren() override;
void requestDoLayout(); void requestDoLayout();
@ -336,6 +335,9 @@ protected:
void onBeforeVisitStencil(); void onBeforeVisitStencil();
void onAfterDrawStencil(); void onAfterDrawStencil();
void onAfterVisitStencil(); void onAfterVisitStencil();
/**draw fullscreen quad to clear stencil bits
*/
void drawFullScreenQuadClearStencil();
void onBeforeVisitScissor(); void onBeforeVisitScissor();
void onAfterVisitScissor(); void onAfterVisitScissor();