|
|
|
|
|
|
width * this._fringeWidth, |
|
|
|
height * this._fringeWidth); |
|
|
|
|
|
|
|
firstLayer = new RenderLayer { |
|
|
|
width = width, |
|
|
|
height = height, |
|
|
|
layerBounds = bounds, |
|
|
|
}; |
|
|
|
firstLayer = RenderLayer.create( |
|
|
|
width : width, |
|
|
|
height : height, |
|
|
|
layerBounds : bounds |
|
|
|
); |
|
|
|
firstLayer = new RenderLayer { |
|
|
|
width = firstLayer.width, |
|
|
|
height = firstLayer.height, |
|
|
|
layerBounds = firstLayer.layerBounds, |
|
|
|
}; |
|
|
|
firstLayer = RenderLayer.create( |
|
|
|
width : firstLayer.width, |
|
|
|
height : firstLayer.height, |
|
|
|
layerBounds : firstLayer.layerBounds |
|
|
|
); |
|
|
|
foreach (var layer in this._layers) { |
|
|
|
layer.dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
this._layers.Clear(); |
|
|
|
this._layers.Add(firstLayer); |
|
|
|
this._currentLayer = firstLayer; |
|
|
|
|
|
|
textureHeight = 1; |
|
|
|
} |
|
|
|
|
|
|
|
var layer = new RenderLayer { |
|
|
|
rtID = Shader.PropertyToID("_rtID_" + this._layers.Count + "_" + parentLayer.layers.Count), |
|
|
|
width = textureWidth, |
|
|
|
height = textureHeight, |
|
|
|
layerBounds = bounds, |
|
|
|
layerPaint = paint, |
|
|
|
}; |
|
|
|
var layer = RenderLayer.create( |
|
|
|
rtID : Shader.PropertyToID("_rtID_" + this._layers.Count + "_" + parentLayer.layers.Count), |
|
|
|
width : textureWidth, |
|
|
|
height : textureHeight, |
|
|
|
layerBounds : bounds, |
|
|
|
layerPaint : paint |
|
|
|
); |
|
|
|
|
|
|
|
parentLayer.addLayer(layer); |
|
|
|
this._layers.Add(layer); |
|
|
|
|
|
|
textureHeight = 1; |
|
|
|
} |
|
|
|
|
|
|
|
var maskLayer = new RenderLayer { |
|
|
|
rtID = Shader.PropertyToID("_rtID_" + this._layers.Count + "_" + parentLayer.layers.Count), |
|
|
|
width = textureWidth, |
|
|
|
height = textureHeight, |
|
|
|
layerBounds = maskBounds, |
|
|
|
filterMode = FilterMode.Bilinear, |
|
|
|
noMSAA = true, |
|
|
|
}; |
|
|
|
var maskLayer = RenderLayer.create( |
|
|
|
rtID : Shader.PropertyToID("_rtID_" + this._layers.Count + "_" + parentLayer.layers.Count), |
|
|
|
width : textureWidth, |
|
|
|
height : textureHeight, |
|
|
|
layerBounds : maskBounds, |
|
|
|
filterMode : FilterMode.Bilinear, |
|
|
|
noMSAA : true |
|
|
|
); |
|
|
|
|
|
|
|
parentLayer.addLayer(maskLayer); |
|
|
|
this._layers.Add(maskLayer); |
|
|
|
|
|
|
textureHeight = 1; |
|
|
|
} |
|
|
|
|
|
|
|
var blurXLayer = new RenderLayer { |
|
|
|
rtID = Shader.PropertyToID("_rtID_" + this._layers.Count + "_" + parentLayer.layers.Count), |
|
|
|
width = textureWidth, |
|
|
|
height = textureHeight, |
|
|
|
layerBounds = maskLayer.layerBounds, |
|
|
|
filterMode = FilterMode.Bilinear, |
|
|
|
noMSAA = true, |
|
|
|
}; |
|
|
|
var blurXLayer = RenderLayer.create( |
|
|
|
rtID : Shader.PropertyToID("_rtID_" + this._layers.Count + "_" + parentLayer.layers.Count), |
|
|
|
width : textureWidth, |
|
|
|
height : textureHeight, |
|
|
|
layerBounds : maskLayer.layerBounds, |
|
|
|
filterMode : FilterMode.Bilinear, |
|
|
|
noMSAA : true |
|
|
|
); |
|
|
|
var blurYLayer = new RenderLayer { |
|
|
|
rtID = Shader.PropertyToID("_rtID_" + this._layers.Count + "_" + parentLayer.layers.Count), |
|
|
|
width = textureWidth, |
|
|
|
height = textureHeight, |
|
|
|
layerBounds = maskLayer.layerBounds, |
|
|
|
filterMode = FilterMode.Bilinear, |
|
|
|
noMSAA = true, |
|
|
|
}; |
|
|
|
var blurYLayer = RenderLayer.create( |
|
|
|
rtID : Shader.PropertyToID("_rtID_" + this._layers.Count + "_" + parentLayer.layers.Count), |
|
|
|
width : textureWidth, |
|
|
|
height : textureHeight, |
|
|
|
layerBounds : maskLayer.layerBounds, |
|
|
|
filterMode : FilterMode.Bilinear, |
|
|
|
noMSAA : true |
|
|
|
); |
|
|
|
|
|
|
|
parentLayer.addLayer(blurYLayer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var subLayer in layer.layers) { |
|
|
|
this._clearLayer(subLayer); |
|
|
|
subLayer.dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
layer.layers.Clear(); |
|
|
|
|
|
|
internal class RenderLayer { |
|
|
|
internal class RenderLayer : PoolItem { |
|
|
|
public int rtID; |
|
|
|
public int width; |
|
|
|
public int height; |
|
|
|
|
|
|
public readonly List<RenderLayer> layers = new List<RenderLayer>(); |
|
|
|
public readonly List<State> states = new List<State>(); |
|
|
|
public State currentState; |
|
|
|
public readonly ClipStack clipStack = new ClipStack(); |
|
|
|
public ClipStack clipStack = new ClipStack(); |
|
|
|
public uint lastClipGenId; |
|
|
|
public Rect lastClipBounds; |
|
|
|
public bool ignoreClip = true; |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public RenderLayer() { |
|
|
|
this.currentState = new State(); |
|
|
|
this.states.Add(this.currentState); |
|
|
|
public static RenderLayer create(int rtID = 0, int width = 0, int height = 0, FilterMode filterMode = FilterMode.Point, |
|
|
|
bool noMSAA = false, Rect layerBounds = null, Paint layerPaint = null, bool ignoreClip = true) { |
|
|
|
var newLayer = ItemPoolManager.alloc<RenderLayer>(); |
|
|
|
newLayer.rtID = rtID; |
|
|
|
newLayer.width = width; |
|
|
|
newLayer.height = height; |
|
|
|
newLayer.filterMode = filterMode; |
|
|
|
newLayer.noMSAA = noMSAA; |
|
|
|
newLayer.layerBounds = layerBounds; |
|
|
|
newLayer.layerPaint = layerPaint; |
|
|
|
newLayer.ignoreClip = ignoreClip; |
|
|
|
newLayer.currentState = new State(); |
|
|
|
newLayer.states.Add(newLayer.currentState); |
|
|
|
|
|
|
|
return newLayer; |
|
|
|
} |
|
|
|
|
|
|
|
public override void dispose() { |
|
|
|
this.draws.Clear(); |
|
|
|
this.layers.Clear(); |
|
|
|
this.states.Clear(); |
|
|
|
this.clipStack = new ClipStack(); |
|
|
|
this._viewport = null; |
|
|
|
base.dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|