From 92241e4ca91960b297dfdfe02e5d259b7192211a Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 20 Apr 2018 14:43:58 +0800 Subject: [PATCH] fix bugs for new renderer (#2574) * gulp task: add clean cache & support native renderer * fix binding codes of Texture2D.updateSubImage * fix some issues * fix Texture2D.updateSubImage() --- cocos2d/core/platform/CCSys.js | 3 +++ jsb/gfx.js | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/platform/CCSys.js b/cocos2d/core/platform/CCSys.js index c23599e019..ec552e97e5 100644 --- a/cocos2d/core/platform/CCSys.js +++ b/cocos2d/core/platform/CCSys.js @@ -588,6 +588,9 @@ function initSys () { DELAY_CREATE_CTX: false, format: ['.mp3'] }; + + // Adaptation + wx.getOpenDataContext = function () {return {canvas: null};} } else if (CC_WECHATGAME) { var env = wx.getSystemInfoSync(); diff --git a/jsb/gfx.js b/jsb/gfx.js index 6d16f5de70..c2b78d2b40 100644 --- a/jsb/gfx.js +++ b/jsb/gfx.js @@ -94,7 +94,28 @@ _p.destroy = function() { }; _p.update = function(options) { convertImages(options.images); - this.updateBinding(options); + this.updateNative(options); +}; +_p.updateSubImage = function(option) { + var images = [option.image]; + convertImages(images); + var data = new Uint16Array(8 + + (images[0].length + 1) / 2); + + data[0] = option.x; + data[1] = option.y; + data[2] = option.width; + data[3] = option.height; + data[4] = option.level; + data[5] = option.flipY; + data[6] = false; + + + data[7] = images[0].length; + var imageData = new Uint8Array(data.buffer); + imageData.set(images[0], 16); + + this.updateSubImageNative(data); }; cc.defineGetterSetter(_p, "_width", _p.getWidth); cc.defineGetterSetter(_p, "_height", _p.getHeight);