2 * Copyright 2011, Blender Foundation.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #include "COM_ViewerBaseOperation.h"
24 #include "COM_SocketConnection.h"
25 #include "BLI_listbase.h"
26 #include "DNA_scene_types.h"
27 #include "BKE_image.h"
31 #include "BLI_utildefines.h"
32 #include "BLI_math_color.h"
35 #include "MEM_guardedalloc.h"
36 #include "IMB_imbuf.h"
37 #include "IMB_imbuf_types.h"
41 ViewerBaseOperation::ViewerBaseOperation() : NodeOperation()
44 this->setImageUser(NULL);
45 this->m_outputBuffer = NULL;
46 this->m_outputBufferDisplay = NULL;
47 this->m_active = false;
48 this->m_doColorManagement = true;
51 void ViewerBaseOperation::initExecution()
53 if (isActiveViewerOutput()) {
58 void ViewerBaseOperation::initImage()
60 Image *anImage = this->m_image;
61 ImBuf *ibuf = BKE_image_acquire_ibuf(anImage, this->m_imageUser, &this->m_lock);
64 if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) {
65 imb_freerectImBuf(ibuf);
66 imb_freerectfloatImBuf(ibuf);
67 IMB_freezbuffloatImBuf(ibuf);
69 ibuf->y = getHeight();
70 imb_addrectImBuf(ibuf);
71 imb_addrectfloatImBuf(ibuf);
72 anImage->ok = IMA_OK_LOADED;
75 /* now we combine the input with ibuf */
76 this->m_outputBuffer = ibuf->rect_float;
77 this->m_outputBufferDisplay = (unsigned char *)ibuf->rect;
79 BKE_image_release_ibuf(this->m_image, this->m_lock);
81 void ViewerBaseOperation:: updateImage(rcti *rect)
83 WM_main_add_notifier(NC_WINDOW | ND_DRAW, NULL);
86 void ViewerBaseOperation::deinitExecution()
88 this->m_outputBuffer = NULL;
91 const CompositorPriority ViewerBaseOperation::getRenderPriority() const
93 if (this->isActiveViewerOutput()) {
94 return COM_PRIORITY_HIGH;
97 return COM_PRIORITY_LOW;