1 // Copyright (C) 2019 The Android Open Source Project 2 // Copyright (C) 2019 Google Inc. 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 #include "android/base/Tracing.h" 16 17 #if defined(__ANDROID__) || defined(HOST_BUILD) 18 19 #include <cutils/trace.h> 20 21 #define VK_TRACE_TAG ATRACE_TAG_GRAPHICS 22 23 namespace android { 24 namespace base { 25 beginTraceImpl(const char * name)26void ScopedTrace::beginTraceImpl(const char* name) { 27 atrace_begin(VK_TRACE_TAG, name); 28 } 29 endTraceImpl(const char *)30void ScopedTrace::endTraceImpl(const char*) { 31 atrace_end(VK_TRACE_TAG); 32 } 33 34 } // namespace base 35 } // namespace android 36 37 #elif __Fuchsia__ 38 39 #ifndef FUCHSIA_NO_TRACE 40 #include <lib/trace/event.h> 41 #endif 42 43 #define VK_TRACE_TAG "gfx" 44 45 namespace android { 46 namespace base { 47 beginTraceImpl(const char * name)48void ScopedTrace::beginTraceImpl(const char* name) { 49 #ifndef FUCHSIA_NO_TRACE 50 TRACE_DURATION_BEGIN(VK_TRACE_TAG, name); 51 #endif 52 } 53 endTraceImpl(const char * name)54void ScopedTrace::endTraceImpl(const char* name) { 55 #ifndef FUCHSIA_NO_TRACE 56 TRACE_DURATION_END(VK_TRACE_TAG, name); 57 #endif 58 } 59 60 } // namespace base 61 } // namespace android 62 63 #endif 64 65