From bbb85bb133da2973f5496caabbb3118cb084a1d5 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Tue, 2 Jun 2026 08:08:49 +0200 Subject: [PATCH] Move canvas action pixel mapping to renderer gl --- docs/modernization/build-inventory.md | 6 ++++-- docs/modernization/roadmap.md | 7 ++++-- src/canvas_actions.cpp | 31 ++++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index d3aabf8..a8b4cd2 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -1,7 +1,7 @@ # Build And Platform Inventory Status: live -Last updated: 2026-06-01 +Last updated: 2026-06-02 This inventory records the known build surfaces during the CMake migration. Keep it updated as platform paths move to shared CMake targets. @@ -164,7 +164,9 @@ Known local toolchain state: used before runtime capability detection are cataloged here. Legacy font atlas texture formats, text mesh buffer targets, attribute component and normalization tokens, draw primitive/index type, upload usage, and active - texture unit selection also consume the backend mapping. + texture unit selection also consume the backend mapping. Canvas undo/redo + dirty-region texture updates and readbacks also consume the backend-owned 2D + texture target, RGBA pixel format, and unsigned-byte component mapping. - `windows-msvc-vcpkg-headless` validates manifest install/configure/build/test for the current headless component matrix; see DEBT-0007 for remaining app and platform triplet migration. diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 4f762b8..4a2baa1 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -1,7 +1,7 @@ # PanoPainter Modernization Roadmap Status: live -Last updated: 2026-06-01 +Last updated: 2026-06-02 This is the living roadmap for modernizing PanoPainter into independently testable C++23 components while retaining all existing functionality. Keep this @@ -430,6 +430,9 @@ capability detection also live in `pp_renderer_gl`. Legacy font atlas texture formats, text mesh buffer targets, attribute component/normalization, draw primitive/index type, upload usage, and active texture unit selection also delegate to `pp_renderer_gl`; `Font` no longer spells GL enum names directly. +Canvas undo/redo dirty-region texture updates and readbacks now also delegate +their 2D texture target, RGBA pixel format, and unsigned-byte component type +mapping to `pp_renderer_gl`. The existing renderer classes are not yet fully behind the renderer interfaces. @@ -595,7 +598,7 @@ Acceptance for each phase: ## Verified Commands -Last verified on 2026-06-01: +Last verified on 2026-06-02: ```powershell cmake --preset windows-msvc-default diff --git a/src/canvas_actions.cpp b/src/canvas_actions.cpp index c76f3e9..fbe2d1c 100644 --- a/src/canvas_actions.cpp +++ b/src/canvas_actions.cpp @@ -4,6 +4,7 @@ #include "canvas.h" #include "canvas_actions.h" #include "node_panel_layer.h" +#include "renderer_gl/opengl_capabilities.h" void ActionStroke::undo() { @@ -36,8 +37,21 @@ void ActionStroke::undo() { App::I->render_task([&] { + const auto texture_target = pp::renderer::gl::texture_2d_target(); + const auto pixel_format = pp::renderer::gl::rgba_pixel_format(); + const auto component_type = pp::renderer::gl::unsigned_byte_component_type(); + m_canvas->m_layers[m_layer_idx]->rtt(i, m_frame_idx).bindTexture(); - glTexSubImage2D(GL_TEXTURE_2D, 0, (int)m_box[i].x, (int)m_box[i].y, (int)box_sz.x, (int)box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, m_image[i].get()); + glTexSubImage2D( + texture_target, + 0, + (int)m_box[i].x, + (int)m_box[i].y, + (int)box_sz.x, + (int)box_sz.y, + pixel_format, + component_type, + m_image[i].get()); m_canvas->m_layers[m_layer_idx]->rtt(i, m_frame_idx).unbindTexture(); }); } @@ -76,11 +90,22 @@ Action* ActionStroke::get_redo() glm::vec2 box_sz = zw(box) - xy(box); if (box_sz.x > 0 && box_sz.y > 0 && box_sz.x <= layer->w && box_sz.y <= layer->h) { - action->m_image[i] = std::make_unique(box_sz.x * box_sz.y * 4); + action->m_image[i] = std::make_unique( + static_cast((int)box_sz.x) * static_cast((int)box_sz.y) * 4U); App::I->render_task([&] { + const auto pixel_format = pp::renderer::gl::rgba_pixel_format(); + const auto component_type = pp::renderer::gl::unsigned_byte_component_type(); + layer->rtt(i, m_frame_idx).bindFramebuffer(); - glReadPixels(box_or.x, box_or.y, box_sz.x, box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, action->m_image[i].get()); + glReadPixels( + (int)box_or.x, + (int)box_or.y, + (int)box_sz.x, + (int)box_sz.y, + pixel_format, + component_type, + action->m_image[i].get()); layer->rtt(i, m_frame_idx).unbindFramebuffer(); }); }