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

Side by Side Diff: tests/ResourceCacheTest.cpp

Issue 91453002: Speed up GrResourceCache add and lookup by using TDynamicHash (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrTMultiMap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #if SK_SUPPORT_GPU 8 #if SK_SUPPORT_GPU
9 9
10 #include "GrContextFactory.h" 10 #include "GrContextFactory.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 r->unref(); 123 r->unref();
124 124
125 // Invalidate all three, all three should be purged and destroyed. 125 // Invalidate all three, all three should be purged and destroyed.
126 REPORTER_ASSERT(reporter, 3 == TestResource::alive()); 126 REPORTER_ASSERT(reporter, 3 == TestResource::alive());
127 const GrResourceInvalidatedMessage msg = { key }; 127 const GrResourceInvalidatedMessage msg = { key };
128 SkMessageBus<GrResourceInvalidatedMessage>::Post(msg); 128 SkMessageBus<GrResourceInvalidatedMessage>::Post(msg);
129 cache.purgeAsNeeded(); 129 cache.purgeAsNeeded();
130 REPORTER_ASSERT(reporter, 0 == TestResource::alive()); 130 REPORTER_ASSERT(reporter, 0 == TestResource::alive());
131 } 131 }
132 132
133 static void test_cache_delete_on_destruction(skiatest::Reporter* reporter,
134 GrContext* context) {
135 GrCacheID::Domain domain = GrCacheID::GenerateDomain();
136 GrCacheID::Key keyData;
137 keyData.fData64[0] = 5;
138 keyData.fData64[1] = 0;
139 GrResourceKey::ResourceType t = GrResourceKey::GenerateResourceType();
140
141 GrResourceKey key(GrCacheID(domain, keyData), t, 0);
142
143 {
144 {
145 GrResourceCache cache(3, 30000);
146 TestResource* a = new TestResource(context->getGpu());
147 TestResource* b = new TestResource(context->getGpu());
148 cache.addResource(key, a);
149 cache.addResource(key, b);
150
151 a->setDeleteWhenDestroyed(&cache, b);
152 b->setDeleteWhenDestroyed(&cache, a);
153
154 a->unref();
155 b->unref();
156 REPORTER_ASSERT(reporter, 2 == TestResource::alive());
157 }
158 REPORTER_ASSERT(reporter, 0 == TestResource::alive());
159 }
160 {
161 GrResourceCache cache(3, 30000);
162 TestResource* a = new TestResource(context->getGpu());
163 TestResource* b = new TestResource(context->getGpu());
164 cache.addResource(key, a);
165 cache.addResource(key, b);
166
167 a->setDeleteWhenDestroyed(&cache, b);
168 b->setDeleteWhenDestroyed(&cache, a);
169
170 a->unref();
171 b->unref();
172
173 cache.deleteResource(a->getCacheEntry());
174
175 REPORTER_ASSERT(reporter, 0 == TestResource::alive());
176 }
177 }
178
133 //////////////////////////////////////////////////////////////////////////////// 179 ////////////////////////////////////////////////////////////////////////////////
134 DEF_GPUTEST(ResourceCache, reporter, factory) { 180 DEF_GPUTEST(ResourceCache, reporter, factory) {
135 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { 181 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
136 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type); 182 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type);
137 if (!GrContextFactory::IsRenderingGLContext(glType)) { 183 if (!GrContextFactory::IsRenderingGLContext(glType)) {
138 continue; 184 continue;
139 } 185 }
140 GrContext* context = factory->get(glType); 186 GrContext* context = factory->get(glType);
141 if (NULL == context) { 187 if (NULL == context) {
142 continue; 188 continue;
143 } 189 }
144 190
145 GrTextureDesc desc; 191 GrTextureDesc desc;
146 desc.fConfig = kSkia8888_GrPixelConfig; 192 desc.fConfig = kSkia8888_GrPixelConfig;
147 desc.fFlags = kRenderTarget_GrTextureFlagBit; 193 desc.fFlags = kRenderTarget_GrTextureFlagBit;
148 desc.fWidth = gWidth; 194 desc.fWidth = gWidth;
149 desc.fHeight = gHeight; 195 desc.fHeight = gHeight;
150 196
151 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NUL L, 0)); 197 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NUL L, 0));
152 SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (context, textu re.get()))); 198 SkAutoTUnref<SkGpuDevice> device(SkNEW_ARGS(SkGpuDevice, (context, textu re.get())));
153 SkCanvas canvas(device.get()); 199 SkCanvas canvas(device.get());
154 200
155 test_cache(reporter, context, &canvas); 201 test_cache(reporter, context, &canvas);
156 test_purge_invalidated(reporter, context); 202 test_purge_invalidated(reporter, context);
203 test_cache_delete_on_destruction(reporter, context);
157 } 204 }
158 } 205 }
159 206
160 #endif 207 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTMultiMap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698