Rename TransferMode to BlendMode (#7357)

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

Fixes #7200
This commit is contained in:
Adam Barth 2017-01-06 00:07:47 -08:00 committed by GitHub
parent b0e8520ae6
commit 5b1e7c0a37
9 changed files with 41 additions and 41 deletions

View file

@ -1 +1 @@
ed5a1d2d37e203ec2abce01c7af9ce5fdbdb49a1
f13518d7e75d30cab494339060c2dfd3121d291b

View file

@ -3,6 +3,7 @@
// found in the LICENSE file.
export 'dart:ui' show
BlendMode,
BlurStyle,
Canvas,
Color,
@ -30,7 +31,6 @@ export 'dart:ui' show
TextDecorationStyle,
TextDirection,
TileMode,
TransferMode,
VertexMode,
VoidCallback,
hashValues,

View file

@ -306,7 +306,7 @@ class _FlutterLogoPainter extends BoxPainter {
);
final Paint trianglePaint = new Paint()
..shader = triangleGradient
..transferMode = TransferMode.multiply;
..blendMode = BlendMode.multiply;
final ui.Gradient rectangleGradient = new ui.Gradient.linear(
const <Point>[
@ -328,7 +328,7 @@ class _FlutterLogoPainter extends BoxPainter {
);
final Paint rectanglePaint = new Paint()
..shader = rectangleGradient
..transferMode = TransferMode.multiply;
..blendMode = BlendMode.multiply;
// Draw the basic shape.
final Path topBeam = new Path()
@ -432,7 +432,7 @@ class _FlutterLogoPainter extends BoxPainter {
new Paint()
..colorFilter = new ColorFilter.mode(
const Color(0xFFFFFFFF).withOpacity(_config._opacity),
TransferMode.modulate,
BlendMode.modulate,
)
);
}
@ -481,7 +481,7 @@ class _FlutterLogoPainter extends BoxPainter {
_textPainter.paint(canvas, Offset.zero);
if (_config._position > -1.0) {
canvas.drawRect(_textBoundingRect.inflate(_textBoundingRect.width * 0.5), new Paint()
..transferMode = TransferMode.modulate
..blendMode = BlendMode.modulate
..shader = new ui.Gradient.linear(
<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)],

View file

@ -95,12 +95,12 @@ class RenderImage extends RenderBox {
ColorFilter _colorFilter;
// Should we make the transfer mode configurable?
// Should we make the blend mode configurable?
void _updateColorFilter() {
if (_color == null)
_colorFilter = null;
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.

View file

@ -470,9 +470,9 @@ class OpacityLayer extends ContainerLayer {
class ShaderMaskLayer extends ContainerLayer {
/// 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.
ShaderMaskLayer({ this.shader, this.maskRect, this.transferMode });
ShaderMaskLayer({ this.shader, this.maskRect, this.blendMode });
/// The shader to apply to the children.
Shader shader;
@ -480,12 +480,12 @@ class ShaderMaskLayer extends ContainerLayer {
/// The size of the shader.
Rect maskRect;
/// The tranfer mode to apply when blending the shader with the children.
TransferMode transferMode;
/// The blend mode to apply when blending the shader with the children.
BlendMode blendMode;
@override
void addToScene(ui.SceneBuilder builder, Offset layerOffset) {
builder.pushShaderMask(shader, maskRect.shift(layerOffset), transferMode);
builder.pushShaderMask(shader, maskRect.shift(layerOffset), blendMode);
addChildrenToScene(builder, layerOffset);
builder.pop();
}
@ -495,7 +495,7 @@ class ShaderMaskLayer extends ContainerLayer {
super.debugFillDescription(description);
description.add('shader: $shader');
description.add('maskRect: $maskRect');
description.add('transferMode: $transferMode');
description.add('blendMode: $blendMode');
}
}

View file

@ -390,7 +390,7 @@ class PaintingContext {
/// in the coordinate system of the caller.
/// * `maskRect` is the region of the canvas (in the coodinate system of the
/// 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`.
/// * `painter` is a callback that will paint with the mask applied. This
/// function calls the `painter` synchronously.
@ -399,12 +399,12 @@ class PaintingContext {
/// [RenderObject.alwaysNeedsCompositing] property to return true. That informs
/// ancestor render objects that this render object will include a composited
/// 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();
final ShaderMaskLayer shaderLayer = new ShaderMaskLayer(
shader: shader,
maskRect: maskRect,
transferMode: transferMode
blendMode: blendMode,
);
_appendLayer(shaderLayer);
final PaintingContext childContext = new PaintingContext._(shaderLayer, _paintBounds);

View file

@ -237,7 +237,7 @@ class RenderParagraph extends RenderBox {
if (_overflowShader != null) {
canvas.translate(offset.dx, offset.dy);
Paint paint = new Paint()
..transferMode = TransferMode.modulate
..blendMode = BlendMode.modulate
..shader = _overflowShader;
canvas.drawRect(Point.origin & size, paint);
}

View file

@ -774,14 +774,14 @@ typedef Shader ShaderCallback(Rect bounds);
class RenderShaderMask extends RenderProxyBox {
/// 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({
ShaderCallback shaderCallback,
TransferMode transferMode: TransferMode.modulate,
BlendMode blendMode: BlendMode.modulate,
RenderBox child
}) : _shaderCallback = shaderCallback, _transferMode = transferMode, super(child) {
}) : _shaderCallback = shaderCallback, _blendMode = blendMode, super(child) {
assert(shaderCallback != null);
assert(transferMode != null);
assert(blendMode != null);
}
/// Called to creates the [Shader] that generates the mask.
@ -800,17 +800,17 @@ class RenderShaderMask extends RenderProxyBox {
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
/// to the child. Other transfer modes can be used to create other effects.
TransferMode get transferMode => _transferMode;
TransferMode _transferMode;
set transferMode (TransferMode newTransferMode) {
assert(newTransferMode != null);
if (_transferMode == newTransferMode)
/// The default, [BlendMode.modulate], is useful for applying an alpha blend
/// to the child. Other blend modes can be used to create other effects.
BlendMode get blendMode => _blendMode;
BlendMode _blendMode;
set blendMode (BlendMode newBlendMode) {
assert(newBlendMode != null);
if (_blendMode == newBlendMode)
return;
_transferMode = newTransferMode;
_blendMode = newBlendMode;
markNeedsPaint();
}
@ -822,7 +822,7 @@ class RenderShaderMask extends RenderProxyBox {
if (child != null) {
assert(needsCompositing);
Rect rect = Point.origin & size;
context.pushShaderMask(offset, _shaderCallback(rect), rect, _transferMode, super.paint);
context.pushShaderMask(offset, _shaderCallback(rect), rect, _blendMode, super.paint);
}
}
}

View file

@ -112,15 +112,15 @@ class Opacity extends SingleChildRenderObjectWidget {
class ShaderMask extends SingleChildRenderObjectWidget {
/// 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({
Key key,
@required this.shaderCallback,
this.transferMode: TransferMode.modulate,
this.blendMode: BlendMode.modulate,
Widget child
}) : super(key: key, child: child) {
assert(shaderCallback != null);
assert(transferMode != null);
assert(blendMode != null);
}
/// Called to creates the [Shader] that generates the mask.
@ -129,17 +129,17 @@ class ShaderMask extends SingleChildRenderObjectWidget {
/// it can customize the shader to the size and location of the child.
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
/// to the child. Other transfer modes can be used to create other effects.
final TransferMode transferMode;
/// The default, [BlendMode.modulate], is useful for applying an alpha blend
/// to the child. Other blend modes can be used to create other effects.
final BlendMode blendMode;
@override
RenderShaderMask createRenderObject(BuildContext context) {
return new RenderShaderMask(
shaderCallback: shaderCallback,
transferMode: transferMode
blendMode: blendMode
);
}
@ -147,7 +147,7 @@ class ShaderMask extends SingleChildRenderObjectWidget {
void updateRenderObject(BuildContext context, RenderShaderMask renderObject) {
renderObject
..shaderCallback = shaderCallback
..transferMode = transferMode;
..blendMode = blendMode;
}
}