HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PXL_DeepCompressor.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: PXL_DeepCompressor.h (PXL Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __PXL_DeepCompressor__
12 #define __PXL_DeepCompressor__
13 
14 #include "PXL_API.h"
15 #include <SYS/SYS_Types.h>
16 #include <UT/UT_Vector2.h>
17 #include <UT/UT_SharedPtr.h>
18 #include "PXL_Forward.h"
19 #include "PXL_DeepSampleList.h"
20 #include "PXL_DeepChannelList.h"
21 
22 class UT_Options;
23 
24 extern "C" {
25  /// DSO's should have this function declared. The function should call
26  /// PXL_DeepCompressor::registerCompressor.
28 };
29 
30 /// Combines a set of deep sample lists to create a single new deep sample list.
31 ///
32 /// Deep compressors take multiple sample lists and combine them, possibly
33 /// compressing them into a single deep sample list. The compressor may sit
34 /// between the renderer and a deep image writer. Or it may be used to create
35 /// MIP Maps for deep images.
36 ///
37 /// When used by a renderer, compressors have the ability to add or modify
38 /// channels.
39 ///
40 /// Factory compressors include:
41 ///
42 /// Name = "default
43 /// Options:
44 /// - zbias
45 ///
47 {
48 public:
50  {
51  public:
52  virtual ~Factory();
53 
54  /// Method to construct a deep compressor given options.
55  /// The caller to the compressor will be passing pixel sample lists
56  virtual PXL_DeepCompressorPtr create(
57  const PXL_DeepChannelListPtr &c,
58  const UT_Options &options
59  ) const = 0;
60 
61  /// Load all compressor factories
62  static void initCompressors();
63 
64  /// Register a new compressor. This should be called during
65  /// initCompressors() only.
66  static void registerCompressor(const char *name,
67  const UT_SharedPtr<Factory> &factory);
68 
69  /// Create a pixel compressor. This will return NULL for an invalid
70  /// compressor.
71  /// Factory compressors include:
72  /// - "null" @n
73  /// No compression. Records are just merged with no combining.
74  /// - "simple" @n
75  /// Option: "float zbias" Controls zbias for compression @n
76  /// This compressor will peform simple compression, merging similar
77  /// records within a z-tolerance.
78  static PXL_DeepCompressorPtr create(const char *name,
79  const PXL_DeepChannelListPtr &c,
80  const UT_Options &options);
81 
82  /// Return the list of possible compressors
83  static void getCompressors(UT_StringArray &types);
84  };
85 
87  virtual ~PXL_DeepCompressor();
88 
89  /// Return the channels as a result of the compress() operation
90  virtual PXL_DeepChannelListPtr channels() const = 0;
91 
92  /// Compress the samples provided into a single PXL_DeepSampleListPtr. The
93  /// @c samples array will contain <tt> pixel.myPixelResolution.x() *
94  /// pixel.myPixelResolution.y()</tt> entries.
96  int nsamples) const
97  {
98  return doMerge(slist, nsamples);
99  }
102  ) const
103  {
104  return doMerge(slist.array(), slist.entries());
105  }
106  /// Compress a single sample list, returning a new sample list.
108  {
109  return doCompress(slist);
110  }
111 
112  void dump(const char *msg="") const;
113 
114 protected:
115  virtual const char *className() const = 0;
116 
117  /// Merge multiple deep sample lists into a single deep sample list. For
118  /// example, this is done when creating MIP maps.
119  virtual PXL_DeepSampleListPtr doMerge(
120  const PXL_DeepSampleListPtr *slist,
121  int nsamples
122  ) const = 0;
123  /// Compress a single sample list, returning a new sample list.
124  virtual PXL_DeepSampleListPtr doCompress(
126  ) const = 0;
127 
128  /// Dump any optional information to stdout
129  virtual void doDump() const;
130 };
131 
132 #endif
#define SYS_VISIBILITY_EXPORT
T * array()
Definition: UT_Array.h:607
PXL_DeepSampleListPtr merge(const PXL_DeepSampleListPtr *slist, int nsamples) const
#define PXL_API
Definition: PXL_API.h:10
SYS_VISIBILITY_EXPORT void newPXLDeepCompressor()
GLuint const GLchar * name
Definition: glcorearb.h:785
GLsizei samples
Definition: glcorearb.h:1297
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:446
A map of string to various well defined value types.
Definition: UT_Options.h:42
PXL_DeepSampleListPtr merge(const UT_Array< PXL_DeepSampleListPtr > &slist) const
GLsizei GLenum GLenum * types
Definition: glcorearb.h:2541
PXL_DeepSampleListPtr compress(const PXL_DeepSampleListPtr &slist) const
Compress a single sample list, returning a new sample list.