├── .gitignore ├── CMakeLists.txt ├── README.md └── src ├── common.h ├── flutter └── embedder.h ├── flutter_hadk.cpp ├── flutter_hadk.h ├── hadk ├── binding │ ├── binding.cpp │ └── binding.h ├── hadk.h └── include │ └── hadk │ ├── input.h │ └── native_window.h └── main.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeLists.txt.user 2 | CMakeCache.txt 3 | CMakeFiles 4 | CMakeScripts 5 | Testing 6 | Makefile 7 | cmake_install.cmake 8 | install_manifest.txt 9 | compile_commands.json 10 | CTestTestfile.cmake 11 | _deps 12 | build/* 13 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | cmake_minimum_required(VERSION 3.4.1) 18 | 19 | # build native_app_glue as a static lib 20 | set(${CMAKE_C_FLAGS}, "${CMAKE_C_FLAGS}") 21 | 22 | # now build app's shared lib 23 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DANDROID_STL=c++_static -std=c++14 -Wall -Werror") 24 | 25 | if (NOT CMAKE_BUILD_TYPE) 26 | set (CMAKE_BUILD_TYPE "RelWithDebInfo") 27 | message ( 28 | STATUS "No CMAKE_BUILD_TYPE selected, defaulting to ${CMAKE_BUILD_TYPE}" 29 | ) 30 | endif () 31 | 32 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 33 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) 34 | 35 | add_executable( 36 | flutter-hadk 37 | src/main.cpp 38 | src/flutter_hadk.cpp 39 | src/hadk/binding/binding.cpp 40 | ) 41 | 42 | ########################################################################### 43 | 44 | # add lib dependencies 45 | target_link_libraries(flutter-hadk 46 | android 47 | EGL 48 | GLESv2 49 | log) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flutter-hadk 2 | A light-weight Flutter Engine Embedder based on HADK ,which for Android devices that runs without any java code 3 | 4 | # 1.Build by android-ndk-toolchain 5 | build isuse fixed by: https://www.jianshu.com/p/f84dbf8ec147 6 | ``` 7 | cd build 8 | 9 | cmake .. \ 10 | -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \ 11 | -DANDROID_ABI=arm64-v8a \ 12 | -DANDROID_NATIVE_API_LEVEL=21 13 | 14 | make 15 | ``` -------------------------------------------------------------------------------- /src/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | #ifndef FLUTTER_HADK_H 19 | #define FLUTTER_HADK_H 20 | 21 | #include 22 | #include "flutter/embedder.h" 23 | 24 | #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "[fluttere-hadk]", __VA_ARGS__)) 25 | #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "[fluttere-hadk]", __VA_ARGS__)) 26 | 27 | #define FLWAY_DISALLOW_COPY(TypeName) TypeName(const TypeName&) = delete; 28 | 29 | #define FLWAY_DISALLOW_ASSIGN(TypeName) \ 30 | void operator=(const TypeName&) = delete; 31 | 32 | #define FLWAY_DISALLOW_COPY_AND_ASSIGN(TypeName) \ 33 | FLWAY_DISALLOW_COPY(TypeName) \ 34 | FLWAY_DISALLOW_ASSIGN(TypeName) 35 | 36 | typedef struct { 37 | FlutterEngineResult (*FlutterEngineCreateAOTData)(const FlutterEngineAOTDataSource* source, FlutterEngineAOTData* data_out); 38 | FlutterEngineResult (*FlutterEngineCollectAOTData)(FlutterEngineAOTData data); 39 | FlutterEngineResult (*FlutterEngineRun)(size_t version, const FlutterRendererConfig* config, const FlutterProjectArgs* args, void* user_data, FlutterEngine *engine_out); 40 | FlutterEngineResult (*FlutterEngineShutdown)(FlutterEngine engine); 41 | FlutterEngineResult (*FlutterEngineInitialize)(size_t version, const FlutterRendererConfig* config, const FlutterProjectArgs* args, void* user_data, FlutterEngine *engine_out); 42 | FlutterEngineResult (*FlutterEngineDeinitialize)(FlutterEngine engine); 43 | FlutterEngineResult (*FlutterEngineRunInitialized)(FlutterEngine engine); 44 | FlutterEngineResult (*FlutterEngineSendWindowMetricsEvent)(FlutterEngine engine, const FlutterWindowMetricsEvent* event); 45 | FlutterEngineResult (*FlutterEngineSendPointerEvent)(FlutterEngine engine, const FlutterPointerEvent* events, size_t events_count); 46 | FlutterEngineResult (*FlutterEngineSendPlatformMessage)(FlutterEngine engine, const FlutterPlatformMessage* message); 47 | FlutterEngineResult (*FlutterPlatformMessageCreateResponseHandle)(FlutterEngine engine, FlutterDataCallback data_callback, void* user_data, FlutterPlatformMessageResponseHandle** response_out); 48 | FlutterEngineResult (*FlutterPlatformMessageReleaseResponseHandle)(FlutterEngine engine, FlutterPlatformMessageResponseHandle* response); 49 | FlutterEngineResult (*FlutterEngineSendPlatformMessageResponse)(FlutterEngine engine, const FlutterPlatformMessageResponseHandle* handle, const uint8_t* data, size_t data_length); 50 | FlutterEngineResult (*__FlutterEngineFlushPendingTasksNow)(); 51 | FlutterEngineResult (*FlutterEngineRegisterExternalTexture)(FlutterEngine engine, int64_t texture_identifier); 52 | FlutterEngineResult (*FlutterEngineUnregisterExternalTexture)(FlutterEngine engine, int64_t texture_identifier); 53 | FlutterEngineResult (*FlutterEngineMarkExternalTextureFrameAvailable)(FlutterEngine engine, int64_t texture_identifier); 54 | FlutterEngineResult (*FlutterEngineUpdateSemanticsEnabled)(FlutterEngine engine, bool enabled); 55 | FlutterEngineResult (*FlutterEngineUpdateAccessibilityFeatures)(FlutterEngine engine, FlutterAccessibilityFeature features); 56 | FlutterEngineResult (*FlutterEngineDispatchSemanticsAction)(FlutterEngine engine, uint64_t id, FlutterSemanticsAction action, const uint8_t* data, size_t data_length); 57 | FlutterEngineResult (*FlutterEngineOnVsync)(FlutterEngine engine, intptr_t baton, uint64_t frame_start_time_nanos, uint64_t frame_target_time_nanos); 58 | FlutterEngineResult (*FlutterEngineReloadSystemFonts)(FlutterEngine engine); 59 | void (*FlutterEngineTraceEventDurationBegin)(const char* name); 60 | void (*FlutterEngineTraceEventDurationEnd)(const char* name); 61 | void (*FlutterEngineTraceEventInstant)(const char* name); 62 | FlutterEngineResult (*FlutterEnginePostRenderThreadTask)(FlutterEngine engine, VoidCallback callback, void* callback_data); 63 | uint64_t (*FlutterEngineGetCurrentTime)(); 64 | FlutterEngineResult (*FlutterEngineRunTask)(FlutterEngine engine, const FlutterTask* task); 65 | FlutterEngineResult (*FlutterEngineUpdateLocales)(FlutterEngine engine, const FlutterLocale** locales, size_t locales_count); 66 | bool (*FlutterEngineRunsAOTCompiledDartCode)(void); 67 | FlutterEngineResult (*FlutterEnginePostDartObject)(FlutterEngine engine, FlutterEngineDartPort port, const FlutterEngineDartObject* object); 68 | FlutterEngineResult (*FlutterEngineNotifyLowMemoryWarning)(FlutterEngine engine); 69 | FlutterEngineResult (*FlutterEnginePostCallbackOnAllNativeThreads)(FlutterEngine engine, FlutterNativeThreadCallback callback, void* user_data); 70 | } FlutterEngineLib; 71 | 72 | typedef enum { 73 | kDebug, 74 | kRelease 75 | }FlutterRuntimeMode; 76 | 77 | typedef struct { 78 | char *asset_bundle_path; 79 | char *kernel_blob_path; 80 | char *app_elf_path; 81 | void *app_elf_handle; 82 | char *icu_data_path; 83 | 84 | int engine_argc; 85 | char **engine_argv; 86 | FlutterRuntimeMode runtime_mode; 87 | } FlutterAppArgs; 88 | 89 | typedef struct { 90 | void* window; 91 | int32_t width; 92 | int32_t height; 93 | float scale; 94 | } FlutterHadkDisplay; 95 | 96 | #endif -------------------------------------------------------------------------------- /src/flutter/embedder.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_EMBEDDER_H_ 6 | #define FLUTTER_EMBEDDER_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | // This file defines an Application Binary Interface (ABI), which requires more 13 | // stability than regular code to remain functional for exchanging messages 14 | // between different versions of the embedding and the engine, to allow for both 15 | // forward and backward compatibility. 16 | // 17 | // Specifically, 18 | // - The order, type, and size of the struct members below must remain the same, 19 | // and members should not be removed. 20 | // - New structures that are part of the ABI must be defined with "size_t 21 | // struct_size;" as their first member, which should be initialized using 22 | // "sizeof(Type)". 23 | // - Enum values must not change or be removed. 24 | // - Enum members without explicit values must not be reordered. 25 | // - Function signatures (names, argument counts, argument order, and argument 26 | // type) cannot change. 27 | // - The core behavior of existing functions cannot change. 28 | // 29 | // These changes are allowed: 30 | // - Adding new struct members at the end of a structure. 31 | // - Adding new enum members with a new value. 32 | // - Renaming a struct member as long as its type, size, and intent remain the 33 | // same. 34 | // - Renaming an enum member as long as its value and intent remains the same. 35 | // 36 | // It is expected that struct members and implicitly-valued enums will not 37 | // always be declared in an order that is optimal for the reader, since members 38 | // will be added over time, and they can't be reordered. 39 | // 40 | // Existing functions should continue to appear from the caller's point of view 41 | // to operate as they did when they were first introduced, so introduce a new 42 | // function instead of modifying the core behavior of a function (and continue 43 | // to support the existing function with the previous behavior). 44 | 45 | #if defined(__cplusplus) 46 | extern "C" { 47 | #endif 48 | 49 | #ifndef FLUTTER_EXPORT 50 | #define FLUTTER_EXPORT 51 | #endif // FLUTTER_EXPORT 52 | 53 | #ifdef FLUTTER_API_SYMBOL_PREFIX 54 | #define FLUTTER_EMBEDDING_CONCAT(a, b) a##b 55 | #define FLUTTER_EMBEDDING_ADD_PREFIX(symbol, prefix) \ 56 | FLUTTER_EMBEDDING_CONCAT(prefix, symbol) 57 | #define FLUTTER_API_SYMBOL(symbol) \ 58 | FLUTTER_EMBEDDING_ADD_PREFIX(symbol, FLUTTER_API_SYMBOL_PREFIX) 59 | #else 60 | #define FLUTTER_API_SYMBOL(symbol) symbol 61 | #endif 62 | 63 | #define FLUTTER_ENGINE_VERSION 1 64 | 65 | typedef enum { 66 | kSuccess = 0, 67 | kInvalidLibraryVersion, 68 | kInvalidArguments, 69 | kInternalInconsistency, 70 | } FlutterEngineResult; 71 | 72 | typedef enum { 73 | kOpenGL, 74 | kSoftware, 75 | /// Metal is only supported on Darwin platforms (macOS / iOS). 76 | /// iOS version >= 10.0 (device), 13.0 (simulator) 77 | /// macOS version >= 10.14 78 | kMetal, 79 | } FlutterRendererType; 80 | 81 | /// Additional accessibility features that may be enabled by the platform. 82 | /// Must match the `AccessibilityFeatures` enum in window.dart. 83 | typedef enum { 84 | /// Indicate there is a running accessibility service which is changing the 85 | /// interaction model of the device. 86 | kFlutterAccessibilityFeatureAccessibleNavigation = 1 << 0, 87 | /// Indicate the platform is inverting the colors of the application. 88 | kFlutterAccessibilityFeatureInvertColors = 1 << 1, 89 | /// Request that animations be disabled or simplified. 90 | kFlutterAccessibilityFeatureDisableAnimations = 1 << 2, 91 | /// Request that text be rendered at a bold font weight. 92 | kFlutterAccessibilityFeatureBoldText = 1 << 3, 93 | /// Request that certain animations be simplified and parallax effects 94 | // removed. 95 | kFlutterAccessibilityFeatureReduceMotion = 1 << 4, 96 | } FlutterAccessibilityFeature; 97 | 98 | /// The set of possible actions that can be conveyed to a semantics node. 99 | /// 100 | /// Must match the `SemanticsAction` enum in semantics.dart. 101 | typedef enum { 102 | /// The equivalent of a user briefly tapping the screen with the finger 103 | /// without moving it. 104 | kFlutterSemanticsActionTap = 1 << 0, 105 | /// The equivalent of a user pressing and holding the screen with the finger 106 | /// for a few seconds without moving it. 107 | kFlutterSemanticsActionLongPress = 1 << 1, 108 | /// The equivalent of a user moving their finger across the screen from right 109 | /// to left. 110 | kFlutterSemanticsActionScrollLeft = 1 << 2, 111 | /// The equivalent of a user moving their finger across the screen from left 112 | /// to 113 | /// right. 114 | kFlutterSemanticsActionScrollRight = 1 << 3, 115 | /// The equivalent of a user moving their finger across the screen from bottom 116 | /// to top. 117 | kFlutterSemanticsActionScrollUp = 1 << 4, 118 | /// The equivalent of a user moving their finger across the screen from top to 119 | /// bottom. 120 | kFlutterSemanticsActionScrollDown = 1 << 5, 121 | /// Increase the value represented by the semantics node. 122 | kFlutterSemanticsActionIncrease = 1 << 6, 123 | /// Decrease the value represented by the semantics node. 124 | kFlutterSemanticsActionDecrease = 1 << 7, 125 | /// A request to fully show the semantics node on screen. 126 | kFlutterSemanticsActionShowOnScreen = 1 << 8, 127 | /// Move the cursor forward by one character. 128 | kFlutterSemanticsActionMoveCursorForwardByCharacter = 1 << 9, 129 | /// Move the cursor backward by one character. 130 | kFlutterSemanticsActionMoveCursorBackwardByCharacter = 1 << 10, 131 | /// Set the text selection to the given range. 132 | kFlutterSemanticsActionSetSelection = 1 << 11, 133 | /// Copy the current selection to the clipboard. 134 | kFlutterSemanticsActionCopy = 1 << 12, 135 | /// Cut the current selection and place it in the clipboard. 136 | kFlutterSemanticsActionCut = 1 << 13, 137 | /// Paste the current content of the clipboard. 138 | kFlutterSemanticsActionPaste = 1 << 14, 139 | /// Indicate that the node has gained accessibility focus. 140 | kFlutterSemanticsActionDidGainAccessibilityFocus = 1 << 15, 141 | /// Indicate that the node has lost accessibility focus. 142 | kFlutterSemanticsActionDidLoseAccessibilityFocus = 1 << 16, 143 | /// Indicate that the user has invoked a custom accessibility action. 144 | kFlutterSemanticsActionCustomAction = 1 << 17, 145 | /// A request that the node should be dismissed. 146 | kFlutterSemanticsActionDismiss = 1 << 18, 147 | /// Move the cursor forward by one word. 148 | kFlutterSemanticsActionMoveCursorForwardByWord = 1 << 19, 149 | /// Move the cursor backward by one word. 150 | kFlutterSemanticsActionMoveCursorBackwardByWord = 1 << 20, 151 | } FlutterSemanticsAction; 152 | 153 | /// The set of properties that may be associated with a semantics node. 154 | /// 155 | /// Must match the `SemanticsFlag` enum in semantics.dart. 156 | typedef enum { 157 | /// The semantics node has the quality of either being "checked" or 158 | /// "unchecked". 159 | kFlutterSemanticsFlagHasCheckedState = 1 << 0, 160 | /// Whether a semantics node is checked. 161 | kFlutterSemanticsFlagIsChecked = 1 << 1, 162 | /// Whether a semantics node is selected. 163 | kFlutterSemanticsFlagIsSelected = 1 << 2, 164 | /// Whether the semantic node represents a button. 165 | kFlutterSemanticsFlagIsButton = 1 << 3, 166 | /// Whether the semantic node represents a text field. 167 | kFlutterSemanticsFlagIsTextField = 1 << 4, 168 | /// Whether the semantic node currently holds the user's focus. 169 | kFlutterSemanticsFlagIsFocused = 1 << 5, 170 | /// The semantics node has the quality of either being "enabled" or 171 | /// "disabled". 172 | kFlutterSemanticsFlagHasEnabledState = 1 << 6, 173 | /// Whether a semantic node that hasEnabledState is currently enabled. 174 | kFlutterSemanticsFlagIsEnabled = 1 << 7, 175 | /// Whether a semantic node is in a mutually exclusive group. 176 | kFlutterSemanticsFlagIsInMutuallyExclusiveGroup = 1 << 8, 177 | /// Whether a semantic node is a header that divides content into sections. 178 | kFlutterSemanticsFlagIsHeader = 1 << 9, 179 | /// Whether the value of the semantics node is obscured. 180 | kFlutterSemanticsFlagIsObscured = 1 << 10, 181 | /// Whether the semantics node is the root of a subtree for which a route name 182 | /// should be announced. 183 | kFlutterSemanticsFlagScopesRoute = 1 << 11, 184 | /// Whether the semantics node label is the name of a visually distinct route. 185 | kFlutterSemanticsFlagNamesRoute = 1 << 12, 186 | /// Whether the semantics node is considered hidden. 187 | kFlutterSemanticsFlagIsHidden = 1 << 13, 188 | /// Whether the semantics node represents an image. 189 | kFlutterSemanticsFlagIsImage = 1 << 14, 190 | /// Whether the semantics node is a live region. 191 | kFlutterSemanticsFlagIsLiveRegion = 1 << 15, 192 | /// The semantics node has the quality of either being "on" or "off". 193 | kFlutterSemanticsFlagHasToggledState = 1 << 16, 194 | /// If true, the semantics node is "on". If false, the semantics node is 195 | /// "off". 196 | kFlutterSemanticsFlagIsToggled = 1 << 17, 197 | /// Whether the platform can scroll the semantics node when the user attempts 198 | /// to move the accessibility focus to an offscreen child. 199 | /// 200 | /// For example, a `ListView` widget has implicit scrolling so that users can 201 | /// easily move the accessibility focus to the next set of children. A 202 | /// `PageView` widget does not have implicit scrolling, so that users don't 203 | /// navigate to the next page when reaching the end of the current one. 204 | kFlutterSemanticsFlagHasImplicitScrolling = 1 << 18, 205 | /// Whether the semantic node is read only. 206 | /// 207 | /// Only applicable when kFlutterSemanticsFlagIsTextField flag is on. 208 | kFlutterSemanticsFlagIsReadOnly = 1 << 20, 209 | /// Whether the semantic node can hold the user's focus. 210 | kFlutterSemanticsFlagIsFocusable = 1 << 21, 211 | /// Whether the semantics node represents a link. 212 | kFlutterSemanticsFlagIsLink = 1 << 22, 213 | } FlutterSemanticsFlag; 214 | 215 | typedef enum { 216 | /// Text has unknown text direction. 217 | kFlutterTextDirectionUnknown = 0, 218 | /// Text is read from right to left. 219 | kFlutterTextDirectionRTL = 1, 220 | /// Text is read from left to right. 221 | kFlutterTextDirectionLTR = 2, 222 | } FlutterTextDirection; 223 | 224 | typedef struct _FlutterEngine* FLUTTER_API_SYMBOL(FlutterEngine); 225 | 226 | typedef struct { 227 | /// horizontal scale factor 228 | double scaleX; 229 | /// horizontal skew factor 230 | double skewX; 231 | /// horizontal translation 232 | double transX; 233 | /// vertical skew factor 234 | double skewY; 235 | /// vertical scale factor 236 | double scaleY; 237 | /// vertical translation 238 | double transY; 239 | /// input x-axis perspective factor 240 | double pers0; 241 | /// input y-axis perspective factor 242 | double pers1; 243 | /// perspective scale factor 244 | double pers2; 245 | } FlutterTransformation; 246 | 247 | typedef void (*VoidCallback)(void* /* user data */); 248 | 249 | typedef enum { 250 | /// Specifies an OpenGL texture target type. Textures are specified using 251 | /// the FlutterOpenGLTexture struct. 252 | kFlutterOpenGLTargetTypeTexture, 253 | /// Specifies an OpenGL frame-buffer target type. Framebuffers are specified 254 | /// using the FlutterOpenGLFramebuffer struct. 255 | kFlutterOpenGLTargetTypeFramebuffer, 256 | } FlutterOpenGLTargetType; 257 | 258 | typedef struct { 259 | /// Target texture of the active texture unit (example GL_TEXTURE_2D or 260 | /// GL_TEXTURE_RECTANGLE). 261 | uint32_t target; 262 | /// The name of the texture. 263 | uint32_t name; 264 | /// The texture format (example GL_RGBA8). 265 | uint32_t format; 266 | /// User data to be returned on the invocation of the destruction callback. 267 | void* user_data; 268 | /// Callback invoked (on an engine managed thread) that asks the embedder to 269 | /// collect the texture. 270 | VoidCallback destruction_callback; 271 | /// Optional parameters for texture height/width, default is 0, non-zero means 272 | /// the texture has the specified width/height. Usually, when the texture type 273 | /// is GL_TEXTURE_RECTANGLE, we need to specify the texture width/height to 274 | /// tell the embedder to scale when rendering. 275 | /// Width of the texture. 276 | size_t width; 277 | /// Height of the texture. 278 | size_t height; 279 | } FlutterOpenGLTexture; 280 | 281 | typedef struct { 282 | /// The target of the color attachment of the frame-buffer. For example, 283 | /// GL_TEXTURE_2D or GL_RENDERBUFFER. In case of ambiguity when dealing with 284 | /// Window bound frame-buffers, 0 may be used. 285 | uint32_t target; 286 | 287 | /// The name of the framebuffer. 288 | uint32_t name; 289 | 290 | /// User data to be returned on the invocation of the destruction callback. 291 | void* user_data; 292 | 293 | /// Callback invoked (on an engine managed thread) that asks the embedder to 294 | /// collect the framebuffer. 295 | VoidCallback destruction_callback; 296 | } FlutterOpenGLFramebuffer; 297 | 298 | typedef bool (*BoolCallback)(void* /* user data */); 299 | typedef FlutterTransformation (*TransformationCallback)(void* /* user data */); 300 | typedef uint32_t (*UIntCallback)(void* /* user data */); 301 | typedef bool (*SoftwareSurfacePresentCallback)(void* /* user data */, 302 | const void* /* allocation */, 303 | size_t /* row bytes */, 304 | size_t /* height */); 305 | typedef void* (*ProcResolver)(void* /* user data */, const char* /* name */); 306 | typedef bool (*TextureFrameCallback)(void* /* user data */, 307 | int64_t /* texture identifier */, 308 | size_t /* width */, 309 | size_t /* height */, 310 | FlutterOpenGLTexture* /* texture out */); 311 | typedef void (*VsyncCallback)(void* /* user data */, intptr_t /* baton */); 312 | 313 | /// A structure to represent the width and height. 314 | typedef struct { 315 | double width; 316 | double height; 317 | } FlutterSize; 318 | 319 | /// A structure to represent the width and height. 320 | /// 321 | /// See: \ref FlutterSize when the value are not integers. 322 | typedef struct { 323 | uint32_t width; 324 | uint32_t height; 325 | } FlutterUIntSize; 326 | 327 | /// A structure to represent a rectangle. 328 | typedef struct { 329 | double left; 330 | double top; 331 | double right; 332 | double bottom; 333 | } FlutterRect; 334 | 335 | /// A structure to represent a 2D point. 336 | typedef struct { 337 | double x; 338 | double y; 339 | } FlutterPoint; 340 | 341 | /// A structure to represent a rounded rectangle. 342 | typedef struct { 343 | FlutterRect rect; 344 | FlutterSize upper_left_corner_radius; 345 | FlutterSize upper_right_corner_radius; 346 | FlutterSize lower_right_corner_radius; 347 | FlutterSize lower_left_corner_radius; 348 | } FlutterRoundedRect; 349 | 350 | /// This information is passed to the embedder when requesting a frame buffer 351 | /// object. 352 | /// 353 | /// See: \ref FlutterOpenGLRendererConfig.fbo_with_frame_info_callback. 354 | typedef struct { 355 | /// The size of this struct. Must be sizeof(FlutterFrameInfo). 356 | size_t struct_size; 357 | /// The size of the surface that will be backed by the fbo. 358 | FlutterUIntSize size; 359 | } FlutterFrameInfo; 360 | 361 | /// Callback for when a frame buffer object is requested. 362 | typedef uint32_t (*UIntFrameInfoCallback)( 363 | void* /* user data */, 364 | const FlutterFrameInfo* /* frame info */); 365 | 366 | /// This information is passed to the embedder when a surface is presented. 367 | /// 368 | /// See: \ref FlutterOpenGLRendererConfig.present_with_info. 369 | typedef struct { 370 | /// The size of this struct. Must be sizeof(FlutterFrameInfo). 371 | size_t struct_size; 372 | /// Id of the fbo backing the surface that was presented. 373 | uint32_t fbo_id; 374 | } FlutterPresentInfo; 375 | 376 | /// Callback for when a surface is presented. 377 | typedef bool (*BoolPresentInfoCallback)( 378 | void* /* user data */, 379 | const FlutterPresentInfo* /* present info */); 380 | 381 | typedef struct { 382 | /// The size of this struct. Must be sizeof(FlutterOpenGLRendererConfig). 383 | size_t struct_size; 384 | BoolCallback make_current; 385 | BoolCallback clear_current; 386 | /// Specifying one (and only one) of `present` or `present_with_info` is 387 | /// required. Specifying both is an error and engine initialization will be 388 | /// terminated. The return value indicates success of the present call. 389 | BoolCallback present; 390 | /// Specifying one (and only one) of the `fbo_callback` or 391 | /// `fbo_with_frame_info_callback` is required. Specifying both is an error 392 | /// and engine intialization will be terminated. The return value indicates 393 | /// the id of the frame buffer object that flutter will obtain the gl surface 394 | /// from. 395 | UIntCallback fbo_callback; 396 | /// This is an optional callback. Flutter will ask the emebdder to create a GL 397 | /// context current on a background thread. If the embedder is able to do so, 398 | /// Flutter will assume that this context is in the same sharegroup as the 399 | /// main rendering context and use this context for asynchronous texture 400 | /// uploads. Though optional, it is recommended that all embedders set this 401 | /// callback as it will lead to better performance in texture handling. 402 | BoolCallback make_resource_current; 403 | /// By default, the renderer config assumes that the FBO does not change for 404 | /// the duration of the engine run. If this argument is true, the 405 | /// engine will ask the embedder for an updated FBO target (via an 406 | /// fbo_callback invocation) after a present call. 407 | bool fbo_reset_after_present; 408 | /// The transformation to apply to the render target before any rendering 409 | /// operations. This callback is optional. 410 | /// @attention When using a custom compositor, the layer offset and sizes 411 | /// will be affected by this transformation. It will be 412 | /// embedder responsibility to render contents at the 413 | /// transformed offset and size. This is useful for embedders 414 | /// that want to render transformed contents directly into 415 | /// hardware overlay planes without having to apply extra 416 | /// transformations to layer contents (which may necessitate 417 | /// an expensive off-screen render pass). 418 | TransformationCallback surface_transformation; 419 | ProcResolver gl_proc_resolver; 420 | /// When the embedder specifies that a texture has a frame available, the 421 | /// engine will call this method (on an internal engine managed thread) so 422 | /// that external texture details can be supplied to the engine for subsequent 423 | /// composition. 424 | TextureFrameCallback gl_external_texture_frame_callback; 425 | /// Specifying one (and only one) of the `fbo_callback` or 426 | /// `fbo_with_frame_info_callback` is required. Specifying both is an error 427 | /// and engine intialization will be terminated. The return value indicates 428 | /// the id of the frame buffer object (fbo) that flutter will obtain the gl 429 | /// surface from. When using this variant, the embedder is passed a 430 | /// `FlutterFrameInfo` struct that indicates the properties of the surface 431 | /// that flutter will acquire from the returned fbo. 432 | UIntFrameInfoCallback fbo_with_frame_info_callback; 433 | /// Specifying one (and only one) of `present` or `present_with_info` is 434 | /// required. Specifying both is an error and engine initialization will be 435 | /// terminated. When using this variant, the embedder is passed a 436 | /// `FlutterPresentInfo` struct that the embedder can use to release any 437 | /// resources. The return value indicates success of the present call. 438 | BoolPresentInfoCallback present_with_info; 439 | } FlutterOpenGLRendererConfig; 440 | 441 | /// Alias for id. 442 | typedef const void* FlutterMetalDeviceHandle; 443 | 444 | /// Alias for id. 445 | typedef const void* FlutterMetalCommandQueueHandle; 446 | 447 | /// Alias for id. 448 | typedef const void* FlutterMetalTextureHandle; 449 | 450 | /// Pixel format for the external texture. 451 | typedef enum { 452 | kYUVA, 453 | kRGBA, 454 | } FlutterMetalExternalTexturePixelFormat; 455 | 456 | typedef struct { 457 | /// The size of this struct. Must be sizeof(FlutterMetalExternalTexture). 458 | size_t struct_size; 459 | /// Height of the texture. 460 | size_t width; 461 | /// Height of the texture. 462 | size_t height; 463 | /// The pixel format type of the external. 464 | FlutterMetalExternalTexturePixelFormat pixel_format; 465 | /// Represents the size of the `textures` array. 466 | size_t num_textures; 467 | /// Supported textures are YUVA and RGBA, in case of YUVA we expect 2 texture 468 | /// handles to be provided by the embedder, Y first and UV next. In case of 469 | /// RGBA only one should be passed. 470 | /// These are individually aliases for id. These textures are 471 | /// retained by the engine for the period of the composition. Once these 472 | /// textures have been unregistered via the 473 | /// `FlutterEngineUnregisterExternalTexture`, the embedder has to release 474 | /// these textures. 475 | FlutterMetalTextureHandle* textures; 476 | } FlutterMetalExternalTexture; 477 | 478 | /// Callback to provide an external texture for a given texture_id. 479 | /// See: external_texture_frame_callback. 480 | typedef bool (*FlutterMetalTextureFrameCallback)( 481 | void* /* user data */, 482 | int64_t /* texture identifier */, 483 | size_t /* width */, 484 | size_t /* height */, 485 | FlutterMetalExternalTexture* /* texture out */); 486 | 487 | typedef struct { 488 | /// The size of this struct. Must be sizeof(FlutterMetalTexture). 489 | size_t struct_size; 490 | /// Embedder provided unique identifier to the texture buffer. Given that the 491 | /// `texture` handle is passed to the engine to render to, the texture buffer 492 | /// is itseld owned by the embedder. This `texture_id` is then also given to 493 | /// the embedder in the present callback. 494 | int64_t texture_id; 495 | /// Handle to the MTLTexture that is owned by the embedder. Engine will render 496 | /// the frame into this texture. 497 | FlutterMetalTextureHandle texture; 498 | } FlutterMetalTexture; 499 | 500 | /// Callback for when a metal texture is requested. 501 | typedef FlutterMetalTexture (*FlutterMetalTextureCallback)( 502 | void* /* user data */, 503 | const FlutterFrameInfo* /* frame info */); 504 | 505 | /// Callback for when a metal texture is presented. The texture_id here 506 | /// corresponds to the texture_id provided by the embedder in the 507 | /// `FlutterMetalTextureCallback` callback. 508 | typedef bool (*FlutterMetalPresentCallback)( 509 | void* /* user data */, 510 | const FlutterMetalTexture* /* texture */); 511 | 512 | typedef struct { 513 | /// The size of this struct. Must be sizeof(FlutterMetalRendererConfig). 514 | size_t struct_size; 515 | /// Alias for id. 516 | FlutterMetalDeviceHandle device; 517 | /// Alias for id. 518 | FlutterMetalCommandQueueHandle present_command_queue; 519 | /// The callback that gets invoked when the engine requests the embedder for a 520 | /// texture to render to. 521 | FlutterMetalTextureCallback get_next_drawable_callback; 522 | /// The callback presented to the embedder to present a fully populated metal 523 | /// texture to the user. 524 | FlutterMetalPresentCallback present_drawable_callback; 525 | /// When the embedder specifies that a texture has a frame available, the 526 | /// engine will call this method (on an internal engine managed thread) so 527 | /// that external texture details can be supplied to the engine for subsequent 528 | /// composition. 529 | FlutterMetalTextureFrameCallback external_texture_frame_callback; 530 | } FlutterMetalRendererConfig; 531 | 532 | typedef struct { 533 | /// The size of this struct. Must be sizeof(FlutterSoftwareRendererConfig). 534 | size_t struct_size; 535 | /// The callback presented to the embedder to present a fully populated buffer 536 | /// to the user. The pixel format of the buffer is the native 32-bit RGBA 537 | /// format. The buffer is owned by the Flutter engine and must be copied in 538 | /// this callback if needed. 539 | SoftwareSurfacePresentCallback surface_present_callback; 540 | } FlutterSoftwareRendererConfig; 541 | 542 | typedef struct { 543 | FlutterRendererType type; 544 | union { 545 | FlutterOpenGLRendererConfig open_gl; 546 | FlutterSoftwareRendererConfig software; 547 | FlutterMetalRendererConfig metal; 548 | }; 549 | } FlutterRendererConfig; 550 | 551 | typedef struct { 552 | /// The size of this struct. Must be sizeof(FlutterWindowMetricsEvent). 553 | size_t struct_size; 554 | /// Physical width of the window. 555 | size_t width; 556 | /// Physical height of the window. 557 | size_t height; 558 | /// Scale factor for the physical screen. 559 | double pixel_ratio; 560 | /// Horizontal physical location of the left side of the window on the screen. 561 | size_t left; 562 | /// Vertical physical location of the top of the window on the screen. 563 | size_t top; 564 | } FlutterWindowMetricsEvent; 565 | 566 | /// The phase of the pointer event. 567 | typedef enum { 568 | kCancel, 569 | /// The pointer, which must have been down (see kDown), is now up. 570 | /// 571 | /// For touch, this means that the pointer is no longer in contact with the 572 | /// screen. For a mouse, it means the last button was released. Note that if 573 | /// any other buttons are still pressed when one button is released, that 574 | /// should be sent as a kMove rather than a kUp. 575 | kUp, 576 | /// The pointer, which must have been been up, is now down. 577 | /// 578 | /// For touch, this means that the pointer has come into contact with the 579 | /// screen. For a mouse, it means a button is now pressed. Note that if any 580 | /// other buttons are already pressed when a new button is pressed, that 581 | /// should be sent as a kMove rather than a kDown. 582 | kDown, 583 | /// The pointer moved while down. 584 | /// 585 | /// This is also used for changes in button state that don't cause a kDown or 586 | /// kUp, such as releasing one of two pressed buttons. 587 | kMove, 588 | /// The pointer is now sending input to Flutter. For instance, a mouse has 589 | /// entered the area where the Flutter content is displayed. 590 | /// 591 | /// A pointer should always be added before sending any other events. 592 | kAdd, 593 | /// The pointer is no longer sending input to Flutter. For instance, a mouse 594 | /// has left the area where the Flutter content is displayed. 595 | /// 596 | /// A removed pointer should no longer send events until sending a new kAdd. 597 | kRemove, 598 | /// The pointer moved while up. 599 | kHover, 600 | } FlutterPointerPhase; 601 | 602 | /// The device type that created a pointer event. 603 | typedef enum { 604 | kFlutterPointerDeviceKindMouse = 1, 605 | kFlutterPointerDeviceKindTouch, 606 | } FlutterPointerDeviceKind; 607 | 608 | /// Flags for the `buttons` field of `FlutterPointerEvent` when `device_kind` 609 | /// is `kFlutterPointerDeviceKindMouse`. 610 | typedef enum { 611 | kFlutterPointerButtonMousePrimary = 1 << 0, 612 | kFlutterPointerButtonMouseSecondary = 1 << 1, 613 | kFlutterPointerButtonMouseMiddle = 1 << 2, 614 | kFlutterPointerButtonMouseBack = 1 << 3, 615 | kFlutterPointerButtonMouseForward = 1 << 4, 616 | /// If a mouse has more than five buttons, send higher bit shifted values 617 | /// corresponding to the button number: 1 << 5 for the 6th, etc. 618 | } FlutterPointerMouseButtons; 619 | 620 | /// The type of a pointer signal. 621 | typedef enum { 622 | kFlutterPointerSignalKindNone, 623 | kFlutterPointerSignalKindScroll, 624 | } FlutterPointerSignalKind; 625 | 626 | typedef struct { 627 | /// The size of this struct. Must be sizeof(FlutterPointerEvent). 628 | size_t struct_size; 629 | FlutterPointerPhase phase; 630 | /// The timestamp at which the pointer event was generated. The timestamp 631 | /// should be specified in microseconds and the clock should be the same as 632 | /// that used by `FlutterEngineGetCurrentTime`. 633 | size_t timestamp; 634 | /// The x coordinate of the pointer event in physical pixels. 635 | double x; 636 | /// The y coordinate of the pointer event in physical pixels. 637 | double y; 638 | /// An optional device identifier. If this is not specified, it is assumed 639 | /// that the embedder has no multi-touch capability. 640 | int32_t device; 641 | FlutterPointerSignalKind signal_kind; 642 | /// The x offset of the scroll in physical pixels. 643 | double scroll_delta_x; 644 | /// The y offset of the scroll in physical pixels. 645 | double scroll_delta_y; 646 | /// The type of the device generating this event. 647 | /// Backwards compatibility note: If this is not set, the device will be 648 | /// treated as a mouse, with the primary button set for `kDown` and `kMove`. 649 | /// If set explicitly to `kFlutterPointerDeviceKindMouse`, you must set the 650 | /// correct buttons. 651 | FlutterPointerDeviceKind device_kind; 652 | /// The buttons currently pressed, if any. 653 | int64_t buttons; 654 | } FlutterPointerEvent; 655 | 656 | typedef enum { 657 | kFlutterKeyEventTypeUp = 1, 658 | kFlutterKeyEventTypeDown, 659 | kFlutterKeyEventTypeRepeat, 660 | } FlutterKeyEventType; 661 | 662 | /// A structure to represent a key event. 663 | /// 664 | /// Sending `FlutterKeyEvent` via `FlutterEngineSendKeyEvent` results in a 665 | /// corresponding `FlutterKeyEvent` to be dispatched in the framework. It is 666 | /// embedder's responsibility to ensure the regularity of sent events, since the 667 | /// framework only performs simple one-to-one mapping. The events must conform 668 | /// the following rules: 669 | /// 670 | /// * Each key press sequence shall consist of one key down event (`kind` being 671 | /// `kFlutterKeyEventTypeDown`), zero or more repeat events, and one key up 672 | /// event, representing a physical key button being pressed, held, and 673 | /// released. 674 | /// * All events throughout a key press sequence shall have the same `physical` 675 | /// and `logical`. Having different `character`s is allowed. 676 | typedef struct { 677 | /// The size of this struct. Must be sizeof(FlutterKeyEvent). 678 | size_t struct_size; 679 | /// The timestamp at which the key event was generated. The timestamp should 680 | /// be specified in microseconds and the clock should be the same as that used 681 | /// by `FlutterEngineGetCurrentTime`. 682 | double timestamp; 683 | /// The event kind. 684 | FlutterKeyEventType type; 685 | /// The USB HID code for the physical key of the event. 686 | /// 687 | /// For the full definition and list of pre-defined physical keys, see 688 | /// `PhysicalKeyboardKey` from the framework. 689 | uint64_t physical; 690 | /// The key ID for the logical key of this event. 691 | /// 692 | /// For the full definition and a list of pre-defined logical keys, see 693 | /// `LogicalKeyboardKey` from the framework. 694 | uint64_t logical; 695 | /// Null-terminated character input from the event. Can be null. Ignored for 696 | /// up events. 697 | const char* character; 698 | /// True if this event does not correspond to a native event. 699 | /// 700 | /// The embedder is likely to skip events and/or construct new events that do 701 | /// not correspond to any native events in order to conform the regularity 702 | /// of events (as documented in `FlutterKeyEvent`). An example is when a key 703 | /// up is missed due to loss of window focus, on a platform that provides 704 | /// query to key pressing status, the embedder might realize that the key has 705 | /// been released at the next key event, and should construct a synthesized up 706 | /// event immediately before the actual event. 707 | /// 708 | /// An event being synthesized means that the `timestamp` might greatly 709 | /// deviate from the actual time when the event occurs physically. 710 | bool synthesized; 711 | } FlutterKeyEvent; 712 | 713 | typedef void (*FlutterKeyEventCallback)(bool /* handled */, 714 | void* /* user_data */); 715 | 716 | struct _FlutterPlatformMessageResponseHandle; 717 | typedef struct _FlutterPlatformMessageResponseHandle 718 | FlutterPlatformMessageResponseHandle; 719 | 720 | typedef struct { 721 | /// The size of this struct. Must be sizeof(FlutterPlatformMessage). 722 | size_t struct_size; 723 | const char* channel; 724 | const uint8_t* message; 725 | size_t message_size; 726 | /// The response handle on which to invoke 727 | /// `FlutterEngineSendPlatformMessageResponse` when the response is ready. 728 | /// `FlutterEngineSendPlatformMessageResponse` must be called for all messages 729 | /// received by the embedder. Failure to call 730 | /// `FlutterEngineSendPlatformMessageResponse` will cause a memory leak. It is 731 | /// not safe to send multiple responses on a single response object. 732 | const FlutterPlatformMessageResponseHandle* response_handle; 733 | } FlutterPlatformMessage; 734 | 735 | typedef void (*FlutterPlatformMessageCallback)( 736 | const FlutterPlatformMessage* /* message*/, 737 | void* /* user data */); 738 | 739 | typedef void (*FlutterDataCallback)(const uint8_t* /* data */, 740 | size_t /* size */, 741 | void* /* user data */); 742 | 743 | /// The identifier of the platform view. This identifier is specified by the 744 | /// application when a platform view is added to the scene via the 745 | /// `SceneBuilder.addPlatformView` call. 746 | typedef int64_t FlutterPlatformViewIdentifier; 747 | 748 | /// `FlutterSemanticsNode` ID used as a sentinel to signal the end of a batch of 749 | /// semantics node updates. 750 | FLUTTER_EXPORT 751 | extern const int32_t kFlutterSemanticsNodeIdBatchEnd; 752 | 753 | /// A node that represents some semantic data. 754 | /// 755 | /// The semantics tree is maintained during the semantics phase of the pipeline 756 | /// (i.e., during PipelineOwner.flushSemantics), which happens after 757 | /// compositing. Updates are then pushed to embedders via the registered 758 | /// `FlutterUpdateSemanticsNodeCallback`. 759 | typedef struct { 760 | /// The size of this struct. Must be sizeof(FlutterSemanticsNode). 761 | size_t struct_size; 762 | /// The unique identifier for this node. 763 | int32_t id; 764 | /// The set of semantics flags associated with this node. 765 | FlutterSemanticsFlag flags; 766 | /// The set of semantics actions applicable to this node. 767 | FlutterSemanticsAction actions; 768 | /// The position at which the text selection originates. 769 | int32_t text_selection_base; 770 | /// The position at which the text selection terminates. 771 | int32_t text_selection_extent; 772 | /// The total number of scrollable children that contribute to semantics. 773 | int32_t scroll_child_count; 774 | /// The index of the first visible semantic child of a scroll node. 775 | int32_t scroll_index; 776 | /// The current scrolling position in logical pixels if the node is 777 | /// scrollable. 778 | double scroll_position; 779 | /// The maximum in-range value for `scrollPosition` if the node is scrollable. 780 | double scroll_extent_max; 781 | /// The minimum in-range value for `scrollPosition` if the node is scrollable. 782 | double scroll_extent_min; 783 | /// The elevation along the z-axis at which the rect of this semantics node is 784 | /// located above its parent. 785 | double elevation; 786 | /// Describes how much space the semantics node takes up along the z-axis. 787 | double thickness; 788 | /// A textual description of the node. 789 | const char* label; 790 | /// A brief description of the result of performing an action on the node. 791 | const char* hint; 792 | /// A textual description of the current value of the node. 793 | const char* value; 794 | /// A value that `value` will have after a kFlutterSemanticsActionIncrease` 795 | /// action has been performed. 796 | const char* increased_value; 797 | /// A value that `value` will have after a kFlutterSemanticsActionDecrease` 798 | /// action has been performed. 799 | const char* decreased_value; 800 | /// The reading direction for `label`, `value`, `hint`, `increasedValue`, and 801 | /// `decreasedValue`. 802 | FlutterTextDirection text_direction; 803 | /// The bounding box for this node in its coordinate system. 804 | FlutterRect rect; 805 | /// The transform from this node's coordinate system to its parent's 806 | /// coordinate system. 807 | FlutterTransformation transform; 808 | /// The number of children this node has. 809 | size_t child_count; 810 | /// Array of child node IDs in traversal order. Has length `child_count`. 811 | const int32_t* children_in_traversal_order; 812 | /// Array of child node IDs in hit test order. Has length `child_count`. 813 | const int32_t* children_in_hit_test_order; 814 | /// The number of custom accessibility action associated with this node. 815 | size_t custom_accessibility_actions_count; 816 | /// Array of `FlutterSemanticsCustomAction` IDs associated with this node. 817 | /// Has length `custom_accessibility_actions_count`. 818 | const int32_t* custom_accessibility_actions; 819 | /// Identifier of the platform view associated with this semantics node, or 820 | /// -1 if none. 821 | FlutterPlatformViewIdentifier platform_view_id; 822 | } FlutterSemanticsNode; 823 | 824 | /// `FlutterSemanticsCustomAction` ID used as a sentinel to signal the end of a 825 | /// batch of semantics custom action updates. 826 | FLUTTER_EXPORT 827 | extern const int32_t kFlutterSemanticsCustomActionIdBatchEnd; 828 | 829 | /// A custom semantics action, or action override. 830 | /// 831 | /// Custom actions can be registered by applications in order to provide 832 | /// semantic actions other than the standard actions available through the 833 | /// `FlutterSemanticsAction` enum. 834 | /// 835 | /// Action overrides are custom actions that the application developer requests 836 | /// to be used in place of the standard actions in the `FlutterSemanticsAction` 837 | /// enum. 838 | typedef struct { 839 | /// The size of the struct. Must be sizeof(FlutterSemanticsCustomAction). 840 | size_t struct_size; 841 | /// The unique custom action or action override ID. 842 | int32_t id; 843 | /// For overridden standard actions, corresponds to the 844 | /// `FlutterSemanticsAction` to override. 845 | FlutterSemanticsAction override_action; 846 | /// The user-readable name of this custom semantics action. 847 | const char* label; 848 | /// The hint description of this custom semantics action. 849 | const char* hint; 850 | } FlutterSemanticsCustomAction; 851 | 852 | typedef void (*FlutterUpdateSemanticsNodeCallback)( 853 | const FlutterSemanticsNode* /* semantics node */, 854 | void* /* user data */); 855 | 856 | typedef void (*FlutterUpdateSemanticsCustomActionCallback)( 857 | const FlutterSemanticsCustomAction* /* semantics custom action */, 858 | void* /* user data */); 859 | 860 | typedef struct _FlutterTaskRunner* FlutterTaskRunner; 861 | 862 | typedef struct { 863 | FlutterTaskRunner runner; 864 | uint64_t task; 865 | } FlutterTask; 866 | 867 | typedef void (*FlutterTaskRunnerPostTaskCallback)( 868 | FlutterTask /* task */, 869 | uint64_t /* target time nanos */, 870 | void* /* user data */); 871 | 872 | /// An interface used by the Flutter engine to execute tasks at the target time 873 | /// on a specified thread. There should be a 1-1 relationship between a thread 874 | /// and a task runner. It is undefined behavior to run a task on a thread that 875 | /// is not associated with its task runner. 876 | typedef struct { 877 | /// The size of this struct. Must be sizeof(FlutterTaskRunnerDescription). 878 | size_t struct_size; 879 | void* user_data; 880 | /// May be called from any thread. Should return true if tasks posted on the 881 | /// calling thread will be run on that same thread. 882 | /// 883 | /// @attention This field is required. 884 | BoolCallback runs_task_on_current_thread_callback; 885 | /// May be called from any thread. The given task should be executed by the 886 | /// embedder on the thread associated with that task runner by calling 887 | /// `FlutterEngineRunTask` at the given target time. The system monotonic 888 | /// clock should be used for the target time. The target time is the absolute 889 | /// time from epoch (NOT a delta) at which the task must be returned back to 890 | /// the engine on the correct thread. If the embedder needs to calculate a 891 | /// delta, `FlutterEngineGetCurrentTime` may be called and the difference used 892 | /// as the delta. 893 | /// 894 | /// @attention This field is required. 895 | FlutterTaskRunnerPostTaskCallback post_task_callback; 896 | /// A unique identifier for the task runner. If multiple task runners service 897 | /// tasks on the same thread, their identifiers must match. 898 | size_t identifier; 899 | } FlutterTaskRunnerDescription; 900 | 901 | typedef struct { 902 | /// The size of this struct. Must be sizeof(FlutterCustomTaskRunners). 903 | size_t struct_size; 904 | /// Specify the task runner for the thread on which the `FlutterEngineRun` 905 | /// call is made. The same task runner description can be specified for both 906 | /// the render and platform task runners. This makes the Flutter engine use 907 | /// the same thread for both task runners. 908 | const FlutterTaskRunnerDescription* platform_task_runner; 909 | /// Specify the task runner for the thread on which the render tasks will be 910 | /// run. The same task runner description can be specified for both the render 911 | /// and platform task runners. This makes the Flutter engine use the same 912 | /// thread for both task runners. 913 | const FlutterTaskRunnerDescription* render_task_runner; 914 | } FlutterCustomTaskRunners; 915 | 916 | typedef struct { 917 | /// The type of the OpenGL backing store. Currently, it can either be a 918 | /// texture or a framebuffer. 919 | FlutterOpenGLTargetType type; 920 | union { 921 | /// A texture for Flutter to render into. 922 | FlutterOpenGLTexture texture; 923 | /// A framebuffer for Flutter to render into. The embedder must ensure that 924 | /// the framebuffer is complete. 925 | FlutterOpenGLFramebuffer framebuffer; 926 | }; 927 | } FlutterOpenGLBackingStore; 928 | 929 | typedef struct { 930 | /// A pointer to the raw bytes of the allocation described by this software 931 | /// backing store. 932 | const void* allocation; 933 | /// The number of bytes in a single row of the allocation. 934 | size_t row_bytes; 935 | /// The number of rows in the allocation. 936 | size_t height; 937 | /// A baton that is not interpreted by the engine in any way. It will be given 938 | /// back to the embedder in the destruction callback below. Embedder resources 939 | /// may be associated with this baton. 940 | void* user_data; 941 | /// The callback invoked by the engine when it no longer needs this backing 942 | /// store. 943 | VoidCallback destruction_callback; 944 | } FlutterSoftwareBackingStore; 945 | 946 | typedef enum { 947 | /// Indicates that the Flutter application requested that an opacity be 948 | /// applied to the platform view. 949 | kFlutterPlatformViewMutationTypeOpacity, 950 | /// Indicates that the Flutter application requested that the platform view be 951 | /// clipped using a rectangle. 952 | kFlutterPlatformViewMutationTypeClipRect, 953 | /// Indicates that the Flutter application requested that the platform view be 954 | /// clipped using a rounded rectangle. 955 | kFlutterPlatformViewMutationTypeClipRoundedRect, 956 | /// Indicates that the Flutter application requested that the platform view be 957 | /// transformed before composition. 958 | kFlutterPlatformViewMutationTypeTransformation, 959 | } FlutterPlatformViewMutationType; 960 | 961 | typedef struct { 962 | /// The type of the mutation described by the subsequent union. 963 | FlutterPlatformViewMutationType type; 964 | union { 965 | double opacity; 966 | FlutterRect clip_rect; 967 | FlutterRoundedRect clip_rounded_rect; 968 | FlutterTransformation transformation; 969 | }; 970 | } FlutterPlatformViewMutation; 971 | 972 | typedef struct { 973 | /// The size of this struct. Must be sizeof(FlutterPlatformView). 974 | size_t struct_size; 975 | /// The identifier of this platform view. This identifier is specified by the 976 | /// application when a platform view is added to the scene via the 977 | /// `SceneBuilder.addPlatformView` call. 978 | FlutterPlatformViewIdentifier identifier; 979 | /// The number of mutations to be applied to the platform view by the embedder 980 | /// before on-screen composition. 981 | size_t mutations_count; 982 | /// The mutations to be applied by this platform view before it is composited 983 | /// on-screen. The Flutter application may transform the platform view but 984 | /// these transformations cannot be affected by the Flutter compositor because 985 | /// it does not render platform views. Since the embedder is responsible for 986 | /// composition of these views, it is also the embedder's responsibility to 987 | /// affect the appropriate transformation. 988 | /// 989 | /// The mutations must be applied in order. The mutations done in the 990 | /// collection don't take into account the device pixel ratio or the root 991 | /// surface transformation. If these exist, the first mutation in the list 992 | /// will be a transformation mutation to make sure subsequent mutations are in 993 | /// the correct coordinate space. 994 | const FlutterPlatformViewMutation** mutations; 995 | } FlutterPlatformView; 996 | 997 | typedef enum { 998 | /// Specifies an OpenGL backing store. Can either be an OpenGL texture or 999 | /// framebuffer. 1000 | kFlutterBackingStoreTypeOpenGL, 1001 | /// Specified an software allocation for Flutter to render into using the CPU. 1002 | kFlutterBackingStoreTypeSoftware, 1003 | } FlutterBackingStoreType; 1004 | 1005 | typedef struct { 1006 | /// The size of this struct. Must be sizeof(FlutterBackingStore). 1007 | size_t struct_size; 1008 | /// A baton that is not interpreted by the engine in any way. The embedder may 1009 | /// use this to associate resources that are tied to the lifecycle of the 1010 | /// `FlutterBackingStore`. 1011 | void* user_data; 1012 | /// Specifies the type of backing store. 1013 | FlutterBackingStoreType type; 1014 | /// Indicates if this backing store was updated since the last time it was 1015 | /// associated with a presented layer. 1016 | bool did_update; 1017 | union { 1018 | /// The description of the OpenGL backing store. 1019 | FlutterOpenGLBackingStore open_gl; 1020 | /// The description of the software backing store. 1021 | FlutterSoftwareBackingStore software; 1022 | }; 1023 | } FlutterBackingStore; 1024 | 1025 | typedef struct { 1026 | /// The size of this struct. Must be sizeof(FlutterBackingStoreConfig). 1027 | size_t struct_size; 1028 | /// The size of the render target the engine expects to render into. 1029 | FlutterSize size; 1030 | } FlutterBackingStoreConfig; 1031 | 1032 | typedef enum { 1033 | /// Indicates that the contents of this layer are rendered by Flutter into a 1034 | /// backing store. 1035 | kFlutterLayerContentTypeBackingStore, 1036 | /// Indicates that the contents of this layer are determined by the embedder. 1037 | kFlutterLayerContentTypePlatformView, 1038 | } FlutterLayerContentType; 1039 | 1040 | typedef struct { 1041 | /// This size of this struct. Must be sizeof(FlutterLayer). 1042 | size_t struct_size; 1043 | /// Each layer displays contents in one way or another. The type indicates 1044 | /// whether those contents are specified by Flutter or the embedder. 1045 | FlutterLayerContentType type; 1046 | union { 1047 | /// Indicates that the contents of this layer are rendered by Flutter into a 1048 | /// backing store. 1049 | const FlutterBackingStore* backing_store; 1050 | /// Indicates that the contents of this layer are determined by the 1051 | /// embedder. 1052 | const FlutterPlatformView* platform_view; 1053 | }; 1054 | /// The offset of this layer (in physical pixels) relative to the top left of 1055 | /// the root surface used by the engine. 1056 | FlutterPoint offset; 1057 | /// The size of the layer (in physical pixels). 1058 | FlutterSize size; 1059 | } FlutterLayer; 1060 | 1061 | typedef bool (*FlutterBackingStoreCreateCallback)( 1062 | const FlutterBackingStoreConfig* config, 1063 | FlutterBackingStore* backing_store_out, 1064 | void* user_data); 1065 | 1066 | typedef bool (*FlutterBackingStoreCollectCallback)( 1067 | const FlutterBackingStore* renderer, 1068 | void* user_data); 1069 | 1070 | typedef bool (*FlutterLayersPresentCallback)(const FlutterLayer** layers, 1071 | size_t layers_count, 1072 | void* user_data); 1073 | 1074 | typedef struct { 1075 | /// This size of this struct. Must be sizeof(FlutterCompositor). 1076 | size_t struct_size; 1077 | /// A baton that in not interpreted by the engine in any way. If it passed 1078 | /// back to the embedder in `FlutterCompositor.create_backing_store_callback`, 1079 | /// `FlutterCompositor.collect_backing_store_callback` and 1080 | /// `FlutterCompositor.present_layers_callback` 1081 | void* user_data; 1082 | /// A callback invoked by the engine to obtain a backing store for a specific 1083 | /// `FlutterLayer`. 1084 | /// 1085 | /// On ABI stability: Callers must take care to restrict access within 1086 | /// `FlutterBackingStore::struct_size` when specifying a new backing store to 1087 | /// the engine. This only matters if the embedder expects to be used with 1088 | /// engines older than the version whose headers it used during compilation. 1089 | FlutterBackingStoreCreateCallback create_backing_store_callback; 1090 | /// A callback invoked by the engine to release the backing store. The 1091 | /// embedder may collect any resources associated with the backing store. 1092 | FlutterBackingStoreCollectCallback collect_backing_store_callback; 1093 | /// Callback invoked by the engine to composite the contents of each layer 1094 | /// onto the screen. 1095 | FlutterLayersPresentCallback present_layers_callback; 1096 | /// Avoid caching backing stores provided by this compositor. 1097 | bool avoid_backing_store_cache; 1098 | } FlutterCompositor; 1099 | 1100 | typedef struct { 1101 | /// This size of this struct. Must be sizeof(FlutterLocale). 1102 | size_t struct_size; 1103 | /// The language code of the locale. For example, "en". This is a required 1104 | /// field. The string must be null terminated. It may be collected after the 1105 | /// call to `FlutterEngineUpdateLocales`. 1106 | const char* language_code; 1107 | /// The country code of the locale. For example, "US". This is a an optional 1108 | /// field. The string must be null terminated if present. It may be collected 1109 | /// after the call to `FlutterEngineUpdateLocales`. If not present, a 1110 | /// `nullptr` may be specified. 1111 | const char* country_code; 1112 | /// The script code of the locale. This is a an optional field. The string 1113 | /// must be null terminated if present. It may be collected after the call to 1114 | /// `FlutterEngineUpdateLocales`. If not present, a `nullptr` may be 1115 | /// specified. 1116 | const char* script_code; 1117 | /// The variant code of the locale. This is a an optional field. The string 1118 | /// must be null terminated if present. It may be collected after the call to 1119 | /// `FlutterEngineUpdateLocales`. If not present, a `nullptr` may be 1120 | /// specified. 1121 | const char* variant_code; 1122 | } FlutterLocale; 1123 | 1124 | /// Callback that returns the system locale. 1125 | /// 1126 | /// Embedders that implement this callback should return the `FlutterLocale` 1127 | /// from the `supported_locales` list that most closely matches the 1128 | /// user/device's preferred locale. 1129 | /// 1130 | /// This callback does not currently provide the user_data baton. 1131 | /// https://github.com/flutter/flutter/issues/79826 1132 | typedef const FlutterLocale* (*FlutterComputePlatformResolvedLocaleCallback)( 1133 | const FlutterLocale** /* supported_locales*/, 1134 | size_t /* Number of locales*/); 1135 | 1136 | /// Display refers to a graphics hardware system consisting of a framebuffer, 1137 | /// typically a monitor or a screen. This ID is unique per display and is 1138 | /// stable until the Flutter application restarts. 1139 | typedef uint64_t FlutterEngineDisplayId; 1140 | 1141 | typedef struct { 1142 | /// This size of this struct. Must be sizeof(FlutterDisplay). 1143 | size_t struct_size; 1144 | 1145 | FlutterEngineDisplayId display_id; 1146 | 1147 | /// This is set to true if the embedder only has one display. In cases where 1148 | /// this is set to true, the value of display_id is ignored. In cases where 1149 | /// this is not set to true, it is expected that a valid display_id be 1150 | /// provided. 1151 | bool single_display; 1152 | 1153 | /// This represents the refresh period in frames per second. This value may be 1154 | /// zero if the device is not running or unavailable or unknown. 1155 | double refresh_rate; 1156 | } FlutterEngineDisplay; 1157 | 1158 | /// The update type parameter that is passed to 1159 | /// `FlutterEngineNotifyDisplayUpdate`. 1160 | typedef enum { 1161 | /// `FlutterEngineDisplay`s that were active during start-up. A display is 1162 | /// considered active if: 1163 | /// 1. The frame buffer hardware is connected. 1164 | /// 2. The display is drawable, e.g. it isn't being mirrored from another 1165 | /// connected display or sleeping. 1166 | kFlutterEngineDisplaysUpdateTypeStartup, 1167 | kFlutterEngineDisplaysUpdateTypeCount, 1168 | } FlutterEngineDisplaysUpdateType; 1169 | 1170 | typedef int64_t FlutterEngineDartPort; 1171 | 1172 | typedef enum { 1173 | kFlutterEngineDartObjectTypeNull, 1174 | kFlutterEngineDartObjectTypeBool, 1175 | kFlutterEngineDartObjectTypeInt32, 1176 | kFlutterEngineDartObjectTypeInt64, 1177 | kFlutterEngineDartObjectTypeDouble, 1178 | kFlutterEngineDartObjectTypeString, 1179 | /// The object will be made available to Dart code as an instance of 1180 | /// Uint8List. 1181 | kFlutterEngineDartObjectTypeBuffer, 1182 | } FlutterEngineDartObjectType; 1183 | 1184 | typedef struct { 1185 | /// The size of this struct. Must be sizeof(FlutterEngineDartBuffer). 1186 | size_t struct_size; 1187 | /// An opaque baton passed back to the embedder when the 1188 | /// buffer_collect_callback is invoked. The engine does not interpret this 1189 | /// field in any way. 1190 | void* user_data; 1191 | /// This is an optional field. 1192 | /// 1193 | /// When specified, the engine will assume that the buffer is owned by the 1194 | /// embedder. When the data is no longer needed by any isolate, this callback 1195 | /// will be made on an internal engine managed thread. The embedder is free to 1196 | /// collect the buffer here. When this field is specified, it is the embedders 1197 | /// responsibility to keep the buffer alive and not modify it till this 1198 | /// callback is invoked by the engine. The user data specified in the callback 1199 | /// is the value of `user_data` field in this struct. 1200 | /// 1201 | /// When NOT specified, the VM creates an internal copy of the buffer. The 1202 | /// caller is free to modify the buffer as necessary or collect it immediately 1203 | /// after the call to `FlutterEnginePostDartObject`. 1204 | /// 1205 | /// @attention The buffer_collect_callback is will only be invoked by the 1206 | /// engine when the `FlutterEnginePostDartObject` method 1207 | /// returns kSuccess. In case of non-successful calls to this 1208 | /// method, it is the embedders responsibility to collect the 1209 | /// buffer. 1210 | VoidCallback buffer_collect_callback; 1211 | /// A pointer to the bytes of the buffer. When the buffer is owned by the 1212 | /// embedder (by specifying the `buffer_collect_callback`), Dart code may 1213 | /// modify that embedder owned buffer. For this reason, it is important that 1214 | /// this buffer not have page protections that restrict writing to this 1215 | /// buffer. 1216 | uint8_t* buffer; 1217 | /// The size of the buffer. 1218 | size_t buffer_size; 1219 | } FlutterEngineDartBuffer; 1220 | 1221 | /// This struct specifies the native representation of a Dart object that can be 1222 | /// sent via a send port to any isolate in the VM that has the corresponding 1223 | /// receive port. 1224 | /// 1225 | /// All fields in this struct are copied out in the call to 1226 | /// `FlutterEnginePostDartObject` and the caller is free to reuse or collect 1227 | /// this struct after that call. 1228 | typedef struct { 1229 | FlutterEngineDartObjectType type; 1230 | union { 1231 | bool bool_value; 1232 | int32_t int32_value; 1233 | int64_t int64_value; 1234 | double double_value; 1235 | /// A null terminated string. This string will be copied by the VM in the 1236 | /// call to `FlutterEnginePostDartObject` and must be collected by the 1237 | /// embedder after that call is made. 1238 | const char* string_value; 1239 | const FlutterEngineDartBuffer* buffer_value; 1240 | }; 1241 | } FlutterEngineDartObject; 1242 | 1243 | /// This enum allows embedders to determine the type of the engine thread in the 1244 | /// FlutterNativeThreadCallback. Based on the thread type, the embedder may be 1245 | /// able to tweak the thread priorities for optimum performance. 1246 | typedef enum { 1247 | /// The Flutter Engine considers the thread on which the FlutterEngineRun call 1248 | /// is made to be the platform thread. There is only one such thread per 1249 | /// engine instance. 1250 | kFlutterNativeThreadTypePlatform, 1251 | /// This is the thread the Flutter Engine uses to execute rendering commands 1252 | /// based on the selected client rendering API. There is only one such thread 1253 | /// per engine instance. 1254 | kFlutterNativeThreadTypeRender, 1255 | /// This is a dedicated thread on which the root Dart isolate is serviced. 1256 | /// There is only one such thread per engine instance. 1257 | kFlutterNativeThreadTypeUI, 1258 | /// Multiple threads are used by the Flutter engine to perform long running 1259 | /// background tasks. 1260 | kFlutterNativeThreadTypeWorker, 1261 | } FlutterNativeThreadType; 1262 | 1263 | /// A callback made by the engine in response to 1264 | /// `FlutterEnginePostCallbackOnAllNativeThreads` on all internal thread. 1265 | typedef void (*FlutterNativeThreadCallback)(FlutterNativeThreadType type, 1266 | void* user_data); 1267 | 1268 | /// AOT data source type. 1269 | typedef enum { 1270 | kFlutterEngineAOTDataSourceTypeElfPath 1271 | } FlutterEngineAOTDataSourceType; 1272 | 1273 | /// This struct specifies one of the various locations the engine can look for 1274 | /// AOT data sources. 1275 | typedef struct { 1276 | FlutterEngineAOTDataSourceType type; 1277 | union { 1278 | /// Absolute path to an ELF library file. 1279 | const char* elf_path; 1280 | }; 1281 | } FlutterEngineAOTDataSource; 1282 | 1283 | // Logging callback for Dart application messages. 1284 | // 1285 | // The `tag` parameter contains a null-terminated string containing a logging 1286 | // tag or component name that can be used to identify system log messages from 1287 | // the app. The `message` parameter contains a null-terminated string 1288 | // containing the message to be logged. `user_data` is a user data baton passed 1289 | // in `FlutterEngineRun`. 1290 | typedef void (*FlutterLogMessageCallback)(const char* /* tag */, 1291 | const char* /* message */, 1292 | void* /* user_data */); 1293 | 1294 | /// An opaque object that describes the AOT data that can be used to launch a 1295 | /// FlutterEngine instance in AOT mode. 1296 | typedef struct _FlutterEngineAOTData* FlutterEngineAOTData; 1297 | 1298 | typedef struct { 1299 | /// The size of this struct. Must be sizeof(FlutterProjectArgs). 1300 | size_t struct_size; 1301 | /// The path to the Flutter assets directory containing project assets. The 1302 | /// string can be collected after the call to `FlutterEngineRun` returns. The 1303 | /// string must be NULL terminated. 1304 | const char* assets_path; 1305 | /// The path to the Dart file containing the `main` entry point. 1306 | /// The string can be collected after the call to `FlutterEngineRun` returns. 1307 | /// The string must be NULL terminated. 1308 | /// 1309 | /// @deprecated As of Dart 2, running from Dart source is no longer 1310 | /// supported. Dart code should now be compiled to kernel form 1311 | /// and will be loaded by from `kernel_blob.bin` in the assets 1312 | /// directory. This struct member is retained for ABI 1313 | /// stability. 1314 | const char* main_path__unused__; 1315 | /// The path to the `.packages` file for the project. The string can be 1316 | /// collected after the call to `FlutterEngineRun` returns. The string must be 1317 | /// NULL terminated. 1318 | /// 1319 | /// @deprecated As of Dart 2, running from Dart source is no longer 1320 | /// supported. Dart code should now be compiled to kernel form 1321 | /// and will be loaded by from `kernel_blob.bin` in the assets 1322 | /// directory. This struct member is retained for ABI 1323 | /// stability. 1324 | const char* packages_path__unused__; 1325 | /// The path to the `icudtl.dat` file for the project. The string can be 1326 | /// collected after the call to `FlutterEngineRun` returns. The string must 1327 | /// be NULL terminated. 1328 | const char* icu_data_path; 1329 | /// The command line argument count used to initialize the project. 1330 | int command_line_argc; 1331 | /// The command line arguments used to initialize the project. The strings can 1332 | /// be collected after the call to `FlutterEngineRun` returns. The strings 1333 | /// must be `NULL` terminated. 1334 | /// 1335 | /// @attention The first item in the command line (if specified at all) is 1336 | /// interpreted as the executable name. So if an engine flag 1337 | /// needs to be passed into the same, it needs to not be the 1338 | /// very first item in the list. 1339 | /// 1340 | /// The set of engine flags are only meant to control 1341 | /// unstable features in the engine. Deployed applications should not pass any 1342 | /// command line arguments at all as they may affect engine stability at 1343 | /// runtime in the presence of un-sanitized input. The list of currently 1344 | /// recognized engine flags and their descriptions can be retrieved from the 1345 | /// `switches.h` engine source file. 1346 | const char* const* command_line_argv; 1347 | /// The callback invoked by the engine in order to give the embedder the 1348 | /// chance to respond to platform messages from the Dart application. The 1349 | /// callback will be invoked on the thread on which the `FlutterEngineRun` 1350 | /// call is made. 1351 | FlutterPlatformMessageCallback platform_message_callback; 1352 | /// The VM snapshot data buffer used in AOT operation. This buffer must be 1353 | /// mapped in as read-only. For more information refer to the documentation on 1354 | /// the Wiki at 1355 | /// https://github.com/flutter/flutter/wiki/Flutter-engine-operation-in-AOT-Mode 1356 | const uint8_t* vm_snapshot_data; 1357 | /// The size of the VM snapshot data buffer. If vm_snapshot_data is a symbol 1358 | /// reference, 0 may be passed here. 1359 | size_t vm_snapshot_data_size; 1360 | /// The VM snapshot instructions buffer used in AOT operation. This buffer 1361 | /// must be mapped in as read-execute. For more information refer to the 1362 | /// documentation on the Wiki at 1363 | /// https://github.com/flutter/flutter/wiki/Flutter-engine-operation-in-AOT-Mode 1364 | const uint8_t* vm_snapshot_instructions; 1365 | /// The size of the VM snapshot instructions buffer. If 1366 | /// vm_snapshot_instructions is a symbol reference, 0 may be passed here. 1367 | size_t vm_snapshot_instructions_size; 1368 | /// The isolate snapshot data buffer used in AOT operation. This buffer must 1369 | /// be mapped in as read-only. For more information refer to the documentation 1370 | /// on the Wiki at 1371 | /// https://github.com/flutter/flutter/wiki/Flutter-engine-operation-in-AOT-Mode 1372 | const uint8_t* isolate_snapshot_data; 1373 | /// The size of the isolate snapshot data buffer. If isolate_snapshot_data is 1374 | /// a symbol reference, 0 may be passed here. 1375 | size_t isolate_snapshot_data_size; 1376 | /// The isolate snapshot instructions buffer used in AOT operation. This 1377 | /// buffer must be mapped in as read-execute. For more information refer to 1378 | /// the documentation on the Wiki at 1379 | /// https://github.com/flutter/flutter/wiki/Flutter-engine-operation-in-AOT-Mode 1380 | const uint8_t* isolate_snapshot_instructions; 1381 | /// The size of the isolate snapshot instructions buffer. If 1382 | /// isolate_snapshot_instructions is a symbol reference, 0 may be passed here. 1383 | size_t isolate_snapshot_instructions_size; 1384 | /// The callback invoked by the engine in root isolate scope. Called 1385 | /// immediately after the root isolate has been created and marked runnable. 1386 | VoidCallback root_isolate_create_callback; 1387 | /// The callback invoked by the engine in order to give the embedder the 1388 | /// chance to respond to semantics node updates from the Dart application. 1389 | /// Semantics node updates are sent in batches terminated by a 'batch end' 1390 | /// callback that is passed a sentinel `FlutterSemanticsNode` whose `id` field 1391 | /// has the value `kFlutterSemanticsNodeIdBatchEnd`. 1392 | /// 1393 | /// The callback will be invoked on the thread on which the `FlutterEngineRun` 1394 | /// call is made. 1395 | FlutterUpdateSemanticsNodeCallback update_semantics_node_callback; 1396 | /// The callback invoked by the engine in order to give the embedder the 1397 | /// chance to respond to updates to semantics custom actions from the Dart 1398 | /// application. Custom action updates are sent in batches terminated by a 1399 | /// 'batch end' callback that is passed a sentinel 1400 | /// `FlutterSemanticsCustomAction` whose `id` field has the value 1401 | /// `kFlutterSemanticsCustomActionIdBatchEnd`. 1402 | /// 1403 | /// The callback will be invoked on the thread on which the `FlutterEngineRun` 1404 | /// call is made. 1405 | FlutterUpdateSemanticsCustomActionCallback 1406 | update_semantics_custom_action_callback; 1407 | /// Path to a directory used to store data that is cached across runs of a 1408 | /// Flutter application (such as compiled shader programs used by Skia). 1409 | /// This is optional. The string must be NULL terminated. 1410 | /// 1411 | // This is different from the cache-path-dir argument defined in switches.h, 1412 | // which is used in `flutter::Settings` as `temp_directory_path`. 1413 | const char* persistent_cache_path; 1414 | 1415 | /// If true, the engine would only read the existing cache, but not write new 1416 | /// ones. 1417 | bool is_persistent_cache_read_only; 1418 | 1419 | /// A callback that gets invoked by the engine when it attempts to wait for a 1420 | /// platform vsync event. The engine will give the platform a baton that needs 1421 | /// to be returned back to the engine via `FlutterEngineOnVsync`. All batons 1422 | /// must be retured to the engine before initializing a 1423 | /// `FlutterEngineShutdown`. Not doing the same will result in a memory leak. 1424 | /// While the call to `FlutterEngineOnVsync` must occur on the thread that 1425 | /// made the call to `FlutterEngineRun`, the engine will make this callback on 1426 | /// an internal engine-managed thread. If the components accessed on the 1427 | /// embedder are not thread safe, the appropriate re-threading must be done. 1428 | VsyncCallback vsync_callback; 1429 | 1430 | /// The name of a custom Dart entrypoint. This is optional and specifying a 1431 | /// null or empty entrypoint makes the engine look for a method named "main" 1432 | /// in the root library of the application. 1433 | /// 1434 | /// Care must be taken to ensure that the custom entrypoint is not tree-shaken 1435 | /// away. Usually, this is done using the `@pragma('vm:entry-point')` 1436 | /// decoration. 1437 | const char* custom_dart_entrypoint; 1438 | 1439 | /// Typically the Flutter engine create and manages its internal threads. This 1440 | /// optional argument allows for the specification of task runner interfaces 1441 | /// to event loops managed by the embedder on threads it creates. 1442 | const FlutterCustomTaskRunners* custom_task_runners; 1443 | 1444 | /// All `FlutterEngine` instances in the process share the same Dart VM. When 1445 | /// the first engine is launched, it starts the Dart VM as well. It used to be 1446 | /// the case that it was not possible to shutdown the Dart VM cleanly and 1447 | /// start it back up in the process in a safe manner. This issue has since 1448 | /// been patched. Unfortunately, applications already began to make use of the 1449 | /// fact that shutting down the Flutter engine instance left a running VM in 1450 | /// the process. Since a Flutter engine could be launched on any thread, 1451 | /// applications would "warm up" the VM on another thread by launching 1452 | /// an engine with no isolates and then shutting it down immediately. The main 1453 | /// Flutter application could then be started on the main thread without 1454 | /// having to incur the Dart VM startup costs at that time. With the new 1455 | /// behavior, this "optimization" immediately becomes massive performance 1456 | /// pessimization as the VM would be started up in the "warm up" phase, shut 1457 | /// down there and then started again on the main thread. Changing this 1458 | /// behavior was deemed to be an unacceptable breaking change. Embedders that 1459 | /// wish to shutdown the Dart VM when the last engine is terminated in the 1460 | /// process should opt into this behavior by setting this flag to true. 1461 | bool shutdown_dart_vm_when_done; 1462 | 1463 | /// Typically, Flutter renders the layer hierarchy into a single root surface. 1464 | /// However, when embedders need to interleave their own contents within the 1465 | /// Flutter layer hierarchy, their applications can push platform views within 1466 | /// the Flutter scene. This is done using the `SceneBuilder.addPlatformView` 1467 | /// call. When this happens, the Flutter rasterizer divides the effective view 1468 | /// hierarchy into multiple layers. Each layer gets its own backing store and 1469 | /// Flutter renders into the same. Once the layers contents have been 1470 | /// fulfilled, the embedder is asked to composite these layers on-screen. At 1471 | /// this point, it can interleave its own contents within the effective 1472 | /// hierarchy. The interface for the specification of these layer backing 1473 | /// stores and the hooks to listen for the composition of layers on-screen can 1474 | /// be controlled using this field. This field is completely optional. In its 1475 | /// absence, platforms views in the scene are ignored and Flutter renders to 1476 | /// the root surface as normal. 1477 | const FlutterCompositor* compositor; 1478 | 1479 | /// Max size of the old gen heap for the Dart VM in MB, or 0 for unlimited, -1 1480 | /// for default value. 1481 | /// 1482 | /// See also: 1483 | /// https://github.com/dart-lang/sdk/blob/ca64509108b3e7219c50d6c52877c85ab6a35ff2/runtime/vm/flag_list.h#L150 1484 | int64_t dart_old_gen_heap_size; 1485 | 1486 | /// The AOT data to be used in AOT operation. 1487 | /// 1488 | /// Embedders should instantiate and destroy this object via the 1489 | /// FlutterEngineCreateAOTData and FlutterEngineCollectAOTData methods. 1490 | /// 1491 | /// Embedders can provide either snapshot buffers or aot_data, but not both. 1492 | FlutterEngineAOTData aot_data; 1493 | 1494 | /// A callback that computes the locale the platform would natively resolve 1495 | /// to. 1496 | /// 1497 | /// The input parameter is an array of FlutterLocales which represent the 1498 | /// locales supported by the app. One of the input supported locales should 1499 | /// be selected and returned to best match with the user/device's preferred 1500 | /// locale. The implementation should produce a result that as closely 1501 | /// matches what the platform would natively resolve to as possible. 1502 | FlutterComputePlatformResolvedLocaleCallback 1503 | compute_platform_resolved_locale_callback; 1504 | 1505 | /// The command line argument count for arguments passed through to the Dart 1506 | /// entrypoint. 1507 | int dart_entrypoint_argc; 1508 | 1509 | /// The command line arguments passed through to the Dart entrypoint. The 1510 | /// strings must be `NULL` terminated. 1511 | /// 1512 | /// The strings will be copied out and so any strings passed in here can 1513 | /// be safely collected after initializing the engine with 1514 | /// `FlutterProjectArgs`. 1515 | const char* const* dart_entrypoint_argv; 1516 | 1517 | // Logging callback for Dart application messages. 1518 | // 1519 | // This callback is used by embedder to log print messages from the running 1520 | // Flutter application. This callback is made on an internal engine managed 1521 | // thread and embedders must re-thread if necessary. Performing blocking calls 1522 | // in this callback may introduce application jank. 1523 | FlutterLogMessageCallback log_message_callback; 1524 | 1525 | // A tag string associated with application log messages. 1526 | // 1527 | // A log message tag string that can be used convey application, subsystem, 1528 | // or component name to embedder's logger. This string will be passed to to 1529 | // callbacks on `log_message_callback`. Defaults to "flutter" if unspecified. 1530 | const char* log_tag; 1531 | } FlutterProjectArgs; 1532 | 1533 | #ifndef FLUTTER_ENGINE_NO_PROTOTYPES 1534 | 1535 | //------------------------------------------------------------------------------ 1536 | /// @brief Creates the necessary data structures to launch a Flutter Dart 1537 | /// application in AOT mode. The data may only be collected after 1538 | /// all FlutterEngine instances launched using this data have been 1539 | /// terminated. 1540 | /// 1541 | /// @param[in] source The source of the AOT data. 1542 | /// @param[out] data_out The AOT data on success. Unchanged on failure. 1543 | /// 1544 | /// @return Returns if the AOT data could be successfully resolved. 1545 | /// 1546 | FLUTTER_EXPORT 1547 | FlutterEngineResult FlutterEngineCreateAOTData( 1548 | const FlutterEngineAOTDataSource* source, 1549 | FlutterEngineAOTData* data_out); 1550 | 1551 | //------------------------------------------------------------------------------ 1552 | /// @brief Collects the AOT data. 1553 | /// 1554 | /// @warning The embedder must ensure that this call is made only after all 1555 | /// FlutterEngine instances launched using this data have been 1556 | /// terminated, and that all of those instances were launched with 1557 | /// the FlutterProjectArgs::shutdown_dart_vm_when_done flag set to 1558 | /// true. 1559 | /// 1560 | /// @param[in] data The data to collect. 1561 | /// 1562 | /// @return Returns if the AOT data was successfully collected. 1563 | /// 1564 | FLUTTER_EXPORT 1565 | FlutterEngineResult FlutterEngineCollectAOTData(FlutterEngineAOTData data); 1566 | 1567 | //------------------------------------------------------------------------------ 1568 | /// @brief Initialize and run a Flutter engine instance and return a handle 1569 | /// to it. This is a convenience method for the pair of calls to 1570 | /// `FlutterEngineInitialize` and `FlutterEngineRunInitialized`. 1571 | /// 1572 | /// @note This method of running a Flutter engine works well except in 1573 | /// cases where the embedder specifies custom task runners via 1574 | /// `FlutterProjectArgs::custom_task_runners`. In such cases, the 1575 | /// engine may need the embedder to post tasks back to it before 1576 | /// `FlutterEngineRun` has returned. Embedders can only post tasks 1577 | /// to the engine if they have a handle to the engine. In such 1578 | /// cases, embedders are advised to get the engine handle via the 1579 | /// `FlutterInitializeCall`. Then they can call 1580 | /// `FlutterEngineRunInitialized` knowing that they will be able to 1581 | /// service custom tasks on other threads with the engine handle. 1582 | /// 1583 | /// @param[in] version The Flutter embedder API version. Must be 1584 | /// FLUTTER_ENGINE_VERSION. 1585 | /// @param[in] config The renderer configuration. 1586 | /// @param[in] args The Flutter project arguments. 1587 | /// @param user_data A user data baton passed back to embedders in 1588 | /// callbacks. 1589 | /// @param[out] engine_out The engine handle on successful engine creation. 1590 | /// 1591 | /// @return The result of the call to run the Flutter engine. 1592 | /// 1593 | FLUTTER_EXPORT 1594 | FlutterEngineResult FlutterEngineRun(size_t version, 1595 | const FlutterRendererConfig* config, 1596 | const FlutterProjectArgs* args, 1597 | void* user_data, 1598 | FLUTTER_API_SYMBOL(FlutterEngine) * 1599 | engine_out); 1600 | 1601 | //------------------------------------------------------------------------------ 1602 | /// @brief Shuts down a Flutter engine instance. The engine handle is no 1603 | /// longer valid for any calls in the embedder API after this point. 1604 | /// Making additional calls with this handle is undefined behavior. 1605 | /// 1606 | /// @note This de-initializes the Flutter engine instance (via an implicit 1607 | /// call to `FlutterEngineDeinitialize`) if necessary. 1608 | /// 1609 | /// @param[in] engine The Flutter engine instance to collect. 1610 | /// 1611 | /// @return The result of the call to shutdown the Flutter engine instance. 1612 | /// 1613 | FLUTTER_EXPORT 1614 | FlutterEngineResult FlutterEngineShutdown(FLUTTER_API_SYMBOL(FlutterEngine) 1615 | engine); 1616 | 1617 | //------------------------------------------------------------------------------ 1618 | /// @brief Initialize a Flutter engine instance. This does not run the 1619 | /// Flutter application code till the `FlutterEngineRunInitialized` 1620 | /// call is made. Besides Flutter application code, no tasks are 1621 | /// scheduled on embedder managed task runners either. This allows 1622 | /// embedders providing custom task runners to the Flutter engine to 1623 | /// obtain a handle to the Flutter engine before the engine can post 1624 | /// tasks on these task runners. 1625 | /// 1626 | /// @param[in] version The Flutter embedder API version. Must be 1627 | /// FLUTTER_ENGINE_VERSION. 1628 | /// @param[in] config The renderer configuration. 1629 | /// @param[in] args The Flutter project arguments. 1630 | /// @param user_data A user data baton passed back to embedders in 1631 | /// callbacks. 1632 | /// @param[out] engine_out The engine handle on successful engine creation. 1633 | /// 1634 | /// @return The result of the call to initialize the Flutter engine. 1635 | /// 1636 | FLUTTER_EXPORT 1637 | FlutterEngineResult FlutterEngineInitialize(size_t version, 1638 | const FlutterRendererConfig* config, 1639 | const FlutterProjectArgs* args, 1640 | void* user_data, 1641 | FLUTTER_API_SYMBOL(FlutterEngine) * 1642 | engine_out); 1643 | 1644 | //------------------------------------------------------------------------------ 1645 | /// @brief Stops running the Flutter engine instance. After this call, the 1646 | /// embedder is also guaranteed that no more calls to post tasks 1647 | /// onto custom task runners specified by the embedder are made. The 1648 | /// Flutter engine handle still needs to be collected via a call to 1649 | /// `FlutterEngineShutdown`. 1650 | /// 1651 | /// @param[in] engine The running engine instance to de-initialize. 1652 | /// 1653 | /// @return The result of the call to de-initialize the Flutter engine. 1654 | /// 1655 | FLUTTER_EXPORT 1656 | FlutterEngineResult FlutterEngineDeinitialize(FLUTTER_API_SYMBOL(FlutterEngine) 1657 | engine); 1658 | 1659 | //------------------------------------------------------------------------------ 1660 | /// @brief Runs an initialized engine instance. An engine can be 1661 | /// initialized via `FlutterEngineInitialize`. An initialized 1662 | /// instance can only be run once. During and after this call, 1663 | /// custom task runners supplied by the embedder are expected to 1664 | /// start servicing tasks. 1665 | /// 1666 | /// @param[in] engine An initialized engine instance that has not previously 1667 | /// been run. 1668 | /// 1669 | /// @return The result of the call to run the initialized Flutter 1670 | /// engine instance. 1671 | /// 1672 | FLUTTER_EXPORT 1673 | FlutterEngineResult FlutterEngineRunInitialized( 1674 | FLUTTER_API_SYMBOL(FlutterEngine) engine); 1675 | 1676 | FLUTTER_EXPORT 1677 | FlutterEngineResult FlutterEngineSendWindowMetricsEvent( 1678 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 1679 | const FlutterWindowMetricsEvent* event); 1680 | 1681 | FLUTTER_EXPORT 1682 | FlutterEngineResult FlutterEngineSendPointerEvent( 1683 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 1684 | const FlutterPointerEvent* events, 1685 | size_t events_count); 1686 | 1687 | //------------------------------------------------------------------------------ 1688 | /// @brief Sends a key event to the engine. The framework will decide 1689 | /// whether to handle this event in a synchronous fashion, although 1690 | /// due to technical limitation, the result is always reported 1691 | /// asynchronously. The `callback` is guaranteed to be called 1692 | /// exactly once. 1693 | /// 1694 | /// @param[in] engine A running engine instance. 1695 | /// @param[in] event The event data to be sent. This function will no 1696 | /// longer access `event` after returning. 1697 | /// @param[in] callback The callback invoked by the engine when the 1698 | /// Flutter application has decided whether it 1699 | /// handles this event. Accepts nullptr. 1700 | /// @param[in] user_data The context associated with the callback. The 1701 | /// exact same value will used to invoke `callback`. 1702 | /// Accepts nullptr. 1703 | /// 1704 | /// @return The result of the call. 1705 | /// 1706 | FLUTTER_EXPORT 1707 | FlutterEngineResult FlutterEngineSendKeyEvent(FLUTTER_API_SYMBOL(FlutterEngine) 1708 | engine, 1709 | const FlutterKeyEvent* event, 1710 | FlutterKeyEventCallback callback, 1711 | void* user_data); 1712 | 1713 | FLUTTER_EXPORT 1714 | FlutterEngineResult FlutterEngineSendPlatformMessage( 1715 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 1716 | const FlutterPlatformMessage* message); 1717 | 1718 | //------------------------------------------------------------------------------ 1719 | /// @brief Creates a platform message response handle that allows the 1720 | /// embedder to set a native callback for a response to a message. 1721 | /// This handle may be set on the `response_handle` field of any 1722 | /// `FlutterPlatformMessage` sent to the engine. 1723 | /// 1724 | /// The handle must be collected via a call to 1725 | /// `FlutterPlatformMessageReleaseResponseHandle`. This may be done 1726 | /// immediately after a call to `FlutterEngineSendPlatformMessage` 1727 | /// with a platform message whose response handle contains the handle 1728 | /// created using this call. In case a handle is created but never 1729 | /// sent in a message, the release call must still be made. Not 1730 | /// calling release on the handle results in a small memory leak. 1731 | /// 1732 | /// The user data baton passed to the data callback is the one 1733 | /// specified in this call as the third argument. 1734 | /// 1735 | /// @see FlutterPlatformMessageReleaseResponseHandle() 1736 | /// 1737 | /// @param[in] engine A running engine instance. 1738 | /// @param[in] data_callback The callback invoked by the engine when the 1739 | /// Flutter application send a response on the 1740 | /// handle. 1741 | /// @param[in] user_data The user data associated with the data callback. 1742 | /// @param[out] response_out The response handle created when this call is 1743 | /// successful. 1744 | /// 1745 | /// @return The result of the call. 1746 | /// 1747 | FLUTTER_EXPORT 1748 | FlutterEngineResult FlutterPlatformMessageCreateResponseHandle( 1749 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 1750 | FlutterDataCallback data_callback, 1751 | void* user_data, 1752 | FlutterPlatformMessageResponseHandle** response_out); 1753 | 1754 | //------------------------------------------------------------------------------ 1755 | /// @brief Collects the handle created using 1756 | /// `FlutterPlatformMessageCreateResponseHandle`. 1757 | /// 1758 | /// @see FlutterPlatformMessageCreateResponseHandle() 1759 | /// 1760 | /// @param[in] engine A running engine instance. 1761 | /// @param[in] response The platform message response handle to collect. 1762 | /// These handles are created using 1763 | /// `FlutterPlatformMessageCreateResponseHandle()`. 1764 | /// 1765 | /// @return The result of the call. 1766 | /// 1767 | FLUTTER_EXPORT 1768 | FlutterEngineResult FlutterPlatformMessageReleaseResponseHandle( 1769 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 1770 | FlutterPlatformMessageResponseHandle* response); 1771 | 1772 | //------------------------------------------------------------------------------ 1773 | /// @brief Send a response from the native side to a platform message from 1774 | /// the Dart Flutter application. 1775 | /// 1776 | /// @param[in] engine The running engine instance. 1777 | /// @param[in] handle The platform message response handle. 1778 | /// @param[in] data The data to associate with the platform message 1779 | /// response. 1780 | /// @param[in] data_length The length of the platform message response data. 1781 | /// 1782 | /// @return The result of the call. 1783 | /// 1784 | FLUTTER_EXPORT 1785 | FlutterEngineResult FlutterEngineSendPlatformMessageResponse( 1786 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 1787 | const FlutterPlatformMessageResponseHandle* handle, 1788 | const uint8_t* data, 1789 | size_t data_length); 1790 | 1791 | //------------------------------------------------------------------------------ 1792 | /// @brief This API is only meant to be used by platforms that need to 1793 | /// flush tasks on a message loop not controlled by the Flutter 1794 | /// engine. 1795 | /// 1796 | /// @deprecated This API will be deprecated and is not part of the stable API. 1797 | /// Please use the custom task runners API by setting an 1798 | /// appropriate `FlutterProjectArgs::custom_task_runners` 1799 | /// interface. This will yield better performance and the 1800 | /// interface is stable. 1801 | /// 1802 | /// @return The result of the call. 1803 | /// 1804 | FLUTTER_EXPORT 1805 | FlutterEngineResult __FlutterEngineFlushPendingTasksNow(); 1806 | 1807 | //------------------------------------------------------------------------------ 1808 | /// @brief Register an external texture with a unique (per engine) 1809 | /// identifier. Only rendering backends that support external 1810 | /// textures accept external texture registrations. After the 1811 | /// external texture is registered, the application can mark that a 1812 | /// frame is available by calling 1813 | /// `FlutterEngineMarkExternalTextureFrameAvailable`. 1814 | /// 1815 | /// @see FlutterEngineUnregisterExternalTexture() 1816 | /// @see FlutterEngineMarkExternalTextureFrameAvailable() 1817 | /// 1818 | /// @param[in] engine A running engine instance. 1819 | /// @param[in] texture_identifier The identifier of the texture to register 1820 | /// with the engine. The embedder may supply new 1821 | /// frames to this texture using the same 1822 | /// identifier. 1823 | /// 1824 | /// @return The result of the call. 1825 | /// 1826 | FLUTTER_EXPORT 1827 | FlutterEngineResult FlutterEngineRegisterExternalTexture( 1828 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 1829 | int64_t texture_identifier); 1830 | 1831 | //------------------------------------------------------------------------------ 1832 | /// @brief Unregister a previous texture registration. 1833 | /// 1834 | /// @see FlutterEngineRegisterExternalTexture() 1835 | /// @see FlutterEngineMarkExternalTextureFrameAvailable() 1836 | /// 1837 | /// @param[in] engine A running engine instance. 1838 | /// @param[in] texture_identifier The identifier of the texture for which new 1839 | /// frame will not be available. 1840 | /// 1841 | /// @return The result of the call. 1842 | /// 1843 | FLUTTER_EXPORT 1844 | FlutterEngineResult FlutterEngineUnregisterExternalTexture( 1845 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 1846 | int64_t texture_identifier); 1847 | 1848 | //------------------------------------------------------------------------------ 1849 | /// @brief Mark that a new texture frame is available for a given texture 1850 | /// identifier. 1851 | /// 1852 | /// @see FlutterEngineRegisterExternalTexture() 1853 | /// @see FlutterEngineUnregisterExternalTexture() 1854 | /// 1855 | /// @param[in] engine A running engine instance. 1856 | /// @param[in] texture_identifier The identifier of the texture whose frame 1857 | /// has been updated. 1858 | /// 1859 | /// @return The result of the call. 1860 | /// 1861 | FLUTTER_EXPORT 1862 | FlutterEngineResult FlutterEngineMarkExternalTextureFrameAvailable( 1863 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 1864 | int64_t texture_identifier); 1865 | 1866 | //------------------------------------------------------------------------------ 1867 | /// @brief Enable or disable accessibility semantics. 1868 | /// 1869 | /// @param[in] engine A running engine instance. 1870 | /// @param[in] enabled When enabled, changes to the semantic contents of the 1871 | /// window are sent via the 1872 | /// `FlutterUpdateSemanticsNodeCallback` registered to 1873 | /// `update_semantics_node_callback` in 1874 | /// `FlutterProjectArgs`. 1875 | /// 1876 | /// @return The result of the call. 1877 | /// 1878 | FLUTTER_EXPORT 1879 | FlutterEngineResult FlutterEngineUpdateSemanticsEnabled( 1880 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 1881 | bool enabled); 1882 | 1883 | //------------------------------------------------------------------------------ 1884 | /// @brief Sets additional accessibility features. 1885 | /// 1886 | /// @param[in] engine A running engine instance 1887 | /// @param[in] features The accessibility features to set. 1888 | /// 1889 | /// @return The result of the call. 1890 | /// 1891 | FLUTTER_EXPORT 1892 | FlutterEngineResult FlutterEngineUpdateAccessibilityFeatures( 1893 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 1894 | FlutterAccessibilityFeature features); 1895 | 1896 | //------------------------------------------------------------------------------ 1897 | /// @brief Dispatch a semantics action to the specified semantics node. 1898 | /// 1899 | /// @param[in] engine A running engine instance. 1900 | /// @param[in] identifier The semantics action identifier. 1901 | /// @param[in] action The semantics action. 1902 | /// @param[in] data Data associated with the action. 1903 | /// @param[in] data_length The data length. 1904 | /// 1905 | /// @return The result of the call. 1906 | /// 1907 | FLUTTER_EXPORT 1908 | FlutterEngineResult FlutterEngineDispatchSemanticsAction( 1909 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 1910 | uint64_t id, 1911 | FlutterSemanticsAction action, 1912 | const uint8_t* data, 1913 | size_t data_length); 1914 | 1915 | //------------------------------------------------------------------------------ 1916 | /// @brief Notify the engine that a vsync event occurred. A baton passed to 1917 | /// the platform via the vsync callback must be returned. This call 1918 | /// must be made on the thread on which the call to 1919 | /// `FlutterEngineRun` was made. 1920 | /// 1921 | /// @see FlutterEngineGetCurrentTime() 1922 | /// 1923 | /// @attention That frame timepoints are in nanoseconds. 1924 | /// 1925 | /// @attention The system monotonic clock is used as the timebase. 1926 | /// 1927 | /// @param[in] engine. A running engine instance. 1928 | /// @param[in] baton The baton supplied by the engine. 1929 | /// @param[in] frame_start_time_nanos The point at which the vsync event 1930 | /// occurred or will occur. If the time 1931 | /// point is in the future, the engine will 1932 | /// wait till that point to begin its frame 1933 | /// workload. 1934 | /// @param[in] frame_target_time_nanos The point at which the embedder 1935 | /// anticipates the next vsync to occur. 1936 | /// This is a hint the engine uses to 1937 | /// schedule Dart VM garbage collection in 1938 | /// periods in which the various threads 1939 | /// are most likely to be idle. For 1940 | /// example, for a 60Hz display, embedders 1941 | /// should add 16.6 * 1e6 to the frame time 1942 | /// field. 1943 | /// 1944 | /// @return The result of the call. 1945 | /// 1946 | FLUTTER_EXPORT 1947 | FlutterEngineResult FlutterEngineOnVsync(FLUTTER_API_SYMBOL(FlutterEngine) 1948 | engine, 1949 | intptr_t baton, 1950 | uint64_t frame_start_time_nanos, 1951 | uint64_t frame_target_time_nanos); 1952 | 1953 | //------------------------------------------------------------------------------ 1954 | /// @brief Reloads the system fonts in engine. 1955 | /// 1956 | /// @param[in] engine. A running engine instance. 1957 | /// 1958 | /// @return The result of the call. 1959 | /// 1960 | FLUTTER_EXPORT 1961 | FlutterEngineResult FlutterEngineReloadSystemFonts( 1962 | FLUTTER_API_SYMBOL(FlutterEngine) engine); 1963 | 1964 | //------------------------------------------------------------------------------ 1965 | /// @brief A profiling utility. Logs a trace duration begin event to the 1966 | /// timeline. If the timeline is unavailable or disabled, this has 1967 | /// no effect. Must be balanced with an duration end event (via 1968 | /// `FlutterEngineTraceEventDurationEnd`) with the same name on the 1969 | /// same thread. Can be called on any thread. Strings passed into 1970 | /// the function will NOT be copied when added to the timeline. Only 1971 | /// string literals may be passed in. 1972 | /// 1973 | /// @param[in] name The name of the trace event. 1974 | /// 1975 | FLUTTER_EXPORT 1976 | void FlutterEngineTraceEventDurationBegin(const char* name); 1977 | 1978 | //----------------------------------------------------------------------------- 1979 | /// @brief A profiling utility. Logs a trace duration end event to the 1980 | /// timeline. If the timeline is unavailable or disabled, this has 1981 | /// no effect. This call must be preceded by a trace duration begin 1982 | /// call (via `FlutterEngineTraceEventDurationBegin`) with the same 1983 | /// name on the same thread. Can be called on any thread. Strings 1984 | /// passed into the function will NOT be copied when added to the 1985 | /// timeline. Only string literals may be passed in. 1986 | /// 1987 | /// @param[in] name The name of the trace event. 1988 | /// 1989 | FLUTTER_EXPORT 1990 | void FlutterEngineTraceEventDurationEnd(const char* name); 1991 | 1992 | //----------------------------------------------------------------------------- 1993 | /// @brief A profiling utility. Logs a trace duration instant event to the 1994 | /// timeline. If the timeline is unavailable or disabled, this has 1995 | /// no effect. Can be called on any thread. Strings passed into the 1996 | /// function will NOT be copied when added to the timeline. Only 1997 | /// string literals may be passed in. 1998 | /// 1999 | /// @param[in] name The name of the trace event. 2000 | /// 2001 | FLUTTER_EXPORT 2002 | void FlutterEngineTraceEventInstant(const char* name); 2003 | 2004 | //------------------------------------------------------------------------------ 2005 | /// @brief Posts a task onto the Flutter render thread. Typically, this may 2006 | /// be called from any thread as long as a `FlutterEngineShutdown` 2007 | /// on the specific engine has not already been initiated. 2008 | /// 2009 | /// @param[in] engine A running engine instance. 2010 | /// @param[in] callback The callback to execute on the render thread. 2011 | /// @param callback_data The callback context. 2012 | /// 2013 | /// @return The result of the call. 2014 | /// 2015 | FLUTTER_EXPORT 2016 | FlutterEngineResult FlutterEnginePostRenderThreadTask( 2017 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2018 | VoidCallback callback, 2019 | void* callback_data); 2020 | 2021 | //------------------------------------------------------------------------------ 2022 | /// @brief Get the current time in nanoseconds from the clock used by the 2023 | /// flutter engine. This is the system monotonic clock. 2024 | /// 2025 | /// @return The current time in nanoseconds. 2026 | /// 2027 | FLUTTER_EXPORT 2028 | uint64_t FlutterEngineGetCurrentTime(); 2029 | 2030 | //------------------------------------------------------------------------------ 2031 | /// @brief Inform the engine to run the specified task. This task has been 2032 | /// given to the engine via the 2033 | /// `FlutterTaskRunnerDescription.post_task_callback`. This call 2034 | /// must only be made at the target time specified in that callback. 2035 | /// Running the task before that time is undefined behavior. 2036 | /// 2037 | /// @param[in] engine A running engine instance. 2038 | /// @param[in] task the task handle. 2039 | /// 2040 | /// @return The result of the call. 2041 | /// 2042 | FLUTTER_EXPORT 2043 | FlutterEngineResult FlutterEngineRunTask(FLUTTER_API_SYMBOL(FlutterEngine) 2044 | engine, 2045 | const FlutterTask* task); 2046 | 2047 | //------------------------------------------------------------------------------ 2048 | /// @brief Notify a running engine instance that the locale has been 2049 | /// updated. The preferred locale must be the first item in the list 2050 | /// of locales supplied. The other entries will be used as a 2051 | /// fallback. 2052 | /// 2053 | /// @param[in] engine A running engine instance. 2054 | /// @param[in] locales The updated locales in the order of preference. 2055 | /// @param[in] locales_count The count of locales supplied. 2056 | /// 2057 | /// @return Whether the locale updates were applied. 2058 | /// 2059 | FLUTTER_EXPORT 2060 | FlutterEngineResult FlutterEngineUpdateLocales(FLUTTER_API_SYMBOL(FlutterEngine) 2061 | engine, 2062 | const FlutterLocale** locales, 2063 | size_t locales_count); 2064 | 2065 | //------------------------------------------------------------------------------ 2066 | /// @brief Returns if the Flutter engine instance will run AOT compiled 2067 | /// Dart code. This call has no threading restrictions. 2068 | /// 2069 | /// For embedder code that is configured for both AOT and JIT mode 2070 | /// Dart execution based on the Flutter engine being linked to, this 2071 | /// runtime check may be used to appropriately configure the 2072 | /// `FlutterProjectArgs`. In JIT mode execution, the kernel 2073 | /// snapshots must be present in the Flutter assets directory 2074 | /// specified in the `FlutterProjectArgs`. For AOT execution, the 2075 | /// fields `vm_snapshot_data`, `vm_snapshot_instructions`, 2076 | /// `isolate_snapshot_data` and `isolate_snapshot_instructions` 2077 | /// (along with their size fields) must be specified in 2078 | /// `FlutterProjectArgs`. 2079 | /// 2080 | /// @return True, if AOT Dart code is run. JIT otherwise. 2081 | /// 2082 | FLUTTER_EXPORT 2083 | bool FlutterEngineRunsAOTCompiledDartCode(void); 2084 | 2085 | //------------------------------------------------------------------------------ 2086 | /// @brief Posts a Dart object to specified send port. The corresponding 2087 | /// receive port for send port can be in any isolate running in the 2088 | /// VM. This isolate can also be the root isolate for an 2089 | /// unrelated engine. The engine parameter is necessary only to 2090 | /// ensure the call is not made when no engine (and hence no VM) is 2091 | /// running. 2092 | /// 2093 | /// Unlike the platform messages mechanism, there are no threading 2094 | /// restrictions when using this API. Message can be posted on any 2095 | /// thread and they will be made available to isolate on which the 2096 | /// corresponding send port is listening. 2097 | /// 2098 | /// However, it is the embedders responsibility to ensure that the 2099 | /// call is not made during an ongoing call the 2100 | /// `FlutterEngineDeinitialize` or `FlutterEngineShutdown` on 2101 | /// another thread. 2102 | /// 2103 | /// @param[in] engine A running engine instance. 2104 | /// @param[in] port The send port to send the object to. 2105 | /// @param[in] object The object to send to the isolate with the 2106 | /// corresponding receive port. 2107 | /// 2108 | /// @return If the message was posted to the send port. 2109 | /// 2110 | FLUTTER_EXPORT 2111 | FlutterEngineResult FlutterEnginePostDartObject( 2112 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2113 | FlutterEngineDartPort port, 2114 | const FlutterEngineDartObject* object); 2115 | 2116 | //------------------------------------------------------------------------------ 2117 | /// @brief Posts a low memory notification to a running engine instance. 2118 | /// The engine will do its best to release non-critical resources in 2119 | /// response. It is not guaranteed that the resource would have been 2120 | /// collected by the time this call returns however. The 2121 | /// notification is posted to engine subsystems that may be 2122 | /// operating on other threads. 2123 | /// 2124 | /// Flutter applications can respond to these notifications by 2125 | /// setting `WidgetsBindingObserver.didHaveMemoryPressure` 2126 | /// observers. 2127 | /// 2128 | /// @param[in] engine A running engine instance. 2129 | /// 2130 | /// @return If the low memory notification was sent to the running engine 2131 | /// instance. 2132 | /// 2133 | FLUTTER_EXPORT 2134 | FlutterEngineResult FlutterEngineNotifyLowMemoryWarning( 2135 | FLUTTER_API_SYMBOL(FlutterEngine) engine); 2136 | 2137 | //------------------------------------------------------------------------------ 2138 | /// @brief Schedule a callback to be run on all engine managed threads. 2139 | /// The engine will attempt to service this callback the next time 2140 | /// the message loop for each managed thread is idle. Since the 2141 | /// engine manages the entire lifecycle of multiple threads, there 2142 | /// is no opportunity for the embedders to finely tune the 2143 | /// priorities of threads directly, or, perform other thread 2144 | /// specific configuration (for example, setting thread names for 2145 | /// tracing). This callback gives embedders a chance to affect such 2146 | /// tuning. 2147 | /// 2148 | /// @attention This call is expensive and must be made as few times as 2149 | /// possible. The callback must also return immediately as not doing 2150 | /// so may risk performance issues (especially for callbacks of type 2151 | /// kFlutterNativeThreadTypeUI and kFlutterNativeThreadTypeRender). 2152 | /// 2153 | /// @attention Some callbacks (especially the ones of type 2154 | /// kFlutterNativeThreadTypeWorker) may be called after the 2155 | /// FlutterEngine instance has shut down. Embedders must be careful 2156 | /// in handling the lifecycle of objects associated with the user 2157 | /// data baton. 2158 | /// 2159 | /// @attention In case there are multiple running Flutter engine instances, 2160 | /// their workers are shared. 2161 | /// 2162 | /// @param[in] engine A running engine instance. 2163 | /// @param[in] callback The callback that will get called multiple times on 2164 | /// each engine managed thread. 2165 | /// @param[in] user_data A baton passed by the engine to the callback. This 2166 | /// baton is not interpreted by the engine in any way. 2167 | /// 2168 | /// @return Returns if the callback was successfully posted to all threads. 2169 | /// 2170 | FLUTTER_EXPORT 2171 | FlutterEngineResult FlutterEnginePostCallbackOnAllNativeThreads( 2172 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2173 | FlutterNativeThreadCallback callback, 2174 | void* user_data); 2175 | 2176 | //------------------------------------------------------------------------------ 2177 | /// @brief Posts updates corresponding to display changes to a running engine 2178 | /// instance. 2179 | /// 2180 | /// @param[in] update_type The type of update pushed to the engine. 2181 | /// @param[in] displays The displays affected by this update. 2182 | /// @param[in] display_count Size of the displays array, must be at least 1. 2183 | /// 2184 | /// @return the result of the call made to the engine. 2185 | /// 2186 | FLUTTER_EXPORT 2187 | FlutterEngineResult FlutterEngineNotifyDisplayUpdate( 2188 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2189 | FlutterEngineDisplaysUpdateType update_type, 2190 | const FlutterEngineDisplay* displays, 2191 | size_t display_count); 2192 | 2193 | #endif // !FLUTTER_ENGINE_NO_PROTOTYPES 2194 | 2195 | // Typedefs for the function pointers in FlutterEngineProcTable. 2196 | typedef FlutterEngineResult (*FlutterEngineCreateAOTDataFnPtr)( 2197 | const FlutterEngineAOTDataSource* source, 2198 | FlutterEngineAOTData* data_out); 2199 | typedef FlutterEngineResult (*FlutterEngineCollectAOTDataFnPtr)( 2200 | FlutterEngineAOTData data); 2201 | typedef FlutterEngineResult (*FlutterEngineRunFnPtr)( 2202 | size_t version, 2203 | const FlutterRendererConfig* config, 2204 | const FlutterProjectArgs* args, 2205 | void* user_data, 2206 | FLUTTER_API_SYMBOL(FlutterEngine) * engine_out); 2207 | typedef FlutterEngineResult (*FlutterEngineShutdownFnPtr)( 2208 | FLUTTER_API_SYMBOL(FlutterEngine) engine); 2209 | typedef FlutterEngineResult (*FlutterEngineInitializeFnPtr)( 2210 | size_t version, 2211 | const FlutterRendererConfig* config, 2212 | const FlutterProjectArgs* args, 2213 | void* user_data, 2214 | FLUTTER_API_SYMBOL(FlutterEngine) * engine_out); 2215 | typedef FlutterEngineResult (*FlutterEngineDeinitializeFnPtr)( 2216 | FLUTTER_API_SYMBOL(FlutterEngine) engine); 2217 | typedef FlutterEngineResult (*FlutterEngineRunInitializedFnPtr)( 2218 | FLUTTER_API_SYMBOL(FlutterEngine) engine); 2219 | typedef FlutterEngineResult (*FlutterEngineSendWindowMetricsEventFnPtr)( 2220 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2221 | const FlutterWindowMetricsEvent* event); 2222 | typedef FlutterEngineResult (*FlutterEngineSendPointerEventFnPtr)( 2223 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2224 | const FlutterPointerEvent* events, 2225 | size_t events_count); 2226 | typedef FlutterEngineResult (*FlutterEngineSendKeyEventFnPtr)( 2227 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2228 | const FlutterKeyEvent* event, 2229 | FlutterKeyEventCallback callback, 2230 | void* user_data); 2231 | typedef FlutterEngineResult (*FlutterEngineSendPlatformMessageFnPtr)( 2232 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2233 | const FlutterPlatformMessage* message); 2234 | typedef FlutterEngineResult ( 2235 | *FlutterEnginePlatformMessageCreateResponseHandleFnPtr)( 2236 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2237 | FlutterDataCallback data_callback, 2238 | void* user_data, 2239 | FlutterPlatformMessageResponseHandle** response_out); 2240 | typedef FlutterEngineResult ( 2241 | *FlutterEnginePlatformMessageReleaseResponseHandleFnPtr)( 2242 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2243 | FlutterPlatformMessageResponseHandle* response); 2244 | typedef FlutterEngineResult (*FlutterEngineSendPlatformMessageResponseFnPtr)( 2245 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2246 | const FlutterPlatformMessageResponseHandle* handle, 2247 | const uint8_t* data, 2248 | size_t data_length); 2249 | typedef FlutterEngineResult (*FlutterEngineRegisterExternalTextureFnPtr)( 2250 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2251 | int64_t texture_identifier); 2252 | typedef FlutterEngineResult (*FlutterEngineUnregisterExternalTextureFnPtr)( 2253 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2254 | int64_t texture_identifier); 2255 | typedef FlutterEngineResult ( 2256 | *FlutterEngineMarkExternalTextureFrameAvailableFnPtr)( 2257 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2258 | int64_t texture_identifier); 2259 | typedef FlutterEngineResult (*FlutterEngineUpdateSemanticsEnabledFnPtr)( 2260 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2261 | bool enabled); 2262 | typedef FlutterEngineResult (*FlutterEngineUpdateAccessibilityFeaturesFnPtr)( 2263 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2264 | FlutterAccessibilityFeature features); 2265 | typedef FlutterEngineResult (*FlutterEngineDispatchSemanticsActionFnPtr)( 2266 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2267 | uint64_t id, 2268 | FlutterSemanticsAction action, 2269 | const uint8_t* data, 2270 | size_t data_length); 2271 | typedef FlutterEngineResult (*FlutterEngineOnVsyncFnPtr)( 2272 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2273 | intptr_t baton, 2274 | uint64_t frame_start_time_nanos, 2275 | uint64_t frame_target_time_nanos); 2276 | typedef FlutterEngineResult (*FlutterEngineReloadSystemFontsFnPtr)( 2277 | FLUTTER_API_SYMBOL(FlutterEngine) engine); 2278 | typedef void (*FlutterEngineTraceEventDurationBeginFnPtr)(const char* name); 2279 | typedef void (*FlutterEngineTraceEventDurationEndFnPtr)(const char* name); 2280 | typedef void (*FlutterEngineTraceEventInstantFnPtr)(const char* name); 2281 | typedef FlutterEngineResult (*FlutterEnginePostRenderThreadTaskFnPtr)( 2282 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2283 | VoidCallback callback, 2284 | void* callback_data); 2285 | typedef uint64_t (*FlutterEngineGetCurrentTimeFnPtr)(); 2286 | typedef FlutterEngineResult (*FlutterEngineRunTaskFnPtr)( 2287 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2288 | const FlutterTask* task); 2289 | typedef FlutterEngineResult (*FlutterEngineUpdateLocalesFnPtr)( 2290 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2291 | const FlutterLocale** locales, 2292 | size_t locales_count); 2293 | typedef bool (*FlutterEngineRunsAOTCompiledDartCodeFnPtr)(void); 2294 | typedef FlutterEngineResult (*FlutterEnginePostDartObjectFnPtr)( 2295 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2296 | FlutterEngineDartPort port, 2297 | const FlutterEngineDartObject* object); 2298 | typedef FlutterEngineResult (*FlutterEngineNotifyLowMemoryWarningFnPtr)( 2299 | FLUTTER_API_SYMBOL(FlutterEngine) engine); 2300 | typedef FlutterEngineResult (*FlutterEnginePostCallbackOnAllNativeThreadsFnPtr)( 2301 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2302 | FlutterNativeThreadCallback callback, 2303 | void* user_data); 2304 | typedef FlutterEngineResult (*FlutterEngineNotifyDisplayUpdateFnPtr)( 2305 | FLUTTER_API_SYMBOL(FlutterEngine) engine, 2306 | FlutterEngineDisplaysUpdateType update_type, 2307 | const FlutterEngineDisplay* displays, 2308 | size_t display_count); 2309 | 2310 | /// Function-pointer-based versions of the APIs above. 2311 | typedef struct { 2312 | /// The size of this struct. Must be sizeof(FlutterEngineProcs). 2313 | size_t struct_size; 2314 | 2315 | FlutterEngineCreateAOTDataFnPtr CreateAOTData; 2316 | FlutterEngineCollectAOTDataFnPtr CollectAOTData; 2317 | FlutterEngineRunFnPtr Run; 2318 | FlutterEngineShutdownFnPtr Shutdown; 2319 | FlutterEngineInitializeFnPtr Initialize; 2320 | FlutterEngineDeinitializeFnPtr Deinitialize; 2321 | FlutterEngineRunInitializedFnPtr RunInitialized; 2322 | FlutterEngineSendWindowMetricsEventFnPtr SendWindowMetricsEvent; 2323 | FlutterEngineSendPointerEventFnPtr SendPointerEvent; 2324 | FlutterEngineSendKeyEventFnPtr SendKeyEvent; 2325 | FlutterEngineSendPlatformMessageFnPtr SendPlatformMessage; 2326 | FlutterEnginePlatformMessageCreateResponseHandleFnPtr 2327 | PlatformMessageCreateResponseHandle; 2328 | FlutterEnginePlatformMessageReleaseResponseHandleFnPtr 2329 | PlatformMessageReleaseResponseHandle; 2330 | FlutterEngineSendPlatformMessageResponseFnPtr SendPlatformMessageResponse; 2331 | FlutterEngineRegisterExternalTextureFnPtr RegisterExternalTexture; 2332 | FlutterEngineUnregisterExternalTextureFnPtr UnregisterExternalTexture; 2333 | FlutterEngineMarkExternalTextureFrameAvailableFnPtr 2334 | MarkExternalTextureFrameAvailable; 2335 | FlutterEngineUpdateSemanticsEnabledFnPtr UpdateSemanticsEnabled; 2336 | FlutterEngineUpdateAccessibilityFeaturesFnPtr UpdateAccessibilityFeatures; 2337 | FlutterEngineDispatchSemanticsActionFnPtr DispatchSemanticsAction; 2338 | FlutterEngineOnVsyncFnPtr OnVsync; 2339 | FlutterEngineReloadSystemFontsFnPtr ReloadSystemFonts; 2340 | FlutterEngineTraceEventDurationBeginFnPtr TraceEventDurationBegin; 2341 | FlutterEngineTraceEventDurationEndFnPtr TraceEventDurationEnd; 2342 | FlutterEngineTraceEventInstantFnPtr TraceEventInstant; 2343 | FlutterEnginePostRenderThreadTaskFnPtr PostRenderThreadTask; 2344 | FlutterEngineGetCurrentTimeFnPtr GetCurrentTime; 2345 | FlutterEngineRunTaskFnPtr RunTask; 2346 | FlutterEngineUpdateLocalesFnPtr UpdateLocales; 2347 | FlutterEngineRunsAOTCompiledDartCodeFnPtr RunsAOTCompiledDartCode; 2348 | FlutterEnginePostDartObjectFnPtr PostDartObject; 2349 | FlutterEngineNotifyLowMemoryWarningFnPtr NotifyLowMemoryWarning; 2350 | FlutterEnginePostCallbackOnAllNativeThreadsFnPtr 2351 | PostCallbackOnAllNativeThreads; 2352 | FlutterEngineNotifyDisplayUpdateFnPtr NotifyDisplayUpdate; 2353 | } FlutterEngineProcTable; 2354 | 2355 | //------------------------------------------------------------------------------ 2356 | /// @brief Gets the table of engine function pointers. 2357 | /// 2358 | /// @param[out] table The table to fill with pointers. This should be 2359 | /// zero-initialized, except for struct_size. 2360 | /// 2361 | /// @return Returns whether the table was successfully populated. 2362 | /// 2363 | FLUTTER_EXPORT 2364 | FlutterEngineResult FlutterEngineGetProcAddresses( 2365 | FlutterEngineProcTable* table); 2366 | 2367 | #if defined(__cplusplus) 2368 | } // extern "C" 2369 | #endif 2370 | 2371 | #endif // FLUTTER_EMBEDDER_H_ -------------------------------------------------------------------------------- /src/flutter_hadk.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "common.h" 6 | #include "flutter_hadk.h" 7 | #include 8 | 9 | FlutterHadk::FlutterHadk(FlutterHadkDisplay* display,FlutterEngineLib* lib,FlutterAppArgs* args) 10 | : display_info_(display) 11 | , engine_lib_(lib) 12 | , app_args_(args) 13 | , main_thread_id_(std::this_thread::get_id()) { 14 | } 15 | 16 | FlutterHadk::~FlutterHadk() { 17 | 18 | } 19 | 20 | void FlutterHadk::init() { 21 | if(!initEGL(display_info_->window)) { 22 | LOGE("InitializeEGL failed."); 23 | return; 24 | } 25 | 26 | if(!initApplication()) { 27 | LOGE("initApplication failed."); 28 | return; 29 | } 30 | valid_ = true; 31 | } 32 | 33 | void FlutterHadk::run() { 34 | 35 | } 36 | 37 | void FlutterHadk::cleanup() { 38 | 39 | } 40 | 41 | void FlutterHadk::postTaskCallback(FlutterTask task, uint64_t target_time) { 42 | TaskRunner.push(std::make_pair(target_time, task)); 43 | } 44 | 45 | bool FlutterHadk::initApplication() { 46 | // configure flutter rendering 47 | FlutterRendererConfig config = {}; 48 | config.type = kOpenGL; 49 | config.open_gl.struct_size = sizeof(config.open_gl); 50 | config.open_gl.make_current = [](void* context) -> bool { 51 | return reinterpret_cast(context)->GLMakeCurrent(); 52 | }; 53 | config.open_gl.clear_current = [](void* context) -> bool { 54 | return reinterpret_cast(context)->GLClearCurrent(); 55 | }; 56 | config.open_gl.present = [](void* context) -> bool { 57 | return reinterpret_cast(context)->GLPresent(); 58 | }; 59 | config.open_gl.fbo_callback = [](void* context) -> uint32_t { 60 | return reinterpret_cast(context)->GLFboCallback(); 61 | }; 62 | config.open_gl.make_resource_current = [](void* context) -> bool { 63 | return reinterpret_cast(context)->GLMakeResourceCurrent(); 64 | }; 65 | config.open_gl.gl_proc_resolver = [](void* context, 66 | const char* name) -> void* { 67 | auto address = eglGetProcAddress(name); 68 | if (address != nullptr) { 69 | return reinterpret_cast(address); 70 | } 71 | LOGE("Tried unsuccessfully to resolve"); 72 | return nullptr; 73 | }; 74 | 75 | FlutterProjectArgs args = { 0 }; 76 | args.struct_size = sizeof(FlutterProjectArgs); 77 | args.assets_path = app_args_->asset_bundle_path; 78 | args.icu_data_path = app_args_->icu_data_path; 79 | args.command_line_argc = app_args_->engine_argc; 80 | args.command_line_argv = (const char * const*) app_args_->engine_argv; 81 | args.shutdown_dart_vm_when_done = true; 82 | 83 | // Configure task runner interop 84 | FlutterTaskRunnerDescription platform_task_runner = {}; 85 | platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription); 86 | platform_task_runner.user_data = this; 87 | platform_task_runner.runs_task_on_current_thread_callback = 88 | [](void* context) -> bool { 89 | return reinterpret_cast(context)->mainThreadID() == std::this_thread::get_id(); 90 | }; 91 | platform_task_runner.post_task_callback = 92 | [](FlutterTask task, uint64_t target_time, void* context) -> void { 93 | reinterpret_cast(context)->postTaskCallback(task, 94 | target_time); 95 | }; 96 | 97 | FlutterCustomTaskRunners custom_task_runners = {}; 98 | custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners); 99 | custom_task_runners.platform_task_runner = &platform_task_runner; 100 | args.custom_task_runners = &custom_task_runners; 101 | 102 | // check flutter runtime mode. 103 | bool engine_is_aot = engine_lib_->FlutterEngineRunsAOTCompiledDartCode(); 104 | if ((engine_is_aot == true) && app_args_->runtime_mode != kRelease) { 105 | LOGE("flutter engine is release, but app runtime_mode is kDebug, quit"); 106 | return false; 107 | } else if ((engine_is_aot == false) && app_args_->runtime_mode != kDebug) { 108 | LOGE("flutter engine is debug, but app runtime_mode is kRelease, quit"); 109 | return false; 110 | } 111 | 112 | FlutterEngineResult engine_result; 113 | FlutterEngineAOTDataSource aot_source; 114 | FlutterEngineAOTData aot_data; 115 | if(app_args_->runtime_mode == kRelease) { 116 | aot_source.elf_path = app_args_->app_elf_path; 117 | aot_source.type = kFlutterEngineAOTDataSourceTypeElfPath; 118 | 119 | engine_result = engine_lib_->FlutterEngineCreateAOTData(&aot_source, &aot_data); 120 | if (engine_result != kSuccess) { 121 | LOGE("Could not load AOT data. FlutterEngineCreateAOTData: %d",engine_result); 122 | return false; 123 | } 124 | 125 | args.aot_data = aot_data; 126 | } 127 | 128 | engine_result = engine_lib_->FlutterEngineRun(FLUTTER_ENGINE_VERSION, &config, &args, NULL, &engine_); 129 | if (engine_result != kSuccess) { 130 | LOGE( "Could not run the flutter engine. FlutterEngineRun: %d", engine_result); 131 | return false; 132 | } 133 | 134 | FlutterWindowMetricsEvent event = {}; 135 | event.struct_size = sizeof(event); 136 | event.width = display_info_->width; 137 | event.height = display_info_->height; 138 | event.pixel_ratio = display_info_->scale; 139 | engine_result = engine_lib_->FlutterEngineSendWindowMetricsEvent(engine_, &event); 140 | if (engine_result != kSuccess) { 141 | LOGE("Could not send window metrics to flutter engine."); 142 | return false; 143 | } 144 | 145 | return true; 146 | } 147 | 148 | bool FlutterHadk::initEGL(void* window) { 149 | // 1.Get the display. 150 | egl_display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY); 151 | if (egl_display_ == EGL_NO_DISPLAY) { 152 | LOGE("InitializeEGL failed phase 1"); 153 | return false; 154 | } 155 | 156 | // 2.Initialize the display connection. 157 | if (eglInitialize(egl_display_, nullptr, nullptr) != EGL_TRUE) { 158 | LOGE("InitializeEGL failed phase 2"); 159 | return false; 160 | } 161 | 162 | // 3.Choose egl configuration 163 | EGLint config_attributes[] = { 164 | // clang-format off 165 | EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 166 | EGL_SURFACE_TYPE, EGL_WINDOW_BIT, 167 | EGL_RED_SIZE, 8, 168 | EGL_GREEN_SIZE, 8, 169 | EGL_BLUE_SIZE, 8, 170 | EGL_ALPHA_SIZE, 8, 171 | EGL_DEPTH_SIZE, 0, 172 | EGL_STENCIL_SIZE, 0, 173 | EGL_NONE, // termination sentinel 174 | // clang-format on 175 | }; 176 | 177 | EGLint config_count = 0; 178 | 179 | if (eglChooseConfig(egl_display_, config_attributes, &egl_config_, 1, &config_count) != 180 | EGL_TRUE || !(config_count > 0 && egl_config_ != nullptr)) { 181 | LOGE("InitializeEGL failed phase 3"); 182 | return false; 183 | } 184 | 185 | 186 | // 4. create egl resource context 187 | EGLint context_attributes[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; 188 | egl_resource_context_ = eglCreateContext( 189 | egl_display_, egl_config_, EGL_NO_CONTEXT, context_attributes); 190 | 191 | if (egl_resource_context_ == EGL_NO_CONTEXT) { 192 | LOGE("InitializeEGL failed phase 4"); 193 | return false; 194 | } 195 | 196 | egl_context_ = eglCreateContext(egl_display_, egl_config_, egl_resource_context_, 197 | context_attributes); 198 | if (egl_context_ == EGL_NO_CONTEXT) { 199 | LOGE("InitializeEGL failed phase 5"); 200 | return false; 201 | } 202 | 203 | // 5. create egl window surface 204 | const EGLint surfaceAttributes[] = {EGL_NONE}; 205 | 206 | egl_window_surface_ = eglCreateWindowSurface(egl_display_, egl_config_, 207 | static_cast(window), 208 | surfaceAttributes); 209 | if (egl_window_surface_ == EGL_NO_SURFACE) { 210 | LOGE("InitializeEGL failed phase 6"); 211 | return false; 212 | } 213 | 214 | // 6. create egl resource pbuffer surface 215 | const EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE}; 216 | egl_resource_surface_ = eglCreatePbufferSurface(egl_display_, egl_config_, attribs); 217 | return egl_resource_surface_ != EGL_NO_SURFACE; 218 | } 219 | 220 | bool FlutterHadk::cleanupEGL(){ 221 | EGLBoolean result = EGL_FALSE; 222 | 223 | // 1. destroy egl window surface 224 | if (egl_display_ != EGL_NO_DISPLAY && egl_window_surface_ != EGL_NO_SURFACE) { 225 | result = eglDestroySurface(egl_display_, egl_window_surface_); 226 | egl_window_surface_ = EGL_NO_SURFACE; 227 | 228 | if (result == EGL_FALSE) { 229 | LOGE("cleanupEGL failed phase 1"); 230 | return false; 231 | } 232 | } 233 | 234 | // 2. destory egl context 235 | if (egl_display_ != EGL_NO_DISPLAY && egl_context_ != EGL_NO_CONTEXT) { 236 | result = eglDestroyContext(egl_display_, egl_context_); 237 | egl_context_ = EGL_NO_CONTEXT; 238 | 239 | if (result == EGL_FALSE) { 240 | LOGE("cleanupEGL failed phase 2"); 241 | return false; 242 | } 243 | } 244 | 245 | // 3. destroy egl resource pbuffer surface 246 | if (egl_display_ != EGL_NO_DISPLAY && egl_resource_surface_ != EGL_NO_SURFACE) { 247 | result = eglDestroySurface(egl_display_, egl_resource_surface_); 248 | egl_resource_surface_ = EGL_NO_SURFACE; 249 | 250 | if (result == EGL_FALSE) { 251 | LOGE("cleanupEGL failed phase 3"); 252 | return false; 253 | } 254 | } 255 | 256 | // 4. destroy egl resource context 257 | if (egl_display_ != EGL_NO_DISPLAY && 258 | egl_resource_context_ != EGL_NO_CONTEXT) { 259 | result = eglDestroyContext(egl_display_, egl_resource_context_); 260 | egl_resource_context_ = EGL_NO_CONTEXT; 261 | 262 | if (result == EGL_FALSE) { 263 | LOGE("cleanupEGL failed phase 4"); 264 | return false; 265 | } 266 | } 267 | 268 | if (egl_display_ != EGL_NO_DISPLAY) { 269 | eglTerminate(egl_display_); 270 | egl_display_ = EGL_NO_DISPLAY; 271 | } 272 | 273 | return true; 274 | } 275 | 276 | 277 | bool FlutterHadk::GLMakeCurrent() { 278 | if (!valid_) { 279 | return false; 280 | } 281 | 282 | return (eglMakeCurrent(egl_display_, egl_window_surface_, egl_window_surface_, egl_context_) == 283 | EGL_TRUE); 284 | } 285 | 286 | bool FlutterHadk::GLClearCurrent() { 287 | if (!valid_) { 288 | return false; 289 | } 290 | 291 | return (eglMakeCurrent(egl_display_, EGL_NO_SURFACE, EGL_NO_SURFACE, 292 | EGL_NO_CONTEXT) == EGL_TRUE); 293 | } 294 | 295 | bool FlutterHadk::GLPresent() { 296 | if (!valid_) { 297 | return false; 298 | } 299 | 300 | return (eglSwapBuffers(egl_display_, egl_window_surface_) == EGL_TRUE); 301 | } 302 | 303 | uint32_t FlutterHadk::GLFboCallback() { 304 | if (!valid_) { 305 | return -1; 306 | } 307 | 308 | return 0; // FBO0 309 | } 310 | 311 | bool FlutterHadk::GLMakeResourceCurrent() { 312 | if (!valid_) { 313 | return false; 314 | } 315 | 316 | return (eglMakeCurrent(egl_display_, egl_resource_surface_, egl_resource_surface_, 317 | egl_resource_context_) == EGL_TRUE); 318 | } 319 | 320 | 321 | -------------------------------------------------------------------------------- /src/flutter_hadk.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_HADK_H_ 6 | #define FLUTTER_HADK_H_ 7 | 8 | #include "common.h" 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | class FlutterHadk 17 | { 18 | public: 19 | FlutterHadk(FlutterHadkDisplay* ,FlutterEngineLib* lib,FlutterAppArgs* args); 20 | ~FlutterHadk(); 21 | 22 | void init(); 23 | void run(); 24 | void cleanup(); 25 | 26 | std::thread::id mainThreadID() { return main_thread_id_; } 27 | 28 | private: 29 | EGLDisplay egl_display_ = EGL_NO_DISPLAY; 30 | EGLContext egl_context_ = EGL_NO_CONTEXT; 31 | EGLSurface egl_window_surface_ = EGL_NO_SURFACE; 32 | EGLContext egl_resource_context_ = EGL_NO_CONTEXT; 33 | EGLSurface egl_resource_surface_= EGL_NO_SURFACE; 34 | EGLConfig egl_config_; 35 | 36 | FlutterHadkDisplay* display_info_ = nullptr; 37 | FlutterEngineLib* engine_lib_ = nullptr; 38 | FlutterAppArgs* app_args_ = nullptr; 39 | FlutterEngine engine_ = nullptr; 40 | 41 | bool valid_ = false; 42 | std::thread::id main_thread_id_; 43 | 44 | bool initEGL(void* window); 45 | bool cleanupEGL(); 46 | 47 | bool initApplication(); 48 | 49 | bool GLMakeCurrent(); 50 | bool GLClearCurrent(); 51 | bool GLPresent(); 52 | uint32_t GLFboCallback(); 53 | bool GLMakeResourceCurrent(); 54 | 55 | class CompareFlutterTask { 56 | public: 57 | bool operator()(std::pair n1, 58 | std::pair n2) { 59 | return n1.first > n2.first; 60 | } 61 | }; 62 | std::priority_queue, 63 | std::vector>, 64 | CompareFlutterTask> TaskRunner; 65 | 66 | void postTaskCallback(FlutterTask task, uint64_t target_time); 67 | 68 | }; 69 | 70 | #endif -------------------------------------------------------------------------------- /src/hadk/binding/binding.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Canonical Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * Authored by: Michael Frey 17 | * Ricardo Salveti de Araujo 18 | */ 19 | #include "binding.h" 20 | #include "../include/hadk/native_window.h" 21 | #include "../include/hadk/input.h" 22 | 23 | #define HADK_LIBRARY_PATH "libhadk.so" 24 | HADK_LIBRARY_INITIALIZE(hadk, HADK_LIBRARY_PATH) 25 | 26 | /** 27 | ********************************************************************** 28 | * native_window.h 29 | ********************************************************************** 30 | */ 31 | 32 | /** 33 | * HDisplayInfo* 34 | * Hadk_GetDisplayInfo(); 35 | */ 36 | HADK_IMPLEMENT_FUNCTION0( hadk, 37 | HDisplayInfo*, 38 | Hadk_GetDisplayInfo ) 39 | 40 | /** 41 | * void 42 | * Hadk_ReleaseDisplayInfo(HDisplayInfo* info); 43 | */ 44 | HADK_IMPLEMENT_VOID_FUNCTION1( hadk, 45 | Hadk_ReleaseDisplayInfo, 46 | HDisplayInfo* ) 47 | 48 | /** 49 | * uint32_t 50 | * HDisplayInfo_getWidth(HDisplayInfo* info); 51 | */ 52 | HADK_IMPLEMENT_FUNCTION1( hadk, 53 | uint32_t, 54 | HDisplayInfo_getWidth, 55 | HDisplayInfo* ) 56 | 57 | /** 58 | * uint32_t 59 | * HDisplayInfo_getHeight(HDisplayInfo* info); 60 | */ 61 | HADK_IMPLEMENT_FUNCTION1( hadk, 62 | uint32_t, 63 | HDisplayInfo_getHeight, 64 | HDisplayInfo* ) 65 | 66 | /** 67 | * float 68 | * HDisplayInfo_getDensity(HDisplayInfo* info); 69 | */ 70 | HADK_IMPLEMENT_FUNCTION1( hadk, 71 | float, 72 | HDisplayInfo_getDensity, 73 | HDisplayInfo* ) 74 | 75 | /** 76 | ************************************************************* 77 | * NativeSurface API 78 | ************************************************************* 79 | */ 80 | 81 | /** 82 | * HNativeSurface* 83 | * Hadk_CreateNativeSurface(const char* name ,uint32_t width,uint32_t height); 84 | */ 85 | HADK_IMPLEMENT_FUNCTION3( hadk, 86 | HNativeSurface*, 87 | Hadk_CreateNativeSurface, 88 | const char*,uint32_t,uint32_t ) 89 | 90 | /** 91 | * void* 92 | * HNativeWindow_fromSurface(HNativeSurface* surface); 93 | */ 94 | HADK_IMPLEMENT_FUNCTION1( hadk, 95 | void*, 96 | HNativeWindow_fromSurface, 97 | HNativeSurface* ) 98 | 99 | /** 100 | * void 101 | * Hadk_ReleaseNativeSurface(HNativeSurface* dispatcher); 102 | */ 103 | HADK_IMPLEMENT_VOID_FUNCTION1( hadk, 104 | Hadk_ReleaseNativeSurface, 105 | HNativeSurface* ) 106 | 107 | /** 108 | ********************************************************************** 109 | * input.h 110 | ********************************************************************** 111 | */ 112 | 113 | /** 114 | * HInputDispatcher* 115 | * Hadk_CreateInputDispatcher(int32_t w,int32_t h,void* user_data,OnInputEvent callback); 116 | */ 117 | HADK_IMPLEMENT_FUNCTION4( hadk, 118 | HInputDispatcher*, 119 | Hadk_CreateInputDispatcher, 120 | int32_t,int32_t,void*,OnInputEvent ) 121 | /** 122 | * bool 123 | * HInputDispatcher_PumpEvent(HInputDispatcher* dispatcher); 124 | */ 125 | HADK_IMPLEMENT_FUNCTION1( hadk, 126 | bool, 127 | HInputDispatcher_PumpEvent, 128 | HInputDispatcher* ) 129 | 130 | /** 131 | * void 132 | * Hadk_ReleaseInputDispatcher(HInputDispatcher* dispatcher); 133 | */ 134 | HADK_IMPLEMENT_VOID_FUNCTION1( hadk, 135 | Hadk_ReleaseInputDispatcher, 136 | HInputDispatcher* ) -------------------------------------------------------------------------------- /src/hadk/binding/binding.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Copyright (C) 2013 Simon Busch 4 | * 2012 Canonical Ltd 5 | * 2013 Jolla Ltd. 6 | * 7 | * Auto-generated via "generate_wrapper_macros.py" 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | **/ 21 | 22 | #ifndef HADK_BINDING_H_ 23 | #define HADK_BINDING_H_ 24 | 25 | #ifdef __ARM_PCS_VFP 26 | # define FP_ATTRIB __attribute__((pcs("aapcs"))) 27 | #else 28 | # define FP_ATTRIB 29 | #endif 30 | 31 | 32 | #include 33 | 34 | 35 | /** 36 | * XXX AUTO-GENERATED FILE XXX 37 | * 38 | * Do not edit this file directly, but update the templates in 39 | * utils/generate_wrapper_macros.py and run it again to build 40 | * an updated version of this header file: 41 | * 42 | * python utils/generate_wrapper_macros.py > \ 43 | * hybris/include/hybris/internal/binding.h 44 | * 45 | * If you need macros with more arguments, just customize the 46 | * MAX_ARGS variable in generate_wrapper_macros.py. 47 | * 48 | * XXX AUTO-GENERATED FILE XXX 49 | **/ 50 | 51 | 52 | #define HADK_DLSYSM(name, fptr, sym) \ 53 | if (!name##_handle) \ 54 | hybris_##name##_initialize(); \ 55 | if (*(fptr) == NULL) \ 56 | { \ 57 | *((void**)fptr) = (void *)dlsym(name##_handle, sym); \ 58 | } 59 | 60 | #define HADK_LIBRARY_INITIALIZE(name, path) \ 61 | static void *name##_handle = nullptr; \ 62 | void hybris_##name##_initialize() \ 63 | { \ 64 | name##_handle = dlopen(path, RTLD_LAZY); \ 65 | } 66 | 67 | #define HADK_LIRBARY_CHECK_SYMBOL(name) \ 68 | bool hybris_##name##_check_for_symbol(const char *sym) \ 69 | { \ 70 | return dlsym((void*)(name##_handle) sym) != NULL; \ 71 | } 72 | 73 | 74 | 75 | #define HADK_IMPLEMENT_FUNCTION0(name, return_type, symbol) \ 76 | return_type symbol() \ 77 | { \ 78 | static return_type (*f)() FP_ATTRIB = NULL; \ 79 | HADK_DLSYSM(name, &f, #symbol); \ 80 | return f(); \ 81 | } 82 | 83 | 84 | #define HADK_IMPLEMENT_FUNCTION1(name, return_type, symbol, a1) \ 85 | return_type symbol(a1 n1) \ 86 | { \ 87 | static return_type (*f)(a1) FP_ATTRIB = NULL; \ 88 | HADK_DLSYSM(name, &f, #symbol); \ 89 | return f(n1); \ 90 | } 91 | 92 | 93 | #define HADK_IMPLEMENT_FUNCTION2(name, return_type, symbol, a1, a2) \ 94 | return_type symbol(a1 n1, a2 n2) \ 95 | { \ 96 | static return_type (*f)(a1, a2) FP_ATTRIB = NULL; \ 97 | HADK_DLSYSM(name, &f, #symbol); \ 98 | return f(n1, n2); \ 99 | } 100 | 101 | 102 | #define HADK_IMPLEMENT_FUNCTION3(name, return_type, symbol, a1, a2, a3) \ 103 | return_type symbol(a1 n1, a2 n2, a3 n3) \ 104 | { \ 105 | static return_type (*f)(a1, a2, a3) FP_ATTRIB = NULL; \ 106 | HADK_DLSYSM(name, &f, #symbol); \ 107 | return f(n1, n2, n3); \ 108 | } 109 | 110 | 111 | #define HADK_IMPLEMENT_FUNCTION4(name, return_type, symbol, a1, a2, a3, a4) \ 112 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4) \ 113 | { \ 114 | static return_type (*f)(a1, a2, a3, a4) FP_ATTRIB = NULL; \ 115 | HADK_DLSYSM(name, &f, #symbol); \ 116 | return f(n1, n2, n3, n4); \ 117 | } 118 | 119 | 120 | #define HADK_IMPLEMENT_FUNCTION5(name, return_type, symbol, a1, a2, a3, a4, a5) \ 121 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5) \ 122 | { \ 123 | static return_type (*f)(a1, a2, a3, a4, a5) FP_ATTRIB = NULL; \ 124 | HADK_DLSYSM(name, &f, #symbol); \ 125 | return f(n1, n2, n3, n4, n5); \ 126 | } 127 | 128 | 129 | #define HADK_IMPLEMENT_FUNCTION6(name, return_type, symbol, a1, a2, a3, a4, a5, a6) \ 130 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6) \ 131 | { \ 132 | static return_type (*f)(a1, a2, a3, a4, a5, a6) FP_ATTRIB = NULL; \ 133 | HADK_DLSYSM(name, &f, #symbol); \ 134 | return f(n1, n2, n3, n4, n5, n6); \ 135 | } 136 | 137 | 138 | #define HADK_IMPLEMENT_FUNCTION7(name, return_type, symbol, a1, a2, a3, a4, a5, a6, a7) \ 139 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7) \ 140 | { \ 141 | static return_type (*f)(a1, a2, a3, a4, a5, a6, a7) FP_ATTRIB = NULL; \ 142 | HADK_DLSYSM(name, &f, #symbol); \ 143 | return f(n1, n2, n3, n4, n5, n6, n7); \ 144 | } 145 | 146 | 147 | #define HADK_IMPLEMENT_FUNCTION8(name, return_type, symbol, a1, a2, a3, a4, a5, a6, a7, a8) \ 148 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8) \ 149 | { \ 150 | static return_type (*f)(a1, a2, a3, a4, a5, a6, a7, a8) FP_ATTRIB = NULL; \ 151 | HADK_DLSYSM(name, &f, #symbol); \ 152 | return f(n1, n2, n3, n4, n5, n6, n7, n8); \ 153 | } 154 | 155 | 156 | #define HADK_IMPLEMENT_FUNCTION9(name, return_type, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9) \ 157 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9) \ 158 | { \ 159 | static return_type (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9) FP_ATTRIB = NULL; \ 160 | HADK_DLSYSM(name, &f, #symbol); \ 161 | return f(n1, n2, n3, n4, n5, n6, n7, n8, n9); \ 162 | } 163 | 164 | 165 | #define HADK_IMPLEMENT_FUNCTION10(name, return_type, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \ 166 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10) \ 167 | { \ 168 | static return_type (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) FP_ATTRIB = NULL; \ 169 | HADK_DLSYSM(name, &f, #symbol); \ 170 | return f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10); \ 171 | } 172 | 173 | 174 | #define HADK_IMPLEMENT_FUNCTION11(name, return_type, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) \ 175 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11) \ 176 | { \ 177 | static return_type (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) FP_ATTRIB = NULL; \ 178 | HADK_DLSYSM(name, &f, #symbol); \ 179 | return f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11); \ 180 | } 181 | 182 | 183 | #define HADK_IMPLEMENT_FUNCTION12(name, return_type, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) \ 184 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12) \ 185 | { \ 186 | static return_type (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) FP_ATTRIB = NULL; \ 187 | HADK_DLSYSM(name, &f, #symbol); \ 188 | return f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12); \ 189 | } 190 | 191 | 192 | #define HADK_IMPLEMENT_FUNCTION13(name, return_type, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) \ 193 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12, a13 n13) \ 194 | { \ 195 | static return_type (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) FP_ATTRIB = NULL; \ 196 | HADK_DLSYSM(name, &f, #symbol); \ 197 | return f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13); \ 198 | } 199 | 200 | 201 | #define HADK_IMPLEMENT_FUNCTION14(name, return_type, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) \ 202 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12, a13 n13, a14 n14) \ 203 | { \ 204 | static return_type (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) FP_ATTRIB = NULL; \ 205 | HADK_DLSYSM(name, &f, #symbol); \ 206 | return f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14); \ 207 | } 208 | 209 | 210 | #define HADK_IMPLEMENT_FUNCTION15(name, return_type, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) \ 211 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12, a13 n13, a14 n14, a15 n15) \ 212 | { \ 213 | static return_type (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) FP_ATTRIB = NULL; \ 214 | HADK_DLSYSM(name, &f, #symbol); \ 215 | return f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15); \ 216 | } 217 | 218 | 219 | #define HADK_IMPLEMENT_FUNCTION16(name, return_type, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) \ 220 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12, a13 n13, a14 n14, a15 n15, a16 n16) \ 221 | { \ 222 | static return_type (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) FP_ATTRIB = NULL; \ 223 | HADK_DLSYSM(name, &f, #symbol); \ 224 | return f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16); \ 225 | } 226 | 227 | 228 | #define HADK_IMPLEMENT_FUNCTION17(name, return_type, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) \ 229 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12, a13 n13, a14 n14, a15 n15, a16 n16, a17 n17) \ 230 | { \ 231 | static return_type (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) FP_ATTRIB = NULL; \ 232 | HADK_DLSYSM(name, &f, #symbol); \ 233 | return f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17); \ 234 | } 235 | 236 | 237 | #define HADK_IMPLEMENT_FUNCTION18(name, return_type, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) \ 238 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12, a13 n13, a14 n14, a15 n15, a16 n16, a17 n17, a18 n18) \ 239 | { \ 240 | static return_type (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) FP_ATTRIB = NULL; \ 241 | HADK_DLSYSM(name, &f, #symbol); \ 242 | return f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18); \ 243 | } 244 | 245 | 246 | #define HADK_IMPLEMENT_FUNCTION19(name, return_type, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) \ 247 | return_type symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12, a13 n13, a14 n14, a15 n15, a16 n16, a17 n17, a18 n18, a19 n19) \ 248 | { \ 249 | static return_type (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) FP_ATTRIB = NULL; \ 250 | HADK_DLSYSM(name, &f, #symbol); \ 251 | return f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19); \ 252 | } 253 | 254 | 255 | #define HADK_IMPLEMENT_VOID_FUNCTION0(name, symbol) \ 256 | void symbol() \ 257 | { \ 258 | static void (*f)() FP_ATTRIB = NULL; \ 259 | HADK_DLSYSM(name, &f, #symbol); \ 260 | f(); \ 261 | } 262 | 263 | 264 | #define HADK_IMPLEMENT_VOID_FUNCTION1(name, symbol, a1) \ 265 | void symbol(a1 n1) \ 266 | { \ 267 | static void (*f)(a1) FP_ATTRIB = NULL; \ 268 | HADK_DLSYSM(name, &f, #symbol); \ 269 | f(n1); \ 270 | } 271 | 272 | 273 | #define HADK_IMPLEMENT_VOID_FUNCTION2(name, symbol, a1, a2) \ 274 | void symbol(a1 n1, a2 n2) \ 275 | { \ 276 | static void (*f)(a1, a2) FP_ATTRIB = NULL; \ 277 | HADK_DLSYSM(name, &f, #symbol); \ 278 | f(n1, n2); \ 279 | } 280 | 281 | 282 | #define HADK_IMPLEMENT_VOID_FUNCTION3(name, symbol, a1, a2, a3) \ 283 | void symbol(a1 n1, a2 n2, a3 n3) \ 284 | { \ 285 | static void (*f)(a1, a2, a3) FP_ATTRIB = NULL; \ 286 | HADK_DLSYSM(name, &f, #symbol); \ 287 | f(n1, n2, n3); \ 288 | } 289 | 290 | 291 | #define HADK_IMPLEMENT_VOID_FUNCTION4(name, symbol, a1, a2, a3, a4) \ 292 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4) \ 293 | { \ 294 | static void (*f)(a1, a2, a3, a4) FP_ATTRIB = NULL; \ 295 | HADK_DLSYSM(name, &f, #symbol); \ 296 | f(n1, n2, n3, n4); \ 297 | } 298 | 299 | 300 | #define HADK_IMPLEMENT_VOID_FUNCTION5(name, symbol, a1, a2, a3, a4, a5) \ 301 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5) \ 302 | { \ 303 | static void (*f)(a1, a2, a3, a4, a5) FP_ATTRIB = NULL; \ 304 | HADK_DLSYSM(name, &f, #symbol); \ 305 | f(n1, n2, n3, n4, n5); \ 306 | } 307 | 308 | 309 | #define HADK_IMPLEMENT_VOID_FUNCTION6(name, symbol, a1, a2, a3, a4, a5, a6) \ 310 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6) \ 311 | { \ 312 | static void (*f)(a1, a2, a3, a4, a5, a6) FP_ATTRIB = NULL; \ 313 | HADK_DLSYSM(name, &f, #symbol); \ 314 | f(n1, n2, n3, n4, n5, n6); \ 315 | } 316 | 317 | 318 | #define HADK_IMPLEMENT_VOID_FUNCTION7(name, symbol, a1, a2, a3, a4, a5, a6, a7) \ 319 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7) \ 320 | { \ 321 | static void (*f)(a1, a2, a3, a4, a5, a6, a7) FP_ATTRIB = NULL; \ 322 | HADK_DLSYSM(name, &f, #symbol); \ 323 | f(n1, n2, n3, n4, n5, n6, n7); \ 324 | } 325 | 326 | 327 | #define HADK_IMPLEMENT_VOID_FUNCTION8(name, symbol, a1, a2, a3, a4, a5, a6, a7, a8) \ 328 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8) \ 329 | { \ 330 | static void (*f)(a1, a2, a3, a4, a5, a6, a7, a8) FP_ATTRIB = NULL; \ 331 | HADK_DLSYSM(name, &f, #symbol); \ 332 | f(n1, n2, n3, n4, n5, n6, n7, n8); \ 333 | } 334 | 335 | 336 | #define HADK_IMPLEMENT_VOID_FUNCTION9(name, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9) \ 337 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9) \ 338 | { \ 339 | static void (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9) FP_ATTRIB = NULL; \ 340 | HADK_DLSYSM(name, &f, #symbol); \ 341 | f(n1, n2, n3, n4, n5, n6, n7, n8, n9); \ 342 | } 343 | 344 | 345 | #define HADK_IMPLEMENT_VOID_FUNCTION10(name, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \ 346 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10) \ 347 | { \ 348 | static void (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) FP_ATTRIB = NULL; \ 349 | HADK_DLSYSM(name, &f, #symbol); \ 350 | f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10); \ 351 | } 352 | 353 | 354 | #define HADK_IMPLEMENT_VOID_FUNCTION11(name, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) \ 355 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11) \ 356 | { \ 357 | static void (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) FP_ATTRIB = NULL; \ 358 | HADK_DLSYSM(name, &f, #symbol); \ 359 | f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11); \ 360 | } 361 | 362 | 363 | #define HADK_IMPLEMENT_VOID_FUNCTION12(name, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) \ 364 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12) \ 365 | { \ 366 | static void (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) FP_ATTRIB = NULL; \ 367 | HADK_DLSYSM(name, &f, #symbol); \ 368 | f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12); \ 369 | } 370 | 371 | 372 | #define HADK_IMPLEMENT_VOID_FUNCTION13(name, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) \ 373 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12, a13 n13) \ 374 | { \ 375 | static void (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) FP_ATTRIB = NULL; \ 376 | HADK_DLSYSM(name, &f, #symbol); \ 377 | f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13); \ 378 | } 379 | 380 | 381 | #define HADK_IMPLEMENT_VOID_FUNCTION14(name, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) \ 382 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12, a13 n13, a14 n14) \ 383 | { \ 384 | static void (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) FP_ATTRIB = NULL; \ 385 | HADK_DLSYSM(name, &f, #symbol); \ 386 | f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14); \ 387 | } 388 | 389 | 390 | #define HADK_IMPLEMENT_VOID_FUNCTION15(name, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) \ 391 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12, a13 n13, a14 n14, a15 n15) \ 392 | { \ 393 | static void (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) FP_ATTRIB = NULL; \ 394 | HADK_DLSYSM(name, &f, #symbol); \ 395 | f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15); \ 396 | } 397 | 398 | 399 | #define HADK_IMPLEMENT_VOID_FUNCTION16(name, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) \ 400 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12, a13 n13, a14 n14, a15 n15, a16 n16) \ 401 | { \ 402 | static void (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) FP_ATTRIB = NULL; \ 403 | HADK_DLSYSM(name, &f, #symbol); \ 404 | f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16); \ 405 | } 406 | 407 | 408 | #define HADK_IMPLEMENT_VOID_FUNCTION17(name, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) \ 409 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12, a13 n13, a14 n14, a15 n15, a16 n16, a17 n17) \ 410 | { \ 411 | static void (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17) FP_ATTRIB = NULL; \ 412 | HADK_DLSYSM(name, &f, #symbol); \ 413 | f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17); \ 414 | } 415 | 416 | 417 | #define HADK_IMPLEMENT_VOID_FUNCTION18(name, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) \ 418 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12, a13 n13, a14 n14, a15 n15, a16 n16, a17 n17, a18 n18) \ 419 | { \ 420 | static void (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18) FP_ATTRIB = NULL; \ 421 | HADK_DLSYSM(name, &f, #symbol); \ 422 | f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18); \ 423 | } 424 | 425 | 426 | #define HADK_IMPLEMENT_VOID_FUNCTION19(name, symbol, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) \ 427 | void symbol(a1 n1, a2 n2, a3 n3, a4 n4, a5 n5, a6 n6, a7 n7, a8 n8, a9 n9, a10 n10, a11 n11, a12 n12, a13 n13, a14 n14, a15 n15, a16 n16, a17 n17, a18 n18, a19 n19) \ 428 | { \ 429 | static void (*f)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19) FP_ATTRIB = NULL; \ 430 | HADK_DLSYSM(name, &f, #symbol); \ 431 | f(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19); \ 432 | } 433 | 434 | 435 | /** 436 | * XXX AUTO-GENERATED FILE XXX 437 | * 438 | * Do not edit this file directly, but update the templates in 439 | * utils/generate_wrapper_macros.py and run it again to build 440 | * an updated version of this header file: 441 | * 442 | * python utils/generate_wrapper_macros.py > \ 443 | * hybris/include/hybris/internal/binding.h 444 | * 445 | * If you need macros with more arguments, just customize the 446 | * MAX_ARGS variable in generate_wrapper_macros.py. 447 | * 448 | * XXX AUTO-GENERATED FILE XXX 449 | **/ 450 | 451 | 452 | #endif /* HADK_BINDING_H_ */ 453 | 454 | -------------------------------------------------------------------------------- /src/hadk/hadk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Canonical Ltd 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * Authored by: boxuechen 17 | */ 18 | #ifndef HADK_HADK_H_ 19 | #define HADK_HADK_H_ 20 | 21 | #include "include/hadk/native_window.h" 22 | #include "include/hadk/input.h" 23 | 24 | #endif //HADK_HADK_H_ 25 | -------------------------------------------------------------------------------- /src/hadk/include/hadk/input.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @file native_input.h 19 | * @brief API for hadk accessing input event. 20 | */ 21 | 22 | #ifndef HADK_NATIVE_INPUT_H 23 | #define HADK_NATIVE_INPUT_H 24 | 25 | #include 26 | #include 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | /** 33 | ************************************************************* 34 | * NativeInput API 35 | ************************************************************* 36 | */ 37 | 38 | struct HInputDispatcher; 39 | typedef struct HInputDispatcher HInputDispatcher; 40 | 41 | typedef int32_t (*OnInputEvent)(void* user_data, void* event); 42 | 43 | /** 44 | * Create a pointer to intput dispatcher. 45 | */ 46 | HInputDispatcher* Hadk_CreateInputDispatcher(int32_t w,int32_t h,void* user_data,OnInputEvent callback); 47 | 48 | /** 49 | * Pump input queue to get input event pointer. 50 | */ 51 | bool HInputDispatcher_PumpEvent(HInputDispatcher* dispatcher); 52 | 53 | /** 54 | * Release a pointer to input queue. 55 | */ 56 | void Hadk_ReleaseInputDispatcher(HInputDispatcher* dispatcher); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif // HADK_NATIVE_INPUT_H -------------------------------------------------------------------------------- /src/hadk/include/hadk/native_window.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @file native_window.h 19 | * @brief API for hadk accessing a display/surface/window. 20 | */ 21 | 22 | #ifndef HADK_NATIVE_WINDOW_H 23 | #define HADK_NATIVE_WINDOW_H 24 | 25 | #include 26 | #include 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | /** 33 | ************************************************************* 34 | * DisplayInfo API 35 | ************************************************************* 36 | */ 37 | 38 | struct HDisplayInfo; 39 | /** 40 | * Opaque type that provides access to a display info. 41 | * 42 | * A pointer can be obtained using {@link Hadk_GetDisplayInfo()}. 43 | */ 44 | typedef struct HDisplayInfo HDisplayInfo; 45 | 46 | /** 47 | * Get a pointer to display info. 48 | */ 49 | HDisplayInfo* Hadk_GetDisplayInfo(); 50 | 51 | /** 52 | * Release display info pointer. 53 | */ 54 | void Hadk_ReleaseDisplayInfo(HDisplayInfo* info); 55 | 56 | /** 57 | * Get display width. 58 | */ 59 | uint32_t HDisplayInfo_getWidth(HDisplayInfo* info); 60 | 61 | /** 62 | * Get display height. 63 | */ 64 | uint32_t HDisplayInfo_getHeight(HDisplayInfo* info); 65 | 66 | /** 67 | * Get display density. 68 | */ 69 | float HDisplayInfo_getDensity(HDisplayInfo* info); 70 | 71 | /** 72 | ************************************************************* 73 | * NativeSurface API 74 | ************************************************************* 75 | */ 76 | 77 | struct HNativeSurface; 78 | typedef struct HNativeSurface HNativeSurface; 79 | 80 | /** 81 | * Create a pointer to native surface. 82 | */ 83 | HNativeSurface* Hadk_CreateNativeSurface(const char* name ,uint32_t width,uint32_t height); 84 | 85 | /** 86 | * Get a native window pointer by native surface. 87 | */ 88 | void* HNativeWindow_fromSurface(HNativeSurface* surface); 89 | 90 | /** 91 | * Release a pointer to native surface. 92 | */ 93 | void Hadk_ReleaseNativeSurface(HNativeSurface* surface); 94 | 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif // HADK_NATIVE_WINDOW_H -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter/embedder.h" 2 | #include "hadk/hadk.h" 3 | 4 | int main(int argc, char* argv[]){ 5 | 6 | return 0; 7 | } 8 | --------------------------------------------------------------------------------