Browse Source

perf(border render speed up): cache border infomationn

master
liuyang 5 years ago
parent
commit
f4efc73d01
  1. 6
      src/global/border.js
  2. 12
      src/global/draw.js
  3. 2
      src/global/method.js
  4. 2
      src/store/index.js

6
src/global/border.js

@ -6,6 +6,10 @@ import Store from '../store';
function getBorderInfoCompute(sheetIndex) {
let borderInfoCompute = {};
if(Store.borderInfoCache!=null){
return Store.borderInfoCache;
}
let cfg, data;
if(sheetIndex == null){
cfg = Store.config;
@ -1026,6 +1030,8 @@ function getBorderInfoCompute(sheetIndex) {
}
}
Store.borderInfoCache = borderInfoCompute;
return borderInfoCompute;
}

12
src/global/draw.js

@ -1018,6 +1018,10 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
let bd_r = x.substr(0, x.indexOf('_'));
let bd_c = x.substr(x.indexOf('_') + 1);
if(bd_r < dataset_row_st || bd_r > dataset_row_ed || bd_c < dataset_col_st || bd_c > dataset_col_ed){
continue;
}
if(borderOffset[bd_r + "_" + bd_c]){
let start_r = borderOffset[bd_r + "_" + bd_c].start_r;
let start_c = borderOffset[bd_r + "_" + bd_c].start_c;
@ -1064,6 +1068,8 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
Store.measureTextCacheTimeOut = setTimeout(() => {
Store.measureTextCache = {};
Store.measureTextCellInfoCache = {};
Store.borderInfoCache = null;
Store.cellOverflowMapCache = null;
}, 2000);
}
@ -1954,6 +1960,10 @@ let cellOverflowRender = function(r, c, stc, edc,luckysheetTableContent,scrollHe
function getCellOverflowMap(canvas, col_st, col_ed, row_st, row_end){
let map = {};
if(Store.cellOverflowMapCache!=null){
return Store.cellOverflowMapCache;
}
let data = Store.flowdata;
for(let r = row_st; r <= row_end; r++){
@ -2055,6 +2065,8 @@ function getCellOverflowMap(canvas, col_st, col_ed, row_st, row_end){
}
}
Store.cellOverflowMapCache = map;
return map;
}

2
src/global/method.js

@ -135,6 +135,8 @@ const defaultConfig = {
measureTextCache:{},
measureTextCellInfoCache:{},
measureTextCacheTimeOut:null,
borderInfoCache:null,
cellOverflowMapCache:null,
zoomRatio:1,

2
src/store/index.js

@ -119,6 +119,8 @@ const Store = {
measureTextCache:{},
measureTextCellInfoCache:{},
measureTextCacheTimeOut:null,
borderInfoCache:null,
cellOverflowMapCache:null,
zoomRatio:1,

Loading…
Cancel
Save