UNPKG

starling-framework

Version:

A fast, productive library for 2D cross-platform development.

93 lines (75 loc) 2.83 kB
// Class: starling.rendering.BatchPool var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this $global.Object.defineProperty(exports, "__esModule", {value: true}); var __map_reserved = {}; // Imports var $hxClasses = require("./../../hxClasses_stub").default; var $hxEnums = require("./../../hxEnums_stub").default; var $import = require("./../../import_stub").default; function Reflect() {return require("./../../Reflect");} function HxOverrides() {return require("./../../HxOverrides");} function openfl__$Vector_Vector_$Impl_$() {return require("./../../openfl/_Vector/Vector_Impl_");} function starling_display_MeshBatch() {return require("./../../starling/display/MeshBatch");} function openfl_utils__$Dictionary_Dictionary_$Impl_$() {return require("./../../openfl/utils/_Dictionary/Dictionary_Impl_");} // Constructor var BatchPool = function() { this._batchLists = (openfl_utils__$Dictionary_Dictionary_$Impl_$().default)._new(); } // Meta BatchPool.__name__ = "starling.rendering.BatchPool"; BatchPool.__isInterface__ = false; BatchPool.prototype = { purge: function() { var this1 = this._batchLists; var values = []; var _g = 0; var _g1 = (Reflect().default).fields(this1); while(_g < _g1.length) { var field = _g1[_g]; ++_g; values.push((Reflect().default).field(this1,field)); } var batchList = (HxOverrides().default).iter(values); while(batchList.hasNext()) { var batchList1 = batchList.next(); if(batchList1 != null) { var _g2 = 0; var _g11 = batchList1.length; while(_g2 < _g11) { var i = _g2++; if(batchList1[i] != null) { batchList1[i].dispose(); } } batchList1.length = 0; } } }, get: function(styleType) { var batchList = (Reflect().default).field(this._batchLists,styleType); if(batchList == null) { batchList = (openfl__$Vector_Vector_$Impl_$().default)._new(); (Reflect().default).setField(this._batchLists,styleType,batchList); } if(batchList.length > 0) { return (openfl__$Vector_Vector_$Impl_$().default).pop(batchList); } else { return new (starling_display_MeshBatch().default)(); } }, put: function(meshBatch) { var styleType = meshBatch.get_style().get_type(); var batchList = (Reflect().default).field(this._batchLists,styleType); if(batchList == null) { batchList = (openfl__$Vector_Vector_$Impl_$().default)._new(); (Reflect().default).setField(this._batchLists,styleType,batchList); } meshBatch.clear(); (openfl__$Vector_Vector_$Impl_$().default).set(batchList,batchList.length,meshBatch); } }; BatchPool.prototype.__class__ = BatchPool.prototype.constructor = $hxClasses["starling.rendering.BatchPool"] = BatchPool; // Init // Statics // Export exports.default = BatchPool;