blob: 358369d51654d080a2216315298739d6f8da4452 [file] [log] [blame]
Robert Phillips420c4cf2017-09-28 09:00:45 -04001/*
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
Brian Osman099fa0f2017-10-02 16:38:32 -040013class GrDeferredProxyUploader;
14class GrOpFlushState;
15
Robert Phillips420c4cf2017-09-28 09:00:45 -040016/**
17 * This class hides the more specialized capabilities of GrTextureProxy.
18 */
19class GrTextureProxyPriv {
20public:
Brian Osman099fa0f2017-10-02 16:38:32 -040021 // 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();
Greg Daniel3b2ebbb2018-02-09 10:49:23 -050030 // Returns the GrMipMapped value of the proxy from creation time regardless of whether it has
31 // been instantiated or not.
32 GrMipMapped proxyMipMapped() const { return fTextureProxy->fMipMapped; }
Robert Phillips420c4cf2017-09-28 09:00:45 -040033
Greg Danielb73a9f82018-05-02 15:06:47 -040034 bool isGLTextureRectangleOrExternal() const {
35 return fTextureProxy->isGLTextureRectangleOrExternal();
36 }
Greg Daniel26dbe3b2018-05-03 10:35:42 -040037 // We assume that if a texture is not a GL_TEXTURE_RECTANGLE or GL_TEXTURE_EXTERNAL then it is a
38 // GL_TEXTURE_2D
39 bool isGLTexture2D() const { return !fTextureProxy->isGLTextureRectangleOrExternal(); }
Greg Danielb73a9f82018-05-02 15:06:47 -040040 // We only support the clamp wrap mode with gl rectangle or external textures.
41 bool isClampOnly() const { return fTextureProxy->isGLTextureRectangleOrExternal(); }
Robert Phillipsabf7b762018-03-21 12:13:37 -040042
Robert Phillips420c4cf2017-09-28 09:00:45 -040043private:
44 explicit GrTextureProxyPriv(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {}
45 GrTextureProxyPriv(const GrTextureProxyPriv&) {} // unimpl
46 GrTextureProxyPriv& operator=(const GrTextureProxyPriv&); // unimpl
47
48 // No taking addresses of this type.
49 const GrTextureProxyPriv* operator&() const;
50 GrTextureProxyPriv* operator&();
51
52 GrTextureProxy* fTextureProxy;
53
54 friend class GrTextureProxy; // to construct/copy this type.
55};
56
57inline GrTextureProxyPriv GrTextureProxy::texPriv() { return GrTextureProxyPriv(this); }
58
59inline const GrTextureProxyPriv GrTextureProxy::texPriv() const {
60 return GrTextureProxyPriv(const_cast<GrTextureProxy*>(this));
61}
62
63#endif