final int col2 = Math.min(layerWidth, (int) ((viewBounds.x + viewBounds.width + layerTileWidth) / layerTileWidth));
final int row1 = Math.max(0, (int) (viewBounds.y / layerTileHeight));
final int row2 = Math.min(layerHeight, (int) ((viewBounds.y + viewBounds.height + layerTileHeight) / layerTileHeight));
for (int row = row1; row < row2; row++) {
for (int col = col1; col < col2; col++) {
<BUG>final TiledMapTileLayer.Cell cell = layer.getCell(col, row);
final TiledMapTile tile = cell.getTile();</BUG>
if (tile != null) {
count++;
final boolean flipX = cell.getFlipHorizontally();

final int col2 = Math.min(layerWidth, (int) ((viewBounds.x + viewBounds.width + layerTileWidth) / layerTileWidth));
final int row1 = Math.max(0, (int) (viewBounds.y / layerTileHeight));
final int row2 = Math.min(layerHeight, (int) ((viewBounds.y + viewBounds.height + layerTileHeight) / layerTileHeight));
for (int row = row1; row < row2; row++) {
for (int col = col1; col < col2; col++) {
final TiledMapTileLayer.Cell cell = layer.getCell(col, row);
if(cell == null) continue;
final TiledMapTile tile = cell.getTile();
if (tile != null) {
count++;
final boolean flipX = cell.getFlipHorizontally();
