blob: cadd2fde638f5999ca24d7f6b61df17b830fb264 [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
Robert Phillipsabf7b762018-03-21 12:13:37 -040034 bool doesNotSupportMipMaps() const { return fTextureProxy->doesNotSupportMipMaps(); }
Greg Danielb73a9f82018-05-02 15:06:47 -040035 bool isGLTextureRectangleOrExternal() const {
36 return fTextureProxy->isGLTextureRectangleOrExternal();
37 }
Greg Daniel26dbe3b2018-05-03 10:35:42 -040038 // 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 Danielb73a9f82018-05-02 15:06:47 -040041 // We only support the clamp wrap mode with gl rectangle or external textures.
42 bool isClampOnly() const { return fTextureProxy->isGLTextureRectangleOrExternal(); }
Robert Phillipsabf7b762018-03-21 12:13:37 -040043
Greg Daniele3204862018-04-16 11:24:10 -040044 void setDoesNotSupportMipMaps() {
45 fTextureProxy->setDoesNotSupportMipMaps();
46 }
47
Robert Phillips420c4cf2017-09-28 09:00:45 -040048private:
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
62inline GrTextureProxyPriv GrTextureProxy::texPriv() { return GrTextureProxyPriv(this); }
63
64inline const GrTextureProxyPriv GrTextureProxy::texPriv() const {
65 return GrTextureProxyPriv(const_cast<GrTextureProxy*>(this));
66}
67
68#endif