graphics: Skip clearing the screen framebuffer

This commit is contained in:
Hajime Hoshi 2018-03-05 02:59:52 +09:00
parent 64abc79dc2
commit d523229d9f

View File

@ -102,19 +102,22 @@ func (c *graphicsContext) Update(afterFrameUpdate func()) error {
// Clear the screen framebuffer by DrawImage instad of Fill // Clear the screen framebuffer by DrawImage instad of Fill
// to clear the whole region including fullscreen's padding. // to clear the whole region including fullscreen's padding.
op := &DrawImageOptions{} // TODO: This clear is needed only when the screen size is changed.
w, h := emptyImage.Size() if c.offsetX > 0 || c.offsetY > 0 {
// graphics.MaxImageSize should be the maximum size of framebuffer. op := &DrawImageOptions{}
op.GeoM.Scale(graphics.MaxImageSize/float64(w), graphics.MaxImageSize/float64(h)) w, h := emptyImage.Size()
op.CompositeMode = CompositeModeCopy // graphics.MaxImageSize should be the maximum size of framebuffer.
op.Filter = filterScreen // any filter is fine: just use the same filter as below. op.GeoM.Scale(graphics.MaxImageSize/float64(w), graphics.MaxImageSize/float64(h))
c.screen.DrawImage(emptyImage, op) op.CompositeMode = CompositeModeCopy
op.Filter = filterScreen // any filter is fine: just use the same filter as below.
c.screen.DrawImage(emptyImage, op)
}
dw, dh := c.screen.Size() dw, dh := c.screen.Size()
sw, _ := c.offscreen.Size() sw, _ := c.offscreen.Size()
scale := float64(dw) / float64(sw) scale := float64(dw) / float64(sw)
op = &DrawImageOptions{} op := &DrawImageOptions{}
// c.screen is special: its Y axis is down to up, // c.screen is special: its Y axis is down to up,
// and the origin point is lower left. // and the origin point is lower left.
op.GeoM.Scale(scale, -scale) op.GeoM.Scale(scale, -scale)