[aseprite] 139/250: Try to initialize the display with GPU acceleration and then without it
Tobias Hansen
thansen at moszumanska.debian.org
Sun Dec 20 15:27:22 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 165c7ccca49a518b17fea1c5eaf0e39ff3e65717
Author: David Capello <davidcapello at gmail.com>
Date: Tue Oct 6 17:04:03 2015 -0300
Try to initialize the display with GPU acceleration and then without it
---
src/app/modules/gui.cpp | 35 ++++++++++++++++++++++++++++++-----
1 file changed, 30 insertions(+), 5 deletions(-)
diff --git a/src/app/modules/gui.cpp b/src/app/modules/gui.cpp
index 05649d8..6fbddcc 100644
--- a/src/app/modules/gui.cpp
+++ b/src/app/modules/gui.cpp
@@ -100,15 +100,16 @@ static int get_screen_scale()
return scale;
}
-// Initializes GUI.
-int init_module_gui()
+static bool create_main_display(bool gpuAccel,
+ bool& maximized,
+ std::string& lastError)
{
- std::string lastError = "Unknown error";
int w, h;
- bool maximized;
int scale = get_screen_scale();
load_gui_config(w, h, maximized);
+ she::instance()->setGpuAcceleration(gpuAccel);
+
try {
if (w > 0 && h > 0)
main_display = she::instance()->createDisplay(w, h, scale);
@@ -135,8 +136,32 @@ int init_module_gui()
}
}
+ return (main_display != nullptr);
+}
+
+// Initializes GUI.
+int init_module_gui()
+{
+ bool maximized = false;
+ std::string lastError = "Unknown error";
+ bool gpuAccel = Preferences::instance().general.gpuAcceleration();
+
+ if (!create_main_display(gpuAccel, maximized, lastError)) {
+ // If we've created the display with hardware acceleration,
+ // now we try to do it without hardware acceleration.
+ if (gpuAccel &&
+ (int(she::instance()->capabilities()) &
+ int(she::Capabilities::GpuAccelerationSwitch)) == int(she::Capabilities::GpuAccelerationSwitch)) {
+ if (create_main_display(false, maximized, lastError)) {
+ // Disable hardware acceleration
+ Preferences::instance().general.gpuAcceleration(false);
+ }
+ }
+ }
+
if (!main_display) {
- she::error_message(("Unable to create a user-interface display.\nDetails: "+lastError+"\n").c_str());
+ she::error_message(
+ ("Unable to create a user-interface display.\nDetails: "+lastError+"\n").c_str());
return -1;
}
--
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