⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filters.h

📁 hl2 source code. Do not use it illegal.
💻 H
📖 第 1 页 / 共 2 页
字号:
//-----------------------------------------------------------------------------
// --------------------
// File ....: Filters.h
// --------------------
// Author...: Gus Grubba
// Date ....: September 1995
//
// History .: Sep, 07 1995 - Started
//
//-----------------------------------------------------------------------------
		
#ifndef    FILTERS_H_DEFINED
#define    FILTERS_H_DEFINED

#include <fltapi.h>
#include <tvnode.h>

//-- Just to make it shorter

#define dVirtual FLTExport virtual

//-- How long can a filter name be

#define MAXFILTERNAME  MAX_PATH
#define MAXRESOURCE    MAX_PATH

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-- Frame Range
//
	
class FrameRange {

		int start;
		int end;
		int current;
		
	 public:
	 
		FLTExport       FrameRange  ( ) {start = end = current  = 0;}
		FLTExport       ~FrameRange ( ) {};

		FLTExport int   First       ( ) {   return (start); }
		FLTExport int   Last        ( ) {   return (end); }
		FLTExport int   Count       ( ) {   return (end - start + 1); }
		FLTExport int   Current     ( ) {   return (current);   }
		FLTExport int   Elapsed     ( ) {   return (current -   start); }

		FLTExport void  SetFirst    ( int u ) { start = u; }
		FLTExport void  SetLast     ( int u ) { end = u; }
		FLTExport void  SetCurrent  ( int u ) { current = u; }


};

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//--   Forward Reference

class ImageFilter;
class FilterManager;

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-- Time Change Notification (R2)

class TimeChange : public TimeChangeCallback {
	public:
		BOOL set;
		TimeChange () { set = FALSE; }
		ImageFilter *filter;
		void TimeChanged(TimeValue t);
};

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//--   Filter Info
//
	
enum MaskType {
	MASK_R = 0,  
	MASK_G, 
	MASK_B, 
	MASK_A, 
	MASK_L, 
	MASK_Z, 
	MASK_MTL_ID,
	MASK_NODE_ID

};

#define NUMMASKFLAGS (MASK_NODE_ID - MASK_R) + 1

class ImageFilterInfo {

		//-- Name of the filter used internally for identitification.

		TCHAR            name[MAXFILTERNAME];

		//-- Filters may want to identify themselves by something more  
		//   specific than their names. Specially filters that give names
		//   to parameter sets. If "resource" below is not empty, it
		//   will be used to identify the filter in the Video Post Queue.
		//   This is saved along with everything else by the host (Max).
		//   If all the filter needs is a resource to identify a set of
		//   parameters, this will sufice.

		TCHAR            resource[MAXRESOURCE];

		//-- Plug-In Parameter Block ------------------------------------------
		//
		//    No direct access to clients. Use the  methods in the  filter class.
		//

		void             *pidata;
		DWORD            pisize;

		//-- New R2 Stuff

		TCHAR			*userlabel;		//-- Optional label given by user
		ITrackViewNode	*node;			//-- TV Node (if any)
		Class_ID		nodeid;			//-- TV Node ID (if any);

		int				flttype;

	public:

		FLTExport        ImageFilterInfo                  ( );
		FLTExport       ~ImageFilterInfo                  ( );

		//-- Mask Information -------------------------------------------------

		BOOL                         maskenabled,evCopy;
		BOOL                         invertedmask;
		BitmapInfo                   mask;
		WORD                         maskflag;
		
		//-- This is a BitmapInfo that holds information about the current 
		//   Video Post main queue Image buffer. This can be used to get
		//   VP's (or target image) resolution, etc. To make an analogy, if
		//   this was a BitmapIO plug-in, this is the BitmapInfo given as
		//   the argument. This used primarilly at the time the filter
		//   receives the "Setup()" call as at render time, all this can be
		//   found in srcmap.

		BitmapInfo                   imgQueue;

		//-- Internal Helpers -------------------------------------------------

		FLTExport void              SetName         ( const TCHAR *n )    { _tcscpy(name,n);}
		FLTExport void              SetResource     ( const TCHAR *n )    { _tcscpy(resource,n);}
		FLTExport const TCHAR		*Name           ( )   { return    (const TCHAR *)name;}
		FLTExport const TCHAR		*Resource       ( )   { return    (const TCHAR *)resource;}
		
		//-- Plug-In Parameter Block ------------------------------------------
		
		FLTExport void              *GetPiData      ( ) { return pidata; }
		FLTExport void              SetPiData       ( void    *ptr ) { pidata = ptr; }
		FLTExport DWORD          	GetPiDataSize   ( )   { return    pisize; }
		FLTExport void              SetPiDataSize   ( DWORD s ) { pisize = s; }
		FLTExport void              ResetPiData     ( );
		FLTExport BOOL              AllocPiData     ( DWORD size  );

		FLTExport ImageFilterInfo &operator= (  ImageFilterInfo &from );
		
		//-- Load/Save
		
		FLTExport IOResult       	Save            ( ISave *isave );
		FLTExport IOResult       	Load            ( ILoad *iload, Interface *max );
		
		//-- Execution  Info ---------------------------------------------------
		//
		//    12/06/95 - GG
		//
		//    QueueRange defines    the entire Video Post Queue range. Execution
		//    is only the portion being rendered. This is, unless   the user    selects
		//    a "range", the same as QueueRange. FilterRange is where this  filter
		//    starts    and ends.
		//
		//    Video Post Queue
		//
		//              1         2         3         4         5
		//    0----|----|----|----|----|----|----|----|----|----|----|----|----|---- ...
		//
		//    Video Post spans from 0 to 49 (QueueRange) Start: 0  End: 49
		//
		//    qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
		//
		//    User executes a "range" from 10 to 30 (Execution Range) Start: 10 End: 30
		//
		//                  uuuuuuuuuuuuuuuuuuuuu
		//
		//    This filter appears in the queue from 5 to 35 (Filter Range) Start: 5 End: 35
		//
		//           fffffffffffffffffffffffffffffff        

		FrameRange                   QueueRange;              //-- Entire Video Post Queue
		FrameRange                   ExecutionRange;          //-- Segement being rendered
		FrameRange                   FilterRange;             //-- Filter Segment
		
		//----------------------------------------------------------------------
		//-- R2 Stuff Below ----------------------------------------------------
		//----------------------------------------------------------------------
	
		//-- Trackview Node Functions ------------------------------------------

		FLTExport ITrackViewNode	*Node	( ) 				{ return node;	}
		FLTExport void				SetNode (ITrackViewNode	*n) { node = n;		}

		FLTExport Class_ID			NodeID		( )		 		{ return nodeid;}
		FLTExport void				SetNodeID	( Class_ID id )	{ nodeid = id;  }

		//-- Optional Label given by user while adding or editing a filter. This label
		//   replaces the filter's name in Video Post's tracks for easier identification.

		FLTExport TCHAR				*UserLabel		( )			{ return userlabel; }

		//-- Used by VP to update the label. Not to be used by filters.

		FLTExport void				SetUserLabel	( TCHAR *l)	{ userlabel = l; }

		//-- Used to determine what type of filter this is at "Setup" time.

		#define	FLT_FILTER	0
		#define	FLT_LAYER	1

		FLTExport int				FilterType		( )	{ return flttype; }
		FLTExport void				SetFilterType	( int type ) { flttype = type; }

};

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//--   Filter Plug-Ins Handler
//
	
class FLT_FilterHandler {

		//-- Name and Capabilities  ------------------------
		
		TCHAR         fltDescription[MAXFILTERNAME];    
		DWORD         fltCapability;

		//-- DLL    Handler ----------------------------------
		
		ClassDesc *cd;
		
	public:

		FLT_FilterHandler();
		
		FLTExport TCHAR           *Description        ( const TCHAR  *d = NULL  );

		FLTExport void             SetCD              ( ClassDesc *dll )    { cd = dll;}
		FLTExport ClassDesc       *GetCD              ( )                   { return    cd;}

		FLTExport void             SetCapabilities  ( DWORD cap )      { fltCapability |= cap;}
		FLTExport DWORD            GetCapabilities  ( )                { return    (fltCapability);}
		FLTExport BOOL             TestCapabilities ( DWORD cap )      { return    (fltCapability  & cap);}

};

//-----------------------------------------------------------------------------
//--   Messages    sent back by various    (client)    methods

//--   Sent by the plug-in to notify   host of current progress. The   host should
// return TRUE if  it's ok to continue or FALSE to abort process.

#define    FLT_PROGRESS    WM_USER + 0x20    //-- wParam:  Current lParam: Total

//--   Sent by the plug-in to check for    process interruption. The host should
// return FALSE (by setting *lParam) if it's   ok  to  continue    or  TRUE to abort 
// process.

#define	FLT_CHECKABORT	WM_USER + 0x21    //-- wParam:  0         lParam: BOOL*

//--   Sent by the plug-in to display an optional textual  message (for progress
// report).

#define	FLT_TEXTMSG		WM_USER + 0x22    //-- wParam:  0         lParam: LPCTSTR

//--   Sent by the host TO the plug-in to notify the time has changed (the user
// moved the time slider in Max).

#define    FLT_TIMECHANGED	WM_USER + 0x23    //-- wParam:  0         lParam: TimeValue t

//--   Sent by the host TO the plug-in to notify that an Undo operation has been done.
// The plugin will set some boolean internally and wait for the next WM_PAINT message
// in order to update any spinners or other values that may have been undone.

#define    FLT_UNDO		WM_USER + 0x24    //-- wParam:  0         lParam: 0

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//--   List of Filter  Plug-Ins
//
	
class FLT_FilterList: public   Tab<FLT_FilterHandler> {

		BOOL        listed;
		 
	public:

		FLT_FilterList        ( )           { listed    = FALSE;    }

		BOOL        Listed    ( BOOL    f)  { listed    = f; return (listed);};
		BOOL        Listed    ( )           { return    (listed);};

		FLTExport int    FindFilter              ( const TCHAR *name );
		FLTExport DWORD  GetFilterCapabilities   ( const TCHAR *name );

		//-- This Creates   an  Instance    - Make sure to  "delete"    it  after   use.

		FLTExport ImageFilter *CreateFilterInstance(const TCHAR *d);

};

//-----------------------------------------------------------------------------
//-- Undo Notification

class UndoNotify : public TVNodeNotify {
	HWND hWnd;
public:
	UndoNotify (HWND hwnd) {hWnd = hwnd;}
	RefResult NotifyRefChanged	(Interval changeInt, RefTargetHandle hTarget, 
			PartID& partID,  RefMessage message) {
			SendMessage(hWnd,FLT_UNDO,0,0);
			InvalidateRect(hWnd,NULL,FALSE);
			return(REF_SUCCEED);
	}
};

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//--   ImageFilter Capability Flags
//
// It  is  valid   for a   plug-in to both Filter and  Compositor. If  both flags are
// set, the    user will be able   to  select it from  both the    Filter list and from
// the Compositor  list.   The plug-in will know it is running as  a filter    when
// the foreground  map pointer is  NULL.
//

#define IMGFLT_NONE              0      //  None

#define IMGFLT_MASK              (1<<0) //  Supports Masking
#define IMGFLT_CONTROL           (1<<1) //  Plug-In has a Control Panel
#define IMGFLT_FILTER            (1<<2) //  Plug-In is a Filter
#define IMGFLT_COMPOSITOR        (1<<3) //  Plug-In is a Compositor
#define IMGFLT_THREADED          (1<<4) //  Thread aware plug-in

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -