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