Flutter Impeller
impeller.cc
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 
6 
7 #include <sstream>
8 
9 #include "flutter/fml/mapping.h"
11 #include "impeller/core/texture.h"
33 
34 namespace impeller::interop {
35 
36 #define DEFINE_PEER_GETTER(cxx_type, c_type) \
37  cxx_type* GetPeer(c_type object) { \
38  return reinterpret_cast<cxx_type*>(object); \
39  }
40 
41 DEFINE_PEER_GETTER(ColorFilter, ImpellerColorFilter);
42 DEFINE_PEER_GETTER(ColorSource, ImpellerColorSource);
43 DEFINE_PEER_GETTER(Context, ImpellerContext);
44 DEFINE_PEER_GETTER(DisplayList, ImpellerDisplayList);
45 DEFINE_PEER_GETTER(DisplayListBuilder, ImpellerDisplayListBuilder);
46 DEFINE_PEER_GETTER(ImageFilter, ImpellerImageFilter);
47 DEFINE_PEER_GETTER(MaskFilter, ImpellerMaskFilter);
48 DEFINE_PEER_GETTER(Paint, ImpellerPaint);
49 DEFINE_PEER_GETTER(Paragraph, ImpellerParagraph);
50 DEFINE_PEER_GETTER(ParagraphBuilder, ImpellerParagraphBuilder);
51 DEFINE_PEER_GETTER(ParagraphStyle, ImpellerParagraphStyle);
52 DEFINE_PEER_GETTER(Path, ImpellerPath);
53 DEFINE_PEER_GETTER(PathBuilder, ImpellerPathBuilder);
54 DEFINE_PEER_GETTER(Surface, ImpellerSurface);
55 DEFINE_PEER_GETTER(Texture, ImpellerTexture);
56 DEFINE_PEER_GETTER(TypographyContext, ImpellerTypographyContext);
57 
58 static std::string GetVersionAsString(uint32_t version) {
59  std::stringstream stream;
60  stream << IMPELLER_VERSION_GET_VARIANT(version) << "."
61  << IMPELLER_VERSION_GET_MAJOR(version) << "."
62  << IMPELLER_VERSION_GET_MINOR(version) << "."
63  << IMPELLER_VERSION_GET_PATCH(version);
64  return stream.str();
65 }
66 
68 uint32_t ImpellerGetVersion() {
69  return IMPELLER_VERSION;
70 }
71 
74  uint32_t version,
75  ImpellerProcAddressCallback gl_proc_address_callback,
76  void* gl_proc_address_callback_user_data) {
77  if (version != IMPELLER_VERSION) {
78  VALIDATION_LOG << "This version of Impeller ("
80  << "doesn't match the version the user expects ("
81  << GetVersionAsString(version) << ").";
82  return nullptr;
83  }
84  auto context = Context::CreateOpenGLES(
85  [gl_proc_address_callback,
86  gl_proc_address_callback_user_data](const char* proc_name) -> void* {
87  return gl_proc_address_callback(proc_name,
88  gl_proc_address_callback_user_data);
89  });
90  if (!context || !context->IsValid()) {
91  VALIDATION_LOG << "Could not create valid context.";
92  return nullptr;
93  }
94  return context.Leak();
95 }
96 
98 void ImpellerContextRetain(ImpellerContext context) {
99  ObjectBase::SafeRetain(context);
100 }
101 
103 void ImpellerContextRelease(ImpellerContext context) {
104  ObjectBase::SafeRelease(context);
105 }
106 
108 ImpellerDisplayListBuilder ImpellerDisplayListBuilderNew(
109  const ImpellerRect* cull_rect) {
110  return Create<DisplayListBuilder>(cull_rect).Leak();
111 }
112 
114 void ImpellerDisplayListBuilderRetain(ImpellerDisplayListBuilder builder) {
115  ObjectBase::SafeRetain(builder);
116 }
117 
119 void ImpellerDisplayListBuilderRelease(ImpellerDisplayListBuilder builder) {
120  ObjectBase::SafeRelease(builder);
121 }
122 
124 void ImpellerDisplayListBuilderSave(ImpellerDisplayListBuilder builder) {
125  GetPeer(builder)->Save();
126 }
127 
129 void ImpellerDisplayListBuilderSaveLayer(ImpellerDisplayListBuilder builder,
130  const ImpellerRect* bounds,
131  ImpellerPaint paint,
132  ImpellerImageFilter backdrop) {
133  GetPeer(builder)->SaveLayer(ToImpellerType(*bounds), //
134  GetPeer(paint), //
135  GetPeer(backdrop) //
136  );
137 }
138 
140 void ImpellerDisplayListBuilderRestore(ImpellerDisplayListBuilder builder) {
141  GetPeer(builder)->Restore();
142 }
143 
145 void ImpellerDisplayListBuilderScale(ImpellerDisplayListBuilder builder,
146  float x_scale,
147  float y_scale) {
148  GetPeer(builder)->Scale(Size{x_scale, y_scale});
149 }
150 
152 void ImpellerDisplayListBuilderRotate(ImpellerDisplayListBuilder builder,
153  float angle_degrees) {
154  GetPeer(builder)->Rotate(Degrees{angle_degrees});
155 }
156 
158 void ImpellerDisplayListBuilderTranslate(ImpellerDisplayListBuilder builder,
159  float x_translation,
160  float y_translation) {
161  GetPeer(builder)->Translate(Point{x_translation, y_translation});
162 }
163 
165 void ImpellerDisplayListBuilderSetTransform(ImpellerDisplayListBuilder builder,
166  const ImpellerMatrix* transform) {
167  GetPeer(builder)->SetTransform(ToImpellerType(*transform));
168 }
169 
171 void ImpellerDisplayListBuilderTransform(ImpellerDisplayListBuilder builder,
172  const ImpellerMatrix* transform) {
173  GetPeer(builder)->Transform(ToImpellerType(*transform));
174 }
175 
177 void ImpellerDisplayListBuilderGetTransform(ImpellerDisplayListBuilder builder,
178  ImpellerMatrix* out_transform) {
179  FromImpellerType(GetPeer(builder)->GetTransform(), *out_transform);
180 }
181 
184  ImpellerDisplayListBuilder builder) {
185  GetPeer(builder)->ResetTransform();
186 }
187 
190  ImpellerDisplayListBuilder builder) {
191  return GetPeer(builder)->GetSaveCount();
192 }
193 
196  ImpellerDisplayListBuilder builder,
197  uint32_t count) {
198  GetPeer(builder)->RestoreToCount(count);
199 }
200 
202 void ImpellerPathRetain(ImpellerPath path) {
204 }
205 
207 void ImpellerPathRelease(ImpellerPath path) {
209 }
210 
212 ImpellerPathBuilder ImpellerPathBuilderNew() {
213  return Create<PathBuilder>().Leak();
214 }
215 
217 void ImpellerPathBuilderRetain(ImpellerPathBuilder builder) {
218  ObjectBase::SafeRetain(builder);
219 }
220 
222 void ImpellerPathBuilderRelease(ImpellerPathBuilder builder) {
223  ObjectBase::SafeRelease(builder);
224 }
225 
227 void ImpellerPathBuilderMoveTo(ImpellerPathBuilder builder,
228  const ImpellerPoint* location) {
229  GetPeer(builder)->MoveTo(ToImpellerType(*location));
230 }
231 
233 void ImpellerPathBuilderLineTo(ImpellerPathBuilder builder,
234  const ImpellerPoint* location) {
235  GetPeer(builder)->LineTo(ToImpellerType(*location));
236 }
237 
239 void ImpellerPathBuilderQuadraticCurveTo(ImpellerPathBuilder builder,
240  const ImpellerPoint* control_point,
241  const ImpellerPoint* end_point) {
242  GetPeer(builder)->QuadraticCurveTo(ToImpellerType(*control_point),
243  ToImpellerType(*end_point));
244 }
245 
247 void ImpellerPathBuilderCubicCurveTo(ImpellerPathBuilder builder,
248  const ImpellerPoint* control_point_1,
249  const ImpellerPoint* control_point_2,
250  const ImpellerPoint* end_point) {
251  GetPeer(builder)->CubicCurveTo(ToImpellerType(*control_point_1), //
252  ToImpellerType(*control_point_2), //
253  ToImpellerType(*end_point) //
254  );
255 }
256 
258 void ImpellerPathBuilderAddRect(ImpellerPathBuilder builder,
259  const ImpellerRect* rect) {
260  GetPeer(builder)->AddRect(ToImpellerType(*rect));
261 }
262 
264 void ImpellerPathBuilderAddArc(ImpellerPathBuilder builder,
265  const ImpellerRect* oval_bounds,
266  float start_angle_degrees,
267  float end_angle_degrees) {
268  GetPeer(builder)->AddArc(ToImpellerType(*oval_bounds), //
269  Degrees{start_angle_degrees}, //
270  Degrees{end_angle_degrees} //
271  );
272 }
273 
275 void ImpellerPathBuilderAddOval(ImpellerPathBuilder builder,
276  const ImpellerRect* oval_bounds) {
277  GetPeer(builder)->AddOval(ToImpellerType(*oval_bounds));
278 }
279 
282  ImpellerPathBuilder builder,
283  const ImpellerRect* rect,
284  const ImpellerRoundingRadii* rounding_radii) {
285  GetPeer(builder)->AddRoundedRect(ToImpellerType(*rect),
286  ToImpellerType(*rounding_radii));
287 }
288 
290 void ImpellerPathBuilderClose(ImpellerPathBuilder builder) {
291  GetPeer(builder)->Close();
292 }
293 
295 ImpellerPath ImpellerPathBuilderCopyPathNew(ImpellerPathBuilder builder,
296  ImpellerFillType fill) {
297  return GetPeer(builder)->CopyPath(ToImpellerType(fill)).Leak();
298 }
299 
301 ImpellerPath ImpellerPathBuilderTakePathNew(ImpellerPathBuilder builder,
302  ImpellerFillType fill) {
303  return GetPeer(builder)->TakePath(ToImpellerType(fill)).Leak();
304 }
305 
307 void ImpellerDisplayListBuilderClipRect(ImpellerDisplayListBuilder builder,
308  const ImpellerRect* rect,
310  GetPeer(builder)->ClipRect(ToImpellerType(*rect), ToImpellerType(op));
311 }
312 
314 void ImpellerDisplayListBuilderClipOval(ImpellerDisplayListBuilder builder,
315  const ImpellerRect* oval_bounds,
317  GetPeer(builder)->ClipOval(ToImpellerType(*oval_bounds), ToImpellerType(op));
318 }
319 
322  ImpellerDisplayListBuilder builder,
323  const ImpellerRect* rect,
324  const ImpellerRoundingRadii* radii,
326  GetPeer(builder)->ClipRoundedRect(ToImpellerType(*rect), //
327  ToImpellerType(*radii), //
328  ToImpellerType(op) //
329  );
330 }
331 
333 void ImpellerDisplayListBuilderClipPath(ImpellerDisplayListBuilder builder,
334  ImpellerPath path,
336  GetPeer(builder)->ClipPath(*GetPeer(path), ToImpellerType(op));
337 }
338 
340 ImpellerPaint ImpellerPaintNew() {
341  return Create<Paint>().Leak();
342 }
343 
345 void ImpellerPaintRetain(ImpellerPaint paint) {
346  ObjectBase::SafeRetain(paint);
347 }
348 
350 void ImpellerPaintRelease(ImpellerPaint paint) {
352 }
353 
355 void ImpellerPaintSetColor(ImpellerPaint paint, const ImpellerColor* color) {
356  GetPeer(paint)->SetColor(ToDisplayListType(*color));
357 }
358 
360 void ImpellerPaintSetBlendMode(ImpellerPaint paint, ImpellerBlendMode mode) {
361  GetPeer(paint)->SetBlendMode(ToImpellerType(mode));
362 }
363 
365 void ImpellerPaintSetDrawStyle(ImpellerPaint paint, ImpellerDrawStyle style) {
366  GetPeer(paint)->SetDrawStyle(ToDisplayListType(style));
367 }
368 
370 void ImpellerPaintSetStrokeCap(ImpellerPaint paint, ImpellerStrokeCap cap) {
371  GetPeer(paint)->SetStrokeCap(ToDisplayListType(cap));
372 }
373 
375 void ImpellerPaintSetStrokeJoin(ImpellerPaint paint, ImpellerStrokeJoin join) {
376  GetPeer(paint)->SetStrokeJoin(ToDisplayListType(join));
377 }
378 
380 void ImpellerPaintSetStrokeWidth(ImpellerPaint paint, float width) {
381  GetPeer(paint)->SetStrokeWidth(width);
382 }
383 
385 void ImpellerPaintSetStrokeMiter(ImpellerPaint paint, float miter) {
386  GetPeer(paint)->SetStrokeMiter(miter);
387 }
388 
390 void ImpellerDisplayListBuilderDrawPaint(ImpellerDisplayListBuilder builder,
391  ImpellerPaint paint) {
392  GetPeer(builder)->DrawPaint(*GetPeer(paint));
393 }
394 
396 void ImpellerDisplayListBuilderDrawLine(ImpellerDisplayListBuilder builder,
397  const ImpellerPoint* from,
398  const ImpellerPoint* to,
399  ImpellerPaint paint) {
400  GetPeer(builder)->DrawLine(ToImpellerType(*from), //
401  ToImpellerType(*to), //
402  *GetPeer(paint) //
403  );
404 }
405 
408  ImpellerDisplayListBuilder builder,
409  const ImpellerPoint* from,
410  const ImpellerPoint* to,
411  float on_length,
412  float off_length,
413  ImpellerPaint paint) {
414  GetPeer(builder)->DrawDashedLine(ToImpellerType(*from), //
415  ToImpellerType(*to), //
416  on_length, //
417  off_length, //
418  *GetPeer(paint) //
419  );
420 }
421 
423 void ImpellerDisplayListBuilderDrawRect(ImpellerDisplayListBuilder builder,
424  const ImpellerRect* rect,
425  ImpellerPaint paint) {
426  GetPeer(builder)->DrawRect(ToImpellerType(*rect), *GetPeer(paint));
427 }
428 
430 void ImpellerDisplayListBuilderDrawOval(ImpellerDisplayListBuilder builder,
431  const ImpellerRect* oval_bounds,
432  ImpellerPaint paint) {
433  GetPeer(builder)->DrawOval(ToImpellerType(*oval_bounds), *GetPeer(paint));
434 }
435 
438  ImpellerDisplayListBuilder builder,
439  const ImpellerRect* rect,
440  const ImpellerRoundingRadii* radii,
441  ImpellerPaint paint) {
442  GetPeer(builder)->DrawRoundedRect(ToImpellerType(*rect), //
443  ToImpellerType(*radii), //
444  *GetPeer(paint) //
445  );
446 }
447 
450  ImpellerDisplayListBuilder builder,
451  const ImpellerRect* outer_rect,
452  const ImpellerRoundingRadii* outer_radii,
453  const ImpellerRect* inner_rect,
454  const ImpellerRoundingRadii* inner_radii,
455  ImpellerPaint paint) {
456  GetPeer(builder)->DrawRoundedRectDifference(ToImpellerType(*outer_rect), //
457  ToImpellerType(*outer_radii), //
458  ToImpellerType(*inner_rect), //
459  ToImpellerType(*inner_radii), //
460  *GetPeer(paint) //
461  );
462 }
463 
465 void ImpellerDisplayListBuilderDrawPath(ImpellerDisplayListBuilder builder,
466  ImpellerPath path,
467  ImpellerPaint paint) {
468  GetPeer(builder)->DrawPath(*GetPeer(path), *GetPeer(paint));
469 }
470 
473  ImpellerContext context,
474  const ImpellerTextureDescriptor* descriptor,
475  const ImpellerMapping* contents,
476  void* contents_on_release_user_data) {
477  TextureDescriptor desc;
480  desc.format = ToImpellerType(descriptor->pixel_format);
481  desc.size = ToImpellerType(descriptor->size);
482  desc.mip_count = std::min(descriptor->mip_count, 1u);
485  auto texture = Create<Texture>(*GetPeer(context), desc);
486  if (!texture->IsValid()) {
487  VALIDATION_LOG << "Could not create texture.";
488  return nullptr;
489  }
490  // Depending on whether the de-allocation can be delayed, it may be possible
491  // to avoid a data copy.
492  if (contents->on_release) {
493  // Avoids data copy.
494  auto wrapped_contents = std::make_shared<fml::NonOwnedMapping>(
495  contents->data, // data ptr
496  contents->length, // data length
497  [on_release = contents->on_release, contents_on_release_user_data](
498  auto, auto) {
499  on_release(contents_on_release_user_data);
500  } // release callback
501  );
502  if (!texture->SetContents(std::move(wrapped_contents))) {
503  VALIDATION_LOG << "Could not set texture contents.";
504  return nullptr;
505  }
506  } else {
507  // May copy.
508  if (!texture->SetContents(contents->data, contents->length)) {
509  VALIDATION_LOG << "Could not set texture contents.";
510  return nullptr;
511  }
512  }
513  return texture.Leak();
514 }
515 
518  ImpellerContext context,
519  const ImpellerTextureDescriptor* descriptor,
520  uint64_t external_gl_handle) {
521  auto impeller_context = GetPeer(context)->GetContext();
522  if (impeller_context->GetBackendType() !=
524  VALIDATION_LOG << "Context is not OpenGL.";
525  return nullptr;
526  }
527 
528  const auto& impeller_context_gl = ContextGLES::Cast(*impeller_context);
529  const auto& reactor = impeller_context_gl.GetReactor();
530 
531  TextureDescriptor desc;
534  desc.format = ToImpellerType(descriptor->pixel_format);
535  desc.size = ToImpellerType(descriptor->size);
536  desc.mip_count = std::min(descriptor->mip_count, 1u);
539 
540  auto texture = TextureGLES::WrapTexture(
541  reactor, //
542  desc, //
543  reactor->CreateHandle(HandleType::kTexture, external_gl_handle) //
544  );
545  if (!texture || !texture->IsValid()) {
546  VALIDATION_LOG << "Could not wrap external texture.";
547  return nullptr;
548  }
549  texture->SetCoordinateSystem(TextureCoordinateSystem::kUploadFromHost);
550  return Create<Texture>(impeller::Context::BackendType::kOpenGLES,
551  std::move(texture))
552  .Leak();
553 }
554 
556 void ImpellerTextureRetain(ImpellerTexture texture) {
557  ObjectBase::SafeRetain(texture);
558 }
559 
561 void ImpellerTextureRelease(ImpellerTexture texture) {
562  ObjectBase::SafeRelease(texture);
563 }
564 
566 uint64_t ImpellerTextureGetOpenGLHandle(ImpellerTexture texture) {
567  auto interop_texture = GetPeer(texture);
568  if (interop_texture->GetBackendType() !=
570  VALIDATION_LOG << "Can only fetch the texture handle of an OpenGL texture.";
571  return 0u;
572  }
573  return TextureGLES::Cast(*interop_texture->GetTexture())
574  .GetGLHandle()
575  .value_or(0u);
576 }
577 
579 void ImpellerDisplayListRetain(ImpellerDisplayList display_list) {
580  ObjectBase::SafeRetain(display_list);
581 }
582 
584 void ImpellerDisplayListRelease(ImpellerDisplayList display_list) {
585  ObjectBase::SafeRelease(display_list);
586 }
587 
590  ImpellerDisplayListBuilder builder) {
591  auto dl = GetPeer(builder)->Build();
592  if (!dl->IsValid()) {
593  return nullptr;
594  }
595  return dl.Leak();
596 }
597 
600  ImpellerDisplayListBuilder builder,
601  ImpellerDisplayList display_list,
602  float opacity) {
603  GetPeer(builder)->DrawDisplayList(*GetPeer(display_list), opacity);
604 }
605 
607 ImpellerSurface ImpellerSurfaceCreateWrappedFBONew(ImpellerContext context,
608  uint64_t fbo,
609  ImpellerPixelFormat format,
610  const ImpellerISize* size) {
611  return Surface::WrapFBO(*GetPeer(context), //
612  fbo, //
613  ToImpellerType(format), //
614  ToImpellerType(*size)) //
615  .Leak();
616 }
617 
619 void ImpellerSurfaceRetain(ImpellerSurface surface) {
620  ObjectBase::SafeRetain(surface);
621 }
622 
624 void ImpellerSurfaceRelease(ImpellerSurface surface) {
625  ObjectBase::SafeRelease(surface);
626 }
627 
629 bool ImpellerSurfaceDrawDisplayList(ImpellerSurface surface,
630  ImpellerDisplayList display_list) {
631  return GetPeer(surface)->DrawDisplayList(*GetPeer(display_list));
632 }
633 
635 void ImpellerDisplayListBuilderDrawTexture(ImpellerDisplayListBuilder builder,
636  ImpellerTexture texture,
637  const ImpellerPoint* point,
638  ImpellerTextureSampling sampling,
639  ImpellerPaint paint) {
640  GetPeer(builder)->DrawTexture(*GetPeer(texture), //
641  ToImpellerType(*point), //
642  ToDisplayListType(sampling), //
643  GetPeer(paint) //
644  );
645 }
646 
649  ImpellerDisplayListBuilder builder,
650  ImpellerTexture texture,
651  const ImpellerRect* src_rect,
652  const ImpellerRect* dst_rect,
653  ImpellerTextureSampling sampling,
654  ImpellerPaint paint) {
655  GetPeer(builder)->DrawTextureRect(*GetPeer(texture), //
656  ToImpellerType(*src_rect), //
657  ToImpellerType(*dst_rect), //
658  ToDisplayListType(sampling), //
659  GetPeer(paint) //
660  );
661 }
662 
664 void ImpellerColorSourceRetain(ImpellerColorSource color_source) {
665  ObjectBase::SafeRetain(color_source);
666 }
667 
669 void ImpellerColorSourceRelease(ImpellerColorSource color_source) {
670  ObjectBase::SafeRelease(color_source);
671 }
672 
673 static std::pair<std::vector<flutter::DlColor>, std::vector<Scalar>>
674 ParseColorsAndStops(uint32_t stop_count,
675  const ImpellerColor* colors,
676  const float* stops) {
677  if (stop_count == 0) {
678  return {};
679  }
680  std::pair<std::vector<flutter::DlColor>, std::vector<Scalar>> result;
681  result.first.reserve(stop_count);
682  result.second.reserve(stop_count);
683  for (size_t i = 0; i < stop_count; i++) {
684  result.first.emplace_back(ToDisplayListType(colors[i]));
685  result.second.emplace_back(stops[i]);
686  }
687  return result;
688 }
689 
692  const ImpellerPoint* start_point,
693  const ImpellerPoint* end_point,
694  uint32_t stop_count,
695  const ImpellerColor* colors,
696  const float* stops,
697  ImpellerTileMode tile_mode,
698  const ImpellerMatrix* transformation) {
699  const auto colors_and_stops = ParseColorsAndStops(stop_count, colors, stops);
701  ToImpellerType(*start_point), //
702  ToImpellerType(*end_point), //
703  colors_and_stops.first, //
704  colors_and_stops.second, //
705  ToDisplayListType(tile_mode), //
706  transformation == nullptr ? Matrix{}
707  : ToImpellerType(*transformation) //
708  )
709  .Leak();
710 }
711 
714  const ImpellerPoint* center,
715  float radius,
716  uint32_t stop_count,
717  const ImpellerColor* colors,
718  const float* stops,
719  ImpellerTileMode tile_mode,
720  const ImpellerMatrix* transformation) {
721  const auto colors_and_stops = ParseColorsAndStops(stop_count, colors, stops);
723  ToImpellerType(*center), //
724  radius, //
725  colors_and_stops.first, //
726  colors_and_stops.second, //
727  ToDisplayListType(tile_mode), //
728  transformation == nullptr ? Matrix{}
729  : ToImpellerType(*transformation) //
730  )
731  .Leak();
732 }
733 
736  const ImpellerPoint* start_center,
737  float start_radius,
738  const ImpellerPoint* end_center,
739  float end_radius,
740  uint32_t stop_count,
741  const ImpellerColor* colors,
742  const float* stops,
743  ImpellerTileMode tile_mode,
744  const ImpellerMatrix* transformation) {
745  const auto colors_and_stops = ParseColorsAndStops(stop_count, colors, stops);
747  ToImpellerType(*start_center), //
748  start_radius, //
749  ToImpellerType(*end_center), //
750  end_radius, //
751  colors_and_stops.first, //
752  colors_and_stops.second, //
753  ToDisplayListType(tile_mode), //
754  transformation == nullptr ? Matrix{}
755  : ToImpellerType(*transformation) //
756  )
757  .Leak();
758 }
759 
762  const ImpellerPoint* center,
763  float start,
764  float end,
765  uint32_t stop_count,
766  const ImpellerColor* colors,
767  const float* stops,
768  ImpellerTileMode tile_mode,
769  const ImpellerMatrix* transformation) {
770  const auto colors_and_stops = ParseColorsAndStops(stop_count, colors, stops);
772  ToImpellerType(*center), //
773  start, //
774  end, //
775  colors_and_stops.first, //
776  colors_and_stops.second, //
777  ToDisplayListType(tile_mode), //
778  transformation == nullptr ? Matrix{}
779  : ToImpellerType(*transformation) //
780  )
781  .Leak();
782 }
783 
786  ImpellerTexture image,
787  ImpellerTileMode horizontal_tile_mode,
788  ImpellerTileMode vertical_tile_mode,
789  ImpellerTextureSampling sampling,
790  const ImpellerMatrix* transformation) {
791  return ColorSource::MakeImage(
792  *GetPeer(image), //
793  ToDisplayListType(horizontal_tile_mode), //
794  ToDisplayListType(vertical_tile_mode), //
795  ToDisplayListType(sampling), //
796  transformation == nullptr ? Matrix{}
797  : ToImpellerType(*transformation) //
798  )
799  .Leak();
800 }
801 
803 void ImpellerColorFilterRetain(ImpellerColorFilter color_filter) {
804  ObjectBase::SafeRetain(color_filter);
805 }
806 
808 void ImpellerColorFilterRelease(ImpellerColorFilter color_filter) {
809  ObjectBase::SafeRelease(color_filter);
810 }
811 
814  const ImpellerColor* color,
815  ImpellerBlendMode blend_mode) {
816  return ColorFilter::MakeBlend(ToImpellerType(*color),
817  ToImpellerType(blend_mode))
818  .Leak();
819 }
820 
823  const ImpellerColorMatrix* color_matrix) {
824  return ColorFilter::MakeMatrix(color_matrix->m).Leak();
825 }
826 
828 void ImpellerMaskFilterRetain(ImpellerMaskFilter mask_filter) {
829  ObjectBase::SafeRetain(mask_filter);
830 }
831 
833 void ImpellerMaskFilterRelease(ImpellerMaskFilter mask_filter) {
834  ObjectBase::SafeRelease(mask_filter);
835 }
836 
839  float sigma) {
840  return MaskFilter::MakeBlur(ToDisplayListType(style), sigma).Leak();
841 }
842 
844 void ImpellerImageFilterRetain(ImpellerImageFilter image_filter) {
845  ObjectBase::SafeRetain(image_filter);
846 }
847 
849 void ImpellerImageFilterRelease(ImpellerImageFilter image_filter) {
850  ObjectBase::SafeRelease(image_filter);
851 }
852 
855  float x_sigma,
856  float y_sigma,
857  ImpellerTileMode tile_mode) {
858  return ImageFilter::MakeBlur(x_sigma, y_sigma, ToDisplayListType(tile_mode))
859  .Leak();
860 }
861 
863 ImpellerImageFilter ImpellerImageFilterCreateDilateNew(float x_radius,
864  float y_radius) {
865  return ImageFilter::MakeDilate(x_radius, y_radius).Leak();
866 }
867 
869 ImpellerImageFilter ImpellerImageFilterCreateErodeNew(float x_radius,
870  float y_radius) {
871  return ImageFilter::MakeErode(x_radius, y_radius).Leak();
872 }
873 
876  const ImpellerMatrix* matrix,
877  ImpellerTextureSampling sampling) {
878  return ImageFilter::MakeMatrix(ToImpellerType(*matrix),
879  ToDisplayListType(sampling))
880  .Leak();
881 }
882 
885  ImpellerImageFilter outer,
886  ImpellerImageFilter inner) {
887  return ImageFilter::MakeCompose(*GetPeer(outer), *GetPeer(inner)).Leak();
888 }
889 
891 void ImpellerPaintSetColorFilter(ImpellerPaint paint,
892  ImpellerColorFilter color_filter) {
893  GetPeer(paint)->SetColorFilter(*GetPeer(color_filter));
894 }
895 
897 void ImpellerPaintSetColorSource(ImpellerPaint paint,
898  ImpellerColorSource color_source) {
899  GetPeer(paint)->SetColorSource(*GetPeer(color_source));
900 }
901 
903 void ImpellerPaintSetImageFilter(ImpellerPaint paint,
904  ImpellerImageFilter image_filter) {
905  GetPeer(paint)->SetImageFilter(*GetPeer(image_filter));
906 }
907 
909 void ImpellerPaintSetMaskFilter(ImpellerPaint paint,
910  ImpellerMaskFilter mask_filter) {
911  GetPeer(paint)->SetMaskFilter(*GetPeer(mask_filter));
912 }
913 
915 ImpellerParagraphStyle ImpellerParagraphStyleNew() {
916  return Create<ParagraphStyle>().Leak();
917 }
918 
920 void ImpellerParagraphStyleRetain(ImpellerParagraphStyle paragraph_style) {
921  ObjectBase::SafeRetain(paragraph_style);
922 }
923 
925 void ImpellerParagraphStyleRelease(ImpellerParagraphStyle paragraph_style) {
926  ObjectBase::SafeRelease(paragraph_style);
927 }
928 
930 void ImpellerParagraphStyleSetForeground(ImpellerParagraphStyle paragraph_style,
931  ImpellerPaint paint) {
932  GetPeer(paragraph_style)->SetForeground(Ref(GetPeer(paint)));
933 }
934 
936 void ImpellerParagraphStyleSetBackground(ImpellerParagraphStyle paragraph_style,
937  ImpellerPaint paint) {
938  GetPeer(paragraph_style)->SetBackground(Ref(GetPeer(paint)));
939 }
940 
942 void ImpellerParagraphStyleSetFontWeight(ImpellerParagraphStyle paragraph_style,
943  ImpellerFontWeight weight) {
944  GetPeer(paragraph_style)->SetFontWeight(ToTxtType(weight));
945 }
946 
948 void ImpellerParagraphStyleSetFontStyle(ImpellerParagraphStyle paragraph_style,
949  ImpellerFontStyle style) {
950  GetPeer(paragraph_style)->SetFontStyle(ToTxtType(style));
951 }
952 
953 static std::string ReadString(const char* string) {
954  if (string == nullptr) {
955  return "";
956  }
957  return std::string{string};
958 }
959 
961 void ImpellerParagraphStyleSetFontFamily(ImpellerParagraphStyle paragraph_style,
962  const char* family_name) {
963  GetPeer(paragraph_style)->SetFontFamily(ReadString(family_name));
964 }
965 
967 void ImpellerParagraphStyleSetFontSize(ImpellerParagraphStyle paragraph_style,
968  float size) {
969  GetPeer(paragraph_style)->SetFontSize(size);
970 }
971 
973 void ImpellerParagraphStyleSetHeight(ImpellerParagraphStyle paragraph_style,
974  float height) {
975  GetPeer(paragraph_style)->SetHeight(height);
976 }
977 
980  ImpellerParagraphStyle paragraph_style,
981  ImpellerTextAlignment align) {
982  GetPeer(paragraph_style)->SetTextAlignment(ToTxtType(align));
983 }
984 
987  ImpellerParagraphStyle paragraph_style,
988  ImpellerTextDirection direction) {
989  GetPeer(paragraph_style)->SetTextDirection(ToTxtType(direction));
990 }
991 
993 void ImpellerParagraphStyleSetMaxLines(ImpellerParagraphStyle paragraph_style,
994  uint32_t max_lines) {
995  GetPeer(paragraph_style)->SetMaxLines(max_lines);
996 }
997 
999 void ImpellerParagraphStyleSetLocale(ImpellerParagraphStyle paragraph_style,
1000  const char* locale) {
1001  GetPeer(paragraph_style)->SetLocale(ReadString(locale));
1002 }
1003 
1005 void ImpellerDisplayListBuilderDrawParagraph(ImpellerDisplayListBuilder builder,
1006  ImpellerParagraph paragraph,
1007  const ImpellerPoint* point) {
1008  GetPeer(builder)->DrawParagraph(*GetPeer(paragraph), ToImpellerType(*point));
1009 }
1010 
1012 ImpellerParagraphBuilder ImpellerParagraphBuilderNew(
1013  ImpellerTypographyContext context) {
1014  auto builder =
1015  Create<ParagraphBuilder>(Ref<TypographyContext>(GetPeer(context)));
1016  if (!builder->IsValid()) {
1017  VALIDATION_LOG << "Could not create valid paragraph builder.";
1018  return nullptr;
1019  }
1020  return builder.Leak();
1021 }
1022 
1025  ImpellerParagraphBuilder paragraph_builder) {
1026  ObjectBase::SafeRetain(paragraph_builder);
1027 }
1028 
1031  ImpellerParagraphBuilder paragraph_builder) {
1032  ObjectBase::SafeRelease(paragraph_builder);
1033 }
1034 
1037  ImpellerParagraphBuilder paragraph_builder,
1038  ImpellerParagraphStyle style) {
1039  GetPeer(paragraph_builder)->PushStyle(*GetPeer(style));
1040 }
1041 
1044  ImpellerParagraphBuilder paragraph_builder) {
1045  GetPeer(paragraph_builder)->PopStyle();
1046 }
1047 
1049 void ImpellerParagraphBuilderAddText(ImpellerParagraphBuilder paragraph_builder,
1050  const uint8_t* data,
1051  uint32_t length) {
1052  if (data == nullptr) {
1053  length = 0;
1054  }
1055  if (length == 0) {
1056  return;
1057  }
1058  GetPeer(paragraph_builder)->AddText(data, length);
1059 }
1060 
1063  ImpellerParagraphBuilder paragraph_builder,
1064  float width) {
1065  return GetPeer(paragraph_builder)->Build(width).Leak();
1066 }
1067 
1069 void ImpellerParagraphRetain(ImpellerParagraph paragraph) {
1070  ObjectBase::SafeRetain(paragraph);
1071 }
1072 
1074 void ImpellerParagraphRelease(ImpellerParagraph paragraph) {
1075  ObjectBase::SafeRelease(paragraph);
1076 }
1077 
1079 float ImpellerParagraphGetMaxWidth(ImpellerParagraph paragraph) {
1080  return GetPeer(paragraph)->GetMaxWidth();
1081 }
1082 
1084 float ImpellerParagraphGetHeight(ImpellerParagraph paragraph) {
1085  return GetPeer(paragraph)->GetHeight();
1086 }
1087 
1089 float ImpellerParagraphGetLongestLineWidth(ImpellerParagraph paragraph) {
1090  return GetPeer(paragraph)->GetLongestLineWidth();
1091 }
1092 
1094 float ImpellerParagraphGetMinIntrinsicWidth(ImpellerParagraph paragraph) {
1095  return GetPeer(paragraph)->GetMinIntrinsicWidth();
1096 }
1097 
1099 float ImpellerParagraphGetMaxIntrinsicWidth(ImpellerParagraph paragraph) {
1100  return GetPeer(paragraph)->GetMaxIntrinsicWidth();
1101 }
1102 
1104 float ImpellerParagraphGetIdeographicBaseline(ImpellerParagraph paragraph) {
1105  return GetPeer(paragraph)->GetIdeographicBaseline();
1106 }
1107 
1109 float ImpellerParagraphGetAlphabeticBaseline(ImpellerParagraph paragraph) {
1110  return GetPeer(paragraph)->GetAlphabeticBaseline();
1111 }
1112 
1114 uint32_t ImpellerParagraphGetLineCount(ImpellerParagraph paragraph) {
1115  return GetPeer(paragraph)->GetLineCount();
1116 }
1117 
1119 ImpellerTypographyContext ImpellerTypographyContextNew() {
1120  auto context = Create<TypographyContext>();
1121  if (!context->IsValid()) {
1122  VALIDATION_LOG << "Could not create typography context.";
1123  return nullptr;
1124  }
1125  return Create<TypographyContext>().Leak();
1126 }
1127 
1129 void ImpellerTypographyContextRetain(ImpellerTypographyContext context) {
1130  ObjectBase::SafeRetain(context);
1131 }
1132 
1134 void ImpellerTypographyContextRelease(ImpellerTypographyContext context) {
1135  ObjectBase::SafeRelease(context);
1136 }
1137 
1139 bool ImpellerTypographyContextRegisterFont(ImpellerTypographyContext context,
1140  const ImpellerMapping* contents,
1141  void* contents_on_release_user_data,
1142  const char* family_name_alias) {
1143  auto wrapped_contents = std::make_unique<fml::NonOwnedMapping>(
1144  contents->data, // data ptr
1145  contents->length, // data length
1146  [on_release = contents->on_release, contents_on_release_user_data](auto,
1147  auto) {
1148  on_release(contents_on_release_user_data);
1149  } // release callback
1150  );
1151  return GetPeer(context)->RegisterFont(std::move(wrapped_contents),
1152  family_name_alias);
1153 }
1154 
1155 } // namespace impeller::interop
static ContextGLES & Cast(Context &base)
Definition: backend_cast.h:13
std::optional< GLuint > GetGLHandle() const
static std::shared_ptr< TextureGLES > WrapTexture(std::shared_ptr< ReactorGLES > reactor, TextureDescriptor desc, HandleGLES external_handle)
Create a texture by wrapping an external OpenGL texture handle. Ownership of the texture handle is as...
static ScopedObject< ColorFilter > MakeMatrix(const float matrix[20])
Definition: color_filter.cc:18
static ScopedObject< ColorFilter > MakeBlend(Color color, BlendMode mode)
Definition: color_filter.cc:9
static ScopedObject< ColorSource > MakeSweepGradient(const Point &center, Scalar start, Scalar end, const std::vector< flutter::DlColor > &colors, const std::vector< Scalar > &stops, flutter::DlTileMode tile_mode, const Matrix &transformation)
Definition: color_source.cc:76
static ScopedObject< ColorSource > MakeImage(const Texture &image, flutter::DlTileMode horizontal_tile_mode, flutter::DlTileMode vertical_tile_mode, flutter::DlImageSampling sampling, const Matrix &transformation)
Definition: color_source.cc:99
static ScopedObject< ColorSource > MakeRadialGradient(const Point &center, Scalar radius, const std::vector< flutter::DlColor > &colors, const std::vector< Scalar > &stops, flutter::DlTileMode tile_mode, const Matrix &transformation)
Definition: color_source.cc:30
static ScopedObject< ColorSource > MakeLinearGradient(const Point &start_point, const Point &end_point, const std::vector< flutter::DlColor > &colors, const std::vector< Scalar > &stops, flutter::DlTileMode tile_mode, const Matrix &transformation)
Definition: color_source.cc:9
static ScopedObject< ColorSource > MakeConicalGradient(const Point &start_center, Scalar start_radius, const Point &end_center, Scalar end_radius, const std::vector< flutter::DlColor > &colors, const std::vector< Scalar > &stops, flutter::DlTileMode tile_mode, const Matrix &transformation)
Definition: color_source.cc:51
static ScopedObject< Context > CreateOpenGLES(std::function< void *(const char *gl_proc_name)> proc_address_callback)
Definition: context.cc:65
static ScopedObject< ImageFilter > MakeDilate(Scalar x_radius, Scalar y_radius)
Definition: image_filter.cc:26
static ScopedObject< ImageFilter > MakeErode(Scalar x_radius, Scalar y_radius)
Definition: image_filter.cc:35
static ScopedObject< ImageFilter > MakeCompose(const ImageFilter &outer, const ImageFilter &inner)
Definition: image_filter.cc:54
static ScopedObject< ImageFilter > MakeBlur(Scalar x_sigma, Scalar y_sigma, flutter::DlTileMode tile_mode)
Definition: image_filter.cc:16
static ScopedObject< ImageFilter > MakeMatrix(const Matrix &matrix, flutter::DlImageSampling sampling)
Definition: image_filter.cc:44
static ScopedObject< MaskFilter > MakeBlur(flutter::DlBlurStyle style, float sigma)
Definition: mask_filter.cc:9
static void SafeRelease(void *ptr)
Definition: object.h:43
static void SafeRetain(void *ptr)
Definition: object.h:37
static ScopedObject< Surface > WrapFBO(Context &context, uint64_t fbo, PixelFormat color_format, ISize size)
Definition: surface.cc:23
ImpellerFillType
Definition: impeller.h:317
ImpellerTextDirection
Definition: impeller.h:432
ImpellerTextureSampling
Definition: impeller.h:381
#define IMPELLER_VERSION_GET_PATCH(version)
Definition: impeller.h:133
#define IMPELLER_VERSION_GET_MAJOR(version)
Definition: impeller.h:117
#define IMPELLER_VERSION_GET_VARIANT(version)
Definition: impeller.h:110
ImpellerStrokeJoin
Definition: impeller.h:371
ImpellerBlendMode
Definition: impeller.h:327
#define IMPELLER_VERSION
Definition: impeller.h:101
ImpellerFontWeight
Definition: impeller.h:406
#define IMPELLER_VERSION_GET_MINOR(version)
Definition: impeller.h:125
void *IMPELLER_NULLABLE(* ImpellerProcAddressCallback)(const char *IMPELLER_NONNULL proc_name, void *IMPELLER_NULLABLE user_data)
Definition: impeller.h:310
#define IMPELLER_EXTERN_C
Definition: impeller.h:34
ImpellerStrokeCap
Definition: impeller.h:365
ImpellerDrawStyle
Definition: impeller.h:359
ImpellerTileMode
Definition: impeller.h:386
ImpellerTextAlignment
Definition: impeller.h:423
ImpellerFontStyle
Definition: impeller.h:418
ImpellerClipOperation
Definition: impeller.h:322
ImpellerBlurStyle
Definition: impeller.h:393
ImpellerPixelFormat
Definition: impeller.h:377
IMPELLER_EXTERN_C ImpellerImageFilter ImpellerImageFilterCreateComposeNew(ImpellerImageFilter outer, ImpellerImageFilter inner)
Definition: impeller.cc:884
IMPELLER_EXTERN_C void ImpellerParagraphBuilderRetain(ImpellerParagraphBuilder paragraph_builder)
Definition: impeller.cc:1024
IMPELLER_EXTERN_C ImpellerColorSource ImpellerColorSourceCreateSweepGradientNew(const ImpellerPoint *center, float start, float end, uint32_t stop_count, const ImpellerColor *colors, const float *stops, ImpellerTileMode tile_mode, const ImpellerMatrix *transformation)
Definition: impeller.cc:761
IMPELLER_EXTERN_C ImpellerImageFilter ImpellerImageFilterCreateMatrixNew(const ImpellerMatrix *matrix, ImpellerTextureSampling sampling)
Definition: impeller.cc:875
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawPaint(ImpellerDisplayListBuilder builder, ImpellerPaint paint)
Definition: impeller.cc:390
IMPELLER_EXTERN_C void ImpellerSurfaceRetain(ImpellerSurface surface)
Definition: impeller.cc:619
IMPELLER_EXTERN_C void ImpellerParagraphStyleRelease(ImpellerParagraphStyle paragraph_style)
Definition: impeller.cc:925
IMPELLER_EXTERN_C uint32_t ImpellerGetVersion()
Definition: impeller.cc:68
IMPELLER_EXTERN_C void ImpellerParagraphStyleRetain(ImpellerParagraphStyle paragraph_style)
Definition: impeller.cc:920
IMPELLER_EXTERN_C void ImpellerPaintSetColorSource(ImpellerPaint paint, ImpellerColorSource color_source)
Definition: impeller.cc:897
IMPELLER_EXTERN_C void ImpellerPathBuilderClose(ImpellerPathBuilder builder)
Definition: impeller.cc:290
IMPELLER_EXTERN_C void ImpellerPathBuilderQuadraticCurveTo(ImpellerPathBuilder builder, const ImpellerPoint *control_point, const ImpellerPoint *end_point)
Definition: impeller.cc:239
IMPELLER_EXTERN_C uint64_t ImpellerTextureGetOpenGLHandle(ImpellerTexture texture)
Definition: impeller.cc:566
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderRetain(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:114
IMPELLER_EXTERN_C void ImpellerParagraphBuilderPopStyle(ImpellerParagraphBuilder paragraph_builder)
Definition: impeller.cc:1043
IMPELLER_EXTERN_C ImpellerMaskFilter ImpellerMaskFilterCreateBlurNew(ImpellerBlurStyle style, float sigma)
Definition: impeller.cc:838
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetMaxLines(ImpellerParagraphStyle paragraph_style, uint32_t max_lines)
Definition: impeller.cc:993
IMPELLER_EXTERN_C void ImpellerColorFilterRetain(ImpellerColorFilter color_filter)
Definition: impeller.cc:803
IMPELLER_EXTERN_C ImpellerSurface ImpellerSurfaceCreateWrappedFBONew(ImpellerContext context, uint64_t fbo, ImpellerPixelFormat format, const ImpellerISize *size)
Definition: impeller.cc:607
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawTextureRect(ImpellerDisplayListBuilder builder, ImpellerTexture texture, const ImpellerRect *src_rect, const ImpellerRect *dst_rect, ImpellerTextureSampling sampling, ImpellerPaint paint)
Definition: impeller.cc:648
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderSave(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:124
IMPELLER_EXTERN_C ImpellerDisplayList ImpellerDisplayListBuilderCreateDisplayListNew(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:589
IMPELLER_EXTERN_C void ImpellerPathBuilderRelease(ImpellerPathBuilder builder)
Definition: impeller.cc:222
IMPELLER_EXTERN_C ImpellerParagraphBuilder ImpellerParagraphBuilderNew(ImpellerTypographyContext context)
Definition: impeller.cc:1012
IMPELLER_EXTERN_C ImpellerColorFilter ImpellerColorFilterCreateColorMatrixNew(const ImpellerColorMatrix *color_matrix)
Definition: impeller.cc:822
static std::pair< std::vector< flutter::DlColor >, std::vector< Scalar > > ParseColorsAndStops(uint32_t stop_count, const ImpellerColor *colors, const float *stops)
Definition: impeller.cc:674
IMPELLER_EXTERN_C void ImpellerPaintRelease(ImpellerPaint paint)
Definition: impeller.cc:350
IMPELLER_EXTERN_C ImpellerDisplayListBuilder ImpellerDisplayListBuilderNew(const ImpellerRect *cull_rect)
Definition: impeller.cc:108
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetFontStyle(ImpellerParagraphStyle paragraph_style, ImpellerFontStyle style)
Definition: impeller.cc:948
IMPELLER_EXTERN_C ImpellerPaint ImpellerPaintNew()
Definition: impeller.cc:340
IMPELLER_EXTERN_C void ImpellerTypographyContextRetain(ImpellerTypographyContext context)
Definition: impeller.cc:1129
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetTextDirection(ImpellerParagraphStyle paragraph_style, ImpellerTextDirection direction)
Definition: impeller.cc:986
ScopedObject< Object > Ref(Object *object)
Definition: object.h:145
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawOval(ImpellerDisplayListBuilder builder, const ImpellerRect *oval_bounds, ImpellerPaint paint)
Definition: impeller.cc:430
IMPELLER_EXTERN_C ImpellerParagraph ImpellerParagraphBuilderBuildParagraphNew(ImpellerParagraphBuilder paragraph_builder, float width)
Definition: impeller.cc:1062
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderSaveLayer(ImpellerDisplayListBuilder builder, const ImpellerRect *bounds, ImpellerPaint paint, ImpellerImageFilter backdrop)
Definition: impeller.cc:129
IMPELLER_EXTERN_C void ImpellerPathBuilderAddRect(ImpellerPathBuilder builder, const ImpellerRect *rect)
Definition: impeller.cc:258
IMPELLER_EXTERN_C void ImpellerPaintSetStrokeCap(ImpellerPaint paint, ImpellerStrokeCap cap)
Definition: impeller.cc:370
IMPELLER_EXTERN_C void ImpellerParagraphBuilderRelease(ImpellerParagraphBuilder paragraph_builder)
Definition: impeller.cc:1030
IMPELLER_EXTERN_C void ImpellerPathBuilderLineTo(ImpellerPathBuilder builder, const ImpellerPoint *location)
Definition: impeller.cc:233
IMPELLER_EXTERN_C void ImpellerPathRetain(ImpellerPath path)
Definition: impeller.cc:202
IMPELLER_EXTERN_C void ImpellerPaintSetStrokeJoin(ImpellerPaint paint, ImpellerStrokeJoin join)
Definition: impeller.cc:375
IMPELLER_EXTERN_C float ImpellerParagraphGetHeight(ImpellerParagraph paragraph)
Definition: impeller.cc:1084
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderClipOval(ImpellerDisplayListBuilder builder, const ImpellerRect *oval_bounds, ImpellerClipOperation op)
Definition: impeller.cc:314
IMPELLER_EXTERN_C void ImpellerPathBuilderRetain(ImpellerPathBuilder builder)
Definition: impeller.cc:217
IMPELLER_EXTERN_C void ImpellerParagraphBuilderPushStyle(ImpellerParagraphBuilder paragraph_builder, ImpellerParagraphStyle style)
Definition: impeller.cc:1036
IMPELLER_EXTERN_C void ImpellerPathBuilderAddOval(ImpellerPathBuilder builder, const ImpellerRect *oval_bounds)
Definition: impeller.cc:275
IMPELLER_EXTERN_C ImpellerTypographyContext ImpellerTypographyContextNew()
Definition: impeller.cc:1119
IMPELLER_EXTERN_C float ImpellerParagraphGetAlphabeticBaseline(ImpellerParagraph paragraph)
Definition: impeller.cc:1109
IMPELLER_EXTERN_C void ImpellerPathRelease(ImpellerPath path)
Definition: impeller.cc:207
IMPELLER_EXTERN_C ImpellerImageFilter ImpellerImageFilterCreateBlurNew(float x_sigma, float y_sigma, ImpellerTileMode tile_mode)
Definition: impeller.cc:854
IMPELLER_EXTERN_C void ImpellerColorSourceRetain(ImpellerColorSource color_source)
Definition: impeller.cc:664
IMPELLER_EXTERN_C float ImpellerParagraphGetMinIntrinsicWidth(ImpellerParagraph paragraph)
Definition: impeller.cc:1094
IMPELLER_EXTERN_C void ImpellerPaintSetStrokeWidth(ImpellerPaint paint, float width)
Definition: impeller.cc:380
IMPELLER_EXTERN_C void ImpellerMaskFilterRetain(ImpellerMaskFilter mask_filter)
Definition: impeller.cc:828
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawDashedLine(ImpellerDisplayListBuilder builder, const ImpellerPoint *from, const ImpellerPoint *to, float on_length, float off_length, ImpellerPaint paint)
Definition: impeller.cc:407
IMPELLER_EXTERN_C ImpellerPath ImpellerPathBuilderTakePathNew(ImpellerPathBuilder builder, ImpellerFillType fill)
Definition: impeller.cc:301
IMPELLER_EXTERN_C ImpellerPath ImpellerPathBuilderCopyPathNew(ImpellerPathBuilder builder, ImpellerFillType fill)
Definition: impeller.cc:295
IMPELLER_EXTERN_C void ImpellerColorSourceRelease(ImpellerColorSource color_source)
Definition: impeller.cc:669
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderClipRoundedRect(ImpellerDisplayListBuilder builder, const ImpellerRect *rect, const ImpellerRoundingRadii *radii, ImpellerClipOperation op)
Definition: impeller.cc:321
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderClipRect(ImpellerDisplayListBuilder builder, const ImpellerRect *rect, ImpellerClipOperation op)
Definition: impeller.cc:307
constexpr Matrix ToImpellerType(const ImpellerMatrix &m)
Definition: formats.h:201
IMPELLER_EXTERN_C ImpellerColorSource ImpellerColorSourceCreateRadialGradientNew(const ImpellerPoint *center, float radius, uint32_t stop_count, const ImpellerColor *colors, const float *stops, ImpellerTileMode tile_mode, const ImpellerMatrix *transformation)
Definition: impeller.cc:713
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetTextAlignment(ImpellerParagraphStyle paragraph_style, ImpellerTextAlignment align)
Definition: impeller.cc:979
IMPELLER_EXTERN_C void ImpellerTypographyContextRelease(ImpellerTypographyContext context)
Definition: impeller.cc:1134
IMPELLER_EXTERN_C ImpellerTexture ImpellerTextureCreateWithOpenGLTextureHandleNew(ImpellerContext context, const ImpellerTextureDescriptor *descriptor, uint64_t external_gl_handle)
Definition: impeller.cc:517
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawRoundedRect(ImpellerDisplayListBuilder builder, const ImpellerRect *rect, const ImpellerRoundingRadii *radii, ImpellerPaint paint)
Definition: impeller.cc:437
IMPELLER_EXTERN_C ImpellerTexture ImpellerTextureCreateWithContentsNew(ImpellerContext context, const ImpellerTextureDescriptor *descriptor, const ImpellerMapping *contents, void *contents_on_release_user_data)
Definition: impeller.cc:472
IMPELLER_EXTERN_C void ImpellerPathBuilderMoveTo(ImpellerPathBuilder builder, const ImpellerPoint *location)
Definition: impeller.cc:227
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderTransform(ImpellerDisplayListBuilder builder, const ImpellerMatrix *transform)
Definition: impeller.cc:171
IMPELLER_EXTERN_C void ImpellerColorFilterRelease(ImpellerColorFilter color_filter)
Definition: impeller.cc:808
IMPELLER_EXTERN_C bool ImpellerTypographyContextRegisterFont(ImpellerTypographyContext context, const ImpellerMapping *contents, void *contents_on_release_user_data, const char *family_name_alias)
Definition: impeller.cc:1139
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetFontWeight(ImpellerParagraphStyle paragraph_style, ImpellerFontWeight weight)
Definition: impeller.cc:942
IMPELLER_EXTERN_C float ImpellerParagraphGetMaxIntrinsicWidth(ImpellerParagraph paragraph)
Definition: impeller.cc:1099
IMPELLER_EXTERN_C ImpellerColorSource ImpellerColorSourceCreateLinearGradientNew(const ImpellerPoint *start_point, const ImpellerPoint *end_point, uint32_t stop_count, const ImpellerColor *colors, const float *stops, ImpellerTileMode tile_mode, const ImpellerMatrix *transformation)
Definition: impeller.cc:691
IMPELLER_EXTERN_C ImpellerPathBuilder ImpellerPathBuilderNew()
Definition: impeller.cc:212
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetFontSize(ImpellerParagraphStyle paragraph_style, float size)
Definition: impeller.cc:967
IMPELLER_EXTERN_C void ImpellerTextureRelease(ImpellerTexture texture)
Definition: impeller.cc:561
IMPELLER_EXTERN_C void ImpellerContextRelease(ImpellerContext context)
Definition: impeller.cc:103
IMPELLER_EXTERN_C void ImpellerImageFilterRelease(ImpellerImageFilter image_filter)
Definition: impeller.cc:849
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawParagraph(ImpellerDisplayListBuilder builder, ImpellerParagraph paragraph, const ImpellerPoint *point)
Definition: impeller.cc:1005
IMPELLER_EXTERN_C ImpellerContext ImpellerContextCreateOpenGLESNew(uint32_t version, ImpellerProcAddressCallback gl_proc_address_callback, void *gl_proc_address_callback_user_data)
Definition: impeller.cc:73
constexpr txt::FontWeight ToTxtType(ImpellerFontWeight weight)
Definition: formats.h:430
IMPELLER_EXTERN_C ImpellerColorSource ImpellerColorSourceCreateImageNew(ImpellerTexture image, ImpellerTileMode horizontal_tile_mode, ImpellerTileMode vertical_tile_mode, ImpellerTextureSampling sampling, const ImpellerMatrix *transformation)
Definition: impeller.cc:785
IMPELLER_EXTERN_C void ImpellerMaskFilterRelease(ImpellerMaskFilter mask_filter)
Definition: impeller.cc:833
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetFontFamily(ImpellerParagraphStyle paragraph_style, const char *family_name)
Definition: impeller.cc:961
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetHeight(ImpellerParagraphStyle paragraph_style, float height)
Definition: impeller.cc:973
IMPELLER_EXTERN_C void ImpellerPaintRetain(ImpellerPaint paint)
Definition: impeller.cc:345
IMPELLER_EXTERN_C void ImpellerContextRetain(ImpellerContext context)
Definition: impeller.cc:98
IMPELLER_EXTERN_C void ImpellerParagraphRelease(ImpellerParagraph paragraph)
Definition: impeller.cc:1074
IMPELLER_EXTERN_C void ImpellerPaintSetBlendMode(ImpellerPaint paint, ImpellerBlendMode mode)
Definition: impeller.cc:360
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderResetTransform(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:183
static std::string GetVersionAsString(uint32_t version)
Definition: impeller.cc:58
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderScale(ImpellerDisplayListBuilder builder, float x_scale, float y_scale)
Definition: impeller.cc:145
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetLocale(ImpellerParagraphStyle paragraph_style, const char *locale)
Definition: impeller.cc:999
IMPELLER_EXTERN_C bool ImpellerSurfaceDrawDisplayList(ImpellerSurface surface, ImpellerDisplayList display_list)
Definition: impeller.cc:629
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawLine(ImpellerDisplayListBuilder builder, const ImpellerPoint *from, const ImpellerPoint *to, ImpellerPaint paint)
Definition: impeller.cc:396
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawDisplayList(ImpellerDisplayListBuilder builder, ImpellerDisplayList display_list, float opacity)
Definition: impeller.cc:599
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderRestore(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:140
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderTranslate(ImpellerDisplayListBuilder builder, float x_translation, float y_translation)
Definition: impeller.cc:158
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetForeground(ImpellerParagraphStyle paragraph_style, ImpellerPaint paint)
Definition: impeller.cc:930
IMPELLER_EXTERN_C uint32_t ImpellerDisplayListBuilderGetSaveCount(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:189
IMPELLER_EXTERN_C ImpellerImageFilter ImpellerImageFilterCreateDilateNew(float x_radius, float y_radius)
Definition: impeller.cc:863
IMPELLER_EXTERN_C void ImpellerPaintSetStrokeMiter(ImpellerPaint paint, float miter)
Definition: impeller.cc:385
IMPELLER_EXTERN_C ImpellerParagraphStyle ImpellerParagraphStyleNew()
Definition: impeller.cc:915
IMPELLER_EXTERN_C void ImpellerTextureRetain(ImpellerTexture texture)
Definition: impeller.cc:556
IMPELLER_EXTERN_C void ImpellerPathBuilderCubicCurveTo(ImpellerPathBuilder builder, const ImpellerPoint *control_point_1, const ImpellerPoint *control_point_2, const ImpellerPoint *end_point)
Definition: impeller.cc:247
IMPELLER_EXTERN_C void ImpellerImageFilterRetain(ImpellerImageFilter image_filter)
Definition: impeller.cc:844
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawRoundedRectDifference(ImpellerDisplayListBuilder builder, const ImpellerRect *outer_rect, const ImpellerRoundingRadii *outer_radii, const ImpellerRect *inner_rect, const ImpellerRoundingRadii *inner_radii, ImpellerPaint paint)
Definition: impeller.cc:449
IMPELLER_EXTERN_C void ImpellerParagraphRetain(ImpellerParagraph paragraph)
Definition: impeller.cc:1069
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderRelease(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:119
IMPELLER_EXTERN_C ImpellerColorFilter ImpellerColorFilterCreateBlendNew(const ImpellerColor *color, ImpellerBlendMode blend_mode)
Definition: impeller.cc:813
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderRestoreToCount(ImpellerDisplayListBuilder builder, uint32_t count)
Definition: impeller.cc:195
IMPELLER_EXTERN_C float ImpellerParagraphGetLongestLineWidth(ImpellerParagraph paragraph)
Definition: impeller.cc:1089
IMPELLER_EXTERN_C void ImpellerPaintSetMaskFilter(ImpellerPaint paint, ImpellerMaskFilter mask_filter)
Definition: impeller.cc:909
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderSetTransform(ImpellerDisplayListBuilder builder, const ImpellerMatrix *transform)
Definition: impeller.cc:165
IMPELLER_EXTERN_C uint32_t ImpellerParagraphGetLineCount(ImpellerParagraph paragraph)
Definition: impeller.cc:1114
IMPELLER_EXTERN_C ImpellerImageFilter ImpellerImageFilterCreateErodeNew(float x_radius, float y_radius)
Definition: impeller.cc:869
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderGetTransform(ImpellerDisplayListBuilder builder, ImpellerMatrix *out_transform)
Definition: impeller.cc:177
IMPELLER_EXTERN_C void ImpellerSurfaceRelease(ImpellerSurface surface)
Definition: impeller.cc:624
constexpr void FromImpellerType(const Matrix &from, ImpellerMatrix &to)
Definition: formats.h:209
static std::string ReadString(const char *string)
Definition: impeller.cc:953
IMPELLER_EXTERN_C void ImpellerPaintSetColorFilter(ImpellerPaint paint, ImpellerColorFilter color_filter)
Definition: impeller.cc:891
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderRotate(ImpellerDisplayListBuilder builder, float angle_degrees)
Definition: impeller.cc:152
IMPELLER_EXTERN_C float ImpellerParagraphGetMaxWidth(ImpellerParagraph paragraph)
Definition: impeller.cc:1079
DEFINE_PEER_GETTER(ColorFilter, ImpellerColorFilter)
IMPELLER_EXTERN_C void ImpellerPathBuilderAddRoundedRect(ImpellerPathBuilder builder, const ImpellerRect *rect, const ImpellerRoundingRadii *rounding_radii)
Definition: impeller.cc:281
IMPELLER_EXTERN_C float ImpellerParagraphGetIdeographicBaseline(ImpellerParagraph paragraph)
Definition: impeller.cc:1104
constexpr flutter::DlColor ToDisplayListType(Color color)
Definition: formats.h:77
IMPELLER_EXTERN_C void ImpellerPaintSetDrawStyle(ImpellerPaint paint, ImpellerDrawStyle style)
Definition: impeller.cc:365
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawTexture(ImpellerDisplayListBuilder builder, ImpellerTexture texture, const ImpellerPoint *point, ImpellerTextureSampling sampling, ImpellerPaint paint)
Definition: impeller.cc:635
IMPELLER_EXTERN_C void ImpellerPaintSetImageFilter(ImpellerPaint paint, ImpellerImageFilter image_filter)
Definition: impeller.cc:903
IMPELLER_EXTERN_C void ImpellerDisplayListRelease(ImpellerDisplayList display_list)
Definition: impeller.cc:584
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderClipPath(ImpellerDisplayListBuilder builder, ImpellerPath path, ImpellerClipOperation op)
Definition: impeller.cc:333
IMPELLER_EXTERN_C ImpellerColorSource ImpellerColorSourceCreateConicalGradientNew(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)
Definition: impeller.cc:735
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawPath(ImpellerDisplayListBuilder builder, ImpellerPath path, ImpellerPaint paint)
Definition: impeller.cc:465
IMPELLER_EXTERN_C void ImpellerPathBuilderAddArc(ImpellerPathBuilder builder, const ImpellerRect *oval_bounds, float start_angle_degrees, float end_angle_degrees)
Definition: impeller.cc:264
IMPELLER_EXTERN_C void ImpellerDisplayListRetain(ImpellerDisplayList display_list)
Definition: impeller.cc:579
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetBackground(ImpellerParagraphStyle paragraph_style, ImpellerPaint paint)
Definition: impeller.cc:936
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawRect(ImpellerDisplayListBuilder builder, const ImpellerRect *rect, ImpellerPaint paint)
Definition: impeller.cc:423
IMPELLER_EXTERN_C void ImpellerPaintSetColor(ImpellerPaint paint, const ImpellerColor *color)
Definition: impeller.cc:355
IMPELLER_EXTERN_C void ImpellerParagraphBuilderAddText(ImpellerParagraphBuilder paragraph_builder, const uint8_t *data, uint32_t length)
Definition: impeller.cc:1049
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
ImpellerPixelFormat pixel_format
Definition: impeller.h:554
ImpellerISize size
Definition: impeller.h:555
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:64
#define VALIDATION_LOG
Definition: validation.h:91