| 230 | } |
| 231 | |
| 232 | uint32_t CalculateTileSize(uint32_t screenWidth, uint32_t screenHeight) |
| 233 | { |
| 234 | uint32_t const maxSz = std::max(screenWidth, screenHeight); |
| 235 | |
| 236 | // we're calculating the tileSize based on (maxSz > 1024 ? rounded : ceiled) |
| 237 | // to the nearest power of two value of the maxSz |
| 238 | |
| 239 | int const ceiledSz = 1 << static_cast<int>(ceil(std::log2(double(maxSz + 1)))); |
| 240 | int res = 0; |
| 241 | |
| 242 | if (maxSz < 1024) |
| 243 | { |
| 244 | res = ceiledSz; |
| 245 | } |
| 246 | else |
| 247 | { |
| 248 | int const flooredSz = ceiledSz / 2; |
| 249 | // rounding to the nearest power of two. |
| 250 | if (ceiledSz - maxSz < maxSz - flooredSz) |
| 251 | res = ceiledSz; |
| 252 | else |
| 253 | res = flooredSz; |
| 254 | } |
| 255 | |
| 256 | #ifndef OMIM_OS_DESKTOP |
| 257 | return static_cast<uint32_t>(math::Clamp(res / 2, 256, 1024)); |
| 258 | #else |
| 259 | return static_cast<uint32_t>(math::Clamp(res / 2, 512, 1024)); |
| 260 | #endif |
| 261 | } |
| 262 | |
| 263 | int GetDrawTileScale(int baseScale, uint32_t tileSize, double visualScale) |
| 264 | { |
no test coverage detected