GrGLStencilAttachment.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 GrGLStencilAttachment_DEFINED
  8. #define GrGLStencilAttachment_DEFINED
  9. #include "include/gpu/gl/GrGLInterface.h"
  10. #include "src/gpu/GrStencilAttachment.h"
  11. class GrGLStencilAttachment : public GrStencilAttachment {
  12. public:
  13. static const GrGLenum kUnknownInternalFormat = ~0U;
  14. static const GrGLuint kUnknownBitCount = ~0U;
  15. struct Format {
  16. GrGLenum fInternalFormat;
  17. GrGLuint fStencilBits;
  18. GrGLuint fTotalBits;
  19. bool fPacked;
  20. };
  21. struct IDDesc {
  22. IDDesc() : fRenderbufferID(0) {}
  23. GrGLuint fRenderbufferID;
  24. };
  25. GrGLStencilAttachment(GrGpu* gpu,
  26. const IDDesc& idDesc,
  27. int width, int height,
  28. int sampleCnt,
  29. const Format& format)
  30. : GrStencilAttachment(gpu, width, height, format.fStencilBits, sampleCnt)
  31. , fFormat(format)
  32. , fRenderbufferID(idDesc.fRenderbufferID) {
  33. this->registerWithCache(SkBudgeted::kYes);
  34. }
  35. GrGLuint renderbufferID() const {
  36. return fRenderbufferID;
  37. }
  38. const Format& format() const { return fFormat; }
  39. protected:
  40. // overrides of GrResource
  41. void onRelease() override;
  42. void onAbandon() override;
  43. void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
  44. const SkString& dumpName) const override;
  45. private:
  46. size_t onGpuMemorySize() const override;
  47. Format fFormat;
  48. // may be zero for external SBs associated with external RTs
  49. // (we don't require the client to give us the id, just tell
  50. // us how many bits of stencil there are).
  51. GrGLuint fRenderbufferID;
  52. typedef GrStencilAttachment INHERITED;
  53. };
  54. #endif