Share Canvas state GL dispatch adapters
This commit is contained in:
@@ -556,9 +556,13 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p
|
|||||||
queries now use tested backend query dispatch too. Retained `Canvas` stroke draw/commit, thumbnail
|
queries now use tested backend query dispatch too. Retained `Canvas` stroke draw/commit, thumbnail
|
||||||
generation, object rendering, and `LayerFrame::clear` saved viewport or
|
generation, object rendering, and `LayerFrame::clear` saved viewport or
|
||||||
clear-color query plus clear-color restore paths also use tested
|
clear-color query plus clear-color restore paths also use tested
|
||||||
`pp_renderer_gl` dispatch helpers. `NodeCanvas` saved viewport/clear-color
|
`pp_renderer_gl` dispatch helpers. Retained `Canvas` active texture, fallback
|
||||||
query, density/offscreen color clear, and clear-color restore paths use the
|
texture unbind, viewport/scissor execution, viewport and clear-color query,
|
||||||
same helpers. `NodeCanvas` and `NodeStrokePreview` now share
|
clear-color restore, and capability query/apply adapter endpoints now share
|
||||||
|
`legacy_ui_gl_dispatch`; Canvas depth renderbuffer allocation/attachment/delete
|
||||||
|
remains a separate retained renderer-resource bridge. `NodeCanvas` saved
|
||||||
|
viewport/clear-color query, density/offscreen color clear, and clear-color
|
||||||
|
restore paths use the same helpers. `NodeCanvas` and `NodeStrokePreview` now share
|
||||||
`legacy_ui_gl_dispatch` for active texture, texture unbind, viewport/scissor,
|
`legacy_ui_gl_dispatch` for active texture, texture unbind, viewport/scissor,
|
||||||
clear-color, color-buffer clear, and capability query/apply adapter endpoints.
|
clear-color, color-buffer clear, and capability query/apply adapter endpoints.
|
||||||
`CanvasMode` overlay, mask, transform, and canvas-tip pick paths now also
|
`CanvasMode` overlay, mask, transform, and canvas-tip pick paths now also
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1268,8 +1268,13 @@ snapshots now route through the same backend dispatch contracts. Retained
|
|||||||
`Canvas` stroke draw/commit, thumbnail
|
`Canvas` stroke draw/commit, thumbnail
|
||||||
generation, object drawing, and `LayerFrame::clear` saved viewport/clear-color
|
generation, object drawing, and `LayerFrame::clear` saved viewport/clear-color
|
||||||
query plus clear-color restore paths also use tested `pp_renderer_gl` dispatch
|
query plus clear-color restore paths also use tested `pp_renderer_gl` dispatch
|
||||||
helpers. `NodeCanvas` saved viewport/clear-color query, density target color
|
helpers. The retained `Canvas` active-texture, fallback texture unbind,
|
||||||
clear, and clear-color restore paths use the same helpers. `NodeCanvas` and
|
viewport/scissor execution, viewport and clear-color query, clear-color
|
||||||
|
restore, and capability query/apply adapter endpoints now share
|
||||||
|
`legacy_ui_gl_dispatch`; Canvas depth renderbuffer allocation/attachment/delete
|
||||||
|
remains a separate retained renderer-resource bridge under DEBT-0036.
|
||||||
|
`NodeCanvas` saved viewport/clear-color query, density target color clear, and
|
||||||
|
clear-color restore paths use the same helpers. `NodeCanvas` and
|
||||||
`NodeStrokePreview` now share that retained UI GL dispatch bridge for
|
`NodeStrokePreview` now share that retained UI GL dispatch bridge for
|
||||||
active-texture, fallback texture unbind, viewport/scissor, clear-color,
|
active-texture, fallback texture unbind, viewport/scissor, clear-color,
|
||||||
color-buffer clear, and capability query/apply adapter endpoints.
|
color-buffer clear, and capability query/apply adapter endpoints.
|
||||||
@@ -2532,6 +2537,11 @@ Results:
|
|||||||
`LayerFrame::clear` paths now use the same tested backend viewport query,
|
`LayerFrame::clear` paths now use the same tested backend viewport query,
|
||||||
clear-color query, and clear-color restore helpers, removing direct
|
clear-color query, and clear-color restore helpers, removing direct
|
||||||
viewport/clear-state queries from `src/canvas.cpp` and the frame clear path.
|
viewport/clear-state queries from `src/canvas.cpp` and the frame clear path.
|
||||||
|
Their active-texture selection, fallback 2D texture unbind, viewport/scissor
|
||||||
|
execution, clear-color restore, and capability query/apply adapter endpoints
|
||||||
|
now share `legacy_ui_gl_dispatch`; retained Canvas depth renderbuffer
|
||||||
|
allocation/attachment/delete remains open as a renderer-resource bridge under
|
||||||
|
DEBT-0036.
|
||||||
- Canvas draw-merge shader-blend selection now consumes the extracted
|
- Canvas draw-merge shader-blend selection now consumes the extracted
|
||||||
`pp_paint_renderer` stroke composite planner for current layer and primary
|
`pp_paint_renderer` stroke composite planner for current layer and primary
|
||||||
brush blend modes, while preserving legacy OpenGL compositing execution under
|
brush blend modes, while preserving legacy OpenGL compositing execution under
|
||||||
|
|||||||
147
src/canvas.cpp
147
src/canvas.cpp
@@ -2,6 +2,7 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "canvas.h"
|
#include "canvas.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
#include "legacy_ui_gl_dispatch.h"
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
#include "node_progress_bar.h"
|
#include "node_progress_bar.h"
|
||||||
#include "paint_renderer/compositor.h"
|
#include "paint_renderer/compositor.h"
|
||||||
@@ -142,177 +143,49 @@ pp::renderer::gl::OpenGlPixelFormat texture_format_for_image_channels(int channe
|
|||||||
return pp::renderer::gl::texture_format_for_channel_count(static_cast<std::uint32_t>(channel_count));
|
return pp::renderer::gl::texture_format_for_channel_count(static_cast<std::uint32_t>(channel_count));
|
||||||
}
|
}
|
||||||
|
|
||||||
void activate_opengl_texture(std::uint32_t texture_unit) noexcept
|
|
||||||
{
|
|
||||||
glActiveTexture(static_cast<GLenum>(texture_unit));
|
|
||||||
}
|
|
||||||
|
|
||||||
void bind_opengl_texture(std::uint32_t target, std::uint32_t texture) noexcept
|
|
||||||
{
|
|
||||||
glBindTexture(static_cast<GLenum>(target), static_cast<GLuint>(texture));
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_active_texture_unit(std::uint32_t unit_index)
|
void set_active_texture_unit(std::uint32_t unit_index)
|
||||||
{
|
{
|
||||||
const auto status = pp::renderer::gl::activate_opengl_texture_unit(
|
pp::legacy::ui_gl::activate_texture_unit(unit_index, "Canvas");
|
||||||
unit_index,
|
|
||||||
pp::renderer::gl::OpenGlActiveTextureDispatch {
|
|
||||||
.active_texture = activate_opengl_texture,
|
|
||||||
});
|
|
||||||
if (!status.ok())
|
|
||||||
LOG("Canvas active texture dispatch failed because: %s", status.message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void unbind_texture_2d()
|
void unbind_texture_2d()
|
||||||
{
|
{
|
||||||
const auto status = pp::renderer::gl::bind_opengl_texture_2d(
|
pp::legacy::ui_gl::unbind_texture_2d("Canvas");
|
||||||
0U,
|
|
||||||
pp::renderer::gl::OpenGlTexture2DBindDispatch {
|
|
||||||
.bind_texture = bind_opengl_texture,
|
|
||||||
});
|
|
||||||
if (!status.ok())
|
|
||||||
LOG("Canvas texture unbind dispatch failed because: %s", status.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
void enable_opengl_state(std::uint32_t state) noexcept
|
|
||||||
{
|
|
||||||
glEnable(static_cast<GLenum>(state));
|
|
||||||
}
|
|
||||||
|
|
||||||
void disable_opengl_state(std::uint32_t state) noexcept
|
|
||||||
{
|
|
||||||
glDisable(static_cast<GLenum>(state));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::uint8_t query_opengl_capability(std::uint32_t state) noexcept
|
|
||||||
{
|
|
||||||
return static_cast<std::uint8_t>(glIsEnabled(static_cast<GLenum>(state)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_opengl_viewport(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height) noexcept
|
|
||||||
{
|
|
||||||
glViewport(static_cast<GLint>(x), static_cast<GLint>(y), static_cast<GLsizei>(width), static_cast<GLsizei>(height));
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_opengl_clear_color(float r, float g, float b, float a) noexcept
|
|
||||||
{
|
|
||||||
glClearColor(r, g, b, a);
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_opengl_integer(std::uint32_t name, std::int32_t* values) noexcept
|
|
||||||
{
|
|
||||||
GLint raw_values[4] {};
|
|
||||||
glGetIntegerv(static_cast<GLenum>(name), raw_values);
|
|
||||||
values[0] = static_cast<std::int32_t>(raw_values[0]);
|
|
||||||
values[1] = static_cast<std::int32_t>(raw_values[1]);
|
|
||||||
values[2] = static_cast<std::int32_t>(raw_values[2]);
|
|
||||||
values[3] = static_cast<std::int32_t>(raw_values[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_opengl_float(std::uint32_t name, float* values) noexcept
|
|
||||||
{
|
|
||||||
glGetFloatv(static_cast<GLenum>(name), values);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_opengl_scissor(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height) noexcept
|
|
||||||
{
|
|
||||||
glScissor(static_cast<GLint>(x), static_cast<GLint>(y), static_cast<GLsizei>(width), static_cast<GLsizei>(height));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_canvas_viewport(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height)
|
void apply_canvas_viewport(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height)
|
||||||
{
|
{
|
||||||
const auto status = pp::renderer::gl::apply_opengl_viewport(
|
pp::legacy::ui_gl::apply_viewport(x, y, width, height, "Canvas");
|
||||||
pp::renderer::gl::OpenGlViewportRect {
|
|
||||||
.x = x,
|
|
||||||
.y = y,
|
|
||||||
.width = width,
|
|
||||||
.height = height,
|
|
||||||
},
|
|
||||||
pp::renderer::gl::OpenGlViewportDispatch {
|
|
||||||
.viewport = set_opengl_viewport,
|
|
||||||
});
|
|
||||||
if (!status.ok())
|
|
||||||
LOG("Canvas viewport dispatch failed because: %s", status.message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pp::renderer::gl::OpenGlViewportRect query_canvas_viewport()
|
pp::renderer::gl::OpenGlViewportRect query_canvas_viewport()
|
||||||
{
|
{
|
||||||
const auto result = pp::renderer::gl::query_opengl_viewport(
|
return pp::legacy::ui_gl::query_viewport_rect("Canvas");
|
||||||
pp::renderer::gl::OpenGlViewportQueryDispatch {
|
|
||||||
.get_integer = get_opengl_integer,
|
|
||||||
});
|
|
||||||
if (!result.ok()) {
|
|
||||||
LOG("Canvas viewport query dispatch failed because: %s", result.status().message);
|
|
||||||
}
|
|
||||||
return result.value();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<float, 4> query_canvas_clear_color()
|
std::array<float, 4> query_canvas_clear_color()
|
||||||
{
|
{
|
||||||
const auto result = pp::renderer::gl::query_opengl_clear_color(
|
return pp::legacy::ui_gl::query_clear_color("Canvas");
|
||||||
pp::renderer::gl::OpenGlClearColorQueryDispatch {
|
|
||||||
.get_float = get_opengl_float,
|
|
||||||
});
|
|
||||||
if (!result.ok()) {
|
|
||||||
LOG("Canvas clear-color query dispatch failed because: %s", result.status().message);
|
|
||||||
}
|
|
||||||
return result.value();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_canvas_clear_color(std::array<float, 4> color)
|
void apply_canvas_clear_color(std::array<float, 4> color)
|
||||||
{
|
{
|
||||||
const auto status = pp::renderer::gl::apply_opengl_clear_color(
|
pp::legacy::ui_gl::set_clear_color(color, "Canvas");
|
||||||
color,
|
|
||||||
pp::renderer::gl::OpenGlClearColorDispatch {
|
|
||||||
.clear_color = set_opengl_clear_color,
|
|
||||||
});
|
|
||||||
if (!status.ok())
|
|
||||||
LOG("Canvas clear-color dispatch failed because: %s", status.message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_canvas_scissor(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height)
|
void apply_canvas_scissor(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height)
|
||||||
{
|
{
|
||||||
const auto status = pp::renderer::gl::apply_opengl_scissor_rect(
|
pp::legacy::ui_gl::apply_scissor_rect(x, y, width, height, "Canvas");
|
||||||
pp::renderer::gl::OpenGlScissorRect {
|
|
||||||
.enabled = 1U,
|
|
||||||
.x = x,
|
|
||||||
.y = y,
|
|
||||||
.width = width,
|
|
||||||
.height = height,
|
|
||||||
},
|
|
||||||
pp::renderer::gl::OpenGlScissorDispatch {
|
|
||||||
.enable = enable_opengl_state,
|
|
||||||
.disable = disable_opengl_state,
|
|
||||||
.scissor = set_opengl_scissor,
|
|
||||||
});
|
|
||||||
if (!status.ok())
|
|
||||||
LOG("Canvas scissor dispatch failed because: %s", status.message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_canvas_capability(std::uint32_t state, bool enabled)
|
void apply_canvas_capability(std::uint32_t state, bool enabled)
|
||||||
{
|
{
|
||||||
const auto status = pp::renderer::gl::apply_opengl_capability(
|
pp::legacy::ui_gl::set_capability(state, enabled, "Canvas");
|
||||||
state,
|
|
||||||
enabled,
|
|
||||||
pp::renderer::gl::OpenGlCapabilityDispatch {
|
|
||||||
.enable = enable_opengl_state,
|
|
||||||
.disable = disable_opengl_state,
|
|
||||||
});
|
|
||||||
if (!status.ok())
|
|
||||||
LOG("Canvas capability dispatch failed because: %s", status.message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool query_canvas_capability(std::uint32_t state)
|
bool query_canvas_capability(std::uint32_t state)
|
||||||
{
|
{
|
||||||
const auto result = pp::renderer::gl::query_opengl_capability_state(
|
return pp::legacy::ui_gl::query_capability(state, "Canvas");
|
||||||
state,
|
|
||||||
pp::renderer::gl::OpenGlCapabilityStateQueryDispatch {
|
|
||||||
.is_enabled = query_opengl_capability,
|
|
||||||
});
|
|
||||||
if (!result.ok()) {
|
|
||||||
LOG("Canvas capability query dispatch failed because: %s", result.status().message);
|
|
||||||
}
|
|
||||||
return result.value();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gen_opengl_renderbuffers(std::uint32_t count, std::uint32_t* ids) noexcept
|
void gen_opengl_renderbuffers(std::uint32_t count, std::uint32_t* ids) noexcept
|
||||||
|
|||||||
Reference in New Issue
Block a user