Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
DocumentPresenter.h File Reference

Owns the per-frame decision of where this frame's document pixels land. More...

#include <cstdint>
#include <functional>
#include <memory>
#include <optional>
#include <vector>
#include "donner/base/Box.h"
#include "donner/base/EcsRegistry.h"
#include "donner/editor/GlTextureCache.h"
#include "donner/editor/SelectTool.h"
#include "donner/editor/ViewportState.h"
Include dependency graph for DocumentPresenter.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::editor::FramebufferUnderlayPlan
 Everything the framebuffer underlay needs to draw one frame of document pixels. Captured by value because the underlay callback runs later in the frame, after the shell's borrowed tile views would have gone stale. More...
struct  donner::editor::DocumentPresentationFrame
 Per-frame inputs to the external-surface half of the presentation decision. More...
struct  donner::editor::DocumentPresentationResult
 What the presenter resolved for this frame. More...
class  donner::editor::DocumentPresenter
 The per-frame document presentation decision. More...
class  donner::editor::FramebufferUnderlayPresenter
 Presents document tiles by compositing them onto the window framebuffer underneath the ImGui UI. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Typedefs

using donner::editor::FramebufferUnderlayPlanSink = std::function<void(std::optional<FramebufferUnderlayPlan>)>
 Sink installing (or, on std::nullopt, clearing) this frame's framebuffer underlay plan.

Functions

bool donner::editor::DocumentPresentationMappingChanged (const ViewportState &before, const ViewportState &after)
 Return whether two viewports place document pixels differently on screen.
std::unique_ptr< DocumentPresenterdonner::editor::MakeDocumentPresenter (FramebufferUnderlayPlanSink planSink)
 Build the presenter every platform presents through.

Detailed Description

Owns the per-frame decision of where this frame's document pixels land.

There is exactly one presentation target on every platform: the framebuffer underlay. Cached document tiles are composited straight onto the window framebuffer underneath the ImGui UI, together with the WGSL checkerboard backdrop.

This used to be a fork. The browser presented through a worker-owned canvas outside the window framebuffer, placed and clipped with CSS from the live viewport, and fell back to the underlay whenever the worker had no accepted surface epoch. The single-canvas replacement deleted that target: the browser build now runs the whole application on one worker thread that owns the single canvas, so the document composites under the UI in the same WebGPU frame that draws the UI, exactly as on desktop. The fork it replaced is the reason this seam exists at all, and the seam is kept because the underlay plan is still worth testing headlessly.

The presenter deliberately owns no rendering resources. It talks to the outside world through an injected sink, so the placement math is unit-testable headlessly on any build.

Function Documentation

◆ DocumentPresentationMappingChanged()

bool donner::editor::DocumentPresentationMappingChanged ( const ViewportState & before,
const ViewportState & after )
nodiscard

Return whether two viewports place document pixels differently on screen.

Compares only what moves the document: the screen/document mapping, the artboard rect, and the device pixel ratio the chrome is rasterized at. Pane origin and size are deliberately excluded - the pane moving does not by itself move the document within it.

Parameters
beforeViewport the presented pixels were previously placed with.
afterViewport they are placed with now.

◆ MakeDocumentPresenter()

std::unique_ptr< DocumentPresenter > donner::editor::MakeDocumentPresenter ( FramebufferUnderlayPlanSink planSink)
nodiscard

Build the presenter every platform presents through.

Parameters
planSinkInstalls or clears the framebuffer underlay draw plan.