~eliasnaur/gio

75c9736708723a121ab44c381edaf61f2625a6ad — Elias Naur 1 year, 11 months ago 3fc8f55
op/paint: skip zero images

Updates gio#235

Signed-off-by: Elias Naur <mail@eliasnaur.com>
M gpu/internal/rendertest/render_test.go => gpu/internal/rendertest/render_test.go +10 -0
@@ 340,6 340,16 @@ func TestLinearGradientAngled(t *testing.T) {
	}, func(r result) {})
}

func TestZeroImage(t *testing.T) {
	ops := new(op.Ops)
	w := newWindow(t, 10, 10)
	paint.ImageOp{}.Add(ops)
	paint.PaintOp{}.Add(ops)
	if err := w.Frame(ops); err != nil {
		t.Error(err)
	}
}

// lerp calculates linear interpolation with color b and p.
func lerp(a, b f32color.RGBA, p float32) f32color.RGBA {
	return f32color.RGBA{

M gpu/internal/rendertest/util_test.go => gpu/internal/rendertest/util_test.go +2 -2
@@ 70,7 70,7 @@ func drawImage(t *testing.T, size int, ops *op.Ops, draw func(o *op.Ops)) (im *i
}

func run(t *testing.T, f func(o *op.Ops), c func(r result)) {
	// draw a few times and check that it is correct each time, to
	// Draw a few times and check that it is correct each time, to
	// ensure any caching effects still generate the correct images.
	var img *image.RGBA
	var err error


@@ 82,7 82,7 @@ func run(t *testing.T, f func(o *op.Ops), c func(r result)) {
			t.Error("error rendering:", err)
			return
		}
		// check for a reference image and make sure we are identical.
		// Check for a reference image and make sure it is identical.
		if !verifyRef(t, img, 0) {
			name := fmt.Sprintf("%s-%d-bad.png", t.Name(), i)
			if err := saveImage(name, img); err != nil {

M op/paint/paint.go => op/paint/paint.go +2 -0
@@ 98,6 98,8 @@ func (i ImageOp) Add(o *op.Ops) {
			Color: i.color,
		}.Add(o)
		return
	} else if i.src == nil || i.src.Bounds().Empty() {
		return
	}
	data := o.Write2(opconst.TypeImageLen, i.src, i.handle)
	data[0] = byte(opconst.TypeImage)