• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2011 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 
9 #ifndef GrStencilAttachment_DEFINED
10 #define GrStencilAttachment_DEFINED
11 
12 #include "GrGpuResource.h"
13 #include "SkClipStack.h"
14 
15 class GrRenderTarget;
16 class GrResourceKey;
17 
18 class GrStencilAttachment : public GrGpuResource {
19 public:
20 
21 
~GrStencilAttachment()22     virtual ~GrStencilAttachment() {
23         // TODO: allow SB to be purged and detach itself from rts
24     }
25 
width()26     int width() const { return fWidth; }
height()27     int height() const { return fHeight; }
bits()28     int bits() const { return fBits; }
numSamples()29     int numSamples() const { return fSampleCnt; }
30 
31     // We create a unique stencil buffer at each width, height and sampleCnt and share it for
32     // all render targets that require a stencil with those params.
33     static void ComputeSharedStencilAttachmentKey(int width, int height, int sampleCnt,
34                                                   GrUniqueKey* key);
35 
36 protected:
GrStencilAttachment(GrGpu * gpu,int width,int height,int bits,int sampleCnt)37     GrStencilAttachment(GrGpu* gpu, int width, int height, int bits, int sampleCnt)
38         : GrGpuResource(gpu)
39         , fWidth(width)
40         , fHeight(height)
41         , fBits(bits)
42         , fSampleCnt(sampleCnt) {
43     }
44 
45 private:
46 
47     int fWidth;
48     int fHeight;
49     int fBits;
50     int fSampleCnt;
51 
52     typedef GrGpuResource INHERITED;
53 };
54 
55 #endif
56