@@ -2296,12 +2296,13 @@ class OIIO_API ImageOutput {
22962296 // / y, and z).
22972297 // / @returns `true` upon success, or `false` upon failure.
22982298 // /
2299- virtual bool write_image (TypeDesc format, image_span<const std::byte> data);
2299+ virtual bool write_image (TypeDesc format,
2300+ const image_span<const std::byte>& data);
23002301
23012302 // / A version of `write_image()` taking an `image_span<T>`, where the type
23022303 // / of the underlying data is `T`. This is a convenience wrapper around
23032304 // / the `write_image()` that takes an `image_span<const std::byte>`.
2304- template <typename T> bool write_image (image_span<T> data)
2305+ template <typename T> bool write_image (const image_span<T>& data)
23052306 {
23062307 return write_image (TypeDescFromC<T>::value (),
23072308 as_image_span_bytes (data));
@@ -2340,13 +2341,14 @@ class OIIO_API ImageOutput {
23402341 // / @returns `true` upon success, or `false` upon failure.
23412342 // /
23422343 virtual bool write_scanline (int y, int z, TypeDesc format,
2343- image_span<const std::byte> data);
2344+ const image_span<const std::byte>& data);
23442345
23452346 // / A version of `write_scanline()` taking an `image_span<T>`, where the
23462347 // / type of the underlying data is `T`. This is a convenience wrapper
23472348 // / around the `write_scanline()` that takes an `image_span<const
23482349 // / std::byte>`.
2349- template <typename T> bool write_scanline (int y, int z, image_span<T> data)
2350+ template <typename T>
2351+ bool write_scanline (int y, int z, const image_span<T>& data)
23502352 {
23512353 // reduce to type + image_span<byte>
23522354 return write_scanline (y, z, TypeDescFromC<T>::value (),
@@ -2389,14 +2391,14 @@ class OIIO_API ImageOutput {
23892391 // / @returns `true` upon success, or `false` upon failure.
23902392 // /
23912393 virtual bool write_scanlines (int ybegin, int yend, int z, TypeDesc format,
2392- image_span<const std::byte> data);
2394+ const image_span<const std::byte>& data);
23932395
23942396 // / A version of `write_scanlines()` taking an `image_span<T>`, where the
23952397 // / type of the underlying data is `T`. This is a convenience wrapper
23962398 // / around the `write_scanlines()` that takes an `image_span<const
23972399 // / std::byte>`.
23982400 template <typename T>
2399- bool write_scanlines (int ybegin, int yend, int z, image_span<T> data)
2401+ bool write_scanlines (int ybegin, int yend, int z, const image_span<T>& data)
24002402 {
24012403 // image_span<T>: reduces to type + byte_buffer
24022404 return write_scanlines (ybegin, yend, z, TypeDescFromC<T>::value (),
@@ -2442,13 +2444,13 @@ class OIIO_API ImageOutput {
24422444 // / @returns `true` upon success, or `false` upon failure.
24432445 // /
24442446 virtual bool write_tile (int x, int y, int z, TypeDesc format,
2445- image_span<const std::byte> data);
2447+ const image_span<const std::byte>& data);
24462448
24472449 // / A version of `write_tile()` taking an `image_span<T>`, where the type
24482450 // / of the underlying data is `T`. This is a convenience wrapper around
24492451 // / the `write_tile()` that takes an `image_span<const std::byte>`.
24502452 template <typename T>
2451- bool write_tile (int x, int y, int z, image_span<T> data)
2453+ bool write_tile (int x, int y, int z, const image_span<T>& data)
24522454 {
24532455 return write_tile (x, y, z, TypeDescFromC<T>::value (),
24542456 as_image_span_bytes (data));
@@ -2495,14 +2497,14 @@ class OIIO_API ImageOutput {
24952497 // /
24962498 virtual bool write_tiles (int xbegin, int xend, int ybegin, int yend,
24972499 int zbegin, int zend, TypeDesc format,
2498- image_span<const std::byte> data);
2500+ const image_span<const std::byte>& data);
24992501
25002502 // / A version of `write_tiles()` taking an `image_span<T>`, where the type
25012503 // / of the underlying data is `T`. This is a convenience wrapper around
25022504 // / the `write_tiles()` that takes an `image_span<const std::byte>`.
25032505 template <typename T>
25042506 bool write_tiles (int xbegin, int xend, int ybegin, int yend, int zbegin,
2505- int zend, image_span<T> data)
2507+ int zend, const image_span<T>& data)
25062508 {
25072509 return write_tiles (xbegin, xend, ybegin, yend, zbegin, zend,
25082510 TypeDescFromC<T>::value (),
@@ -2550,15 +2552,15 @@ class OIIO_API ImageOutput {
25502552 // /
25512553 virtual bool write_rectangle (int xbegin, int xend, int ybegin, int yend,
25522554 int zbegin, int zend, TypeDesc format,
2553- image_span<const std::byte> data);
2555+ const image_span<const std::byte>& data);
25542556
25552557 // / A version of `write_rectangle()` taking an `image_span<T>`, where the
25562558 // / type of the underlying data is `T`. This is a convenience wrapper
25572559 // / around the `write_rectangle()` that takes an `image_span<const
25582560 // / std::byte>`.
25592561 template <typename T>
25602562 bool write_rectangle (int xbegin, int xend, int ybegin, int yend, int zbegin,
2561- int zend, image_span<T> data)
2563+ int zend, const image_span<T>& data)
25622564 {
25632565 return write_rectangle (xbegin, xend, ybegin, yend, zbegin, zend,
25642566 TypeDescFromC<T>::value (),
@@ -3141,7 +3143,7 @@ class OIIO_API ImageOutput {
31413143 // / the pixels to the right position in the dither pattern.
31423144 template <typename T>
31433145 cspan<std::byte> to_native (int xbegin, int xend, int ybegin, int yend,
3144- int zbegin, int zend, image_span<T> data,
3146+ int zbegin, int zend, const image_span<T>& data,
31453147 std::vector<unsigned char >& scratch,
31463148 unsigned int dither = 0 , int xorigin = 0 ,
31473149 int yorigin = 0 , int zorigin = 0 )
@@ -3158,7 +3160,7 @@ class OIIO_API ImageOutput {
31583160 // / `format` and an image_span of generic (std::byte) data.
31593161 cspan<std::byte> to_native (int xbegin, int xend, int ybegin, int yend,
31603162 int zbegin, int zend, TypeDesc format,
3161- image_span<const std::byte> data,
3163+ const image_span<const std::byte>& data,
31623164 std::vector<unsigned char >& scratch,
31633165 unsigned int dither = 0 , int xorigin = 0 ,
31643166 int yorigin = 0 , int zorigin = 0 );
@@ -3856,7 +3858,7 @@ OIIO_API bool convert_image (int nchannels, int width, int height, int depth,
38563858// / Return true if ok, false if it didn't know how to do the conversion.
38573859template <typename SrcType, typename DstType>
38583860bool
3859- convert_image (image_span<SrcType> src, image_span<DstType> dst)
3861+ convert_image (const image_span<SrcType>& src, const image_span<DstType>& dst)
38603862{
38613863 // For now, just implement by wrapping the pointer-based version.
38623864 OIIO_DASSERT (src.nchannels () == dst.nchannels ()
@@ -3876,8 +3878,8 @@ convert_image(image_span<SrcType> src, image_span<DstType> dst)
38763878// / `TypeDesc`, and the spans are untyped bytes that provide the dimensions
38773879// / and memory layout.
38783880inline bool
3879- convert_image (image_span<const std::byte> src, TypeDesc src_type,
3880- image_span<std::byte> dst, TypeDesc dst_type)
3881+ convert_image (const image_span<const std::byte>& src, TypeDesc src_type,
3882+ const image_span<std::byte>& dst, TypeDesc dst_type)
38813883{
38823884 // For now, just implement by wrapping the pointer-based version.
38833885 OIIO_DASSERT (src.nchannels () == dst.nchannels ()
@@ -3908,8 +3910,8 @@ OIIO_API bool parallel_convert_image (
39083910// / threads. The data types are taken from the spans.
39093911template <typename SrcType, typename DstType>
39103912bool
3911- parallel_convert_image (image_span<SrcType> src, image_span<DstType> dst ,
3912- int nthreads = 0 )
3913+ parallel_convert_image (const image_span<SrcType>& src,
3914+ const image_span<DstType>& dst, int nthreads = 0 )
39133915{
39143916 // For now, just implement by wrapping the pointer-based version.
39153917 OIIO_DASSERT (src.nchannels () == dst.nchannels ()
@@ -3927,9 +3929,9 @@ parallel_convert_image(image_span<SrcType> src, image_span<DstType> dst,
39273929// / threads. The data types are passed as `TypeDesc`, and the spans are
39283930// / untyped bytes that provide the dimensions and memory layout.
39293931inline bool
3930- parallel_convert_image (image_span<const std::byte> src, TypeDesc src_type ,
3931- image_span<std::byte> dst, TypeDesc dst_type ,
3932- int nthreads = 0 )
3932+ parallel_convert_image (const image_span<const std::byte>& src,
3933+ TypeDesc src_type, const image_span<std::byte>& dst,
3934+ TypeDesc dst_type, int nthreads = 0 )
39333935{
39343936 // For now, just implement by wrapping the pointer-based version.
39353937 OIIO_DASSERT (src.nchannels () == dst.nchannels ()
@@ -3995,7 +3997,8 @@ OIIO_API bool copy_image (int nchannels, int width, int height, int depth,
39953997// / strides. Return true if ok, false if it couldn't do it. (Reserved for
39963998// / future use; currently is always succeeds)
39973999template <typename D, size_t Drank, typename S, size_t Srank>
3998- bool copy_image (image_span<D, Drank> dst, image_span<S, Srank> src)
4000+ bool copy_image (const image_span<D, Drank>& dst,
4001+ const image_span<S, Srank>& src)
39994002{
40004003 // Arbitrary types are handled by just converting to generic byte
40014004 // image_spans.
@@ -4005,7 +4008,8 @@ bool copy_image(image_span<D, Drank> dst, image_span<S, Srank> src)
40054008
40064009// / copy_image base case: generic span of bytes.
40074010OIIO_API bool
4008- copy_image (image_span<std::byte> dst, image_span<const std::byte> src);
4011+ copy_image (const image_span<std::byte> &dst,
4012+ const image_span<const std::byte>& src);
40094013
40104014
40114015
0 commit comments