GrResourceProviderPriv.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 GrResourceProviderPriv_DEFINED
  8. #define GrResourceProviderPriv_DEFINED
  9. #include "src/gpu/GrResourceProvider.h"
  10. /** Class that adds methods to GrResourceProvider that are only intended for use internal to Skia.
  11. This class is purely a privileged window into GrResourceProvider. It should never have
  12. additional data members or virtual methods. */
  13. class GrResourceProviderPriv {
  14. public:
  15. GrGpu* gpu() { return fResourceProvider->gpu(); }
  16. private:
  17. explicit GrResourceProviderPriv(GrResourceProvider* provider) : fResourceProvider(provider) {}
  18. GrResourceProviderPriv(const GrResourceProviderPriv&); // unimpl
  19. GrResourceProviderPriv& operator=(const GrResourceProviderPriv&); // unimpl
  20. // No taking addresses of this type.
  21. const GrResourceProviderPriv* operator&() const;
  22. GrResourceProviderPriv* operator&();
  23. GrResourceProvider* fResourceProvider;
  24. friend class GrResourceProvider; // to construct/copy this type
  25. };
  26. inline GrResourceProviderPriv GrResourceProvider::priv() { return GrResourceProviderPriv(this); }
  27. inline const GrResourceProviderPriv GrResourceProvider::priv() const {
  28. return GrResourceProviderPriv(const_cast<GrResourceProvider*>(this));
  29. }
  30. #endif