diff --git a/CMakeLists.txt b/CMakeLists.txt index dc8f61db..bebee5ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -584,6 +584,7 @@ if(PP_BUILD_APP) target_link_libraries(pp_panopainter_ui PUBLIC pp_legacy_app + pp_ui_core pp_project_options PRIVATE pp_assets diff --git a/src/app.cpp b/src/app.cpp index d7c96ec9..51042f8c 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -658,7 +658,7 @@ void App::render_thread_tick() void App::render_thread_main() { - runtime_.render_thread_main(*this); + runtime_.render_thread_main(*this, {}); } void App::ui_thread_tick() @@ -668,7 +668,7 @@ void App::ui_thread_tick() void App::ui_thread_main() { - runtime_.ui_thread_main(*this); + runtime_.ui_thread_main(*this, {}); } void App::render_thread_start() diff --git a/src/canvas.cpp b/src/canvas.cpp index 52df7180..4096a787 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -877,8 +877,7 @@ static void execute_canvas_draw_merge_plane_dispatch( brush, ortho, use_blend, - copy_blend_destination, - draw_checkerboard); + copy_blend_destination); } execute_canvas_draw_merge_plane_final_composite(canvas, ortho, draw_checkerboard, use_blend); diff --git a/src/legacy_document_session_services.cpp b/src/legacy_document_session_services.cpp index d56370b2..09a269a7 100644 --- a/src/legacy_document_session_services.cpp +++ b/src/legacy_document_session_services.cpp @@ -231,7 +231,7 @@ private: std::shared_ptr dialog_; }; -void save_document_version(App& app, const pp::app::DocumentVersionTarget& target); +void save_legacy_document_version(App& app, const pp::app::DocumentVersionTarget& target); class LegacyDocumentVersionSaveServices final : public pp::app::DocumentVersionSaveServices { public: @@ -242,14 +242,14 @@ public: void save_document_version(const pp::app::DocumentVersionTarget& target) override { - save_document_version(app_, target); + save_legacy_document_version(app_, target); } private: App& app_; }; -void save_document_version(App& app, const pp::app::DocumentVersionTarget& target) +void save_legacy_document_version(App& app, const pp::app::DocumentVersionTarget& target) { const auto history_status = pp::panopainter::execute_legacy_history_plan( pp::app::plan_document_version_save_history(target)); diff --git a/src/legacy_recording_services.cpp b/src/legacy_recording_services.cpp index ae7ca39b..8c06e7ac 100644 --- a/src/legacy_recording_services.cpp +++ b/src/legacy_recording_services.cpp @@ -30,7 +30,7 @@ void encode_recording_frame( const pp::app::RecordingWorkerIterationPlan& plan, Canvas* legacy_canvas, Canvas* canvas_document, - CanvasEncoder* encoder) + MP4Encoder* encoder) { if (plan.clear_dirty_stroke) canvas_document->m_dirty_stroke = false; diff --git a/src/main.cpp b/src/main.cpp index 17ebc0ba..314821c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -92,6 +92,13 @@ void enqueue_main_task(Callable&& task) queue.tasklist.emplace_back(std::forward(task)); } +void enqueue_main_task_bridge(std::packaged_task task) +{ + auto& queue = retained_main_task_queue(); + std::lock_guard lock(queue.task_mutex); + queue.tasklist.emplace_back(std::move(task)); +} + void drain_main_tasks() { std::deque> working_list; @@ -110,6 +117,16 @@ void drain_main_tasks() } +HWND pp_windows_main_window_handle() +{ + return retained_state().hWnd; +} + +void pp_windows_enqueue_main_task(std::packaged_task task) +{ + enqueue_main_task_bridge(std::move(task)); +} + std::atomic vr_frames{0}; std::atomic running{-1}; std::atomic_bool vr_running{false}; @@ -1096,7 +1113,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) case WM_ACTIVATE: { pp::platform::windows::platform_services().set_cursor_visible(true); - App::I->ui_task_async([=] { + App::I->ui_task_async([&state, wp, lp] { int active = GET_WM_ACTIVATE_STATE(wp, lp); WacomTablet::I.set_focus(active); static BYTE keys[256]; diff --git a/src/node_canvas.cpp b/src/node_canvas.cpp index 7debf28b..a9af7b5d 100644 --- a/src/node_canvas.cpp +++ b/src/node_canvas.cpp @@ -726,7 +726,7 @@ void NodeCanvas::draw() proj, camera, m_canvas->m_layers.size() + 500.f, - m_canvas->m_plane_transform, + std::to_array(m_canvas->m_plane_transform), { .set_active_texture_unit = [&] { set_active_texture_unit(0); @@ -750,7 +750,7 @@ void NodeCanvas::draw() ortho_proj, proj, camera), - .draw_heightmap = pp::panopainter::make_legacy_canvas_draw_merge_heightmap_draw(App::I->grid, proj, camera), + .draw_heightmap = pp::panopainter::make_legacy_canvas_draw_merge_heightmap_draw(App::I->grid.get(), proj, camera), .draw_current_modes = pp::panopainter::make_legacy_canvas_draw_merge_current_modes_draw( m_canvas->m_mode, ortho_proj, diff --git a/src/node_dialog_cloud.cpp b/src/node_dialog_cloud.cpp index 769c07a9..a2c711bd 100644 --- a/src/node_dialog_cloud.cpp +++ b/src/node_dialog_cloud.cpp @@ -68,7 +68,9 @@ void NodeDialogCloud::init_controls() btn_cancel = find("btn-cancel"); pp::panopainter::bind_legacy_click_destroys_node(*btn_cancel, *this); container = find("files-list"); - load_thumbs_worker_ = std::jthread(&NodeDialogCloud::load_thumbs_thread, this); + load_thumbs_worker_ = std::jthread([this](std::stop_token stop) { + load_thumbs_thread(stop); + }); } void NodeDialogCloud::loaded() diff --git a/src/platform_windows/windows_platform_services.cpp b/src/platform_windows/windows_platform_services.cpp index c59bb863..5c44036c 100644 --- a/src/platform_windows/windows_platform_services.cpp +++ b/src/platform_windows/windows_platform_services.cpp @@ -11,10 +11,6 @@ #include #include -extern HWND hWnd; -extern std::deque> main_tasklist; -extern std::mutex main_task_mutex; - void destroy_window(); void async_lock(); void async_unlock(); @@ -27,6 +23,8 @@ void win32_save_window_state(); bool win32_vr_start(); void win32_vr_stop(); std::string GetLastErrorAsString(); +HWND pp_windows_main_window_handle(); +void pp_windows_enqueue_main_task(std::packaged_task task); namespace pp::platform::windows { @@ -166,19 +164,18 @@ void handle_gl_callback( void show_cursor(bool visible) { - std::lock_guard lock(main_task_mutex); - main_tasklist.emplace_back([=] { + pp_windows_enqueue_main_task(std::packaged_task([=] { if (visible) while (ShowCursor(true) < 0); else while (ShowCursor(false) >= 0); - }); + })); } std::string clipboard_text() { std::string ret; - if (OpenClipboard(hWnd)) + if (OpenClipboard(pp_windows_main_window_handle())) { if (HANDLE h = GetClipboardData(CF_TEXT)) { @@ -196,7 +193,7 @@ std::string clipboard_text() bool set_clipboard_text(const std::string& s) { bool success = false; - if (OpenClipboard(hWnd)) + if (OpenClipboard(pp_windows_main_window_handle())) { // owned by SetClipboardData if (HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, s.size() + 1)) @@ -222,7 +219,7 @@ std::string open_file(const char* filter) char fileName[MAX_PATH] = ""; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = hWnd; + ofn.hwndOwner = pp_windows_main_window_handle(); ofn.lpstrFilter = filter; ofn.lpstrFile = fileName; ofn.nMaxFile = MAX_PATH; @@ -240,7 +237,7 @@ std::string save_file(const char* filter) char fileName[MAX_PATH] = ""; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = hWnd; + ofn.hwndOwner = pp_windows_main_window_handle(); ofn.lpstrFilter = filter; ofn.lpstrFile = fileName; ofn.nMaxFile = MAX_PATH; @@ -258,7 +255,7 @@ std::string open_directory() char Buffer[MAX_PATH]; ZeroMemory(Buffer, MAX_PATH); ZeroMemory(&bi, sizeof(bi)); - bi.hwndOwner = hWnd; + bi.hwndOwner = pp_windows_main_window_handle(); bi.pszDisplayName = Buffer; bi.lpszTitle = "Title"; bi.ulFlags = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_SHAREABLE;