• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define ATRACE_TAG ATRACE_TAG_GRAPHICS
20 
21 #include <cutils/trace.h>
22 
23 #define VK_TRACE_TAG ATRACE_TAG_GRAPHICS
24 
25 namespace android {
26 namespace base {
27 
isTracingEnabled()28 bool isTracingEnabled() {
29     return atrace_is_tag_enabled(ATRACE_TAG_GRAPHICS);
30 }
31 
beginTraceImpl(const char * name)32 void ScopedTraceGuest::beginTraceImpl(const char* name) {
33     atrace_begin(VK_TRACE_TAG, name);
34 }
35 
endTraceImpl(const char *)36 void ScopedTraceGuest::endTraceImpl(const char*) {
37     atrace_end(VK_TRACE_TAG);
38 }
39 
40 } // namespace base
41 } // namespace android
42 
43 #elif __Fuchsia__
44 
45 #ifndef FUCHSIA_NO_TRACE
46 #include <lib/trace/event.h>
47 #endif
48 
49 #define VK_TRACE_TAG "gfx"
50 
51 namespace android {
52 namespace base {
53 
isTracingEnabled()54 bool isTracingEnabled() {
55     // TODO: Fuchsia
56     return false;
57 }
58 
beginTraceImpl(const char * name)59 void ScopedTraceGuest::beginTraceImpl(const char* name) {
60 #ifndef FUCHSIA_NO_TRACE
61     TRACE_DURATION_BEGIN(VK_TRACE_TAG, name);
62 #endif
63 }
64 
endTraceImpl(const char * name)65 void ScopedTraceGuest::endTraceImpl(const char* name) {
66 #ifndef FUCHSIA_NO_TRACE
67     TRACE_DURATION_END(VK_TRACE_TAG, name);
68 #endif
69 }
70 
71 } // namespace base
72 } // namespace android
73 
74 #endif
75 
76