Update to new laf API (os::System::instance()/make())

This commit is contained in:
David Capello 2024-03-05 18:50:24 -03:00
parent 66313e540f
commit 571b4ec9f2
48 changed files with 165 additions and 146 deletions

2
laf

@ -1 +1 @@
Subproject commit a2bc68cd98d881c00fd7a376161b85e36c02bc76
Subproject commit 3bea53125ccafce878d17fcf8d9d192ad69fafb4

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -263,7 +263,7 @@ App::App(AppMod* mod)
int App::initialize(const AppOptions& options)
{
os::System* system = os::instance();
const os::SystemRef system = os::System::instance();
#ifdef ENABLE_UI
m_isGui = options.startUI() && !options.previewCLI();
@ -485,14 +485,15 @@ void App::run()
#if LAF_LINUX
// Setup app icon for Linux window managers
try {
os::Window* window = os::instance()->defaultWindow();
os::Window* window = os::System::instance()->defaultWindow();
os::SurfaceList icons;
for (const int size : { 32, 64, 128 }) {
ResourceFinder rf;
rf.includeDataDir(fmt::format("icons/ase{0}.png", size).c_str());
if (rf.findFirst()) {
os::SurfaceRef surf = os::instance()->loadRgbaSurface(rf.filename().c_str());
os::SurfaceRef surf = os::System::instance()
->loadRgbaSurface(rf.filename().c_str());
if (surf) {
surf->setImmutable();
icons.push_back(surf);
@ -512,14 +513,14 @@ void App::run()
#ifdef ENABLE_STEAM
steam::SteamAPI steam;
if (steam.initialized())
os::instance()->activateApp();
os::System::instance()->activateApp();
#endif
#if defined(_DEBUG) || defined(ENABLE_DEVMODE)
// On OS X, when we compile Aseprite on devmode, we're using it
// outside an app bundle, so we must active the app explicitly.
if (isGui())
os::instance()->activateApp();
os::System::instance()->activateApp();
#endif
#ifdef ENABLE_UPDATER
@ -804,7 +805,7 @@ void App::updateDisplayTitleBar()
}
title += defaultTitle;
os::instance()->defaultWindow()->setTitle(title);
os::System::instance()->defaultWindow()->setTitle(title);
}
InputChain& App::inputChain()

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2023 Igara Studio S.A.
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -597,7 +597,7 @@ bool AppMenus::rebuildRecentList()
// Sync native menus
if (owner->native() &&
owner->native()->menuItem) {
auto menus = os::instance()->menus();
auto menus = os::System::instance()->menus();
os::MenuRef osMenu = (menus ? menus->makeMenu(): nullptr);
if (osMenu) {
createNativeSubmenus(osMenu.get(), menu);
@ -923,7 +923,7 @@ void AppMenus::updateMenusList()
void AppMenus::createNativeMenus()
{
os::Menus* menus = os::instance()->menus();
os::Menus* menus = os::System::instance()->menus();
if (!menus) // This platform doesn't support native menu items
return;
@ -1021,7 +1021,7 @@ void AppMenus::createNativeMenus()
void AppMenus::createNativeSubmenus(os::Menu* osMenu,
const ui::Menu* uiMenu)
{
os::Menus* menus = os::instance()->menus();
os::Menus* menus = os::System::instance()->menus();
for (const auto& child : uiMenu->children()) {
os::MenuItemInfo info;

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -661,7 +661,7 @@ bool CliProcessor::openFile(Context* ctx, CliOpenFile& cof)
auto fn = base::normalize_path(usedFn);
m_usedFiles.insert(fn);
os::instance()->markCliFileAsProcessed(fn);
os::System::instance()->markCliFileAsProcessed(fn);
}
Doc* doc = ctx->activeDocument();

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2021 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -76,7 +76,7 @@ void convert_color_profile(doc::Sprite* sprite,
ASSERT(sprite->colorSpace());
ASSERT(newCS);
os::System* system = os::instance();
const os::SystemRef system = os::System::instance();
auto srcOCS = system->makeColorSpace(sprite->colorSpace());
auto dstOCS = system->makeColorSpace(newCS);
ASSERT(srcOCS);
@ -131,7 +131,7 @@ void convert_color_profile(doc::Image* image,
ASSERT(oldCS);
ASSERT(newCS);
os::System* system = os::instance();
const os::SystemRef system = os::System::instance();
auto srcOCS = system->makeColorSpace(oldCS);
auto dstOCS = system->makeColorSpace(newCS);
ASSERT(srcOCS);
@ -166,7 +166,7 @@ void convert_color_profile(doc::Image* image,
ConvertColorProfile::ConvertColorProfile(doc::Sprite* sprite, const gfx::ColorSpaceRef& newCS)
: WithSprite(sprite)
{
os::System* system = os::instance();
const os::SystemRef system = os::System::instance();
ASSERT(sprite->colorSpace());
ASSERT(newCS);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -34,7 +34,7 @@ void initialize_color_spaces(Preferences& pref)
os::ColorSpaceRef get_screen_color_space()
{
return os::instance()->defaultWindow()->colorSpace();
return os::System::instance()->defaultWindow()->colorSpace();
}
os::ColorSpaceRef get_current_color_space()
@ -55,7 +55,7 @@ gfx::ColorSpaceRef get_working_rgb_space_from_preferences()
return gfx::ColorSpace::MakeSRGB();
std::vector<os::ColorSpaceRef> colorSpaces;
os::instance()->listColorSpaces(colorSpaces);
os::System::instance()->listColorSpaces(colorSpaces);
for (auto& cs : colorSpaces) {
if (cs->gfxColorSpace()->name() == name)
return cs->gfxColorSpace();
@ -73,7 +73,8 @@ ConvertCS::ConvertCS()
auto srcCS = get_current_color_space();
auto dstCS = get_screen_color_space();
if (srcCS && dstCS)
m_conversion = os::instance()->convertBetweenColorSpace(srcCS, dstCS);
m_conversion = os::System::instance()
->convertBetweenColorSpace(srcCS, dstCS);
}
}
@ -81,7 +82,8 @@ ConvertCS::ConvertCS(const os::ColorSpaceRef& srcCS,
const os::ColorSpaceRef& dstCS)
{
if (g_manage) {
m_conversion = os::instance()->convertBetweenColorSpace(srcCS, dstCS);
m_conversion = os::System::instance()
->convertBetweenColorSpace(srcCS, dstCS);
}
}
@ -110,7 +112,8 @@ ConvertCS convert_from_current_to_screen_color_space()
ConvertCS convert_from_custom_to_srgb(const os::ColorSpaceRef& from)
{
return ConvertCS(from,
os::instance()->makeColorSpace(gfx::ColorSpace::MakeSRGB()));
os::System::instance()
->makeColorSpace(gfx::ColorSpace::MakeSRGB()));
}
} // namespace app

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -184,8 +184,8 @@ protected:
// Render sprite and leave the result in 'm_render' variable
if (m_render == nullptr) {
m_render = os::instance()->makeRgbaSurface(m_sprite->width(),
m_sprite->height());
m_render = os::System::instance()->makeRgbaSurface(m_sprite->width(),
m_sprite->height());
#if LAF_SKIA
// The SimpleRenderer renders unpremultiplied surfaces when

View File

@ -256,7 +256,8 @@ class OptionsWindow : public app::gen::Options {
public:
OptionsWindow(Context* context, int& curSection)
: m_context(context)
: m_system(os::System::instance())
, m_context(context)
, m_pref(Preferences::instance())
, m_globPref(m_pref.document(nullptr))
, m_docPref(m_pref.document(context->activeDocument()))
@ -289,7 +290,7 @@ public:
resetColorManagement()->Click.connect([this]{ onResetColorManagement(); });
colorManagement()->Click.connect([this]{ onColorManagement(); });
{
os::instance()->listColorSpaces(m_colorSpaces);
m_system->listColorSpaces(m_colorSpaces);
for (auto& cs : m_colorSpaces) {
if (cs->gfxColorSpace()->type() != gfx::ColorSpace::None)
workingRgbCs()->addItem(new ColorSpaceItem(cs));
@ -400,8 +401,7 @@ public:
moveOnAddMode()->setSelected(true);
// If the platform supports native cursors...
if ((int(os::instance()->capabilities()) &
int(os::Capabilities::CustomMouseCursor)) != 0) {
if (m_system->hasCapability(os::Capabilities::CustomMouseCursor)) {
if (m_pref.cursor.useNativeCursor())
nativeCursor()->setSelected(true);
nativeCursor()->Click.connect([this]{ onNativeCursorChange(); });
@ -431,7 +431,7 @@ public:
#ifdef _WIN32 // Show Tablet section on Windows
{
os::TabletAPI tabletAPI = os::instance()->tabletAPI();
os::TabletAPI tabletAPI = m_system->tabletAPI();
if (tabletAPI == os::TabletAPI::Wintab) {
tabletApiWintabSystem()->setSelected(true);
@ -521,7 +521,7 @@ public:
#ifdef ENABLE_DEVMODE // TODO enable this on Release when Aseprite supports
// GPU-acceleration properly
if (os::instance()->hasCapability(os::Capabilities::GpuAccelerationSwitch)) {
if (m_system->hasCapability(os::Capabilities::GpuAccelerationSwitch)) {
gpuAcceleration()->setSelected(m_pref.general.gpuAcceleration());
}
else
@ -532,7 +532,7 @@ public:
// If the platform does support native menus, we show the option,
// in other case, the option doesn't make sense for this platform.
if (os::instance()->menus())
if (m_system->menus())
showMenuBar()->setSelected(m_pref.general.showMenuBar());
else
showMenuBar()->setVisible(false);
@ -855,7 +855,7 @@ public:
->setInterpretOneFingerGestureAsMouseMovement(
oneFingerAsMouseMovement()->isSelected());
os::instance()->setTabletAPI(tabletAPI);
os::System::instance()->setTabletAPI(tabletAPI);
}
#endif
@ -883,7 +883,7 @@ public:
reset_screen = true;
}
if (os::instance()->menus() &&
if (m_system->menus() &&
m_pref.general.showMenuBar() != showMenuBar()->isSelected()) {
m_pref.general.showMenuBar(showMenuBar()->isSelected());
}
@ -1013,7 +1013,7 @@ private:
void updateScreenScaling() {
ui::Manager* manager = ui::Manager::getDefault();
os::instance()->setGpuAcceleration(m_pref.general.gpuAcceleration());
m_system->setGpuAcceleration(m_pref.general.gpuAcceleration());
manager->updateAllDisplaysWithNewScale(m_pref.general.screenScale());
}
@ -1027,8 +1027,7 @@ private:
void onNativeCursorChange() {
bool state =
// If the platform supports custom cursors...
(((int(os::instance()->capabilities()) &
int(os::Capabilities::CustomMouseCursor)) != 0) &&
((m_system->hasCapability(os::Capabilities::CustomMouseCursor)) &&
// If the native cursor option is not selec
!nativeCursor()->isSelected());
@ -1789,6 +1788,7 @@ private:
#endif // _WIN32
os::SystemRef m_system;
Context* m_context;
Preferences& m_pref;
DocumentPreferences& m_globPref;

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -244,8 +244,9 @@ void SpritePropertiesCommand::onExecute(Context* context)
ColorButton* color_button = nullptr;
// List of available color profiles
const os::SystemRef system = os::System::instance();
std::vector<os::ColorSpaceRef> colorSpaces;
os::instance()->listColorSpaces(colorSpaces);
system->listColorSpaces(colorSpaces);
// Load the window widget
SpritePropertiesWindow window(context->activeDocument()->sprite());
@ -335,7 +336,7 @@ void SpritePropertiesCommand::onExecute(Context* context)
++i;
}
if (selectedColorProfile < 0) {
colorSpaces.push_back(os::instance()->makeColorSpace(sprite->colorSpace()));
colorSpaces.push_back(system->makeColorSpace(sprite->colorSpace()));
selectedColorProfile = colorSpaces.size()-1;
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -671,8 +671,7 @@ void Doc::removeFromContext()
void Doc::updateOSColorSpace(bool appWideSignal)
{
auto system = os::instance();
if (system) {
if (const os::SystemRef system = os::System::instance()) {
m_osColorSpace = system->makeColorSpace(sprite()->colorSpace());
if (!m_osColorSpace && system->defaultWindow())
m_osColorSpace = system->defaultWindow()->colorSpace();

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2022 Igara Studio S.A.
// Copyright (C) 2022-2024 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -134,7 +134,7 @@ BENCHMARK(BM_ZoomEditor)
int app_main(int argc, char* argv[])
{
os::SystemRef system(os::make_system());
os::SystemRef system = os::System::make();
App app;
const char* argv2[] = { argv[0] };
app.initialize(AppOptions(1, { argv2 }));

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2020-2023 Igara Studio S.A.
// Copyright (C) 2020-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -28,13 +28,14 @@ bool show_file_selector(
FileSelectorType type,
base::paths& output)
{
const os::SystemRef system = os::System::instance();
const std::string defExtension =
Preferences::instance().saveFile.defaultExtension();
if (Preferences::instance().experimental.useNativeFileDialog() &&
os::instance()->nativeDialogs()) {
system->nativeDialogs()) {
os::FileDialogRef dlg =
os::instance()->nativeDialogs()->makeFileDialog();
system->nativeDialogs()->makeFileDialog();
if (dlg) {
dlg->setTitle(title);
@ -71,7 +72,7 @@ bool show_file_selector(
for (const auto& ext : extensions)
dlg->addFilter(ext, ext + " files (*." + ext + ")");
auto res = dlg->show(os::instance()->defaultWindow());
auto res = dlg->show(system->defaultWindow());
if (res != os::FileDialog::Result::Error) {
if (res == os::FileDialog::Result::OK) {
if (type == FileSelectorType::OpenMultiple)

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -464,7 +464,8 @@ const FileItemList& FileItem::children()
// Get the interface to enumerate subitems
hr = pFolder->EnumObjects(
reinterpret_cast<HWND>(os::instance()->defaultWindow()->nativeHandle()),
reinterpret_cast<HWND>(os::System::instance()
->defaultWindow()->nativeHandle()),
SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &pEnum);
if (hr == S_OK && pEnum) {

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This program is distributed under the terms of
@ -73,7 +73,7 @@ ConfigModule::ConfigModule()
std::string err = "Error in configuration migration: ";
err += ex.what();
auto system = os::instance();
const os::SystemRef system = os::System::instance();
if (system && system->logger())
system->logger()->logError(err.c_str());
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -228,7 +228,8 @@ void draw_tile(ui::Graphics* g,
int w = tileImage->width();
int h = tileImage->height();
os::SurfaceRef surface = os::instance()->makeRgbaSurface(w, h);
os::SurfaceRef surface = os::System::instance()->makeRgbaSurface(w, h);
convert_image_to_surface(tileImage.get(), get_current_palette(),
surface.get(), 0, 0, 0, 0, w, h);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -127,13 +127,14 @@ static bool create_main_window(bool gpuAccel,
// executed.
int scale = Preferences::instance().general.screenScale();
os::instance()->setGpuAcceleration(gpuAccel);
const os::SystemRef system = os::System::instance();
system->setGpuAcceleration(gpuAccel);
try {
if (!spec.frame().isEmpty() ||
!spec.contentRect().isEmpty()) {
spec.scale(scale == 0 ? 2: std::clamp(scale, 1, 4));
main_window = os::instance()->makeWindow(spec);
main_window = system->makeWindow(spec);
}
}
catch (const os::WindowCreationException& e) {
@ -149,7 +150,7 @@ static bool create_main_window(bool gpuAccel,
spec.contentRect(gfx::Rect(0, 0,
try_resolutions[c].width * spec.scale(),
try_resolutions[c].height * spec.scale()));
main_window = os::instance()->makeWindow(spec);
main_window = system->makeWindow(spec);
break;
}
catch (const os::WindowCreationException& e) {
@ -174,6 +175,7 @@ static bool create_main_window(bool gpuAccel,
// Initializes GUI.
int init_module_gui()
{
const os::SystemRef system = os::System::instance();
auto& pref = Preferences::instance();
bool maximized = false;
std::string lastError = "Unknown error";
@ -183,7 +185,7 @@ int init_module_gui()
// If we've created the native window with hardware acceleration,
// now we try to do it without hardware acceleration.
if (gpuAccel &&
os::instance()->hasCapability(os::Capabilities::GpuAccelerationSwitch)) {
system->hasCapability(os::Capabilities::GpuAccelerationSwitch)) {
if (create_main_window(false, maximized, lastError)) {
// Disable hardware acceleration
pref.general.gpuAcceleration(false);
@ -209,7 +211,7 @@ int init_module_gui()
// Handle live resize too redraw the entire manager, dispatch the UI
// messages, and flip the window.
os::instance()->handleWindowResize =
system->handleWindowResize =
[](os::Window* window) {
Display* display = Manager::getDisplayFromNativeWindow(window);
if (!display)
@ -250,7 +252,7 @@ void exit_module_gui()
void update_windows_color_profile_from_preferences()
{
auto system = os::instance();
const os::SystemRef system = os::System::instance();
gen::WindowColorProfile windowProfile;
if (Preferences::instance().color.manage())
@ -303,7 +305,8 @@ void update_windows_color_profile_from_preferences()
static bool load_gui_config(os::WindowSpec& spec, bool& maximized)
{
os::ScreenRef screen = os::instance()->mainScreen();
const os::SystemRef system = os::System::instance();
os::ScreenRef screen = system->mainScreen();
#ifdef LAF_SKIA
ASSERT(screen);
#else
@ -333,7 +336,7 @@ static bool load_gui_config(os::WindowSpec& spec, bool& maximized)
// 2nd monitor that then unplugged and start Aseprite again.
bool ok = false;
os::ScreenList screens;
os::instance()->listScreens(screens);
os::System::instance()->listScreens(screens);
for (const auto& screen : screens) {
gfx::Rect wa = screen->workarea();
gfx::Rect intersection = (frame & wa);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -95,10 +95,10 @@ Preferences::Preferences()
// Hide the menu bar depending on:
// 1. this is the first run of the program
// 2. the native menu bar is available
if (firstTime &&
os::instance() &&
os::instance()->menus()) {
general.showMenuBar(false);
if (firstTime) {
const os::SystemRef system = os::System::instance();
if (system && system->menus())
general.showMenuBar(false);
}
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (c) 2022-2023 Igara Studio S.A.
// Copyright (c) 2022-2024 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -183,7 +183,9 @@ bool Canvas::onProcessMessage(ui::Message* msg)
void Canvas::onResize(ui::ResizeEvent& ev)
{
Widget::onResize(ev);
if (os::instance() && !ev.bounds().isEmpty()) {
const os::SystemRef system = os::System::instance();
if (system && !ev.bounds().isEmpty()) {
int w = ev.bounds().w;
int h = ev.bounds().h;
@ -195,7 +197,7 @@ void Canvas::onResize(ui::ResizeEvent& ev)
if (!m_surface ||
m_surface->width() != w ||
m_surface->height() != h) {
m_surface = os::instance()->makeSurface(w, h);
m_surface = system->makeSurface(w, h);
callPaint();
}
}

View File

@ -70,7 +70,7 @@ void GraphicsContext::drawImage(const doc::Image* img,
if (!tmpSurface ||
tmpSurface->width() < srcRc.w ||
tmpSurface->height() < srcRc.h) {
tmpSurface = os::instance()->makeRgbaSurface(
tmpSurface = os::System::instance()->makeRgbaSurface(
std::max(srcRc.w, (tmpSurface ? tmpSurface->width(): 0)),
std::max(srcRc.h, (tmpSurface ? tmpSurface->height(): 0)));
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2023 Igara Studio S.A.
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -158,7 +158,7 @@ private:
// Set the thumbnail of the file-item.
if (thumbnailImage) {
os::SurfaceRef thumbnail =
os::instance()->makeRgbaSurface(
os::System::instance()->makeRgbaSurface(
thumbnailImage->width(),
thumbnailImage->height());

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2018 David Capello
// Copyright (C) 2016 Carlo Caputo
//
@ -58,7 +58,7 @@ os::SurfaceRef get_cel_thumbnail(const doc::Cel* cel,
gfx::Clip(gfx::Rect(gfx::Point(0, 0), newSize)),
255, doc::BlendMode::NORMAL);
if (os::SurfaceRef thumbnail = os::instance()->makeRgbaSurface(
if (os::SurfaceRef thumbnail = os::System::instance()->makeRgbaSurface(
thumbnailImage->width(),
thumbnailImage->height())) {
convert_image_to_surface(

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -478,7 +478,7 @@ os::SurfaceRef BrushPopup::createSurfaceForBrush(const BrushRef& origBrush,
image = brush->image();
}
os::SurfaceRef surface = os::instance()->makeRgbaSurface(
os::SurfaceRef surface = os::System::instance()->makeRgbaSurface(
std::min(kMaxSize, (image ? image->width(): 4)),
std::min(kMaxSize, (image ? image->height(): 4)));

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2020-2023 Igara Studio S.A.
// Copyright (C) 2020-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -187,7 +187,7 @@ bool ColorButton::onProcessMessage(Message* msg)
// Or get the color from the screen
if (gfxColor == gfx::ColorNone) {
gfxColor = os::instance()->getColorFromScreen(screenPos);
gfxColor = os::System::instance()->getColorFromScreen(screenPos);
}
color = app::Color::fromRgb(gfx::getr(gfxColor),

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2016-2018 David Capello
//
// This program is distributed under the terms of
@ -121,7 +121,7 @@ public:
stopCurrentPainting(lock);
os::SurfaceRef oldCanvas = m_canvas;
m_canvas = os::instance()->makeSurface(w, h, activeCS);
m_canvas = os::System::instance()->makeSurface(w, h, activeCS);
os::Paint paint;
paint.color(bgColor);
paint.style(os::Paint::Fill);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2023 Igara Studio S.A.
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2017 David Capello
//
// This program is distributed under the terms of
@ -112,7 +112,7 @@ private:
m_dithering, nullptr, palette, true, -1, nullptr);
}
m_preview = os::instance()->makeRgbaSurface(w, h);
m_preview = os::System::instance()->makeRgbaSurface(w, h);
convert_image_to_surface(image2.get(), palette, m_preview.get(),
0, 0, 0, 0, w, h);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -143,7 +143,7 @@ private:
gfx::Size sz = getFloatingOverlaySize();
sz.w = std::max(1, sz.w);
sz.h = std::max(1, sz.h);
os::SurfaceRef surface = os::instance()->makeRgbaSurface(sz.w, sz.h);
os::SurfaceRef surface = os::System::instance()->makeRgbaSurface(sz.w, sz.h);
{
os::SurfaceLock lock(surface.get());

View File

@ -673,8 +673,8 @@ void BrushPreview::createCrosshairCursor(ui::Graphics* g,
const gfx::Color black = gfx::rgba(0, 0, 0);
const gfx::Color white = gfx::rgba(255, 255, 255);
os::SurfaceRef cursorSurface =
os::instance()->makeRgbaSurface(cursorBounds.w,
cursorBounds.h);
os::System::instance()->makeRgbaSurface(cursorBounds.w,
cursorBounds.h);
cursorSurface->clear();
int bit = 0;
if (m_type & CROSSHAIR) {
@ -704,7 +704,7 @@ void BrushPreview::createCrosshairCursor(ui::Graphics* g,
}
cursor = g_bwCursors[k] =
os::instance()->makeCursor(
os::System::instance()->makeCursor(
cursorSurface.get(),
cursorCenter,
scale);
@ -733,8 +733,8 @@ void BrushPreview::createCrosshairCursor(ui::Graphics* g,
}
else {
os::SurfaceRef cursorSurface =
os::instance()->makeRgbaSurface(cursorBounds.w,
cursorBounds.h);
os::System::instance()->makeRgbaSurface(cursorBounds.w,
cursorBounds.h);
cursorSurface->clear();
if (m_type & CROSSHAIR) {
for (int v=0; v<7; v++)
@ -746,7 +746,7 @@ void BrushPreview::createCrosshairCursor(ui::Graphics* g,
cursorSurface->putPixel(cursorColor, cursorBounds.w/2, cursorBounds.h/2);
cursor = g_solidCursors[k] =
os::instance()->makeCursor(
os::System::instance()->makeCursor(
cursorSurface.get(),
cursorCenter,
scale);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -733,7 +733,7 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
rendered->colorSpace() != m_document->osColorSpace()) {
const int maxw = std::max(rc2.w, rendered ? rendered->width(): 0);
const int maxh = std::max(rc2.h, rendered ? rendered->height(): 0);
rendered = os::instance()->makeRgbaSurface(
rendered = os::System::instance()->makeRgbaSurface(
maxw, maxh, m_document->osColorSpace());
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -926,7 +926,7 @@ bool StandbyState::Decorator::onSetCursor(tools::Ink* ink, Editor* editor, const
ink->isSelection() &&
editor->document()->isMaskVisible() &&
(!Preferences::instance().selection.modifiersDisableHandles() ||
os::instance()->keyModifiers() == kKeyNoneModifier)) {
os::System::instance()->keyModifiers() == kKeyNoneModifier)) {
auto theme = skin::SkinTheme::get(editor);
const Transformation transformation(m_standbyState->getTransformation(editor));
TransformHandles* tr = getTransformHandles(editor);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2020-2022 Igara Studio S.A.
// Copyright (C) 2020-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -73,8 +73,9 @@ private:
if (m_image) {
Graphics* g = ev.graphics();
os::SurfaceRef sur = os::instance()->makeRgbaSurface(m_image->width(),
m_image->height());
os::SurfaceRef sur = os::System::instance()
->makeRgbaSurface(m_image->width(),
m_image->height());
convert_image_to_surface(
m_image.get(), nullptr, sur.get(),

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -587,7 +587,7 @@ void MainWindow::configureWorkspaceLayout()
bool normal = (m_mode == NormalMode);
bool isDoc = (getDocView() != nullptr);
if (os::instance()->menus() == nullptr ||
if (os::System::instance()->menus() == nullptr ||
pref.general.showMenuBar()) {
m_menuBar->resetMaxSize();
}

View File

@ -311,7 +311,7 @@ public:
if (tileImage) {
int w = tileImage->width();
int h = tileImage->height();
os::SurfaceRef surface = os::instance()->makeRgbaSurface(w, h);
os::SurfaceRef surface = os::System::instance()->makeRgbaSurface(w, h);
convert_image_to_surface(tileImage.get(), get_current_palette(),
surface.get(), 0, 0, 0, 0, w, h);

View File

@ -376,11 +376,13 @@ void SkinTheme::loadAll(const std::string& themeId,
void SkinTheme::loadSheet()
{
os::SystemRef system = os::System::instance();
// Load the skin sheet
std::string sheet_filename(base::join_path(m_path, "sheet.png"));
os::SurfaceRef newSheet;
try {
newSheet = os::instance()->loadRgbaSurface(sheet_filename.c_str());
newSheet = os::System::instance()->loadRgbaSurface(sheet_filename.c_str());
}
catch (...) {
// Ignore the error, newSheet is nullptr and we will throw our own
@ -393,7 +395,7 @@ void SkinTheme::loadSheet()
// avoid loading two times the same file (even more, if there
// is no scale to apply, m_unscaledSheet must reference the
// same m_sheet).
m_unscaledSheet = os::instance()->loadRgbaSurface(sheet_filename.c_str());
m_unscaledSheet = system->loadRgbaSurface(sheet_filename.c_str());
// Replace the sprite sheet
if (m_sheet)
@ -886,7 +888,7 @@ static os::SurfaceRef sliceSheet(os::SurfaceRef sheet, os::SurfaceRef sur, const
if (!bounds.isEmpty()) {
if (!sur)
sur = os::instance()->makeRgbaSurface(bounds.w, bounds.h);
sur = os::System::instance()->makeRgbaSurface(bounds.w, bounds.h);
os::SurfaceLock lockSrc(sheet.get());
os::SurfaceLock lockDst(sur.get());

View File

@ -970,8 +970,8 @@ void Tabs::createFloatingOverlay(Tab* tab)
ASSERT(!m_floatingOverlay);
ui::Display* display = this->display();
os::SurfaceRef surface = os::instance()->makeRgbaSurface(
tab->width, m_tabsHeight);
os::SurfaceRef surface = os::System::instance()
->makeRgbaSurface(tab->width, m_tabsHeight);
// Fill the surface with pink color
{

View File

@ -660,7 +660,7 @@ bool Timeline::onProcessMessage(Message* msg)
break;
if (mouseMsg->middle() ||
os::instance()->isKeyPressed(kKeySpace)) {
os::System::instance()->isKeyPressed(kKeySpace)) {
captureMouse();
m_state = STATE_SCROLLING;
m_oldPos = static_cast<MouseMessage*>(msg)->position();

View File

@ -53,7 +53,7 @@ namespace {
};
void* native_window_handle() {
return os::instance()->defaultWindow()->nativeHandle();
return os::System::instance()->defaultWindow()->nativeHandle();
}
void custom_error_handler(clip::ErrorCode code) {

View File

@ -511,7 +511,8 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
throw base::Exception("File %s not found", file);
try {
os::SurfaceRef sur = os::instance()->loadRgbaSurface(rf.filename().c_str());
os::SurfaceRef sur = os::System::instance()
->loadRgbaSurface(rf.filename().c_str());
if (sur) {
sur->setImmutable();
widget = new ImageView(sur, 0);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2023 Igara Studio S.A.
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This program is distributed under the terms of
@ -78,10 +78,10 @@ namespace {
bool m_done = false;
public:
WintabApiDelegate() {
os::instance()->setWintabDelegate(this);
os::System::instance()->setWintabDelegate(this);
}
~WintabApiDelegate() {
os::instance()->setWintabDelegate(nullptr);
os::System::instance()->setWintabDelegate(nullptr);
}
void onWintabID(const std::string& id) override {
if (!m_done) {
@ -125,7 +125,7 @@ int app_main(int argc, char* argv[])
MemLeak memleak;
base::SystemConsole systemConsole;
app::AppOptions options(argc, const_cast<const char**>(argv));
os::SystemRef system(os::make_system());
os::SystemRef system = os::System::make();
doc::Palette::initBestfit();
app::App app;

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2024 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
@ -37,7 +38,7 @@ int main(int argc, char* argv[])
#ifdef TEST_GUI
{
os::SystemRef system(os::make_system());
os::SystemRef system = os::System::make();
ui::UISystem uiSystem;
ui::Manager uiManager(nullptr);
#endif

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2020-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
@ -335,7 +335,7 @@ bool Accelerator::isPressed(KeyModifiers modifiers, KeyScancode scancode, int un
bool Accelerator::isPressed() const
{
os::System* sys = os::instance();
os::SystemRef sys = os::System::instance();
if (!sys)
return false;
@ -359,7 +359,7 @@ bool Accelerator::isPressed() const
bool Accelerator::isLooselyPressed() const
{
os::System* sys = os::instance();
os::SystemRef sys = os::System::instance();
if (!sys)
return false;

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2020-2021 Igara Studio S.A.
// Copyright (C) 2020-2024 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
@ -38,7 +38,7 @@ os::CursorRef Cursor::nativeCursor(const int scale) const
if (m_cursor && m_scale == scale)
return m_cursor;
m_cursor = os::instance()->makeCursor(
m_cursor = os::System::instance()->makeCursor(
m_surface.get(),
m_focus,
m_scale = scale);

View File

@ -264,7 +264,7 @@ bool Entry::onProcessMessage(Message* msg)
// Start processing dead keys
if (m_translate_dead_keys)
os::instance()->setTranslateDeadKeys(true);
os::System::instance()->setTranslateDeadKeys(true);
break;
case kFocusLeaveMessage:
@ -279,7 +279,7 @@ bool Entry::onProcessMessage(Message* msg)
// Stop processing dead keys
if (m_translate_dead_keys)
os::instance()->setTranslateDeadKeys(false);
os::System::instance()->setTranslateDeadKeys(false);
break;
case kKeyDownMessage:

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2019-2023 Igara Studio S.A.
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
@ -29,7 +29,7 @@ static gfx::Region get_workarea_region()
// Returns the union of the workarea of all available screens
gfx::Region wa;
os::ScreenList screens;
os::instance()->listScreens(screens);
os::System::instance()->listScreens(screens);
for (const auto& screen : screens)
wa |= gfx::Region(screen->workarea());
return wa;

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
@ -200,7 +200,7 @@ bool Manager::widgetAssociatedToManager(Widget* widget)
Manager::Manager(const os::WindowRef& nativeWindow)
: Widget(kManagerWidget)
, m_display(nullptr, nativeWindow, this)
, m_eventQueue(os::instance()->eventQueue())
, m_eventQueue(os::System::instance()->eventQueue())
, m_lockedWindow(nullptr)
, m_mouseButton(kButtonNone)
{
@ -1428,7 +1428,7 @@ void Manager::_openWindow(Window* window, bool center)
spec.parent(parentDisplay->nativeWindow());
}
os::WindowRef newNativeWindow = os::instance()->makeWindow(spec);
os::WindowRef newNativeWindow = os::System::instance()->makeWindow(spec);
ui::Display* newDisplay = new ui::Display(parentDisplay, newNativeWindow, window);
newNativeWindow->setUserData(newDisplay);

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2018-2021 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
@ -27,8 +27,9 @@ Message::Message(MessageType type, KeyModifiers modifiers)
, m_recipient(nullptr)
, m_commonAncestor(nullptr)
{
if (modifiers == kKeyUninitializedModifier && os::instance())
m_modifiers = os::instance()->keyModifiers();
const os::SystemRef system = os::System::instance();
if (modifiers == kKeyUninitializedModifier && system)
m_modifiers = system->keyModifiers();
else
m_modifiers = modifiers;
}

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
@ -93,9 +93,10 @@ void Overlay::captureOverlappedArea()
if (!m_overlap) {
// Use the same color space for the overlay as in the screen
m_overlap = os::instance()->makeSurface(m_surface->width(),
m_surface->height(),
displaySurface->colorSpace());
m_overlap = os::System::instance()
->makeSurface(m_surface->width(),
m_surface->height(),
displaySurface->colorSpace());
}
os::SurfaceLock lock(m_overlap.get());

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
@ -219,13 +219,13 @@ UISystem::UISystem()
ASSERT(!g_instance);
g_instance = this;
os::SystemRef system = os::System::instance();
main_gui_thread = std::this_thread::get_id();
mouse_cursor_type = kOutsideDisplay;
support_native_custom_cursor =
((os::instance() &&
(int(os::instance()->capabilities()) &
int(os::Capabilities::CustomMouseCursor))) ?
true: false);
(system &&
system->hasCapability(os::Capabilities::CustomMouseCursor));
details::initWidgets();
}
@ -354,7 +354,7 @@ void _internal_no_mouse_position()
gfx::Point get_mouse_position()
{
return os::instance()->mousePosition();
return os::System::instance()->mousePosition();
}
void set_mouse_position(const gfx::Point& newPos,
@ -366,7 +366,7 @@ void set_mouse_position(const gfx::Point& newPos,
if (display)
display->nativeWindow()->setMousePosition(newPos);
else
os::instance()->setMousePosition(newPos);
os::System::instance()->setMousePosition(newPos);
}
void execute_from_ui_thread(std::function<void()>&& func)

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2018-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
@ -1314,7 +1314,7 @@ GraphicsPtr Widget::getGraphics(const gfx::Rect& clip)
// buffer only if the default surface is the screen.
if (isDoubleBuffered() && dstSurface->isDirectToScreen()) {
os::SurfaceRef surface =
os::instance()->makeSurface(clip.w, clip.h);
os::System::instance()->makeSurface(clip.w, clip.h);
graphics.reset(new Graphics(display, surface, -clip.x, -clip.y),
DeleteGraphicsAndSurface(clip, surface,
dstSurface));