From 32b4f63d45893372c9904f99098c9436cc07b7c9 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 15 Aug 2016 01:11:32 +0800 Subject: [PATCH 01/14] Fix Creator module memory not controlled by cpp --- native/tools/tojs/creator.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/tools/tojs/creator.ini b/native/tools/tojs/creator.ini index d57a7a029e..97674c8da2 100755 --- a/native/tools/tojs/creator.ini +++ b/native/tools/tojs/creator.ini @@ -63,4 +63,4 @@ base_classes_to_skip = Ref abstract_classes = Helper LayoutManager AbstractCheckButton # 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 = yes +script_control_cpp = no From 2a903b9ce2192962654948035d4045b545585d41 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 15 Aug 2016 01:17:57 +0800 Subject: [PATCH 02/14] Gen autobindings for v1.2 branch --- native/.travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/.travis.yml b/native/.travis.yml index 2cde41c24c..8bb07b54d1 100644 --- a/native/.travis.yml +++ b/native/.travis.yml @@ -8,7 +8,7 @@ before_install: - tools/travis-scripts/before-install.sh branches: only: - - develop + - v1.2 env: global: - secure: bUrk522Qw5Mc3SfDXHZtJ/aF9QbLXYDnUVSOJXt1wUB1d8xAQphTcZ1ARNYu7I5m3ZXqRfzTS4POOT58qeS3sYPpJ8urWW18hgX3I/dmsL1WJXmwnOV+0J3xLt6AT3ttqj7/emaf0xxuBvZ0szyRz0rU4wprtWftWMFiUrsF8G1an2Qa/g/f5LhilnDiKAqFdHMkn0ogaggL0PbgliHeHo7SEOfSF2gQaSIBta7jzE/BEZZ3R4AuReB3oNDwxr+1E4BpPaGO1lMLzdr8MAjWBGVLBRlpVDihgFTTmdka8UYasjEWDs6GbSjJRsTZQkluOo+1UylSiLn5o1tnWMqINo5DDaayBSKWRV/x+Sx+KMG221BwHLGFHrhEm8Jwc3g5IBiFrc9Xn/PAoCL3Zi/m0m8Y/TVIlA2nWuU0jeMZYXOb0ALCplAQMrG/Yt7euzgSjZ9iPvO7HO8BkaRkUxafcp6svWyMedNeDczG6liLSquJak+XIbOpWCOW+KVxc2S2Unz37MSOQR/aB9dJ8fKI/4e3LCdYrSKW9MSKAz9BSYA2IK2F8Fgr6zY3IPTANQCi6o8i/N54wsmpY17uvzqNDGuag5m/FkNpFWVQUy/TdONanXV6m1jvREaxtDHucSnP3olmvx6pi1awRspDfRmcILK08yvul+yLol0nQwenlx0= From 9da0205b308c21b6d25121f6dae2be20fc54c17f Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Sun, 14 Aug 2016 17:25:41 +0000 Subject: [PATCH 03/14] [ci skip][AUTO]: updating jsbinding automatically --- .../js-bindings/auto/jsb_creator_auto.cpp | 52 ++++++++----------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_creator_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_creator_auto.cpp index 4f75509b9f..5f7b3bad27 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_creator_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_creator_auto.cpp @@ -8,6 +8,8 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedValue initializing(cx); bool isNewValid = true; + JS::RootedObject global(cx, ScriptingCore::getInstance()->getGlobalObject()); + isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && initializing.toBoolean(); if (isNewValid) { TypeTest t; @@ -22,13 +24,11 @@ static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::RootedObject parent(cx, typeClass->parentProto.ref()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); - T* cobj = new T(); - js_proxy_t *pp = jsb_new_proxy(cobj, _tmp); - AddObjectRoot(cx, &pp->obj); args.rval().set(OBJECT_TO_JSVAL(_tmp)); return true; } + JS_ReportError(cx, "Constructor for the requested class is not available, please refer to the API reference."); return false; } @@ -784,6 +784,10 @@ bool js_creator_Scale9SpriteV2_constructor(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; creator::Scale9SpriteV2* cobj = new (std::nothrow) creator::Scale9SpriteV2(); + cocos2d::Ref *_ccobj = dynamic_cast(cobj); + if (_ccobj) { + _ccobj->autorelease(); + } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); @@ -796,7 +800,8 @@ bool js_creator_Scale9SpriteV2_constructor(JSContext *cx, uint32_t argc, jsval * JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object - jsb_new_proxy(cobj, obj); + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "creator::Scale9SpriteV2"); if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; @@ -805,7 +810,11 @@ bool js_creator_Scale9SpriteV2_constructor(JSContext *cx, uint32_t argc, jsval * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); creator::Scale9SpriteV2 *nobj = new (std::nothrow) creator::Scale9SpriteV2(); + if (nobj) { + nobj->autorelease(); + } js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "creator::Scale9SpriteV2"); bool isFound = false; if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); @@ -817,18 +826,6 @@ extern JSObject *jsb_cocos2d_Node_prototype; void js_creator_Scale9SpriteV2_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Scale9SpriteV2)", obj); - JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - JS::RootedObject jsobj(cx, obj); - auto proxy = jsb_get_js_proxy(jsobj); - if (proxy) { - creator::Scale9SpriteV2 *nobj = static_cast(proxy->ptr); - - if (nobj) { - jsb_remove_proxy(proxy); - nobj->release(); - } - else jsb_remove_proxy(proxy); - } } void js_register_creator_Scale9SpriteV2(JSContext *cx, JS::HandleObject global) { @@ -1595,6 +1592,10 @@ bool js_creator_GraphicsNode_constructor(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; creator::GraphicsNode* cobj = new (std::nothrow) creator::GraphicsNode(); + cocos2d::Ref *_ccobj = dynamic_cast(cobj); + if (_ccobj) { + _ccobj->autorelease(); + } TypeTest t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); @@ -1607,7 +1608,8 @@ bool js_creator_GraphicsNode_constructor(JSContext *cx, uint32_t argc, jsval *vp JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object - jsb_new_proxy(cobj, obj); + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "creator::GraphicsNode"); if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); return true; @@ -1616,7 +1618,11 @@ bool js_creator_GraphicsNode_constructor(JSContext *cx, uint32_t argc, jsval *vp JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); creator::GraphicsNode *nobj = new (std::nothrow) creator::GraphicsNode(); + if (nobj) { + nobj->autorelease(); + } js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "creator::GraphicsNode"); bool isFound = false; if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); @@ -1628,18 +1634,6 @@ extern JSObject *jsb_cocos2d_Node_prototype; void js_creator_GraphicsNode_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (GraphicsNode)", obj); - JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - JS::RootedObject jsobj(cx, obj); - auto proxy = jsb_get_js_proxy(jsobj); - if (proxy) { - creator::GraphicsNode *nobj = static_cast(proxy->ptr); - - if (nobj) { - jsb_remove_proxy(proxy); - nobj->release(); - } - else jsb_remove_proxy(proxy); - } } void js_register_creator_GraphicsNode(JSContext *cx, JS::HandleObject global) { From b7c07b6b6c0b78ab1bbfa8cb4888e91ce612b41e Mon Sep 17 00:00:00 2001 From: 2youyouo2 <501251991@qq.com> Date: Mon, 15 Aug 2016 12:01:57 +0800 Subject: [PATCH 04/14] fixed graphics arc --- native/cocos/editor-support/creator/CCGraphicsNode.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/native/cocos/editor-support/creator/CCGraphicsNode.cpp b/native/cocos/editor-support/creator/CCGraphicsNode.cpp index 3647390519..c6606ed4eb 100644 --- a/native/cocos/editor-support/creator/CCGraphicsNode.cpp +++ b/native/cocos/editor-support/creator/CCGraphicsNode.cpp @@ -214,7 +214,7 @@ void GraphicsNode::arc(float cx, float cy, float r, float startAngle, float endA // Clamp angles da = endAngle - startAngle; - if (!counterclockwise) { + if (counterclockwise) { if (absf(da) >= PI_2) { da = PI_2; } else { @@ -233,7 +233,7 @@ void GraphicsNode::arc(float cx, float cy, float r, float startAngle, float endA hda = (da / (float)ndivs) / 2.0f; kappa = absf(4.0f / 3.0f * (1.0f - cosf(hda)) / sinf(hda)); - if (counterclockwise) { + if (!counterclockwise) { kappa = -kappa; } From 15515c3d2de4a8398a1ce5ec57349735a2f96de8 Mon Sep 17 00:00:00 2001 From: "yanli.huang" Date: Tue, 16 Aug 2016 11:48:52 +0800 Subject: [PATCH 05/14] =?UTF-8?q?update=20cocos2d-console=20commit?= =?UTF-8?q?=EF=BC=9A=20add=20--env=20param=20to=20cocos=20package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- native/tools/cocos2d-console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/tools/cocos2d-console b/native/tools/cocos2d-console index 7164d48421..fdad71adcf 160000 --- a/native/tools/cocos2d-console +++ b/native/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 7164d484212b95578e9827cae595cb2590d648a7 +Subproject commit fdad71adcf580741398d3ef93ac2f835023ef06c From 062169358d322dc53653dba290864cb41ceaa318 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 15 Aug 2016 19:55:13 +0800 Subject: [PATCH 06/14] add currentTime and duration in iOS --- native/cocos/ui/UIVideoPlayer-ios.mm | 28 ++++++++++++++++++++++++++++ native/cocos/ui/UIVideoPlayer.h | 7 +++++++ 2 files changed, 35 insertions(+) diff --git a/native/cocos/ui/UIVideoPlayer-ios.mm b/native/cocos/ui/UIVideoPlayer-ios.mm index 01417589f8..fb3dd9e931 100644 --- a/native/cocos/ui/UIVideoPlayer-ios.mm +++ b/native/cocos/ui/UIVideoPlayer-ios.mm @@ -45,6 +45,8 @@ using namespace cocos2d::experimental::ui; - (void) resume; - (void) stop; - (void) seekTo:(float) sec; +- (float) currentTime; +- (float) duration; - (void) setVisible:(BOOL) visible; - (void) setKeepRatioEnabled:(bool) enabled; - (void) setFullScreenEnabled:(bool) enabled; @@ -207,6 +209,22 @@ using namespace cocos2d::experimental::ui; } } +-(float) currentTime +{ + if (self.moviePlayer != NULL) { + return [self.moviePlayer currentPlaybackTime]; + } + return -1; +} + +-(float) duration +{ + if (self.moviePlayer != NULL) { + return [self.moviePlayer duration]; + } + return -1; +} + -(void) setVisible:(BOOL)visible { if (self.moviePlayer != NULL) { @@ -409,6 +427,16 @@ void VideoPlayer::seekTo(float sec) } } +float VideoPlayer::currentTime()const +{ + return [((UIVideoViewWrapperIos*)_videoView) currentTime]; +} + +float VideoPlayer::duration()const +{ + return [((UIVideoViewWrapperIos*)_videoView) duration]; +} + bool VideoPlayer::isPlaying() const { return _isPlaying; diff --git a/native/cocos/ui/UIVideoPlayer.h b/native/cocos/ui/UIVideoPlayer.h index 79ebddaa2e..9f672c0fab 100644 --- a/native/cocos/ui/UIVideoPlayer.h +++ b/native/cocos/ui/UIVideoPlayer.h @@ -122,6 +122,13 @@ namespace experimental{ */ virtual void seekTo(float sec); + /** + * Get the current play time, measure in seconds. + */ + float currentTime()const; + + float duration() const; + /** * Checks whether the VideoPlayer is playing. * From 860428af73c36fe1ebba2744ddd310026a321802 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Tue, 16 Aug 2016 12:01:23 +0800 Subject: [PATCH 07/14] add android support --- .../org/cocos2dx/lib/Cocos2dxVideoHelper.java | 66 ++++++++++++++++++- ...sb_cocos2dx_experimental_video_auto_api.js | 20 ++++++ .../jsb_cocos2dx_experimental_video_auto.cpp | 38 +++++++++++ .../jsb_cocos2dx_experimental_video_auto.hpp | 2 + native/cocos/ui/UIVideoPlayer-android.cpp | 10 +++ 5 files changed, 135 insertions(+), 1 deletion(-) diff --git a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoHelper.java b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoHelper.java index cacebbd246..fda28608c7 100644 --- a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoHelper.java +++ b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoHelper.java @@ -26,24 +26,34 @@ package org.cocos2dx.lib; import android.graphics.Rect; import android.os.Handler; +import android.os.Looper; import android.os.Message; +import android.util.Log; import android.util.SparseArray; import android.view.View; import android.widget.FrameLayout; +import android.widget.VideoView; import org.cocos2dx.lib.Cocos2dxVideoView.OnVideoEventListener; import java.lang.ref.WeakReference; +import java.util.concurrent.Callable; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.FutureTask; public class Cocos2dxVideoHelper { static VideoHandler sVideoHandler = null; - private SparseArray mVideoViews = null; + private static SparseArray mVideoViews = null; + private static Handler sHandler = null; + Cocos2dxVideoHelper() { sVideoHandler = new VideoHandler(this); mVideoViews = new SparseArray(); + sHandler = new Handler(Looper.myLooper()); } private static int videoTag = 0; @@ -60,6 +70,8 @@ public class Cocos2dxVideoHelper { private final static int VideoTaskRestart = 10; private final static int VideoTaskKeepRatio = 11; private final static int VideoTaskFullScreen = 12; + private final static int VideoTaskCurrentTime = 13; + private final static int VideoTaskDuration = 14; final static int KeyEventBack = 1000; static class VideoHandler extends Handler{ @@ -370,6 +382,58 @@ public class Cocos2dxVideoHelper { } } + + public static T callInMainThread(Callable call) throws ExecutionException, InterruptedException { + FutureTask task = new FutureTask(call); + sHandler.post(task); + return task.get(); + } + + public static float getCurrentTime(final int index) { + Callable callable = new Callable() { + @Override + public Float call() throws Exception { + Cocos2dxVideoView viedo = mVideoViews.get(index); + float currentPosition = -1; + if (viedo != null) { + currentPosition = viedo.getCurrentPosition() / 1000.0f; + } + return new Float(currentPosition); + } + }; + + try { + return callInMainThread(callable); + } catch (ExecutionException e) { + return -1; + } catch (InterruptedException e) { + return -1; + } + } + + public static float getDuration(final int index) { + Callable callable = new Callable() { + @Override + public Float call() throws Exception { + Cocos2dxVideoView viedo = mVideoViews.get(index); + float duration = -1; + if (viedo != null) { + duration = viedo.getDuration() / 1000.0f; + } + return new Float(duration); + } + }; + + try { + return callInMainThread(callable); + } catch (ExecutionException e) { + return -1; + } catch (InterruptedException e) { + return -1; + } + } + + public static void setVideoVisible(int index, boolean visible) { Message msg = Message.obtain(); msg.what = VideoTaskSetVisible; diff --git a/native/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_experimental_video_auto_api.js b/native/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_experimental_video_auto_api.js index 1751546076..670496d4b2 100644 --- a/native/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_experimental_video_auto_api.js +++ b/native/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_experimental_video_auto_api.js @@ -46,6 +46,16 @@ bool { }, +/** + * @method currentTime + * @return {float} + */ +currentTime : function ( +) +{ + return 0; +}, + /** * @method stop */ @@ -114,6 +124,16 @@ isFullScreenEnabled : function ( return false; }, +/** + * @method duration + * @return {float} + */ +duration : function ( +) +{ + return 0; +}, + /** * @method isPlaying * @return {bool} diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp index 9b93d5ebe9..d1d629b6ae 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp @@ -117,6 +117,24 @@ bool js_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled(JSCont JS_ReportError(cx, "js_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_experimental_video_VideoPlayer_currentTime(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_experimental_video_VideoPlayer_currentTime : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->currentTime(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_experimental_video_VideoPlayer_currentTime : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_experimental_video_VideoPlayer_stop(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -249,6 +267,24 @@ bool js_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled(JSContext *c JS_ReportError(cx, "js_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_experimental_video_VideoPlayer_duration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::experimental::ui::VideoPlayer* cobj = (cocos2d::experimental::ui::VideoPlayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_experimental_video_VideoPlayer_duration : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->duration(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_experimental_video_VideoPlayer_duration : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_experimental_video_VideoPlayer_isPlaying(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -363,6 +399,7 @@ void js_register_cocos2dx_experimental_video_VideoPlayer(JSContext *cx, JS::Hand JS_FN("getURL", js_cocos2dx_experimental_video_VideoPlayer_getURL, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("play", js_cocos2dx_experimental_video_VideoPlayer_play, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setKeepAspectRatioEnabled", js_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("currentTime", js_cocos2dx_experimental_video_VideoPlayer_currentTime, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stop", js_cocos2dx_experimental_video_VideoPlayer_stop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFullScreenEnabled", js_cocos2dx_experimental_video_VideoPlayer_setFullScreenEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFileName", js_cocos2dx_experimental_video_VideoPlayer_setFileName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -370,6 +407,7 @@ void js_register_cocos2dx_experimental_video_VideoPlayer(JSContext *cx, JS::Hand JS_FN("isKeepAspectRatioEnabled", js_cocos2dx_experimental_video_VideoPlayer_isKeepAspectRatioEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("onPlayEvent", js_cocos2dx_experimental_video_VideoPlayer_onPlayEvent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isFullScreenEnabled", js_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("duration", js_cocos2dx_experimental_video_VideoPlayer_duration, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isPlaying", js_cocos2dx_experimental_video_VideoPlayer_isPlaying, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("seekTo", js_cocos2dx_experimental_video_VideoPlayer_seekTo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.hpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.hpp index 5e854598b2..0fd62dee36 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.hpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.hpp @@ -17,6 +17,7 @@ bool js_cocos2dx_experimental_video_VideoPlayer_getFileName(JSContext *cx, uint3 bool js_cocos2dx_experimental_video_VideoPlayer_getURL(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_experimental_video_VideoPlayer_play(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_experimental_video_VideoPlayer_setKeepAspectRatioEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_experimental_video_VideoPlayer_currentTime(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_experimental_video_VideoPlayer_stop(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_experimental_video_VideoPlayer_setFullScreenEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_experimental_video_VideoPlayer_setFileName(JSContext *cx, uint32_t argc, jsval *vp); @@ -24,6 +25,7 @@ bool js_cocos2dx_experimental_video_VideoPlayer_setURL(JSContext *cx, uint32_t a bool js_cocos2dx_experimental_video_VideoPlayer_isKeepAspectRatioEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_experimental_video_VideoPlayer_onPlayEvent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_experimental_video_VideoPlayer_isFullScreenEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_experimental_video_VideoPlayer_duration(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_experimental_video_VideoPlayer_isPlaying(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_experimental_video_VideoPlayer_seekTo(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_experimental_video_VideoPlayer_create(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/native/cocos/ui/UIVideoPlayer-android.cpp b/native/cocos/ui/UIVideoPlayer-android.cpp index fc2cb72a0f..8db8dde37c 100644 --- a/native/cocos/ui/UIVideoPlayer-android.cpp +++ b/native/cocos/ui/UIVideoPlayer-android.cpp @@ -313,5 +313,15 @@ void executeVideoCallback(int index,int event) } } +float VideoPlayer::currentTime() const +{ + return JniHelper::callStaticFloatMethod(videoHelperClassName, "getCurrentTime", _videoPlayerIndex); +} + +float VideoPlayer::duration() const +{ + return JniHelper::callStaticFloatMethod(videoHelperClassName, "getDuration", _videoPlayerIndex); +} + #endif From c18fa069ffc3d044abc96694d70892e81a31d198 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Tue, 16 Aug 2016 12:52:38 +0800 Subject: [PATCH 08/14] fix android isPlaying API --- .../org/cocos2dx/lib/Cocos2dxVideoHelper.java | 35 +++++++++++++------ native/cocos/ui/UIVideoPlayer-android.cpp | 2 +- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoHelper.java b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoHelper.java index fda28608c7..782e337778 100644 --- a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoHelper.java +++ b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoHelper.java @@ -28,17 +28,14 @@ import android.graphics.Rect; import android.os.Handler; import android.os.Looper; import android.os.Message; -import android.util.Log; import android.util.SparseArray; import android.view.View; import android.widget.FrameLayout; -import android.widget.VideoView; import org.cocos2dx.lib.Cocos2dxVideoView.OnVideoEventListener; import java.lang.ref.WeakReference; import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.FutureTask; @@ -70,8 +67,6 @@ public class Cocos2dxVideoHelper { private final static int VideoTaskRestart = 10; private final static int VideoTaskKeepRatio = 11; private final static int VideoTaskFullScreen = 12; - private final static int VideoTaskCurrentTime = 13; - private final static int VideoTaskDuration = 14; final static int KeyEventBack = 1000; static class VideoHandler extends Handler{ @@ -393,10 +388,10 @@ public class Cocos2dxVideoHelper { Callable callable = new Callable() { @Override public Float call() throws Exception { - Cocos2dxVideoView viedo = mVideoViews.get(index); + Cocos2dxVideoView video = mVideoViews.get(index); float currentPosition = -1; - if (viedo != null) { - currentPosition = viedo.getCurrentPosition() / 1000.0f; + if (video != null) { + currentPosition = video.getCurrentPosition() / 1000.0f; } return new Float(currentPosition); } @@ -415,10 +410,10 @@ public class Cocos2dxVideoHelper { Callable callable = new Callable() { @Override public Float call() throws Exception { - Cocos2dxVideoView viedo = mVideoViews.get(index); + Cocos2dxVideoView video = mVideoViews.get(index); float duration = -1; - if (viedo != null) { - duration = viedo.getDuration() / 1000.0f; + if (video != null) { + duration = video.getDuration() / 1000.0f; } return new Float(duration); } @@ -433,6 +428,24 @@ public class Cocos2dxVideoHelper { } } + public static boolean isPlaying(final int index) { + Callable callable = new Callable() { + @Override + public Boolean call() throws Exception { + Cocos2dxVideoView video = mVideoViews.get(index); + return video != null && video.isPlaying(); + } + }; + + try { + return callInMainThread(callable); + } catch (ExecutionException e) { + return false; + } catch (InterruptedException e) { + return false; + } + } + public static void setVideoVisible(int index, boolean visible) { Message msg = Message.obtain(); diff --git a/native/cocos/ui/UIVideoPlayer-android.cpp b/native/cocos/ui/UIVideoPlayer-android.cpp index 8db8dde37c..4a8f866a2b 100644 --- a/native/cocos/ui/UIVideoPlayer-android.cpp +++ b/native/cocos/ui/UIVideoPlayer-android.cpp @@ -227,7 +227,7 @@ void VideoPlayer::seekTo(float sec) bool VideoPlayer::isPlaying() const { - return _isPlaying; + return JniHelper::callStaticBooleanMethod(videoHelperClassName, "isPlaying", _videoPlayerIndex); } void VideoPlayer::setVisible(bool visible) From 0df076d5084bd877b774fffeaeda0b9624558bd8 Mon Sep 17 00:00:00 2001 From: "yanli.huang" Date: Mon, 22 Aug 2016 16:29:13 +0800 Subject: [PATCH 09/14] update cocos2d-console commit id : cocos package so change pyc --- native/tools/cocos2d-console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/tools/cocos2d-console b/native/tools/cocos2d-console index fdad71adcf..fc15e7c22c 160000 --- a/native/tools/cocos2d-console +++ b/native/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit fdad71adcf580741398d3ef93ac2f835023ef06c +Subproject commit fc15e7c22ce3345d47d0978054c3eed012ce5076 From 17bba052e5e329f2e6f66eea68567c703fd7804f Mon Sep 17 00:00:00 2001 From: "yanli.huang" Date: Mon, 22 Aug 2016 16:46:10 +0800 Subject: [PATCH 10/14] update cocos2d-console commit id :add cocospackage.pyc --- native/tools/cocos2d-console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/tools/cocos2d-console b/native/tools/cocos2d-console index fc15e7c22c..f054a3e506 160000 --- a/native/tools/cocos2d-console +++ b/native/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit fc15e7c22ce3345d47d0978054c3eed012ce5076 +Subproject commit f054a3e506124f62288e5ba1cab5b48feacb1d37 From c216e504f18fafc9937e5f54d24507c9db536da1 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 29 Aug 2016 11:12:01 +0800 Subject: [PATCH 11/14] fix label shrink crash issue --- native/cocos/platform/mac/CCDevice-mac.mm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/native/cocos/platform/mac/CCDevice-mac.mm b/native/cocos/platform/mac/CCDevice-mac.mm index 6ac18241eb..e5a9bb286c 100644 --- a/native/cocos/platform/mac/CCDevice-mac.mm +++ b/native/cocos/platform/mac/CCDevice-mac.mm @@ -129,7 +129,10 @@ static NSSize _calculateRealSizeForString(NSAttributedString **str, id font, NSS while (actualSize.size.width > constrainSize.width || actualSize.size.height > constrainSize.height) { fontSize = fontSize - 1; - + if (fontSize < 0) { + actualSize = CGRectMake(0, 0, 0, 0); + break; + } NSMutableAttributedString *mutableString = [[*str mutableCopy] autorelease]; *str = __attributedStringWithFontSize(mutableString, fontSize); @@ -156,7 +159,10 @@ static NSSize _calculateRealSizeForString(NSAttributedString **str, id font, NSS while (actualSize.size.height > constrainSize.height ||actualSize.size.width > constrainSize.width) { fontSize = fontSize - 1; - + if (fontSize < 0) { + actualSize = CGRectMake(0, 0, 0, 0); + break; + } NSMutableAttributedString *mutableString = [[*str mutableCopy] autorelease]; *str = __attributedStringWithFontSize(mutableString, fontSize); From b73e97e40397602701dec244d80036f2d5a85505 Mon Sep 17 00:00:00 2001 From: knoxHuang <821686174@qq.com> Date: Mon, 29 Aug 2016 16:33:52 +0800 Subject: [PATCH 12/14] add enableAntiAlias for Native for fireball/issues/2836 --- native/cocos/platform/CCGLView.cpp | 27 ++++++++++++++++++++++++ native/cocos/platform/CCGLView.h | 15 +++++++++++++ native/cocos/renderer/CCTexture2D.cpp | 1 + native/cocos/renderer/CCTextureCache.cpp | 9 ++++++++ native/cocos/renderer/CCTextureCache.h | 8 +++++++ 5 files changed, 60 insertions(+) diff --git a/native/cocos/platform/CCGLView.cpp b/native/cocos/platform/CCGLView.cpp index 993cc80ce9..9bb022f45b 100644 --- a/native/cocos/platform/CCGLView.cpp +++ b/native/cocos/platform/CCGLView.cpp @@ -101,6 +101,7 @@ GLContextAttrs GLView::getGLContextAttrs() GLView::GLView() : _scaleX(1.0f) , _scaleY(1.0f) +, _antiAliasEnabled(true) , _resolutionPolicy(ResolutionPolicy::UNKNOWN) { } @@ -457,5 +458,31 @@ float GLView::getScaleY() const return _scaleY; } +bool GLView::isAntiAliasEnabled() const +{ + return _antiAliasEnabled; +} + +void GLView::enableAntiAlias(bool enabled) +{ + if (_antiAliasEnabled == enabled) { + return; + } + _antiAliasEnabled = enabled; + + cocos2d::Vector list = Director::getInstance()->getTextureCache()->getAllTextures(); + for (size_t i = 0; i < list.size(); i++) { + Texture2D* tex = list.at(i); + if (tex) { + if (enabled) { + tex->setAntiAliasTexParameters(); + } + else { + tex->setAliasTexParameters(); + } + } + } +} + NS_CC_END diff --git a/native/cocos/platform/CCGLView.h b/native/cocos/platform/CCGLView.h index bccd5fa294..e43325b686 100644 --- a/native/cocos/platform/CCGLView.h +++ b/native/cocos/platform/CCGLView.h @@ -371,6 +371,19 @@ public: */ ResolutionPolicy getResolutionPolicy() const { return _resolutionPolicy; } + /** Returns whether the current enable on anti-alias. + * + * @return The antiAlias enabled. + */ + bool isAntiAliasEnabled() const; + + /** Whether to Enable on anti-alias. + * + * @param enabled The Enable or not anti-alias. + */ + void enableAntiAlias(bool enabled); + + #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) virtual HWND getWin32Window() = 0; #endif /* (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) */ @@ -392,6 +405,8 @@ protected: Rect _viewPortRect; // the view name std::string _viewName; + // anti alias state + bool _antiAliasEnabled; float _scaleX; float _scaleY; diff --git a/native/cocos/renderer/CCTexture2D.cpp b/native/cocos/renderer/CCTexture2D.cpp index e36f6244c7..d726a45b3c 100644 --- a/native/cocos/renderer/CCTexture2D.cpp +++ b/native/cocos/renderer/CCTexture2D.cpp @@ -446,6 +446,7 @@ Texture2D::Texture2D() , _ninePatchInfo(nullptr) { s_allGLTexture2D.insert(this); + _antialiasEnabled = Director::getInstance()->getOpenGLView()->isAntiAliasEnabled(); } Texture2D::~Texture2D() diff --git a/native/cocos/renderer/CCTextureCache.cpp b/native/cocos/renderer/CCTextureCache.cpp index 24ca7a1a55..9ccb84976c 100644 --- a/native/cocos/renderer/CCTextureCache.cpp +++ b/native/cocos/renderer/CCTextureCache.cpp @@ -456,6 +456,15 @@ bool TextureCache::reloadTexture(const std::string& fileName) return ret; } +cocos2d::Vector TextureCache::getAllTextures() const +{ + cocos2d::Vector result; + for( auto it=_textures.begin(); it!=_textures.end(); ++it ) { + result.pushBack(it->second); + } + return result; +} + // TextureCache - Remove void TextureCache::removeAllTextures() diff --git a/native/cocos/renderer/CCTextureCache.h b/native/cocos/renderer/CCTextureCache.h index aee08409b1..a74a16a501 100644 --- a/native/cocos/renderer/CCTextureCache.h +++ b/native/cocos/renderer/CCTextureCache.h @@ -38,6 +38,7 @@ THE SOFTWARE. #include #include "base/CCRef.h" +#include "base/CCVector.h" #include "renderer/CCTexture2D.h" #include "platform/CCImage.h" @@ -151,6 +152,13 @@ public: */ bool reloadTexture(const std::string& fileName); + /** + * get all textures. + * + * @return all textures. + */ + cocos2d::Vector getAllTextures() const; + /** Purges the dictionary of loaded textures. * Call this method if you receive the "Memory Warning". * In the short term: it will free some resources preventing your app from being killed. From de6dd6d450ed9d541dcd88345b81a8d77c884ba9 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 29 Aug 2016 09:10:20 +0000 Subject: [PATCH 13/14] [ci skip][AUTO]: updating jsbinding automatically --- .../auto/api/jsb_cocos2dx_auto_api.js | 30 ++++++++++ .../js-bindings/auto/jsb_cocos2dx_auto.cpp | 59 +++++++++++++++++++ .../js-bindings/auto/jsb_cocos2dx_auto.hpp | 3 + 3 files changed, 92 insertions(+) diff --git a/native/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/native/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index 1f548ddeee..09e5fc1218 100644 --- a/native/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/native/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -2120,6 +2120,16 @@ bool { }, +/** + * @method isAntiAliasEnabled + * @return {bool} + */ +isAntiAliasEnabled : function ( +) +{ + return false; +}, + /** * @method setScissorInPoints * @param {float} arg0 @@ -2306,6 +2316,16 @@ getScissorRect : function ( return cc.Rect; }, +/** + * @method enableAntiAlias + * @param {bool} arg0 + */ +enableAntiAlias : function ( +bool +) +{ +}, + /** * @method getRetinaFactor * @return {int} @@ -18958,6 +18978,16 @@ func { }, +/** + * @method getAllTextures + * @return {Array} + */ +getAllTextures : function ( +) +{ + return new Array(); +}, + /** * @method getDescription * @return {String} diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index 7f36506039..d25665fab0 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -5604,6 +5604,24 @@ bool js_cocos2dx_GLView_setIMEKeyboardState(JSContext *cx, uint32_t argc, jsval JS_ReportError(cx, "js_cocos2dx_GLView_setIMEKeyboardState : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_GLView_isAntiAliasEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_isAntiAliasEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isAntiAliasEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_isAntiAliasEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_GLView_setScissorInPoints(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -5936,6 +5954,26 @@ bool js_cocos2dx_GLView_getScissorRect(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_GLView_getScissorRect : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_GLView_enableAntiAlias(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_enableAntiAlias : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLView_enableAntiAlias : Error processing arguments"); + cobj->enableAntiAlias(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_enableAntiAlias : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_GLView_getRetinaFactor(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -6088,6 +6126,7 @@ void js_register_cocos2dx_GLView(JSContext *cx, JS::HandleObject global) { JS_FN("setContentScaleFactor", js_cocos2dx_GLView_setContentScaleFactor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getContentScaleFactor", js_cocos2dx_GLView_getContentScaleFactor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setIMEKeyboardState", js_cocos2dx_GLView_setIMEKeyboardState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isAntiAliasEnabled", js_cocos2dx_GLView_isAntiAliasEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScissorInPoints", js_cocos2dx_GLView_setScissorInPoints, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getViewName", js_cocos2dx_GLView_getViewName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isOpenGLReady", js_cocos2dx_GLView_isOpenGLReady, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -6105,6 +6144,7 @@ void js_register_cocos2dx_GLView(JSContext *cx, JS::HandleObject global) { JS_FN("isRetinaDisplay", js_cocos2dx_GLView_isRetinaDisplay, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setViewPortInPoints", js_cocos2dx_GLView_setViewPortInPoints, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getScissorRect", js_cocos2dx_GLView_getScissorRect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("enableAntiAlias", js_cocos2dx_GLView_enableAntiAlias, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRetinaFactor", js_cocos2dx_GLView_getRetinaFactor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setViewName", js_cocos2dx_GLView_setViewName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVisibleRect", js_cocos2dx_GLView_getVisibleRect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -57034,6 +57074,24 @@ bool js_cocos2dx_TextureCache_addImageAsync(JSContext *cx, uint32_t argc, jsval JS_ReportError(cx, "js_cocos2dx_TextureCache_addImageAsync : wrong number of arguments: %d, was expecting %d", argc, 2); return false; } +bool js_cocos2dx_TextureCache_getAllTextures(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_getAllTextures : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vector ret = cobj->getAllTextures(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextureCache_getAllTextures : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_TextureCache_getDescription(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -57331,6 +57389,7 @@ void js_register_cocos2dx_TextureCache(JSContext *cx, JS::HandleObject global) { JS_FN("removeTextureForKey", js_cocos2dx_TextureCache_removeTextureForKey, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllTextures", js_cocos2dx_TextureCache_removeAllTextures, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addImageAsync", js_cocos2dx_TextureCache_addImageAsync, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAllTextures", js_cocos2dx_TextureCache_getAllTextures, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDescription", js_cocos2dx_TextureCache_getDescription, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCachedTextureInfo", js_cocos2dx_TextureCache_getCachedTextureInfo, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addImage", js_cocos2dx_TextureCache_addImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index d7704a99c4..dda60fe656 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -274,6 +274,7 @@ bool js_cocos2dx_GLView_getViewPortRect(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_GLView_setContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLView_getContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLView_setIMEKeyboardState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_isAntiAliasEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLView_setScissorInPoints(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLView_getViewName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLView_isOpenGLReady(JSContext *cx, uint32_t argc, jsval *vp); @@ -291,6 +292,7 @@ bool js_cocos2dx_GLView_getResolutionPolicy(JSContext *cx, uint32_t argc, jsval bool js_cocos2dx_GLView_isRetinaDisplay(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLView_setViewPortInPoints(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLView_getScissorRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_enableAntiAlias(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLView_getRetinaFactor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLView_setViewName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLView_getVisibleRect(JSContext *cx, uint32_t argc, jsval *vp); @@ -3443,6 +3445,7 @@ bool js_cocos2dx_TextureCache_unbindAllImageAsync(JSContext *cx, uint32_t argc, bool js_cocos2dx_TextureCache_removeTextureForKey(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TextureCache_removeAllTextures(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TextureCache_addImageAsync(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextureCache_getAllTextures(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TextureCache_getDescription(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TextureCache_getCachedTextureInfo(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TextureCache_addImage(JSContext *cx, uint32_t argc, jsval *vp); From 20e981f64e1b801c3e192b40a86535a6d394a630 Mon Sep 17 00:00:00 2001 From: "yanli.huang" Date: Tue, 30 Aug 2016 13:59:45 +0800 Subject: [PATCH 14/14] update cocos2d-console commit id :fix cocos package can't update --- native/tools/cocos2d-console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/tools/cocos2d-console b/native/tools/cocos2d-console index f054a3e506..2aa56f9f8b 160000 --- a/native/tools/cocos2d-console +++ b/native/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit f054a3e506124f62288e5ba1cab5b48feacb1d37 +Subproject commit 2aa56f9f8bd60e60d48078731457318f43ab5195