| 375 | |
| 376 | |
| 377 | void TileEngine::renderTilesLazy( |
| 378 | cairo_t *ctx, |
| 379 | PyObject *tileFunction, |
| 380 | PyObject *tileMap, |
| 381 | int tileSize, |
| 382 | int renderCol, |
| 383 | int renderRow, |
| 384 | int renderCols, |
| 385 | int renderRows, |
| 386 | double alpha, |
| 387 | PyObject *tileGenerator, |
| 388 | PyObject *tileCache, |
| 389 | PyObject *tileCacheSurfaces, |
| 390 | PyObject *tileState) |
| 391 | { |
| 392 | if ((tileFunction != Py_None) && |
| 393 | !PyCallable_Check(tileFunction)) { |
| 394 | PyErr_SetString( |
| 395 | PyExc_TypeError, |
| 396 | "expected tileFunction to be a callable function or None"); |
| 397 | return; |
| 398 | } |
| 399 | |
| 400 | // The tileMap should be None, or an array of 4 byte integers, |
| 401 | // mapping virtual tiles indices to absolute tile numbers. |
| 402 | |
| 403 | const int *tileMapData = NULL; |
| 404 | unsigned int tileMapCount = 0; |
| 405 | |
| 406 | if (tileMap != Py_None) { |
| 407 | |
| 408 | if (!PySequence_Check(tileMap)) { |
| 409 | PyErr_SetString( |
| 410 | PyExc_TypeError, |
| 411 | "expected tileMap to be an array " |
| 412 | "of 4 byte integers or None"); |
| 413 | return; |
| 414 | } |
| 415 | |
| 416 | tileMapCount = (unsigned int)PySequence_Size(tileMap); |
| 417 | Py_ssize_t tileMapLength = 0; |
| 418 | if (PyObject_AsReadBuffer( |
| 419 | tileMap, |
| 420 | (const void **)&tileMapData, |
| 421 | &tileMapLength) != 0) { |
| 422 | PyErr_SetString( |
| 423 | PyExc_TypeError, |
| 424 | "expected tileMap with read buffer"); |
| 425 | return; |
| 426 | } |
| 427 | |
| 428 | int tileMapDataCount = |
| 429 | (int)tileMapLength / sizeof(unsigned int); |
| 430 | |
| 431 | if (tileMapDataCount != (int)tileMapCount) { |
| 432 | PyErr_SetString( |
| 433 | PyExc_TypeError, |
| 434 | "expected tileMap read buffer of 4 byte integers"); |
nothing calls this directly
no outgoing calls
no test coverage detected