diff --git a/doc/release-note/0.2.9/README.md b/doc/release-note/0.2.9/README.md new file mode 100755 index 0000000..265ab2c --- /dev/null +++ b/doc/release-note/0.2.9/README.md @@ -0,0 +1,12 @@ +## Baidu MiniGame Support 0.2.9 Release Notes + +- **[OPTIMIZE]** Optimize the canvas transform strategy +- **[OPTIMIZE]** Remove invalid comments and reduce the volume of the adapter layer js file + + +## 百度小游戏支持库 0.2.9 更新日志 +- **[优化]** 优化 canvas 缩放策略 +- **[优化]** 移除无效的注释,减小适配层 js 文件体积 + + +【2019.10.15】 \ No newline at end of file diff --git a/src/WebPlayer.ts b/src/WebPlayer.ts index 4b2fe57..dca20bf 100644 --- a/src/WebPlayer.ts +++ b/src/WebPlayer.ts @@ -221,11 +221,6 @@ namespace egret.baidugame { let canvasScaleX = scalex * sys.DisplayList.$canvasScaleFactor; let canvasScaleY = scaley * sys.DisplayList.$canvasScaleFactor; - let m = new egret.Matrix(); - m.scale(scalex / canvasScaleX, scaley / canvasScaleY); - m.rotate(rotation * Math.PI / 180); - let transform = `matrix(${m.a},${m.b},${m.c},${m.d},${m.tx},${m.ty})`; - canvas.style[getPrefixStyleName("transform")] = transform; sys.DisplayList.$setCanvasScale(canvasScaleX, canvasScaleY); this.webTouchHandler.updateScaleMode(scalex, scaley, rotation); this.player.updateStageSize(stageWidth, stageHeight);//不要在这个方法后面修改属性 diff --git a/target/target.json b/target/target.json index c39849a..b73b82a 100755 --- a/target/target.json +++ b/target/target.json @@ -1,6 +1,6 @@ { "projectType": "baidugame", - "version": "0.2.8", + "version": "0.2.9", "args": [ { "name": "appid", diff --git a/target/template/egret.baidugame.js b/target/template/egret.baidugame.js index 16dd369..383f237 100644 --- a/target/template/egret.baidugame.js +++ b/target/template/egret.baidugame.js @@ -12,19 +12,10 @@ r.prototype = e.prototype, t.prototype = new r(); (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var WebGeolocation = (function (_super) { __extends(WebGeolocation, _super); - /** - * @private - */ function WebGeolocation(option) { var _this = _super.call(this) || this; - /** - * @private - */ _this.onUpdate = function (position) { var event = new egret.GeolocationEvent(egret.Event.CHANGE); var coords = position.coords; @@ -37,9 +28,6 @@ r.prototype = e.prototype, t.prototype = new r(); event.altitudeAccuracy = coords.altitudeAccuracy; _this.dispatchEvent(event); }; - /** - * @private - */ _this.onError = function (error) { var errorType = egret.GeolocationEvent.UNAVAILABLE; if (error.code == error.PERMISSION_DENIED) @@ -52,10 +40,6 @@ r.prototype = e.prototype, t.prototype = new r(); _this.geolocation = navigator.geolocation; return _this; } - /** - * @private - * - */ WebGeolocation.prototype.start = function () { var geo = this.geolocation; if (geo) @@ -68,10 +52,6 @@ r.prototype = e.prototype, t.prototype = new r(); POSITION_UNAVAILABLE: 2 }); }; - /** - * @private - * - */ WebGeolocation.prototype.stop = function () { var geo = this.geolocation; geo.clearWatch(this.watchId); @@ -86,16 +66,10 @@ r.prototype = e.prototype, t.prototype = new r(); (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var WebMotion = (function (_super) { __extends(WebMotion, _super); function WebMotion() { var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ _this.onChange = function (e) { var event = new egret.MotionEvent(egret.Event.CHANGE); var acceleration = { @@ -120,17 +94,9 @@ r.prototype = e.prototype, t.prototype = new r(); }; return _this; } - /** - * @private - * - */ WebMotion.prototype.start = function () { window.addEventListener("devicemotion", this.onChange); }; - /** - * @private - * - */ WebMotion.prototype.stop = function () { window.removeEventListener("devicemotion", this.onChange); }; @@ -140,41 +106,10 @@ r.prototype = e.prototype, t.prototype = new r(); __reflect(WebMotion.prototype, "egret.baidugame.WebMotion", ["egret.Motion"]); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var WebPlayer = (function (_super) { __extends(WebPlayer, _super); function WebPlayer(container, options) { @@ -221,9 +156,6 @@ r.prototype = e.prototype, t.prototype = new r(); }, 350); }); }; - /** - * 读取初始化参数 - */ WebPlayer.prototype.readOption = function (container, options) { var option = {}; option.entryClassName = options.entryClassName || "Main"; @@ -252,10 +184,6 @@ r.prototype = e.prototype, t.prototype = new r(); option.logFilter = ""; return option; }; - /** - * @private - * 添加canvas到container。 - */ WebPlayer.prototype.attachCanvas = function (container, canvas) { var style = canvas.style; style.cursor = "inherit"; @@ -264,15 +192,7 @@ r.prototype = e.prototype, t.prototype = new r(); style.bottom = "0"; style.left = "0"; style.right = "0"; - // container.appendChild(canvas); - // style = container.style; - // style.overflow = "hidden"; - // style.position = "absolute"; - }; - /** - * @private - * 更新播放器视口尺寸 - */ + }; WebPlayer.prototype.updateScreenSize = function () { var canvas = this.canvas; if (canvas['userTyping']) @@ -324,14 +244,9 @@ r.prototype = e.prototype, t.prototype = new r(); var scalex = displayWidth / stageWidth, scaley = displayHeight / stageHeight; var canvasScaleX = scalex * egret.sys.DisplayList.$canvasScaleFactor; var canvasScaleY = scaley * egret.sys.DisplayList.$canvasScaleFactor; - var m = new egret.Matrix(); - m.scale(scalex / canvasScaleX, scaley / canvasScaleY); - m.rotate(rotation * Math.PI / 180); - var transform = "matrix(" + m.a + "," + m.b + "," + m.c + "," + m.d + "," + m.tx + "," + m.ty + ")"; - canvas.style[baidugame.getPrefixStyleName("transform")] = transform; egret.sys.DisplayList.$setCanvasScale(canvasScaleX, canvasScaleY); this.webTouchHandler.updateScaleMode(scalex, scaley, rotation); - this.player.updateStageSize(stageWidth, stageHeight); //不要在这个方法后面修改属性 + this.player.updateStageSize(stageWidth, stageHeight); }; WebPlayer.prototype.setContentSize = function (width, height) { var option = this.playerOption; @@ -339,10 +254,6 @@ r.prototype = e.prototype, t.prototype = new r(); option.contentHeight = height; this.updateScreenSize(); }; - /** - * @private - * 更新触摸数量 - */ WebPlayer.prototype.updateMaxTouches = function () { this.webTouchHandler.$updateMaxTouches(); }; @@ -352,53 +263,14 @@ r.prototype = e.prototype, t.prototype = new r(); __reflect(WebPlayer.prototype, "egret.baidugame.WebPlayer", ["egret.sys.Screen"]); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - * @inheritDoc - */ var HtmlSound = (function (_super) { __extends(HtmlSound, _super); - /** - * @private - * @inheritDoc - */ function HtmlSound() { var _this = _super.call(this) || this; - /** - * @private - */ _this.loaded = false; return _this; } @@ -408,14 +280,10 @@ r.prototype = e.prototype, t.prototype = new r(); return this.originAudio.duration; } throw new Error("sound not loaded!"); - //return 0; }, enumerable: true, configurable: true }); - /** - * @inheritDoc - */ HtmlSound.prototype.load = function (url) { var self = this; this.url = url; @@ -425,7 +293,6 @@ r.prototype = e.prototype, t.prototype = new r(); var audio = new Audio(url); audio.addEventListener("canplaythrough", onAudioLoaded); audio.addEventListener("error", onAudioError); - // audio.load(); swan没有此接口 this.originAudio = audio; if (HtmlSound.clearAudios[this.url]) { delete HtmlSound.clearAudios[this.url]; @@ -445,9 +312,6 @@ r.prototype = e.prototype, t.prototype = new r(); audio.removeEventListener("error", onAudioError); } }; - /** - * @inheritDoc - */ HtmlSound.prototype.play = function (startTime, loops) { startTime = +startTime || 0; loops = +loops || 0; @@ -459,7 +323,6 @@ r.prototype = e.prototype, t.prototype = new r(); audio = this.originAudio.cloneNode(); } else { - //audio.load(); } audio.autoplay = true; var channel = new baidugame.HtmlSoundChannel(audio); @@ -470,9 +333,6 @@ r.prototype = e.prototype, t.prototype = new r(); egret.sys.$pushSoundChannel(channel); return channel; }; - /** - * @inheritDoc - */ HtmlSound.prototype.close = function () { if (this.loaded && this.originAudio) this.originAudio.src = ""; @@ -505,35 +365,8 @@ r.prototype = e.prototype, t.prototype = new r(); } array.push(audio); }; - /** - * Background music - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 背景音乐 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ HtmlSound.MUSIC = "music"; - /** - * EFFECT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音效 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ HtmlSound.EFFECT = "effect"; - /** - * @private - */ HtmlSound.audios = {}; HtmlSound.clearAudios = {}; return HtmlSound; @@ -542,62 +375,17 @@ r.prototype = e.prototype, t.prototype = new r(); __reflect(HtmlSound.prototype, "egret.baidugame.HtmlSound", ["egret.Sound"]); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - * @inheritDoc - */ var HtmlSoundChannel = (function (_super) { __extends(HtmlSoundChannel, _super); - /** - * @private - */ function HtmlSoundChannel(audio) { var _this = _super.call(this) || this; - /** - * @private - */ _this.$startTime = 0; - /** - * @private - */ _this.audio = null; - //声音是否已经播放完成 _this.isStopped = false; - /** - * @private - */ _this.onPlayEnd = function () { if (_this.$loops == 1) { _this.stop(); @@ -607,13 +395,8 @@ r.prototype = e.prototype, t.prototype = new r(); if (_this.$loops > 0) { _this.$loops--; } - ///////////// - //this.audio.load(); _this.$play(); }; - /** - * @private - */ _this._volume = 1; audio.addEventListener("ended", _this.onPlayEnd); _this.audio = audio; @@ -628,10 +411,6 @@ r.prototype = e.prototype, t.prototype = new r(); this.audio.volume = this._volume; this.audio.currentTime = this.$startTime; }; - /** - * @private - * @inheritDoc - */ HtmlSoundChannel.prototype.stop = function () { if (!this.audio) return; @@ -645,23 +424,15 @@ r.prototype = e.prototype, t.prototype = new r(); this._volume = 0; this.audio = null; var url = this.$url; - //延迟一定时间再停止,规避chrome报错 window.setTimeout(function () { audio.pause(); baidugame.HtmlSound.$recycle(url, audio); }, 200); }; Object.defineProperty(HtmlSoundChannel.prototype, "volume", { - /** - * @private - * @inheritDoc - */ get: function () { return this._volume; }, - /** - * @inheritDoc - */ set: function (value) { if (this.isStopped) { egret.$error(1036); @@ -676,10 +447,6 @@ r.prototype = e.prototype, t.prototype = new r(); configurable: true }); Object.defineProperty(HtmlSoundChannel.prototype, "position", { - /** - * @private - * @inheritDoc - */ get: function () { if (!this.audio) return 0; @@ -694,48 +461,13 @@ r.prototype = e.prototype, t.prototype = new r(); __reflect(HtmlSoundChannel.prototype, "egret.baidugame.HtmlSoundChannel", ["egret.SoundChannel", "egret.IEventDispatcher"]); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var WebAudioDecode = (function () { function WebAudioDecode() { } - /** - * @private - * - */ WebAudioDecode.decodeAudios = function () { if (WebAudioDecode.decodeArr.length <= 0) { return; @@ -761,33 +493,16 @@ r.prototype = e.prototype, t.prototype = new r(); WebAudioDecode.decodeAudios(); }); }; - /** - * @private - */ WebAudioDecode.decodeArr = []; - /** - * @private - */ WebAudioDecode.isDecoding = false; return WebAudioDecode; }()); baidugame.WebAudioDecode = WebAudioDecode; __reflect(WebAudioDecode.prototype, "egret.baidugame.WebAudioDecode"); - /** - * @private - * @inheritDoc - */ var WebAudioSound = (function (_super) { __extends(WebAudioSound, _super); - /** - * @private - * @inheritDoc - */ function WebAudioSound() { var _this = _super.call(this) || this; - /** - * @private - */ _this.loaded = false; return _this; } @@ -797,14 +512,10 @@ r.prototype = e.prototype, t.prototype = new r(); return this.audioBuffer.duration; } throw new Error("sound not loaded!"); - //return 0; }, enumerable: true, configurable: true }); - /** - * @inheritDoc - */ WebAudioSound.prototype.load = function (url) { var self = this; this.url = url; @@ -841,9 +552,6 @@ r.prototype = e.prototype, t.prototype = new r(); self.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); } }; - /** - * @inheritDoc - */ WebAudioSound.prototype.play = function (startTime, loops) { startTime = +startTime || 0; loops = +loops || 0; @@ -859,36 +567,9 @@ r.prototype = e.prototype, t.prototype = new r(); egret.sys.$pushSoundChannel(channel); return channel; }; - /** - * @inheritDoc - */ WebAudioSound.prototype.close = function () { }; - /** - * Background music - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 背景音乐 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ WebAudioSound.MUSIC = "music"; - /** - * EFFECT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音效 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ WebAudioSound.EFFECT = "effect"; return WebAudioSound; }(egret.EventDispatcher)); @@ -896,74 +577,20 @@ r.prototype = e.prototype, t.prototype = new r(); __reflect(WebAudioSound.prototype, "egret.baidugame.WebAudioSound", ["egret.Sound"]); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - * @inheritDoc - */ var WebAudioSoundChannel = (function (_super) { __extends(WebAudioSoundChannel, _super); - /** - * @private - */ function WebAudioSoundChannel() { var _this = _super.call(this) || this; - /** - * @private - */ _this.$startTime = 0; - /** - * @private - */ _this.bufferSource = null; - /** - * @private - */ _this.context = baidugame.WebAudioDecode.ctx; - //声音是否已经播放完成 _this.isStopped = false; - /** - * @private - */ _this._currentTime = 0; - /** - * @private - */ _this._volume = 1; - /** - * @private - */ _this.onPlayEnd = function () { if (_this.$loops == 1) { _this.stop(); @@ -973,12 +600,8 @@ r.prototype = e.prototype, t.prototype = new r(); if (_this.$loops > 0) { _this.$loops--; } - ///////////// _this.$play(); }; - /** - * @private - */ _this._startTime = 0; if (_this.context["createGain"]) { _this.gain = _this.context["createGain"](); @@ -1030,16 +653,9 @@ r.prototype = e.prototype, t.prototype = new r(); this.isStopped = true; }; Object.defineProperty(WebAudioSoundChannel.prototype, "volume", { - /** - * @private - * @inheritDoc - */ get: function () { return this._volume; }, - /** - * @inheritDoc - */ set: function (value) { if (this.isStopped) { egret.$error(1036); @@ -1052,10 +668,6 @@ r.prototype = e.prototype, t.prototype = new r(); configurable: true }); Object.defineProperty(WebAudioSoundChannel.prototype, "position", { - /** - * @private - * @inheritDoc - */ get: function () { if (this.bufferSource) { return (Date.now() - this._startTime) / 1000 + this.$startTime; @@ -1071,80 +683,21 @@ r.prototype = e.prototype, t.prototype = new r(); __reflect(WebAudioSoundChannel.prototype, "egret.baidugame.WebAudioSoundChannel", ["egret.SoundChannel", "egret.IEventDispatcher"]); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - * @inheritDoc - */ var WebVideo = (function (_super) { __extends(WebVideo, _super); - /** - * @inheritDoc - */ function WebVideo(url, cache) { if (cache === void 0) { cache = true; } var _this = _super.call(this) || this; - /** - * @private - */ _this.loaded = false; - /** - * @private - */ _this.closed = false; - /** - * @private - */ _this.heightSet = NaN; - /** - * @private - */ _this.widthSet = NaN; - /** - * @private - * pc上视频卡住的时候不能暂停 - */ _this.waiting = false; - /** - * @private - * 用户是否设置了 pause - */ _this.userPause = false; - /** - * @private - * 用户是否设置了 play - */ _this.userPlay = false; _this.isPlayed = false; _this.screenChanged = function (e) { @@ -1157,15 +710,10 @@ r.prototype = e.prototype, t.prototype = new r(); } }; _this._fullscreen = true; - /** - * @private - * - */ _this.onVideoLoaded = function () { _this.video.removeEventListener("canplay", _this.onVideoLoaded); var video = _this.video; _this.loaded = true; - //video.pause(); if (_this.posterData) { _this.posterData.width = _this.getPlayWidth(); _this.posterData.height = _this.getPlayHeight(); @@ -1184,9 +732,6 @@ r.prototype = e.prototype, t.prototype = new r(); } return _this; } - /** - * @inheritDoc - */ WebVideo.prototype.load = function (url, cache) { var _this = this; if (cache === void 0) { cache = true; } @@ -1241,9 +786,6 @@ r.prototype = e.prototype, t.prototype = new r(); video.height = 1; video.width = 1; }; - /** - * @inheritDoc - */ WebVideo.prototype.play = function (startTime, loop) { var _this = this; if (loop === void 0) { loop = false; } @@ -1258,7 +800,7 @@ r.prototype = e.prototype, t.prototype = new r(); video.currentTime = +startTime || 0; video.loop = !!loop; if (egret.Capabilities.isMobile) { - video.style.zIndex = "-88888"; //移动端,就算设置成最小,只要全屏,都会在最上层,而且在自动退出去后,不担心挡住canvas + video.style.zIndex = "-88888"; } else { video.style.zIndex = "9999"; @@ -1343,7 +885,6 @@ r.prototype = e.prototype, t.prototype = new r(); egret.$error(3014); }; WebVideo.prototype.exitFullscreen = function () { - //退出全屏 if (document['exitFullscreen']) { document['exitFullscreen'](); } @@ -1362,25 +903,14 @@ r.prototype = e.prototype, t.prototype = new r(); else { } }; - /** - * @private - * - */ WebVideo.prototype.onVideoEnded = function () { this.pause(); this.isPlayed = false; this.dispatchEventWith(egret.Event.ENDED); }; - /** - * @private - * - */ WebVideo.prototype.onVideoError = function () { this.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); }; - /** - * @inheritDoc - */ WebVideo.prototype.close = function () { var _this = this; this.closed = true; @@ -1396,9 +926,6 @@ r.prototype = e.prototype, t.prototype = new r(); } this.loaded = false; }; - /** - * @inheritDoc - */ WebVideo.prototype.pause = function () { this.userPlay = false; if (this.waiting) { @@ -1409,17 +936,11 @@ r.prototype = e.prototype, t.prototype = new r(); egret.stopTick(this.markDirty, this); }; Object.defineProperty(WebVideo.prototype, "volume", { - /** - * @inheritDoc - */ get: function () { if (!this.video) return 1; return this.video.volume; }, - /** - * @inheritDoc - */ set: function (value) { if (!this.video) return; @@ -1429,17 +950,11 @@ r.prototype = e.prototype, t.prototype = new r(); configurable: true }); Object.defineProperty(WebVideo.prototype, "position", { - /** - * @inheritDoc - */ get: function () { if (!this.video) return 0; return this.video.currentTime; }, - /** - * @inheritDoc - */ set: function (value) { if (!this.video) return; @@ -1449,15 +964,9 @@ r.prototype = e.prototype, t.prototype = new r(); configurable: true }); Object.defineProperty(WebVideo.prototype, "fullscreen", { - /** - * @inheritDoc - */ get: function () { return this._fullscreen; }, - /** - * @inheritDoc - */ set: function (value) { if (egret.Capabilities.isMobile) { return; @@ -1471,9 +980,6 @@ r.prototype = e.prototype, t.prototype = new r(); configurable: true }); Object.defineProperty(WebVideo.prototype, "bitmapData", { - /** - * @inheritDoc - */ get: function () { if (!this.video || !this.loaded) return null; @@ -1502,9 +1008,6 @@ r.prototype = e.prototype, t.prototype = new r(); }, this); imageLoader.load(poster); }; - /** - * @private - */ WebVideo.prototype.$measureContentBounds = function (bounds) { var bitmapData = this.bitmapData; var posterData = this.posterData; @@ -1542,9 +1045,6 @@ r.prototype = e.prototype, t.prototype = new r(); } return NaN; }; - /** - * @private - */ WebVideo.prototype.$updateRenderNode = function () { var node = this.$renderNode; var bitmapData = this.bitmapData; @@ -1570,18 +1070,10 @@ r.prototype = e.prototype, t.prototype = new r(); this.$renderDirty = true; return true; }; - /** - * @private - * 设置显示高度 - */ WebVideo.prototype.$setHeight = function (value) { this.heightSet = +value || 0; _super.prototype.$setHeight.call(this, value); }; - /** - * @private - * 设置显示宽度 - */ WebVideo.prototype.$setWidth = function (value) { this.widthSet = +value || 0; _super.prototype.$setWidth.call(this, value); @@ -1597,9 +1089,6 @@ r.prototype = e.prototype, t.prototype = new r(); configurable: true }); Object.defineProperty(WebVideo.prototype, "length", { - /** - * @inheritDoc - */ get: function () { if (this.video) { return this.video.duration; @@ -1616,61 +1105,20 @@ r.prototype = e.prototype, t.prototype = new r(); egret.Video = WebVideo; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var WebHttpRequest = (function (_super) { __extends(WebHttpRequest, _super); - /** - * @private - */ function WebHttpRequest() { var _this = _super.call(this) || this; _this.timeout = 0; - /** - * @private - */ _this._url = ""; _this._method = ""; return _this; } Object.defineProperty(WebHttpRequest.prototype, "response", { - /** - * @private - * 本次请求返回的数据,数据类型根据responseType设置的值确定。 - */ get: function () { if (!this._xhr) { return null; @@ -1690,10 +1138,6 @@ r.prototype = e.prototype, t.prototype = new r(); configurable: true }); Object.defineProperty(WebHttpRequest.prototype, "responseType", { - /** - * @private - * 设置返回的数据格式,请使用 HttpResponseType 里定义的枚举值。设置非法的值或不设置,都将使用HttpResponseType.TEXT。 - */ get: function () { return this._responseType; }, @@ -1704,10 +1148,6 @@ r.prototype = e.prototype, t.prototype = new r(); configurable: true }); Object.defineProperty(WebHttpRequest.prototype, "withCredentials", { - /** - * @private - * 表明在进行跨站(cross-site)的访问控制(Access-Control)请求时,是否使用认证信息(例如cookie或授权的header)。 默认为 false。(这个标志不会影响同站的请求) - */ get: function () { return this._withCredentials; }, @@ -1717,12 +1157,6 @@ r.prototype = e.prototype, t.prototype = new r(); enumerable: true, configurable: true }); - /** - * @private - * 初始化一个请求.注意,若在已经发出请求的对象上调用此方法,相当于立即调用abort(). - * @param url 该请求所要访问的URL该请求所要访问的URL - * @param method 请求所使用的HTTP方法, 请使用 HttpMethod 定义的枚举值. - */ WebHttpRequest.prototype.open = function (url, method) { if (method === void 0) { method = "GET"; } this._url = url; @@ -1737,11 +1171,6 @@ r.prototype = e.prototype, t.prototype = new r(); this._xhr.ontimeout = this.onTimeout.bind(this); this._xhr.open(this._method, this._url, true); }; - /** - * @private - * 发送请求. - * @param data 需要发送的数据 - */ WebHttpRequest.prototype.send = function (data) { if (this._responseType != null) { this._xhr.responseType = this._responseType; @@ -1757,19 +1186,11 @@ r.prototype = e.prototype, t.prototype = new r(); this._xhr.timeout = this.timeout; this._xhr.send(data); }; - /** - * @private - * 如果请求已经被发送,则立刻中止请求. - */ WebHttpRequest.prototype.abort = function () { if (this._xhr) { this._xhr.abort(); } }; - /** - * @private - * 返回所有响应头信息(响应头名和值), 如果响应头还没接受,则返回"". - */ WebHttpRequest.prototype.getAllResponseHeaders = function () { if (!this._xhr) { return null; @@ -1777,23 +1198,12 @@ r.prototype = e.prototype, t.prototype = new r(); var result = this._xhr.getAllResponseHeaders(); return result ? result : ""; }; - /** - * @private - * 给指定的HTTP请求头赋值.在这之前,您必须确认已经调用 open() 方法打开了一个url. - * @param header 将要被赋值的请求头名称. - * @param value 给指定的请求头赋的值. - */ WebHttpRequest.prototype.setRequestHeader = function (header, value) { if (!this.headerObj) { this.headerObj = {}; } this.headerObj[header] = value; }; - /** - * @private - * 返回指定的响应头的值, 如果响应头还没被接受,或该响应头不存在,则返回"". - * @param header 要返回的响应头名称 - */ WebHttpRequest.prototype.getResponseHeader = function (header) { if (!this._xhr) { return null; @@ -1801,17 +1211,11 @@ r.prototype = e.prototype, t.prototype = new r(); var result = this._xhr.getResponseHeader(header); return result ? result : ""; }; - /** - * @private - */ WebHttpRequest.prototype.onTimeout = function () { var message = egret.sys.tr(1052, this._url); console.warn(message); this.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); }; - /** - * @private - */ WebHttpRequest.prototype.onReadyStateChange = function () { var xhr = this._xhr; if (xhr.readyState == 4) { @@ -1831,9 +1235,6 @@ r.prototype = e.prototype, t.prototype = new r(); }, 0); } }; - /** - * @private - */ WebHttpRequest.prototype.updateProgress = function (event) { if (event.lengthComputable) { egret.ProgressEvent.dispatchProgressEvent(this, egret.ProgressEvent.PROGRESS, event.loaded, event.total); @@ -1846,70 +1247,19 @@ r.prototype = e.prototype, t.prototype = new r(); egret.HttpRequest = WebHttpRequest; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { var winURL = window["URL"] || window["webkitURL"]; - /** - * @private - * ImageLoader 类可用于加载图像(JPG、PNG 或 GIF)文件。使用 load() 方法来启动加载。被加载的图像对象数据将存储在 ImageLoader.data 属性上 。 - */ var WebImageLoader = (function (_super) { __extends(WebImageLoader, _super); function WebImageLoader() { var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - * 使用 load() 方法加载成功的 BitmapData 图像数据。 - */ _this.data = null; - /** - * @private - * 当从其他站点加载一个图片时,指定是否启用跨域资源共享(CORS),默认值为null。 - * 可以设置为"anonymous","use-credentials"或null,设置为其他值将等同于"anonymous"。 - */ _this._crossOrigin = null; - /** - * @private - * 标记crossOrigin有没有被设置过,设置过之后使用设置的属性 - */ _this._hasCrossOriginSet = false; - /** - * @private - */ _this.currentImage = null; - /** - * @private - */ _this.request = null; return _this; } @@ -1924,17 +1274,9 @@ r.prototype = e.prototype, t.prototype = new r(); enumerable: true, configurable: true }); - /** - * @private - * 启动一次图像加载。注意:若之前已经调用过加载请求,重新调用 load() 将终止先前的请求,并开始新的加载。 - * @param url 要加载的图像文件的地址。 - */ WebImageLoader.prototype.load = function (url) { this.loadImage(url); }; - /** - * @private - */ WebImageLoader.prototype.loadImage = function (src) { var image = new Image(); this.data = null; @@ -1949,18 +1291,10 @@ r.prototype = e.prototype, t.prototype = new r(); image.crossOrigin = WebImageLoader.crossOrigin; } } - /*else { - if (image.hasAttribute("crossOrigin")) {//兼容猎豹 - image.removeAttribute("crossOrigin"); - } - }*/ image.onload = this.onImageComplete.bind(this); image.onerror = this.onLoadError.bind(this); image.src = src; }; - /** - * @private - */ WebImageLoader.prototype.onImageComplete = function (event) { var image = this.getImage(event); if (!image) { @@ -1972,9 +1306,6 @@ r.prototype = e.prototype, t.prototype = new r(); self.dispatchEventWith(egret.Event.COMPLETE); }, 0); }; - /** - * @private - */ WebImageLoader.prototype.onLoadError = function (event) { var image = this.getImage(event); if (!image) { @@ -1991,9 +1322,6 @@ r.prototype = e.prototype, t.prototype = new r(); self.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); }, 0); }; - /** - * @private - */ WebImageLoader.prototype.getImage = function (event) { var image = event.target; var url = image.src; @@ -2005,10 +1333,6 @@ r.prototype = e.prototype, t.prototype = new r(); this.currentImage = null; return image; }; - /** - * @private - * 指定是否启用跨域资源共享,如果ImageLoader实例有设置过crossOrigin属性将使用设置的属性 - */ WebImageLoader.crossOrigin = null; return WebImageLoader; }(egret.EventDispatcher)); @@ -2017,77 +1341,25 @@ r.prototype = e.prototype, t.prototype = new r(); egret.ImageLoader = WebImageLoader; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @classdesc - * @extends egret.StageText - * @private - */ var HTML5StageText = (function (_super) { __extends(HTML5StageText, _super); - /** - * @private - */ function HTML5StageText() { var _this = _super.call(this) || this; - /** - * @private - */ _this.textValue = ""; _this.onKeyboardComplete = _this.onKeyboardComplete.bind(_this); _this.onKeyboardInput = _this.onKeyboardInput.bind(_this); return _this; } - /** - * @private - * - * @param textfield - */ HTML5StageText.prototype.$setTextField = function (textfield) { this.$textfield = textfield; return true; }; - /** - * @private - * - */ HTML5StageText.prototype.$addToStage = function () { }; - /** - * @private - * - */ HTML5StageText.prototype.$show = function () { var info = { defaultValue: this.$textfield.text, @@ -2115,9 +1387,6 @@ r.prototype = e.prototype, t.prototype = new r(); this.$textfield.text = res.value; this.$hide(); }; - /** - * @private - */ HTML5StageText.prototype.$hide = function () { swan.offKeyboardComplete(); swan.offKeyboardConfirm(); @@ -2125,45 +1394,23 @@ r.prototype = e.prototype, t.prototype = new r(); swan.hideKeyboard(); this.dispatchEvent(new egret.Event("blur")); }; - /** - * @private - * - * @returns - */ HTML5StageText.prototype.$getText = function () { if (!this.textValue) { this.textValue = ""; } return this.textValue; }; - /** - * @private - * - * @param value - */ HTML5StageText.prototype.$setText = function (value) { this.textValue = value; - // this.resetText(); return true; }; - /** - * @private - */ HTML5StageText.prototype.$setColor = function (value) { return true; }; HTML5StageText.prototype.$onBlur = function () { }; - /** - * @private - * - */ HTML5StageText.prototype.$removeFromStage = function () { }; - /** - * 修改位置 - * @private - */ HTML5StageText.prototype.$resetStageText = function () { }; return HTML5StageText; @@ -2173,54 +1420,12 @@ r.prototype = e.prototype, t.prototype = new r(); egret.StageText = HTML5StageText; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var context = null; - /** - * @private - */ var fontCache = {}; - /** - * 测量文本在指定样式下的宽度。 - * @param text 要测量的文本内容。 - * @param fontFamily 字体名称 - * @param fontSize 字体大小 - * @param bold 是否粗体 - * @param italic 是否斜体 - */ function measureText(text, fontFamily, fontSize, bold, italic) { if (!context) { createContext(); @@ -2235,9 +1440,6 @@ r.prototype = e.prototype, t.prototype = new r(); context.font = font; return egret.sys.measureTextWith(context, text); } - /** - * @private - */ function createContext() { context = egret.sys.canvasHitTestBuffer.context; context.textAlign = "left"; @@ -2246,41 +1448,10 @@ r.prototype = e.prototype, t.prototype = new r(); egret.sys.measureText = measureText; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * 创建一个canvas。 - */ function __createCanvas__(width, height) { var canvas = egret.sys.createCanvas(width, height); var context = canvas.getContext("2d"); @@ -2310,10 +1481,6 @@ r.prototype = e.prototype, t.prototype = new r(); return canvas; } var sharedCanvas; - /** - * @private - * Canvas2D渲染缓冲 - */ var CanvasRenderBuffer = (function () { function CanvasRenderBuffer(width, height, root) { this.surface = egret.sys.createCanvasRenderBufferSurface(__createCanvas__, width, height, root); @@ -2325,10 +1492,6 @@ r.prototype = e.prototype, t.prototype = new r(); this.resize(width, height); } Object.defineProperty(CanvasRenderBuffer.prototype, "width", { - /** - * 渲染缓冲的宽度,以像素为单位。 - * @readOnly - */ get: function () { return this.surface.width; }, @@ -2336,50 +1499,27 @@ r.prototype = e.prototype, t.prototype = new r(); configurable: true }); Object.defineProperty(CanvasRenderBuffer.prototype, "height", { - /** - * 渲染缓冲的高度,以像素为单位。 - * @readOnly - */ get: function () { return this.surface.height; }, enumerable: true, configurable: true }); - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param width 改变后的宽 - * @param height 改变后的高 - * @param useMaxSize 若传入true,则将改变后的尺寸与已有尺寸对比,保留较大的尺寸。 - */ CanvasRenderBuffer.prototype.resize = function (width, height, useMaxSize) { egret.sys.resizeCanvasRenderBuffer(this, width, height, useMaxSize); }; - /** - * 获取指定区域的像素 - */ CanvasRenderBuffer.prototype.getPixels = function (x, y, width, height) { if (width === void 0) { width = 1; } if (height === void 0) { height = 1; } return this.context.getImageData(x, y, width, height).data; }; - /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如: "image/png","image/jpeg" - */ CanvasRenderBuffer.prototype.toDataURL = function (type, encoderOptions) { return this.surface.toDataURL(type, encoderOptions); }; - /** - * 清空缓冲区数据 - */ CanvasRenderBuffer.prototype.clear = function () { this.context.setTransform(1, 0, 0, 1, 0, 0); this.context.clearRect(0, 0, this.surface.width, this.surface.height); }; - /** - * 销毁绘制对象 - */ CanvasRenderBuffer.prototype.destroy = function () { this.surface.width = this.surface.height = 0; }; @@ -2389,90 +1529,34 @@ r.prototype = e.prototype, t.prototype = new r(); __reflect(CanvasRenderBuffer.prototype, "egret.baidugame.CanvasRenderBuffer", ["egret.sys.RenderBuffer"]); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided this the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var WebTouchHandler = (function (_super) { __extends(WebTouchHandler, _super); - /** - * @private - */ function WebTouchHandler(stage, canvas) { var _this = _super.call(this) || this; - /** - * @private - */ _this.onTouchBegin = function (event) { var location = _this.getLocation(event); _this.touch.onTouchBegin(location.x, location.y, event.identifier); }; - /** - * @private - */ _this.onTouchMove = function (event) { var location = _this.getLocation(event); _this.touch.onTouchMove(location.x, location.y, event.identifier); }; - /** - * @private - */ _this.onTouchEnd = function (event) { var location = _this.getLocation(event); _this.touch.onTouchEnd(location.x, location.y, event.identifier); }; - /** - * @private - */ _this.scaleX = 1; - /** - * @private - */ _this.scaleY = 1; - /** - * @private - */ _this.rotation = 0; _this.canvas = canvas; _this.touch = new egret.sys.TouchHandler(stage); _this.addTouchListener(); return _this; } - /** - * @private - * - */ WebTouchHandler.prototype.addTouchListener = function () { var self = this; self.canvas.addEventListener("touchstart", function (event) { @@ -2504,18 +1588,12 @@ r.prototype = e.prototype, t.prototype = new r(); self.prevent(event); }, false); }; - /** - * @private - */ WebTouchHandler.prototype.prevent = function (event) { event.stopPropagation(); if (event["isScroll"] != true && !this.canvas['userTyping']) { event.preventDefault(); } }; - /** - * @private - */ WebTouchHandler.prototype.getLocation = function (event) { var doc = document.documentElement; var box = this.canvas.getBoundingClientRect(); @@ -2535,21 +1613,11 @@ r.prototype = e.prototype, t.prototype = new r(); newy = newy / this.scaleY; return egret.$TempPoint.setTo(Math.round(newx), Math.round(newy)); }; - /** - * @private - * 更新屏幕当前的缩放比例,用于计算准确的点击位置。 - * @param scaleX 水平方向的缩放比例。 - * @param scaleY 垂直方向的缩放比例。 - */ WebTouchHandler.prototype.updateScaleMode = function (scaleX, scaleY, rotation) { this.scaleX = scaleX; this.scaleY = scaleY; this.rotation = rotation; }; - /** - * @private - * 更新同时触摸点的数量 - */ WebTouchHandler.prototype.$updateMaxTouches = function () { this.touch.$initMaxTouches(); }; @@ -2559,42 +1627,11 @@ r.prototype = e.prototype, t.prototype = new r(); __reflect(WebTouchHandler.prototype, "egret.baidugame.WebTouchHandler"); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { var isShow = true; - /** - * @private - */ baidugame.WebLifeCycleHandler = function (context) { if (swan.onShow) { swan.onShow(function () { @@ -2615,72 +1652,24 @@ r.prototype = e.prototype, t.prototype = new r(); }; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var AudioType = (function () { function AudioType() { } - /** - * @private - */ AudioType.WEB_AUDIO = 2; - /** - * @private - */ AudioType.HTML5_AUDIO = 3; return AudioType; }()); baidugame.AudioType = AudioType; __reflect(AudioType.prototype, "egret.baidugame.AudioType"); - /** - * html5兼容性配置 - * @private - */ var Html5Capatibility = (function (_super) { __extends(Html5Capatibility, _super); - /** - * @private - */ function Html5Capatibility() { return _super.call(this) || this; } - /** - * @private - * - */ Html5Capatibility.$init = function () { Html5Capatibility._canUseBlob = false; var audioType = Html5Capatibility._audioType; @@ -2698,21 +1687,13 @@ r.prototype = e.prototype, t.prototype = new r(); break; } }; - //当前浏览器版本是否支持blob Html5Capatibility._canUseBlob = false; - //当前浏览器版本是否支持webaudio Html5Capatibility._audioType = 0; return Html5Capatibility; }(egret.HashObject)); baidugame.Html5Capatibility = Html5Capatibility; __reflect(Html5Capatibility.prototype, "egret.baidugame.Html5Capatibility"); - /** - * @private - */ var currentPrefix = null; - /** - * @private - */ function getPrefixStyleName(name, element) { var header = ""; if (element != null) { @@ -2731,9 +1712,6 @@ r.prototype = e.prototype, t.prototype = new r(); return header + name.charAt(0).toUpperCase() + name.substring(1, name.length); } baidugame.getPrefixStyleName = getPrefixStyleName; - /** - * @private - */ function getPrefix(name, element) { if (name in element) { return ""; @@ -2751,70 +1729,23 @@ r.prototype = e.prototype, t.prototype = new r(); baidugame.getPrefix = getPrefix; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -// declare const swan: any; (function (egret) { var baidugame; (function (baidugame) { - /** - * 小游戏支持库版本号 - */ - baidugame.version = "0.2.8"; + baidugame.version = "0.2.9"; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - * 刷新所有Egret播放器的显示区域尺寸。仅当使用外部JavaScript代码动态修改了Egret容器大小时,需要手动调用此方法刷新显示区域。 - * 当网页尺寸发生改变时此方法会自动被调用。 - */ function updateAllScreens() { if (!isRunning) { return; } - // let containerList = document.querySelectorAll(".egret-player"); - // let length = containerList.length; - // for (let i = 0; i < length; i++) { - // let container = containerList[i]; - // let player = container["egret-player"]; window['player'].updateScreenSize(); - // } } var isRunning = false; - /** - * @private - * 网页加载完成,实例化页面中定义的Egret标签 - */ function runEgret(options) { if (isRunning) { return; @@ -2825,12 +1756,9 @@ r.prototype = e.prototype, t.prototype = new r(); } baidugame.Html5Capatibility._audioType = options.audioType; baidugame.Html5Capatibility.$init(); - // WebGL上下文参数自定义 if (options.renderMode == "webgl") { - // WebGL抗锯齿默认关闭,提升PC及某些平台性能 var antialias = options.antialias; baidugame.WebGLRenderContext.antialias = !!antialias; - // WebGLRenderContext.antialias = (typeof antialias == undefined) ? true : antialias; } egret.sys.CanvasRenderBuffer = baidugame.CanvasRenderBuffer; setRenderMode(options.renderMode); @@ -2842,7 +1770,6 @@ r.prototype = e.prototype, t.prototype = new r(); canvasScaleFactor = options.calculateCanvasScaleFactor(egret.sys.canvasHitTestBuffer.context); } else { - //based on : https://github.com/jondavidjohn/hidpi-canvas-polyfill var context = egret.sys.canvasHitTestBuffer.context; var backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || @@ -2861,13 +1788,6 @@ r.prototype = e.prototype, t.prototype = new r(); else if (!egret.sys.screenAdapter) { egret.sys.screenAdapter = new egret.sys.DefaultScreenAdapter(); } - // let list = document.querySelectorAll(".egret-player"); - // let length = list.length; - // for (let i = 0; i < length; i++) { - // let container = list[i]; - // let player = new WebPlayer(container, options); - // container["egret-player"] = player; - // } var container = {}; var player = new baidugame.WebPlayer(container, options); window['player'] = player; @@ -2877,10 +1797,6 @@ r.prototype = e.prototype, t.prototype = new r(); } }); } - /** - * 设置渲染模式。"auto","webgl","canvas" - * @param renderMode - */ function setRenderMode(renderMode) { if (renderMode === "webgl") { egret.Capabilities["renderMode" + ""] = "webgl"; @@ -2899,10 +1815,6 @@ r.prototype = e.prototype, t.prototype = new r(); egret.sys.canvasHitTestBuffer = egret.sys.customHitTestBuffer; } } - /** - * @private - * 启动心跳计时器。 - */ function startTicker(ticker) { var requestAnimationFrame = window["requestAnimationFrame"] || window["webkitRequestAnimationFrame"] || @@ -2943,48 +1855,13 @@ if (true) { } } egret.Capabilities["runtimeType" + ""] = "baidugame"; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var WebCapability = (function () { function WebCapability() { } - /** - * @private - * 检测系统属性 - */ WebCapability.detect = function () { var capabilities = egret.Capabilities; capabilities["isMobile" + ""] = true; @@ -3012,49 +1889,12 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; WebCapability.detect(); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var fpsText = new egret.TextField(); - /** - * @private - */ var logText = new egret.TextField(); - /** - * @private - */ var WebFps = (function (_super) { __extends(WebFps, _super); function WebFps(stage, showFPS, showLog, logFilter, styles) { @@ -3198,41 +2038,10 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; egret.FPSDisplay = WebFps; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ function getOption(key) { return ""; } @@ -3240,56 +2049,15 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; egret.getOption = getOption; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var WebExternalInterface = (function () { function WebExternalInterface() { } - /** - * @private - * @param functionName - * @param value - */ WebExternalInterface.call = function (functionName, value) { }; - /** - * @private - * @param functionName - * @param listener - */ WebExternalInterface.addCallback = function (functionName, listener) { }; return WebExternalInterface; @@ -3299,43 +2067,12 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; egret.ExternalInterface = WebExternalInterface; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { var sharedCanvas; var sharedContext; - /** - * @private - */ function convertImageToCanvas(texture, rect) { if (!sharedCanvas) { sharedCanvas = document.createElement("canvas"); @@ -3363,7 +2100,6 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; sharedCanvas.height = iHeight; if (egret.Capabilities.renderMode == "webgl") { var renderTexture = void 0; - //webgl下非RenderTexture纹理先画到RenderTexture if (!texture.$renderBuffer) { renderTexture = new egret.RenderTexture(); renderTexture.drawToTexture(new egret.Bitmap(texture)); @@ -3371,7 +2107,6 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; else { renderTexture = texture; } - //从RenderTexture中读取像素数据,填入canvas var pixels = renderTexture.$renderBuffer.getPixels(rect.x, rect.y, iWidth, iHeight); var x = 0; var y = 0; @@ -3403,9 +2138,6 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; return surface; } } - /** - * @private - */ function toDataURL(type, rect, encoderOptions) { try { var surface = convertImageToCanvas(this, rect); @@ -3417,9 +2149,6 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; } return null; } - /** - * 有些杀毒软件认为 saveToFile 可能是一个病毒文件 - */ function eliFoTevas(type, filePath, rect, encoderOptions) { } function getPixel32(x, y) { @@ -3429,10 +2158,8 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; function getPixels(x, y, width, height) { if (width === void 0) { width = 1; } if (height === void 0) { height = 1; } - //webgl环境下不需要转换成canvas获取像素信息 if (egret.Capabilities.renderMode == "webgl") { var renderTexture = void 0; - //webgl下非RenderTexture纹理先画到RenderTexture if (!this.$renderBuffer) { renderTexture = new egret.RenderTexture(); renderTexture.drawToTexture(new egret.Bitmap(this)); @@ -3440,7 +2167,6 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; else { renderTexture = this; } - //从RenderTexture中读取像素数据 var pixels = renderTexture.$renderBuffer.getPixels(x, y, width, height); return pixels; } @@ -3459,46 +2185,11 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; egret.Texture.prototype.getPixels = getPixels; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - * XML节点基类 - */ var XMLNode = (function () { - /** - * @private - */ function XMLNode(nodeType, parent) { this.nodeType = nodeType; this.parent = parent; @@ -3507,26 +2198,11 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; }()); baidugame.XMLNode = XMLNode; __reflect(XMLNode.prototype, "egret.baidugame.XMLNode"); - /** - * @private - * XML节点对象 - */ var XML = (function (_super) { __extends(XML, _super); - /** - * @private - */ function XML(localName, parent, prefix, namespace, name) { var _this = _super.call(this, 1, parent) || this; - /** - * @private - * 当前节点上的属性列表 - */ _this.attributes = {}; - /** - * @private - * 当前节点的子节点列表 - */ _this.children = []; _this.localName = localName; _this.prefix = prefix; @@ -3538,15 +2214,8 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; }(XMLNode)); baidugame.XML = XML; __reflect(XML.prototype, "egret.baidugame.XML"); - /** - * @private - * XML文本节点 - */ var XMLText = (function (_super) { __extends(XMLText, _super); - /** - * @private - */ function XMLText(text, parent) { var _this = _super.call(this, 3, parent) || this; _this.text = text; @@ -3557,11 +2226,6 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; baidugame.XMLText = XMLText; __reflect(XMLText.prototype, "egret.baidugame.XMLText"); var parser; - /** - * @private - * 解析字符串为XML对象 - * @param text 要解析的字符串 - */ function parse(text) { if (!parser) { if (!window["DOMParser"]) { @@ -3581,10 +2245,6 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; } return null; } - /** - * @private - * 解析一个节点 - */ function parseNode(node, parent) { if (node.localName == "parsererror") { throw new Error(node.textContent); @@ -3631,16 +2291,10 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var WebDeviceOrientation = (function (_super) { __extends(WebDeviceOrientation, _super); function WebDeviceOrientation() { var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ _this.onChange = function (e) { var event = new egret.OrientationEvent(egret.Event.CHANGE); event.beta = e.beta; @@ -3650,17 +2304,9 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; }; return _this; } - /** - * @private - * - */ WebDeviceOrientation.prototype.start = function () { window.addEventListener("deviceorientation", this.onChange); }; - /** - * @private - * - */ WebDeviceOrientation.prototype.stop = function () { window.removeEventListener("deviceorientation", this.onChange); }; @@ -3671,39 +2317,8 @@ egret.Capabilities["runtimeType" + ""] = "baidugame"; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { - /** - * @private - */ var WebGLUtils = (function () { function WebGLUtils() { } @@ -3730,7 +2345,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; gl.shaderSource(shader, shaderSrc); gl.compileShader(shader); if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { - //egret.info(gl.getShaderInfoLog(shader)); return null; } return shader; @@ -3754,7 +2368,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } if (webglTexture[egret.engine_default_empty_texture]) { if (true) { - //引擎默认的空白纹理,不允许删除 console.warn('deleteWebGLTexture:' + egret.engine_default_empty_texture); } return; @@ -3768,21 +2381,7 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; console.error('deleteWebGLTexture gl = ' + gl); } } - /*old - if (webglTexture && !webglTexture['engine_default_empty_texture']) { - const gl = webglTexture['glContext'] as WebGLRenderingContext;//bitmapData.glContext; - if (gl) { - gl.deleteTexture(webglTexture); - } - else { - console.error('deleteWebGLTexture gl = ' + gl); - } - } - */ }; - /** - * inspired by pixi.js - */ WebGLUtils.premultiplyTint = function (tint, alpha) { if (alpha === 1.0) { return (alpha * 255 << 24) + tint; @@ -3803,97 +2402,23 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; egret.WebGLUtils = WebGLUtils; __reflect(WebGLUtils.prototype, "egret.WebGLUtils"); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { - /** - * 转换 Image,Canvas,Video 为 Egret 框架内使用的 BitmapData 对象。 - * @param data 需要转换的对象,包括HTMLImageElement|HTMLCanvasElement|HTMLVideoElement - * @deprecated - */ function $toBitmapData(data) { data["hashCode"] = data["$hashCode"] = egret.$hashCount++; return data; } egret.$toBitmapData = $toBitmapData; })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var localStorage; (function (localStorage) { var swan; (function (swan) { - /** - * @private - * - * @param key - * @returns - */ function getItem(key) { return window.localStorage.getItem(key); } - /** - * @private - * - * @param key - * @param value - * @returns - */ function setItem(key, value) { try { window.localStorage.setItem(key, value); @@ -3904,18 +2429,9 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return false; } } - /** - * @private - * - * @param key - */ function removeItem(key) { window.localStorage.removeItem(key); } - /** - * @private - * - */ function clear() { window.localStorage.clear(); } @@ -3926,34 +2442,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; })(swan = localStorage.swan || (localStorage.swan = {})); })(localStorage = egret.localStorage || (egret.localStorage = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; @@ -4011,73 +2499,30 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - * 绘制指令管理器 - * 用来维护drawData数组 - */ var WebGLDrawCmdManager = (function () { function WebGLDrawCmdManager() { - /** - * 用于缓存绘制命令的数组 - */ this.drawData = []; this.drawDataLen = 0; } - /** - * 压入绘制矩形指令 - */ WebGLDrawCmdManager.prototype.pushDrawRect = function () { - if (this.drawDataLen == 0 || this.drawData[this.drawDataLen - 1].type != 1 /* RECT */) { + if (this.drawDataLen == 0 || this.drawData[this.drawDataLen - 1].type != 1) { var data = this.drawData[this.drawDataLen] || {}; - data.type = 1 /* RECT */; + data.type = 1; data.count = 0; this.drawData[this.drawDataLen] = data; this.drawDataLen++; } this.drawData[this.drawDataLen - 1].count += 2; }; - /** - * 压入绘制texture指令 - */ WebGLDrawCmdManager.prototype.pushDrawTexture = function (texture, count, filter, textureWidth, textureHeight) { if (count === void 0) { count = 2; } if (filter) { - // 目前有滤镜的情况下不会合并绘制 var data = this.drawData[this.drawDataLen] || {}; - data.type = 0 /* TEXTURE */; + data.type = 0; data.texture = texture; data.filter = filter; data.count = count; @@ -4087,9 +2532,9 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.drawDataLen++; } else { - if (this.drawDataLen == 0 || this.drawData[this.drawDataLen - 1].type != 0 /* TEXTURE */ || texture != this.drawData[this.drawDataLen - 1].texture || this.drawData[this.drawDataLen - 1].filter) { + if (this.drawDataLen == 0 || this.drawData[this.drawDataLen - 1].type != 0 || texture != this.drawData[this.drawDataLen - 1].texture || this.drawData[this.drawDataLen - 1].filter) { var data = this.drawData[this.drawDataLen] || {}; - data.type = 0 /* TEXTURE */; + data.type = 0; data.texture = texture; data.count = 0; this.drawData[this.drawDataLen] = data; @@ -4101,55 +2546,43 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; WebGLDrawCmdManager.prototype.pushChangeSmoothing = function (texture, smoothing) { texture["smoothing"] = smoothing; var data = this.drawData[this.drawDataLen] || {}; - data.type = 10 /* SMOOTHING */; + data.type = 10; data.texture = texture; data.smoothing = smoothing; this.drawData[this.drawDataLen] = data; this.drawDataLen++; }; - /** - * 压入pushMask指令 - */ WebGLDrawCmdManager.prototype.pushPushMask = function (count) { if (count === void 0) { count = 1; } var data = this.drawData[this.drawDataLen] || {}; - data.type = 2 /* PUSH_MASK */; + data.type = 2; data.count = count * 2; this.drawData[this.drawDataLen] = data; this.drawDataLen++; }; - /** - * 压入popMask指令 - */ WebGLDrawCmdManager.prototype.pushPopMask = function (count) { if (count === void 0) { count = 1; } var data = this.drawData[this.drawDataLen] || {}; - data.type = 3 /* POP_MASK */; + data.type = 3; data.count = count * 2; this.drawData[this.drawDataLen] = data; this.drawDataLen++; }; - /** - * 压入混色指令 - */ WebGLDrawCmdManager.prototype.pushSetBlend = function (value) { var len = this.drawDataLen; - // 有无遍历到有效绘图操作 var drawState = false; for (var i = len - 1; i >= 0; i--) { var data = this.drawData[i]; if (data) { - if (data.type == 0 /* TEXTURE */ || data.type == 1 /* RECT */) { + if (data.type == 0 || data.type == 1) { drawState = true; } - // 如果与上一次blend操作之间无有效绘图,上一次操作无效 - if (!drawState && data.type == 4 /* BLEND */) { + if (!drawState && data.type == 4) { this.drawData.splice(i, 1); this.drawDataLen--; continue; } - // 如果与上一次blend操作重复,本次操作无效 - if (data.type == 4 /* BLEND */) { + if (data.type == 4) { if (data.value == value) { return; } @@ -4160,75 +2593,53 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } } var _data = this.drawData[this.drawDataLen] || {}; - _data.type = 4 /* BLEND */; + _data.type = 4; _data.value = value; this.drawData[this.drawDataLen] = _data; this.drawDataLen++; }; - /* - * 压入resize render target命令 - */ WebGLDrawCmdManager.prototype.pushResize = function (buffer, width, height) { var data = this.drawData[this.drawDataLen] || {}; - data.type = 5 /* RESIZE_TARGET */; + data.type = 5; data.buffer = buffer; data.width = width; data.height = height; this.drawData[this.drawDataLen] = data; this.drawDataLen++; }; - /* - * 压入clear color命令 - */ WebGLDrawCmdManager.prototype.pushClearColor = function () { var data = this.drawData[this.drawDataLen] || {}; - data.type = 6 /* CLEAR_COLOR */; + data.type = 6; this.drawData[this.drawDataLen] = data; this.drawDataLen++; }; - /** - * 压入激活buffer命令 - */ WebGLDrawCmdManager.prototype.pushActivateBuffer = function (buffer) { var len = this.drawDataLen; - // 有无遍历到有效绘图操作 var drawState = false; for (var i = len - 1; i >= 0; i--) { var data = this.drawData[i]; if (data) { - if (data.type != 4 /* BLEND */ && data.type != 7 /* ACT_BUFFER */) { + if (data.type != 4 && data.type != 7) { drawState = true; } - // 如果与上一次buffer操作之间无有效绘图,上一次操作无效 - if (!drawState && data.type == 7 /* ACT_BUFFER */) { + if (!drawState && data.type == 7) { this.drawData.splice(i, 1); this.drawDataLen--; continue; } - // 如果与上一次buffer操作重复,本次操作无效 - // if(data.type == DRAWABLE_TYPE.ACT_BUFFER) { - // if(data.buffer == buffer) { - // return; - // } else { - // break; - // } - // } } } var _data = this.drawData[this.drawDataLen] || {}; - _data.type = 7 /* ACT_BUFFER */; + _data.type = 7; _data.buffer = buffer; _data.width = buffer.rootRenderTarget.width; _data.height = buffer.rootRenderTarget.height; this.drawData[this.drawDataLen] = _data; this.drawDataLen++; }; - /* - * 压入enabel scissor命令 - */ WebGLDrawCmdManager.prototype.pushEnableScissor = function (x, y, width, height) { var data = this.drawData[this.drawDataLen] || {}; - data.type = 8 /* ENABLE_SCISSOR */; + data.type = 8; data.x = x; data.y = y; data.width = width; @@ -4236,18 +2647,12 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.drawData[this.drawDataLen] = data; this.drawDataLen++; }; - /* - * 压入disable scissor命令 - */ WebGLDrawCmdManager.prototype.pushDisableScissor = function () { var data = this.drawData[this.drawDataLen] || {}; - data.type = 9 /* DISABLE_SCISSOR */; + data.type = 9; this.drawData[this.drawDataLen] = data; this.drawDataLen++; }; - /** - * 清空命令数组 - */ WebGLDrawCmdManager.prototype.clear = function () { for (var i = 0; i < this.drawDataLen; i++) { var data = this.drawData[i]; @@ -4255,7 +2660,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; data.count = 0; data.texture = null; data.filter = null; - //data.uv = null; data.value = ""; data.buffer = null; data.width = 0; @@ -4274,61 +2678,16 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; __reflect(WebGLDrawCmdManager.prototype, "egret.baidugame.WebGLDrawCmdManager"); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - * 顶点数组管理对象 - * 用来维护顶点数组 - */ var WebGLVertexArrayObject = (function () { function WebGLVertexArrayObject() { - /*定义顶点格式 - * (x: 8 * 4 = 32) + (y: 8 * 4 = 32) + (u: 8 * 4 = 32) + (v: 8 * 4 = 32) + (tintcolor: 8 * 4 = 32) = (8 * 4 = 32) * (x + y + u + v + tintcolor: 5); - */ this.vertSize = 5; this.vertByteSize = this.vertSize * 4; - /* - *最多单次提交maxQuadsCount这么多quad - */ this.maxQuadsCount = 2048; - /* - *quad = 4个Vertex - */ this.maxVertexCount = this.maxQuadsCount * 4; - /* - *配套的Indices = quad * 6. - */ this.maxIndicesCount = this.maxQuadsCount * 6; this.vertices = null; this.indices = null; @@ -4336,30 +2695,15 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.vertexIndex = 0; this.indexIndex = 0; this.hasMesh = false; - /* - * refactor: - */ this._vertices = null; this._verticesFloat32View = null; this._verticesUint32View = null; - //old var numVerts = this.maxVertexCount * this.vertSize; this.vertices = new Float32Array(numVerts); - /// this._vertices = new ArrayBuffer(this.maxVertexCount * this.vertByteSize); this._verticesFloat32View = new Float32Array(this._vertices); this._verticesUint32View = new Uint32Array(this._vertices); this.vertices = this._verticesFloat32View; - //索引缓冲,最大索引数 - /* - 0-------1 - | | - | | - 3-------2 - 0->1->2 - 0->2->3 - 两个三角形 - */ var maxIndicesCount = this.maxIndicesCount; this.indices = new Uint16Array(maxIndicesCount); this.indicesForMesh = new Uint16Array(maxIndicesCount); @@ -4372,39 +2716,23 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.indices[i + 5] = j + 3; } } - /** - * 是否达到最大缓存数量 - */ WebGLVertexArrayObject.prototype.reachMaxSize = function (vertexCount, indexCount) { if (vertexCount === void 0) { vertexCount = 4; } if (indexCount === void 0) { indexCount = 6; } return this.vertexIndex > this.maxVertexCount - vertexCount || this.indexIndex > this.maxIndicesCount - indexCount; }; - /** - * 获取缓存完成的顶点数组 - */ WebGLVertexArrayObject.prototype.getVertices = function () { var view = this.vertices.subarray(0, this.vertexIndex * this.vertSize); return view; }; - /** - * 获取缓存完成的索引数组 - */ WebGLVertexArrayObject.prototype.getIndices = function () { return this.indices; }; - /** - * 获取缓存完成的mesh索引数组 - */ WebGLVertexArrayObject.prototype.getMeshIndices = function () { return this.indicesForMesh; }; - /** - * 切换成mesh索引缓存方式 - */ WebGLVertexArrayObject.prototype.changeToMeshIndices = function () { if (!this.hasMesh) { - // 拷贝默认index信息到for mesh中 for (var i = 0, l = this.indexIndex; i < l; ++i) { this.indicesForMesh[i] = this.indices[i]; } @@ -4414,35 +2742,14 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; WebGLVertexArrayObject.prototype.isMesh = function () { return this.hasMesh; }; - /** - * 默认构成矩形 - */ - // private defaultMeshVertices = [0, 0, 1, 0, 1, 1, 0, 1]; - // private defaultMeshUvs = [ - // 0, 0, - // 1, 0, - // 1, 1, - // 0, 1 - // ]; - // private defaultMeshIndices = [0, 1, 2, 0, 2, 3]; - /** - * 缓存一组顶点 - */ WebGLVertexArrayObject.prototype.cacheArrays = function (buffer, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight, textureSourceWidth, textureSourceHeight, meshUVs, meshVertices, meshIndices, rotated) { var alpha = buffer.globalAlpha; - /* - * 混入tintcolor => alpha - */ alpha = Math.min(alpha, 1.0); var globalTintColor = buffer.globalTintColor || 0xFFFFFF; var currentTexture = buffer.currentTexture; alpha = ((alpha < 1.0 && currentTexture && currentTexture[egret.UNPACK_PREMULTIPLY_ALPHA_WEBGL]) ? egret.WebGLUtils.premultiplyTint(globalTintColor, alpha) : globalTintColor + (alpha * 255 << 24)); - /* - 临时测试 - */ - //计算出绘制矩阵,之后把矩阵还原回之前的 var locWorldTransform = buffer.globalMatrix; var a = locWorldTransform.a; var b = locWorldTransform.b; @@ -4473,11 +2780,9 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } } if (meshVertices) { - // 计算索引位置与赋值 var vertices = this.vertices; var verticesUint32View = this._verticesUint32View; var index = this.vertexIndex * this.vertSize; - // 缓存顶点数组 var i = 0, iD = 0, l = 0; var u = 0, v = 0, x = 0, y = 0; for (i = 0, l = meshUVs.length; i < l; i += 2) { @@ -4486,10 +2791,8 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; y = meshVertices[i + 1]; u = meshUVs[i]; v = meshUVs[i + 1]; - // xy vertices[iD + 0] = a * x + c * y + tx; vertices[iD + 1] = b * x + d * y + ty; - // uv if (rotated) { vertices[iD + 2] = (sourceX + (1.0 - v) * sourceHeight) / textureSourceWidth; vertices[iD + 3] = (sourceY + u * sourceWidth) / textureSourceHeight; @@ -4498,10 +2801,8 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; vertices[iD + 2] = (sourceX + u * sourceWidth) / textureSourceWidth; vertices[iD + 3] = (sourceY + v * sourceHeight) / textureSourceHeight; } - // alpha verticesUint32View[iD + 4] = alpha; } - // 缓存索引数组 if (this.hasMesh) { for (var i_1 = 0, l_1 = meshIndices.length; i_1 < l_1; ++i_1) { this.indicesForMesh[this.indexIndex + i_1] = meshIndices[i_1] + this.vertexIndex; @@ -4524,76 +2825,51 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; var temp = sourceWidth; sourceWidth = sourceHeight / width; sourceHeight = temp / height; - // xy vertices[index++] = tx; vertices[index++] = ty; - // uv vertices[index++] = sourceWidth + sourceX; vertices[index++] = sourceY; - // alpha verticesUint32View[index++] = alpha; - // xy vertices[index++] = a * w + tx; vertices[index++] = b * w + ty; - // uv vertices[index++] = sourceWidth + sourceX; vertices[index++] = sourceHeight + sourceY; - // alpha verticesUint32View[index++] = alpha; - // xy vertices[index++] = a * w + c * h + tx; vertices[index++] = d * h + b * w + ty; - // uv vertices[index++] = sourceX; vertices[index++] = sourceHeight + sourceY; - // alpha verticesUint32View[index++] = alpha; - // xy vertices[index++] = c * h + tx; vertices[index++] = d * h + ty; - // uv vertices[index++] = sourceX; vertices[index++] = sourceY; - // alpha verticesUint32View[index++] = alpha; } else { sourceWidth = sourceWidth / width; sourceHeight = sourceHeight / height; - // xy vertices[index++] = tx; vertices[index++] = ty; - // uv vertices[index++] = sourceX; vertices[index++] = sourceY; - // alpha verticesUint32View[index++] = alpha; - // xy vertices[index++] = a * w + tx; vertices[index++] = b * w + ty; - // uv vertices[index++] = sourceWidth + sourceX; vertices[index++] = sourceY; - // alpha verticesUint32View[index++] = alpha; - // xy vertices[index++] = a * w + c * h + tx; vertices[index++] = d * h + b * w + ty; - // uv vertices[index++] = sourceWidth + sourceX; vertices[index++] = sourceHeight + sourceY; - // alpha verticesUint32View[index++] = alpha; - // xy vertices[index++] = c * h + tx; vertices[index++] = d * h + ty; - // uv vertices[index++] = sourceX; vertices[index++] = sourceHeight + sourceY; - // alpha verticesUint32View[index++] = alpha; } - // 缓存索引数组 if (this.hasMesh) { var indicesForMesh = this.indicesForMesh; indicesForMesh[this.indexIndex + 0] = 0 + this.vertexIndex; @@ -4618,58 +2894,21 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; __reflect(WebGLVertexArrayObject.prototype, "egret.baidugame.WebGLVertexArrayObject"); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - * WebGLRenderTarget - * A WebGL render target with a frame buffer and texture - */ var WebGLRenderTarget = (function (_super) { __extends(WebGLRenderTarget, _super); function WebGLRenderTarget(gl, width, height) { var _this = _super.call(this) || this; _this.clearColor = [0, 0, 0, 0]; - /** - * If frame buffer is enabled, the default is true - */ _this.useFrameBuffer = true; _this.gl = gl; _this._resize(width, height); return _this; } WebGLRenderTarget.prototype._resize = function (width, height) { - // Chrome alerts if the size is 0 width = width || 1; height = height || 1; if (width < 1) { @@ -4693,7 +2932,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; if (this.frameBuffer) { gl.bindTexture(gl.TEXTURE_2D, this.texture); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - // gl.bindTexture(gl.TEXTURE_2D, null); } if (this.stencilBuffer) { gl.deleteRenderbuffer(this.stencilBuffer); @@ -4720,21 +2958,8 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } }; WebGLRenderTarget.prototype.createTexture = function () { - //就是创建空的纹理 var webglrendercontext = baidugame.WebGLRenderContext.getInstance(0, 0); return egret.sys._createTexture(webglrendercontext, this.width, this.height, null); - /* - const gl = this.gl; - const texture: WebGLTexture = gl.createTexture(); - texture[glContext] = gl; - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - return texture; - */ }; WebGLRenderTarget.prototype.clear = function (bind) { var gl = this.gl; @@ -4755,8 +2980,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; gl.bindRenderbuffer(gl.RENDERBUFFER, this.stencilBuffer); gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, this.width, this.height); gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, this.stencilBuffer); - // Is unbundling a bug here? - // gl.bindFramebuffer(gl.FRAMEBUFFER, null); }; WebGLRenderTarget.prototype.dispose = function () { egret.WebGLUtils.deleteWebGLTexture(this.texture); @@ -4767,54 +2990,18 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; __reflect(WebGLRenderTarget.prototype, "egret.baidugame.WebGLRenderTarget"); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - //TO DO var debugLogCompressedTextureNotSupported = {}; - /** - * @private - * WebGL上下文对象,提供简单的绘图接口 - * 抽象出此类,以实现共用一个context - */ var WebGLRenderContext = (function () { function WebGLRenderContext(width, height) { - // this._defaultEmptyTexture = null; this.glID = null; this.projectionX = NaN; this.projectionY = NaN; this.contextLost = false; - //refactor this._supportedCompressedTextureInfo = []; this.$scissorState = false; this.vertSize = 5; @@ -4840,40 +3027,26 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.instance = new WebGLRenderContext(width, height); return this.instance; }; - /** - * 推入一个RenderBuffer并绑定 - */ WebGLRenderContext.prototype.pushBuffer = function (buffer) { this.$bufferStack.push(buffer); if (buffer != this.currentBuffer) { if (this.currentBuffer) { - // this.$drawWebGL(); } this.drawCmdManager.pushActivateBuffer(buffer); } this.currentBuffer = buffer; }; - /** - * 推出一个RenderBuffer并绑定上一个RenderBuffer - */ WebGLRenderContext.prototype.popBuffer = function () { - // 如果只剩下一个buffer,则不执行pop操作 - // 保证舞台buffer永远在最开始 if (this.$bufferStack.length <= 1) { return; } var buffer = this.$bufferStack.pop(); var lastBuffer = this.$bufferStack[this.$bufferStack.length - 1]; - // 重新绑定 if (buffer != lastBuffer) { - // this.$drawWebGL(); this.drawCmdManager.pushActivateBuffer(lastBuffer); } this.currentBuffer = lastBuffer; }; - /** - * 启用RenderBuffer - */ WebGLRenderContext.prototype.activateBuffer = function (buffer, width, height) { buffer.rootRenderTarget.activate(); if (!this.bindIndices) { @@ -4883,25 +3056,15 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; buffer.restoreScissor(); this.onResize(width, height); }; - /** - * 上传顶点数据 - */ WebGLRenderContext.prototype.uploadVerticesArray = function (array) { var gl = this.context; gl.bufferData(gl.ARRAY_BUFFER, array, gl.STREAM_DRAW); - // gl.bufferSubData(gl.ARRAY_BUFFER, 0, array); }; - /** - * 上传索引数据 - */ WebGLRenderContext.prototype.uploadIndicesArray = function (array) { var gl = this.context; gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, array, gl.STATIC_DRAW); this.bindIndices = true; }; - /** - * 销毁绘制对象 - */ WebGLRenderContext.prototype.destroy = function () { this.surface.width = this.surface.height = 0; }; @@ -4914,43 +3077,11 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.context.viewport(0, 0, width, height); } }; - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param width 改变后的宽 - * @param height 改变后的高 - * @param useMaxSize 若传入true,则将改变后的尺寸与已有尺寸对比,保留较大的尺寸。 - */ WebGLRenderContext.prototype.resize = function (width, height, useMaxSize) { egret.sys.resizeContext(this, width, height, useMaxSize); - /* - let surface = this.surface; - if (useMaxSize) { - if (surface.width < width) { - surface.width = width; - } - if (surface.height < height) { - surface.height = height; - } - } - else { - if (surface.width != width) { - surface.width = width; - } - if (surface.height != height) { - surface.height = height; - } - } - - this.onResize(); - */ }; - WebGLRenderContext.prototype._buildSupportedCompressedTextureInfo = function (/*gl: WebGLRenderingContext, compressedTextureExNames: string[],*/ extensions) { - // if (compressedTextureExNames.length === 0) { - // return []; - // } + WebGLRenderContext.prototype._buildSupportedCompressedTextureInfo = function (extensions) { var returnValue = []; - // for (const exName of compressedTextureExNames) { - // const extension = gl.getExtension(exName); for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { var extension = extensions_1[_i]; if (!extension) { @@ -4960,11 +3091,9 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; extensionName: extension.name, supportedFormats: [] }; - // for (var key in extension) { info.supportedFormats.push([key, extension[key]]); } - // if (true) { if (info.supportedFormats.length === 0) { console.error('buildSupportedCompressedTextureInfo failed = ' + extension.name); @@ -4987,36 +3116,18 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.getWebGLContext(); var gl = this.context; this.$maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); - //refactor - // this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc'); - // this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc'); - // this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'); - // this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1'); - // this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') || - // this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3 - // const compressedTextureExNames = [ - // 'WEBGL_compressed_texture_pvrtc', 'WEBKIT_WEBGL_compressed_texture_pvrtc', - // 'WEBGL_compressed_texture_etc1', 'WEBKIT_WEBGL_compressed_texture_etc1', - // 'WEBGL_compressed_texture_etc', 'WEBKIT_WEBGL_compressed_texture_etc', - // 'WEBGL_compressed_texture_astc', 'WEBKIT_WEBGL_compressed_texture_astc', - // 'WEBGL_compressed_texture_s3tc', 'WEBKIT_WEBGL_compressed_texture_s3tc', - // 'WEBGL_compressed_texture_es3_0']; - // this.pvrtc = gl.getExtension('WEBGL_compressed_texture_pvrtc') || gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'); if (this.pvrtc) { this.pvrtc.name = 'WEBGL_compressed_texture_pvrtc'; } - // this.etc1 = gl.getExtension('WEBGL_compressed_texture_etc1') || gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1'); if (this.etc1) { this.etc1.name = 'WEBGL_compressed_texture_etc1'; } - // egret.Capabilities.supportedCompressedTexture = egret.Capabilities.supportedCompressedTexture || {}; egret.Capabilities.supportedCompressedTexture.pvrtc = !!this.pvrtc; egret.Capabilities.supportedCompressedTexture.etc1 = !!this.etc1; - // - this._supportedCompressedTextureInfo = this._buildSupportedCompressedTextureInfo(/*this.context, compressedTextureExNames,*/ [this.etc1, this.pvrtc]); + this._supportedCompressedTextureInfo = this._buildSupportedCompressedTextureInfo([this.etc1, this.pvrtc]); }; WebGLRenderContext.prototype.handleContextLost = function () { this.contextLost = true; @@ -5026,28 +3137,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.contextLost = false; }; WebGLRenderContext.prototype.getWebGLContext = function () { - /* - let options = { - antialias: WebGLRenderContext.antialias, - stencil: true//设置可以使用模板(用于不规则遮罩) - }; - let gl: any; - //todo 是否使用chrome源码names - //let contextNames = ["moz-webgl", "webkit-3d", "experimental-webgl", "webgl", "3d"]; - let names = ["webgl", "experimental-webgl"]; - for (let i = 0; i < names.length; i++) { - try { - gl = this.surface.getContext(names[i], options); - } catch (e) { - } - if (gl) { - break; - } - } - if (!gl) { - $error(1021); - } - */ var gl = egret.sys.getContextWebGL(this.surface); this.setContext(gl); }; @@ -5059,64 +3148,35 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; gl.disable(gl.CULL_FACE); gl.enable(gl.BLEND); gl.colorMask(true, true, true, true); - // 目前只使用0号材质单元,默认开启 gl.activeTexture(gl.TEXTURE0); }; - /** - * 开启模版检测 - */ WebGLRenderContext.prototype.enableStencilTest = function () { var gl = this.context; gl.enable(gl.STENCIL_TEST); }; - /** - * 关闭模版检测 - */ WebGLRenderContext.prototype.disableStencilTest = function () { var gl = this.context; gl.disable(gl.STENCIL_TEST); }; - /** - * 开启scissor检测 - */ WebGLRenderContext.prototype.enableScissorTest = function (rect) { var gl = this.context; gl.enable(gl.SCISSOR_TEST); gl.scissor(rect.x, rect.y, rect.width, rect.height); }; - /** - * 关闭scissor检测 - */ WebGLRenderContext.prototype.disableScissorTest = function () { var gl = this.context; gl.disable(gl.SCISSOR_TEST); }; - /** - * 获取像素信息 - */ WebGLRenderContext.prototype.getPixels = function (x, y, width, height, pixels) { var gl = this.context; gl.readPixels(x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels); }; - /** - * 创建一个WebGLTexture - */ WebGLRenderContext.prototype.createTexture = function (bitmapData) { return egret.sys.createTexture(this, bitmapData); }; - /* - * TO DO - */ WebGLRenderContext.prototype.checkCompressedTextureInternalFormat = function (supportedCompressedTextureInfo, internalFormat) { - //width: number, height: number max ? for (var i = 0, length_1 = supportedCompressedTextureInfo.length; i < length_1; ++i) { var ss = supportedCompressedTextureInfo[i]; - // const formats = ss._COMPRESSED_TEXTURE_FORMATS_; - // for (let j = 0, length = formats.length; j < length; ++j) { - // if (formats[j] === internalFormat) { - // return true; - // } - // } var supportedFormats = ss.supportedFormats; for (var j = 0, length_2 = supportedFormats.length; j < length_2; ++j) { if (supportedFormats[j][1] === internalFormat) { @@ -5126,9 +3186,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } return false; }; - /* - * TO DO - */ WebGLRenderContext.prototype.$debugLogCompressedTextureNotSupported = function (supportedCompressedTextureInfo, internalFormat) { if (!debugLogCompressedTextureNotSupported[internalFormat]) { debugLogCompressedTextureNotSupported[internalFormat] = true; @@ -5145,14 +3202,12 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } } }; - // WebGLRenderContext.prototype.createCompressedTexture = function (data, width, height, levels, internalFormat) { var checkSupported = this.checkCompressedTextureInternalFormat(this._supportedCompressedTextureInfo, internalFormat); if (!checkSupported) { this.$debugLogCompressedTextureNotSupported(this._supportedCompressedTextureInfo, internalFormat); return this.defaultEmptyTexture; } - /// var gl = this.context; var texture = gl.createTexture(); if (!texture) { @@ -5172,9 +3227,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; gl.bindTexture(gl.TEXTURE_2D, null); return texture; }; - /** - * 更新材质的bitmapData - */ WebGLRenderContext.prototype.updateTexture = function (texture, bitmapData) { var gl = this.context; gl.bindTexture(gl.TEXTURE_2D, texture); @@ -5185,7 +3237,7 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; if (!this._defaultEmptyTexture) { var size = 16; var canvas = egret.sys.createCanvas(size, size); - var context = egret.sys.getContext2d(canvas); //canvas.getContext('2d'); + var context = egret.sys.getContext2d(canvas); context.fillStyle = 'white'; context.fillRect(0, 0, size, size); this._defaultEmptyTexture = this.createTexture(canvas); @@ -5204,7 +3256,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; else if (bitmapData.hasCompressed2d()) { var compressedData = bitmapData.getCompressed2dTextureData(); bitmapData.webGLTexture = this.createCompressedTexture(compressedData.byteArray, compressedData.width, compressedData.height, compressedData.level, compressedData.glInternalFormat); - /// var etcAlphaMask = bitmapData.etcAlphaMask; if (etcAlphaMask) { var maskTexture = this.getWebGLTexture(etcAlphaMask); @@ -5215,22 +3266,17 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } if (bitmapData.$deleteSource && bitmapData.webGLTexture) { if (bitmapData.source) { - // WeChat Memory leakage bug bitmapData.source.src = ''; bitmapData.source = null; } bitmapData.clearCompressedTextureData(); } if (bitmapData.webGLTexture) { - //todo 默认值 bitmapData.webGLTexture["smoothing"] = true; } } return bitmapData.webGLTexture; }; - /** - * 清除矩形区域 - */ WebGLRenderContext.prototype.clearRect = function (x, y, width, height) { if (x != 0 || y != 0 || width != this.surface.width || height != this.surface.height) { var buffer = this.currentBuffer; @@ -5261,15 +3307,9 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.clear(); } }; - /** - * 设置混色 - */ WebGLRenderContext.prototype.setGlobalCompositeOperation = function (value) { this.drawCmdManager.pushSetBlend(value); }; - /** - * 绘制图片,image参数可以是BitmapData或者renderTarget - */ WebGLRenderContext.prototype.drawImage = function (image, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight, imageSourceWidth, imageSourceHeight, rotated, smoothing) { var buffer = this.currentBuffer; if (this.contextLost || !image || !buffer) { @@ -5279,13 +3319,12 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; var offsetX; var offsetY; if (image["texture"] || (image.source && image.source["texture"])) { - // 如果是render target texture = image["texture"] || image.source["texture"]; buffer.saveTransform(); offsetX = buffer.$offsetX; offsetY = buffer.$offsetY; buffer.useOffset(); - buffer.transform(1, 0, 0, -1, 0, destHeight + destY * 2); // 翻转 + buffer.transform(1, 0, 0, -1, 0, destHeight + destY * 2); } else if (!image.source && !image.webGLTexture) { return; @@ -5303,9 +3342,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; buffer.restoreTransform(); } }; - /** - * 绘制Mesh - */ WebGLRenderContext.prototype.drawMesh = function (image, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight, imageSourceWidth, imageSourceHeight, meshUVs, meshVertices, meshIndices, bounds, rotated, smoothing) { var buffer = this.currentBuffer; if (this.contextLost || !image || !buffer) { @@ -5315,13 +3351,12 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; var offsetX; var offsetY; if (image["texture"] || (image.source && image.source["texture"])) { - // 如果是render target texture = image["texture"] || image.source["texture"]; buffer.saveTransform(); offsetX = buffer.$offsetX; offsetY = buffer.$offsetY; buffer.useOffset(); - buffer.transform(1, 0, 0, -1, 0, destHeight + destY * 2); // 翻转 + buffer.transform(1, 0, 0, -1, 0, destHeight + destY * 2); } else if (!image.source && !image.webGLTexture) { return; @@ -5339,9 +3374,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; buffer.restoreTransform(); } }; - /** - * 绘制材质 - */ WebGLRenderContext.prototype.drawTexture = function (texture, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight, textureWidth, textureHeight, meshUVs, meshVertices, meshIndices, bounds, rotated, smoothing) { var buffer = this.currentBuffer; if (this.contextLost || !texture || !buffer) { @@ -5364,14 +3396,10 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.vao.changeToMeshIndices(); } var count = meshIndices ? meshIndices.length / 3 : 2; - // 应用$filter,因为只可能是colorMatrixFilter,最后两个参数可不传 this.drawCmdManager.pushDrawTexture(texture, count, this.$filter, textureWidth, textureHeight); buffer.currentTexture = texture; this.vao.cacheArrays(buffer, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight, textureWidth, textureHeight, meshUVs, meshVertices, meshIndices, rotated); }; - /** - * 绘制矩形(仅用于遮罩擦除等) - */ WebGLRenderContext.prototype.drawRect = function (x, y, width, height) { var buffer = this.currentBuffer; if (this.contextLost || !buffer) { @@ -5384,9 +3412,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; buffer.currentTexture = null; this.vao.cacheArrays(buffer, 0, 0, width, height, x, y, width, height, width, height); }; - /** - * 绘制遮罩 - */ WebGLRenderContext.prototype.pushMask = function (x, y, width, height) { var buffer = this.currentBuffer; if (this.contextLost || !buffer) { @@ -5400,9 +3425,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; buffer.currentTexture = null; this.vao.cacheArrays(buffer, 0, 0, width, height, x, y, width, height, width, height); }; - /** - * 恢复遮罩 - */ WebGLRenderContext.prototype.popMask = function () { var buffer = this.currentBuffer; if (this.contextLost || !buffer) { @@ -5416,23 +3438,14 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; buffer.currentTexture = null; this.vao.cacheArrays(buffer, 0, 0, mask.width, mask.height, mask.x, mask.y, mask.width, mask.height, mask.width, mask.height); }; - /** - * 清除颜色缓存 - */ WebGLRenderContext.prototype.clear = function () { this.drawCmdManager.pushClearColor(); }; - /** - * 开启scissor test - */ WebGLRenderContext.prototype.enableScissor = function (x, y, width, height) { var buffer = this.currentBuffer; this.drawCmdManager.pushEnableScissor(x, y, width, height); buffer.$hasScissor = true; }; - /** - * 关闭scissor test - */ WebGLRenderContext.prototype.disableScissor = function () { var buffer = this.currentBuffer; this.drawCmdManager.pushDisableScissor(); @@ -5443,7 +3456,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return; } this.uploadVerticesArray(this.vao.getVertices()); - // 有mesh,则使用indicesForMesh if (this.vao.isMesh()) { this.uploadIndicesArray(this.vao.getMeshIndices()); } @@ -5452,27 +3464,21 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; for (var i = 0; i < length; i++) { var data = this.drawCmdManager.drawData[i]; offset = this.drawData(data, offset); - // 计算draw call - if (data.type == 7 /* ACT_BUFFER */) { + if (data.type == 7) { this.activatedBuffer = data.buffer; } - if (data.type == 0 /* TEXTURE */ || data.type == 1 /* RECT */ || data.type == 2 /* PUSH_MASK */ || data.type == 3 /* POP_MASK */) { + if (data.type == 0 || data.type == 1 || data.type == 2 || data.type == 3) { if (this.activatedBuffer && this.activatedBuffer.$computeDrawCall) { this.activatedBuffer.$drawCalls++; } } } - // 切换回默认indices if (this.vao.isMesh()) { this.uploadIndicesArray(this.vao.getIndices()); } - // 清空数据 this.drawCmdManager.clear(); this.vao.clear(); }; - /** - * 执行绘制命令 - */ WebGLRenderContext.prototype.drawData = function (data, offset) { if (!data) { return; @@ -5481,8 +3487,7 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; var program; var filter = data.filter; switch (data.type) { - case 0 /* TEXTURE */: - //这段的切换可以优化 + case 0: if (filter) { if (filter.type === "custom") { program = baidugame.EgretWebGLProgram.getProgram(gl, filter.$vertexSrc, filter.$fragmentSrc, filter.$shaderKey); @@ -5510,7 +3515,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; else { if (data.texture[egret.etc_alpha_mask]) { program = baidugame.EgretWebGLProgram.getProgram(gl, baidugame.EgretShaderLib.default_vert, baidugame.EgretShaderLib.texture_etc_alphamask_frag, egret.etc_alpha_mask); - ///need refactor gl.activeTexture(gl.TEXTURE1); gl.bindTexture(gl.TEXTURE_2D, data.texture[egret.etc_alpha_mask]); } @@ -5522,32 +3526,32 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.syncUniforms(program, filter, data.textureWidth, data.textureHeight); offset += this.drawTextureElements(data, offset); break; - case 1 /* RECT */: + case 1: program = baidugame.EgretWebGLProgram.getProgram(gl, baidugame.EgretShaderLib.default_vert, baidugame.EgretShaderLib.primitive_frag, "primitive"); this.activeProgram(gl, program); this.syncUniforms(program, filter, data.textureWidth, data.textureHeight); offset += this.drawRectElements(data, offset); break; - case 2 /* PUSH_MASK */: + case 2: program = baidugame.EgretWebGLProgram.getProgram(gl, baidugame.EgretShaderLib.default_vert, baidugame.EgretShaderLib.primitive_frag, "primitive"); this.activeProgram(gl, program); this.syncUniforms(program, filter, data.textureWidth, data.textureHeight); offset += this.drawPushMaskElements(data, offset); break; - case 3 /* POP_MASK */: + case 3: program = baidugame.EgretWebGLProgram.getProgram(gl, baidugame.EgretShaderLib.default_vert, baidugame.EgretShaderLib.primitive_frag, "primitive"); this.activeProgram(gl, program); this.syncUniforms(program, filter, data.textureWidth, data.textureHeight); offset += this.drawPopMaskElements(data, offset); break; - case 4 /* BLEND */: + case 4: this.setBlendMode(data.value); break; - case 5 /* RESIZE_TARGET */: + case 5: data.buffer.rootRenderTarget.resize(data.width, data.height); this.onResize(data.width, data.height); break; - case 6 /* CLEAR_COLOR */: + case 6: if (this.activatedBuffer) { var target = this.activatedBuffer.rootRenderTarget; if (target.width != 0 || target.height != 0) { @@ -5555,10 +3559,10 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } } break; - case 7 /* ACT_BUFFER */: + case 7: this.activateBuffer(data.buffer, data.width, data.height); break; - case 8 /* ENABLE_SCISSOR */: + case 8: var buffer = this.activatedBuffer; if (buffer) { if (buffer.rootRenderTarget) { @@ -5567,13 +3571,13 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; buffer.enableScissor(data.x, data.y, data.width, data.height); } break; - case 9 /* DISABLE_SCISSOR */: + case 9: buffer = this.activatedBuffer; if (buffer) { buffer.disableScissor(); } break; - case 10 /* SMOOTHING */: + case 10: gl.bindTexture(gl.TEXTURE_2D, data.texture); if (data.smoothing) { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); @@ -5592,7 +3596,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; WebGLRenderContext.prototype.activeProgram = function (gl, program) { if (program != this.currentProgram) { gl.useProgram(program.id); - // 目前所有attribute buffer的绑定方法都是一致的 var attribute = program.attributes; for (var key in attribute) { if (key === "aVertexPosition") { @@ -5633,39 +3636,19 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; uniforms[key].setValue(value); } else { - // egret.warn("filter custom: uniform " + key + " not defined!"); } } } }; - /** - * 画texture - **/ WebGLRenderContext.prototype.drawTextureElements = function (data, offset) { return egret.sys.drawTextureElements(this, data, offset); - /* - let gl: any = this.context; - gl.activeTexture(gl.TEXTURE0); ///refactor - gl.bindTexture(gl.TEXTURE_2D, data.texture); - let size = data.count * 3; - gl.drawElements(gl.TRIANGLES, size, gl.UNSIGNED_SHORT, offset * 2); - return size; - */ }; - /** - * @private - * 画rect - **/ WebGLRenderContext.prototype.drawRectElements = function (data, offset) { var gl = this.context; - // gl.bindTexture(gl.TEXTURE_2D, null); var size = data.count * 3; gl.drawElements(gl.TRIANGLES, size, gl.UNSIGNED_SHORT, offset * 2); return size; }; - /** - * 画push mask - **/ WebGLRenderContext.prototype.drawPushMaskElements = function (data, offset) { var gl = this.context; var size = data.count * 3; @@ -5676,14 +3659,13 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } if (buffer.stencilHandleCount == 0) { buffer.enableStencil(); - gl.clear(gl.STENCIL_BUFFER_BIT); // clear + gl.clear(gl.STENCIL_BUFFER_BIT); } var level = buffer.stencilHandleCount; buffer.stencilHandleCount++; gl.colorMask(false, false, false, false); gl.stencilFunc(gl.EQUAL, level, 0xFF); gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR); - // gl.bindTexture(gl.TEXTURE_2D, null); gl.drawElements(gl.TRIANGLES, size, gl.UNSIGNED_SHORT, offset * 2); gl.stencilFunc(gl.EQUAL, level + 1, 0xFF); gl.colorMask(true, true, true, true); @@ -5691,9 +3673,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } return size; }; - /** - * 画pop mask - **/ WebGLRenderContext.prototype.drawPopMaskElements = function (data, offset) { var gl = this.context; var size = data.count * 3; @@ -5701,14 +3680,13 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; if (buffer) { buffer.stencilHandleCount--; if (buffer.stencilHandleCount == 0) { - buffer.disableStencil(); // skip this draw + buffer.disableStencil(); } else { var level = buffer.stencilHandleCount; gl.colorMask(false, false, false, false); gl.stencilFunc(gl.EQUAL, level + 1, 0xFF); gl.stencilOp(gl.KEEP, gl.KEEP, gl.DECR); - // gl.bindTexture(gl.TEXTURE_2D, null); gl.drawElements(gl.TRIANGLES, size, gl.UNSIGNED_SHORT, offset * 2); gl.stencilFunc(gl.EQUAL, level, 0xFF); gl.colorMask(true, true, true, true); @@ -5717,9 +3695,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } return size; }; - /** - * 设置混色 - */ WebGLRenderContext.prototype.setBlendMode = function (value) { var gl = this.context; var blendModeWebGL = WebGLRenderContext.blendModesForGL[value]; @@ -5727,13 +3702,8 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); } }; - /** - * 应用滤镜绘制给定的render target - * 此方法不会导致input被释放,所以如果需要释放input,需要调用此方法后手动调用release - */ WebGLRenderContext.prototype.drawTargetWidthFilters = function (filters, input) { var originInput = input, filtersLen = filters.length, output; - // 应用前面的滤镜 if (filtersLen > 1) { for (var i = 0; i < filtersLen - 1; i++) { var filter_1 = filters[i]; @@ -5749,17 +3719,12 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; input = output; } } - // 应用最后一个滤镜并绘制到当前场景中 var filter = filters[filtersLen - 1]; this.drawToRenderTarget(filter, input, this.currentBuffer); - // 释放掉用于交换的buffer if (input != originInput) { baidugame.WebGLRenderBuffer.release(input); } }; - /** - * 向一个renderTarget中绘制 - * */ WebGLRenderContext.prototype.drawToRenderTarget = function (filter, input, output) { if (this.contextLost) { return; @@ -5769,7 +3734,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } this.pushBuffer(output); var originInput = input, temp, width = input.rootRenderTarget.width, height = input.rootRenderTarget.height; - // 模糊滤镜分别处理blurX与blurY if (filter.type == "blur") { var blurXFilter = filter.blurXFilter; var blurYFilter = filter.blurYFilter; @@ -5788,37 +3752,18 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; filter = blurXFilter.blurX === 0 ? blurYFilter : blurXFilter; } } - // 绘制input结果到舞台 output.saveTransform(); output.transform(1, 0, 0, -1, 0, height); output.currentTexture = input.rootRenderTarget.texture; this.vao.cacheArrays(output, 0, 0, width, height, 0, 0, width, height, width, height); output.restoreTransform(); this.drawCmdManager.pushDrawTexture(input.rootRenderTarget.texture, 2, filter, width, height); - // 释放掉input if (input != originInput) { baidugame.WebGLRenderBuffer.release(input); } this.popBuffer(); }; WebGLRenderContext.initBlendMode = function () { - /*参考 - gl.ZERO = 0 - gl.ONE = 1 - gl.SRC_COLOR = 768 - gl.ONE_MINUS_SRC_COLOR = 769 - gl.DST_COLOR = 774 - gl.ONE_MINUS_DST_COLOR = 775 - gl.SRC_ALPHA = 770 - gl.ONE_MINUS_SRC_ALPHA = 771 - gl.DST_ALPHA = 772 - gl.ONE_MINUS_DST_ALPHA = 773 - gl.CONSTANT_COLOR = 32769 - gl.ONE_MINUS_CONSTANT_COLOR = 32770 - gl.CONSTANT_ALPHA = 32771 - gl.ONE_MINUS_CONSTANT_ALPHA = 32772 - gl.SRC_ALPHA_SATURATE = 776 - */ WebGLRenderContext.blendModesForGL = {}; WebGLRenderContext.blendModesForGL["source-over"] = [1, 771]; WebGLRenderContext.blendModesForGL["lighter"] = [1, 1]; @@ -5835,61 +3780,20 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; WebGLRenderContext.initBlendMode(); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - * WebGL渲染缓存 - */ var WebGLRenderBuffer = (function (_super) { __extends(WebGLRenderBuffer, _super); function WebGLRenderBuffer(width, height, root) { var _this = _super.call(this) || this; - // _this.currentTexture = null; _this.globalAlpha = 1; _this.globalTintColor = 0xFFFFFF; - /** - * stencil state - * 模版开关状态 - */ _this.stencilState = false; _this.$stencilList = []; _this.stencilHandleCount = 0; - /** - * scissor state - * scissor 开关状态 - */ _this.$scissorState = false; _this.scissorRect = new egret.Rectangle(); _this.$hasScissor = false; @@ -5899,7 +3803,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; _this.savedGlobalMatrix = new egret.Matrix(); _this.$offsetX = 0; _this.$offsetY = 0; - // 获取webglRenderContext _this.context = baidugame.WebGLRenderContext.getInstance(width, height); if (egret.nativeRender) { if (root) { @@ -5911,22 +3814,17 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; _this.rootRenderTarget = null; return _this; } - // buffer 对应的 render target _this.rootRenderTarget = new baidugame.WebGLRenderTarget(_this.context.context, 3, 3); if (width && height) { _this.resize(width, height); } - // 如果是第一个加入的buffer,说明是舞台buffer _this.root = root; - // 如果是用于舞台渲染的renderBuffer,则默认添加renderTarget到renderContext中,而且是第一个 if (_this.root) { _this.context.pushBuffer(_this); - // 画布 _this.surface = _this.context.surface; _this.$computeDrawCall = true; } else { - // 由于创建renderTarget造成的frameBuffer绑定,这里重置绑定 var lastBuffer = _this.context.activatedBuffer; if (lastBuffer) { lastBuffer.rootRenderTarget.activate(); @@ -5979,10 +3877,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } }; Object.defineProperty(WebGLRenderBuffer.prototype, "width", { - /** - * 渲染缓冲的宽度,以像素为单位。 - * @readOnly - */ get: function () { if (egret.nativeRender) { return this.surface.width; @@ -5995,10 +3889,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; configurable: true }); Object.defineProperty(WebGLRenderBuffer.prototype, "height", { - /** - * 渲染缓冲的高度,以像素为单位。 - * @readOnly - */ get: function () { if (egret.nativeRender) { return this.surface.height; @@ -6010,12 +3900,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; enumerable: true, configurable: true }); - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param width 改变后的宽 - * @param height 改变后的高 - * @param useMaxSize 若传入true,则将改变后的尺寸与已有尺寸对比,保留较大的尺寸。 - */ WebGLRenderBuffer.prototype.resize = function (width, height, useMaxSize) { width = width || 1; height = height || 1; @@ -6024,23 +3908,17 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return; } this.context.pushBuffer(this); - // render target 尺寸重置 if (width != this.rootRenderTarget.width || height != this.rootRenderTarget.height) { this.context.drawCmdManager.pushResize(this, width, height); - // 同步更改宽高 this.rootRenderTarget.width = width; this.rootRenderTarget.height = height; } - // 如果是舞台的渲染缓冲,执行resize,否则surface大小不随之改变 if (this.root) { this.context.resize(width, height, useMaxSize); } this.context.clear(); this.context.popBuffer(); }; - /** - * 获取指定区域的像素 - */ WebGLRenderBuffer.prototype.getPixels = function (x, y, width, height) { if (width === void 0) { width = 1; } if (height === void 0) { height = 1; } @@ -6058,7 +3936,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.rootRenderTarget.useFrameBuffer = useFrameBuffer; this.rootRenderTarget.activate(); } - //图像反转 var result = new Uint8Array(4 * width * height); for (var i = 0; i < height; i++) { for (var j = 0; j < width; j++) { @@ -6073,32 +3950,20 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } return result; }; - /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如: "image/png","image/jpeg" - */ WebGLRenderBuffer.prototype.toDataURL = function (type, encoderOptions) { return this.context.surface.toDataURL(type, encoderOptions); }; - /** - * 销毁绘制对象 - */ WebGLRenderBuffer.prototype.destroy = function () { this.context.destroy(); }; WebGLRenderBuffer.prototype.onRenderFinish = function () { this.$drawCalls = 0; }; - /** - * 交换frameBuffer中的图像到surface中 - * @param width 宽度 - * @param height 高度 - */ WebGLRenderBuffer.prototype.drawFrameBufferToSurface = function (sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight, clear) { if (clear === void 0) { clear = false; } this.rootRenderTarget.useFrameBuffer = false; this.rootRenderTarget.activate(); - this.context.disableStencilTest(); // 切换frameBuffer注意要禁用STENCIL_TEST + this.context.disableStencilTest(); this.context.disableScissorTest(); this.setTransform(1, 0, 0, 1, 0, 0); this.globalAlpha = 1; @@ -6111,16 +3976,11 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.restoreStencil(); this.restoreScissor(); }; - /** - * 交换surface的图像到frameBuffer中 - * @param width 宽度 - * @param height 高度 - */ WebGLRenderBuffer.prototype.drawSurfaceToFrameBuffer = function (sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight, clear) { if (clear === void 0) { clear = false; } this.rootRenderTarget.useFrameBuffer = true; this.rootRenderTarget.activate(); - this.context.disableStencilTest(); // 切换frameBuffer注意要禁用STENCIL_TEST + this.context.disableStencilTest(); this.context.disableScissorTest(); this.setTransform(1, 0, 0, 1, 0, 0); this.globalAlpha = 1; @@ -6133,16 +3993,12 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.restoreStencil(); this.restoreScissor(); }; - /** - * 清空缓冲区数据 - */ WebGLRenderBuffer.prototype.clear = function () { this.context.pushBuffer(this); this.context.clear(); this.context.popBuffer(); }; WebGLRenderBuffer.prototype.setTransform = function (a, b, c, d, tx, ty) { - // this.globalMatrix.setTo(a, b, c, d, tx, ty); var matrix = this.globalMatrix; matrix.a = a; matrix.b = b; @@ -6193,13 +4049,8 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; matrix.tx = sMatrix.tx; matrix.ty = sMatrix.ty; }; - /** - * 创建一个buffer实例 - */ WebGLRenderBuffer.create = function (width, height) { var buffer = renderBufferPool.pop(); - // width = Math.min(width, 1024); - // height = Math.min(height, 1024); if (buffer) { buffer.resize(width, height); var matrix = buffer.globalMatrix; @@ -6219,9 +4070,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } return buffer; }; - /** - * 回收一个buffer实例 - */ WebGLRenderBuffer.release = function (buffer) { renderBufferPool.push(buffer); }; @@ -6230,37 +4078,9 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; }(egret.HashObject)); baidugame.WebGLRenderBuffer = WebGLRenderBuffer; __reflect(WebGLRenderBuffer.prototype, "egret.baidugame.WebGLRenderBuffer", ["egret.sys.RenderBuffer"]); - var renderBufferPool = []; //渲染缓冲区对象池 + var renderBufferPool = []; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; @@ -6269,35 +4089,18 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; var defaultCompositeOp = "source-over"; var BLACK_COLOR = "#000000"; var CAPS_STYLES = { none: 'butt', square: 'square', round: 'round' }; - var renderBufferPool = []; //渲染缓冲区对象池 - /** - * @private - * WebGL渲染器 - */ + var renderBufferPool = []; var WebGLRenderer = (function () { function WebGLRenderer() { - /** - * Do special treatment on wechat ios10 - */ this.wxiOS10 = false; - this.nestLevel = 0; //渲染的嵌套层次,0表示在调用堆栈的最外层。 + this.nestLevel = 0; } - /** - * 渲染一个显示对象 - * @param displayObject 要渲染的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要对显示对象整体叠加的变换矩阵 - * @param dirtyList 脏矩形列表 - * @param forRenderTexture 绘制目标是RenderTexture的标志 - * @returns drawCall触发绘制的次数 - */ WebGLRenderer.prototype.render = function (displayObject, buffer, matrix, forRenderTexture) { this.nestLevel++; var webglBuffer = buffer; var webglBufferContext = webglBuffer.context; var root = forRenderTexture ? displayObject : null; webglBufferContext.pushBuffer(webglBuffer); - //绘制显示对象 webglBuffer.transform(matrix.a, matrix.b, matrix.c, matrix.d, 0, 0); this.drawDisplayObject(displayObject, webglBuffer, matrix.tx, matrix.ty, true); webglBufferContext.$drawWebGL(); @@ -6310,7 +4113,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; egret.Matrix.release(invert); this.nestLevel--; if (this.nestLevel === 0) { - //最大缓存6个渲染缓冲 if (renderBufferPool.length > 6) { renderBufferPool.length = 6; } @@ -6321,10 +4123,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } return drawCall; }; - /** - * @private - * 绘制一个显示对象 - */ WebGLRenderer.prototype.drawDisplayObject = function (displayObject, buffer, offsetX, offsetY, isStage) { var drawCalls = 0; var node; @@ -6351,22 +4149,22 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; buffer.$offsetX = offsetX; buffer.$offsetY = offsetY; switch (node.type) { - case 1 /* BitmapNode */: + case 1: this.renderBitmap(node, buffer); break; - case 2 /* TextNode */: + case 2: this.renderText(node, buffer); break; - case 3 /* GraphicsNode */: + case 3: this.renderGraphics(node, buffer); break; - case 4 /* GroupNode */: + case 4: this.renderGroup(node, buffer); break; - case 5 /* MeshNode */: + case 5: this.renderMesh(node, buffer); break; - case 6 /* NormalBitmapNode */: + case 6: this.renderNormalBitmap(node, buffer); break; } @@ -6379,7 +4177,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; var children = displayObject.$children; if (children) { if (displayObject.sortableChildren && displayObject.$sortDirty) { - //绘制排序 displayObject.sortChildren(); } var length_6 = children.length; @@ -6419,15 +4216,15 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; offsetY2 = offsetY + child.$y - child.$anchorOffsetY; } switch (child.$renderMode) { - case 1 /* NONE */: + case 1: break; - case 2 /* FILTER */: + case 2: drawCalls += this.drawWithFilter(child, buffer, offsetX2, offsetY2); break; - case 3 /* CLIP */: + case 3: drawCalls += this.drawWithClip(child, buffer, offsetX2, offsetY2); break; - case 4 /* SCROLLRECT */: + case 4: drawCalls += this.drawWithScrollRect(child, buffer, offsetX2, offsetY2); break; default: @@ -6454,9 +4251,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } return drawCalls; }; - /** - * @private - */ WebGLRenderer.prototype.drawWithFilter = function (displayObject, buffer, offsetX, offsetY) { var drawCalls = 0; if (displayObject.$children && displayObject.$children.length == 0 && (!displayObject.$renderNode || displayObject.$renderNode.$getRenderCount() == 0)) { @@ -6502,10 +4296,8 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return drawCalls; } } - // 为显示对象创建一个新的buffer var displayBuffer = this.createRenderBuffer(displayBoundsWidth, displayBoundsHeight); displayBuffer.context.pushBuffer(displayBuffer); - //todo 可以优化减少draw次数 if (displayObject.$mask) { drawCalls += this.drawWithClip(displayObject, displayBuffer, -displayBoundsX, -displayBoundsY); } @@ -6516,13 +4308,11 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; drawCalls += this.drawDisplayObject(displayObject, displayBuffer, -displayBoundsX, -displayBoundsY); } displayBuffer.context.popBuffer(); - //绘制结果到屏幕 if (drawCalls > 0) { if (hasBlendMode) { buffer.context.setGlobalCompositeOperation(compositeOp); } drawCalls++; - // 绘制结果的时候,应用滤镜 buffer.$offsetX = offsetX + displayBoundsX; buffer.$offsetY = offsetY + displayBoundsY; var savedMatrix = egret.Matrix.create(); @@ -6559,7 +4349,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; for (var _i = 0, _a = displayObject.$children; _i < _a.length; _i++) { var child = _a[_i]; var filters = child.$filters; - // 特殊处理有滤镜的对象 if (filters && filters.length > 0) { return 2; } @@ -6576,9 +4365,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } return drawCount; }; - /** - * @private - */ WebGLRenderer.prototype.drawWithClip = function (displayObject, buffer, offsetX, offsetY) { var drawCalls = 0; var hasBlendMode = (displayObject.$blendMode !== 0); @@ -6593,17 +4379,14 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; var mask = displayObject.$mask; if (mask) { var maskRenderMatrix = mask.$getMatrix(); - //遮罩scaleX或scaleY为0,放弃绘制 if ((maskRenderMatrix.a == 0 && maskRenderMatrix.b == 0) || (maskRenderMatrix.c == 0 && maskRenderMatrix.d == 0)) { return drawCalls; } } - //没有遮罩,同时显示对象没有子项 if (!mask && (!displayObject.$children || displayObject.$children.length == 0)) { if (scrollRect) { buffer.context.pushMask(scrollRect.x + offsetX, scrollRect.y + offsetY, scrollRect.width, scrollRect.height); } - //绘制显示对象 if (hasBlendMode) { buffer.context.setGlobalCompositeOperation(compositeOp); } @@ -6625,11 +4408,9 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; if (displayBoundsWidth <= 0 || displayBoundsHeight <= 0) { return drawCalls; } - //绘制显示对象自身,若有scrollRect,应用clip var displayBuffer = this.createRenderBuffer(displayBoundsWidth, displayBoundsHeight); displayBuffer.context.pushBuffer(displayBuffer); drawCalls += this.drawDisplayObject(displayObject, displayBuffer, -displayBoundsX, -displayBoundsY); - //绘制遮罩 if (mask) { var maskBuffer = this.createRenderBuffer(displayBoundsWidth, displayBoundsHeight); maskBuffer.context.pushBuffer(maskBuffer); @@ -6653,7 +4434,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } displayBuffer.context.setGlobalCompositeOperation(defaultCompositeOp); displayBuffer.context.popBuffer(); - //绘制结果到屏幕 if (drawCalls > 0) { drawCalls++; if (hasBlendMode) { @@ -6693,9 +4473,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return drawCalls; } }; - /** - * @private - */ WebGLRenderer.prototype.drawWithScrollRect = function (displayObject, buffer, offsetX, offsetY) { var drawCalls = 0; var scrollRect = displayObject.$scrollRect ? displayObject.$scrollRect : displayObject.$maskRect; @@ -6722,7 +4499,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; var xMax = x + scrollRect.width; var yMax = y + scrollRect.height; var minX = void 0, minY = void 0, maxX = void 0, maxY = void 0; - //优化,通常情况下不缩放的对象占多数,直接加上偏移量即可。 if (a == 1.0 && d == 1.0) { minX = x + tx; minY = y + ty; @@ -6776,30 +4552,15 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } return drawCalls; }; - /** - * 将一个RenderNode对象绘制到渲染缓冲 - * @param node 要绘制的节点 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - * @param forHitTest 绘制结果是用于碰撞检测。若为true,当渲染GraphicsNode时,会忽略透明度样式设置,全都绘制为不透明的。 - */ WebGLRenderer.prototype.drawNodeToBuffer = function (node, buffer, matrix, forHitTest) { var webglBuffer = buffer; - //pushRenderTARGET webglBuffer.context.pushBuffer(webglBuffer); webglBuffer.setTransform(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty); this.renderNode(node, buffer, 0, 0, forHitTest); webglBuffer.context.$drawWebGL(); webglBuffer.onRenderFinish(); - //popRenderTARGET webglBuffer.context.popBuffer(); }; - /** - * 将一个DisplayObject绘制到渲染缓冲,用于RenderTexture绘制 - * @param displayObject 要绘制的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - */ WebGLRenderer.prototype.drawDisplayToBuffer = function (displayObject, buffer, matrix) { buffer.context.pushBuffer(buffer); if (matrix) { @@ -6816,22 +4577,22 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; if (node) { drawCalls++; switch (node.type) { - case 1 /* BitmapNode */: + case 1: this.renderBitmap(node, buffer); break; - case 2 /* TextNode */: + case 2: this.renderText(node, buffer); break; - case 3 /* GraphicsNode */: + case 3: this.renderGraphics(node, buffer); break; - case 4 /* GroupNode */: + case 4: this.renderGroup(node, buffer); break; - case 5 /* MeshNode */: + case 5: this.renderMesh(node, buffer); break; - case 6 /* NormalBitmapNode */: + case 6: this.renderNormalBitmap(node, buffer); break; } @@ -6842,15 +4603,15 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; for (var i = 0; i < length_7; i++) { var child = children[i]; switch (child.$renderMode) { - case 1 /* NONE */: + case 1: break; - case 2 /* FILTER */: + case 2: drawCalls += this.drawWithFilter(child, buffer, 0, 0); break; - case 3 /* CLIP */: + case 3: drawCalls += this.drawWithClip(child, buffer, 0, 0); break; - case 4 /* SCROLLRECT */: + case 4: drawCalls += this.drawWithScrollRect(child, buffer, 0, 0); break; default: @@ -6864,36 +4625,30 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; buffer.context.popBuffer(); return drawCalls; }; - /** - * @private - */ WebGLRenderer.prototype.renderNode = function (node, buffer, offsetX, offsetY, forHitTest) { buffer.$offsetX = offsetX; buffer.$offsetY = offsetY; switch (node.type) { - case 1 /* BitmapNode */: + case 1: this.renderBitmap(node, buffer); break; - case 2 /* TextNode */: + case 2: this.renderText(node, buffer); break; - case 3 /* GraphicsNode */: + case 3: this.renderGraphics(node, buffer, forHitTest); break; - case 4 /* GroupNode */: + case 4: this.renderGroup(node, buffer); break; - case 5 /* MeshNode */: + case 5: this.renderMesh(node, buffer); break; - case 6 /* NormalBitmapNode */: + case 6: this.renderNormalBitmap(node, buffer); break; } }; - /** - * @private - */ WebGLRenderer.prototype.renderNormalBitmap = function (node, buffer) { var image = node.image; if (!image) { @@ -6901,15 +4656,11 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } buffer.context.drawImage(image, node.sourceX, node.sourceY, node.sourceW, node.sourceH, node.drawX, node.drawY, node.drawW, node.drawH, node.imageWidth, node.imageHeight, node.rotated, node.smoothing); }; - /** - * @private - */ WebGLRenderer.prototype.renderBitmap = function (node, buffer) { var image = node.image; if (!image) { return; } - //buffer.imageSmoothingEnabled = node.smoothing; var data = node.drawData; var length = data.length; var pos = 0; @@ -6933,7 +4684,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; buffer.useOffset(); buffer.transform(m.a, m.b, m.c, m.d, m.tx, m.ty); } - //这里不考虑嵌套 if (blendMode) { buffer.context.setGlobalCompositeOperation(blendModes[blendMode]); } @@ -6973,12 +4723,8 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; egret.Matrix.release(savedMatrix); } }; - /** - * @private - */ WebGLRenderer.prototype.renderMesh = function (node, buffer) { var image = node.image; - //buffer.imageSmoothingEnabled = node.smoothing; var data = node.drawData; var length = data.length; var pos = 0; @@ -7002,7 +4748,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; buffer.useOffset(); buffer.transform(m.a, m.b, m.c, m.d, m.tx, m.ty); } - //这里不考虑嵌套 if (blendMode) { buffer.context.setGlobalCompositeOperation(blendModes[blendMode]); } @@ -7042,9 +4787,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; egret.Matrix.release(savedMatrix); } }; - /** - * @private - */ WebGLRenderer.prototype.___renderText____ = function (node, buffer) { var width = node.width - node.x; var height = node.height - node.y; @@ -7077,10 +4819,8 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } var drawCommands = node[baidugame.property_drawLabel]; if (drawCommands && drawCommands.length > 0) { - //存一下 var saveOffsetX = buffer.$offsetX; var saveOffsetY = buffer.$offsetY; - //开始画 var cmd = null; var anchorX = 0; var anchorY = 0; @@ -7104,7 +4844,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; buffer.$offsetX += (tb.contentWidth - tb.canvasWidthOffset); } } - //还原回去 buffer.$offsetX = saveOffsetX; buffer.$offsetY = saveOffsetY; } @@ -7113,12 +4852,8 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } node.dirtyRender = false; }; - /** - * @private - */ WebGLRenderer.prototype.renderText = function (node, buffer) { if (baidugame.textAtlasRenderEnable) { - //新的文字渲染机制 this.___renderText____(node, buffer); return; } @@ -7185,18 +4920,15 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; node.$texture = surface; } else { - // 拷贝canvas到texture var texture = node.$texture; if (!texture) { texture = buffer.context.createTexture(surface); node.$texture = texture; } else { - // 重新拷贝新的图像 buffer.context.updateTexture(texture, surface); } } - // 保存材质尺寸 node.$textureWidth = surface.width; node.$textureHeight = surface.height; } @@ -7211,9 +4943,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } node.dirtyRender = false; }; - /** - * @private - */ WebGLRenderer.prototype.renderGraphics = function (node, buffer, forHitTest) { var width = node.width; var height = node.height; @@ -7230,7 +4959,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; node.$canvasScaleY = canvasScaleY; node.dirtyRender = true; } - //缩放叠加 width2 / width 填满整个区域 width = width * canvasScaleX; height = height * canvasScaleY; var width2 = Math.ceil(width); @@ -7290,18 +5018,15 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; node.$texture = surface; } else { - // 拷贝canvas到texture var texture = node.$texture; if (!texture) { texture = buffer.context.createTexture(surface); node.$texture = texture; } else { - // 重新拷贝新的图像 buffer.context.updateTexture(texture, surface); } } - // 保存材质尺寸 node.$textureWidth = surface.width; node.$textureHeight = surface.height; } @@ -7357,9 +5082,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; egret.Matrix.release(savedMatrix); } }; - /** - * @private - */ WebGLRenderer.prototype.createRenderBuffer = function (width, height) { var buffer = renderBufferPool.pop(); if (buffer) { @@ -7377,41 +5099,10 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; __reflect(WebGLRenderer.prototype, "egret.baidugame.WebGLRenderer", ["egret.sys.SystemRenderer"]); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var EgretWebGLAttribute = (function () { function EgretWebGLAttribute(gl, program, attributeData) { this.gl = gl; @@ -7470,34 +5161,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; __reflect(EgretWebGLAttribute.prototype, "egret.baidugame.EgretWebGLAttribute"); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; @@ -7542,9 +5205,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } return uniforms; } - /** - * @private - */ var EgretWebGLProgram = (function () { function EgretWebGLProgram(gl, vertSource, fragSource) { this.vshaderSource = vertSource; @@ -7555,10 +5215,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; this.uniforms = extractUniforms(gl, this.id); this.attributes = extractAttributes(gl, this.id); } - /** - * 获取所需的WebGL Program - * @param key {string} 对于唯一的program程序,对应唯一的key - */ EgretWebGLProgram.getProgram = function (gl, vertSource, fragSource, key) { if (!this.programCache[key]) { this.programCache[key] = new EgretWebGLProgram(gl, vertSource, fragSource); @@ -7566,7 +5222,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return this.programCache[key]; }; EgretWebGLProgram.deleteProgram = function (gl, vertSource, fragSource, key) { - // TODO delete }; EgretWebGLProgram.programCache = {}; return EgretWebGLProgram; @@ -7575,41 +5230,10 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; __reflect(EgretWebGLProgram.prototype, "egret.baidugame.EgretWebGLProgram"); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var EgretWebGLUniform = (function () { function EgretWebGLUniform(gl, program, uniformData) { this.gl = gl; @@ -7809,34 +5433,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; __reflect(EgretWebGLUniform.prototype, "egret.baidugame.EgretWebGLUniform"); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; @@ -7850,45 +5446,7 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; EgretShaderLib.glow_frag = "precision highp float;\r\nvarying vec2 vTextureCoord;\r\n\r\nuniform sampler2D uSampler;\r\n\r\nuniform float dist;\r\nuniform float angle;\r\nuniform vec4 color;\r\nuniform float alpha;\r\nuniform float blurX;\r\nuniform float blurY;\r\n// uniform vec4 quality;\r\nuniform float strength;\r\nuniform float inner;\r\nuniform float knockout;\r\nuniform float hideObject;\r\n\r\nuniform vec2 uTextureSize;\r\n\r\nfloat random(vec2 scale)\r\n{\r\n return fract(sin(dot(gl_FragCoord.xy, scale)) * 43758.5453);\r\n}\r\n\r\nvoid main(void) {\r\n vec2 px = vec2(1.0 / uTextureSize.x, 1.0 / uTextureSize.y);\r\n // TODO 自动调节采样次数?\r\n const float linearSamplingTimes = 7.0;\r\n const float circleSamplingTimes = 12.0;\r\n vec4 ownColor = texture2D(uSampler, vTextureCoord);\r\n vec4 curColor;\r\n float totalAlpha = 0.0;\r\n float maxTotalAlpha = 0.0;\r\n float curDistanceX = 0.0;\r\n float curDistanceY = 0.0;\r\n float offsetX = dist * cos(angle) * px.x;\r\n float offsetY = dist * sin(angle) * px.y;\r\n\r\n const float PI = 3.14159265358979323846264;\r\n float cosAngle;\r\n float sinAngle;\r\n float offset = PI * 2.0 / circleSamplingTimes * random(vec2(12.9898, 78.233));\r\n float stepX = blurX * px.x / linearSamplingTimes;\r\n float stepY = blurY * px.y / linearSamplingTimes;\r\n for (float a = 0.0; a <= PI * 2.0; a += PI * 2.0 / circleSamplingTimes) {\r\n cosAngle = cos(a + offset);\r\n sinAngle = sin(a + offset);\r\n for (float i = 1.0; i <= linearSamplingTimes; i++) {\r\n curDistanceX = i * stepX * cosAngle;\r\n curDistanceY = i * stepY * sinAngle;\r\n if (vTextureCoord.x + curDistanceX - offsetX >= 0.0 && vTextureCoord.y + curDistanceY + offsetY <= 1.0){\r\n curColor = texture2D(uSampler, vec2(vTextureCoord.x + curDistanceX - offsetX, vTextureCoord.y + curDistanceY + offsetY));\r\n totalAlpha += (linearSamplingTimes - i) * curColor.a;\r\n }\r\n maxTotalAlpha += (linearSamplingTimes - i);\r\n }\r\n }\r\n\r\n ownColor.a = max(ownColor.a, 0.0001);\r\n ownColor.rgb = ownColor.rgb / ownColor.a;\r\n\r\n float outerGlowAlpha = (totalAlpha / maxTotalAlpha) * strength * alpha * (1. - inner) * max(min(hideObject, knockout), 1. - ownColor.a);\r\n float innerGlowAlpha = ((maxTotalAlpha - totalAlpha) / maxTotalAlpha) * strength * alpha * inner * ownColor.a;\r\n\r\n ownColor.a = max(ownColor.a * knockout * (1. - hideObject), 0.0001);\r\n vec3 mix1 = mix(ownColor.rgb, color.rgb, innerGlowAlpha / (innerGlowAlpha + ownColor.a));\r\n vec3 mix2 = mix(mix1, color.rgb, outerGlowAlpha / (innerGlowAlpha + ownColor.a + outerGlowAlpha));\r\n float resultAlpha = min(ownColor.a + outerGlowAlpha + innerGlowAlpha, 1.);\r\n gl_FragColor = vec4(mix2 * resultAlpha, resultAlpha);\r\n}"; EgretShaderLib.primitive_frag = "precision lowp float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\n\r\nvoid main(void) {\r\n gl_FragColor = vColor;\r\n}"; EgretShaderLib.texture_frag = "precision lowp float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform sampler2D uSampler;\r\n\r\nvoid main(void) {\r\n gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;\r\n}"; - /* - "precision lowp float; - varying vec2 vTextureCoord; - varying vec4 vColor; - uniform sampler2D uSampler; - uniform sampler2D uSamplerAlphaMask; - void main(void) { - float alpha = texture2D(uSamplerAlphaMask, vTextureCoord).r; - if (alpha < 0.0039) { discard; } - vec4 v4Color = texture2D(uSampler, vTextureCoord); - v4Color.rgb = v4Color.rgb * alpha; - v4Color.a = alpha; - gl_FragColor = v4Color * vColor; - }" - */ EgretShaderLib.texture_etc_alphamask_frag = "precision lowp float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform sampler2D uSampler;\r\nuniform sampler2D uSamplerAlphaMask;\r\nvoid main(void) {\r\nfloat alpha = texture2D(uSamplerAlphaMask, vTextureCoord).r;\r\nif (alpha < 0.0039) { discard; }\r\nvec4 v4Color = texture2D(uSampler, vTextureCoord);\r\nv4Color.rgb = v4Color.rgb * alpha;\r\nv4Color.a = alpha;\r\ngl_FragColor = v4Color * vColor;\r\n}"; - /* - "precision mediump float; - varying vec2 vTextureCoord; - varying vec4 vColor; - uniform mat4 matrix; - uniform vec4 colorAdd; - uniform sampler2D uSampler; - uniform sampler2D uSamplerAlphaMask; - - void main(void){ - float alpha = texture2D(uSamplerAlphaMask, vTextureCoord).r; - if (alpha < 0.0039) { discard; } - vec4 texColor = texture2D(uSampler, vTextureCoord); - if(texColor.a > 0.0) { - // 抵消预乘的alpha通道 - texColor = vec4(texColor.rgb / texColor.a, texColor.a); - } - vec4 v4Color = clamp(texColor * matrix + colorAdd, 0.0, 1.0); - v4Color.rgb = v4Color.rgb * alpha; - v4Color.a = alpha; - gl_FragColor = v4Color * vColor; - }" - */ EgretShaderLib.colorTransform_frag_etc_alphamask_frag = "precision mediump float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform mat4 matrix;\r\nuniform vec4 colorAdd;\r\nuniform sampler2D uSampler;\r\nuniform sampler2D uSamplerAlphaMask;\r\n\r\nvoid main(void){\r\nfloat alpha = texture2D(uSamplerAlphaMask, vTextureCoord).r;\r\nif (alpha < 0.0039) { discard; }\r\nvec4 texColor = texture2D(uSampler, vTextureCoord);\r\nif(texColor.a > 0.0) {\r\n // 抵消预乘的alpha通道\r\ntexColor = vec4(texColor.rgb / texColor.a, texColor.a);\r\n}\r\nvec4 v4Color = clamp(texColor * matrix + colorAdd, 0.0, 1.0);\r\nv4Color.rgb = v4Color.rgb * alpha;\r\nv4Color.a = alpha;\r\ngl_FragColor = v4Color * vColor;\r\n}"; return EgretShaderLib; }()); @@ -7897,37 +5455,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); ; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/* -*** 一个管理模型,逐级包含: back -> page -> line -> textBlock -*/ (function (egret) { var baidugame; @@ -8005,7 +5532,7 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; TextBlock.prototype.updateUV = function () { var line = this.line; if (!line) { - return false; //不属于任何的line就是错的 + return false; } this.u = line.x + this.x + this.border * 1; this.v = line.y + this.y + this.border * 1; @@ -8054,7 +5581,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; if (!textBlock) { return false; } - // var posx = 0; var posy = 0; var lastTxtBlock = this.lastTextBlock(); @@ -8062,14 +5588,12 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; posx = lastTxtBlock.x + lastTxtBlock.width; posy = lastTxtBlock.y; } - // if (posx + textBlock.width > this.maxWidth) { - return false; //宽度不够 + return false; } - // if (this.dynamicMaxHeight > 0) { if (textBlock.height > this.dynamicMaxHeight || (textBlock.height / this.dynamicMaxHeight < 0.5)) { - return false; //如果有已经有动态高度,到这里,要么高度不够,要么小于动态高度的0.6差距, 就不填充 + return false; } } return true; @@ -8082,17 +5606,14 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return null; }; Line.prototype.addTextBlock = function (textBlock, needCheck) { - // if (!textBlock) { return false; } - // if (needCheck) { if (!this.isCapacityOf(textBlock)) { return false; } } - // var posx = 0; var posy = 0; var lastTxtBlock = this.lastTextBlock(); @@ -8100,7 +5621,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; posx = lastTxtBlock.x + lastTxtBlock.width; posy = lastTxtBlock.y; } - // textBlock.x = posx; textBlock.y = posy; textBlock.line = this; @@ -8128,10 +5648,8 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; if (!line) { return false; } - // var posx = 0; var posy = 0; - // var lines = this.lines; if (lines.length > 0) { var lastLine = lines[lines.length - 1]; @@ -8140,12 +5658,11 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } if (line.maxWidth > this.pageWidth) { console.error('line.maxWidth = ' + line.maxWidth + ', ' + 'this.pageWidth = ' + this.pageWidth); - return false; //宽度不够 + return false; } if (posy + line.dynamicMaxHeight > this.pageHeight) { - return false; //满了 + return false; } - //更新数据 line.x = posx; line.y = posy; line.page = this; @@ -8173,9 +5690,7 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; if (!result) { return false; } - //更新下uv textBlock.updateUV(); - //没有才要添加 var exist = false; var cast = result; var _sortLines = this._sortLines; @@ -8189,7 +5704,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; if (!exist) { _sortLines.push(cast[1]); } - //重新排序 this.sort(); return true; }; @@ -8198,10 +5712,8 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return null; } if (textBlock.width > this._maxSize || textBlock.height > this._maxSize) { - //console.log('this._maxSize = ' + this._maxSize + ', textBlock.width = ' + textBlock.width + ', textBlock.height = ' + textBlock.height); return null; } - //找到最合适的 var _sortLines = this._sortLines; for (var i = 0, length_9 = _sortLines.length; i < length_9; ++i) { var line = _sortLines[i]; @@ -8212,13 +5724,11 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return [line.page, line]; } } - //做新的行 var newLine = new Line(this._maxSize); if (!newLine.addTextBlock(textBlock, true)) { console.error('_addTextBlock !newLine.addTextBlock(textBlock, true)'); return null; } - //现有的page中插入 var _pages = this._pages; for (var i = 0, length_10 = _pages.length; i < length_10; ++i) { var page = _pages[i]; @@ -8226,8 +5736,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return [page, newLine]; } } - //都没有,就做新的page - //添加目标行 var newPage = this.createPage(this._maxSize, this._maxSize); if (!newPage.addLine(newLine)) { console.error('_addText newPage.addLine failed'); @@ -8252,8 +5760,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; Book.prototype.createTextBlock = function (tag, width, height, measureWidth, measureHeight, canvasWidthOffset, canvasHeightOffset, stroke2) { var txtBlock = new TextBlock(width, height, measureWidth, measureHeight, canvasWidthOffset, canvasHeightOffset, stroke2, this._border); if (!this.addTextBlock(txtBlock)) { - //走到这里几乎是不可能的,除非内存分配没了 - //暂时还没有到提交纹理的地步,现在都是虚拟的 return null; } txtBlock.tag = tag; @@ -8265,65 +5771,28 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; __reflect(Book.prototype, "egret.baidugame.Book"); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - //测试开关,打开会截住老的字体渲染 baidugame.textAtlasRenderEnable = false; - //测试对象, 先不用singleton的,后续整理代码,就new一个,放在全局的context上做成员变量 baidugame.__textAtlasRender__ = null; - //不想改TextNode的代码了,先用这种方式实现,以后稳了再改 baidugame.property_drawLabel = 'DrawLabel'; - //开启这个,用textAtlas渲染出来的,都是红字,而且加黑框 var textAtlasDebug = false; - //画一行 var DrawLabel = (function (_super) { __extends(DrawLabel, _super); function DrawLabel() { var _this = _super !== null && _super.apply(this, arguments) || this; - //记录初始位置 _this.anchorX = 0; _this.anchorY = 0; - //要画的字块 _this.textBlocks = []; return _this; } - //清除数据,回池 DrawLabel.prototype.clear = function () { this.anchorX = 0; this.anchorY = 0; - this.textBlocks.length = 0; //这个没事,实体在book里面存着 + this.textBlocks.length = 0; }; - //池子创建 DrawLabel.create = function () { var pool = DrawLabel.pool; if (pool.length === 0) { @@ -8331,7 +5800,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } return pool.pop(); }; - //回池 DrawLabel.back = function (drawLabel, checkRepeat) { if (!drawLabel) { return; @@ -8344,26 +5812,21 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; drawLabel.clear(); pool.push(drawLabel); }; - //池子,防止反复创建 DrawLabel.pool = []; return DrawLabel; }(egret.HashObject)); baidugame.DrawLabel = DrawLabel; __reflect(DrawLabel.prototype, "egret.baidugame.DrawLabel"); - //记录样式的 var StyleInfo = (function (_super) { __extends(StyleInfo, _super); - // function StyleInfo(textNode, format) { var _this = _super.call(this) || this; _this.format = null; - //debug强制红色 var saveTextColorForDebug = 0; if (textAtlasDebug) { saveTextColorForDebug = textNode.textColor; textNode.textColor = 0xff0000; } - //存上 _this.textColor = textNode.textColor; _this.strokeColor = textNode.strokeColor; _this.size = textNode.size; @@ -8373,19 +5836,16 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; _this.fontFamily = textNode.fontFamily; _this.format = format; _this.font = egret.getFontString(textNode, _this.format); - //描述用于生成hashcode var textColor = (!format.textColor ? textNode.textColor : format.textColor); var strokeColor = (!format.strokeColor ? textNode.strokeColor : format.strokeColor); var stroke = (!format.stroke ? textNode.stroke : format.stroke); var size = (!format.size ? textNode.size : format.size); - // _this.description = '' + _this.font + '-' + size; _this.description += '-' + egret.toColorString(textColor); _this.description += '-' + egret.toColorString(strokeColor); if (stroke) { _this.description += '-' + stroke * 2; } - //还原 if (textAtlasDebug) { textNode.textColor = saveTextColorForDebug; } @@ -8394,26 +5854,18 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return StyleInfo; }(egret.HashObject)); __reflect(StyleInfo.prototype, "StyleInfo"); - //测量字体和绘制的 var CharImageRender = (function (_super) { __extends(CharImageRender, _super); function CharImageRender() { var _this = _super !== null && _super.apply(this, arguments) || this; - //要渲染的字符串 _this.char = ''; - //StyleInfo _this.styleInfo = null; - //生成hashcode的字符串 _this.hashCodeString = ''; - //字母:style设置行程唯一值 _this.charWithStyleHashCode = 0; - //测量实际的size _this.measureWidth = 0; _this.measureHeight = 0; - //边缘放大之后的偏移 _this.canvasWidthOffset = 0; _this.canvasHeightOffset = 0; - //描边的记录 _this.stroke2 = 0; return _this; } @@ -8432,17 +5884,14 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; if (!canvas) { return; } - //读取设置 var text = this.char; var format = this.styleInfo.format; var textColor = (!format.textColor ? this.styleInfo.textColor : format.textColor); var strokeColor = (!format.strokeColor ? this.styleInfo.strokeColor : format.strokeColor); var stroke = (!format.stroke ? this.styleInfo.stroke : format.stroke); var size = (!format.size ? this.styleInfo.size : format.size); - //开始测量--------------------------------------- this.measureWidth = this.measure(text, this.styleInfo, size); - this.measureHeight = size; //this.styleInfo.size; - //调整 参考TextField: $getRenderBounds(): Rectangle { + this.measureHeight = size; var canvasWidth = this.measureWidth; var canvasHeight = this.measureHeight; var _strokeDouble = stroke * 2; @@ -8451,17 +5900,14 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; canvasHeight += _strokeDouble * 2; } this.stroke2 = _strokeDouble; - //赋值 canvas.width = canvasWidth = Math.ceil(canvasWidth) + 2 * 2; canvas.height = canvasHeight = Math.ceil(canvasHeight) + 2 * 2; this.canvasWidthOffset = (canvas.width - this.measureWidth) / 2; this.canvasHeightOffset = (canvas.height - this.measureHeight) / 2; - //全部保留numberOfPrecision位小数 var numberOfPrecision = 3; var precision = Math.pow(10, numberOfPrecision); this.canvasWidthOffset = Math.floor(this.canvasWidthOffset * precision) / precision; this.canvasHeightOffset = Math.floor(this.canvasHeightOffset * precision) / precision; - //再开始绘制--------------------------------------- var context = egret.sys.getContext2d(canvas); context.save(); context.textAlign = 'center'; @@ -8491,16 +5937,13 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } return measureTextWidth; }; - //针对中文的加速查找 CharImageRender.chineseCharactersRegExp = new RegExp("^[\u4E00-\u9FA5]$"); CharImageRender.chineseCharacterMeasureFastMap = {}; return CharImageRender; }(egret.HashObject)); __reflect(CharImageRender.prototype, "CharImageRender"); - //对外的类 var TextAtlasRender = (function (_super) { __extends(TextAtlasRender, _super); - // function TextAtlasRender(webglRenderContext, maxSize, border) { var _this = _super.call(this) || this; _this.book = null; @@ -8513,27 +5956,21 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; _this.book = new baidugame.Book(maxSize, border); return _this; } - //分析textNode,把数据提取出来,然后给textNode挂上渲染的信息 TextAtlasRender.analysisTextNodeAndFlushDrawLabel = function (textNode) { if (!textNode) { return; } if (!baidugame.__textAtlasRender__) { - //创建,后续会转移给WebGLRenderContext var webglcontext = egret.baidugame.WebGLRenderContext.getInstance(0, 0); - //初期先512,因为不会大规模batch, 老项目最好不要直接使用这个,少数几个总变内容的TextField可以用,所以先不用$maxTextureSize - baidugame.__textAtlasRender__ = new TextAtlasRender(webglcontext, textAtlasDebug ? 512 : 512 /*webglcontext.$maxTextureSize*/, textAtlasDebug ? 12 : 1); + baidugame.__textAtlasRender__ = new TextAtlasRender(webglcontext, textAtlasDebug ? 512 : 512, textAtlasDebug ? 12 : 1); } - //清除命令 textNode[baidugame.property_drawLabel] = textNode[baidugame.property_drawLabel] || []; var drawLabels = textNode[baidugame.property_drawLabel]; for (var _i = 0, drawLabels_1 = drawLabels; _i < drawLabels_1.length; _i++) { var drawLabel = drawLabels_1[_i]; - //还回去 DrawLabel.back(drawLabel, false); } drawLabels.length = 0; - //重新装填 var offset = 4; var drawData = textNode.drawData; var anchorX = 0; @@ -8547,9 +5984,7 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; labelString = drawData[i + 2]; labelFormat = drawData[i + 3] || {}; resultAsRenderTextBlocks.length = 0; - //提取数据 baidugame.__textAtlasRender__.convertLabelStringToTextAtlas(labelString, new StyleInfo(textNode, labelFormat), resultAsRenderTextBlocks); - //pool创建 + 添加命令 var drawLabel = DrawLabel.create(); drawLabel.anchorX = anchorX; drawLabel.anchorY = anchorY; @@ -8557,32 +5992,24 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; drawLabels.push(drawLabel); } }; - //字符串转化成为TextBlock TextAtlasRender.prototype.convertLabelStringToTextAtlas = function (labelstring, styleKey, resultAsRenderTextBlocks) { var canvas = this.canvas; var charImageRender = this.charImageRender; var textBlockMap = this.textBlockMap; for (var _i = 0, labelstring_1 = labelstring; _i < labelstring_1.length; _i++) { var char = labelstring_1[_i]; - //不反复创建 charImageRender.reset(char, styleKey); if (textBlockMap[charImageRender.charWithStyleHashCode]) { - //检查重复 resultAsRenderTextBlocks.push(textBlockMap[charImageRender.charWithStyleHashCode]); continue; } - //画到到canvas charImageRender.measureAndDraw(canvas); - //创建新的文字块 var txtBlock = this.book.createTextBlock(char, canvas.width, canvas.height, charImageRender.measureWidth, charImageRender.measureHeight, charImageRender.canvasWidthOffset, charImageRender.canvasHeightOffset, charImageRender.stroke2); if (!txtBlock) { continue; } - //需要绘制 resultAsRenderTextBlocks.push(txtBlock); - //记录快速查找 textBlockMap[charImageRender.charWithStyleHashCode] = txtBlock; - //生成纹理 var page = txtBlock.page; if (!page.webGLTexture) { page.webGLTexture = this.createTextTextureAtlas(page.pageWidth, page.pageHeight, textAtlasDebug); @@ -8596,11 +6023,9 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false); } }; - //给一个page创建一个纹理 TextAtlasRender.prototype.createTextTextureAtlas = function (width, height, debug) { var texture = null; if (debug) { - //做一个黑底子的,方便调试代码 var canvas = egret.sys.createCanvas(width, width); var context = egret.sys.getContext2d(canvas); context.fillStyle = 'black'; @@ -8608,20 +6033,16 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; texture = egret.sys.createTexture(this.webglRenderContext, canvas); } else { - //真的 texture = egret.sys._createTexture(this.webglRenderContext, width, height, null); } if (texture) { - //存起来,未来可以删除,或者查看 this.textAtlasTextureCache.push(texture); } return texture; }; Object.defineProperty(TextAtlasRender.prototype, "canvas", { - //给CharImageRender用的canvas get: function () { if (!this._canvas) { - //就用默认体积24 this._canvas = egret.sys.createCanvas(24, 24); } return this._canvas; @@ -8635,41 +6056,10 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; __reflect(TextAtlasRender.prototype, "egret.baidugame.TextAtlasRender"); })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// (function (egret) { var baidugame; (function (baidugame) { - /** - * @private - */ var WEBGL_ATTRIBUTE_TYPE; (function (WEBGL_ATTRIBUTE_TYPE) { WEBGL_ATTRIBUTE_TYPE[WEBGL_ATTRIBUTE_TYPE["FLOAT_VEC2"] = 35664] = "FLOAT_VEC2"; @@ -8680,9 +6070,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; WEBGL_ATTRIBUTE_TYPE[WEBGL_ATTRIBUTE_TYPE["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE"; WEBGL_ATTRIBUTE_TYPE[WEBGL_ATTRIBUTE_TYPE["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT"; })(WEBGL_ATTRIBUTE_TYPE = baidugame.WEBGL_ATTRIBUTE_TYPE || (baidugame.WEBGL_ATTRIBUTE_TYPE = {})); - /** - * @private - */ var WEBGL_UNIFORM_TYPE; (function (WEBGL_UNIFORM_TYPE) { WEBGL_UNIFORM_TYPE[WEBGL_UNIFORM_TYPE["FLOAT_VEC2"] = 35664] = "FLOAT_VEC2"; @@ -8708,9 +6095,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; WEBGL_UNIFORM_TYPE[WEBGL_UNIFORM_TYPE["UNSIGNED_INT"] = 5125] = "UNSIGNED_INT"; WEBGL_UNIFORM_TYPE[WEBGL_UNIFORM_TYPE["FLOAT"] = 5126] = "FLOAT"; })(WEBGL_UNIFORM_TYPE = baidugame.WEBGL_UNIFORM_TYPE || (baidugame.WEBGL_UNIFORM_TYPE = {})); - /* - * 覆盖掉系统的 createCanvas - */ function mainCanvas(width, height) { return window['canvas']; } @@ -8724,9 +6108,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return canvas; } egret.sys.createCanvas = createCanvas; - /* - * 覆盖掉系统的 resizeContext - */ function resizeContext(renderContext, width, height, useMaxSize) { if (!renderContext) { return; @@ -8753,24 +6134,15 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } baidugame.resizeContext = resizeContext; egret.sys.resizeContext = resizeContext; - /** - * sys.getContextWebGL - */ function getContextWebGL(surface) { return surface ? surface.getContext('webgl') : null; } egret.sys.getContextWebGL = getContextWebGL; - /** - * sys.getContext2d - */ function getContext2d(surface) { return surface ? surface.getContext('2d') : null; } baidugame.getContext2d = getContext2d; egret.sys.getContext2d = getContext2d; - /** - * 覆盖掉系统的createTexture - */ function createTexture(renderContext, bitmapData) { var webglrendercontext = renderContext; var gl = webglrendercontext.context; @@ -8779,7 +6151,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } var texture = gl.createTexture(); if (!texture) { - //先创建texture失败,然后lost事件才发出来.. webglrendercontext.contextLost = true; return null; } @@ -8798,19 +6169,14 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return texture; } egret.sys.createTexture = createTexture; - /** - * 覆盖掉系统的createTexture - */ function _createTexture(renderContext, width, height, data) { var webglrendercontext = renderContext; var gl = webglrendercontext.context; var texture = gl.createTexture(); if (!texture) { - //先创建texture失败,然后lost事件才发出来.. webglrendercontext.contextLost = true; return null; } - // texture[egret.glContext] = gl; gl.bindTexture(gl.TEXTURE_2D, texture); gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1); @@ -8823,9 +6189,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return texture; } egret.sys._createTexture = _createTexture; - /** - * 覆盖掉系统的drawTextureElements - **/ function drawTextureElements(renderContext, data, offset) { var webglrendercontext = renderContext; var gl = webglrendercontext.context; @@ -8836,22 +6199,10 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; return size; } egret.sys.drawTextureElements = drawTextureElements; - /** - * 测量文本的宽度 - * @param context - * @param text - */ function measureTextWith(context, text) { return context.measureText(text).width; } egret.sys.measureTextWith = measureTextWith; - /** - * 为CanvasRenderBuffer创建一个HTMLCanvasElement - * @param defaultFunc - * @param width - * @param height - * @param root - */ function createCanvasRenderBufferSurface(defaultFunc, width, height, root) { if (root) { return window["canvas"]; @@ -8861,13 +6212,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; } } egret.sys.createCanvasRenderBufferSurface = createCanvasRenderBufferSurface; - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param renderContext - * @param width - * @param height - * @param useMaxSize - */ function resizeCanvasRenderBuffer(renderContext, width, height, useMaxSize) { var canvasRenderBuffer = renderContext; var surface = canvasRenderBuffer.surface; @@ -8881,7 +6225,6 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; surface.height = height; change = true; } - //尺寸没有变化时,将绘制属性重置 if (!change) { canvasRenderBuffer.context.globalCompositeOperation = "source-over"; canvasRenderBuffer.context.setTransform(1, 0, 0, 1, 0, 0); @@ -8903,4 +6246,3 @@ egret.DeviceOrientation = egret.baidugame.WebDeviceOrientation; egret.Motion = egret.baidugame.WebMotion; })(baidugame = egret.baidugame || (egret.baidugame = {})); })(egret || (egret = {})); -// window["sharedCanvas"].isCanvas = true; diff --git a/tsconfig.json b/tsconfig.json index bb28fcc..1e6aedd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "target": "es5", + "removeComments":true, "outFile": "./target/template/egret.baidugame.js" }, "files": [