Skip to content

Commit

Permalink
fix text dirty rect considered when text in host
Browse files Browse the repository at this point in the history
  • Loading branch information
linghaoSu committed Feb 21, 2022
1 parent 4e721ed commit 458d111
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/canvas/Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export default class Layer extends Eventful {
* if it's currently on the canvas and needs repaint this frame
* or not painted this frame.
*/
const shouldPaint = el.shouldBePainted(viewWidth, viewHeight, true, true);
const shouldPaint = el.shouldBePainted(viewWidth, viewHeight, true, true, true);
const prevRect = el.__isRendered && ((el.__dirty & REDRAW_BIT) || !shouldPaint)
? el.getPrevPaintRect()
: null;
Expand Down Expand Up @@ -311,7 +311,7 @@ export default class Layer extends Eventful {
* rect if and only if it's not painted this frame and was
* previously painted on the canvas.
*/
const shouldPaint = el.shouldBePainted(viewWidth, viewHeight, true, true);
const shouldPaint = el.shouldBePainted(viewWidth, viewHeight, true, true, true);
if (el && (!shouldPaint || !el.__zr) && el.__isRendered) {
// el was removed
const prevRect = el.getPrevPaintRect();
Expand Down
2 changes: 1 addition & 1 deletion src/canvas/graphic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ export function brush(
) {
const m = el.transform;

if (!el.shouldBePainted(scope.viewWidth, scope.viewHeight, false, false)) {
if (!el.shouldBePainted(scope.viewWidth, scope.viewHeight, false, false, false)) {
// Needs to mark el rendered.
// Or this element will always been rendered in progressive rendering.
// But other dirty bit should not be cleared, otherwise it cause the shape
Expand Down
20 changes: 19 additions & 1 deletion src/graphic/Displayable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ class Displayable<Props extends DisplayableProps = DisplayableProps> extends Ele
viewWidth: number,
viewHeight: number,
considerClipPath: boolean,
considerAncestors: boolean
considerAncestors: boolean,
considerHostTarget: boolean
) {
const m = this.transform;
if (
Expand Down Expand Up @@ -234,6 +235,23 @@ class Displayable<Props extends DisplayableProps = DisplayableProps> extends Ele
}
}

// consider host target
if (
considerAncestors
&& considerHostTarget
&& this.parent
&& this.parent.__hostTarget
) {
let hostTarget = this.parent.__hostTarget;
let parent = hostTarget;
while (parent) {
if (parent.ignore) {
return false;
}
parent = parent.parent;
}
}

return true;
}

Expand Down

0 comments on commit 458d111

Please sign in to comment.