Commit 5b1e7c0a authored by Adam Barth's avatar Adam Barth Committed by GitHub

Rename TransferMode to BlendMode (#7357)

Skia calls this BlendMode now and that's a better name.

Fixes #7200
parent b0e8520a
ed5a1d2d37e203ec2abce01c7af9ce5fdbdb49a1 f13518d7e75d30cab494339060c2dfd3121d291b
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
export 'dart:ui' show export 'dart:ui' show
BlendMode,
BlurStyle, BlurStyle,
Canvas, Canvas,
Color, Color,
...@@ -30,7 +31,6 @@ export 'dart:ui' show ...@@ -30,7 +31,6 @@ export 'dart:ui' show
TextDecorationStyle, TextDecorationStyle,
TextDirection, TextDirection,
TileMode, TileMode,
TransferMode,
VertexMode, VertexMode,
VoidCallback, VoidCallback,
hashValues, hashValues,
......
...@@ -306,7 +306,7 @@ class _FlutterLogoPainter extends BoxPainter { ...@@ -306,7 +306,7 @@ class _FlutterLogoPainter extends BoxPainter {
); );
final Paint trianglePaint = new Paint() final Paint trianglePaint = new Paint()
..shader = triangleGradient ..shader = triangleGradient
..transferMode = TransferMode.multiply; ..blendMode = BlendMode.multiply;
final ui.Gradient rectangleGradient = new ui.Gradient.linear( final ui.Gradient rectangleGradient = new ui.Gradient.linear(
const <Point>[ const <Point>[
...@@ -328,7 +328,7 @@ class _FlutterLogoPainter extends BoxPainter { ...@@ -328,7 +328,7 @@ class _FlutterLogoPainter extends BoxPainter {
); );
final Paint rectanglePaint = new Paint() final Paint rectanglePaint = new Paint()
..shader = rectangleGradient ..shader = rectangleGradient
..transferMode = TransferMode.multiply; ..blendMode = BlendMode.multiply;
// Draw the basic shape. // Draw the basic shape.
final Path topBeam = new Path() final Path topBeam = new Path()
...@@ -432,7 +432,7 @@ class _FlutterLogoPainter extends BoxPainter { ...@@ -432,7 +432,7 @@ class _FlutterLogoPainter extends BoxPainter {
new Paint() new Paint()
..colorFilter = new ColorFilter.mode( ..colorFilter = new ColorFilter.mode(
const Color(0xFFFFFFFF).withOpacity(_config._opacity), const Color(0xFFFFFFFF).withOpacity(_config._opacity),
TransferMode.modulate, BlendMode.modulate,
) )
); );
} }
...@@ -481,7 +481,7 @@ class _FlutterLogoPainter extends BoxPainter { ...@@ -481,7 +481,7 @@ class _FlutterLogoPainter extends BoxPainter {
_textPainter.paint(canvas, Offset.zero); _textPainter.paint(canvas, Offset.zero);
if (_config._position > -1.0) { if (_config._position > -1.0) {
canvas.drawRect(_textBoundingRect.inflate(_textBoundingRect.width * 0.5), new Paint() canvas.drawRect(_textBoundingRect.inflate(_textBoundingRect.width * 0.5), new Paint()
..transferMode = TransferMode.modulate ..blendMode = BlendMode.modulate
..shader = new ui.Gradient.linear( ..shader = new ui.Gradient.linear(
<Point>[new Point(_textBoundingRect.width * -0.5, 0.0), new Point(_textBoundingRect.width * 1.5, 0.0)], <Point>[new Point(_textBoundingRect.width * -0.5, 0.0), new Point(_textBoundingRect.width * 1.5, 0.0)],
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF), const Color(0x00FFFFFF), const Color(0x00FFFFFF)], <Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF), const Color(0x00FFFFFF), const Color(0x00FFFFFF)],
......
...@@ -95,12 +95,12 @@ class RenderImage extends RenderBox { ...@@ -95,12 +95,12 @@ class RenderImage extends RenderBox {
ColorFilter _colorFilter; ColorFilter _colorFilter;
// Should we make the transfer mode configurable? // Should we make the blend mode configurable?
void _updateColorFilter() { void _updateColorFilter() {
if (_color == null) if (_color == null)
_colorFilter = null; _colorFilter = null;
else else
_colorFilter = new ColorFilter.mode(_color, TransferMode.srcIn); _colorFilter = new ColorFilter.mode(_color, BlendMode.srcIn);
} }
/// If non-null, apply this color filter to the image before painting. /// If non-null, apply this color filter to the image before painting.
......
...@@ -470,9 +470,9 @@ class OpacityLayer extends ContainerLayer { ...@@ -470,9 +470,9 @@ class OpacityLayer extends ContainerLayer {
class ShaderMaskLayer extends ContainerLayer { class ShaderMaskLayer extends ContainerLayer {
/// Creates a shader mask layer. /// Creates a shader mask layer.
/// ///
/// The [shader], [maskRect], and [transferMode] properties must be non-null /// The [shader], [maskRect], and [blendMode] properties must be non-null
/// before the compositing phase of the pipeline. /// before the compositing phase of the pipeline.
ShaderMaskLayer({ this.shader, this.maskRect, this.transferMode }); ShaderMaskLayer({ this.shader, this.maskRect, this.blendMode });
/// The shader to apply to the children. /// The shader to apply to the children.
Shader shader; Shader shader;
...@@ -480,12 +480,12 @@ class ShaderMaskLayer extends ContainerLayer { ...@@ -480,12 +480,12 @@ class ShaderMaskLayer extends ContainerLayer {
/// The size of the shader. /// The size of the shader.
Rect maskRect; Rect maskRect;
/// The tranfer mode to apply when blending the shader with the children. /// The blend mode to apply when blending the shader with the children.
TransferMode transferMode; BlendMode blendMode;
@override @override
void addToScene(ui.SceneBuilder builder, Offset layerOffset) { void addToScene(ui.SceneBuilder builder, Offset layerOffset) {
builder.pushShaderMask(shader, maskRect.shift(layerOffset), transferMode); builder.pushShaderMask(shader, maskRect.shift(layerOffset), blendMode);
addChildrenToScene(builder, layerOffset); addChildrenToScene(builder, layerOffset);
builder.pop(); builder.pop();
} }
...@@ -495,7 +495,7 @@ class ShaderMaskLayer extends ContainerLayer { ...@@ -495,7 +495,7 @@ class ShaderMaskLayer extends ContainerLayer {
super.debugFillDescription(description); super.debugFillDescription(description);
description.add('shader: $shader'); description.add('shader: $shader');
description.add('maskRect: $maskRect'); description.add('maskRect: $maskRect');
description.add('transferMode: $transferMode'); description.add('blendMode: $blendMode');
} }
} }
......
...@@ -390,7 +390,7 @@ class PaintingContext { ...@@ -390,7 +390,7 @@ class PaintingContext {
/// in the coordinate system of the caller. /// in the coordinate system of the caller.
/// * `maskRect` is the region of the canvas (in the coodinate system of the /// * `maskRect` is the region of the canvas (in the coodinate system of the
/// caller) in which to apply the mask. /// caller) in which to apply the mask.
/// * `transferMode` is the [TransferMode] to use when applying the shader to /// * `blendMode` is the [BlendMode] to use when applying the shader to
/// the painting done by `painter`. /// the painting done by `painter`.
/// * `painter` is a callback that will paint with the mask applied. This /// * `painter` is a callback that will paint with the mask applied. This
/// function calls the `painter` synchronously. /// function calls the `painter` synchronously.
...@@ -399,12 +399,12 @@ class PaintingContext { ...@@ -399,12 +399,12 @@ class PaintingContext {
/// [RenderObject.alwaysNeedsCompositing] property to return true. That informs /// [RenderObject.alwaysNeedsCompositing] property to return true. That informs
/// ancestor render objects that this render object will include a composited /// ancestor render objects that this render object will include a composited
/// layer, which causes them to use composited clips, for example. /// layer, which causes them to use composited clips, for example.
void pushShaderMask(Offset offset, Shader shader, Rect maskRect, TransferMode transferMode, PaintingContextCallback painter) { void pushShaderMask(Offset offset, Shader shader, Rect maskRect, BlendMode blendMode, PaintingContextCallback painter) {
_stopRecordingIfNeeded(); _stopRecordingIfNeeded();
final ShaderMaskLayer shaderLayer = new ShaderMaskLayer( final ShaderMaskLayer shaderLayer = new ShaderMaskLayer(
shader: shader, shader: shader,
maskRect: maskRect, maskRect: maskRect,
transferMode: transferMode blendMode: blendMode,
); );
_appendLayer(shaderLayer); _appendLayer(shaderLayer);
final PaintingContext childContext = new PaintingContext._(shaderLayer, _paintBounds); final PaintingContext childContext = new PaintingContext._(shaderLayer, _paintBounds);
......
...@@ -237,7 +237,7 @@ class RenderParagraph extends RenderBox { ...@@ -237,7 +237,7 @@ class RenderParagraph extends RenderBox {
if (_overflowShader != null) { if (_overflowShader != null) {
canvas.translate(offset.dx, offset.dy); canvas.translate(offset.dx, offset.dy);
Paint paint = new Paint() Paint paint = new Paint()
..transferMode = TransferMode.modulate ..blendMode = BlendMode.modulate
..shader = _overflowShader; ..shader = _overflowShader;
canvas.drawRect(Point.origin & size, paint); canvas.drawRect(Point.origin & size, paint);
} }
......
...@@ -774,14 +774,14 @@ typedef Shader ShaderCallback(Rect bounds); ...@@ -774,14 +774,14 @@ typedef Shader ShaderCallback(Rect bounds);
class RenderShaderMask extends RenderProxyBox { class RenderShaderMask extends RenderProxyBox {
/// Creates a render object that applies a mask generated by a [Shader] to its child. /// Creates a render object that applies a mask generated by a [Shader] to its child.
/// ///
/// The [shaderCallback] and [transferMode] arguments must not be null. /// The [shaderCallback] and [blendMode] arguments must not be null.
RenderShaderMask({ RenderShaderMask({
ShaderCallback shaderCallback, ShaderCallback shaderCallback,
TransferMode transferMode: TransferMode.modulate, BlendMode blendMode: BlendMode.modulate,
RenderBox child RenderBox child
}) : _shaderCallback = shaderCallback, _transferMode = transferMode, super(child) { }) : _shaderCallback = shaderCallback, _blendMode = blendMode, super(child) {
assert(shaderCallback != null); assert(shaderCallback != null);
assert(transferMode != null); assert(blendMode != null);
} }
/// Called to creates the [Shader] that generates the mask. /// Called to creates the [Shader] that generates the mask.
...@@ -800,17 +800,17 @@ class RenderShaderMask extends RenderProxyBox { ...@@ -800,17 +800,17 @@ class RenderShaderMask extends RenderProxyBox {
markNeedsPaint(); markNeedsPaint();
} }
/// The [TransferMode] to use when applying the shader to the child. /// The [BlendMode] to use when applying the shader to the child.
/// ///
/// The default, [TransferMode.modulate], is useful for applying an alpha blend /// The default, [BlendMode.modulate], is useful for applying an alpha blend
/// to the child. Other transfer modes can be used to create other effects. /// to the child. Other blend modes can be used to create other effects.
TransferMode get transferMode => _transferMode; BlendMode get blendMode => _blendMode;
TransferMode _transferMode; BlendMode _blendMode;
set transferMode (TransferMode newTransferMode) { set blendMode (BlendMode newBlendMode) {
assert(newTransferMode != null); assert(newBlendMode != null);
if (_transferMode == newTransferMode) if (_blendMode == newBlendMode)
return; return;
_transferMode = newTransferMode; _blendMode = newBlendMode;
markNeedsPaint(); markNeedsPaint();
} }
...@@ -822,7 +822,7 @@ class RenderShaderMask extends RenderProxyBox { ...@@ -822,7 +822,7 @@ class RenderShaderMask extends RenderProxyBox {
if (child != null) { if (child != null) {
assert(needsCompositing); assert(needsCompositing);
Rect rect = Point.origin & size; Rect rect = Point.origin & size;
context.pushShaderMask(offset, _shaderCallback(rect), rect, _transferMode, super.paint); context.pushShaderMask(offset, _shaderCallback(rect), rect, _blendMode, super.paint);
} }
} }
} }
......
...@@ -112,15 +112,15 @@ class Opacity extends SingleChildRenderObjectWidget { ...@@ -112,15 +112,15 @@ class Opacity extends SingleChildRenderObjectWidget {
class ShaderMask extends SingleChildRenderObjectWidget { class ShaderMask extends SingleChildRenderObjectWidget {
/// Creates a widget that applies a mask generated by a [Shader] to its child. /// Creates a widget that applies a mask generated by a [Shader] to its child.
/// ///
/// The [shaderCallback] and [transferMode] arguments must not be null. /// The [shaderCallback] and [blendMode] arguments must not be null.
ShaderMask({ ShaderMask({
Key key, Key key,
@required this.shaderCallback, @required this.shaderCallback,
this.transferMode: TransferMode.modulate, this.blendMode: BlendMode.modulate,
Widget child Widget child
}) : super(key: key, child: child) { }) : super(key: key, child: child) {
assert(shaderCallback != null); assert(shaderCallback != null);
assert(transferMode != null); assert(blendMode != null);
} }
/// Called to creates the [Shader] that generates the mask. /// Called to creates the [Shader] that generates the mask.
...@@ -129,17 +129,17 @@ class ShaderMask extends SingleChildRenderObjectWidget { ...@@ -129,17 +129,17 @@ class ShaderMask extends SingleChildRenderObjectWidget {
/// 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.
final ShaderCallback shaderCallback; final ShaderCallback shaderCallback;
/// The [TransferMode] to use when applying the shader to the child. /// The [BlendMode] to use when applying the shader to the child.
/// ///
/// The default, [TransferMode.modulate], is useful for applying an alpha blend /// The default, [BlendMode.modulate], is useful for applying an alpha blend
/// to the child. Other transfer modes can be used to create other effects. /// to the child. Other blend modes can be used to create other effects.
final TransferMode transferMode; final BlendMode blendMode;
@override @override
RenderShaderMask createRenderObject(BuildContext context) { RenderShaderMask createRenderObject(BuildContext context) {
return new RenderShaderMask( return new RenderShaderMask(
shaderCallback: shaderCallback, shaderCallback: shaderCallback,
transferMode: transferMode blendMode: blendMode
); );
} }
...@@ -147,7 +147,7 @@ class ShaderMask extends SingleChildRenderObjectWidget { ...@@ -147,7 +147,7 @@ class ShaderMask extends SingleChildRenderObjectWidget {
void updateRenderObject(BuildContext context, RenderShaderMask renderObject) { void updateRenderObject(BuildContext context, RenderShaderMask renderObject) {
renderObject renderObject
..shaderCallback = shaderCallback ..shaderCallback = shaderCallback
..transferMode = transferMode; ..blendMode = blendMode;
} }
} }
......
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