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

Unified Diff: include/gpu/GrTexture.h

Issue 275903002: Factor GrTexture into public GrTexture and private GrTextureImpl. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 months 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/GrTexture.h
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index ac31f51b001b693a571022e794c15a4ccd6f59d2..7767b75221331c58e8a0974cccef6700287943db 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -15,41 +15,10 @@
class GrResourceKey;
class GrTextureParams;
+class GrTextureImpl;
class GrTexture : public GrSurface {
-
public:
- SK_DECLARE_INST_COUNT(GrTexture)
- // from GrResource
- /**
- * Informational texture flags
- */
- enum FlagBits {
- kFirstBit = (kLastPublic_GrTextureFlagBit << 1),
-
- /**
- * This texture should be returned to the texture cache when
- * it is no longer reffed
- */
- kReturnToCache_FlagBit = kFirstBit,
- };
-
- void setFlag(GrTextureFlags flags) {
- fDesc.fFlags = fDesc.fFlags | flags;
- }
- void resetFlag(GrTextureFlags flags) {
- fDesc.fFlags = fDesc.fFlags & ~flags;
- }
- bool isSetFlag(GrTextureFlags flags) const {
- return 0 != (fDesc.fFlags & flags);
- }
-
- void dirtyMipMaps(bool mipMapsDirty);
-
- bool mipMapsAreDirty() const {
- return kValid_MipMapsStatus != fMipMapsStatus;
- }
-
/**
* Approximate number of bytes used by the texture
*/
@@ -68,30 +37,14 @@ public:
size_t rowBytes = 0,
uint32_t pixelOpsFlags = 0) SK_OVERRIDE;
- /**
- * @return this texture
- */
virtual GrTexture* asTexture() SK_OVERRIDE { return this; }
virtual const GrTexture* asTexture() const SK_OVERRIDE { return this; }
+ virtual GrRenderTarget* asRenderTarget() SK_OVERRIDE { return fRenderTarget.get(); }
+ virtual const GrRenderTarget* asRenderTarget() const SK_OVERRIDE { return fRenderTarget.get(); }
/**
- * Retrieves the render target underlying this texture that can be passed to
- * GrGpu::setRenderTarget().
- *
- * @return handle to render target or NULL if the texture is not a
- * render target
- */
- virtual GrRenderTarget* asRenderTarget() SK_OVERRIDE {
- return fRenderTarget.get();
- }
- virtual const GrRenderTarget* asRenderTarget() const SK_OVERRIDE {
- return fRenderTarget.get();
- }
-
- // GrTexture
- /**
- * Convert from texels to normalized texture coords for POT textures
- * only.
+ * Convert from texels to normalized texture coords for POT textures only. Please don't add
+ * new callsites for these functions. They are slated for removal.
*/
SkFixed normalizeFixedX(SkFixed x) const {
SkASSERT(GrIsPow2(fDesc.fWidth));
@@ -108,12 +61,6 @@ public:
*/
virtual GrBackendObject getTextureHandle() const = 0;
- /**
- * Call this when the state of the native API texture object is
- * altered directly, without being tracked by skia.
- */
- virtual void invalidateCachedState() = 0;
-
#ifdef SK_DEBUG
void validate() const {
this->INHERITED::validate();
@@ -122,13 +69,8 @@ public:
}
#endif
- static GrResourceKey ComputeKey(const GrGpu* gpu,
- const GrTextureParams* params,
- const GrTextureDesc& desc,
- const GrCacheID& cacheID);
- static GrResourceKey ComputeScratchKey(const GrTextureDesc& desc);
- static bool NeedsResizing(const GrResourceKey& key);
- static bool NeedsBilerp(const GrResourceKey& key);
+ GrTextureImpl* impl() { return reinterpret_cast<GrTextureImpl*>(this); }
bsalomon 2014/05/09 14:44:15 This can only be static_cast if GrTextureImpl is a
+ const GrTextureImpl* impl() const { return reinterpret_cast<const GrTextureImpl*>(this); }
protected:
// A texture refs its rt representation but not vice-versa. It is up to
@@ -137,13 +79,12 @@ protected:
GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc)
: INHERITED(gpu, isWrapped, desc)
- , fRenderTarget(NULL)
- , fMipMapsStatus(kNotAllocated_MipMapsStatus) {
-
+ , fRenderTarget(NULL) {
// only make sense if alloc size is pow2
fShiftFixedX = 31 - SkCLZ(fDesc.fWidth);
fShiftFixedY = 31 - SkCLZ(fDesc.fHeight);
}
+
virtual ~GrTexture();
// GrResource overrides
@@ -153,22 +94,79 @@ protected:
void validateDesc() const;
private:
- enum MipMapsStatus {
- kNotAllocated_MipMapsStatus,
- kAllocated_MipMapsStatus,
- kValid_MipMapsStatus
- };
+ virtual void internal_dispose() const SK_OVERRIDE;
// these two shift a fixed-point value into normalized coordinates
// for this texture if the texture is power of two sized.
int fShiftFixedX;
int fShiftFixedY;
- MipMapsStatus fMipMapsStatus;
+ typedef GrSurface INHERITED;
+};
- virtual void internal_dispose() const SK_OVERRIDE;
+class GrTextureImpl : public GrTexture {
bsalomon 2014/05/09 14:44:15 Kept this in the same file for the initial review.
+public:
robertphillips 2014/05/09 14:57:22 Name here
bsalomon 2014/05/09 15:10:39 Done.
+ SK_DECLARE_INST_COUNT(GrTexture)
+ /**
+ * Informational texture flags
+ */
+ enum FlagBits {
+ kFirstBit = (kLastPublic_GrTextureFlagBit << 1),
- typedef GrSurface INHERITED;
+ /**
+ * This texture should be returned to the texture cache when
+ * it is no longer reffed
+ */
+ kReturnToCache_FlagBit = kFirstBit,
+ };
+
+ void setFlag(GrTextureFlags flags) {
+ fDesc.fFlags = fDesc.fFlags | flags;
+ }
+ void resetFlag(GrTextureFlags flags) {
+ fDesc.fFlags = fDesc.fFlags & ~flags;
+ }
+ bool isSetFlag(GrTextureFlags flags) const {
+ return 0 != (fDesc.fFlags & flags);
+ }
+
+ void dirtyMipMaps(bool mipMapsDirty);
+
+ bool mipMapsAreDirty() const {
+ return kValid_MipMapsStatus != fMipMapsStatus;
+ }
+
+ /**
+ * Call this when the state of the native API texture object is
+ * altered directly, without being tracked by skia.
+ */
+ virtual void invalidateCachedState() = 0;
+
+ static GrResourceKey ComputeKey(const GrGpu* gpu,
+ const GrTextureParams* params,
+ const GrTextureDesc& desc,
+ const GrCacheID& cacheID);
+ static GrResourceKey ComputeScratchKey(const GrTextureDesc& desc);
+ static bool NeedsResizing(const GrResourceKey& key);
+ static bool NeedsBilerp(const GrResourceKey& key);
+
+protected:
+ GrTextureImpl(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc)
+ : INHERITED(gpu, isWrapped, desc)
+ , fMipMapsStatus(kNotAllocated_MipMapsStatus) {
+ }
+
+private:
+ enum MipMapsStatus {
+ kNotAllocated_MipMapsStatus,
+ kAllocated_MipMapsStatus,
+ kValid_MipMapsStatus
+ };
+
+ MipMapsStatus fMipMapsStatus;
+
robertphillips 2014/05/09 14:57:22 Can't GrTexture just access fMipMapsStatus via the
bsalomon 2014/05/09 15:10:39 It was accessing the flags enum. But I added a pub
+ friend class GrTexture;
+ typedef GrTexture INHERITED;
};
/**
@@ -204,6 +202,7 @@ public:
fTexture.reset(SkSafeRef(texture));
return texture;
}
+
private:
SkAutoTUnref<GrTexture> fTexture;
SkIPoint fOffset;
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/gpu/GrContext.cpp » ('j') | src/gpu/GrTexture.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698