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

Side by Side Diff: src/gpu/GrTraceMarker.cpp

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, 8 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrTraceMarker.h ('k') | src/gpu/GrTracing.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2014 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9 #include "GrTraceMarker.h"
10 #include "GrTracing.h"
11 #include "SkString.h"
12 #include "SkTSort.h"
13
14 ////////////////////////////////////////////////////////////////////////////////
15
16 class GrTraceMarkerSet::Iter {
17 public:
18 Iter() {};
19 Iter& operator=(const Iter& i) {
20 fCurrentIndex = i.fCurrentIndex;
21 fMarkers = i.fMarkers;
22 return *this;
23 }
24 bool operator==(const Iter& i) const {
25 return fCurrentIndex == i.fCurrentIndex && fMarkers == i.fMarkers;
26 }
27 bool operator!=(const Iter& i) const { return !(*this == i); }
28 const GrGpuTraceMarker& operator*() const { return fMarkers->fMarkerArray[fC urrentIndex]; }
29 Iter& operator++() {
30 SkASSERT(*this != fMarkers->end());
31 ++fCurrentIndex;
32 return *this;
33 }
34
35 private:
36 friend class GrTraceMarkerSet;
37 Iter(const GrTraceMarkerSet* markers, int index)
38 : fMarkers(markers), fCurrentIndex(index) {
39 SkASSERT(markers);
40 }
41
42 const GrTraceMarkerSet* fMarkers;
43 int fCurrentIndex;
44 };
45
46 ////////////////////////////////////////////////////////////////////////////////
47
48 GrTraceMarkerSet::GrTraceMarkerSet(const GrTraceMarkerSet& other) {
49 this->addSet(other);
50 }
51
52 void GrTraceMarkerSet::add(const GrGpuTraceMarker& marker) {
53 this->fMarkerArray.push(marker);
54 }
55
56 void GrTraceMarkerSet::addSet(const GrTraceMarkerSet& markerSet) {
57 for (Iter iter = markerSet.begin(); iter != markerSet.end(); ++iter) {
58 this->add(*iter);
59 }
60 }
61
62 void GrTraceMarkerSet::remove(const GrGpuTraceMarker& marker) {
63 SkASSERT(-1 != fMarkerArray.find(marker));
64 int index = this->fMarkerArray.find(marker);
65 this->fMarkerArray.remove(index);
66 }
67
68 int GrTraceMarkerSet::count() const {
69 return this->fMarkerArray.count();
70 }
71
72 SkString GrTraceMarkerSet::toString() const {
73 SkTQSort<GrGpuTraceMarker>(this->fMarkerArray.begin(), this->fMarkerArray.en d() - 1);
74 SkString marker_string;
75 const char* prevMarkerName = "";
76 int prevMarkerID = -1;
77 int counter = 0;
78 const int numMarkers = this->fMarkerArray.count();
79
80 // check used for GrGpuGL device after we've already collapsed all markers
81 if (1 == numMarkers && -1 == this->fMarkerArray[0].fID) {
82 marker_string.append(this->fMarkerArray[0].fMarker);
83 return marker_string;
84 }
85
86 for (int i = 0; i < numMarkers; ++i ) {
87 GrGpuTraceMarker& currMarker = this->fMarkerArray[i];
88 const char* currCmd = currMarker.fMarker;
89 if (currCmd != prevMarkerName) {
90 if (counter != 0) {
91 marker_string.append(") ");
92 }
93 marker_string.append(currCmd);
94 marker_string.append("(");
95 marker_string.appendS32(currMarker.fID);
96 prevMarkerName = currCmd;
97 } else if (currMarker.fID != prevMarkerID) {
98 marker_string.append(", ");
99 marker_string.appendS32(currMarker.fID);
100 }
101 prevMarkerID = currMarker.fID;
102 ++counter;
103 }
104 if (counter > 0) {
105 marker_string.append(")");
106 }
107 return marker_string;
108 }
109
110 GrTraceMarkerSet::Iter GrTraceMarkerSet::begin() const {
111 return Iter(this, 0);
112 }
113
114 GrTraceMarkerSet::Iter GrTraceMarkerSet::end() const {
115 return Iter(this, this->fMarkerArray.count());
116 }
117
OLDNEW
« no previous file with comments | « src/gpu/GrTraceMarker.h ('k') | src/gpu/GrTracing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698