Commit 50e5773b authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'enh/platform' into 'master'

Enh/platform

See merge request fsl/fsleyes/widgets!62
parents 34128320 01f3d610
......@@ -12,10 +12,9 @@ Added
* New functions for querying the environment at runtime, including,
:func:`.wxVersion` (not to be confused with the deprecated
:func:`.wxversion`), :func:`.wxPlatform`, :func:`.wxFlavour`, :func:`.frozen`,
:func:`.canHaveGui`, :func:`.haveGui`, :func:`.inSSHSession`,
:func:`.inVNCSession`, :func:`.glVersion`, :func:`.glRenderer`, and
:func:`.glIsSoftwareRenderer`.
:func:`.wxversion`), :func:`.wxPlatform`, :func:`.wxFlavour`,
:func:`.frozen`, :func:`.canHaveGui`, :func:`.haveGui`,
:func:`.inSSHSession`, and :func:`.inVNCSession`.
Deprecated
......
......@@ -36,7 +36,4 @@ from fsleyes_widgets.utils import (WX_PYTHON, # noqa
haveGui,
inSSHSession,
inVNCSession,
glVersion,
glRenderer,
glIsSoftwareRenderer,
isalive)
......@@ -18,9 +18,6 @@ random things. A few functions are also defined at the package level:
haveGui
inSSHSession
inVNCSession
glVersion
glRenderer
glIsSoftwareRenderer
isalive
......@@ -222,56 +219,6 @@ def inVNCSession():
return any(v in os.environ for v in vncVars)
def glVersion():
"""Return the OpenGL version.
.. note:: The values of ``glVersion`` is not automatically set - it
will only contain a value if one is assigned to it. *FSLeyes*
does this during startup, in the :func:`fsleyes.gl.bootstrap`
function. A value can be assigend directly to an attribute on
the ``glVersion`` function called ``version``, e.g.;;
import fsl.utils.platform as plat
plat.glVersion.version = '2.1'
"""
return getattr(glVersion, 'version', None)
def glRenderer():
"""Return the OpenGL renderer description.
.. note:: The values of ``glRenderer`` is not automatically set - it
will only contain a value if one is assigned to it. *FSLeyes*
does this during startup, in the :func:`fsleyes.gl.bootstrap`
function. A value can be assigend directly to an attribute on
the ``glRenderer`` function called ``renderer``, e.g.;;
import fsl.utils.platform as plat
plat.glRenderer.renderer = 'Mesa DRI Intel(R) UHD ' \
'Graphics 620 (WHL GT2)'
"""
return getattr(glRenderer, 'renderer', None)
def glIsSoftwareRenderer():
"""Returns ``True`` if the OpenGL renderer appears to be software based,
``False`` otherwise, or ``None`` if the renderer has not yet been set.
.. note:: This check is based on heuristics, ans is not guaranteed to
be correct.
"""
renderer = glRenderer()
if renderer is None:
return None
# There doesn't seem to be any quantitative
# method for determining whether we are using
# software-based rendering, so a hack is
# necessary.
renderer = renderer.lower()
return any(('software' in renderer,
'chromium' in renderer))
def isalive(widget):
"""Returns ``True`` if the given ``wx.Window`` object is "alive" (i.e. has
not been destroyed), ``False`` otherwise. Works in both wxPython and
......
......@@ -149,27 +149,3 @@ def test_inVNCSession():
with mock.patch('os.environ', {}):
assert not fw.inVNCSession()
def test_glVersion():
assert fw.glVersion() is None
fw.glVersion.version = '2.1'
assert fw.glVersion() == '2.1'
fw.glVersion.version = None
def test_glRenderer():
assert fw.glRenderer() is None
fw.glRenderer.renderer = 'llvmpipe'
assert fw.glRenderer() == 'llvmpipe'
fw.glRenderer.renderer = None
def test_glIsSoftwareRenderer():
assert fw.glRenderer() is None
assert fw.glIsSoftwareRenderer() is None
fw.glRenderer.renderer = 'nvidia'
assert not fw.glIsSoftwareRenderer()
fw.glRenderer.renderer = 'software'
assert fw.glIsSoftwareRenderer()
fw.glRenderer.renderer = None
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment