
#ifndef _JL_SamplePattern_H_
#define _JL_SamplePattern_H_

#include <stdlib.h>
#include <iostream.h>

#define SAMPLE_PATTERN_EVERY_PIXEL			0
#define SAMPLE_PATTERN_ALMOST_EVERY_PIXEL	1
#define SAMPLE_PATTERN_MOST_PIXELS			2
#define SAMPLE_PATTERN_CHECKERBOARD			3
#define SAMPLE_PATTERN_SPARSE				4
#define SAMPLE_PATTERN_VERY_SPARSE			5

//  0: sample this pixel
// !0: don't sample this pixel

// !0: each 4 bits specify weights to blend
//     neighboring pixels
//
//     0x########
//       76543210
//
//			0 1 2
//			3   4
//			5 6 7

class SamplePattern {

	private:
		unsigned int	*_pattern;
		float			*_multiplier;
		int				_xsize, _ysize, _size;
		int				_inited;
		int				_updated;

	public: 
		SamplePattern();
		SamplePattern(const SamplePattern &S) { CopyFrom(S); }
		virtual ~SamplePattern();

		SamplePattern& CopyFrom(const SamplePattern&);
		SamplePattern& operator=(const SamplePattern &S) { return CopyFrom(S); }

		void NewSize(int x, int y);

		void SampleEveryPixel();

		void SetSamplePattern(int p, int x1=0, int x2=-1, int y1=0, int y2=-1);

		void Update();

		unsigned int Sample(int x, int y) { return _pattern[y*_xsize + x]; }
		float Multiplier(int x, int y) { return _multiplier[y*_xsize + x]; }
};

#endif
