Extract app runtime tail, canvas camera shell, and preview sample services
This commit is contained in:
69
src/app.cpp
69
src/app.cpp
@@ -63,17 +63,6 @@ bool App::request_close()
|
||||
return close_decision == pp::app::CloseRequestDecision::close_now;
|
||||
}
|
||||
|
||||
void App::clear()
|
||||
{
|
||||
const auto status = pp::renderer::gl::clear_panopainter_default_target(
|
||||
pp::renderer::gl::OpenGlClearDispatch {
|
||||
.clear_color = pp::legacy::ui_gl::set_opengl_clear_color,
|
||||
.clear = pp::legacy::ui_gl::clear_opengl_buffer,
|
||||
});
|
||||
if (!status.ok())
|
||||
LOG("OpenGL clear failed: %s", status.message);
|
||||
}
|
||||
|
||||
void App::initAssets()
|
||||
{
|
||||
pp::panopainter::execute_legacy_app_init_assets(*this);
|
||||
@@ -89,69 +78,11 @@ namespace pp::panopainter
|
||||
bool update_legacy_app_ui_observer(App& app, Node* n);
|
||||
}
|
||||
|
||||
bool App::check_license()
|
||||
{
|
||||
return true; // TODO: for distribuiton only
|
||||
|
||||
#if WITH_CURL
|
||||
CURL *curl = curl_easy_init();
|
||||
if (curl)
|
||||
{
|
||||
std::string url = "https://panopainter.com/license/7565D057-ACBE-4721-9A4E-F342D3DDB7D8.php";
|
||||
//std::string url = "https://panopainter.com/license/E8EDC2FE-E1BD-4AB1-91BD-FCCD926739BD.php"; // wacom
|
||||
//std::string url = "https://panopainter.com/license/A744FBA9-BC6C-43C8-BD24-0CCE24B3D985.php"; // others
|
||||
|
||||
std::string ret;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ret);
|
||||
//curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 2L);
|
||||
if (disables_network_tls_verification())
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
|
||||
auto err = curl_easy_perform(curl);
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
LOG("License check: %s", ret.c_str());
|
||||
if (err == CURLcode::CURLE_OK && ret == "success")
|
||||
return true;
|
||||
}
|
||||
#endif //CURL
|
||||
return false;
|
||||
}
|
||||
|
||||
void App::init()
|
||||
{
|
||||
pp::panopainter::execute_legacy_app_init(*this);
|
||||
}
|
||||
|
||||
void App::async_start()
|
||||
{
|
||||
acquire_render_context();
|
||||
}
|
||||
|
||||
void App::async_redraw()
|
||||
{
|
||||
const auto plan = pp::app::plan_app_async_redraw();
|
||||
if (plan.set_redraw)
|
||||
redraw = true;
|
||||
if (plan.notify_ui)
|
||||
runtime_.notify_ui_worker();
|
||||
}
|
||||
|
||||
void App::async_end()
|
||||
{
|
||||
release_render_context();
|
||||
}
|
||||
|
||||
void App::async_swap()
|
||||
{
|
||||
present_render_context();
|
||||
}
|
||||
|
||||
bool App::update_ui_observer(Node *n)
|
||||
{
|
||||
return pp::panopainter::update_legacy_app_ui_observer(*this, n);
|
||||
|
||||
@@ -418,38 +418,3 @@ glm::vec3 Canvas::project2Dpoint(glm::vec2 pt)
|
||||
return pp::panopainter::legacy_canvas_project_2d_point(*this, pt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// return the 2d shape of the faces based on the current camera
|
||||
// this can be used for screen space shapes clipping
|
||||
std::vector<glm::vec2> Canvas::face_to_shape2D(int plane_index)
|
||||
{
|
||||
return pp::panopainter::legacy_canvas_face_to_shape_2d(*this, plane_index);
|
||||
}
|
||||
|
||||
void Canvas::push_camera()
|
||||
{
|
||||
pp::panopainter::legacy_canvas_push_camera(*this);
|
||||
}
|
||||
|
||||
void Canvas::pop_camera()
|
||||
{
|
||||
pp::panopainter::legacy_canvas_pop_camera(*this);
|
||||
}
|
||||
|
||||
CameraData Canvas::get_camera()
|
||||
{
|
||||
return pp::panopainter::legacy_canvas_render_shell_get_camera(*this);
|
||||
}
|
||||
|
||||
void Canvas::set_camera(const CameraData& c)
|
||||
{
|
||||
pp::panopainter::legacy_canvas_render_shell_set_camera(*this, c);
|
||||
}
|
||||
|
||||
void Canvas::timelapse_reset_encoder() noexcept
|
||||
{
|
||||
m_encoder = std::make_unique<MP4Encoder>();
|
||||
int res = glm::min<int>(m_width / 2, 1024);
|
||||
m_encoder->init(res * 4, res * 2, 30, 2000 << 10);
|
||||
}
|
||||
|
||||
@@ -108,6 +108,75 @@ void App::update(float dt)
|
||||
pp::panopainter::update_legacy_canvas_toolbar(*this);
|
||||
}
|
||||
|
||||
void App::clear()
|
||||
{
|
||||
const auto status = pp::renderer::gl::clear_panopainter_default_target(
|
||||
pp::renderer::gl::OpenGlClearDispatch {
|
||||
.clear_color = pp::legacy::ui_gl::set_opengl_clear_color,
|
||||
.clear = pp::legacy::ui_gl::clear_opengl_buffer,
|
||||
});
|
||||
if (!status.ok())
|
||||
LOG("OpenGL clear failed: %s", status.message);
|
||||
}
|
||||
|
||||
bool App::check_license()
|
||||
{
|
||||
return true; // TODO: for distribuiton only
|
||||
|
||||
#if WITH_CURL
|
||||
CURL* curl = curl_easy_init();
|
||||
if (curl)
|
||||
{
|
||||
std::string url = "https://panopainter.com/license/7565D057-ACBE-4721-9A4E-F342D3DDB7D8.php";
|
||||
//std::string url = "https://panopainter.com/license/E8EDC2FE-E1BD-4AB1-91BD-FCCD926739BD.php"; // wacom
|
||||
//std::string url = "https://panopainter.com/license/A744FBA9-BC6C-43C8-BD24-0CCE24B3D985.php"; // others
|
||||
|
||||
std::string ret;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ret);
|
||||
//curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 2L);
|
||||
if (disables_network_tls_verification())
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
|
||||
const auto err = curl_easy_perform(curl);
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
LOG("License check: %s", ret.c_str());
|
||||
if (err == CURLcode::CURLE_OK && ret == "success")
|
||||
return true;
|
||||
}
|
||||
#endif //CURL
|
||||
return false;
|
||||
}
|
||||
|
||||
void App::async_start()
|
||||
{
|
||||
acquire_render_context();
|
||||
}
|
||||
|
||||
void App::async_redraw()
|
||||
{
|
||||
const auto plan = pp::app::plan_app_async_redraw();
|
||||
if (plan.set_redraw)
|
||||
redraw = true;
|
||||
if (plan.notify_ui)
|
||||
runtime_.notify_ui_worker();
|
||||
}
|
||||
|
||||
void App::async_end()
|
||||
{
|
||||
release_render_context();
|
||||
}
|
||||
|
||||
void App::async_swap()
|
||||
{
|
||||
present_render_context();
|
||||
}
|
||||
|
||||
void App::terminate()
|
||||
{
|
||||
LOG("App::terminate");
|
||||
|
||||
40
src/legacy_canvas_camera_services.cpp
Normal file
40
src/legacy_canvas_camera_services.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "canvas.h"
|
||||
|
||||
#include "legacy_canvas_projection_services.h"
|
||||
#include "legacy_canvas_render_shell_services.h"
|
||||
|
||||
// return the 2d shape of the faces based on the current camera
|
||||
// this can be used for screen space shapes clipping
|
||||
std::vector<glm::vec2> Canvas::face_to_shape2D(int plane_index)
|
||||
{
|
||||
return pp::panopainter::legacy_canvas_face_to_shape_2d(*this, plane_index);
|
||||
}
|
||||
|
||||
void Canvas::push_camera()
|
||||
{
|
||||
pp::panopainter::legacy_canvas_push_camera(*this);
|
||||
}
|
||||
|
||||
void Canvas::pop_camera()
|
||||
{
|
||||
pp::panopainter::legacy_canvas_pop_camera(*this);
|
||||
}
|
||||
|
||||
CameraData Canvas::get_camera()
|
||||
{
|
||||
return pp::panopainter::legacy_canvas_render_shell_get_camera(*this);
|
||||
}
|
||||
|
||||
void Canvas::set_camera(const CameraData& c)
|
||||
{
|
||||
pp::panopainter::legacy_canvas_render_shell_set_camera(*this, c);
|
||||
}
|
||||
|
||||
void Canvas::timelapse_reset_encoder() noexcept
|
||||
{
|
||||
m_encoder = std::make_unique<MP4Encoder>();
|
||||
int res = glm::min<int>(m_width / 2, 1024);
|
||||
m_encoder->init(res * 4, res * 2, 30, 2000 << 10);
|
||||
}
|
||||
60
src/legacy_node_stroke_preview_sample_services.cpp
Normal file
60
src/legacy_node_stroke_preview_sample_services.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "legacy_node_stroke_preview_sample_services.h"
|
||||
|
||||
namespace pp::panopainter {
|
||||
|
||||
namespace {
|
||||
|
||||
std::array<pp::paint_renderer::CanvasStrokePoint, 4> make_stroke_preview_sample_points(
|
||||
const std::array<vertex_t, 4>& vertices)
|
||||
{
|
||||
return {
|
||||
pp::paint_renderer::CanvasStrokePoint { .x = vertices[0].pos.x, .y = vertices[0].pos.y },
|
||||
pp::paint_renderer::CanvasStrokePoint { .x = vertices[1].pos.x, .y = vertices[1].pos.y },
|
||||
pp::paint_renderer::CanvasStrokePoint { .x = vertices[2].pos.x, .y = vertices[2].pos.y },
|
||||
pp::paint_renderer::CanvasStrokePoint { .x = vertices[3].pos.x, .y = vertices[3].pos.y },
|
||||
};
|
||||
}
|
||||
|
||||
void upload_stroke_preview_brush_vertices(DynamicShape& brush_shape, std::span<const vertex_t> vertices)
|
||||
{
|
||||
brush_shape.update_vertices(
|
||||
const_cast<vertex_t*>(vertices.data()),
|
||||
static_cast<int>(vertices.size()));
|
||||
}
|
||||
|
||||
LegacyStrokeSampleExecutionRequest make_stroke_preview_sample_request(
|
||||
const LegacyNodeStrokePreviewSamplePassRequest& request,
|
||||
const std::array<pp::paint_renderer::CanvasStrokePoint, 4>& sample_points)
|
||||
{
|
||||
return LegacyStrokeSampleExecutionRequest {
|
||||
.context = "NodeStrokePreview::stroke_draw_samples",
|
||||
.target_size = request.target_size,
|
||||
.vertices = request.vertices,
|
||||
.sample_points = sample_points,
|
||||
.copy_stroke_destination = request.copy_stroke_destination,
|
||||
.bind_destination_texture = request.bind_destination_texture,
|
||||
.copy_framebuffer_to_destination_texture = request.copy_framebuffer_to_destination_texture,
|
||||
.unbind_destination_texture = request.unbind_destination_texture,
|
||||
.upload_brush_vertices = [&](std::span<const vertex_t> brush_vertices) {
|
||||
upload_stroke_preview_brush_vertices(request.brush_shape, brush_vertices);
|
||||
},
|
||||
.draw_brush_shape = [&] {
|
||||
request.brush_shape.draw_fill();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
glm::vec4 execute_legacy_node_stroke_preview_sample_pass(
|
||||
const LegacyNodeStrokePreviewSamplePassRequest& request)
|
||||
{
|
||||
const auto sample_points = make_stroke_preview_sample_points(request.vertices);
|
||||
const auto result = execute_legacy_canvas_stroke_sample(
|
||||
make_stroke_preview_sample_request(request, sample_points));
|
||||
return result.dirty_bounds;
|
||||
}
|
||||
|
||||
} // namespace pp::panopainter
|
||||
28
src/legacy_node_stroke_preview_sample_services.h
Normal file
28
src/legacy_node_stroke_preview_sample_services.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "legacy_canvas_stroke_execution_services.h"
|
||||
#include "paint_renderer/compositor.h"
|
||||
#include "shape.h"
|
||||
#include "texture.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <span>
|
||||
|
||||
namespace pp::panopainter {
|
||||
|
||||
struct LegacyNodeStrokePreviewSamplePassRequest {
|
||||
glm::vec2 target_size {};
|
||||
std::array<vertex_t, 4>& vertices;
|
||||
DynamicShape& brush_shape;
|
||||
bool copy_stroke_destination = false;
|
||||
std::function<void()> bind_destination_texture;
|
||||
std::function<void(int, int, int, int, int, int)> copy_framebuffer_to_destination_texture;
|
||||
std::function<void()> unbind_destination_texture;
|
||||
};
|
||||
|
||||
[[nodiscard]] glm::vec4 execute_legacy_node_stroke_preview_sample_pass(
|
||||
const LegacyNodeStrokePreviewSamplePassRequest& request);
|
||||
|
||||
} // namespace pp::panopainter
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "legacy_canvas_stroke_services.h"
|
||||
#include "legacy_node_stroke_preview_execution_services.h"
|
||||
#include "legacy_node_stroke_preview_runtime_services.h"
|
||||
#include "legacy_node_stroke_preview_sample_services.h"
|
||||
#include "legacy_ui_gl_dispatch.h"
|
||||
#include "paint_renderer/compositor.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
@@ -242,89 +243,6 @@ void copy_stroke_preview_destination_texture_region(
|
||||
copy_framebuffer_to_texture_2d(src_x, src_y, dst_x, dst_y, width, height);
|
||||
}
|
||||
|
||||
std::array<pp::paint_renderer::CanvasStrokePoint, 4> make_stroke_preview_sample_points(
|
||||
const std::array<vertex_t, 4>& vertices)
|
||||
{
|
||||
return {
|
||||
pp::paint_renderer::CanvasStrokePoint { .x = vertices[0].pos.x, .y = vertices[0].pos.y },
|
||||
pp::paint_renderer::CanvasStrokePoint { .x = vertices[1].pos.x, .y = vertices[1].pos.y },
|
||||
pp::paint_renderer::CanvasStrokePoint { .x = vertices[2].pos.x, .y = vertices[2].pos.y },
|
||||
pp::paint_renderer::CanvasStrokePoint { .x = vertices[3].pos.x, .y = vertices[3].pos.y },
|
||||
};
|
||||
}
|
||||
|
||||
void upload_stroke_preview_brush_vertices(DynamicShape& brush_shape, std::span<const vertex_t> vertices);
|
||||
|
||||
pp::panopainter::LegacyStrokeSampleExecutionRequest make_stroke_preview_sample_request(
|
||||
std::array<vertex_t, 4>& vertices,
|
||||
const std::array<pp::paint_renderer::CanvasStrokePoint, 4>& sample_points,
|
||||
glm::vec2 target_size,
|
||||
Texture2D& blend_texture,
|
||||
DynamicShape& brush_shape,
|
||||
bool copy_stroke_destination)
|
||||
{
|
||||
return pp::panopainter::LegacyStrokeSampleExecutionRequest {
|
||||
.context = "NodeStrokePreview::stroke_draw_samples",
|
||||
.target_size = target_size,
|
||||
.vertices = vertices,
|
||||
.sample_points = sample_points,
|
||||
.copy_stroke_destination = copy_stroke_destination,
|
||||
.bind_destination_texture = [&] {
|
||||
bind_stroke_preview_destination_texture(blend_texture);
|
||||
},
|
||||
.copy_framebuffer_to_destination_texture = [](
|
||||
int src_x,
|
||||
int src_y,
|
||||
int dst_x,
|
||||
int dst_y,
|
||||
int width,
|
||||
int height) {
|
||||
copy_stroke_preview_destination_texture_region(
|
||||
src_x,
|
||||
src_y,
|
||||
dst_x,
|
||||
dst_y,
|
||||
width,
|
||||
height);
|
||||
},
|
||||
.unbind_destination_texture = [&] {
|
||||
unbind_stroke_preview_destination_texture(blend_texture);
|
||||
},
|
||||
.upload_brush_vertices = [&](std::span<const vertex_t> brush_vertices) {
|
||||
upload_stroke_preview_brush_vertices(brush_shape, brush_vertices);
|
||||
},
|
||||
.draw_brush_shape = [&] {
|
||||
brush_shape.draw_fill();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
void upload_stroke_preview_brush_vertices(DynamicShape& brush_shape, std::span<const vertex_t> vertices)
|
||||
{
|
||||
brush_shape.update_vertices(
|
||||
const_cast<vertex_t*>(vertices.data()),
|
||||
static_cast<int>(vertices.size()));
|
||||
}
|
||||
|
||||
glm::vec4 execute_stroke_preview_sample_pass(
|
||||
std::array<vertex_t, 4>& vertices,
|
||||
glm::vec2 target_size,
|
||||
Texture2D& blend_texture,
|
||||
DynamicShape& brush_shape,
|
||||
bool copy_stroke_destination)
|
||||
{
|
||||
const auto sample_points = make_stroke_preview_sample_points(vertices);
|
||||
const auto result = pp::panopainter::execute_legacy_canvas_stroke_sample(
|
||||
make_stroke_preview_sample_request(
|
||||
vertices,
|
||||
sample_points,
|
||||
target_size,
|
||||
blend_texture,
|
||||
brush_shape,
|
||||
copy_stroke_destination));
|
||||
return result.dirty_bounds;
|
||||
}
|
||||
|
||||
void execute_stroke_preview_background_capture_pass(
|
||||
glm::vec2 size,
|
||||
bool colorize,
|
||||
@@ -441,12 +359,34 @@ glm::vec4 NodeStrokePreview::stroke_draw_samples(
|
||||
bool copy_stroke_destination)
|
||||
{
|
||||
const glm::vec2 size = { m_rtt.getWidth(), m_rtt.getHeight() };
|
||||
return execute_stroke_preview_sample_pass(
|
||||
P,
|
||||
size,
|
||||
blend_tex,
|
||||
m_brush_shape,
|
||||
copy_stroke_destination);
|
||||
return pp::panopainter::execute_legacy_node_stroke_preview_sample_pass(
|
||||
pp::panopainter::LegacyNodeStrokePreviewSamplePassRequest {
|
||||
.target_size = size,
|
||||
.vertices = P,
|
||||
.brush_shape = m_brush_shape,
|
||||
.copy_stroke_destination = copy_stroke_destination,
|
||||
.bind_destination_texture = [&] {
|
||||
bind_stroke_preview_destination_texture(blend_tex);
|
||||
},
|
||||
.copy_framebuffer_to_destination_texture = [](
|
||||
int src_x,
|
||||
int src_y,
|
||||
int dst_x,
|
||||
int dst_y,
|
||||
int width,
|
||||
int height) {
|
||||
copy_stroke_preview_destination_texture_region(
|
||||
src_x,
|
||||
src_y,
|
||||
dst_x,
|
||||
dst_y,
|
||||
width,
|
||||
height);
|
||||
},
|
||||
.unbind_destination_texture = [&] {
|
||||
unbind_stroke_preview_destination_texture(blend_tex);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
std::vector<NodeStrokePreview::StrokeFrame> NodeStrokePreview::stroke_draw_compute(const Stroke& stroke, float zoom) const
|
||||
|
||||
Reference in New Issue
Block a user