mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
debug total render size
This commit is contained in:
parent
a26e8bade8
commit
808e4711f9
4 changed files with 47 additions and 34 deletions
|
@ -96,7 +96,6 @@ export interface ExcalidrawElementWithCanvas {
|
|||
export const cappedElementCanvasSize = (
|
||||
element: NonDeletedExcalidrawElement,
|
||||
zoom: Zoom,
|
||||
renderConfig: RenderConfig,
|
||||
): {
|
||||
width: number;
|
||||
height: number;
|
||||
|
@ -115,7 +114,7 @@ export const cappedElementCanvasSize = (
|
|||
let height =
|
||||
distance(y1, y2) * window.devicePixelRatio * zoomValue +
|
||||
padding * zoomValue * 2;
|
||||
|
||||
|
||||
const size = width * height;
|
||||
if (size > sizelimit) {
|
||||
zoomValue = Math.sqrt(sizelimit / size) as NormalizedZoomValue;
|
||||
|
@ -126,28 +125,27 @@ export const cappedElementCanvasSize = (
|
|||
distance(y1, y2) * window.devicePixelRatio * zoomValue +
|
||||
padding * zoomValue * 2;
|
||||
}
|
||||
return {width, height, zoomValue};
|
||||
} else {
|
||||
let width =
|
||||
return { width, height, zoomValue };
|
||||
}
|
||||
let width =
|
||||
element.width * window.devicePixelRatio * zoomValue +
|
||||
padding * zoomValue * 2;
|
||||
let height =
|
||||
element.height * window.devicePixelRatio * zoomValue +
|
||||
padding * zoomValue * 2;
|
||||
|
||||
const size = width * height;
|
||||
if (size > sizelimit) {
|
||||
zoomValue = Math.sqrt(sizelimit / size) as NormalizedZoomValue;
|
||||
width =
|
||||
element.width * window.devicePixelRatio * zoomValue +
|
||||
padding * zoomValue * 2;
|
||||
let height =
|
||||
height =
|
||||
element.height * window.devicePixelRatio * zoomValue +
|
||||
padding * zoomValue * 2;
|
||||
|
||||
const size = width * height;
|
||||
if (size > sizelimit) {
|
||||
zoomValue = Math.sqrt(sizelimit / size) as NormalizedZoomValue;
|
||||
width =
|
||||
element.width * window.devicePixelRatio * zoomValue +
|
||||
padding * zoomValue * 2;
|
||||
height =
|
||||
element.height * window.devicePixelRatio * zoomValue +
|
||||
padding * zoomValue * 2;
|
||||
}
|
||||
return {width, height, zoomValue};
|
||||
}
|
||||
}
|
||||
return { width, height, zoomValue };
|
||||
};
|
||||
|
||||
const generateElementCanvas = (
|
||||
element: NonDeletedExcalidrawElement,
|
||||
|
@ -158,12 +156,8 @@ const generateElementCanvas = (
|
|||
const context = canvas.getContext("2d")!;
|
||||
const padding = getCanvasPadding(element);
|
||||
|
||||
const {width, height, zoomValue} = cappedElementCanvasSize (
|
||||
element,
|
||||
zoom,
|
||||
renderConfig,
|
||||
);
|
||||
|
||||
const { width, height, zoomValue } = cappedElementCanvasSize(element, zoom);
|
||||
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
|
||||
|
@ -171,7 +165,7 @@ const generateElementCanvas = (
|
|||
let canvasOffsetY = 0;
|
||||
|
||||
if (isLinearElement(element) || isFreeDrawElement(element)) {
|
||||
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
||||
const [x1, y1] = getElementAbsoluteCoords(element);
|
||||
|
||||
canvasOffsetX =
|
||||
element.x > x1
|
||||
|
|
|
@ -29,7 +29,11 @@ import {
|
|||
} from "../scene/scrollbars";
|
||||
import { getSelectedElements } from "../scene/selection";
|
||||
|
||||
import { renderElement, renderElementToSvg } from "./renderElement";
|
||||
import {
|
||||
cappedElementCanvasSize,
|
||||
renderElement,
|
||||
renderElementToSvg,
|
||||
} from "./renderElement";
|
||||
import { getClientColors } from "../clients";
|
||||
import { LinearElementEditor } from "../element/linearElementEditor";
|
||||
import {
|
||||
|
@ -408,8 +412,16 @@ export const _renderScene = ({
|
|||
let editingLinearElement: NonDeleted<ExcalidrawLinearElement> | undefined =
|
||||
undefined;
|
||||
const start = Date.now();
|
||||
const showDebug = !appState.shouldCacheIgnoreZoom && (appState.zoom.value < 0.5);
|
||||
if(showDebug) console.log("start: renderElements");
|
||||
const showDebug = false; //!appState.shouldCacheIgnoreZoom && (appState.zoom.value < 0.5);
|
||||
if (showDebug) {
|
||||
console.log("start: renderElements");
|
||||
}
|
||||
console.log(
|
||||
visibleElements.reduce((acc, el) => {
|
||||
const { width, height } = cappedElementCanvasSize(el, appState.zoom);
|
||||
return acc + width * height;
|
||||
}, 0),
|
||||
);
|
||||
visibleElements.forEach((element) => {
|
||||
try {
|
||||
renderElement(element, rc, context, renderConfig, appState);
|
||||
|
@ -429,7 +441,9 @@ export const _renderScene = ({
|
|||
console.error(error);
|
||||
}
|
||||
});
|
||||
if(showDebug) console.log(`finish: renderElements ${Date.now()-start}`);
|
||||
if (showDebug) {
|
||||
console.log(`finish: renderElements ${Date.now() - start}`);
|
||||
}
|
||||
if (editingLinearElement) {
|
||||
renderLinearPointHandles(
|
||||
context,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue