mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 02:48:12 +08:00
Display images in the SVG viewport renderer via canvases instead of base64 PNGs (#2903)
* add: move images as rendered canvases to node_graph_executor
* add: added the frontend message
* fix: bytemuck stuff
* fix: canvas element breaking
* fix: width issues
* fix: remove the old message
* npm: run lint-fix
* fix
* works finally
* fix transforms
* Fix self closing tag
* fix: reuse id
* fix: have it working with repeat instance
* cargo: fmt
* fix
* Avoid "canvas" prefix to IDs
* fix
* fix: vello issue from 6111440
* fix: gpu stuff
* fix: vello bbox
* Code review
---------
Co-authored-by: hypercube <0hypercube@gmail.com>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
@@ -192,12 +192,25 @@
|
||||
|
||||
const placeholders = window.document.querySelectorAll("[data-viewport] [data-canvas-placeholder]");
|
||||
// Replace the placeholders with the actual canvas elements
|
||||
placeholders.forEach((placeholder) => {
|
||||
Array.from(placeholders).forEach((placeholder) => {
|
||||
const canvasName = placeholder.getAttribute("data-canvas-placeholder");
|
||||
if (!canvasName) return;
|
||||
// Get the canvas element from the global storage
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const canvas = (window as any).imageCanvases[canvasName];
|
||||
let canvas = (window as any).imageCanvases[canvasName];
|
||||
|
||||
if (canvasName !== "0" && canvas.parentElement) {
|
||||
var newCanvas = window.document.createElement("canvas");
|
||||
var context = newCanvas.getContext("2d");
|
||||
|
||||
newCanvas.width = canvas.width;
|
||||
newCanvas.height = canvas.height;
|
||||
|
||||
context?.drawImage(canvas, 0, 0);
|
||||
|
||||
canvas = newCanvas;
|
||||
}
|
||||
|
||||
placeholder.replaceWith(canvas);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user