void TextureBaseOperation::initExecution()
{
	this->m_inputOffset = getInputSocketReader(0);
	this->m_inputSize = getInputSocketReader(1);
	this->m_pool = BKE_image_pool_new();
	SingleThreadedOperation::initExecution();
}
void *PlaneCornerPinWarpImageOperation::initializeTileData(rcti *rect)
{
  void *data = PlaneDistortWarpImageOperation::initializeTileData(rect);

  /* get corner values once, by reading inputs at (0,0)
   * XXX this assumes invariable values (no image inputs),
   * we don't have a nice generic system for that yet
   */
  lockMutex();
  if (!m_corners_ready) {
    /* corner sockets start at index 1 */
    SocketReader *readers[4] = {
        getInputSocketReader(1),
        getInputSocketReader(2),
        getInputSocketReader(3),
        getInputSocketReader(4),
    };
    float corners[4][2];
    readCornersFromSockets(rect, readers, corners);
    calculateCorners(corners, true, 0);

    m_corners_ready = true;
  }
  unlockMutex();

  return data;
}
void *ScreenLensDistortionOperation::initializeTileData(rcti *rect)
{
	void *buffer = this->m_inputProgram->initializeTileData(NULL);

	/* get distortion/dispersion values once, by reading inputs at (0,0)
	 * XXX this assumes invariable values (no image inputs),
	 * we don't have a nice generic system for that yet
	 */
	if (!m_variables_ready) {
		this->lockMutex();
		
		if (!m_distortion_const) {
			float result[4];
			getInputSocketReader(1)->readSampled(result, 0, 0, COM_PS_NEAREST);
			m_distortion = result[0];
		}
		if (!m_dispersion_const) {
			float result[4];
			getInputSocketReader(2)->readSampled(result, 0, 0, COM_PS_NEAREST);
			m_dispersion = result[0];
		}
		
		updateVariables(m_distortion, m_dispersion);
		m_variables_ready = true;
		
		this->unlockMutex();
	}
	
	return buffer;
}
void VectorBlurOperation::initExecution()
{
	initMutex();
	this->m_inputImageProgram = getInputSocketReader(0);
	this->m_inputZProgram = getInputSocketReader(1);
	this->m_inputSpeedProgram = getInputSocketReader(2);
	this->m_cachedInstance = NULL;
	QualityStepHelper::initExecution(COM_QH_INCREASE);
	
}
void TextureBaseOperation::initExecution()
{
  this->m_inputOffset = getInputSocketReader(0);
  this->m_inputSize = getInputSocketReader(1);
  this->m_pool = BKE_image_pool_new();
  if (this->m_texture != NULL && this->m_texture->nodetree != NULL && this->m_texture->use_nodes) {
    ntreeTexBeginExecTree(this->m_texture->nodetree);
  }
  NodeOperation::initExecution();
}
void VariableSizeBokehBlurOperation::initExecution()
{
	this->m_inputProgram = getInputSocketReader(0);
	this->m_inputBokehProgram = getInputSocketReader(1);
	this->m_inputSizeProgram = getInputSocketReader(2);
#ifdef COM_DEFOCUS_SEARCH
	this->m_inputSearchProgram = getInputSocketReader(3);
#endif
	QualityStepHelper::initExecution(COM_QH_INCREASE);
}
void ViewerOperation::initExecution()
{
	// When initializing the tree during initial load the width and height can be zero.
	this->m_imageInput = getInputSocketReader(0);
	this->m_alphaInput = getInputSocketReader(1);
	this->m_depthInput = getInputSocketReader(2);
	this->m_doDepthBuffer = (this->m_depthInput != NULL);
	
	if (isActiveViewerOutput()) {
		initImage();
	}
}
void CompositorOperation::initExecution()
{
	if (!this->m_active)
		return;

	// When initializing the tree during initial load the width and height can be zero.
	this->m_imageInput = getInputSocketReader(0);
	this->m_alphaInput = getInputSocketReader(1);
	this->m_depthInput = getInputSocketReader(2);
	if (this->getWidth() * this->getHeight() != 0) {
		this->m_outputBuffer = (float *) MEM_callocN(this->getWidth() * this->getHeight() * 4 * sizeof(float), "CompositorOperation");
	}
	if (this->m_depthInput != NULL) {
		this->m_depthBuffer = (float *) MEM_callocN(this->getWidth() * this->getHeight() * sizeof(float), "CompositorOperation");
	}
}
void OutputOpenExrMultiLayerOperation::initExecution()
{
	for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
		this->m_layers[i].imageInput = getInputSocketReader(i);
		this->m_layers[i].outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->m_layers[i].datatype);
	}
}
void BokehBlurOperation::initExecution()
{
  initMutex();
  this->m_inputProgram = getInputSocketReader(0);
  this->m_inputBokehProgram = getInputSocketReader(1);
  this->m_inputBoundingBoxReader = getInputSocketReader(2);

  int width = this->m_inputBokehProgram->getWidth();
  int height = this->m_inputBokehProgram->getHeight();

  float dimension = min(width, height);

  this->m_bokehMidX = width / 2.0f;
  this->m_bokehMidY = height / 2.0f;
  this->m_bokehDimension = dimension / 2.0f;
  QualityStepHelper::initExecution(COM_QH_INCREASE);
}
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;
	}
}
void FastGaussianBlurValueOperation::initExecution()
{
	this->m_inputprogram = getInputSocketReader(0);
	initMutex();
}
void GlareBaseOperation::initExecution()
{
	SingleThreadedOperation::initExecution();
	this->m_inputProgram = getInputSocketReader(0);
}
void OutputSingleLayerOperation::initExecution()
{
	this->m_imageInput = getInputSocketReader(0);
	this->m_outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->m_datatype);
}
void TextureBaseOperation::initExecution()
{
	this->m_inputOffset = getInputSocketReader(0);
	this->m_inputSize = getInputSocketReader(1);
}