Render fixed sized tiles, pre-drawn into the Cairo surface "tiles".
| 246 | |
| 247 | // Render fixed sized tiles, pre-drawn into the Cairo surface "tiles". |
| 248 | void TileEngine::renderTiles( |
| 249 | cairo_t *ctx, |
| 250 | cairo_surface_t *tilesSurf, |
| 251 | int tilesWidth, |
| 252 | int tilesHeight, |
| 253 | PyObject *tileFunction, |
| 254 | PyObject *tileMap, |
| 255 | int tileSize, |
| 256 | int renderCol, |
| 257 | int renderRow, |
| 258 | int renderCols, |
| 259 | int renderRows, |
| 260 | double alpha) |
| 261 | { |
| 262 | |
| 263 | if ((tileFunction != Py_None) && |
| 264 | !PyCallable_Check(tileFunction)) { |
| 265 | PyErr_SetString( |
| 266 | PyExc_TypeError, |
| 267 | "expected tileFunction to be a callable function or None"); |
| 268 | return; |
| 269 | } |
| 270 | |
| 271 | // The tileMap should be an array of 4 byte integers, |
| 272 | // mapping virtual tiles indices to absolute tile numbers. |
| 273 | if ((tileMap != Py_None) && |
| 274 | !PySequence_Check(tileMap)) { |
| 275 | PyErr_SetString( |
| 276 | PyExc_TypeError, |
| 277 | "expected tileMap to be an array " |
| 278 | "of 4 byte integers or None"); |
| 279 | return; |
| 280 | } |
| 281 | |
| 282 | const int *tileMapData = NULL; |
| 283 | unsigned int tileMapCount = 0; |
| 284 | |
| 285 | if (tileMap != Py_None) { |
| 286 | tileMapCount = (unsigned int)PySequence_Size(tileMap); |
| 287 | Py_ssize_t tileMapLength = 0; |
| 288 | if (PyObject_AsReadBuffer( |
| 289 | tileMap, |
| 290 | (const void **)&tileMapData, |
| 291 | &tileMapLength) != 0) { |
| 292 | PyErr_SetString( |
| 293 | PyExc_TypeError, |
| 294 | "expected tileMap with read buffer"); |
| 295 | return; |
| 296 | } |
| 297 | |
| 298 | int tileMapDataCount = |
| 299 | (int)tileMapLength / sizeof(unsigned int); |
| 300 | |
| 301 | if (tileMapDataCount != (int)tileMapCount) { |
| 302 | PyErr_SetString( |
| 303 | PyExc_TypeError, |
| 304 | "expected tileMap read buffer of 4 byte integers"); |
| 305 | return; |
nothing calls this directly
no outgoing calls
no test coverage detected