10469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy/* 20469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy * Copyright 2011, The Android Open Source Project 30469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy * 40469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy * Licensed under the Apache License, Version 2.0 (the "License"); 50469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy * you may not use this file except in compliance with the License. 60469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy * You may obtain a copy of the License at 70469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy * 80469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy * http://www.apache.org/licenses/LICENSE-2.0 90469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy * 100469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy * Unless required by applicable law or agreed to in writing, software 110469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy * distributed under the License is distributed on an "AS IS" BASIS, 120469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy * See the License for the specific language governing permissions and 140469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy * limitations under the License. 150469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy */ 160469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy 170469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#include <cutils/log.h> 1856ac6ff9bdc3c117e820c5a361ab45049c8b03f8Siva Velusamy#include <utils/Timers.h> 190469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy 200469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#include "gltrace.pb.h" 210469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#include "gltrace_context.h" 220469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#include "gltrace_fixup.h" 230469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy#include "gltrace_transport.h" 240469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy 250469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamynamespace android { 260469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamynamespace gltrace { 270469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy 2893a826f78f6313db791e6fc880439189897651b3Siva Velusamyvoid GLTrace_eglCreateContext(int version, int contextId) { 2993a826f78f6313db791e6fc880439189897651b3Siva Velusamy GLMessage glmessage; 3093a826f78f6313db791e6fc880439189897651b3Siva Velusamy GLTraceContext *glContext = getGLTraceContext(); 3193a826f78f6313db791e6fc880439189897651b3Siva Velusamy 3293a826f78f6313db791e6fc880439189897651b3Siva Velusamy glmessage.set_context_id(contextId); 3393a826f78f6313db791e6fc880439189897651b3Siva Velusamy glmessage.set_function(GLMessage::eglCreateContext); 3493a826f78f6313db791e6fc880439189897651b3Siva Velusamy 3593a826f78f6313db791e6fc880439189897651b3Siva Velusamy // copy argument version 3693a826f78f6313db791e6fc880439189897651b3Siva Velusamy GLMessage_DataType *arg_version = glmessage.add_args(); 3793a826f78f6313db791e6fc880439189897651b3Siva Velusamy arg_version->set_isarray(false); 3893a826f78f6313db791e6fc880439189897651b3Siva Velusamy arg_version->set_type(GLMessage::DataType::INT); 3993a826f78f6313db791e6fc880439189897651b3Siva Velusamy arg_version->add_intvalue(version); 4093a826f78f6313db791e6fc880439189897651b3Siva Velusamy 4193a826f78f6313db791e6fc880439189897651b3Siva Velusamy // copy argument context 4293a826f78f6313db791e6fc880439189897651b3Siva Velusamy GLMessage_DataType *arg_context = glmessage.add_args(); 4393a826f78f6313db791e6fc880439189897651b3Siva Velusamy arg_context->set_isarray(false); 4493a826f78f6313db791e6fc880439189897651b3Siva Velusamy arg_context->set_type(GLMessage::DataType::INT); 4593a826f78f6313db791e6fc880439189897651b3Siva Velusamy arg_context->add_intvalue(contextId); 4693a826f78f6313db791e6fc880439189897651b3Siva Velusamy 4756ac6ff9bdc3c117e820c5a361ab45049c8b03f8Siva Velusamy // set start time and duration 4856ac6ff9bdc3c117e820c5a361ab45049c8b03f8Siva Velusamy glmessage.set_start_time(systemTime()); 4956ac6ff9bdc3c117e820c5a361ab45049c8b03f8Siva Velusamy glmessage.set_duration(0); 5056ac6ff9bdc3c117e820c5a361ab45049c8b03f8Siva Velusamy 5193a826f78f6313db791e6fc880439189897651b3Siva Velusamy glContext->traceGLMessage(&glmessage); 5293a826f78f6313db791e6fc880439189897651b3Siva Velusamy} 5393a826f78f6313db791e6fc880439189897651b3Siva Velusamy 5493a826f78f6313db791e6fc880439189897651b3Siva Velusamyvoid GLTrace_eglMakeCurrent(int contextId) { 5593a826f78f6313db791e6fc880439189897651b3Siva Velusamy GLMessage glmessage; 5693a826f78f6313db791e6fc880439189897651b3Siva Velusamy GLTraceContext *glContext = getGLTraceContext(); 5793a826f78f6313db791e6fc880439189897651b3Siva Velusamy 5893a826f78f6313db791e6fc880439189897651b3Siva Velusamy glmessage.set_context_id(contextId); 5993a826f78f6313db791e6fc880439189897651b3Siva Velusamy glmessage.set_function(GLMessage::eglMakeCurrent); 6093a826f78f6313db791e6fc880439189897651b3Siva Velusamy 6193a826f78f6313db791e6fc880439189897651b3Siva Velusamy // copy argument context 6293a826f78f6313db791e6fc880439189897651b3Siva Velusamy GLMessage_DataType *arg_context = glmessage.add_args(); 6393a826f78f6313db791e6fc880439189897651b3Siva Velusamy arg_context->set_isarray(false); 6493a826f78f6313db791e6fc880439189897651b3Siva Velusamy arg_context->set_type(GLMessage::DataType::INT); 6593a826f78f6313db791e6fc880439189897651b3Siva Velusamy arg_context->add_intvalue(contextId); 6693a826f78f6313db791e6fc880439189897651b3Siva Velusamy 6756ac6ff9bdc3c117e820c5a361ab45049c8b03f8Siva Velusamy // set start time and duration 6856ac6ff9bdc3c117e820c5a361ab45049c8b03f8Siva Velusamy glmessage.set_start_time(systemTime()); 6956ac6ff9bdc3c117e820c5a361ab45049c8b03f8Siva Velusamy glmessage.set_duration(0); 7056ac6ff9bdc3c117e820c5a361ab45049c8b03f8Siva Velusamy 7193a826f78f6313db791e6fc880439189897651b3Siva Velusamy glContext->traceGLMessage(&glmessage); 7293a826f78f6313db791e6fc880439189897651b3Siva Velusamy} 7393a826f78f6313db791e6fc880439189897651b3Siva Velusamy 740469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamyvoid GLTrace_eglSwapBuffers(void *dpy, void *draw) { 750469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy GLMessage glmessage; 760469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy GLTraceContext *glContext = getGLTraceContext(); 770469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy 7893a826f78f6313db791e6fc880439189897651b3Siva Velusamy glmessage.set_context_id(glContext->getId()); 790469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy glmessage.set_function(GLMessage::eglSwapBuffers); 800469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy 813f194e6e3a62cbb846e8948eac8e4ce9aa7444a6Siva Velusamy if (glContext->getGlobalTraceState()->shouldCollectFbOnEglSwap()) { 823f194e6e3a62cbb846e8948eac8e4ce9aa7444a6Siva Velusamy // read FB0 since that is what is displayed on the screen 833f194e6e3a62cbb846e8948eac8e4ce9aa7444a6Siva Velusamy fixup_addFBContents(glContext, &glmessage, FB0); 843f194e6e3a62cbb846e8948eac8e4ce9aa7444a6Siva Velusamy } 8556ac6ff9bdc3c117e820c5a361ab45049c8b03f8Siva Velusamy 8656ac6ff9bdc3c117e820c5a361ab45049c8b03f8Siva Velusamy // set start time and duration 8756ac6ff9bdc3c117e820c5a361ab45049c8b03f8Siva Velusamy glmessage.set_start_time(systemTime()); 8856ac6ff9bdc3c117e820c5a361ab45049c8b03f8Siva Velusamy glmessage.set_duration(0); 8956ac6ff9bdc3c117e820c5a361ab45049c8b03f8Siva Velusamy 9093a826f78f6313db791e6fc880439189897651b3Siva Velusamy glContext->traceGLMessage(&glmessage); 910469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy} 920469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy 930469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy}; 940469dd6d55fa331bfd7de9431da98b6340d82271Siva Velusamy}; 95