Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 31x 31x 31x 31x 8x 8x 8x 8x 8x 8x 8x 31x 31x 31x 31x 31x 1x 1x 31x 31x 31x 31x 31x 31x 31x 1x 1x 31x 31x 31x 31x 31x 31x 31x 31x 8x 8x 8x 31x | import { BaseModel } from './base-model';
import { MessageType } from '../core/message-type';
import { Servicer } from '../servicer/servicer';
const commands = MessageType.viewTarget;
/**
* 视图目标
*/
export class Target extends BaseModel {
public offscreen = false;
constructor(
targetId: string,
public width: number,
public height: number,
servicer: Servicer
) {
super(targetId, servicer);
}
/**
* 销毁视图目标实例
*/
async destory() {
await this.servicer.do(commands.destory, [this.id]);
}
/**
* 设置视图目标尺寸
* @param width - 宽度
* @param height - 高度
*/
async setTargetSize(width: number, height: number) {
await this.servicer.do(commands.setTargetSize, [this.id, width, height]);
}
/**
* 设置离屏渲染
* @param offscreen - 是否离屏渲染
* @param needTransform - 是否需要在 worker 中传递 bitmap
* 在 worker 中,如果需要 offscreen canvas 在渲染后将渲染结果返回,需要设置将 needTransform 设置为 true,但是这样会导致主线程的 offscreen canvas 失去挂载,需要根据实际需求设置
*/
async setOffscreen(offscreen: boolean, needTransform: boolean = false) {
await this.servicer.do(commands.setOffscreen, [this.id, offscreen, needTransform]);
this.offscreen = offscreen;
}
} |