opengles emulator: Fixed upside-down gl image

This fix performs a flip software copy to match our coords with those expected by the flinger.
We may think of a better implementation in the future.

Change-Id: Ic09a5d0e22f7e209b33c07c993a3d56e328dd3ed
This commit is contained in:
Stas Gurtovoy
2011-06-06 13:42:06 +03:00
committed by Guy Zadickario
parent 688620eb31
commit fdcba322fe
3 changed files with 24 additions and 4 deletions

View File

@@ -231,10 +231,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);

View File

@@ -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,

View File

@@ -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;