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 "GrTextureProxy.h"
12
13class GrDeferredProxyUploader;
14class GrOpFlushState;
15
16/**
17 * This class hides the more specialized capabilities of GrTextureProxy.
18 */
19class GrTextureProxyPriv {
20public:
21    // Attach a deferred uploader to the proxy. Holds data being prepared by a worker thread.
22    void setDeferredUploader(std::unique_ptr<GrDeferredProxyUploader>);
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
31private:
32    explicit GrTextureProxyPriv(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {}
33    GrTextureProxyPriv(const GrTextureProxyPriv&) {} // unimpl
34    GrTextureProxyPriv& operator=(const GrTextureProxyPriv&); // unimpl
35
36    // No taking addresses of this type.
37    const GrTextureProxyPriv* operator&() const;
38    GrTextureProxyPriv* operator&();
39
40    GrTextureProxy* fTextureProxy;
41
42    friend class GrTextureProxy;  // to construct/copy this type.
43};
44
45inline GrTextureProxyPriv GrTextureProxy::texPriv() { return GrTextureProxyPriv(this); }
46
47inline const GrTextureProxyPriv GrTextureProxy::texPriv() const {
48    return GrTextureProxyPriv(const_cast<GrTextureProxy*>(this));
49}
50
51#endif
52