@pixi/prepare
Advanced tools
Comparing version 6.4.2 to 6.5.0-rc
/*! | ||
* @pixi/prepare - v6.4.2 | ||
* Compiled Thu, 02 Jun 2022 15:39:26 UTC | ||
* @pixi/prepare - v6.5.0-rc | ||
* Compiled Thu, 14 Jul 2022 18:30:46 UTC | ||
* | ||
@@ -9,3 +9,3 @@ * @pixi/prepare is licensed under the MIT License. | ||
this.PIXI = this.PIXI || {}; | ||
var _pixi_prepare = (function (exports, settings, core, graphics, ticker, display, text) { | ||
var _pixi_prepare = (function (exports, settings, core, graphics, ticker, display, text, utils) { | ||
'use strict'; | ||
@@ -24,14 +24,14 @@ | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -71,4 +71,6 @@ /* global Reflect, Promise */ | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
{ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0) | ||
{ t[p[i]] = s[p[i]]; } } } | ||
{ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
{ t[p[i]] = s[p[i]]; } | ||
} } | ||
return t; | ||
@@ -93,6 +95,7 @@ } | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -130,10 +133,15 @@ }); | ||
function __createBinding(o, m, k, k2) { | ||
if (k2 === undefined) { k2 = k; } | ||
o[k2] = m[k]; | ||
} | ||
function __exportStar(m, exports) { | ||
for (var p in m) { if (!exports.hasOwnProperty(p)) { exports[p] = m[p]; } } | ||
for (var p in m) { if (p !== "default" && !exports.hasOwnProperty(p)) { exports[p] = m[p]; } } | ||
} | ||
function __values(o) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) { return m.call(o); } | ||
return { | ||
if (o && typeof o.length === "number") { return { | ||
next: function () { | ||
@@ -143,3 +151,4 @@ if (o && i >= o.length) { o = void 0; } | ||
} | ||
}; | ||
}; } | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
} | ||
@@ -172,2 +181,12 @@ | ||
function __spreadArrays() { | ||
var arguments$1 = arguments; | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) { s += arguments$1[i].length; } | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
{ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
{ r[k] = a[j]; } } | ||
return r; | ||
}; | ||
function __await(v) { | ||
@@ -220,2 +239,17 @@ return this instanceof __await ? (this.v = v, this) : new __await(v); | ||
function __classPrivateFieldGet(receiver, privateMap) { | ||
if (!privateMap.has(receiver)) { | ||
throw new TypeError("attempted to get private field on non-instance"); | ||
} | ||
return privateMap.get(receiver); | ||
} | ||
function __classPrivateFieldSet(receiver, privateMap, value) { | ||
if (!privateMap.has(receiver)) { | ||
throw new TypeError("attempted to set private field on non-instance"); | ||
} | ||
privateMap.set(receiver, value); | ||
return value; | ||
} | ||
/** | ||
@@ -428,10 +462,5 @@ * CountLimiter limits the number of items handled by a {@link PIXI.BasePrepare} to a specified | ||
} | ||
/** | ||
* Upload all the textures and graphics to the GPU. | ||
* @param {Function|PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text} item - | ||
* Either the container or display object to search for items to upload, the items to upload themselves, | ||
* or the callback function, if items have been added using `prepare.add`. | ||
* @param {Function} [done] - Optional callback when all queued uploads have completed | ||
*/ | ||
/** @ignore */ | ||
BasePrepare.prototype.upload = function (item, done) { | ||
var _this = this; | ||
if (typeof item === 'function') { | ||
@@ -441,20 +470,28 @@ done = item; | ||
} | ||
// If a display object, search for items | ||
// that we could upload | ||
if (item) { | ||
this.add(item); | ||
if (done) { | ||
utils.deprecation('6.5.0', 'BasePrepare.upload callback is deprecated, use the return Promise instead.'); | ||
} | ||
// Get the items for upload from the display | ||
if (this.queue.length) { | ||
if (done) { | ||
this.completes.push(done); | ||
return new Promise(function (resolve) { | ||
// If a display object, search for items | ||
// that we could upload | ||
if (item) { | ||
_this.add(item); | ||
} | ||
if (!this.ticking) { | ||
this.ticking = true; | ||
ticker.Ticker.system.addOnce(this.tick, this, ticker.UPDATE_PRIORITY.UTILITY); | ||
// TODO: remove done callback and just use resolve | ||
var complete = function () { | ||
done === null || done === void 0 ? void 0 : done(); | ||
resolve(); | ||
}; | ||
// Get the items for upload from the display | ||
if (_this.queue.length) { | ||
_this.completes.push(complete); | ||
if (!_this.ticking) { | ||
_this.ticking = true; | ||
ticker.Ticker.system.addOnce(_this.tick, _this, ticker.UPDATE_PRIORITY.UTILITY); | ||
} | ||
} | ||
} | ||
else if (done) { | ||
done(); | ||
} | ||
else { | ||
complete(); | ||
} | ||
}); | ||
}; | ||
@@ -673,2 +710,7 @@ /** | ||
} | ||
/** @ignore */ | ||
Prepare.extension = { | ||
name: 'prepare', | ||
type: core.ExtensionType.RendererPlugin, | ||
}; | ||
return Prepare; | ||
@@ -711,4 +753,4 @@ }(BasePrepare)); | ||
})({}, PIXI, PIXI, PIXI, PIXI, PIXI, PIXI); | ||
})({}, PIXI, PIXI, PIXI, PIXI, PIXI, PIXI, PIXI.utils); | ||
Object.assign(this.PIXI, _pixi_prepare); | ||
//# sourceMappingURL=prepare.js.map |
/*! | ||
* @pixi/prepare - v6.4.2 | ||
* Compiled Thu, 02 Jun 2022 15:39:26 UTC | ||
* @pixi/prepare - v6.5.0-rc | ||
* Compiled Thu, 14 Jul 2022 18:30:46 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/prepare is licensed under the MIT License. | ||
*/ | ||
this.PIXI=this.PIXI||{};var _pixi_prepare=function(t,e,i,r,n,o,s){"use strict";e.settings.UPLOADS_PER_FRAME=4;var u=function(t,e){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])},u(t,e)};var a=function(){function t(t){this.maxItemsPerFrame=t,this.itemsLeft=0}return t.prototype.beginFrame=function(){this.itemsLeft=this.maxItemsPerFrame},t.prototype.allowedToUpload=function(){return this.itemsLeft-- >0},t}();function h(t,e){var r=!1;if(t&&t._textures&&t._textures.length)for(var n=0;n<t._textures.length;n++)if(t._textures[n]instanceof i.Texture){var o=t._textures[n].baseTexture;-1===e.indexOf(o)&&(e.push(o),r=!0)}return r}function c(t,e){if(t.baseTexture instanceof i.BaseTexture){var r=t.baseTexture;return-1===e.indexOf(r)&&e.push(r),!0}return!1}function l(t,e){if(t._texture&&t._texture instanceof i.Texture){var r=t._texture.baseTexture;return-1===e.indexOf(r)&&e.push(r),!0}return!1}function p(t,e){return e instanceof s.Text&&(e.updateText(!0),!0)}function f(t,e){if(e instanceof s.TextStyle){var i=e.toFontString();return s.TextMetrics.measureFont(i),!0}return!1}function d(t,e){if(t instanceof s.Text){-1===e.indexOf(t.style)&&e.push(t.style),-1===e.indexOf(t)&&e.push(t);var i=t._texture.baseTexture;return-1===e.indexOf(i)&&e.push(i),!0}return!1}function k(t,e){return t instanceof s.TextStyle&&(-1===e.indexOf(t)&&e.push(t),!0)}var x=function(){function t(t){var i=this;this.limiter=new a(e.settings.UPLOADS_PER_FRAME),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=function(){i.queue&&i.prepareItems()},this.registerFindHook(d),this.registerFindHook(k),this.registerFindHook(h),this.registerFindHook(c),this.registerFindHook(l),this.registerUploadHook(p),this.registerUploadHook(f)}return t.prototype.upload=function(t,e){"function"==typeof t&&(e=t,t=null),t&&this.add(t),this.queue.length?(e&&this.completes.push(e),this.ticking||(this.ticking=!0,n.Ticker.system.addOnce(this.tick,this,n.UPDATE_PRIORITY.UTILITY))):e&&e()},t.prototype.tick=function(){setTimeout(this.delayedTick,0)},t.prototype.prepareItems=function(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){var t=this.queue[0],e=!1;if(t&&!t._destroyed)for(var i=0,r=this.uploadHooks.length;i<r;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}e||this.queue.shift()}if(this.queue.length)n.Ticker.system.addOnce(this.tick,this,n.UPDATE_PRIORITY.UTILITY);else{this.ticking=!1;var o=this.completes.slice(0);this.completes.length=0;for(i=0,r=o.length;i<r;i++)o[i]()}},t.prototype.registerFindHook=function(t){return t&&this.addHooks.push(t),this},t.prototype.registerUploadHook=function(t){return t&&this.uploadHooks.push(t),this},t.prototype.add=function(t){for(var e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof o.Container)for(e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this},t.prototype.destroy=function(){this.ticking&&n.Ticker.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null},t}();function g(t,e){return e instanceof i.BaseTexture&&(e._glTextures[t.CONTEXT_UID]||t.texture.bind(e),!0)}function m(t,e){if(!(e instanceof r.Graphics))return!1;var i=e.geometry;e.finishPoly(),i.updateBatches();for(var n=i.batches,o=0;o<n.length;o++){var s=n[o].style.texture;s&&g(t,s.baseTexture)}return i.batchable||t.geometry.bind(i,e._resolveDirectShader(t)),!0}function T(t,e){return t instanceof r.Graphics&&(e.push(t),!0)}var y=function(t){function e(e){var i=t.call(this,e)||this;return i.uploadHookHelper=i.renderer,i.registerFindHook(T),i.registerUploadHook(g),i.registerUploadHook(m),i}return function(t,e){function i(){this.constructor=t}u(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}(e,t),e}(x),_=function(){function t(t){this.maxMilliseconds=t,this.frameStart=0}return t.prototype.beginFrame=function(){this.frameStart=Date.now()},t.prototype.allowedToUpload=function(){return Date.now()-this.frameStart<this.maxMilliseconds},t}();return t.BasePrepare=x,t.CountLimiter=a,t.Prepare=y,t.TimeLimiter=_,Object.defineProperty(t,"__esModule",{value:!0}),t}({},PIXI,PIXI,PIXI,PIXI,PIXI,PIXI);Object.assign(this.PIXI,_pixi_prepare); | ||
this.PIXI=this.PIXI||{};var _pixi_prepare=function(e,t,i,r,n,o,s){"use strict";t.settings.UPLOADS_PER_FRAME=4;var u=function(e,t){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])},u(e,t)};var a=function(){function e(e){this.maxItemsPerFrame=e,this.itemsLeft=0}return e.prototype.beginFrame=function(){this.itemsLeft=this.maxItemsPerFrame},e.prototype.allowedToUpload=function(){return this.itemsLeft-- >0},e}();function h(e,t){var r=!1;if(e&&e._textures&&e._textures.length)for(var n=0;n<e._textures.length;n++)if(e._textures[n]instanceof i.Texture){var o=e._textures[n].baseTexture;-1===t.indexOf(o)&&(t.push(o),r=!0)}return r}function c(e,t){if(e.baseTexture instanceof i.BaseTexture){var r=e.baseTexture;return-1===t.indexOf(r)&&t.push(r),!0}return!1}function l(e,t){if(e._texture&&e._texture instanceof i.Texture){var r=e._texture.baseTexture;return-1===t.indexOf(r)&&t.push(r),!0}return!1}function p(e,t){return t instanceof s.Text&&(t.updateText(!0),!0)}function f(e,t){if(t instanceof s.TextStyle){var i=t.toFontString();return s.TextMetrics.measureFont(i),!0}return!1}function d(e,t){if(e instanceof s.Text){-1===t.indexOf(e.style)&&t.push(e.style),-1===t.indexOf(e)&&t.push(e);var i=e._texture.baseTexture;return-1===t.indexOf(i)&&t.push(i),!0}return!1}function x(e,t){return e instanceof s.TextStyle&&(-1===t.indexOf(e)&&t.push(e),!0)}var k=function(){function e(e){var i=this;this.limiter=new a(t.settings.UPLOADS_PER_FRAME),this.renderer=e,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=function(){i.queue&&i.prepareItems()},this.registerFindHook(d),this.registerFindHook(x),this.registerFindHook(h),this.registerFindHook(c),this.registerFindHook(l),this.registerUploadHook(p),this.registerUploadHook(f)}return e.prototype.upload=function(e,t){var i=this;return"function"==typeof e&&(t=e,e=null),new Promise((function(r){e&&i.add(e);var o=function(){null==t||t(),r()};i.queue.length?(i.completes.push(o),i.ticking||(i.ticking=!0,n.Ticker.system.addOnce(i.tick,i,n.UPDATE_PRIORITY.UTILITY))):o()}))},e.prototype.tick=function(){setTimeout(this.delayedTick,0)},e.prototype.prepareItems=function(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){var e=this.queue[0],t=!1;if(e&&!e._destroyed)for(var i=0,r=this.uploadHooks.length;i<r;i++)if(this.uploadHooks[i](this.uploadHookHelper,e)){this.queue.shift(),t=!0;break}t||this.queue.shift()}if(this.queue.length)n.Ticker.system.addOnce(this.tick,this,n.UPDATE_PRIORITY.UTILITY);else{this.ticking=!1;var o=this.completes.slice(0);this.completes.length=0;for(i=0,r=o.length;i<r;i++)o[i]()}},e.prototype.registerFindHook=function(e){return e&&this.addHooks.push(e),this},e.prototype.registerUploadHook=function(e){return e&&this.uploadHooks.push(e),this},e.prototype.add=function(e){for(var t=0,i=this.addHooks.length;t<i&&!this.addHooks[t](e,this.queue);t++);if(e instanceof o.Container)for(t=e.children.length-1;t>=0;t--)this.add(e.children[t]);return this},e.prototype.destroy=function(){this.ticking&&n.Ticker.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null},e}();function m(e,t){return t instanceof i.BaseTexture&&(t._glTextures[e.CONTEXT_UID]||e.texture.bind(t),!0)}function g(e,t){if(!(t instanceof r.Graphics))return!1;var i=t.geometry;t.finishPoly(),i.updateBatches();for(var n=i.batches,o=0;o<n.length;o++){var s=n[o].style.texture;s&&m(e,s.baseTexture)}return i.batchable||e.geometry.bind(i,t._resolveDirectShader(e)),!0}function T(e,t){return e instanceof r.Graphics&&(t.push(e),!0)}var y=function(e){function t(t){var i=e.call(this,t)||this;return i.uploadHookHelper=i.renderer,i.registerFindHook(T),i.registerUploadHook(m),i.registerUploadHook(g),i}return function(e,t){function i(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}(t,e),t.extension={name:"prepare",type:i.ExtensionType.RendererPlugin},t}(k),_=function(){function e(e){this.maxMilliseconds=e,this.frameStart=0}return e.prototype.beginFrame=function(){this.frameStart=Date.now()},e.prototype.allowedToUpload=function(){return Date.now()-this.frameStart<this.maxMilliseconds},e}();return e.BasePrepare=k,e.CountLimiter=a,e.Prepare=y,e.TimeLimiter=_,Object.defineProperty(e,"__esModule",{value:!0}),e}({},PIXI,PIXI,PIXI,PIXI,PIXI,PIXI);Object.assign(this.PIXI,_pixi_prepare); | ||
//# sourceMappingURL=prepare.min.js.map |
/*! | ||
* @pixi/prepare - v6.4.2 | ||
* Compiled Thu, 02 Jun 2022 15:39:26 UTC | ||
* @pixi/prepare - v6.5.0-rc | ||
* Compiled Thu, 14 Jul 2022 18:30:46 UTC | ||
* | ||
@@ -18,2 +18,3 @@ * @pixi/prepare is licensed under the MIT License. | ||
var text = require('@pixi/text'); | ||
var utils = require('@pixi/utils'); | ||
@@ -31,14 +32,14 @@ /** | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -267,10 +268,5 @@ /* global Reflect, Promise */ | ||
} | ||
/** | ||
* Upload all the textures and graphics to the GPU. | ||
* @param {Function|PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text} item - | ||
* Either the container or display object to search for items to upload, the items to upload themselves, | ||
* or the callback function, if items have been added using `prepare.add`. | ||
* @param {Function} [done] - Optional callback when all queued uploads have completed | ||
*/ | ||
/** @ignore */ | ||
BasePrepare.prototype.upload = function (item, done) { | ||
var _this = this; | ||
if (typeof item === 'function') { | ||
@@ -280,20 +276,28 @@ done = item; | ||
} | ||
// If a display object, search for items | ||
// that we could upload | ||
if (item) { | ||
this.add(item); | ||
if (done) { | ||
utils.deprecation('6.5.0', 'BasePrepare.upload callback is deprecated, use the return Promise instead.'); | ||
} | ||
// Get the items for upload from the display | ||
if (this.queue.length) { | ||
if (done) { | ||
this.completes.push(done); | ||
return new Promise(function (resolve) { | ||
// If a display object, search for items | ||
// that we could upload | ||
if (item) { | ||
_this.add(item); | ||
} | ||
if (!this.ticking) { | ||
this.ticking = true; | ||
ticker.Ticker.system.addOnce(this.tick, this, ticker.UPDATE_PRIORITY.UTILITY); | ||
// TODO: remove done callback and just use resolve | ||
var complete = function () { | ||
done === null || done === void 0 ? void 0 : done(); | ||
resolve(); | ||
}; | ||
// Get the items for upload from the display | ||
if (_this.queue.length) { | ||
_this.completes.push(complete); | ||
if (!_this.ticking) { | ||
_this.ticking = true; | ||
ticker.Ticker.system.addOnce(_this.tick, _this, ticker.UPDATE_PRIORITY.UTILITY); | ||
} | ||
} | ||
} | ||
else if (done) { | ||
done(); | ||
} | ||
else { | ||
complete(); | ||
} | ||
}); | ||
}; | ||
@@ -512,2 +516,7 @@ /** | ||
} | ||
/** @ignore */ | ||
Prepare.extension = { | ||
name: 'prepare', | ||
type: core.ExtensionType.RendererPlugin, | ||
}; | ||
return Prepare; | ||
@@ -514,0 +523,0 @@ }(BasePrepare)); |
/*! | ||
* @pixi/prepare - v6.4.2 | ||
* Compiled Thu, 02 Jun 2022 15:39:26 UTC | ||
* @pixi/prepare - v6.5.0-rc | ||
* Compiled Thu, 14 Jul 2022 18:30:46 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/prepare is licensed under the MIT License. | ||
*/ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@pixi/settings"),e=require("@pixi/core"),i=require("@pixi/graphics"),r=require("@pixi/ticker"),o=require("@pixi/display"),n=require("@pixi/text");t.settings.UPLOADS_PER_FRAME=4;var s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])},s(t,e)};var u=function(){function t(t){this.maxItemsPerFrame=t,this.itemsLeft=0}return t.prototype.beginFrame=function(){this.itemsLeft=this.maxItemsPerFrame},t.prototype.allowedToUpload=function(){return this.itemsLeft-- >0},t}();function a(t,i){var r=!1;if(t&&t._textures&&t._textures.length)for(var o=0;o<t._textures.length;o++)if(t._textures[o]instanceof e.Texture){var n=t._textures[o].baseTexture;-1===i.indexOf(n)&&(i.push(n),r=!0)}return r}function h(t,i){if(t.baseTexture instanceof e.BaseTexture){var r=t.baseTexture;return-1===i.indexOf(r)&&i.push(r),!0}return!1}function p(t,i){if(t._texture&&t._texture instanceof e.Texture){var r=t._texture.baseTexture;return-1===i.indexOf(r)&&i.push(r),!0}return!1}function c(t,e){return e instanceof n.Text&&(e.updateText(!0),!0)}function l(t,e){if(e instanceof n.TextStyle){var i=e.toFontString();return n.TextMetrics.measureFont(i),!0}return!1}function f(t,e){if(t instanceof n.Text){-1===e.indexOf(t.style)&&e.push(t.style),-1===e.indexOf(t)&&e.push(t);var i=t._texture.baseTexture;return-1===e.indexOf(i)&&e.push(i),!0}return!1}function d(t,e){return t instanceof n.TextStyle&&(-1===e.indexOf(t)&&e.push(t),!0)}var x=function(){function e(e){var i=this;this.limiter=new u(t.settings.UPLOADS_PER_FRAME),this.renderer=e,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=function(){i.queue&&i.prepareItems()},this.registerFindHook(f),this.registerFindHook(d),this.registerFindHook(a),this.registerFindHook(h),this.registerFindHook(p),this.registerUploadHook(c),this.registerUploadHook(l)}return e.prototype.upload=function(t,e){"function"==typeof t&&(e=t,t=null),t&&this.add(t),this.queue.length?(e&&this.completes.push(e),this.ticking||(this.ticking=!0,r.Ticker.system.addOnce(this.tick,this,r.UPDATE_PRIORITY.UTILITY))):e&&e()},e.prototype.tick=function(){setTimeout(this.delayedTick,0)},e.prototype.prepareItems=function(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){var t=this.queue[0],e=!1;if(t&&!t._destroyed)for(var i=0,o=this.uploadHooks.length;i<o;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}e||this.queue.shift()}if(this.queue.length)r.Ticker.system.addOnce(this.tick,this,r.UPDATE_PRIORITY.UTILITY);else{this.ticking=!1;var n=this.completes.slice(0);this.completes.length=0;for(i=0,o=n.length;i<o;i++)n[i]()}},e.prototype.registerFindHook=function(t){return t&&this.addHooks.push(t),this},e.prototype.registerUploadHook=function(t){return t&&this.uploadHooks.push(t),this},e.prototype.add=function(t){for(var e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof o.Container)for(e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this},e.prototype.destroy=function(){this.ticking&&r.Ticker.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null},e}();function k(t,i){return i instanceof e.BaseTexture&&(i._glTextures[t.CONTEXT_UID]||t.texture.bind(i),!0)}function g(t,e){if(!(e instanceof i.Graphics))return!1;var r=e.geometry;e.finishPoly(),r.updateBatches();for(var o=r.batches,n=0;n<o.length;n++){var s=o[n].style.texture;s&&k(t,s.baseTexture)}return r.batchable||t.geometry.bind(r,e._resolveDirectShader(t)),!0}function m(t,e){return t instanceof i.Graphics&&(e.push(t),!0)}var T=function(t){function e(e){var i=t.call(this,e)||this;return i.uploadHookHelper=i.renderer,i.registerFindHook(m),i.registerUploadHook(k),i.registerUploadHook(g),i}return function(t,e){function i(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}(e,t),e}(x),y=function(){function t(t){this.maxMilliseconds=t,this.frameStart=0}return t.prototype.beginFrame=function(){this.frameStart=Date.now()},t.prototype.allowedToUpload=function(){return Date.now()-this.frameStart<this.maxMilliseconds},t}();exports.BasePrepare=x,exports.CountLimiter=u,exports.Prepare=T,exports.TimeLimiter=y; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@pixi/settings"),t=require("@pixi/core"),i=require("@pixi/graphics"),r=require("@pixi/ticker"),n=require("@pixi/display"),o=require("@pixi/text");e.settings.UPLOADS_PER_FRAME=4;var s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])},s(e,t)};var u=function(){function e(e){this.maxItemsPerFrame=e,this.itemsLeft=0}return e.prototype.beginFrame=function(){this.itemsLeft=this.maxItemsPerFrame},e.prototype.allowedToUpload=function(){return this.itemsLeft-- >0},e}();function a(e,i){var r=!1;if(e&&e._textures&&e._textures.length)for(var n=0;n<e._textures.length;n++)if(e._textures[n]instanceof t.Texture){var o=e._textures[n].baseTexture;-1===i.indexOf(o)&&(i.push(o),r=!0)}return r}function h(e,i){if(e.baseTexture instanceof t.BaseTexture){var r=e.baseTexture;return-1===i.indexOf(r)&&i.push(r),!0}return!1}function p(e,i){if(e._texture&&e._texture instanceof t.Texture){var r=e._texture.baseTexture;return-1===i.indexOf(r)&&i.push(r),!0}return!1}function c(e,t){return t instanceof o.Text&&(t.updateText(!0),!0)}function l(e,t){if(t instanceof o.TextStyle){var i=t.toFontString();return o.TextMetrics.measureFont(i),!0}return!1}function f(e,t){if(e instanceof o.Text){-1===t.indexOf(e.style)&&t.push(e.style),-1===t.indexOf(e)&&t.push(e);var i=e._texture.baseTexture;return-1===t.indexOf(i)&&t.push(i),!0}return!1}function d(e,t){return e instanceof o.TextStyle&&(-1===t.indexOf(e)&&t.push(e),!0)}var x=function(){function t(t){var i=this;this.limiter=new u(e.settings.UPLOADS_PER_FRAME),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=function(){i.queue&&i.prepareItems()},this.registerFindHook(f),this.registerFindHook(d),this.registerFindHook(a),this.registerFindHook(h),this.registerFindHook(p),this.registerUploadHook(c),this.registerUploadHook(l)}return t.prototype.upload=function(e,t){var i=this;return"function"==typeof e&&(t=e,e=null),new Promise((function(n){e&&i.add(e);var o=function(){null==t||t(),n()};i.queue.length?(i.completes.push(o),i.ticking||(i.ticking=!0,r.Ticker.system.addOnce(i.tick,i,r.UPDATE_PRIORITY.UTILITY))):o()}))},t.prototype.tick=function(){setTimeout(this.delayedTick,0)},t.prototype.prepareItems=function(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){var e=this.queue[0],t=!1;if(e&&!e._destroyed)for(var i=0,n=this.uploadHooks.length;i<n;i++)if(this.uploadHooks[i](this.uploadHookHelper,e)){this.queue.shift(),t=!0;break}t||this.queue.shift()}if(this.queue.length)r.Ticker.system.addOnce(this.tick,this,r.UPDATE_PRIORITY.UTILITY);else{this.ticking=!1;var o=this.completes.slice(0);this.completes.length=0;for(i=0,n=o.length;i<n;i++)o[i]()}},t.prototype.registerFindHook=function(e){return e&&this.addHooks.push(e),this},t.prototype.registerUploadHook=function(e){return e&&this.uploadHooks.push(e),this},t.prototype.add=function(e){for(var t=0,i=this.addHooks.length;t<i&&!this.addHooks[t](e,this.queue);t++);if(e instanceof n.Container)for(t=e.children.length-1;t>=0;t--)this.add(e.children[t]);return this},t.prototype.destroy=function(){this.ticking&&r.Ticker.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null},t}();function k(e,i){return i instanceof t.BaseTexture&&(i._glTextures[e.CONTEXT_UID]||e.texture.bind(i),!0)}function g(e,t){if(!(t instanceof i.Graphics))return!1;var r=t.geometry;t.finishPoly(),r.updateBatches();for(var n=r.batches,o=0;o<n.length;o++){var s=n[o].style.texture;s&&k(e,s.baseTexture)}return r.batchable||e.geometry.bind(r,t._resolveDirectShader(e)),!0}function m(e,t){return e instanceof i.Graphics&&(t.push(e),!0)}var T=function(e){function i(t){var i=e.call(this,t)||this;return i.uploadHookHelper=i.renderer,i.registerFindHook(m),i.registerUploadHook(k),i.registerUploadHook(g),i}return function(e,t){function i(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}(i,e),i.extension={name:"prepare",type:t.ExtensionType.RendererPlugin},i}(x),y=function(){function e(e){this.maxMilliseconds=e,this.frameStart=0}return e.prototype.beginFrame=function(){this.frameStart=Date.now()},e.prototype.allowedToUpload=function(){return Date.now()-this.frameStart<this.maxMilliseconds},e}();exports.BasePrepare=x,exports.CountLimiter=u,exports.Prepare=T,exports.TimeLimiter=y; | ||
//# sourceMappingURL=prepare.min.js.map |
/*! | ||
* @pixi/prepare - v6.4.2 | ||
* Compiled Thu, 02 Jun 2022 15:39:26 UTC | ||
* @pixi/prepare - v6.5.0-rc | ||
* Compiled Thu, 14 Jul 2022 18:30:46 UTC | ||
* | ||
@@ -9,3 +9,3 @@ * @pixi/prepare is licensed under the MIT License. | ||
import { settings } from '@pixi/settings'; | ||
import { Texture, BaseTexture } from '@pixi/core'; | ||
import { Texture, BaseTexture, ExtensionType } from '@pixi/core'; | ||
import { Graphics } from '@pixi/graphics'; | ||
@@ -15,2 +15,3 @@ import { Ticker, UPDATE_PRIORITY } from '@pixi/ticker'; | ||
import { Text, TextStyle, TextMetrics } from '@pixi/text'; | ||
import { deprecation } from '@pixi/utils'; | ||
@@ -28,14 +29,14 @@ /** | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -264,10 +265,5 @@ /* global Reflect, Promise */ | ||
} | ||
/** | ||
* Upload all the textures and graphics to the GPU. | ||
* @param {Function|PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text} item - | ||
* Either the container or display object to search for items to upload, the items to upload themselves, | ||
* or the callback function, if items have been added using `prepare.add`. | ||
* @param {Function} [done] - Optional callback when all queued uploads have completed | ||
*/ | ||
/** @ignore */ | ||
BasePrepare.prototype.upload = function (item, done) { | ||
var _this = this; | ||
if (typeof item === 'function') { | ||
@@ -277,20 +273,28 @@ done = item; | ||
} | ||
// If a display object, search for items | ||
// that we could upload | ||
if (item) { | ||
this.add(item); | ||
if (done) { | ||
deprecation('6.5.0', 'BasePrepare.upload callback is deprecated, use the return Promise instead.'); | ||
} | ||
// Get the items for upload from the display | ||
if (this.queue.length) { | ||
if (done) { | ||
this.completes.push(done); | ||
return new Promise(function (resolve) { | ||
// If a display object, search for items | ||
// that we could upload | ||
if (item) { | ||
_this.add(item); | ||
} | ||
if (!this.ticking) { | ||
this.ticking = true; | ||
Ticker.system.addOnce(this.tick, this, UPDATE_PRIORITY.UTILITY); | ||
// TODO: remove done callback and just use resolve | ||
var complete = function () { | ||
done === null || done === void 0 ? void 0 : done(); | ||
resolve(); | ||
}; | ||
// Get the items for upload from the display | ||
if (_this.queue.length) { | ||
_this.completes.push(complete); | ||
if (!_this.ticking) { | ||
_this.ticking = true; | ||
Ticker.system.addOnce(_this.tick, _this, UPDATE_PRIORITY.UTILITY); | ||
} | ||
} | ||
} | ||
else if (done) { | ||
done(); | ||
} | ||
else { | ||
complete(); | ||
} | ||
}); | ||
}; | ||
@@ -509,2 +513,7 @@ /** | ||
} | ||
/** @ignore */ | ||
Prepare.extension = { | ||
name: 'prepare', | ||
type: ExtensionType.RendererPlugin, | ||
}; | ||
return Prepare; | ||
@@ -511,0 +520,0 @@ }(BasePrepare)); |
/*! | ||
* @pixi/prepare - v6.4.2 | ||
* Compiled Thu, 02 Jun 2022 15:39:26 UTC | ||
* @pixi/prepare - v6.5.0-rc | ||
* Compiled Thu, 14 Jul 2022 18:30:46 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/prepare is licensed under the MIT License. | ||
*/ | ||
import{settings as t}from"@pixi/settings";import{Texture as e,BaseTexture as i}from"@pixi/core";import{Graphics as r}from"@pixi/graphics";import{Ticker as o,UPDATE_PRIORITY as n}from"@pixi/ticker";import{Container as s}from"@pixi/display";import{Text as u,TextStyle as a,TextMetrics as h}from"@pixi/text";t.UPLOADS_PER_FRAME=4;var p=function(t,e){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])},p(t,e)};var f=function(){function t(t){this.maxItemsPerFrame=t,this.itemsLeft=0}return t.prototype.beginFrame=function(){this.itemsLeft=this.maxItemsPerFrame},t.prototype.allowedToUpload=function(){return this.itemsLeft-- >0},t}();function l(t,i){var r=!1;if(t&&t._textures&&t._textures.length)for(var o=0;o<t._textures.length;o++)if(t._textures[o]instanceof e){var n=t._textures[o].baseTexture;-1===i.indexOf(n)&&(i.push(n),r=!0)}return r}function c(t,e){if(t.baseTexture instanceof i){var r=t.baseTexture;return-1===e.indexOf(r)&&e.push(r),!0}return!1}function d(t,i){if(t._texture&&t._texture instanceof e){var r=t._texture.baseTexture;return-1===i.indexOf(r)&&i.push(r),!0}return!1}function m(t,e){return e instanceof u&&(e.updateText(!0),!0)}function k(t,e){if(e instanceof a){var i=e.toFontString();return h.measureFont(i),!0}return!1}function g(t,e){if(t instanceof u){-1===e.indexOf(t.style)&&e.push(t.style),-1===e.indexOf(t)&&e.push(t);var i=t._texture.baseTexture;return-1===e.indexOf(i)&&e.push(i),!0}return!1}function x(t,e){return t instanceof a&&(-1===e.indexOf(t)&&e.push(t),!0)}var y=function(){function e(e){var i=this;this.limiter=new f(t.UPLOADS_PER_FRAME),this.renderer=e,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=function(){i.queue&&i.prepareItems()},this.registerFindHook(g),this.registerFindHook(x),this.registerFindHook(l),this.registerFindHook(c),this.registerFindHook(d),this.registerUploadHook(m),this.registerUploadHook(k)}return e.prototype.upload=function(t,e){"function"==typeof t&&(e=t,t=null),t&&this.add(t),this.queue.length?(e&&this.completes.push(e),this.ticking||(this.ticking=!0,o.system.addOnce(this.tick,this,n.UTILITY))):e&&e()},e.prototype.tick=function(){setTimeout(this.delayedTick,0)},e.prototype.prepareItems=function(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){var t=this.queue[0],e=!1;if(t&&!t._destroyed)for(var i=0,r=this.uploadHooks.length;i<r;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}e||this.queue.shift()}if(this.queue.length)o.system.addOnce(this.tick,this,n.UTILITY);else{this.ticking=!1;var s=this.completes.slice(0);this.completes.length=0;for(i=0,r=s.length;i<r;i++)s[i]()}},e.prototype.registerFindHook=function(t){return t&&this.addHooks.push(t),this},e.prototype.registerUploadHook=function(t){return t&&this.uploadHooks.push(t),this},e.prototype.add=function(t){for(var e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof s)for(e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this},e.prototype.destroy=function(){this.ticking&&o.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null},e}();function H(t,e){return e instanceof i&&(e._glTextures[t.CONTEXT_UID]||t.texture.bind(e),!0)}function _(t,e){if(!(e instanceof r))return!1;var i=e.geometry;e.finishPoly(),i.updateBatches();for(var o=i.batches,n=0;n<o.length;n++){var s=o[n].style.texture;s&&H(t,s.baseTexture)}return i.batchable||t.geometry.bind(i,e._resolveDirectShader(t)),!0}function v(t,e){return t instanceof r&&(e.push(t),!0)}var T=function(t){function e(e){var i=t.call(this,e)||this;return i.uploadHookHelper=i.renderer,i.registerFindHook(v),i.registerUploadHook(H),i.registerUploadHook(_),i}return function(t,e){function i(){this.constructor=t}p(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}(e,t),e}(y),b=function(){function t(t){this.maxMilliseconds=t,this.frameStart=0}return t.prototype.beginFrame=function(){this.frameStart=Date.now()},t.prototype.allowedToUpload=function(){return Date.now()-this.frameStart<this.maxMilliseconds},t}();export{y as BasePrepare,f as CountLimiter,T as Prepare,b as TimeLimiter}; | ||
import{settings as t}from"@pixi/settings";import{Texture as e,BaseTexture as i,ExtensionType as r}from"@pixi/core";import{Graphics as o}from"@pixi/graphics";import{Ticker as n,UPDATE_PRIORITY as s}from"@pixi/ticker";import{Container as u}from"@pixi/display";import{Text as a,TextStyle as h,TextMetrics as p}from"@pixi/text";t.UPLOADS_PER_FRAME=4;var f=function(t,e){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])},f(t,e)};var l=function(){function t(t){this.maxItemsPerFrame=t,this.itemsLeft=0}return t.prototype.beginFrame=function(){this.itemsLeft=this.maxItemsPerFrame},t.prototype.allowedToUpload=function(){return this.itemsLeft-- >0},t}();function c(t,i){var r=!1;if(t&&t._textures&&t._textures.length)for(var o=0;o<t._textures.length;o++)if(t._textures[o]instanceof e){var n=t._textures[o].baseTexture;-1===i.indexOf(n)&&(i.push(n),r=!0)}return r}function d(t,e){if(t.baseTexture instanceof i){var r=t.baseTexture;return-1===e.indexOf(r)&&e.push(r),!0}return!1}function m(t,i){if(t._texture&&t._texture instanceof e){var r=t._texture.baseTexture;return-1===i.indexOf(r)&&i.push(r),!0}return!1}function k(t,e){return e instanceof a&&(e.updateText(!0),!0)}function g(t,e){if(e instanceof h){var i=e.toFontString();return p.measureFont(i),!0}return!1}function x(t,e){if(t instanceof a){-1===e.indexOf(t.style)&&e.push(t.style),-1===e.indexOf(t)&&e.push(t);var i=t._texture.baseTexture;return-1===e.indexOf(i)&&e.push(i),!0}return!1}function y(t,e){return t instanceof h&&(-1===e.indexOf(t)&&e.push(t),!0)}var H=function(){function e(e){var i=this;this.limiter=new l(t.UPLOADS_PER_FRAME),this.renderer=e,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=function(){i.queue&&i.prepareItems()},this.registerFindHook(x),this.registerFindHook(y),this.registerFindHook(c),this.registerFindHook(d),this.registerFindHook(m),this.registerUploadHook(k),this.registerUploadHook(g)}return e.prototype.upload=function(t,e){var i=this;return"function"==typeof t&&(e=t,t=null),new Promise((function(r){t&&i.add(t);var o=function(){null==e||e(),r()};i.queue.length?(i.completes.push(o),i.ticking||(i.ticking=!0,n.system.addOnce(i.tick,i,s.UTILITY))):o()}))},e.prototype.tick=function(){setTimeout(this.delayedTick,0)},e.prototype.prepareItems=function(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){var t=this.queue[0],e=!1;if(t&&!t._destroyed)for(var i=0,r=this.uploadHooks.length;i<r;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}e||this.queue.shift()}if(this.queue.length)n.system.addOnce(this.tick,this,s.UTILITY);else{this.ticking=!1;var o=this.completes.slice(0);this.completes.length=0;for(i=0,r=o.length;i<r;i++)o[i]()}},e.prototype.registerFindHook=function(t){return t&&this.addHooks.push(t),this},e.prototype.registerUploadHook=function(t){return t&&this.uploadHooks.push(t),this},e.prototype.add=function(t){for(var e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof u)for(e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this},e.prototype.destroy=function(){this.ticking&&n.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null},e}();function v(t,e){return e instanceof i&&(e._glTextures[t.CONTEXT_UID]||t.texture.bind(e),!0)}function _(t,e){if(!(e instanceof o))return!1;var i=e.geometry;e.finishPoly(),i.updateBatches();for(var r=i.batches,n=0;n<r.length;n++){var s=r[n].style.texture;s&&v(t,s.baseTexture)}return i.batchable||t.geometry.bind(i,e._resolveDirectShader(t)),!0}function T(t,e){return t instanceof o&&(e.push(t),!0)}var b=function(t){function e(e){var i=t.call(this,e)||this;return i.uploadHookHelper=i.renderer,i.registerFindHook(T),i.registerUploadHook(v),i.registerUploadHook(_),i}return function(t,e){function i(){this.constructor=t}f(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}(e,t),e.extension={name:"prepare",type:r.RendererPlugin},e}(H),F=function(){function t(t){this.maxMilliseconds=t,this.frameStart=0}return t.prototype.beginFrame=function(){this.frameStart=Date.now()},t.prototype.allowedToUpload=function(){return Date.now()-this.frameStart<this.maxMilliseconds},t}();export{H as BasePrepare,l as CountLimiter,b as Prepare,F as TimeLimiter}; | ||
//# sourceMappingURL=prepare.min.js.map |
import type { AbstractRenderer } from '@pixi/core'; | ||
import { BaseTexture } from '@pixi/core'; | ||
import { Container } from '@pixi/display'; | ||
import { DisplayObject } from '@pixi/display'; | ||
import type { DisplayObject } from '@pixi/display'; | ||
import type { ExtensionMetadata } from '@pixi/core'; | ||
import type { Renderer } from '@pixi/core'; | ||
@@ -75,9 +76,25 @@ import { TextStyle } from '@pixi/text'; | ||
* Upload all the textures and graphics to the GPU. | ||
* @param {Function|PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text} item - | ||
* Either the container or display object to search for items to upload, the items to upload themselves, | ||
* or the callback function, if items have been added using `prepare.add`. | ||
* @param {Function} [done] - Optional callback when all queued uploads have completed | ||
* @method PIXI.BasePrepare#upload | ||
* @param {PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text} [item] - | ||
* Container or display object to search for items to upload or the items to upload themselves, | ||
* or optionally ommitted, if items have been added using {@link PIXI.BasePrepare#add `prepare.add`}. | ||
*/ | ||
upload(item: IDisplayObjectExtended | Container | BaseTexture | Texture | (() => void), done?: () => void): void; | ||
upload(item?: IDisplayObjectExtended | Container | BaseTexture | Texture): Promise<void>; | ||
/** | ||
* Use the Promise-based API instead. | ||
* @method PIXI.BasePrepare#upload | ||
* @deprecated since version 6.5.0 | ||
* @param {PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text} item - | ||
* Item to upload. | ||
* @param {Function} [done] - Callback when completed. | ||
*/ | ||
upload(item?: IDisplayObjectExtended | Container | BaseTexture | Texture, done?: () => void): void; | ||
/** | ||
* Use the Promise-based API instead. | ||
* @method PIXI.BasePrepare#upload | ||
* @deprecated since version 6.5.0 | ||
* @param {Function} [done] - Callback when completed. | ||
*/ | ||
upload(done?: () => void): void; | ||
/** | ||
* Handle tick update | ||
@@ -184,2 +201,4 @@ * @private | ||
export declare class Prepare extends BasePrepare { | ||
/** @ignore */ | ||
static extension: ExtensionMetadata; | ||
/** | ||
@@ -186,0 +205,0 @@ * @param {PIXI.Renderer} renderer - A reference to the current renderer |
{ | ||
"name": "@pixi/prepare", | ||
"version": "6.4.2", | ||
"version": "6.5.0-rc", | ||
"main": "dist/cjs/prepare.js", | ||
@@ -41,10 +41,11 @@ "module": "dist/esm/prepare.js", | ||
"peerDependencies": { | ||
"@pixi/core": "6.4.2", | ||
"@pixi/display": "6.4.2", | ||
"@pixi/graphics": "6.4.2", | ||
"@pixi/settings": "6.4.2", | ||
"@pixi/text": "6.4.2", | ||
"@pixi/ticker": "6.4.2" | ||
"@pixi/core": "6.5.0-rc", | ||
"@pixi/display": "6.5.0-rc", | ||
"@pixi/graphics": "6.5.0-rc", | ||
"@pixi/settings": "6.5.0-rc", | ||
"@pixi/text": "6.5.0-rc", | ||
"@pixi/ticker": "6.5.0-rc", | ||
"@pixi/utils": "6.5.0-rc" | ||
}, | ||
"gitHead": "a87bb87036d5fb9119ee92fd9c3da23b5bb9424b" | ||
"gitHead": "16005f83e7a6d87831ce84f8a6d460606a331ef6" | ||
} |
@@ -13,5 +13,5 @@ # @pixi/prepare | ||
import { Prepare } from '@pixi/canvas-prepare'; | ||
import { Renderer } from '@pixi/core'; | ||
import { extensions } from '@pixi/core'; | ||
Renderer.registerPlugin('prepare', Prepare); | ||
extensions.add(Prepare); | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
356068
0
2074
7
2