|
|
|
|
|
|
|
|
|
|
static readonly int _viewportId = Shader.PropertyToID("_viewport"); |
|
|
|
static readonly int _alphaId = Shader.PropertyToID("_alpha"); |
|
|
|
static readonly int _strokeMultId = Shader.PropertyToID("_strokeMult"); |
|
|
|
static readonly int _colorId = Shader.PropertyToID("_color"); |
|
|
|
static readonly int _shaderMatId = Shader.PropertyToID("_shaderMat"); |
|
|
|
static readonly int _shaderTexId = Shader.PropertyToID("_shaderTex"); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
static void _getShaderPassAndProps( |
|
|
|
PictureFlusher.RenderLayer layer, uiPaint paint, uiMatrix3? meshMatrix, float alpha, |
|
|
|
PictureFlusher.RenderLayer layer, uiPaint paint, uiMatrix3? meshMatrix, float alpha, float strokeMult, |
|
|
|
out int pass, out MaterialPropertyBlockWrapper props) { |
|
|
|
Vector4 viewport = layer.viewport; |
|
|
|
|
|
|
|
|
|
|
props.SetFloat(_strokeMultId, strokeMult); |
|
|
|
|
|
|
|
switch (paint.shader) { |
|
|
|
case null: |
|
|
|
|
|
|
public static PictureFlusher.CmdDraw convexFill(PictureFlusher.RenderLayer layer, uiPaint paint, |
|
|
|
uiMeshMesh mesh) { |
|
|
|
var mat = _convexFillMat.getMaterial(paint.blendMode, layer.ignoreClip); |
|
|
|
_getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, out var pass, out var props); |
|
|
|
_getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, 0.0f, out var pass, out var props); |
|
|
|
|
|
|
|
return PictureFlusher.CmdDraw.create( |
|
|
|
mesh: mesh, |
|
|
|
|
|
|
public static PictureFlusher.CmdDraw fill1(PictureFlusher.RenderLayer layer, uiPaint paint, |
|
|
|
uiMeshMesh mesh) { |
|
|
|
var mat = _fill1Mat.getMaterial(paint.blendMode); |
|
|
|
_getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, out var pass, out var props); |
|
|
|
_getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, 0.0f, out var pass, out var props); |
|
|
|
|
|
|
|
var ret = PictureFlusher.CmdDraw.create( |
|
|
|
mesh: mesh.boundsMesh, |
|
|
|
|
|
|
public static PictureFlusher.CmdDraw stroke0(PictureFlusher.RenderLayer layer, uiPaint paint, |
|
|
|
float alpha, uiMeshMesh mesh) { |
|
|
|
var mat = _stroke0Mat.getMaterial(paint.blendMode, layer.ignoreClip); |
|
|
|
_getShaderPassAndProps(layer, paint, mesh.matrix, alpha, out var pass, out var props); |
|
|
|
_getShaderPassAndProps(layer, paint, mesh.matrix, alpha, 0.0f, out var pass, out var props); |
|
|
|
|
|
|
|
return PictureFlusher.CmdDraw.create( |
|
|
|
mesh: mesh, |
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
public static PictureFlusher.CmdDraw strokeAlpha(PictureFlusher.RenderLayer layer, uiPaint paint, float strokeMult, uiMeshMesh mesh) { |
|
|
|
public static PictureFlusher.CmdDraw strokeAlpha(PictureFlusher.RenderLayer layer, uiPaint paint, float alpha, float strokeMult, uiMeshMesh mesh) { |
|
|
|
_getShaderPassAndProps(layer, paint, mesh.matrix, strokeMult, out var pass, out var props); |
|
|
|
_getShaderPassAndProps(layer, paint, mesh.matrix, alpha, strokeMult, out var pass, out var props); |
|
|
|
|
|
|
|
return PictureFlusher.CmdDraw.create( |
|
|
|
mesh: mesh, |
|
|
|
|
|
|
public static PictureFlusher.CmdDraw tex(PictureFlusher.RenderLayer layer, uiPaint paint, |
|
|
|
uiMeshMesh mesh, Image image) { |
|
|
|
var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip); |
|
|
|
_getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, out var pass, out var props); |
|
|
|
_getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, 0.0f, out var pass, out var props); |
|
|
|
|
|
|
|
image.texture.filterMode = paint.filterMode; |
|
|
|
props.SetTexture(_texId, image.texture); |
|
|
|
|
|
|
public static PictureFlusher.CmdDraw texRT(PictureFlusher.RenderLayer layer, uiPaint paint, |
|
|
|
uiMeshMesh mesh, PictureFlusher.RenderLayer renderLayer) { |
|
|
|
var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip); |
|
|
|
_getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, out var pass, out var props); |
|
|
|
_getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, 0.0f, out var pass, out var props); |
|
|
|
props.SetInt(_texModeId, 1); // pre alpha
|
|
|
|
|
|
|
|
return PictureFlusher.CmdDraw.create( |
|
|
|
|
|
|
uiMeshMesh mesh, TextBlobMesh textMesh, Texture tex) { |
|
|
|
var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip); |
|
|
|
var meshMatrix = mesh != null ? mesh.matrix : textMesh.matrix; |
|
|
|
_getShaderPassAndProps(layer, paint, meshMatrix, 1.0f, out var pass, out var props); |
|
|
|
_getShaderPassAndProps(layer, paint, meshMatrix, 1.0f, 0.0f, out var pass, out var props); |
|
|
|
tex.filterMode = paint.filterMode; |
|
|
|
props.SetTexture(_texId, tex); |
|
|
|
props.SetInt(_texModeId, 2); // alpha only
|
|
|
|