Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
90230637
G
Graphic Ui
项目概览
OpenHarmony
/
Graphic Ui
大约 1 年 前同步成功
通知
13
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Graphic Ui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
90230637
编写于
9月 29, 2021
作者:
O
openharmony_ci
提交者:
Gitee
9月 29, 2021
浏览文件
操作
浏览文件
下载
差异文件
!457 修复draw_utils.cpp code clean
Merge pull request !457 from guyuanzhang/code_check
上级
a1285661
5ea0f596
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
48 addition
and
53 deletion
+48
-53
frameworks/draw/draw_utils.cpp
frameworks/draw/draw_utils.cpp
+48
-53
未找到文件。
frameworks/draw/draw_utils.cpp
浏览文件 @
90230637
...
...
@@ -14,6 +14,7 @@
*/
#include "draw/draw_utils.h"
#include "draw/draw_triangle.h"
#include "engines/gfx/gfx_engine_manager.h"
#include "font/ui_font.h"
...
...
@@ -35,16 +36,16 @@
namespace
OHOS
{
// Preprocess operation for draw
#define DRAW_UTILS_PREPROCESS(gfxBufferInfo, opa)
\
if ((opa) == OPA_TRANSPARENT) {
\
return;
\
}
\
uint8_t* screenBuffer = static_cast<uint8_t*>(gfxBufferInfo.virAddr);
\
if (screenBuffer == nullptr) {
\
return;
\
}
\
ColorMode bufferMode = gfxBufferInfo.mode;
\
uint8_t bufferPxSize = GetByteSizeByColorMode(bufferMode);
\
#define DRAW_UTILS_PREPROCESS(gfxBufferInfo, opa) \
if ((opa) == OPA_TRANSPARENT) { \
return; \
} \
uint8_t* screenBuffer = static_cast<uint8_t*>(gfxBufferInfo.virAddr); \
if (screenBuffer == nullptr) { \
return; \
} \
ColorMode bufferMode = gfxBufferInfo.mode; \
uint8_t bufferPxSize = GetByteSizeByColorMode(bufferMode); \
uint16_t screenBufferWidth = gfxBufferInfo.width;
/* cover mode, src alpha is 255 */
...
...
@@ -84,14 +85,14 @@ namespace OHOS {
ASSERT(0); \
}
#define COLOR_BLEND_RGBA(r1, g1, b1, a1, r2, g2, b2, a2) \
const float A
1 = static_cast<float>(a1) / OPA_OPAQUE;
\
const float A
2 = static_cast<float>(a2) / OPA_OPAQUE;
\
const float
a = 1 - (1 - A1) * (1 - A2);
\
(r1) = (A
2 * (r2) + (1 - A2) * A1 * (r1)) / a;
\
(g1) = (A
2 * (g2) + (1 - A2) * A1 * (g1)) / a;
\
(b1) = (A
2 * (b2) + (1 - A2) * A1 * (b1)) / a;
\
(a1) =
a
* OPA_OPAQUE;
#define COLOR_BLEND_RGBA(r1, g1, b1, a1, r2, g2, b2, a2)
\
const float A
lpha1 = static_cast<float>(a1) / OPA_OPAQUE;
\
const float A
lpha2 = static_cast<float>(a2) / OPA_OPAQUE;
\
const float
Alpha3 = 1 - (1 - Alpha1) * (1 - Alpha2);
\
(r1) = (A
lpha2 * (r2) + (1 - Alpha2) * Alpha1 * (r1)) / Alpha3;
\
(g1) = (A
lpha2 * (g2) + (1 - Alpha2) * Alpha1 * (g1)) / Alpha3;
\
(b1) = (A
lpha2 * (b2) + (1 - Alpha2) * Alpha1 * (b1)) / Alpha3;
\
(a1) =
Alpha3
* OPA_OPAQUE;
#define COLOR_BLEND_RGB(r1, g1, b1, r2, g2, b2, a2) \
(r1) = (((r2) * (a2)) / OPA_OPAQUE) + (((r1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \
...
...
@@ -435,12 +436,8 @@ void DrawUtils::DrawImage(BufferInfo& gfxDstBuffer,
}
BufferInfo
src
;
src
.
rect
=
{
imageX
,
imageY
,
static_cast
<
int16_t
>
(
imageX
+
maskedArea
.
GetWidth
()
-
1
),
static_cast
<
int16_t
>
(
imageY
+
maskedArea
.
GetHeight
()
-
1
)
};
src
.
rect
=
{
imageX
,
imageY
,
static_cast
<
int16_t
>
(
imageX
+
maskedArea
.
GetWidth
()
-
1
),
static_cast
<
int16_t
>
(
imageY
+
maskedArea
.
GetHeight
()
-
1
)};
src
.
virAddr
=
static_cast
<
void
*>
(
const_cast
<
uint8_t
*>
(
image
));
src
.
stride
=
imageWidthInByte
;
...
...
@@ -862,7 +859,7 @@ void DrawUtils::DrawTriangleTrueColorBilinear565(const TriangleScanInfo& in, con
Color16
result
;
#if ENABLE_FIXED_POINT
result
.
red
=
static_cast
<
uint8_t
>
(
outR
>>
15
);
// 15: shift 15 bit right to convert fixed to int
result
.
red
=
static_cast
<
uint8_t
>
(
outR
>>
15
);
// 15: shift 15 bit right to convert fixed to int
result
.
green
=
static_cast
<
uint8_t
>
(
outG
>>
15
);
// 15: shift 15 bit right to convert fixed to int
result
.
blue
=
static_cast
<
uint8_t
>
(
outB
>>
15
);
// 15: shift 15 bit right to convert fixed to int
#else
...
...
@@ -982,7 +979,7 @@ void DrawUtils::DrawTriangleTrueColorBilinear888(const TriangleScanInfo& in, con
Color24
result
;
#if ENABLE_FIXED_POINT
result
.
red
=
static_cast
<
uint8_t
>
(
outR
>>
15
);
// 15: shift 15 bit right to convert fixed to int
result
.
red
=
static_cast
<
uint8_t
>
(
outR
>>
15
);
// 15: shift 15 bit right to convert fixed to int
result
.
green
=
static_cast
<
uint8_t
>
(
outG
>>
15
);
// 15: shift 15 bit right to convert fixed to int
result
.
blue
=
static_cast
<
uint8_t
>
(
outB
>>
15
);
// 15: shift 15 bit right to convert fixed to int
#else
...
...
@@ -1082,11 +1079,11 @@ static void DrawTriangleTrueColorBilinear8888Inner(const TriangleScanInfo& in,
#endif
static
void
DrawFixedTriangleTrueColorBilinear8888Inner
(
const
TriangleScanInfo
&
in
,
uint8_t
*
screenBuffer
,
int16_t
len
,
const
ColorMode
bufferMode
,
int64_t
u
,
int64_t
v
)
uint8_t
*
screenBuffer
,
int16_t
len
,
const
ColorMode
bufferMode
,
int64_t
u
,
int64_t
v
)
{
for
(
int16_t
x
=
0
;
x
<
len
;
++
x
)
{
int16_t
intU
=
FO_TO_INTEGER
(
u
);
...
...
@@ -1182,10 +1179,10 @@ static void DrawTriangleTrueColorBilinear8888InnerNeon(const TriangleScanInfo& i
#endif
}
// Monotonically increasing or decreasing, so only judge the beginning and end.
if
((
arrayU
[
0
]
>=
0
)
&&
(
arrayU
[
0
]
<
in
.
info
.
header
.
width
-
1
)
&&
(
arrayV
[
0
]
>=
0
)
&&
(
arrayV
[
0
]
<
in
.
info
.
header
.
height
-
1
)
&&
(
arrayU
[
NEON_STEP_8
-
1
]
>=
0
)
&&
(
arrayU
[
NEON_STEP_8
-
1
]
<
in
.
info
.
header
.
width
-
1
)
&&
(
arrayV
[
NEON_STEP_8
-
1
]
>=
0
)
&&
(
arrayV
[
NEON_STEP_8
-
1
]
<
in
.
info
.
header
.
height
-
1
))
{
if
((
arrayU
[
0
]
>=
0
)
&&
(
arrayU
[
0
]
<
in
.
info
.
header
.
width
-
1
)
&&
(
arrayV
[
0
]
>=
0
)
&&
(
arrayV
[
0
]
<
in
.
info
.
header
.
height
-
1
)
&&
(
arrayU
[
NEON_STEP_8
-
1
]
>=
0
)
&&
(
arrayU
[
NEON_STEP_8
-
1
]
<
in
.
info
.
header
.
width
-
1
)
&&
(
arrayV
[
NEON_STEP_8
-
1
]
>=
0
)
&&
(
arrayV
[
NEON_STEP_8
-
1
]
<
in
.
info
.
header
.
height
-
1
))
{
// Process the lower half of arrayU and arrayV
float32x4_t
vU
=
vld1q_f32
(
arrayU
);
float32x4_t
vV
=
vld1q_f32
(
arrayV
);
...
...
@@ -1299,7 +1296,7 @@ void DrawUtils::Draw3DTriangleTrueColorBilinear8888(const TriangleScanInfo& in,
int64_t
invMatrix30
=
FO_TRANS_FLOAT_TO_FIXED
(
in
.
matrix
.
GetData
()[
6
]);
int64_t
invMatrix31
=
FO_TRANS_FLOAT_TO_FIXED
(
in
.
matrix
.
GetData
()[
7
]);
int64_t
invMatrix32
=
FO_TRANS_FLOAT_TO_FIXED
(
in
.
matrix
.
GetData
()[
8
]);
#else // ENABLE_FIXED_POINT
#else
// ENABLE_FIXED_POINT
float
invMatrix00
=
in
.
matrix
.
GetData
()[
0
];
float
invMatrix01
=
in
.
matrix
.
GetData
()[
1
];
float
invMatrix02
=
in
.
matrix
.
GetData
()[
2
];
...
...
@@ -1316,12 +1313,12 @@ void DrawUtils::Draw3DTriangleTrueColorBilinear8888(const TriangleScanInfo& in,
int16_t
xMin
=
MATH_MAX
(
tempV
,
maskLeft
);
tempV
=
FO_TO_INTEGER
(
in
.
edge2
.
curX
)
+
xMaxErr
;
int16_t
xMax
=
MATH_MIN
(
tempV
,
maskRight
);
#else // ENABLE_FIXED_POINT
#else
// ENABLE_FIXED_POINT
int16_t
xMin
=
MATH_MAX
(
static_cast
<
int16_t
>
(
in
.
edge1
.
curX
+
xMinErr
),
maskLeft
);
int16_t
xMax
=
MATH_MIN
(
static_cast
<
int16_t
>
(
in
.
edge2
.
curX
+
xMaxErr
),
maskRight
);
#endif // ENABLE_FIXED_POINT
// move to current position
uint8_t
*
screenBuffer
=
in
.
screenBuffer
+
(
y
*
in
.
screenBufferWidth
+
xMin
)
*
in
.
bufferPxSize
;
// move to current position
for
(
int16_t
x
=
xMin
;
x
<=
xMax
;
x
++
)
{
#if ENABLE_FIXED_POINT
int64_t
w
=
invMatrix02
*
x
+
invMatrix22
*
y
+
invMatrix32
;
...
...
@@ -1329,7 +1326,7 @@ void DrawUtils::Draw3DTriangleTrueColorBilinear8888(const TriangleScanInfo& in,
int64_t
v
=
FO_DIV
((
invMatrix01
*
x
+
invMatrix21
*
y
+
invMatrix31
),
w
);
int16_t
intU
=
FO_TO_INTEGER
(
u
);
int16_t
intV
=
FO_TO_INTEGER
(
v
);
#else // ENABLE_FIXED_POINT
#else
// ENABLE_FIXED_POINT
float
w
=
invMatrix02
*
x
+
invMatrix22
*
y
+
invMatrix32
;
float
u
=
(
invMatrix00
*
x
+
invMatrix20
*
y
+
invMatrix30
)
/
w
;
float
v
=
(
invMatrix01
*
x
+
invMatrix21
*
y
+
invMatrix31
)
/
w
;
...
...
@@ -1341,7 +1338,7 @@ void DrawUtils::Draw3DTriangleTrueColorBilinear8888(const TriangleScanInfo& in,
uint32_t
val1
=
__SMUAD
(
intV
,
in
.
srcLineWidth
);
uint32_t
val2
=
__SMUAD
(
intU
,
in
.
pixelSize
);
uint32_t
px1
=
val1
+
val2
;
#else // ENABLE_ARM_MATH
#else
// ENABLE_ARM_MATH
uint32_t
px1
=
intV
*
in
.
srcLineWidth
+
intU
*
in
.
pixelSize
;
#endif // ENABLE_ARM_MATH
uint8_t
*
imgHead
=
const_cast
<
uint8_t
*>
(
in
.
info
.
data
);
...
...
@@ -1396,7 +1393,7 @@ void DrawUtils::Draw3DTriangleTrueColorBilinear8888(const TriangleScanInfo& in,
__SMUAD
(
p1
.
blue
,
w1
)
+
__SMUAD
(
p2
.
blue
,
w2
)
+
__SMUAD
(
p3
.
blue
,
w3
)
+
__SMUAD
(
p4
.
blue
,
w4
);
const
int32_t
outA
=
__SMUAD
(
p1
.
alpha
,
w1
)
+
__SMUAD
(
p2
.
alpha
,
w2
)
+
__SMUAD
(
p3
.
alpha
,
w3
)
+
__SMUAD
(
p4
.
alpha
,
w4
);
#else // ENABLE_ARM_MATH
#else
// ENABLE_ARM_MATH
const
int32_t
outR
=
p1
.
red
*
w1
+
p2
.
red
*
w2
+
p3
.
red
*
w3
+
p4
.
red
*
w4
;
const
int32_t
outG
=
p1
.
green
*
w1
+
p2
.
green
*
w2
+
p3
.
green
*
w3
+
p4
.
green
*
w4
;
const
int32_t
outB
=
p1
.
blue
*
w1
+
p2
.
blue
*
w2
+
p3
.
blue
*
w3
+
p4
.
blue
*
w4
;
...
...
@@ -1474,9 +1471,9 @@ void DrawUtils::DrawTriangleTrueColorBilinear8888(const TriangleScanInfo& in, co
in
.
init
.
verticalU
+=
in
.
init
.
duVertical
;
in
.
init
.
verticalV
+=
in
.
init
.
dvVertical
;
#if ENABLE_FIXED_POINT
int16_t
deltaX
=
FO_TO_INTEGER
(
in
.
edge1
.
curX
)
-
xMin
;
int16_t
deltaX
=
FO_TO_INTEGER
(
in
.
edge1
.
curX
)
-
xMin
;
#else
int16_t
deltaX
=
static_cast
<
int16_t
>
(
in
.
edge1
.
curX
)
-
xMin
;
int16_t
deltaX
=
static_cast
<
int16_t
>
(
in
.
edge1
.
curX
)
-
xMin
;
#endif
in
.
init
.
verticalU
+=
in
.
init
.
duHorizon
*
deltaX
;
in
.
init
.
verticalV
+=
in
.
init
.
dvHorizon
*
deltaX
;
...
...
@@ -1586,11 +1583,11 @@ void DrawUtils::DrawTriangleTrueColorNearest(const TriangleScanInfo& in, const C
void
DrawUtils
::
DrawTriangleTransformPart
(
BufferInfo
&
gfxDstBuffer
,
const
TrianglePartInfo
&
part
)
{
#if ENABLE_FIXED_POINT
// parameters below are Q15 fixed-point number
// parameters below are Q15 fixed-point number
int64_t
yMin
=
FO_TRANS_INTEGER_TO_FIXED
(
part
.
yMin
);
part
.
edge1
.
curX
+=
(
static_cast
<
int64_t
>
(
part
.
edge1
.
du
)
*
(
yMin
-
part
.
edge1
.
curY
)
/
part
.
edge1
.
dv
);
part
.
edge1
.
curX
+=
(
static_cast
<
int64_t
>
(
part
.
edge1
.
du
)
*
(
yMin
-
part
.
edge1
.
curY
)
/
part
.
edge1
.
dv
);
part
.
edge1
.
curY
=
yMin
;
part
.
edge2
.
curX
+=
(
static_cast
<
int64_t
>
(
part
.
edge2
.
du
)
*
(
yMin
-
part
.
edge2
.
curY
)
/
part
.
edge2
.
dv
);
part
.
edge2
.
curX
+=
(
static_cast
<
int64_t
>
(
part
.
edge2
.
du
)
*
(
yMin
-
part
.
edge2
.
curY
)
/
part
.
edge2
.
dv
);
part
.
edge2
.
curY
=
yMin
;
Rect
line
;
line
.
SetLeft
(
FO_TO_INTEGER
(
part
.
edge1
.
curX
));
...
...
@@ -1739,7 +1736,7 @@ BottomHalf:
void
DrawUtils
::
AddBorderToImageData
(
TransformDataInfo
&
newDataInfo
)
{
int16_t
border
=
1
;
// 1 : border width
int16_t
border
=
1
;
// 1 : border width
int16_t
offset
=
border
*
2
;
// 2 : offset
uint16_t
width
=
newDataInfo
.
header
.
width
;
uint16_t
height
=
newDataInfo
.
header
.
height
;
...
...
@@ -1789,8 +1786,8 @@ void DrawUtils::UpdateTransMap(int16_t width, int16_t height, TransformMap& tran
Rect
rect
=
transMap
.
GetTransMapRect
();
Matrix4
<
float
>
matrix
=
transMap
.
GetTransformMatrix
();
matrix
=
matrix
*
(
Matrix4
<
float
>::
Translate
(
Vector3
<
float
>
(
-
rect
.
GetX
(),
-
rect
.
GetY
(),
0
)));
int16_t
offsetX
=
(
width
-
rect
.
GetWidth
())
/
2
;
// 2 : half;
int16_t
offsetY
=
(
height
-
rect
.
GetHeight
())
/
2
;
// 2 : half;
int16_t
offsetX
=
(
width
-
rect
.
GetWidth
())
/
2
;
// 2 : half;
int16_t
offsetY
=
(
height
-
rect
.
GetHeight
())
/
2
;
// 2 : half;
rect
.
SetPosition
(
rect
.
GetX
()
-
offsetX
,
rect
.
GetY
()
-
offsetY
);
rect
.
Resize
(
width
,
height
);
Polygon
polygon
=
Polygon
(
rect
);
...
...
@@ -1816,8 +1813,7 @@ void DrawUtils::UpdateTransMap(int16_t width, int16_t height, TransformMap& tran
}
}
transMap
.
SetPolygon
(
polygon
);
Matrix3
<
float
>
matrix3
(
matrix
[
0
][
0
],
matrix
[
0
][
1
],
matrix
[
0
][
3
],
matrix
[
1
][
0
],
matrix
[
1
][
1
],
matrix
[
1
][
3
],
Matrix3
<
float
>
matrix3
(
matrix
[
0
][
0
],
matrix
[
0
][
1
],
matrix
[
0
][
3
],
matrix
[
1
][
0
],
matrix
[
1
][
1
],
matrix
[
1
][
3
],
matrix
[
3
][
0
],
matrix
[
3
][
1
],
matrix
[
3
][
3
]);
transMap
.
invMatrix_
=
(
matrix3
*
(
Matrix3
<
float
>::
Translate
(
Vector2
<
float
>
(
rect
.
GetX
(),
rect
.
GetY
())))).
Inverse
();
}
...
...
@@ -1947,8 +1943,7 @@ void DrawUtils::DrawTranspantArea(BufferInfo& gfxDstBuffer, const Rect& rect, co
FillArea
(
gfxDstBuffer
,
rect
,
mask
,
true
,
nullptr
);
}
void
DrawUtils
::
DrawWithBuffer
(
BufferInfo
&
gfxDstBuffer
,
const
Rect
&
rect
,
const
Rect
&
mask
,
const
ColorType
*
colorBuf
)
void
DrawUtils
::
DrawWithBuffer
(
BufferInfo
&
gfxDstBuffer
,
const
Rect
&
rect
,
const
Rect
&
mask
,
const
ColorType
*
colorBuf
)
{
FillArea
(
gfxDstBuffer
,
rect
,
mask
,
false
,
colorBuf
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录