Skip to content

Instantly share code, notes, and snippets.

@ivanpopelyshev
Last active May 28, 2020 15:53
Show Gist options
  • Save ivanpopelyshev/5fd138caba12775e3a5ed79a03dbf14d to your computer and use it in GitHub Desktop.
Save ivanpopelyshev/5fd138caba12775e3a5ed79a03dbf14d to your computer and use it in GitHub Desktop.
export class BlitterRenderState implements core.IPreRenderState {
constructor(public cache: RuntimeCache) {
}
visit(node: Node) {
const vs = node.rendererObject as pixi.VectorSprite;
if (vs && vs.model) {
// && vs.model.preferredCache === pixi.CacheType.RuntimeWebGL ?
this.cache.foundVectors.push(vs);
}
}
screenStack: Array<core.Rectangle> = [new core.Rectangle()];
prStack: Array<PreRenderStackElement> = [new PreRenderStackElement()];
preRenderId = 0;
prNum = 0;
start(screen: core.Rectangle) {
this.screenStack[0].copyFrom(screen);
this.prNum = 0;
this.prStack[0].reset();
}
pushFilters(target: pixi.systems.FilterTarget, filters: Array<pixi.Filter>) {
this.screenStack.push(target.filterArea);
this.prNum++;
while (!this.prStack[this.prNum]) {
this.prStack.push(new PreRenderStackElement());
}
this.prStack[this.prNum].reset();
}
popFilters() {
this.screenStack.pop();
this.prNum--;
}
get sourceFrame() {
return this.screenStack[this.screenStack.length - 1];
}
get current() {
return this.prStack[this.prNum];
}
}
export class PreRenderStackElement {
snapFlags = 0;
renderObjectsNum = 0;
multiplyBlendMode = 2;
maskBalance = 0;
reset() {
this.snapFlags = 0;
this.renderObjectsNum = 0;
this.multiplyBlendMode = 2;
this.maskBalance = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment