replaceRootLayer method
Replace the layer. This is only valid for the root of a render object subtree (whatever object scheduleInitialPaint was called on).
This might be called if, e.g., the device pixel ratio changed.
Implementation
void replaceRootLayer(OffsetLayer rootLayer) {
assert(rootLayer.attached);
assert(attached);
assert(parent is! RenderObject);
assert(!owner._debugDoingPaint);
assert(isRepaintBoundary);
assert(_layer != null); // use scheduleInitialPaint the first time
_layer.detach();
_layer = rootLayer;
markNeedsPaint();
}