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 <algorithm>
8 #include <iterator>
9 #include <sstream>
10 
11 #include "flutter/fml/mapping.h"
37 
38 #if IMPELLER_ENABLE_OPENGLES
41 #endif // IMPELLER_ENABLE_OPENGLES
42 
43 #if IMPELLER_ENABLE_METAL
46 #endif // IMPELLER_ENABLE_METAL
47 
48 #if IMPELLER_ENABLE_VULKAN
52 #endif // IMPELLER_ENABLE_VULKAN
53 
54 namespace impeller::interop {
55 
56 #define DEFINE_PEER_GETTER(cxx_type, c_type) \
57  cxx_type* GetPeer(c_type object) { \
58  return reinterpret_cast<cxx_type*>(object); \
59  }
60 
61 DEFINE_PEER_GETTER(ColorFilter, ImpellerColorFilter);
62 DEFINE_PEER_GETTER(ColorSource, ImpellerColorSource);
63 DEFINE_PEER_GETTER(Context, ImpellerContext);
64 DEFINE_PEER_GETTER(DisplayList, ImpellerDisplayList);
65 DEFINE_PEER_GETTER(DisplayListBuilder, ImpellerDisplayListBuilder);
66 DEFINE_PEER_GETTER(FragmentProgram, ImpellerFragmentProgram);
67 DEFINE_PEER_GETTER(GlyphInfo, ImpellerGlyphInfo);
68 DEFINE_PEER_GETTER(ImageFilter, ImpellerImageFilter);
69 DEFINE_PEER_GETTER(LineMetrics, ImpellerLineMetrics);
70 DEFINE_PEER_GETTER(MaskFilter, ImpellerMaskFilter);
71 DEFINE_PEER_GETTER(Paint, ImpellerPaint);
72 DEFINE_PEER_GETTER(Paragraph, ImpellerParagraph);
73 DEFINE_PEER_GETTER(ParagraphBuilder, ImpellerParagraphBuilder);
74 DEFINE_PEER_GETTER(ParagraphStyle, ImpellerParagraphStyle);
75 DEFINE_PEER_GETTER(Path, ImpellerPath);
76 DEFINE_PEER_GETTER(PathBuilder, ImpellerPathBuilder);
77 DEFINE_PEER_GETTER(Surface, ImpellerSurface);
78 DEFINE_PEER_GETTER(SwapchainVK, ImpellerVulkanSwapchain);
79 DEFINE_PEER_GETTER(Texture, ImpellerTexture);
80 DEFINE_PEER_GETTER(TypographyContext, ImpellerTypographyContext);
81 
82 static std::string GetVersionAsString(uint32_t version) {
83  std::stringstream stream;
84  stream << IMPELLER_VERSION_GET_VARIANT(version) << "."
85  << IMPELLER_VERSION_GET_MAJOR(version) << "."
86  << IMPELLER_VERSION_GET_MINOR(version) << "."
87  << IMPELLER_VERSION_GET_PATCH(version);
88  return stream.str();
89 }
90 
92 uint32_t ImpellerGetVersion() {
93  return IMPELLER_VERSION;
94 }
95 
96 static bool CheckVersion(uint32_t version) {
97  if (version != IMPELLER_VERSION) {
98  VALIDATION_LOG << "This version of Impeller ("
100  << "doesn't match the version the user expects ("
101  << GetVersionAsString(version) << ").";
102  return false;
103  }
104  return true;
105 }
106 
109  uint32_t version,
110  ImpellerProcAddressCallback gl_proc_address_callback,
111  void* gl_proc_address_callback_user_data) {
112  if (!CheckVersion(version)) {
113  return nullptr;
114  }
115 #if IMPELLER_ENABLE_OPENGLES
117  [gl_proc_address_callback,
118  gl_proc_address_callback_user_data](const char* proc_name) -> void* {
119  return gl_proc_address_callback(proc_name,
120  gl_proc_address_callback_user_data);
121  });
122  if (!context || !context->IsValid()) {
123  VALIDATION_LOG << "Could not create valid context.";
124  return nullptr;
125  }
126  return context.Leak();
127 #else // IMPELLER_ENABLE_OPENGLES
128  VALIDATION_LOG << "OpenGLES not available.";
129  return nullptr;
130 #endif // IMPELLER_ENABLE_OPENGLES
131 }
132 
133 IMPELLER_EXTERN_C ImpellerContext
134 ImpellerContextCreateMetalNew(uint32_t version) {
135  if (!CheckVersion(version)) {
136  return nullptr;
137  }
138 #if IMPELLER_ENABLE_METAL
139  auto context = ContextMTL::Create();
140  if (!context || !context->IsValid()) {
141  VALIDATION_LOG << "Could not create valid context.";
142  return nullptr;
143  }
144  return context.Leak();
145 #else // IMPELLER_ENABLE_METAL
146  VALIDATION_LOG << "Metal not available.";
147  return nullptr;
148 #endif // IMPELLER_ENABLE_METAL
149 }
150 
151 IMPELLER_EXTERN_C ImpellerContext
153  const ImpellerContextVulkanSettings* settings) {
154  if (!CheckVersion(version)) {
155  return nullptr;
156  }
157 #if IMPELLER_ENABLE_VULKAN
158  auto context = ContextVK::Create(ContextVK::Settings(*settings));
159  if (!context || !context->IsValid()) {
160  VALIDATION_LOG << "Could not create valid context.";
161  return nullptr;
162  }
163  return context.Leak();
164 #else // IMPELLER_ENABLE_VULKAN
165  VALIDATION_LOG << "Vulkan not available.";
166  return nullptr;
167 #endif // IMPELLER_ENABLE_VULKAN
168 }
169 
171 void ImpellerContextRetain(ImpellerContext context) {
173 }
174 
176 void ImpellerContextRelease(ImpellerContext context) {
178 }
179 
182  ImpellerContextVulkanInfo* out_vulkan_info) {
183 #if IMPELLER_ENABLE_VULKAN
184  if (!GetPeer(context)->IsVulkan()) {
185  VALIDATION_LOG << "Not a Vulkan context.";
186  return false;
187  }
188  return reinterpret_cast<ContextVK*>(GetPeer(context))
189  ->GetInfo(*out_vulkan_info);
190 #else // IMPELLER_ENABLE_VULKAN
191  VALIDATION_LOG << "Vulkan not available.";
192  return nullptr;
193 #endif // IMPELLER_ENABLE_VULKAN
194 }
195 
197 ImpellerVulkanSwapchain ImpellerVulkanSwapchainCreateNew(
198  ImpellerContext context,
199  void* vulkan_surface_khr) {
200 #if IMPELLER_ENABLE_VULKAN
201  return Create<SwapchainVK>(
202  *GetPeer(context), //
203  reinterpret_cast<VkSurfaceKHR>(vulkan_surface_khr) //
204  )
205  .Leak();
206 #else // IMPELLER_ENABLE_VULKAN
207  VALIDATION_LOG << "Vulkan not available.";
208  return nullptr;
209 #endif // IMPELLER_ENABLE_VULKAN
210 }
211 
213 void ImpellerVulkanSwapchainRetain(ImpellerVulkanSwapchain swapchain) {
214  ObjectBase::SafeRetain(swapchain);
215 }
216 
218 void ImpellerVulkanSwapchainRelease(ImpellerVulkanSwapchain swapchain) {
219  ObjectBase::SafeRelease(swapchain);
220 }
221 
224  ImpellerVulkanSwapchain swapchain) {
225  return GetPeer(swapchain)->AcquireNextSurface().Leak();
226 }
227 
228 IMPELLER_EXTERN_C ImpellerDisplayListBuilder
230  return Create<DisplayListBuilder>(cull_rect).Leak();
231 }
232 
234 void ImpellerDisplayListBuilderRetain(ImpellerDisplayListBuilder builder) {
235  ObjectBase::SafeRetain(builder);
236 }
237 
239 void ImpellerDisplayListBuilderRelease(ImpellerDisplayListBuilder builder) {
240  ObjectBase::SafeRelease(builder);
241 }
242 
244 void ImpellerDisplayListBuilderSave(ImpellerDisplayListBuilder builder) {
245  GetPeer(builder)->Save();
246 }
247 
249 void ImpellerDisplayListBuilderSaveLayer(ImpellerDisplayListBuilder builder,
250  const ImpellerRect* bounds,
251  ImpellerPaint paint,
252  ImpellerImageFilter backdrop) {
253  GetPeer(builder)->SaveLayer(ToImpellerType(*bounds), //
254  GetPeer(paint), //
255  GetPeer(backdrop) //
256  );
257 }
258 
260 void ImpellerDisplayListBuilderRestore(ImpellerDisplayListBuilder builder) {
261  GetPeer(builder)->Restore();
262 }
263 
265 void ImpellerDisplayListBuilderScale(ImpellerDisplayListBuilder builder,
266  float x_scale,
267  float y_scale) {
268  GetPeer(builder)->Scale(Size{x_scale, y_scale});
269 }
270 
272 void ImpellerDisplayListBuilderRotate(ImpellerDisplayListBuilder builder,
273  float angle_degrees) {
274  GetPeer(builder)->Rotate(Degrees{angle_degrees});
275 }
276 
278 void ImpellerDisplayListBuilderTranslate(ImpellerDisplayListBuilder builder,
279  float x_translation,
280  float y_translation) {
281  GetPeer(builder)->Translate(Point{x_translation, y_translation});
282 }
283 
285 void ImpellerDisplayListBuilderSetTransform(ImpellerDisplayListBuilder builder,
286  const ImpellerMatrix* transform) {
287  GetPeer(builder)->SetTransform(ToImpellerType(*transform));
288 }
289 
291 void ImpellerDisplayListBuilderTransform(ImpellerDisplayListBuilder builder,
292  const ImpellerMatrix* transform) {
293  GetPeer(builder)->Transform(ToImpellerType(*transform));
294 }
295 
297 void ImpellerDisplayListBuilderGetTransform(ImpellerDisplayListBuilder builder,
298  ImpellerMatrix* out_transform) {
299  FromImpellerType(GetPeer(builder)->GetTransform(), *out_transform);
300 }
301 
304  ImpellerDisplayListBuilder builder) {
305  GetPeer(builder)->ResetTransform();
306 }
307 
310  ImpellerDisplayListBuilder builder) {
311  return GetPeer(builder)->GetSaveCount();
312 }
313 
316  ImpellerDisplayListBuilder builder,
317  uint32_t count) {
318  GetPeer(builder)->RestoreToCount(count);
319 }
320 
322 void ImpellerPathRetain(ImpellerPath path) {
324 }
325 
327 void ImpellerPathRelease(ImpellerPath path) {
329 }
330 
332 void ImpellerPathGetBounds(ImpellerPath path, ImpellerRect* out_bounds) {
333  *out_bounds = GetPeer(path)->GetBounds();
334 }
335 
337 ImpellerPathBuilder ImpellerPathBuilderNew() {
338  return Create<PathBuilder>().Leak();
339 }
340 
342 void ImpellerPathBuilderRetain(ImpellerPathBuilder builder) {
343  ObjectBase::SafeRetain(builder);
344 }
345 
347 void ImpellerPathBuilderRelease(ImpellerPathBuilder builder) {
348  ObjectBase::SafeRelease(builder);
349 }
350 
352 void ImpellerPathBuilderMoveTo(ImpellerPathBuilder builder,
353  const ImpellerPoint* location) {
354  GetPeer(builder)->MoveTo(ToImpellerType(*location));
355 }
356 
358 void ImpellerPathBuilderLineTo(ImpellerPathBuilder builder,
359  const ImpellerPoint* location) {
360  GetPeer(builder)->LineTo(ToImpellerType(*location));
361 }
362 
364 void ImpellerPathBuilderQuadraticCurveTo(ImpellerPathBuilder builder,
365  const ImpellerPoint* control_point,
366  const ImpellerPoint* end_point) {
367  GetPeer(builder)->QuadraticCurveTo(ToImpellerType(*control_point),
368  ToImpellerType(*end_point));
369 }
370 
372 void ImpellerPathBuilderCubicCurveTo(ImpellerPathBuilder builder,
373  const ImpellerPoint* control_point_1,
374  const ImpellerPoint* control_point_2,
375  const ImpellerPoint* end_point) {
376  GetPeer(builder)->CubicCurveTo(ToImpellerType(*control_point_1), //
377  ToImpellerType(*control_point_2), //
378  ToImpellerType(*end_point) //
379  );
380 }
381 
383 void ImpellerPathBuilderAddRect(ImpellerPathBuilder builder,
384  const ImpellerRect* rect) {
385  GetPeer(builder)->AddRect(ToImpellerType(*rect));
386 }
387 
389 void ImpellerPathBuilderAddArc(ImpellerPathBuilder builder,
390  const ImpellerRect* oval_bounds,
391  float start_angle_degrees,
392  float end_angle_degrees) {
393  GetPeer(builder)->AddArc(ToImpellerType(*oval_bounds), //
394  Degrees{start_angle_degrees}, //
395  Degrees{end_angle_degrees} //
396  );
397 }
398 
400 void ImpellerPathBuilderAddOval(ImpellerPathBuilder builder,
401  const ImpellerRect* oval_bounds) {
402  GetPeer(builder)->AddOval(ToImpellerType(*oval_bounds));
403 }
404 
407  ImpellerPathBuilder builder,
408  const ImpellerRect* rect,
409  const ImpellerRoundingRadii* rounding_radii) {
410  GetPeer(builder)->AddRoundedRect(ToImpellerType(*rect),
411  ToImpellerType(*rounding_radii));
412 }
413 
415 void ImpellerPathBuilderClose(ImpellerPathBuilder builder) {
416  GetPeer(builder)->Close();
417 }
418 
420 ImpellerPath ImpellerPathBuilderCopyPathNew(ImpellerPathBuilder builder,
421  ImpellerFillType fill) {
422  return GetPeer(builder)->CopyPath(ToImpellerType(fill)).Leak();
423 }
424 
426 ImpellerPath ImpellerPathBuilderTakePathNew(ImpellerPathBuilder builder,
427  ImpellerFillType fill) {
428  return GetPeer(builder)->TakePath(ToImpellerType(fill)).Leak();
429 }
430 
432 void ImpellerDisplayListBuilderClipRect(ImpellerDisplayListBuilder builder,
433  const ImpellerRect* rect,
435  GetPeer(builder)->ClipRect(ToImpellerType(*rect), ToImpellerType(op));
436 }
437 
439 void ImpellerDisplayListBuilderClipOval(ImpellerDisplayListBuilder builder,
440  const ImpellerRect* oval_bounds,
442  GetPeer(builder)->ClipOval(ToImpellerType(*oval_bounds), ToImpellerType(op));
443 }
444 
447  ImpellerDisplayListBuilder builder,
448  const ImpellerRect* rect,
449  const ImpellerRoundingRadii* radii,
451  GetPeer(builder)->ClipRoundedRect(ToImpellerType(*rect), //
452  ToImpellerType(*radii), //
453  ToImpellerType(op) //
454  );
455 }
456 
458 void ImpellerDisplayListBuilderClipPath(ImpellerDisplayListBuilder builder,
459  ImpellerPath path,
461  GetPeer(builder)->ClipPath(*GetPeer(path), ToImpellerType(op));
462 }
463 
465 ImpellerPaint ImpellerPaintNew() {
466  return Create<Paint>().Leak();
467 }
468 
470 void ImpellerPaintRetain(ImpellerPaint paint) {
471  ObjectBase::SafeRetain(paint);
472 }
473 
475 void ImpellerPaintRelease(ImpellerPaint paint) {
477 }
478 
480 void ImpellerPaintSetColor(ImpellerPaint paint, const ImpellerColor* color) {
481  GetPeer(paint)->SetColor(ToDisplayListType(*color));
482 }
483 
485 void ImpellerPaintSetBlendMode(ImpellerPaint paint, ImpellerBlendMode mode) {
486  GetPeer(paint)->SetBlendMode(ToImpellerType(mode));
487 }
488 
490 void ImpellerPaintSetDrawStyle(ImpellerPaint paint, ImpellerDrawStyle style) {
491  GetPeer(paint)->SetDrawStyle(ToDisplayListType(style));
492 }
493 
495 void ImpellerPaintSetStrokeCap(ImpellerPaint paint, ImpellerStrokeCap cap) {
496  GetPeer(paint)->SetStrokeCap(ToDisplayListType(cap));
497 }
498 
500 void ImpellerPaintSetStrokeJoin(ImpellerPaint paint, ImpellerStrokeJoin join) {
501  GetPeer(paint)->SetStrokeJoin(ToDisplayListType(join));
502 }
503 
505 void ImpellerPaintSetStrokeWidth(ImpellerPaint paint, float width) {
506  GetPeer(paint)->SetStrokeWidth(width);
507 }
508 
510 void ImpellerPaintSetStrokeMiter(ImpellerPaint paint, float miter) {
511  GetPeer(paint)->SetStrokeMiter(miter);
512 }
513 
515 void ImpellerDisplayListBuilderDrawPaint(ImpellerDisplayListBuilder builder,
516  ImpellerPaint paint) {
517  GetPeer(builder)->DrawPaint(*GetPeer(paint));
518 }
519 
521 void ImpellerDisplayListBuilderDrawLine(ImpellerDisplayListBuilder builder,
522  const ImpellerPoint* from,
523  const ImpellerPoint* to,
524  ImpellerPaint paint) {
525  GetPeer(builder)->DrawLine(ToImpellerType(*from), //
526  ToImpellerType(*to), //
527  *GetPeer(paint) //
528  );
529 }
530 
533  ImpellerDisplayListBuilder builder,
534  const ImpellerPoint* from,
535  const ImpellerPoint* to,
536  float on_length,
537  float off_length,
538  ImpellerPaint paint) {
539  GetPeer(builder)->DrawDashedLine(ToImpellerType(*from), //
540  ToImpellerType(*to), //
541  on_length, //
542  off_length, //
543  *GetPeer(paint) //
544  );
545 }
546 
548 void ImpellerDisplayListBuilderDrawRect(ImpellerDisplayListBuilder builder,
549  const ImpellerRect* rect,
550  ImpellerPaint paint) {
551  GetPeer(builder)->DrawRect(ToImpellerType(*rect), *GetPeer(paint));
552 }
553 
555 void ImpellerDisplayListBuilderDrawOval(ImpellerDisplayListBuilder builder,
556  const ImpellerRect* oval_bounds,
557  ImpellerPaint paint) {
558  GetPeer(builder)->DrawOval(ToImpellerType(*oval_bounds), *GetPeer(paint));
559 }
560 
563  ImpellerDisplayListBuilder builder,
564  const ImpellerRect* rect,
565  const ImpellerRoundingRadii* radii,
566  ImpellerPaint paint) {
567  GetPeer(builder)->DrawRoundedRect(ToImpellerType(*rect), //
568  ToImpellerType(*radii), //
569  *GetPeer(paint) //
570  );
571 }
572 
575  ImpellerDisplayListBuilder builder,
576  const ImpellerRect* outer_rect,
577  const ImpellerRoundingRadii* outer_radii,
578  const ImpellerRect* inner_rect,
579  const ImpellerRoundingRadii* inner_radii,
580  ImpellerPaint paint) {
581  GetPeer(builder)->DrawRoundedRectDifference(ToImpellerType(*outer_rect), //
582  ToImpellerType(*outer_radii), //
583  ToImpellerType(*inner_rect), //
584  ToImpellerType(*inner_radii), //
585  *GetPeer(paint) //
586  );
587 }
588 
590 void ImpellerDisplayListBuilderDrawPath(ImpellerDisplayListBuilder builder,
591  ImpellerPath path,
592  ImpellerPaint paint) {
593  GetPeer(builder)->DrawPath(*GetPeer(path), *GetPeer(paint));
594 }
595 
598  ImpellerContext context,
599  const ImpellerTextureDescriptor* descriptor,
600  const ImpellerMapping* contents,
601  void* contents_on_release_user_data) {
602  TextureDescriptor desc;
605  desc.format = ToImpellerType(descriptor->pixel_format);
606  desc.size = ToImpellerType(descriptor->size);
607  desc.mip_count = std::min(descriptor->mip_count, 1u);
610  auto texture = Create<Texture>(*GetPeer(context), desc);
611  if (!texture->IsValid()) {
612  VALIDATION_LOG << "Could not create texture.";
613  return nullptr;
614  }
615  // Depending on whether the de-allocation can be delayed, it may be possible
616  // to avoid a data copy.
617  if (contents->on_release) {
618  // Avoids data copy.
619  auto wrapped_contents = std::make_shared<fml::NonOwnedMapping>(
620  contents->data, // data ptr
621  contents->length, // data length
622  [on_release = contents->on_release, contents_on_release_user_data](
623  auto, auto) {
624  on_release(contents_on_release_user_data);
625  } // release callback
626  );
627  if (!texture->SetContents(std::move(wrapped_contents))) {
628  VALIDATION_LOG << "Could not set texture contents.";
629  return nullptr;
630  }
631  } else {
632  // May copy.
633  if (!texture->SetContents(contents->data, contents->length)) {
634  VALIDATION_LOG << "Could not set texture contents.";
635  return nullptr;
636  }
637  }
638  return texture.Leak();
639 }
640 
643  ImpellerContext context,
644  const ImpellerTextureDescriptor* descriptor,
645  uint64_t external_gl_handle) {
646  auto impeller_context = GetPeer(context)->GetContext();
647  if (impeller_context->GetBackendType() !=
649  VALIDATION_LOG << "Context is not OpenGL.";
650  return nullptr;
651  }
652 
653  const auto& impeller_context_gl =
654  impeller::ContextGLES::Cast(*impeller_context);
655  const auto& reactor = impeller_context_gl.GetReactor();
656 
657  TextureDescriptor desc;
660  desc.format = ToImpellerType(descriptor->pixel_format);
661  desc.size = ToImpellerType(descriptor->size);
662  desc.mip_count = std::min(descriptor->mip_count, 1u);
665 
666  auto texture = TextureGLES::WrapTexture(
667  reactor, //
668  desc, //
669  reactor->CreateHandle(HandleType::kTexture, external_gl_handle) //
670  );
671  if (!texture || !texture->IsValid()) {
672  VALIDATION_LOG << "Could not wrap external texture.";
673  return nullptr;
674  }
675  return Create<Texture>(impeller::Context::BackendType::kOpenGLES,
676  std::move(texture))
677  .Leak();
678 }
679 
681 void ImpellerTextureRetain(ImpellerTexture texture) {
682  ObjectBase::SafeRetain(texture);
683 }
684 
686 void ImpellerTextureRelease(ImpellerTexture texture) {
687  ObjectBase::SafeRelease(texture);
688 }
689 
691 uint64_t ImpellerTextureGetOpenGLHandle(ImpellerTexture texture) {
692  auto interop_texture = GetPeer(texture);
693  if (interop_texture->GetBackendType() !=
695  VALIDATION_LOG << "Can only fetch the texture handle of an OpenGL texture.";
696  return 0u;
697  }
698  return TextureGLES::Cast(*interop_texture->GetTexture())
699  .GetGLHandle()
700  .value_or(0u);
701 }
702 
704 void ImpellerDisplayListRetain(ImpellerDisplayList display_list) {
705  ObjectBase::SafeRetain(display_list);
706 }
707 
709 void ImpellerDisplayListRelease(ImpellerDisplayList display_list) {
710  ObjectBase::SafeRelease(display_list);
711 }
712 
715  ImpellerDisplayListBuilder builder) {
716  auto dl = GetPeer(builder)->Build();
717  if (!dl->IsValid()) {
718  return nullptr;
719  }
720  return dl.Leak();
721 }
722 
725  ImpellerDisplayListBuilder builder,
726  ImpellerDisplayList display_list,
727  float opacity) {
728  GetPeer(builder)->DrawDisplayList(*GetPeer(display_list), opacity);
729 }
730 
732 ImpellerSurface ImpellerSurfaceCreateWrappedFBONew(ImpellerContext context,
733  uint64_t fbo,
734  ImpellerPixelFormat format,
735  const ImpellerISize* size) {
736 #if IMPELLER_ENABLE_OPENGLES
737  if (!GetPeer(context)->IsGL()) {
738  VALIDATION_LOG << "Context is not OpenGL.";
739  return nullptr;
740  }
741  return Create<SurfaceGLES>(*GetPeer(context), //
742  fbo, //
743  ToImpellerType(format), //
744  ToImpellerType(*size)) //
745  .Leak();
746 #else // IMPELLER_ENABLE_OPENGLES
747  VALIDATION_LOG << "OpenGL unavailable.";
748  return nullptr;
749 #endif // IMPELLER_ENABLE_OPENGLES
750 }
751 
754  ImpellerContext context,
755  void* metal_drawable) {
756 #if IMPELLER_ENABLE_METAL
757  if (!GetPeer(context)->IsMetal()) {
758  VALIDATION_LOG << "Context is not Metal.";
759  return nullptr;
760  }
761  return Create<SurfaceMTL>(*GetPeer(context), metal_drawable).Leak();
762 #else // IMPELLER_ENABLE_METAL
763  VALIDATION_LOG << "Metal unavailable.";
764  return nullptr;
765 #endif // IMPELLER_ENABLE_METAL
766 }
767 
768 IMPELLER_EXTERN_C void ImpellerSurfaceRetain(ImpellerSurface surface) {
769  ObjectBase::SafeRetain(surface);
770 }
771 
773 void ImpellerSurfaceRelease(ImpellerSurface surface) {
774  ObjectBase::SafeRelease(surface);
775 }
776 
778 bool ImpellerSurfaceDrawDisplayList(ImpellerSurface surface,
779  ImpellerDisplayList display_list) {
780  return GetPeer(surface)->DrawDisplayList(*GetPeer(display_list));
781 }
782 
784 bool ImpellerSurfacePresent(ImpellerSurface surface) {
785  return GetPeer(surface)->Present();
786 }
787 
789 void ImpellerDisplayListBuilderDrawTexture(ImpellerDisplayListBuilder builder,
790  ImpellerTexture texture,
791  const ImpellerPoint* point,
792  ImpellerTextureSampling sampling,
793  ImpellerPaint paint) {
794  GetPeer(builder)->DrawTexture(*GetPeer(texture), //
795  ToImpellerType(*point), //
796  ToDisplayListType(sampling), //
797  GetPeer(paint) //
798  );
799 }
800 
803  ImpellerDisplayListBuilder builder,
804  ImpellerTexture texture,
805  const ImpellerRect* src_rect,
806  const ImpellerRect* dst_rect,
807  ImpellerTextureSampling sampling,
808  ImpellerPaint paint) {
809  GetPeer(builder)->DrawTextureRect(*GetPeer(texture), //
810  ToImpellerType(*src_rect), //
811  ToImpellerType(*dst_rect), //
812  ToDisplayListType(sampling), //
813  GetPeer(paint) //
814  );
815 }
816 
818 void ImpellerColorSourceRetain(ImpellerColorSource color_source) {
819  ObjectBase::SafeRetain(color_source);
820 }
821 
823 void ImpellerColorSourceRelease(ImpellerColorSource color_source) {
824  ObjectBase::SafeRelease(color_source);
825 }
826 
827 static std::pair<std::vector<flutter::DlColor>, std::vector<Scalar>>
828 ParseColorsAndStops(uint32_t stop_count,
829  const ImpellerColor* colors,
830  const float* stops) {
831  if (stop_count == 0) {
832  return {};
833  }
834  std::pair<std::vector<flutter::DlColor>, std::vector<Scalar>> result;
835  result.first.reserve(stop_count);
836  result.second.reserve(stop_count);
837  for (size_t i = 0; i < stop_count; i++) {
838  result.first.emplace_back(ToDisplayListType(colors[i]));
839  result.second.emplace_back(stops[i]);
840  }
841  return result;
842 }
843 
846  const ImpellerPoint* start_point,
847  const ImpellerPoint* end_point,
848  uint32_t stop_count,
849  const ImpellerColor* colors,
850  const float* stops,
851  ImpellerTileMode tile_mode,
852  const ImpellerMatrix* transformation) {
853  const auto colors_and_stops = ParseColorsAndStops(stop_count, colors, stops);
855  ToImpellerType(*start_point), //
856  ToImpellerType(*end_point), //
857  colors_and_stops.first, //
858  colors_and_stops.second, //
859  ToDisplayListType(tile_mode), //
860  transformation == nullptr ? Matrix{}
861  : ToImpellerType(*transformation) //
862  )
863  .Leak();
864 }
865 
868  const ImpellerPoint* center,
869  float radius,
870  uint32_t stop_count,
871  const ImpellerColor* colors,
872  const float* stops,
873  ImpellerTileMode tile_mode,
874  const ImpellerMatrix* transformation) {
875  const auto colors_and_stops = ParseColorsAndStops(stop_count, colors, stops);
877  ToImpellerType(*center), //
878  radius, //
879  colors_and_stops.first, //
880  colors_and_stops.second, //
881  ToDisplayListType(tile_mode), //
882  transformation == nullptr ? Matrix{}
883  : ToImpellerType(*transformation) //
884  )
885  .Leak();
886 }
887 
890  const ImpellerPoint* start_center,
891  float start_radius,
892  const ImpellerPoint* end_center,
893  float end_radius,
894  uint32_t stop_count,
895  const ImpellerColor* colors,
896  const float* stops,
897  ImpellerTileMode tile_mode,
898  const ImpellerMatrix* transformation) {
899  const auto colors_and_stops = ParseColorsAndStops(stop_count, colors, stops);
901  ToImpellerType(*start_center), //
902  start_radius, //
903  ToImpellerType(*end_center), //
904  end_radius, //
905  colors_and_stops.first, //
906  colors_and_stops.second, //
907  ToDisplayListType(tile_mode), //
908  transformation == nullptr ? Matrix{}
909  : ToImpellerType(*transformation) //
910  )
911  .Leak();
912 }
913 
916  const ImpellerPoint* center,
917  float start,
918  float end,
919  uint32_t stop_count,
920  const ImpellerColor* colors,
921  const float* stops,
922  ImpellerTileMode tile_mode,
923  const ImpellerMatrix* transformation) {
924  const auto colors_and_stops = ParseColorsAndStops(stop_count, colors, stops);
926  ToImpellerType(*center), //
927  start, //
928  end, //
929  colors_and_stops.first, //
930  colors_and_stops.second, //
931  ToDisplayListType(tile_mode), //
932  transformation == nullptr ? Matrix{}
933  : ToImpellerType(*transformation) //
934  )
935  .Leak();
936 }
937 
940  ImpellerTexture image,
941  ImpellerTileMode horizontal_tile_mode,
942  ImpellerTileMode vertical_tile_mode,
943  ImpellerTextureSampling sampling,
944  const ImpellerMatrix* transformation) {
945  return ColorSource::MakeImage(
946  *GetPeer(image), //
947  ToDisplayListType(horizontal_tile_mode), //
948  ToDisplayListType(vertical_tile_mode), //
949  ToDisplayListType(sampling), //
950  transformation == nullptr ? Matrix{}
951  : ToImpellerType(*transformation) //
952  )
953  .Leak();
954 }
955 
957  std::vector<std::shared_ptr<flutter::DlColorSource>> samplers;
958  std::shared_ptr<std::vector<uint8_t>> uniforms;
959 };
960 
961 static SamplersAndUniforms ReadSamplersAndUniforms(ImpellerTexture* samplers,
962  size_t samplers_count,
963  const uint8_t* data,
964  size_t data_bytes_length) {
965  SamplersAndUniforms result;
966  result.uniforms = std::make_shared<std::vector<uint8_t>>();
967  if (data_bytes_length > 0) {
968  std::copy(data, data + data_bytes_length,
969  std::back_inserter(*result.uniforms));
970  }
971  if (samplers_count > 0) {
972  result.samplers.reserve(samplers_count);
973  for (size_t i = 0; i < samplers_count; i++) {
974  result.samplers.emplace_back(flutter::DlColorSource::MakeImage(
975  DlImageImpeller::Make(GetPeer(samplers[i])->GetTexture()), //
976  flutter::DlTileMode::kClamp, //
977  flutter::DlTileMode::kClamp //
978  ));
979  }
980  }
981  return result;
982 }
983 
984 IMPELLER_EXTERN_C ImpellerColorSource
986  ImpellerContext context,
987  ImpellerFragmentProgram fragment_program,
988  ImpellerTexture* samplers,
989  size_t samplers_count,
990  const uint8_t* data,
991  size_t data_bytes_length) {
992  auto bindings = ReadSamplersAndUniforms(samplers, samplers_count, data,
993  data_bytes_length);
994  return ColorSource::MakeFragmentProgram(*GetPeer(context), //
995  *GetPeer(fragment_program), //
996  std::move(bindings.samplers), //
997  std::move(bindings.uniforms) //
998  )
999  .Leak();
1000 }
1001 
1003 void ImpellerColorFilterRetain(ImpellerColorFilter color_filter) {
1004  ObjectBase::SafeRetain(color_filter);
1005 }
1006 
1008 void ImpellerColorFilterRelease(ImpellerColorFilter color_filter) {
1009  ObjectBase::SafeRelease(color_filter);
1010 }
1011 
1014  const ImpellerColor* color,
1015  ImpellerBlendMode blend_mode) {
1016  return ColorFilter::MakeBlend(ToImpellerType(*color),
1017  ToImpellerType(blend_mode))
1018  .Leak();
1019 }
1020 
1023  const ImpellerColorMatrix* color_matrix) {
1024  return ColorFilter::MakeMatrix(color_matrix->m).Leak();
1025 }
1026 
1028 void ImpellerMaskFilterRetain(ImpellerMaskFilter mask_filter) {
1029  ObjectBase::SafeRetain(mask_filter);
1030 }
1031 
1033 void ImpellerMaskFilterRelease(ImpellerMaskFilter mask_filter) {
1034  ObjectBase::SafeRelease(mask_filter);
1035 }
1036 
1039  float sigma) {
1040  return MaskFilter::MakeBlur(ToDisplayListType(style), sigma).Leak();
1041 }
1042 
1044 void ImpellerImageFilterRetain(ImpellerImageFilter image_filter) {
1045  ObjectBase::SafeRetain(image_filter);
1046 }
1047 
1049 void ImpellerImageFilterRelease(ImpellerImageFilter image_filter) {
1050  ObjectBase::SafeRelease(image_filter);
1051 }
1052 
1055  float x_sigma,
1056  float y_sigma,
1057  ImpellerTileMode tile_mode) {
1058  return ImageFilter::MakeBlur(x_sigma, y_sigma, ToDisplayListType(tile_mode))
1059  .Leak();
1060 }
1061 
1063 ImpellerImageFilter ImpellerImageFilterCreateDilateNew(float x_radius,
1064  float y_radius) {
1065  return ImageFilter::MakeDilate(x_radius, y_radius).Leak();
1066 }
1067 
1069 ImpellerImageFilter ImpellerImageFilterCreateErodeNew(float x_radius,
1070  float y_radius) {
1071  return ImageFilter::MakeErode(x_radius, y_radius).Leak();
1072 }
1073 
1076  const ImpellerMatrix* matrix,
1077  ImpellerTextureSampling sampling) {
1078  return ImageFilter::MakeMatrix(ToImpellerType(*matrix),
1079  ToDisplayListType(sampling))
1080  .Leak();
1081 }
1082 
1085  ImpellerContext context,
1086  ImpellerFragmentProgram fragment_program,
1087  ImpellerTexture* samplers,
1088  size_t samplers_count,
1089  const uint8_t* data,
1090  size_t data_bytes_length) {
1091  auto bindings = ReadSamplersAndUniforms(samplers, samplers_count, data,
1092  data_bytes_length);
1093  return ImageFilter::MakeFragmentProgram(*GetPeer(context), //
1094  *GetPeer(fragment_program), //
1095  std::move(bindings.samplers), //
1096  std::move(bindings.uniforms) //
1097  )
1098  .Leak();
1099 }
1100 
1101 IMPELLER_EXTERN_C ImpellerImageFilter
1102 ImpellerImageFilterCreateComposeNew(ImpellerImageFilter outer,
1103  ImpellerImageFilter inner) {
1104  return ImageFilter::MakeCompose(*GetPeer(outer), *GetPeer(inner)).Leak();
1105 }
1106 
1108 void ImpellerPaintSetColorFilter(ImpellerPaint paint,
1109  ImpellerColorFilter color_filter) {
1110  GetPeer(paint)->SetColorFilter(*GetPeer(color_filter));
1111 }
1112 
1114 void ImpellerPaintSetColorSource(ImpellerPaint paint,
1115  ImpellerColorSource color_source) {
1116  GetPeer(paint)->SetColorSource(*GetPeer(color_source));
1117 }
1118 
1120 void ImpellerPaintSetImageFilter(ImpellerPaint paint,
1121  ImpellerImageFilter image_filter) {
1122  GetPeer(paint)->SetImageFilter(*GetPeer(image_filter));
1123 }
1124 
1126 void ImpellerPaintSetMaskFilter(ImpellerPaint paint,
1127  ImpellerMaskFilter mask_filter) {
1128  GetPeer(paint)->SetMaskFilter(*GetPeer(mask_filter));
1129 }
1130 
1132 ImpellerParagraphStyle ImpellerParagraphStyleNew() {
1133  return Create<ParagraphStyle>().Leak();
1134 }
1135 
1137 void ImpellerParagraphStyleRetain(ImpellerParagraphStyle paragraph_style) {
1138  ObjectBase::SafeRetain(paragraph_style);
1139 }
1140 
1142 void ImpellerParagraphStyleRelease(ImpellerParagraphStyle paragraph_style) {
1143  ObjectBase::SafeRelease(paragraph_style);
1144 }
1145 
1147 void ImpellerParagraphStyleSetForeground(ImpellerParagraphStyle paragraph_style,
1148  ImpellerPaint paint) {
1149  GetPeer(paragraph_style)->SetForeground(Ref(GetPeer(paint)));
1150 }
1151 
1153 void ImpellerParagraphStyleSetBackground(ImpellerParagraphStyle paragraph_style,
1154  ImpellerPaint paint) {
1155  GetPeer(paragraph_style)->SetBackground(Ref(GetPeer(paint)));
1156 }
1157 
1159 void ImpellerParagraphStyleSetFontWeight(ImpellerParagraphStyle paragraph_style,
1161  GetPeer(paragraph_style)->SetFontWeight(ToTxtType(weight));
1162 }
1163 
1165 void ImpellerParagraphStyleSetFontStyle(ImpellerParagraphStyle paragraph_style,
1166  ImpellerFontStyle style) {
1167  GetPeer(paragraph_style)->SetFontStyle(ToTxtType(style));
1168 }
1169 
1170 static std::string ReadString(const char* string) {
1171  if (string == nullptr) {
1172  return "";
1173  }
1174  return std::string{string};
1175 }
1176 
1178 void ImpellerParagraphStyleSetFontFamily(ImpellerParagraphStyle paragraph_style,
1179  const char* family_name) {
1180  GetPeer(paragraph_style)->SetFontFamily(ReadString(family_name));
1181 }
1182 
1184 void ImpellerParagraphStyleSetFontSize(ImpellerParagraphStyle paragraph_style,
1185  float size) {
1186  GetPeer(paragraph_style)->SetFontSize(size);
1187 }
1188 
1190 void ImpellerParagraphStyleSetHeight(ImpellerParagraphStyle paragraph_style,
1191  float height) {
1192  GetPeer(paragraph_style)->SetHeight(height);
1193 }
1194 
1197  ImpellerParagraphStyle paragraph_style,
1198  ImpellerTextAlignment align) {
1199  GetPeer(paragraph_style)->SetTextAlignment(ToTxtType(align));
1200 }
1201 
1204  ImpellerParagraphStyle paragraph_style,
1205  ImpellerTextDirection direction) {
1206  GetPeer(paragraph_style)->SetTextDirection(ToTxtType(direction));
1207 }
1208 
1211  ImpellerParagraphStyle paragraph_style,
1212  const ImpellerTextDecoration* decoration) {
1213  GetPeer(paragraph_style)->SetTextDecoration(*decoration);
1214 }
1215 
1217 void ImpellerParagraphStyleSetMaxLines(ImpellerParagraphStyle paragraph_style,
1218  uint32_t max_lines) {
1219  GetPeer(paragraph_style)->SetMaxLines(max_lines);
1220 }
1221 
1223 void ImpellerParagraphStyleSetLocale(ImpellerParagraphStyle paragraph_style,
1224  const char* locale) {
1225  GetPeer(paragraph_style)->SetLocale(ReadString(locale));
1226 }
1227 
1229 void ImpellerParagraphStyleSetEllipsis(ImpellerParagraphStyle paragraph_style,
1230  const char* ellipsis) {
1231  GetPeer(paragraph_style)->SetEllipsis(ReadString(ellipsis));
1232 }
1233 
1235 void ImpellerDisplayListBuilderDrawParagraph(ImpellerDisplayListBuilder builder,
1236  ImpellerParagraph paragraph,
1237  const ImpellerPoint* point) {
1238  GetPeer(builder)->DrawParagraph(*GetPeer(paragraph), ToImpellerType(*point));
1239 }
1240 
1242 void ImpellerDisplayListBuilderDrawShadow(ImpellerDisplayListBuilder builder,
1243  ImpellerPath path,
1244  const ImpellerColor* color,
1245  float elevation,
1246  bool occluder_is_transparent,
1247  float device_pixel_ratio) {
1248  GetPeer(builder)->DrawShadow(*GetPeer(path), //
1249  ToDisplayListType(*color), //
1250  elevation, //
1251  occluder_is_transparent, //
1252  device_pixel_ratio //
1253  );
1254 }
1255 
1257 ImpellerParagraphBuilder ImpellerParagraphBuilderNew(
1258  ImpellerTypographyContext context) {
1259  auto builder =
1260  Create<ParagraphBuilder>(Ref<TypographyContext>(GetPeer(context)));
1261  if (!builder->IsValid()) {
1262  VALIDATION_LOG << "Could not create valid paragraph builder.";
1263  return nullptr;
1264  }
1265  return builder.Leak();
1266 }
1267 
1270  ImpellerParagraphBuilder paragraph_builder) {
1271  ObjectBase::SafeRetain(paragraph_builder);
1272 }
1273 
1276  ImpellerParagraphBuilder paragraph_builder) {
1277  ObjectBase::SafeRelease(paragraph_builder);
1278 }
1279 
1282  ImpellerParagraphBuilder paragraph_builder,
1283  ImpellerParagraphStyle style) {
1284  GetPeer(paragraph_builder)->PushStyle(*GetPeer(style));
1285 }
1286 
1289  ImpellerParagraphBuilder paragraph_builder) {
1290  GetPeer(paragraph_builder)->PopStyle();
1291 }
1292 
1294 void ImpellerParagraphBuilderAddText(ImpellerParagraphBuilder paragraph_builder,
1295  const uint8_t* data,
1296  uint32_t length) {
1297  if (data == nullptr) {
1298  length = 0;
1299  }
1300  if (length == 0) {
1301  return;
1302  }
1303  GetPeer(paragraph_builder)->AddText(data, length);
1304 }
1305 
1308  ImpellerParagraphBuilder paragraph_builder,
1309  float width) {
1310  return GetPeer(paragraph_builder)->Build(width).Leak();
1311 }
1312 
1314 void ImpellerParagraphRetain(ImpellerParagraph paragraph) {
1315  ObjectBase::SafeRetain(paragraph);
1316 }
1317 
1319 void ImpellerParagraphRelease(ImpellerParagraph paragraph) {
1320  ObjectBase::SafeRelease(paragraph);
1321 }
1322 
1324 float ImpellerParagraphGetMaxWidth(ImpellerParagraph paragraph) {
1325  return GetPeer(paragraph)->GetMaxWidth();
1326 }
1327 
1329 float ImpellerParagraphGetHeight(ImpellerParagraph paragraph) {
1330  return GetPeer(paragraph)->GetHeight();
1331 }
1332 
1334 float ImpellerParagraphGetLongestLineWidth(ImpellerParagraph paragraph) {
1335  return GetPeer(paragraph)->GetLongestLineWidth();
1336 }
1337 
1339 float ImpellerParagraphGetMinIntrinsicWidth(ImpellerParagraph paragraph) {
1340  return GetPeer(paragraph)->GetMinIntrinsicWidth();
1341 }
1342 
1344 float ImpellerParagraphGetMaxIntrinsicWidth(ImpellerParagraph paragraph) {
1345  return GetPeer(paragraph)->GetMaxIntrinsicWidth();
1346 }
1347 
1349 float ImpellerParagraphGetIdeographicBaseline(ImpellerParagraph paragraph) {
1350  return GetPeer(paragraph)->GetIdeographicBaseline();
1351 }
1352 
1354 float ImpellerParagraphGetAlphabeticBaseline(ImpellerParagraph paragraph) {
1355  return GetPeer(paragraph)->GetAlphabeticBaseline();
1356 }
1357 
1359 uint32_t ImpellerParagraphGetLineCount(ImpellerParagraph paragraph) {
1360  return GetPeer(paragraph)->GetLineCount();
1361 }
1362 
1364 void ImpellerParagraphGetWordBoundary(ImpellerParagraph paragraph,
1365  size_t code_unit_index,
1366  ImpellerRange* out_range) {
1367  *out_range = GetPeer(paragraph)->GetWordBoundary(code_unit_index);
1368 }
1369 
1371 ImpellerTypographyContext ImpellerTypographyContextNew() {
1372  auto context = Create<TypographyContext>();
1373  if (!context->IsValid()) {
1374  VALIDATION_LOG << "Could not create typography context.";
1375  return nullptr;
1376  }
1377  return context.Leak();
1378 }
1379 
1381 void ImpellerTypographyContextRetain(ImpellerTypographyContext context) {
1383 }
1384 
1386 void ImpellerTypographyContextRelease(ImpellerTypographyContext context) {
1388 }
1389 
1391 bool ImpellerTypographyContextRegisterFont(ImpellerTypographyContext context,
1392  const ImpellerMapping* contents,
1393  void* contents_on_release_user_data,
1394  const char* family_name_alias) {
1395  auto wrapped_contents = std::make_unique<fml::NonOwnedMapping>(
1396  contents->data, // data ptr
1397  contents->length, // data length
1398  [on_release = contents->on_release, contents_on_release_user_data](auto,
1399  auto) {
1400  on_release(contents_on_release_user_data);
1401  } // release callback
1402  );
1403  return GetPeer(context)->RegisterFont(std::move(wrapped_contents),
1404  family_name_alias);
1405 }
1406 
1409  ImpellerParagraph paragraph) {
1410  return GetPeer(paragraph)->GetLineMetrics().GetC();
1411 }
1412 
1415  ImpellerParagraph paragraph,
1416  size_t code_unit_index) {
1417  return GetPeer(paragraph)
1418  ->GetGlyphInfoAtCodeUnitIndex(code_unit_index)
1419  .Leak();
1420 }
1421 
1424  ImpellerParagraph paragraph,
1425  double x,
1426  double y) {
1427  return GetPeer(paragraph)
1428  ->GetClosestGlyphInfoAtParagraphCoordinates(x, y)
1429  .Leak();
1430 }
1431 
1432 //------------------------------------------------------------------------------
1433 // Line Metrics
1434 //------------------------------------------------------------------------------
1435 
1437 void ImpellerLineMetricsRetain(ImpellerLineMetrics line_metrics) {
1438  ObjectBase::SafeRetain(line_metrics);
1439 }
1440 
1442 void ImpellerLineMetricsRelease(ImpellerLineMetrics line_metrics) {
1443  ObjectBase::SafeRelease(line_metrics);
1444 }
1445 
1447 double ImpellerLineMetricsGetUnscaledAscent(ImpellerLineMetrics metrics,
1448  size_t line) {
1449  return GetPeer(metrics)->GetUnscaledAscent(line);
1450 }
1451 
1453 double ImpellerLineMetricsGetAscent(ImpellerLineMetrics metrics, size_t line) {
1454  return GetPeer(metrics)->GetAscent(line);
1455 }
1456 
1458 double ImpellerLineMetricsGetDescent(ImpellerLineMetrics metrics, size_t line) {
1459  return GetPeer(metrics)->GetDescent(line);
1460 }
1461 
1463 double ImpellerLineMetricsGetBaseline(ImpellerLineMetrics metrics,
1464  size_t line) {
1465  return GetPeer(metrics)->GetBaseline(line);
1466 }
1467 
1469 bool ImpellerLineMetricsIsHardbreak(ImpellerLineMetrics metrics, size_t line) {
1470  return GetPeer(metrics)->IsHardbreak(line);
1471 }
1472 
1474 double ImpellerLineMetricsGetWidth(ImpellerLineMetrics metrics, size_t line) {
1475  return GetPeer(metrics)->GetWidth(line);
1476 }
1477 
1479 double ImpellerLineMetricsGetHeight(ImpellerLineMetrics metrics, size_t line) {
1480  return GetPeer(metrics)->GetHeight(line);
1481 }
1482 
1484 double ImpellerLineMetricsGetLeft(ImpellerLineMetrics metrics, size_t line) {
1485  return GetPeer(metrics)->GetLeft(line);
1486 }
1487 
1489 size_t ImpellerLineMetricsGetCodeUnitStartIndex(ImpellerLineMetrics metrics,
1490  size_t line) {
1491  return GetPeer(metrics)->GetCodeUnitStartIndex(line);
1492 }
1493 
1495 size_t ImpellerLineMetricsGetCodeUnitEndIndex(ImpellerLineMetrics metrics,
1496  size_t line) {
1497  return GetPeer(metrics)->GetCodeUnitEndIndex(line);
1498 }
1499 
1502  ImpellerLineMetrics metrics,
1503  size_t line) {
1504  return GetPeer(metrics)->GetCodeUnitEndIndexExcludingWhitespace(line);
1505 }
1506 
1509  ImpellerLineMetrics metrics,
1510  size_t line) {
1511  return GetPeer(metrics)->GetCodeUnitEndIndexIncludingNewline(line);
1512 }
1513 
1514 //------------------------------------------------------------------------------
1515 // Glyph Info
1516 //------------------------------------------------------------------------------
1517 
1519 void ImpellerGlyphInfoRetain(ImpellerGlyphInfo glyph_info) {
1520  ObjectBase::SafeRetain(glyph_info);
1521 }
1522 
1524 void ImpellerGlyphInfoRelease(ImpellerGlyphInfo glyph_info) {
1525  ObjectBase::SafeRelease(glyph_info);
1526 }
1527 
1530  ImpellerGlyphInfo glyph_info) {
1531  return GetPeer(glyph_info)->GetGraphemeClusterCodeUnitRangeBegin();
1532 }
1533 
1536  ImpellerGlyphInfo glyph_info) {
1537  return GetPeer(glyph_info)->GetGraphemeClusterCodeUnitRangeEnd();
1538 }
1539 
1541 void ImpellerGlyphInfoGetGraphemeClusterBounds(ImpellerGlyphInfo glyph_info,
1542  ImpellerRect* out_bounds) {
1543  *out_bounds = GetPeer(glyph_info)->GetGraphemeClusterBounds();
1544 }
1545 
1547 bool ImpellerGlyphInfoIsEllipsis(ImpellerGlyphInfo glyph_info) {
1548  return GetPeer(glyph_info)->IsEllipsis();
1549 }
1550 
1553  ImpellerGlyphInfo glyph_info) {
1554  return GetPeer(glyph_info)->GetTextDirection();
1555 }
1556 
1557 //------------------------------------------------------------------------------
1558 // Fragment Program
1559 //------------------------------------------------------------------------------
1560 
1561 static std::shared_ptr<fml::Mapping> MakeCopyableMapping(
1562  const ImpellerMapping* data,
1563  void* user_data) {
1564  if (data == nullptr) {
1565  return nullptr;
1566  }
1567 
1568  // If the user has supplied a release callback, defer deallocation to them.
1569  if (auto callback = data->on_release) {
1570  return std::make_shared<fml::NonOwnedMapping>(
1571  data->data, //
1572  data->length, //
1573  [user_data, callback](const uint8_t* data, size_t size) {
1574  callback(user_data);
1575  });
1576  }
1577 
1578  return std::make_shared<fml::MallocMapping>(
1579  fml::MallocMapping::Copy(data->data, data->length));
1580 }
1581 
1583 ImpellerFragmentProgram ImpellerFragmentProgramNew(
1584  const ImpellerMapping* data,
1585  void* data_release_user_data) {
1586  auto data_mapping = MakeCopyableMapping(data, data_release_user_data);
1587  auto program = Create<FragmentProgram>(std::move(data_mapping));
1588  if (!program->IsValid()) {
1589  VALIDATION_LOG << "Could not create valid fragment program.";
1590  return nullptr;
1591  }
1592  return program.Leak();
1593 }
1594 
1596 void ImpellerFragmentProgramRetain(ImpellerFragmentProgram fragment_program) {
1597  ObjectBase::SafeRetain(fragment_program);
1598 }
1599 
1601 void ImpellerFragmentProgramRelease(ImpellerFragmentProgram fragment_program) {
1602  ObjectBase::SafeRelease(fragment_program);
1603 }
1604 
1605 } // namespace impeller::interop
static ContextGLES & Cast(Context &base)
Definition: backend_cast.h:13
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
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:78
static ScopedObject< ColorSource > MakeFragmentProgram(const Context &context, const FragmentProgram &program, std::vector< std::shared_ptr< flutter::DlColorSource >> samplers, std::shared_ptr< std::vector< uint8_t >> uniform_data)
static ScopedObject< ColorSource > MakeImage(const Texture &image, flutter::DlTileMode horizontal_tile_mode, flutter::DlTileMode vertical_tile_mode, flutter::DlImageSampling sampling, const Matrix &transformation)
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:32
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:11
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:53
static ScopedObject< Context > Create(std::function< void *(const char *gl_proc_name)> proc_address_callback)
Definition: context_gles.cc:14
static ScopedObject< Context > Create()
Definition: context_mtl.mm:29
static ScopedObject< Context > Create(const Settings &settings)
Definition: context_vk.cc:44
Internal C++ peer of ImpellerGlyphInfo. For detailed documentation, refer to the headerdocs in the pu...
Definition: glyph_info.h:21
static ScopedObject< ImageFilter > MakeDilate(Scalar x_radius, Scalar y_radius)
Definition: image_filter.cc:29
static ScopedObject< ImageFilter > MakeFragmentProgram(const Context &context, const FragmentProgram &program, std::vector< std::shared_ptr< flutter::DlColorSource >> samplers, std::shared_ptr< std::vector< uint8_t >> uniform_data)
Definition: image_filter.cc:57
static ScopedObject< ImageFilter > MakeErode(Scalar x_radius, Scalar y_radius)
Definition: image_filter.cc:38
static ScopedObject< ImageFilter > MakeCompose(const ImageFilter &outer, const ImageFilter &inner)
Definition: image_filter.cc:86
static ScopedObject< ImageFilter > MakeBlur(Scalar x_sigma, Scalar y_sigma, flutter::DlTileMode tile_mode)
Definition: image_filter.cc:19
static ScopedObject< ImageFilter > MakeMatrix(const Matrix &matrix, flutter::DlImageSampling sampling)
Definition: image_filter.cc:47
Internal C++ peer of ImpellerLineMetrics. For detailed documentation, refer to the headerdocs in the ...
Definition: line_metrics.h:26
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
uint32_t location
int32_t x
ImpellerFillType
Definition: impeller.h:364
ImpellerTextDirection
Definition: impeller.h:479
ImpellerTextureSampling
Definition: impeller.h:428
#define IMPELLER_VERSION_GET_PATCH(version)
Definition: impeller.h:135
#define IMPELLER_VERSION_GET_MAJOR(version)
Definition: impeller.h:119
#define IMPELLER_VERSION_GET_VARIANT(version)
Definition: impeller.h:112
ImpellerStrokeJoin
Definition: impeller.h:418
ImpellerBlendMode
Definition: impeller.h:374
#define IMPELLER_VERSION
Definition: impeller.h:103
ImpellerFontWeight
Definition: impeller.h:453
#define IMPELLER_VERSION_GET_MINOR(version)
Definition: impeller.h:127
void *IMPELLER_NULLABLE(* ImpellerProcAddressCallback)(const char *IMPELLER_NONNULL proc_name, void *IMPELLER_NULLABLE user_data)
Definition: impeller.h:347
#define IMPELLER_EXTERN_C
Definition: impeller.h:36
ImpellerStrokeCap
Definition: impeller.h:412
ImpellerDrawStyle
Definition: impeller.h:406
ImpellerTileMode
Definition: impeller.h:433
ImpellerTextAlignment
Definition: impeller.h:470
ImpellerFontStyle
Definition: impeller.h:465
ImpellerClipOperation
Definition: impeller.h:369
#define IMPELLER_NONNULL
Definition: impeller.h:58
ImpellerBlurStyle
Definition: impeller.h:440
ImpellerPixelFormat
Definition: impeller.h:424
IMPELLER_EXTERN_C ImpellerImageFilter ImpellerImageFilterCreateComposeNew(ImpellerImageFilter outer, ImpellerImageFilter inner)
Definition: impeller.cc:1102
IMPELLER_EXTERN_C void ImpellerParagraphBuilderRetain(ImpellerParagraphBuilder paragraph_builder)
Definition: impeller.cc:1269
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:915
IMPELLER_EXTERN_C bool ImpellerLineMetricsIsHardbreak(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1469
IMPELLER_EXTERN_C void ImpellerGlyphInfoRelease(ImpellerGlyphInfo glyph_info)
Definition: impeller.cc:1524
IMPELLER_EXTERN_C ImpellerImageFilter ImpellerImageFilterCreateMatrixNew(const ImpellerMatrix *matrix, ImpellerTextureSampling sampling)
Definition: impeller.cc:1075
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawPaint(ImpellerDisplayListBuilder builder, ImpellerPaint paint)
Definition: impeller.cc:515
IMPELLER_EXTERN_C void ImpellerSurfaceRetain(ImpellerSurface surface)
Definition: impeller.cc:768
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetEllipsis(ImpellerParagraphStyle paragraph_style, const char *ellipsis)
Definition: impeller.cc:1229
IMPELLER_EXTERN_C void ImpellerParagraphStyleRelease(ImpellerParagraphStyle paragraph_style)
Definition: impeller.cc:1142
IMPELLER_EXTERN_C uint32_t ImpellerGetVersion()
Definition: impeller.cc:92
IMPELLER_EXTERN_C ImpellerColorSource ImpellerColorSourceCreateFragmentProgramNew(ImpellerContext context, ImpellerFragmentProgram fragment_program, ImpellerTexture *samplers, size_t samplers_count, const uint8_t *data, size_t data_bytes_length)
Definition: impeller.cc:985
IMPELLER_EXTERN_C void ImpellerParagraphStyleRetain(ImpellerParagraphStyle paragraph_style)
Definition: impeller.cc:1137
IMPELLER_EXTERN_C size_t ImpellerLineMetricsGetCodeUnitStartIndex(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1489
IMPELLER_EXTERN_C ImpellerTextDirection ImpellerGlyphInfoGetTextDirection(ImpellerGlyphInfo glyph_info)
Definition: impeller.cc:1552
IMPELLER_EXTERN_C void ImpellerPaintSetColorSource(ImpellerPaint paint, ImpellerColorSource color_source)
Definition: impeller.cc:1114
IMPELLER_EXTERN_C void ImpellerPathBuilderClose(ImpellerPathBuilder builder)
Definition: impeller.cc:415
IMPELLER_EXTERN_C void ImpellerPathBuilderQuadraticCurveTo(ImpellerPathBuilder builder, const ImpellerPoint *control_point, const ImpellerPoint *end_point)
Definition: impeller.cc:364
IMPELLER_EXTERN_C void ImpellerParagraphGetWordBoundary(ImpellerParagraph paragraph, size_t code_unit_index, ImpellerRange *out_range)
Definition: impeller.cc:1364
IMPELLER_EXTERN_C uint64_t ImpellerTextureGetOpenGLHandle(ImpellerTexture texture)
Definition: impeller.cc:691
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderRetain(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:234
IMPELLER_EXTERN_C void ImpellerParagraphBuilderPopStyle(ImpellerParagraphBuilder paragraph_builder)
Definition: impeller.cc:1288
static bool CheckVersion(uint32_t version)
Definition: impeller.cc:96
IMPELLER_EXTERN_C ImpellerMaskFilter ImpellerMaskFilterCreateBlurNew(ImpellerBlurStyle style, float sigma)
Definition: impeller.cc:1038
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetMaxLines(ImpellerParagraphStyle paragraph_style, uint32_t max_lines)
Definition: impeller.cc:1217
IMPELLER_EXTERN_C size_t ImpellerLineMetricsGetCodeUnitEndIndex(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1495
IMPELLER_EXTERN_C void ImpellerColorFilterRetain(ImpellerColorFilter color_filter)
Definition: impeller.cc:1003
IMPELLER_EXTERN_C ImpellerSurface ImpellerSurfaceCreateWrappedFBONew(ImpellerContext context, uint64_t fbo, ImpellerPixelFormat format, const ImpellerISize *size)
Definition: impeller.cc:732
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawTextureRect(ImpellerDisplayListBuilder builder, ImpellerTexture texture, const ImpellerRect *src_rect, const ImpellerRect *dst_rect, ImpellerTextureSampling sampling, ImpellerPaint paint)
Definition: impeller.cc:802
IMPELLER_EXTERN_C ImpellerFragmentProgram ImpellerFragmentProgramNew(const ImpellerMapping *data, void *data_release_user_data)
Definition: impeller.cc:1583
IMPELLER_EXTERN_C ImpellerImageFilter ImpellerImageFilterCreateFragmentProgramNew(ImpellerContext context, ImpellerFragmentProgram fragment_program, ImpellerTexture *samplers, size_t samplers_count, const uint8_t *data, size_t data_bytes_length)
Definition: impeller.cc:1084
IMPELLER_EXTERN_C void ImpellerLineMetricsRelease(ImpellerLineMetrics line_metrics)
Definition: impeller.cc:1442
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderSave(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:244
IMPELLER_EXTERN_C ImpellerDisplayList ImpellerDisplayListBuilderCreateDisplayListNew(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:714
IMPELLER_EXTERN_C bool ImpellerGlyphInfoIsEllipsis(ImpellerGlyphInfo glyph_info)
Definition: impeller.cc:1547
IMPELLER_EXTERN_C void ImpellerPathBuilderRelease(ImpellerPathBuilder builder)
Definition: impeller.cc:347
constexpr txt::TextDecorationStyle ToTxtType(ImpellerTextDecorationStyle style)
Definition: formats.h:442
IMPELLER_EXTERN_C ImpellerParagraphBuilder ImpellerParagraphBuilderNew(ImpellerTypographyContext context)
Definition: impeller.cc:1257
IMPELLER_EXTERN_C ImpellerColorFilter ImpellerColorFilterCreateColorMatrixNew(const ImpellerColorMatrix *color_matrix)
Definition: impeller.cc:1022
static std::pair< std::vector< flutter::DlColor >, std::vector< Scalar > > ParseColorsAndStops(uint32_t stop_count, const ImpellerColor *colors, const float *stops)
Definition: impeller.cc:828
static std::shared_ptr< fml::Mapping > MakeCopyableMapping(const ImpellerMapping *data, void *user_data)
Definition: impeller.cc:1561
IMPELLER_EXTERN_C void ImpellerPaintRelease(ImpellerPaint paint)
Definition: impeller.cc:475
IMPELLER_EXTERN_C ImpellerDisplayListBuilder ImpellerDisplayListBuilderNew(const ImpellerRect *cull_rect)
Definition: impeller.cc:229
IMPELLER_EXTERN_C double ImpellerLineMetricsGetDescent(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1458
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetFontStyle(ImpellerParagraphStyle paragraph_style, ImpellerFontStyle style)
Definition: impeller.cc:1165
IMPELLER_EXTERN_C ImpellerPaint ImpellerPaintNew()
Definition: impeller.cc:465
IMPELLER_EXTERN_C void ImpellerTypographyContextRetain(ImpellerTypographyContext context)
Definition: impeller.cc:1381
static SamplersAndUniforms ReadSamplersAndUniforms(ImpellerTexture *samplers, size_t samplers_count, const uint8_t *data, size_t data_bytes_length)
Definition: impeller.cc:961
IMPELLER_EXTERN_C size_t ImpellerLineMetricsGetCodeUnitEndIndexIncludingNewline(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1508
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetTextDirection(ImpellerParagraphStyle paragraph_style, ImpellerTextDirection direction)
Definition: impeller.cc:1203
ScopedObject< Object > Ref(Object *object)
Definition: object.h:146
IMPELLER_EXTERN_C ImpellerSurface ImpellerSurfaceCreateWrappedMetalDrawableNew(ImpellerContext context, void *metal_drawable)
Definition: impeller.cc:753
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawOval(ImpellerDisplayListBuilder builder, const ImpellerRect *oval_bounds, ImpellerPaint paint)
Definition: impeller.cc:555
IMPELLER_EXTERN_C size_t ImpellerLineMetricsGetCodeUnitEndIndexExcludingWhitespace(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1501
IMPELLER_EXTERN_C ImpellerContext ImpellerContextCreateVulkanNew(uint32_t version, const ImpellerContextVulkanSettings *settings)
Definition: impeller.cc:152
IMPELLER_EXTERN_C ImpellerParagraph ImpellerParagraphBuilderBuildParagraphNew(ImpellerParagraphBuilder paragraph_builder, float width)
Definition: impeller.cc:1307
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderSaveLayer(ImpellerDisplayListBuilder builder, const ImpellerRect *bounds, ImpellerPaint paint, ImpellerImageFilter backdrop)
Definition: impeller.cc:249
IMPELLER_EXTERN_C void ImpellerPathBuilderAddRect(ImpellerPathBuilder builder, const ImpellerRect *rect)
Definition: impeller.cc:383
IMPELLER_EXTERN_C ImpellerGlyphInfo ImpellerParagraphCreateGlyphInfoAtCodeUnitIndexNew(ImpellerParagraph paragraph, size_t code_unit_index)
Definition: impeller.cc:1414
IMPELLER_EXTERN_C double ImpellerLineMetricsGetBaseline(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1463
IMPELLER_EXTERN_C void ImpellerPaintSetStrokeCap(ImpellerPaint paint, ImpellerStrokeCap cap)
Definition: impeller.cc:495
IMPELLER_EXTERN_C void ImpellerParagraphBuilderRelease(ImpellerParagraphBuilder paragraph_builder)
Definition: impeller.cc:1275
IMPELLER_EXTERN_C double ImpellerLineMetricsGetUnscaledAscent(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1447
IMPELLER_EXTERN_C void ImpellerPathBuilderLineTo(ImpellerPathBuilder builder, const ImpellerPoint *location)
Definition: impeller.cc:358
IMPELLER_EXTERN_C void ImpellerPathRetain(ImpellerPath path)
Definition: impeller.cc:322
IMPELLER_EXTERN_C void ImpellerPaintSetStrokeJoin(ImpellerPaint paint, ImpellerStrokeJoin join)
Definition: impeller.cc:500
IMPELLER_EXTERN_C ImpellerGlyphInfo ImpellerParagraphCreateGlyphInfoAtParagraphCoordinatesNew(ImpellerParagraph paragraph, double x, double y)
Definition: impeller.cc:1423
IMPELLER_EXTERN_C float ImpellerParagraphGetHeight(ImpellerParagraph paragraph)
Definition: impeller.cc:1329
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderClipOval(ImpellerDisplayListBuilder builder, const ImpellerRect *oval_bounds, ImpellerClipOperation op)
Definition: impeller.cc:439
IMPELLER_EXTERN_C void ImpellerPathBuilderRetain(ImpellerPathBuilder builder)
Definition: impeller.cc:342
IMPELLER_EXTERN_C void ImpellerParagraphBuilderPushStyle(ImpellerParagraphBuilder paragraph_builder, ImpellerParagraphStyle style)
Definition: impeller.cc:1281
IMPELLER_EXTERN_C void ImpellerPathBuilderAddOval(ImpellerPathBuilder builder, const ImpellerRect *oval_bounds)
Definition: impeller.cc:400
IMPELLER_EXTERN_C ImpellerTypographyContext ImpellerTypographyContextNew()
Definition: impeller.cc:1371
IMPELLER_EXTERN_C float ImpellerParagraphGetAlphabeticBaseline(ImpellerParagraph paragraph)
Definition: impeller.cc:1354
IMPELLER_EXTERN_C void ImpellerPathRelease(ImpellerPath path)
Definition: impeller.cc:327
IMPELLER_EXTERN_C ImpellerImageFilter ImpellerImageFilterCreateBlurNew(float x_sigma, float y_sigma, ImpellerTileMode tile_mode)
Definition: impeller.cc:1054
IMPELLER_EXTERN_C void ImpellerColorSourceRetain(ImpellerColorSource color_source)
Definition: impeller.cc:818
IMPELLER_EXTERN_C float ImpellerParagraphGetMinIntrinsicWidth(ImpellerParagraph paragraph)
Definition: impeller.cc:1339
IMPELLER_EXTERN_C void ImpellerPaintSetStrokeWidth(ImpellerPaint paint, float width)
Definition: impeller.cc:505
IMPELLER_EXTERN_C void ImpellerMaskFilterRetain(ImpellerMaskFilter mask_filter)
Definition: impeller.cc:1028
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawDashedLine(ImpellerDisplayListBuilder builder, const ImpellerPoint *from, const ImpellerPoint *to, float on_length, float off_length, ImpellerPaint paint)
Definition: impeller.cc:532
IMPELLER_EXTERN_C ImpellerPath ImpellerPathBuilderTakePathNew(ImpellerPathBuilder builder, ImpellerFillType fill)
Definition: impeller.cc:426
IMPELLER_EXTERN_C ImpellerPath ImpellerPathBuilderCopyPathNew(ImpellerPathBuilder builder, ImpellerFillType fill)
Definition: impeller.cc:420
IMPELLER_EXTERN_C void ImpellerColorSourceRelease(ImpellerColorSource color_source)
Definition: impeller.cc:823
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderClipRoundedRect(ImpellerDisplayListBuilder builder, const ImpellerRect *rect, const ImpellerRoundingRadii *radii, ImpellerClipOperation op)
Definition: impeller.cc:446
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderClipRect(ImpellerDisplayListBuilder builder, const ImpellerRect *rect, ImpellerClipOperation op)
Definition: impeller.cc:432
IMPELLER_EXTERN_C double ImpellerLineMetricsGetAscent(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1453
constexpr Matrix ToImpellerType(const ImpellerMatrix &m)
Definition: formats.h:213
IMPELLER_EXTERN_C void ImpellerGlyphInfoGetGraphemeClusterBounds(ImpellerGlyphInfo glyph_info, ImpellerRect *out_bounds)
Definition: impeller.cc:1541
IMPELLER_EXTERN_C size_t ImpellerGlyphInfoGetGraphemeClusterCodeUnitRangeEnd(ImpellerGlyphInfo glyph_info)
Definition: impeller.cc:1535
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:867
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetTextAlignment(ImpellerParagraphStyle paragraph_style, ImpellerTextAlignment align)
Definition: impeller.cc:1196
IMPELLER_EXTERN_C void ImpellerTypographyContextRelease(ImpellerTypographyContext context)
Definition: impeller.cc:1386
IMPELLER_EXTERN_C ImpellerTexture ImpellerTextureCreateWithOpenGLTextureHandleNew(ImpellerContext context, const ImpellerTextureDescriptor *descriptor, uint64_t external_gl_handle)
Definition: impeller.cc:642
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawRoundedRect(ImpellerDisplayListBuilder builder, const ImpellerRect *rect, const ImpellerRoundingRadii *radii, ImpellerPaint paint)
Definition: impeller.cc:562
IMPELLER_EXTERN_C ImpellerTexture ImpellerTextureCreateWithContentsNew(ImpellerContext context, const ImpellerTextureDescriptor *descriptor, const ImpellerMapping *contents, void *contents_on_release_user_data)
Definition: impeller.cc:597
IMPELLER_EXTERN_C void ImpellerPathBuilderMoveTo(ImpellerPathBuilder builder, const ImpellerPoint *location)
Definition: impeller.cc:352
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderTransform(ImpellerDisplayListBuilder builder, const ImpellerMatrix *transform)
Definition: impeller.cc:291
IMPELLER_EXTERN_C double ImpellerLineMetricsGetWidth(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1474
IMPELLER_EXTERN_C void ImpellerColorFilterRelease(ImpellerColorFilter color_filter)
Definition: impeller.cc:1008
IMPELLER_EXTERN_C bool ImpellerTypographyContextRegisterFont(ImpellerTypographyContext context, const ImpellerMapping *contents, void *contents_on_release_user_data, const char *family_name_alias)
Definition: impeller.cc:1391
IMPELLER_EXTERN_C double ImpellerLineMetricsGetLeft(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1484
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetFontWeight(ImpellerParagraphStyle paragraph_style, ImpellerFontWeight weight)
Definition: impeller.cc:1159
IMPELLER_EXTERN_C float ImpellerParagraphGetMaxIntrinsicWidth(ImpellerParagraph paragraph)
Definition: impeller.cc:1344
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:845
IMPELLER_EXTERN_C ImpellerSurface ImpellerVulkanSwapchainAcquireNextSurfaceNew(ImpellerVulkanSwapchain swapchain)
Definition: impeller.cc:223
IMPELLER_EXTERN_C ImpellerPathBuilder ImpellerPathBuilderNew()
Definition: impeller.cc:337
IMPELLER_EXTERN_C ImpellerContext ImpellerContextCreateMetalNew(uint32_t version)
Definition: impeller.cc:134
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetFontSize(ImpellerParagraphStyle paragraph_style, float size)
Definition: impeller.cc:1184
IMPELLER_EXTERN_C void ImpellerTextureRelease(ImpellerTexture texture)
Definition: impeller.cc:686
IMPELLER_EXTERN_C bool ImpellerContextGetVulkanInfo(ImpellerContext IMPELLER_NONNULL context, ImpellerContextVulkanInfo *out_vulkan_info)
Definition: impeller.cc:181
IMPELLER_EXTERN_C void ImpellerContextRelease(ImpellerContext context)
Definition: impeller.cc:176
IMPELLER_EXTERN_C void ImpellerImageFilterRelease(ImpellerImageFilter image_filter)
Definition: impeller.cc:1049
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawParagraph(ImpellerDisplayListBuilder builder, ImpellerParagraph paragraph, const ImpellerPoint *point)
Definition: impeller.cc:1235
IMPELLER_EXTERN_C ImpellerContext ImpellerContextCreateOpenGLESNew(uint32_t version, ImpellerProcAddressCallback gl_proc_address_callback, void *gl_proc_address_callback_user_data)
Definition: impeller.cc:108
IMPELLER_EXTERN_C ImpellerColorSource ImpellerColorSourceCreateImageNew(ImpellerTexture image, ImpellerTileMode horizontal_tile_mode, ImpellerTileMode vertical_tile_mode, ImpellerTextureSampling sampling, const ImpellerMatrix *transformation)
Definition: impeller.cc:939
IMPELLER_EXTERN_C void ImpellerMaskFilterRelease(ImpellerMaskFilter mask_filter)
Definition: impeller.cc:1033
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetFontFamily(ImpellerParagraphStyle paragraph_style, const char *family_name)
Definition: impeller.cc:1178
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetHeight(ImpellerParagraphStyle paragraph_style, float height)
Definition: impeller.cc:1190
IMPELLER_EXTERN_C void ImpellerPaintRetain(ImpellerPaint paint)
Definition: impeller.cc:470
IMPELLER_EXTERN_C void ImpellerContextRetain(ImpellerContext context)
Definition: impeller.cc:171
IMPELLER_EXTERN_C void ImpellerParagraphRelease(ImpellerParagraph paragraph)
Definition: impeller.cc:1319
IMPELLER_EXTERN_C void ImpellerPaintSetBlendMode(ImpellerPaint paint, ImpellerBlendMode mode)
Definition: impeller.cc:485
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderResetTransform(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:303
static std::string GetVersionAsString(uint32_t version)
Definition: impeller.cc:82
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderScale(ImpellerDisplayListBuilder builder, float x_scale, float y_scale)
Definition: impeller.cc:265
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetLocale(ImpellerParagraphStyle paragraph_style, const char *locale)
Definition: impeller.cc:1223
IMPELLER_EXTERN_C bool ImpellerSurfaceDrawDisplayList(ImpellerSurface surface, ImpellerDisplayList display_list)
Definition: impeller.cc:778
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetTextDecoration(ImpellerParagraphStyle paragraph_style, const ImpellerTextDecoration *decoration)
Definition: impeller.cc:1210
IMPELLER_EXTERN_C bool ImpellerSurfacePresent(ImpellerSurface surface)
Definition: impeller.cc:784
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawLine(ImpellerDisplayListBuilder builder, const ImpellerPoint *from, const ImpellerPoint *to, ImpellerPaint paint)
Definition: impeller.cc:521
IMPELLER_EXTERN_C size_t ImpellerGlyphInfoGetGraphemeClusterCodeUnitRangeBegin(ImpellerGlyphInfo glyph_info)
Definition: impeller.cc:1529
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawDisplayList(ImpellerDisplayListBuilder builder, ImpellerDisplayList display_list, float opacity)
Definition: impeller.cc:724
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderRestore(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:260
IMPELLER_EXTERN_C void ImpellerFragmentProgramRetain(ImpellerFragmentProgram fragment_program)
Definition: impeller.cc:1596
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawShadow(ImpellerDisplayListBuilder builder, ImpellerPath path, const ImpellerColor *color, float elevation, bool occluder_is_transparent, float device_pixel_ratio)
Definition: impeller.cc:1242
IMPELLER_EXTERN_C void ImpellerVulkanSwapchainRelease(ImpellerVulkanSwapchain swapchain)
Definition: impeller.cc:218
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderTranslate(ImpellerDisplayListBuilder builder, float x_translation, float y_translation)
Definition: impeller.cc:278
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetForeground(ImpellerParagraphStyle paragraph_style, ImpellerPaint paint)
Definition: impeller.cc:1147
IMPELLER_EXTERN_C uint32_t ImpellerDisplayListBuilderGetSaveCount(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:309
IMPELLER_EXTERN_C ImpellerImageFilter ImpellerImageFilterCreateDilateNew(float x_radius, float y_radius)
Definition: impeller.cc:1063
IMPELLER_EXTERN_C void ImpellerPaintSetStrokeMiter(ImpellerPaint paint, float miter)
Definition: impeller.cc:510
IMPELLER_EXTERN_C ImpellerParagraphStyle ImpellerParagraphStyleNew()
Definition: impeller.cc:1132
IMPELLER_EXTERN_C void ImpellerTextureRetain(ImpellerTexture texture)
Definition: impeller.cc:681
IMPELLER_EXTERN_C ImpellerLineMetrics ImpellerParagraphGetLineMetrics(ImpellerParagraph paragraph)
Definition: impeller.cc:1408
IMPELLER_EXTERN_C void ImpellerPathBuilderCubicCurveTo(ImpellerPathBuilder builder, const ImpellerPoint *control_point_1, const ImpellerPoint *control_point_2, const ImpellerPoint *end_point)
Definition: impeller.cc:372
IMPELLER_EXTERN_C void ImpellerImageFilterRetain(ImpellerImageFilter image_filter)
Definition: impeller.cc:1044
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:574
IMPELLER_EXTERN_C void ImpellerParagraphRetain(ImpellerParagraph paragraph)
Definition: impeller.cc:1314
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderRelease(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:239
IMPELLER_EXTERN_C ImpellerColorFilter ImpellerColorFilterCreateBlendNew(const ImpellerColor *color, ImpellerBlendMode blend_mode)
Definition: impeller.cc:1013
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderRestoreToCount(ImpellerDisplayListBuilder builder, uint32_t count)
Definition: impeller.cc:315
IMPELLER_EXTERN_C float ImpellerParagraphGetLongestLineWidth(ImpellerParagraph paragraph)
Definition: impeller.cc:1334
IMPELLER_EXTERN_C void ImpellerGlyphInfoRetain(ImpellerGlyphInfo glyph_info)
Definition: impeller.cc:1519
IMPELLER_EXTERN_C void ImpellerPaintSetMaskFilter(ImpellerPaint paint, ImpellerMaskFilter mask_filter)
Definition: impeller.cc:1126
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderSetTransform(ImpellerDisplayListBuilder builder, const ImpellerMatrix *transform)
Definition: impeller.cc:285
IMPELLER_EXTERN_C uint32_t ImpellerParagraphGetLineCount(ImpellerParagraph paragraph)
Definition: impeller.cc:1359
IMPELLER_EXTERN_C void ImpellerLineMetricsRetain(ImpellerLineMetrics line_metrics)
Definition: impeller.cc:1437
IMPELLER_EXTERN_C ImpellerImageFilter ImpellerImageFilterCreateErodeNew(float x_radius, float y_radius)
Definition: impeller.cc:1069
IMPELLER_EXTERN_C double ImpellerLineMetricsGetHeight(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1479
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderGetTransform(ImpellerDisplayListBuilder builder, ImpellerMatrix *out_transform)
Definition: impeller.cc:297
IMPELLER_EXTERN_C void ImpellerSurfaceRelease(ImpellerSurface surface)
Definition: impeller.cc:773
constexpr void FromImpellerType(const Matrix &from, ImpellerMatrix &to)
Definition: formats.h:221
static std::string ReadString(const char *string)
Definition: impeller.cc:1170
IMPELLER_EXTERN_C void ImpellerPaintSetColorFilter(ImpellerPaint paint, ImpellerColorFilter color_filter)
Definition: impeller.cc:1108
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderRotate(ImpellerDisplayListBuilder builder, float angle_degrees)
Definition: impeller.cc:272
IMPELLER_EXTERN_C float ImpellerParagraphGetMaxWidth(ImpellerParagraph paragraph)
Definition: impeller.cc:1324
DEFINE_PEER_GETTER(ColorFilter, ImpellerColorFilter)
IMPELLER_EXTERN_C void ImpellerPathBuilderAddRoundedRect(ImpellerPathBuilder builder, const ImpellerRect *rect, const ImpellerRoundingRadii *rounding_radii)
Definition: impeller.cc:406
IMPELLER_EXTERN_C void ImpellerVulkanSwapchainRetain(ImpellerVulkanSwapchain swapchain)
Definition: impeller.cc:213
IMPELLER_EXTERN_C ImpellerVulkanSwapchain ImpellerVulkanSwapchainCreateNew(ImpellerContext context, void *vulkan_surface_khr)
Definition: impeller.cc:197
IMPELLER_EXTERN_C float ImpellerParagraphGetIdeographicBaseline(ImpellerParagraph paragraph)
Definition: impeller.cc:1349
constexpr flutter::DlColor ToDisplayListType(Color color)
Definition: formats.h:89
IMPELLER_EXTERN_C void ImpellerPaintSetDrawStyle(ImpellerPaint paint, ImpellerDrawStyle style)
Definition: impeller.cc:490
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawTexture(ImpellerDisplayListBuilder builder, ImpellerTexture texture, const ImpellerPoint *point, ImpellerTextureSampling sampling, ImpellerPaint paint)
Definition: impeller.cc:789
IMPELLER_EXTERN_C void ImpellerPaintSetImageFilter(ImpellerPaint paint, ImpellerImageFilter image_filter)
Definition: impeller.cc:1120
IMPELLER_EXTERN_C void ImpellerPathGetBounds(ImpellerPath path, ImpellerRect *out_bounds)
Definition: impeller.cc:332
IMPELLER_EXTERN_C void ImpellerDisplayListRelease(ImpellerDisplayList display_list)
Definition: impeller.cc:709
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderClipPath(ImpellerDisplayListBuilder builder, ImpellerPath path, ImpellerClipOperation op)
Definition: impeller.cc:458
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:889
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawPath(ImpellerDisplayListBuilder builder, ImpellerPath path, ImpellerPaint paint)
Definition: impeller.cc:590
IMPELLER_EXTERN_C void ImpellerPathBuilderAddArc(ImpellerPathBuilder builder, const ImpellerRect *oval_bounds, float start_angle_degrees, float end_angle_degrees)
Definition: impeller.cc:389
IMPELLER_EXTERN_C void ImpellerDisplayListRetain(ImpellerDisplayList display_list)
Definition: impeller.cc:704
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetBackground(ImpellerParagraphStyle paragraph_style, ImpellerPaint paint)
Definition: impeller.cc:1153
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawRect(ImpellerDisplayListBuilder builder, const ImpellerRect *rect, ImpellerPaint paint)
Definition: impeller.cc:548
IMPELLER_EXTERN_C void ImpellerPaintSetColor(ImpellerPaint paint, const ImpellerColor *color)
Definition: impeller.cc:480
IMPELLER_EXTERN_C void ImpellerParagraphBuilderAddText(ImpellerParagraphBuilder paragraph_builder, const uint8_t *data, uint32_t length)
Definition: impeller.cc:1294
IMPELLER_EXTERN_C void ImpellerFragmentProgramRelease(ImpellerFragmentProgram fragment_program)
Definition: impeller.cc:1601
std::shared_ptr< ReactorGLES > reactor
std::shared_ptr< ContextGLES > context
Scalar weight
ImpellerCallback IMPELLER_NULLABLE on_release
Definition: impeller.h:629
uint64_t length
Definition: impeller.h:628
const uint8_t *IMPELLER_NONNULL data
Definition: impeller.h:627
ImpellerPixelFormat pixel_format
Definition: impeller.h:621
ImpellerISize size
Definition: impeller.h:622
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< std::vector< uint8_t > > uniforms
Definition: impeller.cc:958
std::vector< std::shared_ptr< flutter::DlColorSource > > samplers
Definition: impeller.cc:957
const size_t start
const size_t end
#define VALIDATION_LOG
Definition: validation.h:91