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 10 matching lines...) Expand all Loading... |
21 | 21 |
22 virtual ~GrStencilAttachment() { | 22 virtual ~GrStencilAttachment() { |
23 // TODO: allow SB to be purged and detach itself from rts | 23 // TODO: allow SB to be purged and detach itself from rts |
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. | |
32 void setLastClip(int32_t clipStackGenID, | |
33 const SkIRect& clipSpaceRect, | |
34 const SkIPoint clipOrigin) { | |
35 fLastClipStackGenID = clipStackGenID; | |
36 fLastClipStackRect = clipSpaceRect; | |
37 fLastClipOrigin = clipOrigin; | |
38 } | |
39 | |
40 // called to determine if we have to render the clip into SB. | |
41 bool mustRenderClip(int32_t clipStackGenID, | |
42 const SkIRect& clipSpaceRect, | |
43 const SkIPoint& clipOrigin) const { | |
44 return fLastClipStackGenID != clipStackGenID || | |
45 fLastClipOrigin != clipOrigin || | |
46 !fLastClipStackRect.contains(clipSpaceRect); | |
47 } | |
48 | |
49 // We create a unique stencil buffer at each width, height and sampleCnt and
share it for | 31 // 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. | 32 // all render targets that require a stencil with those params. |
51 static void ComputeSharedStencilAttachmentKey(int width, int height, int sam
pleCnt, | 33 static void ComputeSharedStencilAttachmentKey(int width, int height, int sam
pleCnt, |
52 GrUniqueKey* key); | 34 GrUniqueKey* key); |
53 | 35 |
54 protected: | 36 protected: |
55 GrStencilAttachment(GrGpu* gpu, int width, int height, int bits, int sampleC
nt) | 37 GrStencilAttachment(GrGpu* gpu, int width, int height, int bits, int sampleC
nt) |
56 : GrGpuResource(gpu) | 38 : GrGpuResource(gpu) |
57 , fWidth(width) | 39 , fWidth(width) |
58 , fHeight(height) | 40 , fHeight(height) |
59 , fBits(bits) | 41 , fBits(bits) |
60 , fSampleCnt(sampleCnt) | 42 , fSampleCnt(sampleCnt) { |
61 , fLastClipStackGenID(SkClipStack::kInvalidGenID) { | |
62 fLastClipStackRect.setEmpty(); | |
63 } | 43 } |
64 | 44 |
65 private: | 45 private: |
66 | 46 |
67 int fWidth; | 47 int fWidth; |
68 int fHeight; | 48 int fHeight; |
69 int fBits; | 49 int fBits; |
70 int fSampleCnt; | 50 int fSampleCnt; |
71 | 51 |
72 int32_t fLastClipStackGenID; | |
73 SkIRect fLastClipStackRect; | |
74 SkIPoint fLastClipOrigin; | |
75 | |
76 typedef GrGpuResource INHERITED; | 52 typedef GrGpuResource INHERITED; |
77 }; | 53 }; |
78 | 54 |
79 #endif | 55 #endif |
OLD | NEW |