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;
|
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) {
|
void paint(sky.Canvas canvas) {
|
||||||
canvas.translate(offset.dx, offset.dy);
|
canvas.translate(offset.dx, offset.dy);
|
||||||
paintChildren(canvas);
|
paintChildren(canvas);
|
||||||
|
@ -51,13 +51,6 @@ class PaintingContext {
|
|||||||
_startRecording(paintBounds);
|
_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);
|
PaintingContext.forTesting(this._canvas);
|
||||||
|
|
||||||
ContainerLayer _containerLayer;
|
ContainerLayer _containerLayer;
|
||||||
@ -650,21 +643,20 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
|
|||||||
sky.tracing.end('RenderObject.flushPaint');
|
sky.tracing.end('RenderObject.flushPaint');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void initialPaint(ContainerLayer rootLayer, Size size) {
|
void scheduleInitialPaint(ContainerLayer rootLayer) {
|
||||||
assert(attached);
|
assert(attached);
|
||||||
assert(parent is! RenderObject);
|
assert(parent is! RenderObject);
|
||||||
assert(!_debugDoingPaint);
|
assert(!_debugDoingPaint);
|
||||||
assert(hasLayer);
|
assert(hasLayer);
|
||||||
PaintingContext newContext = new PaintingContext.withLayer(rootLayer, Point.origin & size);
|
_layer = rootLayer;
|
||||||
_paintLayer(newContext);
|
assert(_needsPaint);
|
||||||
|
_nodesNeedingPaint.add(this);
|
||||||
}
|
}
|
||||||
void _repaint() {
|
void _repaint() {
|
||||||
assert(hasLayer);
|
assert(hasLayer);
|
||||||
assert(_layer != null);
|
assert(_layer != null);
|
||||||
PaintingContext newContext = new PaintingContext.replacingLayer(_layer, paintBounds);
|
_layer.removeAllChildren();
|
||||||
_paintLayer(newContext);
|
PaintingContext context = new PaintingContext.withLayer(_layer, paintBounds);
|
||||||
}
|
|
||||||
void _paintLayer(PaintingContext context) {
|
|
||||||
_layer = context._containerLayer;
|
_layer = context._containerLayer;
|
||||||
try {
|
try {
|
||||||
_paintWithContext(context, Offset.zero);
|
_paintWithContext(context, Offset.zero);
|
||||||
|
@ -44,6 +44,7 @@ class SkyBinding {
|
|||||||
_renderView.attach();
|
_renderView.attach();
|
||||||
_renderView.rootConstraints = _createConstraints();
|
_renderView.rootConstraints = _createConstraints();
|
||||||
_renderView.scheduleInitialLayout();
|
_renderView.scheduleInitialLayout();
|
||||||
|
_renderView.initializeLayerTree();
|
||||||
} else {
|
} else {
|
||||||
_renderView = renderViewOverride;
|
_renderView = renderViewOverride;
|
||||||
}
|
}
|
||||||
@ -74,7 +75,6 @@ class SkyBinding {
|
|||||||
RenderObject.flushLayout();
|
RenderObject.flushLayout();
|
||||||
_renderView.updateCompositingBits();
|
_renderView.updateCompositingBits();
|
||||||
RenderObject.flushPaint();
|
RenderObject.flushPaint();
|
||||||
_renderView.paintFrame();
|
|
||||||
_renderView.compositeFrame();
|
_renderView.compositeFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,12 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
|
|||||||
markNeedsLayout();
|
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
|
// We never call layout() on this class, so this should never get
|
||||||
// checked. (This class is laid out using scheduleInitialLayout().)
|
// checked. (This class is laid out using scheduleInitialLayout().)
|
||||||
bool debugDoesMeetConstraints() { assert(false); return false; }
|
bool debugDoesMeetConstraints() { assert(false); return false; }
|
||||||
@ -84,18 +90,6 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
|
|||||||
context.paintChild(child, offset.toPoint());
|
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() {
|
void compositeFrame() {
|
||||||
sky.tracing.begin('RenderView.compositeFrame');
|
sky.tracing.begin('RenderView.compositeFrame');
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user