Home | History | Annotate | Download | only in gpu
      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     ~GrStencilAttachment() override {
     21         // TODO: allow SB to be purged and detach itself from rts
     22     }
     23 
     24     int width() const { return fWidth; }
     25     int height() const { return fHeight; }
     26     int bits() const { return fBits; }
     27     int numSamples() const { return fSampleCnt; }
     28     bool isDirty() const { return fIsDirty; }
     29 
     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:
     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:
     48 
     49     int fWidth;
     50     int fHeight;
     51     int fBits;
     52     int fSampleCnt;
     53     bool fIsDirty;
     54 
     55     typedef GrGpuResource INHERITED;
     56 };
     57 
     58 #endif
     59