GrTextureProxyPriv.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2017 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 GrTextureProxyPriv_DEFINED
  8. #define GrTextureProxyPriv_DEFINED
  9. #include "src/gpu/GrTextureProxy.h"
  10. class GrDeferredProxyUploader;
  11. class GrOpFlushState;
  12. /**
  13. * This class hides the more specialized capabilities of GrTextureProxy.
  14. */
  15. class GrTextureProxyPriv {
  16. public:
  17. // Attach a deferred uploader to the proxy. Holds data being prepared by a worker thread.
  18. void setDeferredUploader(std::unique_ptr<GrDeferredProxyUploader>);
  19. bool isDeferred() const { return SkToBool(fTextureProxy->fDeferredUploader.get()); }
  20. // For a deferred proxy (one that has a deferred uploader attached), this schedules an ASAP
  21. // upload of that data to the instantiated texture.
  22. void scheduleUpload(GrOpFlushState*);
  23. // Clears any deferred uploader object on the proxy. Used to free the CPU data after the
  24. // contents have been uploaded.
  25. void resetDeferredUploader();
  26. private:
  27. explicit GrTextureProxyPriv(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {}
  28. GrTextureProxyPriv(const GrTextureProxyPriv&) {} // unimpl
  29. GrTextureProxyPriv& operator=(const GrTextureProxyPriv&); // unimpl
  30. // No taking addresses of this type.
  31. const GrTextureProxyPriv* operator&() const;
  32. GrTextureProxyPriv* operator&();
  33. GrTextureProxy* fTextureProxy;
  34. friend class GrTextureProxy; // to construct/copy this type.
  35. };
  36. inline GrTextureProxyPriv GrTextureProxy::texPriv() { return GrTextureProxyPriv(this); }
  37. inline const GrTextureProxyPriv GrTextureProxy::texPriv() const {
  38. return GrTextureProxyPriv(const_cast<GrTextureProxy*>(this));
  39. }
  40. #endif