• 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:
~GrStencilAttachment()20     ~GrStencilAttachment() override {
21         // TODO: allow SB to be purged and detach itself from rts
22     }
23 
width()24     int width() const { return fWidth; }
height()25     int height() const { return fHeight; }
bits()26     int bits() const { return fBits; }
numSamples()27     int numSamples() const { return fSampleCnt; }
isDirty()28     bool isDirty() const { return fIsDirty; }
29 
cleared()30     void cleared() { fIsDirty = false; }
31 
32     // We create a unique stencil buffer at each width, height and sampleCnt and share it for
33     // all render targets that require a stencil with those params.
34     static void ComputeSharedStencilAttachmentKey(int width, int height, int sampleCnt,
35                                                   GrUniqueKey* key);
36 
37 protected:
GrStencilAttachment(GrGpu * gpu,int width,int height,int bits,int sampleCnt)38     GrStencilAttachment(GrGpu* gpu, int width, int height, int bits, int sampleCnt)
39             : INHERITED(gpu)
40             , fWidth(width)
41             , fHeight(height)
42             , fBits(bits)
43             , fSampleCnt(sampleCnt)
44             , fIsDirty(true) {
45     }
46 
47 private:
getResourceType()48     const char* getResourceType() const override { return "Stencil"; }
49 
50     int fWidth;
51     int fHeight;
52     int fBits;
53     int fSampleCnt;
54     bool fIsDirty;
55 
56     typedef GrGpuResource INHERITED;
57 };
58 
59 #endif
60