summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/common/event_tracer.cpp
blob: c9eb5e307373d5bf5f523d33ed9998a5672d4a6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "common/event_tracer.h"

#include "common/debug.h"

namespace angle
{

const unsigned char *GetTraceCategoryEnabledFlag(const char *name)
{
    angle::Platform *platform = ANGLEPlatformCurrent();
    ASSERT(platform);

    const unsigned char *categoryEnabledFlag = platform->getTraceCategoryEnabledFlag(name);
    if (categoryEnabledFlag != nullptr)
    {
        return categoryEnabledFlag;
    }

    static unsigned char disabled = 0;
    return &disabled;
}

Platform::TraceEventHandle AddTraceEvent(char phase, const unsigned char* categoryGroupEnabled, const char* name, unsigned long long id,
                                         int numArgs, const char** argNames, const unsigned char* argTypes,
                                         const unsigned long long* argValues, unsigned char flags)
{
    angle::Platform *platform = ANGLEPlatformCurrent();
    ASSERT(platform);

    double timestamp = platform->monotonicallyIncreasingTime();

    if (timestamp != 0)
    {
        angle::Platform::TraceEventHandle handle =
            platform->addTraceEvent(phase,
                                    categoryGroupEnabled,
                                    name,
                                    id,
                                    timestamp,
                                    numArgs,
                                    argNames,
                                    argTypes,
                                    argValues,
                                    flags);
        ASSERT(handle != 0);
        return handle;
    }

    return static_cast<Platform::TraceEventHandle>(0);
}

}  // namespace angle