HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TIL_MakeTexture.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: TIL_MakeTexture.h (TIL Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __TIL_MakeTexture__
12 #define __TIL_MakeTexture__
13 
14 #include "TIL_API.h"
15 
16 #include <PXL/PXL_OCIO.h>
17 #include <UT/UT_NonCopyable.h>
18 #include <UT/UT_Set.h>
19 #include <UT/UT_StringHolder.h>
20 #include <UT/UT_WorkBuffer.h>
21 
22 class FS_DiskCache;
23 
25 {
26 public:
27  enum SRGB_MODE
28  {
29  SRGB_DISABLE, // No sRGB conversions
30  SRGB_FORCE, // Always apply SRGB convresion
31  SRGB_AUTO // Use the file type information for sRGB
32  };
33 
35  : myOutputFormat() // Defaults to determining from file extension
36  , myFilter()
37  , myAOV()
38  , mySRGBMode(SRGB_AUTO)
39  , myOCIO()
40  , mySanitize(true)
41  , myStoreColorSpace(true)
42  , myDeepSource(false)
43  {
44  }
45 
46  virtual ~TIL_MakeTexture();
47 
49 
50  static void initDiskCache();
51  static const UT_StringHolder &fastRemap(const UT_StringRef &name,
52  bool force);
53  static UT_StringHolder remapFile(const UT_StringHolder &name,
54  bool force);
55  static bool clearRemapCache(bool out_of_date);
56  static FS_DiskCache &diskCache();
57 
59  : public UT_NonCopyable
60  {
62  ~CacheErrorFiles();
64  };
65 
66  /// Number of cached files found and used
67  static int64 cacheFilesFound();
68  /// Number of local files created
69  static int64 cacheLocalCreated();
70  /// Number of temp files created
71  static int64 cacheTempCreated();
72  /// Number of errors while trying to create cache files
73  static CacheErrorFiles cacheErrorFiles();
74 
75  // Defaults to computing the output format from the file extension on the
76  // output file.
77  void setOutputFormat(const UT_StringHolder &v) { myOutputFormat = v; }
78  void setFilter(const UT_StringHolder &f) { myFilter = f; }
79  void setAOV(const UT_StringHolder &s) { myAOV = s; }
80  void setSRGBMode(SRGB_MODE mode) { mySRGBMode = mode; };
81  void setOCIO(const UT_StringRef &sspace, const UT_StringRef &infile,
82  const UT_StringRef &dspace, const UT_StringRef &outfile,
83  bool allowparse);
85  {
86  mySWrapMode = s;
87  myTWrapMode = t;
88  }
89  void setSanitize(bool v) { mySanitize = v; }
90  void setStoreColorSpace(bool v) { myStoreColorSpace = v; }
91 
92  // Perform the texture map creation
93  bool makeTexture(const UT_StringRef &infile,
94  const UT_StringRef &outfile,
95  int tile_width=64,
96  int tile_height=64) const;
97 
98  bool deepSource() const { return myDeepSource; }
99 
100  template <typename... Args>
101  void message(const char *fmt, const Args &...args) const
102  {
103  UT_WorkBuffer tmp;
104  tmp.format(fmt, args...);
105  doMessage(tmp.buffer());
106  }
107  template <typename... Args>
108  void warning(const char *fmt, const Args &...args) const
109  {
110  UT_WorkBuffer tmp;
111  tmp.format(fmt, args...);
112  doWarning(tmp.buffer());
113  }
114  template <typename... Args>
115  void error(const char *fmt, const Args &...args) const
116  {
117  UT_WorkBuffer tmp;
118  tmp.format(fmt, args...);
119  doError(tmp.buffer());
120  }
121 
122 protected:
123  virtual void doMessage(const char *msg) const {}
124  virtual void doWarning(const char *msg) const {}
125  virtual void doError(const char *msg) const {}
126 
127 private:
128  // Compute the OCIO color space associated. This uses the @c sspace token
129  // if it's defined (and not "default"). Otherwise, it will inspect the
130  // image file to determine it's color space (when not in @c write_mode).
131  // The @c allowparse will enable/disable OCIO filename color space parsing.
132  UT_StringHolder computeOCIOSpace(const UT_StringRef &sspace,
133  const UT_StringRef &filename,
134  bool write_mode,
135  bool allowparse) const;
136 
137  UT_StringHolder myOutputFormat;
138  UT_StringHolder myOutputSpace;
139  UT_StringHolder myFilter;
140  UT_StringHolder myAOV;
141  PXL_OCIO::PHandle myOCIO;
142  UT_StringHolder mySWrapMode;
143  UT_StringHolder myTWrapMode;
144  SRGB_MODE mySRGBMode;
145  bool mySanitize;
146  bool myStoreColorSpace;
147  mutable bool myDeepSource;
148 };
149 
150 #endif
151 
virtual void doError(const char *msg) const
virtual void doWarning(const char *msg) const
GT_API const UT_StringHolder filename
bool deepSource() const
const GLdouble * v
Definition: glcorearb.h:837
void setStoreColorSpace(bool v)
void setFilter(const UT_StringHolder &f)
SYS_FORCE_INLINE const char * buffer() const
GLdouble s
Definition: glad.h:3009
void setOutputFormat(const UT_StringHolder &v)
void setWrapModes(const UT_StringHolder &s, const UT_StringHolder &t)
void warning(const char *fmt, const Args &...args) const
void setAOV(const UT_StringHolder &s)
void setSanitize(bool v)
GLfloat f
Definition: glcorearb.h:1926
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
long long int64
Definition: SYS_Types.h:116
GLuint const GLchar * name
Definition: glcorearb.h:786
GLdouble t
Definition: glad.h:2397
GLenum mode
Definition: glcorearb.h:99
size_t format(const char *fmt, const Args &...args)
SIM_API const UT_StringHolder force
virtual void doMessage(const char *msg) const
**If you just want to fire and args
Definition: thread.h:609
void message(const char *fmt, const Args &...args) const
void setSRGBMode(SRGB_MODE mode)
#define const
Definition: zconf.h:214
#define TIL_API
Definition: TIL_API.h:10
void error(const char *fmt, const Args &...args) const
const UT_Set< UT_StringHolder > * myFiles