Flutter Engine
flutter::FlutterEventTracer Class Reference
Inheritance diagram for flutter::FlutterEventTracer:

Public Member Functions

 FlutterEventTracer (bool enabled)
 
SkEventTracer::Handle addTraceEvent (char phase, const uint8_t *category_enabled_flag, const char *name, uint64_t id, int num_args, const char **p_arg_names, const uint8_t *p_arg_types, const uint64_t *p_arg_values, uint8_t flags) override
 
void updateTraceEventDuration (const uint8_t *category_enabled_flag, const char *name, SkEventTracer::Handle handle) override
 
const uint8_t * getCategoryGroupEnabled (const char *name) override
 
const char * getCategoryGroupName (const uint8_t *category_enabled_flag) override
 
void enable ()
 

Static Public Attributes

static constexpr const char * kSkiaTag = "skia"
 
static constexpr uint8_t kYes = 1
 
static constexpr uint8_t kNo = 0
 

Detailed Description

Definition at line 58 of file skia_event_tracer_impl.cc.

Constructor & Destructor Documentation

◆ FlutterEventTracer()

flutter::FlutterEventTracer::FlutterEventTracer ( bool  enabled)
inline

Definition at line 64 of file skia_event_tracer_impl.cc.

Referenced by flutter::InitSkiaEventTracer().

64 : enabled_(enabled ? kYes : kNo){};
static constexpr uint8_t kNo
static constexpr uint8_t kYes

Member Function Documentation

◆ addTraceEvent()

SkEventTracer::Handle flutter::FlutterEventTracer::addTraceEvent ( char  phase,
const uint8_t *  category_enabled_flag,
const char *  name,
uint64_t  id,
int  num_args,
const char **  p_arg_names,
const uint8_t *  p_arg_types,
const uint64_t *  p_arg_values,
uint8_t  flags 
)
inlineoverride

Definition at line 66 of file skia_event_tracer_impl.cc.

References FML_DCHECK, fml::tracing::TraceEvent0(), fml::tracing::TraceEventAsyncBegin0(), fml::tracing::TraceEventAsyncEnd0(), fml::tracing::TraceEventEnd(), and fml::tracing::TraceEventInstant0().

74  {
75 #if defined(OS_FUCHSIA)
76  static trace_site_t trace_site;
77  trace_string_ref_t category_ref;
78  trace_context_t* trace_context = trace_acquire_context_for_category_cached(
79  kSkiaTag, &trace_site, &category_ref);
80 
81  if (likely(!trace_context)) {
82  return 0;
83  }
84 
85  trace_ticks_t ticks = zx_ticks_get();
86 
87  trace_thread_ref_t thread_ref;
88  trace_context_register_current_thread(trace_context, &thread_ref);
89  trace_string_ref_t name_ref;
90  trace_context_register_string_literal(trace_context, name, &name_ref);
91 
92  constexpr int kMaxArgs = 2;
93  trace_arg_t trace_args[kMaxArgs] = {};
94  FML_DCHECK(num_args >= 0);
95  int num_trace_args = std::min(kMaxArgs, num_args);
96 
97  for (int i = 0; i < num_trace_args; i++) {
98  const char* arg_name = p_arg_names[i];
99  const uint8_t arg_type = p_arg_types[i];
100  const uint64_t arg_value = p_arg_values[i];
101 
102  trace_string_ref_t arg_name_string_ref =
103  trace_context_make_registered_string_literal(trace_context, arg_name);
104 
105  trace_arg_value_t trace_arg_value;
106  switch (arg_type) {
107  case TRACE_VALUE_TYPE_BOOL: {
108  trace_arg_value = trace_make_bool_arg_value(!!arg_value);
109  break;
110  }
111  case TRACE_VALUE_TYPE_UINT:
112  trace_arg_value = trace_make_uint64_arg_value(arg_value);
113  break;
114  case TRACE_VALUE_TYPE_INT:
115  trace_arg_value =
116  trace_make_int64_arg_value(BitCast<int64_t>(arg_value));
117  break;
118  case TRACE_VALUE_TYPE_DOUBLE:
119  trace_arg_value =
120  trace_make_double_arg_value(BitCast<double>(arg_value));
121  break;
122  case TRACE_VALUE_TYPE_POINTER:
123  trace_arg_value =
124  trace_make_pointer_arg_value(BitCast<uintptr_t>(arg_value));
125  break;
126  case TRACE_VALUE_TYPE_STRING: {
127  trace_string_ref_t arg_value_string_ref =
128  trace_context_make_registered_string_literal(
129  trace_context, reinterpret_cast<const char*>(arg_value));
130  trace_arg_value = trace_make_string_arg_value(arg_value_string_ref);
131  break;
132  }
133  case TRACE_VALUE_TYPE_COPY_STRING: {
134  const char* arg_value_as_cstring =
135  reinterpret_cast<const char*>(arg_value);
136  trace_string_ref_t arg_value_string_ref =
137  trace_context_make_registered_string_copy(
138  trace_context, arg_value_as_cstring,
139  strlen(arg_value_as_cstring));
140  trace_arg_value = trace_make_string_arg_value(arg_value_string_ref);
141  break;
142  }
143  case TRACE_VALUE_TYPE_CONVERTABLE:
144  trace_arg_value = trace_make_null_arg_value();
145  break;
146  default:
147  trace_arg_value = trace_make_null_arg_value();
148  }
149 
150  trace_args[i] = trace_make_arg(arg_name_string_ref, trace_arg_value);
151  }
152 
153  switch (phase) {
154  case TRACE_EVENT_PHASE_BEGIN:
155  case TRACE_EVENT_PHASE_COMPLETE:
156  trace_context_write_duration_begin_event_record(
157  trace_context, ticks, &thread_ref, &category_ref, &name_ref,
158  trace_args, num_trace_args);
159  break;
160  case TRACE_EVENT_PHASE_END:
161  trace_context_write_duration_end_event_record(
162  trace_context, ticks, &thread_ref, &category_ref, &name_ref,
163  trace_args, num_trace_args);
164  break;
165  case TRACE_EVENT_PHASE_INSTANT:
166  trace_context_write_instant_event_record(
167  trace_context, ticks, &thread_ref, &category_ref, &name_ref,
168  TRACE_SCOPE_THREAD, trace_args, num_trace_args);
169  break;
170  case TRACE_EVENT_PHASE_ASYNC_BEGIN:
171  trace_context_write_async_begin_event_record(
172  trace_context, ticks, &thread_ref, &category_ref, &name_ref, id,
173  trace_args, num_trace_args);
174  break;
175  case TRACE_EVENT_PHASE_ASYNC_END:
176  trace_context_write_async_end_event_record(
177  trace_context, ticks, &thread_ref, &category_ref, &name_ref, id,
178  trace_args, num_trace_args);
179  break;
180  default:
181  break;
182  }
183 
184  trace_release_context(trace_context);
185 
186 #else // defined(OS_FUCHSIA)
187  switch (phase) {
188  case TRACE_EVENT_PHASE_BEGIN:
189  case TRACE_EVENT_PHASE_COMPLETE:
191  break;
192  case TRACE_EVENT_PHASE_END:
194  break;
195  case TRACE_EVENT_PHASE_INSTANT:
197  break;
198  case TRACE_EVENT_PHASE_ASYNC_BEGIN:
200  break;
201  case TRACE_EVENT_PHASE_ASYNC_END:
203  break;
204  default:
205  break;
206  }
207 #endif // defined(OS_FUCHSIA)
208  return 0;
209  }
void TraceEventAsyncEnd0(TraceArg category_group, TraceArg name, TraceIDArg id)
Definition: trace_event.cc:335
#define FML_DCHECK(condition)
Definition: logging.h:86
void TraceEventEnd(TraceArg name)
Definition: trace_event.cc:324
void TraceEventInstant0(TraceArg category_group, TraceArg name)
Definition: trace_event.cc:351
FlutterPointerPhase phase
Definition: fl_view.cc:78
void TraceEventAsyncBegin0(TraceArg category_group, TraceArg name, TraceIDArg id)
Definition: trace_event.cc:331
const char * name
Definition: fuchsia.cc:50
static constexpr const char * kSkiaTag
void TraceEvent0(TraceArg category_group, TraceArg name)
Definition: trace_event.cc:310

◆ enable()

void flutter::FlutterEventTracer::enable ( )
inline

Definition at line 232 of file skia_event_tracer_impl.cc.

References kYes.

Referenced by flutter::enableSkiaTracingCallback().

232 { enabled_ = kYes; }
static constexpr uint8_t kYes

◆ getCategoryGroupEnabled()

const uint8_t* flutter::FlutterEventTracer::getCategoryGroupEnabled ( const char *  name)
inlineoverride

Definition at line 223 of file skia_event_tracer_impl.cc.

223  {
224  return &enabled_;
225  }

◆ getCategoryGroupName()

const char* flutter::FlutterEventTracer::getCategoryGroupName ( const uint8_t *  category_enabled_flag)
inlineoverride

Definition at line 227 of file skia_event_tracer_impl.cc.

References kSkiaTag.

228  {
229  return kSkiaTag;
230  }
static constexpr const char * kSkiaTag

◆ updateTraceEventDuration()

void flutter::FlutterEventTracer::updateTraceEventDuration ( const uint8_t *  category_enabled_flag,
const char *  name,
SkEventTracer::Handle  handle 
)
inlineoverride

Definition at line 211 of file skia_event_tracer_impl.cc.

References fml::tracing::TraceEventEnd().

213  {
214  // This is only ever called from a scoped trace event so we will just end
215  // the section.
216 #if defined(OS_FUCHSIA)
217  TRACE_DURATION_END(kSkiaTag, name);
218 #else
220 #endif
221  }
void TraceEventEnd(TraceArg name)
Definition: trace_event.cc:324
const char * name
Definition: fuchsia.cc:50
static constexpr const char * kSkiaTag

Member Data Documentation

◆ kNo

constexpr uint8_t flutter::FlutterEventTracer::kNo = 0
static

Definition at line 62 of file skia_event_tracer_impl.cc.

◆ kSkiaTag

constexpr const char* flutter::FlutterEventTracer::kSkiaTag = "skia"
static

Definition at line 60 of file skia_event_tracer_impl.cc.

Referenced by getCategoryGroupName().

◆ kYes

constexpr uint8_t flutter::FlutterEventTracer::kYes = 1
static

Definition at line 61 of file skia_event_tracer_impl.cc.

Referenced by enable().


The documentation for this class was generated from the following file: