aboutsummaryrefslogtreecommitdiffstats
path: root/emulator
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2012-07-20 21:57:21 -0700
committerJesse Hall <jessehall@google.com>2012-07-20 22:07:13 -0700
commitc1d62c4ff7abafc365be35e08681f9977862fb44 (patch)
tree31e05310c216841e7019fe658dce2c1724f50076 /emulator
parent01bad8e8943286117043a0da1ae3dad75c1b8562 (diff)
downloadsdk-c1d62c4ff7abafc365be35e08681f9977862fb44.zip
sdk-c1d62c4ff7abafc365be35e08681f9977862fb44.tar.gz
sdk-c1d62c4ff7abafc365be35e08681f9977862fb44.tar.bz2
Send full-size framebuffer to OnPost callback
When the emulator window has non-1.0 scaling, the scale is applied when blitting the Android framebuffer to the host window. For the OnPost callback, we were not only reading the image back from the window (so post-scaling), we were also storing it in a 1.0-scaled buffer. Now we read back from the Android framebuffer image, which is always 1.0-scaled. Change-Id: Ia9c974711a9a4b0b19f4b997f65ecc64481b4c6a
Diffstat (limited to 'emulator')
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp12
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h1
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp20
3 files changed, 23 insertions, 10 deletions
diff --git a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
index e50b8ec..567a9f2 100644
--- a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
@@ -354,3 +354,15 @@ void ColorBuffer::drawTexQuad(bool flipy)
s_gl.glVertexPointer(3, GL_FLOAT, 0, verts);
s_gl.glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
+
+void ColorBuffer::readback(unsigned char* img)
+{
+ FrameBuffer *fb = FrameBuffer::getFB();
+ if (fb->bind_locked()) {
+ if (bind_fbo()) {
+ s_gl.glReadPixels(0, 0, m_width, m_height,
+ GL_RGBA, GL_UNSIGNED_BYTE, img);
+ }
+ fb->unbind_locked();
+ }
+}
diff --git a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h
index 4a2c6b4..d481891 100644
--- a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h
+++ b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h
@@ -37,6 +37,7 @@ public:
bool bindToTexture();
bool bindToRenderbuffer();
bool blitFromCurrentReadBuffer();
+ void readback(unsigned char* img);
private:
ColorBuffer();
diff --git a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
index 2f7cd61..d41b9a5 100644
--- a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
@@ -831,16 +831,6 @@ bool FrameBuffer::post(HandleType p_colorbuffer, bool needLock)
if (ret) {
//
- // Send framebuffer (without FPS overlay) to callback
- //
- if (m_onPost) {
- s_gl.glReadPixels(0, 0, m_width, m_height,
- GL_RGBA, GL_UNSIGNED_BYTE, m_fbImage);
- m_onPost(m_onPostContext, m_width, m_height, -1,
- GL_RGBA, GL_UNSIGNED_BYTE, m_fbImage);
- }
-
- //
// output FPS statistics
//
if (m_fpsStats) {
@@ -859,6 +849,16 @@ bool FrameBuffer::post(HandleType p_colorbuffer, bool needLock)
// restore previous binding
unbind_locked();
+
+ //
+ // Send framebuffer (without FPS overlay) to callback
+ //
+ if (m_onPost) {
+ (*c).second.cb->readback(m_fbImage);
+ m_onPost(m_onPostContext, m_width, m_height, -1,
+ GL_RGBA, GL_UNSIGNED_BYTE, m_fbImage);
+ }
+
}
if (needLock) m_lock.unlock();