|
|
|
|
|
|
|
|
|
|
readonly SubmitCallback _submitCallback; |
|
|
|
|
|
|
|
public SurfaceFrame(GrSurface surface, SubmitCallback submitCallback) { |
|
|
|
int _antiAliasing; |
|
|
|
|
|
|
|
public SurfaceFrame(GrSurface surface, SubmitCallback submitCallback, int antiAliasing = Window.DefaultAntiAliasing) { |
|
|
|
this._antiAliasing = antiAliasing; |
|
|
|
} |
|
|
|
|
|
|
|
public void Dispose() { |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public Canvas getCanvas() { |
|
|
|
return this._surface != null ? this._surface.getCanvas() : null; |
|
|
|
return this._surface != null ? this._surface.getCanvas(this._antiAliasing) : null; |
|
|
|
} |
|
|
|
|
|
|
|
public bool submit() { |
|
|
|
|
|
|
GrSurface _surface; |
|
|
|
readonly DrawToTargetFunc _drawToTargetFunc; |
|
|
|
MeshPool _meshPool = new MeshPool(); |
|
|
|
int _antiAliasing; |
|
|
|
public EditorWindowSurface(DrawToTargetFunc drawToTargetFunc = null) { |
|
|
|
public EditorWindowSurface(DrawToTargetFunc drawToTargetFunc = null, int antiAliasing = Window.DefaultAntiAliasing) { |
|
|
|
this._antiAliasing = antiAliasing; |
|
|
|
} |
|
|
|
|
|
|
|
public SurfaceFrame acquireFrame(Size size, float devicePixelRatio) { |
|
|
|
|
|
|
(frame, canvas) => this._presentSurface(canvas)); |
|
|
|
(frame, canvas) => this._presentSurface(canvas, this._antiAliasing)); |
|
|
|
} |
|
|
|
|
|
|
|
public MeshPool getMeshPool() { |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected bool _presentSurface(Canvas canvas) { |
|
|
|
protected bool _presentSurface(Canvas canvas, int antiAliasing) { |
|
|
|
this._surface.getCanvas().flush(); |
|
|
|
this._surface.getCanvas().reset(); |
|
|
|
this._surface.getCanvas(antiAliasing).flush(); |
|
|
|
this._surface.getCanvas(antiAliasing).reset(); |
|
|
|
|
|
|
|
var screenRect = new Rect(0, 0, |
|
|
|
this._surface.size.width / this._surface.devicePixelRatio, |
|
|
|
|
|
|
this._surface = null; |
|
|
|
} |
|
|
|
|
|
|
|
this._surface = new GrSurface(size, devicePixelRatio, this._meshPool); |
|
|
|
this._surface = new GrSurface(size, devicePixelRatio, this._meshPool, this._antiAliasing); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
return this._renderTexture; |
|
|
|
} |
|
|
|
|
|
|
|
public Canvas getCanvas() { |
|
|
|
public Canvas getCanvas(int antiAliasing) { |
|
|
|
this._renderTexture, this.devicePixelRatio, this._meshPool); |
|
|
|
this._renderTexture, this.devicePixelRatio, this._meshPool, antiAliasing); |
|
|
|
public GrSurface(Size size, float devicePixelRatio, MeshPool meshPool) { |
|
|
|
public GrSurface(Size size, float devicePixelRatio, MeshPool meshPool, int antiAliasing) { |
|
|
|
this.size = size; |
|
|
|
this.devicePixelRatio = devicePixelRatio; |
|
|
|
|
|
|
|
|
|
|
autoGenerateMips = false, |
|
|
|
}; |
|
|
|
|
|
|
|
if (Window.instance.antiAliasing != 0) { |
|
|
|
desc.msaaSamples = Window.instance.antiAliasing; |
|
|
|
if (antiAliasing != 0) { |
|
|
|
desc.msaaSamples = antiAliasing; |
|
|
|
} |
|
|
|
|
|
|
|
this._renderTexture = new RenderTexture(desc); |
|
|
|