Sped up rendering significantly
This commit is contained in:
parent
11402cfc25
commit
c171273240
@ -20,17 +20,30 @@ func (pattern Texture) Draw (destination canvas.Canvas, clip image.Rectangle) {
|
|||||||
srcData, srcStride := pattern.Buffer()
|
srcData, srcStride := pattern.Buffer()
|
||||||
srcBounds := pattern.Bounds()
|
srcBounds := pattern.Bounds()
|
||||||
|
|
||||||
point := image.Point { }
|
dstPoint := image.Point { }
|
||||||
for point.Y = bounds.Min.Y; point.Y < bounds.Max.Y; point.Y ++ {
|
srcPoint := bounds.Min.Sub(realBounds.Min).Add(srcBounds.Min)
|
||||||
for point.X = bounds.Min.X; point.X < bounds.Max.X; point.X ++ {
|
srcPoint.X = wrap(srcPoint.X, srcBounds.Min.X, srcBounds.Max.X)
|
||||||
srcPoint := point.Sub(realBounds.Min).Add(srcBounds.Min)
|
srcPoint.Y = wrap(srcPoint.Y, srcBounds.Min.Y, srcBounds.Max.Y)
|
||||||
|
|
||||||
dstIndex := point.X + point.Y * dstStride
|
for dstPoint.Y = bounds.Min.Y; dstPoint.Y < bounds.Max.Y; dstPoint.Y ++ {
|
||||||
srcIndex :=
|
for dstPoint.X = bounds.Min.X; dstPoint.X < bounds.Max.X; dstPoint.X ++ {
|
||||||
wrap(srcPoint.X, srcBounds.Min.X, srcBounds.Max.X) +
|
dstIndex := dstPoint.X + dstPoint.Y * dstStride
|
||||||
wrap(srcPoint.Y, srcBounds.Min.Y, srcBounds.Max.Y) * srcStride
|
srcIndex :=
|
||||||
dstData[dstIndex] = srcData[srcIndex]
|
srcPoint.X +
|
||||||
}}
|
srcPoint.Y * srcStride
|
||||||
|
dstData[dstIndex] = srcData[srcIndex]
|
||||||
|
|
||||||
|
srcPoint.X ++
|
||||||
|
if srcPoint.X >= srcBounds.Max.X {
|
||||||
|
srcPoint.X = srcBounds.Min.X
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
srcPoint.Y ++
|
||||||
|
if srcPoint.Y >= srcBounds.Max.Y {
|
||||||
|
srcPoint.Y = srcBounds.Min.Y
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func wrap (value, min, max int) int {
|
func wrap (value, min, max int) int {
|
||||||
|
@ -3,6 +3,8 @@ package main
|
|||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
|
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
|
||||||
|
import _ "net/http/pprof"
|
||||||
|
import "net/http"
|
||||||
|
|
||||||
func main () {
|
func main () {
|
||||||
tomo.Run(run)
|
tomo.Run(run)
|
||||||
@ -26,4 +28,9 @@ func run () {
|
|||||||
window.Adopt(button)
|
window.Adopt(button)
|
||||||
window.OnClose(tomo.Stop)
|
window.OnClose(tomo.Stop)
|
||||||
window.Show()
|
window.Show()
|
||||||
|
|
||||||
|
// just some stuff for profiling, this is not needed for tomo
|
||||||
|
go func () {
|
||||||
|
http.ListenAndServe("localhost:9090", nil)
|
||||||
|
} ()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user