src/sampler.cc
branchpyrit
changeset 88 f7edb3b90816
parent 87 1081e3dd3f3e
child 92 9af5c039b678
equal deleted inserted replaced
87:1081e3dd3f3e 88:f7edb3b90816
    37 
    37 
    38 int DefaultSampler::initSampleSet()
    38 int DefaultSampler::initSampleSet()
    39 {
    39 {
    40 	static const int gridsamples[] = {1,5,9,16};
    40 	static const int gridsamples[] = {1,5,9,16};
    41 	const int samples = gridsamples[oversample];
    41 	const int samples = gridsamples[oversample];
       
    42 	const int &w = pixmap.getWidth(), &h = pixmap.getHeight();
       
    43 	Float *&buffer = pixmap.getFloatData();
       
    44 
    42 	if ( phase == 0 )
    45 	if ( phase == 0 )
    43 	{
    46 	{
    44 		if (subsample > 1)
    47 		if (subsample > 1)
    45 		{
    48 		{
    46 			phase = 1;
    49 			phase = 1;
   139 	return 0;
   142 	return 0;
   140 }
   143 }
   141 
   144 
   142 bool DefaultSampler::nextSample(Sample* s)
   145 bool DefaultSampler::nextSample(Sample* s)
   143 {
   146 {
       
   147 	const int &w = pixmap.getWidth(), &h = pixmap.getHeight();
       
   148 	Float *&buffer = pixmap.getFloatData();
       
   149 
   144 	if (phase == 1)
   150 	if (phase == 1)
   145 	{
   151 	{
   146 		// subsampling
   152 		// subsampling
   147 		if (sx < 0)
   153 		if (sx < 0)
   148 		{
   154 		{
   266 	return true;
   272 	return true;
   267 }
   273 }
   268 
   274 
   269 void DefaultSampler::saveSample(Sample &samp, Colour &col)
   275 void DefaultSampler::saveSample(Sample &samp, Colour &col)
   270 {
   276 {
   271 	Float *buf = buffer + 3*(samp.sy * w + samp.sx);
   277 	Float *buf = pixmap.getFloatData()
       
   278 		+ 3*(samp.sy * pixmap.getWidth() + samp.sx);
   272 	if (phase == 2 && oversample)
   279 	if (phase == 2 && oversample)
   273 	{
   280 	{
   274 		*(buf+0) += col.r;
   281 		*(buf+0) += col.r;
   275 		*(buf+1) += col.g;
   282 		*(buf+1) += col.g;
   276 		*(buf+2) += col.b;
   283 		*(buf+2) += col.b;