mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-13 22:47:26 +01:00
Compare commits
5 Commits
78ba0ded93
...
b121468991
Author | SHA1 | Date | |
---|---|---|---|
|
b121468991 | ||
|
d37301eeeb | ||
|
e5d10c47e7 | ||
|
6ac1270cb0 | ||
|
ab4a3af1b5 |
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@ -165,9 +165,10 @@ jobs:
|
|||||||
env GOARCH=386 EBITENGINE_DIRECTX=version=12 go test -shuffle=on -v ./...
|
env GOARCH=386 EBITENGINE_DIRECTX=version=12 go test -shuffle=on -v ./...
|
||||||
|
|
||||||
- name: go test (Wasm)
|
- name: go test (Wasm)
|
||||||
if: runner.os != 'macOS'
|
if: ${{ runner.os != 'macOS' && runner.os != 'Windows' }}
|
||||||
run: |
|
run: |
|
||||||
# Wasm tests don't work on macOS with the headless mode, and the headless mode doesn't work in GitHub Actions (#2972).
|
# Wasm tests don't work on macOS with the headless mode, and the headless mode doesn't work in GitHub Actions (#2972).
|
||||||
|
# Wasm tests don't work on Windows well due to mysterious timeouts (#2982).
|
||||||
env GOOS=js GOARCH=wasm cleanenv -remove-prefix GITHUB_ -remove-prefix JAVA_ -remove-prefix PSModulePath -remove-prefix STATS_ -remove-prefix RUNNER_ -- go test -shuffle=on -v ./...
|
env GOOS=js GOARCH=wasm cleanenv -remove-prefix GITHUB_ -remove-prefix JAVA_ -remove-prefix PSModulePath -remove-prefix STATS_ -remove-prefix RUNNER_ -- go test -shuffle=on -v ./...
|
||||||
|
|
||||||
- name: Install ebitenmobile
|
- name: Install ebitenmobile
|
||||||
|
@ -72,11 +72,11 @@ type DrawTrianglesOptions struct {
|
|||||||
|
|
||||||
// FillRule indicates the rule how an overlapped region is rendered.
|
// FillRule indicates the rule how an overlapped region is rendered.
|
||||||
//
|
//
|
||||||
// The rules NonZero and EvenOdd are useful when you want to render a complex polygon.
|
// The rules FileRuleNonZero and FillRuleEvenOdd are useful when you want to render a complex polygon.
|
||||||
// A complex polygon is a non-convex polygon like a concave polygon, a polygon with holes, or a self-intersecting polygon.
|
// A complex polygon is a non-convex polygon like a concave polygon, a polygon with holes, or a self-intersecting polygon.
|
||||||
// See examples/vector for actual usages.
|
// See examples/vector for actual usages.
|
||||||
//
|
//
|
||||||
// The default (zero) value is ebiten.FillAll.
|
// The default (zero) value is ebiten.FillRuleFillAll.
|
||||||
FillRule ebiten.FillRule
|
FillRule ebiten.FillRule
|
||||||
|
|
||||||
// AntiAlias indicates whether the rendering uses anti-alias or not.
|
// AntiAlias indicates whether the rendering uses anti-alias or not.
|
||||||
|
@ -141,14 +141,14 @@ func drawEbitenText(screen *ebiten.Image, x, y int, aa bool, line bool) {
|
|||||||
op := &ebiten.DrawTrianglesOptions{}
|
op := &ebiten.DrawTrianglesOptions{}
|
||||||
op.AntiAlias = aa
|
op.AntiAlias = aa
|
||||||
|
|
||||||
// For strokes (AppendVerticesAndIndicesForStroke), FillAll and NonZero work.
|
// For strokes (AppendVerticesAndIndicesForStroke), FillRuleFillAll and FillRuleNonZero work.
|
||||||
//
|
//
|
||||||
// For filling (AppendVerticesAndIndicesForFilling), NonZero and EvenOdd work.
|
// For filling (AppendVerticesAndIndicesForFilling), FillRuleNonZero and FillRuleEvenOdd work.
|
||||||
// NonZero and EvenOdd differ when rendering a complex polygons with self-intersections and/or holes.
|
// FillRuleNonZero and FillRuleEvenOdd differ when rendering a complex polygons with self-intersections and/or holes.
|
||||||
// See https://en.wikipedia.org/wiki/Nonzero-rule and https://en.wikipedia.org/wiki/Even%E2%80%93odd_rule .
|
// See https://en.wikipedia.org/wiki/Nonzero-rule and https://en.wikipedia.org/wiki/Even%E2%80%93odd_rule .
|
||||||
//
|
//
|
||||||
// For simplicity, this example always uses NonZero, whichever strokes or filling is done.
|
// For simplicity, this example always uses FillRuleNonZero, whichever strokes or filling is done.
|
||||||
op.FillRule = ebiten.NonZero
|
op.FillRule = ebiten.FillRuleNonZero
|
||||||
|
|
||||||
screen.DrawTriangles(vs, is, whiteSubImage, op)
|
screen.DrawTriangles(vs, is, whiteSubImage, op)
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ func drawEbitenLogo(screen *ebiten.Image, x, y int, aa bool, line bool) {
|
|||||||
|
|
||||||
op := &ebiten.DrawTrianglesOptions{}
|
op := &ebiten.DrawTrianglesOptions{}
|
||||||
op.AntiAlias = aa
|
op.AntiAlias = aa
|
||||||
op.FillRule = ebiten.NonZero
|
op.FillRule = ebiten.FillRuleNonZero
|
||||||
screen.DrawTriangles(vs, is, whiteSubImage, op)
|
screen.DrawTriangles(vs, is, whiteSubImage, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ func drawArc(screen *ebiten.Image, count int, aa bool, line bool) {
|
|||||||
|
|
||||||
op := &ebiten.DrawTrianglesOptions{}
|
op := &ebiten.DrawTrianglesOptions{}
|
||||||
op.AntiAlias = aa
|
op.AntiAlias = aa
|
||||||
op.FillRule = ebiten.NonZero
|
op.FillRule = ebiten.FillRuleNonZero
|
||||||
screen.DrawTriangles(vs, is, whiteSubImage, op)
|
screen.DrawTriangles(vs, is, whiteSubImage, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ func drawWave(screen *ebiten.Image, counter int, aa bool, line bool) {
|
|||||||
|
|
||||||
op := &ebiten.DrawTrianglesOptions{}
|
op := &ebiten.DrawTrianglesOptions{}
|
||||||
op.AntiAlias = aa
|
op.AntiAlias = aa
|
||||||
op.FillRule = ebiten.NonZero
|
op.FillRule = ebiten.FillRuleNonZero
|
||||||
screen.DrawTriangles(vs, is, whiteSubImage, op)
|
screen.DrawTriangles(vs, is, whiteSubImage, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
image.go
37
image.go
@ -262,7 +262,7 @@ func (i *Image) DrawImage(img *Image, options *DrawImageOptions) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
i.image.DrawTriangles(srcs, vs, is, blend, i.adjustedBounds(), [graphics.ShaderImageCount]image.Rectangle{img.adjustedBounds()}, shader.shader, i.tmpUniforms, graphicsdriver.FillAll, canSkipMipmap(geoM, filter), false)
|
i.image.DrawTriangles(srcs, vs, is, blend, i.adjustedBounds(), [graphics.ShaderImageCount]image.Rectangle{img.adjustedBounds()}, shader.shader, i.tmpUniforms, graphicsdriver.FillRuleFillAll, canSkipMipmap(geoM, filter), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vertex represents a vertex passed to DrawTriangles.
|
// Vertex represents a vertex passed to DrawTriangles.
|
||||||
@ -310,17 +310,36 @@ const (
|
|||||||
// FillRule is the rule whether an overlapped region is rendered with DrawTriangles(Shader).
|
// FillRule is the rule whether an overlapped region is rendered with DrawTriangles(Shader).
|
||||||
type FillRule int
|
type FillRule int
|
||||||
|
|
||||||
|
const (
|
||||||
|
// FillRuleFillAll indicates all the triangles are rendered regardless of overlaps.
|
||||||
|
FillRuleFillAll FillRule = FillRule(graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
|
// FillRuleNonZero means that triangles are rendered based on the non-zero rule.
|
||||||
|
// If and only if the number of overlaps is not 0, the region is rendered.
|
||||||
|
FillRuleNonZero FillRule = FillRule(graphicsdriver.FillRuleNonZero)
|
||||||
|
|
||||||
|
// FillRuleEvenOdd means that triangles are rendered based on the even-odd rule.
|
||||||
|
// If and only if the number of overlaps is odd, the region is rendered.
|
||||||
|
FillRuleEvenOdd FillRule = FillRule(graphicsdriver.FillRuleEvenOdd)
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// FillAll indicates all the triangles are rendered regardless of overlaps.
|
// FillAll indicates all the triangles are rendered regardless of overlaps.
|
||||||
FillAll FillRule = FillRule(graphicsdriver.FillAll)
|
//
|
||||||
|
// Deprecated: as of v2.8. Use FillRuleFillAll instead.
|
||||||
|
FillAll = FillRuleFillAll
|
||||||
|
|
||||||
// NonZero means that triangles are rendered based on the non-zero rule.
|
// NonZero means that triangles are rendered based on the non-zero rule.
|
||||||
// If and only if the number of overlaps is not 0, the region is rendered.
|
// If and only if the number of overlaps is not 0, the region is rendered.
|
||||||
NonZero FillRule = FillRule(graphicsdriver.NonZero)
|
//
|
||||||
|
// Deprecated: as of v2.8. Use FillRuleNonZero instead.
|
||||||
|
NonZero = FillRuleNonZero
|
||||||
|
|
||||||
// EvenOdd means that triangles are rendered based on the even-odd rule.
|
// EvenOdd means that triangles are rendered based on the even-odd rule.
|
||||||
// If and only if the number of overlaps is odd, the region is rendered.
|
// If and only if the number of overlaps is odd, the region is rendered.
|
||||||
EvenOdd FillRule = FillRule(graphicsdriver.EvenOdd)
|
//
|
||||||
|
// Deprecated: as of v2.8. Use FillRuleEvenOdd instead.
|
||||||
|
EvenOdd = FillRuleEvenOdd
|
||||||
)
|
)
|
||||||
|
|
||||||
// ColorScaleMode is the mode of color scales in vertices.
|
// ColorScaleMode is the mode of color scales in vertices.
|
||||||
@ -371,11 +390,11 @@ type DrawTrianglesOptions struct {
|
|||||||
|
|
||||||
// FillRule indicates the rule how an overlapped region is rendered.
|
// FillRule indicates the rule how an overlapped region is rendered.
|
||||||
//
|
//
|
||||||
// The rules NonZero and EvenOdd are useful when you want to render a complex polygon.
|
// The rules FillRuleNonZero and FillRuleEvenOdd are useful when you want to render a complex polygon.
|
||||||
// A complex polygon is a non-convex polygon like a concave polygon, a polygon with holes, or a self-intersecting polygon.
|
// A complex polygon is a non-convex polygon like a concave polygon, a polygon with holes, or a self-intersecting polygon.
|
||||||
// See examples/vector for actual usages.
|
// See examples/vector for actual usages.
|
||||||
//
|
//
|
||||||
// The default (zero) value is FillAll.
|
// The default (zero) value is FillRuleFillAll.
|
||||||
FillRule FillRule
|
FillRule FillRule
|
||||||
|
|
||||||
// AntiAlias indicates whether the rendering uses anti-alias or not.
|
// AntiAlias indicates whether the rendering uses anti-alias or not.
|
||||||
@ -547,11 +566,11 @@ type DrawTrianglesShaderOptions struct {
|
|||||||
|
|
||||||
// FillRule indicates the rule how an overlapped region is rendered.
|
// FillRule indicates the rule how an overlapped region is rendered.
|
||||||
//
|
//
|
||||||
// The rules NonZero and EvenOdd are useful when you want to render a complex polygon.
|
// The rules FillRuleNonZero and FillRuleEvenOdd are useful when you want to render a complex polygon.
|
||||||
// A complex polygon is a non-convex polygon like a concave polygon, a polygon with holes, or a self-intersecting polygon.
|
// A complex polygon is a non-convex polygon like a concave polygon, a polygon with holes, or a self-intersecting polygon.
|
||||||
// See examples/vector for actual usages.
|
// See examples/vector for actual usages.
|
||||||
//
|
//
|
||||||
// The default (zero) value is FillAll.
|
// The default (zero) value is FillRuleFillAll.
|
||||||
FillRule FillRule
|
FillRule FillRule
|
||||||
|
|
||||||
// AntiAlias indicates whether the rendering uses anti-alias or not.
|
// AntiAlias indicates whether the rendering uses anti-alias or not.
|
||||||
@ -816,7 +835,7 @@ func (i *Image) DrawRectShader(width, height int, shader *Shader, options *DrawR
|
|||||||
i.tmpUniforms = i.tmpUniforms[:0]
|
i.tmpUniforms = i.tmpUniforms[:0]
|
||||||
i.tmpUniforms = shader.appendUniforms(i.tmpUniforms, options.Uniforms)
|
i.tmpUniforms = shader.appendUniforms(i.tmpUniforms, options.Uniforms)
|
||||||
|
|
||||||
i.image.DrawTriangles(imgs, vs, is, blend, i.adjustedBounds(), srcRegions, shader.shader, i.tmpUniforms, graphicsdriver.FillAll, true, false)
|
i.image.DrawTriangles(imgs, vs, is, blend, i.adjustedBounds(), srcRegions, shader.shader, i.tmpUniforms, graphicsdriver.FillRuleFillAll, true, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubImage returns an image representing the portion of the image p visible through r.
|
// SubImage returns an image representing the portion of the image p visible through r.
|
||||||
|
@ -2696,7 +2696,7 @@ func TestImageEvenOdd(t *testing.T) {
|
|||||||
// Draw all the vertices once. The even-odd rule is applied for all the vertices once.
|
// Draw all the vertices once. The even-odd rule is applied for all the vertices once.
|
||||||
dst := ebiten.NewImage(16, 16)
|
dst := ebiten.NewImage(16, 16)
|
||||||
op := &ebiten.DrawTrianglesOptions{
|
op := &ebiten.DrawTrianglesOptions{
|
||||||
FillRule: ebiten.EvenOdd,
|
FillRule: ebiten.FillRuleEvenOdd,
|
||||||
}
|
}
|
||||||
dst.DrawTriangles(append(append(vs0, vs1...), vs2...), append(append(is0, is1...), is2...), emptySubImage, op)
|
dst.DrawTriangles(append(append(vs0, vs1...), vs2...), append(append(is0, is1...), is2...), emptySubImage, op)
|
||||||
for j := 0; j < 16; j++ {
|
for j := 0; j < 16; j++ {
|
||||||
@ -2794,15 +2794,15 @@ func TestImageEvenOdd(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestImageFillRule(t *testing.T) {
|
func TestImageFillRule(t *testing.T) {
|
||||||
for _, fillRule := range []ebiten.FillRule{ebiten.FillAll, ebiten.NonZero, ebiten.EvenOdd} {
|
for _, fillRule := range []ebiten.FillRule{ebiten.FillRuleFillAll, ebiten.FillRuleNonZero, ebiten.FillRuleEvenOdd} {
|
||||||
fillRule := fillRule
|
fillRule := fillRule
|
||||||
var name string
|
var name string
|
||||||
switch fillRule {
|
switch fillRule {
|
||||||
case ebiten.FillAll:
|
case ebiten.FillRuleFillAll:
|
||||||
name = "FillAll"
|
name = "FillAll"
|
||||||
case ebiten.NonZero:
|
case ebiten.FillRuleNonZero:
|
||||||
name = "NonZero"
|
name = "NonZero"
|
||||||
case ebiten.EvenOdd:
|
case ebiten.FillRuleEvenOdd:
|
||||||
name = "EvenOdd"
|
name = "EvenOdd"
|
||||||
}
|
}
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
@ -2885,11 +2885,11 @@ func TestImageFillRule(t *testing.T) {
|
|||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
switch {
|
switch {
|
||||||
case 2 <= i && i < 7 && 2 <= j && j < 7:
|
case 2 <= i && i < 7 && 2 <= j && j < 7:
|
||||||
if fillRule != ebiten.EvenOdd {
|
if fillRule != ebiten.FillRuleEvenOdd {
|
||||||
want = color.RGBA{G: 0xff, A: 0xff}
|
want = color.RGBA{G: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
case 9 <= i && i < 14 && 9 <= j && j < 14:
|
case 9 <= i && i < 14 && 9 <= j && j < 14:
|
||||||
if fillRule == ebiten.FillAll {
|
if fillRule == ebiten.FillRuleFillAll {
|
||||||
want = color.RGBA{B: 0xff, A: 0xff}
|
want = color.RGBA{B: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
case 1 <= i && i < 15 && 1 <= j && j < 15:
|
case 1 <= i && i < 15 && 1 <= j && j < 15:
|
||||||
@ -2922,11 +2922,11 @@ func TestImageFillRule(t *testing.T) {
|
|||||||
var want color.RGBA
|
var want color.RGBA
|
||||||
switch {
|
switch {
|
||||||
case 3 <= i && i < 8 && 3 <= j && j < 8:
|
case 3 <= i && i < 8 && 3 <= j && j < 8:
|
||||||
if fillRule != ebiten.EvenOdd {
|
if fillRule != ebiten.FillRuleEvenOdd {
|
||||||
want = color.RGBA{G: 0xff, A: 0xff}
|
want = color.RGBA{G: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
case 10 <= i && i < 15 && 10 <= j && j < 15:
|
case 10 <= i && i < 15 && 10 <= j && j < 15:
|
||||||
if fillRule == ebiten.FillAll {
|
if fillRule == ebiten.FillRuleFillAll {
|
||||||
want = color.RGBA{B: 0xff, A: 0xff}
|
want = color.RGBA{B: 0xff, A: 0xff}
|
||||||
}
|
}
|
||||||
case 2 <= i && i < 16 && 2 <= j && j < 16:
|
case 2 <= i && i < 16 && 2 <= j && j < 16:
|
||||||
@ -3726,7 +3726,7 @@ func TestImageTooManyConstantBuffersInDirectX(t *testing.T) {
|
|||||||
dst0 := ebiten.NewImage(16, 16)
|
dst0 := ebiten.NewImage(16, 16)
|
||||||
dst1 := ebiten.NewImage(16, 16)
|
dst1 := ebiten.NewImage(16, 16)
|
||||||
op := &ebiten.DrawTrianglesOptions{
|
op := &ebiten.DrawTrianglesOptions{
|
||||||
FillRule: ebiten.EvenOdd,
|
FillRule: ebiten.FillRuleEvenOdd,
|
||||||
}
|
}
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
dst0.DrawTriangles(vs, is, src, op)
|
dst0.DrawTriangles(vs, is, src, op)
|
||||||
|
@ -151,7 +151,7 @@ func (b *backend) extendIfNeeded(width, height int) {
|
|||||||
vs := quadVertices(0, 0, float32(sw), float32(sh), 0, 0, float32(sw), float32(sh), 1, 1, 1, 1)
|
vs := quadVertices(0, 0, float32(sw), float32(sh), 0, 0, float32(sw), float32(sh), 1, 1, 1, 1)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, sw, sh)
|
dr := image.Rect(0, 0, sw, sh)
|
||||||
newImg.DrawTriangles(srcs, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, NearestFilterShader.ensureShader(), nil, graphicsdriver.FillAll)
|
newImg.DrawTriangles(srcs, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, NearestFilterShader.ensureShader(), nil, graphicsdriver.FillRuleFillAll)
|
||||||
b.image.Dispose()
|
b.image.Dispose()
|
||||||
|
|
||||||
b.image = newImg
|
b.image = newImg
|
||||||
@ -175,7 +175,7 @@ func newClearedImage(width, height int, screen bool) *graphicscommand.Image {
|
|||||||
func clearImage(i *graphicscommand.Image, region image.Rectangle) {
|
func clearImage(i *graphicscommand.Image, region image.Rectangle) {
|
||||||
vs := quadVertices(float32(region.Min.X), float32(region.Min.Y), float32(region.Max.X), float32(region.Max.Y), 0, 0, 0, 0, 0, 0, 0, 0)
|
vs := quadVertices(float32(region.Min.X), float32(region.Min.Y), float32(region.Max.X), float32(region.Max.Y), 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
i.DrawTriangles([graphics.ShaderImageCount]*graphicscommand.Image{}, vs, is, graphicsdriver.BlendClear, region, [graphics.ShaderImageCount]image.Rectangle{}, clearShader.ensureShader(), nil, graphicsdriver.FillAll)
|
i.DrawTriangles([graphics.ShaderImageCount]*graphicscommand.Image{}, vs, is, graphicsdriver.BlendClear, region, [graphics.ShaderImageCount]image.Rectangle{}, clearShader.ensureShader(), nil, graphicsdriver.FillRuleFillAll)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *backend) clearPixels(region image.Rectangle) {
|
func (b *backend) clearPixels(region image.Rectangle) {
|
||||||
@ -348,7 +348,7 @@ func (i *Image) ensureIsolatedFromSource(backends []*backend) {
|
|||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, i.width, i.height)
|
dr := image.Rect(0, 0, i.width, i.height)
|
||||||
|
|
||||||
newI.drawTriangles([graphics.ShaderImageCount]*Image{i}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, NearestFilterShader, nil, graphicsdriver.FillAll)
|
newI.drawTriangles([graphics.ShaderImageCount]*Image{i}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
newI.moveTo(i)
|
newI.moveTo(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ func (i *Image) putOnSourceBackend() {
|
|||||||
graphics.QuadVertices(vs, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
|
graphics.QuadVertices(vs, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, i.width, i.height)
|
dr := image.Rect(0, 0, i.width, i.height)
|
||||||
newI.drawTriangles([graphics.ShaderImageCount]*Image{i}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, NearestFilterShader, nil, graphicsdriver.FillAll)
|
newI.drawTriangles([graphics.ShaderImageCount]*Image{i}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
newI.moveTo(i)
|
newI.moveTo(i)
|
||||||
i.usedAsSourceCount = 0
|
i.usedAsSourceCount = 0
|
||||||
|
@ -105,7 +105,7 @@ func TestEnsureIsolatedFromSourceBackend(t *testing.T) {
|
|||||||
vs := quadVertices(size/2, size/2, size/4, size/4, 1)
|
vs := quadVertices(size/2, size/2, size/4, size/4, 1)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, size, size)
|
dr := image.Rect(0, 0, size, size)
|
||||||
img4.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img3}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
img4.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img3}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
if got, want := img4.IsOnSourceBackendForTesting(), false; got != want {
|
if got, want := img4.IsOnSourceBackendForTesting(), false; got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ func TestEnsureIsolatedFromSourceBackend(t *testing.T) {
|
|||||||
// img5 is not allocated now, but is allocated at DrawTriangles.
|
// img5 is not allocated now, but is allocated at DrawTriangles.
|
||||||
vs = quadVertices(0, 0, size/2, size/2, 1)
|
vs = quadVertices(0, 0, size/2, size/2, 1)
|
||||||
dr = image.Rect(0, 0, size/2, size/2)
|
dr = image.Rect(0, 0, size/2, size/2)
|
||||||
img3.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img5}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
img3.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img5}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
if got, want := img3.IsOnSourceBackendForTesting(), false; got != want {
|
if got, want := img3.IsOnSourceBackendForTesting(), false; got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ func TestEnsureIsolatedFromSourceBackend(t *testing.T) {
|
|||||||
// Check further drawing doesn't cause panic.
|
// Check further drawing doesn't cause panic.
|
||||||
// This bug was fixed by 03dcd948.
|
// This bug was fixed by 03dcd948.
|
||||||
vs = quadVertices(0, 0, size/2, size/2, 1)
|
vs = quadVertices(0, 0, size/2, size/2, 1)
|
||||||
img4.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img3}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
img4.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img3}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReputOnSourceBackend(t *testing.T) {
|
func TestReputOnSourceBackend(t *testing.T) {
|
||||||
@ -191,7 +191,7 @@ func TestReputOnSourceBackend(t *testing.T) {
|
|||||||
// Render onto img1. The count should not matter.
|
// Render onto img1. The count should not matter.
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
vs := quadVertices(size, size, 0, 0, 1)
|
vs := quadVertices(size, size, 0, 0, 1)
|
||||||
img1.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img2}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
img1.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img2}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
if got, want := img1.IsOnSourceBackendForTesting(), false; got != want {
|
if got, want := img1.IsOnSourceBackendForTesting(), false; got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ func TestReputOnSourceBackend(t *testing.T) {
|
|||||||
for i := 0; i < atlas.BaseCountToPutOnSourceBackend*2; i++ {
|
for i := 0; i < atlas.BaseCountToPutOnSourceBackend*2; i++ {
|
||||||
atlas.PutImagesOnSourceBackendForTesting()
|
atlas.PutImagesOnSourceBackendForTesting()
|
||||||
vs := quadVertices(size, size, 0, 0, 1)
|
vs := quadVertices(size, size, 0, 0, 1)
|
||||||
img0.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img1}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
img0.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img1}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
if got, want := img1.IsOnSourceBackendForTesting(), false; got != want {
|
if got, want := img1.IsOnSourceBackendForTesting(), false; got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ func TestReputOnSourceBackend(t *testing.T) {
|
|||||||
// Finally, img1 is on a source backend.
|
// Finally, img1 is on a source backend.
|
||||||
atlas.PutImagesOnSourceBackendForTesting()
|
atlas.PutImagesOnSourceBackendForTesting()
|
||||||
vs := quadVertices(size, size, 0, 0, 1)
|
vs := quadVertices(size, size, 0, 0, 1)
|
||||||
img0.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img1}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
img0.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img1}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
if got, want := img1.IsOnSourceBackendForTesting(), true; got != want {
|
if got, want := img1.IsOnSourceBackendForTesting(), true; got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ func TestReputOnSourceBackend(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vs = quadVertices(size, size, 0, 0, 1)
|
vs = quadVertices(size, size, 0, 0, 1)
|
||||||
img0.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img1}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
img0.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img1}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
if got, want := img1.IsOnSourceBackendForTesting(), true; got != want {
|
if got, want := img1.IsOnSourceBackendForTesting(), true; got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -270,7 +270,7 @@ func TestReputOnSourceBackend(t *testing.T) {
|
|||||||
// Use img1 as a render target again. The count should not matter.
|
// Use img1 as a render target again. The count should not matter.
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
vs := quadVertices(size, size, 0, 0, 1)
|
vs := quadVertices(size, size, 0, 0, 1)
|
||||||
img1.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img2}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
img1.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img2}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
if got, want := img1.IsOnSourceBackendForTesting(), false; got != want {
|
if got, want := img1.IsOnSourceBackendForTesting(), false; got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -282,7 +282,7 @@ func TestReputOnSourceBackend(t *testing.T) {
|
|||||||
atlas.PutImagesOnSourceBackendForTesting()
|
atlas.PutImagesOnSourceBackendForTesting()
|
||||||
img1.WritePixels(make([]byte, 4*size*size), image.Rect(0, 0, size, size))
|
img1.WritePixels(make([]byte, 4*size*size), image.Rect(0, 0, size, size))
|
||||||
vs := quadVertices(size, size, 0, 0, 1)
|
vs := quadVertices(size, size, 0, 0, 1)
|
||||||
img0.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img1}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
img0.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img1}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
if got, want := img1.IsOnSourceBackendForTesting(), false; got != want {
|
if got, want := img1.IsOnSourceBackendForTesting(), false; got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ func TestReputOnSourceBackend(t *testing.T) {
|
|||||||
|
|
||||||
// img1 is not on an atlas due to WritePixels.
|
// img1 is not on an atlas due to WritePixels.
|
||||||
vs = quadVertices(size, size, 0, 0, 1)
|
vs = quadVertices(size, size, 0, 0, 1)
|
||||||
img0.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img1}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
img0.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img1}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
if got, want := img1.IsOnSourceBackendForTesting(), false; got != want {
|
if got, want := img1.IsOnSourceBackendForTesting(), false; got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ func TestReputOnSourceBackend(t *testing.T) {
|
|||||||
for i := 0; i < atlas.BaseCountToPutOnSourceBackend*2; i++ {
|
for i := 0; i < atlas.BaseCountToPutOnSourceBackend*2; i++ {
|
||||||
atlas.PutImagesOnSourceBackendForTesting()
|
atlas.PutImagesOnSourceBackendForTesting()
|
||||||
vs := quadVertices(size, size, 0, 0, 1)
|
vs := quadVertices(size, size, 0, 0, 1)
|
||||||
img0.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img3}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
img0.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{img3}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
if got, want := img3.IsOnSourceBackendForTesting(), false; got != want {
|
if got, want := img3.IsOnSourceBackendForTesting(), false; got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -403,7 +403,7 @@ func TestWritePixelsAfterDrawTriangles(t *testing.T) {
|
|||||||
vs := quadVertices(w, h, 0, 0, 1)
|
vs := quadVertices(w, h, 0, 0, 1)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, w, h)
|
dr := image.Rect(0, 0, w, h)
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
dst.WritePixels(pix, image.Rect(0, 0, w, h))
|
dst.WritePixels(pix, image.Rect(0, 0, w, h))
|
||||||
|
|
||||||
pix = make([]byte, 4*w*h)
|
pix = make([]byte, 4*w*h)
|
||||||
@ -450,7 +450,7 @@ func TestSmallImages(t *testing.T) {
|
|||||||
vs := quadVertices(w, h, 0, 0, 1)
|
vs := quadVertices(w, h, 0, 0, 1)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, w, h)
|
dr := image.Rect(0, 0, w, h)
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendSourceOver, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendSourceOver, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
pix = make([]byte, 4*w*h)
|
pix = make([]byte, 4*w*h)
|
||||||
ok, err := dst.ReadPixels(ui.Get().GraphicsDriverForTesting(), pix, image.Rect(0, 0, w, h))
|
ok, err := dst.ReadPixels(ui.Get().GraphicsDriverForTesting(), pix, image.Rect(0, 0, w, h))
|
||||||
@ -497,7 +497,7 @@ func TestLongImages(t *testing.T) {
|
|||||||
vs := quadVertices(w, h, 0, 0, scale)
|
vs := quadVertices(w, h, 0, 0, scale)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, dstW, dstH)
|
dr := image.Rect(0, 0, dstW, dstH)
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendSourceOver, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendSourceOver, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
pix = make([]byte, 4*dstW*dstH)
|
pix = make([]byte, 4*dstW*dstH)
|
||||||
ok, err := dst.ReadPixels(ui.Get().GraphicsDriverForTesting(), pix, image.Rect(0, 0, dstW, dstH))
|
ok, err := dst.ReadPixels(ui.Get().GraphicsDriverForTesting(), pix, image.Rect(0, 0, dstW, dstH))
|
||||||
@ -613,7 +613,7 @@ func TestDeallocatedAndReputOnSourceBackend(t *testing.T) {
|
|||||||
vs := quadVertices(size, size, 0, 0, 1)
|
vs := quadVertices(size, size, 0, 0, 1)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, size, size)
|
dr := image.Rect(0, 0, size, size)
|
||||||
src.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src2}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
src.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src2}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
if got, want := src.IsOnSourceBackendForTesting(), false; got != want {
|
if got, want := src.IsOnSourceBackendForTesting(), false; got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -622,7 +622,7 @@ func TestDeallocatedAndReputOnSourceBackend(t *testing.T) {
|
|||||||
for i := 0; i < atlas.BaseCountToPutOnSourceBackend/2; i++ {
|
for i := 0; i < atlas.BaseCountToPutOnSourceBackend/2; i++ {
|
||||||
atlas.PutImagesOnSourceBackendForTesting()
|
atlas.PutImagesOnSourceBackendForTesting()
|
||||||
vs := quadVertices(size, size, 0, 0, 1)
|
vs := quadVertices(size, size, 0, 0, 1)
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
if got, want := src.IsOnSourceBackendForTesting(), false; got != want {
|
if got, want := src.IsOnSourceBackendForTesting(), false; got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -656,7 +656,7 @@ func TestImageIsNotReputOnSourceBackendWithoutUsingAsSource(t *testing.T) {
|
|||||||
// Call DrawTriangles multiple times.
|
// Call DrawTriangles multiple times.
|
||||||
// The number of DrawTriangles doesn't matter as long as these are called in one frame.
|
// The number of DrawTriangles doesn't matter as long as these are called in one frame.
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
src2.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
src2.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
}
|
}
|
||||||
if got, want := src2.IsOnSourceBackendForTesting(), false; got != want {
|
if got, want := src2.IsOnSourceBackendForTesting(), false; got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
@ -675,7 +675,7 @@ func TestImageIsNotReputOnSourceBackendWithoutUsingAsSource(t *testing.T) {
|
|||||||
for i := 0; i < atlas.BaseCountToPutOnSourceBackend; i++ {
|
for i := 0; i < atlas.BaseCountToPutOnSourceBackend; i++ {
|
||||||
atlas.PutImagesOnSourceBackendForTesting()
|
atlas.PutImagesOnSourceBackendForTesting()
|
||||||
vs := quadVertices(size, size, 0, 0, 1)
|
vs := quadVertices(size, size, 0, 0, 1)
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src2}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src2}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
if got, want := src2.IsOnSourceBackendForTesting(), false; got != want {
|
if got, want := src2.IsOnSourceBackendForTesting(), false; got != want {
|
||||||
t.Errorf("got: %v, want: %v", got, want)
|
t.Errorf("got: %v, want: %v", got, want)
|
||||||
}
|
}
|
||||||
@ -801,14 +801,14 @@ func TestDestinationCountOverflow(t *testing.T) {
|
|||||||
|
|
||||||
// Use dst0 as a destination for a while.
|
// Use dst0 as a destination for a while.
|
||||||
for i := 0; i < 31; i++ {
|
for i := 0; i < 31; i++ {
|
||||||
dst0.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
dst0.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
atlas.PutImagesOnSourceBackendForTesting()
|
atlas.PutImagesOnSourceBackendForTesting()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use dst0 as a source for a while.
|
// Use dst0 as a source for a while.
|
||||||
// As dst0 is used as a destination too many times (31 is a maximum), dst0's backend should never be a source backend.
|
// As dst0 is used as a destination too many times (31 is a maximum), dst0's backend should never be a source backend.
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
dst1.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{dst0}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
dst1.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{dst0}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
atlas.PutImagesOnSourceBackendForTesting()
|
atlas.PutImagesOnSourceBackendForTesting()
|
||||||
if dst0.IsOnSourceBackendForTesting() {
|
if dst0.IsOnSourceBackendForTesting() {
|
||||||
t.Errorf("dst0 cannot be on a source backend: %d", i)
|
t.Errorf("dst0 cannot be on a source backend: %d", i)
|
||||||
@ -834,7 +834,7 @@ func TestIteratingImagesToPutOnSourceBackend(t *testing.T) {
|
|||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, w, h)
|
dr := image.Rect(0, 0, w, h)
|
||||||
for _, img := range srcs {
|
for _, img := range srcs {
|
||||||
img.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
img.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
}
|
}
|
||||||
atlas.PutImagesOnSourceBackendForTesting()
|
atlas.PutImagesOnSourceBackendForTesting()
|
||||||
|
|
||||||
@ -842,7 +842,7 @@ func TestIteratingImagesToPutOnSourceBackend(t *testing.T) {
|
|||||||
// Check iterating the registered image works correctly.
|
// Check iterating the registered image works correctly.
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
for _, src := range srcs {
|
for _, src := range srcs {
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
}
|
}
|
||||||
atlas.PutImagesOnSourceBackendForTesting()
|
atlas.PutImagesOnSourceBackendForTesting()
|
||||||
}
|
}
|
||||||
|
@ -37,12 +37,12 @@ func TestShaderFillTwice(t *testing.T) {
|
|||||||
dr := image.Rect(0, 0, w, h)
|
dr := image.Rect(0, 0, w, h)
|
||||||
g := ui.Get().GraphicsDriverForTesting()
|
g := ui.Get().GraphicsDriverForTesting()
|
||||||
s0 := atlas.NewShader(etesting.ShaderProgramFill(0xff, 0xff, 0xff, 0xff))
|
s0 := atlas.NewShader(etesting.ShaderProgramFill(0xff, 0xff, 0xff, 0xff))
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, s0, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, s0, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
// Vertices must be recreated (#1755)
|
// Vertices must be recreated (#1755)
|
||||||
vs = quadVertices(w, h, 0, 0, 1)
|
vs = quadVertices(w, h, 0, 0, 1)
|
||||||
s1 := atlas.NewShader(etesting.ShaderProgramFill(0x80, 0x80, 0x80, 0xff))
|
s1 := atlas.NewShader(etesting.ShaderProgramFill(0x80, 0x80, 0x80, 0xff))
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, s1, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, s1, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
pix := make([]byte, 4*w*h)
|
pix := make([]byte, 4*w*h)
|
||||||
ok, err := dst.ReadPixels(g, pix, image.Rect(0, 0, w, h))
|
ok, err := dst.ReadPixels(g, pix, image.Rect(0, 0, w, h))
|
||||||
@ -69,11 +69,11 @@ func TestImageDrawTwice(t *testing.T) {
|
|||||||
vs := quadVertices(w, h, 0, 0, 1)
|
vs := quadVertices(w, h, 0, 0, 1)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, w, h)
|
dr := image.Rect(0, 0, w, h)
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src0}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src0}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
// Vertices must be recreated (#1755)
|
// Vertices must be recreated (#1755)
|
||||||
vs = quadVertices(w, h, 0, 0, 1)
|
vs = quadVertices(w, h, 0, 0, 1)
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src1}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{src1}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
pix := make([]byte, 4*w*h)
|
pix := make([]byte, 4*w*h)
|
||||||
ok, err := dst.ReadPixels(ui.Get().GraphicsDriverForTesting(), pix, image.Rect(0, 0, w, h))
|
ok, err := dst.ReadPixels(ui.Get().GraphicsDriverForTesting(), pix, image.Rect(0, 0, w, h))
|
||||||
@ -97,7 +97,7 @@ func TestGCShader(t *testing.T) {
|
|||||||
vs := quadVertices(w, h, 0, 0, 1)
|
vs := quadVertices(w, h, 0, 0, 1)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, w, h)
|
dr := image.Rect(0, 0, w, h)
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, s, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*atlas.Image{}, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, s, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
// Ensure other objects are GCed, as GC appends deferred functions for collected objects.
|
// Ensure other objects are GCed, as GC appends deferred functions for collected objects.
|
||||||
ensureGC()
|
ensureGC()
|
||||||
|
@ -292,7 +292,7 @@ func (i *Image) syncPixelsIfNeeded() {
|
|||||||
srcs := [graphics.ShaderImageCount]*atlas.Image{whiteImage.img}
|
srcs := [graphics.ShaderImageCount]*atlas.Image{whiteImage.img}
|
||||||
dr := image.Rect(0, 0, i.width, i.height)
|
dr := image.Rect(0, 0, i.width, i.height)
|
||||||
blend := graphicsdriver.BlendCopy
|
blend := graphicsdriver.BlendCopy
|
||||||
i.img.DrawTriangles(srcs, vs, is, blend, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
i.img.DrawTriangles(srcs, vs, is, blend, dr, [graphics.ShaderImageCount]image.Rectangle{}, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
// TODO: Use clear if Go 1.21 is available.
|
// TODO: Use clear if Go 1.21 is available.
|
||||||
for pos := range i.dotsBuffer {
|
for pos := range i.dotsBuffer {
|
||||||
|
@ -56,7 +56,7 @@ func TestUnsyncedPixels(t *testing.T) {
|
|||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, 16, 16)
|
dr := image.Rect(0, 0, 16, 16)
|
||||||
sr := [graphics.ShaderImageCount]image.Rectangle{image.Rect(0, 0, 16, 16)}
|
sr := [graphics.ShaderImageCount]image.Rectangle{image.Rect(0, 0, 16, 16)}
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*buffered.Image{src}, vs, is, graphicsdriver.BlendSourceOver, dr, sr, atlas.NearestFilterShader, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*buffered.Image{src}, vs, is, graphicsdriver.BlendSourceOver, dr, sr, atlas.NearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
// Check the result is correct.
|
// Check the result is correct.
|
||||||
var got [4]byte
|
var got [4]byte
|
||||||
|
@ -166,7 +166,7 @@ func (c *drawTrianglesCommand) CanMergeWithDrawTrianglesCommand(dst *Image, srcs
|
|||||||
if c.fillRule != fillRule {
|
if c.fillRule != fillRule {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if c.fillRule != graphicsdriver.FillAll && mightOverlapDstRegions(c.vertices, vertices) {
|
if c.fillRule != graphicsdriver.FillRuleFillAll && mightOverlapDstRegions(c.vertices, vertices) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -59,7 +59,7 @@ func TestClear(t *testing.T) {
|
|||||||
vs := quadVertices(w/2, h/2)
|
vs := quadVertices(w/2, h/2)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, w, h)
|
dr := image.Rect(0, 0, w, h)
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*graphicscommand.Image{src}, vs, is, graphicsdriver.BlendClear, dr, [graphics.ShaderImageCount]image.Rectangle{}, nearestFilterShader, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*graphicscommand.Image{src}, vs, is, graphicsdriver.BlendClear, dr, [graphics.ShaderImageCount]image.Rectangle{}, nearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
pix := make([]byte, 4*w*h)
|
pix := make([]byte, 4*w*h)
|
||||||
if err := dst.ReadPixels(ui.Get().GraphicsDriverForTesting(), []graphicsdriver.PixelsArgs{
|
if err := dst.ReadPixels(ui.Get().GraphicsDriverForTesting(), []graphicsdriver.PixelsArgs{
|
||||||
@ -90,8 +90,8 @@ func TestWritePixelsPartAfterDrawTriangles(t *testing.T) {
|
|||||||
vs := quadVertices(w/2, h/2)
|
vs := quadVertices(w/2, h/2)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, w, h)
|
dr := image.Rect(0, 0, w, h)
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*graphicscommand.Image{clr}, vs, is, graphicsdriver.BlendClear, dr, [graphics.ShaderImageCount]image.Rectangle{}, nearestFilterShader, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*graphicscommand.Image{clr}, vs, is, graphicsdriver.BlendClear, dr, [graphics.ShaderImageCount]image.Rectangle{}, nearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*graphicscommand.Image{src}, vs, is, graphicsdriver.BlendSourceOver, dr, [graphics.ShaderImageCount]image.Rectangle{}, nearestFilterShader, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*graphicscommand.Image{src}, vs, is, graphicsdriver.BlendSourceOver, dr, [graphics.ShaderImageCount]image.Rectangle{}, nearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
bs := graphics.NewManagedBytes(4, func(bs []byte) {
|
bs := graphics.NewManagedBytes(4, func(bs []byte) {
|
||||||
for i := range bs {
|
for i := range bs {
|
||||||
bs[i] = 0
|
bs[i] = 0
|
||||||
@ -109,11 +109,11 @@ func TestShader(t *testing.T) {
|
|||||||
vs := quadVertices(w, h)
|
vs := quadVertices(w, h)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, w, h)
|
dr := image.Rect(0, 0, w, h)
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*graphicscommand.Image{clr}, vs, is, graphicsdriver.BlendClear, dr, [graphics.ShaderImageCount]image.Rectangle{}, nearestFilterShader, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*graphicscommand.Image{clr}, vs, is, graphicsdriver.BlendClear, dr, [graphics.ShaderImageCount]image.Rectangle{}, nearestFilterShader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
g := ui.Get().GraphicsDriverForTesting()
|
g := ui.Get().GraphicsDriverForTesting()
|
||||||
s := graphicscommand.NewShader(etesting.ShaderProgramFill(0xff, 0, 0, 0xff))
|
s := graphicscommand.NewShader(etesting.ShaderProgramFill(0xff, 0, 0, 0xff))
|
||||||
dst.DrawTriangles([graphics.ShaderImageCount]*graphicscommand.Image{}, vs, is, graphicsdriver.BlendSourceOver, dr, [graphics.ShaderImageCount]image.Rectangle{}, s, nil, graphicsdriver.FillAll)
|
dst.DrawTriangles([graphics.ShaderImageCount]*graphicscommand.Image{}, vs, is, graphicsdriver.BlendSourceOver, dr, [graphics.ShaderImageCount]image.Rectangle{}, s, nil, graphicsdriver.FillRuleFillAll)
|
||||||
|
|
||||||
pix := make([]byte, 4*w*h)
|
pix := make([]byte, 4*w*h)
|
||||||
if err := dst.ReadPixels(g, []graphicsdriver.PixelsArgs{
|
if err := dst.ReadPixels(g, []graphicsdriver.PixelsArgs{
|
||||||
|
@ -542,7 +542,7 @@ func (g *graphics11) DrawTriangles(dstID graphicsdriver.ImageID, srcIDs [graphic
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if err := dst.setAsRenderTarget(fillRule != graphicsdriver.FillAll); err != nil {
|
if err := dst.setAsRenderTarget(fillRule != graphicsdriver.FillRuleFillAll); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,7 +552,7 @@ func (g *graphics11) DrawTriangles(dstID graphicsdriver.ImageID, srcIDs [graphic
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if fillRule == graphicsdriver.FillAll {
|
if fillRule == graphicsdriver.FillRuleFillAll {
|
||||||
bs, err := g.blendState(blend, noStencil)
|
bs, err := g.blendState(blend, noStencil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -577,9 +577,9 @@ func (g *graphics11) DrawTriangles(dstID graphicsdriver.ImageID, srcIDs [graphic
|
|||||||
})
|
})
|
||||||
|
|
||||||
switch fillRule {
|
switch fillRule {
|
||||||
case graphicsdriver.FillAll:
|
case graphicsdriver.FillRuleFillAll:
|
||||||
g.deviceContext.DrawIndexed(uint32(dstRegion.IndexCount), uint32(indexOffset), 0)
|
g.deviceContext.DrawIndexed(uint32(dstRegion.IndexCount), uint32(indexOffset), 0)
|
||||||
case graphicsdriver.NonZero:
|
case graphicsdriver.FillRuleNonZero:
|
||||||
bs, err := g.blendState(blend, incrementStencil)
|
bs, err := g.blendState(blend, incrementStencil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -591,7 +591,7 @@ func (g *graphics11) DrawTriangles(dstID graphicsdriver.ImageID, srcIDs [graphic
|
|||||||
}
|
}
|
||||||
g.deviceContext.OMSetDepthStencilState(dss, 0)
|
g.deviceContext.OMSetDepthStencilState(dss, 0)
|
||||||
g.deviceContext.DrawIndexed(uint32(dstRegion.IndexCount), uint32(indexOffset), 0)
|
g.deviceContext.DrawIndexed(uint32(dstRegion.IndexCount), uint32(indexOffset), 0)
|
||||||
case graphicsdriver.EvenOdd:
|
case graphicsdriver.FillRuleEvenOdd:
|
||||||
bs, err := g.blendState(blend, invertStencil)
|
bs, err := g.blendState(blend, invertStencil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -605,7 +605,7 @@ func (g *graphics11) DrawTriangles(dstID graphicsdriver.ImageID, srcIDs [graphic
|
|||||||
g.deviceContext.DrawIndexed(uint32(dstRegion.IndexCount), uint32(indexOffset), 0)
|
g.deviceContext.DrawIndexed(uint32(dstRegion.IndexCount), uint32(indexOffset), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if fillRule != graphicsdriver.FillAll {
|
if fillRule != graphicsdriver.FillRuleFillAll {
|
||||||
bs, err := g.blendState(blend, drawWithStencil)
|
bs, err := g.blendState(blend, drawWithStencil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -1092,7 +1092,7 @@ func (g *graphics12) DrawTriangles(dstID graphicsdriver.ImageID, srcs [graphics.
|
|||||||
|
|
||||||
// Release constant buffers when too many ones will be created.
|
// Release constant buffers when too many ones will be created.
|
||||||
numPipelines := 1
|
numPipelines := 1
|
||||||
if fillRule != graphicsdriver.FillAll {
|
if fillRule != graphicsdriver.FillRuleFillAll {
|
||||||
numPipelines = 2
|
numPipelines = 2
|
||||||
}
|
}
|
||||||
if len(g.pipelineStates.constantBuffers[g.frameIndex])+numPipelines > numDescriptorsPerFrame {
|
if len(g.pipelineStates.constantBuffers[g.frameIndex])+numPipelines > numDescriptorsPerFrame {
|
||||||
@ -1124,7 +1124,7 @@ func (g *graphics12) DrawTriangles(dstID graphicsdriver.ImageID, srcs [graphics.
|
|||||||
g.drawCommandList.ResourceBarrier(resourceBarriers)
|
g.drawCommandList.ResourceBarrier(resourceBarriers)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := dst.setAsRenderTarget(g.drawCommandList, g.device, fillRule != graphicsdriver.FillAll); err != nil {
|
if err := dst.setAsRenderTarget(g.drawCommandList, g.device, fillRule != graphicsdriver.FillRuleFillAll); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ func (p *pipelineStates) drawTriangles(device *_ID3D12Device, commandList *_ID3D
|
|||||||
}
|
}
|
||||||
commandList.SetGraphicsRootDescriptorTable(2, sh)
|
commandList.SetGraphicsRootDescriptorTable(2, sh)
|
||||||
|
|
||||||
if fillRule == graphicsdriver.FillAll {
|
if fillRule == graphicsdriver.FillRuleFillAll {
|
||||||
s, err := shader.pipelineState(blend, noStencil, screen)
|
s, err := shader.pipelineState(blend, noStencil, screen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -307,16 +307,16 @@ func (p *pipelineStates) drawTriangles(device *_ID3D12Device, commandList *_ID3D
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
switch fillRule {
|
switch fillRule {
|
||||||
case graphicsdriver.FillAll:
|
case graphicsdriver.FillRuleFillAll:
|
||||||
commandList.DrawIndexedInstanced(uint32(dstRegion.IndexCount), 1, uint32(indexOffset), 0, 0)
|
commandList.DrawIndexedInstanced(uint32(dstRegion.IndexCount), 1, uint32(indexOffset), 0, 0)
|
||||||
case graphicsdriver.NonZero:
|
case graphicsdriver.FillRuleNonZero:
|
||||||
s, err := shader.pipelineState(blend, incrementStencil, screen)
|
s, err := shader.pipelineState(blend, incrementStencil, screen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
commandList.SetPipelineState(s)
|
commandList.SetPipelineState(s)
|
||||||
commandList.DrawIndexedInstanced(uint32(dstRegion.IndexCount), 1, uint32(indexOffset), 0, 0)
|
commandList.DrawIndexedInstanced(uint32(dstRegion.IndexCount), 1, uint32(indexOffset), 0, 0)
|
||||||
case graphicsdriver.EvenOdd:
|
case graphicsdriver.FillRuleEvenOdd:
|
||||||
s, err := shader.pipelineState(blend, invertStencil, screen)
|
s, err := shader.pipelineState(blend, invertStencil, screen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -325,7 +325,7 @@ func (p *pipelineStates) drawTriangles(device *_ID3D12Device, commandList *_ID3D
|
|||||||
commandList.DrawIndexedInstanced(uint32(dstRegion.IndexCount), 1, uint32(indexOffset), 0, 0)
|
commandList.DrawIndexedInstanced(uint32(dstRegion.IndexCount), 1, uint32(indexOffset), 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if fillRule != graphicsdriver.FillAll {
|
if fillRule != graphicsdriver.FillRuleFillAll {
|
||||||
s, err := shader.pipelineState(blend, drawWithStencil, screen)
|
s, err := shader.pipelineState(blend, drawWithStencil, screen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -30,19 +30,19 @@ type DstRegion struct {
|
|||||||
type FillRule int
|
type FillRule int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FillAll FillRule = iota
|
FillRuleFillAll FillRule = iota
|
||||||
NonZero
|
FillRuleNonZero
|
||||||
EvenOdd
|
FillRuleEvenOdd
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f FillRule) String() string {
|
func (f FillRule) String() string {
|
||||||
switch f {
|
switch f {
|
||||||
case FillAll:
|
case FillRuleFillAll:
|
||||||
return "FillAll"
|
return "FillRuleFillAll"
|
||||||
case NonZero:
|
case FillRuleNonZero:
|
||||||
return "NonZero"
|
return "FillRuleNonZero"
|
||||||
case EvenOdd:
|
case FillRuleEvenOdd:
|
||||||
return "EvenOdd"
|
return "FillRuleEvenOdd"
|
||||||
default:
|
default:
|
||||||
return fmt.Sprintf("FillRule(%d)", f)
|
return fmt.Sprintf("FillRule(%d)", f)
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,7 @@ func (g *Graphics) draw(dst *Image, dstRegions []graphicsdriver.DstRegion, srcs
|
|||||||
// When preparing a stencil buffer, flush the current render command encoder
|
// When preparing a stencil buffer, flush the current render command encoder
|
||||||
// to make sure the stencil buffer is cleared when loading.
|
// to make sure the stencil buffer is cleared when loading.
|
||||||
// TODO: What about clearing the stencil buffer by vertices?
|
// TODO: What about clearing the stencil buffer by vertices?
|
||||||
if g.lastDst != dst || g.lastFillRule != fillRule || fillRule != graphicsdriver.FillAll {
|
if g.lastDst != dst || g.lastFillRule != fillRule || fillRule != graphicsdriver.FillRuleFillAll {
|
||||||
g.flushRenderCommandEncoderIfNeeded()
|
g.flushRenderCommandEncoderIfNeeded()
|
||||||
}
|
}
|
||||||
g.lastDst = dst
|
g.lastDst = dst
|
||||||
@ -497,7 +497,7 @@ func (g *Graphics) draw(dst *Image, dstRegions []graphicsdriver.DstRegion, srcs
|
|||||||
rpd.ColorAttachments[0].Texture = t
|
rpd.ColorAttachments[0].Texture = t
|
||||||
rpd.ColorAttachments[0].ClearColor = mtl.ClearColor{}
|
rpd.ColorAttachments[0].ClearColor = mtl.ClearColor{}
|
||||||
|
|
||||||
if fillRule != graphicsdriver.FillAll {
|
if fillRule != graphicsdriver.FillRuleFillAll {
|
||||||
dst.ensureStencil()
|
dst.ensureStencil()
|
||||||
rpd.StencilAttachment.LoadAction = mtl.LoadActionClear
|
rpd.StencilAttachment.LoadAction = mtl.LoadActionClear
|
||||||
rpd.StencilAttachment.StoreAction = mtl.StoreActionDontCare
|
rpd.StencilAttachment.StoreAction = mtl.StoreActionDontCare
|
||||||
@ -544,26 +544,26 @@ func (g *Graphics) draw(dst *Image, dstRegions []graphicsdriver.DstRegion, srcs
|
|||||||
drawWithStencilRpss mtl.RenderPipelineState
|
drawWithStencilRpss mtl.RenderPipelineState
|
||||||
)
|
)
|
||||||
switch fillRule {
|
switch fillRule {
|
||||||
case graphicsdriver.FillAll:
|
case graphicsdriver.FillRuleFillAll:
|
||||||
s, err := shader.RenderPipelineState(&g.view, blend, noStencil, dst.screen)
|
s, err := shader.RenderPipelineState(&g.view, blend, noStencil, dst.screen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
noStencilRpss = s
|
noStencilRpss = s
|
||||||
case graphicsdriver.NonZero:
|
case graphicsdriver.FillRuleNonZero:
|
||||||
s, err := shader.RenderPipelineState(&g.view, blend, incrementStencil, dst.screen)
|
s, err := shader.RenderPipelineState(&g.view, blend, incrementStencil, dst.screen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
incrementStencilRpss = s
|
incrementStencilRpss = s
|
||||||
case graphicsdriver.EvenOdd:
|
case graphicsdriver.FillRuleEvenOdd:
|
||||||
s, err := shader.RenderPipelineState(&g.view, blend, invertStencil, dst.screen)
|
s, err := shader.RenderPipelineState(&g.view, blend, invertStencil, dst.screen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
invertStencilRpss = s
|
invertStencilRpss = s
|
||||||
}
|
}
|
||||||
if fillRule != graphicsdriver.FillAll {
|
if fillRule != graphicsdriver.FillRuleFillAll {
|
||||||
s, err := shader.RenderPipelineState(&g.view, blend, drawWithStencil, dst.screen)
|
s, err := shader.RenderPipelineState(&g.view, blend, drawWithStencil, dst.screen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -580,20 +580,20 @@ func (g *Graphics) draw(dst *Image, dstRegions []graphicsdriver.DstRegion, srcs
|
|||||||
})
|
})
|
||||||
|
|
||||||
switch fillRule {
|
switch fillRule {
|
||||||
case graphicsdriver.FillAll:
|
case graphicsdriver.FillRuleFillAll:
|
||||||
g.rce.SetDepthStencilState(g.dsss[noStencil])
|
g.rce.SetDepthStencilState(g.dsss[noStencil])
|
||||||
g.rce.SetRenderPipelineState(noStencilRpss)
|
g.rce.SetRenderPipelineState(noStencilRpss)
|
||||||
g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, dstRegion.IndexCount, mtl.IndexTypeUInt32, g.ib, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, dstRegion.IndexCount, mtl.IndexTypeUInt32, g.ib, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
||||||
case graphicsdriver.NonZero:
|
case graphicsdriver.FillRuleNonZero:
|
||||||
g.rce.SetDepthStencilState(g.dsss[incrementStencil])
|
g.rce.SetDepthStencilState(g.dsss[incrementStencil])
|
||||||
g.rce.SetRenderPipelineState(incrementStencilRpss)
|
g.rce.SetRenderPipelineState(incrementStencilRpss)
|
||||||
g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, dstRegion.IndexCount, mtl.IndexTypeUInt32, g.ib, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, dstRegion.IndexCount, mtl.IndexTypeUInt32, g.ib, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
||||||
case graphicsdriver.EvenOdd:
|
case graphicsdriver.FillRuleEvenOdd:
|
||||||
g.rce.SetDepthStencilState(g.dsss[invertStencil])
|
g.rce.SetDepthStencilState(g.dsss[invertStencil])
|
||||||
g.rce.SetRenderPipelineState(invertStencilRpss)
|
g.rce.SetRenderPipelineState(invertStencilRpss)
|
||||||
g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, dstRegion.IndexCount, mtl.IndexTypeUInt32, g.ib, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, dstRegion.IndexCount, mtl.IndexTypeUInt32, g.ib, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
||||||
}
|
}
|
||||||
if fillRule != graphicsdriver.FillAll {
|
if fillRule != graphicsdriver.FillRuleFillAll {
|
||||||
g.rce.SetDepthStencilState(g.dsss[drawWithStencil])
|
g.rce.SetDepthStencilState(g.dsss[drawWithStencil])
|
||||||
g.rce.SetRenderPipelineState(drawWithStencilRpss)
|
g.rce.SetRenderPipelineState(drawWithStencilRpss)
|
||||||
g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, dstRegion.IndexCount, mtl.IndexTypeUInt32, g.ib, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, dstRegion.IndexCount, mtl.IndexTypeUInt32, g.ib, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
||||||
|
@ -259,7 +259,7 @@ func (g *Graphics) DrawTriangles(dstID graphicsdriver.ImageID, srcIDs [graphics.
|
|||||||
}
|
}
|
||||||
g.uniformVars = g.uniformVars[:0]
|
g.uniformVars = g.uniformVars[:0]
|
||||||
|
|
||||||
if fillRule != graphicsdriver.FillAll {
|
if fillRule != graphicsdriver.FillRuleFillAll {
|
||||||
if err := destination.ensureStencilBuffer(); err != nil {
|
if err := destination.ensureStencilBuffer(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -274,14 +274,14 @@ func (g *Graphics) DrawTriangles(dstID graphicsdriver.ImageID, srcIDs [graphics.
|
|||||||
int32(dstRegion.Region.Dy()),
|
int32(dstRegion.Region.Dy()),
|
||||||
)
|
)
|
||||||
switch fillRule {
|
switch fillRule {
|
||||||
case graphicsdriver.NonZero:
|
case graphicsdriver.FillRuleNonZero:
|
||||||
g.context.ctx.Clear(gl.STENCIL_BUFFER_BIT)
|
g.context.ctx.Clear(gl.STENCIL_BUFFER_BIT)
|
||||||
g.context.ctx.StencilFunc(gl.ALWAYS, 0x00, 0xff)
|
g.context.ctx.StencilFunc(gl.ALWAYS, 0x00, 0xff)
|
||||||
g.context.ctx.StencilOpSeparate(gl.FRONT, gl.KEEP, gl.KEEP, gl.INCR_WRAP)
|
g.context.ctx.StencilOpSeparate(gl.FRONT, gl.KEEP, gl.KEEP, gl.INCR_WRAP)
|
||||||
g.context.ctx.StencilOpSeparate(gl.BACK, gl.KEEP, gl.KEEP, gl.DECR_WRAP)
|
g.context.ctx.StencilOpSeparate(gl.BACK, gl.KEEP, gl.KEEP, gl.DECR_WRAP)
|
||||||
g.context.ctx.ColorMask(false, false, false, false)
|
g.context.ctx.ColorMask(false, false, false, false)
|
||||||
g.context.ctx.DrawElements(gl.TRIANGLES, int32(dstRegion.IndexCount), gl.UNSIGNED_INT, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
g.context.ctx.DrawElements(gl.TRIANGLES, int32(dstRegion.IndexCount), gl.UNSIGNED_INT, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
||||||
case graphicsdriver.EvenOdd:
|
case graphicsdriver.FillRuleEvenOdd:
|
||||||
g.context.ctx.Clear(gl.STENCIL_BUFFER_BIT)
|
g.context.ctx.Clear(gl.STENCIL_BUFFER_BIT)
|
||||||
g.context.ctx.StencilFunc(gl.ALWAYS, 0x00, 0xff)
|
g.context.ctx.StencilFunc(gl.ALWAYS, 0x00, 0xff)
|
||||||
g.context.ctx.StencilOpSeparate(gl.FRONT_AND_BACK, gl.KEEP, gl.KEEP, gl.INVERT)
|
g.context.ctx.StencilOpSeparate(gl.FRONT_AND_BACK, gl.KEEP, gl.KEEP, gl.INVERT)
|
||||||
@ -289,7 +289,7 @@ func (g *Graphics) DrawTriangles(dstID graphicsdriver.ImageID, srcIDs [graphics.
|
|||||||
|
|
||||||
g.context.ctx.DrawElements(gl.TRIANGLES, int32(dstRegion.IndexCount), gl.UNSIGNED_INT, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
g.context.ctx.DrawElements(gl.TRIANGLES, int32(dstRegion.IndexCount), gl.UNSIGNED_INT, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
||||||
}
|
}
|
||||||
if fillRule != graphicsdriver.FillAll {
|
if fillRule != graphicsdriver.FillRuleFillAll {
|
||||||
g.context.ctx.StencilFunc(gl.NOTEQUAL, 0x00, 0xff)
|
g.context.ctx.StencilFunc(gl.NOTEQUAL, 0x00, 0xff)
|
||||||
g.context.ctx.StencilOpSeparate(gl.FRONT_AND_BACK, gl.KEEP, gl.KEEP, gl.KEEP)
|
g.context.ctx.StencilOpSeparate(gl.FRONT_AND_BACK, gl.KEEP, gl.KEEP, gl.KEEP)
|
||||||
g.context.ctx.ColorMask(true, true, true, true)
|
g.context.ctx.ColorMask(true, true, true, true)
|
||||||
@ -298,7 +298,7 @@ func (g *Graphics) DrawTriangles(dstID graphicsdriver.ImageID, srcIDs [graphics.
|
|||||||
indexOffset += dstRegion.IndexCount
|
indexOffset += dstRegion.IndexCount
|
||||||
}
|
}
|
||||||
|
|
||||||
if fillRule != graphicsdriver.FillAll {
|
if fillRule != graphicsdriver.FillRuleFillAll {
|
||||||
g.context.ctx.Disable(gl.STENCIL_TEST)
|
g.context.ctx.Disable(gl.STENCIL_TEST)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ func (m *Mipmap) level(level int) *buffered.Image {
|
|||||||
s := buffered.NewImage(w2, h2, m.imageType)
|
s := buffered.NewImage(w2, h2, m.imageType)
|
||||||
|
|
||||||
dstRegion := image.Rect(0, 0, w2, h2)
|
dstRegion := image.Rect(0, 0, w2, h2)
|
||||||
s.DrawTriangles([graphics.ShaderImageCount]*buffered.Image{src}, vs, is, graphicsdriver.BlendCopy, dstRegion, [graphics.ShaderImageCount]image.Rectangle{}, shader, nil, graphicsdriver.FillAll)
|
s.DrawTriangles([graphics.ShaderImageCount]*buffered.Image{src}, vs, is, graphicsdriver.BlendCopy, dstRegion, [graphics.ShaderImageCount]image.Rectangle{}, shader, nil, graphicsdriver.FillRuleFillAll)
|
||||||
m.setImg(level, s)
|
m.setImg(level, s)
|
||||||
|
|
||||||
return m.imgs[level]
|
return m.imgs[level]
|
||||||
|
4
internal/processtest/testdata/issue2138.go
vendored
4
internal/processtest/testdata/issue2138.go
vendored
@ -59,7 +59,7 @@ func (g *Game) Update() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) Draw(screen *ebiten.Image) {
|
func (g *Game) Draw(screen *ebiten.Image) {
|
||||||
// Before the fix, some complex renderings with EvenOdd might cause a DirectX error like this (#2138):
|
// Before the fix, some complex renderings with FillRuleEvenOdd might cause a DirectX error like this (#2138):
|
||||||
// panic: directx: IDXGISwapChain4::Present failed: HRESULT(2289696773)
|
// panic: directx: IDXGISwapChain4::Present failed: HRESULT(2289696773)
|
||||||
|
|
||||||
screen.DrawImage(debugCircleImage, nil)
|
screen.DrawImage(debugCircleImage, nil)
|
||||||
@ -74,7 +74,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
|||||||
p.Arc(100, 100, 6, 0, 2*math.Pi, vector.Clockwise)
|
p.Arc(100, 100, 6, 0, 2*math.Pi, vector.Clockwise)
|
||||||
filling, indicies := p.AppendVerticesAndIndicesForFilling(nil, nil)
|
filling, indicies := p.AppendVerticesAndIndicesForFilling(nil, nil)
|
||||||
screen.DrawTriangles(filling, indicies, whiteTextureImage, &ebiten.DrawTrianglesOptions{
|
screen.DrawTriangles(filling, indicies, whiteTextureImage, &ebiten.DrawTrianglesOptions{
|
||||||
FillRule: ebiten.EvenOdd,
|
FillRule: ebiten.FillRuleEvenOdd,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ func (i *Image) Fill(r, g, b, a float32, region image.Rectangle) {
|
|||||||
blend = graphicsdriver.BlendSourceOver
|
blend = graphicsdriver.BlendSourceOver
|
||||||
}
|
}
|
||||||
// i.lastBlend is updated in DrawTriangles.
|
// i.lastBlend is updated in DrawTriangles.
|
||||||
i.DrawTriangles(srcs, i.tmpVerticesForFill, is, blend, region, [graphics.ShaderImageCount]image.Rectangle{}, NearestFilterShader, nil, graphicsdriver.FillAll, true, false)
|
i.DrawTriangles(srcs, i.tmpVerticesForFill, is, blend, region, [graphics.ShaderImageCount]image.Rectangle{}, NearestFilterShader, nil, graphicsdriver.FillRuleFillAll, true, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
type bigOffscreenImage struct {
|
type bigOffscreenImage struct {
|
||||||
@ -252,7 +252,7 @@ func (i *bigOffscreenImage) drawTriangles(srcs [graphics.ShaderImageCount]*Image
|
|||||||
1, 1, 1, 1)
|
1, 1, 1, 1)
|
||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dstRegion := image.Rect(0, 0, i.region.Dx()*bigOffscreenScale, i.region.Dy()*bigOffscreenScale)
|
dstRegion := image.Rect(0, 0, i.region.Dx()*bigOffscreenScale, i.region.Dy()*bigOffscreenScale)
|
||||||
i.image.DrawTriangles(srcs, i.tmpVerticesForCopying, is, graphicsdriver.BlendCopy, dstRegion, [graphics.ShaderImageCount]image.Rectangle{}, NearestFilterShader, nil, graphicsdriver.FillAll, true, false)
|
i.image.DrawTriangles(srcs, i.tmpVerticesForCopying, is, graphicsdriver.BlendCopy, dstRegion, [graphics.ShaderImageCount]image.Rectangle{}, NearestFilterShader, nil, graphicsdriver.FillRuleFillAll, true, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
for idx := 0; idx < len(vertices); idx += graphics.VertexFloatCount {
|
for idx := 0; idx < len(vertices); idx += graphics.VertexFloatCount {
|
||||||
@ -300,7 +300,7 @@ func (i *bigOffscreenImage) flush() {
|
|||||||
if i.blend != graphicsdriver.BlendSourceOver {
|
if i.blend != graphicsdriver.BlendSourceOver {
|
||||||
blend = graphicsdriver.BlendCopy
|
blend = graphicsdriver.BlendCopy
|
||||||
}
|
}
|
||||||
i.orig.DrawTriangles(srcs, i.tmpVerticesForFlushing, is, blend, dstRegion, [graphics.ShaderImageCount]image.Rectangle{}, LinearFilterShader, nil, graphicsdriver.FillAll, true, false)
|
i.orig.DrawTriangles(srcs, i.tmpVerticesForFlushing, is, blend, dstRegion, [graphics.ShaderImageCount]image.Rectangle{}, LinearFilterShader, nil, graphicsdriver.FillRuleFillAll, true, false)
|
||||||
|
|
||||||
i.image.clear()
|
i.image.clear()
|
||||||
i.dirty = false
|
i.dirty = false
|
||||||
|
@ -396,7 +396,7 @@ func (p *Path) Close() {
|
|||||||
//
|
//
|
||||||
// The returned vertice's SrcX and SrcY are 0, and ColorR, ColorG, ColorB, and ColorA are 1.
|
// The returned vertice's SrcX and SrcY are 0, and ColorR, ColorG, ColorB, and ColorA are 1.
|
||||||
//
|
//
|
||||||
// The returned values are intended to be passed to DrawTriangles or DrawTrianglesShader with the fill rule NonZero or EvenOdd
|
// The returned values are intended to be passed to DrawTriangles or DrawTrianglesShader with FileRuleNonZero or FillRuleEvenOdd
|
||||||
// in order to render a complex polygon like a concave polygon, a polygon with holes, or a self-intersecting polygon.
|
// in order to render a complex polygon like a concave polygon, a polygon with holes, or a self-intersecting polygon.
|
||||||
//
|
//
|
||||||
// The returned vertices and indices should be rendered with a solid (non-transparent) color with the default Blend (source-over).
|
// The returned vertices and indices should be rendered with a solid (non-transparent) color with the default Blend (source-over).
|
||||||
@ -480,7 +480,7 @@ type StrokeOptions struct {
|
|||||||
// The returned vertice's SrcX and SrcY are 0, and ColorR, ColorG, ColorB, and ColorA are 1.
|
// The returned vertice's SrcX and SrcY are 0, and ColorR, ColorG, ColorB, and ColorA are 1.
|
||||||
//
|
//
|
||||||
// The returned values are intended to be passed to DrawTriangles or DrawTrianglesShader with a solid (non-transparent) color
|
// The returned values are intended to be passed to DrawTriangles or DrawTrianglesShader with a solid (non-transparent) color
|
||||||
// with FillAll or NonZero fill rule, not EvenOdd fill rule.
|
// with FillRuleFillAll or FillRuleNonZero, not FileRuleEvenOdd.
|
||||||
func (p *Path) AppendVerticesAndIndicesForStroke(vertices []ebiten.Vertex, indices []uint16, op *StrokeOptions) ([]ebiten.Vertex, []uint16) {
|
func (p *Path) AppendVerticesAndIndicesForStroke(vertices []ebiten.Vertex, indices []uint16, op *StrokeOptions) ([]ebiten.Vertex, []uint16) {
|
||||||
if op == nil {
|
if op == nil {
|
||||||
return vertices, indices
|
return vertices, indices
|
||||||
@ -536,7 +536,7 @@ func (p *Path) AppendVerticesAndIndicesForStroke(vertices []ebiten.Vertex, indic
|
|||||||
ColorA: 1,
|
ColorA: 1,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// All the triangles are rendered in clockwise order to enable NonZero filling rule (#2833).
|
// All the triangles are rendered in clockwise order to enable FillRuleNonZero (#2833).
|
||||||
indices = append(indices, idx, idx+1, idx+2, idx+1, idx+3, idx+2)
|
indices = append(indices, idx, idx+1, idx+2, idx+1, idx+3, idx+2)
|
||||||
|
|
||||||
// Add line joints.
|
// Add line joints.
|
||||||
|
Loading…
Reference in New Issue
Block a user