GrMtlStencilAttachment.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright 2018 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 GrMtlStencil_DEFINED
  8. #define GrMtlStencil_DEFINED
  9. #include "src/gpu/GrStencilAttachment.h"
  10. #import <Metal/Metal.h>
  11. class GrMtlImageView;
  12. class GrMtlGpu;
  13. class GrMtlStencilAttachment : public GrStencilAttachment {
  14. public:
  15. struct Format {
  16. MTLPixelFormat fInternalFormat;
  17. int fStencilBits;
  18. int fTotalBits;
  19. bool fPacked;
  20. };
  21. static GrMtlStencilAttachment* Create(GrMtlGpu* gpu, int width, int height,
  22. int sampleCnt, const Format& format);
  23. ~GrMtlStencilAttachment() override;
  24. MTLPixelFormat mtlFormat() const { return fFormat.fInternalFormat; }
  25. id<MTLTexture> stencilView() const { return fStencilView; }
  26. protected:
  27. void onRelease() override;
  28. void onAbandon() override;
  29. private:
  30. size_t onGpuMemorySize() const override;
  31. GrMtlStencilAttachment(GrMtlGpu* gpu,
  32. const Format& format,
  33. const id<MTLTexture> stencilView);
  34. GrMtlGpu* getMtlGpu() const;
  35. Format fFormat;
  36. id<MTLTexture> fStencilView;
  37. };
  38. #endif