Skip to content

Commit 0d824b6

Browse files
authored
api: imagebufalgo.h mark, warn, or remove various deprecations (#4344)
* The old versions (deprecated since 2.0) of IBA::compare() and computePixelStats() that took a reference to the CompareResults or PixelStats structure now have deprecation warnings. Use the versions that return the structure instead. * The deprecated (often since as far back as 2.0) versions of functions that took raw pointers to color values now have deprecations warnings. Use the versions that take `span<>` or `cspan<>` instead. These include versions of: isConstantColor, isConstantChannel, isMonochrome, isConstantChannel, colorconvert, fill, checker, add, sub, absdiff, mul, div, mad, pow, channel_sum, channels, clamp, color_count, color_range_check, render_text. * The `histogram()` function that takes a reference to a result vector (deprecated since 2.0 and previously warned) has been removed. Use the version that returns the vector instead. The `histogram_draw()` (deprecated since 2.0 and previously warned) has been removed and has no replacement since it was always silly. * The versions of ociodisplay that lacked an `inverse` parameter, which were marked as deprecated since 2.5, now have deprecation warnings. Use the version that takes an `inverse` bool. * The OpenCV-related functions that take old-style IplImage pointers (deprecated since 2.0) have been removed. Use the modern ones that use cv::Mat. * The pre-KWArgs versions of resize, warp, and fit now have deprecation warnings. Use the versions that take KWArgs instead. * IBA::type_merge, deprecated since 2.3, now has a deprecation warning. Instead, use TypeDesc::basetype_merge(). All of the IBA functions with deprecation warnings are additionally implemented inline, so that they can be easily removed later if necessary without an ABI break at that time. Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 722c7f4 commit 0d824b6

27 files changed

Lines changed: 400 additions & 885 deletions

docs/Deprecations-3.0.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ which only occur once every several years, we allow removal of functionality.
1212
OpenImageIO v3.0 is a major release that includes removal of many
1313
long-deprecated API facets. This document lists the deprecations and removals.
1414

15+
NOTE: This is an in-progress document. Some things currently only warning
16+
about being deprecated will be removed in the final 3.0 release.
17+
1518
### Glossary
1619

1720
- "Marked as deprecated" means that we consider an API facet to be obsolete,
@@ -29,6 +32,7 @@ long-deprecated API facets. This document lists the deprecations and removals.
2932

3033
---
3134

35+
---
3236

3337
## array_view.h
3438

@@ -82,6 +86,37 @@ long-deprecated API facets. This document lists the deprecations and removals.
8286
deprecated since OIIO 1.5, now has deprecation warnings. Use
8387
`interppixel_NDC()` instead.
8488

89+
## imagebufalgo.h
90+
91+
* The old versions (deprecated since 2.0) of IBA::compare() and
92+
computePixelStats() that took a reference to the CompareResults or
93+
PixelStats structure now have deprecation warnings. Use the versions that
94+
return the structure instead.
95+
* The deprecated (often since as far back as 2.0) versions of functions that
96+
took raw pointers to color values now have deprecations warnings. Use the
97+
versions that take `span<>` or `cspan<>` instead. These include versions of:
98+
isConstantColor, isConstantChannel, isMonochrome, isConstantChannel,
99+
colorconvert, fill, checker, add, sub, absdiff, mul, div, mad, pow,
100+
channel_sum, channels, clamp, color_count, color_range_check, render_text.
101+
* The `histogram()` function that takes a reference to a result vector
102+
(deprecated since 2.0 and previously warned) has been removed. Use the
103+
version that returns the vector instead. The `histogram_draw()` (deprecated
104+
since 2.0 and previously warned) has been removed and has no replacement
105+
since it was always silly.
106+
* The versions of ociodisplay that lacked an `inverse` parameter, which were
107+
marked as deprecated since 2.5, now have deprecation warnings. Use the
108+
version that takes an `inverse` bool.
109+
* The OpenCV-related functions that take old-style IplImage pointers
110+
(deprecated since 2.0) have been removed. Use the modern ones that use
111+
cv::Mat.
112+
* The pre-KWArgs versions of resize, warp, and fit now have deprecation
113+
warnings. Use the versions that take KWArgs instead.
114+
115+
## imagebufalgo_util.h
116+
117+
* IBA::type_merge, deprecated since 2.3, now has a deprecation warning.
118+
Instead, use TypeDesc::basetype_merge().
119+
85120
## missingmath.h
86121

87122
* This header has been removed entirely. It has was originally needed for

src/include/OpenImageIO/imagebufalgo.h

Lines changed: 166 additions & 172 deletions
Large diffs are not rendered by default.

src/include/OpenImageIO/imagebufalgo_util.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,18 @@ enum IBAprep_flags {
250250

251251

252252

253-
// DEPRECATED(2.3): Prefer TypeDesc::basetype_merge().
254-
TypeDesc::BASETYPE OIIO_API type_merge (TypeDesc::BASETYPE a, TypeDesc::BASETYPE b);
253+
OIIO_DEPRECATED("Use TypeDesc::basetype_merge [2.3]")
254+
inline TypeDesc::BASETYPE type_merge (TypeDesc::BASETYPE a, TypeDesc::BASETYPE b)
255+
{
256+
return TypeDesc::basetype_merge(a, b);
257+
}
255258

256-
// DEPRECATED(2.3): Prefer TypeDesc::basetype_merge().
259+
OIIO_DEPRECATED("Use TypeDesc::basetype_merge [2.3]")
257260
inline TypeDesc type_merge (TypeDesc a, TypeDesc b) {
258261
return TypeDesc::basetype_merge(a, b);
259262
}
260263

261-
// DEPRECATED(2.3): Prefer TypeDesc::basetype_merge().
264+
OIIO_DEPRECATED("Use TypeDesc::basetype_merge [2.3]")
262265
inline TypeDesc type_merge (TypeDesc a, TypeDesc b, TypeDesc c)
263266
{
264267
return TypeDesc::basetype_merge(TypeDesc::basetype_merge(a,b), c);

src/include/OpenImageIO/paramlist.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ class OIIO_UTIL_API ParamValueSpan : public cspan<ParamValue> {
530530
// - operator[int]
531531
// - begin(), end(), cbegin(), cend()
532532

533+
ParamValueSpan() = default;
534+
533535
ParamValueSpan(cspan<ParamValue> p)
534536
: cspan<ParamValue>(p)
535537
{

src/include/OpenImageIO/typedesc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ struct OIIO_UTIL_API TypeDesc {
335335
/// guess for one that can handle both without any loss of range or
336336
/// precision.
337337
static BASETYPE basetype_merge(TypeDesc a, TypeDesc b);
338+
static BASETYPE basetype_merge(TypeDesc a, TypeDesc b, TypeDesc c) {
339+
return basetype_merge(basetype_merge(a, b), c);
340+
}
338341

339342
#if OIIO_DISABLE_DEPRECATED < OIIO_MAKE_VERSION(1,8,0) && OIIO_VERSION_LESS(2,7,0) && !defined(OIIO_DOXYGEN)
340343
// DEPRECATED(1.8): These static const member functions were mildly

src/libOpenImageIO/color_ocio.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,33 +2649,6 @@ ImageBufAlgo::ociodisplay(const ImageBuf& src, string_view display,
26492649

26502650

26512651

2652-
// DEPRECATED(2.5)
2653-
bool
2654-
ImageBufAlgo::ociodisplay(ImageBuf& dst, const ImageBuf& src,
2655-
string_view display, string_view view,
2656-
string_view from, string_view looks, bool unpremult,
2657-
string_view key, string_view value,
2658-
const ColorConfig* colorconfig, ROI roi, int nthreads)
2659-
{
2660-
return ociodisplay(dst, src, display, view, from, looks, unpremult, false,
2661-
key, value, colorconfig, roi, nthreads);
2662-
}
2663-
2664-
2665-
2666-
// DEPRECATED(2.5)
2667-
ImageBuf
2668-
ImageBufAlgo::ociodisplay(const ImageBuf& src, string_view display,
2669-
string_view view, string_view from, string_view looks,
2670-
bool unpremult, string_view key, string_view value,
2671-
const ColorConfig* colorconfig, ROI roi, int nthreads)
2672-
{
2673-
return ociodisplay(src, display, view, from, looks, unpremult, false, key,
2674-
value, colorconfig, roi, nthreads);
2675-
}
2676-
2677-
2678-
26792652
bool
26802653
ImageBufAlgo::ociofiletransform(ImageBuf& dst, const ImageBuf& src,
26812654
string_view name, bool unpremult, bool inverse,

src/libOpenImageIO/compute_test.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,10 @@ main(int argc, char* argv[])
271271
float green[3] = { 0, 1, 0 };
272272
float blue[3] = { 0, 0, 1 };
273273
float black[3] = { 0, 0, 0 };
274-
ImageBufAlgo::fill(imgA, red, green, red, green);
275-
ImageBufAlgo::fill(imgB, blue, blue, black, black);
274+
ImageBufAlgo::fill(imgA, cspan<float>(red), cspan<float>(green),
275+
cspan<float>(red), cspan<float>(green));
276+
ImageBufAlgo::fill(imgB, cspan<float>(blue), cspan<float>(blue),
277+
cspan<float>(black), cspan<float>(black));
276278
// imgA.write ("A.exr");
277279
// imgB.write ("B.exr");
278280

src/libOpenImageIO/imagebuf_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ ImageBuf_test_appbuffer_strided()
248248
// Wrap the whole buffer, fill with green
249249
ImageBuf wrapped(ImageSpec(res, res, nchans, TypeFloat), mem);
250250
const float green[nchans] = { 0.0f, 1.0f, 0.0f };
251-
ImageBufAlgo::fill(wrapped, green);
251+
ImageBufAlgo::fill(wrapped, cspan<float>(green));
252252
float color[nchans] = { -1, -1, -1 };
253253
OIIO_CHECK_ASSERT(ImageBufAlgo::isConstantColor(wrapped, 0.0f, color)
254254
&& color[0] == 0.0f && color[1] == 1.0f
@@ -260,7 +260,7 @@ ImageBuf_test_appbuffer_strided()
260260
2 * nchans * sizeof(float) /* every other pixel */,
261261
2 * res * nchans * sizeof(float) /* ever other line */);
262262
const float red[nchans] = { 1.0f, 0.0f, 0.0f };
263-
ImageBufAlgo::fill(strided, red);
263+
ImageBufAlgo::fill(strided, cspan<float>(red));
264264

265265
// The strided IB ought to look all-red
266266
OIIO_CHECK_ASSERT(ImageBufAlgo::isConstantColor(strided, 0.0f, color)
@@ -409,7 +409,7 @@ test_read_channel_subset()
409409
// FIrst, write a test image with 6 channels
410410
static float color6[] = { 0.6f, 0.5f, 0.4f, 0.3f, 0.2f, 0.1f };
411411
ImageBuf A(ImageSpec(2, 2, 6, TypeDesc::FLOAT));
412-
ImageBufAlgo::fill(A, color6);
412+
ImageBufAlgo::fill(A, cspan<float>(color6));
413413
A.write("sixchans.tif");
414414
std::cout << " Start with image:\n";
415415
print(A);

src/libOpenImageIO/imagebufalgo.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -761,15 +761,6 @@ ImageBufAlgo::perpixel_op(const ImageBuf& srcA, const ImageBuf& srcB,
761761

762762

763763

764-
// DEPRECATED(2.3): Replaced by TypeDesc::type_merge(BASETYPE,BASETYPE)
765-
TypeDesc::BASETYPE
766-
ImageBufAlgo::type_merge(TypeDesc::BASETYPE a, TypeDesc::BASETYPE b)
767-
{
768-
return TypeDesc::basetype_merge(a, b);
769-
}
770-
771-
772-
773764
template<typename DSTTYPE, typename SRCTYPE>
774765
static bool
775766
convolve_(ImageBuf& dst, const ImageBuf& src, const ImageBuf& kernel,
@@ -1618,7 +1609,8 @@ ImageBufAlgo::fillholes_pushpull(ImageBuf& dst, const ImageBuf& src, ROI roi,
16181609
ImageSpec smallspec(w, h, src.nchannels(), TypeDesc::FLOAT);
16191610
smallspec.alpha_channel = topspec.alpha_channel;
16201611
ImageBuf* small = new ImageBuf(smallspec);
1621-
ImageBufAlgo::resize(*small, *pyramid.back(), "triangle");
1612+
ImageBufAlgo::resize(*small, *pyramid.back(),
1613+
{ { "filtername", "triangle" } });
16221614
divide_by_alpha(*small, get_roi(smallspec), nthreads);
16231615
pyramid.emplace_back(small);
16241616
// small->write(Strutil::fmt::format("push{:04d}.exr", small->spec().width));
@@ -1632,7 +1624,7 @@ ImageBufAlgo::fillholes_pushpull(ImageBuf& dst, const ImageBuf& src, ROI roi,
16321624
for (int i = (int)pyramid.size() - 2; i >= 0; --i) {
16331625
ImageBuf &big(*pyramid[i]), &small(*pyramid[i + 1]);
16341626
ImageBuf blowup(big.spec());
1635-
ImageBufAlgo::resize(blowup, small, "triangle");
1627+
ImageBufAlgo::resize(blowup, small, { { "filtername", "triangle" } });
16361628
ImageBufAlgo::over(big, big, blowup);
16371629
// big.write(Strutil::sprintf("pull{:04}.exr", big.spec().width));
16381630
}

0 commit comments

Comments
 (0)