Commit 375c2477 authored by Adam Barth's avatar Adam Barth

Remove weak handle from sky.Paint

This patch converts sky.Paint to be a pure Dart object, which means we don't
need to open a weak handle to sky.Paint. Avoiding the weak handle reduces the
amount of weak handle callbacks we need to process at the end of GC and
therefore reduces jank.
parent 2701b469
......@@ -55,34 +55,29 @@ void beginFrame(double timeStamp) {
..setOffset(const sky.Offset(150.0, 0.0))
..setColorMode(sky.TransferMode.src)
..setPaintBits(sky.PaintBits.all),
(sky.Paint layerPaint) {
layerPaint.color = const sky.Color.fromARGB(128, 255, 255, 0);
layerPaint.setColorFilter(new sky.ColorFilter.mode(
const sky.Color.fromARGB(128, 0, 0, 255), sky.TransferMode.srcIn));
layerPaint.setMaskFilter(new sky.MaskFilter.blur(
sky.BlurStyle.normal, 3.0, highQuality: true));
})
new sky.Paint()
..color = const sky.Color.fromARGB(128, 255, 255, 0)
..setColorFilter(new sky.ColorFilter.mode(
const sky.Color.fromARGB(128, 0, 0, 255), sky.TransferMode.srcIn))
..setMaskFilter(new sky.MaskFilter.blur(
sky.BlurStyle.normal, 3.0, highQuality: true)))
..addLayerOnTop(
new sky.DrawLooperLayerInfo()
..setOffset(const sky.Offset(75.0, 75.0))
..setColorMode(sky.TransferMode.src)
..setPaintBits(sky.PaintBits.shader),
(sky.Paint layerPaint) {
sky.Gradient redYellow = new sky.Gradient.radial(
new sky.Point(0.0, 0.0), radius/3.0,
[const sky.Color(0xFFFFFF00), const sky.Color(0xFFFF0000)],
null, sky.TileMode.mirror);
layerPaint.setShader(redYellow);
// Since we're don't set sky.PaintBits.maskFilter, this has no effect.
layerPaint.setMaskFilter(new sky.MaskFilter.blur(
sky.BlurStyle.normal, 50.0, highQuality: true));
})
new sky.Paint()
..setShader(new sky.Gradient.radial(
new sky.Point(0.0, 0.0), radius/3.0,
[const sky.Color(0xFFFFFF00), const sky.Color(0xFFFF0000)],
null, sky.TileMode.mirror))
// Since we're don't set sky.PaintBits.maskFilter, this has no effect.
..setMaskFilter(new sky.MaskFilter.blur(
sky.BlurStyle.normal, 50.0, highQuality: true)))
..addLayerOnTop(
new sky.DrawLooperLayerInfo()..setOffset(const sky.Offset(225.0, 75.0)),
(sky.Paint layerPaint) {
// Since this layer uses a DST color mode, this has no effect.
layerPaint.color = const sky.Color.fromARGB(128, 255, 0, 0);
});
// Since this layer uses a DST color mode, this has no effect.
new sky.Paint()..color = const sky.Color.fromARGB(128, 255, 0, 0));
paint.setDrawLooper(builder.build());
canvas.drawCircle(sky.Point.origin, radius, paint);
......
......@@ -27,7 +27,7 @@ void beginFrame(double timeStamp) {
new MaskFilter.blur(BlurStyle.normal, 5.0, highQuality: true));
})
// Main layer.
..addLayerOnTop(new DrawLooperLayerInfo(), (Paint) {});
..addLayerOnTop(new DrawLooperLayerInfo(), new Paint());
paint.setDrawLooper(builder.build());
canvas.drawPaint(
......
......@@ -15,15 +15,13 @@ class ShadowDrawLooperBuilder {
..setPaintBits(sky.PaintBits.all)
..setOffset(offset)
..setColorMode(sky.TransferMode.src),
(sky.Paint layerPaint) {
layerPaint.color = color;
layerPaint.setMaskFilter(
new sky.MaskFilter.blur(sky.BlurStyle.normal, blur));
});
new sky.Paint()
..color = color
..setMaskFilter(new sky.MaskFilter.blur(sky.BlurStyle.normal, blur)));
}
sky.DrawLooper build() {
builder_.addLayerOnTop(new sky.DrawLooperLayerInfo(), (_) {});
builder_.addLayerOnTop(new sky.DrawLooperLayerInfo(), new sky.Paint());
return builder_.build();
}
}
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