1 #pragma once
2 
3 #ifndef TCOLUMNFX_H
4 #define TCOLUMNFX_H
5 
6 // TnzCore includes
7 #include "tthreadmessage.h"
8 #include "trastercm.h"
9 
10 // TnzBase includes
11 #include "trasterfx.h"
12 #include "tbasefx.h"
13 
14 #undef DVAPI
15 #undef DVVAR
16 #ifdef TOONZLIB_EXPORTS
17 #define DVAPI DV_EXPORT_API
18 #define DVVAR DV_EXPORT_VAR
19 #else
20 #define DVAPI DV_IMPORT_API
21 #define DVVAR DV_IMPORT_VAR
22 #endif
23 
24 //=========================================================================
25 
26 //    Forward declarations
27 
28 class TXshLevelColumn;
29 class TXshPaletteColumn;
30 class TXshZeraryFxColumn;
31 class TXsheet;
32 class TXshColumn;
33 class TXshSimpleLevel;
34 class FxDag;
35 class TImageInfo;
36 class TOfflineGL;
37 class TVectorImageP;
38 class TVectorRenderData;
39 
40 //=========================================================================
41 
42 //*******************************************************************************************
43 //    TColumnFx  declaration
44 //*******************************************************************************************
45 
46 class DVAPI TColumnFx : public TRasterFx {
47 public:
TColumnFx()48   TColumnFx() : TRasterFx() {}
49 
50   virtual int getColumnIndex() const         = 0;
51   virtual std::wstring getColumnName() const = 0;
52   virtual std::wstring getColumnId() const   = 0;
53   virtual TXshColumn *getXshColumn() const   = 0;
54 
getReferenceColumnIndex()55   int getReferenceColumnIndex() const override { return getColumnIndex(); }
56 };
57 
58 //*******************************************************************************************
59 //    TLevelColumnFx  declaration
60 //*******************************************************************************************
61 
62 class TLevelColumnFx : public TColumnFx {
63   TXshLevelColumn *m_levelColumn;
64   bool m_isCachable;
65 
66   TThread::Mutex m_mutex;
67   TOfflineGL *m_offlineContext;
68 
69 public:
70   TLevelColumnFx();
71   ~TLevelColumnFx();
72 
73   TFx *clone(bool recursive = true) const override;
74 
75   TPalette *getPalette(int frame) const;
76   TFilePath getPalettePath(int frame) const;
77 
78   void setColumn(TXshLevelColumn *column);
getColumn()79   TXshLevelColumn *getColumn() const { return m_levelColumn; }
80 
81   std::wstring getColumnName() const override;
82   std::wstring getColumnId() const override;
83   int getColumnIndex() const override;
84   TXshColumn *getXshColumn() const override;
85 
isCachable()86   bool isCachable() const override { return m_isCachable; }
87 
88   bool canHandle(const TRenderSettings &info, double frame) override;
89   TAffine handledAffine(const TRenderSettings &info, double frame) override;
90   TAffine getDpiAff(int frame);
91 
92   TFxTimeRegion getTimeRegion() const override;
93   bool doGetBBox(double frame, TRectD &bBox,
94                  const TRenderSettings &info) override;
95   std::string getAlias(double frame,
96                        const TRenderSettings &info) const override;
97   int getMemoryRequirement(const TRectD &rect, double frame,
98                            const TRenderSettings &info) override;
99 
100   void doDryCompute(TRectD &rect, double frame,
101                     const TRenderSettings &info) override;
102   void doCompute(TTile &tile, double frame,
103                  const TRenderSettings &info) override;
104 
105   void saveData(TOStream &os) override;
106   void loadData(TIStream &is) override;
107 
108   const TPersistDeclaration *getDeclaration() const override;
109   std::string getPluginId() const override;
110 
111 private:
112   void getImageInfo(TImageInfo &imageInfo, TXshSimpleLevel *sl,
113                     TFrameId frameId);
114 
115   TImageP applyTzpFxs(TToonzImageP &ti, double frame,
116                       const TRenderSettings &info);
117   void applyTzpFxsOnVector(const TVectorImageP &vi, TTile &tile, double frame,
118                            const TRenderSettings &info);
119 
120 private:
121   // not implemented
122   TLevelColumnFx(const TLevelColumnFx &);
123   TLevelColumnFx &operator=(const TLevelColumnFx &);
124 };
125 
126 //*******************************************************************************************
127 //    TPaletteColumnFx  declaration
128 //*******************************************************************************************
129 
130 class TPaletteColumnFx : public TColumnFx {
131   TXshPaletteColumn *m_paletteColumn;
132 
133 public:
134   TPaletteColumnFx();
135   ~TPaletteColumnFx();
136 
137   TFx *clone(bool recursive = true) const override;
138 
139   TPalette *getPalette(int frame) const;
140   TFilePath getPalettePath(int frame) const;
141 
setColumn(TXshPaletteColumn * column)142   void setColumn(TXshPaletteColumn *column) { m_paletteColumn = column; }
getColumn()143   TXshPaletteColumn *getColumn() const { return m_paletteColumn; }
144 
145   std::wstring getColumnName() const override;
146   std::wstring getColumnId() const override;
147   int getColumnIndex() const override;
148   TXshColumn *getXshColumn() const override;
149 
isCachable()150   bool isCachable() const override { return false; }
151 
152   bool canHandle(const TRenderSettings &info, double frame) override;
153 
154   TFxTimeRegion getTimeRegion() const override;
155   bool doGetBBox(double frame, TRectD &bBox,
156                  const TRenderSettings &info) override;
157   std::string getAlias(double frame,
158                        const TRenderSettings &info) const override;
159   TAffine getDpiAff(int frame);
160 
161   void doCompute(TTile &tile, double frame, const TRenderSettings &) override;
162 
163   const TPersistDeclaration *getDeclaration() const override;
164   std::string getPluginId() const override;
165 
166 private:
167   // not implemented
168   TPaletteColumnFx(const TPaletteColumnFx &);
169   TPaletteColumnFx &operator=(const TPaletteColumnFx &);
170 };
171 
172 //*******************************************************************************************
173 //    TZeraryColumnFx  declaration
174 //*******************************************************************************************
175 
176 class DVAPI TZeraryColumnFx final : public TColumnFx {
177   TXshZeraryFxColumn *m_zeraryFxColumn;
178   TZeraryFx *m_fx;
179 
180 public:
181   TZeraryColumnFx();
182   ~TZeraryColumnFx();
183 
getZeraryFx()184   TZeraryFx *getZeraryFx() const { return m_fx; }
185   void setZeraryFx(TFx *fx);
186 
187   void setColumn(TXshZeraryFxColumn *column);
getColumn()188   TXshZeraryFxColumn *getColumn() const { return m_zeraryFxColumn; }
189 
190   std::wstring getColumnName() const override;
191   std::wstring getColumnId() const override;
192   int getColumnIndex() const override;
193   TXshColumn *getXshColumn() const override;
194 
canHandle(const TRenderSettings & info,double frame)195   bool canHandle(const TRenderSettings &info, double frame) override {
196     return true;
197   }
198 
199   TFxTimeRegion getTimeRegion() const override;
200   bool doGetBBox(double frame, TRectD &bBox,
201                  const TRenderSettings &info) override;
202   std::string getAlias(double frame,
203                        const TRenderSettings &info) const override;
204 
205   void doCompute(TTile &tile, double frame, const TRenderSettings &) override;
206 
207   void saveData(TOStream &os) override;
208   void loadData(TIStream &is) override;
209 
210   const TPersistDeclaration *getDeclaration() const override;
211   std::string getPluginId() const override;
212 
213 private:
214   // not implemented
215   TZeraryColumnFx(const TZeraryColumnFx &);
216   TZeraryColumnFx &operator=(const TZeraryColumnFx &);
217 };
218 
219 //*******************************************************************************************
220 //    TXsheetFx  declaration
221 //*******************************************************************************************
222 
223 class TXsheetFx final : public TRasterFx {
224   FxDag *m_fxDag;
225 
226 public:
227   TXsheetFx();
228 
getFxDag()229   FxDag *getFxDag() const { return m_fxDag; }
230 
canHandle(const TRenderSettings & info,double frame)231   bool canHandle(const TRenderSettings &info, double frame) override {
232     return false;
233   }
234 
235   std::string getAlias(double frame,
236                        const TRenderSettings &info) const override;
237 
238   void doCompute(TTile &tile, double frame, const TRenderSettings &) override;
239   bool doGetBBox(double frame, TRectD &bBox,
240                  const TRenderSettings &info) override;
241 
242   const TPersistDeclaration *getDeclaration() const override;
243   std::string getPluginId() const override;
244 
245 private:
246   friend class FxDag;
247   void setFxDag(FxDag *fxDag);
248 
249   // not implemented
250   TXsheetFx(const TXsheetFx &);
251   TXsheetFx &operator=(const TXsheetFx &);
252 };
253 
254 //*******************************************************************************************
255 //    TOutputFx  declaration
256 //*******************************************************************************************
257 
258 class TOutputFx final : public TRasterFx {
259   TRasterFxPort m_input;
260 
261 public:
262   TOutputFx();
263 
canHandle(const TRenderSettings & info,double frame)264   bool canHandle(const TRenderSettings &info, double frame) override {
265     return false;
266   }
267 
268   bool doGetBBox(double frame, TRectD &bBox,
269                  const TRenderSettings &info) override;
270 
271   void doCompute(TTile &tile, double frame, const TRenderSettings &) override;
272 
273   const TPersistDeclaration *getDeclaration() const override;
274   std::string getPluginId() const override;
275 
276 private:
277   // not implemented
278   TOutputFx(const TOutputFx &);
279   TOutputFx &operator=(const TOutputFx &);
280 };
281 
282 //*******************************************************************************************
283 //    TColumnFx functions
284 //*******************************************************************************************
285 
286 bool isSubsheetChainOnColumn0(TXsheet *topXsheet, TXsheet *subsheet, int frame);
287 
288 #endif  // TCOLUMNFX_H
289