OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 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 "GrGpu.h" | 10 #include "GrGpu.h" |
11 | 11 |
12 #include "GrBufferAllocPool.h" | 12 #include "GrBufferAllocPool.h" |
13 #include "GrContext.h" | 13 #include "GrContext.h" |
14 #include "GrDrawTargetCaps.h" | 14 #include "GrDrawTargetCaps.h" |
15 #include "GrIndexBuffer.h" | 15 #include "GrIndexBuffer.h" |
| 16 #include "GrResourceCache2.h" |
16 #include "GrStencilBuffer.h" | 17 #include "GrStencilBuffer.h" |
17 #include "GrVertexBuffer.h" | 18 #include "GrVertexBuffer.h" |
18 | 19 |
19 //////////////////////////////////////////////////////////////////////////////// | 20 //////////////////////////////////////////////////////////////////////////////// |
20 | 21 |
21 #define DEBUG_INVAL_BUFFER 0xdeadcafe | |
22 #define DEBUG_INVAL_START_IDX -1 | |
23 | |
24 GrGpu::GrGpu(GrContext* context) | 22 GrGpu::GrGpu(GrContext* context) |
25 : fResetTimestamp(kExpiredTimestamp+1) | 23 : fResetTimestamp(kExpiredTimestamp+1) |
26 , fResetBits(kAll_GrBackendState) | 24 , fResetBits(kAll_GrBackendState) |
27 , fQuadIndexBuffer(NULL) | 25 , fQuadIndexBuffer(NULL) |
28 , fContext(context) { | 26 , fContext(context) { |
29 } | 27 } |
30 | 28 |
31 GrGpu::~GrGpu() { | 29 GrGpu::~GrGpu() { |
32 SkSafeSetNull(fQuadIndexBuffer); | 30 SkSafeSetNull(fQuadIndexBuffer); |
33 } | 31 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 tex->unref(); | 69 tex->unref(); |
72 return NULL; | 70 return NULL; |
73 } | 71 } |
74 } | 72 } |
75 } | 73 } |
76 return tex; | 74 return tex; |
77 } | 75 } |
78 | 76 |
79 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { | 77 bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) { |
80 SkASSERT(NULL == rt->getStencilBuffer()); | 78 SkASSERT(NULL == rt->getStencilBuffer()); |
81 SkAutoTUnref<GrStencilBuffer> sb( | 79 GrResourceKey sbKey = GrStencilBuffer::ComputeKey(rt->width(), rt->height(),
rt->numSamples()); |
82 this->getContext()->findAndRefStencilBuffer(rt->width(), rt->height(), r
t->numSamples())); | 80 SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>( |
| 81 this->getContext()->getResourceCache2()->findAndRefScratchResource(sbKey
))); |
83 if (sb) { | 82 if (sb) { |
84 rt->setStencilBuffer(sb); | 83 rt->setStencilBuffer(sb); |
85 bool attached = this->attachStencilBufferToRenderTarget(sb, rt); | 84 bool attached = this->attachStencilBufferToRenderTarget(sb, rt); |
86 if (!attached) { | 85 if (!attached) { |
87 rt->setStencilBuffer(NULL); | 86 rt->setStencilBuffer(NULL); |
88 } | 87 } |
89 return attached; | 88 return attached; |
90 } | 89 } |
91 if (this->createStencilBufferForRenderTarget(rt, rt->width(), rt->height()))
{ | 90 if (this->createStencilBufferForRenderTarget(rt, rt->width(), rt->height()))
{ |
92 // Right now we're clearing the stencil buffer here after it is | 91 // Right now we're clearing the stencil buffer here after it is |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 this->handleDirtyContext(); | 325 this->handleDirtyContext(); |
327 | 326 |
328 if (!this->flushGraphicsState(ds, kDrawPaths_DrawType)) { | 327 if (!this->flushGraphicsState(ds, kDrawPaths_DrawType)) { |
329 return; | 328 return; |
330 } | 329 } |
331 | 330 |
332 pathRange->willDrawPaths(indices, count); | 331 pathRange->willDrawPaths(indices, count); |
333 this->pathRendering()->drawPaths(pathRange, indices, count, transforms, tran
sformsType, | 332 this->pathRendering()->drawPaths(pathRange, indices, count, transforms, tran
sformsType, |
334 stencilSettings); | 333 stencilSettings); |
335 } | 334 } |
OLD | NEW |