| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrTracing_DEFINED | 8 #ifndef GrTracing_DEFINED |
| 9 #define GrTracing_DEFINED | 9 #define GrTracing_DEFINED |
| 10 | 10 |
| 11 #include "GrBufferedDrawTarget.h" | 11 #include "GrBufferedDrawTarget.h" |
| 12 #include "GrDrawTarget.h" | 12 #include "GrDrawTarget.h" |
| 13 #include "GrGpu.h" | 13 #include "GrGpu.h" |
| 14 #include "GrTraceMarker.h" | 14 #include "GrTraceMarker.h" |
| 15 #include "SkTLazy.h" | 15 #include "SkTLazy.h" |
| 16 #include "SkTraceEvent.h" | 16 #include "SkTraceEvent.h" |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * Marker generation class used for adding and removing markers around code bloc
ks | 19 * Marker generation class used for adding and removing markers around code bloc
ks |
| 20 */ | 20 */ |
| 21 class GrGpuTraceMarkerGenerator : public ::SkNoncopyable { | 21 class GrGpuTraceMarkerGenerator : public ::SkNoncopyable { |
| 22 public: | 22 public: |
| 23 GrGpuTraceMarkerGenerator(GrDrawTarget* target) : fTarget(target) {} | 23 GrGpuTraceMarkerGenerator(GrDrawTarget* target) {} |
| 24 | 24 |
| 25 ~GrGpuTraceMarkerGenerator() { | 25 ~GrGpuTraceMarkerGenerator() { |
| 26 if (fTraceMarker.isValid()) { | 26 if (fTraceMarker.isValid()) { |
| 27 fTarget->removeGpuTraceMarker(fTraceMarker.get()); | 27 // TODO remove trace marker |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 void initialize(const char* marker_str, int* marker_counter) { | 31 void initialize(const char* marker_str, int* marker_counter) { |
| 32 GrGpuTraceMarker* traceMarker = fTraceMarker.init(marker_str, *marker_co
unter); | 32 // GrGpuTraceMarker* traceMarker = fTraceMarker.init(marker_str, *marker
_counter); |
| 33 fTarget->addGpuTraceMarker(traceMarker); | 33 // TODO add trace marker |
| 34 } | 34 } |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 GrDrawTarget* fTarget; | |
| 38 SkTLazy<GrGpuTraceMarker> fTraceMarker; | 37 SkTLazy<GrGpuTraceMarker> fTraceMarker; |
| 39 }; | 38 }; |
| 40 | 39 |
| 41 class GrGpuTraceMarkerGeneratorContext : public ::SkNoncopyable { | 40 class GrGpuTraceMarkerGeneratorContext : public ::SkNoncopyable { |
| 42 public: | 41 public: |
| 43 GrGpuTraceMarkerGeneratorContext(GrContext* context) : fContext(context) {} | 42 GrGpuTraceMarkerGeneratorContext(GrContext* context) {} |
| 44 | 43 |
| 45 ~GrGpuTraceMarkerGeneratorContext() { | 44 ~GrGpuTraceMarkerGeneratorContext() { |
| 46 if (fTraceMarker.isValid()) { | 45 if (fTraceMarker.isValid()) { |
| 47 fContext->removeGpuTraceMarker(fTraceMarker.get()); | 46 // TODO remove trace marker |
| 48 } | 47 } |
| 49 } | 48 } |
| 50 | 49 |
| 51 void initialize(const char* marker_str, int* marker_counter) { | 50 void initialize(const char* marker_str, int* marker_counter) { |
| 52 GrGpuTraceMarker* traceMarker = fTraceMarker.init(marker_str, *marker_co
unter); | 51 // GrGpuTraceMarker* traceMarker = fTraceMarker.init(marker_str, *marker
_counter); |
| 53 fContext->addGpuTraceMarker(traceMarker); | 52 // TODO add trace marker |
| 54 } | 53 } |
| 55 | 54 |
| 56 private: | 55 private: |
| 57 GrContext* fContext; | |
| 58 SkTLazy<GrGpuTraceMarker> fTraceMarker; | 56 SkTLazy<GrGpuTraceMarker> fTraceMarker; |
| 59 }; | 57 }; |
| 60 | 58 |
| 61 /** | 59 /** |
| 62 * GR_CREATE_TRACE_MARKER will place begin and end trace markers for both | 60 * GR_CREATE_TRACE_MARKER will place begin and end trace markers for both |
| 63 * cpu and gpu (if gpu tracing enabled) for the current scope. | 61 * cpu and gpu (if gpu tracing enabled) for the current scope. |
| 64 * marker is of type const char* and target is of type GrDrawTarget* | 62 * marker is of type const char* and target is of type GrDrawTarget* |
| 65 */ | 63 */ |
| 66 #define GR_CREATE_TRACE_MARKER(name, target)
\ | 64 #define GR_CREATE_TRACE_MARKER(name, target)
\ |
| 67 INTERNAL_GR_CREATE_TRACE_MARKER_SCOPED(name, target)
| 65 INTERNAL_GR_CREATE_TRACE_MARKER_SCOPED(name, target)
|
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 GrGpuTraceMarkerGeneratorContext SK_MACRO_APPEND_LINE(TMG)(context);
\ | 123 GrGpuTraceMarkerGeneratorContext SK_MACRO_APPEND_LINE(TMG)(context);
\ |
| 126 bool SK_MACRO_APPEND_LINE(gpuTracingEnabled);
\ | 124 bool SK_MACRO_APPEND_LINE(gpuTracingEnabled);
\ |
| 127 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("skia.gpu"),
\ | 125 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("skia.gpu"),
\ |
| 128 &SK_MACRO_APPEND_LINE(gpuTracingEnabled)
); \ | 126 &SK_MACRO_APPEND_LINE(gpuTracingEnabled)
); \ |
| 129 if (SK_MACRO_APPEND_LINE(gpuTracingEnabled)) {
\ | 127 if (SK_MACRO_APPEND_LINE(gpuTracingEnabled)) {
\ |
| 130 SK_MACRO_APPEND_LINE(TMG).initialize(name, &name_counter);
\ | 128 SK_MACRO_APPEND_LINE(TMG).initialize(name, &name_counter);
\ |
| 131 }
| 129 }
|
| 132 #endif | 130 #endif |
| 133 | 131 |
| 134 #endif | 132 #endif |
| OLD | NEW |