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

Unified Diff: bench/GrResourceCacheBench.cpp

Issue 251013002: Split GrResource into GrCacheable/GrGpuObject (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 years, 8 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 | « no previous file | gyp/gpu.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/GrResourceCacheBench.cpp
diff --git a/bench/GrResourceCacheBench.cpp b/bench/GrResourceCacheBench.cpp
index e808cd783686487955cfcf9d5077ce0414fc5d1d..6767ca1d49ce66006dadcbbecb6719e56efa52dd 100644
--- a/bench/GrResourceCacheBench.cpp
+++ b/bench/GrResourceCacheBench.cpp
@@ -9,7 +9,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
-#include "GrResource.h"
+#include "GrCacheable.h"
#include "GrResourceCache.h"
#include "GrStencilBuffer.h"
#include "GrTexture.h"
@@ -21,21 +21,21 @@ enum {
CACHE_SIZE_BYTES = 2 * 1024 * 1024,
};
-class StencilResource : public GrResource {
+class StencilResource : public GrCacheable {
public:
SK_DECLARE_INST_COUNT(StencilResource);
- StencilResource(GrGpu* gpu, int id)
- : INHERITED(gpu, false),
- fID(id) {
- }
- ~StencilResource() {
- this->release();
+ StencilResource(int id)
+ : fID(id) {
}
- virtual size_t sizeInBytes() const SK_OVERRIDE {
+ virtual size_t gpuMemorySize() const SK_OVERRIDE {
return 100 + ((fID % 1 == 0) ? -5 : 6);
}
+ virtual bool isValidOnGpu() const SK_OVERRIDE {
+ return true;
+ }
+
static GrResourceKey ComputeKey(int width, int height, int sampleCnt) {
return GrStencilBuffer::ComputeKey(width, height, sampleCnt);
}
@@ -43,24 +43,24 @@ public:
int fID;
private:
- typedef GrResource INHERITED;
+ typedef GrCacheable INHERITED;
};
-class TextureResource : public GrResource {
+class TextureResource : public GrCacheable {
public:
SK_DECLARE_INST_COUNT(TextureResource);
- TextureResource(GrGpu* gpu, int id)
- : INHERITED(gpu, false),
- fID(id) {
- }
- ~TextureResource() {
- this->release();
+ TextureResource(int id)
+ : fID(id) {
}
- virtual size_t sizeInBytes() const SK_OVERRIDE {
+ virtual size_t gpuMemorySize() const SK_OVERRIDE {
return 100 + ((fID % 1 == 0) ? -40 : 33);
}
+ virtual bool isValidOnGpu() const SK_OVERRIDE {
+ return true;
+ }
+
static GrResourceKey ComputeKey(const GrTextureDesc& desc) {
return GrTexture::ComputeScratchKey(desc);
}
@@ -68,7 +68,7 @@ public:
int fID;
private:
- typedef GrResource INHERITED;
+ typedef GrCacheable INHERITED;
};
static void get_stencil(int i, int* w, int* h, int* s) {
@@ -91,8 +91,8 @@ static void populate_cache(GrResourceCache* cache, GrGpu* gpu, int resourceCount
int w, h, s;
get_stencil(i, &w, &h, &s);
GrResourceKey key = GrStencilBuffer::ComputeKey(w, h, s);
- GrResource* resource = SkNEW_ARGS(StencilResource, (gpu, i));
- cache->purgeAsNeeded(1, resource->sizeInBytes());
+ GrCacheable* resource = SkNEW_ARGS(StencilResource, (i));
+ cache->purgeAsNeeded(1, resource->gpuMemorySize());
cache->addResource(key, resource);
resource->unref();
}
@@ -101,8 +101,8 @@ static void populate_cache(GrResourceCache* cache, GrGpu* gpu, int resourceCount
GrTextureDesc desc;
get_texture_desc(i, &desc);
GrResourceKey key = TextureResource::ComputeKey(desc);
- GrResource* resource = SkNEW_ARGS(TextureResource, (gpu, i));
- cache->purgeAsNeeded(1, resource->sizeInBytes());
+ GrCacheable* resource = SkNEW_ARGS(TextureResource, (i));
+ cache->purgeAsNeeded(1, resource->gpuMemorySize());
cache->addResource(key, resource);
resource->unref();
}
@@ -114,7 +114,7 @@ static void check_cache_contents_or_die(GrResourceCache* cache, int k) {
GrTextureDesc desc;
get_texture_desc(k, &desc);
GrResourceKey key = TextureResource::ComputeKey(desc);
- GrResource* item = cache->find(key);
+ GrCacheable* item = cache->find(key);
if (NULL == item) {
SkFAIL("cache add does not work as expected");
return;
@@ -128,7 +128,7 @@ static void check_cache_contents_or_die(GrResourceCache* cache, int k) {
int w, h, s;
get_stencil(k, &w, &h, &s);
GrResourceKey key = StencilResource::ComputeKey(w, h, s);
- GrResource* item = cache->find(key);
+ GrCacheable* item = cache->find(key);
if (NULL == item) {
SkFAIL("cache add does not work as expected");
return;
@@ -145,7 +145,7 @@ static void check_cache_contents_or_die(GrResourceCache* cache, int k) {
get_texture_desc(k, &desc);
desc.fHeight |= 1;
GrResourceKey key = TextureResource::ComputeKey(desc);
- GrResource* item = cache->find(key);
+ GrCacheable* item = cache->find(key);
if (NULL != item) {
SkFAIL("cache add does not work as expected");
return;
@@ -156,7 +156,7 @@ static void check_cache_contents_or_die(GrResourceCache* cache, int k) {
get_stencil(k, &w, &h, &s);
h |= 1;
GrResourceKey key = StencilResource::ComputeKey(w, h, s);
- GrResource* item = cache->find(key);
+ GrCacheable* item = cache->find(key);
if (NULL != item) {
SkFAIL("cache add does not work as expected");
return;
« no previous file with comments | « no previous file | gyp/gpu.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698