Commit d2c22a49 authored by Adam Barth's avatar Adam Barth

Stop passing bogus bounds to SceneBuilder

We no longer need to pass bounds to SceneBuilder. Instead, the
compositor computes these bounds itself from the RTrees in the
SkPictures.
parent 875da1f5
...@@ -103,27 +103,16 @@ abstract class Layer { ...@@ -103,27 +103,16 @@ abstract class Layer {
/// A composited layer containing a [Picture] /// A composited layer containing a [Picture]
class PictureLayer extends Layer { class PictureLayer extends Layer {
PictureLayer({ Offset offset: Offset.zero, this.paintBounds }) PictureLayer({ Offset offset: Offset.zero })
: super(offset: offset); : super(offset: offset);
/// The rectangle in this layer's coodinate system that bounds the recording
///
/// The paint bounds are used to decide how much graphics memory to allocate
/// when rasterizing this layer.
Rect paintBounds;
/// The picture recorded for this layer /// The picture recorded for this layer
/// ///
/// The picture's coodinate system matches this layer's coodinate system /// The picture's coodinate system matches this layer's coodinate system
ui.Picture picture; ui.Picture picture;
void addToScene(ui.SceneBuilder builder, Offset layerOffset) { void addToScene(ui.SceneBuilder builder, Offset layerOffset) {
builder.addPicture(offset + layerOffset, picture, paintBounds); builder.addPicture(offset + layerOffset, picture);
}
void debugDescribeSettings(List<String> settings) {
super.debugDescribeSettings(settings);
settings.add('paintBounds: $paintBounds');
} }
} }
...@@ -132,22 +121,22 @@ class PictureLayer extends Layer { ...@@ -132,22 +121,22 @@ class PictureLayer extends Layer {
class PerformanceOverlayLayer extends Layer { class PerformanceOverlayLayer extends Layer {
PerformanceOverlayLayer({ PerformanceOverlayLayer({
Offset offset: Offset.zero, Offset offset: Offset.zero,
this.paintBounds, this.overlayRect,
this.optionsMask, this.optionsMask,
this.rasterizerThreshold 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 the overlay should occupy.
Rect paintBounds; Rect overlayRect;
/// A mask specifying the statistics to display /// A mask specifying the statistics to display.
final int optionsMask; final int optionsMask;
final int rasterizerThreshold; final int rasterizerThreshold;
void addToScene(ui.SceneBuilder builder, Offset layerOffset) { void addToScene(ui.SceneBuilder builder, Offset layerOffset) {
assert(optionsMask != null); assert(optionsMask != null);
builder.addPerformanceOverlay(optionsMask, paintBounds.shift(offset + layerOffset)); builder.addPerformanceOverlay(optionsMask, overlayRect.shift(offset + layerOffset));
builder.setRasterizerTracingThreshold(rasterizerThreshold); builder.setRasterizerTracingThreshold(rasterizerThreshold);
} }
} }
...@@ -296,11 +285,7 @@ class ClipRectLayer extends ContainerLayer { ...@@ -296,11 +285,7 @@ class ClipRectLayer extends ContainerLayer {
/// A composite layer that clips its children using a rounded rectangle /// A composite layer that clips its children using a rounded rectangle
class ClipRRectLayer extends ContainerLayer { class ClipRRectLayer extends ContainerLayer {
ClipRRectLayer({ Offset offset: Offset.zero, this.bounds, this.clipRRect }) : super(offset: offset); ClipRRectLayer({ Offset offset: Offset.zero, this.clipRRect }) : super(offset: offset);
/// Unused
Rect bounds;
// TODO(abarth): Remove.
/// The rounded-rect to clip in the parent's coordinate system /// The rounded-rect to clip in the parent's coordinate system
ui.RRect clipRRect; ui.RRect clipRRect;
...@@ -309,25 +294,20 @@ class ClipRRectLayer extends ContainerLayer { ...@@ -309,25 +294,20 @@ class ClipRRectLayer extends ContainerLayer {
void addToScene(ui.SceneBuilder builder, Offset layerOffset) { void addToScene(ui.SceneBuilder builder, Offset layerOffset) {
Offset childOffset = offset + layerOffset; Offset childOffset = offset + layerOffset;
builder.pushClipRRect(clipRRect.shift(childOffset), bounds.shift(childOffset)); builder.pushClipRRect(clipRRect.shift(childOffset));
addChildrenToScene(builder, childOffset); addChildrenToScene(builder, childOffset);
builder.pop(); builder.pop();
} }
void debugDescribeSettings(List<String> settings) { void debugDescribeSettings(List<String> settings) {
super.debugDescribeSettings(settings); super.debugDescribeSettings(settings);
settings.add('bounds: $bounds');
settings.add('clipRRect: $clipRRect'); settings.add('clipRRect: $clipRRect');
} }
} }
/// A composite layer that clips its children using a path /// A composite layer that clips its children using a path
class ClipPathLayer extends ContainerLayer { class ClipPathLayer extends ContainerLayer {
ClipPathLayer({ Offset offset: Offset.zero, this.bounds, this.clipPath }) : super(offset: offset); ClipPathLayer({ Offset offset: Offset.zero, this.clipPath }) : super(offset: offset);
/// Unused
Rect bounds;
// TODO(abarth): Remove.
/// The path to clip in the parent's coordinate system /// The path to clip in the parent's coordinate system
Path clipPath; Path clipPath;
...@@ -336,14 +316,13 @@ class ClipPathLayer extends ContainerLayer { ...@@ -336,14 +316,13 @@ class ClipPathLayer extends ContainerLayer {
void addToScene(ui.SceneBuilder builder, Offset layerOffset) { void addToScene(ui.SceneBuilder builder, Offset layerOffset) {
Offset childOffset = offset + layerOffset; Offset childOffset = offset + layerOffset;
builder.pushClipPath(clipPath.shift(childOffset), bounds.shift(childOffset)); builder.pushClipPath(clipPath.shift(childOffset));
addChildrenToScene(builder, childOffset); addChildrenToScene(builder, childOffset);
builder.pop(); builder.pop();
} }
void debugDescribeSettings(List<String> settings) { void debugDescribeSettings(List<String> settings) {
super.debugDescribeSettings(settings); super.debugDescribeSettings(settings);
settings.add('bounds: $bounds');
settings.add('clipPath: $clipPath'); settings.add('clipPath: $clipPath');
} }
} }
......
...@@ -154,7 +154,7 @@ class PaintingContext { ...@@ -154,7 +154,7 @@ class PaintingContext {
void _startRecording() { void _startRecording() {
assert(!_isRecording); assert(!_isRecording);
_currentLayer = new PictureLayer(paintBounds: _paintBounds); _currentLayer = new PictureLayer();
_recorder = new ui.PictureRecorder(); _recorder = new ui.PictureRecorder();
_canvas = new Canvas(_recorder, _paintBounds); _canvas = new Canvas(_recorder, _paintBounds);
_containerLayer.append(_currentLayer); _containerLayer.append(_currentLayer);
...@@ -190,7 +190,7 @@ class PaintingContext { ...@@ -190,7 +190,7 @@ class PaintingContext {
void pushPerformanceOverlay(Offset offset, int optionsMask, int rasterizerThreshold, Size size) { void pushPerformanceOverlay(Offset offset, int optionsMask, int rasterizerThreshold, Size size) {
_stopRecordingIfNeeded(); _stopRecordingIfNeeded();
PerformanceOverlayLayer performanceOverlayLayer = new PerformanceOverlayLayer( PerformanceOverlayLayer performanceOverlayLayer = new PerformanceOverlayLayer(
paintBounds: new Rect.fromLTWH(0.0, 0.0, size.width, size.height), overlayRect: new Rect.fromLTWH(0.0, 0.0, size.width, size.height),
optionsMask: optionsMask, optionsMask: optionsMask,
rasterizerThreshold: rasterizerThreshold rasterizerThreshold: rasterizerThreshold
); );
...@@ -226,16 +226,14 @@ class PaintingContext { ...@@ -226,16 +226,14 @@ class PaintingContext {
void pushClipRRect(bool needsCompositing, Offset offset, Rect bounds, ui.RRect clipRRect, PaintingContextCallback painter) { void pushClipRRect(bool needsCompositing, Offset offset, Rect bounds, ui.RRect clipRRect, PaintingContextCallback painter) {
if (needsCompositing) { if (needsCompositing) {
_stopRecordingIfNeeded(); _stopRecordingIfNeeded();
ClipRRectLayer clipLayer = new ClipRRectLayer(bounds: bounds, clipRRect: clipRRect); ClipRRectLayer clipLayer = new ClipRRectLayer(clipRRect: clipRRect);
_appendLayer(clipLayer, offset); _appendLayer(clipLayer, offset);
PaintingContext childContext = new PaintingContext._(clipLayer, bounds); PaintingContext childContext = new PaintingContext._(clipLayer, bounds);
painter(childContext, Offset.zero); painter(childContext, Offset.zero);
childContext._stopRecordingIfNeeded(); childContext._stopRecordingIfNeeded();
} else { } else {
canvas.saveLayer(bounds.shift(offset), _disableAntialias); canvas.saveLayer(bounds.shift(offset), _disableAntialias);
// TODO(abarth): Remove this translation once RRect.shift works again. canvas.clipRRect(clipRRect.shift(offset));
canvas.translate(offset.dx, offset.dy);
canvas.clipRRect(clipRRect);
painter(this, Offset.zero); painter(this, Offset.zero);
canvas.restore(); canvas.restore();
} }
...@@ -249,7 +247,7 @@ class PaintingContext { ...@@ -249,7 +247,7 @@ class PaintingContext {
void pushClipPath(bool needsCompositing, Offset offset, Rect bounds, Path clipPath, PaintingContextCallback painter) { void pushClipPath(bool needsCompositing, Offset offset, Rect bounds, Path clipPath, PaintingContextCallback painter) {
if (needsCompositing) { if (needsCompositing) {
_stopRecordingIfNeeded(); _stopRecordingIfNeeded();
ClipPathLayer clipLayer = new ClipPathLayer(bounds: bounds, clipPath: clipPath); ClipPathLayer clipLayer = new ClipPathLayer(clipPath: clipPath);
_appendLayer(clipLayer, offset); _appendLayer(clipLayer, offset);
PaintingContext childContext = new PaintingContext._(clipLayer, bounds); PaintingContext childContext = new PaintingContext._(clipLayer, bounds);
painter(childContext, Offset.zero); painter(childContext, Offset.zero);
......
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