All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
baseTextureData.h
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_GLF_BASE_TEXTURE_DATA_H
25 #define PXR_IMAGING_GLF_BASE_TEXTURE_DATA_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/glf/api.h"
29 #include "pxr/imaging/glf/image.h"
30 #include "pxr/imaging/glf/utils.h"
31 #include "pxr/imaging/garch/gl.h"
32 #include "pxr/base/tf/declarePtrs.h"
33 #include "pxr/base/tf/refPtr.h"
34 #include "pxr/base/tf/weakPtr.h"
35 
36 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
39 
40 TF_DECLARE_WEAK_AND_REF_PTRS(GlfBaseTextureData);
41 
42 class GlfBaseTextureData : public TfRefBase,
43  public TfWeakBase
44 {
45 public:
46  GlfBaseTextureData() = default;
47 
48  GLF_API
49  virtual ~GlfBaseTextureData();
50 
51  // Disallow copies
52  GlfBaseTextureData(const GlfBaseTextureData&) = delete;
53  GlfBaseTextureData& operator=(const GlfBaseTextureData&) = delete;
54 
55  struct WrapInfo {
56  WrapInfo() :
57  hasWrapModeS(false), hasWrapModeT(false), hasWrapModeR(false),
58  wrapModeS(GL_REPEAT), wrapModeT(GL_REPEAT), wrapModeR(GL_REPEAT) {};
59 
60  bool hasWrapModeS;
61  bool hasWrapModeT;
62  bool hasWrapModeR;
63  GLenum wrapModeS;
64  GLenum wrapModeT;
65  GLenum wrapModeR;
66  };
67 
69  virtual int NumDimensions() const = 0;
70 
71  virtual int ResizedWidth(int mipLevel = 0) const = 0;
72 
73  virtual int ResizedHeight(int mipLevel = 0) const = 0;
74 
75  virtual int ResizedDepth(int mipLevel = 0) const = 0;
76 
77  virtual GLenum GLInternalFormat() const = 0;
78 
79  virtual GLenum GLFormat() const = 0;
80 
81  virtual GLenum GLType() const = 0;
82 
83  virtual size_t TargetMemory() const = 0;
84 
85  virtual WrapInfo GetWrapInfo() const = 0;
86 
87  virtual size_t ComputeBytesUsed() const = 0;
88 
89  virtual size_t ComputeBytesUsedByMip(int mipLevel = 0) const = 0;
90 
91  virtual bool Read(int degradeLevel,
92  bool generateMipmap,
93  GlfImage::ImageOriginLocation originLocation =
94  GlfImage::OriginUpperLeft) = 0;
95 
96  virtual bool HasRawBuffer(int mipLevel = 0) const = 0;
97 
98  virtual unsigned char * GetRawBuffer(int mipLevel = 0) const = 0;
99 
100  virtual int GetNumMipLevels() const = 0;
101 
102  virtual bool IsCompressed() const {
103  return GlfIsCompressedFormat(GLFormat());
104  }
105 
106 protected:
107  // Map image format and type and encoding to GL format.
108  GLF_API
109  static GLenum _GLInternalFormatFromImageData(
110  GLenum format, GLenum type, bool isSRGB);
111 
112 };
113 
114 
115 PXR_NAMESPACE_CLOSE_SCOPE
116 
117 #endif // GLF_BASETEXTURE_DATA
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:71
ImageOriginLocation
Specifies whether to treat the image origin as the upper-left corner or the lower left...
Definition: image.h:58
GLF_API bool GlfIsCompressedFormat(GLenum format)
Check if the format is compressed.
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:141