void GrGLRenderTarget::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) { fRTFBOID = idDesc.fRTFBOID; fTexFBOID = idDesc.fTexFBOID; fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID; fRTLifecycle = idDesc.fLifeCycle; fViewport.fLeft = 0; fViewport.fBottom = 0; fViewport.fWidth = desc.fWidth; fViewport.fHeight = desc.fHeight; fGpuMemorySize = this->totalSamples() * this->totalBytesPerSample(); SkASSERT(fGpuMemorySize <= WorseCaseSize(desc)); }
size_t GrTexture::onGpuMemorySize() const { size_t textureSize; if (GrPixelConfigIsCompressed(fDesc.fConfig)) { textureSize = GrCompressedFormatDataSize(fDesc.fConfig, fDesc.fWidth, fDesc.fHeight); } else { textureSize = (size_t) fDesc.fWidth * fDesc.fHeight * GrBytesPerPixel(fDesc.fConfig); } if (this->texturePriv().hasMipMaps()) { // We don't have to worry about the mipmaps being a different size than // we'd expect because we never change fDesc.fWidth/fHeight. textureSize += textureSize/3; } SkASSERT(!SkToBool(fDesc.fFlags & kRenderTarget_GrSurfaceFlag)); SkASSERT(textureSize <= WorseCaseSize(fDesc)); return textureSize; }