X backend better handles expose events
Previously, when an expose event was recieved, the backend would call Window.paste, converting RGBA image data to BGRA image data. Now we only call Window.pushRegion with the bounds given to us by the expose event(s). This speeds up window resizing significantly.
This commit is contained in:
parent
803812f9c9
commit
423e6869c0
@ -24,22 +24,27 @@ func (pattern Texture) Draw (destination canvas.Canvas, clip image.Rectangle) {
|
|||||||
srcPoint := bounds.Min.Sub(realBounds.Min).Add(srcBounds.Min)
|
srcPoint := bounds.Min.Sub(realBounds.Min).Add(srcBounds.Min)
|
||||||
srcPoint.X = wrap(srcPoint.X, srcBounds.Min.X, srcBounds.Max.X)
|
srcPoint.X = wrap(srcPoint.X, srcBounds.Min.X, srcBounds.Max.X)
|
||||||
srcPoint.Y = wrap(srcPoint.Y, srcBounds.Min.Y, srcBounds.Max.Y)
|
srcPoint.Y = wrap(srcPoint.Y, srcBounds.Min.Y, srcBounds.Max.Y)
|
||||||
srcPointXStart := srcPoint.X
|
|
||||||
|
|
||||||
for dstPoint.Y = bounds.Min.Y; dstPoint.Y < bounds.Max.Y; dstPoint.Y ++ {
|
for dstPoint.Y = bounds.Min.Y; dstPoint.Y < bounds.Max.Y; dstPoint.Y ++ {
|
||||||
srcPoint.X = srcPointXStart
|
srcPoint.X = srcBounds.Min.X
|
||||||
|
dstPoint.X = bounds.Min.X
|
||||||
|
dstYComponent := dstPoint.Y * dstStride
|
||||||
|
srcYComponent := srcPoint.Y * srcStride
|
||||||
|
|
||||||
for dstPoint.X = bounds.Min.X; dstPoint.X < bounds.Max.X; dstPoint.X ++ {
|
for {
|
||||||
dstIndex := dstPoint.X + dstPoint.Y * dstStride
|
dstIndex := dstYComponent + dstPoint.X
|
||||||
srcIndex :=
|
srcIndex := srcYComponent + srcPoint.X
|
||||||
srcPoint.X +
|
|
||||||
srcPoint.Y * srcStride
|
|
||||||
dstData[dstIndex] = srcData[srcIndex]
|
dstData[dstIndex] = srcData[srcIndex]
|
||||||
|
|
||||||
srcPoint.X ++
|
srcPoint.X ++
|
||||||
if srcPoint.X >= srcBounds.Max.X {
|
if srcPoint.X >= srcBounds.Max.X {
|
||||||
srcPoint.X = srcBounds.Min.X
|
srcPoint.X = srcBounds.Min.X
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dstPoint.X ++
|
||||||
|
if dstPoint.X >= bounds.Max.X {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
srcPoint.Y ++
|
srcPoint.Y ++
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package x
|
package x
|
||||||
|
|
||||||
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/input"
|
import "git.tebibyte.media/sashakoshka/tomo/input"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||||
|
|
||||||
@ -47,8 +48,8 @@ func (window *Window) handleExpose (
|
|||||||
connection *xgbutil.XUtil,
|
connection *xgbutil.XUtil,
|
||||||
event xevent.ExposeEvent,
|
event xevent.ExposeEvent,
|
||||||
) {
|
) {
|
||||||
_ = window.compressExpose(*event.ExposeEvent)
|
_, region := window.compressExpose(*event.ExposeEvent)
|
||||||
window.redrawChildEntirely()
|
window.pushRegion(region)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (window *Window) handleConfigureNotify (
|
func (window *Window) handleConfigureNotify (
|
||||||
@ -234,7 +235,13 @@ func (window *Window) compressExpose (
|
|||||||
firstEvent xproto.ExposeEvent,
|
firstEvent xproto.ExposeEvent,
|
||||||
) (
|
) (
|
||||||
lastEvent xproto.ExposeEvent,
|
lastEvent xproto.ExposeEvent,
|
||||||
|
region image.Rectangle,
|
||||||
) {
|
) {
|
||||||
|
region = image.Rect (
|
||||||
|
int(firstEvent.X), int(firstEvent.Y),
|
||||||
|
int(firstEvent.X + firstEvent.Width),
|
||||||
|
int(firstEvent.Y + firstEvent.Height))
|
||||||
|
|
||||||
window.backend.connection.Sync()
|
window.backend.connection.Sync()
|
||||||
xevent.Read(window.backend.connection, false)
|
xevent.Read(window.backend.connection, false)
|
||||||
lastEvent = firstEvent
|
lastEvent = firstEvent
|
||||||