|
|
|
|
|
|
using UnityEngine; |
|
|
|
|
|
|
|
namespace Unity.UIWidgets.ui { |
|
|
|
class ClipElement { |
|
|
|
public readonly int saveCount; |
|
|
|
public readonly uiMeshMesh mesh; |
|
|
|
public readonly bool convex; |
|
|
|
public readonly bool isRect; |
|
|
|
class ClipElement : PoolItem { |
|
|
|
public int saveCount; |
|
|
|
public uiMeshMesh mesh; |
|
|
|
public bool convex; |
|
|
|
public bool isRect; |
|
|
|
public Rect rect { get; private set; } |
|
|
|
|
|
|
|
uint _genId; |
|
|
|
|
|
|
|
|
|
|
public ClipElement(int saveCount, uiPath uiPath, uiMatrix3 matrix, float scale) { |
|
|
|
this.saveCount = saveCount; |
|
|
|
public ClipElement() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public override void clear() { |
|
|
|
this.mesh.dispose(); |
|
|
|
this.saveCount = 0; |
|
|
|
this.mesh = null; |
|
|
|
this.convex = false; |
|
|
|
this.isRect = false; |
|
|
|
this._genId = 0; |
|
|
|
this._isIntersectionOfRects = false; |
|
|
|
this._bound = null; |
|
|
|
this._invMat = null; |
|
|
|
} |
|
|
|
|
|
|
|
public static ClipElement create(int saveCount, uiPath uiPath, uiMatrix3 matrix, float scale) { |
|
|
|
ClipElement newElement = ItemPoolManager.alloc<ClipElement>(); |
|
|
|
|
|
|
|
newElement.saveCount = saveCount; |
|
|
|
this.mesh = pathCache.getFillMesh(out this.convex).transform(matrix); |
|
|
|
var fillMesh = pathCache.getFillMesh(out newElement.convex); |
|
|
|
newElement.mesh = fillMesh.transform(matrix); |
|
|
|
fillMesh.dispose(); |
|
|
|
var vertices = this.mesh.vertices; |
|
|
|
if (this.convex && vertices.Count == 4 && matrix.rectStaysRect() && |
|
|
|
var vertices = newElement.mesh.vertices; |
|
|
|
if (newElement.convex && vertices.Count == 4 && matrix.rectStaysRect() && |
|
|
|
this.isRect = true; |
|
|
|
this.rect = this.mesh.bounds; |
|
|
|
newElement.isRect = true; |
|
|
|
newElement.rect = newElement.mesh.bounds; |
|
|
|
this.isRect = false; |
|
|
|
this.rect = null; |
|
|
|
newElement.isRect = false; |
|
|
|
newElement.rect = null; |
|
|
|
|
|
|
|
return newElement; |
|
|
|
} |
|
|
|
|
|
|
|
public void setRect(Rect rect) { |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class ClipStack { |
|
|
|
class ClipStack : PoolItem { |
|
|
|
static uint _genId = wideOpenGenID; |
|
|
|
|
|
|
|
public static uint getNextGenID() { |
|
|
|
|
|
|
Rect _bound; |
|
|
|
int _saveCount; |
|
|
|
|
|
|
|
public static ClipStack create() { |
|
|
|
return ItemPoolManager.alloc<ClipStack>(); |
|
|
|
} |
|
|
|
|
|
|
|
public override void clear() { |
|
|
|
this._saveCount = 0; |
|
|
|
this._bound = null; |
|
|
|
this._lastElement = null; |
|
|
|
foreach (var clipelement in this.stack) { |
|
|
|
clipelement.dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
this.stack.Clear(); |
|
|
|
} |
|
|
|
|
|
|
|
public void save() { |
|
|
|
this._saveCount++; |
|
|
|
} |
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
var lastelement = this.stack[this.stack.Count - 1]; |
|
|
|
lastelement.dispose(); |
|
|
|
|
|
|
|
this.stack.RemoveAt(this.stack.Count - 1); |
|
|
|
this._lastElement = this.stack.Count == 0 ? null : this.stack[this.stack.Count - 1]; |
|
|
|
} |
|
|
|
|
|
|
var element = new ClipElement(this._saveCount, uiPath, matrix, scale); |
|
|
|
var element = ClipElement.create(this._saveCount, uiPath, matrix, scale); |
|
|
|
this._pushElement(element); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
if (prior.isEmpty()) { |
|
|
|
element.dispose(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
var isectRect = prior.rect.intersect(element.rect); |
|
|
|
if (isectRect.isEmpty) { |
|
|
|
prior.setEmpty(); |
|
|
|
element.dispose(); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
element.dispose(); |
|
|
|
element.dispose(); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class ReducedClip { |
|
|
|
public readonly Rect scissor; |
|
|
|
public readonly List<ClipElement> maskElements = new List<ClipElement>(); |
|
|
|
class ReducedClip : PoolItem { |
|
|
|
public Rect scissor; |
|
|
|
public List<ClipElement> maskElements = new List<ClipElement>(); |
|
|
|
ClipElement _lastElement; |
|
|
|
|
|
|
|
public bool isEmpty() { |
|
|
|
|
|
|
public ReducedClip() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public override void clear() { |
|
|
|
this.scissor = null; |
|
|
|
this.maskElements.Clear(); |
|
|
|
this._lastElement = null; |
|
|
|
} |
|
|
|
|
|
|
|
public uint maskGenID() { |
|
|
|
var element = this._lastElement; |
|
|
|
if (element == null) { |
|
|
|
|
|
|
return element.getGenID(); |
|
|
|
} |
|
|
|
|
|
|
|
public ReducedClip(ClipStack stack, Rect layerBounds, Rect queryBounds) { |
|
|
|
public static ReducedClip create(ClipStack stack, Rect layerBounds, Rect queryBounds) { |
|
|
|
ReducedClip clip = ItemPoolManager.alloc<ReducedClip>(); |
|
|
|
this.scissor = layerBounds; |
|
|
|
return; |
|
|
|
clip.scissor = layerBounds; |
|
|
|
return clip; |
|
|
|
this.scissor = stackBounds; |
|
|
|
return; |
|
|
|
clip.scissor = stackBounds; |
|
|
|
return clip; |
|
|
|
this.scissor = Rect.zero; |
|
|
|
return; |
|
|
|
clip.scissor = Rect.zero; |
|
|
|
return clip; |
|
|
|
this.scissor = queryBounds; |
|
|
|
this._walkStack(stack, this.scissor); |
|
|
|
clip.scissor = queryBounds; |
|
|
|
clip._walkStack(stack, clip.scissor); |
|
|
|
return clip; |
|
|
|
} |
|
|
|
|
|
|
|
void _walkStack(ClipStack stack, Rect queryBounds) { |
|
|
|