Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
anbox
提交
a2294b22
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,发现更多精彩内容 >>
提交
a2294b22
编写于
1月 31, 2017
作者:
S
Simon Fels
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use a surfaceless EGL context if possible instead of a dummy pbuffer
上级
5be5550d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
77 addition
and
16 deletion
+77
-16
src/CMakeLists.txt
src/CMakeLists.txt
+1
-0
src/anbox/graphics/emugl/Renderer.cpp
src/anbox/graphics/emugl/Renderer.cpp
+24
-16
src/anbox/graphics/gl_extensions.h
src/anbox/graphics/gl_extensions.h
+52
-0
未找到文件。
src/CMakeLists.txt
浏览文件 @
a2294b22
...
...
@@ -125,6 +125,7 @@ set(SOURCES
anbox/graphics/program_family.cpp
anbox/graphics/primitives.h
anbox/graphics/renderer.h
anbox/graphics/gl_extensions.h
anbox/graphics/emugl/ColorBuffer.cpp
anbox/graphics/emugl/DisplayManager.cpp
...
...
src/anbox/graphics/emugl/Renderer.cpp
浏览文件 @
a2294b22
...
...
@@ -23,6 +23,8 @@
#include "OpenGLESDispatch/EGLDispatch.h"
#include "anbox/graphics/gl_extensions.h"
#include "anbox/logger.h"
#include <stdio.h>
...
...
@@ -78,7 +80,6 @@ class ColorBufferHelper : public ColorBuffer::Helper {
private:
Renderer
*
mFb
;
};
}
// namespace
HandleType
Renderer
::
s_nextHandle
=
0
;
...
...
@@ -105,11 +106,9 @@ static char *getGLES1ExtensionString(EGLDisplay p_dpy) {
return
NULL
;
}
static
const
GLint
gles1ContextAttribs
[]
=
{
EGL_CONTEXT_CLIENT_VERSION
,
1
,
EGL_NONE
};
static
const
GLint
gles1ContextAttribs
[]
=
{
EGL_CONTEXT_CLIENT_VERSION
,
1
,
EGL_NONE
};
EGLContext
ctx
=
s_egl
.
eglCreateContext
(
p_dpy
,
config
,
EGL_NO_CONTEXT
,
gles1ContextAttribs
);
EGLContext
ctx
=
s_egl
.
eglCreateContext
(
p_dpy
,
config
,
EGL_NO_CONTEXT
,
gles1ContextAttribs
);
if
(
ctx
==
EGL_NO_CONTEXT
)
{
ERROR
(
"%s: Could not create GLES 1.x Context!"
,
__FUNCTION__
);
s_egl
.
eglDestroySurface
(
p_dpy
,
surface
);
...
...
@@ -156,6 +155,12 @@ bool Renderer::initialize(EGLNativeDisplayType nativeDisplay) {
return
false
;
}
anbox
::
graphics
::
GLExtensions
egl_extensions
{
s_egl
.
eglQueryString
(
m_eglDisplay
,
EGL_EXTENSIONS
)};
const
auto
surfaceless_supported
=
egl_extensions
.
support
(
"EGL_KHR_surfaceless_context"
);
if
(
!
surfaceless_supported
)
DEBUG
(
"EGL doesn't support surfaceless context"
);
s_egl
.
eglBindAPI
(
EGL_OPENGL_ES_API
);
// If GLES2 plugin was loaded - try to make GLES2 context and
...
...
@@ -201,24 +206,27 @@ bool Renderer::initialize(EGLNativeDisplayType nativeDisplay) {
// The main purpose of it is to solve a "blanking" behaviour we see on
// on Mac platform when switching binded drawable for a context however
// it is more efficient on other platforms as well.
m_pbufContext
=
s_egl
.
eglCreateContext
(
m_eglDisplay
,
m_eglConfig
,
m_eglContext
,
glContextAttribs
);
m_pbufContext
=
s_egl
.
eglCreateContext
(
m_eglDisplay
,
m_eglConfig
,
m_eglContext
,
glContextAttribs
);
if
(
m_pbufContext
==
EGL_NO_CONTEXT
)
{
ERROR
(
"Failed to create pbuffer context: error=0x%x"
,
s_egl
.
eglGetError
());
free
(
gles1Extensions
);
return
false
;
}
// Create a 1x1 pbuffer surface which will be used for binding
// the FB context. The FB output will go to a subwindow, if one exist.
static
const
EGLint
pbufAttribs
[]
=
{
EGL_WIDTH
,
1
,
EGL_HEIGHT
,
1
,
EGL_NONE
};
if
(
!
surfaceless_supported
)
{
// Create a 1x1 pbuffer surface which will be used for binding
// the FB context. The FB output will go to a subwindow, if one exist.
static
const
EGLint
pbufAttribs
[]
=
{
EGL_WIDTH
,
1
,
EGL_HEIGHT
,
1
,
EGL_NONE
};
m_pbufSurface
=
s_egl
.
eglCreatePbufferSurface
(
m_eglDisplay
,
m_eglConfig
,
pbufAttribs
);
if
(
m_pbufSurface
==
EGL_NO_SURFACE
)
{
ERROR
(
"Failed to create pbuffer surface: error=0x%x"
,
s_egl
.
eglGetError
());
free
(
gles1Extensions
);
return
false
;
m_pbufSurface
=
s_egl
.
eglCreatePbufferSurface
(
m_eglDisplay
,
m_eglConfig
,
pbufAttribs
);
if
(
m_pbufSurface
==
EGL_NO_SURFACE
)
{
ERROR
(
"Failed to create pbuffer surface: error=0x%x"
,
s_egl
.
eglGetError
());
free
(
gles1Extensions
);
return
false
;
}
}
else
{
DEBUG
(
"Using a surfaceless EGL context"
);
m_pbufSurface
=
EGL_NO_SURFACE
;
}
// Make the context current
...
...
src/anbox/graphics/gl_extensions.h
0 → 100644
浏览文件 @
a2294b22
/*
* Copyright (C) 2017 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/>.
*
*/
#ifndef ANBOX_GRAPHICS_GL_EXTENSIONS_H_
#define ANBOX_GRAPHICS_GL_EXTENSIONS_H_
#include <stdexcept>
#include <string.h>
namespace
anbox
{
namespace
graphics
{
class
GLExtensions
{
public:
GLExtensions
(
char
const
*
extensions
)
:
extensions
{
extensions
}
{
if
(
!
extensions
)
throw
std
::
runtime_error
(
"Couldn't get list of GL extensions"
);
}
bool
support
(
char
const
*
ext
)
const
{
char
const
*
ext_ptr
=
extensions
;
size_t
const
len
=
strlen
(
ext
);
while
((
ext_ptr
=
strstr
(
ext_ptr
,
ext
))
!=
nullptr
)
{
if
(
ext_ptr
[
len
]
==
' '
||
ext_ptr
[
len
]
==
'\0'
)
break
;
ext_ptr
+=
len
;
}
return
ext_ptr
!=
nullptr
;
}
char
const
*
raw
()
{
return
extensions
;
}
private:
char
const
*
extensions
;
};
}
// namespace graphics
}
// namespace anbox
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录