Remove RenderView.paintFrame
We now use the repaint system to do all the painting. During initialization, we set up a root layer that applies the device pixel ratio. Fixes #706
This commit is contained in:
parent
8a3285b6c5
commit
077e75e87b
@ -169,6 +169,19 @@ class ContainerLayer extends Layer {
|
||||
child._parent = null;
|
||||
}
|
||||
|
||||
void removeAllChildren() {
|
||||
Layer child = _firstChild;
|
||||
while (child != null) {
|
||||
Layer next = child.nextSibling;
|
||||
child._previousSibling = null;
|
||||
child._nextSibling = null;
|
||||
child._parent = null;
|
||||
child = next;
|
||||
}
|
||||
_firstChild = null;
|
||||
_lastChild = null;
|
||||
}
|
||||
|
||||
void paint(sky.Canvas canvas) {
|
||||
canvas.translate(offset.dx, offset.dy);
|
||||
paintChildren(canvas);
|
||||
|
@ -51,13 +51,6 @@ class PaintingContext {
|
||||
_startRecording(paintBounds);
|
||||
}
|
||||
|
||||
factory PaintingContext.replacingLayer(ContainerLayer oldLayer, Rect paintBounds) {
|
||||
PaintingContext newContext = new PaintingContext.withOffset(oldLayer.offset, paintBounds);
|
||||
if (oldLayer.parent != null)
|
||||
oldLayer.replaceWith(newContext._containerLayer);
|
||||
return newContext;
|
||||
}
|
||||
|
||||
PaintingContext.forTesting(this._canvas);
|
||||
|
||||
ContainerLayer _containerLayer;
|
||||
@ -650,21 +643,20 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
|
||||
sky.tracing.end('RenderObject.flushPaint');
|
||||
}
|
||||
}
|
||||
void initialPaint(ContainerLayer rootLayer, Size size) {
|
||||
void scheduleInitialPaint(ContainerLayer rootLayer) {
|
||||
assert(attached);
|
||||
assert(parent is! RenderObject);
|
||||
assert(!_debugDoingPaint);
|
||||
assert(hasLayer);
|
||||
PaintingContext newContext = new PaintingContext.withLayer(rootLayer, Point.origin & size);
|
||||
_paintLayer(newContext);
|
||||
_layer = rootLayer;
|
||||
assert(_needsPaint);
|
||||
_nodesNeedingPaint.add(this);
|
||||
}
|
||||
void _repaint() {
|
||||
assert(hasLayer);
|
||||
assert(_layer != null);
|
||||
PaintingContext newContext = new PaintingContext.replacingLayer(_layer, paintBounds);
|
||||
_paintLayer(newContext);
|
||||
}
|
||||
void _paintLayer(PaintingContext context) {
|
||||
_layer.removeAllChildren();
|
||||
PaintingContext context = new PaintingContext.withLayer(_layer, paintBounds);
|
||||
_layer = context._containerLayer;
|
||||
try {
|
||||
_paintWithContext(context, Offset.zero);
|
||||
|
@ -44,6 +44,7 @@ class SkyBinding {
|
||||
_renderView.attach();
|
||||
_renderView.rootConstraints = _createConstraints();
|
||||
_renderView.scheduleInitialLayout();
|
||||
_renderView.initializeLayerTree();
|
||||
} else {
|
||||
_renderView = renderViewOverride;
|
||||
}
|
||||
@ -74,7 +75,6 @@ class SkyBinding {
|
||||
RenderObject.flushLayout();
|
||||
_renderView.updateCompositingBits();
|
||||
RenderObject.flushPaint();
|
||||
_renderView.paintFrame();
|
||||
_renderView.compositeFrame();
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,12 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
|
||||
markNeedsLayout();
|
||||
}
|
||||
|
||||
void initializeLayerTree() {
|
||||
final double devicePixelRatio = sky.view.devicePixelRatio;
|
||||
Matrix4 logicalToDeviceZoom = new Matrix4.diagonal3Values(devicePixelRatio, devicePixelRatio, 1.0);
|
||||
scheduleInitialPaint(new TransformLayer(transform: logicalToDeviceZoom));
|
||||
}
|
||||
|
||||
// We never call layout() on this class, so this should never get
|
||||
// checked. (This class is laid out using scheduleInitialLayout().)
|
||||
bool debugDoesMeetConstraints() { assert(false); return false; }
|
||||
@ -84,18 +90,6 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
|
||||
context.paintChild(child, offset.toPoint());
|
||||
}
|
||||
|
||||
void paintFrame() {
|
||||
sky.tracing.begin('RenderView.paintFrame');
|
||||
try {
|
||||
final double devicePixelRatio = sky.view.devicePixelRatio;
|
||||
Matrix4 logicalToDeviceZoom = new Matrix4.diagonal3Values(devicePixelRatio, devicePixelRatio, 1.0);
|
||||
ContainerLayer rootLayer = new TransformLayer(transform: logicalToDeviceZoom);
|
||||
initialPaint(rootLayer, size);
|
||||
} finally {
|
||||
sky.tracing.end('RenderView.paintFrame');
|
||||
}
|
||||
}
|
||||
|
||||
void compositeFrame() {
|
||||
sky.tracing.begin('RenderView.compositeFrame');
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user