Refactored the X backend draw code a bit
This commit is contained in:
parent
21c19363dd
commit
0f9a33fc57
@ -208,16 +208,7 @@ func (window *Window) reallocateCanvas () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (window *Window) redrawChildEntirely () {
|
func (window *Window) redrawChildEntirely () {
|
||||||
data, stride := window.child.Buffer()
|
window.pushRegion(window.paste(window.child))
|
||||||
bounds := window.child.Bounds()
|
|
||||||
window.xCanvas.For (func (x, y int) (c xgraphics.BGRA) {
|
|
||||||
if !(image.Point { x, y }).In(bounds) { return }
|
|
||||||
rgba := data[x + y * stride]
|
|
||||||
c.R, c.G, c.B, c.A = rgba.R, rgba.G, rgba.B, rgba.A
|
|
||||||
return
|
|
||||||
})
|
|
||||||
|
|
||||||
window.pushRegion(window.xCanvas.Bounds())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (window *Window) resizeChildToFit () {
|
func (window *Window) resizeChildToFit () {
|
||||||
@ -252,21 +243,23 @@ func (window *Window) resizeChildToFit () {
|
|||||||
|
|
||||||
func (window *Window) childDrawCallback (region tomo.Canvas) {
|
func (window *Window) childDrawCallback (region tomo.Canvas) {
|
||||||
if window.skipChildDrawCallback { return }
|
if window.skipChildDrawCallback { return }
|
||||||
|
window.pushRegion(window.paste(region))
|
||||||
|
}
|
||||||
|
|
||||||
data, stride := region.Buffer()
|
func (window *Window) paste (canvas tomo.Canvas) (updatedRegion image.Rectangle) {
|
||||||
bounds := region.Bounds()
|
data, stride := canvas.Buffer()
|
||||||
|
bounds := canvas.Bounds().Intersect(window.xCanvas.Bounds())
|
||||||
for x := bounds.Min.X; x < bounds.Max.X; x ++ {
|
for x := bounds.Min.X; x < bounds.Max.X; x ++ {
|
||||||
for y := bounds.Min.Y; y < bounds.Max.Y; y ++ {
|
for y := bounds.Min.Y; y < bounds.Max.Y; y ++ {
|
||||||
rgba := data[x + y * stride]
|
rgba := data[x + y * stride]
|
||||||
window.xCanvas.SetBGRA (x, y, xgraphics.BGRA {
|
index := x * 4 + y * window.xCanvas.Stride
|
||||||
R: rgba.R,
|
window.xCanvas.Pix[index + 0] = rgba.B
|
||||||
G: rgba.G,
|
window.xCanvas.Pix[index + 1] = rgba.G
|
||||||
B: rgba.B,
|
window.xCanvas.Pix[index + 2] = rgba.R
|
||||||
A: rgba.A,
|
window.xCanvas.Pix[index + 3] = rgba.A
|
||||||
})
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
window.pushRegion(region.Bounds())
|
return bounds
|
||||||
}
|
}
|
||||||
|
|
||||||
func (window *Window) childMinimumSizeChangeCallback (width, height int) {
|
func (window *Window) childMinimumSizeChangeCallback (width, height int) {
|
||||||
|
Reference in New Issue
Block a user