xref: /aosp_15_r20/external/skia/src/gpu/ganesh/GrTextureProxyPriv.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1*c8dee2aaSAndroid Build Coastguard Worker /*
2*c8dee2aaSAndroid Build Coastguard Worker  * Copyright 2017 Google Inc.
3*c8dee2aaSAndroid Build Coastguard Worker  *
4*c8dee2aaSAndroid Build Coastguard Worker  * Use of this source code is governed by a BSD-style license that can be
5*c8dee2aaSAndroid Build Coastguard Worker  * found in the LICENSE file.
6*c8dee2aaSAndroid Build Coastguard Worker  */
7*c8dee2aaSAndroid Build Coastguard Worker 
8*c8dee2aaSAndroid Build Coastguard Worker #ifndef GrTextureProxyPriv_DEFINED
9*c8dee2aaSAndroid Build Coastguard Worker #define GrTextureProxyPriv_DEFINED
10*c8dee2aaSAndroid Build Coastguard Worker 
11*c8dee2aaSAndroid Build Coastguard Worker #include "include/private/base/SkTo.h"
12*c8dee2aaSAndroid Build Coastguard Worker #include "src/gpu/ganesh/GrTextureProxy.h"
13*c8dee2aaSAndroid Build Coastguard Worker 
14*c8dee2aaSAndroid Build Coastguard Worker #include <memory>
15*c8dee2aaSAndroid Build Coastguard Worker 
16*c8dee2aaSAndroid Build Coastguard Worker class GrDeferredProxyUploader;
17*c8dee2aaSAndroid Build Coastguard Worker class GrOpFlushState;
18*c8dee2aaSAndroid Build Coastguard Worker 
19*c8dee2aaSAndroid Build Coastguard Worker /**
20*c8dee2aaSAndroid Build Coastguard Worker  * This class hides the more specialized capabilities of GrTextureProxy.
21*c8dee2aaSAndroid Build Coastguard Worker  */
22*c8dee2aaSAndroid Build Coastguard Worker class GrTextureProxyPriv {
23*c8dee2aaSAndroid Build Coastguard Worker public:
24*c8dee2aaSAndroid Build Coastguard Worker     // Attach a deferred uploader to the proxy. Holds data being prepared by a worker thread.
25*c8dee2aaSAndroid Build Coastguard Worker     void setDeferredUploader(std::unique_ptr<GrDeferredProxyUploader>);
isDeferred()26*c8dee2aaSAndroid Build Coastguard Worker     bool isDeferred() const { return SkToBool(fTextureProxy->fDeferredUploader.get()); }
27*c8dee2aaSAndroid Build Coastguard Worker     // For a deferred proxy (one that has a deferred uploader attached), this schedules an ASAP
28*c8dee2aaSAndroid Build Coastguard Worker     // upload of that data to the instantiated texture.
29*c8dee2aaSAndroid Build Coastguard Worker     void scheduleUpload(GrOpFlushState*);
30*c8dee2aaSAndroid Build Coastguard Worker     // Clears any deferred uploader object on the proxy. Used to free the CPU data after the
31*c8dee2aaSAndroid Build Coastguard Worker     // contents have been uploaded.
32*c8dee2aaSAndroid Build Coastguard Worker     void resetDeferredUploader();
33*c8dee2aaSAndroid Build Coastguard Worker 
34*c8dee2aaSAndroid Build Coastguard Worker private:
GrTextureProxyPriv(GrTextureProxy * textureProxy)35*c8dee2aaSAndroid Build Coastguard Worker     explicit GrTextureProxyPriv(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {}
36*c8dee2aaSAndroid Build Coastguard Worker     GrTextureProxyPriv& operator=(const GrTextureProxyPriv&) = delete;
37*c8dee2aaSAndroid Build Coastguard Worker 
38*c8dee2aaSAndroid Build Coastguard Worker     // No taking addresses of this type.
39*c8dee2aaSAndroid Build Coastguard Worker     const GrTextureProxyPriv* operator&() const;
40*c8dee2aaSAndroid Build Coastguard Worker     GrTextureProxyPriv* operator&();
41*c8dee2aaSAndroid Build Coastguard Worker 
42*c8dee2aaSAndroid Build Coastguard Worker     GrTextureProxy* fTextureProxy;
43*c8dee2aaSAndroid Build Coastguard Worker 
44*c8dee2aaSAndroid Build Coastguard Worker     friend class GrTextureProxy;  // to construct/copy this type.
45*c8dee2aaSAndroid Build Coastguard Worker };
46*c8dee2aaSAndroid Build Coastguard Worker 
texPriv()47*c8dee2aaSAndroid Build Coastguard Worker inline GrTextureProxyPriv GrTextureProxy::texPriv() { return GrTextureProxyPriv(this); }
48*c8dee2aaSAndroid Build Coastguard Worker 
texPriv()49*c8dee2aaSAndroid Build Coastguard Worker inline const GrTextureProxyPriv GrTextureProxy::texPriv() const {  // NOLINT(readability-const-return-type)
50*c8dee2aaSAndroid Build Coastguard Worker     return GrTextureProxyPriv(const_cast<GrTextureProxy*>(this));
51*c8dee2aaSAndroid Build Coastguard Worker }
52*c8dee2aaSAndroid Build Coastguard Worker 
53*c8dee2aaSAndroid Build Coastguard Worker #endif
54