From dd6bb0b3eb72288295688d9cabba1ad4d8423fca Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 23 Oct 2014 10:18:09 +0800 Subject: [PATCH 01/26] Uses reference in for loop inside ccvector_std_string_to_luaval --- cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp index e8f82d9faa..634baf4e97 100644 --- a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp +++ b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp @@ -2922,7 +2922,7 @@ void ccvector_std_string_to_luaval(lua_State* L, const std::vector& int index = 1; - for (const std::string value : inValue) + for (const std::string& value : inValue) { lua_pushnumber(L, (lua_Number)index); lua_pushstring(L, value.c_str()); From 603700179e34bd8967900bb0402e34c7e7bea076 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 24 Oct 2014 12:03:11 +0800 Subject: [PATCH 02/26] closed #8843: Fixes DrawNode::drawPoint crash and uses VAO if it's available when draw points. --- cocos/2d/CCDrawNode.cpp | 36 +++++++++++++------ .../DrawPrimitivesTest/DrawPrimitivesTest.cpp | 4 +++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index eae022bea6..3edbe0bbac 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -346,9 +346,8 @@ void DrawNode::onDraw(const Mat4 &transform, uint32_t flags) // texcood glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); } - glBindBuffer(GL_ARRAY_BUFFER, _vbo); + glDrawArrays(GL_TRIANGLES, 0, _bufferCount); - glBindBuffer(GL_ARRAY_BUFFER, 0); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _bufferCount); CHECK_GL_ERROR_DEBUG(); @@ -382,9 +381,7 @@ void DrawNode::onDrawGLLine(const Mat4 &transform, uint32_t flags) glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); } glLineWidth(2); - glBindBuffer(GL_ARRAY_BUFFER, _vboGLLine); glDrawArrays(GL_LINES, 0, _bufferCountGLLine); - glBindBuffer(GL_ARRAY_BUFFER, 0); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_bufferCountGLLine); CHECK_GL_ERROR_DEBUG(); @@ -399,15 +396,28 @@ void DrawNode::onDrawGLPoint(const Mat4 &transform, uint32_t flags) glProgram->setUniformLocationWith4fv(glProgram->getUniformLocation("u_color"), (GLfloat*) &_pointColor.r, 1); glProgram->setUniformLocationWith1f(glProgram->getUniformLocation("u_pointSize"), _pointSize); - glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint); - glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLPoint, _bufferGLPoint, GL_STREAM_DRAW); - - GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); + if (_dirtyGLPoint) + { + glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint); + glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLPoint, _bufferGLPoint, GL_STREAM_DRAW); + + _dirtyGLPoint = false; + } + + if (Configuration::getInstance()->supportsShareableVAO()) + { + GL::bindVAO(_vaoGLPoint); + } + else + { + glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); + glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint); + } glDrawArrays(GL_POINTS, 0, _bufferCountGLPoint); - glBindBuffer(GL_ARRAY_BUFFER, 0); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_bufferCountGLPoint); CHECK_GL_ERROR_DEBUG(); @@ -415,6 +425,8 @@ void DrawNode::onDrawGLPoint(const Mat4 &transform, uint32_t flags) void DrawNode::drawPoint(const Vec2& position, const float pointSize, const Color4F &color) { + ensureCapacityGLPoint(1); + V2F_C4B_T2F *point = (V2F_C4B_T2F*)(_bufferGLPoint + _bufferCountGLPoint); V2F_C4B_T2F a = {position, Color4B(color), Tex2F(0.0, 0.0) }; *point = a; @@ -423,6 +435,7 @@ void DrawNode::drawPoint(const Vec2& position, const float pointSize, const Colo _pointColor = color; _bufferCountGLPoint += 1; + _dirtyGLPoint = true; } void DrawNode::drawPoints(const Vec2 *position, unsigned int numberOfPoints, const Color4F &color) @@ -440,6 +453,7 @@ void DrawNode::drawPoints(const Vec2 *position, unsigned int numberOfPoints, con _pointColor = color; _bufferCountGLPoint += numberOfPoints; + _dirtyGLPoint = true; } void DrawNode::drawLine(const Vec2 &origin, const Vec2 &destination, const Color4F &color) diff --git a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp index af4e47a407..b213915745 100644 --- a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -375,6 +375,10 @@ DrawNodeTest::DrawNodeTest() // Draw triangle draw->drawTriangle(Vec2(10, 10), Vec2(70, 30), Vec2(100, 140), Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + + for (int i = 0; i < 100; i++) { + draw->drawPoint(Vec2(i*7, 5), 5, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 1)); + } } string DrawNodeTest::title() const From 13b51f7c73cfa7070669be3ffc132566cd1f8e2f Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 24 Oct 2014 12:03:42 +0800 Subject: [PATCH 03/26] Small fixes in Sprite3DTest --- tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index 8e79b5b1f3..a282f2c15c 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -1259,7 +1259,7 @@ void Sprite3DWithOBBPerfromanceTest::addNewOBBWithCoords(Vec2 p) void Sprite3DWithOBBPerfromanceTest::onTouchesBegan(const std::vector& touches, Event* event) { - for (auto touch: touches) + for (const auto& touch: touches) { auto location = touch->getLocationInView(); auto obbSize = _obb.size(); @@ -1287,7 +1287,7 @@ void Sprite3DWithOBBPerfromanceTest::onTouchesEnded(const std::vector& t void Sprite3DWithOBBPerfromanceTest::onTouchesMoved(const std::vector& touches, Event* event) { - for (auto touch: touches) + for (const auto& touch: touches) { auto location = touch->getLocation(); auto obbSize = _obb.size(); @@ -1447,8 +1447,7 @@ void Sprite3DWithOBBPerfromanceTest::calculateRayByLocationInView(Ray* ray, cons { auto dir = Director::getInstance(); auto view = dir->getWinSize(); - Mat4 mat = dir->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - mat = dir->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); + Mat4 mat = dir->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); Vec3 src = Vec3(location.x, location.y, -1); Vec3 nearPoint; From 012683bf6ee34adf950a51d2e64189ae20ede34f Mon Sep 17 00:00:00 2001 From: Ahlwong Date: Thu, 23 Oct 2014 21:18:51 -0700 Subject: [PATCH 04/26] Fix kerning on signle characters --- cocos/2d/CCLabelTextFormatter.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cocos/2d/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp index 56bc1d55fe..358faca793 100644 --- a/cocos/2d/CCLabelTextFormatter.cpp +++ b/cocos/2d/CCLabelTextFormatter.cpp @@ -387,8 +387,13 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel) log("WARNING: can't find letter definition in font file for letter: %c", c); continue; } - - nextFontPositionX += charAdvance + kernings[i] + theLabel->_additionalKerning; + + nextFontPositionX += charAdvance + kernings[i]; + + // only apply kerning shift if string contains more than 1 character + if (stringLen > 1) { + nextFontPositionX += theLabel->_additionalKerning; + } if (longestLine < nextFontPositionX) { From 92bdfea6381d96b296ab2bcdbcd42f696de49fc6 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 24 Oct 2014 17:38:32 +0800 Subject: [PATCH 05/26] update ui button size changed logic --- cocos/ui/UIButton.cpp | 84 ++++++++++++++++++++++++++++--------------- cocos/ui/UIButton.h | 1 + 2 files changed, 56 insertions(+), 29 deletions(-) diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 93b16c8bce..1df7fd7f5d 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -194,16 +194,7 @@ void Button::ignoreContentAdaptWithSize(bool ignore) { if (_unifySize) { - if (_scale9Enabled) - { - ProtectedNode::setContentSize(_customSize); - } - else - { - Size s = getVirtualRendererSize(); - ProtectedNode::setContentSize(s); - } - onSizeChanged(); + this->updateContentSize(); return; } if (!_scale9Enabled || (_scale9Enabled && !ignore)) @@ -249,7 +240,17 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType) updateFlippedY(); this->updateChildrenDisplayedRGBA(); - updateContentSizeWithTextureSize(_normalTextureSize); + if (_unifySize ) + { + if (!_scale9Enabled) + { + updateContentSizeWithTextureSize(this->getNormalSize()); + } + } + else + { + updateContentSizeWithTextureSize(_normalTextureSize); + } _normalTextureLoaded = true; _normalTextureAdaptDirty = true; } @@ -532,9 +533,23 @@ void Button::updateTitleLocation() void Button::updateContentSize() { - if (_ignoreSize) { - this->setContentSize(getVirtualRendererSize()); - } + if (_unifySize) + { + if (_scale9Enabled) + { + ProtectedNode::setContentSize(_customSize); + } + else + { + Size s = getNormalSize(); + ProtectedNode::setContentSize(s); + } + onSizeChanged(); + return; + } + if (_ignoreSize) { + this->setContentSize(getVirtualRendererSize()); + } } void Button::onSizeChanged() @@ -596,11 +611,8 @@ Node* Button::getVirtualRenderer() void Button::normalTextureScaleChangedWithSize() { - if (_unifySize) - { - _buttonNormalRenderer->setPreferredSize(_contentSize); - } - else if (_ignoreSize) + + if (_ignoreSize && !_unifySize) { if (!_scale9Enabled) { @@ -638,11 +650,8 @@ void Button::normalTextureScaleChangedWithSize() void Button::pressedTextureScaleChangedWithSize() { - if (_unifySize) - { - _buttonClickedRenderer->setPreferredSize(_contentSize); - } - else if (_ignoreSize) + + if (_ignoreSize && !_unifySize) { if (!_scale9Enabled) { @@ -679,11 +688,8 @@ void Button::pressedTextureScaleChangedWithSize() void Button::disabledTextureScaleChangedWithSize() { - if (_unifySize) - { - _buttonDisableRenderer->setPreferredSize(_contentSize); - } - else if (_ignoreSize) + + if (_ignoreSize && !_unifySize) { if (!_scale9Enabled) { @@ -784,9 +790,11 @@ void Button::setTitleFontName(const std::string& fontName) { _titleRenderer->requestSystemFontRefresh(); } + _titleRenderer->setSystemFontSize(_fontSize); _type = FontType::SYSTEM; } _fontName = fontName; + this->updateContentSize(); } Label* Button::getTitleRenderer()const @@ -829,6 +837,24 @@ void Button::copySpecialProperties(Widget *widget) setPressedActionEnabled(button->_pressedActionEnabled); setZoomScale(button->_zoomScale); } + +} +Size Button::getNormalSize() +{ + Size titleSize; + if (_titleRenderer != nullptr) + { + titleSize = _titleRenderer->getContentSize(); + } + Size imageSize; + if (_buttonNormalRenderer != nullptr) + { + imageSize = _buttonNormalRenderer->getContentSize(); + } + float width = titleSize.width > imageSize.width ? titleSize.width : imageSize.width; + float height = titleSize.height > imageSize.height ? titleSize.height : imageSize.height; + + return Size(width,height); } } diff --git a/cocos/ui/UIButton.h b/cocos/ui/UIButton.h index 8f1c1b3bfa..6d3e611b6b 100644 --- a/cocos/ui/UIButton.h +++ b/cocos/ui/UIButton.h @@ -234,6 +234,7 @@ protected: virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; + virtual Size getNormalSize(); protected: Scale9Sprite* _buttonNormalRenderer; Scale9Sprite* _buttonClickedRenderer; From 0fb584ad9208c37ec2ae67e4543996f90dbf0330 Mon Sep 17 00:00:00 2001 From: Timothy Zhang Date: Fri, 24 Oct 2014 18:31:00 +0800 Subject: [PATCH 06/26] release old program with the same key before adding glprogram --- cocos/renderer/CCGLProgramCache.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cocos/renderer/CCGLProgramCache.cpp b/cocos/renderer/CCGLProgramCache.cpp index b81f00975c..963a700af0 100644 --- a/cocos/renderer/CCGLProgramCache.cpp +++ b/cocos/renderer/CCGLProgramCache.cpp @@ -432,9 +432,16 @@ GLProgram* GLProgramCache::getGLProgram(const std::string &key) void GLProgramCache::addGLProgram(GLProgram* program, const std::string &key) { + // release old one + auto prev = getProgram(key); + if( prev == program ) + return; + + _programs.erase(key); + CC_SAFE_RELEASE_NULL(prev); + if (program) - program->retain(); - + program->retain(); _programs[key] = program; } From bfe83e5624a39bb7957c99c3acfffcd226296974 Mon Sep 17 00:00:00 2001 From: teivaz Date: Fri, 24 Oct 2014 16:00:08 +0300 Subject: [PATCH 07/26] * [WP8] Enabled GLProgramState restoring on render recreated --- cocos/renderer/CCGLProgramState.cpp | 4 ++-- cocos/renderer/CCGLProgramState.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos/renderer/CCGLProgramState.cpp b/cocos/renderer/CCGLProgramState.cpp index 8955adddc3..7025992f61 100644 --- a/cocos/renderer/CCGLProgramState.cpp +++ b/cocos/renderer/CCGLProgramState.cpp @@ -279,7 +279,7 @@ GLProgramState::GLProgramState() , _textureUnitIndex(1) , _uniformAttributeValueDirty(true) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8) /** listen the event that renderer was recreated on Android/WP8 */ CCLOG("create rendererRecreatedListener for GLProgramState"); _backToForegroundlistener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom*) { _uniformAttributeValueDirty = true; }); @@ -289,7 +289,7 @@ GLProgramState::GLProgramState() GLProgramState::~GLProgramState() { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener); #endif diff --git a/cocos/renderer/CCGLProgramState.h b/cocos/renderer/CCGLProgramState.h index cab3640e65..d741504a32 100644 --- a/cocos/renderer/CCGLProgramState.h +++ b/cocos/renderer/CCGLProgramState.h @@ -217,8 +217,8 @@ protected: int _textureUnitIndex; uint32_t _vertexAttribsFlags; GLProgram *_glprogram; - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8) EventListenerCustom* _backToForegroundlistener; #endif }; From dfcdf10898b249861b810e1a9d8aa725d4a188cb Mon Sep 17 00:00:00 2001 From: Ahlwong Date: Fri, 24 Oct 2014 08:57:37 -0700 Subject: [PATCH 08/26] Fix Label Additional Kerning All Strings --- cocos/2d/CCLabelTextFormatter.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cocos/2d/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp index 358faca793..485c4d61bb 100644 --- a/cocos/2d/CCLabelTextFormatter.cpp +++ b/cocos/2d/CCLabelTextFormatter.cpp @@ -390,15 +390,13 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel) nextFontPositionX += charAdvance + kernings[i]; - // only apply kerning shift if string contains more than 1 character - if (stringLen > 1) { - nextFontPositionX += theLabel->_additionalKerning; - } - if (longestLine < nextFontPositionX) { longestLine = nextFontPositionX; } + + // check longest line before adding additional kerning + nextFontPositionX += theLabel->_additionalKerning; } float lastCharWidth = tempDefinition.width * contentScaleFactor; From c9f5eacc2e46f6cbd93d1a637cec7d59d41c7546 Mon Sep 17 00:00:00 2001 From: Sven Steinbauer Date: Fri, 24 Oct 2014 20:27:06 +0100 Subject: [PATCH 09/26] Add greater than operator to Vec2 --- cocos/math/Vec2.h | 9 +++++++++ cocos/math/Vec2.inl | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/cocos/math/Vec2.h b/cocos/math/Vec2.h index 78aac69b95..79b034d582 100644 --- a/cocos/math/Vec2.h +++ b/cocos/math/Vec2.h @@ -418,6 +418,15 @@ public: * @return True if this vector is less than the given vector, false otherwise. */ inline bool operator<(const Vec2& v) const; + + /** + * Determines if this vector is greater than the given vector. + * + * @param v The vector to compare against. + * + * @return True if this vector is greater than the given vector, false otherwise. + */ + inline bool operator>(const Vec2& v) const; /** * Determines if this vector is equal to the given vector. diff --git a/cocos/math/Vec2.inl b/cocos/math/Vec2.inl index 329208b1e5..4cfbe7d27c 100644 --- a/cocos/math/Vec2.inl +++ b/cocos/math/Vec2.inl @@ -82,6 +82,15 @@ inline bool Vec2::operator<(const Vec2& v) const return x < v.x; } +inline bool Vec2::operator>(const Vec2& v) const +{ + if (x == v.x) + { + return y > v.y; + } + return x > v.x; +} + inline bool Vec2::operator==(const Vec2& v) const { return x==v.x && y==v.y; From f1970e98dd3673102cbf68d1d8ea89cd08356313 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 25 Oct 2014 18:00:57 +0800 Subject: [PATCH 10/26] update for ui button press event --- cocos/ui/UIButton.cpp | 30 +++++++++++++++++++++++++----- cocos/ui/UIButton.h | 2 +- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 1df7fd7f5d..0ecb0aaa47 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -450,8 +450,16 @@ void Button::onPressStateChangedToNormal() _buttonNormalRenderer->setScale(_normalTextureScaleXInSize, _normalTextureScaleYInSize); _titleRenderer->stopAllActions(); - _titleRenderer->setScaleX(_normalTextureScaleXInSize); - _titleRenderer->setScaleY(_normalTextureScaleYInSize); + if (_unifySize) + { + _titleRenderer->setScaleX(1.0f); + _titleRenderer->setScaleY(1.0f); + } + else + { + _titleRenderer->setScaleX(_normalTextureScaleXInSize); + _titleRenderer->setScaleY(_normalTextureScaleYInSize); + } } } } @@ -492,8 +500,16 @@ void Button::onPressStateChangedToPressed() _buttonNormalRenderer->setScale(_normalTextureScaleXInSize +_zoomScale, _normalTextureScaleYInSize + _zoomScale); _titleRenderer->stopAllActions(); - _titleRenderer->setScaleX(_normalTextureScaleXInSize + _zoomScale); - _titleRenderer->setScaleY(_normalTextureScaleYInSize + _zoomScale); + if (_unifySize) + { + _titleRenderer->setScaleX(1.0f + _zoomScale); + _titleRenderer->setScaleY(1.0f + _zoomScale); + } + else + { + _titleRenderer->setScaleX(_normalTextureScaleXInSize + _zoomScale); + _titleRenderer->setScaleY(_normalTextureScaleYInSize + _zoomScale); + } } } } @@ -582,6 +598,10 @@ void Button::adaptRenderers() Size Button::getVirtualRendererSize() const { + if (_unifySize) + { + return this->getNormalSize(); + } Size titleSize = _titleRenderer->getContentSize(); if (!_normalTextureLoaded && _titleRenderer->getString().size() > 0) { return titleSize; @@ -839,7 +859,7 @@ void Button::copySpecialProperties(Widget *widget) } } -Size Button::getNormalSize() +Size Button::getNormalSize() const { Size titleSize; if (_titleRenderer != nullptr) diff --git a/cocos/ui/UIButton.h b/cocos/ui/UIButton.h index 6d3e611b6b..f5dc86a759 100644 --- a/cocos/ui/UIButton.h +++ b/cocos/ui/UIButton.h @@ -234,7 +234,7 @@ protected: virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; - virtual Size getNormalSize(); + virtual Size getNormalSize() const; protected: Scale9Sprite* _buttonNormalRenderer; Scale9Sprite* _buttonClickedRenderer; From 80230258d67d55c4a44d263fb286801df3d2b3aa Mon Sep 17 00:00:00 2001 From: Timothy Zhang Date: Mon, 27 Oct 2014 09:59:47 +0800 Subject: [PATCH 11/26] replace tab with 4 spaces --- cocos/renderer/CCGLProgramCache.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/renderer/CCGLProgramCache.cpp b/cocos/renderer/CCGLProgramCache.cpp index 963a700af0..2273e1f02e 100644 --- a/cocos/renderer/CCGLProgramCache.cpp +++ b/cocos/renderer/CCGLProgramCache.cpp @@ -432,13 +432,13 @@ GLProgram* GLProgramCache::getGLProgram(const std::string &key) void GLProgramCache::addGLProgram(GLProgram* program, const std::string &key) { - // release old one + // release old one auto prev = getProgram(key); - if( prev == program ) - return; + if( prev == program ) + return; - _programs.erase(key); - CC_SAFE_RELEASE_NULL(prev); + _programs.erase(key); + CC_SAFE_RELEASE_NULL(prev); if (program) program->retain(); From d42f8cac65eb6f0288790b5acca9390dd94963f9 Mon Sep 17 00:00:00 2001 From: Timothy Zhang Date: Mon, 27 Oct 2014 10:02:28 +0800 Subject: [PATCH 12/26] replace tab with 4 spaces --- cocos/renderer/CCGLProgramCache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/renderer/CCGLProgramCache.cpp b/cocos/renderer/CCGLProgramCache.cpp index 2273e1f02e..defb6080bb 100644 --- a/cocos/renderer/CCGLProgramCache.cpp +++ b/cocos/renderer/CCGLProgramCache.cpp @@ -433,9 +433,9 @@ GLProgram* GLProgramCache::getGLProgram(const std::string &key) void GLProgramCache::addGLProgram(GLProgram* program, const std::string &key) { // release old one - auto prev = getProgram(key); + auto prev = getProgram(key); if( prev == program ) - return; + return; _programs.erase(key); CC_SAFE_RELEASE_NULL(prev); From 7ccf684a3e81668cba95a01cc7996c76d5550d76 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 27 Oct 2014 11:15:36 +0800 Subject: [PATCH 13/26] [ci skip] Update CHANGELOG --- CHANGELOG | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 54c985e3a5..34c55f566f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,8 @@ cocos2d-x-3.3 ?? - [FIX] WP/WinRT: Windows 8.1 universal app support; `UIEditBox` support + [FIX] GLProgramState: enabled GLProgramState restoring on render recreated on WP8 [FIX] Label: label shifting when outline feature enabled [FIX] Sprite3D: did not create attached sprite from cache + [FIX] WP/WinRT: Windows 8.1 universal app support; `UIEditBox` support cocos2d-x-3.3-rc0 Oct.21 2014 [NEW] 3d: added light support: direction light, point light, spot light and ambient light From 19ed3d1965b8991d477f6d9a8800415d897dc23c Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 27 Oct 2014 11:16:25 +0800 Subject: [PATCH 14/26] udpate for ui button state change event --- cocos/ui/UIButton.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 0ecb0aaa47..a5c66f1802 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -435,7 +435,15 @@ void Button::onPressStateChangedToNormal() _buttonClickedRenderer->setScale(_pressedTextureScaleXInSize, _pressedTextureScaleYInSize); _titleRenderer->stopAllActions(); - _titleRenderer->runAction(zoomAction->clone()); + if (_unifySize) + { + Action *zoomTitleAction = ScaleTo::create(ZOOM_ACTION_TIME_STEP, 1, 1); + _titleRenderer->runAction(zoomTitleAction); + } + else + { + _titleRenderer->runAction(zoomAction->clone()); + } } } else @@ -483,6 +491,15 @@ void Button::onPressStateChangedToPressed() _titleRenderer->stopAllActions(); //we must call zoomAction->clone here _titleRenderer->runAction(zoomAction->clone()); + if (_unifySize) + { + Action *zoomTitleAction = ScaleTo::create(ZOOM_ACTION_TIME_STEP, 1 + _zoomScale, 1 + _zoomScale); + _titleRenderer->runAction(zoomTitleAction); + } + else + { + _titleRenderer->runAction(zoomAction->clone()); + } } } else From b3ade766500d98cfd5c72598ba3da4635ac52c85 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 27 Oct 2014 11:17:07 +0800 Subject: [PATCH 15/26] [ci skip]Update Authors --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 80b1017f66..03b0d06ccd 100644 --- a/AUTHORS +++ b/AUTHORS @@ -938,6 +938,7 @@ Developers: Fixed compiling error on WP8. Added method for custom precompiled shader program loading on WP8 Enable screen orientation change handling on WP8 + Enabled GLProgramState restoring on render recreated on WP8 chareice Make `setup.py` work on zsh From 8eb0f7fa5e9c5888dfd3ef508557889b593e6778 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 27 Oct 2014 11:30:48 +0800 Subject: [PATCH 16/26] [ci skip]Update Authors --- AUTHORS | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index 03b0d06ccd..af38ecab3f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1033,6 +1033,13 @@ Developers: coldfog Fix bug that ActionManagerEx::initWithBinary can only load one UI animation + + timur-losev + Fix a bug that GLProgramCache::addGLProgram() can not replace existing program + + TimothyZhang + Fixed a potential memory leak in GLProgram::setGLProgram() + Retired Core Developers: WenSheng Yang @@ -1045,9 +1052,6 @@ Retired Core Developers: RongHong Huang (flyingpaper) Author of cocos2d-xna and spent all his time on wp7. - - timur-losev - Fix a bug that GLProgramCache::addGLProgram() can not replace existing program Cocos2d-x can not grow so fast without the active community. Thanks to all developers who report & trace bugs, discuss the engine usage in forum & QQ groups! From 354147260c1701e1d7dd325efffa99ad6b6aa751 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 27 Oct 2014 11:32:30 +0800 Subject: [PATCH 17/26] [ci skip] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 34c55f566f..dc3eef08e9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ cocos2d-x-3.3 ?? + [FIX] GLProgramCache: doesn't release old program with the same key before adding a new one [FIX] GLProgramState: enabled GLProgramState restoring on render recreated on WP8 [FIX] Label: label shifting when outline feature enabled [FIX] Sprite3D: did not create attached sprite from cache From 521f5396ccc7a842066c3aa8862026161394d9b3 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 27 Oct 2014 11:39:58 +0800 Subject: [PATCH 18/26] [ci skip] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index dc3eef08e9..806c9c0dcd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ cocos2d-x-3.3 ?? + [FIX] GrawNode: drawPoint() may cause crash [FIX] GLProgramCache: doesn't release old program with the same key before adding a new one [FIX] GLProgramState: enabled GLProgramState restoring on render recreated on WP8 [FIX] Label: label shifting when outline feature enabled From a60d2ded2d98ed5be8ac8437a6d271624f757c8a Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 27 Oct 2014 11:50:02 +0800 Subject: [PATCH 19/26] [ci skip]Update Authors --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index af38ecab3f..4d5d1ab161 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1039,6 +1039,9 @@ Developers: TimothyZhang Fixed a potential memory leak in GLProgram::setGLProgram() + + ahlwong + Fix Label Kerning on Single Characters Retired Core Developers: From 15e92411f983a62d19e66e2195381febfe8b7854 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 27 Oct 2014 11:51:04 +0800 Subject: [PATCH 20/26] [ci skip] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 806c9c0dcd..b781994232 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ cocos2d-x-3.3 ?? [FIX] GLProgramCache: doesn't release old program with the same key before adding a new one [FIX] GLProgramState: enabled GLProgramState restoring on render recreated on WP8 [FIX] Label: label shifting when outline feature enabled + [FIX] Label: when applying additionalKerning to a Label that displays a string with only 1 character, the character is shifted [FIX] Sprite3D: did not create attached sprite from cache [FIX] WP/WinRT: Windows 8.1 universal app support; `UIEditBox` support From 34a7f511f07c77ccf9420f76208f5db848d84061 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 27 Oct 2014 11:55:26 +0800 Subject: [PATCH 21/26] [ci skip]Update Authors --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index 4d5d1ab161..5b41bb8817 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1042,6 +1042,9 @@ Developers: ahlwong Fix Label Kerning on Single Characters + + Svenito + Add greater than operator to Vec2 Retired Core Developers: From 941166d9c745602cee1cb3df29b4b4a39dc5f15c Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 27 Oct 2014 11:56:10 +0800 Subject: [PATCH 22/26] [ci skip] Update CHANGELOG --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index b781994232..9c975708c0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ cocos2d-x-3.3 ?? + [NEW] Vec2: added greater than operator + [FIX] GrawNode: drawPoint() may cause crash [FIX] GLProgramCache: doesn't release old program with the same key before adding a new one [FIX] GLProgramState: enabled GLProgramState restoring on render recreated on WP8 From 74fe1d86e6df13d98aa01088d324c5f5aa922382 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 28 Oct 2014 22:02:56 +0800 Subject: [PATCH 23/26] [ci skip]Update Authors --- AUTHORS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 5b41bb8817..e59e2a6ce3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1045,7 +1045,9 @@ Developers: Svenito Add greater than operator to Vec2 - + + liamcindy + update ui button size changed logic Retired Core Developers: WenSheng Yang From 9d0c8d97f954a9d0345879ff1e38d0feb4b20a18 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 29 Oct 2014 09:42:48 +0800 Subject: [PATCH 24/26] Update vs project setting for lua-empty-test --- .../project/proj.win32/lua-empty-test.vcxproj | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj b/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj index e089f85d8c..d19e7d77ec 100644 --- a/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj +++ b/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj @@ -1,4 +1,4 @@ - + @@ -108,10 +108,8 @@ MachineX86 - xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\cocos2d" "$(ProjectDir)..\..\" /e /Y -xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\cocosdenshion" "$(ProjectDir)..\..\" /e /Y -xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\network" "$(ProjectDir)..\..\" /e /Y -xcopy "$(ProjectDir)..\..\..\..\external\lua\luasocket\*.lua" "$(ProjectDir)..\..\" /e /Y + if not exist "$(ProjectDir)..\..\src\cocos" mkdir "$(ProjectDir)..\..\src\cocos" +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script" "$(ProjectDir)..\..\src\cocos" /e /Y @@ -162,10 +160,8 @@ xcopy "$(ProjectDir)..\..\..\..\external\lua\luasocket\*.lua" "$(ProjectDir)..\. - xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\cocos2d" "$(ProjectDir)..\..\" /e /Y -xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\cocosdenshion" "$(ProjectDir)..\..\" /e /Y -xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script\network" "$(ProjectDir)..\..\" /e /Y -xcopy "$(ProjectDir)..\..\..\..\external\lua\luasocket\*.lua" "$(ProjectDir)..\..\" /e /Y + if not exist "$(ProjectDir)..\..\src\cocos" mkdir "$(ProjectDir)..\..\src\cocos" +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script" "$(ProjectDir)..\..\src\cocos" /e /Y @@ -185,4 +181,4 @@ xcopy "$(ProjectDir)..\..\..\..\external\lua\luasocket\*.lua" "$(ProjectDir)..\. - + \ No newline at end of file From c9daa8244ee772681fc8e36e77f286412c4eea37 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 29 Oct 2014 16:09:35 +0800 Subject: [PATCH 25/26] Add include directories to fix compile error on the window and remove useless `PreBuildEvent` --- .../runtime-src/proj.win32/HelloLua.vcxproj | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.win32/HelloLua.vcxproj b/templates/lua-template-default/frameworks/runtime-src/proj.win32/HelloLua.vcxproj index cc1da377f0..f7df1afe6e 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.win32/HelloLua.vcxproj +++ b/templates/lua-template-default/frameworks/runtime-src/proj.win32/HelloLua.vcxproj @@ -1,4 +1,4 @@ - + @@ -68,7 +68,7 @@ - $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) Level3 @@ -106,14 +106,10 @@ - xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\cocos2d" "$(ProjectDir)..\..\..\" /e /Y -xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\cocosdenshion" "$(ProjectDir)..\..\..\" /e /Y -xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\cocosbuilder" "$(ProjectDir)..\..\..\" /e /Y -xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\cocostudio" "$(ProjectDir)..\..\..\" /e /Y -xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\extension" "$(ProjectDir)..\..\..\" /e /Y -xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\network" "$(ProjectDir)..\..\..\" /e /Y -xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\ui" "$(ProjectDir)..\..\..\" /e /Y - copy files + + + + @@ -122,7 +118,7 @@ xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\ui" "$(P - $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) Level3 @@ -159,14 +155,10 @@ xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\ui" "$(P - xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\cocos2d" "$(ProjectDir)..\..\..\" /e /Y -xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\cocosdenshion" "$(ProjectDir)..\..\..\" /e /Y -xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\cocosbuilder" "$(ProjectDir)..\..\..\" /e /Y -xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\cocostudio" "$(ProjectDir)..\..\..\" /e /Y -xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\extension" "$(ProjectDir)..\..\..\" /e /Y -xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\network" "$(ProjectDir)..\..\..\" /e /Y -xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\ui" "$(ProjectDir)..\..\..\" /e /Y - copy files + + + + @@ -202,4 +194,4 @@ xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script\ui" "$(P - + \ No newline at end of file From d2c36d604f867654f1c85af46b6913da971ef625 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 29 Oct 2014 16:11:00 +0800 Subject: [PATCH 26/26] [ci skip] Update CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 9c975708c0..db133ad049 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ cocos2d-x-3.3 ?? [NEW] Vec2: added greater than operator + [FIX] Cocos console: compile failure on windows if using VS express version [FIX] GrawNode: drawPoint() may cause crash [FIX] GLProgramCache: doesn't release old program with the same key before adding a new one [FIX] GLProgramState: enabled GLProgramState restoring on render recreated on WP8