blob: 4f9b006a62110e702e04afd27e737c2cf9afb587 [file] [log] [blame]
Siva Velusamy0469dd62011-11-30 15:05:37 -08001/*
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>
Siva Velusamy56ac6ff2011-12-15 17:32:05 -080018#include <utils/Timers.h>
Siva Velusamy0469dd62011-11-30 15:05:37 -080019
20#include "gltrace.pb.h"
21#include "gltrace_context.h"
22#include "gltrace_fixup.h"
23#include "gltrace_transport.h"
24
25namespace android {
26namespace gltrace {
27
Siva Velusamy93a826f2011-12-14 12:19:56 -080028void 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
Siva Velusamy56ac6ff2011-12-15 17:32:05 -080047 // set start time and duration
48 glmessage.set_start_time(systemTime());
49 glmessage.set_duration(0);
50
Siva Velusamy93a826f2011-12-14 12:19:56 -080051 glContext->traceGLMessage(&glmessage);
52}
53
54void 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
Siva Velusamy56ac6ff2011-12-15 17:32:05 -080067 // set start time and duration
68 glmessage.set_start_time(systemTime());
69 glmessage.set_duration(0);
70
Siva Velusamy93a826f2011-12-14 12:19:56 -080071 glContext->traceGLMessage(&glmessage);
72}
73
Mark Salyzyn92dc3fc2014-03-12 13:12:44 -070074void GLTrace_eglSwapBuffers(void* /*dpy*/, void* /*draw*/) {
Siva Velusamy0469dd62011-11-30 15:05:37 -080075 GLMessage glmessage;
76 GLTraceContext *glContext = getGLTraceContext();
77
Siva Velusamy93a826f2011-12-14 12:19:56 -080078 glmessage.set_context_id(glContext->getId());
Siva Velusamy0469dd62011-11-30 15:05:37 -080079 glmessage.set_function(GLMessage::eglSwapBuffers);
80
Siva Velusamy3f194e62012-01-03 14:39:31 -080081 if (glContext->getGlobalTraceState()->shouldCollectFbOnEglSwap()) {
82 // read FB0 since that is what is displayed on the screen
83 fixup_addFBContents(glContext, &glmessage, FB0);
84 }
Siva Velusamy56ac6ff2011-12-15 17:32:05 -080085
86 // set start time and duration
87 glmessage.set_start_time(systemTime());
88 glmessage.set_duration(0);
89
Siva Velusamy93a826f2011-12-14 12:19:56 -080090 glContext->traceGLMessage(&glmessage);
Siva Velusamy0469dd62011-11-30 15:05:37 -080091}
92
93};
94};