//**************************************************************************/
// Copyright (c) 2008 Autodesk, Inc.
// All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
//
//**************************************************************************/
// DESCRIPTION:
// CREATED: September 2009
//**************************************************************************/

#if !defined IMAGE_FILTER_H_
#define IMAGE_FILTER_H_

namespace mudbox {

class Image;
class Texture;
class ImageFilter;

//------------------------------------------------------------------------------
/// \brief This is the base image filter type defining the interface to image
/// filters (blur, sharpen, dodge, burn, etc). The filters themselves are
/// implemented as plugins.
///
/// There are two differend kinds of image filters;
///
/// \li Spatial -- These include any where the output pixel depends on any pixel
/// other than the matching (x, y) source pixel. This includes convolutions,
/// warps or other deformations, scaling rotation etc.
/// \li Non Spatial -- where the output pixel depends only on its matching input
/// pixel. Examples would include dodge, burn, lighten, darken, contrast, hue shift,
/// invert, color curves, etc.
///
/// A filter plugin must be capable of handling processing where both the source and
/// target images are in CPU memory.
///
/// It can optionaly support processing with both the source and target in textures.
/// If it supports textures, AND Mudbox has the images in textures, it will be called
/// upon to do the work there, otherwise it will be in a physically contiguous image
/// in memory.
///
class MBDLL_DECL ImageFilter : public Node
{
	DECLARE_CLASS;

public:
    enum FilterType {
        kInvalid, kSpatial, kNonSpatial
    };

    enum Location {
        kCPUMemory = 1, kGPUTexture = 2, kCPUorGPU = 3
    };

    // Lets try using the node attribites for the filter parameters...

protected:
	ImageFilter( void );

    FilterType  m_FilterType;
    Location    m_LocationSupported;
    QString     m_FilterName;

public:

    /** Get the filter type -- spatial or not spatial */
    FilterType getType() const              { return m_FilterType;         }
    Location   getLocationSupported() const { return m_LocationSupported;  }

    /** return the filter name. eg "Blur" or "Dodge", etc. */
    const QString  &getName() const { return m_FilterName; }

    /* Hack to set the filter parameters... Imre, how can I get access to the attributes of a class
    *  implemented in a plugin? Blur filter takes a single float. */
    virtual void         setParameterBlock(void *parmBlock, int size);
    virtual int          getParameterBlockSize() const;
    virtual const void  *getParameterBlockPtr() const;

    /** The ProcessFilter API creates the contents of the destination Image or Texture. */
    virtual void ProcessFilter(Image *src,   Image *dst);
    virtual void ProcessFilter(Texture *src, Texture *dst);
};



//-
// ==================================================================
// (C) Copyright 2009 by Autodesk, Inc. All Rights Reserved. By using
// this code,  you  are  agreeing  to the terms and conditions of the
// License  Agreement  included  in  the documentation for this code.
// AUTODESK  MAKES  NO  WARRANTIES,  EXPRESS  OR  IMPLIED,  AS TO THE
// CORRECTNESS OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE
// IT.  AUTODESK PROVIDES THE CODE ON AN 'AS-IS' BASIS AND EXPLICITLY
// DISCLAIMS  ANY  LIABILITY,  INCLUDING CONSEQUENTIAL AND INCIDENTAL
// DAMAGES  FOR ERRORS, OMISSIONS, AND  OTHER  PROBLEMS IN THE  CODE.
//
// Use, duplication,  or disclosure by the U.S. Government is subject
// to  restrictions  set forth  in FAR 52.227-19 (Commercial Computer
// Software Restricted Rights) as well as DFAR 252.227-7013(c)(1)(ii)
// (Rights  in Technical Data and Computer Software),  as applicable.
// ==================================================================
//+

#endif
//------------------------------------------------------------------------------

}; // end of namespace mudbox
