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

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: Android Fix 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..33ecbefafbdb15e642afdf78a8f347742eb421f4
--- /dev/null
+++ b/src/gpu/GrTracing.h
@@ -0,0 +1,78 @@
+/*
+ * 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() : p_data_(NULL) {}
+
+ ~GrGpuTraceMarkerGenerator() {
+ if (p_data_) {
+ data_.fTarget->removeGpuTraceMarker(&(data_.fTraceMarker));
+ }
+ }
+
+ void Initialize(const char* marker_str, int* marker_counter, GrDrawTarget* target) {
+ data_.fTarget = target;
+ data_.fTraceMarker.fMarker = marker_str;
+ data_.fTraceMarker.fID = *marker_counter;
+ p_data_ = &data_;
+ data_.fTarget->addGpuTraceMarker(&(data_.fTraceMarker));
+ }
+
+private:
+ /**
+ * This Data struct workaround is to avoid initializing all the members
+ * in Data during construction of this object, since this object is always
+ * constructed, even when tracing is disabled. If the members of Data were
+ * members of this class instead, compiler warnings occur about potential
+ * uninitialized accesses.
+ */
+ struct Data {
bsalomon 2014/03/24 14:34:38 Check out SkTLazy.
+ GrDrawTarget* fTarget;
+ GrGpuTraceMarker fTraceMarker;
+ };
+ Data* p_data_;
+ Data data_;
+};
+
+/**
+ * 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); \
+ if (target->isGpuTracingEnabled()) { \
+ SK_MACRO_APPEND_LINE(TMG).Initialize(name, &name_counter, target);\
+ } \
+
+
+#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