a new frame needs to be painted. It provides the low-level implementation of Flutter’s core API, including graphics (through Impeller on iOS and coming to Android, and Skia on other platforms) text layout. 7
common APIs that work across a variety of hardware and software platforms. It serves as the graphics engine for Google Chrome and ChromeOS, Android, Flutter, and many other products. https://github.com/google/skia Skia The 2D Graphics Library 8
at build time. It builds all pipeline state objects upfront. The engine controls caching and caches explicitly. • Instrumentable: Impeller tags and labels all graphics resources like textures, and buffers. It can capture and persist animations to disk without affecting per-frame rendering performance. • Portable: Flutter doesn’t tie Impeller to a specific client rendering API. You can author shaders once and convert them to backend-specific formats as necessary. • Leverages modern graphics APIs: Impeller uses, but doesn’t depend on, features available in modern APIs like Metal and Vulkan. • Leverages concurrency: Impeller can distribute single-frame workloads across multiple threads if necessary. Impeller Impeller provides a new rendering runtime for Flutter. 9
paint on the current canvas, then it paints its child, and then, after painting its child, it asks its foregroundPainter to paint. The coordinate system of the canvas matches the coordinate system of the CustomPaint object. The painters are expected to paint within a rectangle starting at the origin and encompassing a region of the given size. To enforce painting within those bounds, consider wrapping this CustomPaint with a ClipRect widget. Painters are implemented by subclassing CustomPainter. Custom painters normally size themselves to their child. If they do not have a child, they attempt to size themselves to the size, which defaults to Size.zero. size must not be null. A widget that provides a canvas on which to draw during the paint phase. CustomPaint 26 Widget
custom object needs to be repainted. • The shouldRepaint method is called when a new instance of the class is provided, to check if the new instance actually represents different information.
Theme.of(context).colorScheme.inversePrimary, title: Text(widget.title), ), body: Center( const Text( 'You have pushed the button this many times:', ), 36 Flutter
dependency problems // in the C++ code. If we straighten out the C++ dependencies, we can remove // this indirection. @Native<Void Function(Pointer<Void>, Pointer<Void>, Double, Double)> (symbol: 'Paragraph::paint') external void _paint(_NativeCanvas canvas, double x, double y); 43 Flutter
engines. The current implementation is based on // Skia's SkShaper/SkParagraph text layout module. class Paragraph { // Paints the laid out text onto the supplied DisplayListBuilder at // (x, y) offset from the origin. Only valid after Layout() is called. virtual bool Paint(flutter::DisplayListBuilder* builder, double x, double y) = 0; 44 /engine/third_party/txt/src/txt/paragraph.h engine
DlOpReceiver virtual // methods (with help from some of the classes in the utils file) and // passing an instance to the Dispatch() method, or it can be rendered // to Skia using a DlSkCanvasDispatcher. void DlSkCanvasDispatcher::drawTextBlob(const sk_sp<SkTextBlob> blob, SkScalar x, SkScalar y) { canvas_->drawTextBlob(blob, x, y, paint()); } 64 /engine/display_list/skia/dl_sk_dispatcher.cc skia engine private: SkCanvas* canvas_;