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

Unified Diff: src/gpu/GrTracing.h

Issue 340893002: Allow gpu debug markers to be placed by using a GrContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add add/remove marker to GrContext Created 6 years, 6 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/GrContext.cpp ('k') | src/gpu/SkGpuDevice.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
index cfce039b6ce28cdef83954a121c3ba91d20c52ef..311042f27b50659f6f7ca1152741aae1b38e6786 100644
--- a/src/gpu/GrTracing.h
+++ b/src/gpu/GrTracing.h
@@ -9,6 +9,8 @@
#define GrTracing_DEFINED
#include "GrDrawTarget.h"
+#include "GrGpu.h"
+#include "GrInOrderDrawBuffer.h"
#include "GrTraceMarker.h"
#include "SkTraceEvent.h"
@@ -37,6 +39,28 @@ private:
SkTLazy<GrGpuTraceMarker> fTraceMarker;
};
+class GrGpuTraceMarkerGeneratorContext : public ::SkNoncopyable {
+public:
+ GrGpuTraceMarkerGeneratorContext(GrContext* context) : fContext(context) {}
+
+ ~GrGpuTraceMarkerGeneratorContext() {
+ if (fTraceMarker.isValid()) {
+ fContext->removeGpuTraceMarker(fTraceMarker.get());
+ }
+ }
+
+ void initialize(const char* marker_str, int* marker_counter) {
+ GrGpuTraceMarker* traceMarker = fTraceMarker.init();
+ traceMarker->fMarker = marker_str;
+ traceMarker->fID = *marker_counter;
+ fContext->addGpuTraceMarker(traceMarker);
+ }
+
+private:
+ GrContext* fContext;
+ 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.
@@ -48,12 +72,12 @@ private:
INTERNAL_GR_CREATE_TRACE_MARKER(SK_MACRO_APPEND_LINE(static_name), \
SK_MACRO_APPEND_LINE(name_counter), \
target) \
+ sk_atomic_inc(&SK_MACRO_APPEND_LINE(name_counter)); \
#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); \
@@ -61,5 +85,24 @@ private:
SK_MACRO_APPEND_LINE(TMG).initialize(name, &name_counter); \
} \
+#define GR_CREATE_TRACE_MARKER_CONTEXT(name, context) \
+ static const char* SK_MACRO_APPEND_LINE(static_name) = name; \
+ static int SK_MACRO_APPEND_LINE(name_counter) = 0; \
+ INTERNAL_GR_CREATE_TRACE_MARKER_C(SK_MACRO_APPEND_LINE(static_name), \
+ SK_MACRO_APPEND_LINE(name_counter), \
+ context) \
+ sk_atomic_inc(&SK_MACRO_APPEND_LINE(name_counter)); \
+
+#define INTERNAL_GR_CREATE_TRACE_MARKER_C(name, name_counter, context) \
+ GR_CREATE_GPU_TRACE_MARKER_C(name, name_counter, context) \
+ TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("skia.gpu"),name, \
+ "id", name_counter) \
+
+#define GR_CREATE_GPU_TRACE_MARKER_C(name, name_counter, context) \
+ GrGpuTraceMarkerGeneratorContext SK_MACRO_APPEND_LINE(TMG)(context); \
+ if (context->isGpuTracingEnabled()) { \
+ SK_MACRO_APPEND_LINE(TMG).initialize(name, &name_counter); \
+ } \
+
#endif
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698