diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-12-12 16:10:08 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-12-12 16:10:08 +0000 |
commit | 1fadb20c50c2302565f73ae12057a6f5d22192c7 (patch) | |
tree | 2cadd3d9bd7177e048a344ddab29bee86621aa1a /src | |
parent | 4ad7e580e0caab31eb2dd8a682af0750391d89df (diff) |
Remove static initiazled gClampNearest in gpu backend
Review URL: http://codereview.appspot.com/5487044/
git-svn-id: http://skia.googlecode.com/svn/trunk@2851 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrContext.cpp | 59 | ||||
-rw-r--r-- | src/gpu/GrGpu.cpp | 3 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 21 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 2 |
4 files changed, 45 insertions, 40 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index de36307ae0..a798ec9ec2 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -7,9 +7,10 @@ */ +#include "GrContext.h" + #include "GrBufferAllocPool.h" #include "GrClipIterator.h" -#include "GrContext.h" #include "GrGpu.h" #include "GrIndexBuffer.h" #include "GrInOrderDrawBuffer.h" @@ -158,7 +159,7 @@ GrTexture* GrContext::TextureCacheEntry::texture() const { namespace { // returns true if this is a "special" texture because of gpu NPOT limitations bool gen_texture_key_values(const GrGpu* gpu, - const GrSamplerState& sampler, + const GrSamplerState* sampler, GrContext::TextureKey clientKey, int width, int height, @@ -177,12 +178,13 @@ bool gen_texture_key_values(const GrGpu* gpu, if (!gpu->getCaps().fNPOTTextureTileSupport) { bool isPow2 = GrIsPow2(width) && GrIsPow2(height); - bool tiled = (sampler.getWrapX() != GrSamplerState::kClamp_WrapMode) || - (sampler.getWrapY() != GrSamplerState::kClamp_WrapMode); + bool tiled = NULL != sampler && + ((sampler->getWrapX() != GrSamplerState::kClamp_WrapMode) || + (sampler->getWrapY() != GrSamplerState::kClamp_WrapMode)); if (tiled && !isPow2) { v[3] |= kNPOTBit; - if (GrSamplerState::kNearest_Filter != sampler.getFilter()) { + if (GrSamplerState::kNearest_Filter != sampler->getFilter()) { v[3] |= kFilterBit; } } @@ -232,10 +234,11 @@ void reset_draw_state(GrDrawState* drawState){ } } -GrContext::TextureCacheEntry GrContext::findAndLockTexture(TextureKey key, - int width, - int height, - const GrSamplerState& sampler) { +GrContext::TextureCacheEntry GrContext::findAndLockTexture( + TextureKey key, + int width, + int height, + const GrSamplerState* sampler) { uint32_t v[4]; gen_texture_key_values(fGpu, sampler, key, width, height, false, v); GrResourceKey resourceKey(v); @@ -246,7 +249,7 @@ GrContext::TextureCacheEntry GrContext::findAndLockTexture(TextureKey key, bool GrContext::isTextureInCache(TextureKey key, int width, int height, - const GrSamplerState& sampler) const { + const GrSamplerState* sampler) const { uint32_t v[4]; gen_texture_key_values(fGpu, sampler, key, width, height, false, v); GrResourceKey resourceKey(v); @@ -308,10 +311,12 @@ static void stretchImage(void* dst, } } -GrContext::TextureCacheEntry GrContext::createAndLockTexture(TextureKey key, - const GrSamplerState& sampler, - const GrTextureDesc& desc, - void* srcData, size_t rowBytes) { +GrContext::TextureCacheEntry GrContext::createAndLockTexture( + TextureKey key, + const GrSamplerState* sampler, + const GrTextureDesc& desc, + void* srcData, + size_t rowBytes) { SK_TRACE_EVENT0("GrContext::createAndLockTexture"); #if GR_DUMP_TEXTURE_UPLOAD @@ -325,14 +330,15 @@ GrContext::TextureCacheEntry GrContext::createAndLockTexture(TextureKey key, GrResourceKey resourceKey(v); if (special) { - TextureCacheEntry clampEntry = - findAndLockTexture(key, desc.fWidth, desc.fHeight, - GrSamplerState::ClampNearest()); + GrAssert(NULL != sampler); + TextureCacheEntry clampEntry = this->findAndLockTexture(key, + desc.fWidth, + desc.fHeight, + NULL); if (NULL == clampEntry.texture()) { - clampEntry = createAndLockTexture(key, - GrSamplerState::ClampNearest(), - desc, srcData, rowBytes); + clampEntry = this->createAndLockTexture(key, NULL, desc, + srcData, rowBytes); GrAssert(NULL != clampEntry.texture()); if (NULL == clampEntry.texture()) { return entry; @@ -358,7 +364,7 @@ GrContext::TextureCacheEntry GrContext::createAndLockTexture(TextureKey key, // if filtering is not desired then we want to ensure all // texels in the resampled image are copies of texels from // the original. - if (GrSamplerState::kNearest_Filter == sampler.getFilter()) { + if (GrSamplerState::kNearest_Filter == sampler->getFilter()) { filter = GrSamplerState::kNearest_Filter; } else { filter = GrSamplerState::kBilinear_Filter; @@ -430,8 +436,8 @@ inline void gen_scratch_tex_key_values(const GrGpu* gpu, ((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::ClampNearest(), descKey, - desc.fWidth, desc.fHeight, true, v); + gen_texture_key_values(gpu, NULL, descKey, desc.fWidth, + desc.fHeight, true, v); } } @@ -573,7 +579,7 @@ GrResource* GrContext::createPlatformSurface(const GrPlatformSurfaceDesc& desc) /////////////////////////////////////////////////////////////////////////////// -bool GrContext::supportsIndex8PixelConfig(const GrSamplerState& sampler, +bool GrContext::supportsIndex8PixelConfig(const GrSamplerState* sampler, int width, int height) const { const GrDrawTarget::Caps& caps = fGpu->getCaps(); if (!caps.f8BitPaletteSupport) { @@ -583,8 +589,9 @@ bool GrContext::supportsIndex8PixelConfig(const GrSamplerState& sampler, bool isPow2 = GrIsPow2(width) && GrIsPow2(height); if (!isPow2) { - bool tiled = sampler.getWrapX() != GrSamplerState::kClamp_WrapMode || - sampler.getWrapY() != GrSamplerState::kClamp_WrapMode; + bool tiled = NULL != sampler && + (sampler->getWrapX() != GrSamplerState::kClamp_WrapMode || + sampler->getWrapY() != GrSamplerState::kClamp_WrapMode); if (tiled && !caps.fNPOTTextureTileSupport) { return false; } diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index a949acde9a..4a2e5d71a9 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -974,6 +974,3 @@ void GrGpu::printStats() const { } } -//////////////////////////////////////////////////////////////////////////////// - -const GrSamplerState GrSamplerState::gClampNearest; diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index df2ac2283a..bf00fa3d73 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -59,7 +59,7 @@ enum { SkGpuDevice::SkAutoCachedTexture:: SkAutoCachedTexture(SkGpuDevice* device, const SkBitmap& bitmap, - const GrSamplerState& sampler, + const GrSamplerState* sampler, GrTexture** texture) { GrAssert(texture); *texture = this->set(device, bitmap, sampler); @@ -70,7 +70,7 @@ SkGpuDevice::SkAutoCachedTexture::SkAutoCachedTexture() { GrTexture* SkGpuDevice::SkAutoCachedTexture::set(SkGpuDevice* device, const SkBitmap& bitmap, - const GrSamplerState& sampler) { + const GrSamplerState* sampler) { if (fTex.texture()) { fDevice->unlockCachedTexture(fTex); } @@ -195,7 +195,7 @@ SkGpuDevice::SkGpuDevice(GrContext* context, SkBitmap::Config config, int width, TexType type = (kSaveLayer_Usage == usage) ? kSaveLayerDeviceRenderTarget_TexType : kDeviceRenderTarget_TexType; - fCache = this->lockCachedTexture(bm, GrSamplerState::ClampNearest(), type); + fCache = this->lockCachedTexture(bm, NULL, type); fTexture = fCache.texture(); if (fTexture) { SkASSERT(NULL != fTexture->asRenderTarget()); @@ -515,7 +515,7 @@ bool SkGpuDevice::skPaint2GrPaintShader(const SkPaint& skPaint, twoPointParams[2] < 0); } - GrTexture* texture = act->set(this, bitmap, *sampler); + GrTexture* texture = act->set(this, bitmap, sampler); if (NULL == texture) { SkDebugf("Couldn't convert bitmap to texture.\n"); return false; @@ -1407,7 +1407,7 @@ void SkGpuDevice::internalDrawBitmap(const SkDraw& draw, sampler->setMatrix(GrMatrix::I()); GrTexture* texture; - SkAutoCachedTexture act(this, bitmap, *sampler, &texture); + SkAutoCachedTexture act(this, bitmap, sampler, &texture); if (NULL == texture) { return; } @@ -1470,7 +1470,7 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, GrTexture* texture; sampler->reset(); - SkAutoCachedTexture act(this, bitmap, *sampler, &texture); + SkAutoCachedTexture act(this, bitmap, sampler, &texture); grPaint.setTexture(kBitmapTextureIdx, texture); @@ -1755,7 +1755,7 @@ void SkGpuDevice::flush() { /////////////////////////////////////////////////////////////////////////////// SkGpuDevice::TexCache SkGpuDevice::lockCachedTexture(const SkBitmap& bitmap, - const GrSamplerState& sampler, + const GrSamplerState* sampler, TexType type) { GrContext::TextureCacheEntry entry; GrContext* ctx = this->context(); @@ -1787,11 +1787,12 @@ SkGpuDevice::TexCache SkGpuDevice::lockCachedTexture(const SkBitmap& bitmap, entry = ctx->findAndLockTexture(key, bitmap.width(), bitmap.height(), sampler); if (NULL == entry.texture()) { - entry = sk_gr_create_bitmap_texture(ctx, key, sampler, + entry = sk_gr_create_bitmap_texture(ctx, key, sampler, bitmap); } } else { - entry = sk_gr_create_bitmap_texture(ctx, gUNCACHED_KEY, sampler, bitmap); + entry = sk_gr_create_bitmap_texture(ctx, gUNCACHED_KEY, + sampler, bitmap); } if (NULL == entry.texture()) { GrPrintf("---- failed to create texture for cache [%d %d]\n", @@ -1810,7 +1811,7 @@ bool SkGpuDevice::isBitmapInTextureCache(const SkBitmap& bitmap, GrContext::TextureKey key = bitmap.getGenerationID(); key |= ((uint64_t) bitmap.pixelRefOffset()) << 32; return this->context()->isTextureInCache(key, bitmap.width(), - bitmap.height(), sampler); + bitmap.height(), &sampler); } diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 761a46b23c..0205dd6ddb 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -58,7 +58,7 @@ static void build_compressed_data(void* buffer, const SkBitmap& bitmap) { GrContext::TextureCacheEntry sk_gr_create_bitmap_texture(GrContext* ctx, GrContext::TextureKey key, - const GrSamplerState& sampler, + const GrSamplerState* sampler, const SkBitmap& origBitmap) { SkAutoLockPixels alp(origBitmap); GrContext::TextureCacheEntry entry; |