mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
Remove Dirty Region calculations
This commit is contained in:
@@ -28,46 +28,11 @@
|
||||
//The _ccsg.Node's render command for Canvas
|
||||
_ccsg.Node.CanvasRenderCmd = function (renderable) {
|
||||
this._ctor(renderable);
|
||||
|
||||
this._currentRegion = new cc.Region();
|
||||
this._oldRegion = new cc.Region();
|
||||
this._regionFlag = 0;
|
||||
};
|
||||
|
||||
_ccsg.Node.CanvasRenderCmd.RegionStatus = {
|
||||
NotDirty: 0, //the region is not dirty
|
||||
Dirty: 1, //the region is dirty, because of color, opacity or context
|
||||
DirtyDouble: 2 //the region is moved, the old and the new one need considered when rendering
|
||||
};
|
||||
|
||||
var proto = _ccsg.Node.CanvasRenderCmd.prototype = Object.create(_ccsg.Node.RenderCmd.prototype);
|
||||
proto.constructor = _ccsg.Node.CanvasRenderCmd;
|
||||
proto._rootCtor = _ccsg.Node.CanvasRenderCmd;
|
||||
proto._notifyRegionStatus = function(status) {
|
||||
if (this._needDraw && this._regionFlag < status) {
|
||||
this._regionFlag = status;
|
||||
}
|
||||
};
|
||||
|
||||
var localBB = new cc.Rect();
|
||||
proto.getLocalBB = function() {
|
||||
var node = this._node;
|
||||
localBB.x = localBB.y = 0;
|
||||
localBB.width = node._contentSize.width;
|
||||
localBB.height = node._contentSize.height;
|
||||
return localBB;
|
||||
};
|
||||
|
||||
proto._updateCurrentRegions = function() {
|
||||
var temp = this._currentRegion;
|
||||
this._currentRegion = this._oldRegion;
|
||||
this._oldRegion = temp;
|
||||
//hittest will call the transform, and set region flag to DirtyDouble, and the changes need to be considered for rendering
|
||||
if(_ccsg.Node.CanvasRenderCmd.RegionStatus.DirtyDouble === this._regionFlag && (!this._currentRegion.isEmpty())) {
|
||||
this._oldRegion.union(this._currentRegion);
|
||||
}
|
||||
this._currentRegion.updateRegion(this.getLocalBB(), this._worldTransform);
|
||||
};
|
||||
|
||||
proto.detachFromParent = function () {
|
||||
var selChildren = this._node._children, item;
|
||||
|
||||
@@ -460,13 +460,6 @@ var View = cc._Class.extend({
|
||||
var ctx = cc._canvas.getContext('2d');
|
||||
ctx.imageSmoothingEnabled = enabled;
|
||||
ctx.mozImageSmoothingEnabled = enabled;
|
||||
// refresh canvas
|
||||
var dirtyRegion = cc.rendererCanvas._dirtyRegion;
|
||||
if (dirtyRegion) {
|
||||
var oldRegion = new cc.Region();
|
||||
oldRegion.setTo(0, 0, cc.visibleRect.width, cc.visibleRect.height);
|
||||
dirtyRegion.addRegion(oldRegion);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@ _ccsg.ParticleSystem.CanvasRenderCmd = function(renderable){
|
||||
this._needDraw = true;
|
||||
|
||||
this._pointRect = cc.rect(0, 0, 0, 0);
|
||||
//region for local bb
|
||||
this._localRegion = new cc.Region();
|
||||
this._tintCache = null;
|
||||
};
|
||||
var proto = _ccsg.ParticleSystem.CanvasRenderCmd.prototype = Object.create(_ccsg.Node.CanvasRenderCmd.prototype);
|
||||
@@ -45,29 +43,6 @@ proto.updateParticlePosition = function(particle, position){
|
||||
cc.pIn(particle.drawPos, position);
|
||||
};
|
||||
|
||||
var particleRegion = new cc.Region();
|
||||
var localBB = new cc.Rect();
|
||||
proto.updateLocalBB = function() {
|
||||
var region = this._localRegion;
|
||||
var particles = this._node._particles;
|
||||
region.setEmpty();
|
||||
for(var index = particles.length - 1; index >=0; --index) {
|
||||
var particle = particles[index];
|
||||
var pos = particle.drawPos;
|
||||
var size = particle.size * 1.415 /*a little bigger than sqrt(2)*/;
|
||||
particleRegion.setTo(pos.x - size, pos.y - size, pos.x + size, pos.y + size);
|
||||
region.union(particleRegion);
|
||||
}
|
||||
|
||||
localBB.x = region._minX; localBB.y = region._minY;
|
||||
localBB.width = region._maxX - region._minX;
|
||||
localBB.height = region._maxY - region._minY;
|
||||
};
|
||||
|
||||
proto.getLocalBB = function() {
|
||||
return localBB;
|
||||
};
|
||||
|
||||
proto.updateStatus = function() {
|
||||
this.originUpdateStatus();
|
||||
this._updateCurrentRegions();
|
||||
|
||||
Reference in New Issue
Block a user