Commit 945b5bcd authored by Adam Barth's avatar Adam Barth

Remove use of some deprecated functions on sky.Paint

We now expose idiomatic setters for these properties. Eventually we'll remove
the setter functions.
parent d9a955e9
...@@ -15,9 +15,9 @@ class StarField extends NodeWithSize { ...@@ -15,9 +15,9 @@ class StarField extends NodeWithSize {
Size _paddedSize = Size.zero; Size _paddedSize = Size.zero;
Paint _paint = new Paint() Paint _paint = new Paint()
..setFilterQuality(sky.FilterQuality.low) ..filterQuality = sky.FilterQuality.low
..isAntiAlias = false ..isAntiAlias = false
..setTransferMode(sky.TransferMode.plus); ..transferMode = sky.TransferMode.plus;
StarField(this._spriteSheet, this._numStars, [this._autoScroll = false]) : super(Size.zero) { StarField(this._spriteSheet, this._numStars, [this._autoScroll = false]) : super(Size.zero) {
_image = _spriteSheet.image; _image = _spriteSheet.image;
......
...@@ -75,7 +75,9 @@ class TestDrawAtlas extends NodeWithSize { ...@@ -75,7 +75,9 @@ class TestDrawAtlas extends NodeWithSize {
colors, colors,
TransferMode.src, TransferMode.src,
null, null,
new Paint()..setFilterQuality(FilterQuality.low)..isAntiAlias=false new Paint()
..filterQuality = FilterQuality.low
..isAntiAlias = false
); );
} }
} }
...@@ -209,7 +209,7 @@ class TestPerformanceAtlas extends PerformanceTest { ...@@ -209,7 +209,7 @@ class TestPerformanceAtlas extends PerformanceTest {
double rotation = 0.0; double rotation = 0.0;
List<Rect> rects = []; List<Rect> rects = [];
Paint cachedPaint = new Paint() Paint cachedPaint = new Paint()
..setFilterQuality(sky.FilterQuality.low) ..filterQuality = sky.FilterQuality.low
..isAntiAlias = false; ..isAntiAlias = false;
TestPerformanceAtlas() { TestPerformanceAtlas() {
...@@ -262,7 +262,7 @@ class TestPerformanceAtlas2 extends PerformanceTest { ...@@ -262,7 +262,7 @@ class TestPerformanceAtlas2 extends PerformanceTest {
double rotation = 0.0; double rotation = 0.0;
List<Rect> rects = []; List<Rect> rects = [];
Paint cachedPaint = new Paint() Paint cachedPaint = new Paint()
..setFilterQuality(sky.FilterQuality.low) ..filterQuality = sky.FilterQuality.low
..isAntiAlias = false; ..isAntiAlias = false;
TestPerformanceAtlas2() { TestPerformanceAtlas2() {
......
...@@ -53,28 +53,28 @@ sky.Picture paint(sky.Rect paintBounds) { ...@@ -53,28 +53,28 @@ sky.Picture paint(sky.Rect paintBounds) {
..setPaintBits(sky.PaintBits.all), ..setPaintBits(sky.PaintBits.all),
new sky.Paint() new sky.Paint()
..color = const sky.Color.fromARGB(128, 255, 255, 0) ..color = const sky.Color.fromARGB(128, 255, 255, 0)
..setColorFilter(new sky.ColorFilter.mode( ..colorFilter = new sky.ColorFilter.mode(
const sky.Color.fromARGB(128, 0, 0, 255), sky.TransferMode.srcIn)) const sky.Color.fromARGB(128, 0, 0, 255), sky.TransferMode.srcIn)
..setMaskFilter(new sky.MaskFilter.blur( ..maskFilter = new sky.MaskFilter.blur(
sky.BlurStyle.normal, 3.0, highQuality: true))) sky.BlurStyle.normal, 3.0, highQuality: true))
..addLayerOnTop( ..addLayerOnTop(
new sky.DrawLooperLayerInfo() new sky.DrawLooperLayerInfo()
..setOffset(const sky.Offset(75.0, 75.0)) ..setOffset(const sky.Offset(75.0, 75.0))
..setColorMode(sky.TransferMode.src) ..setColorMode(sky.TransferMode.src)
..setPaintBits(sky.PaintBits.shader), ..setPaintBits(sky.PaintBits.shader),
new sky.Paint() new sky.Paint()
..setShader(new sky.Gradient.radial( ..shader = new sky.Gradient.radial(
new sky.Point(0.0, 0.0), radius/3.0, new sky.Point(0.0, 0.0), radius/3.0,
[const sky.Color(0xFFFFFF00), const sky.Color(0xFFFF0000)], [const sky.Color(0xFFFFFF00), const sky.Color(0xFFFF0000)],
null, sky.TileMode.mirror)) null, sky.TileMode.mirror)
// Since we're don't set sky.PaintBits.maskFilter, this has no effect. // Since we're don't set sky.PaintBits.maskFilter, this has no effect.
..setMaskFilter(new sky.MaskFilter.blur( ..maskFilter = new sky.MaskFilter.blur(
sky.BlurStyle.normal, 50.0, highQuality: true))) sky.BlurStyle.normal, 50.0, highQuality: true))
..addLayerOnTop( ..addLayerOnTop(
new sky.DrawLooperLayerInfo()..setOffset(const sky.Offset(225.0, 75.0)), new sky.DrawLooperLayerInfo()..setOffset(const sky.Offset(225.0, 75.0)),
// Since this layer uses a DST color mode, this has no effect. // Since this layer uses a DST color mode, this has no effect.
new sky.Paint()..color = const sky.Color.fromARGB(128, 255, 0, 0)); new sky.Paint()..color = const sky.Color.fromARGB(128, 255, 0, 0));
paint.setDrawLooper(builder.build()); paint.drawLooper = builder.build();
canvas.drawCircle(sky.Point.origin, radius, paint); canvas.drawCircle(sky.Point.origin, radius, paint);
return recorder.endRecording(); return recorder.endRecording();
......
...@@ -23,12 +23,11 @@ sky.Picture paint(sky.Rect paintBounds) { ...@@ -23,12 +23,11 @@ sky.Picture paint(sky.Rect paintBounds) {
..setColorMode(sky.TransferMode.src), ..setColorMode(sky.TransferMode.src),
new sky.Paint() new sky.Paint()
..color = const sky.Color.fromARGB(128, 55, 55, 55) ..color = const sky.Color.fromARGB(128, 55, 55, 55)
..setMaskFilter( ..maskFilter = new sky.MaskFilter.blur(sky.BlurStyle.normal, 5.0)
new sky.MaskFilter.blur(sky.BlurStyle.normal, 5.0))
) )
// Main layer. // Main layer.
..addLayerOnTop(new sky.DrawLooperLayerInfo(), new sky.Paint()); ..addLayerOnTop(new sky.DrawLooperLayerInfo(), new sky.Paint());
paint.setDrawLooper(builder.build()); paint.drawLooper = builder.build();
canvas.drawPaint( canvas.drawPaint(
new sky.Paint()..color = const sky.Color.fromARGB(255, 255, 255, 255)); new sky.Paint()..color = const sky.Color.fromARGB(255, 255, 255, 255));
......
...@@ -401,7 +401,7 @@ void paintImage({ ...@@ -401,7 +401,7 @@ void paintImage({
// TODO(abarth): Implement |repeat|. // TODO(abarth): Implement |repeat|.
Paint paint = new Paint(); Paint paint = new Paint();
if (colorFilter != null) if (colorFilter != null)
paint.setColorFilter(colorFilter); paint.colorFilter = colorFilter;
double dx = (bounds.width - destinationSize.width) * positionX; double dx = (bounds.width - destinationSize.width) * positionX;
double dy = (bounds.height - destinationSize.height) * positionY; double dy = (bounds.height - destinationSize.height) * positionY;
Point destinationPosition = rect.topLeft + new Offset(dx, dy); Point destinationPosition = rect.topLeft + new Offset(dx, dy);
...@@ -605,11 +605,11 @@ class BoxPainter { ...@@ -605,11 +605,11 @@ class BoxPainter {
var builder = new ShadowDrawLooperBuilder(); var builder = new ShadowDrawLooperBuilder();
for (BoxShadow boxShadow in _decoration.boxShadow) for (BoxShadow boxShadow in _decoration.boxShadow)
builder.addShadow(boxShadow.offset, boxShadow.color, boxShadow.blur); builder.addShadow(boxShadow.offset, boxShadow.color, boxShadow.blur);
paint.setDrawLooper(builder.build()); paint.drawLooper = builder.build();
} }
if (_decoration.gradient != null) if (_decoration.gradient != null)
paint.setShader(_decoration.gradient.createShader()); paint.shader = _decoration.gradient.createShader();
_cachedBackgroundPaint = paint; _cachedBackgroundPaint = paint;
} }
......
...@@ -17,7 +17,7 @@ class ShadowDrawLooperBuilder { ...@@ -17,7 +17,7 @@ class ShadowDrawLooperBuilder {
..setColorMode(sky.TransferMode.src), ..setColorMode(sky.TransferMode.src),
new sky.Paint() new sky.Paint()
..color = color ..color = color
..setMaskFilter(new sky.MaskFilter.blur(sky.BlurStyle.normal, blur))); ..maskFilter = new sky.MaskFilter.blur(sky.BlurStyle.normal, blur));
} }
/// Returns the draw looper built for the added shadows /// Returns the draw looper built for the added shadows
......
...@@ -265,7 +265,7 @@ class PaintingContext { ...@@ -265,7 +265,7 @@ class PaintingContext {
static Paint _getPaintForColorFilter(Color color, sky.TransferMode transferMode) { static Paint _getPaintForColorFilter(Color color, sky.TransferMode transferMode) {
return new Paint() return new Paint()
..setColorFilter(new sky.ColorFilter.mode(color, transferMode)) ..colorFilter = new sky.ColorFilter.mode(color, transferMode)
..isAntiAlias = false; ..isAntiAlias = false;
} }
......
...@@ -113,8 +113,9 @@ class _RenderSwitch extends RenderToggleable { ...@@ -113,8 +113,9 @@ class _RenderSwitch extends RenderToggleable {
} }
// Draw the track rrect // Draw the track rrect
sky.Paint paint = new sky.Paint()..color = trackColor; sky.Paint paint = new sky.Paint()
paint.setStyle(sky.PaintingStyle.fill); ..color = trackColor
..style = sky.PaintingStyle.fill;
sky.Rect rect = new sky.Rect.fromLTWH(offset.dx, sky.Rect rect = new sky.Rect.fromLTWH(offset.dx,
offset.dy + _kSwitchHeight / 2.0 - _kTrackHeight / 2.0, _kTrackWidth, offset.dy + _kSwitchHeight / 2.0 - _kTrackHeight / 2.0, _kTrackWidth,
_kTrackHeight); _kTrackHeight);
...@@ -127,10 +128,10 @@ class _RenderSwitch extends RenderToggleable { ...@@ -127,10 +128,10 @@ class _RenderSwitch extends RenderToggleable {
// Draw the raised thumb with a shadow // Draw the raised thumb with a shadow
paint.color = thumbColor; paint.color = thumbColor;
var builder = new ShadowDrawLooperBuilder(); ShadowDrawLooperBuilder builder = new ShadowDrawLooperBuilder();
for (BoxShadow boxShadow in shadows[1]) builder.addShadow( for (BoxShadow boxShadow in shadows[1])
boxShadow.offset, boxShadow.color, boxShadow.blur); builder.addShadow(boxShadow.offset, boxShadow.color, boxShadow.blur);
paint.setDrawLooper(builder.build()); paint.drawLooper = builder.build();
// The thumb contracts slightly during the animation // The thumb contracts slightly during the animation
double inset = 2.0 - (position.value - 0.5).abs() * 2.0; double inset = 2.0 - (position.value - 0.5).abs() * 2.0;
......
...@@ -22,7 +22,7 @@ class Layer extends Node with SpritePaint { ...@@ -22,7 +22,7 @@ class Layer extends Node with SpritePaint {
Layer([Rect this.layerRect = null]); Layer([Rect this.layerRect = null]);
Paint _cachedPaint = new Paint() Paint _cachedPaint = new Paint()
..setFilterQuality(FilterQuality.low) ..filterQuality = FilterQuality.low
..isAntiAlias = false; ..isAntiAlias = false;
void _prePaint(PaintingCanvas canvas, Matrix4 matrix) { void _prePaint(PaintingCanvas canvas, Matrix4 matrix) {
......
...@@ -152,7 +152,7 @@ class ParticleSystem extends Node { ...@@ -152,7 +152,7 @@ class ParticleSystem extends Node {
int _numEmittedParticles = 0; int _numEmittedParticles = 0;
static Paint _paint = new Paint() static Paint _paint = new Paint()
..setFilterQuality(FilterQuality.low) ..filterQuality = FilterQuality.low
..isAntiAlias = false; ..isAntiAlias = false;
ParticleSystem(this.texture, ParticleSystem(this.texture,
......
...@@ -17,7 +17,7 @@ class Sprite extends NodeWithSize with SpritePaint { ...@@ -17,7 +17,7 @@ class Sprite extends NodeWithSize with SpritePaint {
bool constrainProportions = false; bool constrainProportions = false;
Paint _cachedPaint = new Paint() Paint _cachedPaint = new Paint()
..setFilterQuality(FilterQuality.low) ..filterQuality = FilterQuality.low
..isAntiAlias = false; ..isAntiAlias = false;
/// Creates a new sprite from the provided [texture]. /// Creates a new sprite from the provided [texture].
...@@ -113,11 +113,11 @@ abstract class SpritePaint { ...@@ -113,11 +113,11 @@ abstract class SpritePaint {
paint.color = new Color.fromARGB((255.0*_opacity).toInt(), 255, 255, 255); paint.color = new Color.fromARGB((255.0*_opacity).toInt(), 255, 255, 255);
if (colorOverlay != null) { if (colorOverlay != null) {
paint.setColorFilter(new ColorFilter.mode(colorOverlay, TransferMode.srcATop)); paint.colorFilter = new ColorFilter.mode(colorOverlay, TransferMode.srcATop);
} }
if (transferMode != null) { if (transferMode != null) {
paint.setTransferMode(transferMode); paint.transferMode = transferMode;
} }
} }
} }
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