mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-27 09:10:54 +00:00
add TS interface performance test case(textblob,typeface,maskfilter,patheffect)
Signed-off-by: lw19901203 <liuwei793@h-partners.com>
This commit is contained in:
parent
2cf702f528
commit
70404943bb
@ -43,6 +43,23 @@ import { PerformanceFontCountText, PerformanceFontEnableEmbolden, PerformanceFon
|
||||
PerformanceFontMeasureText, PerformanceFontSetBaselineSnap, PerformanceFontSetEdging, PerformanceFontSetEmbeddedBitmaps,
|
||||
PerformanceFontSetForceAutoHinting, PerformanceFontSetHinting, PerformanceFontSetScaleX, PerformanceFontSetSize, PerformanceFontSetSkewX,
|
||||
PerformanceFontTextToGlyphs, PerformanceFontGetSize, PerformanceFontGetTypeface, PerformanceFontSetTypeface } from '../testcase/interface/performancefonttest';
|
||||
import { PerformanceTypeFaceCreateBlurMaskFilter } from '../testcase/interface/performancemaskfiltertest';
|
||||
import { PerformancePathEffectCreateCornerPathEffect, PerformancePathEffectCreateDashPathEffect } from '../testcase/interface/performancepatheffecttest';
|
||||
import { PerformanceTextBlobMakeFromRunBuffer, PerformanceTextBlobMakeFromString } from '../testcase/interface/performancetextblobtest';
|
||||
import { PerformanceTypeFaceGetFamilyName, PerformanceTypeFaceMakeFromFile } from '../testcase/interface/performancetypefacetest';
|
||||
import { PerformanceRegionIsPointContained, PerformanceRegionIsRegionContained,
|
||||
PerformanceRegionOp, PerformanceRegionQuickReject, PerformanceRegionSetPath,
|
||||
PerformanceRegionSetRect } from '../testcase/interface/performanceregiontest';
|
||||
import { PerformancePenGetAlpha, PerformancePenGetCapStyle, PerformancePenGetColor,
|
||||
PerformancePenGetColorFilter, PerformancePenGetFillPath, PerformancePenGetJoinStyler,
|
||||
PerformancePenGetMiterLimit, PerformancePenGetWidth, PerformancePenIsAntiAlias,
|
||||
PerformancePenReset, PerformancePenSetAlpha, PerformancePenSetAntiAlias,
|
||||
PerformancePenSetBlendMode, PerformancePenSetCapStyle, PerformancePenSetColor,
|
||||
PerformancePenSetColorFilter, PerformancePenSetDither, PerformancePenSetImageFilter,
|
||||
PerformancePenSetJoinStyler, PerformancePenSetMaskFilter, PerformancePenSetMiterLimit,
|
||||
PerformancePenSetPathEffect, PerformancePenSetShaderEffect, PerformancePenSetShadowLayer,
|
||||
PerformancePenSetStrokeWidth } from '../testcase/interface/performancepentest';
|
||||
import { PerformanceShadowLayerCreate } from '../testcase/interface/performanceshadowlayertest';
|
||||
|
||||
const TAG = '[DrawingTest]';
|
||||
|
||||
@ -248,6 +265,46 @@ export class CaseFactory {
|
||||
['performance_font_getHinting', () => { return new PerformanceFontGetHinting(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_font_getEdging', () => { return new PerformanceFontGetEdging(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_font_textToGlyphs', () => { return new PerformanceFontTextToGlyphs(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_maskfilter_createblurmaskfilter', () => { return new PerformanceTypeFaceCreateBlurMaskFilter(); }],
|
||||
['performance_patheffect_createdashpatheffect', () => { return new PerformancePathEffectCreateDashPathEffect(); }],
|
||||
['performance_patheffect_createcornerpatheffect', () => { return new PerformancePathEffectCreateCornerPathEffect(); }],
|
||||
['performance_textblob_makefromstring', () => { return new PerformanceTextBlobMakeFromString(); }],
|
||||
['performance_textblob_makefromrunbuffer', () => { return new PerformanceTextBlobMakeFromRunBuffer(); }],
|
||||
['performance_textblob_makefrompostext', () => { return new PerformanceTextBlobMakeFromRunBuffer(); }],
|
||||
['performance_typeface_getfamilyname', () => { return new PerformanceTypeFaceGetFamilyName(); }],
|
||||
['performance_typeface_makefromfile', () => { return new PerformanceTypeFaceMakeFromFile(); }],
|
||||
['performance_shadowLayer_create', () => { return new PerformanceShadowLayerCreate(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setColor', () => { return new PerformancePenSetColor(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_getColor', () => { return new PerformancePenGetColor(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setStrokeWidth', () => { return new PerformancePenSetStrokeWidth(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setAntiAlias', () => { return new PerformancePenSetAntiAlias(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setAlpha', () => { return new PerformancePenSetAlpha(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_getAlpha', () => { return new PerformancePenGetAlpha(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setColorFilter', () => { return new PerformancePenSetColorFilter(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_getColorFilter', () => { return new PerformancePenGetColorFilter(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setMaskFilter', () => { return new PerformancePenSetMaskFilter(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setMiterLimit', () => { return new PerformancePenSetMiterLimit(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_getMiterLimit', () => { return new PerformancePenGetMiterLimit(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setPathEffect', () => { return new PerformancePenSetPathEffect(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setShadowLayer', () => { return new PerformancePenSetShadowLayer(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setShaderEffect', () => { return new PerformancePenSetShaderEffect(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setBlendMode', () => { return new PerformancePenSetBlendMode(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setDither', () => { return new PerformancePenSetDither(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setJoinStyle', () => { return new PerformancePenSetJoinStyler(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_getJoinStyle', () => { return new PerformancePenGetJoinStyler(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setCapStyle', () => { return new PerformancePenSetCapStyle(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_getCapStyle', () => { return new PerformancePenGetCapStyle(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_getWidth', () => { return new PerformancePenGetWidth(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_isAntiAlias', () => { return new PerformancePenIsAntiAlias(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_reset', () => { return new PerformancePenReset(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_getFillPath', () => { return new PerformancePenGetFillPath(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_pen_setImageFilter', () => { return new PerformancePenSetImageFilter(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_region_isPointContained', () => { return new PerformanceRegionIsPointContained(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_region_isRegionContained', () => { return new PerformanceRegionIsRegionContained(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_region_op', () => { return new PerformanceRegionOp(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_region_quickReject', () => { return new PerformanceRegionQuickReject(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_region_setRect', () => { return new PerformanceRegionSetRect(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
['performance_region_setPath', () => { return new PerformanceRegionSetPath(StyleType.DRAW_STYLE_PERFORMANCE_TEST); }],
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import drawing from "@ohos.graphics.drawing";
|
||||
import {TestBase, StyleType} from '../../pages/testbase';
|
||||
|
||||
export class PerformanceTypeFaceCreateBlurMaskFilter extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE){
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
drawing.MaskFilter.createBlurMaskFilter(drawing.BlurType.OUTER, 10);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import drawing from "@ohos.graphics.drawing";
|
||||
import {TestBase, StyleType} from '../../pages/testbase';
|
||||
|
||||
export class PerformancePathEffectCreateDashPathEffect extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE){
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let intervals = [10, 5];
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
drawing.PathEffect.createDashPathEffect(intervals, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePathEffectCreateCornerPathEffect extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE){
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
drawing.PathEffect.createCornerPathEffect(30);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,377 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import drawing from '@ohos.graphics.drawing';
|
||||
import common2D from '@ohos.graphics.common2D';
|
||||
import { StyleType, TestBase } from '../../pages/testbase';
|
||||
|
||||
export class PerformancePenSetColor extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen()
|
||||
let color: common2D.Color = { alpha: 255, red: 1, green: 255, blue: 1 };
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenGetColor extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.getColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenSetStrokeWidth extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setStrokeWidth(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenSetAntiAlias extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setAntiAlias(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenSetAlpha extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setAlpha(15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenGetAlpha extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.getAlpha();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenSetColorFilter extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
let colorFilter = new drawing.ColorFilter();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setColorFilter(colorFilter)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenGetColorFilter extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.getColorFilter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenSetMaskFilter extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
let maskFilter = new drawing.MaskFilter();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setMaskFilter(maskFilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenSetMiterLimit extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setMiterLimit(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenGetMiterLimit extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.getMiterLimit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenSetPathEffect extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
let pathEffect = new drawing.PathEffect();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setPathEffect(pathEffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenSetShadowLayer extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
let effect = new drawing.ShadowLayer();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setShadowLayer(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenSetShaderEffect extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
let effect = new drawing.ShaderEffect();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setShaderEffect(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenSetBlendMode extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setBlendMode(drawing.BlendMode.CLEAR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenSetDither extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setDither(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenSetJoinStyler extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setJoinStyle(drawing.JoinStyle.MITER_JOIN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenGetJoinStyler extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.getJoinStyle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenSetCapStyle extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setCapStyle(drawing.CapStyle.FLAT_CAP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenGetCapStyle extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.getCapStyle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenGetWidth extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.getWidth();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenIsAntiAlias extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.isAntiAlias();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenReset extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenGetFillPath extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
let pathSrc = new drawing.Path();
|
||||
let pathDst = new drawing.Path();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.getFillPath(pathSrc, pathDst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformancePenSetImageFilter extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let pen = new drawing.Pen();
|
||||
let filter = new drawing.ImageFilter();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
pen.setImageFilter(filter);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import drawing from '@ohos.graphics.drawing';
|
||||
import { StyleType, TestBase } from '../../pages/testbase';
|
||||
|
||||
export class PerformanceRegionIsPointContained extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let region = new drawing.Region();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
region.isPointContained(10, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformanceRegionIsRegionContained extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let region = new drawing.Region();
|
||||
let regionContain = new drawing.Region();
|
||||
for (let i = 0; i < 1; i++) {
|
||||
region.isRegionContained(regionContain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformanceRegionOp extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let region = new drawing.Region();
|
||||
let regionOp = new drawing.Region();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
region.op(regionOp, drawing.RegionOp.INTERSECT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformanceRegionQuickReject extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let region = new drawing.Region();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
region.quickReject(10, 20, 100, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformanceRegionSetRect extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let region = new drawing.Region();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
region.setRect(10, 20, 100, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformanceRegionSetPath extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let region = new drawing.Region();
|
||||
let regionPath = new drawing.Region();
|
||||
let path = new drawing.Path();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
region.setPath(path, regionPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import drawing from '@ohos.graphics.drawing';
|
||||
import { StyleType, TestBase } from '../../pages/testbase';
|
||||
import { common2D } from '@kit.ArkGraphics2D';
|
||||
|
||||
export class PerformanceShadowLayerCreate extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE) {
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let color: common2D.Color = { alpha: 255, red: 1, green: 255, blue: 1 };
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
drawing.ShadowLayer.create(10, 2, 2, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import drawing from "@ohos.graphics.drawing";
|
||||
import common2D from "@ohos.graphics.common2D";
|
||||
import {TestBase, StyleType} from '../../pages/testbase';
|
||||
|
||||
export class PerformanceTextBlobMakeFromString extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE){
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
const font: drawing.Font = new drawing.Font();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
const textBlob = drawing.TextBlob.makeFromString("drawing", font, drawing.TextEncoding.TEXT_ENCODING_UTF8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformanceTextBlobMakeFromRunBuffer extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE){
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let font = new drawing.Font();
|
||||
let runBuffer : Array<drawing.TextBlobRunBuffer> = [
|
||||
{ glyph: 65, positionX: 0, positionY: 0 },
|
||||
{ glyph: 227, positionX: 14.9 * 2, positionY: 0 },
|
||||
{ glyph: 283, positionX: 25.84 * 2, positionY: 0 },
|
||||
{ glyph: 283, positionX: 30.62 * 2, positionY: 0 },
|
||||
{ glyph: 299, positionX: 35.4 * 2, positionY: 0},
|
||||
{ glyph: 2, positionX: 47.22 * 2, positionY: 0},
|
||||
{ glyph: 94, positionX: 52.62 * 2, positionY: 0},
|
||||
{ glyph: 37, positionX: 67.42 * 2, positionY: 0},
|
||||
{ glyph: 84, positionX: 81.70 * 2, positionY: 0},
|
||||
];
|
||||
let rect: common2D.Rect = {left: 0, top: 0, right: 100, bottom: 100};
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
drawing.TextBlob.makeFromRunBuffer(runBuffer, font, rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformanceTextBlobMakeFromPosText extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE){
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let text : string = 'makeFromPosText';
|
||||
let font : drawing.Font = new drawing.Font();
|
||||
let points : common2D.Point[] = [];
|
||||
for (let i = 0; i !== text.length; ++i) {
|
||||
points.push({ x: i * 35, y: i * 35 });
|
||||
}
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
drawing.TextBlob.makeFromPosText(text, text.length, points, font);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import drawing from "@ohos.graphics.drawing";
|
||||
import {TestBase, StyleType} from '../../pages/testbase';
|
||||
|
||||
export class PerformanceTypeFaceGetFamilyName extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE){
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let typeface = new drawing.Typeface();
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
typeface.getFamilyName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class PerformanceTypeFaceMakeFromFile extends TestBase {
|
||||
public constructor(styleType: number = StyleType.DRAW_STYLE_NONE){
|
||||
super();
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let str = "/system/fonts/HarmonyOS_Sans_Italic.ttf";
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
drawing.Typeface.makeFromFile(str);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user