All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
uvTextureStorageData.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_UVTEXTURESTORAGE_DATA_H
25 #define GLF_UVTEXTURESTORAGE_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/baseTextureData.h"
31 
32 #include "pxr/base/vt/value.h"
33 
34 #include <boost/shared_ptr.hpp>
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
38 
39 TF_DECLARE_WEAK_AND_REF_PTRS(GlfUVTextureStorageData);
40 
41 class GlfUVTextureStorageData : public GlfBaseTextureData
42 {
43 public:
44  GLF_API
45  static GlfUVTextureStorageDataRefPtr
46  New(unsigned int width,
47  unsigned int height,
48  const VtValue &storageData);
49 
50  GLF_API
51  virtual ~GlfUVTextureStorageData();
52 
53  int NumDimensions() const override;
54 
55  // GlfBaseTextureData overrides
56  int ResizedWidth(int mipLevel = 0) const override {
57  return _resizedWidth;
58  };
59 
60  int ResizedHeight(int mipLevel = 0) const override {
61  return _resizedHeight;
62  };
63 
64  int ResizedDepth(int mipLevel = 0) const override {
65  return 1;
66  };
67 
68  GLenum GLInternalFormat() const override {
69  return _glInternalFormat;
70  };
71 
72  GLenum GLFormat() const override {
73  return _glFormat;
74  };
75 
76  GLenum GLType() const override {
77  return _glType;
78  };
79 
80  size_t TargetMemory() const override {
81  return _targetMemory;
82  };
83 
84  WrapInfo GetWrapInfo() const override {
85  return _wrapInfo;
86  };
87 
88  GLF_API
89  size_t ComputeBytesUsed() const override;
90 
91  size_t ComputeBytesUsedByMip(int mipLevel = 0) const override {
92  return ComputeBytesUsed();
93  }
94 
95  GLF_API
96  bool HasRawBuffer(int mipLevel = 0) const override;
97 
98  GLF_API
99  unsigned char * GetRawBuffer(int mipLevel = 0) const override;
100 
101  GLF_API
102  bool Read(
103  int degradeLevel,
104  bool generateMipmap,
105  GlfImage::ImageOriginLocation originLocation =
106  GlfImage::OriginUpperLeft) override;
107 
108  GLF_API
109  bool IsCompressed() const override;
110 
111  GLF_API
112  int GetNumMipLevels() const override;
113 
114 private:
115 
116  GlfUVTextureStorageData(
117  unsigned int width,
118  unsigned int height,
119  const VtValue &storageData);
120 
121  size_t _targetMemory;
122 
123  int _resizedWidth, _resizedHeight;
124  int _bytesPerPixel;
125 
126  // Note: may not want to retain copy of original data
127  // if _storageData is used for larger images
128  VtValue _storageData;
129 
130  GLenum _glInternalFormat, _glFormat, _glType;
131 
132  WrapInfo _wrapInfo;
133 
134  int _size;
135 
136  unsigned char *_rawBuffer;
137 };
138 
139 PXR_NAMESPACE_CLOSE_SCOPE
140 
141 #endif // GLF_UVTEXTURESTORAGE_DATA_H
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
ImageOriginLocation
Specifies whether to treat the image origin as the upper-left corner or the lower left...
Definition: image.h:60
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182