layout: [API] remove FRect

We're about to unexport f32.Rectangle, this change removes the only
public API for it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-04-26 10:46:20 +02:00
parent 3d37491342
commit fc79ec5c94
4 changed files with 224 additions and 13 deletions
+18 -4
View File
@@ -695,8 +695,8 @@ func (r *renderer) intersectPath(p *pathOp, clip image.Rectangle) {
}
fbo := r.pather.stenciler.cover(p.place.Idx)
r.ctx.BindTexture(0, fbo.tex)
coverScale, coverOff := texSpaceTransform(layout.FRect(uv), fbo.size)
subScale, subOff := texSpaceTransform(layout.FRect(sub), p.clip.Size())
coverScale, coverOff := texSpaceTransform(frect(uv), fbo.size)
subScale, subOff := texSpaceTransform(frect(sub), p.clip.Size())
r.pather.stenciler.ipipeline.uniforms.vert.uvTransform = [4]float32{coverScale.X, coverScale.Y, coverOff.X, coverOff.Y}
r.pather.stenciler.ipipeline.uniforms.vert.subUVTransform = [4]float32{subScale.X, subScale.Y, subOff.X, subOff.Y}
r.pather.stenciler.ipipeline.pipeline.UploadUniforms(r.ctx)
@@ -888,7 +888,7 @@ loop:
var op ops.ClipOp
op.Decode(encOp.Data)
quads.key.outline = op.Outline
bounds := layout.FRect(op.Bounds)
bounds := frect(op.Bounds)
trans, off := splitTransform(state.t)
if len(quads.aux) > 0 {
// There is a clipping path, build the gpu data and update the
@@ -1108,7 +1108,7 @@ func (r *renderer) drawOps(cache *resourceCache, ops []imageOp) {
Min: img.place.Pos,
Max: img.place.Pos.Add(drc.Size()),
}
coverScale, coverOff := texSpaceTransform(layout.FRect(uv), fbo.size)
coverScale, coverOff := texSpaceTransform(frect(uv), fbo.size)
p := r.pather.coverer.pipelines[m.material]
r.ctx.BindPipeline(p.pipeline)
r.ctx.BindVertexBuffer(r.blitter.quadVerts, 0)
@@ -1406,3 +1406,17 @@ func isPureOffset(t f32.Affine2D) bool {
a, b, _, d, e, _ := t.Elems()
return a == 1 && b == 0 && d == 0 && e == 1
}
// frect converts a rectangle to a f32.Rectangle.
func frect(r image.Rectangle) f32.Rectangle {
return f32.Rectangle{
Min: fpt(r.Min), Max: fpt(r.Max),
}
}
// fpt converts an point to a f32.Point.
func fpt(p image.Point) f32.Point {
return f32.Point{
X: float32(p.X), Y: float32(p.Y),
}
}