Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
885b6f72
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,发现更多精彩内容 >>
未验证
提交
885b6f72
编写于
11月 29, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
!810 新增截屏模式
Merge pull request !810 from Zhouyj/xrgb1107
上级
eb8b35da
e4a5561c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
265 addition
and
16 deletion
+265
-16
frameworks/components/ui_view.cpp
frameworks/components/ui_view.cpp
+2
-2
frameworks/draw/draw_utils.cpp
frameworks/draw/draw_utils.cpp
+39
-7
interfaces/kits/components/ui_view.h
interfaces/kits/components/ui_view.h
+2
-1
test/uitest/test_view_bitmap/ui_test_view_bitmap.cpp
test/uitest/test_view_bitmap/ui_test_view_bitmap.cpp
+213
-6
test/uitest/test_view_bitmap/ui_test_view_bitmap.h
test/uitest/test_view_bitmap/ui_test_view_bitmap.h
+9
-0
未找到文件。
frameworks/components/ui_view.cpp
浏览文件 @
885b6f72
...
@@ -1273,7 +1273,7 @@ uint8_t UIView::GetMixOpaScale() const
...
@@ -1273,7 +1273,7 @@ uint8_t UIView::GetMixOpaScale() const
return
opaMix
;
return
opaMix
;
}
}
bool
UIView
::
GetBitmap
(
ImageInfo
&
imageInfo
)
bool
UIView
::
GetBitmap
(
ImageInfo
&
imageInfo
,
ColorMode
colorMode
)
{
{
UIView
*
tempRenderSibling
=
nextRenderSibling_
;
UIView
*
tempRenderSibling
=
nextRenderSibling_
;
nextRenderSibling_
=
nullptr
;
nextRenderSibling_
=
nullptr
;
...
@@ -1284,7 +1284,7 @@ bool UIView::GetBitmap(ImageInfo& imageInfo)
...
@@ -1284,7 +1284,7 @@ bool UIView::GetBitmap(ImageInfo& imageInfo)
rect_
.
SetPosition
(
0
,
0
);
rect_
.
SetPosition
(
0
,
0
);
Rect
mask
=
GetRect
();
Rect
mask
=
GetRect
();
BufferInfo
bufInfo
{
mask
,
0
,
nullptr
,
nullptr
,
0
,
0
,
ARGB8888
,
0
};
BufferInfo
bufInfo
{
mask
,
0
,
nullptr
,
nullptr
,
0
,
0
,
colorMode
,
0
};
bufInfo
.
width
=
mask
.
GetWidth
();
bufInfo
.
width
=
mask
.
GetWidth
();
bufInfo
.
height
=
mask
.
GetHeight
();
bufInfo
.
height
=
mask
.
GetHeight
();
bufInfo
.
stride
=
bufInfo
.
width
*
DrawUtils
::
GetByteSizeByColorMode
(
bufInfo
.
mode
);
bufInfo
.
stride
=
bufInfo
.
width
*
DrawUtils
::
GetByteSizeByColorMode
(
bufInfo
.
mode
);
...
...
frameworks/draw/draw_utils.cpp
浏览文件 @
885b6f72
...
@@ -49,7 +49,7 @@ namespace OHOS {
...
@@ -49,7 +49,7 @@ namespace OHOS {
/* cover mode, src alpha is 255 */
/* cover mode, src alpha is 255 */
#define COLOR_FILL_COVER(d, dm, r2, g2, b2, sm) \
#define COLOR_FILL_COVER(d, dm, r2, g2, b2, sm) \
if ((dm) == ARGB8888
) {
\
if ((dm) == ARGB8888
|| (dm) == XRGB8888) {
\
reinterpret_cast<Color32*>(d)->alpha = OPA_OPAQUE; \
reinterpret_cast<Color32*>(d)->alpha = OPA_OPAQUE; \
if (sm == RGB565) { \
if (sm == RGB565) { \
reinterpret_cast<Color32*>(d)->red = (r2) << 3; \
reinterpret_cast<Color32*>(d)->red = (r2) << 3; \
...
@@ -71,7 +71,7 @@ namespace OHOS {
...
@@ -71,7 +71,7 @@ namespace OHOS {
reinterpret_cast<Color24*>(d)->blue = (b2); \
reinterpret_cast<Color24*>(d)->blue = (b2); \
} \
} \
} else if ((dm) == RGB565) { \
} else if ((dm) == RGB565) { \
if ((sm) == ARGB8888 || (sm) == RGB888
) {
\
if ((sm) == ARGB8888 || (sm) == RGB888
|| (sm) == XRGB8888) {
\
reinterpret_cast<Color16*>(d)->red = (r2) >> 3; \
reinterpret_cast<Color16*>(d)->red = (r2) >> 3; \
reinterpret_cast<Color16*>(d)->green = (g2) >> 2; \
reinterpret_cast<Color16*>(d)->green = (g2) >> 2; \
reinterpret_cast<Color16*>(d)->blue = (b2) >> 3; \
reinterpret_cast<Color16*>(d)->blue = (b2) >> 3; \
...
@@ -93,6 +93,12 @@ namespace OHOS {
...
@@ -93,6 +93,12 @@ namespace OHOS {
(b1) = static_cast<uint8_t>((Alpha2 * (b2) + (1 - Alpha2) * Alpha1 * (b1)) / Alpha3); \
(b1) = static_cast<uint8_t>((Alpha2 * (b2) + (1 - Alpha2) * Alpha1 * (b1)) / Alpha3); \
(a1) = static_cast<uint8_t>(Alpha3 * OPA_OPAQUE)
(a1) = static_cast<uint8_t>(Alpha3 * OPA_OPAQUE)
#define COLOR_BLEND_XRGB(r1, g1, b1, a1, r2, g2, b2, a2) \
(r1) = (((r2) * (a2)) / OPA_OPAQUE) + (((r1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \
(g1) = (((g2) * (a2)) / OPA_OPAQUE) + (((g1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \
(b1) = (((b2) * (a2)) / OPA_OPAQUE) + (((b1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \
(a1) = static_cast<uint8_t>(OPA_OPAQUE)
#define COLOR_BLEND_RGB(r1, g1, b1, r2, g2, b2, a2) \
#define COLOR_BLEND_RGB(r1, g1, b1, r2, g2, b2, a2) \
(r1) = (((r2) * (a2)) / OPA_OPAQUE) + (((r1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \
(r1) = (((r2) * (a2)) / OPA_OPAQUE) + (((r1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \
(g1) = (((g2) * (a2)) / OPA_OPAQUE) + (((g1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \
(g1) = (((g2) * (a2)) / OPA_OPAQUE) + (((g1) * (OPA_OPAQUE - (a2))) / OPA_OPAQUE); \
...
@@ -102,7 +108,7 @@ namespace OHOS {
...
@@ -102,7 +108,7 @@ namespace OHOS {
#define COLOR_FILL_BLEND(d, dm, s, sm, a) \
#define COLOR_FILL_BLEND(d, dm, s, sm, a) \
if ((dm) == ARGB8888) { \
if ((dm) == ARGB8888) { \
Color32* p = reinterpret_cast<Color32*>(d); \
Color32* p = reinterpret_cast<Color32*>(d); \
if ((sm) == ARGB8888
) {
\
if ((sm) == ARGB8888
|| (sm) == XRGB8888) {
\
Color32* sTmp = reinterpret_cast<Color32*>(s); \
Color32* sTmp = reinterpret_cast<Color32*>(s); \
uint8_t alpha = (sTmp->alpha * (a)) / OPA_OPAQUE; \
uint8_t alpha = (sTmp->alpha * (a)) / OPA_OPAQUE; \
COLOR_BLEND_RGBA(p->red, p->green, p->blue, p->alpha, sTmp->red, sTmp->green, sTmp->blue, alpha); \
COLOR_BLEND_RGBA(p->red, p->green, p->blue, p->alpha, sTmp->red, sTmp->green, sTmp->blue, alpha); \
...
@@ -114,9 +120,23 @@ namespace OHOS {
...
@@ -114,9 +120,23 @@ namespace OHOS {
COLOR_BLEND_RGBA(p->red, p->green, p->blue, p->alpha, (sTmp->red) << 3, (sTmp->green) << 2, \
COLOR_BLEND_RGBA(p->red, p->green, p->blue, p->alpha, (sTmp->red) << 3, (sTmp->green) << 2, \
(sTmp->blue) << 3, a); \
(sTmp->blue) << 3, a); \
} \
} \
} else if ((dm) == XRGB8888) { \
Color32* p = reinterpret_cast<Color32*>(d); \
if ((sm) == ARGB8888 || (sm) == XRGB8888) { \
Color32* sTmp = reinterpret_cast<Color32*>(s); \
uint8_t alpha = (sTmp->alpha * (a)) / OPA_OPAQUE; \
COLOR_BLEND_XRGB(p->red, p->green, p->blue, p->alpha, sTmp->red, sTmp->green, sTmp->blue, alpha); \
} else if ((sm) == RGB888) { \
Color24* sTmp = reinterpret_cast<Color24*>(s); \
COLOR_BLEND_XRGB(p->red, p->green, p->blue, p->alpha, sTmp->red, sTmp->green, sTmp->blue, a); \
} else if ((sm) == RGB565) { \
Color16* sTmp = reinterpret_cast<Color16*>(s); \
COLOR_BLEND_XRGB(p->red, p->green, p->blue, p->alpha, (sTmp->red) << 3, (sTmp->green) << 2, \
(sTmp->blue) << 3, a); \
} \
} else if ((dm) == RGB888) { \
} else if ((dm) == RGB888) { \
Color24* p = reinterpret_cast<Color24*>(d); \
Color24* p = reinterpret_cast<Color24*>(d); \
if ((sm) == ARGB8888
) {
\
if ((sm) == ARGB8888
|| (sm) == XRGB8888) {
\
Color32* sTmp = reinterpret_cast<Color32*>(s); \
Color32* sTmp = reinterpret_cast<Color32*>(s); \
uint8_t alpha = (sTmp->alpha * (a)) / OPA_OPAQUE; \
uint8_t alpha = (sTmp->alpha * (a)) / OPA_OPAQUE; \
COLOR_BLEND_RGB(p->red, p->green, p->blue, sTmp->red, sTmp->green, sTmp->blue, alpha); \
COLOR_BLEND_RGB(p->red, p->green, p->blue, sTmp->red, sTmp->green, sTmp->blue, alpha); \
...
@@ -129,7 +149,7 @@ namespace OHOS {
...
@@ -129,7 +149,7 @@ namespace OHOS {
} \
} \
} else if ((dm) == RGB565) { \
} else if ((dm) == RGB565) { \
Color16* p = reinterpret_cast<Color16*>(d); \
Color16* p = reinterpret_cast<Color16*>(d); \
if ((sm) == ARGB8888
) {
\
if ((sm) == ARGB8888
|| (sm) == XRGB8888) {
\
Color32* sTmp = reinterpret_cast<Color32*>(s); \
Color32* sTmp = reinterpret_cast<Color32*>(s); \
uint8_t alpha = (sTmp->alpha * (a)) / OPA_OPAQUE; \
uint8_t alpha = (sTmp->alpha * (a)) / OPA_OPAQUE; \
COLOR_BLEND_RGB(p->red, p->green, p->blue, (sTmp->red) >> 3, (sTmp->green) >> 2, (sTmp->blue) >> 3, \
COLOR_BLEND_RGB(p->red, p->green, p->blue, (sTmp->red) >> 3, (sTmp->green) >> 2, (sTmp->blue) >> 3, \
...
@@ -208,6 +228,7 @@ uint8_t DrawUtils::GetPxSizeByColorMode(uint8_t colorMode)
...
@@ -208,6 +228,7 @@ uint8_t DrawUtils::GetPxSizeByColorMode(uint8_t colorMode)
case
TSC6
:
case
TSC6
:
case
TSC6A
:
case
TSC6A
:
case
ARGB8888
:
case
ARGB8888
:
case
XRGB8888
:
return
32
;
// 32: 32 bit
return
32
;
// 32: 32 bit
case
RGB888
:
case
RGB888
:
return
24
;
// 24: 24 bit
return
24
;
// 24: 24 bit
...
@@ -236,6 +257,7 @@ uint8_t DrawUtils::GetByteSizeByColorMode(uint8_t colorMode)
...
@@ -236,6 +257,7 @@ uint8_t DrawUtils::GetByteSizeByColorMode(uint8_t colorMode)
{
{
switch
(
colorMode
)
{
switch
(
colorMode
)
{
case
ARGB8888
:
case
ARGB8888
:
case
XRGB8888
:
return
4
;
// 4: 4 Byte
return
4
;
// 4: 4 Byte
case
RGB888
:
case
RGB888
:
return
3
;
// 3: 3 Byte
return
3
;
// 3: 3 Byte
...
@@ -494,6 +516,7 @@ void DrawUtils::DrawImage(BufferInfo& gfxDstBuffer,
...
@@ -494,6 +516,7 @@ void DrawUtils::DrawImage(BufferInfo& gfxDstBuffer,
Point
dstPos
=
{
maskedArea
.
GetLeft
(),
maskedArea
.
GetTop
()};
Point
dstPos
=
{
maskedArea
.
GetLeft
(),
maskedArea
.
GetTop
()};
BlendOption
blendOption
;
BlendOption
blendOption
;
blendOption
.
opacity
=
opa
;
blendOption
.
opacity
=
opa
;
blendOption
.
mode
=
BLEND_SRC_OVER
;
BaseGfxEngine
::
GetInstance
()
->
Blit
(
gfxDstBuffer
,
dstPos
,
src
,
maskedArea
,
blendOption
);
BaseGfxEngine
::
GetInstance
()
->
Blit
(
gfxDstBuffer
,
dstPos
,
src
,
maskedArea
,
blendOption
);
}
}
...
@@ -1673,6 +1696,15 @@ void DrawUtils::DrawTriangleTrueColorNearest(const TriangleScanInfo& in, const C
...
@@ -1673,6 +1696,15 @@ void DrawUtils::DrawTriangleTrueColorNearest(const TriangleScanInfo& in, const C
}
}
break
;
break
;
}
}
case
XRGB8888
:
{
Color32
p32
=
*
(
reinterpret_cast
<
Color32
*>
(
&
imgHead
[
px1
]));
if
((
in
.
opaScale
==
OPA_OPAQUE
)
&&
(
p32
.
alpha
==
OPA_OPAQUE
))
{
COLOR_FILL_COVER
(
screenBuffer
,
bufferMode
,
p32
.
red
,
p32
.
green
,
p32
.
blue
,
XRGB8888
);
}
else
{
COLOR_FILL_BLEND
(
screenBuffer
,
bufferMode
,
&
p32
,
XRGB8888
,
in
.
opaScale
);
}
break
;
}
default:
default:
return
;
return
;
}
}
...
@@ -1733,12 +1765,12 @@ void DrawUtils::DrawTriangleTransformPart(BufferInfo& gfxDstBuffer, const Triang
...
@@ -1733,12 +1765,12 @@ void DrawUtils::DrawTriangleTransformPart(BufferInfo& gfxDstBuffer, const Triang
uint8_t
pixelSize
;
uint8_t
pixelSize
;
DrawTriangleTransformFuc
fuc
;
DrawTriangleTransformFuc
fuc
;
bool
isTrueColor
=
(
part
.
info
.
header
.
colorMode
==
ARGB8888
)
||
(
part
.
info
.
header
.
colorMode
==
RGB888
)
||
bool
isTrueColor
=
(
part
.
info
.
header
.
colorMode
==
ARGB8888
)
||
(
part
.
info
.
header
.
colorMode
==
RGB888
)
||
(
part
.
info
.
header
.
colorMode
==
RGB565
);
(
part
.
info
.
header
.
colorMode
==
RGB565
)
||
(
part
.
info
.
header
.
colorMode
==
XRGB8888
)
;
if
(
isTrueColor
)
{
if
(
isTrueColor
)
{
pixelSize
=
part
.
info
.
pxSize
>>
SHIFT_3
;
pixelSize
=
part
.
info
.
pxSize
>>
SHIFT_3
;
if
(
part
.
info
.
algorithm
==
TransformAlgorithm
::
NEAREST_NEIGHBOR
)
{
if
(
part
.
info
.
algorithm
==
TransformAlgorithm
::
NEAREST_NEIGHBOR
)
{
fuc
=
DrawTriangleTrueColorNearest
;
fuc
=
DrawTriangleTrueColorNearest
;
}
else
if
(
part
.
info
.
header
.
colorMode
==
ARGB8888
)
{
}
else
if
(
part
.
info
.
header
.
colorMode
==
ARGB8888
||
part
.
info
.
header
.
colorMode
==
XRGB8888
)
{
if
(
part
.
transMap
.
Is3DTransform
())
{
if
(
part
.
transMap
.
Is3DTransform
())
{
fuc
=
Draw3DTriangleTrueColorBilinear8888
;
fuc
=
Draw3DTriangleTrueColorBilinear8888
;
}
else
{
}
else
{
...
...
interfaces/kits/components/ui_view.h
浏览文件 @
885b6f72
...
@@ -1497,11 +1497,12 @@ public:
...
@@ -1497,11 +1497,12 @@ public:
/**
/**
* @brief 获取当前视图的bitmap截图.请注意该接口会申请内存,请在需要释放时使用{@link ImageCacheFree()}接口.
* @brief 获取当前视图的bitmap截图.请注意该接口会申请内存,请在需要释放时使用{@link ImageCacheFree()}接口.
* @param info bitmap存储对象,获取的截图将被存到该引用中.
* @param info bitmap存储对象,获取的截图将被存到该引用中.
* @param colorMode 截图格式,默认状态下为带透明度的ARGB8888.
* @return bitmap是否获取成功.
* @return bitmap是否获取成功.
* @since 5.0
* @since 5.0
* @version 3.0
* @version 3.0
*/
*/
bool
GetBitmap
(
ImageInfo
&
bitmap
);
bool
GetBitmap
(
ImageInfo
&
bitmap
,
ColorMode
colorMode
=
ARGB8888
);
bool
IsOnViewTree
();
bool
IsOnViewTree
();
...
...
test/uitest/test_view_bitmap/ui_test_view_bitmap.cpp
浏览文件 @
885b6f72
...
@@ -47,7 +47,122 @@ public:
...
@@ -47,7 +47,122 @@ public:
if
(
info_
.
data
!=
nullptr
)
{
if
(
info_
.
data
!=
nullptr
)
{
ImageCacheFree
(
info_
);
ImageCacheFree
(
info_
);
}
}
view
.
GetBitmap
(
info_
);
view
.
GetBitmap
(
info_
,
ARGB8888
);
img_
->
SetVisible
(
true
);
img_
->
SetSrc
(
&
info_
);
img_
->
Invalidate
();
return
false
;
}
private:
UIViewGroup
*
container_
;
UIImageView
*
img_
;
ImageInfo
info_
;
};
class
ViewBitmapListener2
:
public
UIView
::
OnClickListener
{
public:
ViewBitmapListener2
(
UIViewGroup
*
container
,
UIImageView
*
img
)
:
container_
(
container
),
img_
(
img
)
{
(
void
)
memset_s
(
&
info_
,
sizeof
(
ImageInfo
),
0
,
sizeof
(
ImageInfo
));
if
((
img
!=
nullptr
)
&&
(
container
!=
nullptr
))
{
container
->
Add
(
img
);
img
->
SetVisible
(
false
);
}
}
virtual
~
ViewBitmapListener2
()
{
if
(
info_
.
data
!=
nullptr
)
{
ImageCacheFree
(
info_
);
}
}
bool
OnClick
(
UIView
&
view
,
const
ClickEvent
&
event
)
override
{
if
(
img_
==
nullptr
)
{
return
false
;
}
if
(
info_
.
data
!=
nullptr
)
{
ImageCacheFree
(
info_
);
}
view
.
GetBitmap
(
info_
,
XRGB8888
);
img_
->
SetVisible
(
true
);
img_
->
SetSrc
(
&
info_
);
img_
->
Invalidate
();
return
false
;
}
private:
UIViewGroup
*
container_
;
UIImageView
*
img_
;
ImageInfo
info_
;
};
class
ViewBitmapListener3
:
public
UIView
::
OnClickListener
{
public:
ViewBitmapListener3
(
UIViewGroup
*
container
,
UIImageView
*
img
)
:
container_
(
container
),
img_
(
img
)
{
(
void
)
memset_s
(
&
info_
,
sizeof
(
ImageInfo
),
0
,
sizeof
(
ImageInfo
));
if
((
img
!=
nullptr
)
&&
(
container
!=
nullptr
))
{
container
->
Add
(
img
);
img
->
SetVisible
(
false
);
}
}
virtual
~
ViewBitmapListener3
()
{
if
(
info_
.
data
!=
nullptr
)
{
ImageCacheFree
(
info_
);
}
}
bool
OnClick
(
UIView
&
view
,
const
ClickEvent
&
event
)
override
{
if
(
img_
==
nullptr
)
{
return
false
;
}
if
(
info_
.
data
!=
nullptr
)
{
ImageCacheFree
(
info_
);
}
view
.
GetBitmap
(
info_
,
RGB888
);
img_
->
SetVisible
(
true
);
img_
->
SetSrc
(
&
info_
);
img_
->
Invalidate
();
return
false
;
}
private:
UIViewGroup
*
container_
;
UIImageView
*
img_
;
ImageInfo
info_
;
};
class
ViewBitmapListener4
:
public
UIView
::
OnClickListener
{
public:
ViewBitmapListener4
(
UIViewGroup
*
container
,
UIImageView
*
img
)
:
container_
(
container
),
img_
(
img
)
{
(
void
)
memset_s
(
&
info_
,
sizeof
(
ImageInfo
),
0
,
sizeof
(
ImageInfo
));
if
((
img
!=
nullptr
)
&&
(
container
!=
nullptr
))
{
container
->
Add
(
img
);
img
->
SetVisible
(
false
);
}
}
virtual
~
ViewBitmapListener4
()
{
if
(
info_
.
data
!=
nullptr
)
{
ImageCacheFree
(
info_
);
}
}
bool
OnClick
(
UIView
&
view
,
const
ClickEvent
&
event
)
override
{
if
(
img_
==
nullptr
)
{
return
false
;
}
if
(
info_
.
data
!=
nullptr
)
{
ImageCacheFree
(
info_
);
}
view
.
GetBitmap
(
info_
,
RGB565
);
img_
->
SetVisible
(
true
);
img_
->
SetVisible
(
true
);
img_
->
SetSrc
(
&
info_
);
img_
->
SetSrc
(
&
info_
);
img_
->
Invalidate
();
img_
->
Invalidate
();
...
@@ -105,11 +220,27 @@ void UITestViewBitmap::SetUp()
...
@@ -105,11 +220,27 @@ void UITestViewBitmap::SetUp()
container_
=
new
UIScrollView
();
container_
=
new
UIScrollView
();
container_
->
Resize
(
Screen
::
GetInstance
().
GetWidth
(),
Screen
::
GetInstance
().
GetHeight
()
-
BACK_BUTTON_HEIGHT
);
container_
->
Resize
(
Screen
::
GetInstance
().
GetWidth
(),
Screen
::
GetInstance
().
GetHeight
()
-
BACK_BUTTON_HEIGHT
);
container_
->
SetHorizontalScrollState
(
false
);
container_
->
SetHorizontalScrollState
(
false
);
container_
->
SetStyle
(
STYLE_BACKGROUND_COLOR
,
Color
::
White
().
full
);
}
}
if
(
viewBitmap_
==
nullptr
)
{
if
(
viewBitmap_
==
nullptr
)
{
viewBitmap_
=
new
UIImageView
();
viewBitmap_
=
new
UIImageView
();
// 500 : x pos of image; 50: y pos of image; 960 width of image; 480 : height of image.
// 100 : x pos of image; 100: y pos of image; 960 width of image; 480 : height of image.
viewBitmap_
->
SetPosition
(
500
,
50
,
960
,
480
);
viewBitmap_
->
SetPosition
(
100
,
100
,
960
,
480
);
}
if
(
viewBitmap2_
==
nullptr
)
{
viewBitmap2_
=
new
UIImageView
();
// 300 : x pos of image; 100: y pos of image; 960 width of image; 480 : height of image.
viewBitmap2_
->
SetPosition
(
300
,
100
,
960
,
480
);
}
if
(
viewBitmap3_
==
nullptr
)
{
viewBitmap3_
=
new
UIImageView
();
// 500 : x pos of image; 100: y pos of image; 960 width of image; 480 : height of image.
viewBitmap3_
->
SetPosition
(
500
,
100
,
960
,
480
);
}
if
(
viewBitmap4_
==
nullptr
)
{
viewBitmap4_
=
new
UIImageView
();
// 700 : x pos of image; 100: y pos of image; 960 width of image; 480 : height of image.
viewBitmap4_
->
SetPosition
(
700
,
100
,
960
,
480
);
}
}
if
(
screenBitmap_
==
nullptr
)
{
if
(
screenBitmap_
==
nullptr
)
{
screenBitmap_
=
new
UIImageView
();
screenBitmap_
=
new
UIImageView
();
...
@@ -119,6 +250,15 @@ void UITestViewBitmap::SetUp()
...
@@ -119,6 +250,15 @@ void UITestViewBitmap::SetUp()
if
(
viewBitmapListener_
==
nullptr
)
{
if
(
viewBitmapListener_
==
nullptr
)
{
viewBitmapListener_
=
new
ViewBitmapListener
(
container_
,
viewBitmap_
);
viewBitmapListener_
=
new
ViewBitmapListener
(
container_
,
viewBitmap_
);
}
}
if
(
viewBitmapListener2_
==
nullptr
)
{
viewBitmapListener2_
=
new
ViewBitmapListener2
(
container_
,
viewBitmap2_
);
}
if
(
viewBitmapListener3_
==
nullptr
)
{
viewBitmapListener3_
=
new
ViewBitmapListener3
(
container_
,
viewBitmap3_
);
}
if
(
viewBitmapListener4_
==
nullptr
)
{
viewBitmapListener4_
=
new
ViewBitmapListener4
(
container_
,
viewBitmap4_
);
}
if
(
screenBitmapListener_
==
nullptr
)
{
if
(
screenBitmapListener_
==
nullptr
)
{
screenBitmapListener_
=
new
ScreenBitmapListener
(
container_
,
screenBitmap_
);
screenBitmapListener_
=
new
ScreenBitmapListener
(
container_
,
screenBitmap_
);
}
}
...
@@ -130,20 +270,37 @@ void UITestViewBitmap::TearDown()
...
@@ -130,20 +270,37 @@ void UITestViewBitmap::TearDown()
delete
viewBitmapListener_
;
delete
viewBitmapListener_
;
viewBitmapListener_
=
nullptr
;
viewBitmapListener_
=
nullptr
;
}
}
if
(
viewBitmapListener2_
!=
nullptr
)
{
delete
viewBitmapListener2_
;
viewBitmapListener2_
=
nullptr
;
}
if
(
viewBitmapListener3_
!=
nullptr
)
{
delete
viewBitmapListener3_
;
viewBitmapListener3_
=
nullptr
;
}
if
(
viewBitmapListener4_
!=
nullptr
)
{
delete
viewBitmapListener4_
;
viewBitmapListener4_
=
nullptr
;
}
if
(
screenBitmapListener_
!=
nullptr
)
{
if
(
screenBitmapListener_
!=
nullptr
)
{
delete
screenBitmapListener_
;
delete
screenBitmapListener_
;
screenBitmapListener_
=
nullptr
;
screenBitmapListener_
=
nullptr
;
}
}
DeleteChildren
(
container_
);
DeleteChildren
(
container_
);
container_
=
nullptr
;
container_
=
nullptr
;
viewBitmap_
=
nullptr
;
viewBitmap_
=
nullptr
;
viewBitmap2_
=
nullptr
;
viewBitmap3_
=
nullptr
;
viewBitmap4_
=
nullptr
;
screenBitmap_
=
nullptr
;
screenBitmap_
=
nullptr
;
}
}
const
UIView
*
UITestViewBitmap
::
GetTestView
()
const
UIView
*
UITestViewBitmap
::
GetTestView
()
{
{
UIKitBitmapTestGetViewBitmap001
();
UIKitBitmapTestGetViewBitmap001
();
UIKitBitmapTestGetViewBitmap002
();
UIKitBitmapTestGetViewBitmap003
();
UIKitBitmapTestGetViewBitmap004
();
UIKitBitmapTestGetScreenBitmap001
();
UIKitBitmapTestGetScreenBitmap001
();
return
container_
;
return
container_
;
}
}
...
@@ -154,7 +311,7 @@ void UITestViewBitmap::UIKitBitmapTestGetViewBitmap001()
...
@@ -154,7 +311,7 @@ void UITestViewBitmap::UIKitBitmapTestGetViewBitmap001()
container_
->
Add
(
btn
);
container_
->
Add
(
btn
);
// 100 : x pos of button; 50: y pos of button.
// 100 : x pos of button; 50: y pos of button.
btn
->
SetPosition
(
100
,
50
,
BUTTON_WIDHT3
,
BUTTON_HEIGHT3
);
btn
->
SetPosition
(
100
,
50
,
BUTTON_WIDHT3
,
BUTTON_HEIGHT3
);
btn
->
SetText
(
"
测试组件
截屏"
);
btn
->
SetText
(
"
组件ARGB
截屏"
);
btn
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
BUTTON_LABEL_SIZE
);
btn
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
BUTTON_LABEL_SIZE
);
btn
->
SetOnClickListener
(
viewBitmapListener_
);
btn
->
SetOnClickListener
(
viewBitmapListener_
);
btn
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
BUTTON_STYLE_BORDER_RADIUS_VALUE
,
UIButton
::
RELEASED
);
btn
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
BUTTON_STYLE_BORDER_RADIUS_VALUE
,
UIButton
::
RELEASED
);
...
@@ -163,7 +320,57 @@ void UITestViewBitmap::UIKitBitmapTestGetViewBitmap001()
...
@@ -163,7 +320,57 @@ void UITestViewBitmap::UIKitBitmapTestGetViewBitmap001()
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
RELEASED
);
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
RELEASED
);
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
PRESSED
);
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
PRESSED
);
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
INACTIVE
);
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
INACTIVE
);
btn
->
SetViewId
(
UI_TEST_COMPONENT_SCREENSHOT
);
}
void
UITestViewBitmap
::
UIKitBitmapTestGetViewBitmap002
()
{
UILabelButton
*
btn
=
new
UILabelButton
();
container_
->
Add
(
btn
);
// 300 : x pos of button; 50: y pos of button.
btn
->
SetPosition
(
300
,
50
,
BUTTON_WIDHT3
,
BUTTON_HEIGHT3
);
btn
->
SetText
(
"组件XRGB截屏"
);
btn
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
BUTTON_LABEL_SIZE
);
btn
->
SetOnClickListener
(
viewBitmapListener2_
);
btn
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
BUTTON_STYLE_BORDER_RADIUS_VALUE
,
UIButton
::
RELEASED
);
btn
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
BUTTON_STYLE_BORDER_RADIUS_VALUE
,
UIButton
::
PRESSED
);
btn
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
BUTTON_STYLE_BORDER_RADIUS_VALUE
,
UIButton
::
INACTIVE
);
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
RELEASED
);
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
PRESSED
);
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
INACTIVE
);
}
void
UITestViewBitmap
::
UIKitBitmapTestGetViewBitmap003
()
{
UILabelButton
*
btn
=
new
UILabelButton
();
container_
->
Add
(
btn
);
// 500 : x pos of button; 50: y pos of button.
btn
->
SetPosition
(
500
,
50
,
BUTTON_WIDHT3
,
BUTTON_HEIGHT3
);
btn
->
SetText
(
"组件RGB888截屏"
);
btn
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
BUTTON_LABEL_SIZE
);
btn
->
SetOnClickListener
(
viewBitmapListener3_
);
btn
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
BUTTON_STYLE_BORDER_RADIUS_VALUE
,
UIButton
::
RELEASED
);
btn
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
BUTTON_STYLE_BORDER_RADIUS_VALUE
,
UIButton
::
PRESSED
);
btn
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
BUTTON_STYLE_BORDER_RADIUS_VALUE
,
UIButton
::
INACTIVE
);
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
RELEASED
);
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
PRESSED
);
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
INACTIVE
);
}
void
UITestViewBitmap
::
UIKitBitmapTestGetViewBitmap004
()
{
UILabelButton
*
btn
=
new
UILabelButton
();
container_
->
Add
(
btn
);
// 700 : x pos of button; 50: y pos of button.
btn
->
SetPosition
(
700
,
50
,
BUTTON_WIDHT3
,
BUTTON_HEIGHT3
);
btn
->
SetText
(
"组件RGB565截屏"
);
btn
->
SetFont
(
DEFAULT_VECTOR_FONT_FILENAME
,
BUTTON_LABEL_SIZE
);
btn
->
SetOnClickListener
(
viewBitmapListener4_
);
btn
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
BUTTON_STYLE_BORDER_RADIUS_VALUE
,
UIButton
::
RELEASED
);
btn
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
BUTTON_STYLE_BORDER_RADIUS_VALUE
,
UIButton
::
PRESSED
);
btn
->
SetStyleForState
(
STYLE_BORDER_RADIUS
,
BUTTON_STYLE_BORDER_RADIUS_VALUE
,
UIButton
::
INACTIVE
);
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
RELEASED
);
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
PRESSED
);
btn
->
SetStyleForState
(
STYLE_BACKGROUND_COLOR
,
BUTTON_STYLE_BACKGROUND_COLOR_VALUE
,
UIButton
::
INACTIVE
);
}
}
void
UITestViewBitmap
::
UIKitBitmapTestGetScreenBitmap001
()
void
UITestViewBitmap
::
UIKitBitmapTestGetScreenBitmap001
()
...
...
test/uitest/test_view_bitmap/ui_test_view_bitmap.h
浏览文件 @
885b6f72
...
@@ -32,12 +32,21 @@ public:
...
@@ -32,12 +32,21 @@ public:
void
TearDown
()
override
;
void
TearDown
()
override
;
const
UIView
*
GetTestView
()
override
;
const
UIView
*
GetTestView
()
override
;
void
UIKitBitmapTestGetViewBitmap001
();
void
UIKitBitmapTestGetViewBitmap001
();
void
UIKitBitmapTestGetViewBitmap002
();
void
UIKitBitmapTestGetViewBitmap003
();
void
UIKitBitmapTestGetViewBitmap004
();
void
UIKitBitmapTestGetScreenBitmap001
();
void
UIKitBitmapTestGetScreenBitmap001
();
private:
private:
UIScrollView
*
container_
=
nullptr
;
UIScrollView
*
container_
=
nullptr
;
UIImageView
*
viewBitmap_
=
nullptr
;
UIImageView
*
viewBitmap_
=
nullptr
;
UIImageView
*
viewBitmap2_
=
nullptr
;
UIImageView
*
viewBitmap3_
=
nullptr
;
UIImageView
*
viewBitmap4_
=
nullptr
;
UIImageView
*
screenBitmap_
=
nullptr
;
UIImageView
*
screenBitmap_
=
nullptr
;
UIView
::
OnClickListener
*
viewBitmapListener_
=
nullptr
;
UIView
::
OnClickListener
*
viewBitmapListener_
=
nullptr
;
UIView
::
OnClickListener
*
viewBitmapListener2_
=
nullptr
;
UIView
::
OnClickListener
*
viewBitmapListener3_
=
nullptr
;
UIView
::
OnClickListener
*
viewBitmapListener4_
=
nullptr
;
UIView
::
OnClickListener
*
screenBitmapListener_
=
nullptr
;
UIView
::
OnClickListener
*
screenBitmapListener_
=
nullptr
;
};
};
}
// namespace OHOS
}
// namespace OHOS
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录