aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-09 20:46:48 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-09 20:46:48 +0000
commite49157f0838c615b10da0ef2b297c742da662e34 (patch)
tree90fd2bf3ef0bce72423cbd8ebd4fa2bf2d363253 /src
parent96fb7489ba46909c3f81bb2d94755e7d4ccb5fad (diff)
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 Author: bsalomon@google.com Review URL: https://codereview.chromium.org/275903002 git-svn-id: http://skia.googlecode.com/svn/trunk@14687 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrContext.cpp16
-rw-r--r--src/gpu/GrTexture.cpp23
-rw-r--r--src/gpu/gl/GrGLTexture.h6
-rw-r--r--src/gpu/gl/GrGpuGL.cpp6
4 files changed, 27 insertions, 24 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index cd96defbd5..4b37c60a27 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 = GrTexture::ComputeKey(fGpu, params, desc, cacheID);
+ GrResourceKey resourceKey = GrTextureImpl::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 = GrTexture::ComputeKey(fGpu, params, desc, cacheID);
+ GrResourceKey resourceKey = GrTextureImpl::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 = GrTexture::ComputeKey(fGpu, params, desc, cacheID);
+ GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, cacheID);
GrTexture* texture;
- if (GrTexture::NeedsResizing(resourceKey)) {
+ if (GrTextureImpl::NeedsResizing(resourceKey)) {
texture = this->createResizedTexture(desc, cacheID,
srcData, rowBytes,
- GrTexture::NeedsBilerp(resourceKey));
+ GrTextureImpl::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 = GrTexture::ComputeScratchKey(texture->desc());
+ GrResourceKey key = GrTextureImpl::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 = GrTexture::ComputeScratchKey(desc);
+ GrResourceKey key = GrTextureImpl::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->setFlag((GrTextureFlags) GrTexture::kReturnToCache_FlagBit);
+ texture->impl()->setFlag((GrTextureFlags) GrTextureImpl::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 3186d89d77..8651d1090e 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -26,13 +26,12 @@ GrTexture::~GrTexture() {
* textures back in the texture cache when their ref count goes to zero.
*/
void GrTexture::internal_dispose() const {
-
- if (this->isSetFlag((GrTextureFlags) kReturnToCache_FlagBit) &&
+ if (this->impl()->isSetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit) &&
NULL != this->INHERITED::getContext()) {
GrTexture* nonConstThis = const_cast<GrTexture *>(this);
this->fRefCnt = 1; // restore ref count to initial setting
- nonConstThis->resetFlag((GrTextureFlags) kReturnToCache_FlagBit);
+ nonConstThis->impl()->resetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit);
nonConstThis->INHERITED::getContext()->addExistingTextureToCache(nonConstThis);
// Note: "this" texture might be freed inside addExistingTextureToCache
@@ -44,7 +43,7 @@ void GrTexture::internal_dispose() const {
this->INHERITED::internal_dispose();
}
-void GrTexture::dirtyMipMaps(bool mipMapsDirty) {
+void GrTextureImpl::dirtyMipMaps(bool mipMapsDirty) {
if (mipMapsDirty) {
if (kValid_MipMapsStatus == fMipMapsStatus) {
fMipMapsStatus = kAllocated_MipMapsStatus;
@@ -63,7 +62,7 @@ size_t GrTexture::gpuMemorySize() const {
size_t textureSize = (size_t) fDesc.fWidth *
fDesc.fHeight *
GrBytesPerPixel(fDesc.fConfig);
- if (kNotAllocated_MipMapsStatus != fMipMapsStatus) {
+ if (this->impl()->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 *= 2;
@@ -100,7 +99,7 @@ void GrTexture::writePixels(int left, int top, int width, int height,
}
void GrTexture::onRelease() {
- SkASSERT(!this->isSetFlag((GrTextureFlags) kReturnToCache_FlagBit));
+ SkASSERT(!this->impl()->isSetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit));
INHERITED::onRelease();
}
@@ -130,6 +129,8 @@ void GrTexture::validateDesc() const {
}
}
+//////////////////////////////////////////////////////////////////////////////
+
// These flags need to fit in a GrResourceKey::ResourceFlags so they can be folded into the texture
// key
enum TextureFlags {
@@ -186,7 +187,9 @@ GrSurfaceOrigin resolve_origin(const GrTextureDesc& desc) {
}
}
-GrResourceKey GrTexture::ComputeKey(const GrGpu* gpu,
+//////////////////////////////////////////////////////////////////////////////
+
+GrResourceKey GrTextureImpl::ComputeKey(const GrGpu* gpu,
const GrTextureParams* params,
const GrTextureDesc& desc,
const GrCacheID& cacheID) {
@@ -194,7 +197,7 @@ GrResourceKey GrTexture::ComputeKey(const GrGpu* gpu,
return GrResourceKey(cacheID, texture_resource_type(), flags);
}
-GrResourceKey GrTexture::ComputeScratchKey(const GrTextureDesc& desc) {
+GrResourceKey GrTextureImpl::ComputeScratchKey(const GrTextureDesc& desc) {
GrCacheID::Key idKey;
// Instead of a client-provided key of the texture contents we create a key from the
// descriptor.
@@ -213,10 +216,10 @@ GrResourceKey GrTexture::ComputeScratchKey(const GrTextureDesc& desc) {
return GrResourceKey(cacheID, texture_resource_type(), 0);
}
-bool GrTexture::NeedsResizing(const GrResourceKey& key) {
+bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) {
return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag);
}
-bool GrTexture::NeedsBilerp(const GrResourceKey& key) {
+bool GrTextureImpl::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 62052fd16a..a8800fab55 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -45,7 +45,7 @@ private:
////////////////////////////////////////////////////////////////////////////////
-class GrGLTexture : public GrTexture {
+class GrGLTexture : public GrTextureImpl {
public:
struct TexParams {
@@ -75,7 +75,7 @@ public:
virtual GrBackendObject getTextureHandle() const SK_OVERRIDE;
- virtual void invalidateCachedState() SK_OVERRIDE { fTexParams.invalidate(); }
+ virtual void textureParamsModified() SK_OVERRIDE { fTexParams.invalidate(); }
// These functions are used to track the texture parameters associated with the texture.
const TexParams& getCachedTexParams(GrGpu::ResetTimestamp* timestamp) const {
@@ -105,7 +105,7 @@ private:
const Desc& textureDesc,
const GrGLRenderTarget::Desc* rtDesc);
- typedef GrTexture INHERITED;
+ typedef GrTextureImpl INHERITED;
};
#endif
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 1a1bad7f28..a670eae613 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->dirtyMipMaps(true);
+ texture->impl()->dirtyMipMaps(true);
return true;
} else {
return false;
@@ -1583,8 +1583,8 @@ void GrGpuGL::flushRenderTarget(const SkIRect* bound) {
}
GrTexture *texture = rt->asTexture();
- if (texture) {
- texture->dirtyMipMaps(true);
+ if (NULL != texture) {
+ texture->impl()->dirtyMipMaps(true);
}
}