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 #include "GrContext.h" | 9 #include "GrContext.h" |
10 | 10 |
11 #include "GrAARectRenderer.h" | 11 #include "GrAARectRenderer.h" |
12 #include "GrBufferAllocPool.h" | 12 #include "GrBufferAllocPool.h" |
13 #include "GrDefaultGeoProcFactory.h" | 13 #include "GrDefaultGeoProcFactory.h" |
14 #include "GrGpuResource.h" | 14 #include "GrGpuResource.h" |
15 #include "GrGpuResourceCacheAccess.h" | 15 #include "GrGpuResourceCacheAccess.h" |
16 #include "GrDistanceFieldTextContext.h" | 16 #include "GrDistanceFieldTextContext.h" |
17 #include "GrDrawTargetCaps.h" | 17 #include "GrDrawTargetCaps.h" |
18 #include "GrGpu.h" | 18 #include "GrGpu.h" |
19 #include "GrIndexBuffer.h" | 19 #include "GrIndexBuffer.h" |
20 #include "GrInOrderDrawBuffer.h" | 20 #include "GrInOrderDrawBuffer.h" |
21 #include "GrLayerCache.h" | 21 #include "GrLayerCache.h" |
22 #include "GrOvalRenderer.h" | 22 #include "GrOvalRenderer.h" |
23 #include "GrPathRenderer.h" | 23 #include "GrPathRenderer.h" |
24 #include "GrPathUtils.h" | 24 #include "GrPathUtils.h" |
25 #include "GrResourceCache2.h" | 25 #include "GrResourceCache2.h" |
26 #include "GrSoftwarePathRenderer.h" | 26 #include "GrSoftwarePathRenderer.h" |
| 27 #include "GrStencilBuffer.h" |
27 #include "GrStencilAndCoverTextContext.h" | 28 #include "GrStencilAndCoverTextContext.h" |
28 #include "GrStrokeInfo.h" | 29 #include "GrStrokeInfo.h" |
29 #include "GrSurfacePriv.h" | 30 #include "GrSurfacePriv.h" |
30 #include "GrTextStrike.h" | 31 #include "GrTextStrike.h" |
31 #include "GrTexturePriv.h" | 32 #include "GrTexturePriv.h" |
32 #include "GrTraceMarker.h" | 33 #include "GrTraceMarker.h" |
33 #include "GrTracing.h" | 34 #include "GrTracing.h" |
34 #include "SkDashPathPriv.h" | 35 #include "SkDashPathPriv.h" |
35 #include "SkConfig8888.h" | 36 #include "SkConfig8888.h" |
36 #include "SkGr.h" | 37 #include "SkGr.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 return NULL; | 245 return NULL; |
245 } | 246 } |
246 | 247 |
247 bool GrContext::isTextureInCache(const GrSurfaceDesc& desc, | 248 bool GrContext::isTextureInCache(const GrSurfaceDesc& desc, |
248 const GrCacheID& cacheID, | 249 const GrCacheID& cacheID, |
249 const GrTextureParams* params) const { | 250 const GrTextureParams* params) const { |
250 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca
cheID); | 251 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca
cheID); |
251 return fResourceCache2->hasContentKey(resourceKey); | 252 return fResourceCache2->hasContentKey(resourceKey); |
252 } | 253 } |
253 | 254 |
| 255 void GrContext::addStencilBuffer(GrStencilBuffer* sb) { |
| 256 // TODO: Make GrStencilBuffers use the scratch mechanism rather than content
keys. |
| 257 ASSERT_OWNED_RESOURCE(sb); |
| 258 |
| 259 GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(sb->width(), |
| 260 sb->height(), |
| 261 sb->numSamples()); |
| 262 SkAssertResult(sb->cacheAccess().setContentKey(resourceKey)); |
| 263 } |
| 264 |
| 265 GrStencilBuffer* GrContext::findAndRefStencilBuffer(int width, int height, int s
ampleCnt) { |
| 266 GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(width, height, sampl
eCnt); |
| 267 GrGpuResource* resource = this->findAndRefCachedResource(resourceKey); |
| 268 return static_cast<GrStencilBuffer*>(resource); |
| 269 } |
| 270 |
254 static void stretch_image(void* dst, | 271 static void stretch_image(void* dst, |
255 int dstW, | 272 int dstW, |
256 int dstH, | 273 int dstH, |
257 const void* src, | 274 const void* src, |
258 int srcW, | 275 int srcW, |
259 int srcH, | 276 int srcH, |
260 size_t bpp) { | 277 size_t bpp) { |
261 SkFixed dx = (srcW << 16) / dstW; | 278 SkFixed dx = (srcW << 16) / dstW; |
262 SkFixed dy = (srcH << 16) / dstH; | 279 SkFixed dy = (srcH << 16) / dstH; |
263 | 280 |
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 fResourceCache2->printStats(); | 1726 fResourceCache2->printStats(); |
1710 } | 1727 } |
1711 #endif | 1728 #endif |
1712 | 1729 |
1713 #if GR_GPU_STATS | 1730 #if GR_GPU_STATS |
1714 const GrContext::GPUStats* GrContext::gpuStats() const { | 1731 const GrContext::GPUStats* GrContext::gpuStats() const { |
1715 return fGpu->gpuStats(); | 1732 return fGpu->gpuStats(); |
1716 } | 1733 } |
1717 #endif | 1734 #endif |
1718 | 1735 |
OLD | NEW |