Skip to content

Fix PR #1149 - #1177

Open
100pah wants to merge 5 commits into
masterfrom
feat/able_to_update_dpr_in_resize_fix2
Open

100pah wants to merge 5 commits into
masterfrom
feat/able_to_update_dpr_in_resize_fix2

Conversation

@100pah

@100pah 100pah commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor
  1. Fix some issues introduced by PR feat(canvas): update DPR after resizing #1149:
  • Fix the incorrect… usage of this in callback function (
    layer.resize(width as number, height as number, this.dpr);
    ). And the corresponding TS error.
  • PathProxy#setScale was called before PathProxy#setDPR, but PathProxy#setScale used DPR. Fix that: remove setDPR method and add DPR as a parameter of setScale.
  1. Fix and clarify width/height parameters processing in constructor and resize method in singleCanvas case - align them with non-singleCanvas case.
  2. Remove attaching dpr to CanvasRenderingContext2D - not necessary and error-prone.
  3. Fix SVG renderer Painter#toDataURL and Painter#renderToString - add the missing escaping on attribute values.

… usage of `this` in callback function (https://github.com/ecomfe/zrender/blob/349111033fba0fa08cee745b72dd2ea66dc6fcaa/src/canvas/Painter.ts#L1254). And the corresponding TS error. (1.2) `PathProxy#setScale` was called before `PathProxy#setDPR`, but `PathProxy#setScale` used DPR. Fix that: remove `setDPR` method and add DPR as a parameter of `setScale`.

(2). Fix and clarify width/height parameters processing in `constructor` and `resize` method in `singleCanvas` case - align them with `non-singleCanvas` case.
(3). Remove attaching `dpr` to `CanvasRenderingContext2D` - not necessary and error-prone.
@100pah
100pah requested review from plainheart and a balanced review from Copilot October 15, 2026 20:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved canvas resizing and export-scaling regressions can produce incorrectly sized or clipped output.

4 open findings
What changed in this PR

Addresses rendering issues introduced by #1158 by making device pixel ratio (DPR) explicit and revising canvas sizing.

Changes:

  • Passes DPR through brush scopes and path scaling instead of attaching it to rendering contexts.
  • Refactors single-canvas sizing and fixes the resize callback’s this usage.
  • Consolidates shared sizing and rendering option types.
File Description
src/​zrender.ts Uses shared options and clarifies resize documentation.
src/​PainterBase.ts Reuses shared resize parameter types.
src/​graphic/​Displayable.ts Adds DPR to brush parameters.
src/​graphic/​CompoundPath.ts Passes DPR to child path scaling.
src/​core/​types.ts Defines shared options and dimension constants.
src/​core/​PathProxy.ts Accepts DPR directly in setScale.
src/​core/​BoundingRect.ts Reuses shared dimension constants.
src/​canvas/​Painter.ts Revises sizing, resizing, and DPR propagation.
src/​canvas/​Layer.ts Removes context DPR markers and centralizes bitmap sizing.
src/​canvas/​helper.ts Adds single-canvas size resolution.
src/​canvas/​graphic.ts Uses brush-scope DPR throughout rendering.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/canvas/Painter.ts Outdated
Comment thread src/canvas/Painter.ts Outdated
Comment thread src/canvas/Painter.ts
Comment thread src/canvas/Painter.ts Outdated
@100pah 100pah changed the title Fix PR #1158 Fix PR #1149 Oct 15, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants