Status
()
People
(Reporter: xidorn, Assigned: fatseng)
Tracking
(Blocks: 1 bug)
Firefox Tracking Flags
(Not tracked)
Details
(Whiteboard: [gfx-noted])
The HTML spec includes "width" and "height" attribute for CanvasRenderingContext2D to get the dimensions of the canvas. [1] This would be useful because otherwise there is no efficient way to get the geometry inside the rAF loop. Some apps use clientWidth and clientHeight to get the width and height (e.g. MDN's pointerlock demo [2]), which hurts the performance because of triggering flush. [1] https://html.spec.whatwg.org/multipage/scripting.html#2dcontext [2] https://github.com/mdn/pointer-lock-demo/blob/3f6cfe118e5e2b205314680c69dd94f34978b8ed/app.js#L41
Updated•3 years ago
|
Whiteboard: [gfx-noted]
This is different from the width and height that we have today? https://dxr.mozilla.org/mozilla-central/source/dom/canvas/CanvasRenderingContext2D.h#428
(Reporter) | ||
Comment 2•3 years ago
|
||
Probably the same. We may just need to expose it in the WebIDL file.
Comment 3•3 years ago
|
||
(In reply to Xidorn Quan [:xidorn] (UTC+8) from comment #2) > Probably the same. We may just need to expose it in the WebIDL file. I can take this bug for the following things based on requirement.
Assignee: nobody → vliu
Comment 4•3 years ago
|
||
I will assign this bug to Farmer because he is interested in looking into it
Assignee: vliu → fatseng
(Assignee) | ||
Comment 5•3 years ago
|
||
I can't find width and height attributes in CanvasRenderingContext2D spec. [1] But found they are in htmlcanvaselement. [2] Do ctx.canvas.width and ctx.canvas.height also hurt performance? [1] https://html.spec.whatwg.org/multipage/scripting.html#2dcontext [2] https://html.spec.whatwg.org/multipage/scripting.html#htmlcanvaselement
Flags: needinfo?(bugzilla)
(Reporter) | ||
Comment 6•3 years ago
|
||
It seems it is removed a while ago: https://github.com/whatwg/html/pull/1074 And yes, canvas.width / canvas.height should be the right way to go, which I wasn't aware of.
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Flags: needinfo?(bugzilla)
Resolution: --- → INVALID
Updated•3 years ago
|
Keywords: dev-doc-needed
You need to log in
before you can comment on or make changes to this bug.
Description
•