Skip to content

Commit 572c983

Browse files
committed
Better handle use of EGL context API (particularly on Wayland)
Fixes #81
1 parent 280b6ad commit 572c983

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/flitter/render/window/canvas.pyx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ from cpython cimport array, PyObject
1111
from cpython.dict cimport PyDict_GetItem, PyDict_SetItem
1212
from libc.math cimport acos, sqrt
1313
from libc.stdint cimport uint32_t
14+
import glfw
1415
from loguru import logger
1516
import skia
1617

@@ -889,8 +890,12 @@ class Canvas(WindowNode):
889890
self._target.release()
890891
self._target = RenderTarget.get(self.glctx, self.width, self.height, colorbits, srgb=srgb)
891892
if self._graphics_context is None:
892-
if opengl_es:
893-
self._graphics_context = skia.GrDirectContext.MakeGL(skia.GrGLInterface.MakeEGL())
893+
if opengl_es or glfw.get_platform() == glfw.PLATFORM_WAYLAND:
894+
if hasattr(skia.GrGLInterface, 'MakeEGL'):
895+
self._graphics_context = skia.GrDirectContext.MakeGL(skia.GrGLInterface.MakeEGL())
896+
else:
897+
logger.error("Missing EGL context API support in Skia")
898+
self._graphics_context = None
894899
else:
895900
self._graphics_context = skia.GrDirectContext.MakeGL()
896901
if self._graphics_context is None:

0 commit comments

Comments
 (0)