Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
anbox
提交
f2d2a41b
A
anbox
项目概览
openeuler
/
anbox
通知
24
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
anbox
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f2d2a41b
编写于
9月 04, 2016
作者:
S
Simon Fels
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add initial hwcomposer implementation
上级
cda160b3
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
280 addition
and
5 deletion
+280
-5
Android.mk
Android.mk
+10
-0
android/CMakeLists.txt
android/CMakeLists.txt
+13
-5
android/hwcomposer/hwcomposer.cpp
android/hwcomposer/hwcomposer.cpp
+257
-0
未找到文件。
Android.mk
浏览文件 @
f2d2a41b
...
@@ -74,3 +74,13 @@ LOCAL_SHARED_LIBRARIES := \
...
@@ -74,3 +74,13 @@ LOCAL_SHARED_LIBRARIES := \
libcutils
\
libcutils
\
libutils
libutils
include
$(BUILD_EXECUTABLE)
include
$(BUILD_EXECUTABLE)
include
$(CLEAR_VARS)
LOCAL_MODULE_RELATIVE_PATH
:=
hw
LOCAL_SHARED_LIBRARIES
:=
liblog
LOCAL_SRC_FILES
:=
\
android/hwcomposer/hwcomposer.cpp
LOCAL_MODULE
:=
hwcomposer.anbox
LOCAL_CFLAGS
:=
-DLOG_TAG
=
\"
hwcomposer
\"
LOCAL_MODULE_TAGS
:=
optional
include
$(BUILD_SHARED_LIBRARY)
android/CMakeLists.txt
浏览文件 @
f2d2a41b
...
@@ -22,18 +22,26 @@ target_link_libraries(anboxd
...
@@ -22,18 +22,26 @@ target_link_libraries(anboxd
pthread
pthread
process-cpp
process-cpp
anbox-protobuf
)
anbox-protobuf
)
# As we're adding Android specific bits in this project we can't
# build this safely within default build anymore. We keep this
# for easy integration into used IDEs.
set_target_properties
(
anboxd
PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1
)
set
(
TEST_PLATFORM_SERVICE
set
(
TEST_PLATFORM_SERVICE
service/test_platform_service.cpp
)
service/test_platform_service.cpp
)
add_executable
(
test_platform_service
${
TEST_PLATFORM_SERVICE
}
)
add_executable
(
test_platform_service
${
TEST_PLATFORM_SERVICE
}
)
set
(
HWCOMPOSER_SOURCES
hwcomposer/hwcomposer.cpp
)
add_library
(
hwcomposer.anbox SHARED
${
HWCOMPOSER_SOURCES
}
)
# As we're adding Android specific bits in this project we can't
# As we're adding Android specific bits in this project we can't
# build this safely within default build anymore. We keep this
# build this safely within default build anymore. We keep this
# for easy integration into used IDEs.
# for easy integration into used IDEs.
set_target_properties
(
anboxd
PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1
)
set_target_properties
(
test_platform_service
set_target_properties
(
test_platform_service
PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1
)
PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1
)
set_target_properties
(
hwcomposer.anbox
PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1
)
android/hwcomposer/hwcomposer.cpp
0 → 100644
浏览文件 @
f2d2a41b
/*
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <hardware/hardware.h>
#include <hardware/hwcomposer.h>
#define LOG_NDEBUG 0
#include <cutils/log.h>
struct
HwcContext
{
hwc_composer_device_1_t
device
;
// These 3 variables could be reduced to first_overlay only, however it makes
// the conditions in the code more complicated. In order to keep things as
// simple as possible, there are 3 major ways to display a frame.
// 1. Show only the framebuffer.
// 2. Show the framebuffer with some overlays above it.
// 3. Show all overlays and hide the framebuffer.
//
// Since the framebuffer has no alpha channel and is opaque, it can only ever
// be the rearmost layer that we end up putting on screen, otherwise it will
// cover up all layers behind it, since its display frame is the whole window.
//
// Without framebuffer_visible, the condition of whether to display the
// frambuffer becomes more complex and possibly if (numHwLayers == 0 ||
// hwLayers[0]->compositionType != HWC_OVERLAY) but that might not be correct.
//
// The range [first_overlay, first_overlay+num_overlay) is a natural way to
// structure the loop and prevents requiring state and iterating through all
// the non-OVERLAY layers in hwc_set.
bool
framebuffer_visible
;
size_t
first_overlay
;
size_t
num_overlays
;
};
static
void
dump_layer
(
hwc_layer_1_t
const
*
l
)
{
ALOGI
(
"
\t
type=%d, flags=%08x, handle=%p, tr=%02x, blend=%04x, {%d,%d,%d,%d}, {%d,%d,%d,%d}"
,
l
->
compositionType
,
l
->
flags
,
l
->
handle
,
l
->
transform
,
l
->
blending
,
l
->
sourceCrop
.
left
,
l
->
sourceCrop
.
top
,
l
->
sourceCrop
.
right
,
l
->
sourceCrop
.
bottom
,
l
->
displayFrame
.
left
,
l
->
displayFrame
.
top
,
l
->
displayFrame
.
right
,
l
->
displayFrame
.
bottom
);
}
static
int
hwc_prepare
(
hwc_composer_device_1_t
*
dev
,
size_t
numDisplays
,
hwc_display_contents_1_t
**
displays
)
{
auto
context
=
reinterpret_cast
<
HwcContext
*>
(
dev
);
ALOGI
(
"%s"
,
__PRETTY_FUNCTION__
);
if
(
displays
==
NULL
||
displays
[
0
]
==
NULL
)
return
-
EINVAL
;
// Anbox only supports the primary display.
if
(
displays
[
0
]
->
flags
&
HWC_GEOMETRY_CHANGED
)
{
const
size_t
&
num_hw_layers
=
displays
[
0
]
->
numHwLayers
;
size_t
i
=
1
;
bool
visible
=
(
num_hw_layers
==
1
);
// Iterate backwards and skip the first (end) layer, which is the
// framebuffer target layer. According to the SurfaceFlinger folks, the
// actual location of this layer is up to the HWC implementation to
// decide, but is in the well know last slot of the list. This does not
// imply that the framebuffer target layer must be topmost.
for
(;
i
<
num_hw_layers
;
i
++
)
{
hwc_layer_1_t
*
layer
=
&
displays
[
0
]
->
hwLayers
[
num_hw_layers
-
1
-
i
];
if
(
layer
->
flags
&
HWC_SKIP_LAYER
)
{
// All layers below and including this one will be drawn into the
// framebuffer. Stop marking further layers as HWC_OVERLAY.
visible
=
true
;
break
;
}
switch
(
layer
->
compositionType
)
{
case
HWC_OVERLAY
:
case
HWC_FRAMEBUFFER
:
layer
->
compositionType
=
HWC_OVERLAY
;
break
;
case
HWC_BACKGROUND
:
break
;
default:
ALOGE
(
"hwcomposor: Invalid compositionType %d"
,
layer
->
compositionType
);
break
;
}
}
context
->
first_overlay
=
num_hw_layers
-
i
;
context
->
num_overlays
=
i
-
1
;
context
->
framebuffer_visible
=
visible
;
}
return
0
;
}
static
int
hwc_set
(
hwc_composer_device_1_t
*
dev
,
size_t
numDisplays
,
hwc_display_contents_1_t
**
displays
)
{
auto
context
=
reinterpret_cast
<
HwcContext
*>
(
dev
);
ALOGI
(
"%s"
,
__PRETTY_FUNCTION__
);
if
(
displays
==
NULL
||
displays
[
0
]
==
NULL
)
return
-
EFAULT
;
// FIXME Here is the point where we have to collect all layers and sent
// them over to the Anbox rendering process
for
(
size_t
i
=
0
;
i
<
displays
[
0
]
->
numHwLayers
;
i
++
)
dump_layer
(
&
displays
[
0
]
->
hwLayers
[
i
]);
displays
[
0
]
->
retireFenceFd
=
-
1
;
return
0
;
}
static
int
hwc_event_control
(
hwc_composer_device_1
*
dev
,
int
disp
,
int
event
,
int
enabled
)
{
ALOGI
(
"%s"
,
__PRETTY_FUNCTION__
);
return
-
EFAULT
;
}
static
int
hwc_get_display_configs
(
hwc_composer_device_1
*
dev
,
int
disp
,
uint32_t
*
configs
,
size_t
*
numConfigs
)
{
ALOGI
(
"%s"
,
__PRETTY_FUNCTION__
);
if
(
disp
!=
0
)
return
-
EINVAL
;
if
(
*
numConfigs
>
0
)
{
// Config[0] will be passed in to getDisplayAttributes as the disp
// parameter. The ARC display supports only 1 configuration.
configs
[
0
]
=
0
;
*
numConfigs
=
1
;
}
return
0
;
}
static
int
hwc_get_display_attributes
(
hwc_composer_device_1
*
dev
,
int
disp
,
uint32_t
config
,
const
uint32_t
*
attributes
,
int32_t
*
values
)
{
ALOGI
(
"%s"
,
__PRETTY_FUNCTION__
);
if
(
disp
!=
0
||
config
!=
0
)
return
-
EINVAL
;
auto
context
=
reinterpret_cast
<
HwcContext
*>
(
dev
);
while
(
*
attributes
!=
HWC_DISPLAY_NO_ATTRIBUTE
)
{
switch
(
*
attributes
)
{
case
HWC_DISPLAY_VSYNC_PERIOD
:
*
values
=
1
;
break
;
case
HWC_DISPLAY_WIDTH
:
*
values
=
1280
;
break
;
case
HWC_DISPLAY_HEIGHT
:
*
values
=
720
;
break
;
case
HWC_DISPLAY_DPI_X
:
*
values
=
1000
*
120
;
break
;
case
HWC_DISPLAY_DPI_Y
:
*
values
=
1000
*
120
;
break
;
default:
ALOGE
(
"Unknown attribute value 0x%02x"
,
*
attributes
);
}
++
attributes
;
++
values
;
}
return
0
;
}
static
void
hwc_register_procs
(
hwc_composer_device_1
*
dev
,
hwc_procs_t
const
*
procs
)
{
ALOGI
(
"%s"
,
__PRETTY_FUNCTION__
);
}
static
int
hwc_blank
(
hwc_composer_device_1
*
dev
,
int
disp
,
int
blank
)
{
ALOGI
(
"%s"
,
__PRETTY_FUNCTION__
);
return
0
;
}
static
int
hwc_query
(
hwc_composer_device_1
*
dev
,
int
what
,
int
*
value
)
{
ALOGI
(
"%s"
,
__PRETTY_FUNCTION__
);
return
0
;
}
static
int
hwc_device_close
(
hw_device_t
*
dev
)
{
ALOGI
(
"%s"
,
__PRETTY_FUNCTION__
);
auto
context
=
reinterpret_cast
<
HwcContext
*>
(
dev
);
delete
context
;
return
0
;
}
static
int
hwc_device_open
(
const
hw_module_t
*
module
,
const
char
*
name
,
hw_device_t
**
device
)
{
ALOGI
(
"%s"
,
__PRETTY_FUNCTION__
);
if
(
strcmp
(
name
,
HWC_HARDWARE_COMPOSER
)
!=
0
)
return
-
EINVAL
;
auto
dev
=
new
HwcContext
;
dev
->
device
.
common
.
tag
=
HARDWARE_DEVICE_TAG
;
dev
->
device
.
common
.
version
=
HWC_DEVICE_API_VERSION_1_3
;
dev
->
device
.
common
.
module
=
const_cast
<
hw_module_t
*>
(
module
);
dev
->
device
.
common
.
close
=
hwc_device_close
;
dev
->
device
.
prepare
=
hwc_prepare
;
dev
->
device
.
set
=
hwc_set
;
dev
->
device
.
eventControl
=
hwc_event_control
;
dev
->
device
.
blank
=
hwc_blank
;
dev
->
device
.
query
=
hwc_query
;
dev
->
device
.
getDisplayConfigs
=
hwc_get_display_configs
;
dev
->
device
.
getDisplayAttributes
=
hwc_get_display_attributes
;
dev
->
device
.
registerProcs
=
hwc_register_procs
;
*
device
=
&
dev
->
device
.
common
;
return
0
;
}
static
hw_module_methods_t
hwc_module_methods
=
{
.
open
=
hwc_device_open
};
hwc_module_t
HAL_MODULE_INFO_SYM
=
{
.
common
=
{
.
tag
=
HARDWARE_MODULE_TAG
,
.
version_major
=
1
,
.
version_minor
=
0
,
.
id
=
HWC_HARDWARE_MODULE_ID
,
.
name
=
"Hardware Composer Module"
,
.
author
=
"Anbox Developers"
,
.
methods
=
&
hwc_module_methods
,
}
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录