GrContextThreadSafeProxyPriv.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 GrContextThreadSafeProxyPriv_DEFINED
  8. #define GrContextThreadSafeProxyPriv_DEFINED
  9. #include "include/gpu/GrContextThreadSafeProxy.h"
  10. #include "src/gpu/GrCaps.h"
  11. /**
  12. * Class that adds methods to GrContextThreadSafeProxy that are only intended for use internal to
  13. * Skia. This class is purely a privileged window into GrContextThreadSafeProxy. It should never
  14. * have additional data members or virtual methods.
  15. */
  16. class GrContextThreadSafeProxyPriv {
  17. public:
  18. // from GrContext_Base
  19. uint32_t contextID() const { return fProxy->contextID(); }
  20. bool matches(GrContext_Base* candidate) const { return fProxy->matches(candidate); }
  21. const GrContextOptions& options() const { return fProxy->options(); }
  22. const GrCaps* caps() const { return fProxy->caps(); }
  23. sk_sp<const GrCaps> refCaps() const { return fProxy->refCaps(); }
  24. sk_sp<GrSkSLFPFactoryCache> fpFactoryCache();
  25. // GrContextThreadSafeProxyPriv
  26. static sk_sp<GrContextThreadSafeProxy> Make(GrBackendApi,
  27. const GrContextOptions&,
  28. uint32_t contextID,
  29. sk_sp<const GrCaps>,
  30. sk_sp<GrSkSLFPFactoryCache>);
  31. private:
  32. explicit GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy* proxy) : fProxy(proxy) {}
  33. GrContextThreadSafeProxyPriv(const GrContextThreadSafeProxy&) = delete;
  34. GrContextThreadSafeProxyPriv& operator=(const GrContextThreadSafeProxyPriv&) = delete;
  35. // No taking addresses of this type.
  36. const GrContextThreadSafeProxyPriv* operator&() const = delete;
  37. GrContextThreadSafeProxyPriv* operator&() = delete;
  38. GrContextThreadSafeProxy* fProxy;
  39. friend class GrContextThreadSafeProxy; // to construct/copy this type.
  40. };
  41. inline GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() {
  42. return GrContextThreadSafeProxyPriv(this);
  43. }
  44. inline const GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() const {
  45. return GrContextThreadSafeProxyPriv(const_cast<GrContextThreadSafeProxy*>(this));
  46. }
  47. #endif