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
prevent render canvas with quality less than 100% #7537
Conversation
@@ -232,7 +232,7 @@ | |||
* @private | |||
*/ | |||
_isRetinaScaling: function() { | |||
return (fabric.devicePixelRatio !== 1 && this.enableRetinaScaling); | |||
return (fabric.devicePixelRatio > 1 && this.enableRetinaScaling); |
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.
you also need to change getRetinaScaling to return a number that is at minimum 1 i think.
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
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.
Maybe make sense to switch places of these parts for performance? Checking a boolean variable should be faster than comparing two values. Like this: this.enableRetinaScaling && fabric.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.
@Dok11 i don't sure. JS engine probably is don't know whats variable contain, so will not check variable as boolean directly. But symbol >
may suggest that it's just math operation which is instant
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.
@vitonsky I even tested it, and it seems like it doesn't care :D
https://jsbench.me/zkkxq3rjv0/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.
i m sure performance is not an issue here, but in the JS bench seems like Math.random and toFixed are actually the 2 things that will matter for performance. no?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@vitonsky could you push a commit that calculates retina scaling from within |
we broke so many tests. not sure why it wasn't visible in the pr |
}, | ||
|
||
/** | ||
* @private | ||
* @return {Number} retinaScaling if applied, otherwise 1; | ||
*/ | ||
getRetinaScaling: function() { | ||
return this._isRetinaScaling() ? fabric.devicePixelRatio : 1; | ||
return Math.max(1, fabric.devicePixelRatio); |
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.
ok this was the error.
We lessen the importance of the boolean here.
If retina scaling is set as false, whatever is the devicePixelRatio, we return 1.
My bad for not noticing it.
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.
Probably we can fix it like this?
this._isRetinaScaling() ? Math.max(1, fabric.devicePixelRatio) : 1
I'm not sure that we can do it on the library level. If you wish, make own pull request with this change if possible |
Fix issue #7502