diff options
author | Siva Velusamy <vsiva@google.com> | 2012-05-16 11:38:03 -0700 |
---|---|---|
committer | Siva Velusamy <vsiva@google.com> | 2012-05-16 12:00:24 -0700 |
commit | 2fdcc81ddfdbdfbbde63bd64e9ac9272b5417553 (patch) | |
tree | 030d57575e7602f27b9adb872b305e9c269c3c1e /opengl/libs/GLES_trace/src/gltrace_eglapi.cpp | |
parent | dd73996552938ac5165a35f09d389abedcf421ef (diff) | |
download | frameworks_native-2fdcc81ddfdbdfbbde63bd64e9ac9272b5417553.zip frameworks_native-2fdcc81ddfdbdfbbde63bd64e9ac9272b5417553.tar.gz frameworks_native-2fdcc81ddfdbdfbbde63bd64e9ac9272b5417553.tar.bz2 |
gltrace: Allow receiving commands of length > 4
Currently, gltrace offers very few trace collection options. As a
result, these options are encoded in a single integer. The trace
control task simply receives integers and interprets them as
commands.
This patch changes the control protocol to first receive the
command length followed by the actual command itself. This allows
for future flexibility to provide enable other commands.
Change-Id: Id5f56c80a025bbbe7613ab4457e092732e7d9dc9
Diffstat (limited to 'opengl/libs/GLES_trace/src/gltrace_eglapi.cpp')
-rw-r--r-- | opengl/libs/GLES_trace/src/gltrace_eglapi.cpp | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/opengl/libs/GLES_trace/src/gltrace_eglapi.cpp b/opengl/libs/GLES_trace/src/gltrace_eglapi.cpp index c442153..9698bf9 100644 --- a/opengl/libs/GLES_trace/src/gltrace_eglapi.cpp +++ b/opengl/libs/GLES_trace/src/gltrace_eglapi.cpp @@ -44,9 +44,14 @@ static void *commandReceiveTask(void *arg) { GLTraceState *state = (GLTraceState *)arg; TCPStream *stream = state->getStream(); - // Currently, there are very few user configurable settings. - // As a result, they can be encoded in a single integer. - int cmd; + // The control stream always receives an integer size of the + // command buffer, followed by the actual command buffer. + uint32_t cmdSize; + + // Command Buffer + void *cmdBuf = NULL; + uint32_t cmdBufSize = 0; + enum TraceSettingsMasks { READ_FB_ON_EGLSWAP_MASK = 1 << 0, READ_FB_ON_GLDRAW_MASK = 1 << 1, @@ -54,12 +59,33 @@ static void *commandReceiveTask(void *arg) { }; while (true) { - int n = stream->receive(&cmd, 4); - if (n != 4) { + // read command size + if (stream->receive(&cmdSize, sizeof(uint32_t)) < 0) { break; } + cmdSize = ntohl(cmdSize); + + // ensure command buffer is of required size + if (cmdBufSize < cmdSize) { + free(cmdBuf); + cmdBufSize = cmdSize; + cmdBuf = malloc(cmdSize); + if (cmdBuf == NULL) + break; + } - cmd = ntohl(cmd); + // receive the command + if (stream->receive(cmdBuf, cmdSize) < 0) { + break; + } + + if (cmdSize != sizeof(uint32_t)) { + // Currently, we only support commands that are a single integer, + // so we skip all other commands + continue; + } + + uint32_t cmd = ntohl(*(uint32_t*)cmdBuf); bool collectFbOnEglSwap = (cmd & READ_FB_ON_EGLSWAP_MASK) != 0; bool collectFbOnGlDraw = (cmd & READ_FB_ON_GLDRAW_MASK) != 0; @@ -73,6 +99,9 @@ static void *commandReceiveTask(void *arg) { collectFbOnEglSwap, collectFbOnGlDraw, collectTextureData); } + ALOGE("Stopping OpenGL Trace Command Receiver\n"); + + free(cmdBuf); return NULL; } |