Browse Source

Platform: expand EmscriptenApp::GLConfiguration::Flag::PowerPreference*.

It's now possible to choose between low power, high performance and
default, while before it was only possible to switch between low power
and high performance. The old flag is an deprecated alias to the
low-power one.
pull/168/head
Vladimír Vondruš 3 years ago
parent
commit
e9c44739f2
  1. 9
      doc/changelog.dox
  2. 9
      src/Magnum/Platform/EmscriptenApplication.cpp
  3. 37
      src/Magnum/Platform/EmscriptenApplication.h

9
doc/changelog.dox

@ -285,6 +285,10 @@ See also:
@ref Platform::WindowlessGlxApplication,
@ref Platform::WindowlessWglApplication and
@ref Platform::Sdl2Application
- New @ref Platform::EmscriptenApplication::GLConfiguration::Flag::PowerPreferenceLowPower
and @relativeref{Platform::EmscriptenApplication::GLConfiguration,Flag::PowerPreferenceHighPerformance}
flags allowing to pick either a low power, high performance or default
behavior (see [mosra/magnum#500](https://github.com/mosra/magnum/issues/500)).
@subsubsection changelog-latest-new-scenegraph SceneGraph library
@ -1181,6 +1185,11 @@ See also:
@ref MeshTools::reference() and @ref MeshTools::mutableReference() were
moved there as well, with @cpp Magnum/MeshTools/Reference.h @ce being a
deprecated alias now.
- @cpp Platform::EmscriptenApplication::GLConfiguration::Flag::PreferLowPowerToHighPerformance @ce
is deprecated as it didn't allow explicitly choosing between high
performance and a default, use @relativeref{Platform::EmscriptenApplication::GLConfiguration,Flag::PowerPreferenceLowPower}
or @relativeref{Platform::EmscriptenApplication::GLConfiguration,Flag::PowerPreferenceHighPerformance}
instead
- @cpp Shaders::DistanceFieldVector @ce, @cpp Shaders::Flat @ce,
@cpp Shaders::Generic @ce, @cpp Shaders::MeshVisualizer2D @ce,
@cpp Shaders::MeshVisualizer3D @ce, @cpp Shaders::Phong @ce,

9
src/Magnum/Platform/EmscriptenApplication.cpp

@ -341,9 +341,12 @@ bool EmscriptenApplication::tryCreate(const Configuration& configuration, const
!!(glConfiguration.flags() & GLConfiguration::Flag::PremultipliedAlpha);
attrs.preserveDrawingBuffer =
!!(glConfiguration.flags() & GLConfiguration::Flag::PreserveDrawingBuffer);
attrs.powerPreference =
!!(glConfiguration.flags() & GLConfiguration::Flag::PreferLowPowerToHighPerformance)
? EM_WEBGL_POWER_PREFERENCE_LOW_POWER : EM_WEBGL_POWER_PREFERENCE_HIGH_PERFORMANCE;
if(glConfiguration.flags() & GLConfiguration::Flag::PowerPreferenceLowPower)
attrs.powerPreference = EM_WEBGL_POWER_PREFERENCE_LOW_POWER;
else if(glConfiguration.flags() & GLConfiguration::Flag::PowerPreferenceHighPerformance)
attrs.powerPreference = EM_WEBGL_POWER_PREFERENCE_HIGH_PERFORMANCE;
else
attrs.powerPreference = EM_WEBGL_POWER_PREFERENCE_DEFAULT;
attrs.explicitSwapControl =
!!(glConfiguration.flags() & GLConfiguration::Flag::ExplicitSwapControl);
attrs.failIfMajorPerformanceCaveat =

37
src/Magnum/Platform/EmscriptenApplication.h

@ -51,6 +51,7 @@
#endif
#ifdef MAGNUM_BUILD_DEPRECATED
#include <Corrade/Utility/Macros.h>
/* Some APIs used to take or return a std::string before */
#include <Corrade/Containers/StringStl.h>
#endif
@ -967,10 +968,30 @@ class EmscriptenApplication::GLConfiguration: public GL::Context::Configuration
PreserveDrawingBuffer = 1 << 1,
/**
* Prefer low power to high performance. If set, the WebGL power
* preference will be set to reduce power consumption.
* Low power preference. Only at most one of
* @ref Flag::PowerPreferenceLowPower and
* @ref Flag::PowerPreferenceHighPerformance should be set. If
* neither is set, a default is used.
* @m_since_latest
*/
PowerPreferenceLowPower = 1 << 2,
/**
* High performace power preference. Only at most one of
* @ref Flag::PowerPreferenceLowPower and
* @ref Flag::PowerPreferenceHighPerformance should be set. If
* neither is set, a default is used.
* @m_since_latest
*/
PreferLowPowerToHighPerformance = 1 << 2,
PowerPreferenceHighPerformance = 1 << 3,
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* Prefer low power to high performance
* @m_deprecated_since_latest Use @ref Flag::PowerPreferenceLowPower instead.
*/
PreferLowPowerToHighPerformance CORRADE_DEPRECATED_ENUM("use Flag::PowerPreferenceLowPower instead") = PowerPreferenceLowPower,
#endif
/**
* Fail if major performance caveat. If set, requests context
@ -978,32 +999,32 @@ class EmscriptenApplication::GLConfiguration: public GL::Context::Configuration
* context that does not give good hardware-accelerated
* performance.
*/
FailIfMajorPerformanceCaveat = 1 << 3,
FailIfMajorPerformanceCaveat = 1 << 4,
/**
* Explicit swap control. For more details, see the
* [Emscripten API reference](https://emscripten.org/docs/api_reference/html5.h.html#c.EmscriptenWebGLContextAttributes.explicitSwapControl).
*/
ExplicitSwapControl = 1 << 4,
ExplicitSwapControl = 1 << 5,
/**
* Enable WebGL extensions by default. Enabled by default. For more
* details, see @ref Platform-EmscriptenApplication-webgl and the
* [Emscripten API reference](https://emscripten.org/docs/api_reference/html5.h.html#c.EmscriptenWebGLContextAttributes.enableExtensionsByDefault).
*/
EnableExtensionsByDefault = 1 << 5,
EnableExtensionsByDefault = 1 << 6,
/**
* Render via offscreen back buffer. For more details, see the
* [Emscripten API reference](https://emscripten.org/docs/api_reference/html5.h.html#c.EmscriptenWebGLContextAttributes.renderViaOffscreenBackBuffer).
*/
RenderViaOffscreenBackBuffer = 1 << 6,
RenderViaOffscreenBackBuffer = 1 << 7,
/**
* Proxy content to main thread. For more details, see the
* [Emscripten API reference](https://emscripten.org/docs/api_reference/html5.h.html#c.EmscriptenWebGLContextAttributes.proxyContextToMainThread).
*/
ProxyContextToMainThread = 1 << 7,
ProxyContextToMainThread = 1 << 8,
/**
* @copydoc GL::Context::Configuration::Flag::QuietLog

Loading…
Cancel
Save