aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-23 20:25:22 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-23 20:25:22 +0000
commit728302281920727b96e6cec0bfc7575900f34a8b (patch)
treee6db912047f689e3a89e8e26b55c1fab27a42ff3 /include
parentf91c63e116fda7385d9265a00d3302f46baf25c2 (diff)
Make GrResource know whether 3D objects' lifetimes are managed by Skia or not.
Review URL: https://codereview.appspot.com/7201046 git-svn-id: http://skia.googlecode.com/svn/trunk@7348 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrRenderTarget.h3
-rw-r--r--include/gpu/GrResource.h14
-rw-r--r--include/gpu/GrSurface.h4
-rw-r--r--include/gpu/GrTexture.h5
4 files changed, 18 insertions, 8 deletions
diff --git a/include/gpu/GrRenderTarget.h b/include/gpu/GrRenderTarget.h
index 9964c9b7ed..4e77466b9a 100644
--- a/include/gpu/GrRenderTarget.h
+++ b/include/gpu/GrRenderTarget.h
@@ -139,10 +139,11 @@ public:
protected:
GrRenderTarget(GrGpu* gpu,
+ bool isWrapped,
GrTexture* texture,
const GrTextureDesc& desc,
Origin origin)
- : INHERITED(gpu, desc, origin)
+ : INHERITED(gpu, isWrapped, desc, origin)
, fStencilBuffer(NULL)
, fTexture(texture) {
fResolveRect.setLargestInverted();
diff --git a/include/gpu/GrResource.h b/include/gpu/GrResource.h
index 3c306f88c6..9330abba49 100644
--- a/include/gpu/GrResource.h
+++ b/include/gpu/GrResource.h
@@ -70,7 +70,12 @@ public:
GrResourceEntry* getCacheEntry() { return fCacheEntry; }
protected:
- explicit GrResource(GrGpu* gpu);
+ /**
+ * isWrapped indicates we have wrapped a client-created backend resource in a GrResource. If it
+ * is true then the client is responsible for the lifetime of the underlying backend resource.
+ * Otherwise, our onRelease() should free the resource.
+ */
+ GrResource(GrGpu* gpu, bool isWrapped);
virtual ~GrResource();
GrGpu* getGpu() const { return fGpu; }
@@ -81,9 +86,9 @@ protected:
virtual void onAbandon() {};
bool isInCache() const { return NULL != fCacheEntry; }
+ bool isWrapped() const { return kWrapped_Flag & fFlags; }
private:
-
#if GR_DEBUG
friend class GrGpu; // for assert in GrGpu to access getGpu
#endif
@@ -98,6 +103,11 @@ private:
GrResourceEntry* fCacheEntry; // NULL if not in cache
+ enum Flags {
+ kWrapped_Flag,
+ };
+ uint32_t fFlags;
+
typedef GrRefCnt INHERITED;
};
diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h
index d7aa2672d8..4ef0acb82e 100644
--- a/include/gpu/GrSurface.h
+++ b/include/gpu/GrSurface.h
@@ -115,8 +115,8 @@ public:
uint32_t pixelOpsFlags = 0) = 0;
protected:
- GrSurface(GrGpu* gpu, const GrTextureDesc& desc, Origin origin)
- : INHERITED(gpu)
+ GrSurface(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc, Origin origin)
+ : INHERITED(gpu, isWrapped)
, fDesc(desc)
, fOrigin(origin) {
}
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index 36515b49fc..657e6e5078 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -140,8 +140,8 @@ protected:
// base class cons sets to NULL
// subclass cons can create and set
- GrTexture(GrGpu* gpu, const GrTextureDesc& desc, Origin origin)
- : INHERITED(gpu, desc, origin)
+ GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc, Origin origin)
+ : INHERITED(gpu, isWrapped, desc, origin)
, fRenderTarget(NULL) {
// only make sense if alloc size is pow2
@@ -167,4 +167,3 @@ private:
};
#endif
-