[aseprite] 132/250: Add option to disable GPU acceleration
Tobias Hansen
thansen at moszumanska.debian.org
Sun Dec 20 15:27:21 UTC 2015
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 03c03678270c6056451a5be299e92360ecf2f28f
Author: David Capello <davidcapello at gmail.com>
Date: Mon Oct 5 21:18:42 2015 -0300
Add option to disable GPU acceleration
---
data/pref.xml | 1 +
data/widgets/options.xml | 1 +
src/app/commands/cmd_options.cpp | 15 +++++++++++++++
src/she/alleg4/she.cpp | 8 ++++++++
src/she/capabilities.h | 1 +
src/she/skia/skia_system.h | 15 +++++++++++++--
src/she/skia/skia_window_win.cpp | 8 ++++++--
src/she/system.h | 2 ++
8 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/data/pref.xml b/data/pref.xml
index 2c76f9d..83c9230 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -69,6 +69,7 @@
<global>
<section id="general">
<option id="screen_scale" type="int" default="2" />
+ <option id="gpu_acceleration" type="bool" default="true" />
<option id="visible_timeline" type="bool" default="false" />
<option id="autoshow_timeline" type="bool" default="true" migrate="Options.AutoShowTimeline" />
<option id="rewind_on_stop" type="bool" default="false" />
diff --git a/data/widgets/options.xml b/data/widgets/options.xml
index fe91dad..c962cbe 100644
--- a/data/widgets/options.xml
+++ b/data/widgets/options.xml
@@ -37,6 +37,7 @@
</combobox>
</grid>
</hbox>
+ <check text="GPU acceleration" id="gpu_acceleration" tooltip="Check this option to enable hardware acceleration" />
<check text="Expand menu bar items on mouseover" id="expand_menubar_on_mouseover" tooltip="Check this option to get
this old menus behavior." />
<hbox>
<check text="Automatically save recovery data every" id="enable_data_recovery" tooltip="With this option you can recover your documents
if the program finalizes unexpectedly." />
diff --git a/src/app/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp
index b13be39..93ba117 100644
--- a/src/app/commands/cmd_options.cpp
+++ b/src/app/commands/cmd_options.cpp
@@ -116,6 +116,14 @@ public:
uiScale()->findItemIndexByValue(
base::convert_to<std::string>(m_preferences.experimental.uiScale())));
+ if ((int(she::instance()->capabilities()) &
+ int(she::Capabilities::GpuAccelerationSwitch)) == int(she::Capabilities::GpuAccelerationSwitch)) {
+ gpuAcceleration()->setSelected(m_preferences.general.gpuAcceleration());
+ }
+ else {
+ gpuAcceleration()->setVisible(false);
+ }
+
// Right-click
rightClickBehavior()->addItem("Paint with background color");
rightClickBehavior()->addItem("Pick foreground color");
@@ -230,6 +238,12 @@ public:
warnings += "<<- UI Elements Scale";
}
+ bool newGpuAccel = gpuAcceleration()->isSelected();
+ if (newGpuAccel != m_preferences.general.gpuAcceleration()) {
+ m_preferences.general.gpuAcceleration(newGpuAccel);
+ reset_screen = true;
+ }
+
m_preferences.save();
if (!warnings.empty()) {
@@ -242,6 +256,7 @@ public:
ui::Manager* manager = ui::Manager::getDefault();
she::Display* display = manager->getDisplay();
display->setScale(newScreenScale);
+ she::instance()->setGpuAcceleration(newGpuAccel);
manager->setDisplay(display);
}
}
diff --git a/src/she/alleg4/she.cpp b/src/she/alleg4/she.cpp
index 5a0506d..2313b42 100644
--- a/src/she/alleg4/she.cpp
+++ b/src/she/alleg4/she.cpp
@@ -155,6 +155,14 @@ public:
return EventQueue::instance();
}
+ bool gpuAcceleration() const override {
+ return true;
+ }
+
+ void setGpuAcceleration(bool state) override {
+ // Do nothing
+ }
+
Display* defaultDisplay() override {
return unique_display;
}
diff --git a/src/she/capabilities.h b/src/she/capabilities.h
index cb66ef8..98fb382 100644
--- a/src/she/capabilities.h
+++ b/src/she/capabilities.h
@@ -14,6 +14,7 @@ namespace she {
MultipleDisplays = 1,
CanResizeDisplay = 2,
DisplayScale = 4,
+ GpuAccelerationSwitch = 8,
};
} // namespace she
diff --git a/src/she/skia/skia_system.h b/src/she/skia/skia_system.h
index 71b9e9e..bbf576f 100644
--- a/src/she/skia/skia_system.h
+++ b/src/she/skia/skia_system.h
@@ -33,7 +33,8 @@ EventQueueImpl g_queue;
class SkiaSystem : public CommonSystem {
public:
SkiaSystem()
- : m_defaultDisplay(nullptr) {
+ : m_defaultDisplay(nullptr)
+ , m_gpuAcceleration(false) {
}
~SkiaSystem() {
@@ -50,13 +51,22 @@ public:
return Capabilities(
int(Capabilities::MultipleDisplays) |
int(Capabilities::CanResizeDisplay) |
- int(Capabilities::DisplayScale));
+ int(Capabilities::DisplayScale) |
+ int(Capabilities::GpuAccelerationSwitch));
}
EventQueue* eventQueue() override {
return &g_queue;
}
+ bool gpuAcceleration() const override {
+ return m_gpuAcceleration;
+ }
+
+ void setGpuAcceleration(bool state) override {
+ m_gpuAcceleration = state;
+ }
+
Display* defaultDisplay() override {
return m_defaultDisplay;
}
@@ -109,6 +119,7 @@ public:
private:
SkiaDisplay* m_defaultDisplay;
+ bool m_gpuAcceleration;
};
EventQueue* EventQueue::instance() {
diff --git a/src/she/skia/skia_window_win.cpp b/src/she/skia/skia_window_win.cpp
index 1e426c2..6894482 100644
--- a/src/she/skia/skia_window_win.cpp
+++ b/src/she/skia/skia_window_win.cpp
@@ -12,6 +12,7 @@
#include "she/event_queue.h"
#include "she/skia/skia_display.h"
+#include "she/system.h"
#if SK_SUPPORT_GPU
@@ -229,14 +230,17 @@ void SkiaWindow::createRenderTarget(const gfx::Size& size)
void SkiaWindow::resizeImpl(const gfx::Size& size)
{
+ bool gpu = instance()->gpuAcceleration();
+ (void)gpu;
+
#if SK_SUPPORT_GPU
#if SK_ANGLE
- if (attachANGLE()) {
+ if (gpu && attachANGLE()) {
m_backend = Backend::ANGLE;
}
else
#endif // SK_ANGLE
- if (attachGL()) {
+ if (gpu && attachGL()) {
m_backend = Backend::GL;
}
else
diff --git a/src/she/system.h b/src/she/system.h
index 0de3e1b..f73f949 100644
--- a/src/she/system.h
+++ b/src/she/system.h
@@ -36,6 +36,8 @@ namespace she {
virtual Logger* logger() = 0;
virtual NativeDialogs* nativeDialogs() = 0;
virtual EventQueue* eventQueue() = 0;
+ virtual bool gpuAcceleration() const = 0;
+ virtual void setGpuAcceleration(bool state) = 0;
virtual Display* defaultDisplay() = 0;
virtual Display* createDisplay(int width, int height, int scale) = 0;
virtual Surface* createSurface(int width, int height) = 0;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list