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 | |
Robert Phillips | abf7b76 | 2018-03-21 12:13:37 -0400 | [diff] [blame] | 34 | bool doesNotSupportMipMaps() const { return fTextureProxy->doesNotSupportMipMaps(); } |
Greg Daniel | b73a9f8 | 2018-05-02 15:06:47 -0400 | [diff] [blame] | 35 | bool isGLTextureRectangleOrExternal() const { |
| 36 | return fTextureProxy->isGLTextureRectangleOrExternal(); |
| 37 | } |
Greg Daniel | 26dbe3b | 2018-05-03 10:35:42 -0400 | [diff] [blame] | 38 | // We assume that if a texture is not a GL_TEXTURE_RECTANGLE or GL_TEXTURE_EXTERNAL then it is a |
| 39 | // GL_TEXTURE_2D |
| 40 | bool isGLTexture2D() const { return !fTextureProxy->isGLTextureRectangleOrExternal(); } |
Greg Daniel | b73a9f8 | 2018-05-02 15:06:47 -0400 | [diff] [blame] | 41 | // We only support the clamp wrap mode with gl rectangle or external textures. |
| 42 | bool isClampOnly() const { return fTextureProxy->isGLTextureRectangleOrExternal(); } |
Robert Phillips | abf7b76 | 2018-03-21 12:13:37 -0400 | [diff] [blame] | 43 | |
Greg Daniel | e320486 | 2018-04-16 11:24:10 -0400 | [diff] [blame] | 44 | void setDoesNotSupportMipMaps() { |
| 45 | fTextureProxy->setDoesNotSupportMipMaps(); |
| 46 | } |
| 47 | |
Robert Phillips | 420c4cf | 2017-09-28 09:00:45 -0400 | [diff] [blame] | 48 | private: |
| 49 | explicit GrTextureProxyPriv(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {} |
| 50 | GrTextureProxyPriv(const GrTextureProxyPriv&) {} // unimpl |
| 51 | GrTextureProxyPriv& operator=(const GrTextureProxyPriv&); // unimpl |
| 52 | |
| 53 | // No taking addresses of this type. |
| 54 | const GrTextureProxyPriv* operator&() const; |
| 55 | GrTextureProxyPriv* operator&(); |
| 56 | |
| 57 | GrTextureProxy* fTextureProxy; |
| 58 | |
| 59 | friend class GrTextureProxy; // to construct/copy this type. |
| 60 | }; |
| 61 | |
| 62 | inline GrTextureProxyPriv GrTextureProxy::texPriv() { return GrTextureProxyPriv(this); } |
| 63 | |
| 64 | inline const GrTextureProxyPriv GrTextureProxy::texPriv() const { |
| 65 | return GrTextureProxyPriv(const_cast<GrTextureProxy*>(this)); |
| 66 | } |
| 67 | |
| 68 | #endif |