OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 | 9 |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
11 | 11 |
12 #include "effects/GrSingleTextureEffect.h" | 12 #include "effects/GrSingleTextureEffect.h" |
13 #include "effects/GrConfigConversionEffect.h" | 13 #include "effects/GrConfigConversionEffect.h" |
14 | 14 |
15 #include "GrAARectRenderer.h" | 15 #include "GrAARectRenderer.h" |
16 #include "GrBufferAllocPool.h" | 16 #include "GrBufferAllocPool.h" |
17 #include "GrDistanceFieldTextContext.h" | 17 #include "GrGpu.h" |
18 #include "GrDrawTargetCaps.h" | 18 #include "GrDrawTargetCaps.h" |
19 #include "GrGpu.h" | 19 #include "GrIndexBuffer.h" |
20 #include "GrInOrderDrawBuffer.h" | 20 #include "GrInOrderDrawBuffer.h" |
21 #include "GrIndexBuffer.h" | |
22 #include "GrOvalRenderer.h" | 21 #include "GrOvalRenderer.h" |
23 #include "GrPathRenderer.h" | 22 #include "GrPathRenderer.h" |
24 #include "GrPathUtils.h" | 23 #include "GrPathUtils.h" |
25 #include "GrResourceCache.h" | 24 #include "GrResourceCache.h" |
26 #include "GrSoftwarePathRenderer.h" | 25 #include "GrSoftwarePathRenderer.h" |
27 #include "GrStencilAndCoverTextContext.h" | |
28 #include "GrStencilBuffer.h" | 26 #include "GrStencilBuffer.h" |
29 #include "GrTextStrike.h" | 27 #include "GrTextStrike.h" |
30 #include "GrTracing.h" | 28 #include "GrTracing.h" |
31 #include "SkGr.h" | 29 #include "SkGr.h" |
| 30 #include "SkRTConf.h" |
32 #include "SkRRect.h" | 31 #include "SkRRect.h" |
33 #include "SkRTConf.h" | |
34 #include "SkStrokeRec.h" | 32 #include "SkStrokeRec.h" |
| 33 #include "SkTLazy.h" |
35 #include "SkTLS.h" | 34 #include "SkTLS.h" |
36 #include "SkTLazy.h" | |
37 #include "SkTraceEvent.h" | 35 #include "SkTraceEvent.h" |
38 | 36 |
39 // It can be useful to set this to false to test whether a bug is caused by usin
g the | 37 // It can be useful to set this to false to test whether a bug is caused by usin
g the |
40 // InOrderDrawBuffer, to compare performance of using/not using InOrderDrawBuffe
r, or to make | 38 // InOrderDrawBuffer, to compare performance of using/not using InOrderDrawBuffe
r, or to make |
41 // debugging simpler. | 39 // debugging simpler. |
42 SK_CONF_DECLARE(bool, c_Defer, "gpu.deferContext", true, | 40 SK_CONF_DECLARE(bool, c_Defer, "gpu.deferContext", true, |
43 "Defers rendering in GrContext via GrInOrderDrawBuffer."); | 41 "Defers rendering in GrContext via GrInOrderDrawBuffer."); |
44 | 42 |
45 #define BUFFERED_DRAW (c_Defer ? kYes_BufferedDraw : kNo_BufferedDraw) | 43 #define BUFFERED_DRAW (c_Defer ? kYes_BufferedDraw : kNo_BufferedDraw) |
46 | 44 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 } | 220 } |
223 | 221 |
224 size_t GrContext::getGpuTextureCacheBytes() const { | 222 size_t GrContext::getGpuTextureCacheBytes() const { |
225 return fTextureCache->getCachedResourceBytes(); | 223 return fTextureCache->getCachedResourceBytes(); |
226 } | 224 } |
227 | 225 |
228 int GrContext::getGpuTextureCacheResourceCount() const { | 226 int GrContext::getGpuTextureCacheResourceCount() const { |
229 return fTextureCache->getCachedResourceCount(); | 227 return fTextureCache->getCachedResourceCount(); |
230 } | 228 } |
231 | 229 |
232 GrTextContext* GrContext::createTextContext(GrRenderTarget* renderTarget, | |
233 const SkDeviceProperties& | |
234 leakyProperties) { | |
235 if (fGpu->caps()->pathRenderingSupport()) { | |
236 if (renderTarget->getStencilBuffer() && renderTarget->isMultisampled())
{ | |
237 return SkNEW_ARGS(GrStencilAndCoverTextContext, (this, leakyProperti
es)); | |
238 } | |
239 } | |
240 return SkNEW_ARGS(GrDistanceFieldTextContext, (this, leakyProperties)); | |
241 } | |
242 | |
243 //////////////////////////////////////////////////////////////////////////////// | 230 //////////////////////////////////////////////////////////////////////////////// |
244 | 231 |
245 GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc, | 232 GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc, |
246 const GrCacheID& cacheID, | 233 const GrCacheID& cacheID, |
247 const GrTextureParams* params) { | 234 const GrTextureParams* params) { |
248 GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, params, desc, cacheI
D); | 235 GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, params, desc, cacheI
D); |
249 GrResource* resource = fTextureCache->find(resourceKey); | 236 GrResource* resource = fTextureCache->find(resourceKey); |
250 SkSafeRef(resource); | 237 SkSafeRef(resource); |
251 return static_cast<GrTexture*>(resource); | 238 return static_cast<GrTexture*>(resource); |
252 } | 239 } |
(...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1798 } | 1785 } |
1799 return path; | 1786 return path; |
1800 } | 1787 } |
1801 | 1788 |
1802 /////////////////////////////////////////////////////////////////////////////// | 1789 /////////////////////////////////////////////////////////////////////////////// |
1803 #if GR_CACHE_STATS | 1790 #if GR_CACHE_STATS |
1804 void GrContext::printCacheStats() const { | 1791 void GrContext::printCacheStats() const { |
1805 fTextureCache->printStats(); | 1792 fTextureCache->printStats(); |
1806 } | 1793 } |
1807 #endif | 1794 #endif |
OLD | NEW |