GrImageContextPriv.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2019 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 GrImageContextPriv_DEFINED
  8. #define GrImageContextPriv_DEFINED
  9. #include "include/private/GrImageContext.h"
  10. /** Class that exposes methods on GrImageContext that are only intended for use internal to Skia.
  11. This class is purely a privileged window into GrImageContext. It should never have
  12. additional data members or virtual methods. */
  13. class GrImageContextPriv {
  14. public:
  15. // from GrContext_Base
  16. uint32_t contextID() const { return fContext->contextID(); }
  17. bool matches(GrContext_Base* candidate) const { return fContext->matches(candidate); }
  18. const GrContextOptions& options() const { return fContext->options(); }
  19. const GrCaps* caps() const { return fContext->caps(); }
  20. sk_sp<const GrCaps> refCaps() const;
  21. sk_sp<GrSkSLFPFactoryCache> fpFactoryCache();
  22. GrImageContext* asImageContext() { return fContext->asImageContext(); }
  23. GrRecordingContext* asRecordingContext() { return fContext->asRecordingContext(); }
  24. GrContext* asDirectContext() { return fContext->asDirectContext(); }
  25. // from GrImageContext
  26. GrProxyProvider* proxyProvider() { return fContext->proxyProvider(); }
  27. const GrProxyProvider* proxyProvider() const { return fContext->proxyProvider(); }
  28. bool abandoned() const { return fContext->abandoned(); }
  29. /** This is only useful for debug purposes */
  30. SkDEBUGCODE(GrSingleOwner* singleOwner() const { return fContext->singleOwner(); } )
  31. private:
  32. explicit GrImageContextPriv(GrImageContext* context) : fContext(context) {}
  33. GrImageContextPriv(const GrImageContextPriv&); // unimpl
  34. GrImageContextPriv& operator=(const GrImageContextPriv&); // unimpl
  35. // No taking addresses of this type.
  36. const GrImageContextPriv* operator&() const;
  37. GrImageContextPriv* operator&();
  38. GrImageContext* fContext;
  39. friend class GrImageContext; // to construct/copy this type.
  40. };
  41. inline GrImageContextPriv GrImageContext::priv() { return GrImageContextPriv(this); }
  42. inline const GrImageContextPriv GrImageContext::priv () const {
  43. return GrImageContextPriv(const_cast<GrImageContext*>(this));
  44. }
  45. #endif