aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-10-28 19:50:21 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-10-28 19:50:21 +0000
commit4a018bb20bf969a38ec11d9506843f06366dfa7c (patch)
treea7789f10f6d374adfbde9a9a2dab6f00923295c1
parent7b1ca8c66e0bf20d3c0217faf0a733c1e16c1042 (diff)
Fix pure virtual call from destructor and turn VertBench back on
git-svn-id: http://skia.googlecode.com/svn/trunk@2556 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--bench/VertBench.cpp3
-rw-r--r--src/gpu/GrDrawTarget.cpp11
-rw-r--r--src/gpu/GrDrawTarget.h4
-rw-r--r--src/gpu/GrGpuGL.cpp2
-rw-r--r--src/gpu/GrInOrderDrawBuffer.cpp2
5 files changed, 18 insertions, 4 deletions
diff --git a/bench/VertBench.cpp b/bench/VertBench.cpp
index 8cdecfff29..98df44929e 100644
--- a/bench/VertBench.cpp
+++ b/bench/VertBench.cpp
@@ -82,12 +82,11 @@ protected:
virtual void onDraw(SkCanvas* canvas) {
SkPaint paint;
this->setupPaint(&paint);
-#if 0
+
for (int i = 0; i < N; i++) {
canvas->drawVertices(SkCanvas::kTriangles_VertexMode, PTS,
fPts, NULL, fColors, NULL, fIdx, IDX, paint);
}
-#endif
}
private:
typedef SkBenchmark INHERITED;
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 97ec3ba971..f60484572c 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -430,13 +430,20 @@ GrDrawTarget::GrDrawTarget() {
}
GrDrawTarget::~GrDrawTarget() {
+ GrAssert(1 == fGeoSrcStateStack.count());
+ GeometrySrcState& geoSrc = fGeoSrcStateStack.back();
+ GrAssert(kNone_GeometrySrcType == geoSrc.fIndexSrc);
+ GrAssert(kNone_GeometrySrcType == geoSrc.fVertexSrc);
+}
+
+void GrDrawTarget::releaseGeometry() {
int popCnt = fGeoSrcStateStack.count() - 1;
while (popCnt) {
this->popGeometrySource();
--popCnt;
}
- this->releasePreviousVertexSource();
- this->releasePreviousIndexSource();
+ this->resetVertexSource();
+ this->resetIndexSource();
}
void GrDrawTarget::setClip(const GrClip& clip) {
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 16326a9ba1..7d311aa2ec 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -1366,6 +1366,10 @@ protected:
Caps fCaps;
+ // subclasses must call this in their destructors to ensure all vertex
+ // and index sources have been released (including those held by
+ // pushGeometrySource())
+ void releaseGeometry();
private:
// called when setting a new vert/idx source to unref prev vb/ib
void releasePreviousVertexSource();
diff --git a/src/gpu/GrGpuGL.cpp b/src/gpu/GrGpuGL.cpp
index 012fdc1acb..78655929f3 100644
--- a/src/gpu/GrGpuGL.cpp
+++ b/src/gpu/GrGpuGL.cpp
@@ -309,6 +309,8 @@ GrGpuGL::GrGpuGL(const GrGLInterface* gl, GrGLBinding glBinding) {
}
GrGpuGL::~GrGpuGL() {
+ // This must be called by before the GrDrawTarget destructor
+ this->releaseGeometry();
// This subclass must do this before the base class destructor runs
// since we will unref the GrGLInterface.
this->releaseResources();
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index db20846225..837d2c1db9 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -44,6 +44,8 @@ GrInOrderDrawBuffer::GrInOrderDrawBuffer(const GrGpu* gpu,
GrInOrderDrawBuffer::~GrInOrderDrawBuffer() {
this->reset();
+ // This must be called by before the GrDrawTarget destructor
+ this->releaseGeometry();
GrSafeUnref(fQuadIndexBuffer);
}