diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index a5861ef..dbf7787 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -218,6 +218,9 @@ Known local toolchain state: format/type, stroke mixer depth/scissor/blend state, saved viewport and clear-state queries, active texture units, fallback 2D texture unbind targets, and stroke background copy targets. + Canvas stroke commit also consumes backend-owned saved viewport/clear/blend + state, history readback format/type, active texture units, fallback 2D + texture unbind targets, and layer compositing copy targets. - `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 8345a0d..ae16275 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -762,6 +762,9 @@ Results: and blend state, saved viewport/clear-state queries, active texture units, fallback 2D texture unbinds, and stroke background copy targets through the renderer GL backend mapping. +- Canvas stroke commit now routes saved viewport/clear/blend state, history + readbacks, active texture units, fallback 2D texture unbinds, and layer + compositing copy targets through the renderer GL backend mapping. - Known remaining warnings: legacy project/vendor diagnostics, Visual Studio vcpkg-manifest warning, `LNK4099` missing libyuv PDBs, and `LNK4098` runtime library conflict from retained vendor binaries. diff --git a/src/canvas.cpp b/src/canvas.cpp index 6486bd0..4cba841 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -854,9 +854,9 @@ void Canvas::stroke_commit() // save viewport and clear color states GLint vp[4]; GLfloat cc[4]; - glGetIntegerv(GL_VIEWPORT, vp); - glGetFloatv(GL_COLOR_CLEAR_VALUE, cc); - GLboolean blend = glIsEnabled(GL_BLEND); + glGetIntegerv(viewport_query(), vp); + glGetFloatv(color_clear_value_query(), cc); + auto blend = glIsEnabled(blend_state()); // allocate action to add to history auto action = new ActionStroke; @@ -867,7 +867,7 @@ void Canvas::stroke_commit() // prepare common states glViewport(0, 0, m_width, m_height); - glDisable(GL_BLEND); + glDisable(blend_state()); const auto& b = m_current_stroke->m_brush; @@ -882,7 +882,14 @@ void Canvas::stroke_commit() // save image before commit glm::vec2 box_sz = zw(m_dirty_box[i]) - xy(m_dirty_box[i]); action->m_image[i] = std::make_unique(box_sz.x * box_sz.y * 4); - glReadPixels(m_dirty_box[i].x, m_dirty_box[i].y, box_sz.x, box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, action->m_image[i].get()); + glReadPixels( + m_dirty_box[i].x, + m_dirty_box[i].y, + box_sz.x, + box_sz.y, + rgba_pixel_format(), + unsigned_byte_component_type(), + action->m_image[i].get()); action->m_box[i] = m_dirty_box[i]; action->m_old_box[i] = m_layers[m_current_layer_idx]->box(i); @@ -899,13 +906,13 @@ void Canvas::stroke_commit() m_layers[m_current_layer_idx]->face(i) = true; // copy to tmp2 for layer blending - glActiveTexture(GL_TEXTURE0); + set_active_texture_unit(0); m_tex2[i].bind(); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, m_width, m_height); + glCopyTexSubImage2D(texture_2d_target(), 0, 0, 0, 0, 0, m_width, m_height); m_tex2[i].unbind(); m_tmp[i].bindTexture(); - glActiveTexture(GL_TEXTURE1); + set_active_texture_unit(1); m_tex2[i].bind(); m_sampler.bind(0); m_sampler_nearest.bind(1); @@ -922,17 +929,17 @@ void Canvas::stroke_commit() ShaderManager::u_float(kShaderUniform::Alpha, 1); ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f)); - glActiveTexture(GL_TEXTURE0); + set_active_texture_unit(0); m_tex2[i].bind(); - glActiveTexture(GL_TEXTURE1); + set_active_texture_unit(1); m_tmp[i].bindTexture(); - glActiveTexture(GL_TEXTURE2); + set_active_texture_unit(2); m_smask.rtt(i).bindTexture(); m_plane.draw_fill(); m_smask.rtt(i).unbindTexture(); - glActiveTexture(GL_TEXTURE1); + set_active_texture_unit(1); m_tmp[i].unbindTexture(); - glActiveTexture(GL_TEXTURE0); + set_active_texture_unit(0); m_tex2[i].unbind(); } else @@ -966,28 +973,28 @@ void Canvas::stroke_commit() ShaderManager::u_int(kShaderUniform::PatternBlendMode, b->m_pattern_blend_mode); ShaderManager::u_vec2(kShaderUniform::PatternOffset, m_pattern_offset); - glActiveTexture(GL_TEXTURE0); + set_active_texture_unit(0); m_tex2[i].bind(); - glActiveTexture(GL_TEXTURE1); + set_active_texture_unit(1); m_tmp[i].bindTexture(); - glActiveTexture(GL_TEXTURE2); + set_active_texture_unit(2); m_smask.rtt(i).bindTexture(); - glActiveTexture(GL_TEXTURE3); + set_active_texture_unit(3); if (b->m_dual_enabled) m_tmp_dual[i].bindTexture(); - glActiveTexture(GL_TEXTURE4); + set_active_texture_unit(4); b->m_pattern_texture ? b->m_pattern_texture->bind() : - glBindTexture(GL_TEXTURE_2D, 0); + unbind_texture_2d(); m_plane.draw_fill(); - glActiveTexture(GL_TEXTURE3); + set_active_texture_unit(3); if (b->m_dual_enabled) m_tmp_dual[i].unbindTexture(); - glActiveTexture(GL_TEXTURE2); + set_active_texture_unit(2); m_smask.rtt(i).unbindTexture(); - glActiveTexture(GL_TEXTURE1); + set_active_texture_unit(1); m_tmp[i].unbindTexture(); - glActiveTexture(GL_TEXTURE0); + set_active_texture_unit(0); m_tex2[i].unbind(); } // else @@ -1010,19 +1017,19 @@ void Canvas::stroke_commit() ShaderManager::use(kShader::StrokeDilate); ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f)); ShaderManager::u_int(kShaderUniform::TexBG, 0); - glActiveTexture(GL_TEXTURE0); + set_active_texture_unit(0); m_tex2[i].bind(); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, m_width, m_height); + glCopyTexSubImage2D(texture_2d_target(), 0, 0, 0, 0, 0, m_width, m_height); m_plane.draw_fill(); m_layers[m_current_layer_idx]->rtt(i).unbindFramebuffer(); } // restore viewport and clear color states - blend ? glEnable(GL_BLEND) : glDisable(GL_BLEND); + blend ? glEnable(blend_state()) : glDisable(blend_state()); glViewport(vp[0], vp[1], vp[2], vp[3]); glClearColor(cc[0], cc[1], cc[2], cc[3]); - glActiveTexture(GL_TEXTURE0); + set_active_texture_unit(0); // save history action->m_layer_idx = m_current_layer_idx;