浏览代码

convert Rect to uiRect (struct)

/main
xingwei.zhu 6 年前
当前提交
800b3ea1
共有 8 个文件被更改,包括 297 次插入113 次删除
  1. 50
      Runtime/ui/utils/basic_types/canvas_clip.cs
  2. 99
      Runtime/ui/utils/basic_types/canvas_impl.cs
  3. 6
      Runtime/ui/utils/basic_types/canvas_utils.cs
  4. 26
      Runtime/ui/utils/basic_types/matrix.cs
  5. 19
      Runtime/ui/utils/basic_types/mesh_mesh.cs
  6. 197
      Runtime/ui/utils/basic_types/rect.cs
  7. 4
      Runtime/ui/utils/basic_types/render_cmd.cs
  8. 9
      Runtime/ui/utils/basic_types/render_layer.cs

50
Runtime/ui/utils/basic_types/canvas_clip.cs


public uiMeshMesh mesh;
public bool convex;
public bool isRect;
public Rect rect { get; private set; }
public uiRect? rect { get; private set; }
Rect _bound;
uiRect _bound;
uiMatrix3 _invMat;
public ClipElement() {

this.isRect = false;
this._genId = 0;
this._isIntersectionOfRects = false;
this._bound = null;
this._invMat = null;
}

return newElement;
}
public void setRect(Rect rect) {
public void setRect(uiRect rect) {
D.assert(this.isRect && this.rect.contains(rect));
D.assert(this.isRect && uiRectHelper.contains(this.rect.Value, rect));
this.rect = rect;
}

this._bound = Rect.zero;
this._bound = uiRectHelper.zero;
}
public void updateBoundAndGenID(ClipElement prior) {

if (this.isRect) {
this._bound = this.rect;
this._bound = this.rect.Value;
if (prior == null || prior.isIntersectionOfRects()) {
this._isIntersectionOfRects = true;
}

}
if (prior != null) {
this._bound = this._bound.intersect(prior.getBound());
this._bound = uiRectHelper.intersect(this._bound, prior.getBound());
}
if (this._bound.isEmpty) {

return this.getGenID() == ClipStack.emptyGenID;
}
public Rect getBound() {
public uiRect getBound() {
D.assert(ClipStack.invalidGenID != this._genId);
return this._bound;
}

return this._genId;
}
bool _convexContains(Rect rect) {
bool _convexContains(uiRect rect) {
if (this.mesh.vertices.Count <= 2) {
return false;
}

return true;
}
public bool contains(Rect rect) {
public bool contains(uiRect rect) {
return this.rect.contains(rect);
return uiRectHelper.contains(this.rect.Value, rect);
}
if (this.convex) {

public readonly List<ClipElement> stack = new List<ClipElement>();
ClipElement _lastElement;
Rect _bound;
uiRect _bound;
int _saveCount;
public static ClipStack create() {

public override void clear() {
this._saveCount = 0;
this._bound = null;
this._lastElement = null;
foreach (var clipelement in this.stack) {
clipelement.dispose();

if (prior.saveCount == this._saveCount) {
// can not update prior if it's cross save count.
if (prior.isRect && element.isRect) {
var isectRect = prior.rect.intersect(element.rect);
var isectRect = uiRectHelper.intersect(prior.rect.Value, element.rect.Value);
if (isectRect.isEmpty) {
prior.setEmpty();
element.dispose();

return;
}
if (!prior.getBound().overlaps(element.getBound())) {
if (!uiRectHelper.overlaps(prior.getBound(),element.getBound())) {
prior.setEmpty();
element.dispose();
return;

element.updateBoundAndGenID(prior);
}
public void getBounds(out Rect bound, out bool isIntersectionOfRects) {
public void getBounds(out uiRect? bound, out bool isIntersectionOfRects) {
if (this._lastElement == null) {
bound = null;
isIntersectionOfRects = false;

}
class ReducedClip : PoolItem {
public Rect scissor;
public uiRect? scissor;
return this.scissor != null && this.scissor.isEmpty;
return this.scissor != null && this.scissor.Value.isEmpty;
}
public ReducedClip() {

return element.getGenID();
}
public static ReducedClip create(ClipStack stack, Rect layerBounds, Rect queryBounds) {
public static ReducedClip create(ClipStack stack, uiRect layerBounds, uiRect queryBounds) {
Rect stackBounds;
uiRect? stackBounds;
bool iior;
stack.getBounds(out stackBounds, out iior);

}
stackBounds = layerBounds.intersect(stackBounds);
stackBounds = uiRectHelper.intersect(layerBounds,stackBounds.Value);
queryBounds = stackBounds.intersect(queryBounds);
queryBounds = uiRectHelper.intersect(stackBounds.Value, queryBounds);
clip.scissor = Rect.zero;
clip.scissor = uiRectHelper.zero;
clip._walkStack(stack, clip.scissor);
clip._walkStack(stack, clip.scissor.Value);
void _walkStack(ClipStack stack, Rect queryBounds) {
void _walkStack(ClipStack stack, uiRect queryBounds) {
foreach (var element in stack.stack) {
if (element.isRect) {
continue;

99
Runtime/ui/utils/basic_types/canvas_impl.cs


readonly List<RenderLayer> _layers = new List<RenderLayer>();
RenderLayer _currentLayer;
Rect _lastScissor;
uiRect? _lastScissor;
public void dispose() {
if (this._currentLayer != null) {

var width = this._renderTexture.width;
var height = this._renderTexture.height;
var bounds = Rect.fromLTWH(0, 0,
var bounds = uiRectHelper.fromLTWH(0, 0,
width * this._fringeWidth,
height * this._fringeWidth);

layer.clipStack.save();
}
void _saveLayer(Rect bounds, Paint paint) {
D.assert(bounds != null);
void _saveLayer(uiRect bounds, Paint paint) {
D.assert(bounds.width > 0);
D.assert(bounds.height > 0);
D.assert(paint != null);

layer.draws.Add(renderDraw);
var blurLayer = this._createBlurLayer(layer, filter.sigmaX, filter.sigmaY, layer);
var blurMesh = ImageMeshGenerator.imageMesh(null, Rect.one, bounds);
var blurMesh = ImageMeshGenerator.imageMesh(null, uiRectHelper.one, bounds);
layer.draws.Add(CanvasShader.texRT(layer, paint, blurMesh, blurLayer));
}
}

var currentLayer = this._currentLayer = this._layers[this._layers.Count - 1];
var state = currentLayer.currentState;
var mesh = ImageMeshGenerator.imageMesh(state.matrix, Rect.one, layer.layerBounds);
var mesh = ImageMeshGenerator.imageMesh(state.matrix, uiRectHelper.one, layer.layerBounds);
if (!this._applyClip(mesh.bounds)) {
mesh.dispose();

path.dispose();
}
void _tryAddScissor(RenderLayer layer, Rect scissor) {
if (scissor == this._lastScissor) {
void _tryAddScissor(RenderLayer layer, uiRect? scissor) {
if (uiRectHelper.equals(scissor, this._lastScissor)) {
return;
}

this._lastScissor = scissor;
}
bool _applyClip(Rect queryBounds) {
if (queryBounds == null || queryBounds.isEmpty) {
bool _applyClip(uiRect? queryBounds) {
if (queryBounds == null || queryBounds.Value.isEmpty) {
ReducedClip reducedClip = ReducedClip.create(layer.clipStack, layerBounds, queryBounds);
ReducedClip reducedClip = ReducedClip.create(layer.clipStack, layerBounds, queryBounds.Value);
if (reducedClip.isEmpty()) {
reducedClip.dispose();
return false;

var physicalRect = Rect.fromLTRB(0, 0, layer.width, layer.height);
var physicalRect = uiRectHelper.fromLTRB(0, 0, layer.width, layer.height);
if (scissor == layerBounds) {
if (uiRectHelper.equals(scissor,layerBounds)) {
var deviceScissor = Rect.fromLTRB(
scissor.left - layerBounds.left, layerBounds.bottom - scissor.bottom,
scissor.right - layerBounds.left, layerBounds.bottom - scissor.top
).scale(layer.width / layerBounds.width, layer.height / layerBounds.height);
deviceScissor = deviceScissor.roundOut();
deviceScissor = deviceScissor.intersect(physicalRect);
var deviceScissor = uiRectHelper.fromLTRB(
scissor.Value.left - layerBounds.left, layerBounds.bottom - scissor.Value.bottom,
scissor.Value.right - layerBounds.left, layerBounds.bottom - scissor.Value.top
);
deviceScissor = uiRectHelper.scale(deviceScissor, layer.width / layerBounds.width, layer.height / layerBounds.height);
deviceScissor = uiRectHelper.roundOut(deviceScissor);
deviceScissor = uiRectHelper.intersect(deviceScissor, physicalRect);
if (deviceScissor.isEmpty) {
reducedClip.dispose();

}
var maskGenID = reducedClip.maskGenID();
if (this._mustRenderClip(maskGenID, reducedClip.scissor)) {
if (this._mustRenderClip(maskGenID, reducedClip.scissor.Value)) {
if (maskGenID == ClipStack.wideOpenGenID) {
layer.ignoreClip = true;
}

// need to inflate a bit to make sure all area is cleared.
var inflatedScissor = reducedClip.scissor.inflate(this._fringeWidth);
var inflatedScissor = uiRectHelper.inflate(reducedClip.scissor.Value, this._fringeWidth);
var boundsMesh = uiMeshMesh.create(inflatedScissor);
layer.draws.Add(CanvasShader.stencilClear(layer, boundsMesh));

}
}
this._setLastClipGenId(maskGenID, reducedClip.scissor);
this._setLastClipGenId(maskGenID, reducedClip.scissor.Value);
}
reducedClip.dispose();

void _setLastClipGenId(uint clipGenId, Rect clipBounds) {
void _setLastClipGenId(uint clipGenId, uiRect clipBounds) {
bool _mustRenderClip(uint clipGenId, Rect clipBounds) {
bool _mustRenderClip(uint clipGenId, uiRect clipBounds) {
return layer.lastClipGenId != clipGenId || layer.lastClipBounds != clipBounds;
return layer.lastClipGenId != clipGenId || !uiRectHelper.equals(layer.lastClipBounds, clipBounds);
RenderLayer _createMaskLayer(RenderLayer parentLayer, Rect maskBounds, Action<Paint> drawCallback,
RenderLayer _createMaskLayer(RenderLayer parentLayer, uiRect maskBounds, Action<Paint> drawCallback,
Paint paint) {
var textureWidth = Mathf.CeilToInt(maskBounds.width * this._devicePixelRatio);
if (textureWidth < 1) {

parentLayer.addLayer(blurYLayer);
var blurMesh = ImageMeshGenerator.imageMesh(null, Rect.one, maskLayer.layerBounds);
var blurMesh = ImageMeshGenerator.imageMesh(null, uiRectHelper.one, maskLayer.layerBounds);
var kernelX = BlurUtils.get1DGaussianKernel(sigmaX, radiusX);
var kernelY = BlurUtils.get1DGaussianKernel(sigmaY, radiusY);

return blurYLayer;
}
void _drawWithMaskFilter(Rect meshBounds, Action<Paint> drawAction, Paint paint, MaskFilter maskFilter,
void _drawWithMaskFilter(uiRect meshBounds, Action<Paint> drawAction, Paint paint, MaskFilter maskFilter,
Rect stackBounds;
uiRect? stackBounds;
clipBounds = clipBounds.intersect(stackBounds);
clipBounds = uiRectHelper.intersect(clipBounds,stackBounds.Value);
}
if (clipBounds.isEmpty) {

}
float sigma3 = 3 * sigma;
var maskBounds = meshBounds.inflate(sigma3);
maskBounds = maskBounds.intersect(clipBounds.inflate(sigma3));
var maskBounds = uiRectHelper.inflate(meshBounds, sigma3);
maskBounds = uiRectHelper.intersect(maskBounds, uiRectHelper.inflate(clipBounds,sigma3));
if (maskBounds.isEmpty) {
onQuit?.Invoke();
return;

var blurLayer = this._createBlurLayer(maskLayer, sigma, sigma, layer);
var blurMesh = ImageMeshGenerator.imageMesh(null, Rect.one, maskBounds);
var blurMesh = ImageMeshGenerator.imageMesh(null, uiRectHelper.one, maskBounds);
if (!this._applyClip(blurMesh.bounds)) {
blurMesh.dispose();
onQuit?.Invoke();

this._drawImageRect(image,
null,
Rect.fromLTWH(
uiRectHelper.fromLTWH(
offset.dx, offset.dy,
image.width / this._devicePixelRatio,
image.height / this._devicePixelRatio),

void _drawImageRect(Image image, Rect src, Rect dst, Paint paint) {
void _drawImageRect(Image image, uiRect? src, uiRect dst, Paint paint) {
D.assert(dst != null);
src = Rect.one;
src = uiRectHelper.one;
src = src.scale(1f / image.width, 1f / image.height);
src = uiRectHelper.scale(src.Value, 1f / image.width, 1f / image.height);
var mesh = ImageMeshGenerator.imageMesh(state.matrix, src, dst);
var mesh = ImageMeshGenerator.imageMesh(state.matrix, src.Value, dst);
if (!this._applyClip(mesh.bounds)) {
mesh.dispose();
return;

}
void _drawImageNine(Image image, Rect src, Rect center, Rect dst, Paint paint) {
void _drawImageNine(Image image, uiRect? src, uiRect center, uiRect dst, Paint paint) {
D.assert(center != null);
D.assert(dst != null);
src = Rect.one;
src = uiRectHelper.one;
src = src.scale(scaleX, scaleY);
src = uiRectHelper.scale(src.Value, scaleX, scaleY);
center = center.scale(scaleX, scaleY);
center = uiRectHelper.scale(center, scaleX, scaleY);
var mesh = ImageMeshGenerator.imageNineMesh(state.matrix, src, center, image.width, image.height, dst);
var mesh = ImageMeshGenerator.imageNineMesh(state.matrix, src.Value, center, image.width, image.height, dst);
if (!this._applyClip(mesh.bounds)) {
mesh.dispose();
return;

break;
case DrawSaveLayer cmd: {
saveCount++;
this._saveLayer(cmd.rect, cmd.paint);
this._saveLayer(uiRectHelper.fromRect(cmd.rect), cmd.paint);
break;
}
case DrawRestore _: {

break;
}
case DrawImageRect cmd: {
this._drawImageRect(cmd.image, cmd.src, cmd.dst, cmd.paint);
this._drawImageRect(cmd.image, uiRectHelper.fromRect(cmd.src), uiRectHelper.fromRect(cmd.dst), cmd.paint);
this._drawImageNine(cmd.image, cmd.src, cmd.center, cmd.dst, cmd.paint);
this._drawImageNine(cmd.image, uiRectHelper.fromRect(cmd.src), uiRectHelper.fromRect(cmd.center), uiRectHelper.fromRect(cmd.dst), cmd.paint);
break;
}
case DrawPicture cmd: {

matrix.preTranslate(offset.dx, offset.dy);
var mesh = TextBlobMesh.create(textBlob, scale, matrix);
var textBlobBounds = matrix.mapRect(textBlob.boundsInText);
var textBlobBounds = matrix.mapRect(uiRectHelper.fromRect(textBlob.boundsInText));
// request font texture so text mesh could be generated correctly
var style = textBlob.style;

cmdBuf.DisableScissorRect();
}
else {
cmdBuf.EnableScissorRect(cmd.deviceScissor.toRect());
cmdBuf.EnableScissorRect(uiRectHelper.toRect(cmd.deviceScissor.Value));
}
break;

6
Runtime/ui/utils/basic_types/canvas_utils.cs


public static uiMeshMesh imageMesh(uiMatrix3 matrix,
Offset srcTL, Offset srcBL, Offset srcBR, Offset srcTR,
Rect dst) {
uiRect dst) {
var vertices = ItemPoolManager.alloc<uiList<Vector3>>();
vertices.SetCapacity(4);

return uiMeshMesh.create(matrix, vertices, _triangles, uv);
}
public static uiMeshMesh imageMesh(uiMatrix3 matrix, Rect src, Rect dst) {
public static uiMeshMesh imageMesh(uiMatrix3 matrix, uiRect src, uiRect dst) {
var vertices = ItemPoolManager.alloc<uiList<Vector3>>();
vertices.SetCapacity(4);

return uiMeshMesh.create(matrix, vertices, _triangles, uv);
}
public static uiMeshMesh imageNineMesh(uiMatrix3 matrix, Rect src, Rect center, int srcWidth, int srcHeight, Rect dst) {
public static uiMeshMesh imageNineMesh(uiMatrix3 matrix, uiRect src, uiRect center, int srcWidth, int srcHeight, uiRect dst) {
float x0 = dst.left;
float x3 = dst.right;
float x1 = x0 + ((center.left - src.left) * srcWidth);

26
Runtime/ui/utils/basic_types/matrix.cs


this.getMapXYProc()(this, x, y, out x1, out y1);
}
public bool mapRect(out Rect dst, Rect src) {
public bool mapRect(out uiRect dst, uiRect src) {
dst = Rect.fromLTRB(
dst = uiRectHelper.fromLTRB(
).normalize();
);
dst = uiRectHelper.normalize(dst);
return true;
}

maxY = y4;
}
dst = Rect.fromLTRB(minX, minY, maxX, maxY);
dst = uiRectHelper.fromLTRB(minX, minY, maxX, maxY);
public bool mapRect(ref Rect rect) {
public bool mapRect(ref uiRect rect) {
public Rect mapRect(Rect src) {
Rect dst;
public uiRect mapRect(uiRect src) {
uiRect dst;
public void mapRectScaleTranslate(out Rect dst, Rect src) {
public void mapRectScaleTranslate(out uiRect dst, uiRect src) {
D.assert(this.isScaleTranslate());
var sx = this.fMat[kMScaleX];

dst = Rect.fromLTRB(
dst = uiRectHelper.fromLTRB(
).normalize();
);
dst = uiRectHelper.normalize(dst);
public Offset[] mapRectToQuad(Rect rect) {
Offset[] dst = rect.toQuad();
public Offset[] mapRectToQuad(uiRect rect) {
Offset[] dst = uiRectHelper.toQuad(rect);
this.mapPoints(dst, dst);
return dst;
}

19
Runtime/ui/utils/basic_types/mesh_mesh.cs


public uiList<int> triangles;
public uiList<Vector2> uv;
public uiMatrix3 matrix;
public Rect rawBounds;
public uiRect rawBounds;
Rect _bounds;
uiRect? _bounds;
public Rect bounds {
public uiRect bounds {
return this._bounds;
return this._bounds.Value;
}
}

this.triangles = null;
this.uv = null;
this.matrix = null;
this.rawBounds = null;
public static uiMeshMesh create(Rect rect) {
public static uiMeshMesh create(uiRect rect) {
uiMeshMesh newMesh = ItemPoolManager.alloc<uiMeshMesh>();
newMesh.vertices = ItemPoolManager.alloc<uiList<Vector3>>();

}
public static uiMeshMesh create(uiMatrix3 matrix, uiList<Vector3> vertices, uiList<int> triangles, uiList<Vector2> uv = null,
Rect rawBounds = null) {
uiRect? rawBounds = null) {
D.assert(vertices != null);
D.assert(vertices.Count >= 0);
D.assert(triangles != null);

}
}
rawBounds = Rect.fromLTRB(minX, minY, maxX, maxY);
rawBounds = uiRectHelper.fromLTRB(minX, minY, maxX, maxY);
rawBounds = Rect.zero;
rawBounds = uiRectHelper.zero;
newMesh.rawBounds = rawBounds;
newMesh.rawBounds = rawBounds.Value;
return newMesh;
}

197
Runtime/ui/utils/basic_types/rect.cs


public struct uiRect {
public uiRect(float left, float top, float right, float bottom) {
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
public readonly float left;
public readonly float top;
public readonly float right;
public readonly float bottom;
public bool isEmpty {
get { return this.left >= this.right || this.top >= this.bottom; }
}
public float width {
get { return this.right - this.left; }
}
public float height {
get { return this.bottom - this.top; }
}
public Offset topLeft {
get { return new Offset(this.left, this.top); }
}
public Offset topCenter {
get { return new Offset(this.left + this.width / 2.0f, this.top); }
}
public Offset topRight {
get { return new Offset(this.right, this.top); }
}
public Offset centerLeft {
get { return new Offset(this.left, this.top + this.height / 2.0f); }
}
public Offset center {
get { return new Offset(this.left + this.width / 2.0f, this.top + this.height / 2.0f); }
}
public Offset centerRight {
get { return new Offset(this.right, this.bottom); }
}
public Offset bottomLeft {
get { return new Offset(this.left, this.bottom); }
}
public Offset bottomCenter {
get { return new Offset(this.left + this.width / 2.0f, this.bottom); }
}
public Offset bottomRight {
get { return new Offset(this.right, this.bottom); }
}
}
public static class uiRectHelper {
public static uiRect fromRect(Rect rect) {
return new uiRect(rect.left, rect.top, rect.right, rect.bottom);
}
public static uiRect fromLTRB(float left, float top, float right, float bottom) {
return new uiRect(left, top, right, bottom);
}
public static uiRect fromLTWH(float left, float top, float width, float height) {
return new uiRect(left, top, left + width, top + height);
}
public static readonly uiRect zero = new uiRect(0, 0, 0, 0);
public static readonly uiRect one = new uiRect(0, 0, 1, 1);
public static bool equals(uiRect? a, uiRect? b) {
if (a == null && b == null) return true;
if (a == null || b == null) return false;
var aval = a.Value;
var bval = b.Value;
return aval.left == bval.left && aval.right == bval.right && aval.top == bval.top && aval.bottom == bval.bottom;
}
public static uiRect scale(uiRect a, float scaleX, float? scaleY = null) {
scaleY = scaleY ?? scaleX;
return fromLTRB(
a.left * scaleX, a.top * scaleY.Value,
a.right * scaleX, a.bottom * scaleY.Value);
}
public static uiRect inflate(uiRect a, float delta) {
return fromLTRB(a.left - delta, a.top - delta, a.right + delta, a.bottom + delta);
}
public static uiRect deflate(uiRect a, float delta) {
return inflate(a, -delta);
}
public static uiRect intersect(uiRect a, uiRect other) {
return fromLTRB(
Mathf.Max(a.left, other.left),
Mathf.Max(a.top, other.top),
Mathf.Min(a.right, other.right),
Mathf.Min(a.bottom, other.bottom)
);
}
public static uiRect round(uiRect a) {
return fromLTRB(
Mathf.Round(a.left), Mathf.Round(a.top),
Mathf.Round(a.right), Mathf.Round(a.bottom));
}
public static uiRect roundOut(uiRect a) {
return fromLTRB(
Mathf.Floor(a.left), Mathf.Floor(a.top),
Mathf.Ceil(a.right), Mathf.Ceil(a.bottom));
}
public static uiRect roundOut(uiRect a, float devicePixelRatio) {
return fromLTRB(
Mathf.Floor(a.left * devicePixelRatio) / devicePixelRatio,
Mathf.Floor(a.top * devicePixelRatio) / devicePixelRatio,
Mathf.Ceil(a.right * devicePixelRatio) / devicePixelRatio,
Mathf.Ceil(a.bottom * devicePixelRatio) / devicePixelRatio);
}
public static uiRect roundIn(uiRect a) {
return fromLTRB(
Mathf.Ceil(a.left), Mathf.Ceil(a.top),
Mathf.Floor(a.right), Mathf.Floor(a.bottom));
}
public static uiRect normalize(uiRect a) {
if (a.left <= a.right && a.top <= a.bottom) {
return a;
}
return fromLTRB(
Mathf.Min(a.left, a.right),
Mathf.Min(a.top, a.bottom),
Mathf.Max(a.left, a.right),
Mathf.Max(a.top, a.bottom)
);
}
public static Offset[] toQuad(uiRect a) {
Offset[] dst = new Offset[4];
dst[0] = new Offset(a.left, a.top);
dst[1] = new Offset(a.right, a.top);
dst[2] = new Offset(a.right, a.bottom);
dst[3] = new Offset(a.left, a.bottom);
return dst;
}
public static bool contains(uiRect a, Offset offset) {
return offset.dx >= a.left && offset.dx < a.right && offset.dy >= a.top && offset.dy < a.bottom;
}
public static bool contains(uiRect a, uiRect rect) {
return contains(a, rect.topLeft) && contains(a, rect.bottomRight);
}
public static bool overlaps(uiRect a, uiRect other) {
if (a.right <= other.left || other.right <= a.left) {
return false;
}
if (a.bottom <= other.top || other.bottom <= a.top) {
return false;
}
return true;
}
public static UnityEngine.Rect toRect(uiRect rect) {
return new UnityEngine.Rect(rect.left, rect.top, rect.width, rect.height);
}
}
public class uiRect : IEquatable<Rect> {
/*public struct uiRect : IEquatable<uiRect> {
uiRect(float left, float top, float right, float bottom) {
this.left = left;
this.top = top;

);
}
public static uiRect lerp(Rect a, Rect b, float t) {
public static uiRect lerp(uiRect a, uiRect b, float t) {
return null;
Debug.Assert(false, "uiRect cannot be lerpped between two nulls!");
return zero;
}
if (a == null) {

return "Rect.fromLTRB(" + this.left.ToString("0.0") + ", " + this.top.ToString("0.0") + ", " +
this.right.ToString("0.0") + ", " + this.bottom.ToString("0.0") + ")";
}
}
}*/
}

4
Runtime/ui/utils/basic_types/render_cmd.cs


}
internal class CmdScissor : RenderCmd {
public Rect deviceScissor;
public uiRect? deviceScissor;
public CmdScissor() {
}

}
public static CmdScissor create(Rect deviceScissor) {
public static CmdScissor create(uiRect? deviceScissor) {
CmdScissor newCmd = ItemPoolManager.alloc<CmdScissor>();
newCmd.deviceScissor = deviceScissor;
return newCmd;

9
Runtime/ui/utils/basic_types/render_layer.cs


public int height;
public FilterMode filterMode = FilterMode.Point;
public bool noMSAA = false;
public Rect layerBounds;
public uiRect layerBounds;
public Paint layerPaint;
public readonly List<RenderCmd> draws = new List<RenderCmd>();
public readonly List<RenderLayer> layers = new List<RenderLayer>();

public uint lastClipGenId;
public Rect lastClipBounds;
public uiRect lastClipBounds;
public bool ignoreClip = true;
Vector4? _viewport;

}
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) {
bool noMSAA = false, uiRect? layerBounds = null, Paint layerPaint = null, bool ignoreClip = true) {
D.assert(layerBounds != null);
var newLayer = ItemPoolManager.alloc<RenderLayer>();
newLayer.rtID = rtID;
newLayer.width = width;

newLayer.layerBounds = layerBounds;
newLayer.layerBounds = layerBounds.Value;
newLayer.layerPaint = layerPaint;
newLayer.ignoreClip = ignoreClip;
newLayer.currentState = State.create();

正在加载...
取消
保存