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
116  auto context = ContextGLES::Create(
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 
134  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 
152  uint32_t version,
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) {
172  ObjectBase::SafeRetain(context);
173 }
174 
176 void ImpellerContextRelease(ImpellerContext context) {
177  ObjectBase::SafeRelease(context);
178 }
179 
181 bool ImpellerContextGetVulkanInfo(ImpellerContext IMPELLER_NONNULL context,
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 
229  const ImpellerRect* cull_rect) {
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  texture->SetCoordinateSystem(TextureCoordinateSystem::kUploadFromHost);
676  return Create<Texture>(impeller::Context::BackendType::kOpenGLES,
677  std::move(texture))
678  .Leak();
679 }
680 
682 void ImpellerTextureRetain(ImpellerTexture texture) {
683  ObjectBase::SafeRetain(texture);
684 }
685 
687 void ImpellerTextureRelease(ImpellerTexture texture) {
688  ObjectBase::SafeRelease(texture);
689 }
690 
692 uint64_t ImpellerTextureGetOpenGLHandle(ImpellerTexture texture) {
693  auto interop_texture = GetPeer(texture);
694  if (interop_texture->GetBackendType() !=
696  VALIDATION_LOG << "Can only fetch the texture handle of an OpenGL texture.";
697  return 0u;
698  }
699  return TextureGLES::Cast(*interop_texture->GetTexture())
700  .GetGLHandle()
701  .value_or(0u);
702 }
703 
705 void ImpellerDisplayListRetain(ImpellerDisplayList display_list) {
706  ObjectBase::SafeRetain(display_list);
707 }
708 
710 void ImpellerDisplayListRelease(ImpellerDisplayList display_list) {
711  ObjectBase::SafeRelease(display_list);
712 }
713 
716  ImpellerDisplayListBuilder builder) {
717  auto dl = GetPeer(builder)->Build();
718  if (!dl->IsValid()) {
719  return nullptr;
720  }
721  return dl.Leak();
722 }
723 
726  ImpellerDisplayListBuilder builder,
727  ImpellerDisplayList display_list,
728  float opacity) {
729  GetPeer(builder)->DrawDisplayList(*GetPeer(display_list), opacity);
730 }
731 
733 ImpellerSurface ImpellerSurfaceCreateWrappedFBONew(ImpellerContext context,
734  uint64_t fbo,
735  ImpellerPixelFormat format,
736  const ImpellerISize* size) {
737 #if IMPELLER_ENABLE_OPENGLES
738  if (!GetPeer(context)->IsGL()) {
739  VALIDATION_LOG << "Context is not OpenGL.";
740  return nullptr;
741  }
742  return Create<SurfaceGLES>(*GetPeer(context), //
743  fbo, //
744  ToImpellerType(format), //
745  ToImpellerType(*size)) //
746  .Leak();
747 #else // IMPELLER_ENABLE_OPENGLES
748  VALIDATION_LOG << "OpenGL unavailable.";
749  return nullptr;
750 #endif // IMPELLER_ENABLE_OPENGLES
751 }
752 
755  ImpellerContext context,
756  void* metal_drawable) {
757 #if IMPELLER_ENABLE_METAL
758  if (!GetPeer(context)->IsMetal()) {
759  VALIDATION_LOG << "Context is not Metal.";
760  return nullptr;
761  }
762  return Create<SurfaceMTL>(*GetPeer(context), metal_drawable).Leak();
763 #else // IMPELLER_ENABLE_METAL
764  VALIDATION_LOG << "Metal unavailable.";
765  return nullptr;
766 #endif // IMPELLER_ENABLE_METAL
767 }
768 
769 IMPELLER_EXTERN_C void ImpellerSurfaceRetain(ImpellerSurface surface) {
770  ObjectBase::SafeRetain(surface);
771 }
772 
774 void ImpellerSurfaceRelease(ImpellerSurface surface) {
775  ObjectBase::SafeRelease(surface);
776 }
777 
779 bool ImpellerSurfaceDrawDisplayList(ImpellerSurface surface,
780  ImpellerDisplayList display_list) {
781  return GetPeer(surface)->DrawDisplayList(*GetPeer(display_list));
782 }
783 
785 bool ImpellerSurfacePresent(ImpellerSurface surface) {
786  return GetPeer(surface)->Present();
787 }
788 
790 void ImpellerDisplayListBuilderDrawTexture(ImpellerDisplayListBuilder builder,
791  ImpellerTexture texture,
792  const ImpellerPoint* point,
793  ImpellerTextureSampling sampling,
794  ImpellerPaint paint) {
795  GetPeer(builder)->DrawTexture(*GetPeer(texture), //
796  ToImpellerType(*point), //
797  ToDisplayListType(sampling), //
798  GetPeer(paint) //
799  );
800 }
801 
804  ImpellerDisplayListBuilder builder,
805  ImpellerTexture texture,
806  const ImpellerRect* src_rect,
807  const ImpellerRect* dst_rect,
808  ImpellerTextureSampling sampling,
809  ImpellerPaint paint) {
810  GetPeer(builder)->DrawTextureRect(*GetPeer(texture), //
811  ToImpellerType(*src_rect), //
812  ToImpellerType(*dst_rect), //
813  ToDisplayListType(sampling), //
814  GetPeer(paint) //
815  );
816 }
817 
819 void ImpellerColorSourceRetain(ImpellerColorSource color_source) {
820  ObjectBase::SafeRetain(color_source);
821 }
822 
824 void ImpellerColorSourceRelease(ImpellerColorSource color_source) {
825  ObjectBase::SafeRelease(color_source);
826 }
827 
828 static std::pair<std::vector<flutter::DlColor>, std::vector<Scalar>>
829 ParseColorsAndStops(uint32_t stop_count,
830  const ImpellerColor* colors,
831  const float* stops) {
832  if (stop_count == 0) {
833  return {};
834  }
835  std::pair<std::vector<flutter::DlColor>, std::vector<Scalar>> result;
836  result.first.reserve(stop_count);
837  result.second.reserve(stop_count);
838  for (size_t i = 0; i < stop_count; i++) {
839  result.first.emplace_back(ToDisplayListType(colors[i]));
840  result.second.emplace_back(stops[i]);
841  }
842  return result;
843 }
844 
847  const ImpellerPoint* start_point,
848  const ImpellerPoint* end_point,
849  uint32_t stop_count,
850  const ImpellerColor* colors,
851  const float* stops,
852  ImpellerTileMode tile_mode,
853  const ImpellerMatrix* transformation) {
854  const auto colors_and_stops = ParseColorsAndStops(stop_count, colors, stops);
856  ToImpellerType(*start_point), //
857  ToImpellerType(*end_point), //
858  colors_and_stops.first, //
859  colors_and_stops.second, //
860  ToDisplayListType(tile_mode), //
861  transformation == nullptr ? Matrix{}
862  : ToImpellerType(*transformation) //
863  )
864  .Leak();
865 }
866 
869  const ImpellerPoint* center,
870  float radius,
871  uint32_t stop_count,
872  const ImpellerColor* colors,
873  const float* stops,
874  ImpellerTileMode tile_mode,
875  const ImpellerMatrix* transformation) {
876  const auto colors_and_stops = ParseColorsAndStops(stop_count, colors, stops);
878  ToImpellerType(*center), //
879  radius, //
880  colors_and_stops.first, //
881  colors_and_stops.second, //
882  ToDisplayListType(tile_mode), //
883  transformation == nullptr ? Matrix{}
884  : ToImpellerType(*transformation) //
885  )
886  .Leak();
887 }
888 
891  const ImpellerPoint* start_center,
892  float start_radius,
893  const ImpellerPoint* end_center,
894  float end_radius,
895  uint32_t stop_count,
896  const ImpellerColor* colors,
897  const float* stops,
898  ImpellerTileMode tile_mode,
899  const ImpellerMatrix* transformation) {
900  const auto colors_and_stops = ParseColorsAndStops(stop_count, colors, stops);
902  ToImpellerType(*start_center), //
903  start_radius, //
904  ToImpellerType(*end_center), //
905  end_radius, //
906  colors_and_stops.first, //
907  colors_and_stops.second, //
908  ToDisplayListType(tile_mode), //
909  transformation == nullptr ? Matrix{}
910  : ToImpellerType(*transformation) //
911  )
912  .Leak();
913 }
914 
917  const ImpellerPoint* center,
918  float start,
919  float end,
920  uint32_t stop_count,
921  const ImpellerColor* colors,
922  const float* stops,
923  ImpellerTileMode tile_mode,
924  const ImpellerMatrix* transformation) {
925  const auto colors_and_stops = ParseColorsAndStops(stop_count, colors, stops);
927  ToImpellerType(*center), //
928  start, //
929  end, //
930  colors_and_stops.first, //
931  colors_and_stops.second, //
932  ToDisplayListType(tile_mode), //
933  transformation == nullptr ? Matrix{}
934  : ToImpellerType(*transformation) //
935  )
936  .Leak();
937 }
938 
941  ImpellerTexture image,
942  ImpellerTileMode horizontal_tile_mode,
943  ImpellerTileMode vertical_tile_mode,
944  ImpellerTextureSampling sampling,
945  const ImpellerMatrix* transformation) {
946  return ColorSource::MakeImage(
947  *GetPeer(image), //
948  ToDisplayListType(horizontal_tile_mode), //
949  ToDisplayListType(vertical_tile_mode), //
950  ToDisplayListType(sampling), //
951  transformation == nullptr ? Matrix{}
952  : ToImpellerType(*transformation) //
953  )
954  .Leak();
955 }
956 
958  std::vector<std::shared_ptr<flutter::DlColorSource>> samplers;
959  std::shared_ptr<std::vector<uint8_t>> uniforms;
960 };
961 
962 static SamplersAndUniforms ReadSamplersAndUniforms(ImpellerTexture* samplers,
963  size_t samplers_count,
964  const uint8_t* data,
965  size_t data_bytes_length) {
966  SamplersAndUniforms result;
967  result.uniforms = std::make_shared<std::vector<uint8_t>>();
968  if (data_bytes_length > 0) {
969  std::copy(data, data + data_bytes_length,
970  std::back_inserter(*result.uniforms));
971  }
972  if (samplers_count > 0) {
973  result.samplers.reserve(samplers_count);
974  for (size_t i = 0; i < samplers_count; i++) {
975  result.samplers.emplace_back(flutter::DlColorSource::MakeImage(
976  DlImageImpeller::Make(GetPeer(samplers[i])->GetTexture()), //
977  flutter::DlTileMode::kClamp, //
978  flutter::DlTileMode::kClamp //
979  ));
980  }
981  }
982  return result;
983 }
984 
985 IMPELLER_EXTERN_C ImpellerColorSource
987  ImpellerContext context,
988  ImpellerFragmentProgram fragment_program,
989  ImpellerTexture* samplers,
990  size_t samplers_count,
991  const uint8_t* data,
992  size_t data_bytes_length) {
993  auto bindings = ReadSamplersAndUniforms(samplers, samplers_count, data,
994  data_bytes_length);
995  return ColorSource::MakeFragmentProgram(*GetPeer(context), //
996  *GetPeer(fragment_program), //
997  std::move(bindings.samplers), //
998  std::move(bindings.uniforms) //
999  )
1000  .Leak();
1001 }
1002 
1004 void ImpellerColorFilterRetain(ImpellerColorFilter color_filter) {
1005  ObjectBase::SafeRetain(color_filter);
1006 }
1007 
1009 void ImpellerColorFilterRelease(ImpellerColorFilter color_filter) {
1010  ObjectBase::SafeRelease(color_filter);
1011 }
1012 
1015  const ImpellerColor* color,
1016  ImpellerBlendMode blend_mode) {
1017  return ColorFilter::MakeBlend(ToImpellerType(*color),
1018  ToImpellerType(blend_mode))
1019  .Leak();
1020 }
1021 
1024  const ImpellerColorMatrix* color_matrix) {
1025  return ColorFilter::MakeMatrix(color_matrix->m).Leak();
1026 }
1027 
1029 void ImpellerMaskFilterRetain(ImpellerMaskFilter mask_filter) {
1030  ObjectBase::SafeRetain(mask_filter);
1031 }
1032 
1034 void ImpellerMaskFilterRelease(ImpellerMaskFilter mask_filter) {
1035  ObjectBase::SafeRelease(mask_filter);
1036 }
1037 
1040  float sigma) {
1041  return MaskFilter::MakeBlur(ToDisplayListType(style), sigma).Leak();
1042 }
1043 
1045 void ImpellerImageFilterRetain(ImpellerImageFilter image_filter) {
1046  ObjectBase::SafeRetain(image_filter);
1047 }
1048 
1050 void ImpellerImageFilterRelease(ImpellerImageFilter image_filter) {
1051  ObjectBase::SafeRelease(image_filter);
1052 }
1053 
1056  float x_sigma,
1057  float y_sigma,
1058  ImpellerTileMode tile_mode) {
1059  return ImageFilter::MakeBlur(x_sigma, y_sigma, ToDisplayListType(tile_mode))
1060  .Leak();
1061 }
1062 
1064 ImpellerImageFilter ImpellerImageFilterCreateDilateNew(float x_radius,
1065  float y_radius) {
1066  return ImageFilter::MakeDilate(x_radius, y_radius).Leak();
1067 }
1068 
1070 ImpellerImageFilter ImpellerImageFilterCreateErodeNew(float x_radius,
1071  float y_radius) {
1072  return ImageFilter::MakeErode(x_radius, y_radius).Leak();
1073 }
1074 
1077  const ImpellerMatrix* matrix,
1078  ImpellerTextureSampling sampling) {
1079  return ImageFilter::MakeMatrix(ToImpellerType(*matrix),
1080  ToDisplayListType(sampling))
1081  .Leak();
1082 }
1083 
1086  ImpellerContext context,
1087  ImpellerFragmentProgram fragment_program,
1088  ImpellerTexture* samplers,
1089  size_t samplers_count,
1090  const uint8_t* data,
1091  size_t data_bytes_length) {
1092  auto bindings = ReadSamplersAndUniforms(samplers, samplers_count, data,
1093  data_bytes_length);
1094  return ImageFilter::MakeFragmentProgram(*GetPeer(context), //
1095  *GetPeer(fragment_program), //
1096  std::move(bindings.samplers), //
1097  std::move(bindings.uniforms) //
1098  )
1099  .Leak();
1100 }
1101 
1103  ImpellerImageFilter outer,
1104  ImpellerImageFilter inner) {
1105  return ImageFilter::MakeCompose(*GetPeer(outer), *GetPeer(inner)).Leak();
1106 }
1107 
1109 void ImpellerPaintSetColorFilter(ImpellerPaint paint,
1110  ImpellerColorFilter color_filter) {
1111  GetPeer(paint)->SetColorFilter(*GetPeer(color_filter));
1112 }
1113 
1115 void ImpellerPaintSetColorSource(ImpellerPaint paint,
1116  ImpellerColorSource color_source) {
1117  GetPeer(paint)->SetColorSource(*GetPeer(color_source));
1118 }
1119 
1121 void ImpellerPaintSetImageFilter(ImpellerPaint paint,
1122  ImpellerImageFilter image_filter) {
1123  GetPeer(paint)->SetImageFilter(*GetPeer(image_filter));
1124 }
1125 
1127 void ImpellerPaintSetMaskFilter(ImpellerPaint paint,
1128  ImpellerMaskFilter mask_filter) {
1129  GetPeer(paint)->SetMaskFilter(*GetPeer(mask_filter));
1130 }
1131 
1133 ImpellerParagraphStyle ImpellerParagraphStyleNew() {
1134  return Create<ParagraphStyle>().Leak();
1135 }
1136 
1138 void ImpellerParagraphStyleRetain(ImpellerParagraphStyle paragraph_style) {
1139  ObjectBase::SafeRetain(paragraph_style);
1140 }
1141 
1143 void ImpellerParagraphStyleRelease(ImpellerParagraphStyle paragraph_style) {
1144  ObjectBase::SafeRelease(paragraph_style);
1145 }
1146 
1148 void ImpellerParagraphStyleSetForeground(ImpellerParagraphStyle paragraph_style,
1149  ImpellerPaint paint) {
1150  GetPeer(paragraph_style)->SetForeground(Ref(GetPeer(paint)));
1151 }
1152 
1154 void ImpellerParagraphStyleSetBackground(ImpellerParagraphStyle paragraph_style,
1155  ImpellerPaint paint) {
1156  GetPeer(paragraph_style)->SetBackground(Ref(GetPeer(paint)));
1157 }
1158 
1160 void ImpellerParagraphStyleSetFontWeight(ImpellerParagraphStyle paragraph_style,
1161  ImpellerFontWeight weight) {
1162  GetPeer(paragraph_style)->SetFontWeight(ToTxtType(weight));
1163 }
1164 
1166 void ImpellerParagraphStyleSetFontStyle(ImpellerParagraphStyle paragraph_style,
1167  ImpellerFontStyle style) {
1168  GetPeer(paragraph_style)->SetFontStyle(ToTxtType(style));
1169 }
1170 
1171 static std::string ReadString(const char* string) {
1172  if (string == nullptr) {
1173  return "";
1174  }
1175  return std::string{string};
1176 }
1177 
1179 void ImpellerParagraphStyleSetFontFamily(ImpellerParagraphStyle paragraph_style,
1180  const char* family_name) {
1181  GetPeer(paragraph_style)->SetFontFamily(ReadString(family_name));
1182 }
1183 
1185 void ImpellerParagraphStyleSetFontSize(ImpellerParagraphStyle paragraph_style,
1186  float size) {
1187  GetPeer(paragraph_style)->SetFontSize(size);
1188 }
1189 
1191 void ImpellerParagraphStyleSetHeight(ImpellerParagraphStyle paragraph_style,
1192  float height) {
1193  GetPeer(paragraph_style)->SetHeight(height);
1194 }
1195 
1198  ImpellerParagraphStyle paragraph_style,
1199  ImpellerTextAlignment align) {
1200  GetPeer(paragraph_style)->SetTextAlignment(ToTxtType(align));
1201 }
1202 
1205  ImpellerParagraphStyle paragraph_style,
1206  ImpellerTextDirection direction) {
1207  GetPeer(paragraph_style)->SetTextDirection(ToTxtType(direction));
1208 }
1209 
1212  ImpellerParagraphStyle paragraph_style,
1213  const ImpellerTextDecoration* decoration) {
1214  GetPeer(paragraph_style)->SetTextDecoration(*decoration);
1215 }
1216 
1218 void ImpellerParagraphStyleSetMaxLines(ImpellerParagraphStyle paragraph_style,
1219  uint32_t max_lines) {
1220  GetPeer(paragraph_style)->SetMaxLines(max_lines);
1221 }
1222 
1224 void ImpellerParagraphStyleSetLocale(ImpellerParagraphStyle paragraph_style,
1225  const char* locale) {
1226  GetPeer(paragraph_style)->SetLocale(ReadString(locale));
1227 }
1228 
1230 void ImpellerParagraphStyleSetEllipsis(ImpellerParagraphStyle paragraph_style,
1231  const char* ellipsis) {
1232  GetPeer(paragraph_style)->SetEllipsis(ReadString(ellipsis));
1233 }
1234 
1236 void ImpellerDisplayListBuilderDrawParagraph(ImpellerDisplayListBuilder builder,
1237  ImpellerParagraph paragraph,
1238  const ImpellerPoint* point) {
1239  GetPeer(builder)->DrawParagraph(*GetPeer(paragraph), ToImpellerType(*point));
1240 }
1241 
1243 void ImpellerDisplayListBuilderDrawShadow(ImpellerDisplayListBuilder builder,
1244  ImpellerPath path,
1245  const ImpellerColor* color,
1246  float elevation,
1247  bool occluder_is_transparent,
1248  float device_pixel_ratio) {
1249  GetPeer(builder)->DrawShadow(*GetPeer(path), //
1250  ToDisplayListType(*color), //
1251  elevation, //
1252  occluder_is_transparent, //
1253  device_pixel_ratio //
1254  );
1255 }
1256 
1258 ImpellerParagraphBuilder ImpellerParagraphBuilderNew(
1259  ImpellerTypographyContext context) {
1260  auto builder =
1261  Create<ParagraphBuilder>(Ref<TypographyContext>(GetPeer(context)));
1262  if (!builder->IsValid()) {
1263  VALIDATION_LOG << "Could not create valid paragraph builder.";
1264  return nullptr;
1265  }
1266  return builder.Leak();
1267 }
1268 
1271  ImpellerParagraphBuilder paragraph_builder) {
1272  ObjectBase::SafeRetain(paragraph_builder);
1273 }
1274 
1277  ImpellerParagraphBuilder paragraph_builder) {
1278  ObjectBase::SafeRelease(paragraph_builder);
1279 }
1280 
1283  ImpellerParagraphBuilder paragraph_builder,
1284  ImpellerParagraphStyle style) {
1285  GetPeer(paragraph_builder)->PushStyle(*GetPeer(style));
1286 }
1287 
1290  ImpellerParagraphBuilder paragraph_builder) {
1291  GetPeer(paragraph_builder)->PopStyle();
1292 }
1293 
1295 void ImpellerParagraphBuilderAddText(ImpellerParagraphBuilder paragraph_builder,
1296  const uint8_t* data,
1297  uint32_t length) {
1298  if (data == nullptr) {
1299  length = 0;
1300  }
1301  if (length == 0) {
1302  return;
1303  }
1304  GetPeer(paragraph_builder)->AddText(data, length);
1305 }
1306 
1309  ImpellerParagraphBuilder paragraph_builder,
1310  float width) {
1311  return GetPeer(paragraph_builder)->Build(width).Leak();
1312 }
1313 
1315 void ImpellerParagraphRetain(ImpellerParagraph paragraph) {
1316  ObjectBase::SafeRetain(paragraph);
1317 }
1318 
1320 void ImpellerParagraphRelease(ImpellerParagraph paragraph) {
1321  ObjectBase::SafeRelease(paragraph);
1322 }
1323 
1325 float ImpellerParagraphGetMaxWidth(ImpellerParagraph paragraph) {
1326  return GetPeer(paragraph)->GetMaxWidth();
1327 }
1328 
1330 float ImpellerParagraphGetHeight(ImpellerParagraph paragraph) {
1331  return GetPeer(paragraph)->GetHeight();
1332 }
1333 
1335 float ImpellerParagraphGetLongestLineWidth(ImpellerParagraph paragraph) {
1336  return GetPeer(paragraph)->GetLongestLineWidth();
1337 }
1338 
1340 float ImpellerParagraphGetMinIntrinsicWidth(ImpellerParagraph paragraph) {
1341  return GetPeer(paragraph)->GetMinIntrinsicWidth();
1342 }
1343 
1345 float ImpellerParagraphGetMaxIntrinsicWidth(ImpellerParagraph paragraph) {
1346  return GetPeer(paragraph)->GetMaxIntrinsicWidth();
1347 }
1348 
1350 float ImpellerParagraphGetIdeographicBaseline(ImpellerParagraph paragraph) {
1351  return GetPeer(paragraph)->GetIdeographicBaseline();
1352 }
1353 
1355 float ImpellerParagraphGetAlphabeticBaseline(ImpellerParagraph paragraph) {
1356  return GetPeer(paragraph)->GetAlphabeticBaseline();
1357 }
1358 
1360 uint32_t ImpellerParagraphGetLineCount(ImpellerParagraph paragraph) {
1361  return GetPeer(paragraph)->GetLineCount();
1362 }
1363 
1365 void ImpellerParagraphGetWordBoundary(ImpellerParagraph paragraph,
1366  size_t code_unit_index,
1367  ImpellerRange* out_range) {
1368  *out_range = GetPeer(paragraph)->GetWordBoundary(code_unit_index);
1369 }
1370 
1372 ImpellerTypographyContext ImpellerTypographyContextNew() {
1373  auto context = Create<TypographyContext>();
1374  if (!context->IsValid()) {
1375  VALIDATION_LOG << "Could not create typography context.";
1376  return nullptr;
1377  }
1378  return context.Leak();
1379 }
1380 
1382 void ImpellerTypographyContextRetain(ImpellerTypographyContext context) {
1383  ObjectBase::SafeRetain(context);
1384 }
1385 
1387 void ImpellerTypographyContextRelease(ImpellerTypographyContext context) {
1388  ObjectBase::SafeRelease(context);
1389 }
1390 
1392 bool ImpellerTypographyContextRegisterFont(ImpellerTypographyContext context,
1393  const ImpellerMapping* contents,
1394  void* contents_on_release_user_data,
1395  const char* family_name_alias) {
1396  auto wrapped_contents = std::make_unique<fml::NonOwnedMapping>(
1397  contents->data, // data ptr
1398  contents->length, // data length
1399  [on_release = contents->on_release, contents_on_release_user_data](auto,
1400  auto) {
1401  on_release(contents_on_release_user_data);
1402  } // release callback
1403  );
1404  return GetPeer(context)->RegisterFont(std::move(wrapped_contents),
1405  family_name_alias);
1406 }
1407 
1410  ImpellerParagraph paragraph) {
1411  return GetPeer(paragraph)->GetLineMetrics().GetC();
1412 }
1413 
1416  ImpellerParagraph paragraph,
1417  size_t code_unit_index) {
1418  return GetPeer(paragraph)
1419  ->GetGlyphInfoAtCodeUnitIndex(code_unit_index)
1420  .Leak();
1421 }
1422 
1425  ImpellerParagraph paragraph,
1426  double x,
1427  double y) {
1428  return GetPeer(paragraph)
1429  ->GetClosestGlyphInfoAtParagraphCoordinates(x, y)
1430  .Leak();
1431 }
1432 
1433 //------------------------------------------------------------------------------
1434 // Line Metrics
1435 //------------------------------------------------------------------------------
1436 
1438 void ImpellerLineMetricsRetain(ImpellerLineMetrics line_metrics) {
1439  ObjectBase::SafeRetain(line_metrics);
1440 }
1441 
1443 void ImpellerLineMetricsRelease(ImpellerLineMetrics line_metrics) {
1444  ObjectBase::SafeRelease(line_metrics);
1445 }
1446 
1448 double ImpellerLineMetricsGetUnscaledAscent(ImpellerLineMetrics metrics,
1449  size_t line) {
1450  return GetPeer(metrics)->GetUnscaledAscent(line);
1451 }
1452 
1454 double ImpellerLineMetricsGetAscent(ImpellerLineMetrics metrics, size_t line) {
1455  return GetPeer(metrics)->GetAscent(line);
1456 }
1457 
1459 double ImpellerLineMetricsGetDescent(ImpellerLineMetrics metrics, size_t line) {
1460  return GetPeer(metrics)->GetDescent(line);
1461 }
1462 
1464 double ImpellerLineMetricsGetBaseline(ImpellerLineMetrics metrics,
1465  size_t line) {
1466  return GetPeer(metrics)->GetBaseline(line);
1467 }
1468 
1470 bool ImpellerLineMetricsIsHardbreak(ImpellerLineMetrics metrics, size_t line) {
1471  return GetPeer(metrics)->IsHardbreak(line);
1472 }
1473 
1475 double ImpellerLineMetricsGetWidth(ImpellerLineMetrics metrics, size_t line) {
1476  return GetPeer(metrics)->GetWidth(line);
1477 }
1478 
1480 double ImpellerLineMetricsGetHeight(ImpellerLineMetrics metrics, size_t line) {
1481  return GetPeer(metrics)->GetHeight(line);
1482 }
1483 
1485 double ImpellerLineMetricsGetLeft(ImpellerLineMetrics metrics, size_t line) {
1486  return GetPeer(metrics)->GetLeft(line);
1487 }
1488 
1490 size_t ImpellerLineMetricsGetCodeUnitStartIndex(ImpellerLineMetrics metrics,
1491  size_t line) {
1492  return GetPeer(metrics)->GetCodeUnitStartIndex(line);
1493 }
1494 
1496 size_t ImpellerLineMetricsGetCodeUnitEndIndex(ImpellerLineMetrics metrics,
1497  size_t line) {
1498  return GetPeer(metrics)->GetCodeUnitEndIndex(line);
1499 }
1500 
1503  ImpellerLineMetrics metrics,
1504  size_t line) {
1505  return GetPeer(metrics)->GetCodeUnitEndIndexExcludingWhitespace(line);
1506 }
1507 
1510  ImpellerLineMetrics metrics,
1511  size_t line) {
1512  return GetPeer(metrics)->GetCodeUnitEndIndexIncludingNewline(line);
1513 }
1514 
1515 //------------------------------------------------------------------------------
1516 // Glyph Info
1517 //------------------------------------------------------------------------------
1518 
1520 void ImpellerGlyphInfoRetain(ImpellerGlyphInfo glyph_info) {
1521  ObjectBase::SafeRetain(glyph_info);
1522 }
1523 
1525 void ImpellerGlyphInfoRelease(ImpellerGlyphInfo glyph_info) {
1526  ObjectBase::SafeRelease(glyph_info);
1527 }
1528 
1531  ImpellerGlyphInfo glyph_info) {
1532  return GetPeer(glyph_info)->GetGraphemeClusterCodeUnitRangeBegin();
1533 }
1534 
1537  ImpellerGlyphInfo glyph_info) {
1538  return GetPeer(glyph_info)->GetGraphemeClusterCodeUnitRangeEnd();
1539 }
1540 
1542 void ImpellerGlyphInfoGetGraphemeClusterBounds(ImpellerGlyphInfo glyph_info,
1543  ImpellerRect* out_bounds) {
1544  *out_bounds = GetPeer(glyph_info)->GetGraphemeClusterBounds();
1545 }
1546 
1548 bool ImpellerGlyphInfoIsEllipsis(ImpellerGlyphInfo glyph_info) {
1549  return GetPeer(glyph_info)->IsEllipsis();
1550 }
1551 
1554  ImpellerGlyphInfo glyph_info) {
1555  return GetPeer(glyph_info)->GetTextDirection();
1556 }
1557 
1558 //------------------------------------------------------------------------------
1559 // Fragment Program
1560 //------------------------------------------------------------------------------
1561 
1562 static std::shared_ptr<fml::Mapping> MakeCopyableMapping(
1563  const ImpellerMapping* data,
1564  void* user_data) {
1565  if (data == nullptr) {
1566  return nullptr;
1567  }
1568 
1569  // If the user has supplied a release callback, defer deallocation to them.
1570  if (auto callback = data->on_release) {
1571  return std::make_shared<fml::NonOwnedMapping>(
1572  data->data, //
1573  data->length, //
1574  [user_data, callback](const uint8_t* data, size_t size) {
1575  callback(user_data);
1576  });
1577  }
1578 
1579  return std::make_shared<fml::MallocMapping>(
1580  fml::MallocMapping::Copy(data->data, data->length));
1581 }
1582 
1584 ImpellerFragmentProgram ImpellerFragmentProgramNew(
1585  const ImpellerMapping* data,
1586  void* data_release_user_data) {
1587  auto data_mapping = MakeCopyableMapping(data, data_release_user_data);
1588  auto program = Create<FragmentProgram>(std::move(data_mapping));
1589  if (!program->IsValid()) {
1590  VALIDATION_LOG << "Could not create valid fragment program.";
1591  return nullptr;
1592  }
1593  return program.Leak();
1594 }
1595 
1597 void ImpellerFragmentProgramRetain(ImpellerFragmentProgram fragment_program) {
1598  ObjectBase::SafeRetain(fragment_program);
1599 }
1600 
1602 void ImpellerFragmentProgramRelease(ImpellerFragmentProgram fragment_program) {
1603  ObjectBase::SafeRelease(fragment_program);
1604 }
1605 
1606 } // 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:76
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)
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 > 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:45
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:28
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:56
static ScopedObject< ImageFilter > MakeErode(Scalar x_radius, Scalar y_radius)
Definition: image_filter.cc:37
static ScopedObject< ImageFilter > MakeCompose(const ImageFilter &outer, const ImageFilter &inner)
Definition: image_filter.cc:85
static ScopedObject< ImageFilter > MakeBlur(Scalar x_sigma, Scalar y_sigma, flutter::DlTileMode tile_mode)
Definition: image_filter.cc:18
static ScopedObject< ImageFilter > MakeMatrix(const Matrix &matrix, flutter::DlImageSampling sampling)
Definition: image_filter.cc:46
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
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:1270
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:916
IMPELLER_EXTERN_C bool ImpellerLineMetricsIsHardbreak(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1470
IMPELLER_EXTERN_C void ImpellerGlyphInfoRelease(ImpellerGlyphInfo glyph_info)
Definition: impeller.cc:1525
IMPELLER_EXTERN_C ImpellerImageFilter ImpellerImageFilterCreateMatrixNew(const ImpellerMatrix *matrix, ImpellerTextureSampling sampling)
Definition: impeller.cc:1076
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawPaint(ImpellerDisplayListBuilder builder, ImpellerPaint paint)
Definition: impeller.cc:515
IMPELLER_EXTERN_C void ImpellerSurfaceRetain(ImpellerSurface surface)
Definition: impeller.cc:769
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetEllipsis(ImpellerParagraphStyle paragraph_style, const char *ellipsis)
Definition: impeller.cc:1230
IMPELLER_EXTERN_C void ImpellerParagraphStyleRelease(ImpellerParagraphStyle paragraph_style)
Definition: impeller.cc:1143
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:986
IMPELLER_EXTERN_C void ImpellerParagraphStyleRetain(ImpellerParagraphStyle paragraph_style)
Definition: impeller.cc:1138
IMPELLER_EXTERN_C size_t ImpellerLineMetricsGetCodeUnitStartIndex(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1490
IMPELLER_EXTERN_C ImpellerTextDirection ImpellerGlyphInfoGetTextDirection(ImpellerGlyphInfo glyph_info)
Definition: impeller.cc:1553
IMPELLER_EXTERN_C void ImpellerPaintSetColorSource(ImpellerPaint paint, ImpellerColorSource color_source)
Definition: impeller.cc:1115
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:1365
IMPELLER_EXTERN_C uint64_t ImpellerTextureGetOpenGLHandle(ImpellerTexture texture)
Definition: impeller.cc:692
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderRetain(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:234
IMPELLER_EXTERN_C void ImpellerParagraphBuilderPopStyle(ImpellerParagraphBuilder paragraph_builder)
Definition: impeller.cc:1289
static bool CheckVersion(uint32_t version)
Definition: impeller.cc:96
IMPELLER_EXTERN_C ImpellerMaskFilter ImpellerMaskFilterCreateBlurNew(ImpellerBlurStyle style, float sigma)
Definition: impeller.cc:1039
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetMaxLines(ImpellerParagraphStyle paragraph_style, uint32_t max_lines)
Definition: impeller.cc:1218
IMPELLER_EXTERN_C size_t ImpellerLineMetricsGetCodeUnitEndIndex(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1496
IMPELLER_EXTERN_C void ImpellerColorFilterRetain(ImpellerColorFilter color_filter)
Definition: impeller.cc:1004
IMPELLER_EXTERN_C ImpellerSurface ImpellerSurfaceCreateWrappedFBONew(ImpellerContext context, uint64_t fbo, ImpellerPixelFormat format, const ImpellerISize *size)
Definition: impeller.cc:733
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawTextureRect(ImpellerDisplayListBuilder builder, ImpellerTexture texture, const ImpellerRect *src_rect, const ImpellerRect *dst_rect, ImpellerTextureSampling sampling, ImpellerPaint paint)
Definition: impeller.cc:803
IMPELLER_EXTERN_C ImpellerFragmentProgram ImpellerFragmentProgramNew(const ImpellerMapping *data, void *data_release_user_data)
Definition: impeller.cc:1584
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:1085
IMPELLER_EXTERN_C void ImpellerLineMetricsRelease(ImpellerLineMetrics line_metrics)
Definition: impeller.cc:1443
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderSave(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:244
IMPELLER_EXTERN_C ImpellerDisplayList ImpellerDisplayListBuilderCreateDisplayListNew(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:715
IMPELLER_EXTERN_C bool ImpellerGlyphInfoIsEllipsis(ImpellerGlyphInfo glyph_info)
Definition: impeller.cc:1548
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:1258
IMPELLER_EXTERN_C ImpellerColorFilter ImpellerColorFilterCreateColorMatrixNew(const ImpellerColorMatrix *color_matrix)
Definition: impeller.cc:1023
static std::pair< std::vector< flutter::DlColor >, std::vector< Scalar > > ParseColorsAndStops(uint32_t stop_count, const ImpellerColor *colors, const float *stops)
Definition: impeller.cc:829
static std::shared_ptr< fml::Mapping > MakeCopyableMapping(const ImpellerMapping *data, void *user_data)
Definition: impeller.cc:1562
IMPELLER_EXTERN_C void ImpellerPaintRelease(ImpellerPaint paint)
Definition: impeller.cc:475
IMPELLER_EXTERN_C ImpellerDisplayListBuilder ImpellerDisplayListBuilderNew(const ImpellerRect *cull_rect)
Definition: impeller.cc:228
IMPELLER_EXTERN_C double ImpellerLineMetricsGetDescent(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1459
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetFontStyle(ImpellerParagraphStyle paragraph_style, ImpellerFontStyle style)
Definition: impeller.cc:1166
IMPELLER_EXTERN_C ImpellerPaint ImpellerPaintNew()
Definition: impeller.cc:465
IMPELLER_EXTERN_C void ImpellerTypographyContextRetain(ImpellerTypographyContext context)
Definition: impeller.cc:1382
static SamplersAndUniforms ReadSamplersAndUniforms(ImpellerTexture *samplers, size_t samplers_count, const uint8_t *data, size_t data_bytes_length)
Definition: impeller.cc:962
IMPELLER_EXTERN_C size_t ImpellerLineMetricsGetCodeUnitEndIndexIncludingNewline(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1509
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetTextDirection(ImpellerParagraphStyle paragraph_style, ImpellerTextDirection direction)
Definition: impeller.cc:1204
ScopedObject< Object > Ref(Object *object)
Definition: object.h:146
IMPELLER_EXTERN_C ImpellerSurface ImpellerSurfaceCreateWrappedMetalDrawableNew(ImpellerContext context, void *metal_drawable)
Definition: impeller.cc:754
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:1502
IMPELLER_EXTERN_C ImpellerContext ImpellerContextCreateVulkanNew(uint32_t version, const ImpellerContextVulkanSettings *settings)
Definition: impeller.cc:151
IMPELLER_EXTERN_C ImpellerParagraph ImpellerParagraphBuilderBuildParagraphNew(ImpellerParagraphBuilder paragraph_builder, float width)
Definition: impeller.cc:1308
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:1415
IMPELLER_EXTERN_C double ImpellerLineMetricsGetBaseline(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1464
IMPELLER_EXTERN_C void ImpellerPaintSetStrokeCap(ImpellerPaint paint, ImpellerStrokeCap cap)
Definition: impeller.cc:495
IMPELLER_EXTERN_C void ImpellerParagraphBuilderRelease(ImpellerParagraphBuilder paragraph_builder)
Definition: impeller.cc:1276
IMPELLER_EXTERN_C double ImpellerLineMetricsGetUnscaledAscent(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1448
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:1424
IMPELLER_EXTERN_C float ImpellerParagraphGetHeight(ImpellerParagraph paragraph)
Definition: impeller.cc:1330
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:1282
IMPELLER_EXTERN_C void ImpellerPathBuilderAddOval(ImpellerPathBuilder builder, const ImpellerRect *oval_bounds)
Definition: impeller.cc:400
IMPELLER_EXTERN_C ImpellerTypographyContext ImpellerTypographyContextNew()
Definition: impeller.cc:1372
IMPELLER_EXTERN_C float ImpellerParagraphGetAlphabeticBaseline(ImpellerParagraph paragraph)
Definition: impeller.cc:1355
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:1055
IMPELLER_EXTERN_C void ImpellerColorSourceRetain(ImpellerColorSource color_source)
Definition: impeller.cc:819
IMPELLER_EXTERN_C float ImpellerParagraphGetMinIntrinsicWidth(ImpellerParagraph paragraph)
Definition: impeller.cc:1340
IMPELLER_EXTERN_C void ImpellerPaintSetStrokeWidth(ImpellerPaint paint, float width)
Definition: impeller.cc:505
IMPELLER_EXTERN_C void ImpellerMaskFilterRetain(ImpellerMaskFilter mask_filter)
Definition: impeller.cc:1029
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:824
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:1454
constexpr Matrix ToImpellerType(const ImpellerMatrix &m)
Definition: formats.h:213
IMPELLER_EXTERN_C void ImpellerGlyphInfoGetGraphemeClusterBounds(ImpellerGlyphInfo glyph_info, ImpellerRect *out_bounds)
Definition: impeller.cc:1542
IMPELLER_EXTERN_C size_t ImpellerGlyphInfoGetGraphemeClusterCodeUnitRangeEnd(ImpellerGlyphInfo glyph_info)
Definition: impeller.cc:1536
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:868
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetTextAlignment(ImpellerParagraphStyle paragraph_style, ImpellerTextAlignment align)
Definition: impeller.cc:1197
IMPELLER_EXTERN_C void ImpellerTypographyContextRelease(ImpellerTypographyContext context)
Definition: impeller.cc:1387
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:1475
IMPELLER_EXTERN_C void ImpellerColorFilterRelease(ImpellerColorFilter color_filter)
Definition: impeller.cc:1009
IMPELLER_EXTERN_C bool ImpellerTypographyContextRegisterFont(ImpellerTypographyContext context, const ImpellerMapping *contents, void *contents_on_release_user_data, const char *family_name_alias)
Definition: impeller.cc:1392
IMPELLER_EXTERN_C double ImpellerLineMetricsGetLeft(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1485
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetFontWeight(ImpellerParagraphStyle paragraph_style, ImpellerFontWeight weight)
Definition: impeller.cc:1160
IMPELLER_EXTERN_C float ImpellerParagraphGetMaxIntrinsicWidth(ImpellerParagraph paragraph)
Definition: impeller.cc:1345
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:846
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:133
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetFontSize(ImpellerParagraphStyle paragraph_style, float size)
Definition: impeller.cc:1185
IMPELLER_EXTERN_C void ImpellerTextureRelease(ImpellerTexture texture)
Definition: impeller.cc:687
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:1050
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawParagraph(ImpellerDisplayListBuilder builder, ImpellerParagraph paragraph, const ImpellerPoint *point)
Definition: impeller.cc:1236
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:940
IMPELLER_EXTERN_C void ImpellerMaskFilterRelease(ImpellerMaskFilter mask_filter)
Definition: impeller.cc:1034
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetFontFamily(ImpellerParagraphStyle paragraph_style, const char *family_name)
Definition: impeller.cc:1179
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetHeight(ImpellerParagraphStyle paragraph_style, float height)
Definition: impeller.cc:1191
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:1320
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:1224
IMPELLER_EXTERN_C bool ImpellerSurfaceDrawDisplayList(ImpellerSurface surface, ImpellerDisplayList display_list)
Definition: impeller.cc:779
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetTextDecoration(ImpellerParagraphStyle paragraph_style, const ImpellerTextDecoration *decoration)
Definition: impeller.cc:1211
IMPELLER_EXTERN_C bool ImpellerSurfacePresent(ImpellerSurface surface)
Definition: impeller.cc:785
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:1530
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderDrawDisplayList(ImpellerDisplayListBuilder builder, ImpellerDisplayList display_list, float opacity)
Definition: impeller.cc:725
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderRestore(ImpellerDisplayListBuilder builder)
Definition: impeller.cc:260
IMPELLER_EXTERN_C void ImpellerFragmentProgramRetain(ImpellerFragmentProgram fragment_program)
Definition: impeller.cc:1597
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:1243
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:1148
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:1064
IMPELLER_EXTERN_C void ImpellerPaintSetStrokeMiter(ImpellerPaint paint, float miter)
Definition: impeller.cc:510
IMPELLER_EXTERN_C ImpellerParagraphStyle ImpellerParagraphStyleNew()
Definition: impeller.cc:1133
IMPELLER_EXTERN_C void ImpellerTextureRetain(ImpellerTexture texture)
Definition: impeller.cc:682
IMPELLER_EXTERN_C ImpellerLineMetrics ImpellerParagraphGetLineMetrics(ImpellerParagraph paragraph)
Definition: impeller.cc:1409
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:1045
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:1315
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:1014
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderRestoreToCount(ImpellerDisplayListBuilder builder, uint32_t count)
Definition: impeller.cc:315
IMPELLER_EXTERN_C float ImpellerParagraphGetLongestLineWidth(ImpellerParagraph paragraph)
Definition: impeller.cc:1335
IMPELLER_EXTERN_C void ImpellerGlyphInfoRetain(ImpellerGlyphInfo glyph_info)
Definition: impeller.cc:1520
IMPELLER_EXTERN_C void ImpellerPaintSetMaskFilter(ImpellerPaint paint, ImpellerMaskFilter mask_filter)
Definition: impeller.cc:1127
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:1360
IMPELLER_EXTERN_C void ImpellerLineMetricsRetain(ImpellerLineMetrics line_metrics)
Definition: impeller.cc:1438
IMPELLER_EXTERN_C ImpellerImageFilter ImpellerImageFilterCreateErodeNew(float x_radius, float y_radius)
Definition: impeller.cc:1070
IMPELLER_EXTERN_C double ImpellerLineMetricsGetHeight(ImpellerLineMetrics metrics, size_t line)
Definition: impeller.cc:1480
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderGetTransform(ImpellerDisplayListBuilder builder, ImpellerMatrix *out_transform)
Definition: impeller.cc:297
IMPELLER_EXTERN_C void ImpellerSurfaceRelease(ImpellerSurface surface)
Definition: impeller.cc:774
constexpr void FromImpellerType(const Matrix &from, ImpellerMatrix &to)
Definition: formats.h:221
static std::string ReadString(const char *string)
Definition: impeller.cc:1171
IMPELLER_EXTERN_C void ImpellerPaintSetColorFilter(ImpellerPaint paint, ImpellerColorFilter color_filter)
Definition: impeller.cc:1109
IMPELLER_EXTERN_C void ImpellerDisplayListBuilderRotate(ImpellerDisplayListBuilder builder, float angle_degrees)
Definition: impeller.cc:272
IMPELLER_EXTERN_C float ImpellerParagraphGetMaxWidth(ImpellerParagraph paragraph)
Definition: impeller.cc:1325
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:1350
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:790
IMPELLER_EXTERN_C void ImpellerPaintSetImageFilter(ImpellerPaint paint, ImpellerImageFilter image_filter)
Definition: impeller.cc:1121
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:710
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:890
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:705
IMPELLER_EXTERN_C void ImpellerParagraphStyleSetBackground(ImpellerParagraphStyle paragraph_style, ImpellerPaint paint)
Definition: impeller.cc:1154
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:1295
IMPELLER_EXTERN_C void ImpellerFragmentProgramRelease(ImpellerFragmentProgram fragment_program)
Definition: impeller.cc:1602
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:959
std::vector< std::shared_ptr< flutter::DlColorSource > > samplers
Definition: impeller.cc:958
const size_t start
const size_t end
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:68
#define VALIDATION_LOG
Definition: validation.h:91