Skip to content

Commit

Permalink
test: #677
Browse files Browse the repository at this point in the history
  • Loading branch information
lumixraku committed May 13, 2024
1 parent 9879d8b commit 76cd995
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
28 changes: 21 additions & 7 deletions packages/engine-render/src/viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class Viewport {
/**
* viewbound of cache area, cache area is slightly bigger than viewbound.
*/
private _cacheBound: IBoundRectNoAngle;
private _cacheBound: IBoundRectNoAngle | null;
private _preCacheBound: IBoundRectNoAngle | null;

/**
Expand Down Expand Up @@ -245,7 +245,7 @@ export class Viewport {
this._resizeHandler();
});
this._resizeHandler();
// this._testDisplayCache();
this._testDisplayCache();
}

initCacheCanvas(props?: IViewProps) {
Expand Down Expand Up @@ -273,8 +273,8 @@ export class Viewport {
cacheCanvas.getCanvasEle().style.border = '1px solid black'; // 设置边框样式
cacheCanvas.getCanvasEle().style.transformOrigin = '100% 100%';
cacheCanvas.getCanvasEle().style.transform = 'scale(0.5)';
cacheCanvas.getCanvasEle().style.translate = '20% 20%';
cacheCanvas.getCanvasEle().style.opacity = '0.9';
cacheCanvas.getCanvasEle().style.translate = '20% 0%';
cacheCanvas.getCanvasEle().style.opacity = '1';
document.body.appendChild(cacheCanvas.getCanvasEle());
};
if (['viewMain', 'viewMainLeftTop', 'viewMainTop', 'viewMainLeft'].includes(this.viewportKey)) {
Expand Down Expand Up @@ -387,6 +387,18 @@ export class Viewport {
return this._cacheBound;
}

set cacheBound(val) {
this._cacheBound = val;
}

get preCacheBound() {
return this._preCacheBound;
}

set preCacheBound(val: IBoundRectNoAngle | null) {
this._preCacheBound = val;
}

enable() {
this._active = true;
}
Expand Down Expand Up @@ -800,10 +812,9 @@ export class Viewport {


const viewBound = {
// 这里若对 top left 做 Math.floor 对 right bottom Math.ceil 操作, 放大后, 贴图会模糊
top: topLeft.y,
left: topLeft.x,
right: bottomRight.x,
top: topLeft.y,
bottom: bottomRight.y,
};
this._viewBound = viewBound;
Expand Down Expand Up @@ -1083,6 +1094,8 @@ export class Viewport {
const canvasW = width !== 0 ? width + this.bufferEdgeX * 2 * scaleX : 0;
const canvasH = height !== 0 ? height + this.bufferEdgeY * 2 * scaleY : 0;
this._cacheCanvas?.setSize(canvasW, canvasH);
this.cacheBound = null;
this.preCacheBound = null;

const contentWidth = (this._scene.width - this._paddingEndX) * this._scene.scaleX;
const contentHeight = (this._scene.height - this._paddingEndY) * this._scene.scaleY;
Expand Down Expand Up @@ -1267,9 +1280,9 @@ export class Viewport {
expandBounds(value: { top: number; left: number; bottom: number; right: number }) {
const onePixelFix = FIX_ONE_PIXEL_BLUR_OFFSET * 2;
return {
right: value.right + this.bufferEdgeX + onePixelFix,
left: Math.max(this.leftOrigin, value.left - this.bufferEdgeX) - onePixelFix,
top: Math.max(this.topOrigin, value.top - this.bufferEdgeY) - onePixelFix,
right: value.right + this.bufferEdgeX + onePixelFix,
bottom: value.bottom + this.bufferEdgeY + onePixelFix,
} as IBoundRectNoAngle;
}
Expand All @@ -1284,6 +1297,7 @@ export class Viewport {

private _shouldCacheUpdate(viewBound: IBoundRectNoAngle, cacheBounds:
IBoundRectNoAngle | null, diffX: number, diffY: number): number {
if (!this._cacheCanvas) return 0b00;
if (!cacheBounds) return 0b01;
const viewBoundOutCacheArea = !(viewBound.right <= cacheBounds.right && viewBound.top >= cacheBounds.top
&& viewBound.left >= cacheBounds.left && viewBound.bottom <= cacheBounds.bottom)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class DataBar extends SheetExtension {
return false;
}
ctx.save();
ctx.globalCompositeOperation = 'destination-over';
// ctx.globalCompositeOperation = 'destination-over';
Range.foreach(spreadsheetSkeleton.rowColumnSegment, (row, col) => {
const cellData = worksheet.getCell(row, col) as IDataBarCellData;
if (cellData && cellData.dataBar) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class ConditionalFormattingIcon extends SheetExtension {
return false;
}
ctx.save();
ctx.globalCompositeOperation = 'destination-over';
// ctx.globalCompositeOperation = 'destination-over';
Range.foreach(spreadsheetSkeleton.rowColumnSegment, (row, col) => {
const cellData = worksheet.getCell(row, col) as IIconSetCellData;
if (cellData?.iconSet) {
Expand Down

0 comments on commit 76cd995

Please sign in to comment.