-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(dpr): able to update dpr by resize #1149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(dpr): able to update dpr by resize #1149
Conversation
src/canvas/Painter.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to completely replace the constant devicePixelRatio in favor of the new getDevicePixelRatio() function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/canvas/Layer.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just let the DPR fall back to 1 and only do it in zrender constructor?
https://github.com/Justin-ZS/zrender/blob/5a52347e793a2eeffcc9eaed5dd4538087755eac/src/zrender.ts#L92
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to do it only in the Canvas Painter constructor.
| // TODO sting? | ||
| height = opts.height as number; | ||
| } | ||
| this.dpr = opts.devicePixelRatio || 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plainheart
Since this.dpr has already been initialized before, I removed this line.
Please let me know if forcing 1 here was intentional.
Summary
devicePixelRatioupdates through theresize()methodLayer.updateDpr()to keep canvas context dpr in syncFix
apache/echarts#21386
Usage
Changes
devicePixelRatioparameter toPainterBase.resize()interfaceLayer.updateDpr()methodPainter.resize()to trigger layer resize on dpr changedevicePixelRatiooption inZRender.resize()