mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-27 09:10:54 +00:00
修改bench性能用例
Signed-off-by: d00454590 <dingran6@huawei.com>
This commit is contained in:
parent
ba8f139352
commit
ae71a7d80a
@ -176,25 +176,9 @@ export class TestBase {
|
||||
public StyleSettings(canvas: drawing.Canvas, styleType: StyleType) {
|
||||
if (styleType == StyleType.DRAW_STYLE_COMPLEX) {
|
||||
let color: common2D.Color = { alpha: 255, red: 255, green: 0, blue: 0 };
|
||||
let filter = drawing.ColorFilter.createLinearToSRGBGamma();
|
||||
|
||||
let brush = new drawing.Brush();
|
||||
brush.setColor(color);
|
||||
brush.setAntiAlias(true);
|
||||
brush.setAlpha(0xF0);
|
||||
brush.setColorFilter(filter);
|
||||
brush.setBlendMode(1);
|
||||
canvas.attachBrush(brush);
|
||||
|
||||
let pen = new drawing.Pen();
|
||||
pen.setColor(color);
|
||||
pen.setStrokeWidth(5);
|
||||
pen.setAntiAlias(true);
|
||||
pen.setAlpha(0xF0);
|
||||
pen.setColorFilter(filter);
|
||||
pen.setBlendMode(1);
|
||||
pen.setDither(true);
|
||||
canvas.attachPen(pen);
|
||||
}
|
||||
}
|
||||
public StyleSettingsDestroy(canvas: drawing.Canvas) {
|
||||
@ -286,6 +270,6 @@ export enum TestFunctionStyleType {
|
||||
|
||||
export enum StyleType { //公共的pen,brush,filter等配置
|
||||
DRAW_STYLE_NONE = 0,
|
||||
DRAW_STYLE_COMPLEX, //最复杂的配置,会将所有配置加上,得出近似最恶劣的性能数据
|
||||
DRAW_STYLE_COMPLEX, // 保证性能测试稳定性,设置红色填充
|
||||
DRAW_STYLE_FUNCTION_TEST_1, //
|
||||
}
|
@ -30,14 +30,10 @@ export class CanvasDrawRect extends TestBase {
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
console.log(TAG, 'xyj DRAW_ STYLE_COMPLEX end');
|
||||
console.log(TAG, 'draw performance end');
|
||||
// 保证性能测试稳定性: 绘制100,100的矩形
|
||||
let rect: common2D.Rect = {left: 0, top: 0, right: 100, bottom: 100};
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
let l = i % this.width_;
|
||||
let t = (i + 100) % this.height_;
|
||||
let r = ((l + 100) > this.width_) ? this.width_ : (l + 100);
|
||||
let b = ((t + 100) > this.height_) ? this.height_ : (t + 100);
|
||||
//针对rect,每次的绘制起点位置,绘制的宽高大小需要不一致
|
||||
let rect: common2D.Rect = {left: l, top: t, right: r, bottom: b};
|
||||
canvas.drawRect(rect);
|
||||
}
|
||||
}
|
||||
@ -101,13 +97,9 @@ export class CanvasDrawLine extends TestBase {
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let rand: OHRandom = new OHRandom();
|
||||
// 保证性能测试稳定性: 绘制(0, 0) (100, 100)的直线
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
let x1: number = rand.nextULessThan(this.width_);
|
||||
let y1: number = rand.nextULessThan(this.height_);
|
||||
let x2: number = rand.nextULessThan(this.width_);
|
||||
let y2: number = rand.nextULessThan(this.height_);
|
||||
canvas.drawLine(x1, y1, x2, y2);
|
||||
canvas.drawLine(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,10 +158,10 @@ export class CanvasDrawPath extends TestBase {
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
// 保证性能测试稳定性: 绘制半弧的path
|
||||
let path: drawing.Path = new drawing.Path();
|
||||
path.moveTo(0, 0);
|
||||
let rand: OHRandom = new OHRandom();
|
||||
path.lineTo(rand.nextRangeF(0, 720), rand.nextRangeF(0, 720));
|
||||
path.arcTo(0, 0, 100, 100, 0, 180);
|
||||
path.close;
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
canvas.drawPath(path);
|
||||
}
|
||||
@ -259,11 +251,9 @@ export class CanvasDrawPoint extends TestBase {
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let rand: OHRandom = new OHRandom();
|
||||
// 保证性能测试稳定性: 绘制 (10, 10)的点
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
let x: number = rand.nextUScalar1() * 640;
|
||||
let y: number = rand.nextUScalar1() * 480;
|
||||
canvas.drawPoint(x, y);
|
||||
canvas.drawPoint(10, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,12 +316,10 @@ export class CanvasDrawImage extends TestBase {
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let rand: OHRandom = new OHRandom();
|
||||
// 保证性能测试稳定性: 绘制test_1图片
|
||||
let pixelMap: image.PixelMap = globalThis.getInstance().getPixelMap("test_1.jpg")
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
let x: number = rand.nextULessThan(this.width_);
|
||||
let y: number = rand.nextULessThan(this.height_);
|
||||
canvas.drawImage(pixelMap, x, y);
|
||||
canvas.drawImage(pixelMap, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -395,12 +383,9 @@ export class CanvasDrawCircle extends TestBase {
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let rand: OHRandom = new OHRandom();
|
||||
// 保证性能测试稳定性: 绘制圆心(200, 200)半径100的圆
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
let x: number = rand.nextULessThan(this.width_);
|
||||
let y: number = rand.nextULessThan(this.height_);
|
||||
let r: number = rand.nextULessThan(this.height_);
|
||||
canvas.drawCircle(x, y, r);
|
||||
canvas.drawCircle(200, 200, 100);
|
||||
}
|
||||
}
|
||||
|
||||
@ -464,15 +449,13 @@ export class CanvasDrawTextBlob extends TestBase {
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
let rand: OHRandom = new OHRandom();
|
||||
// 保证性能测试稳定性: 绘制'textblob'文字
|
||||
let text: string = 'textblob';
|
||||
const font: drawing.Font = new drawing.Font();
|
||||
font.setSize(20);
|
||||
const textBlob = drawing.TextBlob.makeFromString(text, font, drawing.TextEncoding.TEXT_ENCODING_UTF8);
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
let x: number = rand.nextRangeF(0, this.width_);
|
||||
let y: number = rand.nextRangeF(0, this.height_);
|
||||
canvas.drawTextBlob(textBlob, x, y);
|
||||
canvas.drawTextBlob(textBlob, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -563,12 +546,13 @@ export class CanvasDrawPixelMapMesh extends TestBase {
|
||||
this.styleType_ = styleType;
|
||||
}
|
||||
public OnTestPerformance(canvas: drawing.Canvas) {
|
||||
// 保证性能测试稳定性: 绘制1*1PixelMapMesh
|
||||
let pixelMap: image.PixelMap = globalThis.getInstance().getPixelMap("test_1.jpg")
|
||||
const brush = new drawing.Brush();
|
||||
canvas.attachBrush(brush);
|
||||
let verts: Array<number> = [100, 100, 200, 100, 150, 200, 200, 200];
|
||||
let colors: Array<number> = [0x00ff0088, 0x00ff0088, 0x00ff0088, 0x00ff0088];
|
||||
for (let i = 0; i < this.testCount_; i++) {
|
||||
let verts: Array<number> = [100, 100, 200, 100, 150, 200, 200, 200];
|
||||
let colors: Array<number> = [0x00ff0088, 0x00ff0088, 0x00ff0088, 0x00ff0088];
|
||||
canvas.drawPixelMapMesh(pixelMap, 1, 1, verts, 0, null, 0);
|
||||
}
|
||||
canvas.detachBrush();
|
||||
|
@ -34,24 +34,17 @@
|
||||
|
||||
void ImageBuildFromBitmap::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
uint32_t width = rand.nextULessThan(bitmapWidth_);
|
||||
uint32_t height = rand.nextULessThan(bitmapHeight_);
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = rand.nextULessThan(bitmapWidth_);
|
||||
float b = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Bitmap* bm = OH_Drawing_BitmapCreate();
|
||||
OH_Drawing_Image* image = OH_Drawing_ImageCreate();
|
||||
OH_Drawing_BitmapFormat format = { COLOR_FORMAT_ALPHA_8, ALPHA_FORMAT_OPAQUE };
|
||||
OH_Drawing_BitmapBuild(bm, width, height, &format);
|
||||
OH_Drawing_BitmapBuild(bm, 256, 256, &format); // 256, 256 宽高
|
||||
OH_Drawing_SamplingOptions* samplingOptions =
|
||||
OH_Drawing_SamplingOptionsCreate(FILTER_MODE_LINEAR, MIPMAP_MODE_NEAREST);
|
||||
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_ImageBuildFromBitmap(image, bm);
|
||||
}
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 256, 256); // 0, 0, 256, 256 创建矩形
|
||||
OH_Drawing_CanvasDrawImageRect(canvas, image, rect, samplingOptions);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
OH_Drawing_ImageDestroy(image);
|
||||
|
@ -42,41 +42,29 @@
|
||||
|
||||
void CanvasDrawRect::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
// 保证性能测试稳定性: 绘制100,100的矩形
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
int l = i % bitmapWidth_;
|
||||
int t = (i + 100) % bitmapHeight_; // 100 用于边界计算
|
||||
int r = ((l + 100) > bitmapWidth_) ? bitmapWidth_ : (l + 100); // 100 用于边界计算
|
||||
int b = ((t + 100) > bitmapHeight_) ? bitmapHeight_ : (t + 100); // 100 用于边界计算
|
||||
// 针对rect,每次的绘制起点位置,绘制的宽高大小需要不一致
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
|
||||
void CanvasDrawBitmapRect::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_SamplingOptions* sampling = OH_Drawing_SamplingOptionsCreate(
|
||||
OH_Drawing_FilterMode::FILTER_MODE_NEAREST, OH_Drawing_MipmapMode::MIPMAP_MODE_NONE);
|
||||
float l_1 = rand.nextULessThan(bitmapWidth_);
|
||||
float t_1 = rand.nextULessThan(bitmapHeight_);
|
||||
float r_1 = l_1 + rand.nextULessThan(bitmapWidth_);
|
||||
float b_1 = t_1 + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Bitmap* bm = OH_Drawing_BitmapCreate();
|
||||
OH_Drawing_BitmapFormat cFormat { COLOR_FORMAT_BGRA_8888, ALPHA_FORMAT_OPAQUE };
|
||||
OH_Drawing_BitmapBuild(bm, bitmapWidth_, bitmapHeight_, &cFormat);
|
||||
OH_Drawing_BitmapBuild(bm, 256, 256, &cFormat); // 256, 256 宽高
|
||||
OH_Drawing_Canvas* bitmapCanvas = OH_Drawing_CanvasCreate();
|
||||
OH_Drawing_CanvasBind(bitmapCanvas, bm);
|
||||
OH_Drawing_CanvasClear(bitmapCanvas, OH_Drawing_ColorSetArgb(0xff, 0x00, 0xff, 0x00));
|
||||
OH_Drawing_Rect* dst = OH_Drawing_RectCreate(l_1, t_1, r_1, b_1); // 指定区域
|
||||
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 256, 256); // 0, 0, 256, 256 创建矩形
|
||||
OH_Drawing_Rect* dst = OH_Drawing_RectCreate(100, 100, 256, 256); // 指定区域
|
||||
OH_Drawing_SamplingOptions* sampling = OH_Drawing_SamplingOptionsCreate(
|
||||
OH_Drawing_FilterMode::FILTER_MODE_LINEAR, OH_Drawing_MipmapMode::MIPMAP_MODE_NEAREST);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
// 将位图的指定区域绘制到画布的指定区域,指定区域
|
||||
// 绘制指定区域的纯色bitmap
|
||||
OH_Drawing_CanvasDrawBitmapRect(canvas, bm, rect, dst, sampling);
|
||||
}
|
||||
OH_Drawing_SamplingOptionsDestroy(sampling);
|
||||
@ -88,64 +76,40 @@ void CanvasDrawBitmapRect::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void CanvasDrawCircle::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
OH_Drawing_Point* point = OH_Drawing_PointCreate(200, 200);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
float x = rand.nextULessThan(bitmapWidth_);
|
||||
float y = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Point* point = OH_Drawing_PointCreate(x, y);
|
||||
float z = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_CanvasDrawCircle(canvas, point, z);
|
||||
OH_Drawing_PointDestroy(point);
|
||||
// 保证性能测试稳定性: 绘制圆心(200, 200)半径100的圆
|
||||
OH_Drawing_CanvasDrawCircle(canvas, point, 100);
|
||||
}
|
||||
OH_Drawing_PointDestroy(point);
|
||||
}
|
||||
|
||||
void CanvasDrawOval::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_CanvasDrawOval(canvas, rect);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
|
||||
void CanvasDrawArc::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
float startAngle = rand.nextULessThan(bitmapWidth_);
|
||||
float sweepAngle = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_CanvasDrawArc(canvas, rect, startAngle, sweepAngle);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
OH_Drawing_CanvasDrawArc(canvas, rect, 0.f, 180.f);
|
||||
}
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
|
||||
void CanvasDrawRoundRect::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_RoundRect* roundRect = OH_Drawing_RoundRectCreate(rect, 20, 20);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
float xRad = rand.nextULessThan(bitmapWidth_);
|
||||
float yRad = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_RoundRect* roundRect = OH_Drawing_RoundRectCreate(rect, xRad, yRad);
|
||||
OH_Drawing_CanvasDrawRoundRect(canvas, roundRect);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
|
||||
void CanvasDrawTextBlob::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
@ -153,24 +117,16 @@ void CanvasDrawTextBlob::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
std::string text = "textblob";
|
||||
int len = text.length();
|
||||
OH_Drawing_Font* font = OH_Drawing_FontCreate();
|
||||
TestRend rand;
|
||||
OH_Drawing_TextBlob* blob = OH_Drawing_TextBlobCreateFromText(text.c_str(), len, font, TEXT_ENCODING_UTF8);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
int x = rand.nextRangeF(0, bitmapWidth_);
|
||||
int y = rand.nextRangeF(0, bitmapHeight_);
|
||||
OH_Drawing_CanvasDrawTextBlob(canvas, blob, x, y);
|
||||
OH_Drawing_CanvasDrawTextBlob(canvas, blob, 0, 0);
|
||||
}
|
||||
OH_Drawing_TextBlobDestroy(blob);
|
||||
}
|
||||
|
||||
void CanvasClipRect::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::DIFFERENCE, true);
|
||||
@ -180,55 +136,30 @@ void CanvasClipRect::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void CanvasClipRoundRect::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_RoundRect* roundRect = OH_Drawing_RoundRectCreate(rect, 20, 20);
|
||||
OH_Drawing_CanvasDrawRoundRect(canvas, roundRect);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
float xRad = rand.nextULessThan(bitmapWidth_);
|
||||
float yRad = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_RoundRect* roundRect = OH_Drawing_RoundRectCreate(rect, xRad, yRad);
|
||||
OH_Drawing_CanvasDrawRoundRect(canvas, roundRect);
|
||||
OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
|
||||
void CanvasRotate::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
float_t min = 0.0f; // 0.0f 最小值
|
||||
float_t max = 360.0f;
|
||||
TestRend rand;
|
||||
float_t readTime = rand.nextRangeF(min, max); // 生成随机浮点数
|
||||
float randNumberx = rand.nextF();
|
||||
float randNumbery = rand.nextF();
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_CanvasRotate(canvas, readTime, randNumberx, randNumbery);
|
||||
OH_Drawing_CanvasRotate(canvas, 120, 50, 50); // 120, 50, 50 旋转平移角度
|
||||
}
|
||||
OH_Drawing_CanvasDrawOval(canvas, rect);
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
|
||||
void CanvasTranslate::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
float randNumberx = rand.nextF();
|
||||
float randNumbery = rand.nextF();
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_CanvasTranslate(canvas, randNumberx, randNumbery);
|
||||
OH_Drawing_CanvasTranslate(canvas, 100, 100); // 100, 100 平移
|
||||
}
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
@ -236,32 +167,18 @@ void CanvasTranslate::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void CanvasScale::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
float randNumberx = rand.nextF();
|
||||
float randNumbery = rand.nextF();
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_CanvasScale(canvas, randNumberx, randNumbery);
|
||||
OH_Drawing_CanvasScale(canvas, 2, 2); // 2, 2 缩放比例
|
||||
}
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
|
||||
void CanvasConcatMatrix::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float randNumberx = rand.nextF();
|
||||
float randNumbery = rand.nextF();
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateTranslation(randNumberx, randNumbery);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateTranslation(100, 100); // 100, 100 平移
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_CanvasConcatMatrix(canvas, matrix);
|
||||
}
|
||||
@ -273,12 +190,7 @@ void CanvasConcatMatrix::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
void CanvasClear::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
uint32_t color = 0xFF0000FF;
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_CanvasClear(canvas, color);
|
||||
}
|
||||
@ -289,12 +201,7 @@ void CanvasClear::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
void CanvasSetMatrix::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
OH_Drawing_Matrix* matRix = OH_Drawing_MatrixCreateRotation(45, 100, 100); // 45 矩阵旋转角度,100,100 矩阵偏移量
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_CanvasSetMatrix(canvas, matRix);
|
||||
}
|
||||
@ -305,45 +212,31 @@ void CanvasSetMatrix::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
void CanvasResetMatrix::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
OH_Drawing_Matrix* matRix = OH_Drawing_MatrixCreate();
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasSetMatrix(canvas, matRix);
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
int l = i % bitmapWidth_;
|
||||
int t = (i + 100) % bitmapHeight_; // 100 用于高度计算
|
||||
int r = ((l + 100) > bitmapWidth_) ? bitmapWidth_ : (l + 100); // 100 用于宽度计算
|
||||
int b = ((t + 100) > bitmapHeight_) ? bitmapHeight_ : (t + 100); // 100 用于高度计算
|
||||
// 针对rect,每次的绘制起点位置,绘制的宽高大小需要不一致
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_CanvasSetMatrix(canvas, matRix);
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
OH_Drawing_CanvasResetMatrix(canvas);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
|
||||
void CanvasDrawImageRectWithSrc::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
uint32_t w = 64; // 64 用于宽度计算
|
||||
uint32_t h = 64; // 64 用于高度计算
|
||||
OH_Drawing_Image* Image = OH_Drawing_ImageCreate();
|
||||
OH_Drawing_Bitmap* bm = OH_Drawing_BitmapCreate();
|
||||
OH_Drawing_BitmapFormat format = { COLOR_FORMAT_ALPHA_8, ALPHA_FORMAT_OPAQUE };
|
||||
OH_Drawing_BitmapBuild(bm, w, h, &format);
|
||||
OH_Drawing_BitmapFormat format = { COLOR_FORMAT_BGRA_8888, ALPHA_FORMAT_OPAQUE };
|
||||
OH_Drawing_BitmapBuild(bm, 256, 256, &format); // 256, 256 宽高
|
||||
OH_Drawing_ImageBuildFromBitmap(Image, bm);
|
||||
|
||||
// 创建采样选项对象
|
||||
OH_Drawing_FilterMode filterMode = FILTER_MODE_LINEAR;
|
||||
OH_Drawing_MipmapMode mipmapMode = MIPMAP_MODE_NEAREST;
|
||||
OH_Drawing_SamplingOptions* samplingOptions = OH_Drawing_SamplingOptionsCreate(filterMode, mipmapMode);
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
// 针对rect,每次的绘制起点位置,绘制的宽高大小需要不一致
|
||||
OH_Drawing_Rect* recty = OH_Drawing_RectCreate(l, t, r, b); // 参数3
|
||||
OH_Drawing_Rect* rectm = OH_Drawing_RectCreate(l + 10, t + 10, r + 10, b + 10); // 10 用于矩形创建的参数计算
|
||||
OH_Drawing_Rect* recty = OH_Drawing_RectCreate(0, 0, 256, 256); // 0, 0, 256, 256 创建矩形
|
||||
OH_Drawing_Rect* rectm = OH_Drawing_RectCreate(100, 100, 256, 256); // 100, 100, 256, 256 创建矩形
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_SrcRectConstraint enumConstr = i % 2 == 0 ? STRICT_SRC_RECT_CONSTRAINT : FAST_SRC_RECT_CONSTRAINT;
|
||||
OH_Drawing_CanvasDrawImageRectWithSrc(canvas, Image, recty, rectm, samplingOptions, enumConstr);
|
||||
OH_Drawing_CanvasDrawImageRectWithSrc(canvas, Image, recty, rectm, samplingOptions, FAST_SRC_RECT_CONSTRAINT);
|
||||
}
|
||||
OH_Drawing_CanvasDrawRect(canvas, recty);
|
||||
OH_Drawing_CanvasDrawRect(canvas, rectm);
|
||||
@ -355,7 +248,6 @@ void CanvasDrawImageRectWithSrc::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void CanvasDrawShadow::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
OH_Drawing_Path* pathCreate = OH_Drawing_PathCreate(); // 用于创建一个路径对象。
|
||||
OH_Drawing_Point3D planeParams;
|
||||
OH_Drawing_Point3D devLightPos;
|
||||
@ -369,11 +261,7 @@ void CanvasDrawShadow::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
uint32_t ambientColor = 0x19000000;
|
||||
uint32_t spotColor = 0x40000000;
|
||||
OH_Drawing_CanvasShadowFlags flag = SHADOW_FLAGS_TRANSPARENT_OCCLUDER;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_PathAddRect(pathCreate, l, t, r, b, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
|
||||
OH_Drawing_PathAddRect(pathCreate, 0, 0, 100, 100, OH_Drawing_PathDirection::PATH_DIRECTION_CW); // 100 宽高
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_CanvasDrawShadow(
|
||||
canvas, pathCreate, planeParams, devLightPos, lightRadius, ambientColor, spotColor, flag);
|
||||
@ -384,41 +272,28 @@ void CanvasDrawShadow::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void CanvasSkew::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
float sx = rand.nextF();
|
||||
float sy = rand.nextF();
|
||||
OH_Drawing_CanvasSkew(canvas, sx, sy);
|
||||
OH_Drawing_CanvasSkew(canvas, 50, 50); // 50, 50 斜切值
|
||||
}
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
|
||||
void CanvasDrawImageRect::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
uint32_t w = 64; // 64 用于宽度计算
|
||||
uint32_t h = 64; // 64 用于高度计算
|
||||
OH_Drawing_Bitmap* bm = OH_Drawing_BitmapCreate();
|
||||
OH_Drawing_BitmapFormat format = { COLOR_FORMAT_ALPHA_8, ALPHA_FORMAT_OPAQUE };
|
||||
OH_Drawing_BitmapBuild(bm, w, h, &format);
|
||||
OH_Drawing_BitmapFormat format = { COLOR_FORMAT_BGRA_8888, ALPHA_FORMAT_OPAQUE };
|
||||
OH_Drawing_BitmapBuild(bm, 256, 256, &format); // 256, 256 宽高
|
||||
OH_Drawing_Image* image = OH_Drawing_ImageCreate();
|
||||
OH_Drawing_ImageBuildFromBitmap(image, bm);
|
||||
OH_Drawing_SamplingOptions* samplingOptions =
|
||||
OH_Drawing_SamplingOptionsCreate(FILTER_MODE_LINEAR, MIPMAP_MODE_NEAREST);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 256, 256); // 0, 0, 256, 256 创建矩形
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
int l = i % bitmapWidth_;
|
||||
int t = (i + 100) % bitmapHeight_; // 100 用于高度计算
|
||||
int r = ((l + 100) > bitmapWidth_) ? bitmapWidth_ : (l + 100); // 100 用于宽度计算
|
||||
int b = ((t + 100) > bitmapHeight_) ? bitmapHeight_ : (t + 100); // 100 用于高度计算
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_CanvasDrawImageRect(canvas, image, rect, samplingOptions);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
OH_Drawing_ImageDestroy(image);
|
||||
OH_Drawing_SamplingOptionsDestroy(samplingOptions);
|
||||
OH_Drawing_BitmapDestroy(bm);
|
||||
@ -442,22 +317,15 @@ void CanvasDrawVertices::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void CanvasReadPixels::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
int32_t w = 100; // 100 用于宽度计算
|
||||
int32_t h = 100; // 100 用于高度计算
|
||||
bool res;
|
||||
TestRend rand;
|
||||
OH_Drawing_Image_Info imageInfo { w, h, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE };
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
char* dstPixels = (char*)malloc(r * b * 4); // 4 用于像素计算
|
||||
OH_Drawing_Image_Info imageInfo { 100, 100, COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE }; // 100 用于宽高
|
||||
char* dstPixels = static_cast<char*>malloc(100 * 100 * 4); // 100 4 用于像素计算
|
||||
if (dstPixels == nullptr)
|
||||
return;
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
// 从画布中拷贝像素数据到指定地址,去掉readPixels接口就只有drawRect接口画的一个矩形,用日志看读数据的结果
|
||||
res = OH_Drawing_CanvasReadPixels(canvas, &imageInfo, dstPixels, r * 4, l, t); // 4 用于像素计算
|
||||
res = OH_Drawing_CanvasReadPixels(canvas, &imageInfo, dstPixels, 100 * 4, 0, 0); // 100, 4 用于像素计算
|
||||
}
|
||||
free(dstPixels);
|
||||
DRAWING_LOGI("CanvasReadPixels::OnTestPerformance readPixels success=%{public}s", res ? "true" : "false");
|
||||
@ -467,23 +335,16 @@ void CanvasReadPixels::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void CanvasReadPixelsToBitmap::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
int32_t w = 100; // 100 用于宽度计算
|
||||
int32_t h = 100; // 100 用于高度计算
|
||||
bool res;
|
||||
TestRend rand;
|
||||
OH_Drawing_Bitmap* bm = OH_Drawing_BitmapCreate();
|
||||
OH_Drawing_BitmapFormat cFormat { OH_Drawing_ColorFormat::COLOR_FORMAT_RGBA_8888,
|
||||
OH_Drawing_AlphaFormat::ALPHA_FORMAT_OPAQUE };
|
||||
OH_Drawing_BitmapBuild(bm, w, h, &cFormat);
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_BitmapBuild(bm, 100, 100, &cFormat); // 100, 100 矩形宽高
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
// 从画布拷贝像素数据到位图中,去掉readPixels接口就只有drawRect接口画的一个矩形,用日志看读数据的结果
|
||||
res = OH_Drawing_CanvasReadPixelsToBitmap(canvas, bm, l, t);
|
||||
res = OH_Drawing_CanvasReadPixelsToBitmap(canvas, bm, 0, 0); // 0, 0 位置
|
||||
}
|
||||
DRAWING_LOGI("CanvasReadPixelsToBitmap::OnTestPerformance readPixels success=%{public}s", res ? "true" : "false");
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
@ -493,9 +354,8 @@ void CanvasReadPixelsToBitmap::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
void CanvasDrawPath::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
OH_Drawing_Path* path = OH_Drawing_PathCreate();
|
||||
OH_Drawing_PathMoveTo(path, 0, 0); // 0, 0 表示路径的坐标
|
||||
TestRend rand = TestRend();
|
||||
OH_Drawing_PathLineTo(path, rand.nextRangeF(0, 720), rand.nextRangeF(0, 720)); // 720 用作上限
|
||||
OH_Drawing_PathArcTo(path, 0, 0, 100, 100, 0, 180); // 0, 0, 100, 100, 0, 180 创建Arc
|
||||
OH_Drawing_PathClose(path);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_CanvasDrawPath(canvas, path);
|
||||
}
|
||||
@ -506,14 +366,8 @@ void CanvasRestoreToCount::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
fSave_Count = OH_Drawing_CanvasGetSaveCount(canvas);
|
||||
OH_Drawing_CanvasSave(canvas);
|
||||
TestRend rand;
|
||||
float x1 = rand.nextULessThan(bitmapWidth_);
|
||||
float y1 = rand.nextULessThan(bitmapHeight_);
|
||||
float x2 = rand.nextULessThan(bitmapWidth_);
|
||||
float y2 = rand.nextULessThan(bitmapHeight_);
|
||||
// 针对rect,每次的绘制起点位置,绘制的宽高大小需要不一致
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(x1, y1, x2, y2);
|
||||
OH_Drawing_CanvasTranslate(canvas, x1, y1);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasTranslate(canvas, 100, 100); // 100, 100 平移
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_CanvasRestoreToCount(canvas, fSave_Count);
|
||||
}
|
||||
@ -523,60 +377,46 @@ void CanvasRestoreToCount::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void CanvasDrawPoints::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
OH_Drawing_Point2D pts[n];
|
||||
TestRend rand;
|
||||
for (int i = 0; i < n; i++) {
|
||||
pts[i].x = rand.nextULessThan(bitmapWidth_);
|
||||
pts[i].y = rand.nextULessThan(bitmapHeight_);
|
||||
}
|
||||
OH_Drawing_Point2D pts[2]; // 2 点个数
|
||||
pts[0].x = 50; // 50 点位置
|
||||
pts[0].y = 50; // 50 点位置
|
||||
pts[1].x = 100; // 100 点位置
|
||||
pts[1].y = 100; // 100 点位置
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_CanvasDrawPoints(canvas, OH_Drawing_PointMode::POINT_MODE_POINTS, n, pts);
|
||||
OH_Drawing_CanvasDrawPoints(canvas, OH_Drawing_PointMode::POINT_MODE_POINTS, 2, pts); // 2 点个数
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasDrawLine::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
float x1 = rand.nextULessThan(bitmapWidth_);
|
||||
float y1 = rand.nextULessThan(bitmapHeight_);
|
||||
float x2 = rand.nextULessThan(bitmapWidth_);
|
||||
float y2 = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_CanvasDrawLine(canvas, x1, y1, x2, y2);
|
||||
OH_Drawing_CanvasDrawLine(canvas, 0, 0, 100, 100); // 0, 0, 100, 100 创建直线
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasDrawLayer::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
uint32_t colors[] = { 0xFFFF0000, 0xFF00FF00, 0xFF0000FF };
|
||||
uint32_t color = 0xFF0000FF;
|
||||
OH_Drawing_Rect* bounds = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasSave(canvas);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
float x1 = rand.nextULessThan(bitmapWidth_);
|
||||
float y1 = rand.nextULessThan(bitmapHeight_);
|
||||
float x2 = rand.nextULessThan(bitmapWidth_);
|
||||
float y2 = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* bounds = OH_Drawing_RectCreate(x1, y1, x2, y2);
|
||||
OH_Drawing_CanvasSave(canvas);
|
||||
OH_Drawing_CanvasSaveLayer(canvas, bounds, styleBrush_);
|
||||
OH_Drawing_CanvasClear(canvas, colors[i % 3]); // 3 为 color数组长度
|
||||
OH_Drawing_CanvasRestore(canvas);
|
||||
OH_Drawing_RectDestroy(bounds);
|
||||
}
|
||||
OH_Drawing_CanvasClear(canvas, color);
|
||||
OH_Drawing_CanvasRestore(canvas);
|
||||
OH_Drawing_RectDestroy(bounds);
|
||||
}
|
||||
|
||||
void CanvasDrawBitmap::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
OH_Drawing_Bitmap* bitmap = OH_Drawing_BitmapCreate();
|
||||
OH_Drawing_BitmapFormat cFormat { COLOR_FORMAT_BGRA_8888, ALPHA_FORMAT_OPAQUE };
|
||||
OH_Drawing_BitmapBuild(bitmap, 200, 200, &cFormat); // 200 指定了位图(bitmap)的宽度和高度
|
||||
OH_Drawing_BitmapBuild(bitmap, 256, 256, &cFormat); // 256 指定了位图(bitmap)的宽度和高度
|
||||
OH_Drawing_Canvas* bitmapCanvas = OH_Drawing_CanvasCreate();
|
||||
OH_Drawing_CanvasBind(bitmapCanvas, bitmap);
|
||||
OH_Drawing_CanvasClear(bitmapCanvas, OH_Drawing_ColorSetArgb(0xff, 0x00, 0xff, 0x00));
|
||||
TestRend rand;
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
float x = rand.nextULessThan(bitmapWidth_);
|
||||
float y = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_CanvasDrawBitmap(canvas, bitmap, x, y);
|
||||
OH_Drawing_CanvasDrawBitmap(canvas, bitmap, 0, 0); // 0, 0 位置坐标
|
||||
}
|
||||
OH_Drawing_CanvasDestroy(bitmapCanvas);
|
||||
OH_Drawing_BitmapDestroy(bitmap);
|
||||
@ -591,19 +431,14 @@ void CanvasDrawBackground::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void CanvasDrawRegion::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_Region* region = OH_Drawing_RegionCreate();
|
||||
OH_Drawing_RegionSetRect(region, rect);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
float x1 = rand.nextULessThan(bitmapWidth_);
|
||||
float y1 = rand.nextULessThan(bitmapHeight_);
|
||||
float x2 = rand.nextULessThan(bitmapWidth_);
|
||||
float y2 = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(x1, y1, x2, y2);
|
||||
OH_Drawing_Region* region = OH_Drawing_RegionCreate();
|
||||
OH_Drawing_RegionSetRect(region, rect);
|
||||
OH_Drawing_CanvasDrawRegion(canvas, region);
|
||||
OH_Drawing_RegionDestroy(region);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
OH_Drawing_RegionDestroy(region);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
|
||||
void CanvasDrawPixelMapRect::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
@ -612,31 +447,29 @@ void CanvasDrawPixelMapRect::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
// 无法获得 OH_Drawing_PixelMap
|
||||
// OH_Drawing_CanvasDrawPixelMapRect(OH_Drawing_Canvas *, OH_Drawing_PixelMap *, const OH_Drawing_Rect *src, const
|
||||
// OH_Drawing_Rect *dst, const OH_Drawing_SamplingOptions *)
|
||||
DRAWING_LOGI("CanvasDrawPixelMapRect cant get OH_Drawing_PixelMap");
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
|
||||
void CanvasSave::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
OH_Drawing_Path* Path = OH_Drawing_PathCreate();
|
||||
OH_Drawing_PathMoveTo(Path, 0, 0); // 0, 0 这些数字用于用于设置路径
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_CanvasSave(canvas);
|
||||
OH_Drawing_CanvasRestore(canvas);
|
||||
}
|
||||
float x = rand.nextULessThan(bitmapWidth_);
|
||||
float y = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_CanvasDrawLine(canvas, x, y, x - y, y - x);
|
||||
OH_Drawing_PathDestroy(Path);
|
||||
OH_Drawing_Rect* rect1 = OH_Drawing_RectCreate(100, 100, 200, 200); // 100, 100, 200, 200 创建矩形
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect1);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
OH_Drawing_RectDestroy(rect1);
|
||||
}
|
||||
|
||||
void CanvasClipPath::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
OH_Drawing_Path* path = OH_Drawing_PathCreate();
|
||||
float x = rand.nextULessThan(bitmapWidth_);
|
||||
float y = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_PathLineTo(path, x, y);
|
||||
OH_Drawing_PathArcTo(path, 0, 0, 100, 100, 0, 180); // 0, 0, 100, 100, 0, 180 创建Arc
|
||||
OH_Drawing_PathClose(path);
|
||||
OH_Drawing_CanvasDrawPath(canvas, path);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_CanvasClipPath(canvas, path, OH_Drawing_CanvasClipOp::INTERSECT, true);
|
||||
@ -646,12 +479,7 @@ void CanvasClipPath::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void CanvasGetTotalMatrix::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
OH_Drawing_Matrix* matrix_a = OH_Drawing_MatrixCreateRotation(45, 0, 0); // 45为顺时针旋转角度
|
||||
OH_Drawing_Matrix* matrix_b = OH_Drawing_MatrixCreateTranslation(-10, -10); // -10为水平方向平移距离
|
||||
@ -670,21 +498,21 @@ void CanvasGetTotalMatrix::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void CanvasRestore::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
OH_Drawing_CanvasSave(canvas);
|
||||
OH_Drawing_CanvasScale(canvas, 0.1, 0.1); // 0.1, 0.1 缩放比例
|
||||
OH_Drawing_CanvasScale(canvas, 2, 2); // 2, 2 缩放比例
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_CanvasSave(canvas);
|
||||
OH_Drawing_CanvasRestore(canvas);
|
||||
}
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 300, 300); // 300, 300 创建矩形
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形 // 100, 100 创建矩形
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
|
||||
void CanvasGetLocalClipBounds::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 700, 700); // 0, 0, 700, 700 创建矩形
|
||||
OH_Drawing_Rect* rect1 = OH_Drawing_RectCreate(100, 100, 300, 300); // 100, 100, 300, 300 剪切矩形
|
||||
OH_Drawing_Rect* rect2 = OH_Drawing_RectCreate(400, 400, 700, 700); // 400, 400, 700, 700 剪切矩形
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 400, 400); // 0, 0, 400, 400 创建矩形
|
||||
OH_Drawing_Rect* rect1 = OH_Drawing_RectCreate(100, 100, 200, 200); // 100, 100, 200, 200 剪切矩形
|
||||
OH_Drawing_Rect* rect2 = OH_Drawing_RectCreate(300, 300, 400, 400); // 300, 300, 400, 400 剪切矩形
|
||||
OH_Drawing_CanvasClipRect(canvas, rect1, OH_Drawing_CanvasClipOp::DIFFERENCE, true);
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
@ -699,10 +527,10 @@ void CanvasGetLocalClipBounds::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
void CanvasGetSaveCount::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
OH_Drawing_CanvasSave(canvas);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasScale(canvas, 5, 5); // 5, 5 缩放因子
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形 // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasScale(canvas, 2, 2); // 2, 2 缩放因子
|
||||
OH_Drawing_CanvasSave(canvas);
|
||||
OH_Drawing_CanvasScale(canvas, 0.1, 0.1); // 0.1, 0.1 缩放因子
|
||||
OH_Drawing_CanvasScale(canvas, 0.5, 0.5); // 0.5, 0.5 缩放因子
|
||||
OH_Drawing_CanvasSave(canvas);
|
||||
uint32_t fSave_Count = 0;
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
|
@ -34,18 +34,13 @@
|
||||
|
||||
void ColorFilterCreateBlendMode::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_) + __LINE__;
|
||||
float r = rand.nextULessThan(bitmapWidth_);
|
||||
float b = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_ColorFilter* colorFilter;
|
||||
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
colorFilter = OH_Drawing_ColorFilterCreateBlendMode(0x11, BLEND_MODE_DST_ATOP);
|
||||
OH_Drawing_ColorFilterDestroy(colorFilter);
|
||||
}
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
colorFilter = OH_Drawing_ColorFilterCreateBlendMode(0x11, BLEND_MODE_DST_ATOP);
|
||||
OH_Drawing_FilterSetColorFilter(styleFilter_, colorFilter);
|
||||
OH_Drawing_PenSetFilter(stylePen_, styleFilter_);
|
||||
@ -56,11 +51,6 @@ void ColorFilterCreateBlendMode::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void ColorFilterCreateCompose::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_) + __LINE__;
|
||||
float r = rand.nextULessThan(bitmapWidth_);
|
||||
float b = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_ColorFilter* colorFilter1 = OH_Drawing_ColorFilterCreateBlendMode(0xFF, BLEND_MODE_DST_ATOP);
|
||||
OH_Drawing_ColorFilter* colorFilter2 = OH_Drawing_ColorFilterCreateBlendMode(0x11, BLEND_MODE_DST_ATOP);
|
||||
OH_Drawing_ColorFilter* colorFilter;
|
||||
@ -69,7 +59,7 @@ void ColorFilterCreateCompose::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
colorFilter = OH_Drawing_ColorFilterCreateCompose(colorFilter1, colorFilter2);
|
||||
OH_Drawing_ColorFilterDestroy(colorFilter);
|
||||
}
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
colorFilter = OH_Drawing_ColorFilterCreateCompose(colorFilter1, colorFilter2);
|
||||
OH_Drawing_FilterSetColorFilter(styleFilter_, colorFilter);
|
||||
OH_Drawing_PenSetFilter(stylePen_, styleFilter_);
|
||||
@ -82,11 +72,6 @@ void ColorFilterCreateCompose::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void ColorFilterCreateMatrix::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_) + __LINE__;
|
||||
float r = rand.nextULessThan(bitmapWidth_);
|
||||
float b = rand.nextULessThan(bitmapHeight_);
|
||||
float colorMatrix[20] = { 1, 0, 0, 0, 0, // 1, 0, 0, 0, 0, 颜色矩阵参数
|
||||
0, 1, 0, 0, 0, // 0, 1, 0, 0, 0, 颜色矩阵参数
|
||||
0, 0, 0.5, 0.5, 0, // 0, 0, 0.5, 0.5, 0, 颜色矩阵参数
|
||||
@ -97,7 +82,7 @@ void ColorFilterCreateMatrix::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
colorFilter = OH_Drawing_ColorFilterCreateMatrix(colorMatrix);
|
||||
OH_Drawing_ColorFilterDestroy(colorFilter);
|
||||
}
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
colorFilter = OH_Drawing_ColorFilterCreateMatrix(colorMatrix);
|
||||
OH_Drawing_FilterSetColorFilter(styleFilter_, colorFilter);
|
||||
OH_Drawing_PenSetFilter(stylePen_, styleFilter_);
|
||||
@ -108,18 +93,13 @@ void ColorFilterCreateMatrix::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void ColorFilterCreateLinearToSrgbGamma::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_) + __LINE__;
|
||||
float r = rand.nextULessThan(bitmapWidth_);
|
||||
float b = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_ColorFilter* colorFilter;
|
||||
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
colorFilter = OH_Drawing_ColorFilterCreateLinearToSrgbGamma();
|
||||
OH_Drawing_ColorFilterDestroy(colorFilter);
|
||||
}
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
colorFilter = OH_Drawing_ColorFilterCreateLinearToSrgbGamma();
|
||||
OH_Drawing_FilterSetColorFilter(styleFilter_, colorFilter);
|
||||
OH_Drawing_PenSetFilter(stylePen_, styleFilter_);
|
||||
@ -130,18 +110,13 @@ void ColorFilterCreateLinearToSrgbGamma::OnTestPerformance(OH_Drawing_Canvas* ca
|
||||
|
||||
void ColorFilterCreateSrgbGammaToLinear::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_) + __LINE__;
|
||||
float r = rand.nextULessThan(bitmapWidth_);
|
||||
float b = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_ColorFilter* colorFilter;
|
||||
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
colorFilter = OH_Drawing_ColorFilterCreateSrgbGammaToLinear();
|
||||
OH_Drawing_ColorFilterDestroy(colorFilter);
|
||||
}
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
colorFilter = OH_Drawing_ColorFilterCreateSrgbGammaToLinear();
|
||||
OH_Drawing_FilterSetColorFilter(styleFilter_, colorFilter);
|
||||
OH_Drawing_PenSetFilter(stylePen_, styleFilter_);
|
||||
@ -152,18 +127,13 @@ void ColorFilterCreateSrgbGammaToLinear::OnTestPerformance(OH_Drawing_Canvas* ca
|
||||
|
||||
void ColorFilterCreateLuma::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_) + __LINE__;
|
||||
float r = rand.nextULessThan(bitmapWidth_);
|
||||
float b = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_ColorFilter* colorFilter;
|
||||
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
colorFilter = OH_Drawing_ColorFilterCreateLuma();
|
||||
OH_Drawing_ColorFilterDestroy(colorFilter);
|
||||
}
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
colorFilter = OH_Drawing_ColorFilterCreateLuma();
|
||||
OH_Drawing_FilterSetColorFilter(styleFilter_, colorFilter);
|
||||
OH_Drawing_PenSetFilter(stylePen_, styleFilter_);
|
||||
@ -175,17 +145,11 @@ void ColorFilterCreateLuma::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
// 接口使用方法暂未开放
|
||||
void ColorSpaceCreateSrgb::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_) + __LINE__;
|
||||
float r = rand.nextULessThan(bitmapWidth_);
|
||||
float b = rand.nextULessThan(bitmapHeight_);
|
||||
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_ColorSpace* colorSpace = OH_Drawing_ColorSpaceCreateSrgb();
|
||||
OH_Drawing_ColorSpaceDestroy(colorSpace);
|
||||
}
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
@ -193,17 +157,11 @@ void ColorSpaceCreateSrgb::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
// 接口使用方法暂未开放
|
||||
void ColorSpaceCreateSrgbLinear::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_) + __LINE__;
|
||||
float r = rand.nextULessThan(bitmapWidth_);
|
||||
float b = rand.nextULessThan(bitmapHeight_);
|
||||
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_ColorSpace* colorSpace = OH_Drawing_ColorSpaceCreateSrgbLinear();
|
||||
OH_Drawing_ColorSpaceDestroy(colorSpace);
|
||||
}
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
}
|
||||
|
@ -40,13 +40,7 @@
|
||||
|
||||
void MaskFilterCreateBlur::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
// 性能测试:10000次15ms
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
// 创建画刷brush对象
|
||||
OH_Drawing_Brush* brush = OH_Drawing_BrushCreate();
|
||||
OH_Drawing_BrushSetAntiAlias(brush, true);
|
||||
|
@ -34,18 +34,10 @@
|
||||
|
||||
void MatrixReset::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
OH_Drawing_Path* path = OH_Drawing_PathCreate();
|
||||
float x1 = rand.nextULessThan(bitmapWidth_);
|
||||
float y1 = rand.nextULessThan(bitmapHeight_);
|
||||
float x2 = rand.nextULessThan(bitmapWidth_);
|
||||
float y2 = rand.nextULessThan(bitmapHeight_);
|
||||
float base1 = rand.nextULessThan(bitmapHeight_);
|
||||
float base2 = rand.nextULessThan(bitmapHeight_);
|
||||
float base3 = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_PathAddRect(path, x1, y1, x2, y2, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
|
||||
OH_Drawing_PathAddRect(path, 0, 0, 100, 100, OH_Drawing_PathDirection::PATH_DIRECTION_CW); // 100 矩形宽高
|
||||
OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate();
|
||||
OH_Drawing_MatrixSetMatrix(matrix, base1, 0, 0, 0, base2, 0, 0, 0, base3);
|
||||
OH_Drawing_MatrixSetMatrix(matrix, 50, 0, 0, 0, 50, 0, 0, 0, 50); // 50 matrix值
|
||||
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_MatrixReset(matrix);
|
||||
@ -58,24 +50,13 @@ void MatrixReset::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void MatrixConcat::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
OH_Drawing_Path* path = OH_Drawing_PathCreate();
|
||||
float x1 = rand.nextULessThan(bitmapWidth_);
|
||||
float y1 = rand.nextULessThan(bitmapHeight_);
|
||||
float x2 = rand.nextULessThan(bitmapWidth_);
|
||||
float y2 = rand.nextULessThan(bitmapHeight_);
|
||||
float base1 = rand.nextULessThan(bitmapHeight_);
|
||||
float base2 = rand.nextULessThan(bitmapHeight_);
|
||||
float base3 = rand.nextULessThan(bitmapHeight_);
|
||||
float base4 = rand.nextULessThan(bitmapHeight_);
|
||||
float base5 = rand.nextULessThan(bitmapHeight_);
|
||||
float base6 = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Matrix* matrix_a = OH_Drawing_MatrixCreate();
|
||||
OH_Drawing_Matrix* matrix_b = OH_Drawing_MatrixCreate();
|
||||
OH_Drawing_Matrix* total = OH_Drawing_MatrixCreate();
|
||||
OH_Drawing_PathAddRect(path, x1, y1, x2, y2, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
|
||||
OH_Drawing_MatrixSetMatrix(matrix_a, base1, 0, 0, 0, base2, 0, 0, 0, base3);
|
||||
OH_Drawing_MatrixSetMatrix(matrix_b, base4, 0, 0, 0, base5, 0, 0, 0, base6);
|
||||
OH_Drawing_PathAddRect(path, 0, 0, 100, 100, OH_Drawing_PathDirection::PATH_DIRECTION_CW); // 100 宽高
|
||||
OH_Drawing_MatrixSetMatrix(matrix_a, 50, 0, 0, 0, 50, 0, 0, 0, 50); // 50 matrix值
|
||||
OH_Drawing_MatrixSetMatrix(matrix_b, 60, 0, 0, 0, 60, 0, 0, 0, 60); // 60 matrix值
|
||||
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_MatrixConcat(total, matrix_a, matrix_b);
|
||||
@ -90,19 +71,11 @@ void MatrixConcat::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void MatrixInvert::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
OH_Drawing_Path* path = OH_Drawing_PathCreate();
|
||||
float x1 = rand.nextULessThan(bitmapWidth_);
|
||||
float y1 = rand.nextULessThan(bitmapHeight_);
|
||||
float x2 = rand.nextULessThan(bitmapWidth_);
|
||||
float y2 = rand.nextULessThan(bitmapHeight_);
|
||||
float base1 = rand.nextULessThan(bitmapHeight_);
|
||||
float base2 = rand.nextULessThan(bitmapHeight_);
|
||||
float base3 = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate();
|
||||
OH_Drawing_Matrix* inverse = OH_Drawing_MatrixCreate();
|
||||
OH_Drawing_PathAddRect(path, x1, y1, x2, y2, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
|
||||
OH_Drawing_MatrixSetMatrix(matrix, base1, 0, 0, 0, base2, 0, 0, 0, base3);
|
||||
OH_Drawing_PathAddRect(path, 0, 0, 100, 100, OH_Drawing_PathDirection::PATH_DIRECTION_CW); // 100 宽高
|
||||
OH_Drawing_MatrixSetMatrix(matrix, 50, 0, 0, 0, 50, 0, 0, 0, 50); // 50 matrix值
|
||||
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_MatrixInvert(matrix, inverse);
|
||||
@ -117,20 +90,11 @@ void MatrixInvert::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
void MatrixSetPolyToPoly::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
int count = 4;
|
||||
TestRend rand;
|
||||
OH_Drawing_Path* path = OH_Drawing_PathCreate();
|
||||
float x1 = rand.nextULessThan(bitmapWidth_);
|
||||
float y1 = rand.nextULessThan(bitmapHeight_);
|
||||
float x2 = rand.nextULessThan(bitmapWidth_);
|
||||
float y2 = rand.nextULessThan(bitmapHeight_);
|
||||
float x3 = rand.nextULessThan(bitmapWidth_);
|
||||
float y3 = rand.nextULessThan(bitmapHeight_);
|
||||
float x4 = rand.nextULessThan(bitmapWidth_);
|
||||
float y4 = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_PathAddRect(path, x1, y1, x2, y2, OH_Drawing_PathDirection::PATH_DIRECTION_CW);
|
||||
OH_Drawing_PathAddRect(path, 0, 0, 100, 100, OH_Drawing_PathDirection::PATH_DIRECTION_CW); // 100 宽高
|
||||
OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreate();
|
||||
OH_Drawing_Point2D src[] = { { x1, y1 }, { x2, y1 }, { x1, y2 }, { x2, y2 } };
|
||||
OH_Drawing_Point2D dst[] = { { x3, y3 }, { x3, y4 }, { x4, y3 }, { x4, y4 } };
|
||||
OH_Drawing_Point2D src[] = { { 0, 0 }, { 100, 0 }, { 0, 100 }, { 100, 100 } }; // 0, 100 坐标值
|
||||
OH_Drawing_Point2D dst[] = { { 20, 20 }, { 20, 200 }, { 200, 20 }, { 200, 200 } }; // 20, 200 坐标值
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
OH_Drawing_MatrixSetPolyToPoly(matrix, src, dst, count);
|
||||
}
|
||||
@ -156,12 +120,7 @@ void MatrixPreRotate::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
if (result == true) {
|
||||
DRAWING_LOGI("The OH_Drawing_MatrixPreRotate interface returns a value of true,result=%{public}s",
|
||||
result ? "true" : "false");
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_) + __LINE__;
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
} else {
|
||||
@ -190,12 +149,7 @@ void MatrixPostScale::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
if (result == true) {
|
||||
DRAWING_LOGI("The OH_Drawing_MatrixPostScale interface returns a value of true,result=%{public}s",
|
||||
result ? "true" : "false");
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_) + __LINE__;
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
} else {
|
||||
@ -224,12 +178,7 @@ void MatrixPostTranslate::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
if (result == true) {
|
||||
DRAWING_LOGI("The OH_Drawing_MatrixPostTranslate interface returns a value of true,result=%{public}s",
|
||||
result ? "true" : "false");
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_) + __LINE__;
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
OH_Drawing_CanvasDrawRect(canvas, rect);
|
||||
OH_Drawing_RectDestroy(rect);
|
||||
} else {
|
||||
@ -243,14 +192,9 @@ void MatrixPostTranslate::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
|
||||
void MatrixIsEqual::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
OH_Drawing_Matrix* matrix1 = OH_Drawing_MatrixCreate();
|
||||
OH_Drawing_Matrix* matrix2 = OH_Drawing_MatrixCreate();
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
bool matrixIsEqual = false;
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
matrixIsEqual = OH_Drawing_MatrixIsEqual(matrix1, matrix2);
|
||||
|
@ -36,12 +36,7 @@
|
||||
|
||||
void MemoryStreamCreate::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 100, 100); // 0, 0, 100, 100 创建矩形
|
||||
unsigned char data[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
|
||||
size_t length = sizeof(data);
|
||||
OH_Drawing_Font* font = OH_Drawing_FontCreate();
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
void PenReset::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
OH_Drawing_CanvasDetachPen(canvas);
|
||||
OH_Drawing_Pen* pen = OH_Drawing_PenCreate();
|
||||
OH_Drawing_PenSetColor(pen, DRAW_COLORRED);
|
||||
@ -35,10 +34,6 @@ void PenReset::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
OH_Drawing_PenSetWidth(pen, 10); // 10 width
|
||||
OH_Drawing_PenSetColor(pen, DRAW_COLORGREEN);
|
||||
OH_Drawing_CanvasAttachPen(canvas, pen);
|
||||
float x1 = rand.nextULessThan(bitmapWidth_);
|
||||
float y1 = rand.nextULessThan(bitmapHeight_);
|
||||
float x2 = rand.nextULessThan(bitmapWidth_);
|
||||
float y2 = rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_CanvasDrawLine(canvas, x1, y1, x2, y2);
|
||||
OH_Drawing_CanvasDrawLine(canvas, 0, 0, 100, 100); // 100 宽高
|
||||
OH_Drawing_PenDestroy(pen);
|
||||
}
|
@ -34,18 +34,13 @@
|
||||
|
||||
void SamplingOptionsCreate::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
OH_Drawing_Bitmap* bitmap = OH_Drawing_BitmapCreate();
|
||||
OH_Drawing_BitmapFormat cFormat { COLOR_FORMAT_BGRA_8888, ALPHA_FORMAT_OPAQUE };
|
||||
OH_Drawing_BitmapBuild(bitmap, 200, 200, &cFormat); // 200, 200 创建位图大小
|
||||
OH_Drawing_BitmapBuild(bitmap, 256, 256, &cFormat); // 256, 256 创建位图大小
|
||||
OH_Drawing_Canvas* bitmapCanvas = OH_Drawing_CanvasCreate();
|
||||
OH_Drawing_CanvasBind(bitmapCanvas, bitmap);
|
||||
OH_Drawing_CanvasClear(bitmapCanvas, OH_Drawing_ColorSetArgb(0xff, 0x00, 0xff, 0x00));
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* dst = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* dst = OH_Drawing_RectCreate(0, 0, 256, 256); // 0, 0, 256, 256 创建矩形
|
||||
OH_Drawing_SamplingOptions* sampling = nullptr;
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
sampling = OH_Drawing_SamplingOptionsCreate(filterMode, mipmapMode);
|
||||
|
@ -89,11 +89,10 @@ void ShaderEffectCreateRadialGradient::OnTestPerformance(OH_Drawing_Canvas* canv
|
||||
|
||||
void ShaderEffectCreateImageShader::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
TestRend rand;
|
||||
OH_Drawing_SamplingOptions* option = OH_Drawing_SamplingOptionsCreate(FILTER_MODE_NEAREST, MIPMAP_MODE_NONE);
|
||||
|
||||
OH_Drawing_Image* image = OH_Drawing_ImageCreate();
|
||||
OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateTranslation(rand.nextF(), rand.nextF());
|
||||
OH_Drawing_Matrix* matrix = OH_Drawing_MatrixCreateTranslation(100, 100); // 100 平移
|
||||
OH_Drawing_ShaderEffect* ShaderEffect;
|
||||
OH_Drawing_Brush* brush = OH_Drawing_BrushCreate();
|
||||
OH_Drawing_Rect* rect = OH_Drawing_RectCreate(NUM_20, NUM_50, NUM_300, NUM_300);
|
||||
|
@ -35,19 +35,14 @@
|
||||
void SurfaceCreateFromGpuContext::OnTestPerformance(OH_Drawing_Canvas* canvas)
|
||||
{
|
||||
// 只能用gpu来画,用cpu会闪退
|
||||
TestRend rand;
|
||||
const int32_t width = 500; // 500 绘图表面的宽度
|
||||
const int32_t height = 500; // 500 绘图表面的高度
|
||||
const int32_t width = 256; // 256 绘图表面的宽度
|
||||
const int32_t height = 256; // 256 绘图表面的高度
|
||||
OH_Drawing_GpuContextOptions options;
|
||||
options.allowPathMaskCaching = false;
|
||||
OH_Drawing_GpuContext* gpuContext = OH_Drawing_GpuContextCreateFromGL(options);
|
||||
OH_Drawing_Image_Info imageInfo = { width, height, COLOR_FORMAT_RGBA_8888,
|
||||
ALPHA_FORMAT_OPAQUE }; // COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE 绘图表面的颜色和透明度
|
||||
float l = rand.nextULessThan(bitmapWidth_);
|
||||
float t = rand.nextULessThan(bitmapHeight_);
|
||||
float r = l + rand.nextULessThan(bitmapWidth_);
|
||||
float b = t + rand.nextULessThan(bitmapHeight_);
|
||||
OH_Drawing_Rect* dst = OH_Drawing_RectCreate(l, t, r, b);
|
||||
OH_Drawing_Rect* dst = OH_Drawing_RectCreate(0, 0, 256, 256); // 0, 0, 256, 256 创建矩形
|
||||
OH_Drawing_Surface* surface = nullptr;
|
||||
for (int i = 0; i < testCount_; i++) {
|
||||
surface = OH_Drawing_SurfaceCreateFromGpuContext(gpuContext, budgeted, imageInfo);
|
||||
|
@ -351,39 +351,7 @@ void TestBase::StyleSettings(OH_Drawing_Canvas* canvas, int32_t type)
|
||||
StyleSettingsDestroy(canvas);
|
||||
if (type == DRAW_STYLE_COMPLEX) {
|
||||
styleBrush_ = OH_Drawing_BrushCreate();
|
||||
stylePen_ = OH_Drawing_PenCreate();
|
||||
|
||||
OH_Drawing_BrushSetAntiAlias(styleBrush_, true);
|
||||
OH_Drawing_BrushSetColor(styleBrush_, 0xFFFF0000);
|
||||
OH_Drawing_BrushSetAlpha(styleBrush_, 0xF0);
|
||||
OH_Drawing_BrushSetBlendMode(styleBrush_, BLEND_MODE_SRC);
|
||||
|
||||
OH_Drawing_PenSetAntiAlias(stylePen_, true);
|
||||
OH_Drawing_PenSetColor(stylePen_, 0xFFFF0000);
|
||||
OH_Drawing_PenSetAlpha(stylePen_, 0xF0);
|
||||
OH_Drawing_PenSetBlendMode(stylePen_, BLEND_MODE_SRC);
|
||||
OH_Drawing_PenSetWidth(stylePen_, 5); // width 5
|
||||
|
||||
styleMask_ = OH_Drawing_MaskFilterCreateBlur(NORMAL, 10.0, true); // 10.0 PARAM
|
||||
styleFilter_ = OH_Drawing_FilterCreate();
|
||||
OH_Drawing_FilterSetMaskFilter(styleFilter_, styleMask_);
|
||||
OH_Drawing_BrushSetFilter(styleBrush_, styleFilter_);
|
||||
OH_Drawing_PenSetFilter(stylePen_, styleFilter_);
|
||||
|
||||
styleCenter_ = OH_Drawing_PointCreate(100, 100); // point 100,100
|
||||
uint32_t colors[] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF};
|
||||
float pos[] = {0, 0.5, 1.0};
|
||||
OH_Drawing_ShaderEffect* effect = OH_Drawing_ShaderEffectCreateRadialGradient(styleCenter_, 100, colors,
|
||||
pos, 3, OH_Drawing_TileMode::CLAMP); OH_Drawing_BrushSetShaderEffect(styleBrush_, effect);
|
||||
OH_Drawing_PenSetShaderEffect(stylePen_, effect);
|
||||
|
||||
OH_Drawing_PenSetMiterLimit(stylePen_, 10.0); // 10.0: size
|
||||
OH_Drawing_PenSetJoin(stylePen_, LINE_ROUND_JOIN);
|
||||
OH_Drawing_PenSetCap(stylePen_, LINE_ROUND_CAP);
|
||||
float vals[2] = {1, 1};
|
||||
OH_Drawing_PathEffect *pathEffect = OH_Drawing_CreateDashPathEffect(vals, 2, 0);
|
||||
OH_Drawing_PenSetPathEffect(stylePen_, pathEffect);
|
||||
OH_Drawing_CanvasAttachPen(canvas, stylePen_);
|
||||
OH_Drawing_CanvasAttachBrush(canvas, styleBrush_);
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
|
||||
enum { // 公共的pen,brush,filter等配置,在执行性能用例前设置
|
||||
DRAW_STYLE_NONE = 0, // 无配置
|
||||
DRAW_STYLE_COMPLEX, // 最复杂的配置,会将所有配置加上,得出近似最恶劣的性能数据
|
||||
DRAW_STYLE_COMPLEX, // 保证性能测试稳定性: 绘制一个红色填充
|
||||
};
|
||||
int styleType_ = DRAW_STYLE_NONE;
|
||||
void StyleSettings(OH_Drawing_Canvas* canvas, int32_t type);
|
||||
|
Loading…
Reference in New Issue
Block a user