Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3_fix

This commit is contained in:
samuele3hu 2014-06-03 17:17:11 +08:00
commit 404db49538
13 changed files with 204 additions and 26 deletions

View File

@ -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

View File

@ -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;

View File

@ -603,7 +603,8 @@ std::string ObjLoader::LoadObj(shapes_t& shapes, const char* filename, const cha
std::vector<vertex_index> 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;

View File

@ -465,14 +465,29 @@ 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!
// 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
// is an special list for updates with priority 0

View File

@ -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();
}
}

View File

@ -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);
@ -186,12 +188,17 @@ protected:
VertexAttribValue* getVertexAttribValue(const std::string &attributeName);
UniformValue* getUniformValue(const std::string &uniformName);
bool _uniformAttributeValueDirty;
std::unordered_map<std::string, UniformValue> _uniforms;
std::unordered_map<std::string, VertexAttribValue> _attributes;
int _textureUnitIndex;
uint32_t _vertexAttribsFlags;
GLProgram *_glprogram;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
EventListenerCustom* _backToForegroundlistener;
#endif
};
NS_CC_END

View File

@ -28,7 +28,8 @@ static std::function<Layer*()> 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<int>(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

View File

@ -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:

View File

@ -208,12 +208,42 @@ bool Effect::initGLProgramState(const std::string &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
{

View File

@ -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

View File

@ -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)

View File

@ -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;

View File

@ -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)