mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
ui: Don't use 'image-rendering' CSS on Safari (#293)
This commit is contained in:
parent
d16b5d328a
commit
a1e868b822
@ -18,6 +18,7 @@ package ui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gopherjs/gopherjs/js"
|
"github.com/gopherjs/gopherjs/js"
|
||||||
"github.com/hajimehoshi/ebiten/internal/opengl"
|
"github.com/hajimehoshi/ebiten/internal/opengl"
|
||||||
@ -287,6 +288,17 @@ func (u *userInterface) size() (width, height int) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isSafari() bool {
|
||||||
|
ua := js.Global.Get("navigator").Get("userAgent").String()
|
||||||
|
if !strings.Contains(ua, "Safari") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if strings.Contains(ua, "Chrome") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (u *userInterface) setScreenSize(width, height int, scale float64) bool {
|
func (u *userInterface) setScreenSize(width, height int, scale float64) bool {
|
||||||
w, h := u.size()
|
w, h := u.size()
|
||||||
s := u.scale
|
s := u.scale
|
||||||
@ -295,7 +307,8 @@ func (u *userInterface) setScreenSize(width, height int, scale float64) bool {
|
|||||||
}
|
}
|
||||||
u.scale = scale
|
u.scale = scale
|
||||||
// When the scale is an integer, let's rely on CSS crisp-edge/pixelated effect.
|
// When the scale is an integer, let's rely on CSS crisp-edge/pixelated effect.
|
||||||
if scale == float64(int64(scale)) {
|
// Note that pixelated effect doesn't work for canvas on Safari.
|
||||||
|
if scale == float64(int64(scale)) && !isSafari() {
|
||||||
u.deviceScale = 1
|
u.deviceScale = 1
|
||||||
} else {
|
} else {
|
||||||
u.deviceScale = devicePixelRatio()
|
u.deviceScale = devicePixelRatio()
|
||||||
|
Loading…
Reference in New Issue
Block a user