Skip to content

Commit e32ff3e

Browse files
committed
perf(viewer-ohos): 优化颜色缓存无符号键归一化、Fling回退调度与ArkUI测试key告警消除
Signed-off-by: donglua <dongluh@gmail.com>
1 parent d3ca82f commit e32ff3e

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎viewer-ohos/src/main/ets/render/OfficePreviewView.ets‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export struct OfficePreviewView {
292292
this.childSetZoom = setZoom;
293293
}
294294
})
295-
.key(`doc-${this.docRevision}-${this.rawDocument?.kind ?? ''}`)
295+
.id(`doc-${this.docRevision}-${this.rawDocument?.kind ?? ''}`)
296296
.width('100%')
297297
.height('100%')
298298
} else if (this.rawDocument.kind === 'PPTX') {
@@ -312,7 +312,7 @@ export struct OfficePreviewView {
312312
this.childSetZoom = setZoom;
313313
}
314314
})
315-
.key(`doc-${this.docRevision}-${this.rawDocument?.kind ?? ''}`)
315+
.id(`doc-${this.docRevision}-${this.rawDocument?.kind ?? ''}`)
316316
.width('100%')
317317
.height('100%')
318318
} else if (this.rawDocument.kind === 'XLSX') {
@@ -331,7 +331,7 @@ export struct OfficePreviewView {
331331
this.childSetZoom = setZoom;
332332
}
333333
})
334-
.key(`doc-${this.docRevision}-${this.rawDocument?.kind ?? ''}`)
334+
.id(`doc-${this.docRevision}-${this.rawDocument?.kind ?? ''}`)
335335
.width('100%')
336336
.height('100%')
337337
}
@@ -821,7 +821,7 @@ struct DocxShapeView {
821821
this.drawShape();
822822
})
823823
}
824-
.key(`shape-${this.reuseVersion}`)
824+
.id(`shape-${this.reuseVersion}`)
825825
.width('100%')
826826
.justifyContent(FlexAlign.Center)
827827
.margin({ top: 4, bottom: 6 })
@@ -1456,7 +1456,7 @@ struct PptxSlideCanvas {
14561456
this.drawSlide(false);
14571457
})
14581458
}
1459-
.key(`slide-canvas-${this.reuseVersion}`)
1459+
.id(`slide-canvas-${this.reuseVersion}`)
14601460
.width('100%')
14611461
.accessibilityText(buildSlideAccessibilityLabel(this.page, this.slideNumber, this.slideCount))
14621462
.accessibilityGroup(true)

‎viewer-ohos/src/main/ets/render/RenderUtils.ets‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ export class RenderUtils {
2020
* 若 alpha 为 0(透明),返回 null
2121
*/
2222
public static argbToCss(argb: number): string | null {
23-
const cached = RenderUtils.colorCache.get(argb);
23+
const unsigned = argb >>> 0;
24+
const cached = RenderUtils.colorCache.get(unsigned);
2425
if (cached !== undefined) return cached;
2526

26-
const unsigned = argb >>> 0;
2727
const a = (unsigned >>> 24) & 0xff;
2828
let result: string | null = null;
2929
if (a !== 0) {
@@ -39,7 +39,7 @@ export class RenderUtils {
3939
break;
4040
}
4141
}
42-
RenderUtils.colorCache.set(argb, result);
42+
RenderUtils.colorCache.set(unsigned, result);
4343
return result;
4444
}
4545

‎viewer-ohos/src/main/ets/render/SpreadsheetView.ets‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,10 @@ export struct SpreadsheetView {
391391
this.vsync.start();
392392
} catch (_e) {
393393
this.vsync = null;
394-
this.stepFlingFallback();
394+
this.flingTimer = setTimeout(this.stepFlingFallback, 16);
395395
}
396396
} else {
397-
this.stepFlingFallback();
397+
this.flingTimer = setTimeout(this.stepFlingFallback, 16);
398398
}
399399
}
400400

0 commit comments

Comments
 (0)