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