diff options
author | 2014-05-09 18:02:51 +0000 | |
---|---|---|
committer | 2014-05-09 18:02:51 +0000 | |
commit | 59e7d238522145e00357c54d71a4216b279faf1c (patch) | |
tree | 02a7ac7ad038886b0cded813f5ec3805f22cd527 /src/gpu | |
parent | bd465d141be875278d6bbc06becfdbb4acbbf557 (diff) |
Revert of Factor GrTexture into public GrTexture and private GrTextureImpl. (https://codereview.chromium.org/275903002/)
Reason for revert:
Breaks chrome build.
Original issue's description:
> Factor GrTexture into public GrTexture and private GrTextureImpl.
>
> Committed: http://code.google.com/p/skia/source/detail?r=14680
R=jvanverth@google.com, robertphillips@google.com
TBR=jvanverth@google.com, robertphillips@google.com
NOTREECHECKS=true
NOTRY=true
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/278073002
git-svn-id: http://skia.googlecode.com/svn/trunk@14681 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrContext.cpp | 16 | ||||
-rw-r--r-- | src/gpu/GrTexture.cpp | 23 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTexture.h | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.cpp | 6 |
4 files changed, 23 insertions, 26 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 4b37c60a27..cd96defbd5 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -237,7 +237,7 @@ void GrContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc, const GrCacheID& cacheID, const GrTextureParams* params) { - GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, cacheID); + GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, params, desc, cacheID); GrCacheable* resource = fResourceCache->find(resourceKey); SkSafeRef(resource); return static_cast<GrTexture*>(resource); @@ -246,7 +246,7 @@ GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc, bool GrContext::isTextureInCache(const GrTextureDesc& desc, const GrCacheID& cacheID, const GrTextureParams* params) const { - GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, cacheID); + GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, params, desc, cacheID); return fResourceCache->hasKey(resourceKey); } @@ -383,13 +383,13 @@ GrTexture* GrContext::createTexture(const GrTextureParams* params, void* srcData, size_t rowBytes, GrResourceKey* cacheKey) { - GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, cacheID); + GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, params, desc, cacheID); GrTexture* texture; - if (GrTextureImpl::NeedsResizing(resourceKey)) { + if (GrTexture::NeedsResizing(resourceKey)) { texture = this->createResizedTexture(desc, cacheID, srcData, rowBytes, - GrTextureImpl::NeedsBilerp(resourceKey)); + GrTexture::NeedsBilerp(resourceKey)); } else { texture= fGpu->createTexture(desc, srcData, rowBytes); } @@ -413,7 +413,7 @@ static GrTexture* create_scratch_texture(GrGpu* gpu, const GrTextureDesc& desc) { GrTexture* texture = gpu->createTexture(desc, NULL, 0); if (NULL != texture) { - GrResourceKey key = GrTextureImpl::ComputeScratchKey(texture->desc()); + GrResourceKey key = GrTexture::ComputeScratchKey(texture->desc()); // Adding a resource could put us overbudget. Try to free up the // necessary space before adding it. resourceCache->purgeAsNeeded(1, texture->gpuMemorySize()); @@ -453,7 +453,7 @@ GrTexture* GrContext::lockAndRefScratchTexture(const GrTextureDesc& inDesc, Scra int origHeight = desc.fHeight; do { - GrResourceKey key = GrTextureImpl::ComputeScratchKey(desc); + GrResourceKey key = GrTexture::ComputeScratchKey(desc); // Ensure we have exclusive access to the texture so future 'find' calls don't return it resource = fResourceCache->find(key, GrResourceCache::kHide_OwnershipFlag); if (NULL != resource) { @@ -543,7 +543,7 @@ void GrContext::unlockScratchTexture(GrTexture* texture) { // Instead, give up the cache's ref and leave the decision up to // addExistingTextureToCache once its ref count reaches 0. For // this to work we need to leave it in the exclusive list. - texture->impl()->setFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit); + texture->setFlag((GrTextureFlags) GrTexture::kReturnToCache_FlagBit); // Give up the cache's ref to the texture texture->unref(); } diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp index 8651d1090e..3186d89d77 100644 --- a/src/gpu/GrTexture.cpp +++ b/src/gpu/GrTexture.cpp @@ -26,12 +26,13 @@ GrTexture::~GrTexture() { * textures back in the texture cache when their ref count goes to zero. */ void GrTexture::internal_dispose() const { - if (this->impl()->isSetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit) && + + if (this->isSetFlag((GrTextureFlags) kReturnToCache_FlagBit) && NULL != this->INHERITED::getContext()) { GrTexture* nonConstThis = const_cast<GrTexture *>(this); this->fRefCnt = 1; // restore ref count to initial setting - nonConstThis->impl()->resetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit); + nonConstThis->resetFlag((GrTextureFlags) kReturnToCache_FlagBit); nonConstThis->INHERITED::getContext()->addExistingTextureToCache(nonConstThis); // Note: "this" texture might be freed inside addExistingTextureToCache @@ -43,7 +44,7 @@ void GrTexture::internal_dispose() const { this->INHERITED::internal_dispose(); } -void GrTextureImpl::dirtyMipMaps(bool mipMapsDirty) { +void GrTexture::dirtyMipMaps(bool mipMapsDirty) { if (mipMapsDirty) { if (kValid_MipMapsStatus == fMipMapsStatus) { fMipMapsStatus = kAllocated_MipMapsStatus; @@ -62,7 +63,7 @@ size_t GrTexture::gpuMemorySize() const { size_t textureSize = (size_t) fDesc.fWidth * fDesc.fHeight * GrBytesPerPixel(fDesc.fConfig); - if (this->impl()->hasMipMaps()) { + if (kNotAllocated_MipMapsStatus != fMipMapsStatus) { // 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 *= 2; @@ -99,7 +100,7 @@ void GrTexture::writePixels(int left, int top, int width, int height, } void GrTexture::onRelease() { - SkASSERT(!this->impl()->isSetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit)); + SkASSERT(!this->isSetFlag((GrTextureFlags) kReturnToCache_FlagBit)); INHERITED::onRelease(); } @@ -129,8 +130,6 @@ void GrTexture::validateDesc() const { } } -////////////////////////////////////////////////////////////////////////////// - // These flags need to fit in a GrResourceKey::ResourceFlags so they can be folded into the texture // key enum TextureFlags { @@ -187,9 +186,7 @@ GrSurfaceOrigin resolve_origin(const GrTextureDesc& desc) { } } -////////////////////////////////////////////////////////////////////////////// - -GrResourceKey GrTextureImpl::ComputeKey(const GrGpu* gpu, +GrResourceKey GrTexture::ComputeKey(const GrGpu* gpu, const GrTextureParams* params, const GrTextureDesc& desc, const GrCacheID& cacheID) { @@ -197,7 +194,7 @@ GrResourceKey GrTextureImpl::ComputeKey(const GrGpu* gpu, return GrResourceKey(cacheID, texture_resource_type(), flags); } -GrResourceKey GrTextureImpl::ComputeScratchKey(const GrTextureDesc& desc) { +GrResourceKey GrTexture::ComputeScratchKey(const GrTextureDesc& desc) { GrCacheID::Key idKey; // Instead of a client-provided key of the texture contents we create a key from the // descriptor. @@ -216,10 +213,10 @@ GrResourceKey GrTextureImpl::ComputeScratchKey(const GrTextureDesc& desc) { return GrResourceKey(cacheID, texture_resource_type(), 0); } -bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) { +bool GrTexture::NeedsResizing(const GrResourceKey& key) { return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag); } -bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) { +bool GrTexture::NeedsBilerp(const GrResourceKey& key) { return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag); } diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h index 0b364ac51b..62052fd16a 100644 --- a/src/gpu/gl/GrGLTexture.h +++ b/src/gpu/gl/GrGLTexture.h @@ -45,7 +45,7 @@ private: //////////////////////////////////////////////////////////////////////////////// -class GrGLTexture : public GrTextureImpl { +class GrGLTexture : public GrTexture { public: struct TexParams { @@ -105,7 +105,7 @@ private: const Desc& textureDesc, const GrGLRenderTarget::Desc* rtDesc); - typedef GrTextureImpl INHERITED; + typedef GrTexture INHERITED; }; #endif diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index a670eae613..1a1bad7f28 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -479,7 +479,7 @@ bool GrGpuGL::onWriteTexturePixels(GrTexture* texture, if (this->uploadTexData(desc, false, left, top, width, height, config, buffer, rowBytes)) { - texture->impl()->dirtyMipMaps(true); + texture->dirtyMipMaps(true); return true; } else { return false; @@ -1583,8 +1583,8 @@ void GrGpuGL::flushRenderTarget(const SkIRect* bound) { } GrTexture *texture = rt->asTexture(); - if (NULL != texture) { - texture->impl()->dirtyMipMaps(true); + if (texture) { + texture->dirtyMipMaps(true); } } |