Robert Phillips | 420c4cf | 2017-09-28 09:00:45 -0400 | [diff] [blame] | 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 | |
Brian Osman | 099fa0f | 2017-10-02 16:38:32 -0400 | [diff] [blame] | 13 | class GrDeferredProxyUploader; |
| 14 | class GrOpFlushState; |
| 15 | |
Robert Phillips | 420c4cf | 2017-09-28 09:00:45 -0400 | [diff] [blame] | 16 | /** |
| 17 | * This class hides the more specialized capabilities of GrTextureProxy. |
| 18 | */ |
| 19 | class GrTextureProxyPriv { |
| 20 | public: |
Brian Osman | 099fa0f | 2017-10-02 16:38:32 -0400 | [diff] [blame] | 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(); |
Greg Daniel | 3b2ebbb | 2018-02-09 10:49:23 -0500 | [diff] [blame] | 30 | // 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 Phillips | 420c4cf | 2017-09-28 09:00:45 -0400 | [diff] [blame] | 33 | |
Greg Daniel | b73a9f8 | 2018-05-02 15:06:47 -0400 | [diff] [blame] | 34 | bool isGLTextureRectangleOrExternal() const { |
| 35 | return fTextureProxy->isGLTextureRectangleOrExternal(); |
| 36 | } |
Greg Daniel | 26dbe3b | 2018-05-03 10:35:42 -0400 | [diff] [blame] | 37 | // 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 Daniel | b73a9f8 | 2018-05-02 15:06:47 -0400 | [diff] [blame] | 40 | // We only support the clamp wrap mode with gl rectangle or external textures. |
| 41 | bool isClampOnly() const { return fTextureProxy->isGLTextureRectangleOrExternal(); } |
Robert Phillips | abf7b76 | 2018-03-21 12:13:37 -0400 | [diff] [blame] | 42 | |
Robert Phillips | 420c4cf | 2017-09-28 09:00:45 -0400 | [diff] [blame] | 43 | private: |
| 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 | |
| 57 | inline GrTextureProxyPriv GrTextureProxy::texPriv() { return GrTextureProxyPriv(this); } |
| 58 | |
| 59 | inline const GrTextureProxyPriv GrTextureProxy::texPriv() const { |
| 60 | return GrTextureProxyPriv(const_cast<GrTextureProxy*>(this)); |
| 61 | } |
| 62 | |
| 63 | #endif |