1 /*
2 * Copyright 2011, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <cutils/log.h>
18 #include <utils/Timers.h>
19
20 #include "gltrace.pb.h"
21 #include "gltrace_context.h"
22 #include "gltrace_fixup.h"
23 #include "gltrace_transport.h"
24
25 namespace android {
26 namespace gltrace {
27
GLTrace_eglCreateContext(int version,int contextId)28 void GLTrace_eglCreateContext(int version, int contextId) {
29 GLMessage glmessage;
30 GLTraceContext *glContext = getGLTraceContext();
31
32 glmessage.set_context_id(contextId);
33 glmessage.set_function(GLMessage::eglCreateContext);
34
35 // copy argument version
36 GLMessage_DataType *arg_version = glmessage.add_args();
37 arg_version->set_isarray(false);
38 arg_version->set_type(GLMessage::DataType::INT);
39 arg_version->add_intvalue(version);
40
41 // copy argument context
42 GLMessage_DataType *arg_context = glmessage.add_args();
43 arg_context->set_isarray(false);
44 arg_context->set_type(GLMessage::DataType::INT);
45 arg_context->add_intvalue(contextId);
46
47 // set start time and duration
48 glmessage.set_start_time(systemTime());
49 glmessage.set_duration(0);
50
51 glContext->traceGLMessage(&glmessage);
52 }
53
GLTrace_eglMakeCurrent(int contextId)54 void GLTrace_eglMakeCurrent(int contextId) {
55 GLMessage glmessage;
56 GLTraceContext *glContext = getGLTraceContext();
57
58 glmessage.set_context_id(contextId);
59 glmessage.set_function(GLMessage::eglMakeCurrent);
60
61 // copy argument context
62 GLMessage_DataType *arg_context = glmessage.add_args();
63 arg_context->set_isarray(false);
64 arg_context->set_type(GLMessage::DataType::INT);
65 arg_context->add_intvalue(contextId);
66
67 // set start time and duration
68 glmessage.set_start_time(systemTime());
69 glmessage.set_duration(0);
70
71 glContext->traceGLMessage(&glmessage);
72 }
73
GLTrace_eglSwapBuffers(void * dpy,void * draw)74 void GLTrace_eglSwapBuffers(void *dpy, void *draw) {
75 GLMessage glmessage;
76 GLTraceContext *glContext = getGLTraceContext();
77
78 glmessage.set_context_id(glContext->getId());
79 glmessage.set_function(GLMessage::eglSwapBuffers);
80
81 if (glContext->getGlobalTraceState()->shouldCollectFbOnEglSwap()) {
82 // read FB0 since that is what is displayed on the screen
83 fixup_addFBContents(glContext, &glmessage, FB0);
84 }
85
86 // set start time and duration
87 glmessage.set_start_time(systemTime());
88 glmessage.set_duration(0);
89
90 glContext->traceGLMessage(&glmessage);
91 }
92
93 };
94 };
95