Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
DocumentPixelSampler.h File Reference

Checked access to document-only RGBA pixels captured by the render worker. More...

#include <cstddef>
#include <optional>
#include "donner/base/Vector2.h"
#include "donner/css/Color.h"
#include "donner/editor/ViewportState.h"
#include "donner/svg/renderer/RendererInterface.h"
Include dependency graph for DocumentPixelSampler.h:
This graph shows which files directly or indirectly include this file:

Namespaces

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

Functions

bool donner::editor::CanCaptureDocumentPixelSize (const Vector2i &dimensions) noexcept
 Return whether the planned RGBA8 capture fits after GPU row alignment.
bool donner::editor::IsValidDocumentPixelBitmap (const svg::RendererBitmap &bitmap) noexcept
 Return whether a bitmap has complete RGBA8 rows within the capture limit.
std::optional< Vector2i > donner::editor::DocumentPixelIndexAtScreenPoint (const ViewportState &viewport, const EditorRasterViewport &rasterViewport, const Vector2d &screenPoint) noexcept
 Map one logical screen point to a captured document pixel.
std::optional< css::RGBA > donner::editor::ReadDocumentPixel (const svg::RendererBitmap &bitmap, const Vector2i &pixel) noexcept
 Read a straight-alpha SVG color from a captured pixel.

Variables

constexpr std::size_t donner::editor::kDocumentPixelCaptureMaxBytes = 256u * 1024u * 1024u
 Maximum retained CPU pixel payload for one eyedropper capture.

Detailed Description

Checked access to document-only RGBA pixels captured by the render worker.

Function Documentation

◆ DocumentPixelIndexAtScreenPoint()

std::optional< Vector2i > donner::editor::DocumentPixelIndexAtScreenPoint ( const ViewportState & viewport,
const EditorRasterViewport & rasterViewport,
const Vector2d & screenPoint )
nodiscardnoexcept

Map one logical screen point to a captured document pixel.

Parameters
viewportViewport used to present the document.
rasterViewportRaster mapping that produced the bitmap.
screenPointPointer position in logical screen pixels.
Returns
Pixel index, or nothing outside the document, pane, or raster.

◆ ReadDocumentPixel()

std::optional< css::RGBA > donner::editor::ReadDocumentPixel ( const svg::RendererBitmap & bitmap,
const Vector2i & pixel )
nodiscardnoexcept

Read a straight-alpha SVG color from a captured pixel.

Parameters
bitmapComplete RGBA8 renderer bitmap.
pixelInteger pixel index in the bitmap.
Returns
Color, or nothing when the bitmap or index is invalid.