• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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(const char * eventName,const char * eventMessage)21 void LoggingAnnotator::beginEvent(const char *eventName, const char *eventMessage)
22 {
23     ANGLE_TRACE_EVENT_BEGIN0("gpu.angle", eventName);
24 }
25 
endEvent(const char * eventName)26 void LoggingAnnotator::endEvent(const char *eventName)
27 {
28     ANGLE_TRACE_EVENT_END0("gpu.angle", eventName);
29 }
30 
setMarker(const char * markerName)31 void LoggingAnnotator::setMarker(const char *markerName)
32 {
33     ANGLE_TRACE_EVENT_INSTANT0("gpu.angle", markerName);
34 }
35 
logMessage(const gl::LogMessage & msg) const36 void LoggingAnnotator::logMessage(const gl::LogMessage &msg) const
37 {
38     auto *plat = ANGLEPlatformCurrent();
39     if (plat != nullptr)
40     {
41         switch (msg.getSeverity())
42         {
43             case gl::LOG_FATAL:
44             case gl::LOG_ERR:
45                 plat->logError(plat, msg.getMessage().c_str());
46                 break;
47             case gl::LOG_WARN:
48                 plat->logWarning(plat, msg.getMessage().c_str());
49                 break;
50             case gl::LOG_INFO:
51                 plat->logInfo(plat, msg.getMessage().c_str());
52                 break;
53             default:
54                 UNREACHABLE();
55         }
56     }
57     gl::Trace(msg.getSeverity(), msg.getMessage().c_str());
58 }
59 
60 }  // namespace angle
61