Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6b51fae

Browse files
authored
[Impeller] libImpeller: Add a README. (#55940)
1 parent aa01e25 commit 6b51fae

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

ci/licenses_golden/excluded_files

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@
217217
../../../flutter/impeller/toolkit/android/README.md
218218
../../../flutter/impeller/toolkit/android/toolkit_android_unittests.cc
219219
../../../flutter/impeller/toolkit/glvk/README.md
220+
../../../flutter/impeller/toolkit/interop/README.md
220221
../../../flutter/impeller/toolkit/interop/impeller_unittests.cc
221222
../../../flutter/impeller/toolkit/interop/object_unittests.cc
222223
../../../flutter/impeller/tools/malioc_cores.py

impeller/toolkit/interop/README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Impeller Standalone SDK
2+
3+
## Goals
4+
5+
This Impeller Standalone API is a single-header C API with no external dependencies.
6+
7+
### Full-featured
8+
9+
The library supports all rendering operations supported by Flutter with few exceptions. An optional text-layout and shaping engine is included by default.
10+
11+
### Easy to Embed
12+
13+
The entire library is distributed as a single dynamic library. The public API can be found in a single C header with no dependencies.
14+
15+
For the common platforms, prebuilt artifacts are generated per Flutter Engine commit.
16+
17+
### Easy Interoperability
18+
19+
The C API allows for explicit management of object lifecycle and is well suited for the generation of automated bindings to languages like Rust, Dart, Lua, etc…
20+
21+
### Lightweight
22+
23+
The core rendering engine is less than 200 KB compressed.
24+
25+
The text layout and shaping engine along with the bundled ICU data tables brings the size up to ~2.5 MB. If the application does not need text layout and shaping, or can interface with an existing library on the target platform, it is recommended to generate the SDK without built-in support for typography. Impeller is a rendering engine but typography is really hard to get right and needed by most users of a rendering engine. That is why one is included by default. But it is optional.
26+
27+
> [!CAUTION]
28+
> Users of the prebuilt artifacts should strip the binaries before deployment as these contain debug symbols.
29+
30+
### Performant
31+
32+
Built to perform the best when using a modern graphics API like Metal or Vulkan (not all may be available to start) and when running on mobile tiler GPUs like the ones found in smartphones and AppleSilicon/ARM desktops.
33+
34+
Impeller does need a GPU. Performance will likely be inadequate for interactive use cases when using software rendering. Software rendering can be enabled using projects like SwiftShader, Angle, LLVMPipe, etc… If you are using software rendering in your projects, restrict its use to testing on CI. Impeller will likely never have a dedicated software renderer.
35+
36+
# API Stability
37+
38+
Unlike the Flutter Embedder API which has a stable API as well as ABI, the Impeller API does **not** currently have stability guarantees.
39+
40+
The API does look similar to the one used by Flutter in Dart so major overhauls are not realistically on the horizon.
41+
42+
The API is also versioned and there may be stability guarantees between specific versions in the future.
43+
44+
# Prebuilt Artifacts
45+
46+
Users may plug in any toolchain into the Flutter Engine build system to build the libimpeller.so dynamic library. However, for the common platforms, the CI bots upload a tarball containing the library and headers. This URL for the SDK tarball for a particular platform can be constructed as follows:
47+
48+
```sh
49+
https://storage.googleapis.com/flutter_infra_release/flutter/$FLUTTER_ENGINE_SHA/$PLATFORM_ARCH/impeller_sdk.zip
50+
```
51+
52+
The `$FLUTTER_ENGINE_SHA` is the Git hash in the Flutter Engine repository. To make sure all artifacts for a specific hash have been successfully generated, look up the Flutter Engine SHA currently used by the Flutter Framework in the [engine.version](https://github.com/flutter/flutter/blob/master/bin/internal/engine.version) file.
53+
54+
The `$PLATFORM_ARCH` can be determined from the table below.
55+
56+
| | macOS | Linux | Android | Windows |
57+
|:-----:|:------------:|:-----------:|:--------------:|:-------------:|
58+
| armv7 | | | android-arm | |
59+
| arm64 | darwin-arm64 | linux-arm64 | android-arm64 | windows-arm64 |
60+
| x86 | | | android-x86 | |
61+
| x64 | darwin-x64 | linux-x64 | android-x64 | windows-x64 |
62+
63+
64+
For example, the SDK for `Linux x64` at engine SHA `31aaaaad868743b38ac3b7165f0d58eca94e521b` would be https://storage.googleapis.com/flutter_infra_release/flutter/31aaaaad868743b38ac3b7165f0d58eca94e521b/linux-x64/impeller_sdk.zip
65+
66+
# API Fundamentals
67+
68+
## Versioning
69+
70+
The current version of the API is denoted by the `IMPELLER_VERSION` macro. This version must be passed to APIs that create top-level objects like graphics contexts. Construction of the context may fail if the API version expected by the caller is not supported by the library.
71+
72+
The version currently supported by the library is returned by a call to `ImpellerGetVersion()`
73+
74+
Since there are no API stability guarantees today, passing a version that is different to the one returned by `ImpellerGetVersion` will always fail.
75+
76+
## Object Model
77+
78+
Users interact with Impeller objects using opaque handles. Impeller objects can be identified by their definition using `IMPELLER_DEFINE_HANDLE` in the SDK.
79+
80+
All Impeller objects are thread-safe reference-counted.
81+
82+
## Reference Management
83+
84+
Methods in the Impeller API follow a very strict convention. This makes it easy to write automated bindings generators that handle object lifecycles to various degrees:
85+
86+
* Methods that end with `Retain` increment the reference count of the object by 1.
87+
* Methods that end with `Release` decrement the reference count of the object by 1. When the reference count of the object reaches 0, the object is collected.
88+
* Methods that end with `New` create a new object with a reference count of 1.
89+
* This reference must be relinquished by the appropriate call to `Release`.
90+
* The framework may hold strong references to objects internally. When the user releases their last reference, it is not guaranteed that the object will be immediately destructed.
91+
* Reference counts can be incremented and decremented in a thread-safe manner. But, not all objects can be used safely from multiple thread concurrently. The thread safety attributes of the object should be documented in the header.
92+
93+
## Null Safety
94+
95+
The Impeller API passes [nullability completeness](https://clang.llvm.org/docs/DiagnosticsReference.html#wnullability-completeness) checks. All pointer arguments and return values are decorated with `IMPELLER_NULLABLE` and `IMPELLER_NONNULL`. Passing a null pointer to an argument decorated with `IMPELLER_NONNULL` will very likely result in a null pointer dereference. When generating automated bindings to other languages, it is recommended that these decorations be used to inform the API and perform additional checks.

0 commit comments

Comments
 (0)