GrSurfacePriv.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright 2014 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 GrSurfacePriv_DEFINED
  8. #define GrSurfacePriv_DEFINED
  9. #include "include/gpu/GrSurface.h"
  10. /** Class that adds methods to GrSurface that are only intended for use internal to Skia.
  11. This class is purely a privileged window into GrSurface. It should never have additional data
  12. members or virtual methods.
  13. Non-static methods that are not trivial inlines should be spring-boarded (e.g. declared and
  14. implemented privately in GrSurface with a inline public method here). */
  15. class GrSurfacePriv {
  16. public:
  17. bool hasPendingRead() const { return fSurface->hasPendingRead(); }
  18. bool hasPendingWrite() const { return fSurface->hasPendingWrite(); }
  19. bool hasPendingIO() const { return fSurface->hasPendingIO(); }
  20. bool hasUniqueRef() const { return fSurface->internalHasUniqueRef(); }
  21. GrInternalSurfaceFlags flags() const { return fSurface->fSurfaceFlags; }
  22. private:
  23. explicit GrSurfacePriv(GrSurface* surface) : fSurface(surface) {}
  24. GrSurfacePriv(const GrSurfacePriv&); // unimpl
  25. GrSurfacePriv& operator=(const GrSurfacePriv&); // unimpl
  26. // No taking addresses of this type.
  27. const GrSurfacePriv* operator&() const;
  28. GrSurfacePriv* operator&();
  29. GrSurface* fSurface;
  30. friend class GrSurface; // to construct/copy this type.
  31. };
  32. inline GrSurfacePriv GrSurface::surfacePriv() { return GrSurfacePriv(this); }
  33. inline const GrSurfacePriv GrSurface::surfacePriv() const {
  34. return GrSurfacePriv(const_cast<GrSurface*>(this));
  35. }
  36. #endif