Add reset context count to GrGpu
git-svn-id: http://skia.googlecode.com/svn/trunk@2605 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 1fc8d47..9ce8fa0 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -32,6 +32,7 @@
GrGpu::GrGpu()
: fContext(NULL)
+ , fResetCnt(0)
, fVertexPool(NULL)
, fIndexPool(NULL)
, fVertexPoolUseCnt(0)
@@ -61,6 +62,11 @@
this->releaseResources();
}
+void GrGpu::resetContext() {
+ this->onResetContext();
+ ++fResetCnt;
+}
+
void GrGpu::abandonResources() {
while (NULL != fResourceHead) {
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index cf29ed7..6961a30 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -288,9 +288,14 @@
void finalizeReservedVertices();
void finalizeReservedIndices();
- // overridden by API-specific derived class to handle re-emitting 3D API
- // preample and dirtying state cache.
- virtual void resetContext() = 0;
+ // called to handle re-emitting 3D API preample and dirtying state cache.
+ void resetContext();
+ // returns the number of times resetContext has been called. This value
+ // can be used a timestamp to detect when state cache is dirty.
+ int resetCount() const { return fResetCnt; }
+
+ // subclass implementation of resetContext
+ virtual void onResetContext() = 0;
// overridden by API-specific derived class to create objects.
virtual GrTexture* onCreateTexture(const GrTextureDesc& desc,
@@ -363,6 +368,8 @@
private:
GrContext* fContext; // not reffed (context refs gpu)
+
+ int fResetCnt;
GrVertexBufferAllocPool* fVertexPool;
diff --git a/src/gpu/GrGpuGL.cpp b/src/gpu/GrGpuGL.cpp
index dc4d78a..1927ae4 100644
--- a/src/gpu/GrGpuGL.cpp
+++ b/src/gpu/GrGpuGL.cpp
@@ -559,7 +559,7 @@
}
}
-void GrGpuGL::resetContext() {
+void GrGpuGL::onResetContext() {
if (gPrintStartupSpew && !fPrintedCaps) {
fPrintedCaps = true;
this->getCaps().print();
diff --git a/src/gpu/GrGpuGL.h b/src/gpu/GrGpuGL.h
index 51eb4ae..f28f578 100644
--- a/src/gpu/GrGpuGL.h
+++ b/src/gpu/GrGpuGL.h
@@ -70,7 +70,7 @@
} fHWBounds;
// GrGpu overrides
- virtual void resetContext();
+ virtual void onResetContext() SK_OVERRIDE;
virtual GrTexture* onCreateTexture(const GrTextureDesc& desc,
const void* srcData,
diff --git a/src/gpu/GrGpuGLFixed.cpp b/src/gpu/GrGpuGLFixed.cpp
index 0c01f77..3534ee7 100644
--- a/src/gpu/GrGpuGLFixed.cpp
+++ b/src/gpu/GrGpuGLFixed.cpp
@@ -67,8 +67,8 @@
GrGpuGLFixed::~GrGpuGLFixed() {
}
-void GrGpuGLFixed::resetContext() {
- INHERITED::resetContext();
+void GrGpuGLFixed::onResetContext() {
+ INHERITED::onResetContext();
GL_CALL(Disable(GR_GL_TEXTURE_2D));
diff --git a/src/gpu/GrGpuGLFixed.h b/src/gpu/GrGpuGLFixed.h
index ede47aa..a1fce70 100644
--- a/src/gpu/GrGpuGLFixed.h
+++ b/src/gpu/GrGpuGLFixed.h
@@ -29,7 +29,7 @@
int indexCount);
private:
- virtual void resetContext();
+ virtual void onResetContext() SK_OVERRIDE;
// Helpers to make code more readable
const GrMatrix& getHWSamplerMatrix(int stage) const {
diff --git a/src/gpu/GrGpuGLShaders.cpp b/src/gpu/GrGpuGLShaders.cpp
index 6817580..c287a30 100644
--- a/src/gpu/GrGpuGLShaders.cpp
+++ b/src/gpu/GrGpuGLShaders.cpp
@@ -360,8 +360,8 @@
}
}
-void GrGpuGLShaders::resetContext() {
- INHERITED::resetContext();
+void GrGpuGLShaders::onResetContext() {
+ INHERITED::onResetContext();
fHWGeometryState.fVertexOffset = ~0;
diff --git a/src/gpu/GrGpuGLShaders.h b/src/gpu/GrGpuGLShaders.h
index fc5215f..baa5d9d 100644
--- a/src/gpu/GrGpuGLShaders.h
+++ b/src/gpu/GrGpuGLShaders.h
@@ -22,14 +22,13 @@
GrGpuGLShaders(const GrGLInterface* glInterface);
virtual ~GrGpuGLShaders();
- virtual void resetContext();
-
virtual void abandonResources();
bool programUnitTest();
protected:
// overrides from GrGpu
+ virtual void onResetContext() SK_OVERRIDE;
virtual bool flushGraphicsState(GrPrimitiveType type);
virtual void setupGeometry(int* startVertex,
int* startIndex,