diff --git a/gpu/compute.go b/gpu/compute.go index 36b9f74f6..55704b4f6 100644 --- a/gpu/compute.go +++ b/gpu/compute.go @@ -614,6 +614,9 @@ func (g *compute) encodeOps(trans f32.Affine2D, viewport image.Point, ops []imag case materialLinearGradient: // TODO: implement. g.enc.fill(f32color.NRGBAToRGBA(op.material.color1.SRGB())) + case materialRadialGradient: + // TODO: implement. + g.enc.fill(f32color.NRGBAToRGBA(op.material.color1.SRGB())) default: panic("not implemented") } diff --git a/gpu/gpu.go b/gpu/gpu.go index 41604fa05..e94da75ae 100644 --- a/gpu/gpu.go +++ b/gpu/gpu.go @@ -107,11 +107,14 @@ type drawState struct { // Current paint.ColorOp, if any. color color.NRGBA - // Current paint.LinearGradientOp. + // Current paint.LinearGradientOp and paint.RadialGradientOp. stop1 f32.Point stop2 f32.Point color1 color.NRGBA color2 color.NRGBA + // Current paint.RadialGradientOp. + offset1 float32 + radiusy float32 } type pathOp struct { @@ -187,9 +190,12 @@ type material struct { opaque bool // For materialTypeColor. color f32color.RGBA - // For materialTypeLinearGradient. + // For materialTypeLinearGradient and materialTypeRadialGradient. color1 f32color.RGBA color2 f32color.RGBA + // For materialTypeRadialGradient. + offset1 float32 + radiusy float32 // For materialTypeTexture. data imageOpData uvTrans f32.Affine2D @@ -212,9 +218,21 @@ type imageOpData struct { } type linearGradientOpData struct { - stop1 f32.Point + stop1 f32.Point + stop2 f32.Point + + color1 color.NRGBA + color2 color.NRGBA +} + +type radialGradientOpData struct { + stop1 f32.Point + stop2 f32.Point + + offset1 float32 + radiusy float32 + color1 color.NRGBA - stop2 f32.Point color2 color.NRGBA } @@ -294,6 +312,37 @@ func decodeLinearGradientOp(data []byte) linearGradientOpData { } } +func decodeRadialGradientOp(data []byte) radialGradientOpData { + if opconst.OpType(data[0]) != opconst.TypeRadialGradient { + panic("invalid op") + } + bo := binary.LittleEndian + return radialGradientOpData{ + stop1: f32.Point{ + X: math.Float32frombits(bo.Uint32(data[1:])), + Y: math.Float32frombits(bo.Uint32(data[5:])), + }, + stop2: f32.Point{ + X: math.Float32frombits(bo.Uint32(data[9:])), + Y: math.Float32frombits(bo.Uint32(data[13:])), + }, + radiusy: math.Float32frombits(bo.Uint32(data[17:])), + color1: color.NRGBA{ + R: data[21+0], + G: data[21+1], + B: data[21+2], + A: data[21+3], + }, + color2: color.NRGBA{ + R: data[25+0], + G: data[25+1], + B: data[25+2], + A: data[25+3], + }, + offset1: math.Float32frombits(bo.Uint32(data[29:])), + } +} + type clipType uint8 type resource interface { @@ -308,11 +357,12 @@ type texture struct { type blitter struct { ctx driver.Device viewport image.Point - prog [3]*program + prog [materialCount]*program layout driver.InputLayout colUniforms *blitColUniforms texUniforms *blitTexUniforms linearGradientUniforms *blitLinearGradientUniforms + radialGradientUniforms *blitRadialGradientUniforms quadVerts driver.Buffer } @@ -343,6 +393,17 @@ type blitLinearGradientUniforms struct { } } +type blitRadialGradientUniforms struct { + vert struct { + blitUniforms + _ [12]byte // Padding to a multiple of 16. + } + frag struct { + radialGradientUniforms + _ [12]byte // Padding to multiple of 16. + } +} + type uniformBuffer struct { buf driver.Buffer ptr []byte @@ -370,6 +431,12 @@ type gradientUniforms struct { color2 f32color.RGBA } +type radialGradientUniforms struct { + color1 f32color.RGBA + color2 f32color.RGBA + offset1 float32 +} + type materialType uint8 const ( @@ -381,7 +448,9 @@ const ( const ( materialColor materialType = iota materialLinearGradient + materialRadialGradient materialTexture + materialCount ) func New(api API) (GPU, error) { @@ -569,6 +638,7 @@ func newBlitter(ctx driver.Device) *blitter { if err != nil { panic(err) } + b := &blitter{ ctx: ctx, quadVerts: quadVerts, @@ -576,13 +646,26 @@ func newBlitter(ctx driver.Device) *blitter { b.colUniforms = new(blitColUniforms) b.texUniforms = new(blitTexUniforms) b.linearGradientUniforms = new(blitLinearGradientUniforms) + b.radialGradientUniforms = new(blitRadialGradientUniforms) + prog, layout, err := createColorPrograms(ctx, shader_blit_vert, shader_blit_frag, - [3]interface{}{&b.colUniforms.vert, &b.linearGradientUniforms.vert, &b.texUniforms.vert}, - [3]interface{}{&b.colUniforms.frag, &b.linearGradientUniforms.frag, nil}, + [...]interface{}{ + materialColor: &b.colUniforms.vert, + materialLinearGradient: &b.linearGradientUniforms.vert, + materialRadialGradient: &b.radialGradientUniforms.vert, + materialTexture: &b.texUniforms.vert, + }, + [...]interface{}{ + materialColor: &b.colUniforms.frag, + materialLinearGradient: &b.linearGradientUniforms.frag, + materialRadialGradient: &b.radialGradientUniforms.frag, + materialTexture: nil, + }, ) if err != nil { panic(err) } + b.prog = prog b.layout = layout return b @@ -596,67 +679,40 @@ func (b *blitter) release() { b.layout.Release() } -func createColorPrograms(b driver.Device, vsSrc driver.ShaderSources, fsSrc [3]driver.ShaderSources, vertUniforms, fragUniforms [3]interface{}) ([3]*program, driver.InputLayout, error) { - var progs [3]*program - { - prog, err := b.NewProgram(vsSrc, fsSrc[materialTexture]) - if err != nil { - return progs, nil, err - } - var vertBuffer, fragBuffer *uniformBuffer - if u := vertUniforms[materialTexture]; u != nil { - vertBuffer = newUniformBuffer(b, u) - prog.SetVertexUniforms(vertBuffer.buf) - } - if u := fragUniforms[materialTexture]; u != nil { - fragBuffer = newUniformBuffer(b, u) - prog.SetFragmentUniforms(fragBuffer.buf) +func createColorPrograms(b driver.Device, vsSrc driver.ShaderSources, fsSrc [materialCount]driver.ShaderSources, vertUniforms, fragUniforms [materialCount]interface{}) (_ [materialCount]*program, _ driver.InputLayout, err error) { + var progs [materialCount]*program + + release := func() { + for _, p := range progs { + if p != nil { + p.Release() + } } - progs[materialTexture] = newProgram(prog, vertBuffer, fragBuffer) } - { - var vertBuffer, fragBuffer *uniformBuffer - prog, err := b.NewProgram(vsSrc, fsSrc[materialColor]) + + for variant := range progs { + prog, err := b.NewProgram(vsSrc, fsSrc[variant]) if err != nil { - progs[materialTexture].Release() + release() return progs, nil, err } - if u := vertUniforms[materialColor]; u != nil { - vertBuffer = newUniformBuffer(b, u) - prog.SetVertexUniforms(vertBuffer.buf) - } - if u := fragUniforms[materialColor]; u != nil { - fragBuffer = newUniformBuffer(b, u) - prog.SetFragmentUniforms(fragBuffer.buf) - } - progs[materialColor] = newProgram(prog, vertBuffer, fragBuffer) - } - { var vertBuffer, fragBuffer *uniformBuffer - prog, err := b.NewProgram(vsSrc, fsSrc[materialLinearGradient]) - if err != nil { - progs[materialTexture].Release() - progs[materialColor].Release() - return progs, nil, err - } - if u := vertUniforms[materialLinearGradient]; u != nil { + if u := vertUniforms[variant]; u != nil { vertBuffer = newUniformBuffer(b, u) prog.SetVertexUniforms(vertBuffer.buf) } - if u := fragUniforms[materialLinearGradient]; u != nil { + if u := fragUniforms[variant]; u != nil { fragBuffer = newUniformBuffer(b, u) prog.SetFragmentUniforms(fragBuffer.buf) } - progs[materialLinearGradient] = newProgram(prog, vertBuffer, fragBuffer) + progs[variant] = newProgram(prog, vertBuffer, fragBuffer) } + layout, err := b.NewInputLayout(vsSrc, []driver.InputDesc{ {Type: driver.DataTypeFloat, Size: 2, Offset: 0}, {Type: driver.DataTypeFloat, Size: 2, Offset: 4 * 2}, }) if err != nil { - progs[materialTexture].Release() - progs[materialColor].Release() - progs[materialLinearGradient].Release() return progs, nil, err } return progs, layout, nil @@ -975,6 +1031,15 @@ loop: state.stop2 = op.stop2 state.color1 = op.color1 state.color2 = op.color2 + case opconst.TypeRadialGradient: + state.matType = materialRadialGradient + op := decodeRadialGradientOp(encOp.Data) + state.stop1 = op.stop1 + state.stop2 = op.stop2 + state.offset1 = op.offset1 + state.radiusy = op.radiusy + state.color1 = op.color1 + state.color2 = op.color2 case opconst.TypeImage: state.matType = materialTexture state.image = decodeImageOp(encOp.Data, encOp.Refs) @@ -1086,7 +1151,16 @@ func (d *drawState) materialFor(rect f32.Rectangle, off f32.Point, partTrans f32 m.color2 = f32color.LinearFromSRGB(d.color2) m.opaque = m.color1.A == 1.0 && m.color2.A == 1.0 - m.uvTrans = partTrans.Mul(gradientSpaceTransform(clip, off, d.stop1, d.stop2)) + m.uvTrans = partTrans.Mul(gradientSpaceTransform(clip, off, d.stop1, d.stop2, -1)) + case materialRadialGradient: + m.material = materialRadialGradient + + m.color1 = f32color.LinearFromSRGB(d.color1) + m.color2 = f32color.LinearFromSRGB(d.color2) + m.offset1 = d.offset1 + m.opaque = m.color1.A == 1.0 && m.color2.A == 1.0 + + m.uvTrans = partTrans.Mul(gradientSpaceTransform(clip, off, d.stop1, d.stop2, d.radiusy)) case materialTexture: m.material = materialTexture dr := boundRectF(rect.Add(off)) @@ -1127,7 +1201,7 @@ func (r *renderer) drawZOps(cache *resourceCache, ops []imageOp) { } drc := img.clip scale, off := clipSpaceTransform(drc, r.blitter.viewport) - r.blitter.blit(img.z, m.material, m.color, m.color1, m.color2, scale, off, m.uvTrans) + r.blitter.blit(img.z, m.material, m.color, m.color1, m.color2, m.offset1, scale, off, m.uvTrans) } r.ctx.SetDepthTest(false) } @@ -1151,7 +1225,7 @@ func (r *renderer) drawOps(cache *resourceCache, ops []imageOp) { var fbo stencilFBO switch img.clipType { case clipTypeNone: - r.blitter.blit(img.z, m.material, m.color, m.color1, m.color2, scale, off, m.uvTrans) + r.blitter.blit(img.z, m.material, m.color, m.color1, m.color2, m.offset1, scale, off, m.uvTrans) continue case clipTypePath: fbo = r.pather.stenciler.cover(img.place.Idx) @@ -1167,13 +1241,13 @@ func (r *renderer) drawOps(cache *resourceCache, ops []imageOp) { Max: img.place.Pos.Add(drc.Size()), } coverScale, coverOff := texSpaceTransform(layout.FRect(uv), fbo.size) - r.pather.cover(img.z, m.material, m.color, m.color1, m.color2, scale, off, m.uvTrans, coverScale, coverOff) + r.pather.cover(img.z, m.material, m.color, m.color1, m.color2, m.offset1, scale, off, m.uvTrans, coverScale, coverOff) } r.ctx.DepthMask(true) r.ctx.SetDepthTest(false) } -func (b *blitter) blit(z float32, mat materialType, col f32color.RGBA, col1, col2 f32color.RGBA, scale, off f32.Point, uvTrans f32.Affine2D) { +func (b *blitter) blit(z float32, mat materialType, col f32color.RGBA, col1, col2 f32color.RGBA, col1off float32, scale, off f32.Point, uvTrans f32.Affine2D) { p := b.prog[mat] b.ctx.BindProgram(p.prog) var uniforms *blitUniforms @@ -1181,11 +1255,13 @@ func (b *blitter) blit(z float32, mat materialType, col f32color.RGBA, col1, col case materialColor: b.colUniforms.frag.color = col uniforms = &b.colUniforms.vert.blitUniforms + case materialTexture: t1, t2, t3, t4, t5, t6 := uvTrans.Elems() b.texUniforms.vert.blitUniforms.uvTransformR1 = [4]float32{t1, t2, t3, 0} b.texUniforms.vert.blitUniforms.uvTransformR2 = [4]float32{t4, t5, t6, 0} uniforms = &b.texUniforms.vert.blitUniforms + case materialLinearGradient: b.linearGradientUniforms.frag.color1 = col1 b.linearGradientUniforms.frag.color2 = col2 @@ -1194,6 +1270,16 @@ func (b *blitter) blit(z float32, mat materialType, col f32color.RGBA, col1, col b.linearGradientUniforms.vert.blitUniforms.uvTransformR1 = [4]float32{t1, t2, t3, 0} b.linearGradientUniforms.vert.blitUniforms.uvTransformR2 = [4]float32{t4, t5, t6, 0} uniforms = &b.linearGradientUniforms.vert.blitUniforms + + case materialRadialGradient: + b.radialGradientUniforms.frag.color1 = col1 + b.radialGradientUniforms.frag.color2 = col2 + b.radialGradientUniforms.frag.offset1 = col1off + + t1, t2, t3, t4, t5, t6 := uvTrans.Elems() + b.radialGradientUniforms.vert.blitUniforms.uvTransformR1 = [4]float32{t1, t2, t3, 0} + b.radialGradientUniforms.vert.blitUniforms.uvTransformR2 = [4]float32{t4, t5, t6, 0} + uniforms = &b.radialGradientUniforms.vert.blitUniforms } uniforms.z = z uniforms.transform = [4]float32{scale.X, scale.Y, off.X, off.Y} @@ -1267,11 +1353,20 @@ func texSpaceTransform(r f32.Rectangle, bounds image.Point) (f32.Point, f32.Poin } // gradientSpaceTransform transforms stop1 and stop2 to [(0,0), (1,1)]. -func gradientSpaceTransform(clip image.Rectangle, off f32.Point, stop1, stop2 f32.Point) f32.Affine2D { +func gradientSpaceTransform(clip image.Rectangle, off f32.Point, stop1, stop2 f32.Point, radiusy float32) f32.Affine2D { d := stop2.Sub(stop1) l := float32(math.Sqrt(float64(d.X*d.X + d.Y*d.Y))) a := float32(math.Atan2(float64(-d.Y), float64(d.X))) + scalex := 1 / l + + var scaley float32 + if radiusy == -1 { + scaley = scalex + } else if radiusy != 0 { + scaley = 1 / radiusy + } + // TODO: optimize zp := f32.Point{} return f32.Affine2D{}. @@ -1279,7 +1374,7 @@ func gradientSpaceTransform(clip image.Rectangle, off f32.Point, stop1, stop2 f3 Offset(zp.Sub(off).Add(layout.FPt(clip.Min))). // offset to clip space Offset(zp.Sub(stop1)). // offset to first stop point Rotate(zp, a). // rotate to align gradient - Scale(zp, f32.Pt(1/l, 1/l)) // scale gradient to right size + Scale(zp, f32.Pt(scalex, scaley)) // scale gradient to right size } // clipSpaceTransform returns the scale and offset that transforms the given diff --git a/gpu/internal/convertshaders/main.go b/gpu/internal/convertshaders/main.go index 92b98790e..fb2472271 100644 --- a/gpu/internal/convertshaders/main.go +++ b/gpu/internal/convertshaders/main.go @@ -268,6 +268,10 @@ func (conv *Converter) Shader(shaderPath string) ([]driver.ShaderSources, error) FetchColorExpr: `mix(_color1, _color2, clamp(vUV.x, 0.0, 1.0))`, Header: `layout(binding=0) uniform Gradient { vec4 _color1; vec4 _color2; };`, }, + { + FetchColorExpr: `mix(_color1, _color2, clamp((length(vUV) - _offset1) / (1.0 - _offset1), 0.0, 1.0))`, + Header: `layout(binding=0) uniform Gradient { vec4 _color1; vec4 _color2; float _offset1; };`, + }, { FetchColorExpr: `texture(tex, vUV)`, Header: `layout(binding=0) uniform sampler2D tex;`, diff --git a/gpu/internal/rendertest/refs/TestEllipseGradient.png b/gpu/internal/rendertest/refs/TestEllipseGradient.png new file mode 100644 index 000000000..75283649b Binary files /dev/null and b/gpu/internal/rendertest/refs/TestEllipseGradient.png differ diff --git a/gpu/internal/rendertest/refs/TestEllipseGradientAngled.png b/gpu/internal/rendertest/refs/TestEllipseGradientAngled.png new file mode 100644 index 000000000..3e9378bd6 Binary files /dev/null and b/gpu/internal/rendertest/refs/TestEllipseGradientAngled.png differ diff --git a/gpu/internal/rendertest/refs/TestRadialGradient.png b/gpu/internal/rendertest/refs/TestRadialGradient.png new file mode 100644 index 000000000..8a2ff95bc Binary files /dev/null and b/gpu/internal/rendertest/refs/TestRadialGradient.png differ diff --git a/gpu/internal/rendertest/refs/TestRadialGradientOffset.png b/gpu/internal/rendertest/refs/TestRadialGradientOffset.png new file mode 100644 index 000000000..f9a37d326 Binary files /dev/null and b/gpu/internal/rendertest/refs/TestRadialGradientOffset.png differ diff --git a/gpu/internal/rendertest/render_test.go b/gpu/internal/rendertest/render_test.go index 3e027eb30..8124fccea 100644 --- a/gpu/internal/rendertest/render_test.go +++ b/gpu/internal/rendertest/render_test.go @@ -340,6 +340,57 @@ func TestLinearGradientAngled(t *testing.T) { }, func(r result) {}) } +func TestRadialGradient(t *testing.T) { + run(t, func(ops *op.Ops) { + paint.RadialGradientOp{ + Stop1: f32.Pt(64, 64), + Color1: red, + Stop2: f32.Pt(64, 0), + Color2: black, + }.Add(ops) + paint.PaintOp{}.Add(ops) + }, func(r result) {}) +} + +func TestRadialGradientOffset(t *testing.T) { + run(t, func(ops *op.Ops) { + paint.RadialGradientOp{ + Stop1: f32.Pt(64, 64), + Color1: blue, + Stop2: f32.Pt(64, 0), + Color2: black, + Offset1: 0.5, + }.Add(ops) + paint.PaintOp{}.Add(ops) + }, func(r result) {}) +} + +func TestEllipseGradient(t *testing.T) { + run(t, func(ops *op.Ops) { + paint.RadialGradientOp{ + Stop1: f32.Pt(64, 64), + Color1: red, + Stop2: f32.Pt(64, 0), + Color2: black, + RadiusY: 32, + }.Add(ops) + paint.PaintOp{}.Add(ops) + }, func(r result) {}) +} + +func TestEllipseGradientAngled(t *testing.T) { + run(t, func(ops *op.Ops) { + paint.RadialGradientOp{ + Stop1: f32.Pt(64, 64), + Color1: red, + Stop2: f32.Pt(32, 96), + Color2: black, + RadiusY: 32, + }.Add(ops) + paint.PaintOp{}.Add(ops) + }, func(r result) {}) +} + // lerp calculates linear interpolation with color b and p. func lerp(a, b f32color.RGBA, p float32) f32color.RGBA { return f32color.RGBA{ diff --git a/gpu/path.go b/gpu/path.go index b7ec3ba2c..b14cc38fd 100644 --- a/gpu/path.go +++ b/gpu/path.go @@ -28,10 +28,11 @@ type pather struct { type coverer struct { ctx driver.Device - prog [3]*program + prog [materialCount]*program texUniforms *coverTexUniforms colUniforms *coverColUniforms linearGradientUniforms *coverLinearGradientUniforms + radialGradientUniforms *coverRadialGradientUniforms layout driver.InputLayout } @@ -62,6 +63,17 @@ type coverLinearGradientUniforms struct { } } +type coverRadialGradientUniforms struct { + vert struct { + coverUniforms + _ [12]byte // Padding to multiple of 16. + } + frag struct { + radialGradientUniforms + _ [12]byte // Padding to multiple of 16. + } +} + type coverUniforms struct { transform [4]float32 uvCoverTransform [4]float32 @@ -158,16 +170,30 @@ func newCoverer(ctx driver.Device) *coverer { c := &coverer{ ctx: ctx, } + c.colUniforms = new(coverColUniforms) c.texUniforms = new(coverTexUniforms) c.linearGradientUniforms = new(coverLinearGradientUniforms) + c.radialGradientUniforms = new(coverRadialGradientUniforms) + prog, layout, err := createColorPrograms(ctx, shader_cover_vert, shader_cover_frag, - [3]interface{}{&c.colUniforms.vert, &c.linearGradientUniforms.vert, &c.texUniforms.vert}, - [3]interface{}{&c.colUniforms.frag, &c.linearGradientUniforms.frag, nil}, + [materialCount]interface{}{ + materialColor: &c.colUniforms.vert, + materialLinearGradient: &c.linearGradientUniforms.vert, + materialRadialGradient: &c.radialGradientUniforms.vert, + materialTexture: &c.texUniforms.vert, + }, + [materialCount]interface{}{ + materialColor: &c.colUniforms.frag, + materialLinearGradient: &c.linearGradientUniforms.frag, + materialRadialGradient: &c.radialGradientUniforms.frag, + materialTexture: nil, + }, ) if err != nil { panic(err) } + c.prog = prog c.layout = layout return c @@ -374,11 +400,11 @@ func (s *stenciler) stencilPath(bounds image.Rectangle, offset f32.Point, uv ima } } -func (p *pather) cover(z float32, mat materialType, col f32color.RGBA, col1, col2 f32color.RGBA, scale, off f32.Point, uvTrans f32.Affine2D, coverScale, coverOff f32.Point) { - p.coverer.cover(z, mat, col, col1, col2, scale, off, uvTrans, coverScale, coverOff) +func (p *pather) cover(z float32, mat materialType, col f32color.RGBA, col1, col2 f32color.RGBA, col1off float32, scale, off f32.Point, uvTrans f32.Affine2D, coverScale, coverOff f32.Point) { + p.coverer.cover(z, mat, col, col1, col2, col1off, scale, off, uvTrans, coverScale, coverOff) } -func (c *coverer) cover(z float32, mat materialType, col f32color.RGBA, col1, col2 f32color.RGBA, scale, off f32.Point, uvTrans f32.Affine2D, coverScale, coverOff f32.Point) { +func (c *coverer) cover(z float32, mat materialType, col f32color.RGBA, col1, col2 f32color.RGBA, col1off float32, scale, off f32.Point, uvTrans f32.Affine2D, coverScale, coverOff f32.Point) { p := c.prog[mat] c.ctx.BindProgram(p.prog) var uniforms *coverUniforms @@ -386,6 +412,7 @@ func (c *coverer) cover(z float32, mat materialType, col f32color.RGBA, col1, co case materialColor: c.colUniforms.frag.color = col uniforms = &c.colUniforms.vert.coverUniforms + case materialLinearGradient: c.linearGradientUniforms.frag.color1 = col1 c.linearGradientUniforms.frag.color2 = col2 @@ -394,6 +421,17 @@ func (c *coverer) cover(z float32, mat materialType, col f32color.RGBA, col1, co c.linearGradientUniforms.vert.uvTransformR1 = [4]float32{t1, t2, t3, 0} c.linearGradientUniforms.vert.uvTransformR2 = [4]float32{t4, t5, t6, 0} uniforms = &c.linearGradientUniforms.vert.coverUniforms + + case materialRadialGradient: + c.radialGradientUniforms.frag.color1 = col1 + c.radialGradientUniforms.frag.color2 = col2 + c.radialGradientUniforms.frag.offset1 = col1off + + t1, t2, t3, t4, t5, t6 := uvTrans.Elems() + c.radialGradientUniforms.vert.uvTransformR1 = [4]float32{t1, t2, t3, 0} + c.radialGradientUniforms.vert.uvTransformR2 = [4]float32{t4, t5, t6, 0} + uniforms = &c.radialGradientUniforms.vert.coverUniforms + case materialTexture: t1, t2, t3, t4, t5, t6 := uvTrans.Elems() c.texUniforms.vert.uvTransformR1 = [4]float32{t1, t2, t3, 0} diff --git a/gpu/shaders.go b/gpu/shaders.go index 4ef02174b..8cf6e570f 100644 --- a/gpu/shaders.go +++ b/gpu/shaders.go @@ -40,6 +40,19 @@ var ( GLSL150: "#version 150\n\nstruct Gradient\n{\n vec4 _color1;\n vec4 _color2;\n};\n\nuniform Gradient _12;\n\nout vec4 fragColor;\nin vec2 vUV;\n\nvoid main()\n{\n fragColor = mix(_12._color1, _12._color2, vec4(clamp(vUV.x, 0.0, 1.0)));\n}\n\n", HLSL: []byte{0x44, 0x58, 0x42, 0x43, 0xc0, 0x43, 0x72, 0x3d, 0x68, 0xc9, 0x38, 0x57, 0x9f, 0xa3, 0x60, 0xa8, 0xae, 0xd2, 0xa2, 0xf0, 0x1, 0x0, 0x0, 0x0, 0x40, 0x3, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x38, 0x0, 0x0, 0x0, 0xcc, 0x0, 0x0, 0x0, 0x74, 0x1, 0x0, 0x0, 0xf0, 0x1, 0x0, 0x0, 0xd8, 0x2, 0x0, 0x0, 0xc, 0x3, 0x0, 0x0, 0x41, 0x6f, 0x6e, 0x39, 0x8c, 0x0, 0x0, 0x0, 0x8c, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, 0xff, 0x5c, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x1, 0x0, 0x24, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x24, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, 0xff, 0x1f, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x3, 0xb0, 0x1, 0x0, 0x0, 0x2, 0x0, 0x0, 0x18, 0x80, 0x0, 0x0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0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x1, 0x0, 0x0, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x0, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x0, 0xab, 0xab}, }, + { + Name: "blit.frag", + Uniforms: driver.UniformsReflection{ + Blocks: []driver.UniformBlock{{Name: "Gradient", Binding: 0}}, + Locations: []driver.UniformLocation{{Name: "_12._color1", Type: 0x0, Size: 4, Offset: 0}, {Name: "_12._color2", Type: 0x0, Size: 4, Offset: 16}, {Name: "_12._offset1", Type: 0x0, Size: 1, Offset: 32}}, + Size: 36, + }, + GLSL100ES: "precision mediump float;\nprecision highp int;\n\nstruct Gradient\n{\n vec4 _color1;\n vec4 _color2;\n float _offset1;\n};\n\nuniform Gradient _12;\n\nvarying vec2 vUV;\n\nvoid main()\n{\n gl_FragData[0] = mix(_12._color1, _12._color2, vec4(clamp((length(vUV) - _12._offset1) / (1.0 - _12._offset1), 0.0, 1.0)));\n}\n\n", + GLSL300ES: "#version 300 es\nprecision mediump float;\nprecision highp int;\n\nlayout(std140) uniform Gradient\n{\n vec4 _color1;\n vec4 _color2;\n float _offset1;\n} _12;\n\nlayout(location = 0) out vec4 fragColor;\nin vec2 vUV;\n\nvoid main()\n{\n fragColor = mix(_12._color1, _12._color2, vec4(clamp((length(vUV) - _12._offset1) / (1.0 - _12._offset1), 0.0, 1.0)));\n}\n\n", + GLSL130: "#version 130\n\nstruct Gradient\n{\n vec4 _color1;\n vec4 _color2;\n float _offset1;\n};\n\nuniform Gradient _12;\n\nout vec4 fragColor;\nin vec2 vUV;\n\nvoid main()\n{\n fragColor = mix(_12._color1, _12._color2, vec4(clamp((length(vUV) - _12._offset1) / (1.0 - _12._offset1), 0.0, 1.0)));\n}\n\n", + GLSL150: "#version 150\n\nstruct Gradient\n{\n vec4 _color1;\n vec4 _color2;\n float _offset1;\n};\n\nuniform Gradient _12;\n\nout vec4 fragColor;\nin vec2 vUV;\n\nvoid main()\n{\n fragColor = mix(_12._color1, _12._color2, vec4(clamp((length(vUV) - _12._offset1) / (1.0 - _12._offset1), 0.0, 1.0)));\n}\n\n", + HLSL: []byte{0x44, 0x58, 0x42, 0x43, 0x9c, 0x61, 0x7c, 0xaa, 0x5d, 0x88, 0xba, 0x34, 0x7f, 0x82, 0x36, 0x27, 0x76, 0xc7, 0xe8, 0xf2, 0x1, 0x0, 0x0, 0x0, 0x64, 0x4, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x38, 0x0, 0x0, 0x0, 0x3c, 0x1, 0x0, 0x0, 0x64, 0x2, 0x0, 0x0, 0xe0, 0x2, 0x0, 0x0, 0xfc, 0x3, 0x0, 0x0, 0x30, 0x4, 0x0, 0x0, 0x41, 0x6f, 0x6e, 0x39, 0xfc, 0x0, 0x0, 0x0, 0xfc, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, 0xff, 0xcc, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x1, 0x0, 0x24, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x24, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, 0xff, 0x51, 0x0, 0x0,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.TextureBinding{{Name: "tex", Binding: 0}}, @@ -113,6 +126,20 @@ var ( GLSL150: "#version 150\n\nstruct Gradient\n{\n vec4 _color1;\n vec4 _color2;\n};\n\nuniform Gradient _12;\n\nuniform sampler2D cover;\n\nout vec4 fragColor;\nin vec2 vUV;\nin vec2 vCoverUV;\n\nvoid main()\n{\n fragColor = mix(_12._color1, _12._color2, vec4(clamp(vUV.x, 0.0, 1.0)));\n float cover_1 = min(abs(texture(cover, vCoverUV).x), 1.0);\n fragColor *= cover_1;\n}\n\n", HLSL: []byte{0x44, 0x58, 0x42, 0x43, 0xd2, 0x27, 0xbe, 0xa0, 0xfc, 0x1b, 0xe8, 0x79, 0xd, 0x99, 0xe5, 0xb7, 0xfe, 0x6f, 0x25, 0x6f, 0x1, 0x0, 0x0, 0x0, 0x70, 0x4, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x38, 0x0, 0x0, 0x0, 0x8, 0x1, 0x0, 0x0, 0x38, 0x2, 0x0, 0x0, 0xb4, 0x2, 0x0, 0x0, 0xf0, 0x3, 0x0, 0x0, 0x3c, 0x4, 0x0, 0x0, 0x41, 0x6f, 0x6e, 0x39, 0xc8, 0x0, 0x0, 0x0, 0xc8, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, 0xff, 0x94, 0x0, 0x0, 0x0, 0x34, 0x0, 0x0, 0x0, 0x1, 0x0, 0x28, 0x0, 0x0, 0x0, 0x34, 0x0, 0x0, 0x0, 0x34, 0x0, 0x1, 0x0, 0x24, 0x0, 0x0, 0x0, 0x34, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, 0xff, 0x1f, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0xf, 0xb0, 0x1f, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x90, 0x0, 0x8, 0xf, 0xa0,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0x0, 0x0, 0x0, 0x5f, 0x31, 0x32, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x32, 0x0, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, 0x31, 0x0, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x44, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x38, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x3, 0x0, 0x0, 0x38, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0x4, 0x0, 0x0, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x0, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x0, 0xab, 0xab}, }, + { + Name: "cover.frag", + Uniforms: driver.UniformsReflection{ + Blocks: []driver.UniformBlock{{Name: "Gradient", Binding: 0}}, + Locations: []driver.UniformLocation{{Name: "_12._color1", Type: 0x0, Size: 4, Offset: 0}, {Name: "_12._color2", Type: 0x0, Size: 4, Offset: 16}, {Name: "_12._offset1", Type: 0x0, Size: 1, Offset: 32}}, + Size: 36, + }, + Textures: []driver.TextureBinding{{Name: "cover", Binding: 1}}, + GLSL100ES: "precision mediump float;\nprecision highp int;\n\nstruct Gradient\n{\n vec4 _color1;\n vec4 _color2;\n float _offset1;\n};\n\nuniform Gradient _12;\n\nuniform mediump sampler2D cover;\n\nvarying vec2 vUV;\nvarying highp vec2 vCoverUV;\n\nvoid main()\n{\n gl_FragData[0] = mix(_12._color1, _12._color2, vec4(clamp((length(vUV) - _12._offset1) / (1.0 - _12._offset1), 0.0, 1.0)));\n float cover_1 = min(abs(texture2D(cover, vCoverUV).x), 1.0);\n gl_FragData[0] *= cover_1;\n}\n\n", + GLSL300ES: "#version 300 es\nprecision mediump float;\nprecision highp int;\n\nlayout(std140) uniform Gradient\n{\n vec4 _color1;\n vec4 _color2;\n float _offset1;\n} _12;\n\nuniform mediump sampler2D cover;\n\nlayout(location = 0) out vec4 fragColor;\nin vec2 vUV;\nin highp vec2 vCoverUV;\n\nvoid main()\n{\n fragColor = mix(_12._color1, _12._color2, vec4(clamp((length(vUV) - _12._offset1) / (1.0 - _12._offset1), 0.0, 1.0)));\n float cover_1 = min(abs(texture(cover, vCoverUV).x), 1.0);\n fragColor *= cover_1;\n}\n\n", + GLSL130: "#version 130\n\nstruct Gradient\n{\n vec4 _color1;\n vec4 _color2;\n float _offset1;\n};\n\nuniform Gradient _12;\n\nuniform sampler2D cover;\n\nout vec4 fragColor;\nin vec2 vUV;\nin vec2 vCoverUV;\n\nvoid main()\n{\n fragColor = mix(_12._color1, _12._color2, vec4(clamp((length(vUV) - _12._offset1) / (1.0 - _12._offset1), 0.0, 1.0)));\n float cover_1 = min(abs(texture(cover, vCoverUV).x), 1.0);\n fragColor *= cover_1;\n}\n\n", + GLSL150: "#version 150\n\nstruct Gradient\n{\n vec4 _color1;\n vec4 _color2;\n float _offset1;\n};\n\nuniform Gradient _12;\n\nuniform sampler2D cover;\n\nout vec4 fragColor;\nin vec2 vUV;\nin vec2 vCoverUV;\n\nvoid main()\n{\n fragColor = mix(_12._color1, _12._color2, vec4(clamp((length(vUV) - _12._offset1) / (1.0 - _12._offset1), 0.0, 1.0)));\n float cover_1 = min(abs(texture(cover, vCoverUV).x), 1.0);\n fragColor *= cover_1;\n}\n\n", + HLSL: []byte{0x44, 0x58, 0x42, 0x43, 0x88, 0x20, 0xd, 0xe7, 0x7f, 0x81, 0xbe, 0xdf, 0x42, 0x32, 0x79, 0x2d, 0x4a, 0xd6, 0x93, 0x2e, 0x1, 0x0, 0x0, 0x0, 0xa4, 0x5, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x38, 0x0, 0x0, 0x0, 0x88, 0x1, 0x0, 0x0, 0x38, 0x3, 0x0, 0x0, 0xb4, 0x3, 0x0, 0x0, 0x24, 0x5, 0x0, 0x0, 0x70, 0x5, 0x0, 0x0, 0x41, 0x6f, 0x6e, 0x39, 0x48, 0x1, 0x0, 0x0, 0x48, 0x1, 0x0, 0x0, 0x0, 0x2, 0xff, 0xff, 0x14, 0x1, 0x0, 0x0, 0x34, 0x0, 0x0, 0x0, 0x1, 0x0, 0x28, 0x0, 0x0, 0x0, 0x34, 0x0, 0x0, 0x0, 0x34, 0x0, 0x1, 0x0, 0x24, 0x0, 0x0, 0x0, 0x34, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, 0xff, 0x51, 0x0, 0x0, 0x5, 0x3, 0x0, 0xf, 0xa0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0x3f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0xf, 0xb0, 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, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc, 0xc, 0x0, 0x0, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x0, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x0, 0xab, 0xab}, + }, { Name: "cover.frag", Textures: []driver.TextureBinding{{Name: "tex", Binding: 0}, {Name: "cover", Binding: 1}}, diff --git a/internal/opconst/ops.go b/internal/opconst/ops.go index 8e9a1a35c..23bd4766b 100644 --- a/internal/opconst/ops.go +++ b/internal/opconst/ops.go @@ -17,6 +17,7 @@ const ( TypePaint TypeColor TypeLinearGradient + TypeRadialGradient TypeArea TypePointerInput TypePass @@ -46,6 +47,7 @@ const ( TypePaintLen = 1 TypeColorLen = 1 + 4 TypeLinearGradientLen = 1 + 8*2 + 4*2 + TypeRadialGradientLen = 1 + 8*2 + 4 + 4*2 + 4 TypeAreaLen = 1 + 1 + 4*4 TypePointerInputLen = 1 + 1 + 1 TypePassLen = 1 + 1 @@ -90,6 +92,7 @@ func (t OpType) Size() int { TypePaintLen, TypeColorLen, TypeLinearGradientLen, + TypeRadialGradientLen, TypeAreaLen, TypePointerInputLen, TypePassLen, diff --git a/op/paint/paint.go b/op/paint/paint.go index e36eca3e5..abc33fb00 100644 --- a/op/paint/paint.go +++ b/op/paint/paint.go @@ -36,6 +36,8 @@ type ColorOp struct { // LinearGradientOp sets the brush to a gradient starting at stop1 with color1 and // ending at stop2 with color2. +// +// Note: this gradient does not work together with non-offset transforms. type LinearGradientOp struct { Stop1 f32.Point Color1 color.NRGBA @@ -43,6 +45,23 @@ type LinearGradientOp struct { Color2 color.NRGBA } +// RadialGradientOp sets the brush to a radial gradient center starting at stop1 with color1 +// and ellipse X axis ending at stop2 with color2. +// +// Note: this does not work together with non-offset transforms. +type RadialGradientOp struct { + Stop1 f32.Point + Color1 color.NRGBA + Stop2 f32.Point + Color2 color.NRGBA + + // Offset1 defines ratio to offset Stop1 color. + Offset1 float32 + // RadiusY defines Y axis for the ellipse. + // RadiusY = 0 draws a circle. + RadiusY float32 +} + // PaintOp fills fills the current clip area with the current brush. type PaintOp struct { } @@ -132,6 +151,37 @@ func (c LinearGradientOp) Add(o *op.Ops) { data[21+3] = c.Color2.A } +func (c RadialGradientOp) Add(o *op.Ops) { + data := o.Write(opconst.TypeRadialGradientLen) + data[0] = byte(opconst.TypeRadialGradient) + + bo := binary.LittleEndian + bo.PutUint32(data[1:], math.Float32bits(c.Stop1.X)) + bo.PutUint32(data[5:], math.Float32bits(c.Stop1.Y)) + bo.PutUint32(data[9:], math.Float32bits(c.Stop2.X)) + bo.PutUint32(data[13:], math.Float32bits(c.Stop2.Y)) + + radiusY := c.RadiusY + if radiusY < 0 { + radiusY = 0 + } + if radiusY == 0 { + radiusY = -1 // using -1 to avoid duplicate length calculation + } + bo.PutUint32(data[17:], math.Float32bits(radiusY)) + + data[21+0] = c.Color1.R + data[21+1] = c.Color1.G + data[21+2] = c.Color1.B + data[21+3] = c.Color1.A + data[25+0] = c.Color2.R + data[25+1] = c.Color2.G + data[25+2] = c.Color2.B + data[25+3] = c.Color2.A + + bo.PutUint32(data[29:], math.Float32bits(c.Offset1)) +} + func (d PaintOp) Add(o *op.Ops) { data := o.Write(opconst.TypePaintLen) data[0] = byte(opconst.TypePaint)