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