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 GLF_BASETEXTUREDATA_H
25 #define GLF_BASETEXTUREDATA_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 #include <boost/noncopyable.hpp>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 
41 TF_DECLARE_WEAK_AND_REF_PTRS(GlfBaseTextureData);
42 
43 class GlfBaseTextureData : public TfRefBase,
44  public TfWeakBase,
45  boost::noncopyable
46 {
47 public:
48  GLF_API
49  virtual ~GlfBaseTextureData();
50 
51  struct WrapInfo {
52  WrapInfo() :
53  hasWrapModeS(false), hasWrapModeT(false), hasWrapModeR(false),
54  wrapModeS(GL_REPEAT), wrapModeT(GL_REPEAT), wrapModeR(GL_REPEAT) {};
55 
56  bool hasWrapModeS;
57  bool hasWrapModeT;
58  bool hasWrapModeR;
59  GLenum wrapModeS;
60  GLenum wrapModeT;
61  GLenum wrapModeR;
62  };
63 
65  virtual int NumDimensions() const = 0;
66 
67  virtual int ResizedWidth(int mipLevel = 0) const = 0;
68 
69  virtual int ResizedHeight(int mipLevel = 0) const = 0;
70 
71  virtual int ResizedDepth(int mipLevel = 0) const = 0;
72 
73  virtual GLenum GLInternalFormat() const = 0;
74 
75  virtual GLenum GLFormat() const = 0;
76 
77  virtual GLenum GLType() const = 0;
78 
79  virtual size_t TargetMemory() const = 0;
80 
81  virtual WrapInfo GetWrapInfo() const = 0;
82 
83  virtual size_t ComputeBytesUsed() const = 0;
84 
85  virtual size_t ComputeBytesUsedByMip(int mipLevel = 0) const = 0;
86 
87  virtual bool Read(int degradeLevel,
88  bool generateMipmap,
89  GlfImage::ImageOriginLocation originLocation =
90  GlfImage::OriginUpperLeft) = 0;
91 
92  virtual bool HasRawBuffer(int mipLevel = 0) const = 0;
93 
94  virtual unsigned char * GetRawBuffer(int mipLevel = 0) const = 0;
95 
96  virtual int GetNumMipLevels() const = 0;
97 
98  virtual bool IsCompressed() const {
99  return GlfIsCompressedFormat(GLFormat());
100  }
101 
102 protected:
103  // Map image format and type and encoding to GL format.
104  GLF_API
105  static GLenum _GLInternalFormatFromImageData(
106  GLenum format, GLenum type, bool isSRGB);
107 
108 };
109 
110 
111 PXR_NAMESPACE_CLOSE_SCOPE
112 
113 #endif // GLF_BASETEXTURE_DATA
bool GlfIsCompressedFormat(GLenum format)
Check if the format is compressed.
#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:72
ImageOriginLocation
Specifies whether to treat the image origin as the upper-left corner or the lower left...
Definition: image.h:60
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:142