HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImfDeepFrameBuffer.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
4 // Digital Ltd. LLC
5 //
6 // All rights reserved.
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions are
10 // met:
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
16 // distribution.
17 // * Neither the name of Industrial Light & Magic nor the names of
18 // its contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
33 ///////////////////////////////////////////////////////////////////////////
34 
35 #ifndef IMFDEEPFRAMEBUFFER_H_
36 #define IMFDEEPFRAMEBUFFER_H_
37 
38 #include "ImfFrameBuffer.h"
39 #include "ImfNamespace.h"
40 #include "ImfExport.h"
41 
43 
44 //--------------------------------------------------------
45 // Description of a single deep slice of the frame buffer:
46 //--------------------------------------------------------
47 
48 struct IMF_EXPORT DeepSlice : public Slice
49 {
50  //---------------------------------------------------------------------
51  // The stride for each sample in this slice.
52  //
53  // Memory layout: The address of sample i in pixel (x, y) is
54  //
55  // base + (xp / xSampling) * xStride + (yp / ySampling) * yStride
56  // + i * sampleStride
57  //
58  // where xp and yp are computed as follows:
59  //
60  // * If we are reading or writing a scanline-based file:
61  //
62  // xp = x
63  // yp = y
64  //
65  // * If we are reading a tile whose upper left coorner is at (xt, yt):
66  //
67  // if xTileCoords is true then xp = x - xt, else xp = x
68  // if yTileCoords is true then yp = y - yt, else yp = y
69  //
70  //---------------------------------------------------------------------
71 
73 
74  //------------
75  // Constructor
76  //------------
78  char * base = 0,
79  size_t xStride = 0,
80  size_t yStride = 0,
81  size_t sampleStride = 0,
82  int xSampling = 1,
83  int ySampling = 1,
84  double fillValue = 0.0,
85  bool xTileCoords = false,
86  bool yTileCoords = false);
87 };
88 
89 //-----------------
90 // DeepFrameBuffer.
91 //-----------------
92 
94 {
95  public:
96 
97 
98  //------------
99  // Add a slice
100  //------------
101 
102  void insert (const char name[],
103  const DeepSlice &slice);
104 
105  void insert (const std::string &name,
106  const DeepSlice &slice);
107 
108  //----------------------------------------------------------------
109  // Access to existing slices:
110  //
111  // [n] Returns a reference to the slice with name n.
112  // If no slice with name n exists, an IEX_NAMESPACE::ArgExc
113  // is thrown.
114  //
115  // findSlice(n) Returns a pointer to the slice with name n,
116  // or 0 if no slice with name n exists.
117  //
118  //----------------------------------------------------------------
119 
120  DeepSlice & operator [] (const char name[]);
121  const DeepSlice & operator [] (const char name[]) const;
122 
123  DeepSlice & operator [] (const std::string &name);
124  const DeepSlice & operator [] (const std::string &name) const;
125 
126  DeepSlice * findSlice (const char name[]);
127  const DeepSlice * findSlice (const char name[]) const;
128 
129  DeepSlice * findSlice (const std::string &name);
130  const DeepSlice * findSlice (const std::string &name) const;
131 
132 
133  //-----------------------------------------
134  // Iterator-style access to existing slices
135  //-----------------------------------------
136 
137  typedef std::map <Name, DeepSlice> SliceMap;
138 
139  class Iterator;
140  class ConstIterator;
141 
142  Iterator begin ();
143  ConstIterator begin () const;
144 
145  Iterator end ();
146  ConstIterator end () const;
147 
148  Iterator find (const char name[]);
149  ConstIterator find (const char name[]) const;
150 
151  Iterator find (const std::string &name);
152  ConstIterator find (const std::string &name) const;
153 
154  //----------------------------------------------------
155  // Public function for accessing a sample count slice.
156  //----------------------------------------------------
157 
158  void insertSampleCountSlice(const Slice & slice);
159  const Slice & getSampleCountSlice() const;
160 
161  private:
162 
163  SliceMap _map;
164  Slice _sampleCounts;
165 };
166 
167 //----------
168 // Iterators
169 //----------
170 
172 {
173  public:
174 
175  Iterator ();
176  Iterator (const DeepFrameBuffer::SliceMap::iterator &i);
177 
179  Iterator operator ++ (int);
180 
181  const char * name () const;
182  DeepSlice & slice () const;
183 
184  private:
185 
187 
188  DeepFrameBuffer::SliceMap::iterator _i;
189 };
190 
191 
193 {
194  public:
195 
196  ConstIterator ();
197  ConstIterator (const DeepFrameBuffer::SliceMap::const_iterator &i);
199 
202 
203  const char * name () const;
204  const DeepSlice & slice () const;
205 
206  private:
207 
208  friend bool operator == (const ConstIterator &, const ConstIterator &);
209  friend bool operator != (const ConstIterator &, const ConstIterator &);
210 
211  DeepFrameBuffer::SliceMap::const_iterator _i;
212 };
213 
214 
215 //-----------------
216 // Inline Functions
217 //-----------------
218 
219 inline
221 {
222  // empty
223 }
224 
225 
226 inline
227 DeepFrameBuffer::Iterator::Iterator (const DeepFrameBuffer::SliceMap::iterator &i):
228  _i (i)
229 {
230  // empty
231 }
232 
233 
236 {
237  ++_i;
238  return *this;
239 }
240 
241 
244 {
245  Iterator tmp = *this;
246  ++_i;
247  return tmp;
248 }
249 
250 
251 inline const char *
253 {
254  return *_i->first;
255 }
256 
257 
258 inline DeepSlice &
260 {
261  return _i->second;
262 }
263 
264 
265 inline
267 {
268  // empty
269 }
270 
271 inline
273  (const DeepFrameBuffer::SliceMap::const_iterator &i): _i (i)
274 {
275  // empty
276 }
277 
278 
279 inline
281  _i (other._i)
282 {
283  // empty
284 }
285 
288 {
289  ++_i;
290  return *this;
291 }
292 
293 
296 {
297  ConstIterator tmp = *this;
298  ++_i;
299  return tmp;
300 }
301 
302 
303 inline const char *
305 {
306  return *_i->first;
307 }
308 
309 inline const DeepSlice &
311 {
312  return _i->second;
313 }
314 
315 
316 inline bool
319 {
320  return x._i == y._i;
321 }
322 
323 
324 inline bool
327 {
328  return !(x == y);
329 }
330 
331 
333 
334 
335 
336 
337 
338 
339 #endif /* IMFDEEPFRAMEBUFFER_H_ */
friend bool operator!=(const ConstIterator &, const ConstIterator &)
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImfNamespace.h:109
DeepSlice & slice() const
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
GLint y
Definition: glcorearb.h:102
png_uint_32 i
Definition: png.h:2877
bool operator==(const DeepFrameBuffer::ConstIterator &x, const DeepFrameBuffer::ConstIterator &y)
friend bool operator==(const ConstIterator &, const ConstIterator &)
PixelType
Definition: ImfPixelType.h:51
GLuint GLuint end
Definition: glcorearb.h:474
#define IMF_EXPORT
Definition: ImfExport.h:59
bool operator!=(const DeepFrameBuffer::ConstIterator &x, const DeepFrameBuffer::ConstIterator &y)
GLuint const GLchar * name
Definition: glcorearb.h:785
const char * name() const
const DeepSlice & slice() const
GLint GLenum GLint x
Definition: glcorearb.h:408
std::map< Name, DeepSlice > SliceMap
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Definition: ImfNamespace.h:108
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107