mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 10:25:37 +00:00
gpu/internal/rendertest: test textured strokes, including clipping
The new compute renderer can draw simple strokes. Test that clipping works with a stroke basis, and that images can be drawn into strokes. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -118,6 +118,39 @@ func TestPaintTexture(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTexturedStrokeClipped(t *testing.T) {
|
||||||
|
run(t, func(o *op.Ops) {
|
||||||
|
smallSquares.Add(o)
|
||||||
|
op.Offset(f32.Pt(50, 50)).Add(o)
|
||||||
|
clip.Stroke{
|
||||||
|
Path: clip.RRect{Rect: f32.Rect(0, 0, 30, 30)}.Path(o),
|
||||||
|
Style: clip.StrokeStyle{
|
||||||
|
Width: 10,
|
||||||
|
},
|
||||||
|
}.Op().Add(o)
|
||||||
|
clip.RRect{Rect: f32.Rect(-30, -30, 60, 60)}.Add(o)
|
||||||
|
op.Offset(f32.Pt(-10, -10)).Add(o)
|
||||||
|
paint.PaintOp{}.Add(o)
|
||||||
|
}, func(r result) {
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTexturedStroke(t *testing.T) {
|
||||||
|
run(t, func(o *op.Ops) {
|
||||||
|
smallSquares.Add(o)
|
||||||
|
op.Offset(f32.Pt(50, 50)).Add(o)
|
||||||
|
clip.Stroke{
|
||||||
|
Path: clip.RRect{Rect: f32.Rect(0, 0, 30, 30)}.Path(o),
|
||||||
|
Style: clip.StrokeStyle{
|
||||||
|
Width: 10,
|
||||||
|
},
|
||||||
|
}.Op().Add(o)
|
||||||
|
op.Offset(f32.Pt(-10, -10)).Add(o)
|
||||||
|
paint.PaintOp{}.Add(o)
|
||||||
|
}, func(r result) {
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestPaintClippedTexture(t *testing.T) {
|
func TestPaintClippedTexture(t *testing.T) {
|
||||||
run(t, func(o *op.Ops) {
|
run(t, func(o *op.Ops) {
|
||||||
squares.Add(o)
|
squares.Add(o)
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 732 B |
Binary file not shown.
|
After Width: | Height: | Size: 732 B |
@@ -25,8 +25,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
dumpImages = flag.Bool("saveimages", false, "save test images")
|
dumpImages = flag.Bool("saveimages", false, "save test images")
|
||||||
squares paint.ImageOp
|
squares paint.ImageOp
|
||||||
|
smallSquares paint.ImageOp
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -39,8 +40,11 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// build the texture we use for testing
|
squares = buildSquares(512)
|
||||||
size := 512
|
smallSquares = buildSquares(50)
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildSquares(size int) paint.ImageOp {
|
||||||
sub := size / 4
|
sub := size / 4
|
||||||
im := image.NewNRGBA(image.Rect(0, 0, size, size))
|
im := image.NewNRGBA(image.Rect(0, 0, size, size))
|
||||||
c1, c2 := image.NewUniform(colornames.Green), image.NewUniform(colornames.Blue)
|
c1, c2 := image.NewUniform(colornames.Green), image.NewUniform(colornames.Blue)
|
||||||
@@ -51,7 +55,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
c1, c2 = c2, c1
|
c1, c2 = c2, c1
|
||||||
}
|
}
|
||||||
squares = paint.NewImageOp(im)
|
return paint.NewImageOp(im)
|
||||||
}
|
}
|
||||||
|
|
||||||
func drawImage(t *testing.T, size int, ops *op.Ops, draw func(o *op.Ops)) (im *image.RGBA, err error) {
|
func drawImage(t *testing.T, size int, ops *op.Ops, draw func(o *op.Ops)) (im *image.RGBA, err error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user