Skip to content

Commit e162097

Browse files
author
David Gillen
committed
Incomplete cacheless filter support, minor other cache bugs as result
1 parent b5d88e8 commit e162097

1 file changed

Lines changed: 34 additions & 30 deletions

File tree

src/easeljs/display/StageGL.js

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,7 @@ this.createjs = this.createjs||{};
14281428
this._drawContent(container, true);
14291429

14301430
// re-align buffers with fake filter passes to solve certain error cases
1431-
if (out !== this._batchTextureOutput) {
1431+
if (out !== ((manager._filterCount%2) ? this._batchTextureConcat : this._batchTextureOutput)) {
14321432
// pre filter pass to align output, may of become misaligned due to composite operations
14331433
filtersLeft++;
14341434
}
@@ -2528,31 +2528,33 @@ this.createjs = this.createjs||{};
25282528
var l = container.children.length;
25292529
for (var i = 0; i < l; i++) {
25302530
var item = container.children[i];
2531-
var useCache = item.cacheCanvas && !ignoreCache;
2531+
var useCache = (!ignoreCache && item.cacheCanvas) || false;
25322532

25332533
if (!(item.visible && concatAlpha > 0.0035)) { continue; }
25342534

2535-
if (!useCache && item._updateState){
2536-
item._updateState();
2537-
}
2538-
2539-
if(!ignoreCache && item.filters !== null && item.filters.length) {
2540-
var bounds;
2541-
if (!item.bitmapCache) {
2542-
bounds = item.getBounds();
2543-
item.bitmapCache = new createjs.BitmapCache();
2544-
item.bitmapCache._autoGenerated = true;
2535+
if (useCache === false) {
2536+
if (item._updateState){
2537+
item._updateState();
25452538
}
2546-
if (item.bitmapCache._autoGenerated) {
2547-
this.batchReason = "cachelessFilterInterupt";
2548-
this._renderBatch(); // <----------------------------------------------------
2549-
bounds = bounds || item.getBounds();
2550-
item.bitmapCache.define(item, bounds.x, bounds.y, bounds.width, bounds.height, 1, {useGL:this});
2551-
useCache = true;
2539+
2540+
if(!ignoreCache && item.filters !== null && item.filters.length) {
2541+
var bounds;
2542+
if (item.bitmapCache === null) {
2543+
bounds = item.getBounds();
2544+
item.bitmapCache = new createjs.BitmapCache();
2545+
item.bitmapCache._autoGenerated = true;
2546+
}
2547+
if (item.bitmapCache._autoGenerated) {
2548+
this.batchReason = "cachelessFilterInterupt";
2549+
this._renderBatch(); // <----------------------------------------------------
2550+
bounds = bounds || item.getBounds();
2551+
item.bitmapCache.define(item, bounds.x, bounds.y, bounds.width, bounds.height, 1, {useGL:this});
2552+
useCache = item.bitmapCache._cacheCanvas;
2553+
}
25522554
}
25532555
}
25542556

2555-
if (!useCache && item.children) {
2557+
if (useCache === false && item.children) {
25562558
this._appendToBatch(item, cMtx, item.alpha * concatAlpha);
25572559
continue;
25582560
}
@@ -2562,8 +2564,7 @@ this.createjs = this.createjs||{};
25622564
}
25632565

25642566
// check for overflowing batch, if yes then force a render
2565-
// TODO: DHG: consider making this polygon count dependant for things like vector draws
2566-
if (this._batchVertexCount+StageGL.INDICIES_PER_CARD > this._maxBatchVertexCount) {
2567+
if (this._batchVertexCount + StageGL.INDICIES_PER_CARD > this._maxBatchVertexCount) {
25672568
this.batchReason = "vertexOverflow";
25682569
this._renderBatch(); // <------------------------------------------------------------
25692570
}
@@ -2586,8 +2587,8 @@ this.createjs = this.createjs||{};
25862587

25872588
// get the image data, or abort if not present
25882589
// BITMAP / Cached Canvas
2589-
if (item._webGLRenderStyle === 2 || useCache) {
2590-
image = (ignoreCache?false:item.cacheCanvas) || item.image;
2590+
if (item._webGLRenderStyle === 2 || useCache !== false) {
2591+
image = useCache === false ? item.image : useCache;
25912592

25922593
// SPRITE
25932594
} else if (item._webGLRenderStyle === 1) {
@@ -2627,8 +2628,9 @@ this.createjs = this.createjs||{};
26272628
texIndex = texture._activeIndex;
26282629
image._drawID = this._drawID;
26292630

2630-
if (item._webGLRenderStyle === 2 || useCache) { // BITMAP / Cached Canvas
2631-
if (!useCache && item.sourceRect) {
2631+
// BITMAP / Cached Canvas
2632+
if (item._webGLRenderStyle === 2 || useCache !== false) {
2633+
if (useCache === false && item.sourceRect) {
26322634
// calculate uvs
26332635
if (!item._uvRect) { item._uvRect = {}; }
26342636
src = item.sourceRect;
@@ -2645,16 +2647,18 @@ this.createjs = this.createjs||{};
26452647
// calculate uvs
26462648
uvRect = StageGL.UV_RECT;
26472649
// calculate vertices
2648-
if (useCache) {
2650+
if (useCache === false) {
2651+
subL = 0; subT = 0;
2652+
subR = image.width+subL; subB = image.height+subT;
2653+
} else {
26492654
src = item.bitmapCache;
26502655
subL = src.x+(src._filterOffX/src.scale); subT = src.y+(src._filterOffY/src.scale);
26512656
subR = (src._drawWidth/src.scale)+subL; subB = (src._drawHeight/src.scale)+subT;
2652-
} else {
2653-
subL = 0; subT = 0;
2654-
subR = image.width+subL; subB = image.height+subT;
26552657
}
26562658
}
2657-
} else if (item._webGLRenderStyle === 1) { // SPRITE
2659+
2660+
// SPRITE
2661+
} else if (item._webGLRenderStyle === 1) {
26582662
var rect = frame.rect;
26592663

26602664
// calculate uvs

0 commit comments

Comments
 (0)