gpu,internal/ops: decode scene commands directly, not through quads

We're about to let clip.Path use more of the compute renderer features
(lines, cubic béziers). This change prepares the gpu package for reading
one of several commands types, not just the quadratic béziers of before.

The old Quad type is still the basis for the stroking algorithms, but
this change moves it into package gpu which is the only user.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-03-11 13:47:33 +01:00
parent 07572387e3
commit eb9bf60b09
7 changed files with 116 additions and 82 deletions
+2 -3
View File
@@ -10,7 +10,6 @@ import (
"gioui.org/f32"
"gioui.org/internal/byteslice"
"gioui.org/internal/opconst"
"gioui.org/internal/ops"
"gioui.org/internal/scene"
"gioui.org/op"
)
@@ -154,7 +153,7 @@ func (p *Path) Quad(ctrl, to f32.Point) {
// QuadTo records a quadratic Bézier from the pen to end
// with the control point ctrl, with absolute coordinates.
func (p *Path) QuadTo(ctrl, to f32.Point) {
data := p.ops.Write(ops.QuadSize + 4)
data := p.ops.Write(scene.CommandSize + 4)
bo := binary.LittleEndian
bo.PutUint32(data[0:], uint32(p.contour))
encodeCommand(data[4:], scene.Quad(p.pen, ctrl, to, false))
@@ -395,5 +394,5 @@ func (o Outline) Op() Op {
}
func encodeCommand(out []byte, cmd scene.Command) {
copy(out, byteslice.Slice(cmd[:]))
copy(out, byteslice.Uint32(cmd[:]))
}