Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can treat __hostTarget as a special parent and doing both check in the

let parent = this.parent;

if (considerAncestors) {
      let node = this;
      while (node) {
          if (node.ignore) {
              return false;
          }
          node = node.parent || node.__hostTarget;
      }
  }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, I agree with this way, we don't need to modify the api of shouldBePainted, I have fixed this using these codes. Please review again.

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