Add option to disable GPU acceleration

This commit is contained in:
David Capello 2015-10-05 21:18:42 -03:00
parent 7434dd053a
commit 03c0367827
8 changed files with 47 additions and 4 deletions

View File

@ -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" />

View File

@ -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&#10;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&#10;if the program finalizes unexpectedly." />

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -14,6 +14,7 @@ namespace she {
MultipleDisplays = 1,
CanResizeDisplay = 2,
DisplayScale = 4,
GpuAccelerationSwitch = 8,
};
} // namespace she

View File

@ -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() {

View File

@ -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

View File

@ -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;