diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 66a948f..cb32877 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -182,6 +182,7 @@ this._mask = null; this._cacheAsBitmap = false; + this._cacheIsDirty = false; /* * MOUSE Callbacks */ @@ -377,6 +378,7 @@ if(value) { + //this._cacheIsDirty = true; this._generateCachedSprite(); } else @@ -470,11 +472,12 @@ PIXI.DisplayObject.prototype._renderCachedSprite = function(renderSession) { - if(this.dirty) + // console.log(this._cacheIsDirty) + /* if(this._cacheIsDirty) { - this._generateCachedSprite(); - this.dirty = false; - } + //this._generateCachedSprite(renderSession) + //this._cacheIsDirty = false;a + }*/ if(renderSession.gl) { @@ -486,15 +489,14 @@ } }; -PIXI.DisplayObject.prototype._generateCachedSprite = function(renderer) +PIXI.DisplayObject.prototype._generateCachedSprite = function()//renderSession) { + this._cacheAsBitmap = false; var bounds = this.getLocalBounds(); - // console.log(bounds.width); - // console.log(bounds ) - // console.log("generate sprite " + this._cachedSprite) + if(!this._cachedSprite) { - var renderTexture = new PIXI.RenderTexture(bounds.width | 0, bounds.height | 0, renderer); + var renderTexture = new PIXI.RenderTexture(bounds.width | 0, bounds.height | 0);//, renderSession.renderer); this._cachedSprite = new PIXI.Sprite(renderTexture); this._cachedSprite.worldTransform = this.worldTransform; @@ -504,13 +506,17 @@ this._cachedSprite.texture.resize(bounds.width | 0, bounds.height | 0); } + this._cachedSprite.texture.render(this); - // document.body.appendChild(renderTexture.baseTexture.source) - // this._cachedSprite.buffer.context.restore(); + + + this._cacheAsBitmap = true; }; PIXI.DisplayObject.prototype._destroyCachedSprite = function() { + if(!this._cachedSprite)return; + this._cachedSprite.texture.destroy(true); // console.log("DESTROY") // let the gc collect the unused sprite diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 66a948f..cb32877 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -182,6 +182,7 @@ this._mask = null; this._cacheAsBitmap = false; + this._cacheIsDirty = false; /* * MOUSE Callbacks */ @@ -377,6 +378,7 @@ if(value) { + //this._cacheIsDirty = true; this._generateCachedSprite(); } else @@ -470,11 +472,12 @@ PIXI.DisplayObject.prototype._renderCachedSprite = function(renderSession) { - if(this.dirty) + // console.log(this._cacheIsDirty) + /* if(this._cacheIsDirty) { - this._generateCachedSprite(); - this.dirty = false; - } + //this._generateCachedSprite(renderSession) + //this._cacheIsDirty = false;a + }*/ if(renderSession.gl) { @@ -486,15 +489,14 @@ } }; -PIXI.DisplayObject.prototype._generateCachedSprite = function(renderer) +PIXI.DisplayObject.prototype._generateCachedSprite = function()//renderSession) { + this._cacheAsBitmap = false; var bounds = this.getLocalBounds(); - // console.log(bounds.width); - // console.log(bounds ) - // console.log("generate sprite " + this._cachedSprite) + if(!this._cachedSprite) { - var renderTexture = new PIXI.RenderTexture(bounds.width | 0, bounds.height | 0, renderer); + var renderTexture = new PIXI.RenderTexture(bounds.width | 0, bounds.height | 0);//, renderSession.renderer); this._cachedSprite = new PIXI.Sprite(renderTexture); this._cachedSprite.worldTransform = this.worldTransform; @@ -504,13 +506,17 @@ this._cachedSprite.texture.resize(bounds.width | 0, bounds.height | 0); } + this._cachedSprite.texture.render(this); - // document.body.appendChild(renderTexture.baseTexture.source) - // this._cachedSprite.buffer.context.restore(); + + + this._cacheAsBitmap = true; }; PIXI.DisplayObject.prototype._destroyCachedSprite = function() { + if(!this._cachedSprite)return; + this._cachedSprite.texture.destroy(true); // console.log("DESTROY") // let the gc collect the unused sprite diff --git a/src/pixi/primitives/Graphics.js b/src/pixi/primitives/Graphics.js index 3a18769..d656185 100644 --- a/src/pixi/primitives/Graphics.js +++ b/src/pixi/primitives/Graphics.js @@ -77,17 +77,7 @@ PIXI.Graphics.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Graphics.prototype.constructor = PIXI.Graphics; -/** - * If cacheAsBitmap is true the graphics object will then be rendered as if it was a sprite. - * This is useful if your graphics element does not change often as it will speed up the rendering of the object - * It is also usful as the graphics object will always be antialiased because it will be rendered using canvas - * Not recommended if you are constanly redrawing the graphics element. - * - * @property cacheAsBitmap - * @default false - * @type Boolean - * @private - */ +/* Object.defineProperty(PIXI.Graphics.prototype, "cacheAsBitmap", { get: function() { return this._cacheAsBitmap; @@ -106,7 +96,7 @@ } } -}); +});*/ /** diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 66a948f..cb32877 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -182,6 +182,7 @@ this._mask = null; this._cacheAsBitmap = false; + this._cacheIsDirty = false; /* * MOUSE Callbacks */ @@ -377,6 +378,7 @@ if(value) { + //this._cacheIsDirty = true; this._generateCachedSprite(); } else @@ -470,11 +472,12 @@ PIXI.DisplayObject.prototype._renderCachedSprite = function(renderSession) { - if(this.dirty) + // console.log(this._cacheIsDirty) + /* if(this._cacheIsDirty) { - this._generateCachedSprite(); - this.dirty = false; - } + //this._generateCachedSprite(renderSession) + //this._cacheIsDirty = false;a + }*/ if(renderSession.gl) { @@ -486,15 +489,14 @@ } }; -PIXI.DisplayObject.prototype._generateCachedSprite = function(renderer) +PIXI.DisplayObject.prototype._generateCachedSprite = function()//renderSession) { + this._cacheAsBitmap = false; var bounds = this.getLocalBounds(); - // console.log(bounds.width); - // console.log(bounds ) - // console.log("generate sprite " + this._cachedSprite) + if(!this._cachedSprite) { - var renderTexture = new PIXI.RenderTexture(bounds.width | 0, bounds.height | 0, renderer); + var renderTexture = new PIXI.RenderTexture(bounds.width | 0, bounds.height | 0);//, renderSession.renderer); this._cachedSprite = new PIXI.Sprite(renderTexture); this._cachedSprite.worldTransform = this.worldTransform; @@ -504,13 +506,17 @@ this._cachedSprite.texture.resize(bounds.width | 0, bounds.height | 0); } + this._cachedSprite.texture.render(this); - // document.body.appendChild(renderTexture.baseTexture.source) - // this._cachedSprite.buffer.context.restore(); + + + this._cacheAsBitmap = true; }; PIXI.DisplayObject.prototype._destroyCachedSprite = function() { + if(!this._cachedSprite)return; + this._cachedSprite.texture.destroy(true); // console.log("DESTROY") // let the gc collect the unused sprite diff --git a/src/pixi/primitives/Graphics.js b/src/pixi/primitives/Graphics.js index 3a18769..d656185 100644 --- a/src/pixi/primitives/Graphics.js +++ b/src/pixi/primitives/Graphics.js @@ -77,17 +77,7 @@ PIXI.Graphics.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Graphics.prototype.constructor = PIXI.Graphics; -/** - * If cacheAsBitmap is true the graphics object will then be rendered as if it was a sprite. - * This is useful if your graphics element does not change often as it will speed up the rendering of the object - * It is also usful as the graphics object will always be antialiased because it will be rendered using canvas - * Not recommended if you are constanly redrawing the graphics element. - * - * @property cacheAsBitmap - * @default false - * @type Boolean - * @private - */ +/* Object.defineProperty(PIXI.Graphics.prototype, "cacheAsBitmap", { get: function() { return this._cacheAsBitmap; @@ -106,7 +96,7 @@ } } -}); +});*/ /** diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index ba9def4..7067b93 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -117,7 +117,7 @@ this.renderSession.maskManager = this.maskManager; this.renderSession.filterManager = this.filterManager; this.renderSession.spriteBatch = this.spriteBatch; - + this.renderSession.renderer = this; gl.useProgram(this.shaderManager.defaultShader.program); @@ -156,6 +156,18 @@ // update the scene graph stage.updateTransform(); + + // interaction + if(stage._interactive) + { + //need to add some events! + if(!stage._interactiveEventsAdded) + { + stage._interactiveEventsAdded = true; + stage.interactionManager.setTarget(this); + } + } + var gl = this.gl; // -- Does this need to be set every frame? -- // @@ -182,16 +194,7 @@ this.renderDisplayObject( stage, this.projection ); - // interaction - if(stage._interactive) - { - //need to add some events! - if(!stage._interactiveEventsAdded) - { - stage._interactiveEventsAdded = true; - stage.interactionManager.setTarget(this); - } - } + /* //can simulate context loss in Chrome like so: @@ -226,7 +229,7 @@ // start the sprite batch this.spriteBatch.begin(this.renderSession); - + // start the filter manager this.filterManager.begin(this.renderSession, buffer); diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 66a948f..cb32877 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -182,6 +182,7 @@ this._mask = null; this._cacheAsBitmap = false; + this._cacheIsDirty = false; /* * MOUSE Callbacks */ @@ -377,6 +378,7 @@ if(value) { + //this._cacheIsDirty = true; this._generateCachedSprite(); } else @@ -470,11 +472,12 @@ PIXI.DisplayObject.prototype._renderCachedSprite = function(renderSession) { - if(this.dirty) + // console.log(this._cacheIsDirty) + /* if(this._cacheIsDirty) { - this._generateCachedSprite(); - this.dirty = false; - } + //this._generateCachedSprite(renderSession) + //this._cacheIsDirty = false;a + }*/ if(renderSession.gl) { @@ -486,15 +489,14 @@ } }; -PIXI.DisplayObject.prototype._generateCachedSprite = function(renderer) +PIXI.DisplayObject.prototype._generateCachedSprite = function()//renderSession) { + this._cacheAsBitmap = false; var bounds = this.getLocalBounds(); - // console.log(bounds.width); - // console.log(bounds ) - // console.log("generate sprite " + this._cachedSprite) + if(!this._cachedSprite) { - var renderTexture = new PIXI.RenderTexture(bounds.width | 0, bounds.height | 0, renderer); + var renderTexture = new PIXI.RenderTexture(bounds.width | 0, bounds.height | 0);//, renderSession.renderer); this._cachedSprite = new PIXI.Sprite(renderTexture); this._cachedSprite.worldTransform = this.worldTransform; @@ -504,13 +506,17 @@ this._cachedSprite.texture.resize(bounds.width | 0, bounds.height | 0); } + this._cachedSprite.texture.render(this); - // document.body.appendChild(renderTexture.baseTexture.source) - // this._cachedSprite.buffer.context.restore(); + + + this._cacheAsBitmap = true; }; PIXI.DisplayObject.prototype._destroyCachedSprite = function() { + if(!this._cachedSprite)return; + this._cachedSprite.texture.destroy(true); // console.log("DESTROY") // let the gc collect the unused sprite diff --git a/src/pixi/primitives/Graphics.js b/src/pixi/primitives/Graphics.js index 3a18769..d656185 100644 --- a/src/pixi/primitives/Graphics.js +++ b/src/pixi/primitives/Graphics.js @@ -77,17 +77,7 @@ PIXI.Graphics.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.Graphics.prototype.constructor = PIXI.Graphics; -/** - * If cacheAsBitmap is true the graphics object will then be rendered as if it was a sprite. - * This is useful if your graphics element does not change often as it will speed up the rendering of the object - * It is also usful as the graphics object will always be antialiased because it will be rendered using canvas - * Not recommended if you are constanly redrawing the graphics element. - * - * @property cacheAsBitmap - * @default false - * @type Boolean - * @private - */ +/* Object.defineProperty(PIXI.Graphics.prototype, "cacheAsBitmap", { get: function() { return this._cacheAsBitmap; @@ -106,7 +96,7 @@ } } -}); +});*/ /** diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index ba9def4..7067b93 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -117,7 +117,7 @@ this.renderSession.maskManager = this.maskManager; this.renderSession.filterManager = this.filterManager; this.renderSession.spriteBatch = this.spriteBatch; - + this.renderSession.renderer = this; gl.useProgram(this.shaderManager.defaultShader.program); @@ -156,6 +156,18 @@ // update the scene graph stage.updateTransform(); + + // interaction + if(stage._interactive) + { + //need to add some events! + if(!stage._interactiveEventsAdded) + { + stage._interactiveEventsAdded = true; + stage.interactionManager.setTarget(this); + } + } + var gl = this.gl; // -- Does this need to be set every frame? -- // @@ -182,16 +194,7 @@ this.renderDisplayObject( stage, this.projection ); - // interaction - if(stage._interactive) - { - //need to add some events! - if(!stage._interactiveEventsAdded) - { - stage._interactiveEventsAdded = true; - stage.interactionManager.setTarget(this); - } - } + /* //can simulate context loss in Chrome like so: @@ -226,7 +229,7 @@ // start the sprite batch this.spriteBatch.begin(this.renderSession); - + // start the filter manager this.filterManager.begin(this.renderSession, buffer); diff --git a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js index 61ab704..a97bafb 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js @@ -31,7 +31,7 @@ this.defaultShader = renderSession.shaderManager.defaultShader; var projection = this.renderSession.projection; - + // console.log(this.width) this.width = projection.x * 2; this.height = -projection.y * 2; this.buffer = buffer; @@ -159,6 +159,7 @@ var inputTexture = texture; var outputTexture = this.texturePool.pop(); if(!outputTexture)outputTexture = new PIXI.FilterTexture(this.gl, this.width, this.height); + outputTexture.resize(this.width, this.height); // need to clear this FBO as it may have some left over elements from a previous filter. gl.bindFramebuffer(gl.FRAMEBUFFER, outputTexture.frameBuffer ); @@ -209,7 +210,7 @@ // time to render the filters texture to the previous scene if(this.filterStack.length === 0) { - gl.colorMask(true, true, true, this.transparent); + gl.colorMask(true, true, true, true);//this.transparent); } else { @@ -266,7 +267,12 @@ gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.uvArray); + //console.log(this.vertexArray) + //console.log(this.uvArray) + //console.log(sizeX + " : " + sizeY) + gl.viewport(0, 0, sizeX, sizeY); + // bind the buffer gl.bindFramebuffer(gl.FRAMEBUFFER, buffer ); @@ -324,6 +330,7 @@ // console.log(this.vertexArray[5]) } + // console.log(this.uvArray ) shader.syncUniforms(); gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);