Commit 73dce01e authored by Chinmay Garde's avatar Chinmay Garde

Allow updating the rasterizer tracing threshold from Dart

parent 90d47520
......@@ -93,18 +93,22 @@ class StatisticsLayer extends Layer {
StatisticsLayer({
Offset offset: Offset.zero,
this.paintBounds,
this.optionsMask
this.optionsMask,
this.rasterizerThreshold
}) : super(offset: offset);
/// The rectangle in this layer's coodinate system that bounds the recording
Rect paintBounds;
/// A mask specifying the statistics to display
int optionsMask;
final int optionsMask;
final int rasterizerThreshold;
void addToScene(sky.SceneBuilder builder, Offset layerOffset) {
assert(optionsMask != null);
builder.addStatistics(optionsMask, paintBounds.shift(layerOffset));
builder.setRasterizerTracingThreshold(rasterizerThreshold);
}
}
......
......@@ -132,11 +132,12 @@ class PaintingContext {
}
}
void paintStatistics(int optionsMask, Offset offset, Size size) {
void paintStatistics(int optionsMask, int rasterizerThreshold, Offset offset, Size size) {
StatisticsLayer statsLayer = new StatisticsLayer(
offset: offset,
paintBounds: new Rect.fromLTWH(0.0, 0.0, size.width, size.height),
optionsMask : optionsMask
optionsMask : optionsMask,
rasterizerThreshold : rasterizerThreshold
);
_containerLayer.append(statsLayer);
}
......
......@@ -7,7 +7,9 @@ import 'package:sky/src/rendering/object.dart';
class StatisticsBox extends RenderBox {
StatisticsBox({int optionsMask: 0}) : _optionsMask = optionsMask;
StatisticsBox({int optionsMask: 0, int rasterizerThreshold: 0})
: _optionsMask = optionsMask,
_rasterizerThreshold = rasterizerThreshold;
int _optionsMask;
int get optionsMask => _optionsMask;
......@@ -19,6 +21,16 @@ class StatisticsBox extends RenderBox {
markNeedsPaint();
}
int _rasterizerThreshold;
int get rasterizerThreshold => _rasterizerThreshold;
void set rasterizerThreshold (int threshold) {
if (threshold == _rasterizerThreshold) {
return;
}
_rasterizerThreshold = threshold;
markNeedsPaint();
}
bool get sizedByParent => true;
double getMinIntrinsicWidth(BoxConstraints constraints) {
......@@ -42,6 +54,6 @@ class StatisticsBox extends RenderBox {
}
void paint(PaintingContext context, Offset offset) {
context.paintStatistics(optionsMask, offset, size);
context.paintStatistics(optionsMask, rasterizerThreshold, offset, size);
}
}
......@@ -40,10 +40,10 @@ class StatisticsOverlay extends LeafRenderObjectWidget {
/// Create a statistics overlay that only displays specific statistics. The
/// mask is created by shifting 1 by the index of the specific StatisticOption
/// to enable.
StatisticsOverlay({ this.optionsMask, Key key }) : super(key: key);
StatisticsOverlay({ this.optionsMask, this.rasterizerThreshold: 0, Key key }) : super(key: key);
/// Create a statistics overaly that displays all available statistics
StatisticsOverlay.allEnabled({ Key key }) : super(key: key), optionsMask = (
StatisticsOverlay.allEnabled({ Key key, this.rasterizerThreshold: 0 }) : super(key: key), optionsMask = (
1 << StatisticsOption.displayRasterizerStatistics.index |
1 << StatisticsOption.visualizeRasterizerStatistics.index |
1 << StatisticsOption.displayEngineStatistics.index |
......@@ -51,10 +51,15 @@ class StatisticsOverlay extends LeafRenderObjectWidget {
);
final int optionsMask;
final int rasterizerThreshold;
StatisticsBox createRenderObject() => new StatisticsBox(optionsMask: optionsMask);
StatisticsBox createRenderObject() => new StatisticsBox(
optionsMask: optionsMask,
rasterizerThreshold: rasterizerThreshold
);
void updateRenderObject(StatisticsBox renderObject, RenderObjectWidget oldWidget) {
renderObject.optionsMask = optionsMask;
renderObject.rasterizerThreshold = rasterizerThreshold;
}
}
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