Home | History | Annotate | Download | only in base
      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 
     26 void ScopedTrace::beginTraceImpl(const char* name) {
     27     atrace_begin(VK_TRACE_TAG, name);
     28 }
     29 
     30 void ScopedTrace::endTraceImpl(const char*) {
     31     atrace_end(VK_TRACE_TAG);
     32 }
     33 
     34 } // namespace base
     35 } // namespace android
     36 
     37 #elif __Fuchsia__
     38 
     39 #include <trace/event.h>
     40 
     41 #define VK_TRACE_TAG "gfx"
     42 
     43 namespace android {
     44 namespace base {
     45 
     46 void ScopedTrace::beginTraceImpl(const char* name) {
     47     TRACE_DURATION_BEGIN(VK_TRACE_TAG, name);
     48 }
     49 
     50 void ScopedTrace::endTraceImpl(const char* name) {
     51     TRACE_DURATION_END(VK_TRACE_TAG, name);
     52 }
     53 
     54 } // namespace base
     55 } // namespace android
     56 
     57 #endif
     58 
     59