op/clip: split Rect into pixel-aligned Rect and rounded RRect

The pixel-aligned Rect is more efficient and easier to use in the common case
of layout clipping.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-07-09 18:06:00 +02:00
parent 4818538ef8
commit d572aa23ac
14 changed files with 105 additions and 116 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ func (im Image) Layout(gtx layout.Context) layout.Dimensions {
cs := gtx.Constraints
d := cs.Constrain(image.Pt(w, h))
stack := op.Push(gtx.Ops)
clip.Rect{Rect: f32.Rectangle{Max: layout.FPt(d)}}.Add(gtx.Ops)
clip.Rect(image.Rectangle{Max: d}).Add(gtx.Ops)
im.Src.Add(gtx.Ops)
paint.PaintOp{Rect: f32.Rectangle{Max: f32.Point{X: float32(w), Y: float32(h)}}}.Add(gtx.Ops)
stack.Pop()