Flutter Engine
The Flutter Engine
skpath_bridge.h
Go to the documentation of this file.
1// Copyright 2023 Google LLC
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3#ifndef SkPathBridge_DEFINED
4#define SkPathBridge_DEFINED
5
6#include <cstddef>
7#include <cstdint>
8
9namespace fontations_ffi {
10
11/** C++ pure virtual interface type, exposed to Rust side to be able to write
12 * from Skrifa path output functions to an SkPath type to capture and convert a
13 * glyph path. */
15public:
16 virtual ~PathWrapper() = default;
17 virtual void move_to(float x, float y) = 0;
18 virtual void line_to(float x, float y) = 0;
19 virtual void quad_to(float cx0, float cy0, float x, float y) = 0;
20 virtual void curve_to(float cx0, float cy0, float cx1, float cy1, float x, float y) = 0;
21 virtual void close() = 0;
22};
23
24/** C++ pure virtual interface type, exposed to Rust side to be able to write
25 * out variation design parameters to the caller-side allocated
26 * SkFontParameters::Variation::Axis. A direct cast or mapping between a shared
27 * C++/Rust struct and a Skia side struct is not possible because the
28 * hidden-axis flag is private on SkFontParameters::Variation::Axis. */
30public:
31 virtual ~AxisWrapper() = default;
32 virtual bool populate_axis(
33 size_t i, uint32_t axisTag, float min, float def, float max, bool hidden) = 0;
34 virtual size_t size() const = 0;
35};
36
37struct ColorStop;
38struct BridgeColorStops;
39struct Transform;
40struct FillLinearParams;
41struct FillRadialParams;
42struct FillSweepParams;
43
44/** C++ pure virtual interface, exposed to Rust side for receiving COLRv0/COLRv1 drawing callback
45 * matching Skrifa's ColorPainter trait. */
47public:
48 virtual ~ColorPainterWrapper() = default;
49 virtual void push_transform(const Transform& transform) = 0;
50 virtual void pop_transform() = 0;
51 virtual void push_clip_glyph(uint16_t glyph_id) = 0;
52 virtual void push_clip_rectangle(float x_min, float y_min, float x_max, float y_max) = 0;
53 virtual void pop_clip() = 0;
54
55 // Paint*Gradient equivalents:
56 virtual void fill_solid(uint16_t palette_index, float alpha) = 0;
57 virtual void fill_linear(const FillLinearParams& fill_linear_params,
58 BridgeColorStops& stops,
59 uint8_t extend_mode) = 0;
60 virtual void fill_radial(const FillRadialParams& fill_radial_params,
61 BridgeColorStops& stops,
62 uint8_t extend_mode) = 0;
63 virtual void fill_sweep(const FillSweepParams&,
64 BridgeColorStops& stops,
65 uint8_t extend_mode) = 0;
66
67 // Optimized calls that allow a SkCanvas::drawPath() call.
68 virtual void fill_glyph_solid(uint16_t glyph_id, uint16_t palette_index, float alpha) = 0;
69 virtual void fill_glyph_radial(uint16_t glyph_id,
71 const fontations_ffi::FillRadialParams& fill_radial_params,
72 fontations_ffi::BridgeColorStops& stops,
73 uint8_t) = 0;
74 virtual void fill_glyph_linear(uint16_t glyph_id,
76 const fontations_ffi::FillLinearParams& fill_linear_params,
77 fontations_ffi::BridgeColorStops& stops,
78 uint8_t) = 0;
79 virtual void fill_glyph_sweep(uint16_t glyph_id,
81 const fontations_ffi::FillSweepParams& fill_sweep_params,
82 fontations_ffi::BridgeColorStops& stops,
83 uint8_t) = 0;
84
85 virtual void push_layer(uint8_t colrV1CompositeMode) = 0;
86 virtual void pop_layer() = 0;
87};
88
89} // namespace fontations_ffi
90
91#endif
virtual size_t size() const =0
virtual bool populate_axis(size_t i, uint32_t axisTag, float min, float def, float max, bool hidden)=0
virtual ~AxisWrapper()=default
virtual void push_layer(uint8_t colrV1CompositeMode)=0
virtual ~ColorPainterWrapper()=default
virtual void push_clip_glyph(uint16_t glyph_id)=0
virtual void fill_linear(const FillLinearParams &fill_linear_params, BridgeColorStops &stops, uint8_t extend_mode)=0
virtual void fill_glyph_radial(uint16_t glyph_id, const fontations_ffi::Transform &transform, const fontations_ffi::FillRadialParams &fill_radial_params, fontations_ffi::BridgeColorStops &stops, uint8_t)=0
virtual void fill_glyph_linear(uint16_t glyph_id, const fontations_ffi::Transform &transform, const fontations_ffi::FillLinearParams &fill_linear_params, fontations_ffi::BridgeColorStops &stops, uint8_t)=0
virtual void fill_sweep(const FillSweepParams &, BridgeColorStops &stops, uint8_t extend_mode)=0
virtual void push_transform(const Transform &transform)=0
virtual void fill_radial(const FillRadialParams &fill_radial_params, BridgeColorStops &stops, uint8_t extend_mode)=0
virtual void fill_glyph_solid(uint16_t glyph_id, uint16_t palette_index, float alpha)=0
virtual void push_clip_rectangle(float x_min, float y_min, float x_max, float y_max)=0
virtual void fill_glyph_sweep(uint16_t glyph_id, const fontations_ffi::Transform &transform, const fontations_ffi::FillSweepParams &fill_sweep_params, fontations_ffi::BridgeColorStops &stops, uint8_t)=0
virtual void fill_solid(uint16_t palette_index, float alpha)=0
virtual void line_to(float x, float y)=0
virtual void curve_to(float cx0, float cy0, float cx1, float cy1, float x, float y)=0
virtual ~PathWrapper()=default
virtual void quad_to(float cx0, float cy0, float x, float y)=0
virtual void move_to(float x, float y)=0
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48
double y
double x
const uint32_t extend_mode[]
Definition: colrv1.cpp:203
skgpu::graphite::Transform Transform
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition: p3.cpp:47