OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef GrStencilAttachment_DEFINED | 9 #ifndef GrStencilAttachment_DEFINED |
10 #define GrStencilAttachment_DEFINED | 10 #define GrStencilAttachment_DEFINED |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 int width() const { return fWidth; } | 26 int width() const { return fWidth; } |
27 int height() const { return fHeight; } | 27 int height() const { return fHeight; } |
28 int bits() const { return fBits; } | 28 int bits() const { return fBits; } |
29 int numSamples() const { return fSampleCnt; } | 29 int numSamples() const { return fSampleCnt; } |
30 | 30 |
31 // called to note the last clip drawn to this buffer. | 31 // called to note the last clip drawn to this buffer. |
32 void setLastClip(int32_t clipStackGenID, | 32 void setLastClip(int32_t clipStackGenID, |
33 const SkIRect& clipSpaceRect, | 33 const SkIRect& clipSpaceRect, |
34 const SkIPoint clipSpaceToStencilOffset) { | 34 const SkIPoint clipOrigin) { |
35 fLastClipStackGenID = clipStackGenID; | 35 fLastClipStackGenID = clipStackGenID; |
36 fLastClipStackRect = clipSpaceRect; | 36 fLastClipStackRect = clipSpaceRect; |
37 fLastClipSpaceOffset = clipSpaceToStencilOffset; | 37 fLastClipOrigin = clipOrigin; |
38 } | 38 } |
39 | 39 |
40 // called to determine if we have to render the clip into SB. | 40 // called to determine if we have to render the clip into SB. |
41 bool mustRenderClip(int32_t clipStackGenID, | 41 bool mustRenderClip(int32_t clipStackGenID, |
42 const SkIRect& clipSpaceRect, | 42 const SkIRect& clipSpaceRect, |
43 const SkIPoint clipSpaceToStencilOffset) const { | 43 const SkIPoint& clipOrigin) const { |
44 return fLastClipStackGenID != clipStackGenID || | 44 return fLastClipStackGenID != clipStackGenID || |
45 fLastClipSpaceOffset != clipSpaceToStencilOffset || | 45 fLastClipOrigin != clipOrigin || |
46 !fLastClipStackRect.contains(clipSpaceRect); | 46 !fLastClipStackRect.contains(clipSpaceRect); |
47 } | 47 } |
48 | 48 |
49 // We create a unique stencil buffer at each width, height and sampleCnt and
share it for | 49 // We create a unique stencil buffer at each width, height and sampleCnt and
share it for |
50 // all render targets that require a stencil with those params. | 50 // all render targets that require a stencil with those params. |
51 static void ComputeSharedStencilAttachmentKey(int width, int height, int sam
pleCnt, | 51 static void ComputeSharedStencilAttachmentKey(int width, int height, int sam
pleCnt, |
52 GrUniqueKey* key); | 52 GrUniqueKey* key); |
53 | 53 |
54 protected: | 54 protected: |
55 GrStencilAttachment(GrGpu* gpu, int width, int height, int bits, int sampleC
nt) | 55 GrStencilAttachment(GrGpu* gpu, int width, int height, int bits, int sampleC
nt) |
56 : GrGpuResource(gpu) | 56 : GrGpuResource(gpu) |
57 , fWidth(width) | 57 , fWidth(width) |
58 , fHeight(height) | 58 , fHeight(height) |
59 , fBits(bits) | 59 , fBits(bits) |
60 , fSampleCnt(sampleCnt) | 60 , fSampleCnt(sampleCnt) |
61 , fLastClipStackGenID(SkClipStack::kInvalidGenID) { | 61 , fLastClipStackGenID(SkClipStack::kInvalidGenID) { |
62 fLastClipStackRect.setEmpty(); | 62 fLastClipStackRect.setEmpty(); |
63 } | 63 } |
64 | 64 |
65 private: | 65 private: |
66 | 66 |
67 int fWidth; | 67 int fWidth; |
68 int fHeight; | 68 int fHeight; |
69 int fBits; | 69 int fBits; |
70 int fSampleCnt; | 70 int fSampleCnt; |
71 | 71 |
72 int32_t fLastClipStackGenID; | 72 int32_t fLastClipStackGenID; |
73 SkIRect fLastClipStackRect; | 73 SkIRect fLastClipStackRect; |
74 SkIPoint fLastClipSpaceOffset; | 74 SkIPoint fLastClipOrigin; |
75 | 75 |
76 typedef GrGpuResource INHERITED; | 76 typedef GrGpuResource INHERITED; |
77 }; | 77 }; |
78 | 78 |
79 #endif | 79 #endif |
OLD | NEW |