@@ -118,7 +118,7 @@ class ImageReader::Implementation
118118
119119 public :
120120
121- Implementation ( const ImageReader *reader ) : m_reader( reader ), m_cache( nullptr , &destroyImageCache )
121+ Implementation ( const ImageReader *reader ) : m_reader( reader )
122122 {
123123 }
124124
@@ -251,23 +251,33 @@ class ImageReader::Implementation
251251 Imath::Box2i dataWindow ()
252252 {
253253 open ( /* throwOnFailure */ true );
254- const ImageSpec *spec = m_cache->imagespec ( m_inputFileName, /* subimage = */ 0 , miplevel () );
254+
255+ ImageSpec spec;
256+ #if OIIO_VERSION >= 30000
257+ m_cache->get_cache_dimensions ( m_inputFileName, spec, /* subimage = */ 0 , miplevel () );
258+ #else
259+ spec = *m_cache->imagespec ( m_inputFileName, /* subimage = */ 0 , miplevel () );
260+ #endif
255261
256262 return Imath::Box2i (
257- Imath::V2i ( spec-> x , spec-> y ),
258- Imath::V2i ( spec-> width + spec-> x - 1 , spec-> height + spec-> y - 1 )
263+ Imath::V2i ( spec. x , spec. y ),
264+ Imath::V2i ( spec. width + spec. x - 1 , spec. height + spec. y - 1 )
259265 );
260266 }
261267
262268 Imath::Box2i displayWindow ()
263269 {
264270 open ( /* throwOnFailure */ true );
265271
266- const ImageSpec *spec = m_cache->imagespec ( m_inputFileName, /* subimage = */ 0 , miplevel () );
267-
272+ ImageSpec spec;
273+ #if OIIO_VERSION >= 30000
274+ m_cache->get_cache_dimensions ( m_inputFileName, spec, /* subimage = */ 0 , miplevel () );
275+ #else
276+ spec = *m_cache->imagespec ( m_inputFileName, /* subimage = */ 0 , miplevel () );
277+ #endif
268278 return Imath::Box2i (
269- Imath::V2i ( spec-> full_x , spec-> full_y ),
270- Imath::V2i ( spec-> full_x + spec-> full_width - 1 , spec-> full_y + spec-> full_height - 1 )
279+ Imath::V2i ( spec. full_x , spec. full_y ),
280+ Imath::V2i ( spec. full_x + spec. full_width - 1 , spec. full_y + spec. full_height - 1 )
271281 );
272282 }
273283
@@ -441,8 +451,11 @@ class ImageReader::Implementation
441451 }
442452
443453 m_inputFileName = " " ;
444- m_cache.reset ( ImageCache::create ( /* shared */ false ) );
445-
454+ #if OIIO_VERSION >= 30000
455+ m_cache = ImageCache::create ( /* shared */ false );
456+ #else
457+ m_cache.reset ( ImageCache::create ( /* shared */ false ), destroyImageCache );
458+ #endif
446459 // Autompip ensures that if a miplevel is requested that the file
447460 // doesn't contain, OIIO creates the respective level on the fly.
448461 m_cache->attribute ( " automip" , 1 );
@@ -502,13 +515,15 @@ class ImageReader::Implementation
502515 return p->getNumericValue ();
503516 }
504517
518+ #if OIIO_VERSION < 30000
505519 static void destroyImageCache ( ImageCache *cache )
506520 {
507521 ImageCache::destroy ( cache, /* teardown */ true );
508522 }
523+ #endif
509524
510525 const ImageReader *m_reader;
511- std::unique_ptr <ImageCache, decltype (&destroyImageCache) > m_cache;
526+ std::shared_ptr <ImageCache> m_cache;
512527 ustring m_inputFileName;
513528 std::string m_currentColorSpace;
514529 std::string m_linearColorSpace;
0 commit comments