From 64c4fe4113424bcfab8b3e0c7049887fda5ab4ff Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Sat, 5 Nov 2011 14:51:01 +0000 Subject: [PATCH] More removal of texture fUploadByteCount and rename fFormat to fConfig for consistency. git-svn-id: http://skia.googlecode.com/svn/trunk@2608 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/gpu/GrTypes.h | 7 ++++++- src/gpu/GrContext.cpp | 8 ++++---- src/gpu/GrGLTexture.cpp | 4 ++-- src/gpu/GrGLTexture.h | 3 +-- src/gpu/GrGpuGL.cpp | 22 ++++++++++------------ src/gpu/SkGr.cpp | 2 +- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h index e1ab3d4e3..5e9cdb2bc 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -376,7 +376,12 @@ struct GrTextureDesc { * Format of source data of the texture. Not guaraunteed to be the same as * internal format used by 3D API. */ - GrPixelConfig fFormat; + // This union exists because WebKit uses the deprecated name fFormat. Once + // WebKit has been changed fFormat will be dropped. + union { + GrPixelConfig fFormat; + GrPixelConfig fConfig; + }; }; /** diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 3fc5d7d77..607ade824 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -374,7 +374,7 @@ GrContext::TextureCacheEntry GrContext::createAndLockTexture(TextureKey key, // no longer need to clamp at min RT size. rtDesc.fWidth = GrNextPow2(desc.fWidth); rtDesc.fHeight = GrNextPow2(desc.fHeight); - int bpp = GrBytesPerPixel(desc.fFormat); + int bpp = GrBytesPerPixel(desc.fConfig); SkAutoSMalloc<128*128*4> stretchedPixels(bpp * rtDesc.fWidth * rtDesc.fHeight); @@ -408,7 +408,7 @@ inline void gen_scratch_tex_key_values(const GrGpu* gpu, // we create a key of from the descriptor. GrContext::TextureKey descKey = desc.fAALevel | (desc.fFlags << 8) | - ((uint64_t) desc.fFormat << 32); + ((uint64_t) desc.fConfig << 32); // this code path isn't friendly to tiling with NPOT restricitons // We just pass ClampNoFilter() gen_texture_key_values(gpu, GrSamplerState::ClampNoFilter(), descKey, @@ -428,7 +428,7 @@ GrContext::TextureCacheEntry GrContext::lockScratchTexture( desc.fHeight = GrMax(MIN_SIZE, GrNextPow2(desc.fHeight)); } - uint32_t p0 = desc.fFormat; + uint32_t p0 = desc.fConfig; uint32_t p1 = (desc.fAALevel << 16) | desc.fFlags; GrResourceEntry* entry; @@ -710,7 +710,7 @@ bool GrContext::prepareForOffscreenAA(GrDrawTarget* target, kNoStencil_GrTextureFlagBit; } - desc.fFormat = kRGBA_8888_GrPixelConfig; + desc.fConfig = kRGBA_8888_GrPixelConfig; if (PREFER_MSAA_OFFSCREEN_AA && fGpu->getCaps().fFSAASupport) { record->fDownsample = OffscreenRecord::kFSAA_Downsample; diff --git a/src/gpu/GrGLTexture.cpp b/src/gpu/GrGLTexture.cpp index 29c69b135..7ff658808 100644 --- a/src/gpu/GrGLTexture.cpp +++ b/src/gpu/GrGLTexture.cpp @@ -74,7 +74,7 @@ GrGLTexture::GrGLTexture(GrGpuGL* gpu, textureDesc.fContentHeight, textureDesc.fAllocWidth, textureDesc.fAllocHeight, - textureDesc.fFormat) { + textureDesc.fConfig) { this->init(gpu, textureDesc, NULL, initialTexParams); } @@ -87,7 +87,7 @@ GrGLTexture::GrGLTexture(GrGpuGL* gpu, textureDesc.fContentHeight, textureDesc.fAllocWidth, textureDesc.fAllocHeight, - textureDesc.fFormat) { + textureDesc.fConfig) { this->init(gpu, textureDesc, &rtDesc, initialTexParams); } diff --git a/src/gpu/GrGLTexture.h b/src/gpu/GrGLTexture.h index 8c35430a6..49002af62 100644 --- a/src/gpu/GrGLTexture.h +++ b/src/gpu/GrGLTexture.h @@ -64,11 +64,10 @@ public: int fContentHeight; int fAllocWidth; int fAllocHeight; - GrPixelConfig fFormat; + GrPixelConfig fConfig; GrGLuint fTextureID; bool fOwnsID; GrGLenum fUploadFormat; - GrGLenum fUploadByteCount; GrGLenum fUploadType; Orientation fOrientation; }; diff --git a/src/gpu/GrGpuGL.cpp b/src/gpu/GrGpuGL.cpp index cfacb402e..1b06a4d58 100644 --- a/src/gpu/GrGpuGL.cpp +++ b/src/gpu/GrGpuGL.cpp @@ -687,7 +687,7 @@ GrResource* GrGpuGL::onCreatePlatformSurface(const GrPlatformSurfaceDesc& desc) texDesc.fAllocWidth = texDesc.fContentWidth = desc.fWidth; texDesc.fAllocHeight = texDesc.fContentHeight = desc.fHeight; - texDesc.fFormat = desc.fConfig; + texDesc.fConfig = desc.fConfig; texDesc.fOrientation = GrGLTexture::kBottomUp_Orientation; texDesc.fTextureID = desc.fPlatformTexture; texDesc.fOwnsID = false; @@ -722,8 +722,8 @@ void GrGpuGL::allocateAndUploadTexData(const GrGLTexture::Desc& desc, size_t rowBytes) { // we assume the texture is bound - size_t bpp = GrBytesPerPixel(desc.fFormat); - size_t trimRowBytes = desc.fContentWidth * desc.fUploadByteCount; + size_t bpp = GrBytesPerPixel(desc.fConfig); + size_t trimRowBytes = desc.fContentWidth * bpp; if (!rowBytes) { rowBytes = trimRowBytes; @@ -769,7 +769,7 @@ void GrGpuGL::allocateAndUploadTexData(const GrGLTexture::Desc& desc, } GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, static_cast(bpp))); - if (kIndex_8_GrPixelConfig == desc.fFormat && + if (kIndex_8_GrPixelConfig == desc.fConfig && this->getCaps().f8BitPaletteSupport) { // ES only supports CompressedTexImage2D, not CompressedTexSubimage2D GrAssert(desc.fContentWidth == desc.fAllocWidth); @@ -833,7 +833,7 @@ void GrGpuGL::allocateAndUploadTexData(const GrGLTexture::Desc& desc, desc.fContentHeight * rowBytes - bpp; uint8_t* extraTexel = (uint8_t*)texels.get(); for (int i = 0; i < extraW*extraH; ++i) { - memcpy(extraTexel, cornerTexel, desc.fUploadByteCount); + memcpy(extraTexel, cornerTexel, bpp); extraTexel += bpp; } GL_CALL(TexSubImage2D(GR_GL_TEXTURE_2D, 0, desc.fContentWidth, @@ -967,17 +967,17 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc, glTexDesc.fContentHeight = desc.fHeight; glTexDesc.fAllocWidth = desc.fWidth; glTexDesc.fAllocHeight = desc.fHeight; - glTexDesc.fFormat = desc.fFormat; + glTexDesc.fConfig = desc.fConfig; glTexDesc.fOwnsID = true; glRTDesc.fMSColorRenderbufferID = 0; glRTDesc.fRTFBOID = 0; glRTDesc.fTexFBOID = 0; glRTDesc.fOwnIDs = true; - glRTDesc.fConfig = glTexDesc.fFormat; + glRTDesc.fConfig = glTexDesc.fConfig; bool renderTarget = 0 != (desc.fFlags & kRenderTarget_GrTextureFlagBit); - if (!canBeTexture(desc.fFormat, + if (!canBeTexture(desc.fConfig, &internalFormat, &glTexDesc.fUploadFormat, &glTexDesc.fUploadType)) { @@ -999,8 +999,6 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc, GrPrintf("AA RT requested but not supported on this platform."); } - glTexDesc.fUploadByteCount = GrBytesPerPixel(desc.fFormat); - if (renderTarget) { if (!caps.fNPOTRenderTargetSupport) { glTexDesc.fAllocWidth = GrNextPow2(desc.fWidth); @@ -1064,8 +1062,8 @@ GrTexture* GrGpuGL::onCreateTexture(const GrTextureDesc& desc, tex = new GrGLTexture(this, glTexDesc, DEFAULT_PARAMS); } #ifdef TRACE_TEXTURE_CREATION - GrPrintf("--- new texture [%d] size=(%d %d) bpp=%d\n", - tex->fTextureID, width, height, tex->fUploadByteCount); + GrPrintf("--- new texture [%d] size=(%d %d) config=%d\n", + glTexDesc.fTextureID, desc.fWidth, desc.fHeight, desc.fConfig); #endif return tex; } diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 72a23a65c..bbb55c8a8 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -111,7 +111,7 @@ GrContext::TextureCacheEntry sk_gr_create_bitmap_texture(GrContext* ctx, } } - desc.fFormat = SkGr::Bitmap2PixelConfig(*bitmap); + desc.fConfig = SkGr::Bitmap2PixelConfig(*bitmap); if (gUNCACHED_KEY != key) { return ctx->createAndLockTexture(key, sampler, desc, bitmap->getPixels(),