From 356d1e291bdf837c931f9a52fa1fb6485266af0a Mon Sep 17 00:00:00 2001 From: Francisco Zurita Date: Thu, 2 Jun 2016 23:02:03 -0400 Subject: [PATCH] One less copy when copying GPU Frame Buffer to RDRAM --- src/BufferCopy/ColorBufferToRDRAMAndroid.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/BufferCopy/ColorBufferToRDRAMAndroid.cpp b/src/BufferCopy/ColorBufferToRDRAMAndroid.cpp index 2b79089c..36431355 100644 --- a/src/BufferCopy/ColorBufferToRDRAMAndroid.cpp +++ b/src/BufferCopy/ColorBufferToRDRAMAndroid.cpp @@ -79,16 +79,18 @@ GLubyte* ColorBufferToRDRAMAndroid::_getPixels(GLint _x0, GLint _y0, GLsizei _wi glBindTexture(GL_TEXTURE_2D, m_pTexture->glName); m_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image); glBindTexture(GL_TEXTURE_2D, 0); - - m_window->lock(GraphicBuffer::USAGE_SW_READ_OFTEN, &ptr); - memcpy(pixelData, ptr, m_pTexture->realWidth * m_pTexture->realHeight * colorFormatBytes); - m_window->unlock(); - int widthBytes = _width*colorFormatBytes; int strideBytes = m_pTexture->realWidth * colorFormatBytes; + + m_window->lock(GraphicBuffer::USAGE_SW_READ_OFTEN, &ptr); + for (unsigned int lnIndex = 0; lnIndex < _height; ++lnIndex) { - memmove(pixelData + lnIndex*widthBytes, pixelData + ((lnIndex + _y0)*strideBytes), widthBytes); + memcpy(pixelData + lnIndex*widthBytes, reinterpret_cast(ptr) + ((lnIndex + _y0)*strideBytes), widthBytes); } + + m_window->unlock(); + + } else { glReadPixels(_x0, _y0, _width, _height, colorFormat, colorType, pixelData); }