From cae3bfa5989330ab105b226201366b3189fca529 Mon Sep 17 00:00:00 2001 From: John Stiles Date: Wed, 20 Mar 2024 14:29:03 -0700 Subject: [PATCH] Add naive implementation of `beginWebGPUAccess`. Explainer: https://github.com/fserb/canvas2D/blob/master/spec/webgpu.md This API converts a canvas' currently-displayed image to a GPUTexture which can be used by WebGPU. At present, the current implementation uses Snapshot(), which always clones the image. An ideal design would avoid this copy, but this gives us a starting point to iterate from. We do not yet have any guards against continuing to use the Canvas2D APIs after calling `beginWebGPUAccess`. This is safe because we don't actually steal the existing texture away from the canvas; it still has its own storage, distinct from the WebGPU texture. Once `endWebGPUAccess` is implemented, it is expected that this would clobber any canvas changes that might have occurred during WebGPU access (as the canvas texture would be replaced by the GPUTexture from WebGPU). Change-Id: Ied046431fbfdfff673ae61280317f8e0931ece7e Bug: 41490345 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5289055 Reviewed-by: Austin Eng Reviewed-by: Jean-Philippe Gravel Reviewed-by: Vasiliy Telezhnikov Auto-Submit: John Stiles Commit-Queue: John Stiles Cr-Commit-Position: refs/heads/main@{#1275839} --- html/canvas/tools/gentestutilsunion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/canvas/tools/gentestutilsunion.py b/html/canvas/tools/gentestutilsunion.py index d7042810be89748..445617bed5c4a8e 100644 --- a/html/canvas/tools/gentestutilsunion.py +++ b/html/canvas/tools/gentestutilsunion.py @@ -298,7 +298,7 @@ def _render(jinja_env: jinja2.Environment, template_name: str, params = dict(params) params.update({ # Render the code on its own, as it could contain templates expanding - # to multuple lines. This is needed to get proper indentation of the + # to multiple lines. This is needed to get proper indentation of the # code in the main template. 'code': _render_template(jinja_env, jinja_env.from_string(params['code']),