opengles emulator: replace the readback at end of frame with blit
That replaces the readback to host we do at the end of each frame with two blits on the GPU, one to copy the pixels into a texture and another to render the texture to another in order to flip the image. Change-Id: I7e0e10493d38944d0b613e245023f34236d3dfc4
This commit is contained in:
@@ -115,7 +115,8 @@ void WindowSurface::flushColorBuffer()
|
||||
}
|
||||
|
||||
if (!copied) {
|
||||
copyToColorBuffer();
|
||||
//copyToColorBuffer();
|
||||
blitToColorBuffer();
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -257,6 +258,36 @@ void WindowSurface::copyToColorBuffer()
|
||||
|
||||
}
|
||||
|
||||
void WindowSurface::blitToColorBuffer()
|
||||
{
|
||||
if (!m_width && !m_height) return;
|
||||
|
||||
if (m_attachedColorBuffer->getWidth() != m_width ||
|
||||
m_attachedColorBuffer->getHeight() != m_height) {
|
||||
// XXX: should never happen - how this needs to be handled?
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Make the surface current
|
||||
//
|
||||
EGLContext prevContext = s_egl.eglGetCurrentContext();
|
||||
EGLSurface prevReadSurf = s_egl.eglGetCurrentSurface(EGL_READ);
|
||||
EGLSurface prevDrawSurf = s_egl.eglGetCurrentSurface(EGL_DRAW);
|
||||
FrameBuffer *fb = FrameBuffer::getFB();
|
||||
if (!s_egl.eglMakeCurrent(fb->getDisplay(), m_eglSurface,
|
||||
m_eglSurface, m_drawContext->getEGLContext())) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_attachedColorBuffer->blitFromCurrentReadBuffer();
|
||||
|
||||
// restore current context/surface
|
||||
s_egl.eglMakeCurrent(fb->getDisplay(), prevDrawSurf,
|
||||
prevReadSurf, prevContext);
|
||||
|
||||
}
|
||||
|
||||
bool WindowSurface::resizePbuffer(unsigned int p_width, unsigned int p_height)
|
||||
{
|
||||
if (m_eglSurface &&
|
||||
|
||||
Reference in New Issue
Block a user