Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
anbox
提交
c9c3155e
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,发现更多精彩内容 >>
提交
c9c3155e
编写于
1月 20, 2017
作者:
S
Simon Fels
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
emugl: use our internal logger instead of the emugl one
上级
c199e519
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
95 addition
and
160 deletion
+95
-160
src/anbox/graphics/emugl/ColorBuffer.cpp
src/anbox/graphics/emugl/ColorBuffer.cpp
+3
-3
src/anbox/graphics/emugl/ReadBuffer.cpp
src/anbox/graphics/emugl/ReadBuffer.cpp
+3
-2
src/anbox/graphics/emugl/Renderer.cpp
src/anbox/graphics/emugl/Renderer.cpp
+61
-119
src/anbox/graphics/emugl/RendererConfig.cpp
src/anbox/graphics/emugl/RendererConfig.cpp
+5
-8
src/anbox/graphics/emugl/TextureDraw.cpp
src/anbox/graphics/emugl/TextureDraw.cpp
+10
-11
src/anbox/graphics/emugl/TextureResize.cpp
src/anbox/graphics/emugl/TextureResize.cpp
+4
-4
src/anbox/graphics/emugl/WindowSurface.cpp
src/anbox/graphics/emugl/WindowSurface.cpp
+9
-13
未找到文件。
src/anbox/graphics/emugl/ColorBuffer.cpp
浏览文件 @
c9c3155e
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
#include "OpenGLESDispatch/EGLDispatch.h"
#include "OpenGLESDispatch/EGLDispatch.h"
#include "
ErrorLog
.h"
#include "
anbox/logger
.h"
#include <stdio.h>
#include <stdio.h>
...
@@ -41,7 +41,7 @@ inline unsigned int SafeUIntFromPointer(const void* ptr) {
...
@@ -41,7 +41,7 @@ inline unsigned int SafeUIntFromPointer(const void* ptr) {
// system images, which might have buggy encoder libraries. Print
// system images, which might have buggy encoder libraries. Print
// an error message though.
// an error message though.
if
(
reinterpret_cast
<
uintptr_t
>
(
ptr
)
!=
static_cast
<
unsigned
int
>
(
reinterpret_cast
<
uintptr_t
>
(
ptr
)))
{
if
(
reinterpret_cast
<
uintptr_t
>
(
ptr
)
!=
static_cast
<
unsigned
int
>
(
reinterpret_cast
<
uintptr_t
>
(
ptr
)))
{
fprintf
(
stderr
,
"EmuGL:WARNING: bad generic pointer %p
\n
"
,
ptr
);
WARNING
(
"Bad generic pointer %p
"
,
ptr
);
}
}
#else
#else
// Assertion error if the pointer contains a value that does not fit
// Assertion error if the pointer contains a value that does not fit
...
@@ -69,7 +69,7 @@ bool bindFbo(GLuint* fbo, GLuint tex) {
...
@@ -69,7 +69,7 @@ bool bindFbo(GLuint* fbo, GLuint tex) {
GL_TEXTURE_2D
,
tex
,
0
);
GL_TEXTURE_2D
,
tex
,
0
);
GLenum
status
=
s_gles2
.
glCheckFramebufferStatus
(
GL_FRAMEBUFFER
);
GLenum
status
=
s_gles2
.
glCheckFramebufferStatus
(
GL_FRAMEBUFFER
);
if
(
status
!=
GL_FRAMEBUFFER_COMPLETE_OES
)
{
if
(
status
!=
GL_FRAMEBUFFER_COMPLETE_OES
)
{
ERR
(
"ColorBuffer::bindFbo: FBO not complete: %#x
\n
"
,
status
);
ERR
OR
(
"FBO not complete: %#x
"
,
status
);
s_gles2
.
glBindFramebuffer
(
GL_FRAMEBUFFER
,
0
);
s_gles2
.
glBindFramebuffer
(
GL_FRAMEBUFFER
,
0
);
s_gles2
.
glDeleteFramebuffers
(
1
,
fbo
);
s_gles2
.
glDeleteFramebuffers
(
1
,
fbo
);
*
fbo
=
0
;
*
fbo
=
0
;
...
...
src/anbox/graphics/emugl/ReadBuffer.cpp
浏览文件 @
c9c3155e
...
@@ -17,7 +17,8 @@
...
@@ -17,7 +17,8 @@
#include <assert.h>
#include <assert.h>
#include <limits.h>
#include <limits.h>
#include <string.h>
#include <string.h>
#include "ErrorLog.h"
#include "anbox/logger.h"
ReadBuffer
::
ReadBuffer
(
size_t
bufsize
)
{
ReadBuffer
::
ReadBuffer
(
size_t
bufsize
)
{
m_size
=
bufsize
;
m_size
=
bufsize
;
...
@@ -45,7 +46,7 @@ int ReadBuffer::getData(IOStream* stream) {
...
@@ -45,7 +46,7 @@ int ReadBuffer::getData(IOStream* stream) {
new_buf
=
static_cast
<
unsigned
char
*>
(
realloc
(
m_buf
,
new_size
));
new_buf
=
static_cast
<
unsigned
char
*>
(
realloc
(
m_buf
,
new_size
));
if
(
!
new_buf
)
{
if
(
!
new_buf
)
{
ERR
(
"Failed to alloc %zu bytes for ReadBuffer
\n
"
,
new_size
);
ERR
OR
(
"Failed to alloc %zu bytes for ReadBuffer
"
,
new_size
);
return
-
1
;
return
-
1
;
}
}
m_size
=
new_size
;
m_size
=
new_size
;
...
...
src/anbox/graphics/emugl/Renderer.cpp
浏览文件 @
c9c3155e
...
@@ -23,12 +23,8 @@
...
@@ -23,12 +23,8 @@
#include "OpenGLESDispatch/EGLDispatch.h"
#include "OpenGLESDispatch/EGLDispatch.h"
#include "emugl/common/logging.h"
#include "anbox/logger.h"
#include "anbox/logger.h"
#include "ErrorLog.h"
#include <stdio.h>
#include <stdio.h>
#include <glm/glm.hpp>
#include <glm/glm.hpp>
...
@@ -97,17 +93,15 @@ static char *getGLES1ExtensionString(EGLDisplay p_dpy) {
...
@@ -97,17 +93,15 @@ static char *getGLES1ExtensionString(EGLDisplay p_dpy) {
int
n
;
int
n
;
if
(
!
s_egl
.
eglChooseConfig
(
p_dpy
,
configAttribs
,
&
config
,
1
,
&
n
)
||
n
==
0
)
{
if
(
!
s_egl
.
eglChooseConfig
(
p_dpy
,
configAttribs
,
&
config
,
1
,
&
n
)
||
n
==
0
)
{
ERR
(
"%s: Could not find GLES 1.x config!
\n
"
,
__FUNCTION__
);
ERR
OR
(
"%s: Could not find GLES 1.x config!
"
,
__FUNCTION__
);
return
NULL
;
return
NULL
;
}
}
DBG
(
"%s: Found config %p
\n
"
,
__FUNCTION__
,
reinterpret_cast
<
void
*>
(
config
));
static
const
EGLint
pbufAttribs
[]
=
{
EGL_WIDTH
,
1
,
EGL_HEIGHT
,
1
,
EGL_NONE
};
static
const
EGLint
pbufAttribs
[]
=
{
EGL_WIDTH
,
1
,
EGL_HEIGHT
,
1
,
EGL_NONE
};
surface
=
s_egl
.
eglCreatePbufferSurface
(
p_dpy
,
config
,
pbufAttribs
);
surface
=
s_egl
.
eglCreatePbufferSurface
(
p_dpy
,
config
,
pbufAttribs
);
if
(
surface
==
EGL_NO_SURFACE
)
{
if
(
surface
==
EGL_NO_SURFACE
)
{
ERR
(
"%s: Could not create GLES 1.x Pbuffer!
\n
"
,
__FUNCTION__
);
ERR
OR
(
"%s: Could not create GLES 1.x Pbuffer!
"
,
__FUNCTION__
);
return
NULL
;
return
NULL
;
}
}
...
@@ -117,13 +111,13 @@ static char *getGLES1ExtensionString(EGLDisplay p_dpy) {
...
@@ -117,13 +111,13 @@ static char *getGLES1ExtensionString(EGLDisplay p_dpy) {
EGLContext
ctx
=
s_egl
.
eglCreateContext
(
p_dpy
,
config
,
EGL_NO_CONTEXT
,
EGLContext
ctx
=
s_egl
.
eglCreateContext
(
p_dpy
,
config
,
EGL_NO_CONTEXT
,
gles1ContextAttribs
);
gles1ContextAttribs
);
if
(
ctx
==
EGL_NO_CONTEXT
)
{
if
(
ctx
==
EGL_NO_CONTEXT
)
{
ERR
(
"%s: Could not create GLES 1.x Context!
\n
"
,
__FUNCTION__
);
ERR
OR
(
"%s: Could not create GLES 1.x Context!
"
,
__FUNCTION__
);
s_egl
.
eglDestroySurface
(
p_dpy
,
surface
);
s_egl
.
eglDestroySurface
(
p_dpy
,
surface
);
return
NULL
;
return
NULL
;
}
}
if
(
!
s_egl
.
eglMakeCurrent
(
p_dpy
,
surface
,
surface
,
ctx
))
{
if
(
!
s_egl
.
eglMakeCurrent
(
p_dpy
,
surface
,
surface
,
ctx
))
{
ERR
(
"%s: Could not make GLES 1.x context current!
\n
"
,
__FUNCTION__
);
ERR
OR
(
"%s: Could not make GLES 1.x context current!
"
,
__FUNCTION__
);
s_egl
.
eglDestroySurface
(
p_dpy
,
surface
);
s_egl
.
eglDestroySurface
(
p_dpy
,
surface
);
s_egl
.
eglDestroyContext
(
p_dpy
,
ctx
);
s_egl
.
eglDestroyContext
(
p_dpy
,
ctx
);
return
NULL
;
return
NULL
;
...
@@ -151,61 +145,41 @@ void Renderer::finalize() {
...
@@ -151,61 +145,41 @@ void Renderer::finalize() {
}
}
bool
Renderer
::
initialize
(
EGLNativeDisplayType
nativeDisplay
)
{
bool
Renderer
::
initialize
(
EGLNativeDisplayType
nativeDisplay
)
{
GL_LOG
(
"Renderer::initialize"
);
//
// Initialize backend EGL display
//
m_eglDisplay
=
s_egl
.
eglGetDisplay
(
nativeDisplay
);
m_eglDisplay
=
s_egl
.
eglGetDisplay
(
nativeDisplay
);
if
(
m_eglDisplay
==
EGL_NO_DISPLAY
)
{
if
(
m_eglDisplay
==
EGL_NO_DISPLAY
)
{
ERR
(
"Failed to Initialize backend EGL display
\n
"
);
ERR
OR
(
"Failed to Initialize backend EGL display
"
);
return
false
;
return
false
;
}
}
GL_LOG
(
"call eglInitialize"
);
if
(
!
s_egl
.
eglInitialize
(
m_eglDisplay
,
&
m_caps
.
eglMajor
,
&
m_caps
.
eglMinor
))
{
if
(
!
s_egl
.
eglInitialize
(
m_eglDisplay
,
&
m_caps
.
eglMajor
,
ERROR
(
"Failed to initialize EGL"
);
&
m_caps
.
eglMinor
))
{
ERR
(
"Failed to eglInitialize
\n
"
);
GL_LOG
(
"Failed to eglInitialize"
);
return
false
;
return
false
;
}
}
DBG
(
"egl: %d %d
\n
"
,
m_caps
.
eglMajor
,
m_caps
.
eglMinor
);
GL_LOG
(
"egl: %d %d"
,
m_caps
.
eglMajor
,
m_caps
.
eglMinor
);
s_egl
.
eglBindAPI
(
EGL_OPENGL_ES_API
);
s_egl
.
eglBindAPI
(
EGL_OPENGL_ES_API
);
//
// If GLES2 plugin was loaded - try to make GLES2 context and
// if GLES2 plugin has loaded - try to make GLES2 context and
// get GLES2 extension string
// get GLES2 extension string
//
char
*
gles1Extensions
=
NULL
;
char
*
gles1Extensions
=
NULL
;
gles1Extensions
=
getGLES1ExtensionString
(
m_eglDisplay
);
gles1Extensions
=
getGLES1ExtensionString
(
m_eglDisplay
);
if
(
!
gles1Extensions
)
{
if
(
!
gles1Extensions
)
{
// Could not create GLES2 context - drop GL2 capability
ERROR
(
"Failed to obtain GLES 2.x extensions string!"
);
ERR
(
"Failed to obtain GLES 2.x extensions string!
\n
"
);
return
false
;
return
false
;
}
}
//
// Create EGL context for framebuffer post rendering.
// Create EGL context for framebuffer post rendering.
//
GLint
surfaceType
=
EGL_WINDOW_BIT
|
EGL_PBUFFER_BIT
;
GLint
surfaceType
=
EGL_WINDOW_BIT
|
EGL_PBUFFER_BIT
;
const
GLint
configAttribs
[]
=
{
EGL_RED_SIZE
,
const
GLint
configAttribs
[]
=
{
EGL_RED_SIZE
,
1
,
1
,
EGL_GREEN_SIZE
,
1
,
EGL_GREEN_SIZE
,
EGL_BLUE_SIZE
,
1
,
1
,
EGL_SURFACE_TYPE
,
surfaceType
,
EGL_BLUE_SIZE
,
EGL_RENDERABLE_TYPE
,
EGL_OPENGL_ES2_BIT
,
1
,
EGL_SURFACE_TYPE
,
surfaceType
,
EGL_RENDERABLE_TYPE
,
EGL_OPENGL_ES2_BIT
,
EGL_NONE
};
EGL_NONE
};
int
n
;
int
n
;
if
(
!
s_egl
.
eglChooseConfig
(
m_eglDisplay
,
configAttribs
,
&
m_eglConfig
,
if
(
!
s_egl
.
eglChooseConfig
(
m_eglDisplay
,
configAttribs
,
&
m_eglConfig
,
1
,
&
n
))
{
1
,
&
n
))
{
ERR
(
"Failed on eglChooseConfig
\
n
"
);
ERR
OR
(
"Failed to select EGL configuratio
n"
);
free
(
gles1Extensions
);
free
(
gles1Extensions
);
return
false
;
return
false
;
}
}
...
@@ -213,66 +187,50 @@ bool Renderer::initialize(EGLNativeDisplayType nativeDisplay) {
...
@@ -213,66 +187,50 @@ bool Renderer::initialize(EGLNativeDisplayType nativeDisplay) {
static
const
GLint
glContextAttribs
[]
=
{
EGL_CONTEXT_CLIENT_VERSION
,
2
,
static
const
GLint
glContextAttribs
[]
=
{
EGL_CONTEXT_CLIENT_VERSION
,
2
,
EGL_NONE
};
EGL_NONE
};
GL_LOG
(
"attempting to create egl context"
);
m_eglContext
=
s_egl
.
eglCreateContext
(
m_eglDisplay
,
m_eglConfig
,
m_eglContext
=
s_egl
.
eglCreateContext
(
m_eglDisplay
,
m_eglConfig
,
EGL_NO_CONTEXT
,
glContextAttribs
);
EGL_NO_CONTEXT
,
glContextAttribs
);
if
(
m_eglContext
==
EGL_NO_CONTEXT
)
{
if
(
m_eglContext
==
EGL_NO_CONTEXT
)
{
ERR
(
"Failed to create context 0x%x
\n
"
,
s_egl
.
eglGetError
());
ERR
OR
(
"Failed to create context: error=0x%x
"
,
s_egl
.
eglGetError
());
free
(
gles1Extensions
);
free
(
gles1Extensions
);
return
false
;
return
false
;
}
}
GL_LOG
(
"attempting to create egl pbuffer context"
);
//
// Create another context which shares with the eglContext to be used
// Create another context which shares with the eglContext to be used
// when we bind the pbuffer. That prevent switching drawable binding
// when we bind the pbuffer. That prevent switching drawable binding
// back and forth on framebuffer context.
// back and forth on framebuffer context.
// The main purpose of it is to solve a "blanking" behaviour we see on
// 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
// on Mac platform when switching binded drawable for a context however
// it is more efficient on other platforms as well.
// it is more efficient on other platforms as well.
//
m_pbufContext
=
s_egl
.
eglCreateContext
(
m_pbufContext
=
s_egl
.
eglCreateContext
(
m_eglDisplay
,
m_eglConfig
,
m_eglContext
,
glContextAttribs
);
m_eglDisplay
,
m_eglConfig
,
m_eglContext
,
glContextAttribs
);
if
(
m_pbufContext
==
EGL_NO_CONTEXT
)
{
if
(
m_pbufContext
==
EGL_NO_CONTEXT
)
{
ERR
(
"Failed to create Pbuffer Context 0x%x
\n
"
,
s_egl
.
eglGetError
());
ERR
OR
(
"Failed to create pbuffer context: error=0x%x
"
,
s_egl
.
eglGetError
());
free
(
gles1Extensions
);
free
(
gles1Extensions
);
return
false
;
return
false
;
}
}
GL_LOG
(
"context creation successful"
);
// 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.
// 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
};
static
const
EGLint
pbufAttribs
[]
=
{
EGL_WIDTH
,
1
,
EGL_HEIGHT
,
1
,
EGL_NONE
};
m_pbufSurface
=
s_egl
.
eglCreatePbufferSurface
(
m_pbufSurface
=
s_egl
.
eglCreatePbufferSurface
(
m_eglDisplay
,
m_eglConfig
,
pbufAttribs
);
m_eglDisplay
,
m_eglConfig
,
pbufAttribs
);
if
(
m_pbufSurface
==
EGL_NO_SURFACE
)
{
if
(
m_pbufSurface
==
EGL_NO_SURFACE
)
{
ERR
(
"Failed to create pbuf surface for FB 0x%x
\n
"
,
s_egl
.
eglGetError
());
ERR
OR
(
"Failed to create pbuffer surface: error=0x%x
"
,
s_egl
.
eglGetError
());
free
(
gles1Extensions
);
free
(
gles1Extensions
);
return
false
;
return
false
;
}
}
GL_LOG
(
"attempting to make context current"
);
// Make the context current
// Make the context current
ScopedBind
bind
(
this
);
ScopedBind
bind
(
this
);
if
(
!
bind
.
isValid
())
{
if
(
!
bind
.
isValid
())
{
ERR
(
"Failed to make current
\n
"
);
ERR
OR
(
"Failed to make current
"
);
free
(
gles1Extensions
);
free
(
gles1Extensions
);
return
false
;
return
false
;
}
}
GL_LOG
(
"context-current successful"
);
// Initilize framebuffer capabilities
// Initilize framebuffer capabilities
bool
has_gl_oes_image
=
false
;
auto
has_gl_oes_image
=
strstr
(
gles1Extensions
,
"GL_OES_EGL_image"
)
!=
NULL
;
has_gl_oes_image
=
true
;
if
(
has_gl_oes_image
)
{
has_gl_oes_image
&=
strstr
(
gles1Extensions
,
"GL_OES_EGL_image"
)
!=
NULL
;
}
free
(
gles1Extensions
);
free
(
gles1Extensions
);
gles1Extensions
=
NULL
;
gles1Extensions
=
NULL
;
...
@@ -289,32 +247,25 @@ bool Renderer::initialize(EGLNativeDisplayType nativeDisplay) {
...
@@ -289,32 +247,25 @@ bool Renderer::initialize(EGLNativeDisplayType nativeDisplay) {
m_caps
.
has_eglimage_renderbuffer
=
false
;
m_caps
.
has_eglimage_renderbuffer
=
false
;
}
}
//
// Fail initialization if not all of the following extensions
// Fail initialization if not all of the following extensions
// exist:
// exist:
// EGL_KHR_gl_texture_2d_image
// EGL_KHR_gl_texture_2d_image
// GL_OES_EGL_IMAGE (by both GLES implementations [1 and 2])
// GL_OES_EGL_IMAGE (by both GLES implementations [1 and 2])
//
if
(
!
m_caps
.
has_eglimage_texture_2d
)
{
if
(
!
m_caps
.
has_eglimage_texture_2d
)
{
ERR
(
"Failed: Missing egl_image related extension(s)
\n
"
);
ERR
OR
(
"Failed: Missing egl_image related extension(s)
"
);
bind
.
release
();
bind
.
release
();
return
false
;
return
false
;
}
}
GL_LOG
(
"host system has enough extensions"
);
//
// Initialize set of configs
// Initialize set of configs
//
m_configs
=
new
RendererConfigList
(
m_eglDisplay
);
m_configs
=
new
RendererConfigList
(
m_eglDisplay
);
if
(
m_configs
->
empty
())
{
if
(
m_configs
->
empty
())
{
ERR
(
"Failed: Initialize set of configs
\n
"
);
ERR
OR
(
"Failed: Initialize set of configs
"
);
bind
.
release
();
bind
.
release
();
return
false
;
return
false
;
}
}
//
// Check that we have config for each GLES and GLES2
// Check that we have config for each GLES and GLES2
//
size_t
nConfigs
=
m_configs
->
size
();
size_t
nConfigs
=
m_configs
->
size
();
int
nGLConfigs
=
0
;
int
nGLConfigs
=
0
;
int
nGL2Configs
=
0
;
int
nGL2Configs
=
0
;
...
@@ -328,36 +279,28 @@ bool Renderer::initialize(EGLNativeDisplayType nativeDisplay) {
...
@@ -328,36 +279,28 @@ bool Renderer::initialize(EGLNativeDisplayType nativeDisplay) {
}
}
}
}
//
// Fail initialization if no GLES configs exist
// Fail initialization if no GLES configs exist
//
if
(
nGLConfigs
==
0
)
{
if
(
nGLConfigs
==
0
)
{
bind
.
release
();
bind
.
release
();
return
false
;
return
false
;
}
}
//
// If no GLES2 configs exist - not GLES2 capability
// If no GLES2 configs exist - not GLES2 capability
//
if
(
nGL2Configs
==
0
)
{
if
(
nGL2Configs
==
0
)
{
ERR
(
"Failed: No GLES 2.x configs found!
\n
"
);
ERR
OR
(
"Failed: No GLES 2.x configs found!
"
);
bind
.
release
();
bind
.
release
();
return
false
;
return
false
;
}
}
GL_LOG
(
"There are sufficient EGLconfigs available"
);
//
// Cache the GL strings so we don't have to think about threading or
// Cache the GL strings so we don't have to think about threading or
// current-context when asked for them.
// current-context when asked for them.
//
m_glVendor
=
reinterpret_cast
<
const
char
*>
(
s_gles2
.
glGetString
(
GL_VENDOR
));
m_glVendor
=
reinterpret_cast
<
const
char
*>
(
s_gles2
.
glGetString
(
GL_VENDOR
));
m_glRenderer
=
reinterpret_cast
<
const
char
*>
(
s_gles2
.
glGetString
(
GL_RENDERER
));
m_glRenderer
=
reinterpret_cast
<
const
char
*>
(
s_gles2
.
glGetString
(
GL_RENDERER
));
m_glVersion
=
reinterpret_cast
<
const
char
*>
(
s_gles2
.
glGetString
(
GL_VERSION
));
m_glVersion
=
reinterpret_cast
<
const
char
*>
(
s_gles2
.
glGetString
(
GL_VERSION
));
m_textureDraw
=
new
TextureDraw
(
m_eglDisplay
);
m_textureDraw
=
new
TextureDraw
(
m_eglDisplay
);
if
(
!
m_textureDraw
)
{
if
(
!
m_textureDraw
)
{
ERR
(
"Failed: creation of TextureDraw instance
\n
"
);
ERR
OR
(
"Failed: creation of TextureDraw instance
"
);
bind
.
release
();
bind
.
release
();
return
false
;
return
false
;
}
}
...
@@ -365,10 +308,9 @@ bool Renderer::initialize(EGLNativeDisplayType nativeDisplay) {
...
@@ -365,10 +308,9 @@ bool Renderer::initialize(EGLNativeDisplayType nativeDisplay) {
m_defaultProgram
=
m_family
.
add_program
(
vshader
,
defaultFShader
);
m_defaultProgram
=
m_family
.
add_program
(
vshader
,
defaultFShader
);
m_alphaProgram
=
m_family
.
add_program
(
vshader
,
alphaFShader
);
m_alphaProgram
=
m_family
.
add_program
(
vshader
,
alphaFShader
);
// release the FB context
bind
.
release
();
bind
.
release
();
GL_LOG
(
"basic EGL initialization successful
"
);
DEBUG
(
"Successfully initialized EGL
"
);
return
true
;
return
true
;
}
}
...
@@ -610,7 +552,7 @@ int Renderer::openColorBuffer(HandleType p_colorbuffer) {
...
@@ -610,7 +552,7 @@ int Renderer::openColorBuffer(HandleType p_colorbuffer) {
ColorBufferMap
::
iterator
c
(
m_colorbuffers
.
find
(
p_colorbuffer
));
ColorBufferMap
::
iterator
c
(
m_colorbuffers
.
find
(
p_colorbuffer
));
if
(
c
==
m_colorbuffers
.
end
())
{
if
(
c
==
m_colorbuffers
.
end
())
{
// bad colorbuffer handle
// bad colorbuffer handle
ERR
(
"FB: openColorBuffer cb handle %#x not found
\n
"
,
p_colorbuffer
);
ERR
OR
(
"FB: openColorBuffer cb handle %#x not found
"
,
p_colorbuffer
);
return
-
1
;
return
-
1
;
}
}
(
*
c
).
second
.
refcount
++
;
(
*
c
).
second
.
refcount
++
;
...
@@ -637,7 +579,7 @@ bool Renderer::flushWindowSurfaceColorBuffer(HandleType p_surface) {
...
@@ -637,7 +579,7 @@ bool Renderer::flushWindowSurfaceColorBuffer(HandleType p_surface) {
WindowSurfaceMap
::
iterator
w
(
m_windows
.
find
(
p_surface
));
WindowSurfaceMap
::
iterator
w
(
m_windows
.
find
(
p_surface
));
if
(
w
==
m_windows
.
end
())
{
if
(
w
==
m_windows
.
end
())
{
ERR
(
"FB::flushWindowSurfaceColorBuffer: window handle %#x not found
\n
"
,
ERR
OR
(
"FB::flushWindowSurfaceColorBuffer: window handle %#x not found
"
,
p_surface
);
p_surface
);
// bad surface handle
// bad surface handle
return
false
;
return
false
;
...
@@ -656,13 +598,13 @@ bool Renderer::setWindowSurfaceColorBuffer(HandleType p_surface,
...
@@ -656,13 +598,13 @@ bool Renderer::setWindowSurfaceColorBuffer(HandleType p_surface,
WindowSurfaceMap
::
iterator
w
(
m_windows
.
find
(
p_surface
));
WindowSurfaceMap
::
iterator
w
(
m_windows
.
find
(
p_surface
));
if
(
w
==
m_windows
.
end
())
{
if
(
w
==
m_windows
.
end
())
{
// bad surface handle
// bad surface handle
ERR
(
"%s: bad window surface handle %#x
\n
"
,
__FUNCTION__
,
p_surface
);
ERR
OR
(
"%s: bad window surface handle %#x
"
,
__FUNCTION__
,
p_surface
);
return
false
;
return
false
;
}
}
ColorBufferMap
::
iterator
c
(
m_colorbuffers
.
find
(
p_colorbuffer
));
ColorBufferMap
::
iterator
c
(
m_colorbuffers
.
find
(
p_colorbuffer
));
if
(
c
==
m_colorbuffers
.
end
())
{
if
(
c
==
m_colorbuffers
.
end
())
{
D
BG
(
"%s: bad color buffer handle %#x
\n
"
,
__FUNCTION__
,
p_colorbuffer
);
D
EBUG
(
"%s: bad color buffer handle %#x
"
,
__FUNCTION__
,
p_colorbuffer
);
// bad colorbuffer handle
// bad colorbuffer handle
return
false
;
return
false
;
}
}
...
@@ -767,7 +709,7 @@ bool Renderer::bindContext(HandleType p_context, HandleType p_drawSurface,
...
@@ -767,7 +709,7 @@ bool Renderer::bindContext(HandleType p_context, HandleType p_drawSurface,
draw
?
draw
->
getEGLSurface
()
:
EGL_NO_SURFACE
,
draw
?
draw
->
getEGLSurface
()
:
EGL_NO_SURFACE
,
read
?
read
->
getEGLSurface
()
:
EGL_NO_SURFACE
,
read
?
read
->
getEGLSurface
()
:
EGL_NO_SURFACE
,
ctx
?
ctx
->
getEGLContext
()
:
EGL_NO_CONTEXT
))
{
ctx
?
ctx
->
getEGLContext
()
:
EGL_NO_CONTEXT
))
{
ERR
(
"eglMakeCurrent failed
\n
"
);
ERR
OR
(
"eglMakeCurrent failed
"
);
return
false
;
return
false
;
}
}
...
@@ -849,7 +791,7 @@ bool Renderer::bind_locked() {
...
@@ -849,7 +791,7 @@ bool Renderer::bind_locked() {
if
(
!
s_egl
.
eglMakeCurrent
(
m_eglDisplay
,
m_pbufSurface
,
m_pbufSurface
,
if
(
!
s_egl
.
eglMakeCurrent
(
m_eglDisplay
,
m_pbufSurface
,
m_pbufSurface
,
m_pbufContext
))
{
m_pbufContext
))
{
ERR
(
"eglMakeCurrent failed
\n
"
);
ERR
OR
(
"eglMakeCurrent failed
"
);
return
false
;
return
false
;
}
}
...
@@ -866,7 +808,7 @@ bool Renderer::bindWindow_locked(RendererWindow *window) {
...
@@ -866,7 +808,7 @@ bool Renderer::bindWindow_locked(RendererWindow *window) {
if
(
!
s_egl
.
eglMakeCurrent
(
m_eglDisplay
,
window
->
surface
,
window
->
surface
,
if
(
!
s_egl
.
eglMakeCurrent
(
m_eglDisplay
,
window
->
surface
,
window
->
surface
,
m_eglContext
))
{
m_eglContext
))
{
ERR
(
"eglMakeCurrent failed
\n
"
);
ERR
OR
(
"eglMakeCurrent failed
"
);
return
false
;
return
false
;
}
}
...
@@ -889,38 +831,38 @@ bool Renderer::unbind_locked() {
...
@@ -889,38 +831,38 @@ bool Renderer::unbind_locked() {
}
}
const
GLchar
*
const
Renderer
::
vshader
=
{
const
GLchar
*
const
Renderer
::
vshader
=
{
"attribute vec3 position;
\n
"
"attribute vec3 position;"
"attribute vec2 texcoord;
\n
"
"attribute vec2 texcoord;"
"uniform mat4 screen_to_gl_coords;
\n
"
"uniform mat4 screen_to_gl_coords;"
"uniform mat4 display_transform;
\n
"
"uniform mat4 display_transform;"
"uniform mat4 transform;
\n
"
"uniform mat4 transform;"
"uniform vec2 center;
\n
"
"uniform vec2 center;"
"varying vec2 v_texcoord;
\n
"
"varying vec2 v_texcoord;"
"void main() {
\n
"
"void main() {"
" vec4 mid = vec4(center, 0.0, 0.0);
\n
"
" vec4 mid = vec4(center, 0.0, 0.0);"
" vec4 transformed = (transform * (vec4(position, 1.0) - mid)) + mid;
\n
"
" vec4 transformed = (transform * (vec4(position, 1.0) - mid)) + mid;"
" gl_Position = display_transform * screen_to_gl_coords * transformed;
\n
"
" gl_Position = display_transform * screen_to_gl_coords * transformed;"
" v_texcoord = texcoord;
\n
"
" v_texcoord = texcoord;"
"}
\n
"
};
"}"
};
const
GLchar
*
const
Renderer
::
alphaFShader
=
{
const
GLchar
*
const
Renderer
::
alphaFShader
=
{
"precision mediump float;
\n
"
"precision mediump float;"
"uniform sampler2D tex;
\n
"
"uniform sampler2D tex;"
"uniform float alpha;
\n
"
"uniform float alpha;"
"varying vec2 v_texcoord;
\n
"
"varying vec2 v_texcoord;"
"void main() {
\n
"
"void main() {"
" vec4 frag = texture2D(tex, v_texcoord);
\n
"
" vec4 frag = texture2D(tex, v_texcoord);"
" gl_FragColor = alpha*frag;
\n
"
" gl_FragColor = alpha*frag;"
"}
\n
"
};
"}"
};
const
GLchar
*
const
Renderer
::
defaultFShader
=
const
GLchar
*
const
Renderer
::
defaultFShader
=
{
// This is the fastest fragment shader. Use it when you can.
{
// This is the fastest fragment shader. Use it when you can.
"precision mediump float;
\n
"
"precision mediump float;"
"uniform sampler2D tex;
\n
"
"uniform sampler2D tex;"
"varying vec2 v_texcoord;
\n
"
"varying vec2 v_texcoord;"
"void main() {
\n
"
"void main() {"
" gl_FragColor = texture2D(tex, v_texcoord);
\n
"
" gl_FragColor = texture2D(tex, v_texcoord);"
"}
\n
"
};
"}"
};
void
Renderer
::
setupViewport
(
RendererWindow
*
window
,
void
Renderer
::
setupViewport
(
RendererWindow
*
window
,
const
anbox
::
graphics
::
Rect
&
rect
)
{
const
anbox
::
graphics
::
Rect
&
rect
)
{
...
...
src/anbox/graphics/emugl/RendererConfig.cpp
浏览文件 @
c9c3155e
...
@@ -19,10 +19,9 @@
...
@@ -19,10 +19,9 @@
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
namespace
{
#include "anbox/logger.h"
#define E(...) fprintf(stderr, __VA_ARGS__)
namespace
{
const
GLuint
kConfigAttributes
[]
=
{
const
GLuint
kConfigAttributes
[]
=
{
EGL_DEPTH_SIZE
,
// must be first - see getDepthSize()
EGL_DEPTH_SIZE
,
// must be first - see getDepthSize()
EGL_STENCIL_SIZE
,
// must be second - see getStencilSize()
EGL_STENCIL_SIZE
,
// must be second - see getStencilSize()
...
@@ -65,7 +64,6 @@ bool isCompatibleHostConfig(EGLConfig config, EGLDisplay display) {
...
@@ -65,7 +64,6 @@ bool isCompatibleHostConfig(EGLConfig config, EGLDisplay display) {
return
true
;
return
true
;
}
}
}
// namespace
}
// namespace
RendererConfig
::~
RendererConfig
()
{
delete
[]
mAttribValues
;
}
RendererConfig
::~
RendererConfig
()
{
delete
[]
mAttribValues
;
}
...
@@ -89,14 +87,13 @@ RendererConfig::RendererConfig(EGLConfig hostConfig, EGLDisplay hostDisplay)
...
@@ -89,14 +87,13 @@ RendererConfig::RendererConfig(EGLConfig hostConfig, EGLDisplay hostDisplay)
RendererConfigList
::
RendererConfigList
(
EGLDisplay
display
)
RendererConfigList
::
RendererConfigList
(
EGLDisplay
display
)
:
mCount
(
0
),
mConfigs
(
NULL
),
mDisplay
(
display
)
{
:
mCount
(
0
),
mConfigs
(
NULL
),
mDisplay
(
display
)
{
if
(
display
==
EGL_NO_DISPLAY
)
{
if
(
display
==
EGL_NO_DISPLAY
)
{
E
(
"%s: Invalid display value %p (EGL_NO_DISPLAY)
\n
"
,
__FUNCTION__
,
ERROR
(
"Invalid display value %p (EGL_NO_DISPLAY)"
,
reinterpret_cast
<
void
*>
(
display
));
reinterpret_cast
<
void
*>
(
display
));
return
;
return
;
}
}
EGLint
numHostConfigs
=
0
;
EGLint
numHostConfigs
=
0
;
if
(
!
s_egl
.
eglGetConfigs
(
display
,
NULL
,
0
,
&
numHostConfigs
))
{
if
(
!
s_egl
.
eglGetConfigs
(
display
,
NULL
,
0
,
&
numHostConfigs
))
{
E
(
"%s: Could not get number of host EGL configs
\n
"
,
__FUNCTION__
);
E
RROR
(
"Could not get number of host EGL config"
);
return
;
return
;
}
}
EGLConfig
*
hostConfigs
=
new
EGLConfig
[
numHostConfigs
];
EGLConfig
*
hostConfigs
=
new
EGLConfig
[
numHostConfigs
];
...
@@ -126,7 +123,7 @@ int RendererConfigList::chooseConfig(const EGLint* attribs, EGLint* configs,
...
@@ -126,7 +123,7 @@ int RendererConfigList::chooseConfig(const EGLint* attribs, EGLint* configs,
EGLint
configsSize
)
const
{
EGLint
configsSize
)
const
{
EGLint
numHostConfigs
=
0
;
EGLint
numHostConfigs
=
0
;
if
(
!
s_egl
.
eglGetConfigs
(
mDisplay
,
NULL
,
0
,
&
numHostConfigs
))
{
if
(
!
s_egl
.
eglGetConfigs
(
mDisplay
,
NULL
,
0
,
&
numHostConfigs
))
{
E
(
"%s: Could not get number of host EGL configs
\n
"
,
__FUNCTION__
);
E
RROR
(
"Could not get number of host EGL configs"
);
return
0
;
return
0
;
}
}
...
...
src/anbox/graphics/emugl/TextureDraw.cpp
浏览文件 @
c9c3155e
...
@@ -21,7 +21,8 @@
...
@@ -21,7 +21,8 @@
#include <vector>
#include <vector>
#include <stdio.h>
#include <stdio.h>
#define ERR(...) fprintf(stderr, __VA_ARGS__)
#include "anbox/logger.h"
// M_PI isn't defined in C++ (when strict ISO compliance is enabled)
// M_PI isn't defined in C++ (when strict ISO compliance is enabled)
#ifndef M_PI
#ifndef M_PI
...
@@ -120,7 +121,7 @@ TextureDraw::TextureDraw(EGLDisplay display)
...
@@ -120,7 +121,7 @@ TextureDraw::TextureDraw(EGLDisplay display)
if
(
success
==
GL_FALSE
)
{
if
(
success
==
GL_FALSE
)
{
GLchar
messages
[
256
];
GLchar
messages
[
256
];
s_gles2
.
glGetProgramInfoLog
(
mProgram
,
sizeof
(
messages
),
0
,
&
messages
[
0
]);
s_gles2
.
glGetProgramInfoLog
(
mProgram
,
sizeof
(
messages
),
0
,
&
messages
[
0
]);
ERR
(
"%s: Could not create/link program: %s
\n
"
,
__FUNCTION__
,
messages
);
ERR
OR
(
"Could not create/link program: %s"
,
messages
);
s_gles2
.
glDeleteProgram
(
mProgram
);
s_gles2
.
glDeleteProgram
(
mProgram
);
mProgram
=
0
;
mProgram
=
0
;
return
;
return
;
...
@@ -151,7 +152,7 @@ TextureDraw::TextureDraw(EGLDisplay display)
...
@@ -151,7 +152,7 @@ TextureDraw::TextureDraw(EGLDisplay display)
bool
TextureDraw
::
draw
(
GLuint
texture
)
{
bool
TextureDraw
::
draw
(
GLuint
texture
)
{
if
(
!
mProgram
)
{
if
(
!
mProgram
)
{
ERR
(
"%s: no program
\n
"
,
__FUNCTION__
);
ERR
OR
(
" No program"
);
return
false
;
return
false
;
}
}
...
@@ -162,14 +163,14 @@ bool TextureDraw::draw(GLuint texture) {
...
@@ -162,14 +163,14 @@ bool TextureDraw::draw(GLuint texture) {
s_gles2
.
glUseProgram
(
mProgram
);
s_gles2
.
glUseProgram
(
mProgram
);
err
=
s_gles2
.
glGetError
();
err
=
s_gles2
.
glGetError
();
if
(
err
!=
GL_NO_ERROR
)
{
if
(
err
!=
GL_NO_ERROR
)
{
ERR
(
"%s: Could not use program error=0x%x
\n
"
,
__FUNCTION__
,
err
);
ERR
OR
(
"Could not use program error 0x%x"
,
err
);
}
}
// Setup the |position| attribute values.
// Setup the |position| attribute values.
s_gles2
.
glBindBuffer
(
GL_ARRAY_BUFFER
,
mVertexBuffer
);
s_gles2
.
glBindBuffer
(
GL_ARRAY_BUFFER
,
mVertexBuffer
);
err
=
s_gles2
.
glGetError
();
err
=
s_gles2
.
glGetError
();
if
(
err
!=
GL_NO_ERROR
)
{
if
(
err
!=
GL_NO_ERROR
)
{
ERR
(
"%s: Could not bind GL_ARRAY_BUFFER error=0x%x
\n
"
,
__FUNCTION__
,
err
);
ERR
OR
(
"Could not bind GL_ARRAY_BUFFER error=0x%x"
,
err
);
}
}
s_gles2
.
glEnableVertexAttribArray
(
mPositionSlot
);
s_gles2
.
glEnableVertexAttribArray
(
mPositionSlot
);
...
@@ -177,8 +178,7 @@ bool TextureDraw::draw(GLuint texture) {
...
@@ -177,8 +178,7 @@ bool TextureDraw::draw(GLuint texture) {
sizeof
(
Vertex
),
0
);
sizeof
(
Vertex
),
0
);
err
=
s_gles2
.
glGetError
();
err
=
s_gles2
.
glGetError
();
if
(
err
!=
GL_NO_ERROR
)
{
if
(
err
!=
GL_NO_ERROR
)
{
ERR
(
"%s: Could glVertexAttribPointer with mPositionSlot error=0x%x
\n
"
,
ERROR
(
"Could glVertexAttribPointer with mPositionSlot error 0x%x"
,
err
);
__FUNCTION__
,
err
);
}
}
// Setup the |inCoord| attribute values.
// Setup the |inCoord| attribute values.
...
@@ -199,7 +199,7 @@ bool TextureDraw::draw(GLuint texture) {
...
@@ -199,7 +199,7 @@ bool TextureDraw::draw(GLuint texture) {
if
(
validState
==
GL_FALSE
)
{
if
(
validState
==
GL_FALSE
)
{
GLchar
messages
[
256
];
GLchar
messages
[
256
];
s_gles2
.
glGetProgramInfoLog
(
mProgram
,
sizeof
(
messages
),
0
,
&
messages
[
0
]);
s_gles2
.
glGetProgramInfoLog
(
mProgram
,
sizeof
(
messages
),
0
,
&
messages
[
0
]);
ERR
(
"%s: Could not run program: %s
\n
"
,
__FUNCTION__
,
messages
);
ERR
OR
(
"Could not run program: %s"
,
messages
);
return
false
;
return
false
;
}
}
...
@@ -207,14 +207,13 @@ bool TextureDraw::draw(GLuint texture) {
...
@@ -207,14 +207,13 @@ bool TextureDraw::draw(GLuint texture) {
s_gles2
.
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
mIndexBuffer
);
s_gles2
.
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
mIndexBuffer
);
err
=
s_gles2
.
glGetError
();
err
=
s_gles2
.
glGetError
();
if
(
err
!=
GL_NO_ERROR
)
{
if
(
err
!=
GL_NO_ERROR
)
{
ERR
(
"%s: Could not glBindBuffer(GL_ELEMENT_ARRAY_BUFFER) error=0x%x
\n
"
,
ERROR
(
"Could not glBindBuffer(GL_ELEMENT_ARRAY_BUFFER) error 0x%x"
,
err
);
__FUNCTION__
,
err
);
}
}
s_gles2
.
glDrawElements
(
GL_TRIANGLES
,
kIndicesLen
,
GL_UNSIGNED_BYTE
,
0
);
s_gles2
.
glDrawElements
(
GL_TRIANGLES
,
kIndicesLen
,
GL_UNSIGNED_BYTE
,
0
);
err
=
s_gles2
.
glGetError
();
err
=
s_gles2
.
glGetError
();
if
(
err
!=
GL_NO_ERROR
)
{
if
(
err
!=
GL_NO_ERROR
)
{
ERR
(
"%s: Could not glDrawElements() error=0x%x
\n
"
,
__FUNCTION__
,
err
);
ERR
OR
(
"Could not glDrawElements() error 0x%x"
,
err
);
}
}
// TODO(digit): Restore previous program state.
// TODO(digit): Restore previous program state.
...
...
src/anbox/graphics/emugl/TextureResize.cpp
浏览文件 @
c9c3155e
...
@@ -22,7 +22,8 @@
...
@@ -22,7 +22,8 @@
#include <string>
#include <string>
#include <utility>
#include <utility>
#define ERR(...) fprintf(stderr, __VA_ARGS__)
#include "anbox/logger.h"
#define MAX_FACTOR_POWER 4
#define MAX_FACTOR_POWER 4
static
const
char
kCommonShaderSource
[]
=
static
const
char
kCommonShaderSource
[]
=
...
@@ -150,8 +151,7 @@ static GLuint createShader(GLenum type,
...
@@ -150,8 +151,7 @@ static GLuint createShader(GLenum type,
s_gles2
.
glGetShaderiv
(
shader
,
GL_INFO_LOG_LENGTH
,
&
infoLength
);
s_gles2
.
glGetShaderiv
(
shader
,
GL_INFO_LOG_LENGTH
,
&
infoLength
);
std
::
string
infoLog
(
infoLength
+
1
,
'\0'
);
std
::
string
infoLog
(
infoLength
+
1
,
'\0'
);
s_gles2
.
glGetShaderInfoLog
(
shader
,
infoLength
,
nullptr
,
&
infoLog
[
0
]);
s_gles2
.
glGetShaderInfoLog
(
shader
,
infoLength
,
nullptr
,
&
infoLog
[
0
]);
ERR
(
"%s shader compile failed:
\n
%s
\n
"
,
ERROR
(
"%s shader compile failed: %s"
,
(
type
==
GL_VERTEX_SHADER
)
?
"Vertex"
:
"Fragment"
,
infoLog
.
c_str
());
(
type
==
GL_VERTEX_SHADER
)
?
"Vertex"
:
"Fragment"
,
infoLog
.
c_str
());
s_gles2
.
glDeleteShader
(
shader
);
s_gles2
.
glDeleteShader
(
shader
);
shader
=
0
;
shader
=
0
;
}
}
...
@@ -264,7 +264,7 @@ GLuint TextureResize::update(GLuint texture) {
...
@@ -264,7 +264,7 @@ GLuint TextureResize::update(GLuint texture) {
// If there was an error while resizing, just use the unscaled texture.
// If there was an error while resizing, just use the unscaled texture.
GLenum
error
=
s_gles2
.
glGetError
();
GLenum
error
=
s_gles2
.
glGetError
();
if
(
error
!=
GL_NO_ERROR
)
{
if
(
error
!=
GL_NO_ERROR
)
{
ERR
(
"GL error while resizing: 0x%x (ignored)
\n
"
,
error
);
ERR
OR
(
"GL error while resizing: 0x%x (ignored)
"
,
error
);
return
texture
;
return
texture
;
}
}
...
...
src/anbox/graphics/emugl/WindowSurface.cpp
浏览文件 @
c9c3155e
...
@@ -14,8 +14,6 @@
...
@@ -14,8 +14,6 @@
* limitations under the License.
* limitations under the License.
*/
*/
#include "WindowSurface.h"
#include "WindowSurface.h"
#include "ErrorLog.h"
#include "RendererConfig.h"
#include "RendererConfig.h"
#include "OpenGLESDispatch/EGLDispatch.h"
#include "OpenGLESDispatch/EGLDispatch.h"
...
@@ -25,6 +23,8 @@
...
@@ -25,6 +23,8 @@
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include "anbox/logger.h"
WindowSurface
::
WindowSurface
(
EGLDisplay
display
,
EGLConfig
config
)
WindowSurface
::
WindowSurface
(
EGLDisplay
display
,
EGLConfig
config
)
:
mSurface
(
NULL
),
:
mSurface
(
NULL
),
mAttachedColorBuffer
(
NULL
),
mAttachedColorBuffer
(
NULL
),
...
@@ -94,12 +94,12 @@ bool WindowSurface::flushColorBuffer() {
...
@@ -94,12 +94,12 @@ bool WindowSurface::flushColorBuffer() {
if
(
mAttachedColorBuffer
->
getWidth
()
!=
mWidth
||
if
(
mAttachedColorBuffer
->
getWidth
()
!=
mWidth
||
mAttachedColorBuffer
->
getHeight
()
!=
mHeight
)
{
mAttachedColorBuffer
->
getHeight
()
!=
mHeight
)
{
// XXX: should never happen - how this needs to be handled?
// XXX: should never happen - how this needs to be handled?
fprintf
(
stderr
,
"Dimensions do not match
\n
"
);
ERROR
(
"Dimensions do not match
"
);
return
false
;
return
false
;
}
}
if
(
!
mDrawContext
.
Ptr
())
{
if
(
!
mDrawContext
.
Ptr
())
{
fprintf
(
stderr
,
"Draw context is NULL
\n
"
);
ERROR
(
"Draw context is NULL
"
);
return
false
;
return
false
;
}
}
...
@@ -110,7 +110,7 @@ bool WindowSurface::flushColorBuffer() {
...
@@ -110,7 +110,7 @@ bool WindowSurface::flushColorBuffer() {
if
(
!
s_egl
.
eglMakeCurrent
(
mDisplay
,
mSurface
,
mSurface
,
if
(
!
s_egl
.
eglMakeCurrent
(
mDisplay
,
mSurface
,
mSurface
,
mDrawContext
->
getEGLContext
()))
{
mDrawContext
->
getEGLContext
()))
{
fprintf
(
stderr
,
"Error making draw context current
\n
"
);
ERROR
(
"Failed to make draw context current
"
);
return
false
;
return
false
;
}
}
...
@@ -140,24 +140,20 @@ bool WindowSurface::resize(unsigned int p_width, unsigned int p_height) {
...
@@ -140,24 +140,20 @@ bool WindowSurface::resize(unsigned int p_width, unsigned int p_height) {
EGL_NO_CONTEXT
);
EGL_NO_CONTEXT
);
}
}
//
// Destroy previous surface
//
if
(
mSurface
)
{
if
(
mSurface
)
{
s_egl
.
eglDestroySurface
(
mDisplay
,
mSurface
);
s_egl
.
eglDestroySurface
(
mDisplay
,
mSurface
);
mSurface
=
NULL
;
mSurface
=
NULL
;
}
}
//
// Create pbuffer surface.
//
const
EGLint
pbufAttribs
[
5
]
=
{
const
EGLint
pbufAttribs
[
5
]
=
{
EGL_WIDTH
,
static_cast
<
EGLint
>
(
p_width
),
EGL_HEIGHT
,
static_cast
<
EGLint
>
(
p_height
),
EGL_NONE
,
EGL_WIDTH
,
static_cast
<
EGLint
>
(
p_width
),
EGL_HEIGHT
,
static_cast
<
EGLint
>
(
p_height
),
EGL_NONE
,
};
};
mSurface
=
s_egl
.
eglCreatePbufferSurface
(
mDisplay
,
mConfig
,
pbufAttribs
);
mSurface
=
s_egl
.
eglCreatePbufferSurface
(
mDisplay
,
mConfig
,
pbufAttribs
);
if
(
mSurface
==
EGL_NO_SURFACE
)
{
if
(
mSurface
==
EGL_NO_SURFACE
)
{
fprintf
(
stderr
,
"Renderer error: failed to create/resize pbuffer!!
\n
"
);
ERROR
(
"Failed to create/resize pbuffer
"
);
return
false
;
return
false
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录