Route default canvas resolution through platform services

This commit is contained in:
2026-06-04 19:20:06 +02:00
parent b2334e65c9
commit 0489c4229e
12 changed files with 57 additions and 10 deletions

View File

@@ -192,6 +192,7 @@ public:
[[nodiscard]] bool uses_ppbr_export_data_directory_override() const;
[[nodiscard]] bool platform_supports_sonarpen() const;
void start_platform_sonarpen();
[[nodiscard]] int default_canvas_resolution() const;
[[nodiscard]] bool draws_canvas_tip_for_input(kEventSource source, kEventType type) const;
[[nodiscard]] float adjust_canvas_input_pressure(float pressure) const;
void pick_dir(std::function<void(std::string path)> callback);

View File

@@ -40,7 +40,8 @@ void App::cmd_convert(std::string pano_path, std::string out_path)
glBlendEquation(add_blend_equation());
Canvas* command_canvas = new Canvas;
command_canvas->create(CANVAS_RES, CANVAS_RES);
const int canvas_resolution = default_canvas_resolution();
command_canvas->create(canvas_resolution, canvas_resolution);
command_canvas->project_open_thread(pano_path);
command_canvas->export_equirectangular_thread(out_path);
}

View File

@@ -211,6 +211,11 @@ void App::start_platform_sonarpen()
active_platform_services().start_sonarpen();
}
int App::default_canvas_resolution() const
{
return active_platform_services().default_canvas_resolution();
}
bool App::draws_canvas_tip_for_input(kEventSource source, kEventType type) const
{
return active_platform_services().draws_canvas_tip_for_pointer(

View File

@@ -10,12 +10,6 @@
#include <stack>
#include "mp4enc.h"
#if __WEB__
#define CANVAS_RES 512
#else
#define CANVAS_RES 1536
#endif
struct PPIThumb
{
int width = 128;

View File

@@ -153,7 +153,8 @@ void NodeCanvas::init()
m_mouse_ignore = false;
m_canvas = std::make_unique<Canvas>();
m_canvas->create(CANVAS_RES, CANVAS_RES);
const int canvas_resolution = App::I->default_canvas_resolution();
m_canvas->create(canvas_resolution, canvas_resolution);
m_canvas->m_unsaved = false;
m_canvas->m_node = this;
@@ -179,7 +180,8 @@ void NodeCanvas::init()
void NodeCanvas::restore_context()
{
Node::restore_context();
m_canvas->create(CANVAS_RES, CANVAS_RES);
const int canvas_resolution = App::I->default_canvas_resolution();
m_canvas->create(canvas_resolution, canvas_resolution);
m_sampler.create();

View File

@@ -73,6 +73,7 @@ public:
[[nodiscard]] virtual bool uses_ppbr_export_data_directory_override() = 0;
[[nodiscard]] virtual bool supports_sonarpen() = 0;
virtual void start_sonarpen() = 0;
[[nodiscard]] virtual int default_canvas_resolution() = 0;
[[nodiscard]] virtual bool draws_canvas_tip_for_pointer(
bool is_mouse,
bool is_stylus,

View File

@@ -510,6 +510,15 @@ public:
#endif
}
[[nodiscard]] int default_canvas_resolution() override
{
#if __WEB__
return 512;
#else
return 1536;
#endif
}
[[nodiscard]] bool draws_canvas_tip_for_pointer(
bool is_mouse,
bool is_stylus,

View File

@@ -508,6 +508,11 @@ public:
{
}
[[nodiscard]] int default_canvas_resolution() override
{
return 1536;
}
[[nodiscard]] bool draws_canvas_tip_for_pointer(
bool is_mouse,
bool is_stylus,