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

Unified Diff: include/gpu/GrTexture.h

Issue 278073002: Revert of 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
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrTexture.h
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index 03ea0584855d3258f61b43650a2db0b7dc58daa2..ac31f51b001b693a571022e794c15a4ccd6f59d2 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -15,10 +15,41 @@
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
*/
@@ -37,14 +68,30 @@
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(); }
-
- /**
- * 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.
+
+ /**
+ * 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.
*/
SkFixed normalizeFixedX(SkFixed x) const {
SkASSERT(GrIsPow2(fDesc.fWidth));
@@ -61,6 +108,12 @@
*/
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();
@@ -68,83 +121,6 @@
this->validateDesc();
}
#endif
-
- 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
- // the subclass constructor to initialize this pointer.
- SkAutoTUnref<GrRenderTarget> fRenderTarget;
-
- GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc)
- : INHERITED(gpu, isWrapped, desc)
- , fRenderTarget(NULL) {
- // only make sense if alloc size is pow2
- fShiftFixedX = 31 - SkCLZ(fDesc.fWidth);
- fShiftFixedY = 31 - SkCLZ(fDesc.fHeight);
- }
-
- virtual ~GrTexture();
-
- // GrResource overrides
- virtual void onRelease() SK_OVERRIDE;
- virtual void onAbandon() SK_OVERRIDE;
-
- void validateDesc() const;
-
-private:
- 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;
-
- typedef GrSurface INHERITED;
-};
-
-class GrTextureImpl : public GrTexture {
-public:
- SK_DECLARE_INST_COUNT(GrTextureImpl)
- /**
- * 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;
- }
-
- bool hasMipMaps() const {
- return kNotAllocated_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,
@@ -155,10 +131,26 @@
static bool NeedsBilerp(const GrResourceKey& key);
protected:
- GrTextureImpl(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc)
+ // A texture refs its rt representation but not vice-versa. It is up to
+ // the subclass constructor to initialize this pointer.
+ SkAutoTUnref<GrRenderTarget> fRenderTarget;
+
+ GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc)
: INHERITED(gpu, isWrapped, desc)
+ , fRenderTarget(NULL)
, fMipMapsStatus(kNotAllocated_MipMapsStatus) {
- }
+
+ // only make sense if alloc size is pow2
+ fShiftFixedX = 31 - SkCLZ(fDesc.fWidth);
+ fShiftFixedY = 31 - SkCLZ(fDesc.fHeight);
+ }
+ virtual ~GrTexture();
+
+ // GrResource overrides
+ virtual void onRelease() SK_OVERRIDE;
+ virtual void onAbandon() SK_OVERRIDE;
+
+ void validateDesc() const;
private:
enum MipMapsStatus {
@@ -167,9 +159,16 @@
kValid_MipMapsStatus
};
+ // 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 GrTexture INHERITED;
+ virtual void internal_dispose() const SK_OVERRIDE;
+
+ typedef GrSurface INHERITED;
};
/**
@@ -205,7 +204,6 @@
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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698