1 //
2 // Copyright 2017 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // LoggingAnnotator.cpp: DebugAnnotator implementing logging
7 //
8 
9 #include "libANGLE/LoggingAnnotator.h"
10 
11 #include "libANGLE/trace.h"
12 
13 namespace angle
14 {
15 
getStatus()16 bool LoggingAnnotator::getStatus()
17 {
18     return false;
19 }
20 
beginEvent(gl::Context * context,EntryPoint entryPoint,const char * eventName,const char * eventMessage)21 void LoggingAnnotator::beginEvent(gl::Context *context,
22                                   EntryPoint entryPoint,
23                                   const char *eventName,
24                                   const char *eventMessage)
25 {
26     ANGLE_TRACE_EVENT_BEGIN0("gpu.angle", eventName);
27 }
28 
endEvent(gl::Context * context,const char * eventName,EntryPoint entryPoint)29 void LoggingAnnotator::endEvent(gl::Context *context, const char *eventName, EntryPoint entryPoint)
30 {
31     ANGLE_TRACE_EVENT_END0("gpu.angle", eventName);
32 }
33 
setMarker(const char * markerName)34 void LoggingAnnotator::setMarker(const char *markerName)
35 {
36     ANGLE_TRACE_EVENT_INSTANT0("gpu.angle", markerName);
37 }
38 
logMessage(const gl::LogMessage & msg) const39 void LoggingAnnotator::logMessage(const gl::LogMessage &msg) const
40 {
41     auto *plat = ANGLEPlatformCurrent();
42     if (plat != nullptr)
43     {
44         switch (msg.getSeverity())
45         {
46             case gl::LOG_FATAL:
47             case gl::LOG_ERR:
48                 plat->logError(plat, msg.getMessage().c_str());
49                 break;
50             case gl::LOG_WARN:
51                 plat->logWarning(plat, msg.getMessage().c_str());
52                 break;
53             case gl::LOG_INFO:
54                 plat->logInfo(plat, msg.getMessage().c_str());
55                 break;
56             default:
57                 UNREACHABLE();
58         }
59     }
60     gl::Trace(msg.getSeverity(), msg.getMessage().c_str());
61 }
62 
63 }  // namespace angle
64