Skip to content

Commit

Permalink
Init tile pool in Frame constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Pam Harris committed May 13, 2024
1 parent 418b79a commit 4ec5289
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/Frame/Frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Frame::Frame(uint32_t session_id, std::shared_ptr<FileLoader> loader, const std:
_depth(1),
_num_stokes(1),
_image_cache_valid(false),
_tile_pool(std::make_shared<TilePool>()),
_use_tile_cache(false),
_moment_generator(nullptr),
_moment_name_index(0) {
Expand Down Expand Up @@ -93,6 +94,9 @@ Frame::Frame(uint32_t session_id, std::shared_ptr<FileLoader> loader, const std:
return;
}

// set the tile pool capacity
_tile_pool->Grow(omp_get_max_threads());

// reset the tile cache if the loader will use it
if (_use_tile_cache) {
int tiles_x = (_width - 1) / TILE_SIZE + 1;
Expand Down Expand Up @@ -469,7 +473,7 @@ bool Frame::GetRasterData(std::vector<float>& image_data, CARTA::ImageBounds& bo

// Tile data
bool Frame::FillRasterTileData(CARTA::RasterTileData& raster_tile_data, const Tile& tile, int z, int stokes,
CARTA::CompressionType compression_type, float compression_quality, int num_threads) {
CARTA::CompressionType compression_type, float compression_quality) {
// Early exit if z or stokes has changed
if (ZStokesChanged(z, stokes)) {
return false;
Expand All @@ -483,11 +487,6 @@ bool Frame::FillRasterTileData(CARTA::RasterTileData& raster_tile_data, const Ti
raster_tile_data.clear_tiles();
}

if (!_tile_pool) {
_tile_pool = std::make_shared<TilePool>();
_tile_pool->Grow(num_threads);
}

CARTA::TileData* tile_ptr = raster_tile_data.add_tiles();
tile_ptr->set_layer(tile.layer);
tile_ptr->set_x(tile.x);
Expand Down
2 changes: 1 addition & 1 deletion src/Frame/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class Frame {

// Raster data
bool FillRasterTileData(CARTA::RasterTileData& raster_tile_data, const Tile& tile, int z, int stokes,
CARTA::CompressionType compression_type, float compression_quality, int num_threads);
CARTA::CompressionType compression_type, float compression_quality);

// Functions used for smoothing and contouring
bool SetContourParameters(const CARTA::SetContourParameters& message);
Expand Down
4 changes: 2 additions & 2 deletions src/Session/Session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,8 @@ void Session::OnAddRequiredTiles(const CARTA::AddRequiredTiles& message, int ani
const auto& encoded_coordinate = message.tiles(i);
auto raster_tile_data = Message::RasterTileData(file_id, sync_id, animation_id);
auto tile = Tile::Decode(encoded_coordinate);
if (_frames.count(file_id) && _frames.at(file_id)->FillRasterTileData(
raster_tile_data, tile, z, stokes, compression_type, compression_quality, num_threads)) {
if (_frames.count(file_id) &&
_frames.at(file_id)->FillRasterTileData(raster_tile_data, tile, z, stokes, compression_type, compression_quality)) {
// Only use deflate on outgoing message if the raster image compression type is NONE
SendFileEvent(
file_id, CARTA::EventType::RASTER_TILE_DATA, 0, raster_tile_data, compression_type == CARTA::CompressionType::NONE);
Expand Down

0 comments on commit 4ec5289

Please sign in to comment.