diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/compositor/operations/COM_PreviewOperation.cpp | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/compositor/operations/COM_PreviewOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_PreviewOperation.cpp | 175 |
1 files changed, 90 insertions, 85 deletions
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp index 22215131ce1..cd2bb3b2928 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.cpp +++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp @@ -27,118 +27,123 @@ #include "COM_defines.h" #include "BLI_math.h" extern "C" { -# include "MEM_guardedalloc.h" -# include "IMB_imbuf.h" -# include "IMB_imbuf_types.h" -# include "IMB_colormanagement.h" -# include "BKE_node.h" +#include "MEM_guardedalloc.h" +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" +#include "IMB_colormanagement.h" +#include "BKE_node.h" } - -PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings) : NodeOperation() +PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings, + const ColorManagedDisplaySettings *displaySettings) + : NodeOperation() { - this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); - this->m_preview = NULL; - this->m_outputBuffer = NULL; - this->m_input = NULL; - this->m_divider = 1.0f; - this->m_viewSettings = viewSettings; - this->m_displaySettings = displaySettings; + this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); + this->m_preview = NULL; + this->m_outputBuffer = NULL; + this->m_input = NULL; + this->m_divider = 1.0f; + this->m_viewSettings = viewSettings; + this->m_displaySettings = displaySettings; } void PreviewOperation::verifyPreview(bNodeInstanceHash *previews, bNodeInstanceKey key) { - /* Size (0, 0) ensures the preview rect is not allocated in advance, - * this is set later in initExecution once the resolution is determined. - */ - this->m_preview = BKE_node_preview_verify(previews, key, 0, 0, true); + /* Size (0, 0) ensures the preview rect is not allocated in advance, + * this is set later in initExecution once the resolution is determined. + */ + this->m_preview = BKE_node_preview_verify(previews, key, 0, 0, true); } void PreviewOperation::initExecution() { - this->m_input = getInputSocketReader(0); - - if (this->getWidth() == (unsigned int)this->m_preview->xsize && - this->getHeight() == (unsigned int)this->m_preview->ysize) - { - this->m_outputBuffer = this->m_preview->rect; - } - - if (this->m_outputBuffer == NULL) { - this->m_outputBuffer = (unsigned char *)MEM_callocN(sizeof(unsigned char) * 4 * getWidth() * getHeight(), "PreviewOperation"); - if (this->m_preview->rect) { - MEM_freeN(this->m_preview->rect); - } - this->m_preview->xsize = getWidth(); - this->m_preview->ysize = getHeight(); - this->m_preview->rect = this->m_outputBuffer; - } + this->m_input = getInputSocketReader(0); + + if (this->getWidth() == (unsigned int)this->m_preview->xsize && + this->getHeight() == (unsigned int)this->m_preview->ysize) { + this->m_outputBuffer = this->m_preview->rect; + } + + if (this->m_outputBuffer == NULL) { + this->m_outputBuffer = (unsigned char *)MEM_callocN( + sizeof(unsigned char) * 4 * getWidth() * getHeight(), "PreviewOperation"); + if (this->m_preview->rect) { + MEM_freeN(this->m_preview->rect); + } + this->m_preview->xsize = getWidth(); + this->m_preview->ysize = getHeight(); + this->m_preview->rect = this->m_outputBuffer; + } } void PreviewOperation::deinitExecution() { - this->m_outputBuffer = NULL; - this->m_input = NULL; + this->m_outputBuffer = NULL; + this->m_input = NULL; } void PreviewOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/) { - int offset; - float color[4]; - struct ColormanageProcessor *cm_processor; - - cm_processor = IMB_colormanagement_display_processor_new(this->m_viewSettings, this->m_displaySettings); - - for (int y = rect->ymin; y < rect->ymax; y++) { - offset = (y * getWidth() + rect->xmin) * 4; - for (int x = rect->xmin; x < rect->xmax; x++) { - float rx = floor(x / this->m_divider); - float ry = floor(y / this->m_divider); - - color[0] = 0.0f; - color[1] = 0.0f; - color[2] = 0.0f; - color[3] = 1.0f; - this->m_input->readSampled(color, rx, ry, COM_PS_NEAREST); - IMB_colormanagement_processor_apply_v4(cm_processor, color); - rgba_float_to_uchar(this->m_outputBuffer + offset, color); - offset += 4; - } - } - - IMB_colormanagement_processor_free(cm_processor); + int offset; + float color[4]; + struct ColormanageProcessor *cm_processor; + + cm_processor = IMB_colormanagement_display_processor_new(this->m_viewSettings, + this->m_displaySettings); + + for (int y = rect->ymin; y < rect->ymax; y++) { + offset = (y * getWidth() + rect->xmin) * 4; + for (int x = rect->xmin; x < rect->xmax; x++) { + float rx = floor(x / this->m_divider); + float ry = floor(y / this->m_divider); + + color[0] = 0.0f; + color[1] = 0.0f; + color[2] = 0.0f; + color[3] = 1.0f; + this->m_input->readSampled(color, rx, ry, COM_PS_NEAREST); + IMB_colormanagement_processor_apply_v4(cm_processor, color); + rgba_float_to_uchar(this->m_outputBuffer + offset, color); + offset += 4; + } + } + + IMB_colormanagement_processor_free(cm_processor); } -bool PreviewOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +bool PreviewOperation::determineDependingAreaOfInterest(rcti *input, + ReadBufferOperation *readOperation, + rcti *output) { - rcti newInput; + rcti newInput; - newInput.xmin = input->xmin / this->m_divider; - newInput.xmax = input->xmax / this->m_divider; - newInput.ymin = input->ymin / this->m_divider; - newInput.ymax = input->ymax / this->m_divider; + newInput.xmin = input->xmin / this->m_divider; + newInput.xmax = input->xmax / this->m_divider; + newInput.ymin = input->ymin / this->m_divider; + newInput.ymax = input->ymax / this->m_divider; - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } -void PreviewOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) +void PreviewOperation::determineResolution(unsigned int resolution[2], + unsigned int preferredResolution[2]) { - NodeOperation::determineResolution(resolution, preferredResolution); - int width = resolution[0]; - int height = resolution[1]; - this->m_divider = 0.0f; - if (width > height) { - this->m_divider = COM_PREVIEW_SIZE / (width - 1); - } - else { - this->m_divider = COM_PREVIEW_SIZE / (height - 1); - } - width = width * this->m_divider; - height = height * this->m_divider; - - resolution[0] = width; - resolution[1] = height; + NodeOperation::determineResolution(resolution, preferredResolution); + int width = resolution[0]; + int height = resolution[1]; + this->m_divider = 0.0f; + if (width > height) { + this->m_divider = COM_PREVIEW_SIZE / (width - 1); + } + else { + this->m_divider = COM_PREVIEW_SIZE / (height - 1); + } + width = width * this->m_divider; + height = height * this->m_divider; + + resolution[0] = width; + resolution[1] = height; } CompositorPriority PreviewOperation::getRenderPriority() const { - return COM_PRIORITY_LOW; + return COM_PRIORITY_LOW; } |