Fix sb/rt size computation
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 9 Aug 2011 13:32:14 +0000 (13:32 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 9 Aug 2011 13:32:14 +0000 (13:32 +0000)
Review URL: http://codereview.appspot.com/4809087/

git-svn-id: http://skia.googlecode.com/svn/trunk@2079 2bbb7eff-a529-9590-31e7-b0007b416f81

gpu/src/GrGLStencilBuffer.h
gpu/src/GrRenderTarget.cpp

index f55f518cdb518759980c73d49ebc7d27f21721dc..c2f6aea8670666da8b326a5df9465bd772927b99 100644 (file)
@@ -37,10 +37,11 @@ public:
     }
 
     virtual size_t sizeInBytes() const {
-        return (size_t) this->width() *
-                        this->height() *
-                        fFormat.fTotalBits *
-                        GrMax(1,this->numSamples());
+        uint64_t size = this->width();
+        size *= this->height();
+        size *= fFormat.fTotalBits;
+        size *= GrMax(1,this->numSamples());
+        return (size_t)(size / 8);
     }
 
     GrGLuint renderbufferID() const {
index 7b2681197d7cf4fe267992fce1f4e51c5a0dfa6d..a5f12165714bd027d8fb3899363c98b568ee9905 100644 (file)
@@ -31,10 +31,11 @@ size_t GrRenderTarget::sizeInBytes() const {
     } else {
         colorBits = GrBytesPerPixel(fConfig);
     }
-    return (size_t) fAllocatedWidth *
-                    fAllocatedHeight *
-                    colorBits *
-                    GrMax(1,fSampleCnt);
+    uint64_t size = fAllocatedWidth;
+    size *= fAllocatedHeight;
+    size *= colorBits;
+    size *= GrMax(1,fSampleCnt);
+    return (size_t)(size / 8);
 }
 
 void GrRenderTarget::flagAsNeedingResolve(const GrIRect* rect) {
@@ -71,4 +72,4 @@ void GrRenderTarget::setStencilBuffer(GrStencilBuffer* stencilBuffer) {
         fStencilBuffer->wasAttachedToRenderTarget(this);
         fStencilBuffer->ref();
     }
-}
\ No newline at end of file
+}