SkEventTracer.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (C) 2014 Google Inc. All rights reserved.
  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. #ifndef SkEventTracer_DEFINED
  8. #define SkEventTracer_DEFINED
  9. // The class in this header defines the interface between Skia's internal
  10. // tracing macros and an external entity (e.g., Chrome) that will consume them.
  11. // Such an entity should subclass SkEventTracer and provide an instance of
  12. // that event to SkEventTracer::SetInstance.
  13. // If you're looking for the tracing macros to instrument Skia itself, those
  14. // live in src/core/SkTraceEvent.h
  15. #include "include/core/SkTypes.h"
  16. class SK_API SkEventTracer {
  17. public:
  18. typedef uint64_t Handle;
  19. /**
  20. * If this is the first call to SetInstance or GetInstance then the passed instance is
  21. * installed and true is returned. Otherwise, false is returned. In either case ownership of the
  22. * tracer is transferred and it will be deleted when no longer needed.
  23. */
  24. static bool SetInstance(SkEventTracer*);
  25. /**
  26. * Gets the event tracer. If this is the first call to SetInstance or GetIntance then a default
  27. * event tracer is installed and returned.
  28. */
  29. static SkEventTracer* GetInstance();
  30. virtual ~SkEventTracer() { }
  31. // The pointer returned from GetCategoryGroupEnabled() points to a
  32. // value with zero or more of the following bits. Used in this class only.
  33. // The TRACE_EVENT macros should only use the value as a bool.
  34. // These values must be in sync with macro values in trace_event.h in chromium.
  35. enum CategoryGroupEnabledFlags {
  36. // Category group enabled for the recording mode.
  37. kEnabledForRecording_CategoryGroupEnabledFlags = 1 << 0,
  38. // Category group enabled for the monitoring mode.
  39. kEnabledForMonitoring_CategoryGroupEnabledFlags = 1 << 1,
  40. // Category group enabled by SetEventCallbackEnabled().
  41. kEnabledForEventCallback_CategoryGroupEnabledFlags = 1 << 2,
  42. };
  43. virtual const uint8_t* getCategoryGroupEnabled(const char* name) = 0;
  44. virtual const char* getCategoryGroupName(const uint8_t* categoryEnabledFlag) = 0;
  45. virtual SkEventTracer::Handle
  46. addTraceEvent(char phase,
  47. const uint8_t* categoryEnabledFlag,
  48. const char* name,
  49. uint64_t id,
  50. int32_t numArgs,
  51. const char** argNames,
  52. const uint8_t* argTypes,
  53. const uint64_t* argValues,
  54. uint8_t flags) = 0;
  55. virtual void
  56. updateTraceEventDuration(const uint8_t* categoryEnabledFlag,
  57. const char* name,
  58. SkEventTracer::Handle handle) = 0;
  59. };
  60. #endif // SkEventTracer_DEFINED