Flutter Impeller
impeller.hpp
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_IMPELLER_TOOLKIT_INTEROP_IMPELLER_HPP_
6 #define FLUTTER_IMPELLER_TOOLKIT_INTEROP_IMPELLER_HPP_
7 
8 #include <functional>
9 #include <memory>
10 #include <string>
11 #include <string_view>
12 #include <utility>
13 
14 #include "impeller.h"
15 
16 //------------------------------------------------------------------------------
17 /// A C++ 17 wrapper to the C Impeller API. This is a convenience wrapper for
18 /// the C++ API and only depends on standard libc++ utilities in addition to
19 /// impeller.h
20 ///
21 
22 #ifndef IMPELLER_HPP_NAMESPACE
23 #define IMPELLER_HPP_NAMESPACE impeller::hpp
24 #endif // IMPELLER_HPP_NAMESPACE
25 
26 // Tripping this assertion means that the C++ wrapper needs to be updated to
27 // account for impeller.h changes as necessary.
28 static_assert(IMPELLER_VERSION == IMPELLER_MAKE_VERSION(1, 1, 2, 0),
29  "C++ bindings must be for the same version as the C API.");
30 
32 
33 template <class T>
34 struct Proc {
35  using FunctionType = T;
36 
37  const char* name = nullptr;
38 
39  FunctionType* function = nullptr;
40 
41  template <class... Args>
42  auto operator()(Args&&... args) const {
43  return function(std::forward<Args>(args)...);
44  }
45 };
46 
47 #define IMPELLER_HPP_EACH_PROC(PROC) \
48  PROC(ImpellerColorFilterCreateBlendNew) \
49  PROC(ImpellerColorFilterCreateColorMatrixNew) \
50  PROC(ImpellerColorFilterRelease) \
51  PROC(ImpellerColorFilterRetain) \
52  PROC(ImpellerColorSourceCreateConicalGradientNew) \
53  PROC(ImpellerColorSourceCreateImageNew) \
54  PROC(ImpellerColorSourceCreateLinearGradientNew) \
55  PROC(ImpellerColorSourceCreateRadialGradientNew) \
56  PROC(ImpellerColorSourceCreateSweepGradientNew) \
57  PROC(ImpellerColorSourceRelease) \
58  PROC(ImpellerColorSourceRetain) \
59  PROC(ImpellerContextCreateOpenGLESNew) \
60  PROC(ImpellerContextRelease) \
61  PROC(ImpellerContextRetain) \
62  PROC(ImpellerDisplayListBuilderClipOval) \
63  PROC(ImpellerDisplayListBuilderClipPath) \
64  PROC(ImpellerDisplayListBuilderClipRect) \
65  PROC(ImpellerDisplayListBuilderClipRoundedRect) \
66  PROC(ImpellerDisplayListBuilderCreateDisplayListNew) \
67  PROC(ImpellerDisplayListBuilderDrawDashedLine) \
68  PROC(ImpellerDisplayListBuilderDrawDisplayList) \
69  PROC(ImpellerDisplayListBuilderDrawLine) \
70  PROC(ImpellerDisplayListBuilderDrawOval) \
71  PROC(ImpellerDisplayListBuilderDrawPaint) \
72  PROC(ImpellerDisplayListBuilderDrawParagraph) \
73  PROC(ImpellerDisplayListBuilderDrawPath) \
74  PROC(ImpellerDisplayListBuilderDrawRect) \
75  PROC(ImpellerDisplayListBuilderDrawRoundedRect) \
76  PROC(ImpellerDisplayListBuilderDrawRoundedRectDifference) \
77  PROC(ImpellerDisplayListBuilderDrawTexture) \
78  PROC(ImpellerDisplayListBuilderDrawTextureRect) \
79  PROC(ImpellerDisplayListBuilderGetSaveCount) \
80  PROC(ImpellerDisplayListBuilderGetTransform) \
81  PROC(ImpellerDisplayListBuilderNew) \
82  PROC(ImpellerDisplayListBuilderRelease) \
83  PROC(ImpellerDisplayListBuilderResetTransform) \
84  PROC(ImpellerDisplayListBuilderRestore) \
85  PROC(ImpellerDisplayListBuilderRestoreToCount) \
86  PROC(ImpellerDisplayListBuilderRetain) \
87  PROC(ImpellerDisplayListBuilderRotate) \
88  PROC(ImpellerDisplayListBuilderSave) \
89  PROC(ImpellerDisplayListBuilderSaveLayer) \
90  PROC(ImpellerDisplayListBuilderScale) \
91  PROC(ImpellerDisplayListBuilderSetTransform) \
92  PROC(ImpellerDisplayListBuilderTransform) \
93  PROC(ImpellerDisplayListBuilderTranslate) \
94  PROC(ImpellerDisplayListRelease) \
95  PROC(ImpellerDisplayListRetain) \
96  PROC(ImpellerGetVersion) \
97  PROC(ImpellerImageFilterCreateBlurNew) \
98  PROC(ImpellerImageFilterCreateComposeNew) \
99  PROC(ImpellerImageFilterCreateDilateNew) \
100  PROC(ImpellerImageFilterCreateErodeNew) \
101  PROC(ImpellerImageFilterCreateMatrixNew) \
102  PROC(ImpellerImageFilterRelease) \
103  PROC(ImpellerImageFilterRetain) \
104  PROC(ImpellerMaskFilterCreateBlurNew) \
105  PROC(ImpellerMaskFilterRelease) \
106  PROC(ImpellerMaskFilterRetain) \
107  PROC(ImpellerPaintNew) \
108  PROC(ImpellerPaintRelease) \
109  PROC(ImpellerPaintRetain) \
110  PROC(ImpellerPaintSetBlendMode) \
111  PROC(ImpellerPaintSetColor) \
112  PROC(ImpellerPaintSetColorFilter) \
113  PROC(ImpellerPaintSetColorSource) \
114  PROC(ImpellerPaintSetDrawStyle) \
115  PROC(ImpellerPaintSetImageFilter) \
116  PROC(ImpellerPaintSetMaskFilter) \
117  PROC(ImpellerPaintSetStrokeCap) \
118  PROC(ImpellerPaintSetStrokeJoin) \
119  PROC(ImpellerPaintSetStrokeMiter) \
120  PROC(ImpellerPaintSetStrokeWidth) \
121  PROC(ImpellerParagraphBuilderAddText) \
122  PROC(ImpellerParagraphBuilderBuildParagraphNew) \
123  PROC(ImpellerParagraphBuilderNew) \
124  PROC(ImpellerParagraphBuilderPopStyle) \
125  PROC(ImpellerParagraphBuilderPushStyle) \
126  PROC(ImpellerParagraphBuilderRelease) \
127  PROC(ImpellerParagraphBuilderRetain) \
128  PROC(ImpellerParagraphGetAlphabeticBaseline) \
129  PROC(ImpellerParagraphGetHeight) \
130  PROC(ImpellerParagraphGetIdeographicBaseline) \
131  PROC(ImpellerParagraphGetLineCount) \
132  PROC(ImpellerParagraphGetLongestLineWidth) \
133  PROC(ImpellerParagraphGetMaxIntrinsicWidth) \
134  PROC(ImpellerParagraphGetMaxWidth) \
135  PROC(ImpellerParagraphGetMinIntrinsicWidth) \
136  PROC(ImpellerParagraphRelease) \
137  PROC(ImpellerParagraphRetain) \
138  PROC(ImpellerParagraphStyleNew) \
139  PROC(ImpellerParagraphStyleRelease) \
140  PROC(ImpellerParagraphStyleRetain) \
141  PROC(ImpellerParagraphStyleSetBackground) \
142  PROC(ImpellerParagraphStyleSetFontFamily) \
143  PROC(ImpellerParagraphStyleSetFontSize) \
144  PROC(ImpellerParagraphStyleSetFontStyle) \
145  PROC(ImpellerParagraphStyleSetFontWeight) \
146  PROC(ImpellerParagraphStyleSetForeground) \
147  PROC(ImpellerParagraphStyleSetHeight) \
148  PROC(ImpellerParagraphStyleSetLocale) \
149  PROC(ImpellerParagraphStyleSetMaxLines) \
150  PROC(ImpellerParagraphStyleSetTextAlignment) \
151  PROC(ImpellerParagraphStyleSetTextDirection) \
152  PROC(ImpellerPathBuilderAddArc) \
153  PROC(ImpellerPathBuilderAddOval) \
154  PROC(ImpellerPathBuilderAddRect) \
155  PROC(ImpellerPathBuilderAddRoundedRect) \
156  PROC(ImpellerPathBuilderClose) \
157  PROC(ImpellerPathBuilderCopyPathNew) \
158  PROC(ImpellerPathBuilderCubicCurveTo) \
159  PROC(ImpellerPathBuilderLineTo) \
160  PROC(ImpellerPathBuilderMoveTo) \
161  PROC(ImpellerPathBuilderNew) \
162  PROC(ImpellerPathBuilderQuadraticCurveTo) \
163  PROC(ImpellerPathBuilderRelease) \
164  PROC(ImpellerPathBuilderRetain) \
165  PROC(ImpellerPathBuilderTakePathNew) \
166  PROC(ImpellerPathRelease) \
167  PROC(ImpellerPathRetain) \
168  PROC(ImpellerSurfaceCreateWrappedFBONew) \
169  PROC(ImpellerSurfaceDrawDisplayList) \
170  PROC(ImpellerSurfaceRelease) \
171  PROC(ImpellerSurfaceRetain) \
172  PROC(ImpellerTextureCreateWithContentsNew) \
173  PROC(ImpellerTextureCreateWithOpenGLTextureHandleNew) \
174  PROC(ImpellerTextureGetOpenGLHandle) \
175  PROC(ImpellerTextureRelease) \
176  PROC(ImpellerTextureRetain) \
177  PROC(ImpellerTypographyContextNew) \
178  PROC(ImpellerTypographyContextRegisterFont) \
179  PROC(ImpellerTypographyContextRelease) \
180  PROC(ImpellerTypographyContextRetain)
181 
182 struct ProcTable {
184  const std::function<void*(const char* function_name)>& resolver) {
185 #define IMPELLER_HPP_PROC(proc) \
186  { \
187  proc.function = \
188  reinterpret_cast<decltype(proc.function)>(resolver(proc.name)); \
189  if (proc.function == nullptr) { \
190  return false; \
191  } \
192  }
194 #undef IMPELLER_HPP_PROC
195  return true;
196  }
197 
198 #define IMPELLER_HPP_PROC(name) Proc<decltype(name)> name = {#name, nullptr};
200 #undef IMPELLER_HPP_PROC
201 };
202 
203 extern ProcTable gGlobalProcTable;
204 
205 enum class AdoptTag {
206  kAdopt,
207 };
208 
209 template <class T, class Traits>
210 class Object {
211  public:
212  Object() = default;
213 
214  explicit Object(T object) { Reset(object); }
215 
216  Object(T object, AdoptTag) : object_(object) {}
217 
218  ~Object() { Reset(); }
219 
220  Object(Object&& other) { std::swap(object_, other.object_); }
221 
222  Object(const Object& other) { Reset(other.Get()); }
223 
224  Object& operator=(Object&& other) {
225  std::swap(object_, other.object_);
226  return *this;
227  }
228 
229  Object& operator=(const Object& other) {
230  Reset(other.Get());
231  return *this;
232  }
233 
234  T Get() const { return object_; }
235 
236  explicit operator bool() const { return object_ != nullptr; }
237 
238  private:
239  T object_ = nullptr;
240 
241  void Reset(T other = nullptr) {
242  if (object_ == other) {
243  return;
244  }
245  if (object_) {
246  Traits::Release(object_);
247  object_ = nullptr;
248  }
249  if (other) {
250  Traits::Retain(other);
251  object_ = other;
252  }
253  }
254 
255  [[nodiscard]] T Leak() {
256  T result = object_;
257  object_ = nullptr;
258  return result;
259  }
260 };
261 
262 #define IMPELLER_HPP_DEFINE_TRAITS(object) \
263  struct object##Traits { \
264  static void Retain(object ctx) { \
265  gGlobalProcTable.object##Retain(ctx); \
266  } \
267  static void Release(object ctx) { \
268  gGlobalProcTable.object##Release(ctx); \
269  } \
270  };
271 
272 IMPELLER_HPP_DEFINE_TRAITS(ImpellerColorFilter);
273 IMPELLER_HPP_DEFINE_TRAITS(ImpellerColorSource);
274 IMPELLER_HPP_DEFINE_TRAITS(ImpellerContext);
275 IMPELLER_HPP_DEFINE_TRAITS(ImpellerDisplayList);
276 IMPELLER_HPP_DEFINE_TRAITS(ImpellerDisplayListBuilder);
277 IMPELLER_HPP_DEFINE_TRAITS(ImpellerImageFilter);
278 IMPELLER_HPP_DEFINE_TRAITS(ImpellerMaskFilter);
280 IMPELLER_HPP_DEFINE_TRAITS(ImpellerParagraph);
281 IMPELLER_HPP_DEFINE_TRAITS(ImpellerParagraphBuilder);
282 IMPELLER_HPP_DEFINE_TRAITS(ImpellerParagraphStyle);
284 IMPELLER_HPP_DEFINE_TRAITS(ImpellerPathBuilder);
285 IMPELLER_HPP_DEFINE_TRAITS(ImpellerSurface);
286 IMPELLER_HPP_DEFINE_TRAITS(ImpellerTexture);
287 IMPELLER_HPP_DEFINE_TRAITS(ImpellerTypographyContext);
288 
289 #undef IMPELLER_HPP_DEFINE_TRAITS
290 
291 class Mapping final {
292  public:
293  Mapping(const uint8_t* mapping,
294  size_t size,
295  std::function<void()> release_callback)
296  : mapping_(mapping),
297  size_(size),
298  release_callback_(std::move(release_callback)) {}
299 
300  const uint8_t* GetMapping() const { return mapping_; }
301 
302  size_t GetSize() const { return size_; }
303 
304  private:
305  const uint8_t* mapping_ = nullptr;
306  size_t size_ = 0u;
307  std::function<void()> release_callback_;
308 };
309 
310 //------------------------------------------------------------------------------
311 /// @see ImpellerContext
312 ///
313 class Context final : public Object<ImpellerContext, ImpellerContextTraits> {
314  public:
315  Context(ImpellerContext context, AdoptTag tag) : Object(context, tag) {}
316 
317  //----------------------------------------------------------------------------
318  /// @see ImpellerContextCreateOpenGLESNew
319  ///
321  const std::function<void*(const char*)>& gl_proc_address_resolver) {
322  struct UserData {
323  std::function<void*(const char*)> resolver;
324  };
325  UserData user_data;
326  user_data.resolver = gl_proc_address_resolver;
327  ImpellerProcAddressCallback callback = [](const char* proc_name,
328  void* user_data) -> void* {
329  return reinterpret_cast<UserData*>(user_data)->resolver(proc_name);
330  };
331  return Context(
332  gGlobalProcTable.ImpellerContextCreateOpenGLESNew(IMPELLER_VERSION, //
333  callback, //
334  &user_data //
335  ),
337  }
338 };
339 
340 //------------------------------------------------------------------------------
341 /// @see ImpellerTexture
342 ///
343 class Texture final : public Object<ImpellerTexture, ImpellerTextureTraits> {
344  public:
345  Texture(ImpellerTexture texture, AdoptTag adopt) : Object(texture, adopt) {}
346 
347  //----------------------------------------------------------------------------
348  /// @see ImpellerTextureCreateWithContentsNew
349  ///
350  static Texture WithContents(const Context& context,
351  const ImpellerTextureDescriptor& descriptor,
352  std::unique_ptr<Mapping> mapping = nullptr) {
353  if (mapping == nullptr) {
354  mapping = std::make_unique<Mapping>(nullptr, 0u, nullptr);
355  }
356  ImpellerMapping c_mapping = {};
357  c_mapping.data = mapping->GetMapping();
358  c_mapping.length = mapping->GetSize();
359  c_mapping.on_release = [](void* user_data) -> void {
360  delete reinterpret_cast<Mapping*>(user_data);
361  };
362  return Texture(gGlobalProcTable.ImpellerTextureCreateWithContentsNew(
363  context.Get(), //
364  &descriptor, //
365  &c_mapping, //
366  mapping.release() //
367  ),
369  }
370 
371  //----------------------------------------------------------------------------
372  /// @see ImpellerTextureCreateWithOpenGLTextureHandleNew
373  ///
374  static Texture WithOpenGLTexture(const Context& context,
375  const ImpellerTextureDescriptor& descriptor,
376  uint64_t handle) {
377  return Texture(
378  gGlobalProcTable.ImpellerTextureCreateWithOpenGLTextureHandleNew(
379  context.Get(), //
380  &descriptor, //
381  handle //
382  ),
384  }
385 
386  uint64_t GetOpenGLHandle() const {
387  return gGlobalProcTable.ImpellerTextureGetOpenGLHandle(Get());
388  }
389 };
390 
391 //------------------------------------------------------------------------------
392 /// @see ImpellerColorFilter
393 ///
394 class ColorFilter final
395  : public Object<ImpellerColorFilter, ImpellerColorFilterTraits> {
396  public:
397  ColorFilter(ImpellerColorFilter filter, AdoptTag tag) : Object(filter, tag) {}
398 
399  //----------------------------------------------------------------------------
400  /// @see ImpellerColorFilterCreateBlendNew
401  ///
402  static ColorFilter Blend(const ImpellerColor& color, ImpellerBlendMode mode) {
403  return ColorFilter(
404  gGlobalProcTable.ImpellerColorFilterCreateBlendNew(&color, mode),
406  }
407 
408  //----------------------------------------------------------------------------
409  /// @see ImpellerColorFilterCreateColorMatrixNew
410  ///
411  static ColorFilter Matrix(const ImpellerColorMatrix& color_matrix) {
412  return ColorFilter(
413  gGlobalProcTable.ImpellerColorFilterCreateColorMatrixNew(&color_matrix),
415  }
416 };
417 
418 //------------------------------------------------------------------------------
419 /// @see ImpellerColorSource
420 ///
421 class ColorSource final
422  : public Object<ImpellerColorSource, ImpellerColorSourceTraits> {
423  public:
424  ColorSource(ImpellerColorSource source, AdoptTag tag) : Object(source, tag) {}
425 
426  //----------------------------------------------------------------------------
427  /// @see ImpellerColorSourceCreateConicalGradientNew
428  ///
430  const ImpellerPoint& start_center,
431  float start_radius,
432  const ImpellerPoint& end_center,
433  float end_radius,
434  uint32_t stop_count,
435  const ImpellerColor* colors,
436  const float* stops,
437  ImpellerTileMode tile_mode,
438  const ImpellerMatrix* transformation = nullptr) {
439  return ColorSource(
440  gGlobalProcTable.ImpellerColorSourceCreateConicalGradientNew(
441  &start_center, //
442  start_radius, //
443  &end_center, //
444  end_radius, //
445  stop_count, //
446  colors, //
447  stops, //
448  tile_mode, //
449  transformation //
450  ),
452  }
453 
454  //----------------------------------------------------------------------------
455  /// @see ImpellerColorSourceCreateImageNew
456  ///
457  static ColorSource Image(const Texture& image,
458  ImpellerTileMode horizontal_tile_mode,
459  ImpellerTileMode vertical_tile_mode,
460  ImpellerTextureSampling sampling,
461  const ImpellerMatrix* transformation = nullptr) {
462  return ColorSource(gGlobalProcTable.ImpellerColorSourceCreateImageNew(
463  image.Get(), //
464  horizontal_tile_mode, //
465  vertical_tile_mode, //
466  sampling, //
467  transformation //
468  ),
470  }
471 
472  //----------------------------------------------------------------------------
473  /// @see ImpellerColorSourceCreateLinearGradientNew
474  ///
476  const ImpellerPoint& start_point,
477  const ImpellerPoint& end_point,
478  uint32_t stop_count,
479  const ImpellerColor* colors,
480  const float* stops,
481  ImpellerTileMode tile_mode,
482  const ImpellerMatrix* transformation = nullptr) {
483  return ColorSource(
484  gGlobalProcTable.ImpellerColorSourceCreateLinearGradientNew(
485  &start_point,
486  &end_point, //
487  stop_count, //
488  colors, //
489  stops, //
490  tile_mode, //
491  transformation //
492  ),
494  }
495 
496  //----------------------------------------------------------------------------
497  /// @see ImpellerColorSourceCreateRadialGradientNew
498  ///
500  const ImpellerPoint& center,
501  float radius,
502  uint32_t stop_count,
503  const ImpellerColor* colors,
504  const float* stops,
505  ImpellerTileMode tile_mode,
506  const ImpellerMatrix* transformation = nullptr) {
507  return ColorSource(
508  gGlobalProcTable.ImpellerColorSourceCreateRadialGradientNew(
509  &center, //
510  radius, //
511  stop_count, //
512  colors, //
513  stops, //
514  tile_mode, //
515  transformation //
516  ),
518  }
519 
520  //----------------------------------------------------------------------------
521  /// @see ImpellerColorSourceCreateSweepGradientNew
522  ///
524  const ImpellerPoint& center,
525  float start,
526  float end,
527  uint32_t stop_count,
528  const ImpellerColor* colors,
529  const float* stops,
530  ImpellerTileMode tile_mode,
531  const ImpellerMatrix* transformation = nullptr) {
532  return ColorSource(
533  gGlobalProcTable.ImpellerColorSourceCreateSweepGradientNew(
534  &center, //
535  start, //
536  end, //
537  stop_count, //
538  colors, //
539  stops, //
540  tile_mode, //
541  transformation //
542  ),
544  }
545 };
546 
547 //------------------------------------------------------------------------------
548 /// @see ImpellerImageFilter
549 ///
550 class ImageFilter final
551  : public Object<ImpellerImageFilter, ImpellerImageFilterTraits> {
552  public:
553  ImageFilter(ImpellerImageFilter filter, AdoptTag tag) : Object(filter, tag) {}
554 
555  //----------------------------------------------------------------------------
556  /// @see ImpellerImageFilterCreateBlurNew
557  ///
558  static ImageFilter Blur(float x_sigma,
559  float y_sigma,
560  ImpellerTileMode tile_mode) {
561  return ImageFilter(gGlobalProcTable.ImpellerImageFilterCreateBlurNew(
562  x_sigma, y_sigma, tile_mode),
564  }
565 
566  //----------------------------------------------------------------------------
567  /// @see ImpellerImageFilterCreateComposeNew
568  ///
569  static ImageFilter Compose(const ImageFilter& outer,
570  const ImageFilter& inner) {
571  return ImageFilter(gGlobalProcTable.ImpellerImageFilterCreateComposeNew(
572  outer.Get(), inner.Get()),
574  }
575 
576  //----------------------------------------------------------------------------
577  /// @see ImpellerImageFilterCreateDilateNew
578  ///
579  static ImageFilter Dilate(float x_radius, float y_radius) {
580  return ImageFilter(
581  gGlobalProcTable.ImpellerImageFilterCreateDilateNew(x_radius, y_radius),
583  }
584 
585  //----------------------------------------------------------------------------
586  /// @see ImpellerImageFilterCreateErodeNew
587  ///
588  static ImageFilter Erode(float x_radius, float y_radius) {
589  return ImageFilter(
590  gGlobalProcTable.ImpellerImageFilterCreateErodeNew(x_radius, y_radius),
592  }
593 
594  //----------------------------------------------------------------------------
595  /// @see ImpellerImageFilterCreateMatrixNew
596  ///
597  static ImageFilter Matrix(const ImpellerMatrix& matrix,
598  ImpellerTextureSampling sampling) {
599  return ImageFilter(
600  gGlobalProcTable.ImpellerImageFilterCreateMatrixNew(&matrix, sampling),
602  }
603 };
604 
605 //------------------------------------------------------------------------------
606 /// @see ImpellerMaskFilter
607 ///
608 class MaskFilter final
609  : public Object<ImpellerMaskFilter, ImpellerMaskFilterTraits> {
610  public:
611  MaskFilter(ImpellerMaskFilter filter, AdoptTag tag) : Object(filter, tag) {}
612 
613  //----------------------------------------------------------------------------
614  /// @see ImpellerMaskFilterCreateBlurNew
615  ///
616  static MaskFilter Blur(ImpellerBlurStyle style, float sigma) {
617  return MaskFilter(
618  gGlobalProcTable.ImpellerMaskFilterCreateBlurNew(style, sigma),
620  }
621 };
622 
623 //------------------------------------------------------------------------------
624 /// @see ImpellerParagraph
625 ///
626 class Paragraph final
627  : public Object<ImpellerParagraph, ImpellerParagraphTraits> {
628  public:
629  Paragraph(ImpellerParagraph paragraph, AdoptTag tag)
630  : Object(paragraph, AdoptTag::kAdopt) {}
631 
632  //----------------------------------------------------------------------------
633  /// @see ImpellerParagraphGetAlphabeticBaseline
634  ///
636  return gGlobalProcTable.ImpellerParagraphGetAlphabeticBaseline(Get());
637  }
638 
639  //----------------------------------------------------------------------------
640  /// @see ImpellerParagraphGetHeight
641  ///
642  float GetHeight() {
643  return gGlobalProcTable.ImpellerParagraphGetHeight(Get());
644  }
645 
646  //----------------------------------------------------------------------------
647  /// @see ImpellerParagraphGetIdeographicBaseline
648  ///
650  return gGlobalProcTable.ImpellerParagraphGetIdeographicBaseline(Get());
651  }
652 
653  //----------------------------------------------------------------------------
654  /// @see ImpellerParagraphGetLineCount
655  ///
656  uint32_t GetLineCount() {
657  return gGlobalProcTable.ImpellerParagraphGetLineCount(Get());
658  }
659 
660  //----------------------------------------------------------------------------
661  /// @see ImpellerParagraphGetLongestLineWidth
662  ///
664  return gGlobalProcTable.ImpellerParagraphGetLongestLineWidth(Get());
665  }
666 
667  //----------------------------------------------------------------------------
668  /// @see ImpellerParagraphGetMaxIntrinsicWidth
669  ///
671  return gGlobalProcTable.ImpellerParagraphGetMaxIntrinsicWidth(Get());
672  }
673 
674  //----------------------------------------------------------------------------
675  /// @see ImpellerParagraphGetMaxWidth
676  ///
677  float GetMaxWidth() {
678  return gGlobalProcTable.ImpellerParagraphGetMaxWidth(Get());
679  }
680 
681  //----------------------------------------------------------------------------
682  /// @see ImpellerParagraphGetMinIntrinsicWidth
683  ///
685  return gGlobalProcTable.ImpellerParagraphGetMinIntrinsicWidth(Get());
686  }
687 };
688 
689 //------------------------------------------------------------------------------
690 /// @see ImpellerPaint
691 ///
692 class Paint final : public Object<ImpellerPaint, ImpellerPaintTraits> {
693  public:
695 
696  //----------------------------------------------------------------------------
697  /// @see ImpellerPaintSetColor
698  ///
699  Paint& SetColor(const ImpellerColor& color) {
700  gGlobalProcTable.ImpellerPaintSetColor(Get(), &color);
701  return *this;
702  }
703 
704  //----------------------------------------------------------------------------
705  /// @see ImpellerPaintSetBlendMode
706  ///
708  gGlobalProcTable.ImpellerPaintSetBlendMode(Get(), mode);
709  return *this;
710  }
711 
712  //----------------------------------------------------------------------------
713  /// @see ImpellerPaintSetDrawStyle
714  ///
716  gGlobalProcTable.ImpellerPaintSetDrawStyle(Get(), style);
717  return *this;
718  }
719 
720  //----------------------------------------------------------------------------
721  /// @see ImpellerPaintSetStrokeCap
722  ///
724  gGlobalProcTable.ImpellerPaintSetStrokeCap(Get(), cap);
725  return *this;
726  }
727 
728  //----------------------------------------------------------------------------
729  /// @see ImpellerPaintSetStrokeJoin
730  ///
732  gGlobalProcTable.ImpellerPaintSetStrokeJoin(Get(), join);
733  return *this;
734  }
735 
736  //----------------------------------------------------------------------------
737  /// @see ImpellerPaintSetStrokeWidth
738  ///
739  Paint& SetStrokeWidth(float width) {
740  gGlobalProcTable.ImpellerPaintSetStrokeWidth(Get(), width);
741  return *this;
742  }
743 
744  //----------------------------------------------------------------------------
745  /// @see ImpellerPaintSetStrokeMiter
746  ///
747  Paint& SetStrokeMiter(float miter) {
748  gGlobalProcTable.ImpellerPaintSetStrokeMiter(Get(), miter);
749  return *this;
750  }
751 
752  //----------------------------------------------------------------------------
753  /// @see ImpellerPaintSetColorFilter
754  ///
755  Paint& SetColorFilter(const ColorFilter& filter) {
756  gGlobalProcTable.ImpellerPaintSetColorFilter(Get(), filter.Get());
757  return *this;
758  }
759 
760  //----------------------------------------------------------------------------
761  /// @see ImpellerPaintSetColorSource
762  ///
763  Paint& SetColorSource(const ColorSource& source) {
764  gGlobalProcTable.ImpellerPaintSetColorSource(Get(), source.Get());
765  return *this;
766  }
767 
768  //----------------------------------------------------------------------------
769  /// @see ImpellerPaintSetImageFilter
770  ///
771  Paint& SetImageFilter(const ImageFilter& filter) {
772  gGlobalProcTable.ImpellerPaintSetImageFilter(Get(), filter.Get());
773  return *this;
774  }
775 
776  //----------------------------------------------------------------------------
777  /// @see ImpellerPaintSetMaskFilter
778  ///
779  Paint& SetMaskFilter(const MaskFilter& filter) {
780  gGlobalProcTable.ImpellerPaintSetMaskFilter(Get(), filter.Get());
781  return *this;
782  }
783 };
784 
785 //------------------------------------------------------------------------------
786 /// @see ImpellerParagraphStyle
787 ///
788 class ParagraphStyle final
789  : public Object<ImpellerParagraphStyle, ImpellerParagraphStyleTraits> {
790  public:
793  }
794 
795  //----------------------------------------------------------------------------
796  /// @see ImpellerParagraphStyleSetBackground
797  ///
799  gGlobalProcTable.ImpellerParagraphStyleSetBackground(Get(), paint.Get());
800  return *this;
801  }
802 
803  //----------------------------------------------------------------------------
804  /// @see ImpellerParagraphStyleSetFontFamily
805  ///
806  ParagraphStyle& SetFontFamily(const char* family_name) {
807  gGlobalProcTable.ImpellerParagraphStyleSetFontFamily(Get(), family_name);
808  return *this;
809  }
810 
811  //----------------------------------------------------------------------------
812  /// @see ImpellerParagraphStyleSetFontSize
813  ///
815  gGlobalProcTable.ImpellerParagraphStyleSetFontSize(Get(), size);
816  return *this;
817  }
818 
819  //----------------------------------------------------------------------------
820  /// @see ImpellerParagraphStyleSetFontStyle
821  ///
823  gGlobalProcTable.ImpellerParagraphStyleSetFontStyle(Get(), style);
824  return *this;
825  }
826 
827  //----------------------------------------------------------------------------
828  /// @see ImpellerParagraphStyleSetFontWeight
829  ///
831  gGlobalProcTable.ImpellerParagraphStyleSetFontWeight(Get(), weight);
832  return *this;
833  }
834 
835  //----------------------------------------------------------------------------
836  /// @see ImpellerParagraphStyleSetForeground
837  ///
839  gGlobalProcTable.ImpellerParagraphStyleSetForeground(Get(), paint.Get());
840  return *this;
841  }
842 
843  //----------------------------------------------------------------------------
844  /// @see ImpellerParagraphStyleSetHeight
845  ///
846  ParagraphStyle& SetHeight(float height) {
847  gGlobalProcTable.ImpellerParagraphStyleSetHeight(Get(), height);
848  return *this;
849  }
850 
851  //----------------------------------------------------------------------------
852  /// @see ImpellerParagraphStyleSetLocale
853  ///
854  ParagraphStyle& SetLocale(const char* locale) {
855  gGlobalProcTable.ImpellerParagraphStyleSetLocale(Get(), locale);
856  return *this;
857  }
858 
859  //----------------------------------------------------------------------------
860  /// @see ImpellerParagraphStyleSetMaxLines
861  ///
862  ParagraphStyle& SetMaxLines(uint32_t max_lines) {
863  gGlobalProcTable.ImpellerParagraphStyleSetMaxLines(Get(), max_lines);
864  return *this;
865  }
866 
867  //----------------------------------------------------------------------------
868  /// @see ImpellerParagraphStyleSetTextAlignment
869  ///
871  gGlobalProcTable.ImpellerParagraphStyleSetTextAlignment(Get(), align);
872  return *this;
873  }
874 
875  //----------------------------------------------------------------------------
876  /// @see ImpellerParagraphStyleSetTextDirection
877  ///
879  gGlobalProcTable.ImpellerParagraphStyleSetTextDirection(Get(), direction);
880  return *this;
881  }
882 };
883 
884 //------------------------------------------------------------------------------
885 /// @see ImpellerTypographyContext
886 ///
887 class TypographyContext final : public Object<ImpellerTypographyContext,
888  ImpellerTypographyContextTraits> {
889  public:
892  AdoptTag::kAdopt) {}
893 
894  //----------------------------------------------------------------------------
895  /// @see ImpellerTypographyContextRegisterFont
896  ///
897  bool RegisterFont(std::unique_ptr<Mapping> mapping,
898  const char* optional_family_name_alias = nullptr) {
899  if (!mapping) {
900  return false;
901  }
902  ImpellerMapping c_mapping = {};
903  c_mapping.data = mapping->GetMapping();
904  c_mapping.length = mapping->GetSize();
905  c_mapping.on_release = [](void* user_data) {
906  delete reinterpret_cast<Mapping*>(user_data);
907  };
908  return gGlobalProcTable.ImpellerTypographyContextRegisterFont(
909  Get(), //
910  &c_mapping, //
911  mapping.release(), //
912  optional_family_name_alias //
913  );
914  }
915 };
916 
917 //------------------------------------------------------------------------------
918 /// @see ImpellerParagraphBuilder
919 ///
920 class ParagraphBuilder final
921  : public Object<ImpellerParagraphBuilder, ImpellerParagraphBuilderTraits> {
922  public:
923  explicit ParagraphBuilder(const TypographyContext& context)
925  AdoptTag::kAdopt) {}
926 
927  //----------------------------------------------------------------------------
928  /// @see ImpellerParagraphBuilderBuildParagraphNew
929  ///
930  Paragraph Build(float width) {
931  return Paragraph(
932  gGlobalProcTable.ImpellerParagraphBuilderBuildParagraphNew(Get(), //
933  width //
934  ),
936  }
937 
938  //----------------------------------------------------------------------------
939  /// @see ImpellerParagraphBuilderPushStyle
940  ///
942  gGlobalProcTable.ImpellerParagraphBuilderPushStyle(Get(), style.Get());
943  return *this;
944  }
945 
946  //----------------------------------------------------------------------------
947  /// @see ImpellerParagraphBuilderPopStyle
948  ///
950  gGlobalProcTable.ImpellerParagraphBuilderPopStyle(Get());
951  return *this;
952  }
953 
954  //----------------------------------------------------------------------------
955  /// @see ImpellerParagraphBuilderAddText
956  ///
957  ParagraphBuilder& AddText(const uint8_t* utf8_data, uint32_t length) {
958  gGlobalProcTable.ImpellerParagraphBuilderAddText(Get(), utf8_data, length);
959  return *this;
960  }
961 
962  //----------------------------------------------------------------------------
963  /// @see ImpellerParagraphBuilderAddText
964  ///
965  ParagraphBuilder& AddText(const std::string& string) {
966  return AddText(reinterpret_cast<const uint8_t*>(string.data()),
967  string.size());
968  }
969 
970  //----------------------------------------------------------------------------
971  /// @see ImpellerParagraphBuilderAddText
972  ///
973  ParagraphBuilder& AddText(const std::string_view& string) {
974  return AddText(reinterpret_cast<const uint8_t*>(string.data()),
975  string.size());
976  }
977 };
978 
979 //------------------------------------------------------------------------------
980 /// @see ImpellerPath
981 ///
982 class Path final : public Object<ImpellerPath, ImpellerPathTraits> {
983  public:
984  Path(ImpellerPath path, AdoptTag tag) : Object(path, tag) {}
985 };
986 
987 //------------------------------------------------------------------------------
988 /// @see ImpellerPathBuilder
989 ///
990 class PathBuilder final
991  : public Object<ImpellerPathBuilder, ImpellerPathBuilderTraits> {
992  public:
995 
996  //----------------------------------------------------------------------------
997  /// @see ImpellerPathBuilderCopyPathNew
998  ///
1001  return Path(gGlobalProcTable.ImpellerPathBuilderCopyPathNew(Get(), fill),
1003  }
1004 
1005  //----------------------------------------------------------------------------
1006  /// @see ImpellerPathBuilderTakePathNew
1007  ///
1010  return Path(gGlobalProcTable.ImpellerPathBuilderTakePathNew(Get(), fill),
1012  }
1013 
1014  //----------------------------------------------------------------------------
1015  /// @see ImpellerPathBuilderAddArc
1016  ///
1017  PathBuilder& AddArc(const ImpellerRect& oval_bounds,
1018  float start_angle_degrees,
1019  float end_angle_degrees) {
1020  gGlobalProcTable.ImpellerPathBuilderAddArc(Get(), //
1021  &oval_bounds, //
1022  start_angle_degrees, //
1023  end_angle_degrees //
1024  );
1025  return *this;
1026  }
1027 
1028  //----------------------------------------------------------------------------
1029  /// @see ImpellerPathBuilderAddOval
1030  ///
1031  PathBuilder& AddOval(const ImpellerRect& oval_bounds) {
1032  gGlobalProcTable.ImpellerPathBuilderAddOval(Get(), &oval_bounds);
1033  return *this;
1034  }
1035 
1036  //----------------------------------------------------------------------------
1037  /// @see ImpellerPathBuilderAddRect
1038  ///
1040  gGlobalProcTable.ImpellerPathBuilderAddRect(Get(), &rect);
1041  return *this;
1042  }
1043 
1044  //----------------------------------------------------------------------------
1045  /// @see ImpellerPathBuilderAddRoundedRect
1046  ///
1048  const ImpellerRoundingRadii& rounding_radii) {
1049  gGlobalProcTable.ImpellerPathBuilderAddRoundedRect(Get(), &rect,
1050  &rounding_radii);
1051  return *this;
1052  }
1053 
1054  //----------------------------------------------------------------------------
1055  /// @see ImpellerPathBuilderClose
1056  ///
1058  gGlobalProcTable.ImpellerPathBuilderClose(Get());
1059  return *this;
1060  }
1061 
1062  //----------------------------------------------------------------------------
1063  /// @see ImpellerPathBuilderCubicCurveTo
1064  ///
1065  PathBuilder& CubicCurveTo(const ImpellerPoint& control_point_1,
1066  const ImpellerPoint& control_point_2,
1067  const ImpellerPoint& end_point) {
1068  gGlobalProcTable.ImpellerPathBuilderCubicCurveTo(
1069  Get(), &control_point_1, &control_point_2, &end_point);
1070  return *this;
1071  }
1072 
1073  //----------------------------------------------------------------------------
1074  /// @see ImpellerPathBuilderLineTo
1075  ///
1076  PathBuilder& LineTo(const ImpellerPoint& location) {
1077  gGlobalProcTable.ImpellerPathBuilderLineTo(Get(), &location);
1078  return *this;
1079  }
1080 
1081  //----------------------------------------------------------------------------
1082  /// @see ImpellerPathBuilderMoveTo
1083  ///
1084  PathBuilder& MoveTo(const ImpellerPoint& location) {
1085  gGlobalProcTable.ImpellerPathBuilderMoveTo(Get(), &location);
1086  return *this;
1087  }
1088 
1089  //----------------------------------------------------------------------------
1090  /// @see ImpellerPathBuilderQuadraticCurveTo
1091  ///
1093  const ImpellerPoint& end_point) {
1094  gGlobalProcTable.ImpellerPathBuilderQuadraticCurveTo(Get(), &control_point,
1095  &end_point);
1096  return *this;
1097  }
1098 };
1099 
1100 //------------------------------------------------------------------------------
1101 /// @see ImpellerDisplayList
1102 ///
1103 class DisplayList final
1104  : public Object<ImpellerDisplayList, ImpellerDisplayListTraits> {
1105  public:
1106  DisplayList(ImpellerDisplayList display_list, AdoptTag tag)
1107  : Object(display_list, tag) {}
1108 };
1109 
1110 //------------------------------------------------------------------------------
1111 /// @see ImpellerSurface
1112 ///
1113 class Surface final : public Object<ImpellerSurface, ImpellerSurfaceTraits> {
1114  public:
1115  explicit Surface(ImpellerSurface surface) : Object(surface) {}
1116 
1117  Surface(ImpellerSurface surface, AdoptTag tag) : Object(surface, tag) {}
1118 
1119  //----------------------------------------------------------------------------
1120  /// @see ImpellerSurfaceCreateWrappedFBONew
1121  ///
1122  static Surface WrapFBO(const Context& context,
1123  uint64_t fbo,
1124  ImpellerPixelFormat format,
1125  const ImpellerISize& size) {
1126  return Surface(
1127  gGlobalProcTable.ImpellerSurfaceCreateWrappedFBONew(context.Get(), //
1128  fbo, //
1129  format, //
1130  &size //
1131  ),
1133  }
1134 
1135  //----------------------------------------------------------------------------
1136  /// @see ImpellerSurfaceDrawDisplayList
1137  ///
1138  bool Draw(const DisplayList& display_list) {
1139  return gGlobalProcTable.ImpellerSurfaceDrawDisplayList(Get(),
1140  display_list.Get());
1141  }
1142 };
1143 
1144 //------------------------------------------------------------------------------
1145 /// @see ImpellerDisplayListBuilder
1146 ///
1148  : public Object<ImpellerDisplayListBuilder,
1149  ImpellerDisplayListBuilderTraits> {
1150  public:
1151  //----------------------------------------------------------------------------
1152  /// @see ImpellerDisplayListBuilderNew
1153  ///
1154  explicit DisplayListBuilder(const ImpellerRect* cull_rect = nullptr)
1156  AdoptTag::kAdopt) {}
1157 
1158  //----------------------------------------------------------------------------
1159  /// @see ImpellerDisplayListBuilderCreateDisplayListNew
1160  ///
1162  return DisplayList(
1163  gGlobalProcTable.ImpellerDisplayListBuilderCreateDisplayListNew(Get()),
1165  }
1166 
1167  //----------------------------------------------------------------------------
1168  /// @see ImpellerDisplayListBuilderClipOval
1169  ///
1171  ImpellerClipOperation op) {
1172  gGlobalProcTable.ImpellerDisplayListBuilderClipOval(Get(), //
1173  &oval_bounds, //
1174  op);
1175  return *this;
1176  }
1177 
1178  //----------------------------------------------------------------------------
1179  /// @see ImpellerDisplayListBuilderClipPath
1180  ///
1182  gGlobalProcTable.ImpellerDisplayListBuilderClipPath(Get(), //
1183  path.Get(), //
1184  op);
1185  return *this;
1186  }
1187 
1188  //----------------------------------------------------------------------------
1189  /// @see ImpellerDisplayListBuilderClipRect
1190  ///
1192  ImpellerClipOperation op) {
1193  gGlobalProcTable.ImpellerDisplayListBuilderClipRect(Get(), //
1194  &rect, //
1195  op);
1196  return *this;
1197  }
1198 
1199  //----------------------------------------------------------------------------
1200  /// @see ImpellerDisplayListBuilderClipRoundedRect
1201  ///
1203  const ImpellerRoundingRadii& radii,
1204  ImpellerClipOperation op) {
1205  gGlobalProcTable.ImpellerDisplayListBuilderClipRoundedRect(Get(), //
1206  &rect, //
1207  &radii, //
1208  op //
1209  );
1210  return *this;
1211  }
1212 
1213  //----------------------------------------------------------------------------
1214  /// @see ImpellerDisplayListBuilderDrawDashedLine
1215  ///
1217  const ImpellerPoint& to,
1218  float on_length,
1219  float off_length,
1220  const Paint& paint) {
1221  gGlobalProcTable.ImpellerDisplayListBuilderDrawDashedLine(Get(), //
1222  &from, //
1223  &to, //
1224  on_length, //
1225  off_length, //
1226  paint.Get());
1227  return *this;
1228  }
1229 
1230  //----------------------------------------------------------------------------
1231  /// @see ImpellerDisplayListBuilderDrawDisplayList
1232  ///
1234  float opacity = 1.0f) {
1235  gGlobalProcTable.ImpellerDisplayListBuilderDrawDisplayList(
1236  Get(), display_list.Get(), opacity);
1237  return *this;
1238  }
1239 
1240  //----------------------------------------------------------------------------
1241  /// @see ImpellerDisplayListBuilderDrawLine
1242  ///
1244  const ImpellerPoint& to,
1245  const Paint& paint) {
1246  gGlobalProcTable.ImpellerDisplayListBuilderDrawLine(Get(), //
1247  &from, //
1248  &to, //
1249  paint.Get() //
1250  );
1251  return *this;
1252  }
1253 
1254  //----------------------------------------------------------------------------
1255  /// @see ImpellerDisplayListBuilderDrawOval
1256  ///
1258  const Paint& paint) {
1259  gGlobalProcTable.ImpellerDisplayListBuilderDrawOval(Get(), //
1260  &oval_bounds, //
1261  paint.Get() //
1262  );
1263  return *this;
1264  }
1265 
1266  //----------------------------------------------------------------------------
1267  /// @see ImpellerDisplayListBuilderDrawPaint
1268  ///
1270  gGlobalProcTable.ImpellerDisplayListBuilderDrawPaint(Get(), paint.Get());
1271  return *this;
1272  }
1273 
1274  //----------------------------------------------------------------------------
1275  /// @see ImpellerDisplayListBuilderDrawParagraph
1276  ///
1278  const ImpellerPoint& point) {
1279  gGlobalProcTable.ImpellerDisplayListBuilderDrawParagraph(
1280  Get(), paragraph.Get(), &point);
1281  return *this;
1282  }
1283 
1284  //----------------------------------------------------------------------------
1285  /// @see ImpellerDisplayListBuilderDrawPath
1286  ///
1287  DisplayListBuilder& DrawPath(const Path& path, const Paint& paint) {
1288  gGlobalProcTable.ImpellerDisplayListBuilderDrawPath(Get(), path.Get(),
1289  paint.Get());
1290  return *this;
1291  }
1292 
1293  //----------------------------------------------------------------------------
1294  /// @see ImpellerDisplayListBuilderDrawRect
1295  ///
1296  DisplayListBuilder& DrawRect(const ImpellerRect& rect, const Paint& paint) {
1297  gGlobalProcTable.ImpellerDisplayListBuilderDrawRect(Get(), &rect,
1298  paint.Get());
1299  return *this;
1300  }
1301 
1302  //----------------------------------------------------------------------------
1303  /// @see ImpellerDisplayListBuilderDrawRoundedRect
1304  ///
1306  const ImpellerRoundingRadii& radii,
1307  const Paint& paint) {
1308  gGlobalProcTable.ImpellerDisplayListBuilderDrawRoundedRect(Get(), //
1309  &rect, //
1310  &radii, //
1311  paint.Get());
1312  return *this;
1313  }
1314 
1315  //----------------------------------------------------------------------------
1316  /// @see ImpellerDisplayListBuilderDrawRoundedRectDifference
1317  ///
1319  const ImpellerRect& outer_rect,
1320  const ImpellerRoundingRadii& outer_radii,
1321  const ImpellerRect& inner_rect,
1322  const ImpellerRoundingRadii& inner_radii,
1323  const Paint& paint) {
1324  gGlobalProcTable.ImpellerDisplayListBuilderDrawRoundedRectDifference(
1325  Get(), //
1326  &outer_rect, //
1327  &outer_radii, //
1328  &inner_rect, //
1329  &inner_radii, //
1330  paint.Get());
1331  return *this;
1332  }
1333 
1334  //----------------------------------------------------------------------------
1335  /// @see ImpellerDisplayListBuilderDrawTexture
1336  ///
1338  const ImpellerPoint& point,
1339  ImpellerTextureSampling sampling,
1340  const Paint& paint) {
1341  gGlobalProcTable.ImpellerDisplayListBuilderDrawTexture(
1342  Get(), texture.Get(), &point, sampling, paint.Get());
1343  return *this;
1344  }
1345 
1346  //----------------------------------------------------------------------------
1347  /// @see ImpellerDisplayListBuilderDrawTextureRect
1348  ///
1350  const ImpellerRect& src_rect,
1351  const ImpellerRect& dst_rect,
1352  ImpellerTextureSampling sampling,
1353  const Paint& paint) {
1354  gGlobalProcTable.ImpellerDisplayListBuilderDrawTextureRect(
1355  Get(), texture.Get(), //
1356  &src_rect, //
1357  &dst_rect, //
1358  sampling, //
1359  paint.Get());
1360  return *this;
1361  }
1362 
1363  //----------------------------------------------------------------------------
1364  /// @see ImpellerDisplayListBuilderGetSaveCount
1365  ///
1366  uint32_t GetSaveCount() {
1367  return gGlobalProcTable.ImpellerDisplayListBuilderGetSaveCount(Get());
1368  }
1369 
1370  //----------------------------------------------------------------------------
1371  /// @see ImpellerDisplayListBuilderGetTransform
1372  ///
1374  ImpellerMatrix result;
1375  gGlobalProcTable.ImpellerDisplayListBuilderGetTransform(Get(), &result);
1376  return result;
1377  }
1378 
1379  //----------------------------------------------------------------------------
1380  /// @see ImpellerDisplayListBuilderResetTransform
1381  ///
1383  gGlobalProcTable.ImpellerDisplayListBuilderResetTransform(Get());
1384  return *this;
1385  }
1386 
1387  //----------------------------------------------------------------------------
1388  /// @see ImpellerDisplayListBuilderRestore
1389  ///
1391  gGlobalProcTable.ImpellerDisplayListBuilderRestore(Get());
1392  return *this;
1393  }
1394 
1395  //----------------------------------------------------------------------------
1396  /// @see ImpellerDisplayListBuilderRestoreToCount
1397  ///
1399  gGlobalProcTable.ImpellerDisplayListBuilderRestoreToCount(Get(), //
1400  count);
1401  return *this;
1402  }
1403 
1404  //----------------------------------------------------------------------------
1405  /// @see ImpellerDisplayListBuilderRotate
1406  ///
1407  DisplayListBuilder& Rotate(float angle_degrees) {
1408  gGlobalProcTable.ImpellerDisplayListBuilderRotate(Get(), //
1409  angle_degrees);
1410  return *this;
1411  }
1412 
1413  //----------------------------------------------------------------------------
1414  /// @see ImpellerDisplayListBuilderSave
1415  ///
1417  gGlobalProcTable.ImpellerDisplayListBuilderSave(Get());
1418  return *this;
1419  }
1420 
1421  //----------------------------------------------------------------------------
1422  /// @see ImpellerDisplayListBuilderSaveLayer
1423  ///
1425  const Paint* paint = nullptr,
1426  const ImageFilter* backdrop = nullptr) {
1427  gGlobalProcTable.ImpellerDisplayListBuilderSaveLayer(
1428  Get(), //
1429  &bounds, //
1430  paint ? paint->Get() : NULL, //
1431  backdrop ? backdrop->Get() : NULL //
1432  );
1433  return *this;
1434  }
1435 
1436  //----------------------------------------------------------------------------
1437  /// @see ImpellerDisplayListBuilderScale
1438  ///
1439  DisplayListBuilder& Scale(float x_scale, float y_scale) {
1440  gGlobalProcTable.ImpellerDisplayListBuilderScale(Get(), //
1441  x_scale, //
1442  y_scale);
1443  return *this;
1444  }
1445 
1446  //----------------------------------------------------------------------------
1447  /// @see ImpellerDisplayListBuilderSetTransform
1448  ///
1450  gGlobalProcTable.ImpellerDisplayListBuilderSetTransform(Get(), &transform);
1451  return *this;
1452  }
1453 
1454  //----------------------------------------------------------------------------
1455  /// @see ImpellerDisplayListBuilderTransform
1456  ///
1458  gGlobalProcTable.ImpellerDisplayListBuilderTransform(Get(), &transform);
1459  return *this;
1460  }
1461 
1462  //----------------------------------------------------------------------------
1463  /// @see ImpellerDisplayListBuilderTranslate
1464  ///
1465  DisplayListBuilder& Translate(float x_translation, float y_translation) {
1466  gGlobalProcTable.ImpellerDisplayListBuilderTranslate(Get(), //
1467  x_translation, //
1468  y_translation //
1469  );
1470  return *this;
1471  }
1472 };
1473 
1474 } // namespace IMPELLER_HPP_NAMESPACE
1475 
1476 #endif // FLUTTER_IMPELLER_TOOLKIT_INTEROP_IMPELLER_HPP_
static ColorFilter Blend(const ImpellerColor &color, ImpellerBlendMode mode)
Definition: impeller.hpp:402
static ColorFilter Matrix(const ImpellerColorMatrix &color_matrix)
Definition: impeller.hpp:411
ColorFilter(ImpellerColorFilter filter, AdoptTag tag)
Definition: impeller.hpp:397
ColorSource(ImpellerColorSource source, AdoptTag tag)
Definition: impeller.hpp:424
static ColorSource ConicalGradient(const ImpellerPoint &start_center, float start_radius, const ImpellerPoint &end_center, float end_radius, uint32_t stop_count, const ImpellerColor *colors, const float *stops, ImpellerTileMode tile_mode, const ImpellerMatrix *transformation=nullptr)
Definition: impeller.hpp:429
static ColorSource Image(const Texture &image, ImpellerTileMode horizontal_tile_mode, ImpellerTileMode vertical_tile_mode, ImpellerTextureSampling sampling, const ImpellerMatrix *transformation=nullptr)
Definition: impeller.hpp:457
static ColorSource SweepGradient(const ImpellerPoint &center, float start, float end, uint32_t stop_count, const ImpellerColor *colors, const float *stops, ImpellerTileMode tile_mode, const ImpellerMatrix *transformation=nullptr)
Definition: impeller.hpp:523
static ColorSource LinearGradient(const ImpellerPoint &start_point, const ImpellerPoint &end_point, uint32_t stop_count, const ImpellerColor *colors, const float *stops, ImpellerTileMode tile_mode, const ImpellerMatrix *transformation=nullptr)
Definition: impeller.hpp:475
static ColorSource RadialGradient(const ImpellerPoint &center, float radius, uint32_t stop_count, const ImpellerColor *colors, const float *stops, ImpellerTileMode tile_mode, const ImpellerMatrix *transformation=nullptr)
Definition: impeller.hpp:499
static Context OpenGLES(const std::function< void *(const char *)> &gl_proc_address_resolver)
Definition: impeller.hpp:320
Context(ImpellerContext context, AdoptTag tag)
Definition: impeller.hpp:315
DisplayListBuilder & Transform(const ImpellerMatrix &transform)
Definition: impeller.hpp:1457
DisplayListBuilder & DrawRoundedRect(const ImpellerRect &rect, const ImpellerRoundingRadii &radii, const Paint &paint)
Definition: impeller.hpp:1305
DisplayListBuilder & DrawLine(const ImpellerPoint &from, const ImpellerPoint &to, const Paint &paint)
Definition: impeller.hpp:1243
DisplayListBuilder & Scale(float x_scale, float y_scale)
Definition: impeller.hpp:1439
DisplayListBuilder & DrawRoundedRectDifference(const ImpellerRect &outer_rect, const ImpellerRoundingRadii &outer_radii, const ImpellerRect &inner_rect, const ImpellerRoundingRadii &inner_radii, const Paint &paint)
Definition: impeller.hpp:1318
DisplayListBuilder & Rotate(float angle_degrees)
Definition: impeller.hpp:1407
DisplayListBuilder & ClipRect(const ImpellerRect &rect, ImpellerClipOperation op)
Definition: impeller.hpp:1191
DisplayListBuilder & DrawRect(const ImpellerRect &rect, const Paint &paint)
Definition: impeller.hpp:1296
DisplayListBuilder & DrawTextureRect(const Texture &texture, const ImpellerRect &src_rect, const ImpellerRect &dst_rect, ImpellerTextureSampling sampling, const Paint &paint)
Definition: impeller.hpp:1349
DisplayListBuilder & DrawParagraph(const Paragraph &paragraph, const ImpellerPoint &point)
Definition: impeller.hpp:1277
DisplayListBuilder & DrawPaint(const Paint &paint)
Definition: impeller.hpp:1269
DisplayListBuilder & DrawDashedLine(const ImpellerPoint &from, const ImpellerPoint &to, float on_length, float off_length, const Paint &paint)
Definition: impeller.hpp:1216
DisplayListBuilder & DrawPath(const Path &path, const Paint &paint)
Definition: impeller.hpp:1287
DisplayListBuilder & ClipRoundedRect(const ImpellerRect &rect, const ImpellerRoundingRadii &radii, ImpellerClipOperation op)
Definition: impeller.hpp:1202
DisplayListBuilder & SaveLayer(const ImpellerRect &bounds, const Paint *paint=nullptr, const ImageFilter *backdrop=nullptr)
Definition: impeller.hpp:1424
DisplayListBuilder & SetTransform(const ImpellerMatrix &transform)
Definition: impeller.hpp:1449
DisplayListBuilder(const ImpellerRect *cull_rect=nullptr)
Definition: impeller.hpp:1154
DisplayListBuilder & RestoreToCount(uint32_t count)
Definition: impeller.hpp:1398
DisplayListBuilder & DrawOval(const ImpellerRect &oval_bounds, const Paint &paint)
Definition: impeller.hpp:1257
DisplayListBuilder & Translate(float x_translation, float y_translation)
Definition: impeller.hpp:1465
DisplayListBuilder & DrawTexture(const Texture &texture, const ImpellerPoint &point, ImpellerTextureSampling sampling, const Paint &paint)
Definition: impeller.hpp:1337
DisplayListBuilder & DrawDisplayList(const DisplayList &display_list, float opacity=1.0f)
Definition: impeller.hpp:1233
DisplayListBuilder & ClipPath(const Path &path, ImpellerClipOperation op)
Definition: impeller.hpp:1181
DisplayListBuilder & ClipOval(const ImpellerRect &oval_bounds, ImpellerClipOperation op)
Definition: impeller.hpp:1170
DisplayList(ImpellerDisplayList display_list, AdoptTag tag)
Definition: impeller.hpp:1106
static ImageFilter Compose(const ImageFilter &outer, const ImageFilter &inner)
Definition: impeller.hpp:569
static ImageFilter Dilate(float x_radius, float y_radius)
Definition: impeller.hpp:579
static ImageFilter Matrix(const ImpellerMatrix &matrix, ImpellerTextureSampling sampling)
Definition: impeller.hpp:597
static ImageFilter Blur(float x_sigma, float y_sigma, ImpellerTileMode tile_mode)
Definition: impeller.hpp:558
static ImageFilter Erode(float x_radius, float y_radius)
Definition: impeller.hpp:588
ImageFilter(ImpellerImageFilter filter, AdoptTag tag)
Definition: impeller.hpp:553
const uint8_t * GetMapping() const
Definition: impeller.hpp:300
Mapping(const uint8_t *mapping, size_t size, std::function< void()> release_callback)
Definition: impeller.hpp:293
static MaskFilter Blur(ImpellerBlurStyle style, float sigma)
Definition: impeller.hpp:616
MaskFilter(ImpellerMaskFilter filter, AdoptTag tag)
Definition: impeller.hpp:611
Object & operator=(const Object &other)
Definition: impeller.hpp:229
Object & operator=(Object &&other)
Definition: impeller.hpp:224
Object(T object, AdoptTag)
Definition: impeller.hpp:216
Object(const Object &other)
Definition: impeller.hpp:222
Paint & SetDrawStyle(ImpellerDrawStyle style)
Definition: impeller.hpp:715
Paint & SetColor(const ImpellerColor &color)
Definition: impeller.hpp:699
Paint & SetBlendMode(ImpellerBlendMode mode)
Definition: impeller.hpp:707
Paint & SetMaskFilter(const MaskFilter &filter)
Definition: impeller.hpp:779
Paint & SetStrokeJoin(ImpellerStrokeJoin join)
Definition: impeller.hpp:731
Paint & SetStrokeWidth(float width)
Definition: impeller.hpp:739
Paint & SetStrokeCap(ImpellerStrokeCap cap)
Definition: impeller.hpp:723
Paint & SetColorFilter(const ColorFilter &filter)
Definition: impeller.hpp:755
Paint & SetColorSource(const ColorSource &source)
Definition: impeller.hpp:763
Paint & SetImageFilter(const ImageFilter &filter)
Definition: impeller.hpp:771
Paint & SetStrokeMiter(float miter)
Definition: impeller.hpp:747
ParagraphBuilder & PushStyle(const ParagraphStyle &style)
Definition: impeller.hpp:941
ParagraphBuilder(const TypographyContext &context)
Definition: impeller.hpp:923
ParagraphBuilder & AddText(const std::string &string)
Definition: impeller.hpp:965
ParagraphBuilder & AddText(const std::string_view &string)
Definition: impeller.hpp:973
ParagraphBuilder & AddText(const uint8_t *utf8_data, uint32_t length)
Definition: impeller.hpp:957
Paragraph(ImpellerParagraph paragraph, AdoptTag tag)
Definition: impeller.hpp:629
ParagraphStyle & SetTextAlignment(ImpellerTextAlignment align)
Definition: impeller.hpp:870
ParagraphStyle & SetTextDirection(ImpellerTextDirection direction)
Definition: impeller.hpp:878
ParagraphStyle & SetFontSize(float size)
Definition: impeller.hpp:814
ParagraphStyle & SetForeground(const Paint &paint)
Definition: impeller.hpp:838
ParagraphStyle & SetLocale(const char *locale)
Definition: impeller.hpp:854
ParagraphStyle & SetBackground(const Paint &paint)
Definition: impeller.hpp:798
ParagraphStyle & SetFontStyle(ImpellerFontStyle style)
Definition: impeller.hpp:822
ParagraphStyle & SetFontFamily(const char *family_name)
Definition: impeller.hpp:806
ParagraphStyle & SetFontWeight(ImpellerFontWeight weight)
Definition: impeller.hpp:830
ParagraphStyle & SetMaxLines(uint32_t max_lines)
Definition: impeller.hpp:862
ParagraphStyle & SetHeight(float height)
Definition: impeller.hpp:846
PathBuilder & QuadraticCurveTo(const ImpellerPoint &control_point, const ImpellerPoint &end_point)
Definition: impeller.hpp:1092
PathBuilder & AddRect(const ImpellerRect &rect)
Definition: impeller.hpp:1039
PathBuilder & CubicCurveTo(const ImpellerPoint &control_point_1, const ImpellerPoint &control_point_2, const ImpellerPoint &end_point)
Definition: impeller.hpp:1065
Path BuildCopy(ImpellerFillType fill=ImpellerFillType::kImpellerFillTypeNonZero) const
Definition: impeller.hpp:999
PathBuilder & AddArc(const ImpellerRect &oval_bounds, float start_angle_degrees, float end_angle_degrees)
Definition: impeller.hpp:1017
Path Build(ImpellerFillType fill=ImpellerFillType::kImpellerFillTypeNonZero)
Definition: impeller.hpp:1008
PathBuilder & MoveTo(const ImpellerPoint &location)
Definition: impeller.hpp:1084
PathBuilder & LineTo(const ImpellerPoint &location)
Definition: impeller.hpp:1076
PathBuilder & AddOval(const ImpellerRect &oval_bounds)
Definition: impeller.hpp:1031
PathBuilder & AddRoundedRect(const ImpellerRect &rect, const ImpellerRoundingRadii &rounding_radii)
Definition: impeller.hpp:1047
Path(ImpellerPath path, AdoptTag tag)
Definition: impeller.hpp:984
bool Draw(const DisplayList &display_list)
Definition: impeller.hpp:1138
static Surface WrapFBO(const Context &context, uint64_t fbo, ImpellerPixelFormat format, const ImpellerISize &size)
Definition: impeller.hpp:1122
Surface(ImpellerSurface surface, AdoptTag tag)
Definition: impeller.hpp:1117
Surface(ImpellerSurface surface)
Definition: impeller.hpp:1115
Texture(ImpellerTexture texture, AdoptTag adopt)
Definition: impeller.hpp:345
static Texture WithContents(const Context &context, const ImpellerTextureDescriptor &descriptor, std::unique_ptr< Mapping > mapping=nullptr)
Definition: impeller.hpp:350
static Texture WithOpenGLTexture(const Context &context, const ImpellerTextureDescriptor &descriptor, uint64_t handle)
Definition: impeller.hpp:374
uint64_t GetOpenGLHandle() const
Definition: impeller.hpp:386
bool RegisterFont(std::unique_ptr< Mapping > mapping, const char *optional_family_name_alias=nullptr)
Definition: impeller.hpp:897
ImpellerFillType
Definition: impeller.h:317
@ kImpellerFillTypeNonZero
Definition: impeller.h:318
ImpellerTextDirection
Definition: impeller.h:432
ImpellerTextureSampling
Definition: impeller.h:381
#define IMPELLER_MAKE_VERSION(variant, major, minor, patch)
Pack a version in a uint32_t.
Definition: impeller.h:77
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerPathBuilder IMPELLER_NULLABLE ImpellerPathBuilderNew()
Create a new path builder. Paths themselves are immutable. A builder builds these immutable paths.
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerPaint IMPELLER_NULLABLE ImpellerPaintNew()
Create a new paint with default values.
ImpellerStrokeJoin
Definition: impeller.h:371
ImpellerBlendMode
Definition: impeller.h:327
#define IMPELLER_VERSION
Definition: impeller.h:101
ImpellerFontWeight
Definition: impeller.h:406
void *IMPELLER_NULLABLE(* ImpellerProcAddressCallback)(const char *IMPELLER_NONNULL proc_name, void *IMPELLER_NULLABLE user_data)
Definition: impeller.h:310
ImpellerStrokeCap
Definition: impeller.h:365
ImpellerDrawStyle
Definition: impeller.h:359
ImpellerTileMode
Definition: impeller.h:386
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerParagraphStyle IMPELLER_NULLABLE ImpellerParagraphStyleNew()
Create a new paragraph style.
ImpellerTextAlignment
Definition: impeller.h:423
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerTypographyContext IMPELLER_NULLABLE ImpellerTypographyContextNew()
Create a new typography contents.
ImpellerFontStyle
Definition: impeller.h:418
ImpellerClipOperation
Definition: impeller.h:322
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerDisplayListBuilder IMPELLER_NULLABLE ImpellerDisplayListBuilderNew(const ImpellerRect *IMPELLER_NULLABLE cull_rect)
Create a new display list builder.
ImpellerBlurStyle
Definition: impeller.h:393
ImpellerPixelFormat
Definition: impeller.h:377
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerParagraphBuilder IMPELLER_NULLABLE ImpellerParagraphBuilderNew(ImpellerTypographyContext IMPELLER_NONNULL context)
Create a new paragraph builder.
#define IMPELLER_HPP_PROC(proc)
Definition: impeller.hpp:198
#define IMPELLER_HPP_EACH_PROC(PROC)
Definition: impeller.hpp:47
IMPELLER_HPP_DEFINE_TRAITS(ImpellerColorFilter)
Definition: comparable.h:95
auto operator()(Args &&... args) const
Definition: impeller.hpp:42
bool Initialize(const std::function< void *(const char *function_name)> &resolver)
Definition: impeller.hpp:183
ImpellerCallback IMPELLER_NULLABLE on_release
Definition: impeller.h:562
uint64_t length
Definition: impeller.h:561
const uint8_t *IMPELLER_NONNULL data
Definition: impeller.h:560
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:64