5#include "flutter/lib/ui/dart_ui.h"
10#include "flutter/common/constants.h"
11#include "flutter/common/settings.h"
12#include "flutter/fml/build_config.h"
13#include "flutter/lib/ui/compositing/scene.h"
14#include "flutter/lib/ui/compositing/scene_builder.h"
15#include "flutter/lib/ui/dart_runtime_hooks.h"
16#include "flutter/lib/ui/isolate_name_server/isolate_name_server_natives.h"
17#include "flutter/lib/ui/painting/canvas.h"
18#include "flutter/lib/ui/painting/codec.h"
19#include "flutter/lib/ui/painting/color_filter.h"
20#include "flutter/lib/ui/painting/engine_layer.h"
21#include "flutter/lib/ui/painting/fragment_program.h"
22#include "flutter/lib/ui/painting/fragment_shader.h"
23#include "flutter/lib/ui/painting/gradient.h"
24#include "flutter/lib/ui/painting/image.h"
25#include "flutter/lib/ui/painting/image_descriptor.h"
26#include "flutter/lib/ui/painting/image_filter.h"
27#include "flutter/lib/ui/painting/image_shader.h"
28#include "flutter/lib/ui/painting/immutable_buffer.h"
29#include "flutter/lib/ui/painting/path.h"
30#include "flutter/lib/ui/painting/path_measure.h"
31#include "flutter/lib/ui/painting/picture.h"
32#include "flutter/lib/ui/painting/picture_recorder.h"
33#include "flutter/lib/ui/painting/vertices.h"
34#include "flutter/lib/ui/semantics/semantics_update.h"
35#include "flutter/lib/ui/semantics/semantics_update_builder.h"
36#include "flutter/lib/ui/semantics/string_attribute.h"
37#include "flutter/lib/ui/text/font_collection.h"
38#include "flutter/lib/ui/text/paragraph.h"
39#include "flutter/lib/ui/text/paragraph_builder.h"
40#include "flutter/lib/ui/window/platform_configuration.h"
41#include "flutter/lib/ui/window/platform_isolate.h"
46#ifdef IMPELLER_ENABLE_3D
47#include "flutter/lib/ui/painting/scene/scene_node.h"
48#include "flutter/lib/ui/painting/scene/scene_shader.h"
73#define FFI_FUNCTION_LIST(V) \
76 V(ColorFilter::Create) \
77 V(FragmentProgram::Create) \
78 V(ReusableFragmentShader::Create) \
80 V(ImageFilter::Create) \
81 V(ImageShader::Create) \
82 V(ParagraphBuilder::Create) \
83 V(PathMeasure::Create) \
85 V(PictureRecorder::Create) \
86 V(SceneBuilder::Create) \
87 V(SemanticsUpdateBuilder::Create) \
89 V(FontCollection::LoadFontFromList) \
90 V(ImageDescriptor::initEncoded) \
91 V(ImmutableBuffer::init) \
92 V(ImmutableBuffer::initFromAsset) \
93 V(ImmutableBuffer::initFromFile) \
94 V(ImageDescriptor::initRaw) \
95 V(IsolateNameServerNatives::LookupPortByName) \
96 V(IsolateNameServerNatives::RegisterPortWithName) \
97 V(IsolateNameServerNatives::RemovePortNameMapping) \
98 V(NativeStringAttribute::initLocaleStringAttribute) \
99 V(NativeStringAttribute::initSpellOutStringAttribute) \
100 V(PlatformConfigurationNativeApi::DefaultRouteName) \
101 V(PlatformConfigurationNativeApi::ScheduleFrame) \
102 V(PlatformConfigurationNativeApi::EndWarmUpFrame) \
103 V(PlatformConfigurationNativeApi::Render) \
104 V(PlatformConfigurationNativeApi::UpdateSemantics) \
105 V(PlatformConfigurationNativeApi::SetNeedsReportTimings) \
106 V(PlatformConfigurationNativeApi::SetIsolateDebugName) \
107 V(PlatformConfigurationNativeApi::RequestDartPerformanceMode) \
108 V(PlatformConfigurationNativeApi::GetPersistentIsolateData) \
109 V(PlatformConfigurationNativeApi::ComputePlatformResolvedLocale) \
110 V(PlatformConfigurationNativeApi::SendPlatformMessage) \
111 V(PlatformConfigurationNativeApi::RespondToPlatformMessage) \
112 V(PlatformConfigurationNativeApi::GetRootIsolateToken) \
113 V(PlatformConfigurationNativeApi::RegisterBackgroundIsolate) \
114 V(PlatformConfigurationNativeApi::SendPortPlatformMessage) \
115 V(PlatformConfigurationNativeApi::SendChannelUpdate) \
116 V(PlatformConfigurationNativeApi::GetScaledFontSize) \
117 V(PlatformIsolateNativeApi::IsRunningOnPlatformThread) \
118 V(PlatformIsolateNativeApi::Spawn) \
119 V(DartRuntimeHooks::Logger_PrintDebugString) \
120 V(DartRuntimeHooks::Logger_PrintString) \
121 V(DartRuntimeHooks::ScheduleMicrotask) \
122 V(DartRuntimeHooks::GetCallbackHandle) \
123 V(DartRuntimeHooks::GetCallbackFromHandle) \
124 V(DartPluginRegistrant_EnsureInitialized) \
142#define FFI_METHOD_LIST(V) \
143 V(Canvas, clipPath) \
144 V(Canvas, clipRect) \
145 V(Canvas, clipRRect) \
147 V(Canvas, drawAtlas) \
148 V(Canvas, drawCircle) \
149 V(Canvas, drawColor) \
150 V(Canvas, drawDRRect) \
151 V(Canvas, drawImage) \
152 V(Canvas, drawImageNine) \
153 V(Canvas, drawImageRect) \
154 V(Canvas, drawLine) \
155 V(Canvas, drawOval) \
156 V(Canvas, drawPaint) \
157 V(Canvas, drawPath) \
158 V(Canvas, drawPicture) \
159 V(Canvas, drawPoints) \
160 V(Canvas, drawRRect) \
161 V(Canvas, drawRect) \
162 V(Canvas, drawShadow) \
163 V(Canvas, drawVertices) \
164 V(Canvas, getDestinationClipBounds) \
165 V(Canvas, getLocalClipBounds) \
166 V(Canvas, getSaveCount) \
167 V(Canvas, getTransform) \
169 V(Canvas, restoreToCount) \
172 V(Canvas, saveLayer) \
173 V(Canvas, saveLayerWithoutBounds) \
176 V(Canvas, transform) \
177 V(Canvas, translate) \
179 V(Codec, frameCount) \
180 V(Codec, getNextFrame) \
181 V(Codec, repetitionCount) \
182 V(ColorFilter, initLinearToSrgbGamma) \
183 V(ColorFilter, initMatrix) \
184 V(ColorFilter, initMode) \
185 V(ColorFilter, initSrgbToLinearGamma) \
186 V(EngineLayer, dispose) \
187 V(FragmentProgram, initFromAsset) \
188 V(ReusableFragmentShader, Dispose) \
189 V(ReusableFragmentShader, SetImageSampler) \
190 V(ReusableFragmentShader, ValidateSamplers) \
191 V(Gradient, initLinear) \
192 V(Gradient, initRadial) \
193 V(Gradient, initSweep) \
194 V(Gradient, initTwoPointConical) \
198 V(Image, toByteData) \
199 V(Image, colorSpace) \
200 V(ImageDescriptor, bytesPerPixel) \
201 V(ImageDescriptor, dispose) \
202 V(ImageDescriptor, height) \
203 V(ImageDescriptor, instantiateCodec) \
204 V(ImageDescriptor, width) \
205 V(ImageFilter, initBlur) \
206 V(ImageFilter, initDilate) \
207 V(ImageFilter, initErode) \
208 V(ImageFilter, initColorFilter) \
209 V(ImageFilter, initComposeFilter) \
210 V(ImageFilter, initMatrix) \
211 V(ImageShader, dispose) \
212 V(ImageShader, initWithImage) \
213 V(ImmutableBuffer, dispose) \
214 V(ImmutableBuffer, length) \
215 V(ParagraphBuilder, addPlaceholder) \
216 V(ParagraphBuilder, addText) \
217 V(ParagraphBuilder, build) \
218 V(ParagraphBuilder, pop) \
219 V(ParagraphBuilder, pushStyle) \
220 V(Paragraph, alphabeticBaseline) \
221 V(Paragraph, computeLineMetrics) \
222 V(Paragraph, didExceedMaxLines) \
223 V(Paragraph, dispose) \
224 V(Paragraph, getClosestGlyphInfo) \
225 V(Paragraph, getGlyphInfoAt) \
226 V(Paragraph, getLineBoundary) \
227 V(Paragraph, getLineMetricsAt) \
228 V(Paragraph, getLineNumberAt) \
229 V(Paragraph, getNumberOfLines) \
230 V(Paragraph, getPositionForOffset) \
231 V(Paragraph, getRectsForPlaceholders) \
232 V(Paragraph, getRectsForRange) \
233 V(Paragraph, getWordBoundary) \
234 V(Paragraph, height) \
235 V(Paragraph, ideographicBaseline) \
236 V(Paragraph, layout) \
237 V(Paragraph, longestLine) \
238 V(Paragraph, maxIntrinsicWidth) \
239 V(Paragraph, minIntrinsicWidth) \
240 V(Paragraph, paint) \
241 V(Paragraph, width) \
242 V(PathMeasure, setPath) \
243 V(PathMeasure, getLength) \
244 V(PathMeasure, getPosTan) \
245 V(PathMeasure, getSegment) \
246 V(PathMeasure, isClosed) \
247 V(PathMeasure, nextContour) \
251 V(Path, addPathWithMatrix) \
252 V(Path, addPolygon) \
256 V(Path, arcToPoint) \
262 V(Path, extendWithPath) \
263 V(Path, extendWithPathAndMatrix) \
265 V(Path, getFillType) \
269 V(Path, quadraticBezierTo) \
270 V(Path, relativeArcToPoint) \
271 V(Path, relativeConicTo) \
272 V(Path, relativeCubicTo) \
273 V(Path, relativeLineTo) \
274 V(Path, relativeMoveTo) \
275 V(Path, relativeQuadraticBezierTo) \
277 V(Path, setFillType) \
280 V(PictureRecorder, endRecording) \
281 V(Picture, GetAllocationSize) \
282 V(Picture, dispose) \
283 V(Picture, toImage) \
284 V(Picture, toImageSync) \
285 V(SceneBuilder, addPerformanceOverlay) \
286 V(SceneBuilder, addPicture) \
287 V(SceneBuilder, addPlatformView) \
288 V(SceneBuilder, addRetained) \
289 V(SceneBuilder, addTexture) \
290 V(SceneBuilder, build) \
291 V(SceneBuilder, pop) \
292 V(SceneBuilder, pushBackdropFilter) \
293 V(SceneBuilder, pushClipPath) \
294 V(SceneBuilder, pushClipRRect) \
295 V(SceneBuilder, pushClipRect) \
296 V(SceneBuilder, pushColorFilter) \
297 V(SceneBuilder, pushImageFilter) \
298 V(SceneBuilder, pushOffset) \
299 V(SceneBuilder, pushOpacity) \
300 V(SceneBuilder, pushShaderMask) \
301 V(SceneBuilder, pushTransformHandle) \
304 V(Scene, toImageSync) \
305 V(SemanticsUpdateBuilder, build) \
306 V(SemanticsUpdateBuilder, updateCustomAction) \
307 V(SemanticsUpdateBuilder, updateNode) \
308 V(SemanticsUpdate, dispose) \
311#ifdef IMPELLER_ENABLE_3D
313#define FFI_FUNCTION_LIST_3D(V) \
314 V(SceneNode::Create) \
315 V(SceneShader::Create)
317#define FFI_METHOD_LIST_3D(V) \
318 V(SceneNode, initFromAsset) \
319 V(SceneNode, initFromTransform) \
320 V(SceneNode, AddChild) \
321 V(SceneNode, SetTransform) \
322 V(SceneNode, SetAnimationState) \
323 V(SceneNode, SeekAnimation) \
324 V(SceneShader, SetCameraTransform) \
325 V(SceneShader, Dispose)
329#define FFI_FUNCTION_INSERT(FUNCTION) \
330 g_function_dispatchers.insert(std::make_pair( \
331 std::string_view(#FUNCTION), \
332 reinterpret_cast<void*>( \
333 tonic::FfiDispatcher<void, decltype(&FUNCTION), &FUNCTION>::Call)));
335#define FFI_METHOD_INSERT(CLASS, METHOD) \
336 g_function_dispatchers.insert( \
337 std::make_pair(std::string_view(#CLASS "::" #METHOD), \
338 reinterpret_cast<void*>( \
339 tonic::FfiDispatcher<CLASS, decltype(&CLASS::METHOD), \
340 &CLASS::METHOD>::Call)));
344std::once_flag g_dispatchers_init_flag;
345std::unordered_map<std::string_view, void*> g_function_dispatchers;
347void* ResolveFfiNativeFunction(
const char*
name, uintptr_t
args) {
348 auto it = g_function_dispatchers.find(
name);
349 return (it != g_function_dispatchers.end()) ? it->second :
nullptr;
352void InitDispatcherMap() {
356#ifdef IMPELLER_ENABLE_3D
365 std::call_once(g_dispatchers_init_flag, InitDispatcherMap);
386 if (
settings.enable_platform_isolates) {
static void InitForIsolate(const Settings &settings)
DART_EXPORT Dart_Handle Dart_SetFfiNativeResolver(Dart_Handle library, Dart_FfiNativeResolver resolver)
struct _Dart_Handle * Dart_Handle
DART_EXPORT void Dart_PropagateError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_True(void)
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_SetField(Dart_Handle container, Dart_Handle name, Dart_Handle value)
DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
#define FFI_FUNCTION_LIST(V)
#define FFI_FUNCTION_INSERT(FUNCTION)
#define FFI_METHOD_LIST(V)
#define FFI_METHOD_INSERT(CLASS, METHOD)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
constexpr int64_t kFlutterImplicitViewId
DEF_SWITCHES_START aot vmservice shared library name
CanvasPathMeasure PathMeasure
Dart_Handle ToDart(const T &object)