| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrTraceMarker.h" | 9 #include "GrTraceMarker.h" |
| 10 #include "GrTracing.h" | 10 #include "GrTracing.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 void GrTraceMarkerSet::remove(const GrGpuTraceMarker& marker) { | 32 void GrTraceMarkerSet::remove(const GrGpuTraceMarker& marker) { |
| 33 SkASSERT(-1 != fMarkerArray.find(marker)); | 33 SkASSERT(-1 != fMarkerArray.find(marker)); |
| 34 int index = this->fMarkerArray.find(marker); | 34 int index = this->fMarkerArray.find(marker); |
| 35 this->fMarkerArray.remove(index); | 35 this->fMarkerArray.remove(index); |
| 36 } | 36 } |
| 37 | 37 |
| 38 int GrTraceMarkerSet::count() const { | 38 int GrTraceMarkerSet::count() const { |
| 39 return this->fMarkerArray.count(); | 39 return this->fMarkerArray.count(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 SkString GrTraceMarkerSet::toStringLast() const { |
| 43 const int numMarkers = this->fMarkerArray.count(); |
| 44 SkString marker_string; |
| 45 if (numMarkers > 0) { |
| 46 GrGpuTraceMarker& lastMarker = this->fMarkerArray[numMarkers - 1]; |
| 47 marker_string.append(lastMarker.fMarker); |
| 48 if (lastMarker.fID != -1) { |
| 49 marker_string.append("("); |
| 50 marker_string.appendS32(lastMarker.fID); |
| 51 marker_string.append(")"); |
| 52 } |
| 53 } |
| 54 return marker_string; |
| 55 } |
| 56 |
| 42 SkString GrTraceMarkerSet::toString() const { | 57 SkString GrTraceMarkerSet::toString() const { |
| 43 SkTQSort<GrGpuTraceMarker>(this->fMarkerArray.begin(), this->fMarkerArray.en
d() - 1); | 58 SkTQSort<GrGpuTraceMarker>(this->fMarkerArray.begin(), this->fMarkerArray.en
d() - 1); |
| 44 SkString marker_string; | 59 SkString marker_string; |
| 45 const char* prevMarkerName = ""; | 60 const char* prevMarkerName = ""; |
| 46 int prevMarkerID = -1; | 61 int prevMarkerID = -1; |
| 47 int counter = 0; | 62 int counter = 0; |
| 48 const int numMarkers = this->fMarkerArray.count(); | 63 const int numMarkers = this->fMarkerArray.count(); |
| 49 | 64 |
| 50 // check used for GrGpuGL device after we've already collapsed all markers | 65 // check used for GrGpuGL device after we've already collapsed all markers |
| 51 if (1 == numMarkers && -1 == this->fMarkerArray[0].fID) { | 66 if (1 == numMarkers && -1 == this->fMarkerArray[0].fID) { |
| 52 marker_string.append(this->fMarkerArray[0].fMarker); | 67 marker_string.append(this->fMarkerArray[0].fMarker); |
| 53 return marker_string; | 68 return marker_string; |
| 54 } | 69 } |
| 55 | 70 |
| 56 for (int i = 0; i < numMarkers; ++i ) { | 71 for (int i = 0; i < numMarkers; ++i ) { |
| 57 GrGpuTraceMarker& currMarker = this->fMarkerArray[i]; | 72 GrGpuTraceMarker& currMarker = this->fMarkerArray[i]; |
| 58 const char* currCmd = currMarker.fMarker; | 73 const char* currCmd = currMarker.fMarker; |
| 59 if (currCmd != prevMarkerName) { | 74 if (currCmd != prevMarkerName) { |
| 60 if (counter != 0) { | 75 if (prevMarkerID != -1) { |
| 61 marker_string.append(") "); | 76 marker_string.append(") "); |
| 62 } | 77 } |
| 63 marker_string.append(currCmd); | 78 marker_string.append(currCmd); |
| 64 marker_string.append("("); | 79 if (currMarker.fID != -1) { |
| 65 marker_string.appendS32(currMarker.fID); | 80 marker_string.append("("); |
| 81 marker_string.appendS32(currMarker.fID); |
| 82 } |
| 66 prevMarkerName = currCmd; | 83 prevMarkerName = currCmd; |
| 67 } else if (currMarker.fID != prevMarkerID) { | 84 } else if (currMarker.fID != prevMarkerID) { |
| 68 marker_string.append(", "); | 85 marker_string.append(", "); |
| 69 marker_string.appendS32(currMarker.fID); | 86 marker_string.appendS32(currMarker.fID); |
| 70 } | 87 } |
| 71 prevMarkerID = currMarker.fID; | 88 prevMarkerID = currMarker.fID; |
| 72 ++counter; | 89 ++counter; |
| 73 } | 90 } |
| 74 if (counter > 0) { | 91 if (counter > 0 && prevMarkerID != -1) { |
| 75 marker_string.append(")"); | 92 marker_string.append(")"); |
| 76 } | 93 } |
| 77 return marker_string; | 94 return marker_string; |
| 78 } | 95 } |
| 79 | 96 |
| 80 GrTraceMarkerSet::Iter GrTraceMarkerSet::begin() const { | 97 GrTraceMarkerSet::Iter GrTraceMarkerSet::begin() const { |
| 81 return Iter(this, 0); | 98 return Iter(this, 0); |
| 82 } | 99 } |
| 83 | 100 |
| 84 GrTraceMarkerSet::Iter GrTraceMarkerSet::end() const { | 101 GrTraceMarkerSet::Iter GrTraceMarkerSet::end() const { |
| 85 return Iter(this, this->fMarkerArray.count()); | 102 return Iter(this, this->fMarkerArray.count()); |
| 86 } | 103 } |
| 87 | 104 |
| OLD | NEW |