Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: src/gpu/GrTracing.h

Issue 184443003: Add Gpu Tracing to Ganesh (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Merge fixes 2 Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrTraceMarker.cpp ('k') | src/gpu/gl/GrGLInterface.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrTracing.h
diff --git a/src/gpu/GrTracing.h b/src/gpu/GrTracing.h
new file mode 100644
index 0000000000000000000000000000000000000000..4a79f25b76a045d551f9fcbcbe56ce251e18dcc9
--- /dev/null
+++ b/src/gpu/GrTracing.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrTracing_DEFINED
+#define GrTracing_DEFINED
+
+#include "GrDrawTarget.h"
+#include "GrTraceMarker.h"
+#include "SkTraceEvent.h"
+
+/**
+ * Marker generation class used for adding and removing markers around code blocks
+ */
+class GrGpuTraceMarkerGenerator : public ::SkNoncopyable {
+public:
+ GrGpuTraceMarkerGenerator(GrDrawTarget* target) : fTarget(target) {}
+
+ ~GrGpuTraceMarkerGenerator() {
+ if (fTraceMarker.isValid()) {
+ fTarget->removeGpuTraceMarker(fTraceMarker.get());
+ }
+ }
+
+ void initialize(const char* marker_str, int* marker_counter) {
+ GrGpuTraceMarker* traceMarker = fTraceMarker.init();
+ traceMarker->fMarker = marker_str;
+ traceMarker->fID = *marker_counter;
+ fTarget->addGpuTraceMarker(traceMarker);
+ }
+
+private:
+ GrDrawTarget* fTarget;
+ SkTLazy<GrGpuTraceMarker> fTraceMarker;
+};
+
+/**
+ * GR_CREATE_TRACE_MARKER will place begin and end trace markers for both
+ * cpu and gpu (if gpu tracing enabled) for the current scope.
+ * marker is of type const char* and target is of type GrDrawTarget*
+ */
+#define GR_CREATE_TRACE_MARKER(name, target) \
+ static const char* SK_MACRO_APPEND_LINE(static_name) = name; \
+ static int SK_MACRO_APPEND_LINE(name_counter) = 0; \
+ INTERNAL_GR_CREATE_TRACE_MARKER(SK_MACRO_APPEND_LINE(static_name), \
+ SK_MACRO_APPEND_LINE(name_counter), \
+ target) \
+
+#define INTERNAL_GR_CREATE_TRACE_MARKER(name, name_counter, target) \
+ GR_CREATE_GPU_TRACE_MARKER(name, name_counter, target) \
+ TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("skia.gpu"),name, \
+ "id", name_counter) \
+ sk_atomic_inc(&name_counter); \
+
+#define GR_CREATE_GPU_TRACE_MARKER(name, name_counter, target) \
+ GrGpuTraceMarkerGenerator SK_MACRO_APPEND_LINE(TMG)(target); \
+ if (target->isGpuTracingEnabled()) { \
+ SK_MACRO_APPEND_LINE(TMG).initialize(name, &name_counter); \
+ } \
+
+
+#endif
+
« no previous file with comments | « src/gpu/GrTraceMarker.cpp ('k') | src/gpu/gl/GrGLInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698