Flutter Engine
The Flutter Engine
SkEventTracer.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
11
12#include <stdlib.h>
13#include <atomic>
14
17 addTraceEvent(char phase,
18 const uint8_t* categoryEnabledFlag,
19 const char* name,
20 uint64_t id,
21 int numArgs,
22 const char** argNames,
23 const uint8_t* argTypes,
24 const uint64_t* argValues,
25 uint8_t flags) override { return 0; }
26
27 void
28 updateTraceEventDuration(const uint8_t* categoryEnabledFlag,
29 const char* name,
30 SkEventTracer::Handle handle) override {}
31
32 const uint8_t* getCategoryGroupEnabled(const char* name) override {
33 static uint8_t no = 0;
34 return &no;
35 }
36 const char* getCategoryGroupName(
37 const uint8_t* categoryEnabledFlag) override {
38 static const char* stub = "stub";
39 return stub;
40 }
41
42 // The default tracer does not yet support splitting up trace output into sections.
43 void newTracingSection(const char* name) override {}
44};
45
46// We prefer gUserTracer if it's been set, otherwise we fall back on a default tracer;
47static std::atomic<SkEventTracer*> gUserTracer{nullptr};
48
49bool SkEventTracer::SetInstance(SkEventTracer* tracer, bool leakTracer) {
50 SkEventTracer* expected = nullptr;
51 if (!gUserTracer.compare_exchange_strong(expected, tracer)) {
52 delete tracer;
53 return false;
54 }
55 // If leaking the tracer is accepted then there is no need to install
56 // the atexit.
57 if (!leakTracer) {
58 atexit([]() { delete gUserTracer.load(); });
59 }
60 return true;
61}
62
64 if (auto tracer = gUserTracer.load(std::memory_order_acquire)) {
65 return tracer;
66 }
67 static SkOnce once;
68 static SkDefaultEventTracer* defaultTracer;
69 once([] { defaultTracer = new SkDefaultEventTracer; });
70 return defaultTracer;
71}
static std::atomic< SkEventTracer * > gUserTracer
uint64_t Handle
Definition: SkEventTracer.h:26
static SkEventTracer * GetInstance()
static bool SetInstance(SkEventTracer *, bool leakTracer=false)
Definition: SkOnce.h:22
FlutterSemanticsFlag flags
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32