skip redraw only if both current and prev bounds are not in view
Signed-off-by: Dennis Francis <dennis.francis@collabora.com> Change-Id: Iaa7c8efc41b77f72f1804a4c81d2ec6c6f3d1f10
This commit is contained in:
parent
3a40feda4a
commit
088e48ecc5
3 changed files with 33 additions and 12 deletions
|
@ -71,15 +71,16 @@ abstract class CPath {
|
|||
this.isDeleted = true;
|
||||
}
|
||||
|
||||
redraw() {
|
||||
redraw(oldBounds: CBounds) {
|
||||
if (this.renderer)
|
||||
this.renderer.updatePath(this);
|
||||
this.renderer.updatePath(this, oldBounds);
|
||||
}
|
||||
|
||||
setStyle(style: any) {
|
||||
var oldBounds = this.getBounds();
|
||||
this.setStyleOptions(style);
|
||||
if (this.renderer) {
|
||||
this.renderer.updateStyle(this);
|
||||
this.renderer.updateStyle(this, oldBounds);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,14 +69,30 @@ class CPolyline extends CPath {
|
|||
this.setPointSet(pointSet);
|
||||
}
|
||||
|
||||
private static invalidPoint(): CPoint {
|
||||
return new CPoint(-1000000, -1000000);
|
||||
}
|
||||
|
||||
private static emptyBounds(): CBounds {
|
||||
var bounds = new CBounds();
|
||||
bounds.extend(CPolyline.invalidPoint());
|
||||
return bounds;
|
||||
}
|
||||
|
||||
getPointSet(): CPointSet {
|
||||
return this.pointSet;
|
||||
}
|
||||
|
||||
setPointSet(pointSet: CPointSet) {
|
||||
var oldBounds: CBounds;
|
||||
if (this.bounds)
|
||||
oldBounds = this.bounds.clone();
|
||||
else
|
||||
oldBounds = CPolyline.emptyBounds();
|
||||
|
||||
this.pointSet = pointSet;
|
||||
this.updateRingsBounds();
|
||||
return this.redraw();
|
||||
return this.redraw(oldBounds);
|
||||
}
|
||||
|
||||
updateRingsBounds() {
|
||||
|
@ -84,7 +100,7 @@ class CPolyline extends CPath {
|
|||
var bounds = this.bounds = new CBounds();
|
||||
|
||||
if (this.pointSet.empty()) {
|
||||
bounds.extend(new CPoint(-1000000, -1000000));
|
||||
bounds.extend(CPolyline.invalidPoint());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,12 +50,12 @@ class CanvasOverlay {
|
|||
this.draw();
|
||||
}
|
||||
|
||||
updatePath(path: CPath) {
|
||||
this.redraw(path);
|
||||
updatePath(path: CPath, oldBounds: CBounds) {
|
||||
this.redraw(path, oldBounds);
|
||||
}
|
||||
|
||||
updateStyle(path: CPath) {
|
||||
this.redraw(path);
|
||||
updateStyle(path: CPath, oldBounds: CBounds) {
|
||||
this.redraw(path, oldBounds);
|
||||
}
|
||||
|
||||
paintRegion(paintArea: CBounds) {
|
||||
|
@ -68,9 +68,13 @@ class CanvasOverlay {
|
|||
|
||||
private isVisible(path: CPath): boolean {
|
||||
var pathBounds = path.getBounds();
|
||||
return this.intersectsVisible(pathBounds);
|
||||
}
|
||||
|
||||
private intersectsVisible(queryBounds: CBounds): boolean {
|
||||
this.updateCanvasBounds();
|
||||
var spc = this.getSplitPanesContext();
|
||||
return spc ? spc.intersectsVisible(pathBounds) : this.bounds.intersects(pathBounds);
|
||||
return spc ? spc.intersectsVisible(queryBounds) : this.bounds.intersects(queryBounds);
|
||||
}
|
||||
|
||||
private draw(paintArea?: CBounds) {
|
||||
|
@ -92,8 +96,8 @@ class CanvasOverlay {
|
|||
});
|
||||
}
|
||||
|
||||
private redraw(path: CPath) {
|
||||
if (!this.isVisible(path))
|
||||
private redraw(path: CPath, oldBounds: CBounds) {
|
||||
if (!this.isVisible(path) && !this.intersectsVisible(oldBounds))
|
||||
return;
|
||||
// This does not get called via onDraw(ie, tiles aren't painted), so ask tileSection to "erase" by painting over.
|
||||
// Repainting the whole canvas is not necessary but finding the minimum area to paint over
|
||||
|
|
Loading…
Reference in a new issue