| 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 #ifndef GrStencilBuffer_DEFINED | 10 #ifndef GrStencilBuffer_DEFINED |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 // called to determine if we have to render the clip into SB. | 41 // called to determine if we have to render the clip into SB. |
| 42 bool mustRenderClip(int32_t clipStackGenID, | 42 bool mustRenderClip(int32_t clipStackGenID, |
| 43 const SkIRect& clipSpaceRect, | 43 const SkIRect& clipSpaceRect, |
| 44 const SkIPoint clipSpaceToStencilOffset) const { | 44 const SkIPoint clipSpaceToStencilOffset) const { |
| 45 return fLastClipStackGenID != clipStackGenID || | 45 return fLastClipStackGenID != clipStackGenID || |
| 46 fLastClipSpaceOffset != clipSpaceToStencilOffset || | 46 fLastClipSpaceOffset != clipSpaceToStencilOffset || |
| 47 !fLastClipStackRect.contains(clipSpaceRect); | 47 !fLastClipStackRect.contains(clipSpaceRect); |
| 48 } | 48 } |
| 49 | 49 |
| 50 static void ComputeKey(int width, int height, int sampleCnt, GrScratchKey* k
ey); | 50 // We create a unique stencil buffer at each width, height and sampleCnt and
share it for |
| 51 // all render targets that require a stencil with those params. |
| 52 static void ComputeSharedStencilBufferKey(int width, int height, int sampleC
nt, |
| 53 GrUniqueKey* key); |
| 51 | 54 |
| 52 protected: | 55 protected: |
| 53 GrStencilBuffer(GrGpu* gpu, LifeCycle lifeCycle, int width, int height, int
bits, int sampleCnt) | 56 GrStencilBuffer(GrGpu* gpu, LifeCycle lifeCycle, int width, int height, int
bits, int sampleCnt) |
| 54 : GrGpuResource(gpu, lifeCycle) | 57 : GrGpuResource(gpu, lifeCycle) |
| 55 , fWidth(width) | 58 , fWidth(width) |
| 56 , fHeight(height) | 59 , fHeight(height) |
| 57 , fBits(bits) | 60 , fBits(bits) |
| 58 , fSampleCnt(sampleCnt) | 61 , fSampleCnt(sampleCnt) |
| 59 , fLastClipStackGenID(SkClipStack::kInvalidGenID) { | 62 , fLastClipStackGenID(SkClipStack::kInvalidGenID) { |
| 60 if (kCached_LifeCycle == lifeCycle) { | |
| 61 GrScratchKey key; | |
| 62 ComputeKey(width, height, sampleCnt, &key); | |
| 63 this->setScratchKey(key); | |
| 64 } | |
| 65 fLastClipStackRect.setEmpty(); | 63 fLastClipStackRect.setEmpty(); |
| 66 } | 64 } |
| 67 | 65 |
| 68 private: | 66 private: |
| 69 | 67 |
| 70 int fWidth; | 68 int fWidth; |
| 71 int fHeight; | 69 int fHeight; |
| 72 int fBits; | 70 int fBits; |
| 73 int fSampleCnt; | 71 int fSampleCnt; |
| 74 | 72 |
| 75 int32_t fLastClipStackGenID; | 73 int32_t fLastClipStackGenID; |
| 76 SkIRect fLastClipStackRect; | 74 SkIRect fLastClipStackRect; |
| 77 SkIPoint fLastClipSpaceOffset; | 75 SkIPoint fLastClipSpaceOffset; |
| 78 | 76 |
| 79 typedef GrGpuResource INHERITED; | 77 typedef GrGpuResource INHERITED; |
| 80 }; | 78 }; |
| 81 | 79 |
| 82 #endif | 80 #endif |
| OLD | NEW |