* commit '26025f179e8e51bce376cf7fdad42bcfdcd58fff': emulator opengl: guest/host rendering syncronization. emulator opengl: initialize new colorbuffers emulator opengles: Fixed bug in gralloc unregister_buffer emulator opengles: Fixed a bug in eglChooseConfig implementation. opengles emulator: Fixed upside-down gl image
This commit is contained in:
@@ -56,10 +56,16 @@ ColorBuffer *ColorBuffer::create(int p_width, int p_height,
|
|||||||
|
|
||||||
s_gl.glGenTextures(1, &cb->m_tex);
|
s_gl.glGenTextures(1, &cb->m_tex);
|
||||||
s_gl.glBindTexture(GL_TEXTURE_2D, cb->m_tex);
|
s_gl.glBindTexture(GL_TEXTURE_2D, cb->m_tex);
|
||||||
|
int nComp = (texInternalFormat == GL_RGB ? 3 : 4);
|
||||||
|
char *zBuff = new char[nComp*p_width*p_height];
|
||||||
|
if (zBuff) {
|
||||||
|
memset(zBuff, 0, nComp*p_width*p_height);
|
||||||
|
}
|
||||||
s_gl.glTexImage2D(GL_TEXTURE_2D, 0, texInternalFormat,
|
s_gl.glTexImage2D(GL_TEXTURE_2D, 0, texInternalFormat,
|
||||||
p_width, p_height, 0,
|
p_width, p_height, 0,
|
||||||
texInternalFormat,
|
texInternalFormat,
|
||||||
GL_UNSIGNED_BYTE, NULL);
|
GL_UNSIGNED_BYTE, zBuff);
|
||||||
|
delete [] zBuff;
|
||||||
s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
s_gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
@@ -231,10 +237,10 @@ void ColorBuffer::drawTexQuad()
|
|||||||
+1.0f, -1.0f, 0.0f,
|
+1.0f, -1.0f, 0.0f,
|
||||||
+1.0f, +1.0f, 0.0f };
|
+1.0f, +1.0f, 0.0f };
|
||||||
|
|
||||||
GLfloat tcoords[] = { 0.0f, 0.0f,
|
GLfloat tcoords[] = { 0.0f, 1.0f,
|
||||||
0.0f, 1.0f,
|
0.0f, 0.0f,
|
||||||
1.0f, 0.0f,
|
1.0f, 1.0f,
|
||||||
1.0f, 1.0f };
|
1.0f, 0.0f };
|
||||||
|
|
||||||
s_gl.glClientActiveTexture(GL_TEXTURE0);
|
s_gl.glClientActiveTexture(GL_TEXTURE0);
|
||||||
s_gl.glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
s_gl.glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|||||||
@@ -224,13 +224,14 @@ static void rcDestroyColorBuffer(uint32_t colorbuffer)
|
|||||||
fb->DestroyColorBuffer( colorbuffer );
|
fb->DestroyColorBuffer( colorbuffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rcFlushWindowColorBuffer(uint32_t windowSurface)
|
static int rcFlushWindowColorBuffer(uint32_t windowSurface)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
FrameBuffer *fb = FrameBuffer::getFB();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
fb->flushWindowSurfaceColorBuffer(windowSurface);
|
fb->flushWindowSurfaceColorBuffer(windowSurface);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rcSetWindowColorBuffer(uint32_t windowSurface,
|
static void rcSetWindowColorBuffer(uint32_t windowSurface,
|
||||||
@@ -296,17 +297,18 @@ static void rcReadColorBuffer(uint32_t colorBuffer,
|
|||||||
// XXX: TBD - should be implemented
|
// XXX: TBD - should be implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rcUpdateColorBuffer(uint32_t colorBuffer,
|
static int rcUpdateColorBuffer(uint32_t colorBuffer,
|
||||||
GLint x, GLint y,
|
GLint x, GLint y,
|
||||||
GLint width, GLint height,
|
GLint width, GLint height,
|
||||||
GLenum format, GLenum type, void* pixels)
|
GLenum format, GLenum type, void* pixels)
|
||||||
{
|
{
|
||||||
FrameBuffer *fb = FrameBuffer::getFB();
|
FrameBuffer *fb = FrameBuffer::getFB();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fb->updateColorBuffer(colorBuffer, x, y, width, height, format, type, pixels);
|
fb->updateColorBuffer(colorBuffer, x, y, width, height, format, type, pixels);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initRenderControlContext(renderControl_decoder_context_t *dec)
|
void initRenderControlContext(renderControl_decoder_context_t *dec)
|
||||||
|
|||||||
@@ -227,8 +227,27 @@ void WindowSurface::copyToColorBuffer()
|
|||||||
GL_RGBA, GL_UNSIGNED_BYTE, data);
|
GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FLIP_BUFFER 1
|
||||||
|
#if FLIP_BUFFER
|
||||||
|
//We need to flip the pixels
|
||||||
|
int bpp = 4;
|
||||||
|
void *tmpBuf = m_xUpdateBuf.alloc(m_width * m_height * bpp);
|
||||||
|
|
||||||
|
int dst_line_len = m_width * bpp;
|
||||||
|
int src_line_len = m_width * bpp;
|
||||||
|
char *src = (char *)data;
|
||||||
|
char *dst = (char*)tmpBuf + (m_height-1)*dst_line_len;
|
||||||
|
for (uint32_t y=0; y<m_height; y++) {
|
||||||
|
memcpy(dst, src, dst_line_len);
|
||||||
|
src += src_line_len;
|
||||||
|
dst -= dst_line_len;
|
||||||
|
}
|
||||||
|
// update the attached color buffer with the fliped readback pixels
|
||||||
|
m_attachedColorBuffer->update(GL_RGBA, GL_UNSIGNED_BYTE, tmpBuf);
|
||||||
|
#else
|
||||||
// update the attached color buffer with the readback pixels
|
// update the attached color buffer with the readback pixels
|
||||||
m_attachedColorBuffer->update(GL_RGBA, GL_UNSIGNED_BYTE, data);
|
m_attachedColorBuffer->update(GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||||
|
#endif
|
||||||
|
|
||||||
// restore current context/surface
|
// restore current context/surface
|
||||||
s_egl.eglMakeCurrent(fb->getDisplay(), prevDrawSurf,
|
s_egl.eglMakeCurrent(fb->getDisplay(), prevDrawSurf,
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ private:
|
|||||||
bool m_useEGLImage;
|
bool m_useEGLImage;
|
||||||
bool m_useBindToTexture;
|
bool m_useBindToTexture;
|
||||||
FixedBuffer m_xferBuffer;
|
FixedBuffer m_xferBuffer;
|
||||||
|
FixedBuffer m_xUpdateBuf;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SmartPtr<WindowSurface> WindowSurfacePtr;
|
typedef SmartPtr<WindowSurface> WindowSurfacePtr;
|
||||||
|
|||||||
@@ -325,8 +325,12 @@ EGLBoolean egl_window_surface_t::connect()
|
|||||||
if (nativeWindow->dequeueBuffer(nativeWindow, &buffer) != NO_ERROR) {
|
if (nativeWindow->dequeueBuffer(nativeWindow, &buffer) != NO_ERROR) {
|
||||||
setErrorReturn(EGL_BAD_ALLOC, EGL_FALSE);
|
setErrorReturn(EGL_BAD_ALLOC, EGL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->common.incRef(&buffer->common);
|
buffer->common.incRef(&buffer->common);
|
||||||
|
|
||||||
|
// lock the buffer
|
||||||
|
nativeWindow->lockBuffer(nativeWindow, buffer);
|
||||||
|
|
||||||
DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
|
DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
|
||||||
rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface, ((cb_handle_t *)(buffer->handle))->hostHandle);
|
rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface, ((cb_handle_t *)(buffer->handle))->hostHandle);
|
||||||
|
|
||||||
@@ -360,6 +364,9 @@ EGLBoolean egl_window_surface_t::swapBuffers()
|
|||||||
setErrorReturn(EGL_BAD_ALLOC, EGL_FALSE);
|
setErrorReturn(EGL_BAD_ALLOC, EGL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lock the buffer
|
||||||
|
nativeWindow->lockBuffer(nativeWindow, buffer);
|
||||||
|
|
||||||
rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface, ((cb_handle_t *)(buffer->handle))->hostHandle);
|
rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface, ((cb_handle_t *)(buffer->handle))->hostHandle);
|
||||||
|
|
||||||
return EGL_TRUE;
|
return EGL_TRUE;
|
||||||
@@ -634,7 +641,7 @@ EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
|
DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE);
|
||||||
*num_config = rcEnc->rcChooseConfig(rcEnc, (EGLint*)attrib_list, attribs_size * sizeof(EGLint), (uint32_t*)configs, config_size*sizeof(EGLint));
|
*num_config = rcEnc->rcChooseConfig(rcEnc, (EGLint*)attrib_list, attribs_size * sizeof(EGLint), (uint32_t*)configs, config_size);
|
||||||
|
|
||||||
return EGL_TRUE;
|
return EGL_TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -441,6 +441,8 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module,
|
|||||||
if (err) {
|
if (err) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
cb->ashmemBase = NULL;
|
||||||
|
cb->mappedPid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ rcChooseConfig
|
|||||||
dir attribs in
|
dir attribs in
|
||||||
len attribs attribs_size
|
len attribs attribs_size
|
||||||
dir configs out
|
dir configs out
|
||||||
len configs configs_size
|
len configs configs_size*sizeof(uint32_t)
|
||||||
|
|
||||||
rcReadColorBuffer
|
rcReadColorBuffer
|
||||||
dir pixels out
|
dir pixels out
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ GL_ENTRY(void, rcDestroyWindowSurface, uint32_t windowSurface)
|
|||||||
GL_ENTRY(uint32_t, rcCreateColorBuffer, uint32_t width, uint32_t height, GLenum internalFormat)
|
GL_ENTRY(uint32_t, rcCreateColorBuffer, uint32_t width, uint32_t height, GLenum internalFormat)
|
||||||
GL_ENTRY(void, rcDestroyColorBuffer, uint32_t colorbuffer)
|
GL_ENTRY(void, rcDestroyColorBuffer, uint32_t colorbuffer)
|
||||||
GL_ENTRY(void, rcSetWindowColorBuffer, uint32_t windowSurface, uint32_t colorBuffer)
|
GL_ENTRY(void, rcSetWindowColorBuffer, uint32_t windowSurface, uint32_t colorBuffer)
|
||||||
GL_ENTRY(void, rcFlushWindowColorBuffer, uint32_t windowSurface)
|
GL_ENTRY(int, rcFlushWindowColorBuffer, uint32_t windowSurface)
|
||||||
GL_ENTRY(EGLint, rcMakeCurrent, uint32_t context, uint32_t drawSurf, uint32_t readSurf)
|
GL_ENTRY(EGLint, rcMakeCurrent, uint32_t context, uint32_t drawSurf, uint32_t readSurf)
|
||||||
GL_ENTRY(void, rcFBPost, uint32_t colorBuffer)
|
GL_ENTRY(void, rcFBPost, uint32_t colorBuffer)
|
||||||
GL_ENTRY(void, rcFBSetSwapInterval, EGLint interval)
|
GL_ENTRY(void, rcFBSetSwapInterval, EGLint interval)
|
||||||
GL_ENTRY(void, rcBindTexture, uint32_t colorBuffer)
|
GL_ENTRY(void, rcBindTexture, uint32_t colorBuffer)
|
||||||
GL_ENTRY(EGLint, rcColorBufferCacheFlush, uint32_t colorbuffer, EGLint postCount,int forRead)
|
GL_ENTRY(EGLint, rcColorBufferCacheFlush, uint32_t colorbuffer, EGLint postCount,int forRead)
|
||||||
GL_ENTRY(void, rcReadColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels)
|
GL_ENTRY(void, rcReadColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels)
|
||||||
GL_ENTRY(void, rcUpdateColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels)
|
GL_ENTRY(int, rcUpdateColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels)
|
||||||
|
|||||||
Reference in New Issue
Block a user