GrStencilAttachment.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #ifndef GrStencilAttachment_DEFINED
  8. #define GrStencilAttachment_DEFINED
  9. #include "include/gpu/GrGpuResource.h"
  10. #include "src/core/SkClipStack.h"
  11. class GrRenderTarget;
  12. class GrResourceKey;
  13. class GrStencilAttachment : public GrGpuResource {
  14. public:
  15. ~GrStencilAttachment() override {
  16. // TODO: allow SB to be purged and detach itself from rts
  17. }
  18. int width() const { return fWidth; }
  19. int height() const { return fHeight; }
  20. int bits() const { return fBits; }
  21. int numSamples() const { return fSampleCnt; }
  22. bool isDirty() const { return fIsDirty; }
  23. void cleared() { fIsDirty = false; }
  24. // We create a unique stencil buffer at each width, height and sampleCnt and share it for
  25. // all render targets that require a stencil with those params.
  26. static void ComputeSharedStencilAttachmentKey(int width, int height, int sampleCnt,
  27. GrUniqueKey* key);
  28. protected:
  29. GrStencilAttachment(GrGpu* gpu, int width, int height, int bits, int sampleCnt)
  30. : INHERITED(gpu)
  31. , fWidth(width)
  32. , fHeight(height)
  33. , fBits(bits)
  34. , fSampleCnt(sampleCnt)
  35. , fIsDirty(true) {
  36. }
  37. private:
  38. const char* getResourceType() const override { return "Stencil"; }
  39. int fWidth;
  40. int fHeight;
  41. int fBits;
  42. int fSampleCnt;
  43. bool fIsDirty;
  44. typedef GrGpuResource INHERITED;
  45. };
  46. #endif