the documentation tries to motivate the use of OffscreenCanvasRenderingConxt2D as it reads at the top of this page:
Use OffscreenCanvasRenderingContext2D to draw rectangles, images, and text offscreen onto a canvas. Drawing offscreen onto a canvas is a process where content to draw onto the canvas is first drawn in the buffer, and then converted into a picture, and finally the picture is drawn on the canvas. This process increases the drawing efficiency.
The following examples are basically all like this
Canvas(this.context)
.onReady(() =>{
this.offContext.lineWidth = 5
this.offContext.strokeRect(25, 25, 85, 105)
var image = this.offContext.transferToImageBitmap()
this.context.transferFromImageBitmap(image)
})
comparing to using on screen context
Canvas(this.context)
.onReady(() =>{
this.context.lineWidth = 5
this.context.strokeRect(25, 25, 85, 105)
})
Why would the first be more efficient than the second? - It involves an additional image copy operation. It will be slower to execute!
You need to give a meaningful example that makes it clear why OffscreenCanvasRenderingContext2D is more efficient (if it actually is ;-)
Besides these examples for OffscreenCanvasRenderingContext2D being repetitive. Same as for regular Context.
We have made a proposal how to fix the developer API of Canvas , 2D context and also offscreen context. Shared Huawei internally https://rnd-gitlab-eu-c.huawei.com/zidanehbs/ace-fin-web/ace-reports/-/blob/master/new_feature_ideation/canvas-view-redesign.md
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
登录 后才可以发表评论