Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Unified Diff: src/gpu/GrGpuResourcePriv.h

Issue 923143002: Split out methods in GrGpuResource::CacheAccess that can be called outside of the cache. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: do warning workaround in the right place Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrGpuResourceCacheAccess.h ('k') | src/gpu/GrResourceCache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrGpuResourcePriv.h
diff --git a/src/gpu/GrGpuResourceCacheAccess.h b/src/gpu/GrGpuResourcePriv.h
similarity index 58%
copy from src/gpu/GrGpuResourceCacheAccess.h
copy to src/gpu/GrGpuResourcePriv.h
index 6c99d08e469769df92ef570863e3b8cedcd9a67f..520e217e98e44978324c938f9c9a5b4f6f4eb3c7 100644
--- a/src/gpu/GrGpuResourceCacheAccess.h
+++ b/src/gpu/GrGpuResourcePriv.h
@@ -1,21 +1,21 @@
/*
- * Copyright 2014 Google Inc.
+ * Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef GrGpuResourceCacheAccess_DEFINED
-#define GrGpuResourceCacheAccess_DEFINED
+#ifndef GrGpuResourcePriv_DEFINED
+#define GrGpuResourcePriv_DEFINED
#include "GrGpuResource.h"
/**
- * This class allows code internal to Skia privileged access to manage the cache keys of a
- * GrGpuResource object.
+ * This class allows code internal to Skia privileged access to manage the cache keys and budget
+ * status of a GrGpuResource object.
*/
-class GrGpuResource::CacheAccess {
+class GrGpuResource::ResourcePriv {
public:
/**
* Sets a content key for the resource. If the resource was previously cached as scratch it will
@@ -28,34 +28,20 @@ public:
return fResource->setContentKey(contentKey);
}
+ /** Removes the content key from a resource */
void removeContentKey() { return fResource->removeContentKey(); }
/**
- * Is the resource currently cached as scratch? This means it is cached, has a valid scratch
- * key, and does not have a content key.
- */
- bool isScratch() const {
- return !fResource->getContentKey().isValid() && fResource->fScratchKey.isValid() &&
- this->isBudgeted();
- }
-
- /**
- * If this resource can be used as a scratch resource this returns a valid scratch key.
- * Otherwise it returns a key for which isNullScratch is true. The resource may currently be
- * used as a content resource rather than scratch. Check isScratch().
- */
- const GrScratchKey& getScratchKey() const { return fResource->fScratchKey; }
-
- /**
- * If the resource has a scratch key, the key will be removed. Since scratch keys are installed
- * at resource creation time, this means the resource will never again be used as scratch.
+ * If the resource is uncached make it cached. Has no effect on resources that are wrapped or
+ * already cached.
*/
- void removeScratchKey() const { fResource->removeScratchKey(); }
+ void makeBudgeted() { fResource->makeBudgeted(); }
/**
- * Is the resource object wrapping an externally allocated GPU resource?
+ * If the resource is cached make it uncached. Has no effect on resources that are wrapped or
+ * already uncached. Furthermore, resources with content keys cannot be made unbudgeted.
*/
- bool isWrapped() const { return GrGpuResource::kWrapped_LifeCycle == fResource->fLifeCycle; }
+ void makeUnbudgeted() { fResource->makeUnbudgeted(); }
/**
* Does the resource count against the resource budget?
@@ -66,56 +52,37 @@ public:
return ret;
}
- /**
- * If the resource is uncached make it cached. Has no effect on resources that are wrapped or
- * already cached.
- */
- void makeBudgeted() { fResource->makeBudgeted(); }
-
- /**
- * If the resource is cached make it uncached. Has no effect on resources that are wrapped or
- * already uncached. Furthermore, resources with content keys cannot be made unbudgeted.
- */
- void makeUnbudgeted() { fResource->makeUnbudgeted(); }
-
- /**
- * Called by the cache to delete the resource under normal circumstances.
+ /**
+ * If this resource can be used as a scratch resource this returns a valid scratch key.
+ * Otherwise it returns a key for which isNullScratch is true. The resource may currently be
+ * used as a content resource rather than scratch. Check isScratch().
*/
- void release() {
- fResource->release();
- if (fResource->isPurgeable()) {
- SkDELETE(fResource);
- }
- }
+ const GrScratchKey& getScratchKey() const { return fResource->fScratchKey; }
/**
- * Called by the cache to delete the resource when the backend 3D context is no longer valid.
+ * If the resource has a scratch key, the key will be removed. Since scratch keys are installed
+ * at resource creation time, this means the resource will never again be used as scratch.
*/
- void abandon() {
- fResource->abandon();
- if (fResource->isPurgeable()) {
- SkDELETE(fResource);
- }
- }
+ void removeScratchKey() const { fResource->removeScratchKey(); }
-private:
- CacheAccess(GrGpuResource* resource) : fResource(resource) { }
- CacheAccess(const CacheAccess& that) : fResource(that.fResource) { }
- CacheAccess& operator=(const CacheAccess&); // unimpl
+protected:
+ ResourcePriv(GrGpuResource* resource) : fResource(resource) { }
+ ResourcePriv(const ResourcePriv& that) : fResource(that.fResource) {}
+ ResourcePriv& operator=(const CacheAccess&); // unimpl
// No taking addresses of this type.
- const CacheAccess* operator&() const;
- CacheAccess* operator&();
+ const ResourcePriv* operator&() const;
+ ResourcePriv* operator&();
GrGpuResource* fResource;
friend class GrGpuResource; // to construct/copy this type.
};
-inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAccess(this); }
+inline GrGpuResource::ResourcePriv GrGpuResource::resourcePriv() { return ResourcePriv(this); }
-inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const {
- return CacheAccess(const_cast<GrGpuResource*>(this));
+inline const GrGpuResource::ResourcePriv GrGpuResource::resourcePriv() const {
+ return ResourcePriv(const_cast<GrGpuResource*>(this));
}
#endif
« no previous file with comments | « src/gpu/GrGpuResourceCacheAccess.h ('k') | src/gpu/GrResourceCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698