1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2011, Blender Foundation.
17  */
18 
19 #pragma once
20 
21 #include "BKE_global.h"
22 #include "BLI_rect.h"
23 #include "COM_NodeOperation.h"
24 #include "DNA_color_types.h"
25 #include "DNA_image_types.h"
26 
27 class PreviewOperation : public NodeOperation {
28  protected:
29   unsigned char *m_outputBuffer;
30 
31   /**
32    * \brief holds reference to the SDNA bNode, where this nodes will render the preview image for
33    */
34   bNodePreview *m_preview;
35   SocketReader *m_input;
36   float m_divider;
37 
38   const ColorManagedViewSettings *m_viewSettings;
39   const ColorManagedDisplaySettings *m_displaySettings;
40 
41  public:
42   PreviewOperation(const ColorManagedViewSettings *viewSettings,
43                    const ColorManagedDisplaySettings *displaySettings);
44   void verifyPreview(bNodeInstanceHash *previews, bNodeInstanceKey key);
45 
isOutputOperation(bool)46   bool isOutputOperation(bool /*rendering*/) const
47   {
48     return !G.background;
49   }
50   void initExecution();
51   void deinitExecution();
52   CompositorPriority getRenderPriority() const;
53 
54   void executeRegion(rcti *rect, unsigned int tileNumber);
55   void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
56   bool determineDependingAreaOfInterest(rcti *input,
57                                         ReadBufferOperation *readOperation,
58                                         rcti *output);
isPreviewOperation()59   bool isPreviewOperation() const
60   {
61     return true;
62   }
63 };
64