Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(engine-render): optimize border perf #1574

Merged
merged 6 commits into from
Mar 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions packages/engine-render/src/components/sheets/spreadsheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,23 +494,21 @@ export class Spreadsheet extends SheetComponent {

const columnWidthAccumulationLength = columnWidthAccumulation.length;
const rowHeightAccumulationLength = rowHeightAccumulation.length;

const rowStart = this._allowCache ? startRow : 0;
const rowEnd = this._allowCache ? endRow : rowHeightAccumulationLength - 1;
const columnEnd = this._allowCache ? endColumn : columnWidthAccumulationLength - 1;
const columnStart = this._allowCache ? startColumn : 0;
const EXTRA_BOUND = 0.1;
DR-Univer marked this conversation as resolved.
Show resolved Hide resolved
const rowStart = Math.floor(startRow * (1 - EXTRA_BOUND));
const rowEnd = Math.min(Math.ceil(endRow * (1 + EXTRA_BOUND)), rowHeightAccumulationLength - 1);
const columnEnd = Math.min(Math.ceil(endColumn * (1 + EXTRA_BOUND)), columnWidthAccumulationLength - 1);
const columnStart = Math.floor(startColumn * (1 - EXTRA_BOUND));

const startX = columnWidthAccumulation[columnStart - 1] || 0;
const startY = rowHeightAccumulation[rowStart - 1] || 0;
const endX = columnWidthAccumulation[columnEnd];
const endY = rowHeightAccumulation[rowEnd];

ctx.translateWithPrecisionRatio(FIX_ONE_PIXEL_BLUR_OFFSET, FIX_ONE_PIXEL_BLUR_OFFSET);

ctx.moveToByPrecision(startX, startY);
ctx.lineToByPrecision(endX, startY);

for (let r = 0; r <= rowEnd; r++) {
for (let r = rowStart; r <= rowEnd; r++) {
if (r < 0 || r > rowHeightAccumulationLength - 1) {
continue;
}
Expand All @@ -521,7 +519,7 @@ export class Spreadsheet extends SheetComponent {

ctx.moveToByPrecision(startX, startY);
ctx.lineToByPrecision(startX, endY);
for (let c = 0; c <= endColumn; c++) {
for (let c = columnStart; c <= columnEnd; c++) {
if (c < 0 || c > columnWidthAccumulationLength - 1) {
continue;
}
Expand Down
Loading