GrSurfaceContextPriv.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright 2016 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 GrSurfaceContextPriv_DEFINED
  8. #define GrSurfaceContextPriv_DEFINED
  9. #include "src/gpu/GrSurfaceContext.h"
  10. /** Class that adds methods to GrSurfaceContext that are only intended for use internal to
  11. Skia. This class is purely a privileged window into GrSurfaceContext. It should never have
  12. additional data members or virtual methods. */
  13. class GrSurfaceContextPriv {
  14. public:
  15. GrRecordingContext* getContext() { return fSurfaceContext->fContext; }
  16. private:
  17. explicit GrSurfaceContextPriv(GrSurfaceContext* surfaceContext)
  18. : fSurfaceContext(surfaceContext) {
  19. }
  20. GrSurfaceContextPriv(const GrSurfaceContextPriv&) {} // unimpl
  21. GrSurfaceContextPriv& operator=(const GrSurfaceContextPriv&); // unimpl
  22. // No taking addresses of this type.
  23. const GrSurfaceContextPriv* operator&() const;
  24. GrSurfaceContextPriv* operator&();
  25. GrSurfaceContext* fSurfaceContext;
  26. friend class GrSurfaceContext; // to construct/copy this type.
  27. };
  28. inline GrSurfaceContextPriv GrSurfaceContext::surfPriv() {
  29. return GrSurfaceContextPriv(this);
  30. }
  31. inline const GrSurfaceContextPriv GrSurfaceContext::surfPriv() const {
  32. return GrSurfaceContextPriv(const_cast<GrSurfaceContext*>(this));
  33. }
  34. #endif