GrRenderTargetPriv.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 2015 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 GrRenderTargetPriv_DEFINED
  8. #define GrRenderTargetPriv_DEFINED
  9. #include "include/gpu/GrRenderTarget.h"
  10. #include "src/gpu/GrGpu.h"
  11. class GrStencilSettings;
  12. /** Class that adds methods to GrRenderTarget that are only intended for use internal to Skia.
  13. This class is purely a privileged window into GrRenderTarget. It should never have additional
  14. data members or virtual methods. */
  15. class GrRenderTargetPriv {
  16. public:
  17. /**
  18. * GrStencilAttachment is not part of the public API.
  19. */
  20. GrStencilAttachment* getStencilAttachment() const {
  21. return fRenderTarget->fStencilAttachment.get();
  22. }
  23. /**
  24. * Attaches the GrStencilAttachment onto the render target. If stencil is a nullptr then the
  25. * currently attached GrStencilAttachment will be removed if one was previously attached. This
  26. * function returns false if there were any failure in attaching the GrStencilAttachment.
  27. */
  28. void attachStencilAttachment(sk_sp<GrStencilAttachment> stencil);
  29. int numStencilBits() const;
  30. /**
  31. * Returns a unique key that identifies this render target's sample pattern. (Must be
  32. * multisampled.)
  33. */
  34. int getSamplePatternKey() const;
  35. /**
  36. * Retrieves the per-pixel HW sample locations for this render target, and, as a by-product, the
  37. * actual number of samples in use. (This may differ from fSampleCnt.) Sample locations are
  38. * returned as 0..1 offsets relative to the top-left corner of the pixel.
  39. */
  40. const SkTArray<SkPoint>& getSampleLocations() const {
  41. int samplePatternKey = this->getSamplePatternKey();
  42. return fRenderTarget->getGpu()->retrieveSampleLocations(samplePatternKey);
  43. }
  44. private:
  45. explicit GrRenderTargetPriv(GrRenderTarget* renderTarget) : fRenderTarget(renderTarget) {}
  46. GrRenderTargetPriv(const GrRenderTargetPriv&) {} // unimpl
  47. GrRenderTargetPriv& operator=(const GrRenderTargetPriv&); // unimpl
  48. // No taking addresses of this type.
  49. const GrRenderTargetPriv* operator&() const;
  50. GrRenderTargetPriv* operator&();
  51. GrRenderTarget* fRenderTarget;
  52. friend class GrRenderTarget; // to construct/copy this type.
  53. };
  54. inline GrRenderTargetPriv GrRenderTarget::renderTargetPriv() { return GrRenderTargetPriv(this); }
  55. inline const GrRenderTargetPriv GrRenderTarget::renderTargetPriv () const {
  56. return GrRenderTargetPriv(const_cast<GrRenderTarget*>(this));
  57. }
  58. #endif