first commit

This commit is contained in:
becarta
2025-05-16 00:17:42 +02:00
parent ea5c866137
commit bacf566ec9
6020 changed files with 1715262 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
import {
createSizedArray,
} from '../helpers/arrays';
import shapePool from './shape_pool';
import pooling from './pooling';
import ShapeCollection from '../shapes/ShapeCollection';
const shapeCollectionPool = (function () {
var ob = {
newShapeCollection: newShapeCollection,
release: release,
};
var _length = 0;
var _maxLength = 4;
var pool = createSizedArray(_maxLength);
function newShapeCollection() {
var shapeCollection;
if (_length) {
_length -= 1;
shapeCollection = pool[_length];
} else {
shapeCollection = new ShapeCollection();
}
return shapeCollection;
}
function release(shapeCollection) {
var i;
var len = shapeCollection._length;
for (i = 0; i < len; i += 1) {
shapePool.release(shapeCollection.shapes[i]);
}
shapeCollection._length = 0;
if (_length === _maxLength) {
pool = pooling.double(pool);
_maxLength *= 2;
}
pool[_length] = shapeCollection;
_length += 1;
}
return ob;
}());
export default shapeCollectionPool;