Unverified Commit f87c5102 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Add more documentation around layers. (#45648)

parent 59ca523b
...@@ -182,11 +182,12 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture ...@@ -182,11 +182,12 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
@protected @protected
void handleTextScaleFactorChanged() { } void handleTextScaleFactorChanged() { }
/// {@template on_platform_brightness_change}
/// Called when the platform brightness changes. /// Called when the platform brightness changes.
/// ///
/// The current platform brightness can be queried either from a Flutter /// The current platform brightness can be queried from a Flutter binding or
/// binding, or from a [MediaQuery] widget. /// from a [MediaQuery] widget. The latter is preferred from widgets because
/// it causes the widget to be automatically rebuilt when the brightness
/// changes.
/// ///
/// {@tool sample} /// {@tool sample}
/// Querying [Window.platformBrightness]. /// Querying [Window.platformBrightness].
...@@ -197,7 +198,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture ...@@ -197,7 +198,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
/// {@end-tool} /// {@end-tool}
/// ///
/// {@tool sample} /// {@tool sample}
/// Querying [MediaQuery] directly. /// Querying [MediaQuery] directly. Preferred.
/// ///
/// ```dart /// ```dart
/// final Brightness brightness = MediaQuery.platformBrightnessOf(context); /// final Brightness brightness = MediaQuery.platformBrightnessOf(context);
...@@ -214,7 +215,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture ...@@ -214,7 +215,6 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
/// {@end-tool} /// {@end-tool}
/// ///
/// See [Window.onPlatformBrightnessChanged]. /// See [Window.onPlatformBrightnessChanged].
/// {@endtemplate}
@protected @protected
void handlePlatformBrightnessChanged() { } void handlePlatformBrightnessChanged() { }
......
...@@ -1673,6 +1673,11 @@ class OpacityLayer extends ContainerLayer { ...@@ -1673,6 +1673,11 @@ class OpacityLayer extends ContainerLayer {
} }
/// A composited layer that applies a shader to its children. /// A composited layer that applies a shader to its children.
///
/// The shader is only applied inside the given [maskRect]. The shader itself
/// uses the top left of the [maskRect] as its origin.
///
/// The [maskRect] does not affect the positions of any child layers.
class ShaderMaskLayer extends ContainerLayer { class ShaderMaskLayer extends ContainerLayer {
/// Creates a shader mask layer. /// Creates a shader mask layer.
/// ///
...@@ -1688,8 +1693,16 @@ class ShaderMaskLayer extends ContainerLayer { ...@@ -1688,8 +1693,16 @@ class ShaderMaskLayer extends ContainerLayer {
/// The shader to apply to the children. /// The shader to apply to the children.
/// ///
/// The origin of the shader (e.g. of the coordinate system used by the `from`
/// and `to` arguments to [ui.Gradient.linear]) is at the top left of the
/// [maskRect].
///
/// The scene must be explicitly recomposited after this property is changed /// The scene must be explicitly recomposited after this property is changed
/// (as described at [Layer]). /// (as described at [Layer]).
///
/// See also:
///
/// * [ui.Gradient] and [ui.ImageShader], two shader types that can be used.
Shader get shader => _shader; Shader get shader => _shader;
Shader _shader; Shader _shader;
set shader(Shader value) { set shader(Shader value) {
...@@ -1699,7 +1712,10 @@ class ShaderMaskLayer extends ContainerLayer { ...@@ -1699,7 +1712,10 @@ class ShaderMaskLayer extends ContainerLayer {
} }
} }
/// The size of the shader. /// The position and size of the shader.
///
/// The [shader] is only rendered inside this rectangle, using the top left of
/// the rectangle as its origin.
/// ///
/// The scene must be explicitly recomposited after this property is changed /// The scene must be explicitly recomposited after this property is changed
/// (as described at [Layer]). /// (as described at [Layer]).
...@@ -1730,6 +1746,7 @@ class ShaderMaskLayer extends ContainerLayer { ...@@ -1730,6 +1746,7 @@ class ShaderMaskLayer extends ContainerLayer {
assert(shader != null); assert(shader != null);
assert(maskRect != null); assert(maskRect != null);
assert(blendMode != null); assert(blendMode != null);
assert(layerOffset != null);
final Rect shiftedMaskRect = layerOffset == Offset.zero ? maskRect : maskRect.shift(layerOffset); final Rect shiftedMaskRect = layerOffset == Offset.zero ? maskRect : maskRect.shift(layerOffset);
engineLayer = builder.pushShaderMask(shader, shiftedMaskRect, blendMode, oldLayer: _engineLayer); engineLayer = builder.pushShaderMask(shader, shiftedMaskRect, blendMode, oldLayer: _engineLayer);
addChildrenToScene(builder, layerOffset); addChildrenToScene(builder, layerOffset);
......
...@@ -968,6 +968,9 @@ class RenderShaderMask extends RenderProxyBox { ...@@ -968,6 +968,9 @@ class RenderShaderMask extends RenderProxyBox {
/// ///
/// The shader callback is called with the current size of the child so that /// The shader callback is called with the current size of the child so that
/// it can customize the shader to the size and location of the child. /// it can customize the shader to the size and location of the child.
///
/// The rectangle will always be at the origin when called by
/// [RenderShaderMask].
// TODO(abarth): Use the delegate pattern here to avoid generating spurious // TODO(abarth): Use the delegate pattern here to avoid generating spurious
// repaints when the ShaderCallback changes identity. // repaints when the ShaderCallback changes identity.
ShaderCallback get shaderCallback => _shaderCallback; ShaderCallback get shaderCallback => _shaderCallback;
......
...@@ -214,7 +214,9 @@ abstract class WidgetsBindingObserver { ...@@ -214,7 +214,9 @@ abstract class WidgetsBindingObserver {
/// boilerplate. /// boilerplate.
void didChangeTextScaleFactor() { } void didChangeTextScaleFactor() { }
/// {@macro on_platform_brightness_change} /// Called when the platform brightness changes.
///
/// This method exposes notifications from [Window.onPlatformBrightnessChanged].
void didChangePlatformBrightness() { } void didChangePlatformBrightness() { }
/// Called when the system tells the app that the user's locale has /// Called when the system tells the app that the user's locale has
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment