Index: include/gpu/GrTexture.h |
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h |
index ac31f51b001b693a571022e794c15a4ccd6f59d2..0f7fe9ea2f33cc76133a75704d57cef9d8172bf1 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)); |
@@ -109,10 +62,29 @@ 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. |
+ * This function indicates that the texture parameters (wrap mode, filtering, ...) have been |
+ * changed externally to Skia. |
*/ |
- virtual void invalidateCachedState() = 0; |
+ virtual void textureParamsModified() = 0; |
+ SK_ATTR_DEPRECATED("Renamed to textureParamsModified.") |
+ void invalidateCachedState() { this->textureParamsModified(); } |
+ |
+ /** |
+ * Informational texture flags. This will be moved to the private GrTextureImpl class soon. |
+ */ |
+ 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 resetFlag(GrTextureFlags flags) { |
+ fDesc.fFlags = fDesc.fFlags & ~flags; |
+ } |
#ifdef SK_DEBUG |
void validate() const { |
@@ -122,13 +94,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); } |
+ 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 +104,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 +119,64 @@ 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 { |
+public: |
+ SK_DECLARE_INST_COUNT(GrTextureImpl) |
- typedef GrSurface INHERITED; |
+ 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; |
+ } |
+ |
+ bool hasMipMaps() const { |
+ return kNotAllocated_MipMapsStatus != fMipMapsStatus; |
+ } |
+ |
+ 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; |
+ |
+ typedef GrTexture INHERITED; |
}; |
/** |
@@ -204,6 +212,7 @@ public: |
fTexture.reset(SkSafeRef(texture)); |
return texture; |
} |
+ |
private: |
SkAutoTUnref<GrTexture> fTexture; |
SkIPoint fOffset; |