perf(frontend): MkImgWithBlurhashでblurhash描画に使うcanvasは再利用するようにする (#10966)

* blurhashを描画するためのcanvasは再利用する

* Revert "perf(frontend): WebGL contextの数を減らす"

This reverts commit aeb8955ca2.

* MkAvatarは平均色だけにする

* clean up

* fix
This commit is contained in:
tamaina
2023-07-02 13:46:49 +09:00
committed by GitHub
parent a1327fa9e1
commit 734c41aba5
3 changed files with 39 additions and 23 deletions

View File

@@ -1,5 +1,7 @@
import { render } from 'buraha';
const canvas = new OffscreenCanvas(64, 64);
onmessage = (event) => {
// console.log(event.data);
if (!('id' in event.data && typeof event.data.id === 'string')) {
@@ -8,8 +10,8 @@ onmessage = (event) => {
if (!('hash' in event.data && typeof event.data.hash === 'string')) {
return;
}
const work = new OffscreenCanvas(event.data.width ?? 64, event.data.height ?? 64);
render(event.data.hash, work);
const bitmap = work.transferToImageBitmap();
render(event.data.hash, canvas);
const bitmap = canvas.transferToImageBitmap();
postMessage({ id: event.data.id, bitmap });
};