Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Unified Diff: include/gpu/GrGpuResourceRef.h

Issue 695813003: Add class GrGLTextureRenderTarget for GL texture/rendertarget objects (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: forgot to save file Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/gpu/GrGpuResourceRef.h
diff --git a/include/gpu/GrGpuResourceRef.h b/include/gpu/GrGpuResourceRef.h
index 0223f18977e1d99acf8fc38fd84b52a58842221a..93298f0656f4e5e03529c27e04e59233c0dba1bc 100644
--- a/include/gpu/GrGpuResourceRef.h
+++ b/include/gpu/GrGpuResourceRef.h
@@ -9,6 +9,8 @@
#define GrGpuResourceRef_DEFINED
#include "GrGpuResource.h"
+#include "GrRenderTarget.h"
+#include "GrTexture.h"
#include "SkRefCnt.h"
/**
@@ -96,7 +98,7 @@ public:
/** Adopts a ref from the caller. ioType expresses what type of IO operations will be marked as
pending on the resource when markPendingIO is called. */
- GrTGpuResourceRef(T* resource, GrIOType ioType) : INHERITED(resource, ioType) {}
+ GrTGpuResourceRef(T* resource, GrIOType ioType) : INHERITED(resource, ioType) { }
T* get() const { return static_cast<T*>(this->getResource()); }
@@ -108,6 +110,49 @@ private:
typedef GrGpuResourceRef INHERITED;
};
+// Specializations for GrTexture and GrRenderTarget because they use virtual inheritance.
+template<> class GrTGpuResourceRef<GrTexture> : public GrGpuResourceRef {
+public:
+ GrTGpuResourceRef() {}
+
+ GrTGpuResourceRef(GrTexture* texture, GrIOType ioType) : INHERITED(texture, ioType) { }
+
+ GrTexture* get() const {
+ GrSurface* surface = static_cast<GrSurface*>(this->getResource());
+ if (surface) {
+ return surface->asTexture();
+ } else {
+ return NULL;
+ }
+ }
+
+ void set(GrTexture* texture, GrIOType ioType) { this->setResource(texture, ioType); }
+
+private:
+ typedef GrGpuResourceRef INHERITED;
+};
+
+template<> class GrTGpuResourceRef<GrRenderTarget> : public GrGpuResourceRef {
+public:
+ GrTGpuResourceRef() {}
+
+ GrTGpuResourceRef(GrRenderTarget* rt, GrIOType ioType) : INHERITED(rt, ioType) { }
+
+ GrRenderTarget* get() const {
+ GrSurface* surface = static_cast<GrSurface*>(this->getResource());
+ if (surface) {
+ return surface->asRenderTarget();
+ } else {
+ return NULL;
+ }
+ }
+
+ void set(GrRenderTarget* rt, GrIOType ioType) { this->setResource(rt, ioType); }
+
+private:
+ typedef GrGpuResourceRef INHERITED;
+};
+
/**
* This is similar to GrTGpuResourceRef but can only be in the pending IO state. It never owns a
* ref.

Powered by Google App Engine
This is Rietveld 408576698