GrImageContext.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 GrImageContext_DEFINED
  8. #define GrImageContext_DEFINED
  9. #include "include/private/GrContext_Base.h"
  10. #include "include/private/GrSingleOwner.h"
  11. class GrImageContextPriv;
  12. class GrProxyProvider;
  13. class SK_API GrImageContext : public GrContext_Base {
  14. public:
  15. ~GrImageContext() override;
  16. // Provides access to functions that aren't part of the public API.
  17. GrImageContextPriv priv();
  18. const GrImageContextPriv priv() const;
  19. protected:
  20. friend class GrImageContextPriv; // for hidden functions
  21. GrImageContext(GrBackendApi, const GrContextOptions&, uint32_t contextID);
  22. virtual void abandonContext();
  23. bool abandoned() const;
  24. GrProxyProvider* proxyProvider() { return fProxyProvider.get(); }
  25. const GrProxyProvider* proxyProvider() const { return fProxyProvider.get(); }
  26. /** This is only useful for debug purposes */
  27. GrSingleOwner* singleOwner() const { return &fSingleOwner; }
  28. GrImageContext* asImageContext() override { return this; }
  29. private:
  30. std::unique_ptr<GrProxyProvider> fProxyProvider;
  31. bool fAbandoned = false;
  32. // In debug builds we guard against improper thread handling
  33. // This guard is passed to the GrDrawingManager and, from there to all the
  34. // GrRenderTargetContexts. It is also passed to the GrResourceProvider and SkGpuDevice.
  35. mutable GrSingleOwner fSingleOwner;
  36. typedef GrContext_Base INHERITED;
  37. };
  38. #endif