Some cleanup of GrResource
Review URL: http://codereview.appspot.com/6139043/ git-svn-id: http://skia.googlecode.com/svn/trunk@3782 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
c4ae974db6
commit
76b7fcc79e
@ -15,15 +15,11 @@
|
||||
class GrGpu;
|
||||
class GrContext;
|
||||
|
||||
/**
|
||||
* Base class for the GPU resources created by a GrContext.
|
||||
*/
|
||||
class GrResource : public GrRefCnt {
|
||||
public:
|
||||
explicit GrResource(GrGpu* gpu);
|
||||
|
||||
virtual ~GrResource() {
|
||||
// subclass should have released this.
|
||||
GrAssert(!isValid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees the resource in the underlying 3D API. It must be safe to call this
|
||||
* when the resource has been previously abandoned.
|
||||
@ -59,26 +55,29 @@ public:
|
||||
/**
|
||||
* Retrieves the context that owns the resource. Note that it is possible
|
||||
* for this to return NULL. When resources have been release()ed or
|
||||
* abandon()ed they no longer have an unknowning context. Destroying a
|
||||
* abandon()ed they no longer have an owning context. Destroying a
|
||||
* GrContext automatically releases all its resources.
|
||||
*/
|
||||
const GrContext* getContext() const;
|
||||
GrContext* getContext();
|
||||
|
||||
protected:
|
||||
explicit GrResource(GrGpu* gpu);
|
||||
virtual ~GrResource();
|
||||
|
||||
GrGpu* getGpu() const { return fGpu; }
|
||||
|
||||
virtual void onRelease() = 0;
|
||||
virtual void onAbandon() = 0;
|
||||
|
||||
GrGpu* getGpu() const { return fGpu; }
|
||||
|
||||
private:
|
||||
GrResource(); // unimpl
|
||||
|
||||
GrGpu* fGpu; // not reffed. This can outlive the GrGpu.
|
||||
|
||||
friend class GrGpu; // GrGpu manages list of resources.
|
||||
|
||||
GrGpu* fGpu; // not reffed. The GrGpu can be deleted while there
|
||||
// are still live GrResources. It will call
|
||||
// release() on all such resources in its
|
||||
// destructor.
|
||||
GrResource* fNext; // dl-list of resources per-GrGpu
|
||||
GrResource* fPrevious;
|
||||
|
||||
|
@ -17,6 +17,11 @@ GrResource::GrResource(GrGpu* gpu) {
|
||||
fGpu->insertResource(this);
|
||||
}
|
||||
|
||||
GrResource::~GrResource() {
|
||||
// subclass should have released this.
|
||||
GrAssert(!this->isValid());
|
||||
}
|
||||
|
||||
void GrResource::release() {
|
||||
if (NULL != fGpu) {
|
||||
this->onRelease();
|
||||
|
Loading…
Reference in New Issue
Block a user