summaryrefslogtreecommitdiffstats
path: root/opengl/libs/GLES_trace
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2012-01-04 11:18:29 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-01-04 11:18:29 -0800
commit59511ad1cbdb13509f5c249a5193e0180e0dbf0c (patch)
tree682d05cd6a5c44f64a095380a4bb22615fab7f08 /opengl/libs/GLES_trace
parent3b115238cf237a1d804c87da59f49c085daeeb9e (diff)
parentf132ac35d82a2960542619fb3fb91d22ab256dc7 (diff)
downloadframeworks_native-59511ad1cbdb13509f5c249a5193e0180e0dbf0c.zip
frameworks_native-59511ad1cbdb13509f5c249a5193e0180e0dbf0c.tar.gz
frameworks_native-59511ad1cbdb13509f5c249a5193e0180e0dbf0c.tar.bz2
Merge "gltrace: attach contents of the appropriate framebuffer"
Diffstat (limited to 'opengl/libs/GLES_trace')
-rw-r--r--opengl/libs/GLES_trace/src/gltrace_context.cpp24
-rw-r--r--opengl/libs/GLES_trace/src/gltrace_context.h6
-rw-r--r--opengl/libs/GLES_trace/src/gltrace_egl.cpp3
-rw-r--r--opengl/libs/GLES_trace/src/gltrace_fixup.cpp6
-rw-r--r--opengl/libs/GLES_trace/src/gltrace_fixup.h7
5 files changed, 33 insertions, 13 deletions
diff --git a/opengl/libs/GLES_trace/src/gltrace_context.cpp b/opengl/libs/GLES_trace/src/gltrace_context.cpp
index 8cf5a51..e0dd5f4 100644
--- a/opengl/libs/GLES_trace/src/gltrace_context.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_context.cpp
@@ -82,19 +82,33 @@ void GLTraceContext::resizeFBMemory(unsigned minSize) {
/** obtain a pointer to the compressed framebuffer image */
void GLTraceContext::getCompressedFB(void **fb, unsigned *fbsize, unsigned *fbwidth,
- unsigned *fbheight) {
+ unsigned *fbheight, FBBinding fbToRead) {
int viewport[4] = {};
hooks->gl.glGetIntegerv(GL_VIEWPORT, viewport);
unsigned fbContentsSize = viewport[2] * viewport[3] * 4;
resizeFBMemory(fbContentsSize);
- //TODO: On eglSwapBuffer, read FB0. For glDraw calls, read currently
- // bound FB.
- //hooks->gl.glGetIntegerv(GL_FRAMEBUFFER_BINDING, &bound_fb);
- //hooks->gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ // switch current framebuffer binding if necessary
+ GLint currentFb = -1;
+ bool fbSwitched = false;
+ if (fbToRead != CURRENTLY_BOUND_FB) {
+ hooks->gl.glGetIntegerv(GL_FRAMEBUFFER_BINDING, &currentFb);
+
+ if (currentFb != 0) {
+ hooks->gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ fbSwitched = true;
+ }
+ }
+
hooks->gl.glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3],
GL_RGBA, GL_UNSIGNED_BYTE, fbcontents);
+
+ // switch back to previously bound buffer if necessary
+ if (fbSwitched) {
+ hooks->gl.glBindFramebuffer(GL_FRAMEBUFFER, currentFb);
+ }
+
*fbsize = lzf_compress(fbcontents, fbContentsSize, fbcompressed, fbContentsSize);
*fb = fbcompressed;
*fbwidth = viewport[2];
diff --git a/opengl/libs/GLES_trace/src/gltrace_context.h b/opengl/libs/GLES_trace/src/gltrace_context.h
index 7dbbca4..35436cb 100644
--- a/opengl/libs/GLES_trace/src/gltrace_context.h
+++ b/opengl/libs/GLES_trace/src/gltrace_context.h
@@ -24,6 +24,8 @@ namespace gltrace {
using ::android::gl_hooks_t;
+enum FBBinding {CURRENTLY_BOUND_FB, FB0};
+
class GLTraceContext {
void *fbcontents; /* memory area to read framebuffer contents */
void *fbcompressed; /* destination for lzf compressed framebuffer */
@@ -34,7 +36,9 @@ public:
gl_hooks_t *hooks;
GLTraceContext();
- void getCompressedFB(void **fb, unsigned *fbsize, unsigned *fbwidth, unsigned *fbheight);
+ void getCompressedFB(void **fb, unsigned *fbsize,
+ unsigned *fbwidth, unsigned *fbheight,
+ FBBinding fbToRead);
};
GLTraceContext *getGLTraceContext();
diff --git a/opengl/libs/GLES_trace/src/gltrace_egl.cpp b/opengl/libs/GLES_trace/src/gltrace_egl.cpp
index 5d1f370..8470a5b 100644
--- a/opengl/libs/GLES_trace/src/gltrace_egl.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_egl.cpp
@@ -31,7 +31,8 @@ void GLTrace_eglSwapBuffers(void *dpy, void *draw) {
glmessage.set_context_id(1);
glmessage.set_function(GLMessage::eglSwapBuffers);
- fixup_addFBContents(&glmessage);
+ // read FB0 since that is what is displayed on the screen
+ fixup_addFBContents(&glmessage, FB0);
traceGLMessage(&glmessage);
}
diff --git a/opengl/libs/GLES_trace/src/gltrace_fixup.cpp b/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
index c5b0451..ec59d2f 100644
--- a/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
+++ b/opengl/libs/GLES_trace/src/gltrace_fixup.cpp
@@ -96,10 +96,10 @@ void fixup_glGetString(GLMessage *glmsg) {
}
/* Add the contents of the framebuffer to the protobuf message */
-void fixup_addFBContents(GLMessage *glmsg) {
+void fixup_addFBContents(GLMessage *glmsg, FBBinding fbToRead) {
void *fbcontents;
unsigned fbsize, fbwidth, fbheight;
- getGLTraceContext()->getCompressedFB(&fbcontents, &fbsize, &fbwidth, &fbheight);
+ getGLTraceContext()->getCompressedFB(&fbcontents, &fbsize, &fbwidth, &fbheight, fbToRead);
GLMessage_FrameBuffer *fb = glmsg->mutable_fb();
fb->set_width(fbwidth);
@@ -299,7 +299,7 @@ void fixupGLMessage(GLMessage *glmsg) {
case GLMessage::glDrawElements:
/* void glDrawArrays(GLenum mode, GLint first, GLsizei count) */
/* void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) */
- fixup_addFBContents(glmsg);
+ fixup_addFBContents(glmsg, CURRENTLY_BOUND_FB);
break;
default:
break;
diff --git a/opengl/libs/GLES_trace/src/gltrace_fixup.h b/opengl/libs/GLES_trace/src/gltrace_fixup.h
index bf15a88..4ea4450 100644
--- a/opengl/libs/GLES_trace/src/gltrace_fixup.h
+++ b/opengl/libs/GLES_trace/src/gltrace_fixup.h
@@ -14,16 +14,17 @@
* limitations under the License.
*/
-#include "gltrace.pb.h"
-
#ifndef __GLTRACE_FIXUP_H_
#define __GLTRACE_FIXUP_H_
+#include "gltrace.pb.h"
+#include "gltrace_context.h"
+
namespace android {
namespace gltrace {
void fixupGLMessage(GLMessage *message);
-void fixup_addFBContents(GLMessage *message);
+void fixup_addFBContents(GLMessage *message, FBBinding fbToRead);
};
};