HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BRAY_ImageFilter.h
Go to the documentation of this file.
1 
2 /*
3  * PROPRIETARY INFORMATION. This software is proprietary to
4  * Side Effects Software Inc., and is not to be reproduced,
5  * transmitted, or disclosed in any way without written permission.
6  *
7  * NAME: BRAY_ImageFilter.h (RAY Library, C++)
8  *
9  * COMMENTS:
10  */
11 
12 #ifndef __BRAY_ImageFilter__
13 #define __BRAY_ImageFilter__
14 
15 #include "BRAY_API.h"
16 #include "BRAY_FilterBase.h"
17 #include "BRAY_PixelOracle.h"
18 #include "BRAY_Interface.h"
19 
20 class UT_Options;
21 class BRAY_Raster;
22 class BRAY_FilterInit;
23 
24 extern "C" {
25  SYS_VISIBILITY_EXPORT extern void newBRAYImageFilter(void *);
26 }
27 
28 /// Image filter plugins are run after pixel filtering, but before the rasters
29 /// are written to the display device.
31  : public BRAY_FilterBase
32 {
33 public:
35  {
36  public:
37  virtual ~Factory();
38 
39  /// Create an instance of the BRAY_ImageFilter
40  virtual UT_UniquePtr<BRAY_ImageFilter> instance(const UT_Options *o) const = 0;
41  };
43 
44  /// @{
45  /// Access to factory
46  static void listFactories(UT_StringArray &result);
47 
48  static void registerPlugin(const UT_StringHolder &name, FactoryPtr factory);
49 
50  static UT_UniquePtr<BRAY_ImageFilter> instancePlugin(
51  const UT_StringRef &style,
52  const UT_Options *options=nullptr);
53  static void releasePlugin(UT_UniquePtr<BRAY_ImageFilter> p);
54  static void freePluginCache();
55  /// @}
56 
57  // c-tor
59  : BRAY_FilterBase(o)
60  {
61  }
62 
63  // d-tor
64  ~BRAY_ImageFilter() override;
65 
66  /// @{
67  /// Methods to be implemented from base class
71  /// @}
72 
73  /// Return whether the filter can be run interactively (for intermediate
74  /// IPR updates for example). If this method returns false, when rendering
75  /// interactively, the filter will only be run when the rendering has
76  /// completed. If the method returns true, the filter may be run 100s or
77  /// 1000s of times during an interactive render.
78  ///
79  /// When rendering non-interactively, image filters are run at the end of
80  /// the render.
81  virtual bool isInteractive() const = 0;
82 
83  /// If the filter does not need to read or write to neighbouring pixels,
84  /// then allow it to run per-bucket. When this is true, processBucket() is
85  /// invoked instead of processImage(), and it is invoked each time a bucket
86  /// is finished (by its own worker thread).
87  virtual bool isPerBucket() const { return false; }
88 
89  /// Process the rasters. The plugin should write to the @c write rasters
90  /// passed in, using the @c read rasters as source data. The order of the
91  /// rasters in the arrays matches the order in @c writePlanes() and @c
92  /// readPlanes(). So, it follows the size of the arrays should match the
93  /// size of the @c writePlanes() and @c readPlanes.
94  ///
95  /// This order is immutable after initialization is called.
96  virtual bool processImage(const UT_Array<BRAY_Raster *> &write,
98 
99  /// Process the rasters (per-bucket version).
100  /// Note that per-bucket image filters are processed before whole-image
101  /// filters.
104  const UT_DimRect &bucket)
105  { return false; }
106 
107  /// An image filter can, optionally, provide a pixel oracle to help steer
108  /// rendering. The filter should provide an option to the user to disable
109  /// creation of this oracle. It should also be able to run without the
110  /// oracle. The default method returns a nullptr.
111  ///
112  /// This method is called after @c initialize() is called on the image
113  /// filter.
115  { return BRAY_PixelOraclePtr(); }
116 
117  /// Updates the image filter for the given options.
118  /// If supported an image filter can update itself by calling
119  /// update method with new parameters. This avoids the need to
120  /// recreate the filter everytime an option changes.
121  ///
122  /// Returns true on success or false if fails to update.
123  virtual bool update(const UT_Options& options)
124  { return false; };
125 
126 protected:
127  /// If the filter needs an additional AOV, you can call this method during
128  /// getAOVs(). The function returns the index of the new AOV (or -1 on
129  /// failure). If there are errors, the messages will be printed out to
130  /// UT_ErrorLog.
131  ///
132  /// If options are required, they can be initialized by planeProperties()
133  /// Passing in an empty OptionSet is legal.
134  int addAOV(BRAY_FilterInit &init,
135  const UT_StringHolder &name,
136  const UT_StringHolder &var,
137  int tuple_size,
138  const BRAY::OptionSet &options);
139 
140  /// Create an option set before adding creating an extra AOV
141  BRAY::OptionSet planeProperties(BRAY_FilterInit &init) const;
142 };
143 
145 
146 #endif
virtual bool isPerBucket() const
UT_UniquePtr< BRAY_ImageFilter > BRAY_ImageFilterPtr
Simple raster container.
Definition: BRAY_Raster.h:30
virtual bool processBucket(const UT_Array< BRAY_Raster * > &write, const UT_Array< const BRAY_Raster * > &read, const UT_DimRect &bucket)
#define SYS_VISIBILITY_EXPORT
virtual bool update(const UT_Options &options)
**But if you need a result
Definition: thread.h:613
UT_UniquePtr< BRAY_PixelOracle > BRAY_PixelOraclePtr
void read(T &in, bool &v)
Definition: ImfXdr.h:502
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
Base class for image filters. These are any filters which process AOV data.
SYS_VISIBILITY_EXPORT void newBRAYImageFilter(void *)
GLuint const GLchar * name
Definition: glcorearb.h:786
BRAY_ImageFilter(const UT_Options *o)
virtual const UT_StringHolder & errorMessage() const
A map of string to various well defined value types.
Definition: UT_Options.h:84
virtual const char * className() const =0
Return an identifier for this plugin.
#define BRAY_API
Definition: BRAY_API.h:12
virtual bool getAOVs(BRAY_FilterInit &init, const UT_StringArray &available, UT_StringArray &write, UT_StringArray &read)=0
virtual BRAY_PixelOraclePtr pixelOracle()
void write(T &out, bool v)
Definition: ImfXdr.h:287
UT_UniquePtr< Factory > FactoryPtr