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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,15 +232,15 @@ | |
* @private | ||
*/ | ||
_isRetinaScaling: function() { | ||
return (fabric.devicePixelRatio !== 1 && this.enableRetinaScaling); | ||
return (fabric.devicePixelRatio > 1 && this.enableRetinaScaling); | ||
}, | ||
|
||
/** | ||
* @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 commentThe reason will be displayed to describe this comment to others. Learn more. ok this was the error. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
}, | ||
|
||
/** | ||
|
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 instantThere 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?