Route app frame decisions through app core

This commit is contained in:
2026-06-05 06:08:39 +02:00
parent 678bf2dcd6
commit f7979be80f
11 changed files with 287 additions and 12 deletions

View File

@@ -5,6 +5,7 @@
#include "node_dialog_open.h"
#include "node_progress_bar.h"
#include "mp4enc.h"
#include "app_core/app_frame.h"
#include "app_core/app_status.h"
#include "app_core/app_startup.h"
#include "app_core/canvas_tool_ui.h"
@@ -182,8 +183,9 @@ bool App::ui_running = false;
void App::create()
{
width = 1920/2;
height = 1080/2;
const auto initial_surface = pp::app::plan_app_initial_surface();
width = initial_surface.width;
height = initial_surface.height;
}
void App::open_document(std::string path)
@@ -540,13 +542,20 @@ bool App::update_ui_observer(Node *n)
void App::draw(float dt)
{
const auto draw_plan = pp::app::plan_app_frame_draw(
canvas != nullptr,
canvas && canvas->m_canvas,
vr_active,
ui_visible,
vr_only);
// update offscreen stuff
if (canvas && canvas->m_canvas)
if (draw_plan.draw_canvas_stroke)
canvas->m_canvas->stroke_draw();
auto observer = std::bind(&App::update_ui_observer, this, std::placeholders::_1);
if (vr_active && ui_visible)
if (draw_plan.draw_vr_ui)
{
uirtt.bindFramebuffer();
uirtt.clear();
@@ -564,7 +573,7 @@ void App::draw(float dt)
uirtt.unbindFramebuffer();
}
if (!vr_only)
if (draw_plan.draw_main_ui)
{
bind_main_render_target();
apply_app_viewport(pp::renderer::gl::OpenGlViewportRect {
@@ -582,7 +591,8 @@ void App::draw(float dt)
apply_app_scissor_test(false);
}
redraw = false;
if (draw_plan.reset_redraw)
redraw = false;
}
void App::update(float dt)
@@ -592,15 +602,19 @@ void App::update(float dt)
// avoid multiple threads to update the scene
//std::lock_guard<std::mutex> lock(mutex);
if (!(redraw || animate))
const auto update_plan = pp::app::plan_app_frame_update(redraw, animate);
if (!update_plan.update_frame)
return;
if (auto* main = layout[main_id])
if (auto* main = layout[main_id]; update_plan.update_layouts && main)
main->update(width, height, zoom);
if (auto* main = layout_designer[main_id])
if (auto* main = layout_designer[main_id]; update_plan.update_layouts && main)
main->update(width, height, zoom);
if (!update_plan.refresh_canvas_toolbar)
return;
{
auto mode = Canvas::I->m_current_mode;