Add GrResource base class for ibs, texs, vbs, etc.
Add lostContext() to GrContext.
Review URL: http://codereview.appspot.com/4328044/
git-svn-id: http://skia.googlecode.com/svn/trunk@1026 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/include/GrGpu.h b/gpu/include/GrGpu.h
index 7e12456..c4f5e4b 100644
--- a/gpu/include/GrGpu.h
+++ b/gpu/include/GrGpu.h
@@ -25,6 +25,7 @@
class GrVertexBufferAllocPool;
class GrIndexBufferAllocPool;
+class GrResource;
class GrGpu : public GrDrawTarget {
@@ -158,7 +159,7 @@
* will be embedded in a power of two texture. The extra width and height
* is filled as though srcData were rendered clamped into the texture.
*
- * If kRenderTarget_TextureFlag is specified the GrRenderTarget is
+ * If kRenderTarget_TextureFlag is specified the GrRenderTarget is
* accessible via GrTexture::asRenderTarget(). The texture will hold a ref
* on the render target until its releaseRenderTarget() is called or it is
* destroyed.
@@ -353,11 +354,34 @@
bool readPixels(int left, int top, int width, int height,
GrTexture::PixelConfig, void* buffer);
-
const Stats& getStats() const;
void resetStats();
void printStats() const;
+ /**
+ * Called to tell Gpu object that all GrResources have been lost and should
+ * be abandoned.
+ */
+ void abandonResources();
+
+ /**
+ * Called to tell Gpu object to release all GrResources.
+ */
+ void releaseResources();
+
+ /**
+ * Add resource to list of resources. Should only be called by GrResource.
+ * @param resource the resource to add.
+ */
+ void insertResource(GrResource* resource);
+
+ /**
+ * Remove resource from list of resources. Should only be called by
+ * GrResource.
+ * @param resource the resource to remove.
+ */
+ void removeResource(GrResource* resource);
+
protected:
enum PrivateStateBits {
kFirstBit = (kLastPublicStateBit << 1),
@@ -535,6 +559,8 @@
bool fVertexPoolInUse;
bool fIndexPoolInUse;
+ GrResource* fResourceHead;
+
// used to save and restore state when the GrGpu needs
// to make its geometry pools available internally
class AutoInternalDrawGeomRestore {