mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-16 10:20:50 +00:00
Don't access Preferences to do color conversion from bg threads
Continuation of 673e1955fa10e8ce643c80f64c439852b543f62a
This commit is contained in:
parent
c6fb34ef4a
commit
ed0f4c3023
@ -17,6 +17,7 @@
|
||||
#include "app/cli/cli_processor.h"
|
||||
#include "app/cli/default_cli_delegate.h"
|
||||
#include "app/cli/preview_cli_delegate.h"
|
||||
#include "app/color_spaces.h"
|
||||
#include "app/color_utils.h"
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/console.h"
|
||||
@ -59,11 +60,11 @@
|
||||
#include "base/split_string.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "fmt/format.h"
|
||||
#include "render/render.h"
|
||||
#include "os/display.h"
|
||||
#include "os/error.h"
|
||||
#include "os/surface.h"
|
||||
#include "os/system.h"
|
||||
#include "render/render.h"
|
||||
#include "ui/intern.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
@ -104,6 +105,9 @@ class App::CoreModules {
|
||||
public:
|
||||
ConfigModule m_configModule;
|
||||
Preferences m_preferences;
|
||||
CoreModules() {
|
||||
initialize_color_spaces();
|
||||
}
|
||||
};
|
||||
|
||||
class App::LoadLanguage {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2019 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -19,6 +19,20 @@
|
||||
|
||||
namespace app {
|
||||
|
||||
// We use this variable to avoid accessing Preferences::instance()
|
||||
// from background threads when a color conversion between color
|
||||
// spaces must be done.
|
||||
static bool g_manage = false;
|
||||
|
||||
void initialize_color_spaces()
|
||||
{
|
||||
g_manage = Preferences::instance().color.manage();
|
||||
Preferences::instance().color.manage.AfterChange.connect(
|
||||
[](bool manage){
|
||||
g_manage = manage;
|
||||
});
|
||||
}
|
||||
|
||||
os::ColorSpacePtr get_screen_color_space()
|
||||
{
|
||||
return os::instance()->defaultDisplay()->colorSpace();
|
||||
@ -56,7 +70,7 @@ gfx::ColorSpacePtr get_working_rgb_space_from_preferences()
|
||||
|
||||
ConvertCS::ConvertCS()
|
||||
{
|
||||
if (Preferences::instance().color.manage()) {
|
||||
if (g_manage) {
|
||||
auto srcCS = get_current_color_space();
|
||||
auto dstCS = get_screen_color_space();
|
||||
if (srcCS && dstCS)
|
||||
@ -67,7 +81,7 @@ ConvertCS::ConvertCS()
|
||||
ConvertCS::ConvertCS(const os::ColorSpacePtr& srcCS,
|
||||
const os::ColorSpacePtr& dstCS)
|
||||
{
|
||||
if (Preferences::instance().color.manage()) {
|
||||
if (g_manage) {
|
||||
m_conversion = os::instance()->convertBetweenColorSpace(srcCS, dstCS);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2019 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -20,6 +20,8 @@ namespace doc {
|
||||
|
||||
namespace app {
|
||||
|
||||
void initialize_color_spaces();
|
||||
|
||||
os::ColorSpacePtr get_screen_color_space();
|
||||
|
||||
// Returns the color space of the current document.
|
||||
|
@ -362,7 +362,8 @@ void execute_from_ui_thread(std::function<void()>&& f)
|
||||
|
||||
bool is_ui_thread()
|
||||
{
|
||||
return (main_gui_thread == base::this_thread::native_handle());
|
||||
return (!main_gui_thread ||
|
||||
main_gui_thread == base::this_thread::native_handle());
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
Loading…
x
Reference in New Issue
Block a user