diff --git a/CHANGELOG b/CHANGELOG index 4c3e9331d4..ae6abe643f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,10 +2,13 @@ cocos2d-x-3.2 ??? [NEW] TextureCache: added unbindImageAsync() and unbindAllImageAsync() [FIX] Application.mk: not output debug message in releae mode on Android + [FIX] Android: 3d model will be black when coming from background [FIX] Cocos2dxGLSurfaceView.java: prevent flickering when opening another activity [FIX] Image: Set jpeg save quality to 90 [FIX] Label: label is unsharp if it's created by smaller font + [FIX] Others: Treat warning as error on iOS and Mac [FIX] Repeat: will run one more over in rare situations + [FIX] Schedule: schedulePerFrame() can not be called twice [FIX] SpriteFrameCache: fix memory leak cocos2d-x-3.1 May.24 2014 diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index fcfc6e19d8..e90ce19ea1 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -7073,6 +7073,7 @@ CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); + GCC_TREAT_WARNINGS_AS_ERRORS = YES; HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -7099,6 +7100,7 @@ CC_KEYBOARD_SUPPORT, CC_TARGET_OS_MAC, ); + GCC_TREAT_WARNINGS_AS_ERRORS = YES; HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -7191,6 +7193,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_PREPROCESSOR_DEFINITIONS = CC_TARGET_OS_MAC; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; HEADER_SEARCH_PATHS = ""; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac"; }; @@ -7201,6 +7204,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_PREPROCESSOR_DEFINITIONS = CC_TARGET_OS_MAC; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; HEADER_SEARCH_PATHS = ""; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac"; }; @@ -7215,6 +7219,7 @@ CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); + GCC_TREAT_WARNINGS_AS_ERRORS = YES; HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = "$(inherited)"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../cocos/platform/desktop $(SRCROOT)/../external/glfw3/include/mac"; @@ -7230,6 +7235,7 @@ CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); + GCC_TREAT_WARNINGS_AS_ERRORS = YES; HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = "$(inherited)"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../cocos/platform/desktop $(SRCROOT)/../external/glfw3/include/mac"; @@ -7247,6 +7253,7 @@ "$(inherited)", CC_TARGET_OS_IPHONE, ); + GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; @@ -7285,6 +7292,7 @@ "$(inherited)", CC_TARGET_OS_IPHONE, ); + GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; @@ -7341,6 +7349,7 @@ "$(inherited)", CC_TARGET_OS_IPHONE, ); + GCC_TREAT_WARNINGS_AS_ERRORS = YES; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; LIBRARY_SEARCH_PATHS = "$(inherited)"; @@ -7359,6 +7368,7 @@ "$(inherited)", CC_TARGET_OS_IPHONE, ); + GCC_TREAT_WARNINGS_AS_ERRORS = YES; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; LIBRARY_SEARCH_PATHS = "$(inherited)"; @@ -7437,6 +7447,7 @@ "$(inherited)", CC_TARGET_OS_IPHONE, ); + GCC_TREAT_WARNINGS_AS_ERRORS = YES; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; SDKROOT = iphoneos; @@ -7454,6 +7465,7 @@ "$(inherited)", CC_TARGET_OS_IPHONE, ); + GCC_TREAT_WARNINGS_AS_ERRORS = YES; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; SDKROOT = iphoneos; diff --git a/cocos/3d/CCObjLoader.cpp b/cocos/3d/CCObjLoader.cpp index 939de77984..4c5da0d89e 100644 --- a/cocos/3d/CCObjLoader.cpp +++ b/cocos/3d/CCObjLoader.cpp @@ -603,7 +603,8 @@ std::string ObjLoader::LoadObj(shapes_t& shapes, const char* filename, const cha std::vector face; while (!isNewLine(token[0])) { - vertex_index vi = parseTriple(token, v.size() / 3, vn.size() / 3, vt.size() / 2); + // fix warning, cast to int, i think int is enough + vertex_index vi = parseTriple(token, (int)v.size() / 3, (int)vn.size() / 3, (int)vt.size() / 2); face.push_back(vi); auto n = strspn(token, " \t\r"); token += n; diff --git a/cocos/base/CCScheduler.cpp b/cocos/base/CCScheduler.cpp index 3688f74a3c..9edbaa6c0e 100644 --- a/cocos/base/CCScheduler.cpp +++ b/cocos/base/CCScheduler.cpp @@ -465,13 +465,28 @@ void Scheduler::schedulePerFrame(const ccSchedulerFunc& callback, void *target, HASH_FIND_PTR(_hashForUpdates, &target, hashElement); if (hashElement) { -#if COCOS2D_DEBUG >= 1 - CCASSERT(hashElement->entry->markedForDeletion,""); -#endif - // TODO: check if priority has changed! - - hashElement->entry->markedForDeletion = false; - return; + // check if priority has changed + if ((*hashElement->list)->priority != priority) + { + if (_updateHashLocked) + { + CCLOG("warning: you CANNOT change update priority in scheduled function"); + hashElement->entry->markedForDeletion = false; + hashElement->entry->paused = paused; + return; + } + else + { + // will be added again outside if (hashElement). + unscheduleUpdate(target); + } + } + else + { + hashElement->entry->markedForDeletion = false; + hashElement->entry->paused = paused; + return; + } } // most of the updates are going to be 0, that's way there diff --git a/cocos/renderer/CCGLProgramState.cpp b/cocos/renderer/CCGLProgramState.cpp index eadae38e75..4341cbe4ba 100644 --- a/cocos/renderer/CCGLProgramState.cpp +++ b/cocos/renderer/CCGLProgramState.cpp @@ -33,6 +33,10 @@ THE SOFTWARE. #include "renderer/CCGLProgramCache.h" #include "renderer/ccGLStateCache.h" #include "renderer/CCTexture2D.h" +#include "base/CCEventCustom.h" +#include "base/CCEventListenerCustom.h" +#include "base/CCEventType.h" +#include "base/CCDirector.h" NS_CC_BEGIN @@ -272,11 +276,22 @@ GLProgramState::GLProgramState() : _vertexAttribsFlags(0) , _glprogram(nullptr) , _textureUnitIndex(1) +, _uniformAttributeValueDirty(true) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + // listen the event when app go to foreground + CCLOG("create _backToForegroundlistener for GLProgramState"); + _backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom*) { _uniformAttributeValueDirty = true; }); + Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1); +#endif } GLProgramState::~GLProgramState() -{ +{ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener); +#endif + CC_SAFE_RELEASE(_glprogram); } @@ -312,7 +327,24 @@ void GLProgramState::resetGLProgram() void GLProgramState::apply(const Mat4& modelView) { CCASSERT(_glprogram, "invalid glprogram"); - + if(_uniformAttributeValueDirty) + { + for(auto& uniformValue : _uniforms) + { + uniformValue.second._uniform = _glprogram->getUniform(uniformValue.first); + } + + _vertexAttribsFlags = 0; + for(auto& attributeValue : _attributes) + { + attributeValue.second._vertexAttrib = _glprogram->getVertexAttrib(attributeValue.first);; + if(attributeValue.second._enabled) + _vertexAttribsFlags |= 1 << attributeValue.second._vertexAttrib->index; + } + + _uniformAttributeValueDirty = false; + + } // set shader _glprogram->use(); _glprogram->setUniformsForBuiltins(modelView); @@ -322,9 +354,9 @@ void GLProgramState::apply(const Mat4& modelView) if(_vertexAttribsFlags) { // enable/disable vertex attribs GL::enableVertexAttribs(_vertexAttribsFlags); - // set attributes - for(auto &attribute : _attributes) { + for(auto &attribute : _attributes) + { attribute.second.apply(); } } diff --git a/cocos/renderer/CCGLProgramState.h b/cocos/renderer/CCGLProgramState.h index babfed8fed..019cd95222 100644 --- a/cocos/renderer/CCGLProgramState.h +++ b/cocos/renderer/CCGLProgramState.h @@ -39,6 +39,8 @@ class GLProgram; class Texture2D; struct Uniform; struct VertexAttrib; +class EventListenerCustom; +class EventCustom; // // @@ -48,7 +50,7 @@ struct VertexAttrib; class UniformValue { friend class GLProgram; - + friend class GLProgramState; public: UniformValue(); UniformValue(Uniform *uniform, GLProgram* glprogram); @@ -177,7 +179,7 @@ public: void setUniformCallback(const std::string &uniformName, const std::function &callback); void setUniformTexture(const std::string &uniformName, Texture2D *texture); void setUniformTexture(const std::string &uniformName, GLuint textureId); - + protected: GLProgramState(); ~GLProgramState(); @@ -185,13 +187,18 @@ protected: void resetGLProgram(); VertexAttribValue* getVertexAttribValue(const std::string &attributeName); UniformValue* getUniformValue(const std::string &uniformName); - + + bool _uniformAttributeValueDirty; std::unordered_map _uniforms; std::unordered_map _attributes; int _textureUnitIndex; uint32_t _vertexAttribsFlags; GLProgram *_glprogram; + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + EventListenerCustom* _backToForegroundlistener; +#endif }; NS_CC_END diff --git a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp index cf62c50397..33fae8fb89 100644 --- a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp +++ b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp @@ -28,7 +28,8 @@ static std::function createFunctions[] = { CL(RescheduleSelector), CL(SchedulerDelayAndRepeat), CL(SchedulerIssue2268), - CL(ScheduleCallbackTest) + CL(ScheduleCallbackTest), + CL(ScheduleUpdatePriority) }; #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) @@ -1148,6 +1149,47 @@ void ScheduleCallbackTest::callback(float dt) log("In the callback of schedule(CC_CALLBACK_1(XXX::member_function), this), this, ...), dt = %f", dt); } + +// ScheduleUpdatePriority + +std::string ScheduleUpdatePriority::title() const +{ + return "ScheduleUpdatePriorityTest"; +} + +std::string ScheduleUpdatePriority::subtitle() const +{ + return "click to change update priority with random value"; +} + +bool ScheduleUpdatePriority::onTouchBegan(Touch* touch, Event* event) +{ + int priority = static_cast(CCRANDOM_0_1() * 11) - 5; // -5 ~ 5 + CCLOG("change update priority to %d", priority); + scheduleUpdateWithPriority(priority); + return true; +} + +void ScheduleUpdatePriority::onEnter() +{ + SchedulerTestLayer::onEnter(); + + scheduleUpdate(); + + auto listener = EventListenerTouchOneByOne::create(); + listener->onTouchBegan = CC_CALLBACK_2(ScheduleUpdatePriority::onTouchBegan, this); + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); +} + +void ScheduleUpdatePriority::onExit() +{ + unscheduleUpdate(); +} + +void ScheduleUpdatePriority::update(float dt) +{ +} + //------------------------------------------------------------------ // // SchedulerTestScene diff --git a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h index 57efb807a9..5728f46a3a 100644 --- a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h +++ b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h @@ -302,6 +302,21 @@ public: private: }; +class ScheduleUpdatePriority : public SchedulerTestLayer +{ +public: + CREATE_FUNC(ScheduleUpdatePriority); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + void onEnter(); + void onExit(); + + virtual void update(float dt); + + bool onTouchBegan(Touch* touch, Event* event); +}; + class SchedulerTestScene : public TestScene { public: diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index a697277c78..35cc597f14 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -207,13 +207,43 @@ bool Effect::initGLProgramState(const std::string &fragmentFilename) auto fragmentFullPath = fileUtiles->fullPathForFilename(fragmentFilename); auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath); auto glprogram = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, fragSource.c_str()); - + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + _fragSource = fragSource; +#endif + _glprogramstate = GLProgramState::getOrCreateWithGLProgram(glprogram); _glprogramstate->retain(); return _glprogramstate != nullptr; } +Effect::Effect() +: _glprogramstate(nullptr) +{ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + _backgroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, + [this](EventCustom*) + { + auto glProgram = _glprogramstate->getGLProgram(); + glProgram->reset(); + glProgram->initWithByteArrays(ccPositionTextureColor_noMVP_vert, _fragSource.c_str()); + glProgram->link(); + glProgram->updateUniforms(); + } + ); + Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backgroundListener, -1); +#endif +} + +Effect::~Effect() +{ + CC_SAFE_RELEASE_NULL(_glprogramstate); +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + Director::getInstance()->getEventDispatcher()->removeEventListener(_backgroundListener); +#endif +} + // Blur class EffectBlur : public Effect { diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h index 2d7421fa80..0de6babe69 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h @@ -37,10 +37,13 @@ public: protected: bool initGLProgramState(const std::string &fragmentFilename); - Effect() : _glprogramstate(nullptr) - {} - virtual ~Effect() {} + Effect(); + virtual ~Effect(); GLProgramState *_glprogramstate; +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + std::string _fragSource; + EventListenerCustom* _backgroundListener; +#endif }; class EffectSpriteTest : public ShaderTestDemo2 diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index 8076d2a9e8..889d61611c 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -297,7 +297,7 @@ Effect3DOutline* Effect3DOutline::create() bool Effect3DOutline::init() { - GLProgram* glprogram = Effect3DOutline::getOrCreateProgram(); + GLProgram* glprogram = GLProgram::createWithFilenames(_vertShaderFile, _fragShaderFile); if(nullptr == glprogram) { CC_SAFE_DELETE(glprogram); @@ -320,12 +320,27 @@ Effect3DOutline::Effect3DOutline() , _outlineColor(1, 1, 1) , _sprite(nullptr) { - +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + _backToForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, + [this](EventCustom*) + { + auto glProgram = _glProgramState->getGLProgram(); + glProgram->reset(); + glProgram->initWithFilenames(_vertShaderFile, _fragShaderFile); + glProgram->link(); + glProgram->updateUniforms(); + } + ); + Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundListener, -1); +#endif } Effect3DOutline::~Effect3DOutline() { CC_SAFE_RELEASE_NULL(_sprite); +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); +#endif } void Effect3DOutline::setOutlineColor(const Vec3& color) diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index 843bd0af8a..4d2f134e02 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -98,6 +98,9 @@ protected: Vec3 _outlineColor; float _outlineWidth; EffectSprite3D* _sprite; +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + EventListenerCustom* _backToForegroundListener; +#endif protected: static const std::string _vertShaderFile; diff --git a/tools/jenkins-scripts/post-build.py b/tools/jenkins-scripts/post-build.py index 184b56b900..78f7ddf735 100644 --- a/tools/jenkins-scripts/post-build.py +++ b/tools/jenkins-scripts/post-build.py @@ -5,9 +5,7 @@ import jenkinsapi from jenkinsapi.jenkins import Jenkins from jenkinsapi.constants import STATUS_SUCCESS -http_proxy = '' -if(os.environ.has_key('HTTP_PROXY')): - http_proxy = os.environ['HTTP_PROXY'] +payload_str = os.environ['payload'] payload_str = payload_str.decode('utf-8','ignore') #parse to json obj payload = json.loads(payload_str) @@ -31,6 +29,8 @@ if(result == STATUS_SUCCESS): else: data['state'] = "failure" -http_proxy = os.environ['HTTP_PROXY'] +http_proxy = '' +if(os.environ.has_key('HTTP_PROXY')): + http_proxy = os.environ['HTTP_PROXY'] proxyDict = {'http':http_proxy,'https':http_proxy} requests.post(statuses_url, data=json.dumps(data), headers=Headers, proxies = proxyDict)