aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2014-06-18 13:09:11 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-18 13:09:11 -0700
commit3eee3834fba1d2e29dfb61adcb97e4624b6a3ac8 (patch)
treec886edc991300cac6a6da68c396597df04103ae1 /src
parent1d7975b1c0449f9de0825df2a00951f0173a56a0 (diff)
Modify gpu debug markers to store gpu device markers when a flush occurs.
BUG=skia: R=bsalomon@google.com Author: egdaniel@google.com Review URL: https://codereview.chromium.org/341583002
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrDrawTarget.cpp27
-rw-r--r--src/gpu/GrDrawTarget.h16
-rw-r--r--src/gpu/GrInOrderDrawBuffer.cpp2
-rw-r--r--src/gpu/GrTraceMarker.cpp31
-rw-r--r--src/gpu/GrTraceMarker.h30
5 files changed, 72 insertions, 34 deletions
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index d20368197b..7cdb743a49 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -578,7 +578,30 @@ void GrDrawTarget::drawPaths(int pathCount, const GrPath** paths,
dstCopy.texture() ? &dstCopy : NULL);
}
-void GrDrawTarget::addGpuTraceMarker(GrGpuTraceMarker* marker) {
+typedef GrTraceMarkerSet::Iter TMIter;
+void GrDrawTarget::saveActiveTraceMarkers() {
+ if (this->caps()->gpuTracingSupport()) {
+ SkASSERT(0 == fStoredTraceMarkers.count());
+ fStoredTraceMarkers.addSet(fActiveTraceMarkers);
+ for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMarkers.end(); ++iter) {
+ this->removeGpuTraceMarker(&(*iter));
+ }
+ }
+}
+
+void GrDrawTarget::restoreActiveTraceMarkers() {
+ if (this->caps()->gpuTracingSupport()) {
+ SkASSERT(0 == fActiveTraceMarkers.count());
+ for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMarkers.end(); ++iter) {
+ this->addGpuTraceMarker(&(*iter));
+ }
+ for (TMIter iter = fActiveTraceMarkers.begin(); iter != fActiveTraceMarkers.end(); ++iter) {
+ this->fStoredTraceMarkers.remove(*iter);
+ }
+ }
+}
+
+void GrDrawTarget::addGpuTraceMarker(const GrGpuTraceMarker* marker) {
if (this->caps()->gpuTracingSupport()) {
SkASSERT(fGpuTraceMarkerCount >= 0);
this->fActiveTraceMarkers.add(*marker);
@@ -587,7 +610,7 @@ void GrDrawTarget::addGpuTraceMarker(GrGpuTraceMarker* marker) {
}
}
-void GrDrawTarget::removeGpuTraceMarker(GrGpuTraceMarker* marker) {
+void GrDrawTarget::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
if (this->caps()->gpuTracingSupport()) {
SkASSERT(fGpuTraceMarkerCount >= 1);
this->fActiveTraceMarkers.remove(*marker);
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index bbaf5a9676..7898dfdcab 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -448,8 +448,19 @@ public:
* GR_CREATE_GPU_TRACE_MARKER(marker_str, target) will automatically call these at the start
* and end of a code block respectively
*/
- void addGpuTraceMarker(GrGpuTraceMarker* marker);
- void removeGpuTraceMarker(GrGpuTraceMarker* marker);
+ void addGpuTraceMarker(const GrGpuTraceMarker* marker);
+ void removeGpuTraceMarker(const GrGpuTraceMarker* marker);
+
+ /**
+ * Takes the current active set of markers and stores them for later use. Any current marker
+ * in the active set is removed from the active set and the targets remove function is called.
+ * These functions do not work as a stack so you cannot call save a second time before calling
+ * restore. Also, it is assumed that when restore is called the current active set of markers
+ * is empty. When the stored markers are added back into the active set, the targets add marker
+ * is called.
+ */
+ void saveActiveTraceMarkers();
+ void restoreActiveTraceMarkers();
/**
* Copies a pixel rectangle from one surface to another. This call may finalize
@@ -942,6 +953,7 @@ private:
// To keep track that we always have at least as many debug marker adds as removes
int fGpuTraceMarkerCount;
GrTraceMarkerSet fActiveTraceMarkers;
+ GrTraceMarkerSet fStoredTraceMarkers;
typedef SkRefCnt INHERITED;
};
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 801d163e5d..6a503bbfd5 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -591,6 +591,7 @@ void GrInOrderDrawBuffer::flush() {
int currCopySurface = 0;
int currCmdMarker = 0;
+ fDstGpu->saveActiveTraceMarkers();
for (int c = 0; c < numCmds; ++c) {
GrGpuTraceMarker newMarker("", -1);
if (cmd_has_trace_marker(fCmds[c])) {
@@ -666,6 +667,7 @@ void GrInOrderDrawBuffer::flush() {
fDstGpu->removeGpuTraceMarker(&newMarker);
}
}
+ fDstGpu->restoreActiveTraceMarkers();
// we should have consumed all the states, clips, etc.
SkASSERT(fStates.count() == currState);
SkASSERT(fClips.count() == currClip);
diff --git a/src/gpu/GrTraceMarker.cpp b/src/gpu/GrTraceMarker.cpp
index 16c90c2985..11cdd5e2c2 100644
--- a/src/gpu/GrTraceMarker.cpp
+++ b/src/gpu/GrTraceMarker.cpp
@@ -13,36 +13,6 @@
////////////////////////////////////////////////////////////////////////////////
-class GrTraceMarkerSet::Iter {
-public:
- Iter() {};
- Iter& operator=(const Iter& i) {
- fCurrentIndex = i.fCurrentIndex;
- fMarkers = i.fMarkers;
- return *this;
- }
- bool operator==(const Iter& i) const {
- return fCurrentIndex == i.fCurrentIndex && fMarkers == i.fMarkers;
- }
- bool operator!=(const Iter& i) const { return !(*this == i); }
- const GrGpuTraceMarker& operator*() const { return fMarkers->fMarkerArray[fCurrentIndex]; }
- Iter& operator++() {
- SkASSERT(*this != fMarkers->end());
- ++fCurrentIndex;
- return *this;
- }
-
-private:
- friend class GrTraceMarkerSet;
- Iter(const GrTraceMarkerSet* markers, int index)
- : fMarkers(markers), fCurrentIndex(index) {
- SkASSERT(markers);
- }
-
- const GrTraceMarkerSet* fMarkers;
- int fCurrentIndex;
-};
-
////////////////////////////////////////////////////////////////////////////////
GrTraceMarkerSet::GrTraceMarkerSet(const GrTraceMarkerSet& other) {
@@ -114,3 +84,4 @@ GrTraceMarkerSet::Iter GrTraceMarkerSet::begin() const {
GrTraceMarkerSet::Iter GrTraceMarkerSet::end() const {
return Iter(this, this->fMarkerArray.count());
}
+
diff --git a/src/gpu/GrTraceMarker.h b/src/gpu/GrTraceMarker.h
index 7cc2f7f955..fa4904e0c9 100644
--- a/src/gpu/GrTraceMarker.h
+++ b/src/gpu/GrTraceMarker.h
@@ -65,4 +65,34 @@ private:
mutable SkTDArray<GrGpuTraceMarker> fMarkerArray;
};
+class GrTraceMarkerSet::Iter {
+public:
+ Iter() {};
+ Iter& operator=(const Iter& i) {
+ fCurrentIndex = i.fCurrentIndex;
+ fMarkers = i.fMarkers;
+ return *this;
+ }
+ bool operator==(const Iter& i) const {
+ return fCurrentIndex == i.fCurrentIndex && fMarkers == i.fMarkers;
+ }
+ bool operator!=(const Iter& i) const { return !(*this == i); }
+ const GrGpuTraceMarker& operator*() const { return fMarkers->fMarkerArray[fCurrentIndex]; }
+ Iter& operator++() {
+ SkASSERT(*this != fMarkers->end());
+ ++fCurrentIndex;
+ return *this;
+ }
+
+private:
+ friend class GrTraceMarkerSet;
+ Iter(const GrTraceMarkerSet* markers, int index)
+ : fMarkers(markers), fCurrentIndex(index) {
+ SkASSERT(markers);
+ }
+
+ const GrTraceMarkerSet* fMarkers;
+ int fCurrentIndex;
+};
+
#endif