Skip to content

Commit 9828bf1

Browse files
committed
Skia now supports initialisation with EGL on Linux
Need to use the latest version, but can now run the ES tests on Linux.
1 parent 1b4269e commit 9828bf1

File tree

3 files changed

+10
-45
lines changed

3 files changed

+10
-45
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ dependencies = [
4949
"regex",
5050
"rtmidi2",
5151
"scipy",
52-
"skia-python>=117.0b3",
52+
"skia-python>=138.0rc1",
5353
"trimesh",
5454
]
5555

src/flitter/render/window/canvas.pyx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ class Canvas(WindowNode):
878878
if self._target is not None:
879879
self._target.release()
880880

881-
def create(self, engine, node, resized, **kwargs):
881+
def create(self, engine, node, resized, opengl_es=False, **kwargs):
882882
colorbits = node.get('colorbits', 1, int, 8)
883883
srgb = not node.get('linear', 1, bool, False)
884884
if srgb or colorbits not in COLOR_FORMATS:
@@ -889,7 +889,10 @@ class Canvas(WindowNode):
889889
self._target.release()
890890
self._target = RenderTarget.get(self.glctx, self.width, self.height, colorbits, srgb=srgb)
891891
if self._graphics_context is None:
892-
self._graphics_context = skia.GrDirectContext.MakeGL()
892+
if opengl_es:
893+
self._graphics_context = skia.GrDirectContext.MakeGL(skia.GrGLInterface.MakeEGL())
894+
else:
895+
self._graphics_context = skia.GrDirectContext.MakeGL()
893896
if self._graphics_context is None:
894897
logger.error("Failed to create GL context for Skia (is this OpenGL ES?)")
895898
self._surface = None

tests/test_engine.py

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -251,46 +251,8 @@ def test_translucency(self):
251251
def test_video(self):
252252
self.assertScriptOutputMatchesImage(self.EXAMPLES / 'video.fl')
253253

254-
@unittest.skipIf(sys.platform != 'linux', 'OpenGL ES only available on Linux')
255-
def test_bauble_opengl_es(self):
256-
self.assertScriptOutputMatchesImage(self.EXAMPLES / 'bauble.fl', opengl_es=True, suffix='.es.png')
257254

258-
@unittest.skipIf(sys.platform != 'linux', 'OpenGL ES only available on Linux')
259-
def test_bounce_opengl_es(self):
260-
self.assertScriptOutputMatchesImage(self.EXAMPLES / 'bounce.fl', target_fps=10, opengl_es=True, suffix='.es.png')
261-
262-
@unittest.skipIf(sys.platform != 'linux', 'OpenGL ES only available on Linux')
263-
def test_canvas3d_opengl_es(self):
264-
self.assertScriptOutputMatchesImage(self.EXAMPLES / 'canvas3d.fl', opengl_es=True, suffix='.es.png')
265-
266-
@unittest.skipIf(sys.platform != 'linux', 'OpenGL ES only available on Linux')
267-
def test_linelight_opengl_es(self):
268-
self.assertScriptOutputMatchesImage(self.EXAMPLES / 'linelight.fl', opengl_es=True, suffix='.es.png')
269-
270-
@unittest.skipIf(sys.platform != 'linux', 'OpenGL ES only available on Linux')
271-
def test_oklch_opengl_es(self):
272-
self.assertScriptOutputMatchesImage(self.EXAMPLES / 'oklch.fl', opengl_es=True, suffix='.es.png')
273-
274-
@unittest.skipIf(sys.platform != 'linux', 'OpenGL ES only available on Linux')
275-
def test_physics_opengl_es(self):
276-
self.assertScriptOutputMatchesImage(self.EXAMPLES / 'physics.fl', target_fps=10, opengl_es=True, suffix='.es.png')
277-
278-
@unittest.skipIf(sys.platform != 'linux', 'OpenGL ES only available on Linux')
279-
def test_sdf_opengl_es(self):
280-
self.assertScriptOutputMatchesImage(self.EXAMPLES / 'sdf.fl', opengl_es=True, suffix='.es.png')
281-
282-
@unittest.skipIf(sys.platform != 'linux', 'OpenGL ES only available on Linux')
283-
def test_solidgeometry_opengl_es(self):
284-
self.assertScriptOutputMatchesImage(self.EXAMPLES / 'solidgeometry.fl', opengl_es=True, suffix='.es.png')
285-
286-
@unittest.skipIf(sys.platform != 'linux', 'OpenGL ES only available on Linux')
287-
def test_teaset_opengl_es(self):
288-
self.assertScriptOutputMatchesImage(self.EXAMPLES / 'teaset.fl', opengl_es=True, suffix='.es.png')
289-
290-
@unittest.skipIf(sys.platform != 'linux', 'OpenGL ES only available on Linux')
291-
def test_textures_opengl_es(self):
292-
self.assertScriptOutputMatchesImage(self.EXAMPLES / 'textures.fl', target_fps=2, opengl_es=True, suffix='.es.png')
293-
294-
@unittest.skipIf(sys.platform != 'linux', 'OpenGL ES only available on Linux')
295-
def test_translucency_opengl_es(self):
296-
self.assertScriptOutputMatchesImage(self.EXAMPLES / 'translucency.fl', opengl_es=True, suffix='.es.png')
255+
@unittest.skipIf(sys.platform != 'linux', 'OpenGL ES only available on Linux')
256+
class TestExamplesOpenGLES(TestExamples):
257+
def assertScriptOutputMatchesImage(self, script, suffix='.es.png', target_fps=1, run_time=1, **kwargs):
258+
super().assertScriptOutputMatchesImage(script, suffix, target_fps, run_time, opengl_es=True, **kwargs)

0 commit comments

Comments
 (0)