Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
anbox
提交
30c21868
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,发现更多精彩内容 >>
提交
30c21868
编写于
1月 20, 2017
作者:
S
Simon Fels
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Abstract selector of translator or host GL libs a bit more
上级
d12aad5c
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
130 addition
and
57 deletion
+130
-57
external/android-emugl/host/include/OpenGLESDispatch/EGLDispatch.h
...android-emugl/host/include/OpenGLESDispatch/EGLDispatch.h
+2
-1
external/android-emugl/host/include/OpenGLESDispatch/GLESv1Dispatch.h
...roid-emugl/host/include/OpenGLESDispatch/GLESv1Dispatch.h
+2
-1
external/android-emugl/host/include/OpenGLESDispatch/GLESv2Dispatch.h
...roid-emugl/host/include/OpenGLESDispatch/GLESv2Dispatch.h
+2
-1
external/android-emugl/host/libs/libOpenGLESDispatch/EGLDispatch.cpp
...droid-emugl/host/libs/libOpenGLESDispatch/EGLDispatch.cpp
+14
-8
external/android-emugl/host/libs/libOpenGLESDispatch/GLESv1Dispatch.cpp
...id-emugl/host/libs/libOpenGLESDispatch/GLESv1Dispatch.cpp
+11
-6
external/android-emugl/host/libs/libOpenGLESDispatch/GLESv2Dispatch.cpp
...id-emugl/host/libs/libOpenGLESDispatch/GLESv2Dispatch.cpp
+11
-6
src/anbox/cli.h
src/anbox/cli.h
+1
-1
src/anbox/cmds/run.cpp
src/anbox/cmds/run.cpp
+16
-2
src/anbox/cmds/run.h
src/anbox/cmds/run.h
+3
-0
src/anbox/graphics/emugl/RenderApi.cpp
src/anbox/graphics/emugl/RenderApi.cpp
+36
-5
src/anbox/graphics/emugl/RenderApi.h
src/anbox/graphics/emugl/RenderApi.h
+13
-1
src/anbox/graphics/gl_renderer_server.cpp
src/anbox/graphics/gl_renderer_server.cpp
+13
-24
src/anbox/graphics/gl_renderer_server.h
src/anbox/graphics/gl_renderer_server.h
+6
-1
未找到文件。
external/android-emugl/host/include/OpenGLESDispatch/EGLDispatch.h
浏览文件 @
30c21868
...
...
@@ -42,12 +42,13 @@ LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(RENDER_EGL_DEFINE_TYPE)
// Define EGLDispatch structure.
struct
EGLDispatch
{
bool
initialized
=
false
;
LIST_RENDER_EGL_FUNCTIONS
(
RENDER_EGL_DECLARE_MEMBER
)
LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS
(
RENDER_EGL_DECLARE_MEMBER
)
};
// Initialize EGLDispatch function. Return true on success, false on failure.
bool
init_egl_dispatch
();
bool
init_egl_dispatch
(
const
char
*
path
);
// Global EGLDispatch instance. Call init_egl_dispatch() before using it.
extern
EGLDispatch
s_egl
;
external/android-emugl/host/include/OpenGLESDispatch/GLESv1Dispatch.h
浏览文件 @
30c21868
...
...
@@ -26,6 +26,7 @@
LIST_GLES1_FUNCTIONS
(
GLES1_DISPATCH_DEFINE_TYPE
,
GLES1_DISPATCH_DEFINE_TYPE
)
struct
GLESv1Dispatch
{
bool
initialized
=
false
;
#define GLES1_DISPATCH_DECLARE_POINTER(return_type,func_name,signature,callargs) \
func_name ## _t func_name;
LIST_GLES1_FUNCTIONS
(
GLES1_DISPATCH_DECLARE_POINTER
,
...
...
@@ -35,7 +36,7 @@ struct GLESv1Dispatch {
#undef GLES1_DISPATCH_DECLARE_POINTER
#undef GLES1_DISPATCH_DEFINE_TYPE
bool
gles1_dispatch_init
(
GLESv1Dispatch
*
dispatch_table
);
bool
gles1_dispatch_init
(
const
char
*
path
,
GLESv1Dispatch
*
dispatch_table
);
// Used to initialize the decoder.
void
*
gles1_dispatch_get_proc_func
(
const
char
*
name
,
void
*
userData
);
external/android-emugl/host/include/OpenGLESDispatch/GLESv2Dispatch.h
浏览文件 @
30c21868
...
...
@@ -26,6 +26,7 @@
LIST_GLES2_FUNCTIONS
(
GLES2_DISPATCH_DEFINE_TYPE
,
GLES2_DISPATCH_DEFINE_TYPE
)
struct
GLESv2Dispatch
{
bool
initialized
=
false
;
#define GLES2_DISPATCH_DECLARE_POINTER(return_type,func_name,signature,callargs) \
func_name ## _t func_name;
LIST_GLES2_FUNCTIONS
(
GLES2_DISPATCH_DECLARE_POINTER
,
...
...
@@ -35,7 +36,7 @@ struct GLESv2Dispatch {
#undef GLES2_DISPATCH_DECLARE_POINTER
#undef GLES2_DISPATCH_DEFINE_TYPE
bool
gles2_dispatch_init
(
GLESv2Dispatch
*
dispatch_table
);
bool
gles2_dispatch_init
(
const
char
*
path
,
GLESv2Dispatch
*
dispatch_table
);
// Used to initialize the decoder.
void
*
gles2_dispatch_get_proc_func
(
const
char
*
name
,
void
*
userData
);
external/android-emugl/host/libs/libOpenGLESDispatch/EGLDispatch.cpp
浏览文件 @
30c21868
...
...
@@ -20,9 +20,11 @@
#include <stdio.h>
#include <stdlib.h>
EGLDispatch
s_egl
;
namespace
{
constexpr
const
char
*
egl_lib_env_var
{
"ANBOX_EGL_LIB"
};
}
#define DEFAULT_EGL_LIB EMUGL_LIBNAME("EGL_translator")
EGLDispatch
s_egl
;
#define RENDER_EGL_LOAD_FIELD(return_type, function_name, signature) \
s_egl. function_name = (function_name ## _t) lib->findSymbol(#function_name);
...
...
@@ -33,20 +35,24 @@ EGLDispatch s_egl;
if (!s_egl.function_name || !s_egl.eglGetProcAddress) \
RENDER_EGL_LOAD_FIELD(return_type, function_name, signature)
bool
init_egl_dispatch
()
{
const
char
*
libName
=
getenv
(
"ANDROID_EGL_LIB"
);
if
(
!
libName
)
libName
=
DEFAULT_EGL_LIB
;
bool
init_egl_dispatch
(
const
char
*
path
)
{
const
char
*
libName
=
getenv
(
egl_lib_env_var
);
if
(
!
libName
)
libName
=
path
;
if
(
!
libName
)
return
false
;
char
error
[
256
];
emugl
::
SharedLibrary
*
lib
=
emugl
::
SharedLibrary
::
open
(
libName
,
error
,
sizeof
(
error
));
if
(
!
lib
)
{
printf
(
"Failed to open %s: [%s]
\n
"
,
libName
,
error
);
return
NULL
;
return
false
;
}
LIST_RENDER_EGL_FUNCTIONS
(
RENDER_EGL_LOAD_FIELD
)
LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS
(
RENDER_EGL_LOAD_OPTIONAL_FIELD
)
s_egl
.
initialized
=
true
;
return
true
;
}
external/android-emugl/host/libs/libOpenGLESDispatch/GLESv1Dispatch.cpp
浏览文件 @
30c21868
...
...
@@ -38,13 +38,16 @@ static void gles1_unimplemented() {
// any thread has been created - hence it should NOT be thread safe.
//
#define DEFAULT_GLES_CM_LIB EMUGL_LIBNAME("GLES_CM_translator")
namespace
{
constexpr
const
char
*
glesv1_lib_env_var
{
"ANBOX_GLESv1_LIB"
};
}
bool
gles1_dispatch_init
(
GLESv1Dispatch
*
dispatch_table
)
{
const
char
*
libName
=
getenv
(
"ANDROID_GLESv1_LIB"
);
if
(
!
libName
)
{
libName
=
DEFAULT_GLES_CM_LIB
;
}
bool
gles1_dispatch_init
(
const
char
*
path
,
GLESv1Dispatch
*
dispatch_table
)
{
const
char
*
libName
=
getenv
(
glesv1_lib_env_var
);
if
(
!
libName
)
libName
=
path
;
if
(
!
libName
)
return
false
;
char
error
[
256
];
s_gles1_lib
=
emugl
::
SharedLibrary
::
open
(
libName
,
error
,
sizeof
(
error
));
...
...
@@ -67,6 +70,8 @@ bool gles1_dispatch_init(GLESv1Dispatch* dispatch_table) {
LIST_GLES1_FUNCTIONS
(
LOOKUP_SYMBOL
,
LOOKUP_EXT_SYMBOL
)
dispatch_table
->
initialized
=
true
;
return
true
;
}
...
...
external/android-emugl/host/libs/libOpenGLESDispatch/GLESv2Dispatch.cpp
浏览文件 @
30c21868
...
...
@@ -25,7 +25,9 @@ extern EGLDispatch s_egl;
static
emugl
::
SharedLibrary
*
s_gles2_lib
=
NULL
;
#define DEFAULT_GLES_V2_LIB EMUGL_LIBNAME("GLES_V2_translator")
namespace
{
constexpr
const
char
*
glesv2_lib_env_var
{
"ANDROID_GLESv2_LIB"
};
}
// An unimplemented function which prints out an error message.
// To make it consistent with the guest, all GLES2 functions not supported by
...
...
@@ -39,12 +41,13 @@ static void gles2_unimplemented() {
// This function is called only once during initialiation before
// any thread has been created - hence it should NOT be thread safe.
//
bool
gles2_dispatch_init
(
GLESv2Dispatch
*
dispatch_table
)
bool
gles2_dispatch_init
(
const
char
*
path
,
GLESv2Dispatch
*
dispatch_table
)
{
const
char
*
libName
=
getenv
(
"ANDROID_GLESv2_LIB"
);
if
(
!
libName
)
{
libName
=
DEFAULT_GLES_V2_LIB
;
}
const
char
*
libName
=
getenv
(
glesv2_lib_env_var
);
if
(
!
libName
)
libName
=
path
;
if
(
!
libName
)
return
false
;
char
error
[
256
];
s_gles2_lib
=
emugl
::
SharedLibrary
::
open
(
libName
,
error
,
sizeof
(
error
));
...
...
@@ -67,6 +70,8 @@ bool gles2_dispatch_init(GLESv2Dispatch* dispatch_table)
LIST_GLES2_FUNCTIONS
(
LOOKUP_SYMBOL
,
LOOKUP_EXT_SYMBOL
)
dispatch_table
->
initialized
=
true
;
return
true
;
}
...
...
src/anbox/cli.h
浏览文件 @
30c21868
...
...
@@ -71,7 +71,7 @@ std::ostream& operator<<(std::ostream& out,
// We are imposing size constraints to ensure a consistent CLI layout.
typedef
SizeConstrainedString
<
20
>
Name
;
typedef
SizeConstrainedString
<
60
>
Usage
;
typedef
SizeConstrainedString
<
6
0
>
Description
;
typedef
SizeConstrainedString
<
8
0
>
Description
;
/// @brief Flag models an input parameter to a command.
class
Flag
:
public
DoNotCopyOrMove
{
...
...
src/anbox/cmds/run.cpp
浏览文件 @
30c21868
...
...
@@ -63,6 +63,17 @@ class NullConnectionCreator : public anbox::network::ConnectionCreator<
socket
->
close
();
}
};
std
::
istream
&
operator
>>
(
std
::
istream
&
in
,
anbox
::
graphics
::
GLRendererServer
::
Config
::
Driver
&
driver
)
{
std
::
string
str
(
std
::
istreambuf_iterator
<
char
>
(
in
),
{});
if
(
str
.
empty
()
||
str
==
"translator"
)
driver
=
anbox
::
graphics
::
GLRendererServer
::
Config
::
Driver
::
Translator
;
else
if
(
str
==
"host"
)
driver
=
anbox
::
graphics
::
GLRendererServer
::
Config
::
Driver
::
Host
;
else
BOOST_THROW_EXCEPTION
(
std
::
runtime_error
(
"Invalid GLES driver value provided"
));
return
in
;
}
}
anbox
::
cmds
::
Run
::
BusFactory
anbox
::
cmds
::
Run
::
session_bus_factory
()
{
...
...
@@ -81,6 +92,9 @@ anbox::cmds::Run::Run(const BusFactory &bus_factory)
flag
(
cli
::
make_flag
(
cli
::
Name
{
"desktop_file_hint"
},
cli
::
Description
{
"Desktop file hint for QtMir/Unity8"
},
desktop_file_hint_
));
flag
(
cli
::
make_flag
(
cli
::
Name
{
"gles-driver"
},
cli
::
Description
{
"Which GLES driver to use. Possible values are 'host' or'translator'"
},
gles_driver_
));
action
([
this
](
const
cli
::
Command
::
Context
&
)
{
auto
trap
=
core
::
posix
::
trap_signals_for_process
(
...
...
@@ -119,8 +133,8 @@ anbox::cmds::Run::Run(const BusFactory &bus_factory)
xdg
::
data
().
home
()
/
"applications"
/
"anbox"
,
xdg
::
data
().
home
()
/
"anbox"
/
"icons"
);
auto
gl_server
=
std
::
make_shared
<
graphics
::
GLRendererServer
>
(
window_manager
);
auto
gl_server
=
std
::
make_shared
<
graphics
::
GLRendererServer
>
(
graphics
::
GLRendererServer
::
Config
{
gles_driver_
},
window_manager
);
policy
->
set_renderer
(
gl_server
->
renderer
());
...
...
src/anbox/cmds/run.h
浏览文件 @
30c21868
...
...
@@ -26,6 +26,8 @@
#include <core/dbus/bus.h>
#include "anbox/graphics/gl_renderer_server.h"
namespace
anbox
{
namespace
cmds
{
class
Run
:
public
cli
::
CommandWithFlagsAndAction
{
...
...
@@ -39,6 +41,7 @@ class Run : public cli::CommandWithFlagsAndAction {
private:
BusFactory
bus_factory_
;
std
::
string
desktop_file_hint_
;
graphics
::
GLRendererServer
::
Config
::
Driver
gles_driver_
;
};
}
// namespace cmds
}
// namespace anbox
...
...
src/anbox/graphics/emugl/RenderApi.cpp
浏览文件 @
30c21868
...
...
@@ -30,19 +30,50 @@
GLESv2Dispatch
s_gles2
;
GLESv1Dispatch
s_gles1
;
namespace
{
constexpr
const
char
*
default_egl_lib
{
"libEGL.so.1"
};
constexpr
const
char
*
default_glesv1_lib
{
"libGLESv1_CM.so.1"
};
constexpr
const
char
*
default_glesv2_lib
{
"libGLESv2.so.2"
};
}
namespace
anbox
{
namespace
graphics
{
namespace
emugl
{
bool
initialize
(
emugl_logger_struct
log_funcs
,
emugl_crash_func_t
crash_func
)
{
std
::
vector
<
GLLibrary
>
default_gl_libraries
()
{
return
std
::
vector
<
GLLibrary
>
{
{
GLLibrary
::
Type
::
EGL
,
default_egl_lib
},
{
GLLibrary
::
Type
::
GLESv1
,
default_glesv1_lib
},
{
GLLibrary
::
Type
::
GLESv2
,
default_glesv2_lib
},
};
}
bool
initialize
(
const
std
::
vector
<
GLLibrary
>
&
libs
,
emugl_logger_struct
log_funcs
,
emugl_crash_func_t
crash_func
)
{
set_emugl_crash_reporter
(
crash_func
);
set_emugl_logger
(
log_funcs
.
coarse
);
set_emugl_cxt_logger
(
log_funcs
.
fine
);
if
(
!
init_egl_dispatch
())
return
false
;
if
(
!
gles1_dispatch_init
(
&
s_gles1
))
return
false
;
for
(
const
auto
&
lib
:
libs
)
{
const
auto
path
=
lib
.
path
.
c_str
();
switch
(
lib
.
type
)
{
case
GLLibrary
::
Type
::
EGL
:
if
(
!
init_egl_dispatch
(
path
))
return
false
;
break
;
case
GLLibrary
::
Type
::
GLESv1
:
if
(
!
gles1_dispatch_init
(
path
,
&
s_gles1
))
return
false
;
break
;
case
GLLibrary
::
Type
::
GLESv2
:
if
(
!
gles2_dispatch_init
(
path
,
&
s_gles2
))
return
false
;
break
;
default:
break
;
}
}
if
(
!
gles2_dispatch_init
(
&
s_gles2
))
return
false
;
if
(
!
s_egl
.
initialized
||
!
s_gles1
.
initialized
||
!
s_gles2
.
initialized
)
return
false
;
return
true
;
}
...
...
src/anbox/graphics/emugl/RenderApi.h
浏览文件 @
30c21868
...
...
@@ -17,6 +17,10 @@
#ifndef RENDER_API_H
#define RENDER_API_H
#include <string>
#include <boost/filesystem/path.hpp>
typedef
void
(
*
emugl_logger_func_t
)(
const
char
*
fmt
,
...);
typedef
void
(
*
emugl_crash_func_t
)(
const
char
*
format
,
...);
...
...
@@ -28,7 +32,15 @@ typedef struct {
namespace
anbox
{
namespace
graphics
{
namespace
emugl
{
bool
initialize
(
emugl_logger_struct
log_funcs
,
emugl_crash_func_t
crash_func
);
struct
GLLibrary
{
enum
class
Type
{
EGL
,
GLESv1
,
GLESv2
};
Type
type
;
boost
::
filesystem
::
path
path
;
};
std
::
vector
<
GLLibrary
>
default_gl_libraries
();
bool
initialize
(
const
std
::
vector
<
GLLibrary
>
&
libs
,
emugl_logger_struct
log_funcs
,
emugl_crash_func_t
crash_func
);
}
// namespace emugl
}
// namespace graphics
}
// namespace anbox
...
...
src/anbox/graphics/gl_renderer_server.cpp
浏览文件 @
30c21868
...
...
@@ -24,6 +24,7 @@
#include "anbox/wm/manager.h"
#include <boost/throw_exception.hpp>
#include <boost/filesystem.hpp>
#include <cstdarg>
#include <stdexcept>
...
...
@@ -42,39 +43,27 @@ void logger_write(const char *format, ...) {
namespace
anbox
{
namespace
graphics
{
GLRendererServer
::
GLRendererServer
(
const
std
::
shared_ptr
<
wm
::
Manager
>
&
wm
)
GLRendererServer
::
GLRendererServer
(
const
Config
&
config
,
const
std
::
shared_ptr
<
wm
::
Manager
>
&
wm
)
:
renderer_
(
std
::
make_shared
<::
Renderer
>
()),
wm_
(
wm
),
composer_
(
std
::
make_shared
<
LayerComposer
>
(
renderer_
,
wm
))
{
if
(
utils
::
is_env_set
(
"USE_HOST_GLES"
))
{
// Force the host EGL/GLES libraries as translator implementation
::
setenv
(
"ANDROID_EGL_LIB"
,
"libEGL.so.1"
,
0
);
::
setenv
(
"ANDROID_GLESv1_LIB"
,
"libGLESv2.so.2"
,
0
);
::
setenv
(
"ANDROID_GLESv2_LIB"
,
"libGLESv2.so.2"
,
0
);
}
else
{
auto
translator_dir
=
utils
::
prefix_dir_from_env
(
TRANSLATOR_INSTALL_DIR
,
"SNAP"
);
::
setenv
(
"ANDROID_EGL_LIB"
,
utils
::
string_format
(
"%s/libEGL_translator.so"
,
translator_dir
).
c_str
(),
0
);
::
setenv
(
"ANDROID_GLESv1_LIB"
,
utils
::
string_format
(
"%s/libGLES_CM_translator.so"
,
translator_dir
)
.
c_str
(),
0
);
::
setenv
(
"ANDROID_GLESv2_LIB"
,
utils
::
string_format
(
"%s/libGLES_V2_translator.so"
,
translator_dir
)
.
c_str
(),
0
);
std
::
vector
<
emugl
::
GLLibrary
>
gl_libs
=
emugl
::
default_gl_libraries
();
if
(
config
.
driver
==
Config
::
Driver
::
Translator
)
{
DEBUG
(
"Using GLES-to-GL translator for rendering"
);
boost
::
filesystem
::
path
translator_dir
=
utils
::
prefix_dir_from_env
(
TRANSLATOR_INSTALL_DIR
,
"SNAP"
);
gl_libs
.
push_back
(
emugl
::
GLLibrary
{
emugl
::
GLLibrary
::
Type
::
EGL
,
(
translator_dir
/
"libEGL_translator.so"
)});
gl_libs
.
push_back
(
emugl
::
GLLibrary
{
emugl
::
GLLibrary
::
Type
::
GLESv1
,
(
translator_dir
/
"libGLES_CM_translator.so"
)});
gl_libs
.
push_back
(
emugl
::
GLLibrary
{
emugl
::
GLLibrary
::
Type
::
GLESv2
,
(
translator_dir
/
"libGLES_V2_translator.so"
)});
}
emugl_logger_struct
log_funcs
;
log_funcs
.
coarse
=
logger_write
;
log_funcs
.
fine
=
logger_write
;
if
(
!
emugl
::
initialize
(
log_funcs
,
nullptr
))
BOOST_THROW_EXCEPTION
(
std
::
runtime_error
(
"Failed to initialize OpenGL renderer"
));
if
(
!
emugl
::
initialize
(
gl_libs
,
log_funcs
,
nullptr
))
BOOST_THROW_EXCEPTION
(
std
::
runtime_error
(
"Failed to initialize OpenGL renderer"
));
renderer_
->
initialize
(
0
);
...
...
src/anbox/graphics/gl_renderer_server.h
浏览文件 @
30c21868
...
...
@@ -34,7 +34,12 @@ namespace graphics {
class
LayerComposer
;
class
GLRendererServer
{
public:
GLRendererServer
(
const
std
::
shared_ptr
<
wm
::
Manager
>
&
wm
);
struct
Config
{
enum
class
Driver
{
Translator
,
Host
};
Driver
driver
;
};
GLRendererServer
(
const
Config
&
config
,
const
std
::
shared_ptr
<
wm
::
Manager
>
&
wm
);
~
GLRendererServer
();
std
::
shared_ptr
<
Renderer
>
renderer
()
const
{
return
renderer_
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录