AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
AeonGUI::SkiaCanvas Class Reference

Skia-based Canvas implementation. More...

#include </d/a/AeonGUI/AeonGUI/include/aeongui/SkiaCanvas.hpp>

Inheritance diagram for AeonGUI::SkiaCanvas:
[legend]
Collaboration diagram for AeonGUI::SkiaCanvas:
[legend]

Public Member Functions

 SkiaCanvas ()
 Construct an empty (zero-size) SkiaCanvas.
 SkiaCanvas (uint32_t aWidth, uint32_t aHeight)
 Construct a SkiaCanvas with the given viewport dimensions.
void ResizeViewport (uint32_t aWidth, uint32_t aHeight) final
 Resize the rendering viewport.
const uint8_t * GetPixels () const final
 Get a pointer to the raw pixel data.
size_t GetWidth () const final
 Get the width of the canvas in pixels.
size_t GetHeight () const final
 Get the height of the canvas in pixels.
size_t GetStride () const final
 Get the stride (bytes per row) of the pixel buffer.
void Clear () final
 Clear the canvas to transparent.
void Draw (const Path &aPath) final
 Draw a path using the current fill and stroke settings.
void DrawImage (const uint8_t *aPixels, size_t aImageWidth, size_t aImageHeight, size_t aImageStride, double aX, double aY, double aWidth, double aHeight, double aOpacity) final
 Draw a raster image.
void DrawText (const std::string &aText, double aX, double aY, const std::string &aFontFamily, double aFontSize, int aFontWeight, int aFontStyle) final
double MeasureText (const std::string &aText, const std::string &aFontFamily, double aFontSize, int aFontWeight, int aFontStyle) const final
void DrawTextOnPath (const std::string &aText, const Path &aPath, double aStartOffset, const std::string &aFontFamily, double aFontSize, int aFontWeight, int aFontStyle, bool aReverse=false, bool aClosed=false) final
void SetFillColor (const ColorAttr &aColor) final
 Set the fill color.
const ColorAttr & GetFillColor () const final
 Get the current fill color.
void SetStrokeColor (const ColorAttr &aColor) final
 Set the stroke color.
const ColorAttr & GetStrokeColor () const final
 Get the current stroke color.
void SetStrokeWidth (double aWidth) final
 Set the stroke width.
double GetStrokeWidth () const final
 Get the current stroke width.
void SetStrokeOpacity (double aWidth) final
 Set the stroke opacity.
double GetStrokeOpacity () const final
 Get the current stroke opacity.
void SetFillOpacity (double aWidth) final
 Set the fill opacity.
double GetFillOpacity () const final
 Get the current fill opacity.
void SetOpacity (double aWidth) final
 Set the global opacity.
double GetOpacity () const final
 Get the current global opacity.
void SetViewBox (const ViewBox &aViewBox, const PreserveAspectRatio &aPreserveAspectRatio) final
 Set the SVG viewBox and preserveAspectRatio.
void SetTransform (const Matrix2x3 &aMatrix) final
 Replace the current transformation matrix.
void Transform (const Matrix2x3 &aMatrix) final
 Pre-multiply the current transformation matrix.
void Save () final
 Save the current graphics state (transform, clipping, etc.).
void Restore () final
 Restore the previously saved graphics state.
void * GetNativeSurface () const final
 Get the native rendering surface handle.
void PushGroup () final
 Begin an offscreen group for filter/compositing.
void PopGroup () final
 End an offscreen group and composite back.
void ApplyDropShadow (double aDx, double aDy, double aStdDeviationX, double aStdDeviationY, const Color &aFloodColor, double aFloodOpacity) final
 Apply a drop-shadow filter to the current group content.
uint8_t PickAtPoint (double aX, double aY) const final
 Read the pick ID at the given viewport coordinates.
void ResetPick () final
 Clear the pick buffer and reset for a new frame.
void SetClipRect (double aX, double aY, double aWidth, double aHeight) final
 Set a device-space clip rectangle on both render and pick surfaces.
std::unique_ptr< PathCreatePath () const final
 Create a new Path object suitable for this canvas backend.
Public Member Functions inherited from AeonGUI::Canvas
void SetHitTesting (bool aHitTesting)
 Enable or disable hit-testing mode.
bool IsHitTesting () const
 Query whether the canvas is in hit-testing mode.
void SetPickId (uint8_t aPickId)
 Set the current pick ID for subsequent Draw calls.
virtual ~Canvas ()=0
 Virtual destructor.
const PickBoundsGetPickBounds (uint8_t aId) const
 Get the cached device-space bounds for a pick ID.

Additional Inherited Members

Protected Attributes inherited from AeonGUI::Canvas
bool mHitTesting {false}
 True when in hit-testing mode.
uint8_t mPickId {0}
 Current pick ID for Draw calls.
std::array< PickBounds, 256 > mPickBounds {}
 Cached device-space bounds per pick ID.

Detailed Description

Skia-based Canvas implementation.

Renders 2D geometry, text, and images into a CPU-side pixel buffer using Google Skia. Selected at build time with -DAEONGUI_BACKEND=Skia.

Constructor & Destructor Documentation

◆ SkiaCanvas()

AeonGUI::SkiaCanvas::SkiaCanvas ( uint32_t aWidth,
uint32_t aHeight )

Construct a SkiaCanvas with the given viewport dimensions.

Parameters
aWidthViewport width in pixels.
aHeightViewport height in pixels.

Member Function Documentation

◆ ApplyDropShadow()

void AeonGUI::SkiaCanvas::ApplyDropShadow ( double aDx,
double aDy,
double aStdDeviationX,
double aStdDeviationY,
const Color & aFloodColor,
double aFloodOpacity )
finalvirtual

Apply a drop-shadow filter to the current group content.

Must be called between PushGroup() and PopGroup(). The implementation captures the group, creates a blurred shadow, offsets it, and composites it under the original content.

Parameters
aDxHorizontal offset of the shadow.
aDyVertical offset of the shadow.
aStdDeviationXHorizontal Gaussian blur standard deviation.
aStdDeviationYVertical Gaussian blur standard deviation.
aFloodColorShadow color.
aFloodOpacityShadow opacity [0.0, 1.0].

Implements AeonGUI::Canvas.

◆ Clear()

void AeonGUI::SkiaCanvas::Clear ( )
finalvirtual

Clear the canvas to transparent.

Implements AeonGUI::Canvas.

◆ CreatePath()

std::unique_ptr< Path > AeonGUI::SkiaCanvas::CreatePath ( ) const
finalvirtual

Create a new Path object suitable for this canvas backend.

Returns
A new empty Path instance.

Implements AeonGUI::Canvas.

◆ Draw()

void AeonGUI::SkiaCanvas::Draw ( const Path & aPath)
finalvirtual

Draw a path using the current fill and stroke settings.

Parameters
aPathThe path to draw.

Implements AeonGUI::Canvas.

◆ DrawImage()

void AeonGUI::SkiaCanvas::DrawImage ( const uint8_t * aPixels,
size_t aImageWidth,
size_t aImageHeight,
size_t aImageStride,
double aX,
double aY,
double aWidth,
double aHeight,
double aOpacity )
finalvirtual

Draw a raster image.

Parameters
aPixelsPointer to source BGRA pixel data.
aImageWidthWidth of the source image in pixels.
aImageHeightHeight of the source image in pixels.
aImageStrideStride of the source image in bytes.
aXDestination X coordinate.
aYDestination Y coordinate.
aWidthDestination width in user units.
aHeightDestination height in user units.
aOpacityOpacity for the image [0.0, 1.0].

Implements AeonGUI::Canvas.

◆ DrawText()

void AeonGUI::SkiaCanvas::DrawText ( const std::string & aText,
double aX,
double aY,
const std::string & aFontFamily,
double aFontSize,
int aFontWeight,
int aFontStyle )
finalvirtual

Draw text at the given position using the specified font description and size.

Parameters
aTextThe UTF-8 text string to render.
aXThe x coordinate for the text start position.
aYThe y coordinate for the text baseline.
aFontFamilyFont family name (e.g. "sans-serif").
aFontSizeFont size in CSS pixels.
aFontWeightCSS font weight (400 = normal, 700 = bold).
aFontStyle0 = normal, 1 = italic, 2 = oblique.

Implements AeonGUI::Canvas.

◆ DrawTextOnPath()

void AeonGUI::SkiaCanvas::DrawTextOnPath ( const std::string & aText,
const Path & aPath,
double aStartOffset,
const std::string & aFontFamily,
double aFontSize,
int aFontWeight,
int aFontStyle,
bool aReverse = false,
bool aClosed = false )
finalvirtual

Draw text along a path. Each glyph is positioned and rotated to follow the path.

Parameters
aTextThe UTF-8 text string to render.
aPathThe path to follow.
aStartOffsetStarting distance along the path in user units.
aFontFamilyFont family name.
aFontSizeFont size in CSS pixels.
aFontWeightCSS font weight (400 = normal, 700 = bold).
aFontStyle0 = normal, 1 = italic, 2 = oblique.
aReverseIf true, render glyph order against the path direction.
aClosedIf true, treat the path as closed for offset wrapping.

Implements AeonGUI::Canvas.

◆ GetFillColor()

const ColorAttr & AeonGUI::SkiaCanvas::GetFillColor ( ) const
finalvirtual

Get the current fill color.

Returns
Reference to the current fill color.

Implements AeonGUI::Canvas.

◆ GetFillOpacity()

double AeonGUI::SkiaCanvas::GetFillOpacity ( ) const
finalvirtual

Get the current fill opacity.

Returns
Opacity in [0.0, 1.0].

Implements AeonGUI::Canvas.

◆ GetHeight()

size_t AeonGUI::SkiaCanvas::GetHeight ( ) const
finalvirtual

Get the height of the canvas in pixels.

Returns
Height in pixels.

Implements AeonGUI::Canvas.

◆ GetNativeSurface()

void * AeonGUI::SkiaCanvas::GetNativeSurface ( ) const
finalvirtual

Get the native rendering surface handle.

Returns
Pointer to the underlying surface (e.g. cairo_surface_t).

Implements AeonGUI::Canvas.

◆ GetOpacity()

double AeonGUI::SkiaCanvas::GetOpacity ( ) const
finalvirtual

Get the current global opacity.

Returns
Opacity in [0.0, 1.0].

Implements AeonGUI::Canvas.

◆ GetPixels()

const uint8_t * AeonGUI::SkiaCanvas::GetPixels ( ) const
finalvirtual

Get a pointer to the raw pixel data.

Returns
Pointer to BGRA pixel data, or nullptr if empty.

Implements AeonGUI::Canvas.

◆ GetStride()

size_t AeonGUI::SkiaCanvas::GetStride ( ) const
finalvirtual

Get the stride (bytes per row) of the pixel buffer.

Returns
Stride in bytes.

Implements AeonGUI::Canvas.

◆ GetStrokeColor()

const ColorAttr & AeonGUI::SkiaCanvas::GetStrokeColor ( ) const
finalvirtual

Get the current stroke color.

Returns
Reference to the current stroke color.

Implements AeonGUI::Canvas.

◆ GetStrokeOpacity()

double AeonGUI::SkiaCanvas::GetStrokeOpacity ( ) const
finalvirtual

Get the current stroke opacity.

Returns
Opacity in [0.0, 1.0].

Implements AeonGUI::Canvas.

◆ GetStrokeWidth()

double AeonGUI::SkiaCanvas::GetStrokeWidth ( ) const
finalvirtual

Get the current stroke width.

Returns
Stroke width in user units.

Implements AeonGUI::Canvas.

◆ GetWidth()

size_t AeonGUI::SkiaCanvas::GetWidth ( ) const
finalvirtual

Get the width of the canvas in pixels.

Returns
Width in pixels.

Implements AeonGUI::Canvas.

◆ MeasureText()

double AeonGUI::SkiaCanvas::MeasureText ( const std::string & aText,
const std::string & aFontFamily,
double aFontSize,
int aFontWeight,
int aFontStyle ) const
finalvirtual

Measure the width of text with the given font parameters.

Parameters
aTextThe UTF-8 text string to measure.
aFontFamilyFont family name.
aFontSizeFont size in CSS pixels.
aFontWeightCSS font weight.
aFontStyleFont style (0=normal, 1=italic, 2=oblique).
Returns
The logical width in CSS pixels.

Implements AeonGUI::Canvas.

◆ PickAtPoint()

uint8_t AeonGUI::SkiaCanvas::PickAtPoint ( double aX,
double aY ) const
finalvirtual

Read the pick ID at the given viewport coordinates.

Parameters
aXX coordinate in viewport pixels.
aYY coordinate in viewport pixels.
Returns
Pick ID at that pixel, or 0 if empty / out of bounds.

Implements AeonGUI::Canvas.

◆ PopGroup()

void AeonGUI::SkiaCanvas::PopGroup ( )
finalvirtual

End an offscreen group and composite back.

Pops the group pushed by PushGroup() and paints it back to the underlying surface.

Implements AeonGUI::Canvas.

◆ PushGroup()

void AeonGUI::SkiaCanvas::PushGroup ( )
finalvirtual

Begin an offscreen group for filter/compositing.

All subsequent drawing is redirected to a temporary surface. Call PopGroup() to retrieve and composite the result.

Implements AeonGUI::Canvas.

◆ ResetPick()

void AeonGUI::SkiaCanvas::ResetPick ( )
finalvirtual

Clear the pick buffer and reset for a new frame.

Implements AeonGUI::Canvas.

◆ ResizeViewport()

void AeonGUI::SkiaCanvas::ResizeViewport ( uint32_t aWidth,
uint32_t aHeight )
finalvirtual

Resize the rendering viewport.

Parameters
aWidthNew width in pixels.
aHeightNew height in pixels.

Implements AeonGUI::Canvas.

◆ Restore()

void AeonGUI::SkiaCanvas::Restore ( )
finalvirtual

Restore the previously saved graphics state.

Implements AeonGUI::Canvas.

◆ Save()

void AeonGUI::SkiaCanvas::Save ( )
finalvirtual

Save the current graphics state (transform, clipping, etc.).

Implements AeonGUI::Canvas.

◆ SetClipRect()

void AeonGUI::SkiaCanvas::SetClipRect ( double aX,
double aY,
double aWidth,
double aHeight )
finalvirtual

Set a device-space clip rectangle on both render and pick surfaces.

Must be called between Save() and Restore().

Parameters
aXX of clip rect (device pixels).
aYY of clip rect (device pixels).
aWidthWidth (device pixels).
aHeightHeight (device pixels).

Implements AeonGUI::Canvas.

◆ SetFillColor()

void AeonGUI::SkiaCanvas::SetFillColor ( const ColorAttr & aColor)
finalvirtual

Set the fill color.

Parameters
aColorThe fill color to set.

Implements AeonGUI::Canvas.

◆ SetFillOpacity()

void AeonGUI::SkiaCanvas::SetFillOpacity ( double aWidth)
finalvirtual

Set the fill opacity.

Parameters
aWidthOpacity value in the range [0.0, 1.0].

Implements AeonGUI::Canvas.

◆ SetOpacity()

void AeonGUI::SkiaCanvas::SetOpacity ( double aWidth)
finalvirtual

Set the global opacity.

Parameters
aWidthOpacity value in the range [0.0, 1.0].

Implements AeonGUI::Canvas.

◆ SetStrokeColor()

void AeonGUI::SkiaCanvas::SetStrokeColor ( const ColorAttr & aColor)
finalvirtual

Set the stroke color.

Parameters
aColorThe stroke color to set.

Implements AeonGUI::Canvas.

◆ SetStrokeOpacity()

void AeonGUI::SkiaCanvas::SetStrokeOpacity ( double aWidth)
finalvirtual

Set the stroke opacity.

Parameters
aWidthOpacity value in the range [0.0, 1.0].

Implements AeonGUI::Canvas.

◆ SetStrokeWidth()

void AeonGUI::SkiaCanvas::SetStrokeWidth ( double aWidth)
finalvirtual

Set the stroke width.

Parameters
aWidthThe stroke width in user units.

Implements AeonGUI::Canvas.

◆ SetTransform()

void AeonGUI::SkiaCanvas::SetTransform ( const Matrix2x3 & aMatrix)
finalvirtual

Replace the current transformation matrix.

Parameters
aMatrixThe new 2x3 transformation matrix.

Implements AeonGUI::Canvas.

◆ SetViewBox()

void AeonGUI::SkiaCanvas::SetViewBox ( const ViewBox & aViewBox,
const PreserveAspectRatio & aPreserveAspectRatio )
finalvirtual

Set the SVG viewBox and preserveAspectRatio.

Parameters
aViewBoxThe viewBox rectangle.
aPreserveAspectRatioHow to align and scale.

Implements AeonGUI::Canvas.

◆ Transform()

void AeonGUI::SkiaCanvas::Transform ( const Matrix2x3 & aMatrix)
finalvirtual

Pre-multiply the current transformation matrix.

Parameters
aMatrixThe matrix to concatenate.

Implements AeonGUI::Canvas.


The documentation for this class was generated from the following files:
  • /d/a/AeonGUI/AeonGUI/include/aeongui/SkiaCanvas.hpp
  • /d/a/AeonGUI/AeonGUI/core/SkiaCanvas.cpp