Skip to content

Commit

Permalink
Get rid of deprecations
Browse files Browse the repository at this point in the history
Signed-off-by: Larry Gritz <lg@larrygritz.com>
  • Loading branch information
lgritz committed Oct 8, 2024
1 parent 69e35d1 commit 0db386c
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 783 deletions.
2 changes: 1 addition & 1 deletion docs/Deprecations-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ about being deprecated will be removed in the final 3.0 release.
## ustring.h

* Removed old `ustringHash` (which was just an alias for `std::hash<ustring>`,
which should be used instead.
which should be used instead).

## varyingref.h

Expand Down
7 changes: 6 additions & 1 deletion src/include/OpenImageIO/argparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,20 +760,25 @@ class OIIO_UTIL_API ArgParse {
// The format string is followed by a list of pointers to the argument
// variables, just like scanf. A NULL terminates the list. Multiple
// calls to options() will append additional options.
OIIO_DEPRECATED_EXTERNAL("(2.2)")
int options(const char* intro, ...);

// old name
// DEPRECATED(2.2)
OIIO_DEPRECATED_EXTERNAL("(2.2)")
int parse(int argc, const char** argv) { return parse_args(argc, argv); }

// Type for a callback that writes something to the output stream.
OIIO_DEPRECATED_EXTERNAL("(2.2)")
typedef std::function<void(const ArgParse& ap, std::ostream&)> callback_t;
// Set callbacks to run that will print any matter you want as part
// of the verbose usage, before and after the options are detailed.
OIIO_DEPRECATED_EXTERNAL("(2.2)")
void set_preoption_help(callback_t callback);
OIIO_DEPRECATED_EXTERNAL("(2.2)")
void set_postoption_help(callback_t callback);

// DEPRECATED(2.2) synonym for `print_help()`.
OIIO_DEPRECATED_EXTERNAL("(2.2)")
void usage() const { print_help(); }
};

Expand Down
199 changes: 12 additions & 187 deletions src/include/OpenImageIO/imagebufalgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2483,164 +2483,6 @@ bool OIIO_API deep_holdout (ImageBuf &dst, const ImageBuf &src,

#ifndef DOXYGEN_SHOULD_SKIP_THIS

// DEPRECATED(1.9): These are all functions that take raw pointers,
// which we are deprecating as of 1.9, replaced by new versions that
// take span<> for length safety.

OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool fill (ImageBuf &dst, const float *values,
ROI roi={}, int nthreads=0) {
int nc (roi.defined() ? roi.nchannels() : dst.nchannels());
return fill (dst, {values, span_size_t(nc)}, roi, nthreads);
}
OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool fill (ImageBuf &dst, const float *top, const float *bottom,
ROI roi={}, int nthreads=0) {
int nc (roi.defined() ? roi.nchannels() : dst.nchannels());
return fill (dst, {top, span_size_t(nc)}, {bottom, span_size_t(nc)}, roi, nthreads);
}
OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool fill (ImageBuf &dst, const float *topleft, const float *topright,
const float *bottomleft, const float *bottomright,
ROI roi={}, int nthreads=0) {
int nc (roi.defined() ? roi.nchannels() : dst.nchannels());
return fill (dst, {topleft, span_size_t(nc)}, {topright, span_size_t(nc)}, {bottomleft, span_size_t(nc)},
{bottomright, span_size_t(nc)}, roi, nthreads);
}

OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool checker (ImageBuf &dst, int width, int height, int depth,
const float *color1, const float *color2,
int xoffset=0, int yoffset=0, int zoffset=0,
ROI roi={}, int nthreads=0) {
int nc (roi.defined() ? roi.nchannels() : dst.nchannels());
return checker (dst, width, height, depth,
{color1,span_size_t(nc)}, {color2,span_size_t(nc)},
xoffset, yoffset, zoffset, roi, nthreads);
}

OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool add (ImageBuf &dst, const ImageBuf &A, const float *B,
ROI roi={}, int nthreads=0) {
return add (dst, A, {B,A.nchannels()}, roi, nthreads);
}
OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool sub (ImageBuf &dst, const ImageBuf &A, const float *B,
ROI roi={}, int nthreads=0) {
return sub (dst, A, {B,A.nchannels()}, roi, nthreads);
}
OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool absdiff (ImageBuf &dst, const ImageBuf &A, const float *B,
ROI roi={}, int nthreads=0) {
return absdiff (dst, A, cspan<float>(B,span_size_t(A.nchannels())), roi, nthreads);
}
OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool mul (ImageBuf &dst, const ImageBuf &A, const float *B,
ROI roi={}, int nthreads=0) {
return mul (dst, A, {B, int(A.nchannels())}, roi, nthreads);
}
OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool div (ImageBuf &dst, const ImageBuf &A, const float *B,
ROI roi={}, int nthreads=0) {
return div (dst, A, {B, int(A.nchannels())}, roi, nthreads);
}
OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool mad (ImageBuf &dst, const ImageBuf &A, const float *B,
const ImageBuf &C, ROI roi={}, int nthreads=0) {
return mad (dst, A, {B, int(A.nchannels())}, C, roi, nthreads);
}
OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool mad (ImageBuf &dst, const ImageBuf &A, const ImageBuf &B,
const float *C, ROI roi={}, int nthreads=0) {
return mad (dst, A, {C, int(A.nchannels())}, B, roi, nthreads);
}
OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool mad (ImageBuf &dst, const ImageBuf &A, const float *B,
const float *C, ROI roi={}, int nthreads=0) {
return mad (dst, A, {B, int(A.nchannels())}, {C, int(A.nchannels())}, roi, nthreads);
}

OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool pow (ImageBuf &dst, const ImageBuf &A, const float *B,
ROI roi={}, int nthreads=0) {
return pow (dst, A, {B, span_size_t(A.nchannels())}, roi, nthreads);
}

OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool channel_sum (ImageBuf &dst, const ImageBuf &src,
const float *weights=nullptr, ROI roi={},
int nthreads=0) {
return channel_sum (dst, src, {weights, span_size_t(src.nchannels())},
roi, nthreads);
}

OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool channels (ImageBuf &dst, const ImageBuf &src,
int nchannels, const int *channelorder,
const float *channelvalues=nullptr,
const std::string *newchannelnames=nullptr,
bool shuffle_channel_names=false, int nthreads=0) {
return channels (dst, src, nchannels,
{ channelorder, span_size_t(channelorder?nchannels:0) },
{ channelvalues, span_size_t(channelvalues?nchannels:0) },
{ newchannelnames, span_size_t(newchannelnames?nchannels:0) },
shuffle_channel_names, nthreads);
}

OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool clamp (ImageBuf &dst, const ImageBuf &src,
const float *min=nullptr, const float *max=nullptr,
bool clampalpha01 = false,
ROI roi={}, int nthreads=0) {
return clamp (dst, src, { min, span_size_t(min ? src.nchannels() : 0) },
{ max, span_size_t(max ? src.nchannels() : 0) }, clampalpha01,
roi, nthreads);
}

OIIO_DEPRECATED("use version that takes span<> instead of raw pointer (2.0)")
inline bool isConstantColor (const ImageBuf &src, float *color,
ROI roi={}, int nthreads=0) {
int nc = roi.defined() ? std::min(roi.chend,src.nchannels()) : src.nchannels();
return isConstantColor (src, 0.0f, {color, span_size_t(color ? nc : 0) },
roi, nthreads);
}

OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool color_count (const ImageBuf &src, imagesize_t *count,
int ncolors, const float *color,
const float *eps=nullptr,
ROI roi={}, int nthreads=0) {
return color_count (src, count, ncolors,
{ color, span_size_t(ncolors*src.nchannels()) },
eps ? cspan<float>(eps,span_size_t(src.nchannels())) : cspan<float>(),
roi, nthreads);
}

OIIO_DEPRECATED("use version that takes span<> instead of raw pointer (2.0)")
inline bool color_range_check (const ImageBuf &src, imagesize_t *lowcount,
imagesize_t *highcount, imagesize_t *inrangecount,
const float *low, const float *high,
ROI roi={}, int nthreads=0) {
return color_range_check (src, lowcount, highcount, inrangecount,
{low,span_size_t(src.nchannels())}, {high,span_size_t(src.nchannels())},
roi, nthreads);
}

OIIO_DEPRECATED("use version that takes cspan<> instead of raw pointer (2.0)")
inline bool render_text (ImageBuf &dst, int x, int y, string_view text,
int fontsize, string_view fontname,
const float *textcolor) {
return render_text (dst, x, y, text, fontsize, fontname,
{textcolor, textcolor?span_size_t(dst.nchannels()):0});
}

OIIO_DEPRECATED("Use the that takes a span. [2.1]")
inline bool colorconvert (float *color, int nchannels,
const ColorProcessor *processor, bool unpremult) {
return colorconvert ({color,span_size_t(nchannels)}, processor, unpremult);
}


OIIO_DEPRECATED("prefer the kind that takes an `inverse` parameter (2.5)")
inline ImageBuf ociodisplay (const ImageBuf &src,
string_view display, string_view view,
Expand Down Expand Up @@ -2688,34 +2530,34 @@ bool OIIO_API warp (ImageBuf &dst, const ImageBuf &src, M33fParam M,
const Filter2D *filter, bool recompute_roi = false,
ImageBuf::WrapMode wrap = ImageBuf::WrapDefault,
ROI roi = {}, int nthreads=0);
OIIO_DEPRECATED("prefer the kind that takes keyword args (2.6)")
OIIO_DEPRECATED("prefer the kind that takes keyword args (3.0)")
inline ImageBuf resize(const ImageBuf &src,
string_view filtername, float filterwidth=0.0f,
ROI roi={}, int nthreads=0) {
return resize(src,{ { "filtername", filtername },
{ "filterwidth", filterwidth } },
roi, nthreads);
}
OIIO_DEPRECATED("prefer the kind that takes keyword args (2.6)")
OIIO_DEPRECATED("prefer the kind that takes keyword args (3.0)")
inline ImageBuf resize(const ImageBuf &src, Filter2D *filter,
ROI roi={}, int nthreads=0) {
return resize(src, { make_pv("filterptr", filter) }, roi, nthreads);
}
OIIO_DEPRECATED("prefer the kind that takes keyword args (2.6)")
OIIO_DEPRECATED("prefer the kind that takes keyword args (3.0)")
inline bool resize (ImageBuf &dst, const ImageBuf &src,
string_view filtername, float filterwidth,
ROI roi={}, int nthreads=0) {
return resize(dst, src, { { "filtername", filtername },
{ "filterwidth", filterwidth } },
roi, nthreads);
}
OIIO_DEPRECATED("prefer the kind that takes keyword args (2.6)")
OIIO_DEPRECATED("prefer the kind that takes keyword args (3.0)")
inline bool resize(ImageBuf &dst, const ImageBuf &src, Filter2D *filter,
ROI roi={}, int nthreads=0) {
return resize(dst, src, { make_pv("filterptr", filter) }, roi, nthreads);
}

OIIO_DEPRECATED("prefer the kind that takes keyword args (2.6)")
OIIO_DEPRECATED("prefer the kind that takes keyword args (3.0)")
inline ImageBuf fit(const ImageBuf &src,
string_view filtername = "", float filterwidth=0.0f,
string_view fillmode="letterbox", bool exact=false,
Expand All @@ -2725,15 +2567,15 @@ inline ImageBuf fit(const ImageBuf &src,
{ "fillmode", fillmode }, { "exact", int(exact) } },
roi, nthreads);
}
OIIO_DEPRECATED("prefer the kind that takes keyword args (2.6)")
OIIO_DEPRECATED("prefer the kind that takes keyword args (3.0)")
inline ImageBuf fit(const ImageBuf &src, Filter2D *filter,
string_view fillmode="letterbox", bool exact=false,
ROI roi={}, int nthreads=0) {
return fit(src, { make_pv("filterptr", filter), { "fillmode", fillmode },
{ "exact", int(exact) } },
roi, nthreads);
}
OIIO_DEPRECATED("prefer the kind that takes keyword args (2.6)")
OIIO_DEPRECATED("prefer the kind that takes keyword args (3.0)")
inline bool fit(ImageBuf &dst, const ImageBuf &src,
string_view filtername = "", float filterwidth=0.0f,
string_view fillmode="letterbox", bool exact=false,
Expand All @@ -2743,7 +2585,7 @@ inline bool fit(ImageBuf &dst, const ImageBuf &src,
{ "fillmode", fillmode }, { "exact", int(exact) } },
roi, nthreads);
}
OIIO_DEPRECATED("prefer the kind that takes keyword args (2.6)")
OIIO_DEPRECATED("prefer the kind that takes keyword args (3.0)")
inline bool fit(ImageBuf &dst, const ImageBuf &src, Filter2D *filter,
string_view fillmode="letterbox", bool exact=false,
ROI roi={}, int nthreads=0) {
Expand All @@ -2753,7 +2595,7 @@ inline bool fit(ImageBuf &dst, const ImageBuf &src, Filter2D *filter,
}

// DEPRECATED(2.3): old versions lacking the "fillmode" parameter
OIIO_DEPRECATED("prefer the kind that takes keyword args (2.6)")
OIIO_DEPRECATED("prefer the kind that takes keyword args (3.0)")
inline ImageBuf fit(const ImageBuf &src,
string_view filtername, float filterwidth,
bool exact, ROI roi={}, int nthreads=0)
Expand All @@ -2763,14 +2605,14 @@ inline ImageBuf fit(const ImageBuf &src,
{ "fillmode", "letterbox" }, { "exact", int(exact) } },
roi, nthreads);
}
OIIO_DEPRECATED("prefer the kind that takes keyword args (2.3)")
OIIO_DEPRECATED("prefer the kind that takes keyword args (3.0)")
inline ImageBuf fit(const ImageBuf &src, Filter2D *filter,
bool exact, ROI roi={}, int nthreads=0) {
return fit(src, { make_pv("filterptr", filter),
{ "fillmode", "letterbox" }, { "exact", int(exact) } },
roi, nthreads);
}
OIIO_DEPRECATED("prefer the kind that takes keyword args (2.3)")
OIIO_DEPRECATED("prefer the kind that takes keyword args (3.0)")
inline bool fit(ImageBuf &dst, const ImageBuf &src,
string_view filtername, float filterwidth,
bool exact, ROI roi={}, int nthreads=0) {
Expand All @@ -2779,7 +2621,7 @@ inline bool fit(ImageBuf &dst, const ImageBuf &src,
{ "fillmode", "letterbox" }, { "exact", int(exact) } },
roi, nthreads);
}
OIIO_DEPRECATED("prefer the kind that takes keyword args (2.3)")
OIIO_DEPRECATED("prefer the kind that takes keyword args (3.0)")
inline bool fit(ImageBuf &dst, const ImageBuf &src, Filter2D *filter,
bool exact, ROI roi={}, int nthreads=0) {
return fit(dst, src,
Expand All @@ -2788,23 +2630,6 @@ inline bool fit(ImageBuf &dst, const ImageBuf &src, Filter2D *filter,
roi, nthreads);
}

OIIO_DEPRECATED("Use isConstantColor with span<float> color")
inline bool isConstantColor (const ImageBuf &src, span<float> color,
ROI roi={}, int nthreads=0) {
return isConstantColor (src, 0.0f, color, roi, nthreads);
}

OIIO_DEPRECATED("Use isConstantChannel with the threshold parameter")
inline bool isConstantChannel (const ImageBuf &src, int channel, float val,
ROI roi, int nthreads=0) {
return isConstantChannel (src, channel, val, 0.0f, roi, nthreads);
}

OIIO_DEPRECATED("Use isMonochrome with the threshold dparameter")
inline bool isMonochrome (const ImageBuf &src, ROI roi, int nthreads=0) {
return isMonochrome (src, 0.0f, roi, nthreads);
}

#endif // DOXYGEN_SHOULD_SKIP_THIS

///////////////////////////////////////////////////////////////////////
Expand Down
14 changes: 8 additions & 6 deletions src/include/OpenImageIO/imagecache.h
Original file line number Diff line number Diff line change
Expand Up @@ -752,14 +752,15 @@ class OIIO_API ImageCache {
bool get_imagespec(ImageHandle* file, Perthread* thread_info,
ImageSpec& spec, int subimage = 0);

/// DEPRECATED old API. Note that the miplevel and native parameters are ignored:
/// it will always get the native spec of miplevel 0. We recommend switching to
/// the new API.
/// DEPRECATED(3.0) old API. Note that the miplevel and native parameters
/// are ignored: it will always get the native spec of miplevel 0. We
/// recommend switching to the new API.
bool get_imagespec(ustring filename, ImageSpec& spec, int subimage,
int miplevel, bool native = false)
{
return get_imagespec(filename, spec, subimage);
}
/// DEPRECATED(3.0) old API.
bool get_imagespec(ImageHandle* file, Perthread* thread_info,
ImageSpec& spec, int subimage, int miplevel,
bool native = false)
Expand Down Expand Up @@ -801,14 +802,15 @@ class OIIO_API ImageCache {
const ImageSpec* imagespec(ImageHandle* file, Perthread* thread_info,
int subimage = 0);

/// DEPRECATED old API. Note that the miplevel and native parameters are ignored:
/// it will always get the native spec of miplevel 0. We recommend switching to
/// the new API.
/// DEPRECATED(3.0) old API. Note that the miplevel and native parameters
/// are ignored: it will always get the native spec of miplevel 0. We
/// recommend switching to the new API.
const ImageSpec* imagespec(ustring filename, int subimage, int miplevel,
bool native = false)
{
return imagespec(filename, subimage);
}
/// DEPRECATED(3.0) old API.
const ImageSpec* imagespec(ImageHandle* file, Perthread* thread_info,
int subimage, int miplevel, bool native = false)
{
Expand Down
8 changes: 8 additions & 0 deletions src/include/OpenImageIO/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@
// [[deprecated(msg)]] instead.
#define OIIO_DEPRECATED(msg) [[deprecated(msg)]]

// OIIO_DEPRECATED_EXTERNAL marks things deprecated for downstream apps, but
// still is allowed for internal use. Generally, this is used when we want to
// deprecate for users but can't quite extract it internally yet.
#ifndef OIIO_INTERNAL
# define OIIO_DEPRECATED_EXTERNAL(msg) [[deprecated(msg)]]
#else
# define OIIO_DEPRECATED_EXTERNAL(msg)
#endif

// OIIO_FALLTHROUGH at the end of a `case` label's statements documents that
// the switch statement case is intentionally falling through to the code
Expand Down
10 changes: 0 additions & 10 deletions src/include/OpenImageIO/ustring.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,16 +669,6 @@ class OIIO_UTIL_API ustring {
return ustring(Strutil::fmt::format(fmt, args...));
}

/// NOTE: Semi-DEPRECATED! This will someday switch to behave like
/// fmt::format (or future std::format) but for now, it is back
/// compatible and equivalent to sprintf.
template<typename... Args>
OIIO_FORMAT_DEPRECATED static ustring format(const char* fmt,
const Args&... args)
{
return ustring(Strutil::format(fmt, args...));
}

/// Concatenate two strings, returning a ustring, implemented carefully
/// to not perform any redundant copies or allocations.
static ustring concat(string_view s, string_view t);
Expand Down
Loading

0 comments on commit 0db386c

Please sign in to comment.