Skip to content

Commit

Permalink
Revert "Probe OfflineCanvas speed"
Browse files Browse the repository at this point in the history
This reverts commit 8e88a5b.
  • Loading branch information
hans00 committed Oct 31, 2023
1 parent 67947a4 commit c0a58df
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,6 @@ const newRegExp = (...args) => {
};
global.RegExp = newRegExp;

// Optional polyfill for console.time
const timers = new Map();
console.time ??= ((label) => {
timers.set(label, Date.now());
});
console.timeEnd ??= ((label) => {
const start = timers.get(label);
if (start) {
console.log(`${label}: ${Date.now() - start}ms`);
timers.delete(label);
}
});

// OffscreenCanvas, Image, etc.
global.Image = class ImagePolyfill extends EventEmitter {
constructor(width, height) {
Expand Down Expand Up @@ -168,7 +155,6 @@ global.CanvasRenderingContext2D = class CanvasRenderingContext2DPolyfill {
}

putImageData(imageData, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight) {
console.time('putImageData');
const { data, width, height } = imageData;
const skData = Skia.Data.fromBytes(data);
const image = Skia.Image.MakeImage(getImageInfo(width, height), skData, 4 * width);
Expand All @@ -194,20 +180,16 @@ global.CanvasRenderingContext2D = class CanvasRenderingContext2DPolyfill {
);
}
image.dispose();
console.timeEnd('putImageData');
}

getImageData(sx=0, sy=0, sw, sh) {
console.time('getImageData');
const width = sw ?? this.canvas.width;
const height = sh ?? this.canvas.height;
const pixels = this._ctx.readPixels(sx, sy, getImageInfo(width, height), undefined, 4 * width);
console.timeEnd('getImageData');
return new ImageData(pixels, width, height);
}

drawImage(image, dx, dy, dw, dh, sx, sy, sw, sh) {
console.time('drawImage');
let img;
let width;
let height;
Expand Down Expand Up @@ -262,7 +244,6 @@ global.CanvasRenderingContext2D = class CanvasRenderingContext2DPolyfill {
if (image.surface) {
img.dispose();
}
console.timeEnd('drawImage');
}

fillText(text, x, y, maxWidth) {
Expand Down

0 comments on commit c0a58df

Please sign in to comment.