Route retained draw state through GL dispatch

This commit is contained in:
2026-06-04 23:50:50 +02:00
parent 111cc8c892
commit 3cd1d46025
6 changed files with 92 additions and 29 deletions

View File

@@ -184,6 +184,11 @@ 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));
@@ -297,6 +302,19 @@ void apply_canvas_capability(std::uint32_t state, bool enabled)
LOG("Canvas capability dispatch failed because: %s", status.message);
}
bool query_canvas_capability(std::uint32_t state)
{
const auto result = pp::renderer::gl::query_opengl_capability_state(
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
{
glGenRenderbuffers(static_cast<GLsizei>(count), reinterpret_cast<GLuint*>(ids));
@@ -1121,7 +1139,7 @@ void Canvas::stroke_commit()
// save viewport and clear color states
const auto vp = query_canvas_viewport();
const auto cc = query_canvas_clear_color();
auto blend = glIsEnabled(blend_state());
auto blend = query_canvas_capability(blend_state());
// allocate action to add to history
auto action = new ActionStroke;
@@ -2992,7 +3010,7 @@ Image Canvas::thumbnail_generate(int w, int h)
// save viewport and clear color states
const auto vp = query_canvas_viewport();
const auto cc = query_canvas_clear_color();
auto blend = glIsEnabled(blend_state());
auto blend = query_canvas_capability(blend_state());
// prepare common states
apply_canvas_viewport(0, 0, w, h);
@@ -3125,7 +3143,7 @@ void Canvas::draw_objects_direct(std::function<void(const glm::mat4& camera, con
// save viewport and clear color states
const auto vp = query_canvas_viewport();
const auto cc = query_canvas_clear_color();
auto blend = glIsEnabled(blend_state());
auto blend = query_canvas_capability(blend_state());
// prepare common states
apply_canvas_viewport(0, 0, layer.w, layer.h);
@@ -3166,7 +3184,7 @@ void Canvas::draw_objects(std::function<void(const glm::mat4& camera, const glm:
// save viewport and clear color states
const auto vp = query_canvas_viewport();
const auto cc = query_canvas_clear_color();
auto blend = glIsEnabled(blend_state());
auto blend = query_canvas_capability(blend_state());
// prepare common states
apply_canvas_viewport(0, 0, layer.w, layer.h);