#pragma once

#include "..\ScreenMask\ScreenMask.h"

#define GetAValue(rgb) ((BYTE)((rgb)>>24))
#define SAFE_RELEASE(x) if(x) {x->Release(); x=NULL;}

class CDownSample
{
public:
	LPDIRECT3DSURFACE9	mr_Surface_[2];
	LPDIRECT3DTEXTURE9	mr_Texture_[2];
	LPDIRECT3DTEXTURE9	mr_DownSampledTexture_;

	int mi_Width,mi_Height;
	IShader *mr_BlurHShader_;
	IShader *mr_BlurVShader_;
	IShader *mr_BeforeBlurShader_;
	ScreenMask *mk_Mask_;
	int mi_Steps;
	IDirect3DDevice9 *mr_Device_;
	bool mb_Use;

	CDownSample();
	~CDownSample();
public:
	void Create(IDirect3DDevice9 *inlpd3dd,int inmi_Width, int inmi_Height, int inmi_Steps, IShader *h, IShader *v, IShader *a);
	LPDIRECT3DTEXTURE9 GetDownSampledTexture();
	LPDIRECT3DTEXTURE9 SampleDown(LPDIRECT3DTEXTURE9 tex);
};