Permalink
Browse files

All: Modify all code that use Cache::Handle

They must now manually state that they're done using the cache handle.
  • Loading branch information...
1 parent d35093e commit 1cb0a8cf9dd5df98bce985ece43c024412d2559b Zack Moratto committed Sep 17, 2012
@@ -66,10 +66,16 @@ namespace vw {
if ( m_cache_ptr ) {
// Early-out optimization for single-block resources
if( m_block_table.size() == 1 ) {
- return m_block_table[0]->operator()( x, y, p );
+ const Cache::Handle<BlockGenerator>& handle = m_block_table[0];
+ result_type result = handle->operator()( x, y, p );
+ handle.release();
+ return result;
}
int32 ix = x/m_block_size.x(), iy = y/m_block_size.y();
- return block(ix,iy)->operator()( x-ix*m_block_size.x(), y - iy*m_block_size.y(), p );
+ const Cache::Handle<BlockGenerator>& handle = block(ix,iy);
+ result_type result = handle->operator()( x-ix*m_block_size.x(), y - iy*m_block_size.y(), p );
+ handle.release();
+ return result;
}
else return (*m_child)(x,y,p);
}
@@ -114,7 +120,9 @@ namespace vw {
vw_throw(LogicErr() << "BlockRasterizeView::RasterizeFunctor: bbox spans more than one cache block!");
}
#endif
- m_view.block(ix,iy)->rasterize( crop( m_dest, bbox-m_offset ), bbox-Vector2i(ix*m_view.m_block_size.x(),iy*m_view.m_block_size.y()) );
+ const Cache::Handle<BlockGenerator>& handle = m_view.block(ix,iy);
+ handle->rasterize( crop( m_dest, bbox-m_offset ), bbox-Vector2i(ix*m_view.m_block_size.x(),iy*m_view.m_block_size.y()) );
+ handle.release();
}
else m_view.child().rasterize( crop( m_dest, bbox-m_offset ), bbox );
}
@@ -186,6 +186,7 @@ namespace mosaic {
}
boost::shared_ptr<value_type> generate() const {
ImageView<pixel_type> source = *m_composite.sources[m_index];
+ m_composite.sources[m_index].release();
m_composite.sources[m_index].deprioritize();
return boost::shared_ptr<value_type>( new value_type( select_alpha_channel( source ) ) );
}
@@ -367,6 +368,7 @@ boost::shared_ptr<typename vw::mosaic::ImageComposite<PixelT>::Pyramid> vw::mosa
vw_out(DebugMessage, "mosaic") << "ImageComposite generating pyramid " << m_index << std::endl;
boost::shared_ptr<Pyramid> ptr( new Pyramid );
ImageView<pixel_type> source = copy(*m_composite.sources[m_index]);
+ m_composite.sources[m_index].release();
m_composite.sources[m_index].deprioritize();
// This is sort of a kluge: the hole-filling algorithm currently
@@ -509,6 +511,7 @@ vw::ImageView<PixelT> vw::mosaic::ImageComposite<PixelT>::blend_patch( BBox2i co
pyr->images[l].addto( sum_pyr[l], bbox_pyr[l].min().x(), bbox_pyr[l].min().y() );
pyr->masks[l].addto( msum_pyr[l], bbox_pyr[l].min().x(), bbox_pyr[l].min().y() );
}
+ pyramids[p].release();
}
// Collapse the pyramid
@@ -536,6 +539,7 @@ vw::ImageView<PixelT> vw::mosaic::ImageComposite<PixelT>::blend_patch( BBox2i co
if( ! patch_bbox.intersects( bboxes[p] ) ) continue;
ImageView<channel_type> source_alpha = *alphas[p];
+ alphas[p].release();
BBox2i overlap = patch_bbox;
overlap.crop( bboxes[p] );
@@ -89,7 +89,11 @@ boost::shared_ptr<IndexPage> IndexLevel::load_page(uint32 col, uint32 row) const
m_page_gen_factory->create(m_level, floorto(col, m_page_width), floorto(row, m_page_height), m_page_width, m_page_height);
m_cache_handles[idx] = m_cache.insert( generator );
}
- return m_cache_handles[idx];
+
+ // WARNING! CACHE MIGHT DELETE YOUR POINTER HERE!
+ boost::shared_ptr<IndexPage> result = m_cache_handles[idx];
+ m_cache_handles[idx].release();
+ return result;
}
@@ -127,6 +127,7 @@ class vw::gui::TextureFetchTask {
// deallocation requests to be produced as well if cache tile
// need to be deallocated to make room for the new tile.
(*(r->handle)).texture_id();
+ r->handle.release();
} else {
@@ -241,6 +242,7 @@ GLuint vw::gui::GlTextureCache::get_texture_id(vw::gui::TileLocator const& tile_
new_record->handle = m_gl_texture_cache_ptr->insert( GlTextureGenerator(m_tile_generator,
tile_info,
new_record_ptr) );
+ new_record->handle.release();
// Place this cache handle into the tree for later access.
m_texture_records->insert( new_record_ptr, tile_info.col, tile_info.row,

0 comments on commit 1cb0a8c

Please sign in to comment.