-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
fixed image drawing for the both UI #1302
fixed image drawing for the both UI #1302
Conversation
@@ -692,6 +692,7 @@ export class CanvasViewImpl implements CanvasView, Listener { | |||
ctx.scale(image.renderWidth / image.imageData.width, | |||
image.renderHeight / image.imageData.height); | |||
ctx.putImageData(image.imageData, 0, 0); | |||
ctx.drawImage(this.background, 0, 0); |
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.
What is problem here?
Why putImageData
is not enough?
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 current path, transformation matrix, shadow attributes, global alpha, the clipping region, and global composition operator must not affect the getImageData() and putImageData() methods.
from: https://www.w3.org/TR/2dcontext/#dom-context-2d-putimagedata
By this reason I have to redraw canvas to apply scale.
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.
Is this fast operation? As far as I remember it was quite slow before
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.
In this case putImageData takes ~1ms, drawImage < 1ms for fullHD and ~10 ms and <1ms for 4k.
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.
It would be great if you left a comment in the code about why we need this line (just to do not forget)
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.
Sure
@@ -692,6 +692,7 @@ export class CanvasViewImpl implements CanvasView, Listener { | |||
ctx.scale(image.renderWidth / image.imageData.width, | |||
image.renderHeight / image.imageData.height); | |||
ctx.putImageData(image.imageData, 0, 0); | |||
ctx.drawImage(this.background, 0, 0); |
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.
It would be great if you left a comment in the code about why we need this line (just to do not forget)
No description provided.