Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
4a6aa6c9
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,发现更多精彩内容 >>
提交
4a6aa6c9
编写于
3月 27, 2021
作者:
N
niulihua
提交者:
Gitee
3月 27, 2021
浏览文件
操作
浏览文件
下载
差异文件
!36 support A4/A8/L4/L8 image formats hardware drawing
Merge pull request !36 from wangtiantian/A4L8
上级
8b6e8160
55b290c4
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
66 addition
and
44 deletion
+66
-44
frameworks/dock/screen_device.h
frameworks/dock/screen_device.h
+2
-0
frameworks/dock/screen_device_proxy.h
frameworks/dock/screen_device_proxy.h
+3
-2
frameworks/draw/draw_image.cpp
frameworks/draw/draw_image.cpp
+32
-8
frameworks/draw/draw_utils.cpp
frameworks/draw/draw_utils.cpp
+24
-25
frameworks/draw/draw_utils.h
frameworks/draw/draw_utils.h
+3
-8
frameworks/imgdecode/file_img_decoder.cpp
frameworks/imgdecode/file_img_decoder.cpp
+1
-1
test/unittest/common/hardware_acceleration_unit_test.cpp
test/unittest/common/hardware_acceleration_unit_test.cpp
+1
-0
未找到文件。
frameworks/dock/screen_device.h
浏览文件 @
4a6aa6c9
...
...
@@ -127,6 +127,7 @@ public:
* @param srcStride Indicates the number of bytes in a single row of source memory
* @param srcLineNumber Indicates the number of source memory rows
* @param srcColorMode Indicates the source memory color format
* @param srcLutColorMode Indicates the source memory lut(Lookup Table) color format
* @param color 32-bit XRGB8888 value
* (valid when the source memory is in a format with only alph information such as A1)
* @param opa Indicates the transparency
...
...
@@ -144,6 +145,7 @@ public:
uint32_t
srcStride
,
uint32_t
srcLineNumber
,
ColorMode
srcColorMode
,
LutColorMode
srcLutColorMode
,
uint32_t
color
,
OpacityType
opa
,
uint8_t
*
dst
,
...
...
frameworks/dock/screen_device_proxy.h
浏览文件 @
4a6aa6c9
...
...
@@ -66,6 +66,7 @@ public:
uint32_t
srcStride
,
uint32_t
srcLineNumber
,
ColorMode
srcColorMode
,
LutColorMode
srcLutColorMode
,
uint32_t
color
,
OpacityType
opa
,
uint8_t
*
dst
,
...
...
@@ -75,8 +76,8 @@ public:
uint32_t
y
)
{
if
(
device_
!=
nullptr
)
{
return
device_
->
HardwareBlend
(
src
,
srcRect
,
srcStride
,
srcLineNumber
,
srcColorMode
,
color
,
opa
,
dst
,
dstStride
,
dstColorMode
,
x
,
y
);
return
device_
->
HardwareBlend
(
src
,
srcRect
,
srcStride
,
srcLineNumber
,
srcColorMode
,
srcLutColorMode
,
color
,
opa
,
dst
,
dstStride
,
dstColorMode
,
x
,
y
);
}
return
false
;
}
...
...
frameworks/draw/draw_image.cpp
浏览文件 @
4a6aa6c9
...
...
@@ -27,10 +27,33 @@ void DrawImage::DrawCommon(const Rect& coords, const Rect& mask,
return
;
}
OpacityType
opa
=
DrawUtils
::
GetMixOpacity
(
opaScale
,
style
.
imageOpa_
);
/* 3 : when single pixel change bit to byte, the buffer should divide by 8, equal to shift right 3 bits. */
uint8_t
pxByteSize
=
DrawUtils
::
GetPxSizeByImageInfo
(
*
img
)
>>
3
;
DrawUtils
::
GetInstance
()
->
DrawImage
(
coords
,
mask
,
img
->
data
,
opa
,
pxByteSize
);
uint8_t
pxBitSize
=
DrawUtils
::
GetPxSizeByColorMode
(
img
->
header
.
colorMode
);
LutColorMode
lutColorMode
=
LUT_UNKNOW
;
uint8_t
size
=
0
;
switch
(
img
->
header
.
colorMode
)
{
case
L1
:
// One index represents 1 bit, 8 : convert to bytes, 1 : 2 color values
size
=
(
img
->
dataSize
-
(
img
->
header
.
width
*
img
->
header
.
height
/
8
))
>>
1
;
break
;
case
L2
:
// One index represents 2 bit, 4 : convert to bytes, 2 : 4 color values
size
=
(
img
->
dataSize
-
(
img
->
header
.
width
*
img
->
header
.
height
/
4
))
>>
2
;
break
;
case
L4
:
// One index represents 4 bit, 2 : convert to bytes, 4 : 16 color values
size
=
(
img
->
dataSize
-
(
img
->
header
.
width
*
img
->
header
.
height
/
2
))
>>
4
;
break
;
case
L8
:
// One index represents 8 bit, 8 : 256 color values
size
=
(
img
->
dataSize
-
(
img
->
header
.
width
*
img
->
header
.
height
))
>>
8
;
break
;
default:
size
=
0
;
break
;
}
lutColorMode
=
DrawUtils
::
GetLutColorModeBySize
(
size
);
DrawUtils
::
GetInstance
()
->
DrawImage
(
coords
,
mask
,
img
->
data
,
opa
,
pxBitSize
,
static_cast
<
ColorMode
>
(
img
->
header
.
colorMode
),
lutColorMode
);
}
void
DrawImage
::
DrawCommon
(
const
Rect
&
coords
,
const
Rect
&
mask
,
...
...
@@ -46,10 +69,10 @@ void DrawImage::DrawCommon(const Rect& coords, const Rect& mask,
return
;
}
/* 3 : when single pixel change bit to byte, the buffer should divide by 8, equal to shift right 3 bits. */
uint8_t
pxByteSize
=
DrawUtils
::
GetPxSizeByImageInfo
(
entry
.
GetImageInfo
())
>>
3
;
uint8_t
pxBitSize
=
DrawUtils
::
GetPxSizeByColorMode
(
entry
.
GetImageInfo
().
header
.
colorMode
);
if
(
entry
.
InCache
())
{
DrawUtils
::
GetInstance
()
->
DrawImage
(
coords
,
mask
,
entry
.
GetImgData
(),
opa
,
pxByteSize
);
DrawUtils
::
GetInstance
()
->
DrawImage
(
coords
,
mask
,
entry
.
GetImgData
(),
opa
,
pxBitSize
,
static_cast
<
ColorMode
>
(
entry
.
GetImageInfo
().
header
.
colorMode
));
}
else
{
Rect
valid
=
coords
;
if
(
!
valid
.
Intersect
(
valid
,
mask
))
{
...
...
@@ -77,7 +100,8 @@ void DrawImage::DrawCommon(const Rect& coords, const Rect& mask,
UIFree
(
buf
);
return
;
}
DrawUtils
::
GetInstance
()
->
DrawImage
(
line
,
mask
,
buf
,
opa
,
pxByteSize
);
DrawUtils
::
GetInstance
()
->
DrawImage
(
line
,
mask
,
buf
,
opa
,
pxBitSize
,
static_cast
<
ColorMode
>
(
entry
.
GetImageInfo
().
header
.
colorMode
));
line
.
SetTop
(
line
.
GetTop
()
+
1
);
line
.
SetBottom
(
line
.
GetBottom
()
+
1
);
start
.
y
++
;
...
...
frameworks/draw/draw_utils.cpp
浏览文件 @
4a6aa6c9
...
...
@@ -206,6 +206,7 @@ void DrawUtils::DrawColorArea(const Rect& area, const Rect& mask, const ColorTyp
uint8_t
DrawUtils
::
GetPxSizeByColorMode
(
uint8_t
colorMode
)
{
switch
(
colorMode
)
{
case
TSC
:
case
ARGB8888
:
return
32
;
// 32: 32 bit
case
RGB888
:
...
...
@@ -247,14 +248,18 @@ uint8_t DrawUtils::GetByteSizeByColorMode(uint8_t colorMode)
}
}
uint8_t
DrawUtils
::
GetPxSizeByImageInfo
(
ImageInfo
imageInfo
)
LutColorMode
DrawUtils
::
GetLutColorModeBySize
(
uint8_t
size
)
{
if
((
imageInfo
.
header
.
width
==
0
)
||
(
imageInfo
.
header
.
height
==
0
))
{
return
0
;
switch
(
size
)
{
case
2
:
// 2: 2 Byte
return
LUT_RGB565
;
case
3
:
// 3: 3 Byte
return
LUT_RGB888
;
case
4
:
// 4: 4 Byte
return
LUT_ARGB8888
;
default:
return
LUT_UNKNOW
;
}
/* 3 : when change byte to single pixel, the buffer should multiply by 8, equal to shift left 3 bits. */
uint8_t
pxSize
=
(
imageInfo
.
dataSize
/
(
imageInfo
.
header
.
width
*
imageInfo
.
header
.
height
))
<<
3
;
return
pxSize
;
}
void
DrawUtils
::
DrawPixel
(
int16_t
x
,
int16_t
y
,
const
Rect
&
mask
,
const
ColorType
&
color
,
OpacityType
opa
)
const
...
...
@@ -348,7 +353,7 @@ void DrawUtils::DrawLetter(const LabelLetterInfo& letterInfo) const
(
posX
+
letterW
<=
letterInfo
.
mask
.
GetRight
())
?
letterW
:
(
letterInfo
.
mask
.
GetRight
()
-
posX
+
1
);
uint8_t
letterWidthInByte
=
(
letterW
*
fontWeight
)
>>
SHIFT_3
;
if
((
letterW
*
fontWeight
)
&
0x7
)
{
if
((
letterW
*
fontWeight
)
&
0x7
)
{
// 0x7 : less than 1 byte is counted as 1 byte
letterWidthInByte
++
;
}
...
...
@@ -363,7 +368,7 @@ void DrawUtils::DrawLetter(const LabelLetterInfo& letterInfo) const
#if ENABLE_HARDWARE_ACCELERATION && ENABLE_HARDWARE_ACCELERATION_FOR_TEXT
Rect
srcRect
(
colStart
,
rowStart
,
colEnd
-
1
,
rowEnd
-
1
);
if
(
ScreenDeviceProxy
::
GetInstance
()
->
HardwareBlend
(
fontMap
,
srcRect
,
letterWidthInByte
,
letterH
,
static_cast
<
ColorMode
>
(
colorMode
),
static_cast
<
ColorMode
>
(
colorMode
),
LUT_UNKNOW
,
Color
::
ColorTo32
(
letterInfo
.
color
),
opa
,
reinterpret_cast
<
uint8_t
*>
(
screenBuffer
),
screenBufferWidth
*
bufferPxSize
,
bufferMode
,
dstPosX
,
dstPosY
))
{
return
;
...
...
@@ -414,7 +419,9 @@ void DrawUtils::DrawImage(const Rect& area,
const
Rect
&
mask
,
const
uint8_t
*
image
,
OpacityType
opa
,
uint8_t
pxByteSize
)
const
uint8_t
pxBitSize
,
ColorMode
colorMode
,
LutColorMode
LutColorMode
)
const
{
if
(
image
==
nullptr
)
{
return
;
...
...
@@ -435,32 +442,24 @@ void DrawUtils::DrawImage(const Rect& area,
int16_t
mapWidth
=
area
.
GetWidth
();
int16_t
imageX
=
originMaskedArea
.
GetLeft
()
-
area
.
GetLeft
();
int16_t
imageY
=
originMaskedArea
.
GetTop
()
-
area
.
GetTop
();
ColorMode
srcMode
;
if
(
pxByteSize
==
static_cast
<
uint8_t
>
(
PixelType
::
IMG_RGB888
))
{
srcMode
=
RGB888
;
}
else
if
(
pxByteSize
==
static_cast
<
uint8_t
>
(
PixelType
::
IMG_RGB565
))
{
srcMode
=
RGB565
;
}
else
if
(
pxByteSize
==
static_cast
<
uint8_t
>
(
PixelType
::
IMG_ARGB8888
))
{
srcMode
=
ARGB8888
;
}
else
{
GRAPHIC_LOGE
(
"DrawUtils::DrawImage image format err
\n
"
);
return
;
uint32_t
imageWidthInByte
=
(
static_cast
<
uint32_t
>
(
mapWidth
)
*
pxBitSize
)
>>
SHIFT_3
;
if
((
mapWidth
*
pxBitSize
)
&
0x7
)
{
// 0x7 : less than 1 byte is counted as 1 byte
imageWidthInByte
++
;
}
#if ENABLE_HARDWARE_ACCELERATION
Rect
srcRect
(
imageX
,
imageY
,
imageX
+
maskedArea
.
GetWidth
()
-
1
,
imageY
+
maskedArea
.
GetHeight
()
-
1
);
if
(
ScreenDeviceProxy
::
GetInstance
()
->
HardwareBlend
(
image
,
srcRect
,
mapWidth
*
pxByteSiz
e
,
area
.
GetHeight
(),
srcMode
,
0
,
opa
,
screenBuffer
,
screenBufferWidth
*
bufferPxSize
,
bufferMode
,
maskedArea
.
GetLeft
()
,
maskedArea
.
GetTop
()))
{
if
(
ScreenDeviceProxy
::
GetInstance
()
->
HardwareBlend
(
image
,
srcRect
,
imageWidthInByt
e
,
area
.
GetHeight
(),
colorMode
,
lutColorMode
,
0
,
opa
,
screenBuffer
,
screenBufferWidth
*
bufferPxSize
,
bufferMode
,
maskedArea
.
Get
Left
(),
maskedArea
.
Get
Top
()))
{
return
;
}
#endif
screenBuffer
+=
static_cast
<
uint32_t
>
(
screenBufferWidth
)
*
maskedArea
.
GetTop
()
*
bufferPxSize
;
screenBuffer
+=
static_cast
<
uint32_t
>
(
maskedArea
.
GetLeft
())
*
bufferPxSize
;
image
+=
(
static_cast
<
uint32_t
>
(
mapWidth
)
*
imageY
+
imageX
)
*
pxByteSize
;
image
+=
(
static_cast
<
uint32_t
>
(
mapWidth
)
*
imageY
+
imageX
)
*
(
pxBitSize
>>
SHIFT_3
)
;
/* RGB565 RGB888 color mode, image src don't have alpha */
BlendWithSoftWare
(
image
,
mapWidth
*
pxByteSize
,
src
Mode
,
screenBuffer
,
screenBufferWidth
*
bufferPxSize
,
bufferMode
,
BlendWithSoftWare
(
image
,
imageWidthInByte
,
color
Mode
,
screenBuffer
,
screenBufferWidth
*
bufferPxSize
,
bufferMode
,
maskedArea
.
GetWidth
(),
maskedArea
.
GetHeight
(),
opa
);
}
...
...
frameworks/draw/draw_utils.h
浏览文件 @
4a6aa6c9
...
...
@@ -167,12 +167,6 @@ enum {
IMG_SRC_UNKNOWN
,
};
enum
PixelType
{
IMG_RGB565
=
2
,
IMG_RGB888
=
3
,
IMG_ARGB8888
=
4
,
};
class
DrawUtils
:
public
HeapBase
{
public:
static
DrawUtils
*
GetInstance
()
...
...
@@ -189,7 +183,8 @@ public:
void
DrawLetter
(
const
LabelLetterInfo
&
letterInfo
)
const
;
void
DrawImage
(
const
Rect
&
area
,
const
Rect
&
mask
,
const
uint8_t
*
image
,
OpacityType
opa
,
uint8_t
pxByteSize
)
const
;
void
DrawImage
(
const
Rect
&
area
,
const
Rect
&
mask
,
const
uint8_t
*
image
,
OpacityType
opa
,
uint8_t
pxBitSize
,
ColorMode
colorMode
,
LutColorMode
lutColorMode
=
LUT_UNKNOW
)
const
;
static
void
GetXAxisErrForJunctionLine
(
bool
ignoreJunctionPoint
,
bool
isRightPart
,
int16_t
&
xMinErr
,
int16_t
&
xMaxErr
);
...
...
@@ -221,7 +216,7 @@ public:
static
uint8_t
GetByteSizeByColorMode
(
uint8_t
colorMode
);
static
uint8_t
GetPxSizeByImageInfo
(
ImageInfo
imageInfo
);
static
LutColorMode
GetLutColorModeBySize
(
uint8_t
size
);
static
OpacityType
GetMixOpacity
(
OpacityType
opa1
,
OpacityType
opa2
)
{
...
...
frameworks/imgdecode/file_img_decoder.cpp
浏览文件 @
4a6aa6c9
...
...
@@ -139,7 +139,7 @@ RetCode FileImgDecoder::ReadToCache(ImgResDsc& dsc)
RetCode
FileImgDecoder
::
ReadLineTrueColor
(
ImgResDsc
&
dsc
,
const
Point
&
start
,
int16_t
len
,
uint8_t
*
buf
)
{
uint8_t
pxSizeInBit
=
DrawUtils
::
GetPxSizeBy
ImageInfo
(
dsc
.
imgInfo
);
uint8_t
pxSizeInBit
=
DrawUtils
::
GetPxSizeBy
ColorMode
(
dsc
.
imgInfo
.
header
.
colorMode
);
off_t
res
;
uint32_t
pos
=
((
start
.
y
*
dsc
.
imgInfo
.
header
.
width
+
start
.
x
)
*
pxSizeInBit
)
>>
BYTE_TO_BIT_SHIFT
;
...
...
test/unittest/common/hardware_acceleration_unit_test.cpp
浏览文件 @
4a6aa6c9
...
...
@@ -52,6 +52,7 @@ public:
uint32_t
srcStride
,
uint32_t
srcLineNumber
,
ColorMode
srcColorMode
,
LutColorMode
srcLutColorMode
,
uint32_t
color
,
OpacityType
opa
,
uint8_t
*
dst
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录