From ad8638d9765d2a07a0adc7c1a5522d7bec8812ec Mon Sep 17 00:00:00 2001 From: samuele3 Date: Fri, 6 Dec 2013 14:16:33 +0800 Subject: [PATCH 01/70] issue #3353:Lua gc mechanism will make the extended attributes of lua userdata disapper --- cocos/scripting/lua/bindings/tolua_fix.c | 7 +- external/lua/tolua/tolua++.h | 6 + external/lua/tolua/tolua_map.c | 5 + external/lua/tolua/tolua_push.c | 170 ++++++++++++++--------- tools/tolua/cocos2dx.ini | 7 +- 5 files changed, 126 insertions(+), 69 deletions(-) diff --git a/cocos/scripting/lua/bindings/tolua_fix.c b/cocos/scripting/lua/bindings/tolua_fix.c index f03dd59b5f..2aabde0980 100644 --- a/cocos/scripting/lua/bindings/tolua_fix.c +++ b/cocos/scripting/lua/bindings/tolua_fix.c @@ -53,7 +53,8 @@ TOLUA_API int toluafix_pushusertype_ccobject(lua_State* L, //printf("[LUA] push CCObject OK - refid: %d, ptr: %x, type: %s\n", *p_refid, (int)ptr, type); } - tolua_pushusertype(L, ptr, type); + tolua_pushusertype_and_addtoroot(L, ptr, type); + return 0; } @@ -118,6 +119,10 @@ TOLUA_API int toluafix_remove_ccobject_by_refid(lua_State* L, int refid) lua_pushstring(L, "tolua_ubox"); /* stack: mt key */ lua_rawget(L, LUA_REGISTRYINDEX); /* stack: mt ubox */ }; + + + // cleanup root + tolua_remove_value_from_root(L, ptr); lua_pushlightuserdata(L, ptr); /* stack: mt ubox ptr */ lua_rawget(L,-2); /* stack: mt ubox ud */ diff --git a/external/lua/tolua/tolua++.h b/external/lua/tolua/tolua++.h index 6183210ba3..173aec08ad 100644 --- a/external/lua/tolua/tolua++.h +++ b/external/lua/tolua/tolua++.h @@ -41,6 +41,8 @@ extern "C" { #define TOLUA_PROTECTED_DESTRUCTOR #define TOLUA_PROPERTY_TYPE(p) +#define TOLUA_VALUE_ROOT "tolua_value_root" + typedef int lua_Object; #include "lua.h" @@ -117,6 +119,10 @@ TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const cha TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v); TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type); TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type); + +TOLUA_API void tolua_pushusertype_and_addtoroot (lua_State* L, void* value, const char* type); +TOLUA_API void tolua_add_value_to_root (lua_State* L,void* value); +TOLUA_API void tolua_remove_value_from_root (lua_State* L, void* value); TOLUA_API lua_Number tolua_tonumber (lua_State* L, int narg, lua_Number def); TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def); diff --git a/external/lua/tolua/tolua_map.c b/external/lua/tolua/tolua_map.c index 6b6c047e15..5528ef6cbe 100644 --- a/external/lua/tolua/tolua_map.c +++ b/external/lua/tolua/tolua_map.c @@ -304,6 +304,11 @@ TOLUA_API void tolua_open (lua_State* L) lua_pushstring(L,"tolua_opened"); lua_pushboolean(L,1); lua_rawset(L,LUA_REGISTRYINDEX); + + // create value root table + lua_pushstring(L, TOLUA_VALUE_ROOT); + lua_newtable(L); + lua_rawset(L, LUA_REGISTRYINDEX); #ifndef LUA_VERSION_NUM /* only prior to lua 5.1 */ /* create peer object table */ diff --git a/external/lua/tolua/tolua_push.c b/external/lua/tolua/tolua_push.c index dbfdb193b6..8d9ee7b33a 100644 --- a/external/lua/tolua/tolua_push.c +++ b/external/lua/tolua/tolua_push.c @@ -17,6 +17,82 @@ #include +void tolua_pushusertype_internal (lua_State* L, void* value, const char* type, int addToRoot) +{ + if (value == NULL) + lua_pushnil(L); + else + { + luaL_getmetatable(L, type); /* stack: mt */ + if (lua_isnil(L, -1)) { /* NOT FOUND metatable */ + lua_pop(L, 1); + return; + } + lua_pushstring(L,"tolua_ubox"); + lua_rawget(L,-2); /* stack: mt ubox */ + if (lua_isnil(L, -1)) { + lua_pop(L, 1); + lua_pushstring(L, "tolua_ubox"); + lua_rawget(L, LUA_REGISTRYINDEX); + }; + + lua_pushlightuserdata(L,value); /* stack: mt ubox key */ + lua_rawget(L,-2); /* stack: mt ubox ubox[value] */ + + if (lua_isnil(L,-1)) + { + lua_pop(L,1); /* stack: mt ubox */ + lua_pushlightuserdata(L,value); + *(void**)lua_newuserdata(L,sizeof(void *)) = value; /* stack: mt ubox value newud */ + lua_pushvalue(L,-1); /* stack: mt ubox value newud newud */ + lua_insert(L,-4); /* stack: mt newud ubox value newud */ + lua_rawset(L,-3); /* ubox[value] = newud, stack: mt newud ubox */ + lua_pop(L,1); /* stack: mt newud */ + /*luaL_getmetatable(L,type);*/ + lua_pushvalue(L, -2); /* stack: mt newud mt */ + lua_setmetatable(L,-2); /* update mt, stack: mt newud */ + +#ifdef LUA_VERSION_NUM + lua_pushvalue(L, TOLUA_NOPEER); /* stack: mt newud peer */ + lua_setfenv(L, -2); /* stack: mt newud */ +#endif + } + else + { + /* check the need of updating the metatable to a more specialized class */ + lua_insert(L,-2); /* stack: mt ubox[u] ubox */ + lua_pop(L,1); /* stack: mt ubox[u] */ + lua_pushstring(L,"tolua_super"); + lua_rawget(L,LUA_REGISTRYINDEX); /* stack: mt ubox[u] super */ + lua_getmetatable(L,-2); /* stack: mt ubox[u] super mt */ + lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] */ + if (lua_istable(L,-1)) + { + lua_pushstring(L,type); /* stack: mt ubox[u] super super[mt] type */ + lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] flag */ + if (lua_toboolean(L,-1) == 1) /* if true */ + { + lua_pop(L,3); /* mt ubox[u]*/ + lua_remove(L, -2); + return; + } + } + /* type represents a more specilized type */ + /*luaL_getmetatable(L,type); // stack: mt ubox[u] super super[mt] flag mt */ + lua_pushvalue(L, -5); /* stack: mt ubox[u] super super[mt] flag mt */ + lua_setmetatable(L,-5); /* stack: mt ubox[u] super super[mt] flag */ + lua_pop(L,3); /* stack: mt ubox[u] */ + } + lua_remove(L, -2); /* stack: ubox[u]*/ + + if (0 != addToRoot) + { + lua_pushvalue(L, -1); + tolua_add_value_to_root(L, value); + } + } +} + TOLUA_API void tolua_pushvalue (lua_State* L, int lo) { lua_pushvalue(L,lo); @@ -50,72 +126,12 @@ TOLUA_API void tolua_pushuserdata (lua_State* L, void* value) TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type) { - if (value == NULL) - lua_pushnil(L); - else - { - luaL_getmetatable(L, type); /* stack: mt */ - if (lua_isnil(L, -1)) { /* NOT FOUND metatable */ - lua_pop(L, 1); - return; - } - lua_pushstring(L,"tolua_ubox"); - lua_rawget(L,-2); /* stack: mt ubox */ - if (lua_isnil(L, -1)) { - lua_pop(L, 1); - lua_pushstring(L, "tolua_ubox"); - lua_rawget(L, LUA_REGISTRYINDEX); - }; - - lua_pushlightuserdata(L,value); /* stack: mt ubox key */ - lua_rawget(L,-2); /* stack: mt ubox ubox[value] */ - - if (lua_isnil(L,-1)) - { - lua_pop(L,1); /* stack: mt ubox */ - lua_pushlightuserdata(L,value); - *(void**)lua_newuserdata(L,sizeof(void *)) = value; /* stack: mt ubox value newud */ - lua_pushvalue(L,-1); /* stack: mt ubox value newud newud */ - lua_insert(L,-4); /* stack: mt newud ubox value newud */ - lua_rawset(L,-3); /* ubox[value] = newud, stack: mt newud ubox */ - lua_pop(L,1); /* stack: mt newud */ - /*luaL_getmetatable(L,type);*/ - lua_pushvalue(L, -2); /* stack: mt newud mt */ - lua_setmetatable(L,-2); /* update mt, stack: mt newud */ + tolua_pushusertype_internal(L, value, type, 0); +} -#ifdef LUA_VERSION_NUM - lua_pushvalue(L, TOLUA_NOPEER); - lua_setfenv(L, -2); -#endif - } - else - { - /* check the need of updating the metatable to a more specialized class */ - lua_insert(L,-2); /* stack: mt ubox[u] ubox */ - lua_pop(L,1); /* stack: mt ubox[u] */ - lua_pushstring(L,"tolua_super"); - lua_rawget(L,LUA_REGISTRYINDEX); /* stack: mt ubox[u] super */ - lua_getmetatable(L,-2); /* stack: mt ubox[u] super mt */ - lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] */ - if (lua_istable(L,-1)) - { - lua_pushstring(L,type); /* stack: mt ubox[u] super super[mt] type */ - lua_rawget(L,-2); /* stack: mt ubox[u] super super[mt] flag */ - if (lua_toboolean(L,-1) == 1) /* if true */ - { - lua_pop(L,3); /* mt ubox[u]*/ - lua_remove(L, -2); - return; - } - } - /* type represents a more specilized type */ - /*luaL_getmetatable(L,type); // stack: mt ubox[u] super super[mt] flag mt */ - lua_pushvalue(L, -5); /* stack: mt ubox[u] super super[mt] flag mt */ - lua_setmetatable(L,-5); /* stack: mt ubox[u] super super[mt] flag */ - lua_pop(L,3); /* stack: mt ubox[u] */ - } - lua_remove(L, -2); /* stack: ubox[u]*/ - } +TOLUA_API void tolua_pushusertype_and_addtoroot (lua_State* L, void* value, const char* type) +{ + tolua_pushusertype_internal(L, value, type, 1); } TOLUA_API void tolua_pushusertype_and_takeownership (lua_State* L, void* value, const char* type) @@ -124,6 +140,30 @@ TOLUA_API void tolua_pushusertype_and_takeownership (lua_State* L, void* value, tolua_register_gc(L,lua_gettop(L)); } +TOLUA_API void tolua_add_value_to_root(lua_State* L, void* ptr) +{ + + lua_pushstring(L, TOLUA_VALUE_ROOT); + lua_rawget(L, LUA_REGISTRYINDEX); /* stack: value root */ + lua_insert(L, -2); /* stack: root value */ + lua_pushlightuserdata(L, ptr); /* stack: root value ptr */ + lua_insert(L, -2); /* stack: root ptr value */ + lua_rawset(L, -3); /* root[ptr] = value, stack: root */ + lua_pop(L, 1); /* stack: - */ +} + + +TOLUA_API void tolua_remove_value_from_root (lua_State* L, void* ptr) +{ + lua_pushstring(L, TOLUA_VALUE_ROOT); + lua_rawget(L, LUA_REGISTRYINDEX); /* stack: root */ + lua_pushlightuserdata(L, ptr); /* stack: root ptr */ + + lua_pushnil(L); /* stack: root ptr nil */ + lua_rawset(L, -3); /* root[ptr] = nil, stack: root */ + lua_pop(L, 1); +} + TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v) { lua_pushnumber(L,index); diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 36a6a98ed9..7f09c7a231 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/2d/cocos2d.h %(cocosdir)s/cocos/audio/include/Simpl # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault EGLViewProtocol EGLView Image +classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault EGLViewProtocol EGLView Image DisplayLinkDirector # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -107,7 +107,8 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS UserDefault::[getInstance (s|g)etDataForKey], Label::[getLettersInfo], EGLViewProtocol::[setTouchDelegate], - EGLView::[end swapBuffers] + EGLView::[end swapBuffers], + DisplayLinkDirector::[mainLoop setAnimationInterval startAnimation stopAnimation] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], ProgressTimer::[setReverseProgress=setReverseDirection], @@ -138,7 +139,7 @@ base_classes_to_skip = Clonable # classes that create no constructor # Set is special and we will use a hand-written constructor -abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application ClippingNode Label EGLViewProtocol EGLView +abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application ClippingNode Label EGLViewProtocol EGLView DisplayLinkDirector # Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. script_control_cpp = no From c58963bd45968adafd1b332c0068195441b5dc80 Mon Sep 17 00:00:00 2001 From: yinkaile Date: Thu, 19 Dec 2013 21:12:25 +0800 Subject: [PATCH 02/70] add support for tweenRotate property --- .../cocostudio/CCDataReaderHelper.cpp | 18 +++++++----------- cocos/editor-support/cocostudio/CCDatas.cpp | 4 ++-- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index 5a80d77b24..8787798d63 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -59,8 +59,6 @@ static const char *A_MOVEMENT_SCALE = "sc"; static const char *A_MOVEMENT_DELAY = "dl"; static const char *A_DISPLAY_INDEX = "dI"; -// static const char *A_VERT = "vert"; -// static const char *A_FRAG = "frag"; static const char *A_PLIST = "plist"; static const char *A_PARENT = "parent"; @@ -73,9 +71,8 @@ static const char *A_EVENT = "evt"; static const char *A_SOUND = "sd"; static const char *A_SOUND_EFFECT = "sdE"; static const char *A_TWEEN_EASING = "twE"; -//static const char *A_EASING_PARAM_NUMBER = "twEPN"; static const char *A_EASING_PARAM = "twEP"; -//static const char *A_TWEEN_ROTATE = "twR"; +static const char *A_TWEEN_ROTATE = "twR"; static const char *A_IS_ARMATURE = "isArmature"; static const char *A_DISPLAY_TYPE = "displayType"; static const char *A_MOVEMENT = "mov"; @@ -108,17 +105,12 @@ static const char *A_GREEN_OFFSET = "gM"; static const char *A_BLUE_OFFSET = "bM"; static const char *A_COLOR_TRANSFORM = "colorTransform"; static const char *A_TWEEN_FRAME = "tweenFrame"; -//static const char *A_ROTATION = "rotation"; -//static const char *A_USE_COLOR_INFO = "uci"; static const char *CONTOUR = "con"; static const char *CONTOUR_VERTEX = "con_vt"; -//static const char *MOVEMENT_EVENT_FRAME = "movementEventFrame"; -//static const char *SOUND_FRAME = "soundFrame"; - static const char *FL_NAN = "NaN"; @@ -921,8 +913,8 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxml2::XMLElement *parentFrameXml, BoneData *boneData, DataInfo *dataInfo) { - float x, y, scale_x, scale_y, skew_x, skew_y = 0; - int duration, displayIndex, zOrder, tweenEasing, blendType = 0; + float x = 0, y = 0, scale_x = 0, scale_y = 0, skew_x = 0, skew_y = 0, tweenRotate = 0; + int duration = 0, displayIndex = 0, zOrder = 0, tweenEasing = 0, blendType = 0; FrameData *frameData = new FrameData(); @@ -1005,6 +997,10 @@ FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxm { frameData->zOrder = zOrder; } + if( frameXML->QueryFloatAttribute(A_TWEEN_ROTATE, &tweenRotate) == tinyxml2::XML_SUCCESS ) + { + frameData->tweenRotate = tweenRotate; + } if ( frameXML->QueryIntAttribute(A_BLEND_TYPE, &blendType) == tinyxml2::XML_SUCCESS ) { switch (blendType) diff --git a/cocos/editor-support/cocostudio/CCDatas.cpp b/cocos/editor-support/cocostudio/CCDatas.cpp index d9706a8d26..01b15e2d8c 100644 --- a/cocos/editor-support/cocostudio/CCDatas.cpp +++ b/cocos/editor-support/cocostudio/CCDatas.cpp @@ -123,8 +123,8 @@ void BaseData::subtract(BaseData *from, BaseData *to, bool limit) if (to->tweenRotate) { - skewX += to->tweenRotate; - skewY -= to->tweenRotate; + skewX += to->tweenRotate * M_PI * 2; + skewY -= to->tweenRotate * M_PI * 2; } } From 0a30a9a6047a8b16cd66ec1211afebca2aa4f9d4 Mon Sep 17 00:00:00 2001 From: "byeonggee.seo" Date: Fri, 20 Dec 2013 16:10:15 +0900 Subject: [PATCH 03/70] spine simple JS binding supported --- .../project.pbxproj.REMOVED.git-id | 2 +- .../scripting/javascript/bindings/Android.mk | 8 +++- .../bindings/proj.win32/libJSBinding.vcxproj | 2 + .../proj.win32/libJSBinding.vcxproj.filters | 6 +++ .../multi-platform-js/Classes/AppDelegate.cpp | 2 + .../proj.android/jni/Android.mk | 2 + tools/tojs/cocos2dx_spine.ini | 40 +++++++++++++++++++ tools/tojs/genbindings.sh | 5 ++- 8 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 tools/tojs/cocos2dx_spine.ini diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index c4362e57ff..1db1126f95 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -4cd02813dfcd14b7de3ccb157cd0f25b0bce9f37 \ No newline at end of file +1458a8d0a6bab41613b44cd39a46beabb6db78a6 \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/Android.mk b/cocos/scripting/javascript/bindings/Android.mk index f6e3f684a6..287a9a469b 100644 --- a/cocos/scripting/javascript/bindings/Android.mk +++ b/cocos/scripting/javascript/bindings/Android.mk @@ -14,7 +14,8 @@ LOCAL_SRC_FILES := ScriptingCore.cpp \ jsb_opengl_functions.cpp \ jsb_opengl_manual.cpp \ jsb_opengl_registration.cpp \ - ../../auto-generated/js-bindings/jsb_cocos2dx_auto.cpp + ../../auto-generated/js-bindings/jsb_cocos2dx_auto.cpp \ + ../../auto-generated/js-bindings/jsb_cocos2dx_spine_auto.cpp LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT @@ -24,7 +25,10 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../../audio/include \ $(LOCAL_PATH)/../../../storage \ $(LOCAL_PATH)/../../auto-generated/js-bindings \ - $(LOCAL_PATH)/../../../../extensions + $(LOCAL_PATH)/../../../../extensions \ + $(LOCAL_PATH)/../../../editor-support/spine \ + $(LOCAL_PATH)/../../../editor-support + LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../../auto-generated/js-bindings \ diff --git a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj index a4cbbd4d50..e959aa34a6 100644 --- a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj +++ b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj @@ -12,6 +12,7 @@ + @@ -23,6 +24,7 @@ + diff --git a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters index 85bb2eccd3..13bcceb35b 100644 --- a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters +++ b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters @@ -41,6 +41,9 @@ generated + + generated + @@ -79,6 +82,9 @@ generated + + generated + diff --git a/template/multi-platform-js/Classes/AppDelegate.cpp b/template/multi-platform-js/Classes/AppDelegate.cpp index e409b974b5..0794c10c9a 100644 --- a/template/multi-platform-js/Classes/AppDelegate.cpp +++ b/template/multi-platform-js/Classes/AppDelegate.cpp @@ -5,6 +5,7 @@ #include "ScriptingCore.h" #include "jsb_cocos2dx_auto.hpp" #include "jsb_cocos2dx_extension_auto.hpp" +#include "jsb_cocos2dx_spine_auto.hpp" #include "cocos2d_specifics.hpp" #include "extension/jsb_cocos2dx_extension_manual.h" #include "chipmunk/js_bindings_chipmunk_registration.h" @@ -40,6 +41,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_all_cocos2dx_extension); sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(register_all_cocos2dx_extension_manual); + sc->addRegisterCallback(register_all_cocos2dx_spine); sc->addRegisterCallback(jsb_register_chipmunk); sc->addRegisterCallback(JSB_register_opengl); sc->addRegisterCallback(jsb_register_system); diff --git a/template/multi-platform-js/proj.android/jni/Android.mk b/template/multi-platform-js/proj.android/jni/Android.mk index 08a89b6f22..ae780817f9 100644 --- a/template/multi-platform-js/proj.android/jni/Android.mk +++ b/template/multi-platform-js/proj.android/jni/Android.mk @@ -15,6 +15,7 @@ LOCAL_WHOLE_STATIC_LIBRARIES := cocos_jsb_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_localstorage_static +LOCAL_WHOLE_STATIC_LIBRARIES += spine_static LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=2 -DCOCOS2D_JAVASCRIPT @@ -25,3 +26,4 @@ $(call import-module,scripting/javascript/bindings) $(call import-module,scripting/javascript/bindings/extension) $(call import-module,scripting/javascript/bindings/chipmunk) $(call import-module,scripting/javascript/bindings/localstorage) +$(call import-module,editor-support/spine) diff --git a/tools/tojs/cocos2dx_spine.ini b/tools/tojs/cocos2dx_spine.ini new file mode 100644 index 0000000000..62f4ba8f6a --- /dev/null +++ b/tools/tojs/cocos2dx_spine.ini @@ -0,0 +1,40 @@ +[cocos2dx_spine] +prefix = cocos2dx_spine + +target_namespace = cc + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 + +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/gui -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath/include -I%(cocosdir)s/extensions -I%(cocosdir)s/external -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s + +cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +headers = %(cocosdir)s/cocos/editor-support/spine/spine-cocos2dx.h + +skip = CCSkeleton::[createWithData], + CCSkeletonAnimation::[createWithData] + +classes = CCSkeleton CCSkeletonAnimation + +remove_prefix = CC + +classes_have_no_parents = + +base_classes_to_skip = + +abstract_classes = + +script_control_cpp = + +rename_functions = + +rename_classes = \ No newline at end of file diff --git a/tools/tojs/genbindings.sh b/tools/tojs/genbindings.sh index fedf3cacd5..00d2d7a8c5 100755 --- a/tools/tojs/genbindings.sh +++ b/tools/tojs/genbindings.sh @@ -92,4 +92,7 @@ echo "Generating bindings for cocos2dx_gui..." LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_gui.ini -s cocos2dx_gui -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_gui_auto echo "Generating bindings for cocos2dx_studio..." -LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_studio.ini -s cocos2dx_studio -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_studio_auto \ No newline at end of file +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_studio.ini -s cocos2dx_studio -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_studio_auto + +echo "Generating bindings for cocos2dx_spine..." +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_spine.ini -s cocos2dx_spine -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_spine_auto \ No newline at end of file From f3e4d9277e477255004d9041969f3957930a6d53 Mon Sep 17 00:00:00 2001 From: "byeonggee.seo" Date: Fri, 20 Dec 2013 19:16:16 +0900 Subject: [PATCH 04/70] spine android build phase moved --- cocos/2d/Android.mk | 2 ++ template/multi-platform-js/proj.android/jni/Android.mk | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/2d/Android.mk b/cocos/2d/Android.mk index 9f5eba4108..cd4ec4c772 100644 --- a/cocos/2d/Android.mk +++ b/cocos/2d/Android.mk @@ -210,6 +210,7 @@ LOCAL_EXPORT_LDLIBS := -lGLESv2 \ LOCAL_WHOLE_STATIC_LIBRARIES := cocos_freetype2_static LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static +LOCAL_WHOLE_STATIC_LIBRARIES += spine_static # define the macro to compile through support/zip_support/ioapi.c LOCAL_CFLAGS := -Wno-psabi -DUSE_FILE32API @@ -222,3 +223,4 @@ include $(BUILD_STATIC_LIBRARY) $(call import-module,freetype2/prebuilt/android) $(call import-module,chipmunk) $(call import-module,2d/platform/android) +$(call import-module,editor-support/spine) \ No newline at end of file diff --git a/template/multi-platform-js/proj.android/jni/Android.mk b/template/multi-platform-js/proj.android/jni/Android.mk index ae780817f9..48746a0ffc 100644 --- a/template/multi-platform-js/proj.android/jni/Android.mk +++ b/template/multi-platform-js/proj.android/jni/Android.mk @@ -15,7 +15,6 @@ LOCAL_WHOLE_STATIC_LIBRARIES := cocos_jsb_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += jsb_localstorage_static -LOCAL_WHOLE_STATIC_LIBRARIES += spine_static LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=2 -DCOCOS2D_JAVASCRIPT @@ -25,5 +24,4 @@ include $(BUILD_SHARED_LIBRARY) $(call import-module,scripting/javascript/bindings) $(call import-module,scripting/javascript/bindings/extension) $(call import-module,scripting/javascript/bindings/chipmunk) -$(call import-module,scripting/javascript/bindings/localstorage) -$(call import-module,editor-support/spine) +$(call import-module,scripting/javascript/bindings/localstorage) \ No newline at end of file From ef1709bc3ddee443310ccaa26a0e149c337bd7df Mon Sep 17 00:00:00 2001 From: "byeonggee.seo" Date: Fri, 20 Dec 2013 19:20:13 +0900 Subject: [PATCH 05/70] Add SpineTest to TestJavascript 1 --- build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- samples/Javascript/TestJavascript/Classes/AppDelegate.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id index e83c9c8ec4..fe8529d970 100644 --- a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -52a991e88e049cd371a153ee168260276a7ac664 \ No newline at end of file +4b95c782427340850fcd34136156544774b2effd \ No newline at end of file diff --git a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp index a85f0939c7..0da7de9714 100644 --- a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp +++ b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp @@ -8,6 +8,7 @@ #include "jsb_cocos2dx_builder_auto.hpp" #include "jsb_cocos2dx_studio_auto.hpp" #include "jsb_cocos2dx_gui_auto.hpp" +#include "jsb_cocos2dx_spine_auto.hpp" #include "extension/jsb_cocos2dx_extension_manual.h" #include "cocostudio/jsb_cocos2dx_studio_manual.h" #include "gui/jsb_cocos2dx_gui_manual.h" @@ -70,6 +71,8 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_all_cocos2dx_studio); sc->addRegisterCallback(register_all_cocos2dx_studio_manual); + sc->addRegisterCallback(register_all_cocos2dx_spine); + sc->start(); #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) From d5ea2d22a5980373bba249c8b28121623f43d821 Mon Sep 17 00:00:00 2001 From: "byeonggee.seo" Date: Fri, 20 Dec 2013 19:45:50 +0900 Subject: [PATCH 06/70] undo my mistake --- build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id index fe8529d970..e83c9c8ec4 100644 --- a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -4b95c782427340850fcd34136156544774b2effd \ No newline at end of file +52a991e88e049cd371a153ee168260276a7ac664 \ No newline at end of file From 9901703f4a3260945b175e5eccec928eed5289a2 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 23 Dec 2013 05:52:59 +0000 Subject: [PATCH 07/70] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 0130b23910..a388e918ef 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 0130b23910e0fe7aa27738403c84ee259677a1b8 +Subproject commit a388e918ef871c0fcfeb69bd71b1c784747871b8 From ba809a0096e1e61639ca2cb39a60dc1d58e9c757 Mon Sep 17 00:00:00 2001 From: yinkaile Date: Mon, 23 Dec 2013 14:05:46 +0800 Subject: [PATCH 08/70] change const char* to const std::string& --- .../editor-support/cocostudio/CCArmature.cpp | 24 ++++++------- cocos/editor-support/cocostudio/CCArmature.h | 16 ++++----- .../cocostudio/CCArmatureAnimation.cpp | 12 +++---- .../cocostudio/CCArmatureAnimation.h | 22 ++++++------ .../cocostudio/CCArmatureDataManager.cpp | 34 +++++++++---------- .../cocostudio/CCArmatureDataManager.h | 34 +++++++++---------- cocos/editor-support/cocostudio/CCBone.cpp | 11 +++--- cocos/editor-support/cocostudio/CCBone.h | 6 ++-- .../cocostudio/CCDataReaderHelper.cpp | 10 +++--- .../cocostudio/CCDataReaderHelper.h | 10 +++--- cocos/editor-support/cocostudio/CCDatas.cpp | 8 ++--- cocos/editor-support/cocostudio/CCDatas.h | 10 +++--- .../cocostudio/CCDisplayManager.cpp | 2 +- .../cocostudio/CCDisplayManager.h | 2 +- cocos/editor-support/cocostudio/CCSkin.cpp | 4 +-- cocos/editor-support/cocostudio/CCSkin.h | 4 +-- .../cocostudio/CCSpriteFrameCacheHelper.cpp | 2 +- .../cocostudio/CCSpriteFrameCacheHelper.h | 2 +- .../CocoStudioArmatureTest/ArmatureScene.cpp | 16 ++++----- .../CocoStudioArmatureTest/ArmatureScene.h | 8 ++--- 20 files changed, 115 insertions(+), 122 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 94b09dd4be..27b2b8db77 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -56,7 +56,7 @@ Armature *Armature::create() } -Armature *Armature::create(const char *name) +Armature *Armature::create(const std::string& name) { Armature *armature = new Armature(); if (armature && armature->init(name)) @@ -68,7 +68,7 @@ Armature *Armature::create(const char *name) return nullptr; } -Armature *Armature::create(const char *name, Bone *parentBone) +Armature *Armature::create(const std::string& name, Bone *parentBone) { Armature *armature = new Armature(); if (armature && armature->init(name, parentBone)) @@ -105,7 +105,7 @@ bool Armature::init() } -bool Armature::init(const char *name) +bool Armature::init(const std::string& name) { bool bRet = false; do @@ -121,14 +121,12 @@ bool Armature::init(const char *name) _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; - _name = name == nullptr ? "" : name; + _name = name; ArmatureDataManager *armatureDataManager = ArmatureDataManager::getInstance(); if(_name.length() != 0) { - _name = name; - AnimationData *animationData = armatureDataManager->getAnimationData(name); CCASSERT(animationData, "AnimationData not exist! "); @@ -196,14 +194,14 @@ bool Armature::init(const char *name) return bRet; } -bool Armature::init(const char *name, Bone *parentBone) +bool Armature::init(const std::string& name, Bone *parentBone) { _parentBone = parentBone; return init(name); } -Bone *Armature::createBone(const char *boneName) +Bone *Armature::createBone(const std::string& boneName) { Bone *existedBone = getBone(boneName); if(existedBone != nullptr) @@ -233,12 +231,12 @@ Bone *Armature::createBone(const char *boneName) } -void Armature::addBone(Bone *bone, const char *parentName) +void Armature::addBone(Bone *bone, const std::string& parentName) { CCASSERT( bone != nullptr, "Argument must be non-nil"); CCASSERT(_boneDic.at(bone->getName()) == nullptr, "bone already added. It can't be added again"); - if (nullptr != parentName) + if ("" != parentName) { Bone *boneParent = _boneDic.at(parentName); if (boneParent) @@ -278,13 +276,13 @@ void Armature::removeBone(Bone *bone, bool recursion) } -Bone *Armature::getBone(const char *name) const +Bone *Armature::getBone(const std::string& name) const { return _boneDic.at(name); } -void Armature::changeBoneParent(Bone *bone, const char *parentName) +void Armature::changeBoneParent(Bone *bone, const std::string& parentName) { CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!"); @@ -294,7 +292,7 @@ void Armature::changeBoneParent(Bone *bone, const char *parentName) bone->setParentBone(nullptr); } - if (parentName != nullptr) + if (parentName != "") { Bone *boneParent = _boneDic.at(parentName); diff --git a/cocos/editor-support/cocostudio/CCArmature.h b/cocos/editor-support/cocostudio/CCArmature.h index 44ea889c03..dead282395 100644 --- a/cocos/editor-support/cocostudio/CCArmature.h +++ b/cocos/editor-support/cocostudio/CCArmature.h @@ -84,9 +84,9 @@ public: * @param name Armature will use the name to find the ArmatureData to initializes it. * @return A initialized armature which is marked as "autorelease". */ - static Armature *create(const char *name); + static Armature *create(const std::string& name); - static Armature *create(const char *name, Bone *parentBone); + static Armature *create(const std::string& name, Bone *parentBone); public: /** @@ -108,29 +108,29 @@ public: * Init an armature with specified name * @param name Armature name */ - virtual bool init(const char *name); + virtual bool init(const std::string& name); - virtual bool init(const char *name, Bone *parentBone); + virtual bool init(const std::string& name, Bone *parentBone); /** * Add a Bone to this Armature, * * @param bone The Bone you want to add to Armature * @param parentName The parent Bone's name you want to add to . If it's nullptr, then set Armature to its parent */ - virtual void addBone(Bone *bone, const char *parentName); + virtual void addBone(Bone *bone, const std::string& parentName); /** * Get a bone with the specified name * * @param name The bone's name you want to get */ - virtual Bone *getBone(const char *name) const; + virtual Bone *getBone(const std::string& name) const; /** * Change a bone's parent with the specified parent name. * * @param bone The bone you want to change parent * @param parentName The new parent's name. */ - virtual void changeBoneParent(Bone *bone, const char *parentName); + virtual void changeBoneParent(Bone *bone, const std::string& parentName); /** * Remove a bone with the specified name. If recursion it will also remove child Bone recursionly. * @@ -247,7 +247,7 @@ protected: * @js NA * @lua NA */ - Bone *createBone(const char *boneName ); + Bone *createBone(const std::string& boneName ); protected: ArmatureData *_armatureData; diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp index b4e6c42e3b..1b6c17bc60 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp @@ -164,11 +164,11 @@ float ArmatureAnimation::getSpeedScale() const } -void ArmatureAnimation::play(const char *animationName, int durationTo, int loop) +void ArmatureAnimation::play(const std::string& animationName, int durationTo, int loop) { CCASSERT(_animationData, "_animationData can not be null"); - _movementData = _animationData->getMovement(animationName); + _movementData = _animationData->getMovement(animationName.c_str()); CCASSERT(_movementData, "_movementData can not be null"); //! Get key frame count @@ -461,11 +461,11 @@ void ArmatureAnimation::setFrameEventCallFunc(Object *target, SEL_FrameEventCall _frameEventCallFunc = callFunc; } -void ArmatureAnimation::setMovementEventCallFunc(std::function listener) +void ArmatureAnimation::setMovementEventCallFunc(std::function listener) { _movementEventListener = listener; } -void ArmatureAnimation::setFrameEventCallFunc(std::function listener) +void ArmatureAnimation::setFrameEventCallFunc(std::function listener) { _frameEventListener = listener; } @@ -477,7 +477,7 @@ void ArmatureAnimation::setUserObject(Object *pUserObject) _userObject = pUserObject; } -void ArmatureAnimation::frameEvent(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex) +void ArmatureAnimation::frameEvent(Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex) { if ((_frameEventTarget && _frameEventCallFunc) || _frameEventListener) { @@ -492,7 +492,7 @@ void ArmatureAnimation::frameEvent(Bone *bone, const char *frameEventName, int o } -void ArmatureAnimation::movementEvent(Armature *armature, MovementEventType movementType, const char *movementID) +void ArmatureAnimation::movementEvent(Armature *armature, MovementEventType movementType, const std::string& movementID) { if ((_movementEventTarget && _movementEventCallFunc) || _movementEventListener) { diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.h b/cocos/editor-support/cocostudio/CCArmatureAnimation.h index 25955ecc49..b5fe2a01d9 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.h +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.h @@ -44,8 +44,8 @@ enum MovementEventType class Armature; class Bone; -typedef void (cocos2d::Object::*SEL_MovementEventCallFunc)(Armature *, MovementEventType, const char *); -typedef void (cocos2d::Object::*SEL_FrameEventCallFunc)(Bone *, const char *, int, int); +typedef void (cocos2d::Object::*SEL_MovementEventCallFunc)(Armature *, MovementEventType, const std::string&); +typedef void (cocos2d::Object::*SEL_FrameEventCallFunc)(Bone *, const std::string&, int, int); #define movementEvent_selector(_SELECTOR) (cocostudio::SEL_MovementEventCallFunc)(&_SELECTOR) #define frameEvent_selector(_SELECTOR) (cocostudio::SEL_FrameEventCallFunc)(&_SELECTOR) @@ -53,7 +53,7 @@ typedef void (cocos2d::Object::*SEL_FrameEventCallFunc)(Bone *, const char *, in struct FrameEvent { Bone *bone; - const char *frameEventName; + std::string frameEventName; int originFrameIndex; int currentFrameIndex; }; @@ -62,7 +62,7 @@ struct MovementEvent { Armature *armature; MovementEventType movementType; - const char *movementID; + std::string movementID; }; class ArmatureAnimation : public ProcessBase @@ -123,7 +123,7 @@ public: * loop = 0 : this animation is not loop * loop > 0 : this animation is loop */ - virtual void play(const char *animationName, int durationTo = -1, int loop = -1); + virtual void play(const std::string& animationName, int durationTo = -1, int loop = -1); /** * Play animation by index, the other param is the same to play. @@ -191,8 +191,8 @@ public: */ CC_DEPRECATED_ATTRIBUTE void setFrameEventCallFunc(cocos2d::Object *target, SEL_FrameEventCallFunc callFunc); - void setMovementEventCallFunc(std::function listener); - void setFrameEventCallFunc(std::function listener); + void setMovementEventCallFunc(std::function listener); + void setFrameEventCallFunc(std::function listener); virtual void setAnimationData(AnimationData *data) { @@ -254,12 +254,12 @@ protected: * @js NA * @lua NA */ - void frameEvent(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex); + void frameEvent(Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex); /** * Emit a movement event */ - void movementEvent(Armature *armature, MovementEventType movementType, const char *movementID); + void movementEvent(Armature *armature, MovementEventType movementType, const std::string& movementID); void updateMovementList(); @@ -319,8 +319,8 @@ protected: cocos2d::Object *_frameEventTarget; - std::function _movementEventListener; - std::function _frameEventListener; + std::function _movementEventListener; + std::function _frameEventListener; }; } diff --git a/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp b/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp index 6e6f6bd642..da1506baa8 100644 --- a/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp @@ -89,7 +89,7 @@ bool ArmatureDataManager::init() return bRet; } -void ArmatureDataManager::removeArmatureFileInfo(const char *configFilePath) +void ArmatureDataManager::removeArmatureFileInfo(const std::string& configFilePath) { if (RelativeData *data = getRelativeData(configFilePath)) { @@ -119,7 +119,7 @@ void ArmatureDataManager::removeArmatureFileInfo(const char *configFilePath) } -void ArmatureDataManager::addArmatureData(const char *id, ArmatureData *armatureData, const char *configFilePath) +void ArmatureDataManager::addArmatureData(const std::string& id, ArmatureData *armatureData, const std::string& configFilePath) { if (RelativeData *data = getRelativeData(configFilePath)) { @@ -129,19 +129,19 @@ void ArmatureDataManager::addArmatureData(const char *id, ArmatureData *armature _armarureDatas.insert(id, armatureData); } -ArmatureData *ArmatureDataManager::getArmatureData(const char *id) +ArmatureData *ArmatureDataManager::getArmatureData(const std::string& id) { ArmatureData *armatureData = nullptr; armatureData = (ArmatureData *)_armarureDatas.at(id); return armatureData; } -void ArmatureDataManager::removeArmatureData(const char *id) +void ArmatureDataManager::removeArmatureData(const std::string& id) { _armarureDatas.erase(id); } -void ArmatureDataManager::addAnimationData(const char *id, AnimationData *animationData, const char *configFilePath) +void ArmatureDataManager::addAnimationData(const std::string& id, AnimationData *animationData, const std::string& configFilePath) { if (RelativeData *data = getRelativeData(configFilePath)) { @@ -151,19 +151,19 @@ void ArmatureDataManager::addAnimationData(const char *id, AnimationData *animat _animationDatas.insert(id, animationData); } -AnimationData *ArmatureDataManager::getAnimationData(const char *id) +AnimationData *ArmatureDataManager::getAnimationData(const std::string& id) { AnimationData *animationData = nullptr; animationData = (AnimationData *)_animationDatas.at(id); return animationData; } -void ArmatureDataManager::removeAnimationData(const char *id) +void ArmatureDataManager::removeAnimationData(const std::string& id) { _animationDatas.erase(id); } -void ArmatureDataManager::addTextureData(const char *id, TextureData *textureData, const char *configFilePath) +void ArmatureDataManager::addTextureData(const std::string& id, TextureData *textureData, const std::string& configFilePath) { if (RelativeData *data = getRelativeData(configFilePath)) { @@ -174,7 +174,7 @@ void ArmatureDataManager::addTextureData(const char *id, TextureData *textureDat } -TextureData *ArmatureDataManager::getTextureData(const char *id) +TextureData *ArmatureDataManager::getTextureData(const std::string& id) { TextureData *textureData = nullptr; textureData = (TextureData *)_textureDatas.at(id); @@ -182,12 +182,12 @@ TextureData *ArmatureDataManager::getTextureData(const char *id) } -void ArmatureDataManager::removeTextureData(const char *id) +void ArmatureDataManager::removeTextureData(const std::string& id) { _textureDatas.erase(id); } -void ArmatureDataManager::addArmatureFileInfo(const char *configFilePath) +void ArmatureDataManager::addArmatureFileInfo(const std::string& configFilePath) { addRelativeData(configFilePath); @@ -195,7 +195,7 @@ void ArmatureDataManager::addArmatureFileInfo(const char *configFilePath) DataReaderHelper::getInstance()->addDataFromFile(configFilePath); } -void ArmatureDataManager::addArmatureFileInfoAsync(const char *configFilePath, Object *target, SEL_SCHEDULE selector) +void ArmatureDataManager::addArmatureFileInfoAsync(const std::string& configFilePath, Object *target, SEL_SCHEDULE selector) { addRelativeData(configFilePath); @@ -203,7 +203,7 @@ void ArmatureDataManager::addArmatureFileInfoAsync(const char *configFilePath, O DataReaderHelper::getInstance()->addDataFromFileAsync("", "", configFilePath, target, selector); } -void ArmatureDataManager::addArmatureFileInfo(const char *imagePath, const char *plistPath, const char *configFilePath) +void ArmatureDataManager::addArmatureFileInfo(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath) { addRelativeData(configFilePath); @@ -212,7 +212,7 @@ void ArmatureDataManager::addArmatureFileInfo(const char *imagePath, const char addSpriteFrameFromFile(plistPath, imagePath); } -void ArmatureDataManager::addArmatureFileInfoAsync(const char *imagePath, const char *plistPath, const char *configFilePath, Object *target, SEL_SCHEDULE selector) +void ArmatureDataManager::addArmatureFileInfoAsync(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath, Object *target, SEL_SCHEDULE selector) { addRelativeData(configFilePath); @@ -221,7 +221,7 @@ void ArmatureDataManager::addArmatureFileInfoAsync(const char *imagePath, const addSpriteFrameFromFile(plistPath, imagePath); } -void ArmatureDataManager::addSpriteFrameFromFile(const char *plistPath, const char *imagePath, const char *configFilePath) +void ArmatureDataManager::addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath, const std::string& configFilePath) { if (RelativeData *data = getRelativeData(configFilePath)) { @@ -249,7 +249,7 @@ const cocos2d::Map& ArmatureDataManager::getTextureDa return _textureDatas; } -void CCArmatureDataManager::addRelativeData(const char *configFilePath) +void CCArmatureDataManager::addRelativeData(const std::string& configFilePath) { if (_relativeDatas.find(configFilePath) == _relativeDatas.end()) { @@ -257,7 +257,7 @@ void CCArmatureDataManager::addRelativeData(const char *configFilePath) } } -RelativeData *CCArmatureDataManager::getRelativeData(const char* configFilePath) +RelativeData *CCArmatureDataManager::getRelativeData(const std::string& configFilePath) { return &_relativeDatas[configFilePath]; } diff --git a/cocos/editor-support/cocostudio/CCArmatureDataManager.h b/cocos/editor-support/cocostudio/CCArmatureDataManager.h index e684e615ff..137fbe5d3e 100644 --- a/cocos/editor-support/cocostudio/CCArmatureDataManager.h +++ b/cocos/editor-support/cocostudio/CCArmatureDataManager.h @@ -77,89 +77,89 @@ public: * @param id The id of the armature data * @param armatureData ArmatureData * */ - void addArmatureData(const char *id, ArmatureData *armatureData, const char *configFilePath = ""); + void addArmatureData(const std::string& id, ArmatureData *armatureData, const std::string& configFilePath = ""); /** * @brief get armature data * @param id the id of the armature data you want to get * @return ArmatureData * */ - ArmatureData *getArmatureData(const char *id); + ArmatureData *getArmatureData(const std::string& id); /** * @brief remove armature data * @param id the id of the armature data you want to get */ - void removeArmatureData(const char *id); + void removeArmatureData(const std::string& id); /** * @brief add animation data * @param id the id of the animation data * @return AnimationData * */ - void addAnimationData(const char *id, AnimationData *animationData, const char *configFilePath = ""); + void addAnimationData(const std::string& id, AnimationData *animationData, const std::string& configFilePath = ""); /** * @brief get animation data from _animationDatas(Dictionary) * @param id the id of the animation data you want to get * @return AnimationData * */ - AnimationData *getAnimationData(const char *id); + AnimationData *getAnimationData(const std::string& id); /** * @brief remove animation data * @param id the id of the animation data */ - void removeAnimationData(const char *id); + void removeAnimationData(const std::string& id); /** * @brief add texture data * @param id the id of the texture data * @return TextureData * */ - void addTextureData(const char *id, TextureData *textureData, const char *configFilePath = ""); + void addTextureData(const std::string& id, TextureData *textureData, const std::string& configFilePath = ""); /** * @brief get texture data * @param id the id of the texture data you want to get * @return TextureData * */ - TextureData *getTextureData(const char *id); + TextureData *getTextureData(const std::string& id); /** * @brief remove texture data * @param id the id of the texture data you want to get */ - void removeTextureData(const char *id); + void removeTextureData(const std::string& id); /** * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. */ - void addArmatureFileInfo(const char *configFilePath); + void addArmatureFileInfo(const std::string& configFilePath); /** * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. * It will load data in a new thread */ - void addArmatureFileInfoAsync(const char *configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector); + void addArmatureFileInfoAsync(const std::string& configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector); /** * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. */ - void addArmatureFileInfo(const char *imagePath, const char *plistPath, const char *configFilePath); + void addArmatureFileInfo(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath); /** * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. * It will load data in a new thread */ - void addArmatureFileInfoAsync(const char *imagePath, const char *plistPath, const char *configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector); + void addArmatureFileInfoAsync(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector); /** * @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name */ - void addSpriteFrameFromFile(const char *plistPath, const char *imagePath, const char *configFilePath = ""); + void addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath, const std::string& configFilePath = ""); - virtual void removeArmatureFileInfo(const char *configFilePath); + virtual void removeArmatureFileInfo(const std::string& configFilePath); /** @@ -173,8 +173,8 @@ public: const cocos2d::Map& getTextureDatas() const; protected: - void addRelativeData(const char* configFilePath); - RelativeData *getRelativeData(const char* configFilePath); + void addRelativeData(const std::string& configFilePath); + RelativeData *getRelativeData(const std::string& configFilePath); private: /** * @brief save amature datas diff --git a/cocos/editor-support/cocostudio/CCBone.cpp b/cocos/editor-support/cocostudio/CCBone.cpp index bada90df93..a6b46b3bef 100644 --- a/cocos/editor-support/cocostudio/CCBone.cpp +++ b/cocos/editor-support/cocostudio/CCBone.cpp @@ -47,7 +47,7 @@ Bone *Bone::create() } -Bone *Bone::create(const char *name) +Bone *Bone::create(const std::string& name) { Bone *pBone = new Bone(); @@ -101,16 +101,13 @@ bool Bone::init() } -bool Bone::init(const char *name) +bool Bone::init(const std::string& name) { bool bRet = false; do { - if(nullptr != name) - { - _name = name; - } + _name = name; CC_SAFE_DELETE(_tweenData); _tweenData = new FrameData(); @@ -425,7 +422,7 @@ void Bone::changeDisplayByIndex(int index, bool force) } -void Bone::changeDisplayByName(const char *name, bool force) +void Bone::changeDisplayByName(const std::string& name, bool force) { _displayManager->changeDisplayByName(name, force); } diff --git a/cocos/editor-support/cocostudio/CCBone.h b/cocos/editor-support/cocostudio/CCBone.h index dd5dc8634f..6d469eb965 100644 --- a/cocos/editor-support/cocostudio/CCBone.h +++ b/cocos/editor-support/cocostudio/CCBone.h @@ -50,7 +50,7 @@ public: * @param name If name is not null, then set name to the bone's name * @return A initialized bone which is marked as "autorelease". */ - static Bone *create(const char *name); + static Bone *create(const std::string& name); public: /** @@ -72,7 +72,7 @@ public: * Initializes a Bone with the specified name * @param name Bone's name. */ - virtual bool init(const char *name); + virtual bool init(const std::string& name); /** * Add display and use displayData to init the display. @@ -92,7 +92,7 @@ public: void removeDisplay(int index); void changeDisplayByIndex(int index, bool force); - void changeDisplayByName(const char *name, bool force); + void changeDisplayByName(const std::string& name, bool force); /** * Add a child to this bone, and it will let this child call setParent(Bone *parent) function to set self to it's parent diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index 8787798d63..fe287c6d14 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -254,7 +254,7 @@ DataReaderHelper::~DataReaderHelper() _dataReaderHelper = nullptr; } -void DataReaderHelper::addDataFromFile(const char *filePath) +void DataReaderHelper::addDataFromFile(const std::string& filePath) { /* * Check if file is already added to ArmatureDataManager, if then return. @@ -307,7 +307,7 @@ void DataReaderHelper::addDataFromFile(const char *filePath) free(pFileContent); } -void DataReaderHelper::addDataFromFileAsync(const char *imagePath, const char *plistPath, const char *filePath, Object *target, SEL_SCHEDULE selector) +void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const std::string& plistPath, const std::string& filePath, Object *target, SEL_SCHEDULE selector) { /* * Check if file is already added to ArmatureDataManager, if then return. @@ -470,7 +470,7 @@ void DataReaderHelper::addDataAsyncCallBack(float dt) } -void DataReaderHelper::removeConfigFile(const char *configFile) +void DataReaderHelper::removeConfigFile(const std::string& configFile) { std::vector::iterator it = _configFileList.end(); for (std::vector::iterator i = _configFileList.begin(); i != _configFileList.end(); i++) @@ -489,7 +489,7 @@ void DataReaderHelper::removeConfigFile(const char *configFile) -void DataReaderHelper::addDataFromCache(const char *pFileContent, DataInfo *dataInfo) +void DataReaderHelper::addDataFromCache(const char* pFileContent, DataInfo *dataInfo) { tinyxml2::XMLDocument document; document.Parse(pFileContent); @@ -1180,7 +1180,7 @@ ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML, D -void DataReaderHelper::addDataFromJsonCache(const char *fileContent, DataInfo *dataInfo) +void DataReaderHelper::addDataFromJsonCache(const char* fileContent, DataInfo *dataInfo) { JsonDictionary json; json.initWithDescription(fileContent); diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.h b/cocos/editor-support/cocostudio/CCDataReaderHelper.h index 227481fca0..553a27f15e 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.h +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.h @@ -108,12 +108,12 @@ public: */ ~DataReaderHelper(); - void addDataFromFile(const char *filePath); - void addDataFromFileAsync(const char *imagePath, const char *plistPath, const char *filePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector); + void addDataFromFile(const std::string& filePath); + void addDataFromFileAsync(const std::string& imagePath, const std::string& plistPath, const std::string& filePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector); void addDataAsyncCallBack(float dt); - void removeConfigFile(const char *configFile); + void removeConfigFile(const std::string& configFile); public: /** @@ -122,7 +122,7 @@ public: * * @param xmlPath The cache of the xml */ - static void addDataFromCache(const char *pFileContent, DataInfo *dataInfo = nullptr); + static void addDataFromCache(const char* pFileContent, DataInfo *dataInfo = nullptr); @@ -154,7 +154,7 @@ public: static ContourData *decodeContour(tinyxml2::XMLElement *contourXML, DataInfo *dataInfo); public: - static void addDataFromJsonCache(const char *fileContent, DataInfo *dataInfo = nullptr); + static void addDataFromJsonCache(const char* fileContent, DataInfo *dataInfo = nullptr); static ArmatureData *decodeArmature(JsonDictionary &json, DataInfo *dataInfo); static BoneData *decodeBone(JsonDictionary &json, DataInfo *dataInfo); diff --git a/cocos/editor-support/cocostudio/CCDatas.cpp b/cocos/editor-support/cocostudio/CCDatas.cpp index 01b15e2d8c..07b8599012 100644 --- a/cocos/editor-support/cocostudio/CCDatas.cpp +++ b/cocos/editor-support/cocostudio/CCDatas.cpp @@ -142,7 +142,7 @@ Color4B BaseData::getColor() return Color4B(r, g, b, a); } -const char *DisplayData::changeDisplayToTexture(const char *displayName) +const std::string& DisplayData::changeDisplayToTexture(const std::string& displayName) { // remove .xxx std::string textureName = displayName; @@ -241,7 +241,7 @@ void ArmatureData::addBoneData(BoneData *boneData) boneDataDic.insert(boneData->name, boneData); } -BoneData *ArmatureData::getBoneData(const char *boneName) +BoneData *ArmatureData::getBoneData(const std::string& boneName) { return static_cast(boneDataDic.at(boneName)); } @@ -343,7 +343,7 @@ void MovementData::addMovementBoneData(MovementBoneData *movBoneData) movBoneDataDic.insert(movBoneData->name, movBoneData); } -MovementBoneData *MovementData::getMovementBoneData(const char *boneName) +MovementBoneData *MovementData::getMovementBoneData(const std::string& boneName) { return movBoneDataDic.at(boneName); } @@ -364,7 +364,7 @@ void AnimationData::addMovement(MovementData *movData) movementNames.push_back(movData->name); } -MovementData *AnimationData::getMovement(const char *movementName) +MovementData *AnimationData::getMovement(const std::string& movementName) { return movementDataDic.at(movementName); } diff --git a/cocos/editor-support/cocostudio/CCDatas.h b/cocos/editor-support/cocostudio/CCDatas.h index 2343d63b11..4ab6d267ec 100644 --- a/cocos/editor-support/cocostudio/CCDatas.h +++ b/cocos/editor-support/cocostudio/CCDatas.h @@ -136,7 +136,7 @@ class DisplayData : public cocos2d::Object public: CC_CREATE_NO_PARAM_NO_INIT(DisplayData) - static const char *changeDisplayToTexture(const char *displayName); + static const std::string& changeDisplayToTexture(const std::string& displayName); public: /** * @js ctor @@ -279,7 +279,7 @@ public: bool init(); void addBoneData(BoneData *boneData); - BoneData *getBoneData(const char *boneName); + BoneData *getBoneData(const std::string& boneName); public: std::string name; cocos2d::Map boneDataDic; @@ -403,7 +403,7 @@ public: ~MovementData(void); void addMovementBoneData(MovementBoneData *movBoneData); - MovementBoneData *getMovementBoneData(const char *boneName); + MovementBoneData *getMovementBoneData(const std::string& boneName); public: std::string name; int duration; //! the frames this movement will last @@ -435,7 +435,7 @@ public: /** * @brief save movment bone data - * @key const char * + * @key const std::string& * @value MovementBoneData * */ cocos2d::Map movBoneDataDic; @@ -465,7 +465,7 @@ public: ~AnimationData(void); void addMovement(MovementData *movData); - MovementData *getMovement(const char *movementName); + MovementData *getMovement(const std::string& movementName); ssize_t getMovementCount(); public: std::string name; diff --git a/cocos/editor-support/cocostudio/CCDisplayManager.cpp b/cocos/editor-support/cocostudio/CCDisplayManager.cpp index 67301e376d..aa59698679 100644 --- a/cocos/editor-support/cocostudio/CCDisplayManager.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayManager.cpp @@ -243,7 +243,7 @@ void DisplayManager::changeDisplayByIndex(int index, bool force) setCurrentDecorativeDisplay(decoDisplay); } -void CCDisplayManager::changeDisplayByName(const char *name, bool force) +void CCDisplayManager::changeDisplayByName(const std::string& name, bool force) { for (int i = 0; i<_decoDisplayList.size(); i++) { diff --git a/cocos/editor-support/cocostudio/CCDisplayManager.h b/cocos/editor-support/cocostudio/CCDisplayManager.h index 991a03255c..75ba93b455 100644 --- a/cocos/editor-support/cocostudio/CCDisplayManager.h +++ b/cocos/editor-support/cocostudio/CCDisplayManager.h @@ -85,7 +85,7 @@ public: */ void changeDisplayByIndex(int index, bool force); - void changeDisplayByName(const char *name, bool force); + void changeDisplayByName(const std::string& name, bool force); cocos2d::Node *getDisplayRenderNode() const; DisplayType getDisplayRenderNodeType() const; diff --git a/cocos/editor-support/cocostudio/CCSkin.cpp b/cocos/editor-support/cocostudio/CCSkin.cpp index 00d8137a73..f408e7c4cc 100644 --- a/cocos/editor-support/cocostudio/CCSkin.cpp +++ b/cocos/editor-support/cocostudio/CCSkin.cpp @@ -51,7 +51,7 @@ Skin *Skin::create() return nullptr; } -Skin *Skin::createWithSpriteFrameName(const char *pszSpriteFrameName) +Skin *Skin::createWithSpriteFrameName(const std::string& pszSpriteFrameName) { Skin *skin = new Skin(); if(skin && skin->initWithSpriteFrameName(pszSpriteFrameName)) @@ -63,7 +63,7 @@ Skin *Skin::createWithSpriteFrameName(const char *pszSpriteFrameName) return nullptr; } -Skin *Skin::create(const char *pszFileName) +Skin *Skin::create(const std::string& pszFileName) { Skin *skin = new Skin(); if(skin && skin->initWithFile(pszFileName)) diff --git a/cocos/editor-support/cocostudio/CCSkin.h b/cocos/editor-support/cocostudio/CCSkin.h index 10dd72c5eb..d9e4c4e532 100644 --- a/cocos/editor-support/cocostudio/CCSkin.h +++ b/cocos/editor-support/cocostudio/CCSkin.h @@ -34,8 +34,8 @@ class Skin : public cocos2d::Sprite { public: static Skin *create(); - static Skin *createWithSpriteFrameName(const char *pszSpriteFrameName); - static Skin *create(const char *pszFileName); + static Skin *createWithSpriteFrameName(const std::string& pszSpriteFrameName); + static Skin *create(const std::string& pszFileName); public: /** * @js ctor diff --git a/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.cpp b/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.cpp index d3e2b620fd..fb1cf6065b 100644 --- a/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.cpp +++ b/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.cpp @@ -47,7 +47,7 @@ void SpriteFrameCacheHelper::purge() _spriteFrameCacheHelper = nullptr; } -void SpriteFrameCacheHelper::addSpriteFrameFromFile(const char *plistPath, const char *imagePath) +void SpriteFrameCacheHelper::addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath) { CCSpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath, imagePath); } diff --git a/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h b/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h index 60f7c85fda..89c20f6833 100644 --- a/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h +++ b/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h @@ -47,7 +47,7 @@ public: /** * @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name */ - void addSpriteFrameFromFile(const char *plistPath, const char *imagePath); + void addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath); private: SpriteFrameCacheHelper(); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index 3428885e99..a50301297b 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -535,20 +535,18 @@ std::string TestAnimationEvent::title() const { return "Test Armature Animation Event"; } -void TestAnimationEvent::animationEvent(Armature *armature, MovementEventType movementType, const char *movementID) +void TestAnimationEvent::animationEvent(Armature *armature, MovementEventType movementType, const std::string& movementID) { - std::string id = movementID; - if (movementType == LOOP_COMPLETE) { - if (id.compare("Fire") == 0) + if (movementID.compare("Fire") == 0) { ActionInterval *actionToRight = MoveTo::create(2, Point(VisibleRect::right().x - 50, VisibleRect::right().y)); armature->stopAllActions(); armature->runAction(Sequence::create(actionToRight, CallFunc::create( CC_CALLBACK_0(TestAnimationEvent::callback1, this)), nullptr)); armature->getAnimation()->play("Walk"); } - else if (id.compare("FireMax") == 0) + else if (movementID.compare("FireMax") == 0) { ActionInterval *actionToLeft = MoveTo::create(2, Point(VisibleRect::left().x + 50, VisibleRect::left().y)); armature->stopAllActions(); @@ -596,9 +594,9 @@ std::string TestFrameEvent::title() const { return "Test Frame Event"; } -void TestFrameEvent::onFrameEvent(Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex) +void TestFrameEvent::onFrameEvent(Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex) { - CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt, currentFrameIndex); + CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt.c_str(), currentFrameIndex); if (!_gridNode->getActionByTag(FRAME_EVENT_ACTION_TAG) || _gridNode->getActionByTag(FRAME_EVENT_ACTION_TAG)->isDone()) { @@ -778,9 +776,9 @@ std::string TestColliderDetector::title() const { return "Test Collider Detector"; } -void TestColliderDetector::onFrameEvent(Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex) +void TestColliderDetector::onFrameEvent(Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex) { - CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt, currentFrameIndex); + CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt.c_str(), currentFrameIndex); /* * originFrameIndex is the frame index editted in Action Editor diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h index b17a5a0163..06228f8f98 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h @@ -153,7 +153,7 @@ public: virtual void onEnter(); virtual std::string title() const override; - void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const char *movementID); + void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID); void callback1(); void callback2(); @@ -166,7 +166,7 @@ class TestFrameEvent : public ArmatureTestLayer public: virtual void onEnter(); virtual std::string title() const override; - void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex); + void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex); void checkAction(float dt); protected: NodeGrid* _gridNode; @@ -215,7 +215,7 @@ public: virtual void draw(); virtual void update(float delta); - void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex); + void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex); void initWorld(); @@ -273,7 +273,7 @@ public: virtual void update(float delta); virtual void draw(); - void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex); + void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex); void initWorld() {}; cocostudio::Armature *armature; From 69f1834e61c16686dfd979acd088f14e3d7246fd Mon Sep 17 00:00:00 2001 From: boyu0 Date: Mon, 23 Dec 2013 14:30:43 +0800 Subject: [PATCH 09/70] issue #2771: fix warning log and fix typo. --- cocos/physics/CCPhysicsBody.cpp | 4 ++-- samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cocos/physics/CCPhysicsBody.cpp b/cocos/physics/CCPhysicsBody.cpp index bd0acd3e57..8b9451f873 100644 --- a/cocos/physics/CCPhysicsBody.cpp +++ b/cocos/physics/CCPhysicsBody.cpp @@ -555,7 +555,7 @@ void PhysicsBody::setVelocity(const Point& velocity) { if (!_dynamic) { - CCLOG("physics warning: your cann't set velocity for a static body."); + CCLOG("physics warning: your can't set velocity for a static body."); return; } @@ -581,7 +581,7 @@ void PhysicsBody::setAngularVelocity(float velocity) { if (!_dynamic) { - CCLOG("physics warning: your cann't set angular velocity for a static body."); + CCLOG("physics warning: your can't set angular velocity for a static body."); return; } diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index 7697a53ab8..1aef4a2a94 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -396,7 +396,6 @@ void PhysicsDemo::onTouchMoved(Touch* touch, Event* event) if (it != _mouses.end()) { - it->second->getPhysicsBody()->setVelocity((touch->getLocation() - it->second->getPosition()) * 60.0f); it->second->setPosition(touch->getLocation()); } } From b7c0d7a9e8bf407b97ca620574f7bdb6f3cf42b4 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 23 Dec 2013 14:59:44 +0800 Subject: [PATCH 10/70] 1. remove redundant code in NewRenderTexture 2. rename protected beginWithClear to _beginWithClear --- cocos/2d/CCRenderTexture.cpp | 8 ++++---- cocos/2d/CCRenderTexture.h | 2 +- cocos/2d/renderer/CCNewRenderTexture.cpp | 17 +---------------- cocos/2d/renderer/CCNewRenderTexture.h | 8 ++------ 4 files changed, 8 insertions(+), 27 deletions(-) diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index d3d7b305a2..d63ecf2925 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -339,20 +339,20 @@ void RenderTexture::begin() void RenderTexture::beginWithClear(float r, float g, float b, float a) { - beginWithClear(r, g, b, a, 0, 0, GL_COLOR_BUFFER_BIT); + _beginWithClear(r, g, b, a, 0, 0, GL_COLOR_BUFFER_BIT); } void RenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue) { - beginWithClear(r, g, b, a, depthValue, 0, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + _beginWithClear(r, g, b, a, depthValue, 0, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); } void RenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue) { - beginWithClear(r, g, b, a, depthValue, stencilValue, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); + _beginWithClear(r, g, b, a, depthValue, stencilValue, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); } -void RenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags) +void RenderTexture::_beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags) { this->begin(); diff --git a/cocos/2d/CCRenderTexture.h b/cocos/2d/CCRenderTexture.h index 43246aa184..17a338d323 100644 --- a/cocos/2d/CCRenderTexture.h +++ b/cocos/2d/CCRenderTexture.h @@ -164,7 +164,7 @@ public: bool initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat format, GLuint depthStencilFormat); protected: - virtual void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags); + virtual void _beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags); GLuint _FBO; GLuint _depthRenderBufffer; diff --git a/cocos/2d/renderer/CCNewRenderTexture.cpp b/cocos/2d/renderer/CCNewRenderTexture.cpp index bd61970523..be8b7bc2d2 100644 --- a/cocos/2d/renderer/CCNewRenderTexture.cpp +++ b/cocos/2d/renderer/CCNewRenderTexture.cpp @@ -98,22 +98,7 @@ void NewRenderTexture::draw() } } -void NewRenderTexture::beginWithClear(float r, float g, float b, float a) -{ - beginWithClear(r, g, b, a, 0, 0, GL_COLOR_BUFFER_BIT); -} - -void NewRenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue) -{ - beginWithClear(r, g, b, a, depthValue, 0, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); -} - -void NewRenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue) -{ - beginWithClear(r, g, b, a, depthValue, stencilValue, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); -} - -void NewRenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags) +void NewRenderTexture::_beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags) { setClearColor(Color4F(r, g, b, a)); diff --git a/cocos/2d/renderer/CCNewRenderTexture.h b/cocos/2d/renderer/CCNewRenderTexture.h index 90bf6ce311..65e6694785 100644 --- a/cocos/2d/renderer/CCNewRenderTexture.h +++ b/cocos/2d/renderer/CCNewRenderTexture.h @@ -36,17 +36,13 @@ public: static NewRenderTexture* create(int w, int h, Texture2D::PixelFormat eFormat); static NewRenderTexture* create(int w, int h); - void beginWithClear(float r, float g, float b, float a); - void beginWithClear(float r, float g, float b, float a, float depthValue); - void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue); - void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags); - virtual void begin() override; virtual void end() override; virtual void draw() override; void clearDepth(float depthValue); - +protected: + virtual void _beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags) override; protected: NewRenderTexture(); virtual ~NewRenderTexture(); From fad585fbefe8a1e28897d0309177a4cd18ed132d Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 23 Dec 2013 15:59:47 +0800 Subject: [PATCH 11/70] move rendering callback to RenderTexture --- cocos/2d/CCRenderTexture.cpp | 120 +++++++++++++++++++++++ cocos/2d/CCRenderTexture.h | 9 ++ cocos/2d/renderer/CCNewRenderTexture.cpp | 120 ----------------------- cocos/2d/renderer/CCNewRenderTexture.h | 10 -- 4 files changed, 129 insertions(+), 130 deletions(-) diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index d63ecf2925..f031f06093 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -625,4 +625,124 @@ Image* RenderTexture::newImage(bool fliimage) return image; } +void RenderTexture::onBegin() +{ + // + kmGLGetMatrix(KM_GL_PROJECTION, &_oldProjMatrix); + kmGLMatrixMode(KM_GL_PROJECTION); + kmGLLoadMatrix(&_projectionMatrix); + + kmGLGetMatrix(KM_GL_MODELVIEW, &_oldTransMatrix); + kmGLMatrixMode(KM_GL_MODELVIEW); + kmGLLoadMatrix(&_transformMatrix); + + Director *director = Director::getInstance(); + director->setProjection(director->getProjection()); + + const Size& texSize = _texture->getContentSizeInPixels(); + + // Calculate the adjustment ratios based on the old and new projections + Size size = director->getWinSizeInPixels(); + float widthRatio = size.width / texSize.width; + float heightRatio = size.height / texSize.height; + + // Adjust the orthographic projection and viewport + glViewport(0, 0, (GLsizei)texSize.width, (GLsizei)texSize.height); + + + kmMat4 orthoMatrix; + kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio, (float)1.0 / widthRatio, + (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 ); + kmGLMultMatrix(&orthoMatrix); + + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO); + glBindFramebuffer(GL_FRAMEBUFFER, _FBO); + + //TODO move this to configration, so we don't check it every time + /* Certain Qualcomm Andreno gpu's will retain data in memory after a frame buffer switch which corrupts the render to the texture. The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. Create a temporary texture to overcome this. At the end of RenderTexture::begin(), switch the attached texture to the second one, call glClear, and then switch back to the original texture. This solution is unnecessary for other devices as they don't have the same issue with switching frame buffers. + */ + if (Configuration::getInstance()->checkForGLExtension("GL_QCOM")) + { + // -- bind a temporary texture so we can clear the render buffer without losing our texture + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _textureCopy->getName(), 0); + CHECK_GL_ERROR_DEBUG(); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture->getName(), 0); + } +} + +void RenderTexture::onEnd() +{ + Director *director = Director::getInstance(); + + glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO); + + // restore viewport + director->setViewport(); + + // + kmGLMatrixMode(KM_GL_PROJECTION); + kmGLLoadMatrix(&_oldProjMatrix); + + kmGLMatrixMode(KM_GL_MODELVIEW); + kmGLLoadMatrix(&_oldTransMatrix); +} + +void RenderTexture::onClear() +{ + // save clear color + GLfloat oldClearColor[4] = {0.0f}; + GLfloat oldDepthClearValue = 0.0f; + GLint oldStencilClearValue = 0; + + // backup and set + if (_clearFlags & GL_COLOR_BUFFER_BIT) + { + glGetFloatv(GL_COLOR_CLEAR_VALUE, oldClearColor); + glClearColor(_clearColor.r, _clearColor.g, _clearColor.b, _clearColor.a); + } + + if (_clearFlags & GL_DEPTH_BUFFER_BIT) + { + glGetFloatv(GL_DEPTH_CLEAR_VALUE, &oldDepthClearValue); + glClearDepth(_clearDepth); + } + + if (_clearFlags & GL_STENCIL_BUFFER_BIT) + { + glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &oldStencilClearValue); + glClearStencil(_clearStencil); + } + + // clear + glClear(_clearFlags); + + // restore + if (_clearFlags & GL_COLOR_BUFFER_BIT) + { + glClearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]); + } + if (_clearFlags & GL_DEPTH_BUFFER_BIT) + { + glClearDepth(oldDepthClearValue); + } + if (_clearFlags & GL_STENCIL_BUFFER_BIT) + { + glClearStencil(oldStencilClearValue); + } +} + +void RenderTexture::onClearDepth() +{ + //! save old depth value + GLfloat depthClearValue; + glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue); + + glClearDepth(_clearDepth); + glClear(GL_DEPTH_BUFFER_BIT); + + // restore clear color + glClearDepth(depthClearValue); +} + NS_CC_END diff --git a/cocos/2d/CCRenderTexture.h b/cocos/2d/CCRenderTexture.h index 17a338d323..ac39dade22 100644 --- a/cocos/2d/CCRenderTexture.h +++ b/cocos/2d/CCRenderTexture.h @@ -187,7 +187,16 @@ protected: - [[renderTexture sprite] setBlendFunc:(BlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}]; */ Sprite* _sprite; +protected: + //renderer caches and callbacks + void onBegin(); + void onEnd(); + void onClear(); + void onClearDepth(); + + kmMat4 _oldTransMatrix, _oldProjMatrix; + kmMat4 _transformMatrix, _projectionMatrix; private: CC_DISALLOW_COPY_AND_ASSIGN(RenderTexture); diff --git a/cocos/2d/renderer/CCNewRenderTexture.cpp b/cocos/2d/renderer/CCNewRenderTexture.cpp index be8b7bc2d2..3d6c950668 100644 --- a/cocos/2d/renderer/CCNewRenderTexture.cpp +++ b/cocos/2d/renderer/CCNewRenderTexture.cpp @@ -152,113 +152,6 @@ void NewRenderTexture::end() renderer->popGroup(); } -void NewRenderTexture::onBegin() -{ - // - kmGLGetMatrix(KM_GL_PROJECTION, &_oldProjMatrix); - kmGLMatrixMode(KM_GL_PROJECTION); - kmGLLoadMatrix(&_projectionMatrix); - - kmGLGetMatrix(KM_GL_MODELVIEW, &_oldTransMatrix); - kmGLMatrixMode(KM_GL_MODELVIEW); - kmGLLoadMatrix(&_transformMatrix); - - Director *director = Director::getInstance(); - director->setProjection(director->getProjection()); - - const Size& texSize = _texture->getContentSizeInPixels(); - - // Calculate the adjustment ratios based on the old and new projections - Size size = director->getWinSizeInPixels(); - float widthRatio = size.width / texSize.width; - float heightRatio = size.height / texSize.height; - - // Adjust the orthographic projection and viewport - glViewport(0, 0, (GLsizei)texSize.width, (GLsizei)texSize.height); - - - kmMat4 orthoMatrix; - kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio, (float)1.0 / widthRatio, - (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 ); - kmGLMultMatrix(&orthoMatrix); - - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO); - glBindFramebuffer(GL_FRAMEBUFFER, _FBO); - - //TODO move this to configration, so we don't check it every time - /* Certain Qualcomm Andreno gpu's will retain data in memory after a frame buffer switch which corrupts the render to the texture. The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. Create a temporary texture to overcome this. At the end of RenderTexture::begin(), switch the attached texture to the second one, call glClear, and then switch back to the original texture. This solution is unnecessary for other devices as they don't have the same issue with switching frame buffers. - */ - if (Configuration::getInstance()->checkForGLExtension("GL_QCOM")) - { - // -- bind a temporary texture so we can clear the render buffer without losing our texture - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _textureCopy->getName(), 0); - CHECK_GL_ERROR_DEBUG(); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture->getName(), 0); - } -} - -void NewRenderTexture::onEnd() -{ - Director *director = Director::getInstance(); - - glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO); - - // restore viewport - director->setViewport(); - - // - kmGLMatrixMode(KM_GL_PROJECTION); - kmGLLoadMatrix(&_oldProjMatrix); - - kmGLMatrixMode(KM_GL_MODELVIEW); - kmGLLoadMatrix(&_oldTransMatrix); -} - -void NewRenderTexture::onClear() -{ - // save clear color - GLfloat oldClearColor[4] = {0.0f}; - GLfloat oldDepthClearValue = 0.0f; - GLint oldStencilClearValue = 0; - - // backup and set - if (_clearFlags & GL_COLOR_BUFFER_BIT) - { - glGetFloatv(GL_COLOR_CLEAR_VALUE, oldClearColor); - glClearColor(_clearColor.r, _clearColor.g, _clearColor.b, _clearColor.a); - } - - if (_clearFlags & GL_DEPTH_BUFFER_BIT) - { - glGetFloatv(GL_DEPTH_CLEAR_VALUE, &oldDepthClearValue); - glClearDepth(_clearDepth); - } - - if (_clearFlags & GL_STENCIL_BUFFER_BIT) - { - glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &oldStencilClearValue); - glClearStencil(_clearStencil); - } - - // clear - glClear(_clearFlags); - - // restore - if (_clearFlags & GL_COLOR_BUFFER_BIT) - { - glClearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]); - } - if (_clearFlags & GL_DEPTH_BUFFER_BIT) - { - glClearDepth(oldDepthClearValue); - } - if (_clearFlags & GL_STENCIL_BUFFER_BIT) - { - glClearStencil(oldStencilClearValue); - } -} - void NewRenderTexture::clearDepth(float depthValue) { setClearDepth(depthValue); @@ -274,19 +167,6 @@ void NewRenderTexture::clearDepth(float depthValue) this->end(); } -void NewRenderTexture::onClearDepth() -{ - //! save old depth value - GLfloat depthClearValue; - glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue); - - glClearDepth(_clearDepth); - glClear(GL_DEPTH_BUFFER_BIT); - - // restore clear color - glClearDepth(depthClearValue); -} - NewRenderTexture::NewRenderTexture() :RenderTexture() { diff --git a/cocos/2d/renderer/CCNewRenderTexture.h b/cocos/2d/renderer/CCNewRenderTexture.h index 65e6694785..4d3b989696 100644 --- a/cocos/2d/renderer/CCNewRenderTexture.h +++ b/cocos/2d/renderer/CCNewRenderTexture.h @@ -46,16 +46,6 @@ protected: protected: NewRenderTexture(); virtual ~NewRenderTexture(); - - void onBegin(); - void onEnd(); - - //Clear render buffer - void onClear(); - void onClearDepth(); - - kmMat4 _oldTransMatrix, _oldProjMatrix; - kmMat4 _transformMatrix, _projectionMatrix; }; NS_CC_END From 9dff1dcd3667bcc4dfb9b672120612d5cb178324 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Dec 2013 16:37:40 +0800 Subject: [PATCH 12/70] [LUA] Removes CCCameraDeprecated table in Deprecated.lua. --- cocos/scripting/lua/script/Deprecated.lua | 39 ----------------------- 1 file changed, 39 deletions(-) diff --git a/cocos/scripting/lua/script/Deprecated.lua b/cocos/scripting/lua/script/Deprecated.lua index 83d7b07989..523e56f88d 100644 --- a/cocos/scripting/lua/script/Deprecated.lua +++ b/cocos/scripting/lua/script/Deprecated.lua @@ -300,45 +300,6 @@ end rawset(CCLabelAtlas,"create",CCLabelAtlasDeprecated.create) --functions of CCLabelAtlas will be deprecated end ---functions of CCCamera will be deprecated begin -local CCCameraDeprecated = {} -function CCCameraDeprecated.setUpXYZ(self,...) - deprecatedTip("CCCameraDeprecated:setUpXYZ","CCCameraDeprecated:setUp") - return self:setUp(...) -end -rawset(CCCamera,"setUpXYZ",CCCameraDeprecated.setUpXYZ) - -function CCCameraDeprecated.getUpXYZ(self) - deprecatedTip("CCCameraDeprecated:getUpXYZ","CCCameraDeprecated:getUp") - return self:getUp() -end -rawset(CCCamera,"getUpXYZ",CCCameraDeprecated.getUpXYZ) - -function CCCameraDeprecated.setEyeXYZ(self,...) - deprecatedTip("CCCameraDeprecated:setEyeXYZ","CCCameraDeprecated:setEye") - return self:setEye(...) -end -rawset(CCCamera,"setEyeXYZ",CCCameraDeprecated.setEyeXYZ) - -function CCCameraDeprecated.getEyeXYZ(self) - deprecatedTip("CCCameraDeprecated:getEyeXYZ","CCCameraDeprecated:getEye") - return self:getEye() -end -rawset(CCCamera,"getEyeXYZ",CCCameraDeprecated.getEyeXYZ) - -function CCCameraDeprecated.setCenterXYZ(self,...) - deprecatedTip("CCCameraDeprecated:setCenterXYZ","CCCameraDeprecated:setCenter") - return self:setCenter(...) -end -rawset(CCCamera,"setCenterXYZ",CCCameraDeprecated.setCenterXYZ) - -function CCCameraDeprecated.getCenterXYZ(self) - deprecatedTip("CCCameraDeprecated:getCenterXYZ","CCCameraDeprecated:getCenter") - return self:getCenter() -end -rawset(CCCamera,"getCenterXYZ",CCCameraDeprecated.getCenterXYZ) ---functions of CCCamera will be deprecated end - --------------------------- --global functions wil be deprecated, begin From 43e9df17bb1e8add924baeb4325f2c3ed5ed55c5 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Dec 2013 16:39:25 +0800 Subject: [PATCH 13/70] =?UTF-8?q?Removes=20unneeded=20=E2=80=98clone?= =?UTF-8?q?=E2=80=99=20in=20cocos2d=5Fspecifics.cpp.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index 9a92d58fff..fb16fc8a01 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -4f58619fbbaa2bb184766db408386d247df236ce \ No newline at end of file +80b25c13bca3a2d8adfc68a899c732103f68e0f5 \ No newline at end of file From 46cc91be3b4db5c55e4e793f973ad65a04a81497 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Dec 2013 16:41:17 +0800 Subject: [PATCH 14/70] Updates bindings-generator, skips to bind override functions. --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index ad53201245..5f412d0b3a 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit ad532012457e2eaff15d73d9ba28a638fa748d2d +Subproject commit 5f412d0b3a4eadba3d2abd750de87d1b0e219e0a From ed93f90ccc701e62d70b93b0dc64bfc184eefdda Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Dec 2013 16:58:26 +0800 Subject: [PATCH 15/70] =?UTF-8?q?Removes=20unneeded=20=E2=80=98override?= =?UTF-8?q?=E2=80=99=20codes,=20uses=20`using=20Node::addChild;`=20to=20pr?= =?UTF-8?q?event=20compiler=20warnings.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cocos/2d/CCParticleBatchNode.cpp | 10 ---------- cocos/2d/CCParticleBatchNode.h | 4 ++-- cocos/2d/CCScene.cpp | 10 ---------- cocos/2d/CCScene.h | 3 +-- cocos/2d/CCSprite.cpp | 10 ---------- cocos/2d/CCSprite.h | 5 +---- cocos/2d/CCSpriteBatchNode.h | 4 ++-- extensions/GUI/CCScrollView/CCScrollView.cpp | 10 ---------- extensions/GUI/CCScrollView/CCScrollView.h | 4 ++-- 9 files changed, 8 insertions(+), 52 deletions(-) diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index d6e86dc2b4..e046833d79 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -143,16 +143,6 @@ void ParticleBatchNode::visit() } // override addChild: -void ParticleBatchNode::addChild(Node * child) -{ - Node::addChild(child); -} - -void ParticleBatchNode::addChild(Node * child, int zOrder) -{ - Node::addChild(child, zOrder); -} - void ParticleBatchNode::addChild(Node * aChild, int zOrder, int tag) { CCASSERT( aChild != nullptr, "Argument must be non-nullptr"); diff --git a/cocos/2d/CCParticleBatchNode.h b/cocos/2d/CCParticleBatchNode.h index e8b75a3b70..189bfc7da9 100644 --- a/cocos/2d/CCParticleBatchNode.h +++ b/cocos/2d/CCParticleBatchNode.h @@ -105,8 +105,8 @@ public: // Overrides void visit(); - virtual void addChild(Node * child) override; - virtual void addChild(Node * child, int zOrder) 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; diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index 37b653aad9..b31a499af6 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -121,16 +121,6 @@ bool Scene::initWithPhysics() return ret; } -void Scene::addChild(Node* child) -{ - Node::addChild(child); -} - -void Scene::addChild(Node* child, int zOrder) -{ - Node::addChild(child, zOrder); -} - void Scene::addChild(Node* child, int zOrder, int tag) { Node::addChild(child, zOrder, tag); diff --git a/cocos/2d/CCScene.h b/cocos/2d/CCScene.h index 12c0fa1dea..b52d38e969 100644 --- a/cocos/2d/CCScene.h +++ b/cocos/2d/CCScene.h @@ -64,8 +64,7 @@ public: inline PhysicsWorld* getPhysicsWorld() { return _physicsWorld; } - virtual void addChild(Node* child) override; - virtual void addChild(Node* child, int zOrder) override; + using Node::addChild; virtual void addChild(Node* child, int zOrder, int tag) override; virtual void update(float delta) override; virtual std::string getDescription() const override; diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 6c940d3de3..5bbe9624c6 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -749,16 +749,6 @@ void Sprite::updateQuadVertices() // Node overrides -void Sprite::addChild(Node *child) -{ - Node::addChild(child); -} - -void Sprite::addChild(Node *child, int zOrder) -{ - Node::addChild(child, zOrder); -} - void Sprite::addChild(Node *child, int zOrder, int tag) { CCASSERT(child != nullptr, "Argument must be non-nullptr"); diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index 28313662a4..86df10a055 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -413,10 +413,7 @@ public: virtual void removeChild(Node* child, bool cleanup) override; virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void reorderChild(Node *child, int zOrder) override; - // Should also override addChild(Node*) and addChild(Node*, int), or binding generator will only - // bind addChild(Node*, int, int); - virtual void addChild(Node* child) override; - virtual void addChild(Node* child, int zOrder) override; + using Node::addChild; virtual void addChild(Node *child, int zOrder, int tag) override; virtual void sortAllChildren() override; virtual void setScale(float scale) override; diff --git a/cocos/2d/CCSpriteBatchNode.h b/cocos/2d/CCSpriteBatchNode.h index 73508fe762..29eb7fadb3 100644 --- a/cocos/2d/CCSpriteBatchNode.h +++ b/cocos/2d/CCSpriteBatchNode.h @@ -154,8 +154,8 @@ public: virtual const BlendFunc& getBlendFunc() const override; virtual void visit() override; - virtual void addChild(Node* child) override{ Node::addChild(child);} - virtual void addChild(Node * child, int zOrder) override { Node::addChild(child, zOrder);} + + using Node::addChild; virtual void addChild(Node * child, int zOrder, int tag) override; virtual void reorderChild(Node *child, int zOrder) override; diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index 4a8ab31c81..7ae70819af 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -485,16 +485,6 @@ void ScrollView::addChild(Node * child, int zOrder, int tag) } } -void ScrollView::addChild(Node * child, int zOrder) -{ - this->addChild(child, zOrder, child->getTag()); -} - -void ScrollView::addChild(Node * child) -{ - this->addChild(child, child->getZOrder(), child->getTag()); -} - /** * clip this view so that outside of the visible bounds can be hidden. */ diff --git a/extensions/GUI/CCScrollView/CCScrollView.h b/extensions/GUI/CCScrollView/CCScrollView.h index fb448c314c..bef479e49b 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.h +++ b/extensions/GUI/CCScrollView/CCScrollView.h @@ -224,9 +224,9 @@ public: * @lua NA */ virtual void visit() override; + + using Node::addChild; virtual void addChild(Node * child, int zOrder, int tag) override; - virtual void addChild(Node * child, int zOrder) override; - virtual void addChild(Node * child) override; protected: /** From a7a50dffcc32e6828ade7a9134363e9d50d53771 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 23 Dec 2013 17:13:06 +0800 Subject: [PATCH 16/70] move begin(), end(),draw() to RenderTexture --- cocos/2d/CCRenderTexture.cpp | 251 ++++++++--------------- cocos/2d/renderer/CCNewRenderTexture.cpp | 96 --------- cocos/2d/renderer/CCNewRenderTexture.h | 9 +- 3 files changed, 91 insertions(+), 265 deletions(-) diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index f031f06093..609c287ce2 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -37,6 +37,11 @@ THE SOFTWARE. #include "CCNotificationCenter.h" #include "CCEventType.h" #include "CCGrid.h" + +#include "CCRenderer.h" +#include "CCGroupCommand.h" +#include "CCCustomCommand.h" + // extern #include "kazmath/GL/matrix.h" @@ -296,47 +301,6 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat return ret; } -void RenderTexture::begin() -{ - kmGLMatrixMode(KM_GL_PROJECTION); - kmGLPushMatrix(); - kmGLMatrixMode(KM_GL_MODELVIEW); - kmGLPushMatrix(); - - Director *director = Director::getInstance(); - director->setProjection(director->getProjection()); - - const Size& texSize = _texture->getContentSizeInPixels(); - - // Calculate the adjustment ratios based on the old and new projections - Size size = director->getWinSizeInPixels(); - float widthRatio = size.width / texSize.width; - float heightRatio = size.height / texSize.height; - - // Adjust the orthographic projection and viewport - glViewport(0, 0, (GLsizei)texSize.width, (GLsizei)texSize.height); - - - kmMat4 orthoMatrix; - kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio, (float)1.0 / widthRatio, - (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 ); - kmGLMultMatrix(&orthoMatrix); - - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO); - glBindFramebuffer(GL_FRAMEBUFFER, _FBO); - - /* Certain Qualcomm Andreno gpu's will retain data in memory after a frame buffer switch which corrupts the render to the texture. The solution is to clear the frame buffer before rendering to the texture. However, calling glClear has the unintended result of clearing the current texture. Create a temporary texture to overcome this. At the end of RenderTexture::begin(), switch the attached texture to the second one, call glClear, and then switch back to the original texture. This solution is unnecessary for other devices as they don't have the same issue with switching frame buffers. - */ - if (Configuration::getInstance()->checkForGLExtension("GL_QCOM")) - { - // -- bind a temporary texture so we can clear the render buffer without losing our texture - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _textureCopy->getName(), 0); - CHECK_GL_ERROR_DEBUG(); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture->getName(), 0); - } -} - void RenderTexture::beginWithClear(float r, float g, float b, float a) { _beginWithClear(r, g, b, a, 0, 0, GL_COLOR_BUFFER_BIT); @@ -354,61 +318,21 @@ void RenderTexture::beginWithClear(float r, float g, float b, float a, float dep void RenderTexture::_beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags) { + setClearColor(Color4F(r, g, b, a)); + + setClearDepth(depthValue); + + setClearStencil(stencilValue); + + setClearFlags(flags); + this->begin(); - // save clear color - GLfloat clearColor[4] = {0.0f}; - GLfloat depthClearValue = 0.0f; - int stencilClearValue = 0; - - if (flags & GL_COLOR_BUFFER_BIT) - { - glGetFloatv(GL_COLOR_CLEAR_VALUE,clearColor); - glClearColor(r, g, b, a); - } - - if (flags & GL_DEPTH_BUFFER_BIT) - { - glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue); - glClearDepth(depthValue); - } - - if (flags & GL_STENCIL_BUFFER_BIT) - { - glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilClearValue); - glClearStencil(stencilValue); - } - - glClear(flags); - - // restore - if (flags & GL_COLOR_BUFFER_BIT) - { - glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); - } - if (flags & GL_DEPTH_BUFFER_BIT) - { - glClearDepth(depthClearValue); - } - if (flags & GL_STENCIL_BUFFER_BIT) - { - glClearStencil(stencilClearValue); - } -} - -void RenderTexture::end() -{ - Director *director = Director::getInstance(); - - glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO); - - // restore viewport - director->setViewport(); - - kmGLMatrixMode(KM_GL_PROJECTION); - kmGLPopMatrix(); - kmGLMatrixMode(KM_GL_MODELVIEW); - kmGLPopMatrix(); + //clear screen + CustomCommand* clearCmd = CustomCommand::getCommandPool().generateCommand(); + clearCmd->init(0, _vertexZ); + clearCmd->func = CC_CALLBACK_0(RenderTexture::onClear, this); + Director::getInstance()->getRenderer()->addCommand(clearCmd); } //TODO find a better way to clear the screen, there is no need to rebind render buffer there. @@ -420,16 +344,16 @@ void RenderTexture::clear(float r, float g, float b, float a) void RenderTexture::clearDepth(float depthValue) { + setClearDepth(depthValue); + this->begin(); - //! save old depth value - GLfloat depthClearValue; - glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue); - glClearDepth(depthValue); - glClear(GL_DEPTH_BUFFER_BIT); + CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand(); + cmd->init(0, _vertexZ); + cmd->func = CC_CALLBACK_0(RenderTexture::onClearDepth, this); + + Director::getInstance()->getRenderer()->addCommand(cmd); - // restore clear color - glClearDepth(depthClearValue); this->end(); } @@ -466,69 +390,6 @@ void RenderTexture::visit() _orderOfArrival = 0; } -void RenderTexture::draw() -{ - if( _autoDraw) - { - begin(); - - if (_clearFlags) - { - GLfloat oldClearColor[4] = {0.0f}; - GLfloat oldDepthClearValue = 0.0f; - GLint oldStencilClearValue = 0; - - // backup and set - if (_clearFlags & GL_COLOR_BUFFER_BIT) - { - glGetFloatv(GL_COLOR_CLEAR_VALUE, oldClearColor); - glClearColor(_clearColor.r, _clearColor.g, _clearColor.b, _clearColor.a); - } - - if (_clearFlags & GL_DEPTH_BUFFER_BIT) - { - glGetFloatv(GL_DEPTH_CLEAR_VALUE, &oldDepthClearValue); - glClearDepth(_clearDepth); - } - - if (_clearFlags & GL_STENCIL_BUFFER_BIT) - { - glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &oldStencilClearValue); - glClearStencil(_clearStencil); - } - - // clear - glClear(_clearFlags); - - // restore - if (_clearFlags & GL_COLOR_BUFFER_BIT) - { - glClearColor(oldClearColor[0], oldClearColor[1], oldClearColor[2], oldClearColor[3]); - } - if (_clearFlags & GL_DEPTH_BUFFER_BIT) - { - glClearDepth(oldDepthClearValue); - } - if (_clearFlags & GL_STENCIL_BUFFER_BIT) - { - glClearStencil(oldStencilClearValue); - } - } - - //! make sure all children are drawn - sortAllChildren(); - - for(const auto &child : _children) { - if (child != _sprite) - { - child->visit(); - } - } - - end(); - } -} - bool RenderTexture::saveToFile(const std::string& filename) { bool ret = false; @@ -745,4 +606,66 @@ void RenderTexture::onClearDepth() glClearDepth(depthClearValue); } +void RenderTexture::draw() +{ + if (_autoDraw) + { + //Begin will create a render group using new render target + begin(); + + //clear screen + CustomCommand* clearCmd = CustomCommand::getCommandPool().generateCommand(); + clearCmd->init(0, _vertexZ); + clearCmd->func = CC_CALLBACK_0(RenderTexture::onClear, this); + Director::getInstance()->getRenderer()->addCommand(clearCmd); + + //! make sure all children are drawn + sortAllChildren(); + + for(const auto &child: _children) + { + if (child != _sprite) + child->visit(); + } + + //End will pop the current render group + end(); + } +} + +void RenderTexture::begin() +{ + kmGLMatrixMode(KM_GL_PROJECTION); + kmGLPushMatrix(); + kmGLGetMatrix(KM_GL_PROJECTION, &_projectionMatrix); + + kmGLMatrixMode(KM_GL_MODELVIEW); + kmGLPushMatrix(); + kmGLGetMatrix(KM_GL_MODELVIEW, &_transformMatrix); + + GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand(); + groupCommand->init(0, _vertexZ); + + Renderer *renderer = Director::getInstance()->getRenderer(); + renderer->addCommand(groupCommand); + renderer->pushGroup(groupCommand->getRenderQueueID()); + + CustomCommand* beginCmd = CustomCommand::getCommandPool().generateCommand(); + beginCmd->init(0, _vertexZ); + beginCmd->func = CC_CALLBACK_0(RenderTexture::onBegin, this); + + Director::getInstance()->getRenderer()->addCommand(beginCmd); +} + +void RenderTexture::end() +{ + CustomCommand* endCmd = CustomCommand::getCommandPool().generateCommand(); + endCmd->init(0, _vertexZ); + endCmd->func = CC_CALLBACK_0(RenderTexture::onEnd, this); + + Renderer *renderer = Director::getInstance()->getRenderer(); + renderer->addCommand(endCmd); + renderer->popGroup(); +} + NS_CC_END diff --git a/cocos/2d/renderer/CCNewRenderTexture.cpp b/cocos/2d/renderer/CCNewRenderTexture.cpp index 3d6c950668..c3aba195e1 100644 --- a/cocos/2d/renderer/CCNewRenderTexture.cpp +++ b/cocos/2d/renderer/CCNewRenderTexture.cpp @@ -71,102 +71,6 @@ NewRenderTexture* NewRenderTexture::create(int w, int h) return nullptr; } -void NewRenderTexture::draw() -{ - if (_autoDraw) - { - //Begin will create a render group using new render target - begin(); - - //clear screen - CustomCommand* clearCmd = CustomCommand::getCommandPool().generateCommand(); - clearCmd->init(0, _vertexZ); - clearCmd->func = CC_CALLBACK_0(NewRenderTexture::onClear, this); - Director::getInstance()->getRenderer()->addCommand(clearCmd); - - //! make sure all children are drawn - sortAllChildren(); - - for(const auto &child: _children) - { - if (child != _sprite) - child->visit(); - } - - //End will pop the current render group - end(); - } -} - -void NewRenderTexture::_beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags) -{ - setClearColor(Color4F(r, g, b, a)); - - setClearDepth(depthValue); - - setClearStencil(stencilValue); - - setClearFlags(flags); - - this->begin(); - - //clear screen - CustomCommand* clearCmd = CustomCommand::getCommandPool().generateCommand(); - clearCmd->init(0, _vertexZ); - clearCmd->func = CC_CALLBACK_0(NewRenderTexture::onClear, this); - Director::getInstance()->getRenderer()->addCommand(clearCmd); -} - -void NewRenderTexture::begin() -{ - kmGLMatrixMode(KM_GL_PROJECTION); - kmGLPushMatrix(); - kmGLGetMatrix(KM_GL_PROJECTION, &_projectionMatrix); - - kmGLMatrixMode(KM_GL_MODELVIEW); - kmGLPushMatrix(); - kmGLGetMatrix(KM_GL_MODELVIEW, &_transformMatrix); - - GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand(); - groupCommand->init(0, _vertexZ); - - Renderer *renderer = Director::getInstance()->getRenderer(); - renderer->addCommand(groupCommand); - renderer->pushGroup(groupCommand->getRenderQueueID()); - - CustomCommand* beginCmd = CustomCommand::getCommandPool().generateCommand(); - beginCmd->init(0, _vertexZ); - beginCmd->func = CC_CALLBACK_0(NewRenderTexture::onBegin, this); - - Director::getInstance()->getRenderer()->addCommand(beginCmd); -} - -void NewRenderTexture::end() -{ - CustomCommand* endCmd = CustomCommand::getCommandPool().generateCommand(); - endCmd->init(0, _vertexZ); - endCmd->func = CC_CALLBACK_0(NewRenderTexture::onEnd, this); - - Renderer *renderer = Director::getInstance()->getRenderer(); - renderer->addCommand(endCmd); - renderer->popGroup(); -} - -void NewRenderTexture::clearDepth(float depthValue) -{ - setClearDepth(depthValue); - - this->begin(); - - CustomCommand* cmd = CustomCommand::getCommandPool().generateCommand(); - cmd->init(0, _vertexZ); - cmd->func = CC_CALLBACK_0(NewRenderTexture::onClearDepth, this); - - Director::getInstance()->getRenderer()->addCommand(cmd); - - this->end(); -} - NewRenderTexture::NewRenderTexture() :RenderTexture() { diff --git a/cocos/2d/renderer/CCNewRenderTexture.h b/cocos/2d/renderer/CCNewRenderTexture.h index 4d3b989696..8c4a46493e 100644 --- a/cocos/2d/renderer/CCNewRenderTexture.h +++ b/cocos/2d/renderer/CCNewRenderTexture.h @@ -36,13 +36,12 @@ public: static NewRenderTexture* create(int w, int h, Texture2D::PixelFormat eFormat); static NewRenderTexture* create(int w, int h); - virtual void begin() override; - virtual void end() override; - virtual void draw() override; + //virtual void begin() override; + //virtual void end() override; - void clearDepth(float depthValue); + //void clearDepth(float depthValue); protected: - virtual void _beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags) override; + //virtual void _beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags) override; protected: NewRenderTexture(); virtual ~NewRenderTexture(); From 41a77fed6167546c399916f34f38cbb9afc4c3a2 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 23 Dec 2013 17:13:41 +0800 Subject: [PATCH 17/70] TestCase Use RenderTexture instead of NewRenderTexture --- cocos/2d/CCTransition.cpp | 4 ++-- cocos/2d/CCTransitionProgress.cpp | 2 +- .../Classes/RenderTextureTest/RenderTextureTest.cpp | 12 ++++++------ .../Classes/RenderTextureTest/RenderTextureTest.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cocos/2d/CCTransition.cpp b/cocos/2d/CCTransition.cpp index 2fa930379a..1a8ebd2b1c 100644 --- a/cocos/2d/CCTransition.cpp +++ b/cocos/2d/CCTransition.cpp @@ -1275,7 +1275,7 @@ void TransitionCrossFade::onEnter() LayerColor* layer = LayerColor::create(color); // create the first render texture for inScene - RenderTexture* inTexture = NewRenderTexture::create((int)size.width, (int)size.height); + RenderTexture* inTexture = RenderTexture::create((int)size.width, (int)size.height); if (nullptr == inTexture) { @@ -1292,7 +1292,7 @@ void TransitionCrossFade::onEnter() inTexture->end(); // create the second render texture for outScene - RenderTexture* outTexture = NewRenderTexture::create((int)size.width, (int)size.height); + RenderTexture* outTexture = RenderTexture::create((int)size.width, (int)size.height); outTexture->getSprite()->setAnchorPoint( Point(0.5f,0.5f) ); outTexture->setPosition( Point(size.width/2, size.height/2) ); outTexture->setAnchorPoint( Point(0.5f,0.5f) ); diff --git a/cocos/2d/CCTransitionProgress.cpp b/cocos/2d/CCTransitionProgress.cpp index ff217793ee..f0f163bec8 100644 --- a/cocos/2d/CCTransitionProgress.cpp +++ b/cocos/2d/CCTransitionProgress.cpp @@ -72,7 +72,7 @@ void TransitionProgress::onEnter() Size size = Director::getInstance()->getWinSize(); // create the second render texture for outScene - RenderTexture *texture = NewRenderTexture::create((int)size.width, (int)size.height); + RenderTexture *texture = RenderTexture::create((int)size.width, (int)size.height); texture->getSprite()->setAnchorPoint(Point(0.5f,0.5f)); texture->setPosition(Point(size.width/2, size.height/2)); texture->setAnchorPoint(Point(0.5f,0.5f)); diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp index 507e7594e2..f4135182f7 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -93,7 +93,7 @@ RenderTextureSave::RenderTextureSave() auto s = Director::getInstance()->getWinSize(); // create a render texture, this is what we are going to draw into - _target = NewRenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888); + _target = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888); _target->retain(); _target->setPosition(Point(s.width / 2, s.height / 2)); @@ -241,7 +241,7 @@ RenderTextureIssue937::RenderTextureIssue937() /* A2 & B2 setup */ - auto rend = NewRenderTexture::create(32, 64, Texture2D::PixelFormat::RGBA8888); + auto rend = RenderTexture::create(32, 64, Texture2D::PixelFormat::RGBA8888); if (NULL == rend) { @@ -410,7 +410,7 @@ void RenderTextureZbuffer::onTouchesEnded(const std::vector& touches, Ev void RenderTextureZbuffer::renderScreenShot() { - auto texture = NewRenderTexture::create(512, 512); + auto texture = RenderTexture::create(512, 512); if (NULL == texture) { return; @@ -444,7 +444,7 @@ RenderTextureTestDepthStencil::RenderTextureTestDepthStencil() auto sprite = Sprite::create("Images/fire.png"); sprite->setPosition(Point(s.width * 0.25f, 0)); sprite->setScale(10); - auto rend = NewRenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444, GL_DEPTH24_STENCIL8); + auto rend = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444, GL_DEPTH24_STENCIL8); glStencilMask(0xFF); rend->beginWithClear(0, 0, 0, 0, 0, 0); @@ -506,7 +506,7 @@ RenderTextureTargetNode::RenderTextureTargetNode() auto s = Director::getInstance()->getWinSize(); /* Create the render texture */ - auto renderTexture = NewRenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444); + auto renderTexture = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444); this->renderTexture = renderTexture; renderTexture->setPosition(Point(s.width/2, s.height/2)); @@ -591,7 +591,7 @@ void SpriteRenderTextureBug::SimpleSprite::draw() if (_rt == nullptr) { auto s = Director::getInstance()->getWinSize(); - _rt = NewRenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888); + _rt = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888); _rt->retain(); } _rt->beginWithClear(0.0f, 0.0f, 0.0f, 1.0f); diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h index ac8128a0c1..0c6004b15b 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h @@ -31,7 +31,7 @@ public: void saveImage(Object *pSender); private: - NewRenderTexture *_target; + RenderTexture *_target; Sprite *_brush; }; From 4399adc869341f3ba9081c41fa870edb2b237bf4 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Mon, 23 Dec 2013 17:31:57 +0800 Subject: [PATCH 18/70] issue #3353:Add the DisplayLinkDirector lua binding --- tools/tolua/cocos2dx.ini | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 02b9a3819e..2c86bc2d8e 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/2d/cocos2d.h %(cocosdir)s/cocos/audio/include/Simpl # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault EGLViewProtocol EGLView Image Event.* +classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault EGLViewProtocol EGLView Image Event.* DisplayLinkDirector # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -111,7 +111,8 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS Label::[getLettersInfo], EGLViewProtocol::[setTouchDelegate], EGLView::[end swapBuffers], - NewTextureAtlas::[*] + NewTextureAtlas::[*], + DisplayLinkDirector::[mainLoop setAnimationInterval startAnimation stopAnimation] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], ProgressTimer::[setReverseProgress=setReverseDirection], @@ -142,7 +143,7 @@ base_classes_to_skip = Clonable # classes that create no constructor # Set is special and we will use a hand-written constructor -abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application ClippingNode Label EGLViewProtocol EGLView EventAcceleration +abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application ClippingNode Label EGLViewProtocol EGLView EventAcceleration DisplayLinkDirector # Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. script_control_cpp = no From 487e0b21af171f3f8776b8f28674dad4344b2cd6 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 23 Dec 2013 18:03:08 +0800 Subject: [PATCH 19/70] update Xcode project file& android.mk --- build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- cocos/2d/Android.mk | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 46d83b2d17..a4bc1d2615 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -1df2ba5492ecdbe0c160d2429733c1371b35b21a \ No newline at end of file +6b6f50103f52c3f9535768ce96c0d3eff23c2d20 \ No newline at end of file diff --git a/cocos/2d/Android.mk b/cocos/2d/Android.mk index ee529e0e6d..0c15b3efd8 100644 --- a/cocos/2d/Android.mk +++ b/cocos/2d/Android.mk @@ -117,7 +117,6 @@ platform/CCEGLViewProtocol.cpp \ platform/CCFileUtils.cpp \ platform/CCSAXParser.cpp \ platform/CCThread.cpp \ -renderer/CCNewRenderTexture.cpp \ renderer/CCNewSprite.cpp \ renderer/CCNewSpriteBatchNode.cpp \ renderer/CCNewTextureAtlas.cpp \ From bcaec978d3120d00f0b4e6913d14aeb729e39bac Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 23 Dec 2013 18:04:04 +0800 Subject: [PATCH 20/70] remove NewRenderTexture Class --- cocos/2d/renderer/CCNewRenderTexture.cpp | 85 ------------------------ cocos/2d/renderer/CCNewRenderTexture.h | 52 --------------- 2 files changed, 137 deletions(-) delete mode 100644 cocos/2d/renderer/CCNewRenderTexture.cpp delete mode 100644 cocos/2d/renderer/CCNewRenderTexture.h diff --git a/cocos/2d/renderer/CCNewRenderTexture.cpp b/cocos/2d/renderer/CCNewRenderTexture.cpp deleted file mode 100644 index c3aba195e1..0000000000 --- a/cocos/2d/renderer/CCNewRenderTexture.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - - -#include "CCNewRenderTexture.h" -#include "CCCustomCommand.h" -#include "CCRenderer.h" -#include "CCGroupCommand.h" -#include "CCConfiguration.h" -#include "CCDirector.h" - -NS_CC_BEGIN - -NewRenderTexture* NewRenderTexture::create(int w, int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat) -{ - NewRenderTexture* pRet = new NewRenderTexture(); - - if(pRet && pRet->initWithWidthAndHeight(w, h, eFormat, uDepthStencilFormat)) - { - pRet->autorelease(); - return pRet; - } - CC_SAFE_DELETE(pRet); - return nullptr; -} - -NewRenderTexture* NewRenderTexture::create(int w, int h, Texture2D::PixelFormat eFormat) -{ - NewRenderTexture* pRet = new NewRenderTexture(); - - if(pRet && pRet->initWithWidthAndHeight(w, h, eFormat)) - { - pRet->autorelease(); - return pRet; - } - CC_SAFE_DELETE(pRet); - return nullptr; -} - -NewRenderTexture* NewRenderTexture::create(int w, int h) -{ - NewRenderTexture* pRet = new NewRenderTexture(); - - if(pRet && pRet->initWithWidthAndHeight(w, h, Texture2D::PixelFormat::RGB888 , 0)) - { - pRet->autorelease(); - return pRet; - } - CC_SAFE_DELETE(pRet); - return nullptr; -} - -NewRenderTexture::NewRenderTexture() -:RenderTexture() -{ - -} - -NewRenderTexture::~NewRenderTexture() -{ - -} - -NS_CC_END \ No newline at end of file diff --git a/cocos/2d/renderer/CCNewRenderTexture.h b/cocos/2d/renderer/CCNewRenderTexture.h deleted file mode 100644 index 8c4a46493e..0000000000 --- a/cocos/2d/renderer/CCNewRenderTexture.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __CCNewRenderTexture_H_ -#define __CCNewRenderTexture_H_ - -#include "CCRenderTexture.h" - -NS_CC_BEGIN - -class NewRenderTexture : public RenderTexture -{ -public: - static NewRenderTexture* create(int w, int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat); - static NewRenderTexture* create(int w, int h, Texture2D::PixelFormat eFormat); - static NewRenderTexture* create(int w, int h); - - //virtual void begin() override; - //virtual void end() override; - - //void clearDepth(float depthValue); -protected: - //virtual void _beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags) override; -protected: - NewRenderTexture(); - virtual ~NewRenderTexture(); -}; - -NS_CC_END - -#endif //__CCNewRenderTexture_H_ From 9c97fc6f19b03962dc3c286d06cf615a85c07945 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 23 Dec 2013 18:08:50 +0800 Subject: [PATCH 21/70] remove NewRenderTexture include file --- cocos/2d/CCTransition.cpp | 2 -- cocos/2d/CCTransitionProgress.cpp | 1 - cocos/2d/cocos2d.h | 1 - .../Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp | 1 - .../Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h | 1 - 5 files changed, 6 deletions(-) diff --git a/cocos/2d/CCTransition.cpp b/cocos/2d/CCTransition.cpp index 1a8ebd2b1c..4213232139 100644 --- a/cocos/2d/CCTransition.cpp +++ b/cocos/2d/CCTransition.cpp @@ -35,8 +35,6 @@ THE SOFTWARE. #include "CCLayer.h" #include "CCRenderTexture.h" #include "CCNodeGrid.h" -#include "CCNewRenderTexture.h" - NS_CC_BEGIN diff --git a/cocos/2d/CCTransitionProgress.cpp b/cocos/2d/CCTransitionProgress.cpp index f0f163bec8..7e9d3bbc10 100644 --- a/cocos/2d/CCTransitionProgress.cpp +++ b/cocos/2d/CCTransitionProgress.cpp @@ -32,7 +32,6 @@ THE SOFTWARE. #include "CCLayer.h" #include "CCActionInstant.h" #include "CCActionProgressTimer.h" -#include "CCNewRenderTexture.h" NS_CC_BEGIN diff --git a/cocos/2d/cocos2d.h b/cocos/2d/cocos2d.h index fb61bf1679..21cf523bc2 100644 --- a/cocos/2d/cocos2d.h +++ b/cocos/2d/cocos2d.h @@ -119,7 +119,6 @@ THE SOFTWARE. #include "CCParticleSystemQuad.h" // new renderer -#include "renderer/CCNewRenderTexture.h" #include "renderer/CCNewSprite.h" #include "renderer/CCNewSpriteBatchNode.h" #include "renderer/CCNewTextureAtlas.h" diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp index f4135182f7..b679aeb463 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -1,7 +1,6 @@ #include "CCConfiguration.h" #include "RenderTextureTest.h" #include "../testBasic.h" -#include "renderer/CCNewRenderTexture.h" // Test #1 by Jason Booth (slipster216) // Test #3 by David Deaco (ddeaco) diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h index 0c6004b15b..9e37954566 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h @@ -4,7 +4,6 @@ #include "cocos2d.h" #include "../testBasic.h" #include "../BaseTest.h" -#include "renderer/CCNewRenderTexture.h" class RenderTextureTest : public BaseTest { From 8c3315de7605110e6f13cf046ae4691467885ec0 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Dec 2013 18:23:39 +0800 Subject: [PATCH 22/70] closed #3478: BitmapFontMultiLineAlignment test shows some unneeded 'line break' --- cocos/2d/CCLabelBMFont.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/2d/CCLabelBMFont.cpp b/cocos/2d/CCLabelBMFont.cpp index 868da6591a..1866d022f9 100644 --- a/cocos/2d/CCLabelBMFont.cpp +++ b/cocos/2d/CCLabelBMFont.cpp @@ -867,6 +867,8 @@ void LabelBMFont::updateLabel() startOfLine = startOfWord; start_line = true; } + ++i; + continue; } // Whitespace. From 0dab85a3bff03b55db997fe430b841b33f4df1d9 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 23 Dec 2013 18:37:18 +0800 Subject: [PATCH 23/70] update CMakeLists.txt --- cocos/2d/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index 568f5aafe5..aadc31d9a7 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -139,7 +139,6 @@ set(COCOS2D_SRC platform/CCEGLViewProtocol.cpp platform/CCFileUtils.cpp ../../external/edtaa3func/edtaa3func.cpp - renderer/CCNewRenderTexture.cpp renderer/CCNewSprite.cpp renderer/CCNewSpriteBatchNode.cpp renderer/CCNewTextureAtlas.cpp From 509d4513eb4100830ca0073cb26ec9193fcc4486 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 23 Dec 2013 11:48:15 +0000 Subject: [PATCH 24/70] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index a388e918ef..3363b72bc8 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit a388e918ef871c0fcfeb69bd71b1c784747871b8 +Subproject commit 3363b72bc8069455a80704b9261f8e97c74edb67 From 98d573f4cb14adedfd096218c2e41070bf7a1dd6 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 23 Dec 2013 19:59:09 +0800 Subject: [PATCH 25/70] rename protected _beginWithClear to beginWithClear --- cocos/2d/CCRenderTexture.cpp | 8 ++++---- cocos/2d/CCRenderTexture.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index 609c287ce2..3ba91d0771 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -303,20 +303,20 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat void RenderTexture::beginWithClear(float r, float g, float b, float a) { - _beginWithClear(r, g, b, a, 0, 0, GL_COLOR_BUFFER_BIT); + beginWithClear(r, g, b, a, 0, 0, GL_COLOR_BUFFER_BIT); } void RenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue) { - _beginWithClear(r, g, b, a, depthValue, 0, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + beginWithClear(r, g, b, a, depthValue, 0, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); } void RenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue) { - _beginWithClear(r, g, b, a, depthValue, stencilValue, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); + beginWithClear(r, g, b, a, depthValue, stencilValue, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); } -void RenderTexture::_beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags) +void RenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags) { setClearColor(Color4F(r, g, b, a)); diff --git a/cocos/2d/CCRenderTexture.h b/cocos/2d/CCRenderTexture.h index ac39dade22..8df7eee817 100644 --- a/cocos/2d/CCRenderTexture.h +++ b/cocos/2d/CCRenderTexture.h @@ -164,7 +164,7 @@ public: bool initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat format, GLuint depthStencilFormat); protected: - virtual void _beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags); + virtual void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, GLbitfield flags); GLuint _FBO; GLuint _depthRenderBufffer; From 1dd2c1c20cb9c4d721c98704a7c5ab459fc4b488 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 23 Dec 2013 20:11:50 +0800 Subject: [PATCH 26/70] remove NewTextureAtlas --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos/2d/Android.mk | 1 - cocos/2d/CMakeLists.txt | 1 - cocos/2d/cocos2d.h | 1 - cocos/2d/renderer/CCNewTextureAtlas.cpp | 77 ------------------- cocos/2d/renderer/CCNewTextureAtlas.h | 50 ------------ 6 files changed, 1 insertion(+), 131 deletions(-) delete mode 100644 cocos/2d/renderer/CCNewTextureAtlas.cpp delete mode 100644 cocos/2d/renderer/CCNewTextureAtlas.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index a4bc1d2615..0b1a05e0fa 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -6b6f50103f52c3f9535768ce96c0d3eff23c2d20 \ No newline at end of file +4b776594c76318354842113d2274acda51fe9178 \ No newline at end of file diff --git a/cocos/2d/Android.mk b/cocos/2d/Android.mk index 0c15b3efd8..62d43cfe5c 100644 --- a/cocos/2d/Android.mk +++ b/cocos/2d/Android.mk @@ -119,7 +119,6 @@ platform/CCSAXParser.cpp \ platform/CCThread.cpp \ renderer/CCNewSprite.cpp \ renderer/CCNewSpriteBatchNode.cpp \ -renderer/CCNewTextureAtlas.cpp \ renderer/CCCustomCommand.cpp \ renderer/CCFrustum.cpp \ renderer/CCGroupCommand.cpp \ diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index aadc31d9a7..4f9918efdb 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -141,7 +141,6 @@ set(COCOS2D_SRC ../../external/edtaa3func/edtaa3func.cpp renderer/CCNewSprite.cpp renderer/CCNewSpriteBatchNode.cpp - renderer/CCNewTextureAtlas.cpp renderer/CCCustomCommand.cpp renderer/CCFrustum.cpp renderer/CCGroupCommand.cpp diff --git a/cocos/2d/cocos2d.h b/cocos/2d/cocos2d.h index 21cf523bc2..64be8231b2 100644 --- a/cocos/2d/cocos2d.h +++ b/cocos/2d/cocos2d.h @@ -121,7 +121,6 @@ THE SOFTWARE. // new renderer #include "renderer/CCNewSprite.h" #include "renderer/CCNewSpriteBatchNode.h" -#include "renderer/CCNewTextureAtlas.h" #include "renderer/CCCustomCommand.h" #include "renderer/CCFrustum.h" #include "renderer/CCGroupCommand.h" diff --git a/cocos/2d/renderer/CCNewTextureAtlas.cpp b/cocos/2d/renderer/CCNewTextureAtlas.cpp deleted file mode 100644 index 4358669fcd..0000000000 --- a/cocos/2d/renderer/CCNewTextureAtlas.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCNewTextureAtlas.h" -#include "CCTexture2D.h" -#include "CCDirector.h" -#include "CCRenderer.h" -#include "CCQuadCommand.h" - -NS_CC_BEGIN - -NewTextureAtlas::NewTextureAtlas() -:TextureAtlas() -{ - -} - -NewTextureAtlas::~NewTextureAtlas() -{ - -} - -NewTextureAtlas *NewTextureAtlas::create(const char *file, long capacity) -{ - NewTextureAtlas * textureAtlas = new NewTextureAtlas(); - if(textureAtlas && textureAtlas->initWithFile(file, capacity)) - { - textureAtlas->autorelease(); - return textureAtlas; - } - CC_SAFE_DELETE(textureAtlas); - return nullptr; -} - -NewTextureAtlas *NewTextureAtlas::createWithTexture(Texture2D *texture, long capacity) -{ - NewTextureAtlas * textureAtlas = new NewTextureAtlas(); - if (textureAtlas && textureAtlas->initWithTexture(texture, capacity)) - { - textureAtlas->autorelease(); - return textureAtlas; - } - CC_SAFE_DELETE(textureAtlas); - return nullptr; -} - - -void NewTextureAtlas::drawNumberOfQuads(long numberOfQuads, long start) -{ -// updateTransform(); -// QuadCommand* renderCommand = new QuadCommand(0, 0,_texture->getName(), _shaderProgram, _blendFunc, _quad); -// -// Renderer::getInstance()->addCommand(renderCommand); -} - -NS_CC_END diff --git a/cocos/2d/renderer/CCNewTextureAtlas.h b/cocos/2d/renderer/CCNewTextureAtlas.h deleted file mode 100644 index 9f497c76a6..0000000000 --- a/cocos/2d/renderer/CCNewTextureAtlas.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - - -#ifndef __CCNewTextureAtlas_H_ -#define __CCNewTextureAtlas_H_ - -#include "CCPlatformMacros.h" -#include "CCTextureAtlas.h" - -NS_CC_BEGIN - -class NewTextureAtlas : public TextureAtlas -{ -public: - static NewTextureAtlas* create(const char* file, long capacity); - static NewTextureAtlas* createWithTexture(Texture2D *texture, long capacity); - - void drawNumberOfQuads(long numberOfQuads, long start); - -protected: - NewTextureAtlas(); - virtual ~NewTextureAtlas(); - -}; - -NS_CC_END - -#endif //__CCNewTextureAtlas_H_ From 2efe4b7420af2a226d4b593968e254be780d2a7c Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 23 Dec 2013 12:14:14 +0000 Subject: [PATCH 27/70] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 3363b72bc8..6d602f693d 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 3363b72bc8069455a80704b9261f8e97c74edb67 +Subproject commit 6d602f693d2bb8c92fc860509bc93f8f55a01bf1 From b3cc7d7e688c1d639ec0a232a4af872bc78c81e8 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Dec 2013 20:25:11 +0800 Subject: [PATCH 28/70] Bindings-generator skips Node::setContentSize. Binds it manually. --- tools/tojs/cocos2dx.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 9f17145f6a..ba177b8a27 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -37,7 +37,7 @@ classes_need_extend = Node Layer.* Sprite MenuItemFont Scene DrawNode # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = Node::[^setPosition$ setGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule], +skip = Node::[^setPosition$ setGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule setContentSize], Sprite::[getQuad getBlendFunc ^setPosition$ setBlendFunc], SpriteBatchNode::[getBlendFunc setBlendFunc getDescendants], MotionStreak::[getBlendFunc setBlendFunc draw update], From 3096c3431145d2fa90a79e27f2ffa98083e31e0e Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Dec 2013 20:25:46 +0800 Subject: [PATCH 29/70] Removes unneeded binding glue codes, Sprite::setPosition. --- .../javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index fb16fc8a01..4e31a5e98a 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -80b25c13bca3a2d8adfc68a899c732103f68e0f5 \ No newline at end of file +3ea69b3bde8950d0af9d3a2d25c04bdb0e085f00 \ No newline at end of file From 92ee688b731d593dbf07c430f601c1a7f30b3e41 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Dec 2013 20:26:13 +0800 Subject: [PATCH 30/70] Updates js tests to the latest version. --- samples/Javascript/Shared | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Javascript/Shared b/samples/Javascript/Shared index 148868f7f4..24c7cad588 160000 --- a/samples/Javascript/Shared +++ b/samples/Javascript/Shared @@ -1 +1 @@ -Subproject commit 148868f7f4407a12444f07cb5e5378b1dbd7511c +Subproject commit 24c7cad588c85c5ddc83d1a380203913607ebd4a From 48a95cfa553bd1fc58ec364258847561bb293d8b Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Mon, 23 Dec 2013 20:29:05 +0800 Subject: [PATCH 31/70] [Lua Binding] Supports to bind more container: std::vector, std::vector, cocos2d::Map. --- .../lua/bindings/LuaBasicConversions.cpp | 75 ++++++++++++++++++- .../lua/bindings/LuaBasicConversions.h | 67 ++++++++++++++++- 2 files changed, 135 insertions(+), 7 deletions(-) diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp index 6e96f48d6b..ad7bdeb666 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp @@ -1425,14 +1425,81 @@ bool luaval_to_ccvaluevector(lua_State* L, int lo, cocos2d::ValueVector* ret) bool luaval_to_std_vector_string(lua_State* L, int lo, std::vector* ret) { - // TO BE DONE IN CPP FILE - return false; + if (nullptr == L || nullptr == ret || lua_gettop(L) < lo) + return false; + + tolua_Error tolua_err; + bool ok = true; + if (!tolua_istable(L, lo, 0, &tolua_err)) + { +#if COCOS2D_DEBUG >=1 + luaval_to_native_err(L,"#ferror:",&tolua_err); +#endif + ok = false; + } + + if (ok) + { + size_t len = lua_objlen(L, lo); + std::string value = ""; + for (int i = 0; i < len; i++) + { + lua_pushnumber(L, i + 1); + lua_gettable(L,lo); + if(lua_isstring(L, -1)) + { + ok = luaval_to_std_string(L, -1, &value); + if(ok) + ret->push_back(value); + } + else + { + CCASSERT(false, "string type is needed"); + } + + lua_pop(L, 1); + } + } + + return ok; } bool luaval_to_std_vector_int(lua_State* L, int lo, std::vector* ret) { - // TO BE DONE IN CPP FILE - return false; + if (nullptr == L || nullptr == ret || lua_gettop(L) < lo) + return false; + + tolua_Error tolua_err; + bool ok = true; + if (!tolua_istable(L, lo, 0, &tolua_err)) + { +#if COCOS2D_DEBUG >=1 + luaval_to_native_err(L,"#ferror:",&tolua_err); +#endif + ok = false; + } + + if (ok) + { + size_t len = lua_objlen(L, lo); + for (int i = 0; i < len; i++) + { + lua_pushnumber(L, i + 1); + lua_gettable(L,lo); + if(lua_isnumber(L, -1)) + { + ret->push_back((int)tolua_tonumber(L, -1, 0)); + } + else + { + CCASSERT(false, "int type is needed"); + } + + lua_pop(L, 1); + } + } + + return ok; } void point_to_luaval(lua_State* L,const Point& pt) diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.h b/cocos/scripting/lua/bindings/LuaBasicConversions.h index fe7f05b091..feaf396f70 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.h +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.h @@ -120,8 +120,47 @@ bool luaval_to_std_vector_int(lua_State* L, int lo, std::vector* ret); template bool luaval_to_ccmap_string_key(lua_State* L, int lo, cocos2d::Map* ret) { - // TO BE DONE: - return false; + if(nullptr == L || nullptr == ret || lua_gettop(L) < lo) + return false; + + tolua_Error tolua_err; + bool ok = true; + if (!tolua_istable(L, lo, 0, &tolua_err)) + { +#if COCOS2D_DEBUG >=1 + luaval_to_native_err(L,"#ferror:",&tolua_err); +#endif + ok = false; + } + + if (ok) + { + std::string stringKey = ""; + lua_pushnil(L); /* first key L: lotable ..... nil */ + while ( 0 != lua_next(L, lo ) ) /* L: lotable ..... key value */ + { + if (!lua_isstring(L, -2)) + { + lua_pop(L, 1); /* removes 'value'; keep 'key' for next iteration*/ + continue; + } + + if (lua_isnil(L, -1) || !lua_isuserdata(L, -1)) + { + lua_pop(L, 1); + continue; + } + + luaval_to_std_string(L, -2, &stringKey); + T obj = static_cast(tolua_tousertype(L, -1, NULL) ); + if (nullptr != obj) + ret->insert(stringKey, obj); + + lua_pop(L, 1); /* L: lotable ..... key */ + } + } + + return ok; } @@ -179,7 +218,29 @@ void ccvector_to_luaval(lua_State* L,const cocos2d::Vector& inValue) template void ccmap_string_key_to_luaval(lua_State* L, const cocos2d::Map& v) { - // TO BE DONE: + lua_newtable(L); + + if(nullptr == L) + return; + + for (auto iter = v.begin(); iter != v.end(); ++iter) + { + std::string key = iter->first; + T obj = iter->second; + if (nullptr != dynamic_cast(obj)) + { + std::string name = typeid(*obj).name(); + auto typeIter = g_luaType.find(name); + if (g_luaType.end() != typeIter) + { + lua_pushstring(L, name.c_str()); + int ID = (obj) ? (int)obj->_ID : -1; + int* luaID = (obj) ? &obj->_luaID : NULL; + toluafix_pushusertype_ccobject(L, ID, luaID, (void*)obj,typeIter->second.c_str()); + lua_rawset(L, -3); + } + } + } } void ccvalue_to_luaval(lua_State* L,const cocos2d::Value& inValue); From c3247c800f0d8809297417add97bbeb53a7ddb47 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 23 Dec 2013 21:06:37 +0800 Subject: [PATCH 32/70] merge feature function from NewSprite into Sprite --- cocos/2d/CCSprite.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 5bbe9624c6..642e865aee 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -222,6 +222,7 @@ bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame) // designated initializer bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) { + bool result; if (Node::init()) { _batchNode = nullptr; @@ -262,13 +263,15 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) // by default use "Self Render". // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" setBatchNode(nullptr); - - return true; + result = true; } else { - return false; + result = false; } + _recursiveDirty = true; + setDirty(true); + return result; } Sprite::Sprite(void) @@ -694,7 +697,7 @@ bool Sprite::culling() const Rect newRect = RectApplyTransform(_rect, worldTM); kmVec3 point = {newRect.getMinX(), newRect.getMinY(), _vertexZ}; - + AABB aabb(point,point); kmVec3Fill(&point,newRect.getMaxX(), newRect.getMinY(), _vertexZ); aabb.expand(point); @@ -725,8 +728,8 @@ void Sprite::updateQuadVertices() // } // else // { -// CCASSERT( dynamic_cast(_parent), "Logic error in Sprite. Parent must be a Sprite"); -// _transformToBatch = AffineTransformConcat( getNodeToParentTransform() , static_cast(_parent)->_transformToBatch ); +// CCASSERT( dynamic_cast(_parent), "Logic error in Sprite. Parent must be a Sprite"); +// _transformToBatch = AffineTransformConcat( getNodeToParentTransform() , static_cast(_parent)->_transformToBatch ); // } //TODO optimize this transformation, should use parent's transformation instead From e66eb6464d41deb36c18716b2fc96329dab5e125 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 23 Dec 2013 21:07:25 +0800 Subject: [PATCH 33/70] use Sprite instead of NewSprite --- cocos/2d/CCLabelTTF.h | 2 +- .../NewRendererTest/NewRendererTest.cpp | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cocos/2d/CCLabelTTF.h b/cocos/2d/CCLabelTTF.h index 34ba14d1d4..5a1600b23a 100644 --- a/cocos/2d/CCLabelTTF.h +++ b/cocos/2d/CCLabelTTF.h @@ -54,7 +54,7 @@ NS_CC_BEGIN * @endcode * */ -class CC_DLL LabelTTF : public NewSprite, public LabelProtocol +class CC_DLL LabelTTF : public Sprite, public LabelProtocol { public: /** diff --git a/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp b/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp index 49b318a442..2d9432020e 100644 --- a/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp +++ b/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp @@ -179,21 +179,21 @@ void NewSpriteTest::createNewSpriteTest() { Size winSize = Director::getInstance()->getWinSize(); - NewSprite* parent = NewSprite::create("Images/grossini.png"); + Sprite* parent = Sprite::create("Images/grossini.png"); parent->setPosition(winSize.width*2/3, winSize.height/2); - NewSprite* child1 = NewSprite::create("Images/grossinis_sister1.png"); + Sprite* child1 = Sprite::create("Images/grossinis_sister1.png"); child1->setPosition(0.0f, -20.0f); - NewSprite* child2 = NewSprite::create("Images/grossinis_sister2.png"); + Sprite* child2 = Sprite::create("Images/grossinis_sister2.png"); child2->setPosition(20.0f, -20.0f); - NewSprite* child3 = NewSprite::create("Images/grossinis_sister1.png"); + Sprite* child3 = Sprite::create("Images/grossinis_sister1.png"); child3->setPosition(40.0f, -20.0f); - NewSprite* child4 = NewSprite::create("Images/grossinis_sister2.png"); + Sprite* child4 = Sprite::create("Images/grossinis_sister2.png"); child4->setPosition(60.0f, -20.0f); - NewSprite* child5 = NewSprite::create("Images/grossinis_sister2.png"); + Sprite* child5 = Sprite::create("Images/grossinis_sister2.png"); child5->setPosition(80.0f, -20.0f); - NewSprite* child6 = NewSprite::create("Images/grossinis_sister2.png"); + Sprite* child6 = Sprite::create("Images/grossinis_sister2.png"); child6->setPosition(100.0f, -20.0f); - NewSprite* child7 = NewSprite::create("Images/grossinis_sister2.png"); + Sprite* child7 = Sprite::create("Images/grossinis_sister2.png"); child7->setPosition(120.0f, -20.0f); parent->addChild(child1); @@ -266,7 +266,7 @@ void NewSpriteBatchTest::addNewSpriteWithCoords(Point p) int y = (idx/5) * 121; - auto sprite = NewSprite::createWithTexture(BatchNode->getTexture(), Rect(x,y,85,121)); + auto sprite = Sprite::createWithTexture(BatchNode->getTexture(), Rect(x,y,85,121)); BatchNode->addChild(sprite); sprite->setPosition( Point( p.x, p.y) ); @@ -318,11 +318,11 @@ NewClippingNodeTest::NewClippingNodeTest() //Test with alpha Test clipper->setAlphaThreshold(0.05f); - auto stencil = NewSprite::create("Images/grossini.png"); + auto stencil = Sprite::create("Images/grossini.png"); stencil->setPosition(s.width/2, s.height/2); clipper->setStencil(stencil); - auto content = NewSprite::create("Images/background2.png"); + auto content = Sprite::create("Images/background2.png"); content->setTag( kTagContentNode ); content->setAnchorPoint( Point(0.5, 0.5) ); content->setPosition( Point(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) ); @@ -448,7 +448,7 @@ NewCullingTest::NewCullingTest() parent->addChild(parent2); parent2->setPosition(-50,0); parent2->runAction(RepeatForever::create((JumpBy::create(10, Point(0,0), 400, 1)))); - NewSprite* sprite = NewSprite::create(images[index % images.size()].c_str()); + Sprite* sprite = Sprite::create(images[index % images.size()].c_str()); sprite->setPosition(Point(0,0)); //sprite->runAction(RepeatForever::create(RotateBy::create(3, 360))); sprite->runAction(RepeatForever::create(Sequence::createWithTwoActions(ScaleBy::create(2, 2), ScaleBy::create(2,0.5)))); @@ -461,7 +461,7 @@ NewCullingTest::NewCullingTest() parent->addChild(parent2); parent2->setPosition(50,0); parent2->runAction(RepeatForever::create((JumpBy::create(7, Point(0,0), 400, 1)))); - NewSprite* sprite = NewSprite::create(images[index % images.size()].c_str()); + Sprite* sprite = Sprite::create(images[index % images.size()].c_str()); sprite->setPosition(Point(0,0)); //sprite->runAction(RepeatForever::create(RotateBy::create(3, 360))); sprite->runAction(RepeatForever::create(Sequence::createWithTwoActions(ScaleBy::create(2, 2), ScaleBy::create(2,0.5)))); From 6bbc6e2dde55f2908a7f5b5aadad1c13eb0d883c Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Dec 2013 21:12:58 +0800 Subject: [PATCH 34/70] CCSkeleton is inherited from Node now. --- cocos/editor-support/spine/CCSkeleton.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/editor-support/spine/CCSkeleton.h b/cocos/editor-support/spine/CCSkeleton.h index c9a4b7bd5c..abeb3fa8ce 100644 --- a/cocos/editor-support/spine/CCSkeleton.h +++ b/cocos/editor-support/spine/CCSkeleton.h @@ -42,7 +42,7 @@ namespace spine { /** Draws a skeleton. */ -class CCSkeleton: public cocos2d::NodeRGBA, public cocos2d::BlendProtocol { +class CCSkeleton: public cocos2d::Node, public cocos2d::BlendProtocol { public: spSkeleton* skeleton; spBone* rootBone; From 8c0f6ba80eaaa05845f5f3b9dc04cb26adac684f Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Dec 2013 21:13:23 +0800 Subject: [PATCH 35/70] Adds `SpineTest` to iOS, Mac projects. --- build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id index e83c9c8ec4..32afb7bfa0 100644 --- a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -52a991e88e049cd371a153ee168260276a7ac664 \ No newline at end of file +f36b451a97f9a0c93a4e23c417d7333f1e293993 \ No newline at end of file From b08995ae67138e530a9f29c6376ce181a5828209 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Dec 2013 21:14:55 +0800 Subject: [PATCH 36/70] Updates JS-tests to the latest version. --- samples/Javascript/Shared | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Javascript/Shared b/samples/Javascript/Shared index 24c7cad588..fda861cde4 160000 --- a/samples/Javascript/Shared +++ b/samples/Javascript/Shared @@ -1 +1 @@ -Subproject commit 24c7cad588c85c5ddc83d1a380203913607ebd4a +Subproject commit fda861cde4387948e95811966d9c4ceea04dc758 From cc7aa1ee0dd02269106cde2c616f99307a6f4a4c Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 23 Dec 2013 13:45:59 +0000 Subject: [PATCH 37/70] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 6d602f693d..67d2c21cc9 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 6d602f693d2bb8c92fc860509bc93f8f55a01bf1 +Subproject commit 67d2c21cc9c6b1c35fc64e7aaa3ceda113cfff5b From 5f17984826e54f9fcd8a30c7d41c13ee59256e88 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Dec 2013 21:53:23 +0800 Subject: [PATCH 38/70] =?UTF-8?q?Don=E2=80=99t=20hide=20parent=E2=80=99s?= =?UTF-8?q?=20addChild=20method=20in=20TMXLayer=20class.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cocos/2d/CCTMXLayer.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/2d/CCTMXLayer.h b/cocos/2d/CCTMXLayer.h index b2d254fac4..31cd4b9cbd 100644 --- a/cocos/2d/CCTMXLayer.h +++ b/cocos/2d/CCTMXLayer.h @@ -185,6 +185,7 @@ public: /** TMXLayer doesn't support adding a Sprite manually. @warning addchild(z, tag); is not supported on TMXLayer. Instead of setTileGID. */ + using SpriteBatchNode::addChild; virtual void addChild(Node * child, int zOrder, int tag) override; // super method void removeChild(Node* child, bool cleanup) override; From 3327614a999945668d0dc23928b92a37a8ff9aab Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Dec 2013 21:54:02 +0800 Subject: [PATCH 39/70] Binds Node::setAnchorPoint manually. --- .../javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id | 2 +- tools/tojs/cocos2dx.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index 4e31a5e98a..333d98180a 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -3ea69b3bde8950d0af9d3a2d25c04bdb0e085f00 \ No newline at end of file +4ff49d7d50964fb117a48243d728d75dd6d5ef77 \ No newline at end of file diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index ba177b8a27..b95333b068 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -37,7 +37,7 @@ classes_need_extend = Node Layer.* Sprite MenuItemFont Scene DrawNode # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = Node::[^setPosition$ setGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule setContentSize], +skip = Node::[^setPosition$ setGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule setContentSize setAnchorPoint], Sprite::[getQuad getBlendFunc ^setPosition$ setBlendFunc], SpriteBatchNode::[getBlendFunc setBlendFunc getDescendants], MotionStreak::[getBlendFunc setBlendFunc draw update], From d6850c363aabb6a53b19d8cbf6360901e79ec421 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Dec 2013 22:00:11 +0800 Subject: [PATCH 40/70] Updates Bindings-generator. --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index 5f412d0b3a..1b34f5852f 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 5f412d0b3a4eadba3d2abd750de87d1b0e219e0a +Subproject commit 1b34f5852fcf494499be7eb5ce2bada72a0b16a2 From a9d8a64e6378f1bbda8e44195bf8ee930c92de21 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 23 Dec 2013 14:10:01 +0000 Subject: [PATCH 41/70] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 67d2c21cc9..ae83bfe510 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 67d2c21cc9c6b1c35fc64e7aaa3ceda113cfff5b +Subproject commit ae83bfe510cf81f2185b68b5fbca92c816a1c856 From 8d58e43ad2b62a6edb1e4a089b155eb43e64f494 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 24 Dec 2013 09:40:00 +0800 Subject: [PATCH 42/70] remove Class NewSprite --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos/2d/CCLabelTTF.h | 2 +- cocos/2d/cocos2d.h | 1 - cocos/2d/renderer/CCNewSprite.cpp | 165 ------------------ cocos/2d/renderer/CCNewSprite.h | 54 ------ cocos/2d/renderer/CCNewSpriteBatchNode.cpp | 1 - 6 files changed, 2 insertions(+), 223 deletions(-) delete mode 100644 cocos/2d/renderer/CCNewSprite.cpp delete mode 100644 cocos/2d/renderer/CCNewSprite.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 0b1a05e0fa..fc0676082c 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -4b776594c76318354842113d2274acda51fe9178 \ No newline at end of file +d5c3a61431f7098ddeabd3d035d501e3cc02c6b1 \ No newline at end of file diff --git a/cocos/2d/CCLabelTTF.h b/cocos/2d/CCLabelTTF.h index 5a1600b23a..c9d4f9de26 100644 --- a/cocos/2d/CCLabelTTF.h +++ b/cocos/2d/CCLabelTTF.h @@ -25,8 +25,8 @@ THE SOFTWARE. #ifndef __CCLABELTTF_H__ #define __CCLABELTTF_H__ -#include "renderer/CCNewSprite.h" #include "CCTexture2D.h" +#include "CCSprite.h" NS_CC_BEGIN diff --git a/cocos/2d/cocos2d.h b/cocos/2d/cocos2d.h index 64be8231b2..6a3881e960 100644 --- a/cocos/2d/cocos2d.h +++ b/cocos/2d/cocos2d.h @@ -119,7 +119,6 @@ THE SOFTWARE. #include "CCParticleSystemQuad.h" // new renderer -#include "renderer/CCNewSprite.h" #include "renderer/CCNewSpriteBatchNode.h" #include "renderer/CCCustomCommand.h" #include "renderer/CCFrustum.h" diff --git a/cocos/2d/renderer/CCNewSprite.cpp b/cocos/2d/renderer/CCNewSprite.cpp deleted file mode 100644 index 6cbd62cb97..0000000000 --- a/cocos/2d/renderer/CCNewSprite.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCNewSprite.h" -#include "CCRenderer.h" -#include "CCFrustum.h" -#include "CCDirector.h" -#include "CCQuadCommand.h" - -NS_CC_BEGIN - -#if CC_SPRITEBATCHNODE_RENDER_SUBPIXEL -#define RENDER_IN_SUBPIXEL -#else -#define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__)) -#endif - -NewSprite* NewSprite::create() -{ - NewSprite* sprite = new NewSprite(); - if(sprite && sprite->init()) - { - sprite->autorelease(); - return sprite; - } - CC_SAFE_DELETE(sprite); - return nullptr; -} - -NewSprite* NewSprite::create(const char *filename) -{ - NewSprite* sprite = new NewSprite(); - if(sprite && sprite->initWithFile(filename)) - { - sprite->autorelease(); - return sprite; - } - CC_SAFE_DELETE(sprite); - return nullptr; -} - -NewSprite::NewSprite() -:Sprite() -{ - -} - -NewSprite::~NewSprite(void) -{ -} - -bool NewSprite::initWithTexture(Texture2D *texture, const Rect &rect, bool rotated) -{ - bool result = Sprite::initWithTexture(texture, rect, rotated); - _recursiveDirty = true; - setDirty(true); - return result; -} - -void NewSprite::updateQuadVertices() -{ -#ifdef CC_USE_PHYSICS - updatePhysicsTransform(); - setDirty(true); -#endif - - //TODO optimize the performance cache affineTransformation - - // recalculate matrix only if it is dirty - if(isDirty()) - { - -// if( ! _parent || _parent == (Node*)_batchNode ) -// { -// _transformToBatch = getNodeToParentTransform(); -// } -// else -// { -// CCASSERT( dynamic_cast(_parent), "Logic error in Sprite. Parent must be a Sprite"); -// _transformToBatch = AffineTransformConcat( getNodeToParentTransform() , static_cast(_parent)->_transformToBatch ); -// } - - //TODO optimize this transformation, should use parent's transformation instead - _transformToBatch = getNodeToWorldTransform(); - - // - // calculate the Quad based on the Affine Matrix - // - Rect newRect = RectApplyTransform(_rect, _transformToBatch); - - _quad.bl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(newRect.getMinX()), RENDER_IN_SUBPIXEL(newRect.getMinY()), _vertexZ ); - _quad.br.vertices = Vertex3F( RENDER_IN_SUBPIXEL(newRect.getMaxX()), RENDER_IN_SUBPIXEL(newRect.getMinY()), _vertexZ ); - _quad.tl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(newRect.getMinX()), RENDER_IN_SUBPIXEL(newRect.getMaxY()), _vertexZ ); - _quad.tr.vertices = Vertex3F( RENDER_IN_SUBPIXEL(newRect.getMaxX()), RENDER_IN_SUBPIXEL(newRect.getMaxY()), _vertexZ ); - - _recursiveDirty = false; - setDirty(false); - } -} - -void NewSprite::draw(void) -{ - kmMat4 mv; - kmGLGetMatrix(KM_GL_MODELVIEW, &mv); - //TODO implement z order - QuadCommand* renderCommand = QuadCommand::getCommandPool().generateCommand(); - renderCommand->init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv); - - if(!culling()) - { - renderCommand->releaseToCommandPool(); - return; - } - - Director::getInstance()->getRenderer()->addCommand(renderCommand); -} - -bool NewSprite::culling() const -{ - Frustum* frustum = Director::getInstance()->getFrustum(); - //TODO optimize this transformation, should use parent's transformation instead - kmMat4 worldTM = getNodeToWorldTransform(); - //generate aabb - - // - // calculate the Quad based on the Affine Matrix - // - Rect newRect = RectApplyTransform(_rect, worldTM); - - kmVec3 point = {newRect.getMinX(), newRect.getMinY(), _vertexZ}; - - AABB aabb(point,point); - kmVec3Fill(&point,newRect.getMaxX(), newRect.getMinY(), _vertexZ); - aabb.expand(point); - kmVec3Fill(&point,newRect.getMinX(), newRect.getMaxY(), _vertexZ); - aabb.expand(point); - kmVec3Fill(&point,newRect.getMaxX(), newRect.getMaxY(), _vertexZ); - aabb.expand(point); - - return Frustum::IntersectResult::OUTSIDE !=frustum->intersectAABB(aabb); -} - - -NS_CC_END \ No newline at end of file diff --git a/cocos/2d/renderer/CCNewSprite.h b/cocos/2d/renderer/CCNewSprite.h deleted file mode 100644 index aeda67ab50..0000000000 --- a/cocos/2d/renderer/CCNewSprite.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __CCNEWSPRITE_H_ -#define __CCNEWSPRITE_H_ - -#include "CCSprite.h" -#include "CCPlatformMacros.h" - -NS_CC_BEGIN - -class NewSprite : public Sprite -{ - -public: - static NewSprite* create(); - static NewSprite* create(const char *filename); - - virtual void updateQuadVertices(); - virtual void draw(void) override; - - bool culling() const; - -protected: - NewSprite(void); - ~NewSprite(); - - virtual bool initWithTexture(Texture2D *texture, const Rect& rect, bool rotated); -}; - -NS_CC_END - -#endif /* defined(__CCNEWSPRITE_H_) */ diff --git a/cocos/2d/renderer/CCNewSpriteBatchNode.cpp b/cocos/2d/renderer/CCNewSpriteBatchNode.cpp index 07aa234fce..b8fe266f03 100644 --- a/cocos/2d/renderer/CCNewSpriteBatchNode.cpp +++ b/cocos/2d/renderer/CCNewSpriteBatchNode.cpp @@ -27,7 +27,6 @@ #include "CCShaderCache.h" #include "CCTextureCache.h" #include "CCSprite.h" -#include "CCNewSprite.h" #include "CCQuadCommand.h" #include "CCRenderer.h" From 8310c18105ba20591ddd8e367f54d9b9d3922da7 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 24 Dec 2013 10:07:53 +0800 Subject: [PATCH 43/70] update project file: android and linux --- cocos/2d/Android.mk | 1 - cocos/2d/CMakeLists.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/cocos/2d/Android.mk b/cocos/2d/Android.mk index 62d43cfe5c..48f9f7bffd 100644 --- a/cocos/2d/Android.mk +++ b/cocos/2d/Android.mk @@ -117,7 +117,6 @@ platform/CCEGLViewProtocol.cpp \ platform/CCFileUtils.cpp \ platform/CCSAXParser.cpp \ platform/CCThread.cpp \ -renderer/CCNewSprite.cpp \ renderer/CCNewSpriteBatchNode.cpp \ renderer/CCCustomCommand.cpp \ renderer/CCFrustum.cpp \ diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index 4f9918efdb..a574fecac1 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -139,7 +139,6 @@ set(COCOS2D_SRC platform/CCEGLViewProtocol.cpp platform/CCFileUtils.cpp ../../external/edtaa3func/edtaa3func.cpp - renderer/CCNewSprite.cpp renderer/CCNewSpriteBatchNode.cpp renderer/CCCustomCommand.cpp renderer/CCFrustum.cpp From d22f2aaf6786debc9201a2e64b933704672c77e7 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 24 Dec 2013 02:28:17 +0000 Subject: [PATCH 44/70] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index ae83bfe510..3b8073deee 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit ae83bfe510cf81f2185b68b5fbca92c816a1c856 +Subproject commit 3b8073deee86beb5ede81a24e3ccbfef711bfa41 From 325f2e21a76413a47e2e114fca66d4ced04a651b Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 24 Dec 2013 10:41:45 +0800 Subject: [PATCH 45/70] =?UTF-8?q?[JSB]=20long=20=E2=80=94>=20ssize=5Ft=20i?= =?UTF-8?q?n=20JSB=5FTableViewDataSource::callJSDelegate.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bindings/extension/jsb_cocos2dx_extension_manual.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp b/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp index beea364b4b..6d27aa81a7 100644 --- a/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp @@ -350,7 +350,7 @@ private: return false; } - bool callJSDelegate(TableView* table, long idx, std::string jsFunctionName, jsval& retVal) + bool callJSDelegate(TableView* table, ssize_t idx, std::string jsFunctionName, jsval& retVal) { js_proxy_t * p = jsb_get_native_proxy(table); if (!p) return false; @@ -360,7 +360,7 @@ private: JS::RootedValue temp_retval(cx); jsval dataVal[2]; dataVal[0] = OBJECT_TO_JSVAL(p->obj); - dataVal[1] = long_to_jsval(cx,idx); + dataVal[1] = ssize_to_jsval(cx,idx); JSObject* obj = _JSTableViewDataSource; JSAutoCompartment ac(cx, obj); @@ -377,9 +377,9 @@ private: return false; } - JS_CallFunctionName(cx, obj, jsFunctionName.c_str(), + JSBool ret = JS_CallFunctionName(cx, obj, jsFunctionName.c_str(), 2, dataVal, &retVal); - return true; + return ret == JS_TRUE ? true : false; } return false; } From 410cfb9ca4406a5743d3dbb308e0286ea82cd95f Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 24 Dec 2013 10:48:57 +0800 Subject: [PATCH 46/70] move NewSpriteBatchNode feature function into SpriteBatchNode --- cocos/2d/CCSpriteBatchNode.cpp | 30 +++++++++++------- cocos/2d/renderer/CCNewSpriteBatchNode.cpp | 37 ---------------------- cocos/2d/renderer/CCNewSpriteBatchNode.h | 3 -- 3 files changed, 19 insertions(+), 51 deletions(-) diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index 2ed19e294d..90d6011d0a 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -42,6 +42,8 @@ THE SOFTWARE. #include "CCProfiling.h" #include "CCLayer.h" #include "CCScene.h" +#include "CCRenderer.h" +#include "CCQuadCommand.h" // external #include "kazmath/GL/matrix.h" @@ -342,28 +344,34 @@ void SpriteBatchNode::reorderBatch(bool reorder) _reorderChildDirty=reorder; } -// draw -void SpriteBatchNode::draw(void) +void SpriteBatchNode::draw() { - CC_PROFILER_START("CCSpriteBatchNode - draw"); - // Optimization: Fast Dispatch if( _textureAtlas->getTotalQuads() == 0 ) { return; } - CC_NODE_DRAW_SETUP(); - - for(const auto &child: _children) { + for(const auto &child: _children) child->updateTransform(); - } - GL::blendFunc( _blendFunc.src, _blendFunc.dst ); +// arrayMakeObjectsPerformSelector(_children, updateTransform, NewSprite*); - _textureAtlas->drawQuads(); + auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); - CC_PROFILER_STOP("CCSpriteBatchNode - draw"); + kmMat4 mv; + kmGLGetMatrix(KM_GL_MODELVIEW, &mv); + + QuadCommand* cmd = QuadCommand::getCommandPool().generateCommand(); + cmd->init(0, + _vertexZ, + _textureAtlas->getTexture()->getName(), + shader, + _blendFunc, + _textureAtlas->getQuads(), + _textureAtlas->getTotalQuads(), + mv); + Director::getInstance()->getRenderer()->addCommand(cmd); } void SpriteBatchNode::increaseAtlasCapacity(void) diff --git a/cocos/2d/renderer/CCNewSpriteBatchNode.cpp b/cocos/2d/renderer/CCNewSpriteBatchNode.cpp index b8fe266f03..f7c726949b 100644 --- a/cocos/2d/renderer/CCNewSpriteBatchNode.cpp +++ b/cocos/2d/renderer/CCNewSpriteBatchNode.cpp @@ -61,41 +61,4 @@ NewSpriteBatchNode::~NewSpriteBatchNode() } -bool NewSpriteBatchNode::init() -{ - Texture2D* texture = new Texture2D(); - texture->autorelease(); - return this->initWithTexture(texture, 0); -} - -void NewSpriteBatchNode::draw() -{ - // Optimization: Fast Dispatch - if( _textureAtlas->getTotalQuads() == 0 ) - { - return; - } - - for(const auto &child: _children) - child->updateTransform(); - -// arrayMakeObjectsPerformSelector(_children, updateTransform, NewSprite*); - - auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); - - kmMat4 mv; - kmGLGetMatrix(KM_GL_MODELVIEW, &mv); - - QuadCommand* cmd = QuadCommand::getCommandPool().generateCommand(); - cmd->init(0, - _vertexZ, - _textureAtlas->getTexture()->getName(), - shader, - _blendFunc, - _textureAtlas->getQuads(), - _textureAtlas->getTotalQuads(), - mv); - Director::getInstance()->getRenderer()->addCommand(cmd); -} - NS_CC_END \ No newline at end of file diff --git a/cocos/2d/renderer/CCNewSpriteBatchNode.h b/cocos/2d/renderer/CCNewSpriteBatchNode.h index dabae243aa..5ff3584486 100644 --- a/cocos/2d/renderer/CCNewSpriteBatchNode.h +++ b/cocos/2d/renderer/CCNewSpriteBatchNode.h @@ -38,12 +38,9 @@ public: static NewSpriteBatchNode* createWithTexture(Texture2D* tex, int capacity = DEFAULT_CAPACITY); static NewSpriteBatchNode* create(const char* fileImage, long capacity = DEFAULT_CAPACITY); - void draw(void); - protected: NewSpriteBatchNode(); virtual ~NewSpriteBatchNode(); - bool init(); }; NS_CC_END From b61bf3ad9515fec36df53a98f5f947d08bbe2e0f Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 24 Dec 2013 10:51:35 +0800 Subject: [PATCH 47/70] LabelBMFont inherit SpriteBatchNode instead of NewSpriteBatchNode remove NewSpriteBatchNode testcase to SpriteBatchNode --- cocos/2d/CCLabelBMFont.h | 2 +- .../Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/2d/CCLabelBMFont.h b/cocos/2d/CCLabelBMFont.h index e137734ed1..1679372b7e 100644 --- a/cocos/2d/CCLabelBMFont.h +++ b/cocos/2d/CCLabelBMFont.h @@ -190,7 +190,7 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only) @since v0.8 */ -class CC_DLL LabelBMFont : public NewSpriteBatchNode, public LabelProtocol +class CC_DLL LabelBMFont : public SpriteBatchNode, public LabelProtocol { public: /** diff --git a/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp b/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp index 2d9432020e..d0e68e3c3a 100644 --- a/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp +++ b/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp @@ -229,7 +229,7 @@ NewSpriteBatchTest::NewSpriteBatchTest() touchListener->onTouchesEnded = CC_CALLBACK_2(NewSpriteBatchTest::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); - auto BatchNode = NewSpriteBatchNode::create("Images/grossini_dance_atlas.png", 50); + auto BatchNode = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 50); addChild(BatchNode, 0, kTagSpriteBatchNode); } @@ -259,7 +259,7 @@ void NewSpriteBatchTest::onTouchesEnded(const std::vector &touches, Eve void NewSpriteBatchTest::addNewSpriteWithCoords(Point p) { - auto BatchNode = static_cast( getChildByTag(kTagSpriteBatchNode) ); + auto BatchNode = static_cast( getChildByTag(kTagSpriteBatchNode) ); int idx = (int) (CCRANDOM_0_1() * 1400 / 100); int x = (idx%5) * 85; From 24ac743a3c2065cad3fa9a13a9ec4f870198cd91 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 24 Dec 2013 11:03:59 +0800 Subject: [PATCH 48/70] remove class NewSpriteBatchNode --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos/2d/CCLabelBMFont.h | 2 +- cocos/2d/cocos2d.h | 1 - cocos/2d/renderer/CCNewSpriteBatchNode.cpp | 64 ------------------- cocos/2d/renderer/CCNewSpriteBatchNode.h | 48 -------------- 5 files changed, 2 insertions(+), 115 deletions(-) delete mode 100644 cocos/2d/renderer/CCNewSpriteBatchNode.cpp delete mode 100644 cocos/2d/renderer/CCNewSpriteBatchNode.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index fc0676082c..c10799cfcc 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -d5c3a61431f7098ddeabd3d035d501e3cc02c6b1 \ No newline at end of file +dbc36fc71a80b4f019f1c23f6acd9b2a507e41df \ No newline at end of file diff --git a/cocos/2d/CCLabelBMFont.h b/cocos/2d/CCLabelBMFont.h index 1679372b7e..928d089370 100644 --- a/cocos/2d/CCLabelBMFont.h +++ b/cocos/2d/CCLabelBMFont.h @@ -33,7 +33,7 @@ Use any of these editors to generate BMFonts: #ifndef __CCBITMAP_FONT_ATLAS_H__ #define __CCBITMAP_FONT_ATLAS_H__ -#include "renderer/CCNewSpriteBatchNode.h" +#include "CCSpriteBatchNode.h" #include "uthash.h" #include #include diff --git a/cocos/2d/cocos2d.h b/cocos/2d/cocos2d.h index 6a3881e960..e8fb3bd0c6 100644 --- a/cocos/2d/cocos2d.h +++ b/cocos/2d/cocos2d.h @@ -119,7 +119,6 @@ THE SOFTWARE. #include "CCParticleSystemQuad.h" // new renderer -#include "renderer/CCNewSpriteBatchNode.h" #include "renderer/CCCustomCommand.h" #include "renderer/CCFrustum.h" #include "renderer/CCGroupCommand.h" diff --git a/cocos/2d/renderer/CCNewSpriteBatchNode.cpp b/cocos/2d/renderer/CCNewSpriteBatchNode.cpp deleted file mode 100644 index f7c726949b..0000000000 --- a/cocos/2d/renderer/CCNewSpriteBatchNode.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCNewSpriteBatchNode.h" -#include "CCDirector.h" -#include "CCShaderCache.h" -#include "CCTextureCache.h" -#include "CCSprite.h" -#include "CCQuadCommand.h" -#include "CCRenderer.h" - -NS_CC_BEGIN - -NewSpriteBatchNode *NewSpriteBatchNode::createWithTexture(Texture2D *tex, int capacity) -{ - NewSpriteBatchNode* batchNode = new NewSpriteBatchNode(); - batchNode->initWithTexture(tex, capacity); - batchNode->autorelease(); - - return batchNode; -} - -NewSpriteBatchNode *NewSpriteBatchNode::create(const char *fileImage, long capacity) -{ - NewSpriteBatchNode* batchNode = new NewSpriteBatchNode(); - batchNode->initWithFile(fileImage, capacity); - batchNode->autorelease(); - - return batchNode; -} - -NewSpriteBatchNode::NewSpriteBatchNode() -:SpriteBatchNode() -{ - -} - -NewSpriteBatchNode::~NewSpriteBatchNode() -{ - -} - -NS_CC_END \ No newline at end of file diff --git a/cocos/2d/renderer/CCNewSpriteBatchNode.h b/cocos/2d/renderer/CCNewSpriteBatchNode.h deleted file mode 100644 index 5ff3584486..0000000000 --- a/cocos/2d/renderer/CCNewSpriteBatchNode.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __CCNewSpriteBatchNode_H_ -#define __CCNewSpriteBatchNode_H_ - -#include "CCPlatformMacros.h" -#include "CCTexture2D.h" -#include "CCSpriteBatchNode.h" - -NS_CC_BEGIN - -class NewSpriteBatchNode : public SpriteBatchNode -{ - static const int DEFAULT_CAPACITY = 29; -public: - static NewSpriteBatchNode* createWithTexture(Texture2D* tex, int capacity = DEFAULT_CAPACITY); - static NewSpriteBatchNode* create(const char* fileImage, long capacity = DEFAULT_CAPACITY); - -protected: - NewSpriteBatchNode(); - virtual ~NewSpriteBatchNode(); -}; - -NS_CC_END - -#endif //__CCNewSpriteBatchNode_H_ From ff053e71fe459df98ff50f57739473d34f7927c3 Mon Sep 17 00:00:00 2001 From: yinkaile Date: Tue, 24 Dec 2013 11:05:53 +0800 Subject: [PATCH 49/70] change std::string compare method --- cocos/editor-support/cocostudio/CCArmature.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 27b2b8db77..f063fe60f4 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -125,7 +125,7 @@ bool Armature::init(const std::string& name) ArmatureDataManager *armatureDataManager = ArmatureDataManager::getInstance(); - if(_name.length() != 0) + if(!_name.empty()) { AnimationData *animationData = armatureDataManager->getAnimationData(name); CCASSERT(animationData, "AnimationData not exist! "); @@ -236,7 +236,7 @@ void Armature::addBone(Bone *bone, const std::string& parentName) CCASSERT( bone != nullptr, "Argument must be non-nil"); CCASSERT(_boneDic.at(bone->getName()) == nullptr, "bone already added. It can't be added again"); - if ("" != parentName) + if (!parentName.empty()) { Bone *boneParent = _boneDic.at(parentName); if (boneParent) @@ -292,7 +292,7 @@ void Armature::changeBoneParent(Bone *bone, const std::string& parentName) bone->setParentBone(nullptr); } - if (parentName != "") + if (!parentName.empty()) { Bone *boneParent = _boneDic.at(parentName); From 12e2cfedf2de85f26665ae38e1c4ecd331c39374 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 24 Dec 2013 11:20:21 +0800 Subject: [PATCH 50/70] update project file:android and linux --- cocos/2d/Android.mk | 1 - cocos/2d/CMakeLists.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/cocos/2d/Android.mk b/cocos/2d/Android.mk index 48f9f7bffd..40966dcef7 100644 --- a/cocos/2d/Android.mk +++ b/cocos/2d/Android.mk @@ -117,7 +117,6 @@ platform/CCEGLViewProtocol.cpp \ platform/CCFileUtils.cpp \ platform/CCSAXParser.cpp \ platform/CCThread.cpp \ -renderer/CCNewSpriteBatchNode.cpp \ renderer/CCCustomCommand.cpp \ renderer/CCFrustum.cpp \ renderer/CCGroupCommand.cpp \ diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index a574fecac1..7379a07352 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -139,7 +139,6 @@ set(COCOS2D_SRC platform/CCEGLViewProtocol.cpp platform/CCFileUtils.cpp ../../external/edtaa3func/edtaa3func.cpp - renderer/CCNewSpriteBatchNode.cpp renderer/CCCustomCommand.cpp renderer/CCFrustum.cpp renderer/CCGroupCommand.cpp From b821a33cfa4b7b19bbc2e79c94ab24652e96b15b Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 24 Dec 2013 11:28:42 +0800 Subject: [PATCH 51/70] remove comment code --- cocos/2d/CCSpriteBatchNode.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index 90d6011d0a..2fafa72070 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -355,8 +355,6 @@ void SpriteBatchNode::draw() for(const auto &child: _children) child->updateTransform(); -// arrayMakeObjectsPerformSelector(_children, updateTransform, NewSprite*); - auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); kmMat4 mv; From e50b6b616b93d986face3d1587e026c011aef0e4 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 24 Dec 2013 03:45:37 +0000 Subject: [PATCH 52/70] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 3b8073deee..e7b73bebfb 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 3b8073deee86beb5ede81a24e3ccbfef711bfa41 +Subproject commit e7b73bebfbe42cf352a01fe0793af02423f6713a From 44e22584a495bdd3f7bbaf0210a9a45bebe9606a Mon Sep 17 00:00:00 2001 From: yinkaile Date: Tue, 24 Dec 2013 13:35:46 +0800 Subject: [PATCH 53/70] fixed getFileData --- .../cocostudio/CCDataReaderHelper.cpp | 20 +++++++++++-------- .../cocostudio/CCDataReaderHelper.h | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index fe287c6d14..3219b0b668 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -287,9 +287,12 @@ void DataReaderHelper::addDataFromFile(const std::string& filePath) size_t startPos = filePathStr.find_last_of("."); std::string str = &filePathStr[startPos]; + // Read content from file ssize_t size; std::string fullPath = CCFileUtils::getInstance()->fullPathForFilename(filePath); - char *pFileContent = (char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size); + unsigned char *pTempContent = (unsigned char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size); + + std::string contentStr = std::string((const char*)pTempContent, size); DataInfo dataInfo; dataInfo.filename = filePathStr; @@ -298,13 +301,14 @@ void DataReaderHelper::addDataFromFile(const std::string& filePath) if (str.compare(".xml") == 0) { - DataReaderHelper::addDataFromCache(pFileContent, &dataInfo); + DataReaderHelper::addDataFromCache(contentStr, &dataInfo); } else if(str.compare(".json") == 0 || str.compare(".ExportJson") == 0) { - DataReaderHelper::addDataFromJsonCache(pFileContent, &dataInfo); + DataReaderHelper::addDataFromJsonCache(contentStr, &dataInfo); } - free(pFileContent); + + free(pTempContent); } void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const std::string& plistPath, const std::string& filePath, Object *target, SEL_SCHEDULE selector) @@ -489,10 +493,10 @@ void DataReaderHelper::removeConfigFile(const std::string& configFile) -void DataReaderHelper::addDataFromCache(const char* pFileContent, DataInfo *dataInfo) +void DataReaderHelper::addDataFromCache(const std::string& pFileContent, DataInfo *dataInfo) { tinyxml2::XMLDocument document; - document.Parse(pFileContent); + document.Parse(pFileContent.c_str()); tinyxml2::XMLElement *root = document.RootElement(); CCASSERT(root, "XML error or XML is empty."); @@ -1180,10 +1184,10 @@ ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML, D -void DataReaderHelper::addDataFromJsonCache(const char* fileContent, DataInfo *dataInfo) +void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, DataInfo *dataInfo) { JsonDictionary json; - json.initWithDescription(fileContent); + json.initWithDescription(fileContent.c_str()); dataInfo->contentScale = json.getItemFloatValue(CONTENT_SCALE, 1); diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.h b/cocos/editor-support/cocostudio/CCDataReaderHelper.h index 553a27f15e..3126c6427a 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.h +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.h @@ -122,7 +122,7 @@ public: * * @param xmlPath The cache of the xml */ - static void addDataFromCache(const char* pFileContent, DataInfo *dataInfo = nullptr); + static void addDataFromCache(const std::string& pFileContent, DataInfo *dataInfo = nullptr); @@ -154,7 +154,7 @@ public: static ContourData *decodeContour(tinyxml2::XMLElement *contourXML, DataInfo *dataInfo); public: - static void addDataFromJsonCache(const char* fileContent, DataInfo *dataInfo = nullptr); + static void addDataFromJsonCache(const std::string& fileContent, DataInfo *dataInfo = nullptr); static ArmatureData *decodeArmature(JsonDictionary &json, DataInfo *dataInfo); static BoneData *decodeBone(JsonDictionary &json, DataInfo *dataInfo); From 98e4e802f4046b297dba1cc42916fac919328a81 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Tue, 24 Dec 2013 13:42:32 +0800 Subject: [PATCH 54/70] Support pass by value for setPosition\setAnchorPoint\setContentSize for lua binding --- .../lua/bindings/lua_cocos2dx_manual.cpp.REMOVED.git-id | 2 +- tools/tolua/cocos2dx.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_manual.cpp.REMOVED.git-id b/cocos/scripting/lua/bindings/lua_cocos2dx_manual.cpp.REMOVED.git-id index 60b4dcf835..58e6d8276a 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_manual.cpp.REMOVED.git-id +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_manual.cpp.REMOVED.git-id @@ -1 +1 @@ -b633b49d700c36e38f74509d09c52255e2300ecf \ No newline at end of file +e240eefd2a238e3ae31d78fd78cade02ff8344fb \ No newline at end of file diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 2c86bc2d8e..5121f002c7 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -35,7 +35,7 @@ classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* M # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule getPosition$], +skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule getPosition$ setContentSize setAnchorPoint], Sprite::[getQuad getBlendFunc ^setPosition$ setBlendFunc], SpriteBatchNode::[getBlendFunc setBlendFunc getDescendants], MotionStreak::[getBlendFunc setBlendFunc draw update], From c170559759f4c32ef58dd74a1480920d87be6075 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 24 Dec 2013 05:59:50 +0000 Subject: [PATCH 55/70] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index e7b73bebfb..4196652f09 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit e7b73bebfbe42cf352a01fe0793af02423f6713a +Subproject commit 4196652f09cd156d2432fb368150ae6ea2298922 From 5a6275f3cc6604e5eb605f112d5f66b872b0aa4c Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 24 Dec 2013 14:04:55 +0800 Subject: [PATCH 56/70] Update CHANGELOG [ci skip] --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 06a2a11e02..7987aef21d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,8 @@ cocos2d-x-3.0beta0 ?? 2013 [FIX] UserDefault::getDoubleForKey() doesn't pass default value to Java. [Windows] [NEW] CMake support for windows. +[Bindings] + [FIX] Don't bind override functions for JSB and LuaBining since they aren't needed at all. cocos2d-x-3.0alpha1 Nov.19 2013 [all platforms] From e7facf9f8533fa32bd61f1e3b5f5a66c536319a8 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 24 Dec 2013 14:08:57 +0800 Subject: [PATCH 57/70] remove NewClippingNode feature function into ClippingNode --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos/2d/CCClippingNode.cpp | 435 +++++++++--------- cocos/2d/CCClippingNode.h | 21 + .../NewRendererTest/NewRendererTest.cpp | 2 +- 4 files changed, 241 insertions(+), 219 deletions(-) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index c10799cfcc..f468ef48e1 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -dbc36fc71a80b4f019f1c23f6acd9b2a507e41df \ No newline at end of file +46306289a3acdd8e276623262d79197870e2ee9c \ No newline at end of file diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index 51123ca528..ebd3be5e24 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -31,10 +31,17 @@ #include "CCShaderCache.h" #include "CCDirector.h" #include "CCDrawingPrimitives.h" +#include "CCRenderer.h" +#include "CCGroupCommand.h" +#include "CCCustomCommand.h" NS_CC_BEGIN static GLint g_sStencilBits = -1; +// store the current stencil layer (position in the stencil buffer), +// this will allow nesting up to n ClippingNode, +// where n is the number of bits of the stencil buffer. +static GLint layer = -1; static void setProgram(Node *n, GLProgram *p) { @@ -50,7 +57,21 @@ ClippingNode::ClippingNode() : _stencil(nullptr) , _alphaThreshold(0.0f) , _inverted(false) -{} +, _currentStencilEnabled(GL_FALSE) +, _currentStencilWriteMask(~0) +, _currentStencilFunc(GL_ALWAYS) +, _currentStencilRef(0) +, _currentStencilValueMask(~0) +, _currentStencilFail(GL_KEEP) +, _currentStencilPassDepthFail(GL_KEEP) +, _currentStencilPassDepthPass(GL_KEEP) +, _currentDepthWriteMask(GL_TRUE) +, _currentAlphaTestEnabled(GL_FALSE) +, _currentAlphaTestFunc(GL_ALWAYS) +, _currentAlphaTestRef(1) +{ + +} ClippingNode::~ClippingNode() { @@ -179,225 +200,36 @@ void ClippingNode::drawFullScreenQuadClearStencil() void ClippingNode::visit() { - // if stencil buffer disabled - if (g_sStencilBits < 1) - { - // draw everything, as if there where no stencil - Node::visit(); - return; - } + //Add group command - // return fast (draw nothing, or draw everything if in inverted mode) if: - // - nil stencil node - // - or stencil node invisible: - if (!_stencil || !_stencil->isVisible()) - { - if (_inverted) - { - // draw everything - Node::visit(); - } - return; - } + Renderer* renderer = Director::getInstance()->getRenderer(); - // store the current stencil layer (position in the stencil buffer), - // this will allow nesting up to n ClippingNode, - // where n is the number of bits of the stencil buffer. - static GLint layer = -1; - - // all the _stencilBits are in use? - if (layer + 1 == g_sStencilBits) - { - // warn once - static bool once = true; - if (once) - { - char warning[200] = {0}; - snprintf(warning, sizeof(warning), "Nesting more than %d stencils is not supported. Everything will be drawn without stencil for this node and its childs.", g_sStencilBits); - CCLOG("%s", warning); - - once = false; - } - // draw everything, as if there where no stencil - Node::visit(); - return; - } - - /////////////////////////////////// - // INIT - - // increment the current layer - layer++; - - // mask of the current layer (ie: for layer 3: 00000100) - GLint mask_layer = 0x1 << layer; - // mask of all layers less than the current (ie: for layer 3: 00000011) - GLint mask_layer_l = mask_layer - 1; - // mask of all layers less than or equal to the current (ie: for layer 3: 00000111) - GLint mask_layer_le = mask_layer | mask_layer_l; - - // manually save the stencil state - GLboolean currentStencilEnabled = GL_FALSE; - GLuint currentStencilWriteMask = ~0; - GLenum currentStencilFunc = GL_ALWAYS; - GLint currentStencilRef = 0; - GLuint currentStencilValueMask = ~0; - GLenum currentStencilFail = GL_KEEP; - GLenum currentStencilPassDepthFail = GL_KEEP; - GLenum currentStencilPassDepthPass = GL_KEEP; - currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST); - glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)¤tStencilWriteMask); - glGetIntegerv(GL_STENCIL_FUNC, (GLint *)¤tStencilFunc); - glGetIntegerv(GL_STENCIL_REF, ¤tStencilRef); - glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)¤tStencilValueMask); - glGetIntegerv(GL_STENCIL_FAIL, (GLint *)¤tStencilFail); - glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)¤tStencilPassDepthFail); - glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)¤tStencilPassDepthPass); - - // enable stencil use - glEnable(GL_STENCIL_TEST); - // check for OpenGL error while enabling stencil test - CHECK_GL_ERROR_DEBUG(); - - // all bits on the stencil buffer are readonly, except the current layer bit, - // this means that operation like glClear or glStencilOp will be masked with this value - glStencilMask(mask_layer); - - // manually save the depth test state - //GLboolean currentDepthTestEnabled = GL_TRUE; - GLboolean currentDepthWriteMask = GL_TRUE; - //currentDepthTestEnabled = glIsEnabled(GL_DEPTH_TEST); - glGetBooleanv(GL_DEPTH_WRITEMASK, ¤tDepthWriteMask); - - // disable depth test while drawing the stencil - //glDisable(GL_DEPTH_TEST); - // disable update to the depth buffer while drawing the stencil, - // as the stencil is not meant to be rendered in the real scene, - // it should never prevent something else to be drawn, - // only disabling depth buffer update should do - glDepthMask(GL_FALSE); - - /////////////////////////////////// - // CLEAR STENCIL BUFFER - - // manually clear the stencil buffer by drawing a fullscreen rectangle on it - // setup the stencil test func like this: - // for each pixel in the fullscreen rectangle - // never draw it into the frame buffer - // if not in inverted mode: set the current layer value to 0 in the stencil buffer - // if in inverted mode: set the current layer value to 1 in the stencil buffer - glStencilFunc(GL_NEVER, mask_layer, mask_layer); - glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP); - - // draw a fullscreen solid rectangle to clear the stencil buffer - //ccDrawSolidRect(Point::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1)); - drawFullScreenQuadClearStencil(); - - /////////////////////////////////// - // DRAW CLIPPING STENCIL - - // setup the stencil test func like this: - // for each pixel in the stencil node - // never draw it into the frame buffer - // if not in inverted mode: set the current layer value to 1 in the stencil buffer - // if in inverted mode: set the current layer value to 0 in the stencil buffer - glStencilFunc(GL_NEVER, mask_layer, mask_layer); - glStencilOp(!_inverted ? GL_REPLACE : GL_ZERO, GL_KEEP, GL_KEEP); - - // enable alpha test only if the alpha threshold < 1, - // indeed if alpha threshold == 1, every pixel will be drawn anyways -#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) - GLboolean currentAlphaTestEnabled = GL_FALSE; - GLenum currentAlphaTestFunc = GL_ALWAYS; - GLclampf currentAlphaTestRef = 1; -#endif - if (_alphaThreshold < 1) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) - // manually save the alpha test state - currentAlphaTestEnabled = glIsEnabled(GL_ALPHA_TEST); - glGetIntegerv(GL_ALPHA_TEST_FUNC, (GLint *)¤tAlphaTestFunc); - glGetFloatv(GL_ALPHA_TEST_REF, ¤tAlphaTestRef); - // enable alpha testing - glEnable(GL_ALPHA_TEST); - // check for OpenGL error while enabling alpha test - CHECK_GL_ERROR_DEBUG(); - // pixel will be drawn only if greater than an alpha threshold - glAlphaFunc(GL_GREATER, _alphaThreshold); -#else - // since glAlphaTest do not exists in OES, use a shader that writes - // pixel only if greater than an alpha threshold - GLProgram *program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); - GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); - // set our alphaThreshold - program->use(); - program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); - // we need to recursively apply this shader to all the nodes in the stencil node - // XXX: we should have a way to apply shader to all nodes without having to do this - setProgram(_stencil, program); - -#endif - } - - // draw the stencil node as if it was one of our child - // (according to the stencil test func/op and alpha (or alpha shader) test) - kmGLPushMatrix(); - transform(); - if (_stencil != nullptr) - { - _stencil->visit(); - } - kmGLPopMatrix(); - - // restore alpha test state - if (_alphaThreshold < 1) - { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) - // manually restore the alpha test state - glAlphaFunc(currentAlphaTestFunc, currentAlphaTestRef); - if (!currentAlphaTestEnabled) - { - glDisable(GL_ALPHA_TEST); - } -#else -// XXX: we need to find a way to restore the shaders of the stencil node and its childs -#endif - } - - // restore the depth test state - glDepthMask(currentDepthWriteMask); - //if (currentDepthTestEnabled) { - // glEnable(GL_DEPTH_TEST); - //} - - /////////////////////////////////// - // DRAW CONTENT - - // setup the stencil test func like this: - // for each pixel of this node and its childs - // if all layers less than or equals to the current are set to 1 in the stencil buffer - // draw the pixel and keep the current layer in the stencil buffer - // else - // do not draw the pixel but keep the current layer in the stencil buffer - glStencilFunc(GL_EQUAL, mask_layer_le, mask_layer_le); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - - // draw (according to the stencil test func) this node and its childs + GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand(); + groupCommand->init(0,_vertexZ); + renderer->addCommand(groupCommand); + + renderer->pushGroup(groupCommand->getRenderQueueID()); + + CustomCommand* beforeVisitCmd = CustomCommand::getCommandPool().generateCommand(); + beforeVisitCmd->init(0,_vertexZ); + beforeVisitCmd->func = CC_CALLBACK_0(ClippingNode::beforeVisit, this); + renderer->addCommand(beforeVisitCmd); + + _stencil->visit(); + + CustomCommand* afterDrawStencilCmd = CustomCommand::getCommandPool().generateCommand(); + afterDrawStencilCmd->init(0,_vertexZ); + afterDrawStencilCmd->func = CC_CALLBACK_0(ClippingNode::afterDrawStencil, this); + renderer->addCommand(afterDrawStencilCmd); + Node::visit(); - - /////////////////////////////////// - // CLEANUP - - // manually restore the stencil state - glStencilFunc(currentStencilFunc, currentStencilRef, currentStencilValueMask); - glStencilOp(currentStencilFail, currentStencilPassDepthFail, currentStencilPassDepthPass); - glStencilMask(currentStencilWriteMask); - if (!currentStencilEnabled) - { - glDisable(GL_STENCIL_TEST); - } - - // we are done using this layer, decrement - layer--; + + CustomCommand* afterVisitCmd = CustomCommand::getCommandPool().generateCommand(); + afterVisitCmd->init(0,_vertexZ); + afterVisitCmd->func = CC_CALLBACK_0(ClippingNode::afterVisit, this); + renderer->addCommand(afterVisitCmd); + + renderer->popGroup(); } Node* ClippingNode::getStencil() const @@ -432,4 +264,173 @@ void ClippingNode::setInverted(bool inverted) _inverted = inverted; } +void ClippingNode::beforeVisit() +{ + /////////////////////////////////// + // INIT + + // increment the current layer + layer++; + + // mask of the current layer (ie: for layer 3: 00000100) + GLint mask_layer = 0x1 << layer; + // mask of all layers less than the current (ie: for layer 3: 00000011) + GLint mask_layer_l = mask_layer - 1; + // mask of all layers less than or equal to the current (ie: for layer 3: 00000111) + _mask_layer_le = mask_layer | mask_layer_l; + + // manually save the stencil state + + _currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST); + glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)&_currentStencilWriteMask); + glGetIntegerv(GL_STENCIL_FUNC, (GLint *)&_currentStencilFunc); + glGetIntegerv(GL_STENCIL_REF, &_currentStencilRef); + glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)&_currentStencilValueMask); + glGetIntegerv(GL_STENCIL_FAIL, (GLint *)&_currentStencilFail); + glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)&_currentStencilPassDepthFail); + glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)&_currentStencilPassDepthPass); + + // enable stencil use + glEnable(GL_STENCIL_TEST); + // check for OpenGL error while enabling stencil test + CHECK_GL_ERROR_DEBUG(); + + // all bits on the stencil buffer are readonly, except the current layer bit, + // this means that operation like glClear or glStencilOp will be masked with this value + glStencilMask(mask_layer); + + // manually save the depth test state + + //currentDepthTestEnabled = glIsEnabled(GL_DEPTH_TEST); + glGetBooleanv(GL_DEPTH_WRITEMASK, &_currentDepthWriteMask); + + // disable depth test while drawing the stencil + //glDisable(GL_DEPTH_TEST); + // disable update to the depth buffer while drawing the stencil, + // as the stencil is not meant to be rendered in the real scene, + // it should never prevent something else to be drawn, + // only disabling depth buffer update should do + glDepthMask(GL_FALSE); + + /////////////////////////////////// + // CLEAR STENCIL BUFFER + + // manually clear the stencil buffer by drawing a fullscreen rectangle on it + // setup the stencil test func like this: + // for each pixel in the fullscreen rectangle + // never draw it into the frame buffer + // if not in inverted mode: set the current layer value to 0 in the stencil buffer + // if in inverted mode: set the current layer value to 1 in the stencil buffer + glStencilFunc(GL_NEVER, mask_layer, mask_layer); + glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP); + + // draw a fullscreen solid rectangle to clear the stencil buffer + //ccDrawSolidRect(Point::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1)); + drawFullScreenQuadClearStencil(); + + /////////////////////////////////// + // DRAW CLIPPING STENCIL + + // setup the stencil test func like this: + // for each pixel in the stencil node + // never draw it into the frame buffer + // if not in inverted mode: set the current layer value to 1 in the stencil buffer + // if in inverted mode: set the current layer value to 0 in the stencil buffer + glStencilFunc(GL_NEVER, mask_layer, mask_layer); + glStencilOp(!_inverted ? GL_REPLACE : GL_ZERO, GL_KEEP, GL_KEEP); + + // enable alpha test only if the alpha threshold < 1, + // indeed if alpha threshold == 1, every pixel will be drawn anyways +#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) +// GLboolean currentAlphaTestEnabled = GL_FALSE; +// GLenum currentAlphaTestFunc = GL_ALWAYS; +// GLclampf currentAlphaTestRef = 1; +#endif + if (_alphaThreshold < 1) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) + // manually save the alpha test state + _currentAlphaTestEnabled = glIsEnabled(GL_ALPHA_TEST); + glGetIntegerv(GL_ALPHA_TEST_FUNC, (GLint *)&_currentAlphaTestFunc); + glGetFloatv(GL_ALPHA_TEST_REF, &_currentAlphaTestRef); + // enable alpha testing + glEnable(GL_ALPHA_TEST); + // check for OpenGL error while enabling alpha test + CHECK_GL_ERROR_DEBUG(); + // pixel will be drawn only if greater than an alpha threshold + glAlphaFunc(GL_GREATER, _alphaThreshold); +#else + // since glAlphaTest do not exists in OES, use a shader that writes + // pixel only if greater than an alpha threshold + GLProgram *program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); + GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); + // set our alphaThreshold + program->use(); + program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); + // we need to recursively apply this shader to all the nodes in the stencil node + // XXX: we should have a way to apply shader to all nodes without having to do this + setProgram(_stencil, program); + +#endif + } + + //Draw _stencil +} + +void ClippingNode::afterDrawStencil() +{ + // restore alpha test state + if (_alphaThreshold < 1) + { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) + // manually restore the alpha test state + glAlphaFunc(_currentAlphaTestFunc, _currentAlphaTestRef); + if (!_currentAlphaTestEnabled) + { + glDisable(GL_ALPHA_TEST); + } +#else +// XXX: we need to find a way to restore the shaders of the stencil node and its childs +#endif + } + + // restore the depth test state + glDepthMask(_currentDepthWriteMask); + //if (currentDepthTestEnabled) { + // glEnable(GL_DEPTH_TEST); + //} + + /////////////////////////////////// + // DRAW CONTENT + + // setup the stencil test func like this: + // for each pixel of this node and its childs + // if all layers less than or equals to the current are set to 1 in the stencil buffer + // draw the pixel and keep the current layer in the stencil buffer + // else + // do not draw the pixel but keep the current layer in the stencil buffer + glStencilFunc(GL_EQUAL, _mask_layer_le, _mask_layer_le); + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + + // draw (according to the stencil test func) this node and its childs +} + + +void ClippingNode::afterVisit() +{ + /////////////////////////////////// + // CLEANUP + + // manually restore the stencil state + glStencilFunc(_currentStencilFunc, _currentStencilRef, _currentStencilValueMask); + glStencilOp(_currentStencilFail, _currentStencilPassDepthFail, _currentStencilPassDepthPass); + glStencilMask(_currentStencilWriteMask); + if (!_currentStencilEnabled) + { + glDisable(GL_STENCIL_TEST); + } + + // we are done using this layer, decrement + layer--; +} + NS_CC_END diff --git a/cocos/2d/CCClippingNode.h b/cocos/2d/CCClippingNode.h index 221c1fb4c7..bb247e0961 100644 --- a/cocos/2d/CCClippingNode.h +++ b/cocos/2d/CCClippingNode.h @@ -120,6 +120,27 @@ protected: Node* _stencil; GLfloat _alphaThreshold; bool _inverted; +protected: + //renderData and callback + void beforeVisit(); + void afterDrawStencil(); + void afterVisit(); + + GLboolean _currentStencilEnabled; + GLuint _currentStencilWriteMask; + GLenum _currentStencilFunc; + GLint _currentStencilRef; + GLuint _currentStencilValueMask; + GLenum _currentStencilFail; + GLenum _currentStencilPassDepthFail; + GLenum _currentStencilPassDepthPass; + GLboolean _currentDepthWriteMask; + + GLboolean _currentAlphaTestEnabled; + GLenum _currentAlphaTestFunc; + GLclampf _currentAlphaTestRef; + + GLint _mask_layer_le; private: CC_DISALLOW_COPY_AND_ASSIGN(ClippingNode); diff --git a/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp b/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp index d0e68e3c3a..7044ade0ed 100644 --- a/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp +++ b/samples/Cpp/TestCpp/Classes/NewRendererTest/NewRendererTest.cpp @@ -295,7 +295,7 @@ NewClippingNodeTest::NewClippingNodeTest() { auto s = Director::getInstance()->getWinSize(); - auto clipper = NewClippingNode::create(); + auto clipper = ClippingNode::create(); clipper->setTag( kTagClipperNode ); clipper->setContentSize( Size(200, 200) ); clipper->setAnchorPoint( Point(0.5, 0.5) ); From 9db599c0c9fe87107c3a79e8d7047f64cc961b7e Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 24 Dec 2013 14:10:54 +0800 Subject: [PATCH 58/70] remove class NewClippingNode --- cocos/2d/renderer/CCNewClippingNode.cpp | 301 ------------------------ cocos/2d/renderer/CCNewClippingNode.h | 70 ------ 2 files changed, 371 deletions(-) delete mode 100644 cocos/2d/renderer/CCNewClippingNode.cpp delete mode 100644 cocos/2d/renderer/CCNewClippingNode.h diff --git a/cocos/2d/renderer/CCNewClippingNode.cpp b/cocos/2d/renderer/CCNewClippingNode.cpp deleted file mode 100644 index 399636212d..0000000000 --- a/cocos/2d/renderer/CCNewClippingNode.cpp +++ /dev/null @@ -1,301 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCNewClippingNode.h" -#include "CCGroupCommand.h" -#include "CCRenderer.h" -#include "CCCustomCommand.h" -#include "CCShaderCache.h" -#include "CCDirector.h" - -NS_CC_BEGIN - -// store the current stencil layer (position in the stencil buffer), -// this will allow nesting up to n ClippingNode, -// where n is the number of bits of the stencil buffer. -static GLint layer = -1; - -static void setProgram(Node *n, GLProgram *p) -{ - n->setShaderProgram(p); - - for(const auto &child : n->getChildren()) - setProgram(child, p); -} - -NewClippingNode *NewClippingNode::create() -{ - NewClippingNode* pRet = new NewClippingNode(); - if(pRet && pRet->init()) - { - pRet->autorelease(); - } - else - { - CC_SAFE_DELETE(pRet); - } - return pRet; -} - -NewClippingNode *NewClippingNode::create(Node *pStencil) -{ - NewClippingNode* pRet = new NewClippingNode(); - if(pRet && pRet->init(pStencil)) - { - pRet->autorelease(); - } - else - { - CC_SAFE_DELETE(pRet); - } - return pRet; -} - -NewClippingNode::~NewClippingNode() -{ - -} - -NewClippingNode::NewClippingNode() -:ClippingNode() -{ - currentStencilEnabled = GL_FALSE; - currentStencilWriteMask = ~0; - currentStencilFunc = GL_ALWAYS; - currentStencilRef = 0; - currentStencilValueMask = ~0; - currentStencilFail = GL_KEEP; - currentStencilPassDepthFail = GL_KEEP; - currentStencilPassDepthPass = GL_KEEP; - currentDepthWriteMask = GL_TRUE; - - currentAlphaTestEnabled = GL_FALSE; - currentAlphaTestFunc = GL_ALWAYS; - currentAlphaTestRef = 1; -} - -void NewClippingNode::visit() -{ - //Add group command - - Renderer* renderer = Director::getInstance()->getRenderer(); - - GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand(); - groupCommand->init(0,_vertexZ); - renderer->addCommand(groupCommand); - - renderer->pushGroup(groupCommand->getRenderQueueID()); - - CustomCommand* beforeVisitCmd = CustomCommand::getCommandPool().generateCommand(); - beforeVisitCmd->init(0,_vertexZ); - beforeVisitCmd->func = CC_CALLBACK_0(NewClippingNode::beforeVisit, this); - renderer->addCommand(beforeVisitCmd); - - _stencil->visit(); - - CustomCommand* afterDrawStencilCmd = CustomCommand::getCommandPool().generateCommand(); - afterDrawStencilCmd->init(0,_vertexZ); - afterDrawStencilCmd->func = CC_CALLBACK_0(NewClippingNode::afterDrawStencil, this); - renderer->addCommand(afterDrawStencilCmd); - - Node::visit(); - - CustomCommand* afterVisitCmd = CustomCommand::getCommandPool().generateCommand(); - afterVisitCmd->init(0,_vertexZ); - afterVisitCmd->func = CC_CALLBACK_0(NewClippingNode::afterVisit, this); - renderer->addCommand(afterVisitCmd); - - renderer->popGroup(); -} - -void NewClippingNode::beforeVisit() -{ - /////////////////////////////////// - // INIT - - // increment the current layer - layer++; - - // mask of the current layer (ie: for layer 3: 00000100) - GLint mask_layer = 0x1 << layer; - // mask of all layers less than the current (ie: for layer 3: 00000011) - GLint mask_layer_l = mask_layer - 1; - // mask of all layers less than or equal to the current (ie: for layer 3: 00000111) - mask_layer_le = mask_layer | mask_layer_l; - - // manually save the stencil state - - currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST); - glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)¤tStencilWriteMask); - glGetIntegerv(GL_STENCIL_FUNC, (GLint *)¤tStencilFunc); - glGetIntegerv(GL_STENCIL_REF, ¤tStencilRef); - glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)¤tStencilValueMask); - glGetIntegerv(GL_STENCIL_FAIL, (GLint *)¤tStencilFail); - glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)¤tStencilPassDepthFail); - glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)¤tStencilPassDepthPass); - - // enable stencil use - glEnable(GL_STENCIL_TEST); - // check for OpenGL error while enabling stencil test - CHECK_GL_ERROR_DEBUG(); - - // all bits on the stencil buffer are readonly, except the current layer bit, - // this means that operation like glClear or glStencilOp will be masked with this value - glStencilMask(mask_layer); - - // manually save the depth test state - - //currentDepthTestEnabled = glIsEnabled(GL_DEPTH_TEST); - glGetBooleanv(GL_DEPTH_WRITEMASK, ¤tDepthWriteMask); - - // disable depth test while drawing the stencil - //glDisable(GL_DEPTH_TEST); - // disable update to the depth buffer while drawing the stencil, - // as the stencil is not meant to be rendered in the real scene, - // it should never prevent something else to be drawn, - // only disabling depth buffer update should do - glDepthMask(GL_FALSE); - - /////////////////////////////////// - // CLEAR STENCIL BUFFER - - // manually clear the stencil buffer by drawing a fullscreen rectangle on it - // setup the stencil test func like this: - // for each pixel in the fullscreen rectangle - // never draw it into the frame buffer - // if not in inverted mode: set the current layer value to 0 in the stencil buffer - // if in inverted mode: set the current layer value to 1 in the stencil buffer - glStencilFunc(GL_NEVER, mask_layer, mask_layer); - glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP); - - // draw a fullscreen solid rectangle to clear the stencil buffer - //ccDrawSolidRect(Point::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1)); - drawFullScreenQuadClearStencil(); - - /////////////////////////////////// - // DRAW CLIPPING STENCIL - - // setup the stencil test func like this: - // for each pixel in the stencil node - // never draw it into the frame buffer - // if not in inverted mode: set the current layer value to 1 in the stencil buffer - // if in inverted mode: set the current layer value to 0 in the stencil buffer - glStencilFunc(GL_NEVER, mask_layer, mask_layer); - glStencilOp(!_inverted ? GL_REPLACE : GL_ZERO, GL_KEEP, GL_KEEP); - - // enable alpha test only if the alpha threshold < 1, - // indeed if alpha threshold == 1, every pixel will be drawn anyways -#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) -// GLboolean currentAlphaTestEnabled = GL_FALSE; -// GLenum currentAlphaTestFunc = GL_ALWAYS; -// GLclampf currentAlphaTestRef = 1; -#endif - if (_alphaThreshold < 1) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) - // manually save the alpha test state - currentAlphaTestEnabled = glIsEnabled(GL_ALPHA_TEST); - glGetIntegerv(GL_ALPHA_TEST_FUNC, (GLint *)¤tAlphaTestFunc); - glGetFloatv(GL_ALPHA_TEST_REF, ¤tAlphaTestRef); - // enable alpha testing - glEnable(GL_ALPHA_TEST); - // check for OpenGL error while enabling alpha test - CHECK_GL_ERROR_DEBUG(); - // pixel will be drawn only if greater than an alpha threshold - glAlphaFunc(GL_GREATER, _alphaThreshold); -#else - // since glAlphaTest do not exists in OES, use a shader that writes - // pixel only if greater than an alpha threshold - GLProgram *program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); - GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); - // set our alphaThreshold - program->use(); - program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); - // we need to recursively apply this shader to all the nodes in the stencil node - // XXX: we should have a way to apply shader to all nodes without having to do this - setProgram(_stencil, program); - -#endif - } - - //Draw _stencil -} - -void NewClippingNode::afterDrawStencil() -{ - // restore alpha test state - if (_alphaThreshold < 1) - { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) - // manually restore the alpha test state - glAlphaFunc(currentAlphaTestFunc, currentAlphaTestRef); - if (!currentAlphaTestEnabled) - { - glDisable(GL_ALPHA_TEST); - } -#else -// XXX: we need to find a way to restore the shaders of the stencil node and its childs -#endif - } - - // restore the depth test state - glDepthMask(currentDepthWriteMask); - //if (currentDepthTestEnabled) { - // glEnable(GL_DEPTH_TEST); - //} - - /////////////////////////////////// - // DRAW CONTENT - - // setup the stencil test func like this: - // for each pixel of this node and its childs - // if all layers less than or equals to the current are set to 1 in the stencil buffer - // draw the pixel and keep the current layer in the stencil buffer - // else - // do not draw the pixel but keep the current layer in the stencil buffer - glStencilFunc(GL_EQUAL, mask_layer_le, mask_layer_le); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - - // draw (according to the stencil test func) this node and its childs -} - - -void NewClippingNode::afterVisit() -{ - /////////////////////////////////// - // CLEANUP - - // manually restore the stencil state - glStencilFunc(currentStencilFunc, currentStencilRef, currentStencilValueMask); - glStencilOp(currentStencilFail, currentStencilPassDepthFail, currentStencilPassDepthPass); - glStencilMask(currentStencilWriteMask); - if (!currentStencilEnabled) - { - glDisable(GL_STENCIL_TEST); - } - - // we are done using this layer, decrement - layer--; -} - -NS_CC_END diff --git a/cocos/2d/renderer/CCNewClippingNode.h b/cocos/2d/renderer/CCNewClippingNode.h deleted file mode 100644 index 80136f5832..0000000000 --- a/cocos/2d/renderer/CCNewClippingNode.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __NewClippingNode_H_ -#define __NewClippingNode_H_ - -#include "CCPlatformMacros.h" -#include "CCClippingNode.h" - - -NS_CC_BEGIN - -class NewClippingNode : public ClippingNode -{ -public: - static NewClippingNode* create(); - static NewClippingNode* create(Node* pStencil); - - virtual ~NewClippingNode(); - - virtual void visit() override; - -protected: - NewClippingNode(); - - void beforeVisit(); - void afterDrawStencil(); - void afterVisit(); - - GLboolean currentStencilEnabled; - GLuint currentStencilWriteMask; - GLenum currentStencilFunc; - GLint currentStencilRef; - GLuint currentStencilValueMask; - GLenum currentStencilFail; - GLenum currentStencilPassDepthFail; - GLenum currentStencilPassDepthPass; - GLboolean currentDepthWriteMask; - - GLboolean currentAlphaTestEnabled; - GLenum currentAlphaTestFunc; - GLclampf currentAlphaTestRef; - - GLint mask_layer_le; -}; - -NS_CC_END - -#endif //__NewClippingNode_H_ From eee06ec905dc9f105fd280f7955ba673c67d7705 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 24 Dec 2013 14:12:15 +0800 Subject: [PATCH 59/70] update project file:android and linux --- cocos/2d/Android.mk | 1 - cocos/2d/CMakeLists.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/cocos/2d/Android.mk b/cocos/2d/Android.mk index 40966dcef7..303a1da40f 100644 --- a/cocos/2d/Android.mk +++ b/cocos/2d/Android.mk @@ -121,7 +121,6 @@ renderer/CCCustomCommand.cpp \ renderer/CCFrustum.cpp \ renderer/CCGroupCommand.cpp \ renderer/CCMaterialManager.cpp \ -renderer/CCNewClippingNode.cpp \ renderer/CCQuadCommand.cpp \ renderer/CCRenderCommand.cpp \ renderer/CCRenderer.cpp \ diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index 7379a07352..429647ca8a 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -143,7 +143,6 @@ set(COCOS2D_SRC renderer/CCFrustum.cpp renderer/CCGroupCommand.cpp renderer/CCMaterialManager.cpp - renderer/CCNewClippingNode.cpp renderer/CCQuadCommand.cpp renderer/CCRenderCommand.cpp renderer/CCRenderer.cpp From c36d920159c5ea7eb8ff68223e7bac2ad7c3956f Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 24 Dec 2013 14:15:23 +0800 Subject: [PATCH 60/70] remove include reference --- cocos/2d/cocos2d.h | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos/2d/cocos2d.h b/cocos/2d/cocos2d.h index e8fb3bd0c6..1dfdcba511 100644 --- a/cocos/2d/cocos2d.h +++ b/cocos/2d/cocos2d.h @@ -123,7 +123,6 @@ THE SOFTWARE. #include "renderer/CCFrustum.h" #include "renderer/CCGroupCommand.h" #include "renderer/CCMaterialManager.h" -#include "renderer/CCNewClippingNode.h" #include "renderer/CCQuadCommand.h" #include "renderer/CCRenderCommand.h" #include "renderer/CCRenderCommandPool.h" From 67c34803203e343c6abd88351d69071ce8868b4c Mon Sep 17 00:00:00 2001 From: yinkaile Date: Tue, 24 Dec 2013 14:21:25 +0800 Subject: [PATCH 61/70] change std::string.compare() to == --- .../cocostudio/CCDataReaderHelper.cpp | 20 +++++++++---------- .../CocoStudioArmatureTest/ArmatureScene.cpp | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index 3219b0b668..d5bbec47d5 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -261,7 +261,7 @@ void DataReaderHelper::addDataFromFile(const std::string& filePath) */ for(unsigned int i = 0; i < _configFileList.size(); i++) { - if (_configFileList[i].compare(filePath) == 0) + if (_configFileList[i] == filePath) { return; } @@ -299,11 +299,11 @@ void DataReaderHelper::addDataFromFile(const std::string& filePath) dataInfo.asyncStruct = nullptr; dataInfo.baseFilePath = basefilePath; - if (str.compare(".xml") == 0) + if (str == ".xml") { DataReaderHelper::addDataFromCache(contentStr, &dataInfo); } - else if(str.compare(".json") == 0 || str.compare(".ExportJson") == 0) + else if(str == ".json" || str == ".ExportJson") { DataReaderHelper::addDataFromJsonCache(contentStr, &dataInfo); } @@ -318,7 +318,7 @@ void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const */ for(unsigned int i = 0; i < _configFileList.size(); i++) { - if (_configFileList[i].compare(filePath) == 0) + if (_configFileList[i] == filePath) { if (target && selector) { @@ -396,11 +396,11 @@ void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const // XXX fileContent is being leaked data->fileContent = (char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size); - if (str.compare(".xml") == 0) + if (str == ".xml") { data->configType = DragonBone_XML; } - else if(str.compare(".json") == 0 || str.compare(".ExportJson") == 0) + else if(str == ".json" || str == ".ExportJson") { data->configType = CocoStudio_JSON; } @@ -596,7 +596,7 @@ ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML std::string parentNameStr = parentName; while (parentXML) { - if (parentNameStr.compare(parentXML->Attribute(A_NAME)) == 0) + if (parentNameStr == parentXML->Attribute(A_NAME)) { break; } @@ -741,7 +741,7 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML if(_easing != nullptr) { std::string str = _easing; - if(str.compare(FL_NAN) != 0) + if(str != FL_NAN) { if( movementXML->QueryIntAttribute(A_TWEEN_EASING, &(tweenEasing)) == tinyxml2::XML_SUCCESS) { @@ -778,7 +778,7 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML while (parentXml) { - if (parentName.compare(parentXml->Attribute(A_NAME)) == 0) + if (parentName == parentXml->Attribute(A_NAME)) { break; } @@ -1070,7 +1070,7 @@ FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxm if(_easing != nullptr) { std::string str = _easing; - if(str.compare(FL_NAN) != 0) + if(str != FL_NAN) { if( frameXML->QueryIntAttribute(A_TWEEN_EASING, &(tweenEasing)) == tinyxml2::XML_SUCCESS) { diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index a50301297b..a1f1fdf11f 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -539,14 +539,14 @@ void TestAnimationEvent::animationEvent(Armature *armature, MovementEventType mo { if (movementType == LOOP_COMPLETE) { - if (movementID.compare("Fire") == 0) + if (movementID == "Fire") { ActionInterval *actionToRight = MoveTo::create(2, Point(VisibleRect::right().x - 50, VisibleRect::right().y)); armature->stopAllActions(); armature->runAction(Sequence::create(actionToRight, CallFunc::create( CC_CALLBACK_0(TestAnimationEvent::callback1, this)), nullptr)); armature->getAnimation()->play("Walk"); } - else if (movementID.compare("FireMax") == 0) + else if (movementID == "FireMax") { ActionInterval *actionToLeft = MoveTo::create(2, Point(VisibleRect::left().x + 50, VisibleRect::left().y)); armature->stopAllActions(); From f573f1092c4a60a6c5964e2f5cacf94bf70baa27 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 24 Dec 2013 14:27:25 +0800 Subject: [PATCH 62/70] Update CHANGELOG [ci skip] --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 7987aef21d..dfe36417f8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ cocos2d-x-3.0beta0 ?? 2013 [NEW] New renderer support. [FIX] Potential hash collision fix. [FIX] Updates spine runtime to the latest version. + [FIX] Uses `const std::string&` instead of `const char*`. [Android] [NEW] build/android-build.sh: add supporting to generate .apk file [FIX] XMLHttpRequest receives wrong binary array. @@ -21,6 +22,7 @@ cocos2d-x-3.0beta0 ?? 2013 [NEW] CMake support for windows. [Bindings] [FIX] Don't bind override functions for JSB and LuaBining since they aren't needed at all. + [NEW] Adds spine JS binding support. cocos2d-x-3.0alpha1 Nov.19 2013 [all platforms] From 4775b4c4d897aca36600137f294c0c0f5381dcc3 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 24 Dec 2013 06:33:43 +0000 Subject: [PATCH 63/70] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 4196652f09..c1db53c377 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 4196652f09cd156d2432fb368150ae6ea2298922 +Subproject commit c1db53c377bf7c648e6ec74c875293faf7cb7b3f From 07bc4d34a8c16b5dab0bc85304b9a6ac6e55b5a9 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 24 Dec 2013 14:53:49 +0800 Subject: [PATCH 64/70] some rename for global variables and member functions. --- cocos/2d/CCClippingNode.cpp | 20 ++++++++++---------- cocos/2d/CCClippingNode.h | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index ebd3be5e24..9015c94b8d 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -41,7 +41,7 @@ static GLint g_sStencilBits = -1; // store the current stencil layer (position in the stencil buffer), // this will allow nesting up to n ClippingNode, // where n is the number of bits of the stencil buffer. -static GLint layer = -1; +static GLint s_layer = -1; static void setProgram(Node *n, GLProgram *p) { @@ -212,21 +212,21 @@ void ClippingNode::visit() CustomCommand* beforeVisitCmd = CustomCommand::getCommandPool().generateCommand(); beforeVisitCmd->init(0,_vertexZ); - beforeVisitCmd->func = CC_CALLBACK_0(ClippingNode::beforeVisit, this); + beforeVisitCmd->func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this); renderer->addCommand(beforeVisitCmd); _stencil->visit(); CustomCommand* afterDrawStencilCmd = CustomCommand::getCommandPool().generateCommand(); afterDrawStencilCmd->init(0,_vertexZ); - afterDrawStencilCmd->func = CC_CALLBACK_0(ClippingNode::afterDrawStencil, this); + afterDrawStencilCmd->func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this); renderer->addCommand(afterDrawStencilCmd); Node::visit(); CustomCommand* afterVisitCmd = CustomCommand::getCommandPool().generateCommand(); afterVisitCmd->init(0,_vertexZ); - afterVisitCmd->func = CC_CALLBACK_0(ClippingNode::afterVisit, this); + afterVisitCmd->func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this); renderer->addCommand(afterVisitCmd); renderer->popGroup(); @@ -264,16 +264,16 @@ void ClippingNode::setInverted(bool inverted) _inverted = inverted; } -void ClippingNode::beforeVisit() +void ClippingNode::onBeforeVisit() { /////////////////////////////////// // INIT // increment the current layer - layer++; + s_layer++; // mask of the current layer (ie: for layer 3: 00000100) - GLint mask_layer = 0x1 << layer; + GLint mask_layer = 0x1 << s_layer; // mask of all layers less than the current (ie: for layer 3: 00000011) GLint mask_layer_l = mask_layer - 1; // mask of all layers less than or equal to the current (ie: for layer 3: 00000111) @@ -376,7 +376,7 @@ void ClippingNode::beforeVisit() //Draw _stencil } -void ClippingNode::afterDrawStencil() +void ClippingNode::onAfterDrawStencil() { // restore alpha test state if (_alphaThreshold < 1) @@ -415,7 +415,7 @@ void ClippingNode::afterDrawStencil() } -void ClippingNode::afterVisit() +void ClippingNode::onAfterVisit() { /////////////////////////////////// // CLEANUP @@ -430,7 +430,7 @@ void ClippingNode::afterVisit() } // we are done using this layer, decrement - layer--; + s_layer--; } NS_CC_END diff --git a/cocos/2d/CCClippingNode.h b/cocos/2d/CCClippingNode.h index bb247e0961..656eb8ede9 100644 --- a/cocos/2d/CCClippingNode.h +++ b/cocos/2d/CCClippingNode.h @@ -122,9 +122,9 @@ protected: bool _inverted; protected: //renderData and callback - void beforeVisit(); - void afterDrawStencil(); - void afterVisit(); + void onBeforeVisit(); + void onAfterDrawStencil(); + void onAfterVisit(); GLboolean _currentStencilEnabled; GLuint _currentStencilWriteMask; From ccf47e64227816add0892ffe8bdcb6c2224b7909 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 24 Dec 2013 15:11:01 +0800 Subject: [PATCH 65/70] remove commented codes --- cocos/2d/CCClippingNode.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index 9015c94b8d..a7cd418c20 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -301,7 +301,6 @@ void ClippingNode::onBeforeVisit() // manually save the depth test state - //currentDepthTestEnabled = glIsEnabled(GL_DEPTH_TEST); glGetBooleanv(GL_DEPTH_WRITEMASK, &_currentDepthWriteMask); // disable depth test while drawing the stencil @@ -342,9 +341,6 @@ void ClippingNode::onBeforeVisit() // enable alpha test only if the alpha threshold < 1, // indeed if alpha threshold == 1, every pixel will be drawn anyways #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) -// GLboolean currentAlphaTestEnabled = GL_FALSE; -// GLenum currentAlphaTestFunc = GL_ALWAYS; -// GLclampf currentAlphaTestRef = 1; #endif if (_alphaThreshold < 1) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) From 5cc45493efef2b3b0dba4181ceea7586506f3d3a Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 24 Dec 2013 15:13:37 +0800 Subject: [PATCH 66/70] remove commented codes --- cocos/2d/CCClippingNode.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index a7cd418c20..e69b34273d 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -340,8 +340,6 @@ void ClippingNode::onBeforeVisit() // enable alpha test only if the alpha threshold < 1, // indeed if alpha threshold == 1, every pixel will be drawn anyways -#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) -#endif if (_alphaThreshold < 1) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) // manually save the alpha test state From 3875d89ce648bf2123150de87e61ffb06a1d921a Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 24 Dec 2013 07:31:29 +0000 Subject: [PATCH 67/70] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index c1db53c377..daff147b1f 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit c1db53c377bf7c648e6ec74c875293faf7cb7b3f +Subproject commit daff147b1ff3d3754cb014c4e9c575676dea68b9 From f140ece28244e409442196b648fa83f4fffec890 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Tue, 24 Dec 2013 15:34:40 +0800 Subject: [PATCH 68/70] update vs project for remove some file into renderer. --- cocos/2d/cocos2d.vcxproj | 10 ---------- cocos/2d/cocos2d.vcxproj.filters | 30 ------------------------------ 2 files changed, 40 deletions(-) diff --git a/cocos/2d/cocos2d.vcxproj b/cocos/2d/cocos2d.vcxproj index fd68ca2dd9..02b11faac0 100644 --- a/cocos/2d/cocos2d.vcxproj +++ b/cocos/2d/cocos2d.vcxproj @@ -321,11 +321,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou - - - - - @@ -530,11 +525,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou - - - - - diff --git a/cocos/2d/cocos2d.vcxproj.filters b/cocos/2d/cocos2d.vcxproj.filters index eb2c4938c0..b57af69e45 100644 --- a/cocos/2d/cocos2d.vcxproj.filters +++ b/cocos/2d/cocos2d.vcxproj.filters @@ -586,21 +586,6 @@ renderer - - renderer - - - renderer - - - renderer - - - renderer - - - renderer - renderer @@ -1207,21 +1192,6 @@ renderer - - renderer - - - renderer - - - renderer - - - renderer - - - renderer - renderer From 7ee07711016783adad13a49b057ac791c6675721 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 24 Dec 2013 15:55:45 +0800 Subject: [PATCH 69/70] closed #3492: LabelBMFont string can't be shown integrally. Issue URL: http://www.cocos2d-x.org/issues/3492 --- cocos/2d/CCLabelBMFont.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/cocos/2d/CCLabelBMFont.cpp b/cocos/2d/CCLabelBMFont.cpp index 1866d022f9..f265f3e615 100644 --- a/cocos/2d/CCLabelBMFont.cpp +++ b/cocos/2d/CCLabelBMFont.cpp @@ -817,9 +817,6 @@ void LabelBMFont::updateLabel() } skip += justSkipped; - - if (!characterSprite->isVisible()) - continue; if (i >= stringLength) break; From 91ef6ea1e53a80faa7718d5590f9285426ec320d Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 24 Dec 2013 15:57:39 +0800 Subject: [PATCH 70/70] Update CHANGELOG [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index dfe36417f8..e6b5f0a0a6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ cocos2d-x-3.0beta0 ?? 2013 [FIX] Potential hash collision fix. [FIX] Updates spine runtime to the latest version. [FIX] Uses `const std::string&` instead of `const char*`. + [FIX] LabelBMFont string can't be shown integrally. [Android] [NEW] build/android-build.sh: add supporting to generate .apk file [FIX] XMLHttpRequest receives wrong binary array.