Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2014 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #ifndef GrTracing_DEFINED | |
| 9 #define GrTracing_DEFINED | |
| 10 | |
| 11 #include "SkTraceEvent.h" | |
| 12 | |
| 13 class GrGpuTraceMarker { | |
| 14 public: | |
| 15 GrGpuTraceMarker(const char* marker, int idCounter) : fMarker(marker), fID(i dCounter) {} | |
| 16 | |
| 17 bool operator<(const GrGpuTraceMarker& rhs) const { | |
| 18 return this->fMarker < rhs.fMarker || (this->fMarker == rhs.fMarker && t his->fID < rhs.fID); | |
| 19 } | |
| 20 | |
| 21 bool operator==(const GrGpuTraceMarker& rhs) const { | |
| 22 return (this->fID == rhs.fID && this->fMarker == rhs.fMarker); | |
| 23 } | |
| 24 | |
| 25 const char* fMarker; | |
| 26 int fID; | |
| 27 }; | |
| 28 | |
| 29 template<typename T> | |
| 30 class SkTDArray; | |
| 31 | |
| 32 class GrTraceMarkerSet { | |
| 33 public: | |
| 34 GrTraceMarkerSet() {} | |
| 35 | |
| 36 GrTraceMarkerSet(const GrTraceMarkerSet& other); | |
| 37 | |
| 38 // Adds marker to the set. | |
| 39 void add(const GrGpuTraceMarker& marker); | |
| 40 // Adds all markers from one set into this set. | |
| 41 void addSet(const GrTraceMarkerSet& markerSet); | |
| 42 | |
| 43 void remove(const GrGpuTraceMarker& marker); | |
| 44 | |
| 45 int count() const; | |
| 46 | |
| 47 // First sorts fMarkerArray and returns a string of the format | |
| 48 // MarkerName1(#,#,...)%MarkerName2(#,#,...):... where MarkerName is the | |
| 49 // marker string used in the TraceMarker and the (#,#,..) is a list of insta nce | |
| 50 // id's for the the given marker string | |
| 51 SkString toString() const; | |
| 52 | |
| 53 class Iter; | |
| 54 | |
| 55 Iter begin() const; | |
| 56 | |
| 57 Iter end() const; | |
| 58 | |
| 59 private: | |
| 60 mutable SkTDArray<GrGpuTraceMarker> fMarkerArray; | |
| 61 }; | |
| 62 | |
| 63 class GrDrawTarget; | |
| 64 | |
| 65 /** | |
| 66 * Marker generation class used for adding and removing markers around code bloc ks | |
| 67 */ | |
| 68 class GrGpuTraceMarkerGenerator : public ::SkNoncopyable { | |
| 69 public: | |
| 70 GrGpuTraceMarkerGenerator(const char* marker_str, int* marker_counter, GrDra wTarget* target); | |
|
bsalomon
2014/03/20 16:32:53
I think these should be inlinable. Otherwise we ad
| |
| 71 ~GrGpuTraceMarkerGenerator(); | |
| 72 | |
| 73 private: | |
| 74 GrDrawTarget* fTarget; | |
| 75 GrGpuTraceMarker fTraceMarker; | |
| 76 }; | |
| 77 | |
| 78 ////////// macros to place around the internal draw calls ////////////////// | |
|
bsalomon
2014/03/20 16:32:53
Can we use the /** style comments?
| |
| 79 // GR_CREATE_TRACE_MARKER will place begin and end trace markers for both | |
| 80 // cpu and gpu (if gpu tracing enabled) for the current scope. | |
| 81 // marker is of type const char* and target is of type GrDrawTarget* | |
| 82 | |
| 83 #define GR_CREATE_TRACE_MARKER(marker_str, target) \ | |
|
bsalomon
2014/03/20 16:32:53
If we want to do tracing in SkGpuDevice.cpp we'll
| |
| 84 static const char* static_str = marker_str; \ | |
| 85 static int marker_counter = 0; \ | |
|
bsalomon
2014/03/20 16:32:53
I think these statics need some mangling to make s
| |
| 86 GR_CREATE_GPU_TRACE_MARKER(static_str, target, marker_counter) \ | |
| 87 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), static_str, \ | |
| 88 "id", marker_counter) \ | |
| 89 sk_atomic_inc(&marker_counter); \ | |
| 90 | |
| 91 #define GR_CREATE_GPU_TRACE_MARKER(marker_str, target, marker_counter) \ | |
| 92 GrGpuTraceMarkerGenerator SK_MACRO_APPEND_LINE(TMG)(static_str, \ | |
| 93 &marker_counter, \ | |
| 94 target); \ | |
| 95 | |
| 96 //////////////////////////////////////////////////////////////////////////// | |
| 97 | |
| 98 | |
| 99 #endif | |
| 100 | |
| OLD | NEW |