OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrTest.h" | 9 #include "GrTest.h" |
10 #include "GrContextOptions.h" | 10 #include "GrContextOptions.h" |
11 #include "GrGpuResourceCacheAccess.h" | 11 #include "GrGpuResourceCacheAccess.h" |
12 #include "GrInOrderDrawBuffer.h" | 12 #include "GrInOrderDrawBuffer.h" |
13 #include "GrResourceCache.h" | 13 #include "GrResourceCache.h" |
14 #include "SkString.h" | 14 #include "SkString.h" |
15 | 15 |
16 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target, const GrGLContext*
gl) { | 16 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target) { |
17 SkASSERT(!fContext); | 17 SkASSERT(!fContext); |
18 | 18 |
19 fContext.reset(SkRef(ctx)); | 19 fContext.reset(SkRef(ctx)); |
20 fDrawTarget.reset(SkRef(target)); | 20 fDrawTarget.reset(SkRef(target)); |
21 fGLContext.reset(SkRef(gl)); | |
22 } | 21 } |
23 | 22 |
24 void GrContext::getTestTarget(GrTestTarget* tar) { | 23 void GrContext::getTestTarget(GrTestTarget* tar) { |
25 this->flush(); | 24 this->flush(); |
26 // We could create a proxy GrDrawTarget that passes through to fGpu until ~G
rTextTarget() and | 25 // We could create a proxy GrDrawTarget that passes through to fGpu until ~G
rTextTarget() and |
27 // then disconnects. This would help prevent test writers from mixing using
the returned | 26 // then disconnects. This would help prevent test writers from mixing using
the returned |
28 // GrDrawTarget and regular drawing. We could also assert or fail in GrConte
xt drawing methods | 27 // GrDrawTarget and regular drawing. We could also assert or fail in GrConte
xt drawing methods |
29 // until ~GrTestTarget(). | 28 // until ~GrTestTarget(). |
30 tar->init(this, fDrawingMgr.fDrawTarget, fGpu->glContextForTesting()); | 29 tar->init(this, fDrawingMgr.fDrawTarget); |
31 } | 30 } |
32 | 31 |
33 /////////////////////////////////////////////////////////////////////////////// | 32 /////////////////////////////////////////////////////////////////////////////// |
34 | 33 |
35 void GrContext::purgeAllUnlockedResources() { | 34 void GrContext::purgeAllUnlockedResources() { |
36 fResourceCache->purgeAllUnlocked(); | 35 fResourceCache->purgeAllUnlocked(); |
37 } | 36 } |
38 | 37 |
39 void GrContext::dumpCacheStats(SkString* out) const { | 38 void GrContext::dumpCacheStats(SkString* out) const { |
40 #if GR_CACHE_STATS | 39 #if GR_CACHE_STATS |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 bool attachStencilAttachmentToRenderTarget(GrStencilAttachment*, GrRenderTar
get*) override { | 228 bool attachStencilAttachmentToRenderTarget(GrStencilAttachment*, GrRenderTar
get*) override { |
230 return false; | 229 return false; |
231 } | 230 } |
232 | 231 |
233 void clearStencil(GrRenderTarget* target) override {} | 232 void clearStencil(GrRenderTarget* target) override {} |
234 | 233 |
235 void didAddGpuTraceMarker() override {} | 234 void didAddGpuTraceMarker() override {} |
236 | 235 |
237 void didRemoveGpuTraceMarker() override {} | 236 void didRemoveGpuTraceMarker() override {} |
238 | 237 |
| 238 GrBackendObject createBackendTexture(void* pixels, int w, int h, |
| 239 GrPixelConfig config) const override {
return 0; } |
| 240 bool isBackendTexture(GrBackendObject id) const override { return false; } |
| 241 void deleteBackendTexture(GrBackendObject id) const override {} |
| 242 |
239 typedef GrGpu INHERITED; | 243 typedef GrGpu INHERITED; |
240 }; | 244 }; |
241 | 245 |
242 GrContext* GrContext::CreateMockContext() { | 246 GrContext* GrContext::CreateMockContext() { |
243 GrContext* context = SkNEW(GrContext); | 247 GrContext* context = SkNEW(GrContext); |
244 | 248 |
245 context->initMockContext(); | 249 context->initMockContext(); |
246 return context; | 250 return context; |
247 } | 251 } |
248 | 252 |
249 void GrContext::initMockContext() { | 253 void GrContext::initMockContext() { |
250 GrContextOptions options; | 254 GrContextOptions options; |
251 options.fGeometryBufferMapThreshold = 0; | 255 options.fGeometryBufferMapThreshold = 0; |
252 SkASSERT(NULL == fGpu); | 256 SkASSERT(NULL == fGpu); |
253 fGpu = SkNEW_ARGS(MockGpu, (this, options)); | 257 fGpu = SkNEW_ARGS(MockGpu, (this, options)); |
254 SkASSERT(fGpu); | 258 SkASSERT(fGpu); |
255 this->initCommon(); | 259 this->initCommon(); |
256 | 260 |
257 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of | 261 // We delete these because we want to test the cache starting with zero reso
urces. Also, none of |
258 // these objects are required for any of tests that use this context. TODO:
make stop allocating | 262 // these objects are required for any of tests that use this context. TODO:
make stop allocating |
259 // resources in the buffer pools. | 263 // resources in the buffer pools. |
260 fDrawingMgr.abandon(); | 264 fDrawingMgr.abandon(); |
261 } | 265 } |
OLD | NEW |