diff options
author | 2011-08-08 13:21:05 +0000 | |
---|---|---|
committer | 2011-08-08 13:21:05 +0000 | |
commit | 0168afc7196fe82da8af230c93c56f3035d54d2b (patch) | |
tree | 936ea16266be15bc7e58c6351df39ba7cb0c531d /gpu/include/GrTexture.h | |
parent | 2f9462d29fe4c66660251734c64d16628326f8e5 (diff) |
Make RT & TEX base classes aware of NPOT/min-RT bloated size
Review URL: http://codereview.appspot.com/4849045/
git-svn-id: http://skia.googlecode.com/svn/trunk@2057 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu/include/GrTexture.h')
-rw-r--r-- | gpu/include/GrTexture.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/gpu/include/GrTexture.h b/gpu/include/GrTexture.h index 9bdd34022c..77f88fa110 100644 --- a/gpu/include/GrTexture.h +++ b/gpu/include/GrTexture.h @@ -33,6 +33,20 @@ public: int height() const { return fHeight; } /** + * Retrieves the allocated width. It may differ from width for + * NPOT or min-RT size reasons. + * @return allocated width in texels + */ + int allocatedWidth() const { return fAllocatedWidth; } + + /** + * Retrieves the allocated height. It may differ from height for + * NPOT or min-RT size reasons. + * @return allocated height in texels + */ + int allocatedHeight() const { return fAllocatedHeight; } + + /** * Convert from texels to normalized texture coords for POT textures * only. */ @@ -50,7 +64,7 @@ public: * Approximate number of bytes used by the texture */ virtual size_t sizeInBytes() const { - return fWidth * fHeight * GrBytesPerPixel(fConfig); + return fAllocatedWidth * fAllocatedHeight * GrBytesPerPixel(fConfig); } /** @@ -125,11 +139,15 @@ protected: GrTexture(GrGpu* gpu, int width, int height, + int allocatedWidth, + int allocatedHeight, GrPixelConfig config) : INHERITED(gpu) , fRenderTarget(NULL) , fWidth(width) , fHeight(height) + , fAllocatedWidth(allocatedWidth) + , fAllocatedHeight(allocatedHeight) , fConfig(config) { // only make sense if alloc size is pow2 fShiftFixedX = 31 - Gr_clz(fWidth); @@ -146,6 +164,9 @@ protected: private: int fWidth; int fHeight; + int fAllocatedWidth; + int fAllocatedHeight; + // these two shift a fixed-point value into normalized coordinates // for this texture if the texture is power of two sized. int fShiftFixedX; |