Index: include/utils/SkEventTracer.h |
diff --git a/include/utils/SkEventTracer.h b/include/utils/SkEventTracer.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..61c21ddb02ca36a9aa95ca606ac92dc9e174c76d |
--- /dev/null |
+++ b/include/utils/SkEventTracer.h |
@@ -0,0 +1,99 @@ |
+/* |
+ * Copyright (C) 2014 Google Inc. All rights reserved. |
+ * |
+ * Redistribution and use in source and binary forms, with or without |
+ * modification, are permitted provided that the following conditions are |
+ * met: |
+ * |
+ * * Redistributions of source code must retain the above copyright |
+ * notice, this list of conditions and the following disclaimer. |
+ * * Redistributions in binary form must reproduce the above |
+ * copyright notice, this list of conditions and the following disclaimer |
+ * in the documentation and/or other materials provided with the |
+ * distribution. |
+ * * Neither the name of Google Inc. nor the names of its |
+ * contributors may be used to endorse or promote products derived from |
+ * this software without specific prior written permission. |
+ * |
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
reed1
2014/01/29 18:38:40
This copyright header seems a lot bigger than the
humper
2014/01/29 18:52:06
Whoops, you're right. Shortened.
|
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ */ |
+ |
+#ifndef EventTracer_h |
+#define EventTracer_h |
reed1
2014/01/29 18:38:40
skia's pattern would be to qualify this guard thus
humper
2014/01/29 18:52:06
Yeah, this is another copy/paste bug; fixed.
|
+ |
+#include "SkTypes.h" |
+ |
+// This will mark the trace event as disabled by default. The user will need |
+// to explicitly enable the event. |
+#define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name |
+ |
+namespace skia { |
reed1
2014/01/29 18:38:40
skia namespace not needed for types like SkEventTr
|
+namespace tracing { |
reed1
2014/01/29 18:38:40
why this other namespace? Is this explicitly to ac
humper
2014/01/29 18:52:06
It's probably unnecessary; it just mirrors the Chr
|
+ |
+typedef uint32_t TraceEventHandle; |
+ |
+// FIXME: Make these global variables thread-safe. Make a value update atomic. |
+SK_API extern long* traceSamplingState[3]; |
+ |
+class SK_API SkEventTracer { |
reed1
2014/01/29 18:38:40
This name is very generic looking (and somewhat a
humper
2014/01/29 18:52:06
Sure, I'm open to any name here.
SkEventTracer im
|
+public: |
+ |
+ static SkEventTracer* GetInstance(); |
+ |
+ static void SetInstance(SkEventTracer* tracer) { |
+ SkDELETE(SkEventTracer::_instance); |
+ SkEventTracer::_instance = tracer; |
+ } |
+ |
+ virtual ~SkEventTracer() { SkDELETE(SkEventTracer::_instance); } |
+ |
+ // The pointer returned from GetCategoryGroupEnabled() points to a |
+ // value with zero or more of the following bits. Used in this class only. |
+ // The TRACE_EVENT macros should only use the value as a bool. |
+ // These values must be in sync with macro values in trace_event.h in chromium. |
+ enum CategoryGroupEnabledFlags { |
+ // Category group enabled for the recording mode. |
+ ENABLED_FOR_RECORDING = 1 << 0, |
+ // Category group enabled for the monitoring mode. |
+ ENABLED_FOR_MONITORING = 1 << 1, |
+ // Category group enabled by SetEventCallbackEnabled(). |
+ ENABLED_FOR_EVENT_CALLBACK = 1 << 2, |
+ }; |
+ |
+ virtual const unsigned char* GetCategoryGroupEnabled(const char* name) = 0; |
+ virtual const char* GetCategoryGroupName( |
+ const unsigned char* category_group_enabled) = 0; |
+ |
+ virtual TraceEventHandle |
+ AddTraceEvent(char phase, |
+ const unsigned char* categoryEnabledFlag, |
+ const char* name, |
+ unsigned long long id, |
+ int numArgs, |
+ const char** argNames, |
+ const unsigned char* argTypes, |
+ const unsigned long long* argValues, |
+ unsigned char flags) = 0; |
+ |
+ virtual void |
+ UpdateTraceEventDuration(const unsigned char* categoryEnabledFlag, |
+ const char* name, |
+ tracing::TraceEventHandle) = 0; |
+private: |
+ static SkEventTracer *_instance; |
+}; |
+ |
+} // namespace tracing |
+} // namespace skia |
+ |
+#endif // EventTracer_h |