Debian Codegraph @

src/gpu/ganesh/GrTextureProxyPriv.h

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