Convert public API NativeFieldWrapper classes to abstract interfaces (flutter/engine#41945)
See https://github.com/flutter/flutter/issues/123756
This commit is contained in:
@@ -9,18 +9,40 @@ part of dart.ui;
|
||||
///
|
||||
/// Scene objects can be displayed on the screen using the [FlutterView.render]
|
||||
/// method.
|
||||
abstract class Scene {
|
||||
/// Synchronously creates a handle to an image from this scene.
|
||||
///
|
||||
/// {@macro dart.ui.painting.Picture.toImageSync}
|
||||
Image toImageSync(int width, int height);
|
||||
|
||||
/// Creates a raster image representation of the current state of the scene.
|
||||
///
|
||||
/// This is a slow operation that is performed on a background thread.
|
||||
///
|
||||
/// Callers must dispose the [Image] when they are done with it. If the result
|
||||
/// will be shared with other methods or classes, [Image.clone] should be used
|
||||
/// and each handle created must be disposed.
|
||||
Future<Image> toImage(int width, int height);
|
||||
|
||||
/// Releases the resources used by this scene.
|
||||
///
|
||||
/// After calling this function, the scene is cannot be used further.
|
||||
///
|
||||
/// This can't be a leaf call because the native function calls Dart API
|
||||
/// (Dart_SetNativeInstanceField).
|
||||
void dispose();
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
class Scene extends NativeFieldWrapperClass1 {
|
||||
base class _NativeScene extends NativeFieldWrapperClass1 implements Scene {
|
||||
/// This class is created by the engine, and should not be instantiated
|
||||
/// or extended directly.
|
||||
///
|
||||
/// To create a Scene object, use a [SceneBuilder].
|
||||
@pragma('vm:entry-point')
|
||||
Scene._();
|
||||
_NativeScene._();
|
||||
|
||||
/// Synchronously creates a handle to an image from this scene.
|
||||
///
|
||||
/// {@macro dart.ui.painting.Picture.toImageSync}
|
||||
@override
|
||||
Image toImageSync(int width, int height) {
|
||||
if (width <= 0 || height <= 0) {
|
||||
throw Exception('Invalid image dimensions.');
|
||||
@@ -37,13 +59,7 @@ class Scene extends NativeFieldWrapperClass1 {
|
||||
@Native<Handle Function(Pointer<Void>, Uint32, Uint32, Handle)>(symbol: 'Scene::toImageSync')
|
||||
external String? _toImageSync(int width, int height, _Image outImage);
|
||||
|
||||
/// Creates a raster image representation of the current state of the scene.
|
||||
///
|
||||
/// This is a slow operation that is performed on a background thread.
|
||||
///
|
||||
/// Callers must dispose the [Image] when they are done with it. If the result
|
||||
/// will be shared with other methods or classes, [Image.clone] should be used
|
||||
/// and each handle created must be disposed.
|
||||
@override
|
||||
Future<Image> toImage(int width, int height) {
|
||||
if (width <= 0 || height <= 0) {
|
||||
throw Exception('Invalid image dimensions.');
|
||||
@@ -61,12 +77,7 @@ class Scene extends NativeFieldWrapperClass1 {
|
||||
@Native<Handle Function(Pointer<Void>, Uint32, Uint32, Handle)>(symbol: 'Scene::toImage')
|
||||
external String? _toImage(int width, int height, _Callback<_Image?> callback);
|
||||
|
||||
/// Releases the resources used by this scene.
|
||||
///
|
||||
/// After calling this function, the scene is cannot be used further.
|
||||
///
|
||||
/// This can't be a leaf call because the native function calls Dart API
|
||||
/// (Dart_SetNativeInstanceField).
|
||||
@override
|
||||
@Native<Void Function(Pointer<Void>)>(symbol: 'Scene::dispose')
|
||||
external void dispose();
|
||||
}
|
||||
@@ -219,10 +230,352 @@ class ShaderMaskEngineLayer extends _EngineLayerWrapper {
|
||||
/// To draw graphical operations onto a [Scene], first create a
|
||||
/// [Picture] using a [PictureRecorder] and a [Canvas], and then add
|
||||
/// it to the scene using [addPicture].
|
||||
class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
abstract class SceneBuilder {
|
||||
factory SceneBuilder() = _NativeSceneBuilder;
|
||||
|
||||
/// Pushes a transform operation onto the operation stack.
|
||||
///
|
||||
/// The objects are transformed by the given matrix before rasterization.
|
||||
///
|
||||
/// {@template dart.ui.sceneBuilder.oldLayer}
|
||||
/// If `oldLayer` is not null the engine will attempt to reuse the resources
|
||||
/// allocated for the old layer when rendering the new layer. This is purely
|
||||
/// an optimization. It has no effect on the correctness of rendering.
|
||||
/// {@endtemplate}
|
||||
///
|
||||
/// {@template dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
/// Passing a layer to [addRetained] or as `oldLayer` argument to a push
|
||||
/// method counts as _usage_. A layer can be used no more than once in a scene.
|
||||
/// For example, it may not be passed simultaneously to two push methods, or
|
||||
/// to a push method and to `addRetained`.
|
||||
///
|
||||
/// When a layer is passed to [addRetained] all descendant layers are also
|
||||
/// considered as used in this scene. The same single-usage restriction
|
||||
/// applies to descendants.
|
||||
///
|
||||
/// When a layer is passed as an `oldLayer` argument to a push method, it may
|
||||
/// no longer be used in subsequent frames. If you would like to continue
|
||||
/// reusing the resources associated with the layer, store the layer object
|
||||
/// returned by the push method and use that in the next frame instead of the
|
||||
/// original object.
|
||||
/// {@endtemplate}
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
TransformEngineLayer pushTransform(
|
||||
Float64List matrix4, {
|
||||
TransformEngineLayer? oldLayer,
|
||||
});
|
||||
|
||||
/// Pushes an offset operation onto the operation stack.
|
||||
///
|
||||
/// This is equivalent to [pushTransform] with a matrix with only translation.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
OffsetEngineLayer pushOffset(
|
||||
double dx,
|
||||
double dy, {
|
||||
OffsetEngineLayer? oldLayer,
|
||||
});
|
||||
|
||||
/// Pushes a rectangular clip operation onto the operation stack.
|
||||
///
|
||||
/// Rasterization outside the given rectangle is discarded.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack, and [Clip] for different clip modes.
|
||||
/// By default, the clip will be anti-aliased (clip = [Clip.antiAlias]).
|
||||
ClipRectEngineLayer pushClipRect(
|
||||
Rect rect, {
|
||||
Clip clipBehavior = Clip.antiAlias,
|
||||
ClipRectEngineLayer? oldLayer,
|
||||
});
|
||||
|
||||
/// Pushes a rounded-rectangular clip operation onto the operation stack.
|
||||
///
|
||||
/// Rasterization outside the given rounded rectangle is discarded.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack, and [Clip] for different clip modes.
|
||||
/// By default, the clip will be anti-aliased (clip = [Clip.antiAlias]).
|
||||
ClipRRectEngineLayer pushClipRRect(
|
||||
RRect rrect, {
|
||||
Clip clipBehavior = Clip.antiAlias,
|
||||
ClipRRectEngineLayer? oldLayer,
|
||||
});
|
||||
|
||||
/// Pushes a path clip operation onto the operation stack.
|
||||
///
|
||||
/// Rasterization outside the given path is discarded.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack. See [Clip] for different clip modes.
|
||||
/// By default, the clip will be anti-aliased (clip = [Clip.antiAlias]).
|
||||
ClipPathEngineLayer pushClipPath(
|
||||
Path path, {
|
||||
Clip clipBehavior = Clip.antiAlias,
|
||||
ClipPathEngineLayer? oldLayer,
|
||||
});
|
||||
|
||||
/// Pushes an opacity operation onto the operation stack.
|
||||
///
|
||||
/// The given alpha value is blended into the alpha value of the objects'
|
||||
/// rasterization. An alpha value of 0 makes the objects entirely invisible.
|
||||
/// An alpha value of 255 has no effect (i.e., the objects retain the current
|
||||
/// opacity).
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
OpacityEngineLayer pushOpacity(
|
||||
int alpha, {
|
||||
Offset? offset = Offset.zero,
|
||||
OpacityEngineLayer? oldLayer,
|
||||
});
|
||||
|
||||
/// Pushes a color filter operation onto the operation stack.
|
||||
///
|
||||
/// The given color is applied to the objects' rasterization using the given
|
||||
/// blend mode.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
ColorFilterEngineLayer pushColorFilter(
|
||||
ColorFilter filter, {
|
||||
ColorFilterEngineLayer? oldLayer,
|
||||
});
|
||||
|
||||
/// Pushes an image filter operation onto the operation stack.
|
||||
///
|
||||
/// The given filter is applied to the children's rasterization before compositing them into
|
||||
/// the scene.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
ImageFilterEngineLayer pushImageFilter(
|
||||
ImageFilter filter, {
|
||||
Offset offset = Offset.zero,
|
||||
ImageFilterEngineLayer? oldLayer,
|
||||
});
|
||||
|
||||
/// Pushes a backdrop filter operation onto the operation stack.
|
||||
///
|
||||
/// The given filter is applied to the current contents of the scene as far back as
|
||||
/// the most recent save layer and rendered back to the scene using the indicated
|
||||
/// [blendMode] prior to rasterizing the child layers.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
BackdropFilterEngineLayer pushBackdropFilter(
|
||||
ImageFilter filter, {
|
||||
BlendMode blendMode = BlendMode.srcOver,
|
||||
BackdropFilterEngineLayer? oldLayer,
|
||||
});
|
||||
|
||||
/// Pushes a shader mask operation onto the operation stack.
|
||||
///
|
||||
/// The given shader is applied to the object's rasterization in the given
|
||||
/// rectangle using the given blend mode.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
ShaderMaskEngineLayer pushShaderMask(
|
||||
Shader shader,
|
||||
Rect maskRect,
|
||||
BlendMode blendMode, {
|
||||
ShaderMaskEngineLayer? oldLayer,
|
||||
FilterQuality filterQuality = FilterQuality.low,
|
||||
});
|
||||
|
||||
/// Ends the effect of the most recently pushed operation.
|
||||
///
|
||||
/// Internally the scene builder maintains a stack of operations. Each of the
|
||||
/// operations in the stack applies to each of the objects added to the scene.
|
||||
/// Calling this function removes the most recently added operation from the
|
||||
/// stack.
|
||||
void pop();
|
||||
|
||||
/// Add a retained engine layer subtree from previous frames.
|
||||
///
|
||||
/// All the engine layers that are in the subtree of the retained layer will
|
||||
/// be automatically appended to the current engine layer tree.
|
||||
///
|
||||
/// Therefore, when implementing a subclass of the [Layer] concept defined in
|
||||
/// the rendering layer of Flutter's framework, once this is called, there's
|
||||
/// no need to call [Layer.addToScene] for its children layers.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
void addRetained(EngineLayer retainedLayer);
|
||||
|
||||
/// Adds an object to the scene that displays performance statistics.
|
||||
///
|
||||
/// Useful during development to assess the performance of the application.
|
||||
/// The enabledOptions controls which statistics are displayed. The bounds
|
||||
/// controls where the statistics are displayed.
|
||||
///
|
||||
/// enabledOptions is a bit field with the following bits defined:
|
||||
/// - 0x01: displayRasterizerStatistics - show raster thread frame time
|
||||
/// - 0x02: visualizeRasterizerStatistics - graph raster thread frame times
|
||||
/// - 0x04: displayEngineStatistics - show UI thread frame time
|
||||
/// - 0x08: visualizeEngineStatistics - graph UI thread frame times
|
||||
/// Set enabledOptions to 0x0F to enable all the currently defined features.
|
||||
///
|
||||
/// The "UI thread" is the thread that includes all the execution of the main
|
||||
/// Dart isolate (the isolate that can call [FlutterView.render]). The UI
|
||||
/// thread frame time is the total time spent executing the
|
||||
/// [PlatformDispatcher.onBeginFrame] callback. The "raster thread" is the
|
||||
/// thread (running on the CPU) that subsequently processes the [Scene]
|
||||
/// provided by the Dart code to turn it into GPU commands and send it to the
|
||||
/// GPU.
|
||||
///
|
||||
/// See also the [PerformanceOverlayOption] enum in the rendering library.
|
||||
/// for more details.
|
||||
// Values above must match constants in //engine/src/sky/compositor/performance_overlay_layer.h
|
||||
void addPerformanceOverlay(int enabledOptions, Rect bounds);
|
||||
|
||||
/// Adds a [Picture] to the scene.
|
||||
///
|
||||
/// The picture is rasterized at the given `offset`.
|
||||
///
|
||||
/// The rendering _may_ be cached to reduce the cost of painting the picture
|
||||
/// if it is reused in subsequent frames. Whether a picture is cached or not
|
||||
/// depends on the backend implementation. When caching is considered, the
|
||||
/// choice to cache or not cache is a heuristic based on how often the picture
|
||||
/// is being painted and the cost of painting the picture. To disable this
|
||||
/// caching, set `willChangeHint` to true. To force the caching to happen (in
|
||||
/// backends that do caching), set `isComplexHint` to true. When both are set,
|
||||
/// `willChangeHint` prevails.
|
||||
///
|
||||
/// In general, setting these hints is not very useful. Backends that cache
|
||||
/// pictures only do so for pictures that have been rendered three times
|
||||
/// already; setting `willChangeHint` to true to avoid caching an animating
|
||||
/// picture that changes every frame is therefore redundant, the picture
|
||||
/// wouldn't have been cached anyway. Similarly, backends that cache pictures
|
||||
/// are relatively aggressive about doing so, such that any image complicated
|
||||
/// enough to warrant caching is probably already being cached even without
|
||||
/// `isComplexHint` being set to true.
|
||||
void addPicture(
|
||||
Offset offset,
|
||||
Picture picture, {
|
||||
bool isComplexHint = false,
|
||||
bool willChangeHint = false,
|
||||
});
|
||||
|
||||
/// Adds a backend texture to the scene.
|
||||
///
|
||||
/// The texture is scaled to the given size and rasterized at the given offset.
|
||||
///
|
||||
/// If `freeze` is true the texture that is added to the scene will not
|
||||
/// be updated with new frames. `freeze` is used when resizing an embedded
|
||||
/// Android view: When resizing an Android view there is a short period during
|
||||
/// which the framework cannot tell if the newest texture frame has the
|
||||
/// previous or new size, to workaround this the framework "freezes" the
|
||||
/// texture just before resizing the Android view and un-freezes it when it is
|
||||
/// certain that a frame with the new size is ready.
|
||||
void addTexture(
|
||||
int textureId, {
|
||||
Offset offset = Offset.zero,
|
||||
double width = 0.0,
|
||||
double height = 0.0,
|
||||
bool freeze = false,
|
||||
FilterQuality filterQuality = FilterQuality.low,
|
||||
});
|
||||
|
||||
/// Adds a platform view (e.g an iOS UIView) to the scene.
|
||||
///
|
||||
/// On iOS this layer splits the current output surface into two surfaces, one for the scene nodes
|
||||
/// preceding the platform view, and one for the scene nodes following the platform view.
|
||||
///
|
||||
/// ## Performance impact
|
||||
///
|
||||
/// Adding an additional surface doubles the amount of graphics memory directly used by Flutter
|
||||
/// for output buffers. Quartz might allocated extra buffers for compositing the Flutter surfaces
|
||||
/// and the platform view.
|
||||
///
|
||||
/// With a platform view in the scene, Quartz has to composite the two Flutter surfaces and the
|
||||
/// embedded UIView. In addition to that, on iOS versions greater than 9, the Flutter frames are
|
||||
/// synchronized with the UIView frames adding additional performance overhead.
|
||||
///
|
||||
/// The `offset` argument is not used for iOS and Android.
|
||||
void addPlatformView(
|
||||
int viewId, {
|
||||
Offset offset = Offset.zero,
|
||||
double width = 0.0,
|
||||
double height = 0.0,
|
||||
});
|
||||
|
||||
/// Sets a threshold after which additional debugging information should be recorded.
|
||||
///
|
||||
/// Currently this interface is difficult to use by end-developers. If you're
|
||||
/// interested in using this feature, please contact [flutter-dev](https://groups.google.com/forum/#!forum/flutter-dev).
|
||||
/// We'll hopefully be able to figure out how to make this feature more useful
|
||||
/// to you.
|
||||
void setRasterizerTracingThreshold(int frameInterval);
|
||||
|
||||
/// Sets whether the raster cache should checkerboard cached entries. This is
|
||||
/// only useful for debugging purposes.
|
||||
///
|
||||
/// The compositor can sometimes decide to cache certain portions of the
|
||||
/// widget hierarchy. Such portions typically don't change often from frame to
|
||||
/// frame and are expensive to render. This can speed up overall rendering. However,
|
||||
/// there is certain upfront cost to constructing these cache entries. And, if
|
||||
/// the cache entries are not used very often, this cost may not be worth the
|
||||
/// speedup in rendering of subsequent frames. If the developer wants to be certain
|
||||
/// that populating the raster cache is not causing stutters, this option can be
|
||||
/// set. Depending on the observations made, hints can be provided to the compositor
|
||||
/// that aid it in making better decisions about caching.
|
||||
///
|
||||
/// Currently this interface is difficult to use by end-developers. If you're
|
||||
/// interested in using this feature, please contact [flutter-dev](https://groups.google.com/forum/#!forum/flutter-dev).
|
||||
void setCheckerboardRasterCacheImages(bool checkerboard);
|
||||
|
||||
/// Sets whether the compositor should checkerboard layers that are rendered
|
||||
/// to offscreen bitmaps.
|
||||
///
|
||||
/// This is only useful for debugging purposes.
|
||||
void setCheckerboardOffscreenLayers(bool checkerboard);
|
||||
|
||||
/// Finishes building the scene.
|
||||
///
|
||||
/// Returns a [Scene] containing the objects that have been added to
|
||||
/// this scene builder. The [Scene] can then be displayed on the
|
||||
/// screen with [FlutterView.render].
|
||||
///
|
||||
/// After calling this function, the scene builder object is invalid and
|
||||
/// cannot be used further.
|
||||
Scene build();
|
||||
}
|
||||
|
||||
base class _NativeSceneBuilder extends NativeFieldWrapperClass1 implements SceneBuilder {
|
||||
/// Creates an empty [SceneBuilder] object.
|
||||
@pragma('vm:entry-point')
|
||||
SceneBuilder() {
|
||||
_NativeSceneBuilder() {
|
||||
_constructor();
|
||||
}
|
||||
|
||||
@@ -282,41 +635,14 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Pushes a transform operation onto the operation stack.
|
||||
///
|
||||
/// The objects are transformed by the given matrix before rasterization.
|
||||
///
|
||||
/// {@template dart.ui.sceneBuilder.oldLayer}
|
||||
/// If `oldLayer` is not null the engine will attempt to reuse the resources
|
||||
/// allocated for the old layer when rendering the new layer. This is purely
|
||||
/// an optimization. It has no effect on the correctness of rendering.
|
||||
/// {@endtemplate}
|
||||
///
|
||||
/// {@template dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
/// Passing a layer to [addRetained] or as `oldLayer` argument to a push
|
||||
/// method counts as _usage_. A layer can be used no more than once in a scene.
|
||||
/// For example, it may not be passed simultaneously to two push methods, or
|
||||
/// to a push method and to `addRetained`.
|
||||
///
|
||||
/// When a layer is passed to [addRetained] all descendant layers are also
|
||||
/// considered as used in this scene. The same single-usage restriction
|
||||
/// applies to descendants.
|
||||
///
|
||||
/// When a layer is passed as an `oldLayer` argument to a push method, it may
|
||||
/// no longer be used in subsequent frames. If you would like to continue
|
||||
/// reusing the resources associated with the layer, store the layer object
|
||||
/// returned by the push method and use that in the next frame instead of the
|
||||
/// original object.
|
||||
/// {@endtemplate}
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
@override
|
||||
TransformEngineLayer pushTransform(
|
||||
Float64List matrix4, {
|
||||
TransformEngineLayer? oldLayer,
|
||||
}) {
|
||||
assert(_matrix4IsValid(matrix4));
|
||||
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushTransform'));
|
||||
final EngineLayer engineLayer = EngineLayer._();
|
||||
final EngineLayer engineLayer = _NativeEngineLayer._();
|
||||
_pushTransform(engineLayer, matrix4, oldLayer?._nativeLayer);
|
||||
final TransformEngineLayer layer = TransformEngineLayer._(engineLayer);
|
||||
assert(_debugPushLayer(layer));
|
||||
@@ -326,22 +652,14 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
@Native<Void Function(Pointer<Void>, Handle, Handle, Handle)>(symbol: 'SceneBuilder::pushTransformHandle')
|
||||
external void _pushTransform(EngineLayer layer, Float64List matrix4, EngineLayer? oldLayer);
|
||||
|
||||
/// Pushes an offset operation onto the operation stack.
|
||||
///
|
||||
/// This is equivalent to [pushTransform] with a matrix with only translation.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
@override
|
||||
OffsetEngineLayer pushOffset(
|
||||
double dx,
|
||||
double dy, {
|
||||
OffsetEngineLayer? oldLayer,
|
||||
}) {
|
||||
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushOffset'));
|
||||
final EngineLayer engineLayer = EngineLayer._();
|
||||
final EngineLayer engineLayer = _NativeEngineLayer._();
|
||||
_pushOffset(engineLayer, dx, dy, oldLayer?._nativeLayer);
|
||||
final OffsetEngineLayer layer = OffsetEngineLayer._(engineLayer);
|
||||
assert(_debugPushLayer(layer));
|
||||
@@ -351,16 +669,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
@Native<Void Function(Pointer<Void>, Handle, Double, Double, Handle)>(symbol: 'SceneBuilder::pushOffset')
|
||||
external void _pushOffset(EngineLayer layer, double dx, double dy, EngineLayer? oldLayer);
|
||||
|
||||
/// Pushes a rectangular clip operation onto the operation stack.
|
||||
///
|
||||
/// Rasterization outside the given rectangle is discarded.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack, and [Clip] for different clip modes.
|
||||
/// By default, the clip will be anti-aliased (clip = [Clip.antiAlias]).
|
||||
@override
|
||||
ClipRectEngineLayer pushClipRect(
|
||||
Rect rect, {
|
||||
Clip clipBehavior = Clip.antiAlias,
|
||||
@@ -368,7 +677,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
}) {
|
||||
assert(clipBehavior != Clip.none);
|
||||
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushClipRect'));
|
||||
final EngineLayer engineLayer = EngineLayer._();
|
||||
final EngineLayer engineLayer = _NativeEngineLayer._();
|
||||
_pushClipRect(engineLayer, rect.left, rect.right, rect.top, rect.bottom, clipBehavior.index,
|
||||
oldLayer?._nativeLayer);
|
||||
final ClipRectEngineLayer layer = ClipRectEngineLayer._(engineLayer);
|
||||
@@ -386,16 +695,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
int clipBehavior,
|
||||
EngineLayer? oldLayer);
|
||||
|
||||
/// Pushes a rounded-rectangular clip operation onto the operation stack.
|
||||
///
|
||||
/// Rasterization outside the given rounded rectangle is discarded.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack, and [Clip] for different clip modes.
|
||||
/// By default, the clip will be anti-aliased (clip = [Clip.antiAlias]).
|
||||
@override
|
||||
ClipRRectEngineLayer pushClipRRect(
|
||||
RRect rrect, {
|
||||
Clip clipBehavior = Clip.antiAlias,
|
||||
@@ -403,7 +703,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
}) {
|
||||
assert(clipBehavior != Clip.none);
|
||||
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushClipRRect'));
|
||||
final EngineLayer engineLayer = EngineLayer._();
|
||||
final EngineLayer engineLayer = _NativeEngineLayer._();
|
||||
_pushClipRRect(engineLayer, rrect._getValue32(), clipBehavior.index, oldLayer?._nativeLayer);
|
||||
final ClipRRectEngineLayer layer = ClipRRectEngineLayer._(engineLayer);
|
||||
assert(_debugPushLayer(layer));
|
||||
@@ -413,16 +713,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
@Native<Void Function(Pointer<Void>, Handle, Handle, Int32, Handle)>(symbol: 'SceneBuilder::pushClipRRect')
|
||||
external void _pushClipRRect(EngineLayer layer, Float32List rrect, int clipBehavior, EngineLayer? oldLayer);
|
||||
|
||||
/// Pushes a path clip operation onto the operation stack.
|
||||
///
|
||||
/// Rasterization outside the given path is discarded.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack. See [Clip] for different clip modes.
|
||||
/// By default, the clip will be anti-aliased (clip = [Clip.antiAlias]).
|
||||
@override
|
||||
ClipPathEngineLayer pushClipPath(
|
||||
Path path, {
|
||||
Clip clipBehavior = Clip.antiAlias,
|
||||
@@ -430,35 +721,24 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
}) {
|
||||
assert(clipBehavior != Clip.none);
|
||||
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushClipPath'));
|
||||
final EngineLayer engineLayer = EngineLayer._();
|
||||
_pushClipPath(engineLayer, path, clipBehavior.index, oldLayer?._nativeLayer);
|
||||
final EngineLayer engineLayer = _NativeEngineLayer._();
|
||||
_pushClipPath(engineLayer, path as _NativePath, clipBehavior.index, oldLayer?._nativeLayer);
|
||||
final ClipPathEngineLayer layer = ClipPathEngineLayer._(engineLayer);
|
||||
assert(_debugPushLayer(layer));
|
||||
return layer;
|
||||
}
|
||||
|
||||
@Native<Void Function(Pointer<Void>, Handle, Pointer<Void>, Int32, Handle)>(symbol: 'SceneBuilder::pushClipPath')
|
||||
external void _pushClipPath(EngineLayer layer, Path path, int clipBehavior, EngineLayer? oldLayer);
|
||||
external void _pushClipPath(EngineLayer layer, _NativePath path, int clipBehavior, EngineLayer? oldLayer);
|
||||
|
||||
/// Pushes an opacity operation onto the operation stack.
|
||||
///
|
||||
/// The given alpha value is blended into the alpha value of the objects'
|
||||
/// rasterization. An alpha value of 0 makes the objects entirely invisible.
|
||||
/// An alpha value of 255 has no effect (i.e., the objects retain the current
|
||||
/// opacity).
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
@override
|
||||
OpacityEngineLayer pushOpacity(
|
||||
int alpha, {
|
||||
Offset? offset = Offset.zero,
|
||||
OpacityEngineLayer? oldLayer,
|
||||
}) {
|
||||
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushOpacity'));
|
||||
final EngineLayer engineLayer = EngineLayer._();
|
||||
final EngineLayer engineLayer = _NativeEngineLayer._();
|
||||
_pushOpacity(engineLayer, alpha, offset!.dx, offset.dy, oldLayer?._nativeLayer);
|
||||
final OpacityEngineLayer layer = OpacityEngineLayer._(engineLayer);
|
||||
assert(_debugPushLayer(layer));
|
||||
@@ -468,23 +748,14 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
@Native<Void Function(Pointer<Void>, Handle, Int32, Double, Double, Handle)>(symbol: 'SceneBuilder::pushOpacity')
|
||||
external void _pushOpacity(EngineLayer layer, int alpha, double dx, double dy, EngineLayer? oldLayer);
|
||||
|
||||
/// Pushes a color filter operation onto the operation stack.
|
||||
///
|
||||
/// The given color is applied to the objects' rasterization using the given
|
||||
/// blend mode.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
@override
|
||||
ColorFilterEngineLayer pushColorFilter(
|
||||
ColorFilter filter, {
|
||||
ColorFilterEngineLayer? oldLayer,
|
||||
}) {
|
||||
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushColorFilter'));
|
||||
final _ColorFilter nativeFilter = filter._toNativeColorFilter()!;
|
||||
final EngineLayer engineLayer = EngineLayer._();
|
||||
final EngineLayer engineLayer = _NativeEngineLayer._();
|
||||
_pushColorFilter(engineLayer, nativeFilter, oldLayer?._nativeLayer);
|
||||
final ColorFilterEngineLayer layer = ColorFilterEngineLayer._(engineLayer);
|
||||
assert(_debugPushLayer(layer));
|
||||
@@ -494,16 +765,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
@Native<Void Function(Pointer<Void>, Handle, Pointer<Void>, Handle)>(symbol: 'SceneBuilder::pushColorFilter')
|
||||
external void _pushColorFilter(EngineLayer layer, _ColorFilter filter, EngineLayer? oldLayer);
|
||||
|
||||
/// Pushes an image filter operation onto the operation stack.
|
||||
///
|
||||
/// The given filter is applied to the children's rasterization before compositing them into
|
||||
/// the scene.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
@override
|
||||
ImageFilterEngineLayer pushImageFilter(
|
||||
ImageFilter filter, {
|
||||
Offset offset = Offset.zero,
|
||||
@@ -511,7 +773,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
}) {
|
||||
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushImageFilter'));
|
||||
final _ImageFilter nativeFilter = filter._toNativeImageFilter();
|
||||
final EngineLayer engineLayer = EngineLayer._();
|
||||
final EngineLayer engineLayer = _NativeEngineLayer._();
|
||||
_pushImageFilter(engineLayer, nativeFilter, offset.dx, offset.dy, oldLayer?._nativeLayer);
|
||||
final ImageFilterEngineLayer layer = ImageFilterEngineLayer._(engineLayer);
|
||||
assert(_debugPushLayer(layer));
|
||||
@@ -521,24 +783,14 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
@Native<Void Function(Pointer<Void>, Handle, Pointer<Void>, Double, Double, Handle)>(symbol: 'SceneBuilder::pushImageFilter')
|
||||
external void _pushImageFilter(EngineLayer outEngineLayer, _ImageFilter filter, double dx, double dy, EngineLayer? oldLayer);
|
||||
|
||||
/// Pushes a backdrop filter operation onto the operation stack.
|
||||
///
|
||||
/// The given filter is applied to the current contents of the scene as far back as
|
||||
/// the most recent save layer and rendered back to the scene using the indicated
|
||||
/// [blendMode] prior to rasterizing the child layers.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
@override
|
||||
BackdropFilterEngineLayer pushBackdropFilter(
|
||||
ImageFilter filter, {
|
||||
BlendMode blendMode = BlendMode.srcOver,
|
||||
BackdropFilterEngineLayer? oldLayer,
|
||||
}) {
|
||||
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushBackdropFilter'));
|
||||
final EngineLayer engineLayer = EngineLayer._();
|
||||
final EngineLayer engineLayer = _NativeEngineLayer._();
|
||||
_pushBackdropFilter(engineLayer, filter._toNativeImageFilter(), blendMode.index, oldLayer?._nativeLayer);
|
||||
final BackdropFilterEngineLayer layer = BackdropFilterEngineLayer._(engineLayer);
|
||||
assert(_debugPushLayer(layer));
|
||||
@@ -548,16 +800,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
@Native<Void Function(Pointer<Void>, Handle, Pointer<Void>, Int32, Handle)>(symbol: 'SceneBuilder::pushBackdropFilter')
|
||||
external void _pushBackdropFilter(EngineLayer outEngineLayer, _ImageFilter filter, int blendMode, EngineLayer? oldLayer);
|
||||
|
||||
/// Pushes a shader mask operation onto the operation stack.
|
||||
///
|
||||
/// The given shader is applied to the object's rasterization in the given
|
||||
/// rectangle using the given blend mode.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayer}
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
@override
|
||||
ShaderMaskEngineLayer pushShaderMask(
|
||||
Shader shader,
|
||||
Rect maskRect,
|
||||
@@ -566,7 +809,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
FilterQuality filterQuality = FilterQuality.low,
|
||||
}) {
|
||||
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushShaderMask'));
|
||||
final EngineLayer engineLayer = EngineLayer._();
|
||||
final EngineLayer engineLayer = _NativeEngineLayer._();
|
||||
_pushShaderMask(
|
||||
engineLayer,
|
||||
shader,
|
||||
@@ -595,12 +838,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
int filterQualityIndex,
|
||||
EngineLayer? oldLayer);
|
||||
|
||||
/// Ends the effect of the most recently pushed operation.
|
||||
///
|
||||
/// Internally the scene builder maintains a stack of operations. Each of the
|
||||
/// operations in the stack applies to each of the objects added to the scene.
|
||||
/// Calling this function removes the most recently added operation from the
|
||||
/// stack.
|
||||
@override
|
||||
void pop() {
|
||||
if (_layerStack.isNotEmpty) {
|
||||
_layerStack.removeLast();
|
||||
@@ -611,16 +849,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
@Native<Void Function(Pointer<Void>)>(symbol: 'SceneBuilder::pop', isLeaf: true)
|
||||
external void _pop();
|
||||
|
||||
/// Add a retained engine layer subtree from previous frames.
|
||||
///
|
||||
/// All the engine layers that are in the subtree of the retained layer will
|
||||
/// be automatically appended to the current engine layer tree.
|
||||
///
|
||||
/// Therefore, when implementing a subclass of the [Layer] concept defined in
|
||||
/// the rendering layer of Flutter's framework, once this is called, there's
|
||||
/// no need to call [Layer.addToScene] for its children layers.
|
||||
///
|
||||
/// {@macro dart.ui.sceneBuilder.oldLayerVsRetained}
|
||||
@override
|
||||
void addRetained(EngineLayer retainedLayer) {
|
||||
assert(retainedLayer is _EngineLayerWrapper);
|
||||
assert(() {
|
||||
@@ -651,30 +880,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
@Native<Void Function(Pointer<Void>, Handle)>(symbol: 'SceneBuilder::addRetained')
|
||||
external void _addRetained(EngineLayer retainedLayer);
|
||||
|
||||
/// Adds an object to the scene that displays performance statistics.
|
||||
///
|
||||
/// Useful during development to assess the performance of the application.
|
||||
/// The enabledOptions controls which statistics are displayed. The bounds
|
||||
/// controls where the statistics are displayed.
|
||||
///
|
||||
/// enabledOptions is a bit field with the following bits defined:
|
||||
/// - 0x01: displayRasterizerStatistics - show raster thread frame time
|
||||
/// - 0x02: visualizeRasterizerStatistics - graph raster thread frame times
|
||||
/// - 0x04: displayEngineStatistics - show UI thread frame time
|
||||
/// - 0x08: visualizeEngineStatistics - graph UI thread frame times
|
||||
/// Set enabledOptions to 0x0F to enable all the currently defined features.
|
||||
///
|
||||
/// The "UI thread" is the thread that includes all the execution of the main
|
||||
/// Dart isolate (the isolate that can call [FlutterView.render]). The UI
|
||||
/// thread frame time is the total time spent executing the
|
||||
/// [PlatformDispatcher.onBeginFrame] callback. The "raster thread" is the
|
||||
/// thread (running on the CPU) that subsequently processes the [Scene]
|
||||
/// provided by the Dart code to turn it into GPU commands and send it to the
|
||||
/// GPU.
|
||||
///
|
||||
/// See also the [PerformanceOverlayOption] enum in the rendering library.
|
||||
/// for more details.
|
||||
// Values above must match constants in //engine/src/sky/compositor/performance_overlay_layer.h
|
||||
@override
|
||||
void addPerformanceOverlay(int enabledOptions, Rect bounds) {
|
||||
_addPerformanceOverlay(enabledOptions, bounds.left, bounds.right, bounds.top, bounds.bottom);
|
||||
}
|
||||
@@ -682,27 +888,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
@Native<Void Function(Pointer<Void>, Uint64, Double, Double, Double, Double)>(symbol: 'SceneBuilder::addPerformanceOverlay', isLeaf: true)
|
||||
external void _addPerformanceOverlay(int enabledOptions, double left, double right, double top, double bottom);
|
||||
|
||||
/// Adds a [Picture] to the scene.
|
||||
///
|
||||
/// The picture is rasterized at the given `offset`.
|
||||
///
|
||||
/// The rendering _may_ be cached to reduce the cost of painting the picture
|
||||
/// if it is reused in subsequent frames. Whether a picture is cached or not
|
||||
/// depends on the backend implementation. When caching is considered, the
|
||||
/// choice to cache or not cache is a heuristic based on how often the picture
|
||||
/// is being painted and the cost of painting the picture. To disable this
|
||||
/// caching, set `willChangeHint` to true. To force the caching to happen (in
|
||||
/// backends that do caching), set `isComplexHint` to true. When both are set,
|
||||
/// `willChangeHint` prevails.
|
||||
///
|
||||
/// In general, setting these hints is not very useful. Backends that cache
|
||||
/// pictures only do so for pictures that have been rendered three times
|
||||
/// already; setting `willChangeHint` to true to avoid caching an animating
|
||||
/// picture that changes every frame is therefore redundant, the picture
|
||||
/// wouldn't have been cached anyway. Similarly, backends that cache pictures
|
||||
/// are relatively aggressive about doing so, such that any image complicated
|
||||
/// enough to warrant caching is probably already being cached even without
|
||||
/// `isComplexHint` being set to true.
|
||||
@override
|
||||
void addPicture(
|
||||
Offset offset,
|
||||
Picture picture, {
|
||||
@@ -711,23 +897,13 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
}) {
|
||||
assert(!picture.debugDisposed);
|
||||
final int hints = (isComplexHint ? 1 : 0) | (willChangeHint ? 2 : 0);
|
||||
_addPicture(offset.dx, offset.dy, picture, hints);
|
||||
_addPicture(offset.dx, offset.dy, picture as _NativePicture, hints);
|
||||
}
|
||||
|
||||
@Native<Void Function(Pointer<Void>, Double, Double, Pointer<Void>, Int32)>(symbol: 'SceneBuilder::addPicture')
|
||||
external void _addPicture(double dx, double dy, Picture picture, int hints);
|
||||
external void _addPicture(double dx, double dy, _NativePicture picture, int hints);
|
||||
|
||||
/// Adds a backend texture to the scene.
|
||||
///
|
||||
/// The texture is scaled to the given size and rasterized at the given offset.
|
||||
///
|
||||
/// If `freeze` is true the texture that is added to the scene will not
|
||||
/// be updated with new frames. `freeze` is used when resizing an embedded
|
||||
/// Android view: When resizing an Android view there is a short period during
|
||||
/// which the framework cannot tell if the newest texture frame has the
|
||||
/// previous or new size, to workaround this the framework "freezes" the
|
||||
/// texture just before resizing the Android view and un-freezes it when it is
|
||||
/// certain that a frame with the new size is ready.
|
||||
@override
|
||||
void addTexture(
|
||||
int textureId, {
|
||||
Offset offset = Offset.zero,
|
||||
@@ -742,22 +918,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
@Native<Void Function(Pointer<Void>, Double, Double, Double, Double, Int64, Bool, Int32)>(symbol: 'SceneBuilder::addTexture', isLeaf: true)
|
||||
external void _addTexture(double dx, double dy, double width, double height, int textureId, bool freeze, int filterQuality);
|
||||
|
||||
/// Adds a platform view (e.g an iOS UIView) to the scene.
|
||||
///
|
||||
/// On iOS this layer splits the current output surface into two surfaces, one for the scene nodes
|
||||
/// preceding the platform view, and one for the scene nodes following the platform view.
|
||||
///
|
||||
/// ## Performance impact
|
||||
///
|
||||
/// Adding an additional surface doubles the amount of graphics memory directly used by Flutter
|
||||
/// for output buffers. Quartz might allocated extra buffers for compositing the Flutter surfaces
|
||||
/// and the platform view.
|
||||
///
|
||||
/// With a platform view in the scene, Quartz has to composite the two Flutter surfaces and the
|
||||
/// embedded UIView. In addition to that, on iOS versions greater than 9, the Flutter frames are
|
||||
/// synchronized with the UIView frames adding additional performance overhead.
|
||||
///
|
||||
/// The `offset` argument is not used for iOS and Android.
|
||||
@override
|
||||
void addPlatformView(
|
||||
int viewId, {
|
||||
Offset offset = Offset.zero,
|
||||
@@ -770,50 +931,21 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
|
||||
@Native<Void Function(Pointer<Void>, Double, Double, Double, Double, Int64)>(symbol: 'SceneBuilder::addPlatformView', isLeaf: true)
|
||||
external void _addPlatformView(double dx, double dy, double width, double height, int viewId);
|
||||
|
||||
/// Sets a threshold after which additional debugging information should be recorded.
|
||||
///
|
||||
/// Currently this interface is difficult to use by end-developers. If you're
|
||||
/// interested in using this feature, please contact [flutter-dev](https://groups.google.com/forum/#!forum/flutter-dev).
|
||||
/// We'll hopefully be able to figure out how to make this feature more useful
|
||||
/// to you.
|
||||
@override
|
||||
@Native<Void Function(Pointer<Void>, Uint32)>(symbol: 'SceneBuilder::setRasterizerTracingThreshold', isLeaf: true)
|
||||
external void setRasterizerTracingThreshold(int frameInterval);
|
||||
|
||||
/// Sets whether the raster cache should checkerboard cached entries. This is
|
||||
/// only useful for debugging purposes.
|
||||
///
|
||||
/// The compositor can sometimes decide to cache certain portions of the
|
||||
/// widget hierarchy. Such portions typically don't change often from frame to
|
||||
/// frame and are expensive to render. This can speed up overall rendering. However,
|
||||
/// there is certain upfront cost to constructing these cache entries. And, if
|
||||
/// the cache entries are not used very often, this cost may not be worth the
|
||||
/// speedup in rendering of subsequent frames. If the developer wants to be certain
|
||||
/// that populating the raster cache is not causing stutters, this option can be
|
||||
/// set. Depending on the observations made, hints can be provided to the compositor
|
||||
/// that aid it in making better decisions about caching.
|
||||
///
|
||||
/// Currently this interface is difficult to use by end-developers. If you're
|
||||
/// interested in using this feature, please contact [flutter-dev](https://groups.google.com/forum/#!forum/flutter-dev).
|
||||
@override
|
||||
@Native<Void Function(Pointer<Void>, Bool)>(symbol: 'SceneBuilder::setCheckerboardRasterCacheImages', isLeaf: true)
|
||||
external void setCheckerboardRasterCacheImages(bool checkerboard);
|
||||
|
||||
/// Sets whether the compositor should checkerboard layers that are rendered
|
||||
/// to offscreen bitmaps.
|
||||
///
|
||||
/// This is only useful for debugging purposes.
|
||||
@override
|
||||
@Native<Void Function(Pointer<Void>, Bool)>(symbol: 'SceneBuilder::setCheckerboardOffscreenLayers', isLeaf: true)
|
||||
external void setCheckerboardOffscreenLayers(bool checkerboard);
|
||||
|
||||
/// Finishes building the scene.
|
||||
///
|
||||
/// Returns a [Scene] containing the objects that have been added to
|
||||
/// this scene builder. The [Scene] can then be displayed on the
|
||||
/// screen with [FlutterView.render].
|
||||
///
|
||||
/// After calling this function, the scene builder object is invalid and
|
||||
/// cannot be used further.
|
||||
@override
|
||||
Scene build() {
|
||||
final Scene scene = Scene._();
|
||||
final Scene scene = _NativeScene._();
|
||||
_build(scene);
|
||||
return scene;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
part of dart.ui;
|
||||
|
||||
/// A composable [SceneNode].
|
||||
class SceneNode extends NativeFieldWrapperClass1 {
|
||||
base class SceneNode extends NativeFieldWrapperClass1 {
|
||||
@pragma('vm:entry-point')
|
||||
SceneNode._create() {
|
||||
_constructor();
|
||||
@@ -178,7 +178,7 @@ class SceneNodeValue {
|
||||
///
|
||||
/// Instances of this class can be obtained from the
|
||||
/// [SceneNode.sceneShader] method.
|
||||
class SceneShader extends Shader {
|
||||
base class SceneShader extends Shader {
|
||||
SceneShader._(SceneNode node, { String? debugName }) : _debugName = debugName, super._() {
|
||||
_constructor(node);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -820,10 +820,10 @@ class PlatformDispatcher {
|
||||
semantics, use PlatformDispatcher.instance.views to get a [FlutterView] and
|
||||
call `updateSemantics`.
|
||||
''')
|
||||
void updateSemantics(SemanticsUpdate update) => _updateSemantics(update);
|
||||
void updateSemantics(SemanticsUpdate update) => _updateSemantics(update as _NativeSemanticsUpdate);
|
||||
|
||||
@Native<Void Function(Pointer<Void>)>(symbol: 'PlatformConfigurationNativeApi::UpdateSemantics')
|
||||
external static void _updateSemantics(SemanticsUpdate update);
|
||||
external static void _updateSemantics(_NativeSemanticsUpdate update);
|
||||
|
||||
/// The system-reported default locale of the device.
|
||||
///
|
||||
|
||||
@@ -585,7 +585,7 @@ class SemanticsFlag {
|
||||
/// spell out the string character by character when announcing the string.
|
||||
/// * [LocaleStringAttribute], which causes the assistive technologies to
|
||||
/// treat the string in the specific language.
|
||||
abstract class StringAttribute extends NativeFieldWrapperClass1 {
|
||||
abstract base class StringAttribute extends NativeFieldWrapperClass1 {
|
||||
StringAttribute._({
|
||||
required this.range,
|
||||
});
|
||||
@@ -611,7 +611,7 @@ abstract class StringAttribute extends NativeFieldWrapperClass1 {
|
||||
/// * [AttributedString], where the string attributes are used.
|
||||
/// * [LocaleStringAttribute], which causes the assistive technologies to
|
||||
/// treat the string in the specific language.
|
||||
class SpellOutStringAttribute extends StringAttribute {
|
||||
base class SpellOutStringAttribute extends StringAttribute {
|
||||
/// Creates a string attribute that denotes the text in [range] must be
|
||||
/// spell out when the assistive technologies announce the string.
|
||||
SpellOutStringAttribute({
|
||||
@@ -642,7 +642,7 @@ class SpellOutStringAttribute extends StringAttribute {
|
||||
/// * [AttributedString], where the string attributes are used.
|
||||
/// * [SpellOutStringAttribute], which causes the assistive technologies to
|
||||
/// spell out the string character by character when announcing the string.
|
||||
class LocaleStringAttribute extends StringAttribute {
|
||||
base class LocaleStringAttribute extends StringAttribute {
|
||||
/// Creates a string attribute that denotes the text in [range] must be
|
||||
/// treated as the language specified by the [locale] when the assistive
|
||||
/// technologies announce the string.
|
||||
@@ -675,14 +675,9 @@ class LocaleStringAttribute extends StringAttribute {
|
||||
/// Once created, the [SemanticsUpdate] objects can be passed to
|
||||
/// [PlatformDispatcher.updateSemantics] to update the semantics conveyed to the
|
||||
/// user.
|
||||
@pragma('vm:entry-point')
|
||||
class SemanticsUpdateBuilder extends NativeFieldWrapperClass1 {
|
||||
abstract class SemanticsUpdateBuilder {
|
||||
/// Creates an empty [SemanticsUpdateBuilder] object.
|
||||
@pragma('vm:entry-point')
|
||||
SemanticsUpdateBuilder() { _constructor(); }
|
||||
|
||||
@Native<Void Function(Handle)>(symbol: 'SemanticsUpdateBuilder::Create')
|
||||
external void _constructor();
|
||||
factory SemanticsUpdateBuilder() = _NativeSemanticsUpdateBuilder;
|
||||
|
||||
/// Update the information associated with the node with the given `id`.
|
||||
///
|
||||
@@ -765,6 +760,77 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass1 {
|
||||
/// z-direction starting at `elevation`. Basically, in the z-direction the
|
||||
/// node starts at `elevation` above the parent and ends at `elevation` +
|
||||
/// `thickness` above the parent.
|
||||
void updateNode({
|
||||
required int id,
|
||||
required int flags,
|
||||
required int actions,
|
||||
required int maxValueLength,
|
||||
required int currentValueLength,
|
||||
required int textSelectionBase,
|
||||
required int textSelectionExtent,
|
||||
required int platformViewId,
|
||||
required int scrollChildren,
|
||||
required int scrollIndex,
|
||||
required double scrollPosition,
|
||||
required double scrollExtentMax,
|
||||
required double scrollExtentMin,
|
||||
required double elevation,
|
||||
required double thickness,
|
||||
required Rect rect,
|
||||
required String label,
|
||||
required List<StringAttribute> labelAttributes,
|
||||
required String value,
|
||||
required List<StringAttribute> valueAttributes,
|
||||
required String increasedValue,
|
||||
required List<StringAttribute> increasedValueAttributes,
|
||||
required String decreasedValue,
|
||||
required List<StringAttribute> decreasedValueAttributes,
|
||||
required String hint,
|
||||
required List<StringAttribute> hintAttributes,
|
||||
String? tooltip,
|
||||
TextDirection? textDirection,
|
||||
required Float64List transform,
|
||||
required Int32List childrenInTraversalOrder,
|
||||
required Int32List childrenInHitTestOrder,
|
||||
required Int32List additionalActions,
|
||||
});
|
||||
|
||||
/// Update the custom semantics action associated with the given `id`.
|
||||
///
|
||||
/// The name of the action exposed to the user is the `label`. For overridden
|
||||
/// standard actions this value is ignored.
|
||||
///
|
||||
/// The `hint` should describe what happens when an action occurs, not the
|
||||
/// manner in which a tap is accomplished. For example, use "delete" instead
|
||||
/// of "double tap to delete".
|
||||
///
|
||||
/// The text direction of the `hint` and `label` is the same as the global
|
||||
/// window.
|
||||
///
|
||||
/// For overridden standard actions, `overrideId` corresponds with a
|
||||
/// [SemanticsAction.index] value. For custom actions this argument should not be
|
||||
/// provided.
|
||||
void updateCustomAction({required int id, String? label, String? hint, int overrideId = -1});
|
||||
|
||||
/// Creates a [SemanticsUpdate] object that encapsulates the updates recorded
|
||||
/// by this object.
|
||||
///
|
||||
/// The returned object can be passed to [PlatformDispatcher.updateSemantics]
|
||||
/// to actually update the semantics retained by the system.
|
||||
///
|
||||
/// This object is unusable after calling build.
|
||||
SemanticsUpdate build();
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
base class _NativeSemanticsUpdateBuilder extends NativeFieldWrapperClass1 implements SemanticsUpdateBuilder {
|
||||
@pragma('vm:entry-point')
|
||||
_NativeSemanticsUpdateBuilder() { _constructor(); }
|
||||
|
||||
@Native<Void Function(Handle)>(symbol: 'SemanticsUpdateBuilder::Create')
|
||||
external void _constructor();
|
||||
|
||||
@override
|
||||
void updateNode({
|
||||
required int id,
|
||||
required int flags,
|
||||
@@ -913,41 +979,21 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass1 {
|
||||
Int32List childrenInHitTestOrder,
|
||||
Int32List additionalActions);
|
||||
|
||||
/// Update the custom semantics action associated with the given `id`.
|
||||
///
|
||||
/// The name of the action exposed to the user is the `label`. For overridden
|
||||
/// standard actions this value is ignored.
|
||||
///
|
||||
/// The `hint` should describe what happens when an action occurs, not the
|
||||
/// manner in which a tap is accomplished. For example, use "delete" instead
|
||||
/// of "double tap to delete".
|
||||
///
|
||||
/// The text direction of the `hint` and `label` is the same as the global
|
||||
/// window.
|
||||
///
|
||||
/// For overridden standard actions, `overrideId` corresponds with a
|
||||
/// [SemanticsAction.index] value. For custom actions this argument should not be
|
||||
/// provided.
|
||||
@override
|
||||
void updateCustomAction({required int id, String? label, String? hint, int overrideId = -1}) {
|
||||
_updateCustomAction(id, label ?? '', hint ?? '', overrideId);
|
||||
}
|
||||
@Native<Void Function(Pointer<Void>, Int32, Handle, Handle, Int32)>(symbol: 'SemanticsUpdateBuilder::updateCustomAction')
|
||||
external void _updateCustomAction(int id, String label, String hint, int overrideId);
|
||||
|
||||
/// Creates a [SemanticsUpdate] object that encapsulates the updates recorded
|
||||
/// by this object.
|
||||
///
|
||||
/// The returned object can be passed to [PlatformDispatcher.updateSemantics]
|
||||
/// to actually update the semantics retained by the system.
|
||||
///
|
||||
/// This object is unusable after calling build.
|
||||
@override
|
||||
SemanticsUpdate build() {
|
||||
final SemanticsUpdate semanticsUpdate = SemanticsUpdate._();
|
||||
final _NativeSemanticsUpdate semanticsUpdate = _NativeSemanticsUpdate._();
|
||||
_build(semanticsUpdate);
|
||||
return semanticsUpdate;
|
||||
}
|
||||
@Native<Void Function(Pointer<Void>, Handle)>(symbol: 'SemanticsUpdateBuilder::build')
|
||||
external void _build(SemanticsUpdate outSemanticsUpdate);
|
||||
external void _build(_NativeSemanticsUpdate outSemanticsUpdate);
|
||||
}
|
||||
|
||||
/// An opaque object representing a batch of semantics updates.
|
||||
@@ -956,15 +1002,7 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass1 {
|
||||
///
|
||||
/// Semantics updates can be applied to the system's retained semantics tree
|
||||
/// using the [PlatformDispatcher.updateSemantics] method.
|
||||
@pragma('vm:entry-point')
|
||||
class SemanticsUpdate extends NativeFieldWrapperClass1 {
|
||||
/// This class is created by the engine, and should not be instantiated
|
||||
/// or extended directly.
|
||||
///
|
||||
/// To create a SemanticsUpdate object, use a [SemanticsUpdateBuilder].
|
||||
@pragma('vm:entry-point')
|
||||
SemanticsUpdate._();
|
||||
|
||||
abstract class SemanticsUpdate {
|
||||
/// Releases the resources used by this semantics update.
|
||||
///
|
||||
/// After calling this function, the semantics update is cannot be used
|
||||
@@ -972,6 +1010,19 @@ class SemanticsUpdate extends NativeFieldWrapperClass1 {
|
||||
///
|
||||
/// This can't be a leaf call because the native function calls Dart API
|
||||
/// (Dart_SetNativeInstanceField).
|
||||
void dispose();
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
base class _NativeSemanticsUpdate extends NativeFieldWrapperClass1 implements SemanticsUpdate {
|
||||
/// This class is created by the engine, and should not be instantiated
|
||||
/// or extended directly.
|
||||
///
|
||||
/// To create a SemanticsUpdate object, use a [SemanticsUpdateBuilder].
|
||||
@pragma('vm:entry-point')
|
||||
_NativeSemanticsUpdate._();
|
||||
|
||||
@override
|
||||
@Native<Void Function(Pointer<Void>)>(symbol: 'SemanticsUpdate::dispose')
|
||||
external void dispose();
|
||||
}
|
||||
|
||||
@@ -2677,59 +2677,42 @@ class LineMetrics {
|
||||
///
|
||||
/// Paragraphs can be displayed on a [Canvas] using the [Canvas.drawParagraph]
|
||||
/// method.
|
||||
@pragma('vm:entry-point')
|
||||
class Paragraph extends NativeFieldWrapperClass1 {
|
||||
/// This class is created by the engine, and should not be instantiated
|
||||
/// or extended directly.
|
||||
///
|
||||
/// To create a [Paragraph] object, use a [ParagraphBuilder].
|
||||
@pragma('vm:entry-point')
|
||||
Paragraph._();
|
||||
|
||||
bool _needsLayout = true;
|
||||
|
||||
abstract class Paragraph {
|
||||
/// The amount of horizontal space this paragraph occupies.
|
||||
///
|
||||
/// Valid only after [layout] has been called.
|
||||
@Native<Double Function(Pointer<Void>)>(symbol: 'Paragraph::width', isLeaf: true)
|
||||
external double get width;
|
||||
double get width;
|
||||
|
||||
/// The amount of vertical space this paragraph occupies.
|
||||
///
|
||||
/// Valid only after [layout] has been called.
|
||||
@Native<Double Function(Pointer<Void>)>(symbol: 'Paragraph::height', isLeaf: true)
|
||||
external double get height;
|
||||
double get height;
|
||||
|
||||
/// The distance from the left edge of the leftmost glyph to the right edge of
|
||||
/// the rightmost glyph in the paragraph.
|
||||
///
|
||||
/// Valid only after [layout] has been called.
|
||||
@Native<Double Function(Pointer<Void>)>(symbol: 'Paragraph::longestLine', isLeaf: true)
|
||||
external double get longestLine;
|
||||
double get longestLine;
|
||||
|
||||
/// The minimum width that this paragraph could be without failing to paint
|
||||
/// its contents within itself.
|
||||
///
|
||||
/// Valid only after [layout] has been called.
|
||||
@Native<Double Function(Pointer<Void>)>(symbol: 'Paragraph::minIntrinsicWidth', isLeaf: true)
|
||||
external double get minIntrinsicWidth;
|
||||
double get minIntrinsicWidth;
|
||||
|
||||
/// Returns the smallest width beyond which increasing the width never
|
||||
/// decreases the height.
|
||||
///
|
||||
/// Valid only after [layout] has been called.
|
||||
@Native<Double Function(Pointer<Void>)>(symbol: 'Paragraph::maxIntrinsicWidth', isLeaf: true)
|
||||
external double get maxIntrinsicWidth;
|
||||
double get maxIntrinsicWidth;
|
||||
|
||||
/// The distance from the top of the paragraph to the alphabetic
|
||||
/// baseline of the first line, in logical pixels.
|
||||
@Native<Double Function(Pointer<Void>)>(symbol: 'Paragraph::alphabeticBaseline', isLeaf: true)
|
||||
external double get alphabeticBaseline;
|
||||
double get alphabeticBaseline;
|
||||
|
||||
/// The distance from the top of the paragraph to the ideographic
|
||||
/// baseline of the first line, in logical pixels.
|
||||
@Native<Double Function(Pointer<Void>)>(symbol: 'Paragraph::ideographicBaseline', isLeaf: true)
|
||||
external double get ideographicBaseline;
|
||||
double get ideographicBaseline;
|
||||
|
||||
/// True if there is more vertical content, but the text was truncated, either
|
||||
/// because we reached `maxLines` lines of text or because the `maxLines` was
|
||||
@@ -2738,12 +2721,128 @@ class Paragraph extends NativeFieldWrapperClass1 {
|
||||
///
|
||||
/// See the discussion of the `maxLines` and `ellipsis` arguments at
|
||||
/// [ParagraphStyle.new].
|
||||
@Native<Bool Function(Pointer<Void>)>(symbol: 'Paragraph::didExceedMaxLines', isLeaf: true)
|
||||
external bool get didExceedMaxLines;
|
||||
bool get didExceedMaxLines;
|
||||
|
||||
/// Computes the size and position of each glyph in the paragraph.
|
||||
///
|
||||
/// The [ParagraphConstraints] control how wide the text is allowed to be.
|
||||
void layout(ParagraphConstraints constraints);
|
||||
|
||||
/// Returns a list of text boxes that enclose the given text range.
|
||||
///
|
||||
/// The [boxHeightStyle] and [boxWidthStyle] parameters allow customization
|
||||
/// of how the boxes are bound vertically and horizontally. Both style
|
||||
/// parameters default to the tight option, which will provide close-fitting
|
||||
/// boxes and will not account for any line spacing.
|
||||
///
|
||||
/// Coordinates of the TextBox are relative to the upper-left corner of the paragraph,
|
||||
/// where positive y values indicate down.
|
||||
///
|
||||
/// The [boxHeightStyle] and [boxWidthStyle] parameters must not be null.
|
||||
///
|
||||
/// See [BoxHeightStyle] and [BoxWidthStyle] for full descriptions of each option.
|
||||
List<TextBox> getBoxesForRange(int start, int end, {BoxHeightStyle boxHeightStyle = BoxHeightStyle.tight, BoxWidthStyle boxWidthStyle = BoxWidthStyle.tight});
|
||||
|
||||
/// Returns a list of text boxes that enclose all placeholders in the paragraph.
|
||||
///
|
||||
/// The order of the boxes are in the same order as passed in through
|
||||
/// [ParagraphBuilder.addPlaceholder].
|
||||
///
|
||||
/// Coordinates of the [TextBox] are relative to the upper-left corner of the paragraph,
|
||||
/// where positive y values indicate down.
|
||||
List<TextBox> getBoxesForPlaceholders();
|
||||
|
||||
/// Returns the text position closest to the given offset.
|
||||
TextPosition getPositionForOffset(Offset offset);
|
||||
|
||||
/// Returns the [TextRange] of the word at the given [TextPosition].
|
||||
///
|
||||
/// Characters not part of a word, such as spaces, symbols, and punctuation,
|
||||
/// have word breaks on both sides. In such cases, this method will return
|
||||
/// (offset, offset+1). Word boundaries are defined more precisely in Unicode
|
||||
/// Standard Annex #29 http://www.unicode.org/reports/tr29/#Word_Boundaries
|
||||
///
|
||||
/// The [TextPosition] is treated as caret position, its [TextPosition.affinity]
|
||||
/// is used to determine which character this position points to. For example,
|
||||
/// the word boundary at `TextPosition(offset: 5, affinity: TextPosition.upstream)`
|
||||
/// of the `string = 'Hello word'` will return range (0, 5) because the position
|
||||
/// points to the character 'o' instead of the space.
|
||||
TextRange getWordBoundary(TextPosition position);
|
||||
|
||||
/// Returns the [TextRange] of the line at the given [TextPosition].
|
||||
///
|
||||
/// The newline (if any) is returned as part of the range.
|
||||
///
|
||||
/// Not valid until after layout.
|
||||
///
|
||||
/// This can potentially be expensive, since it needs to compute the line
|
||||
/// metrics, so use it sparingly.
|
||||
TextRange getLineBoundary(TextPosition position);
|
||||
|
||||
/// Returns the full list of [LineMetrics] that describe in detail the various
|
||||
/// metrics of each laid out line.
|
||||
///
|
||||
/// Not valid until after layout.
|
||||
///
|
||||
/// This can potentially return a large amount of data, so it is not recommended
|
||||
/// to repeatedly call this. Instead, cache the results.
|
||||
List<LineMetrics> computeLineMetrics();
|
||||
|
||||
/// Release the resources used by this object. The object is no longer usable
|
||||
/// after this method is called.
|
||||
void dispose();
|
||||
|
||||
/// Whether this reference to the underlying picture is [dispose]d.
|
||||
///
|
||||
/// This only returns a valid value if asserts are enabled, and must not be
|
||||
/// used otherwise.
|
||||
bool get debugDisposed;
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
base class _NativeParagraph extends NativeFieldWrapperClass1 implements Paragraph {
|
||||
/// This class is created by the engine, and should not be instantiated
|
||||
/// or extended directly.
|
||||
///
|
||||
/// To create a [Paragraph] object, use a [ParagraphBuilder].
|
||||
@pragma('vm:entry-point')
|
||||
_NativeParagraph._();
|
||||
|
||||
bool _needsLayout = true;
|
||||
|
||||
@override
|
||||
@Native<Double Function(Pointer<Void>)>(symbol: 'Paragraph::width', isLeaf: true)
|
||||
external double get width;
|
||||
|
||||
@override
|
||||
@Native<Double Function(Pointer<Void>)>(symbol: 'Paragraph::height', isLeaf: true)
|
||||
external double get height;
|
||||
|
||||
@override
|
||||
@Native<Double Function(Pointer<Void>)>(symbol: 'Paragraph::longestLine', isLeaf: true)
|
||||
external double get longestLine;
|
||||
|
||||
@override
|
||||
@Native<Double Function(Pointer<Void>)>(symbol: 'Paragraph::minIntrinsicWidth', isLeaf: true)
|
||||
external double get minIntrinsicWidth;
|
||||
|
||||
@override
|
||||
@Native<Double Function(Pointer<Void>)>(symbol: 'Paragraph::maxIntrinsicWidth', isLeaf: true)
|
||||
external double get maxIntrinsicWidth;
|
||||
|
||||
@override
|
||||
@Native<Double Function(Pointer<Void>)>(symbol: 'Paragraph::alphabeticBaseline', isLeaf: true)
|
||||
external double get alphabeticBaseline;
|
||||
|
||||
@override
|
||||
@Native<Double Function(Pointer<Void>)>(symbol: 'Paragraph::ideographicBaseline', isLeaf: true)
|
||||
external double get ideographicBaseline;
|
||||
|
||||
@override
|
||||
@Native<Bool Function(Pointer<Void>)>(symbol: 'Paragraph::didExceedMaxLines', isLeaf: true)
|
||||
external bool get didExceedMaxLines;
|
||||
|
||||
@override
|
||||
void layout(ParagraphConstraints constraints) {
|
||||
_layout(constraints.width);
|
||||
assert(() {
|
||||
@@ -2770,19 +2869,7 @@ class Paragraph extends NativeFieldWrapperClass1 {
|
||||
return boxes;
|
||||
}
|
||||
|
||||
/// Returns a list of text boxes that enclose the given text range.
|
||||
///
|
||||
/// The [boxHeightStyle] and [boxWidthStyle] parameters allow customization
|
||||
/// of how the boxes are bound vertically and horizontally. Both style
|
||||
/// parameters default to the tight option, which will provide close-fitting
|
||||
/// boxes and will not account for any line spacing.
|
||||
///
|
||||
/// Coordinates of the TextBox are relative to the upper-left corner of the paragraph,
|
||||
/// where positive y values indicate down.
|
||||
///
|
||||
/// The [boxHeightStyle] and [boxWidthStyle] parameters must not be null.
|
||||
///
|
||||
/// See [BoxHeightStyle] and [BoxWidthStyle] for full descriptions of each option.
|
||||
@override
|
||||
List<TextBox> getBoxesForRange(int start, int end, {BoxHeightStyle boxHeightStyle = BoxHeightStyle.tight, BoxWidthStyle boxWidthStyle = BoxWidthStyle.tight}) {
|
||||
return _decodeTextBoxes(_getBoxesForRange(start, end, boxHeightStyle.index, boxWidthStyle.index));
|
||||
}
|
||||
@@ -2791,13 +2878,7 @@ class Paragraph extends NativeFieldWrapperClass1 {
|
||||
@Native<Handle Function(Pointer<Void>, Uint32, Uint32, Uint32, Uint32)>(symbol: 'Paragraph::getRectsForRange')
|
||||
external Float32List _getBoxesForRange(int start, int end, int boxHeightStyle, int boxWidthStyle);
|
||||
|
||||
/// Returns a list of text boxes that enclose all placeholders in the paragraph.
|
||||
///
|
||||
/// The order of the boxes are in the same order as passed in through
|
||||
/// [ParagraphBuilder.addPlaceholder].
|
||||
///
|
||||
/// Coordinates of the [TextBox] are relative to the upper-left corner of the paragraph,
|
||||
/// where positive y values indicate down.
|
||||
@override
|
||||
List<TextBox> getBoxesForPlaceholders() {
|
||||
return _decodeTextBoxes(_getBoxesForPlaceholders());
|
||||
}
|
||||
@@ -2805,7 +2886,7 @@ class Paragraph extends NativeFieldWrapperClass1 {
|
||||
@Native<Handle Function(Pointer<Void>)>(symbol: 'Paragraph::getRectsForPlaceholders')
|
||||
external Float32List _getBoxesForPlaceholders();
|
||||
|
||||
/// Returns the text position closest to the given offset.
|
||||
@override
|
||||
TextPosition getPositionForOffset(Offset offset) {
|
||||
final List<int> encoded = _getPositionForOffset(offset.dx, offset.dy);
|
||||
return TextPosition(offset: encoded[0], affinity: TextAffinity.values[encoded[1]]);
|
||||
@@ -2814,18 +2895,7 @@ class Paragraph extends NativeFieldWrapperClass1 {
|
||||
@Native<Handle Function(Pointer<Void>, Double, Double)>(symbol: 'Paragraph::getPositionForOffset')
|
||||
external List<int> _getPositionForOffset(double dx, double dy);
|
||||
|
||||
/// Returns the [TextRange] of the word at the given [TextPosition].
|
||||
///
|
||||
/// Characters not part of a word, such as spaces, symbols, and punctuation,
|
||||
/// have word breaks on both sides. In such cases, this method will return
|
||||
/// (offset, offset+1). Word boundaries are defined more precisely in Unicode
|
||||
/// Standard Annex #29 http://www.unicode.org/reports/tr29/#Word_Boundaries
|
||||
///
|
||||
/// The [TextPosition] is treated as caret position, its [TextPosition.affinity]
|
||||
/// is used to determine which character this position points to. For example,
|
||||
/// the word boundary at `TextPosition(offset: 5, affinity: TextPosition.upstream)`
|
||||
/// of the `string = 'Hello word'` will return range (0, 5) because the position
|
||||
/// points to the character 'o' instead of the space.
|
||||
@override
|
||||
TextRange getWordBoundary(TextPosition position) {
|
||||
final int characterPosition;
|
||||
switch (position.affinity) {
|
||||
@@ -2841,14 +2911,7 @@ class Paragraph extends NativeFieldWrapperClass1 {
|
||||
@Native<Handle Function(Pointer<Void>, Uint32)>(symbol: 'Paragraph::getWordBoundary')
|
||||
external List<int> _getWordBoundary(int offset);
|
||||
|
||||
/// Returns the [TextRange] of the line at the given [TextPosition].
|
||||
///
|
||||
/// The newline (if any) is returned as part of the range.
|
||||
///
|
||||
/// Not valid until after layout.
|
||||
///
|
||||
/// This can potentially be expensive, since it needs to compute the line
|
||||
/// metrics, so use it sparingly.
|
||||
@override
|
||||
TextRange getLineBoundary(TextPosition position) {
|
||||
final List<int> boundary = _getLineBoundary(position.offset);
|
||||
final TextRange line = TextRange(start: boundary[0], end: boundary[1]);
|
||||
@@ -2877,15 +2940,9 @@ class Paragraph extends NativeFieldWrapperClass1 {
|
||||
// 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(Canvas canvas, double x, double y);
|
||||
external void _paint(_NativeCanvas canvas, double x, double y);
|
||||
|
||||
/// Returns the full list of [LineMetrics] that describe in detail the various
|
||||
/// metrics of each laid out line.
|
||||
///
|
||||
/// Not valid until after layout.
|
||||
///
|
||||
/// This can potentially return a large amount of data, so it is not recommended
|
||||
/// to repeatedly call this. Instead, cache the results.
|
||||
@override
|
||||
List<LineMetrics> computeLineMetrics() {
|
||||
final Float64List encoded = _computeLineMetrics();
|
||||
final int count = encoded.length ~/ 9;
|
||||
@@ -2910,8 +2967,7 @@ class Paragraph extends NativeFieldWrapperClass1 {
|
||||
@Native<Handle Function(Pointer<Void>)>(symbol: 'Paragraph::computeLineMetrics')
|
||||
external Float64List _computeLineMetrics();
|
||||
|
||||
/// Release the resources used by this object. The object is no longer usable
|
||||
/// after this method is called.
|
||||
@override
|
||||
void dispose() {
|
||||
assert(!_disposed);
|
||||
assert(() {
|
||||
@@ -2927,10 +2983,8 @@ class Paragraph extends NativeFieldWrapperClass1 {
|
||||
external void _dispose();
|
||||
|
||||
bool _disposed = false;
|
||||
/// Whether this reference to the underlying picture is [dispose]d.
|
||||
///
|
||||
/// This only returns a valid value if asserts are enabled, and must not be
|
||||
/// used otherwise.
|
||||
|
||||
@override
|
||||
bool get debugDisposed {
|
||||
bool? disposed;
|
||||
assert(() {
|
||||
@@ -2955,12 +3009,99 @@ class Paragraph extends NativeFieldWrapperClass1 {
|
||||
///
|
||||
/// After constructing a [Paragraph], call [Paragraph.layout] on it and then
|
||||
/// paint it with [Canvas.drawParagraph].
|
||||
class ParagraphBuilder extends NativeFieldWrapperClass1 {
|
||||
|
||||
abstract class ParagraphBuilder {
|
||||
/// Creates a new [ParagraphBuilder] object, which is used to create a
|
||||
/// [Paragraph].
|
||||
factory ParagraphBuilder(ParagraphStyle style) = _NativeParagraphBuilder;
|
||||
|
||||
/// The number of placeholders currently in the paragraph.
|
||||
int get placeholderCount;
|
||||
|
||||
/// The scales of the placeholders in the paragraph.
|
||||
List<double> get placeholderScales;
|
||||
|
||||
/// Applies the given style to the added text until [pop] is called.
|
||||
///
|
||||
/// See [pop] for details.
|
||||
void pushStyle(TextStyle style);
|
||||
|
||||
/// Ends the effect of the most recent call to [pushStyle].
|
||||
///
|
||||
/// Internally, the paragraph builder maintains a stack of text styles. Text
|
||||
/// added to the paragraph is affected by all the styles in the stack. Calling
|
||||
/// [pop] removes the topmost style in the stack, leaving the remaining styles
|
||||
/// in effect.
|
||||
void pop();
|
||||
|
||||
/// Adds the given text to the paragraph.
|
||||
///
|
||||
/// The text will be styled according to the current stack of text styles.
|
||||
void addText(String text);
|
||||
|
||||
/// Adds an inline placeholder space to the paragraph.
|
||||
///
|
||||
/// The paragraph will contain a rectangular space with no text of the dimensions
|
||||
/// specified.
|
||||
///
|
||||
/// The `width` and `height` parameters specify the size of the placeholder rectangle.
|
||||
///
|
||||
/// The `alignment` parameter specifies how the placeholder rectangle will be vertically
|
||||
/// aligned with the surrounding text. When [PlaceholderAlignment.baseline],
|
||||
/// [PlaceholderAlignment.aboveBaseline], and [PlaceholderAlignment.belowBaseline]
|
||||
/// alignment modes are used, the baseline needs to be set with the `baseline`.
|
||||
/// When using [PlaceholderAlignment.baseline], `baselineOffset` indicates the distance
|
||||
/// of the baseline down from the top of the rectangle. The default `baselineOffset`
|
||||
/// is the `height`.
|
||||
///
|
||||
/// Examples:
|
||||
///
|
||||
/// * For a 30x50 placeholder with the bottom edge aligned with the bottom of the text, use:
|
||||
/// `addPlaceholder(30, 50, PlaceholderAlignment.bottom);`
|
||||
/// * For a 30x50 placeholder that is vertically centered around the text, use:
|
||||
/// `addPlaceholder(30, 50, PlaceholderAlignment.middle);`.
|
||||
/// * For a 30x50 placeholder that sits completely on top of the alphabetic baseline, use:
|
||||
/// `addPlaceholder(30, 50, PlaceholderAlignment.aboveBaseline, baseline: TextBaseline.alphabetic)`.
|
||||
/// * For a 30x50 placeholder with 40 pixels above and 10 pixels below the alphabetic baseline, use:
|
||||
/// `addPlaceholder(30, 50, PlaceholderAlignment.baseline, baseline: TextBaseline.alphabetic, baselineOffset: 40)`.
|
||||
///
|
||||
/// Lines are permitted to break around each placeholder.
|
||||
///
|
||||
/// Decorations will be drawn based on the font defined in the most recently
|
||||
/// pushed [TextStyle]. The decorations are drawn as if unicode text were present
|
||||
/// in the placeholder space, and will draw the same regardless of the height and
|
||||
/// alignment of the placeholder. To hide or manually adjust decorations to fit,
|
||||
/// a text style with the desired decoration behavior should be pushed before
|
||||
/// adding a placeholder.
|
||||
///
|
||||
/// Any decorations drawn through a placeholder will exist on the same canvas/layer
|
||||
/// as the text. This means any content drawn on top of the space reserved by
|
||||
/// the placeholder will be drawn over the decoration, possibly obscuring the
|
||||
/// decoration.
|
||||
///
|
||||
/// Placeholders are represented by a unicode 0xFFFC "object replacement character"
|
||||
/// in the text buffer. For each placeholder, one object replacement character is
|
||||
/// added on to the text buffer.
|
||||
///
|
||||
/// The `scale` parameter will scale the `width` and `height` by the specified amount,
|
||||
/// and keep track of the scale. The scales of placeholders added can be accessed
|
||||
/// through [placeholderScales]. This is primarily used for accessibility scaling.
|
||||
void addPlaceholder(double width, double height, PlaceholderAlignment alignment, {
|
||||
double scale = 1.0,
|
||||
double? baselineOffset,
|
||||
TextBaseline? baseline,
|
||||
});
|
||||
|
||||
/// Applies the given paragraph style and returns a [Paragraph] containing the
|
||||
/// added text and associated styling.
|
||||
///
|
||||
/// After calling this function, the paragraph builder object is invalid and
|
||||
/// cannot be used further.
|
||||
Paragraph build();
|
||||
}
|
||||
|
||||
base class _NativeParagraphBuilder extends NativeFieldWrapperClass1 implements ParagraphBuilder {
|
||||
@pragma('vm:entry-point')
|
||||
ParagraphBuilder(ParagraphStyle style)
|
||||
_NativeParagraphBuilder(ParagraphStyle style)
|
||||
: _defaultLeadingDistribution = style._leadingDistribution {
|
||||
List<String>? strutFontFamilies;
|
||||
final StrutStyle? strutStyle = style._strutStyle;
|
||||
@@ -3005,18 +3146,17 @@ class ParagraphBuilder extends NativeFieldWrapperClass1 {
|
||||
String ellipsis,
|
||||
String locale);
|
||||
|
||||
/// The number of placeholders currently in the paragraph.
|
||||
@override
|
||||
int get placeholderCount => _placeholderCount;
|
||||
int _placeholderCount = 0;
|
||||
|
||||
/// The scales of the placeholders in the paragraph.
|
||||
@override
|
||||
List<double> get placeholderScales => _placeholderScales;
|
||||
final List<double> _placeholderScales = <double>[];
|
||||
|
||||
final TextLeadingDistribution _defaultLeadingDistribution;
|
||||
/// Applies the given style to the added text until [pop] is called.
|
||||
///
|
||||
/// See [pop] for details.
|
||||
|
||||
@override
|
||||
void pushStyle(TextStyle style) {
|
||||
final List<String> fullFontFamilies = <String>[];
|
||||
fullFontFamilies.add(style._fontFamily);
|
||||
@@ -3112,18 +3252,11 @@ class ParagraphBuilder extends NativeFieldWrapperClass1 {
|
||||
|
||||
static String _encodeLocale(Locale? locale) => locale?.toString() ?? '';
|
||||
|
||||
/// Ends the effect of the most recent call to [pushStyle].
|
||||
///
|
||||
/// Internally, the paragraph builder maintains a stack of text styles. Text
|
||||
/// added to the paragraph is affected by all the styles in the stack. Calling
|
||||
/// [pop] removes the topmost style in the stack, leaving the remaining styles
|
||||
/// in effect.
|
||||
@override
|
||||
@Native<Void Function(Pointer<Void>)>(symbol: 'ParagraphBuilder::pop', isLeaf: true)
|
||||
external void pop();
|
||||
|
||||
/// Adds the given text to the paragraph.
|
||||
///
|
||||
/// The text will be styled according to the current stack of text styles.
|
||||
@override
|
||||
void addText(String text) {
|
||||
final String? error = _addText(text);
|
||||
if (error != null) {
|
||||
@@ -3134,53 +3267,7 @@ class ParagraphBuilder extends NativeFieldWrapperClass1 {
|
||||
@Native<Handle Function(Pointer<Void>, Handle)>(symbol: 'ParagraphBuilder::addText')
|
||||
external String? _addText(String text);
|
||||
|
||||
/// Adds an inline placeholder space to the paragraph.
|
||||
///
|
||||
/// The paragraph will contain a rectangular space with no text of the dimensions
|
||||
/// specified.
|
||||
///
|
||||
/// The `width` and `height` parameters specify the size of the placeholder rectangle.
|
||||
///
|
||||
/// The `alignment` parameter specifies how the placeholder rectangle will be vertically
|
||||
/// aligned with the surrounding text. When [PlaceholderAlignment.baseline],
|
||||
/// [PlaceholderAlignment.aboveBaseline], and [PlaceholderAlignment.belowBaseline]
|
||||
/// alignment modes are used, the baseline needs to be set with the `baseline`.
|
||||
/// When using [PlaceholderAlignment.baseline], `baselineOffset` indicates the distance
|
||||
/// of the baseline down from the top of the rectangle. The default `baselineOffset`
|
||||
/// is the `height`.
|
||||
///
|
||||
/// Examples:
|
||||
///
|
||||
/// * For a 30x50 placeholder with the bottom edge aligned with the bottom of the text, use:
|
||||
/// `addPlaceholder(30, 50, PlaceholderAlignment.bottom);`
|
||||
/// * For a 30x50 placeholder that is vertically centered around the text, use:
|
||||
/// `addPlaceholder(30, 50, PlaceholderAlignment.middle);`.
|
||||
/// * For a 30x50 placeholder that sits completely on top of the alphabetic baseline, use:
|
||||
/// `addPlaceholder(30, 50, PlaceholderAlignment.aboveBaseline, baseline: TextBaseline.alphabetic)`.
|
||||
/// * For a 30x50 placeholder with 40 pixels above and 10 pixels below the alphabetic baseline, use:
|
||||
/// `addPlaceholder(30, 50, PlaceholderAlignment.baseline, baseline: TextBaseline.alphabetic, baselineOffset: 40)`.
|
||||
///
|
||||
/// Lines are permitted to break around each placeholder.
|
||||
///
|
||||
/// Decorations will be drawn based on the font defined in the most recently
|
||||
/// pushed [TextStyle]. The decorations are drawn as if unicode text were present
|
||||
/// in the placeholder space, and will draw the same regardless of the height and
|
||||
/// alignment of the placeholder. To hide or manually adjust decorations to fit,
|
||||
/// a text style with the desired decoration behavior should be pushed before
|
||||
/// adding a placeholder.
|
||||
///
|
||||
/// Any decorations drawn through a placeholder will exist on the same canvas/layer
|
||||
/// as the text. This means any content drawn on top of the space reserved by
|
||||
/// the placeholder will be drawn over the decoration, possibly obscuring the
|
||||
/// decoration.
|
||||
///
|
||||
/// Placeholders are represented by a unicode 0xFFFC "object replacement character"
|
||||
/// in the text buffer. For each placeholder, one object replacement character is
|
||||
/// added on to the text buffer.
|
||||
///
|
||||
/// The `scale` parameter will scale the `width` and `height` by the specified amount,
|
||||
/// and keep track of the scale. The scales of placeholders added can be accessed
|
||||
/// through [placeholderScales]. This is primarily used for accessibility scaling.
|
||||
@override
|
||||
void addPlaceholder(double width, double height, PlaceholderAlignment alignment, {
|
||||
double scale = 1.0,
|
||||
double? baselineOffset,
|
||||
@@ -3201,19 +3288,15 @@ class ParagraphBuilder extends NativeFieldWrapperClass1 {
|
||||
@Native<Void Function(Pointer<Void>, Double, Double, Uint32, Double, Uint32)>(symbol: 'ParagraphBuilder::addPlaceholder')
|
||||
external void _addPlaceholder(double width, double height, int alignment, double baselineOffset, int baseline);
|
||||
|
||||
/// Applies the given paragraph style and returns a [Paragraph] containing the
|
||||
/// added text and associated styling.
|
||||
///
|
||||
/// After calling this function, the paragraph builder object is invalid and
|
||||
/// cannot be used further.
|
||||
@override
|
||||
Paragraph build() {
|
||||
final Paragraph paragraph = Paragraph._();
|
||||
final _NativeParagraph paragraph = _NativeParagraph._();
|
||||
_build(paragraph);
|
||||
return paragraph;
|
||||
}
|
||||
|
||||
@Native<Void Function(Pointer<Void>, Handle)>(symbol: 'ParagraphBuilder::build')
|
||||
external void _build(Paragraph outParagraph);
|
||||
external void _build(_NativeParagraph outParagraph);
|
||||
}
|
||||
|
||||
/// Loads a font from a buffer and makes it available for rendering text.
|
||||
|
||||
@@ -331,10 +331,10 @@ class FlutterView {
|
||||
/// scheduling of frames.
|
||||
/// * [RendererBinding], the Flutter framework class which manages layout and
|
||||
/// painting.
|
||||
void render(Scene scene) => _render(scene);
|
||||
void render(Scene scene) => _render(scene as _NativeScene);
|
||||
|
||||
@Native<Void Function(Pointer<Void>)>(symbol: 'PlatformConfigurationNativeApi::Render')
|
||||
external static void _render(Scene scene);
|
||||
external static void _render(_NativeScene scene);
|
||||
|
||||
/// Change the retained semantics data about this [FlutterView].
|
||||
///
|
||||
@@ -344,10 +344,10 @@ class FlutterView {
|
||||
///
|
||||
/// This function disposes the given update, which means the semantics update
|
||||
/// cannot be used further.
|
||||
void updateSemantics(SemanticsUpdate update) => _updateSemantics(update);
|
||||
void updateSemantics(SemanticsUpdate update) => _updateSemantics(update as _NativeSemanticsUpdate);
|
||||
|
||||
@Native<Void Function(Pointer<Void>)>(symbol: 'PlatformConfigurationNativeApi::UpdateSemantics')
|
||||
external static void _updateSemantics(SemanticsUpdate update);
|
||||
external static void _updateSemantics(_NativeSemanticsUpdate update);
|
||||
}
|
||||
|
||||
/// Deprecated. Will be removed in a future version of Flutter.
|
||||
|
||||
@@ -127,7 +127,7 @@ void callEchoVector() {
|
||||
|
||||
// Test helpers for calls with DartWrappable through Tonic.
|
||||
|
||||
class MyNativeClass extends NativeFieldWrapperClass1 {
|
||||
base class MyNativeClass extends NativeFieldWrapperClass1 {
|
||||
MyNativeClass(int value) {
|
||||
_Create(this, value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user