Mercurial > hg > svcore
diff data/model/PowerOfSqrtTwoZoomConstraint.cpp @ 1529:c1c45c5146bb zoom
Merge from default branch
author | Chris Cannam |
---|---|
date | Tue, 18 Sep 2018 15:06:58 +0100 |
parents | 710e6250a401 a7485c1bdba5 |
children | 1ae6a19464a7 05c3fbaec8ea |
line wrap: on
line diff
--- a/data/model/PowerOfSqrtTwoZoomConstraint.cpp Mon Sep 17 13:51:14 2018 +0100 +++ b/data/model/PowerOfSqrtTwoZoomConstraint.cpp Tue Sep 18 15:06:58 2018 +0100 @@ -18,6 +18,8 @@ #include <iostream> #include <cmath> +#include "base/Debug.h" + ZoomLevel PowerOfSqrtTwoZoomConstraint::getNearestZoomLevel(ZoomLevel requested, @@ -51,7 +53,7 @@ int &power, RoundingDirection dir) const { -// cerr << "given " << blockSize << endl; +// SVCERR << "given " << blockSize << endl; int minCachePower = getMinCachePower(); @@ -63,13 +65,18 @@ prevVal = val; val *= sqrtf(2.f); } - int rval; - if (dir == RoundUp) rval = int(val + 0.01f); - else if (dir == RoundDown) rval = int(prevVal + 0.01f); - else if (val - float(blockSize) < - float(blockSize) - prevVal) rval = int(val + 0.01f); - else rval = int(prevVal + 0.01); -// SVDEBUG << "returning " << rval << endl; + int rval = int(val + 0.01f); +// SVCERR << "got val = " << val << ", rval = " << rval << ", prevVal = " << prevVal << endl; + if (rval != blockSize && dir != RoundUp) { + if (dir == RoundDown) { + rval = int(prevVal + 0.01f); + } else if (val - float(blockSize) < float(blockSize) - prevVal) { + rval = int(val + 0.01f); + } else { + rval = int(prevVal + 0.01); + } + } +// SVCERR << "returning " << rval << endl; return rval; } @@ -92,7 +99,7 @@ << (power - minCachePower)); } -// SVDEBUG << "Testing base " << base << endl; +// SVCERR << "Testing base " << base << " (i = " << i << ", power = " << power << ", type = " << type << ")" << endl; if (base == blockSize) { result = base;