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.
This commit is contained in:
Adam Barth
2015-08-10 23:47:43 -07:00
parent 2701b469cf
commit 375c24772e
3 changed files with 21 additions and 28 deletions

View File

@@ -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);

View File

@@ -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(

View File

@@ -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();
}
}