mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
graphis: Bug fix: blurred screen after restoring the context (#306)
This commit is contained in:
parent
a1885458fb
commit
d3e1f91511
@ -305,13 +305,12 @@ func (u *userInterface) setScreenSize(width, height int, scale float64) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
u.scale = scale
|
u.scale = scale
|
||||||
// When the scale is an integer, let's rely on CSS crisp-edge/pixelated effect.
|
// CSS imageRendering seems useful to enlarge the screen,
|
||||||
// Note that pixelated effect doesn't work for canvas on Safari.
|
// but doesn't work in some cases (#306):
|
||||||
if scale == float64(int64(scale)) && !isSafari() {
|
// * Chrome just after restoring the lost context
|
||||||
u.deviceScale = 1
|
// * Safari
|
||||||
} else {
|
// Let's use the pixel ratio as it is here.
|
||||||
u.deviceScale = devicePixelRatio()
|
u.deviceScale = devicePixelRatio()
|
||||||
}
|
|
||||||
canvas.Set("width", int(float64(width)*u.actualScreenScale()))
|
canvas.Set("width", int(float64(width)*u.actualScreenScale()))
|
||||||
canvas.Set("height", int(float64(height)*u.actualScreenScale()))
|
canvas.Set("height", int(float64(height)*u.actualScreenScale()))
|
||||||
canvasStyle := canvas.Get("style")
|
canvasStyle := canvas.Get("style")
|
||||||
@ -323,9 +322,6 @@ func (u *userInterface) setScreenSize(width, height int, scale float64) bool {
|
|||||||
// CSS calc requires space chars.
|
// CSS calc requires space chars.
|
||||||
canvasStyle.Set("left", "calc((100% - "+strconv.Itoa(cssWidth)+"px) / 2)")
|
canvasStyle.Set("left", "calc((100% - "+strconv.Itoa(cssWidth)+"px) / 2)")
|
||||||
canvasStyle.Set("top", "calc((100% - "+strconv.Itoa(cssHeight)+"px) / 2)")
|
canvasStyle.Set("top", "calc((100% - "+strconv.Itoa(cssHeight)+"px) / 2)")
|
||||||
canvasStyle.Set("imageRendering", "-moz-crisp-edges")
|
|
||||||
canvasStyle.Set("imageRendering", "pixelated")
|
|
||||||
// TODO: Set `-ms-interpolation-mode: nearest-neighbor;` for IE.
|
|
||||||
u.sizeChanged = true
|
u.sizeChanged = true
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user