Cleanup: use doxygen style doc-strings for IMB

This commit is contained in:
Campbell Barton
2025-10-12 01:12:52 +00:00
parent 523322f241
commit ffa750fd5e
7 changed files with 97 additions and 65 deletions

View File

@@ -34,14 +34,18 @@ using ColorSpace = blender::ocio::ColorSpace;
using ColorManagedDisplay = blender::ocio::Display;
enum ColorManagedDisplaySpace {
/* Convert to display space for drawing. This will included emulation of the
* chosen display for an extended sRGB buffer. */
/**
* Convert to display space for drawing. This will included emulation of the
* chosen display for an extended sRGB buffer.
*/
DISPLAY_SPACE_DRAW,
/* Convert to display space for file output. Note image and video have different
* conventions for HDR brightness, so there is a distinction. */
/**
* Convert to display space for file output. Note image and video have different
* conventions for HDR brightness, so there is a distinction.
*/
DISPLAY_SPACE_IMAGE_OUTPUT,
DISPLAY_SPACE_VIDEO_OUTPUT,
/* Convert to display space for inspecting color values as text in the UI. */
/** Convert to display space for inspecting color values as text in the UI. */
DISPLAY_SPACE_COLOR_INSPECTION,
};
@@ -75,11 +79,15 @@ bool IMB_colormanagement_space_name_is_data(const char *name);
bool IMB_colormanagement_space_name_is_scene_linear(const char *name);
bool IMB_colormanagement_space_name_is_srgb(const char *name);
/* Get binary ICC profile contents for a colorspace.
* For describing the colorspace for standard dynamic range image files. */
/**
* Get binary ICC profile contents for a color-space.
* For describing the color-space for standard dynamic range image files.
*/
blender::Vector<char> IMB_colormanagement_space_to_icc_profile(const ColorSpace *colorspace);
/* Get CICP code for colorspace.
* For describing the colorspace of videos and high dynamic range image files. */
/**
* Get CICP code for color-space.
* For describing the color-space of videos and high dynamic range image files.
*/
bool IMB_colormanagement_space_to_cicp(const ColorSpace *colorspace,
const ColorManagedFileOutput output,
const bool rgb_matrix,
@@ -87,8 +95,10 @@ bool IMB_colormanagement_space_to_cicp(const ColorSpace *colorspace,
const ColorSpace *IMB_colormanagement_space_from_cicp(const int cicp[4],
const ColorManagedFileOutput output);
/* Get identifier for colorspaces that works with multiple OpenColorIO configurations,
* as defined by the ASWF Color Interop Forum. */
/**
* Get identifier for color-spaces that works with multiple OpenColorIO configurations,
* as defined by the ASWF Color Interop Forum.
*/
blender::StringRefNull IMB_colormanagement_space_get_interop_id(const ColorSpace *colorspace);
const ColorSpace *IMB_colormanagement_space_from_interop_id(blender::StringRefNull interop_id);

View File

@@ -54,7 +54,7 @@ ImBuf *IMB_load_image_from_filepath(const char *filepath,
*/
bool IMB_save_image(ImBuf *ibuf, const char *filepath, const int flags);
/*
/**
* Test image file.
*/
bool IMB_test_image(const char *filepath);
@@ -62,7 +62,7 @@ bool IMB_test_image_type_matches(const char *filepath, int filetype);
int IMB_test_image_type_from_memory(const unsigned char *buf, size_t buf_size);
int IMB_test_image_type(const char *filepath);
/*
/**
* Load thumbnail image.
*/
enum class IMBThumbLoadFlags {
@@ -78,7 +78,7 @@ ImBuf *IMB_thumb_load_image(const char *filepath,
char colorspace[IM_MAX_SPACE],
const IMBThumbLoadFlags load_flags = IMBThumbLoadFlags::Zero);
/*
/**
* Allocate and free image buffer.
*/
ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags);
@@ -448,7 +448,7 @@ void IMB_alpha_under_color_byte(unsigned char *rect, int x, int y, const float b
void IMB_flipx(ImBuf *ibuf);
void IMB_flipy(ImBuf *ibuf);
/* Rotate by 90 degree increments. Returns true if the ImBuf is altered. */
/** Rotate by 90 degree increments. Returns true if the ImBuf is altered. */
bool IMB_rotate_orthogonal(ImBuf *ibuf, int degrees);
/* Pre-multiply alpha. */
@@ -514,8 +514,10 @@ void IMB_free_float_pixels(ImBuf *ibuf);
/** Deallocate all CPU side data storage (byte, float, encoded). */
void IMB_free_all_data(ImBuf *ibuf);
/* Free the GPU textures of the given image buffer, leaving the CPU buffers unchanged.
* The ibuf can be nullptr, in which case the function does nothing. */
/**
* Free the GPU textures of the given image buffer, leaving the CPU buffers unchanged.
* The ibuf can be nullptr, in which case the function does nothing.
*/
void IMB_free_gpu_textures(ImBuf *ibuf);
/**

View File

@@ -100,13 +100,13 @@ enum eImBufFlags {
* faster since it avoids a memory clear. */
IB_uninitialized_pixels = 1 << 10,
/** indicates whether image on disk have premul alpha */
/** Indicates whether image on disk have pre-multiplied alpha. */
IB_alphamode_premul = 1 << 12,
/** if this flag is set, alpha mode would be guessed from file */
/** If this flag is set, alpha mode would be guessed from file. */
IB_alphamode_detect = 1 << 13,
/* alpha channel is unrelated to RGB and should not affect it */
/** Alpha channel is unrelated to RGB and should not affect it. */
IB_alphamode_channel_packed = 1 << 14,
/** ignore alpha on load and substitute it with 1.0f */
/** Ignore alpha on load and substitute it with 1.0f. */
IB_alphamode_ignore = 1 << 15,
IB_thumbnail = 1 << 16,
};
@@ -117,15 +117,21 @@ enum eImBufFlags {
/** \name ImBuf buffer storage
* \{ */
/* Specialization of an ownership whenever a bare pointer is provided to the ImBuf buffers
* assignment API. */
/**
* Specialization of an ownership whenever a bare pointer is provided to the ImBuf buffers
* assignment API.
*/
enum ImBufOwnership {
/* The ImBuf simply shares pointer with data owned by someone else, and will not perform any
* memory management when the ImBuf frees the buffer. */
/**
* The ImBuf simply shares pointer with data owned by someone else, and will not perform any
* memory management when the ImBuf frees the buffer.
*/
IB_DO_NOT_TAKE_OWNERSHIP = 0,
/* The ImBuf takes ownership of the buffer data, and will use MEM_freeN() to free this memory
* when the ImBuf needs to free the data. */
/**
* The ImBuf takes ownership of the buffer data, and will use MEM_freeN() to free this memory
* when the ImBuf needs to free the data.
*/
IB_TAKE_OWNERSHIP = 1,
};
@@ -164,12 +170,15 @@ struct ImBufFloatBuffer {
};
struct ImBufGPU {
/* Texture which corresponds to the state of the ImBug on the GPU.
/**
* Texture which corresponds to the state of the ImBug on the GPU.
*
* Allocation is supposed to happen outside of the ImBug module from a proper GPU context.
* De-referencing the ImBuf or its GPU texture can happen from any state. */
/* TODO(sergey): This should become a list of textures, to support having high-res ImBuf on GPU
* without hitting hardware limitations. */
* De-referencing the ImBuf or its GPU texture can happen from any state.
*
* TODO(@sergey): This should become a list of textures, to support having high-res ImBuf on GPU
* without hitting hardware limitations.
*/
blender::gpu::Texture *texture;
};
@@ -214,7 +223,7 @@ struct ImBuf {
*/
ImBufFloatBuffer float_buffer;
/* Image buffer on the GPU. */
/** Image buffer on the GPU. */
ImBufGPU gpu;
/** Resolution in pixels per meter. Multiply by `0.0254` for DPI. */
@@ -240,7 +249,7 @@ struct ImBuf {
ImbFormatOptions foptions;
/** The absolute file path associated with this image. */
char filepath[IMB_FILEPATH_SIZE];
/* For movie files, the frame number loaded from the file. */
/** For movie files, the frame number loaded from the file. */
int fileframe;
/** reference counter for multiple users */
@@ -262,14 +271,13 @@ struct ImBuf {
int colormanage_flag;
rcti invalid_rect;
/* information for compressed textures */
/** Information for compressed textures. */
DDSData dds_data;
};
/**
* \brief userflags: Flags used internally by blender for image-buffers.
*/
enum {
/** image needs to be saved is not the same as filename */
IB_BITMAPDIRTY = (1 << 1),

View File

@@ -57,6 +57,6 @@ void IMB_metadata_set_field(IDProperty *metadata, const char *key, const char *v
void IMB_metadata_copy(ImBuf *ibuf_dst, const ImBuf *ibuf_src);
/* Invoke callback for every value stored in the metadata. */
/** Invoke callback for every value stored in the metadata. */
using IMBMetadataForeachCb = void (*)(const char *field, const char *value, void *userdata);
void IMB_metadata_foreach(const ImBuf *ibuf, IMBMetadataForeachCb callback, void *userdata);

View File

@@ -4,14 +4,14 @@
/** \file
* \ingroup imbuf
*
* API for reading and writing multi-layer EXR files.
*/
#pragma once
#include "BLI_string_ref.hh"
/* API for reading and writing multi-layer EXR files. */
/* XXX layer+pass name max 64? */
#define EXR_LAY_MAXNAME 64
#define EXR_PASS_MAXNAME 64

View File

@@ -58,11 +58,11 @@ struct ImFileType {
int default_save_role;
};
/* Color space information provided by the file. */
/** Color space information provided by the file. */
struct ImFileColorSpace {
/* Color space from metadata. */
/** Color space from metadata. */
char metadata_colorspace[IM_MAX_SPACE] = "";
/* Is image HDR with range potentially outside 0..1? */
/** Is image HDR with range potentially outside 0..1? */
bool is_hdr_float = false;
};

View File

@@ -200,9 +200,10 @@ class IMMapStream : public Imf::IStream {
imb_mmap_unlock();
}
/* This is implementing regular `read`, not `readMemoryMapped`, because DWAA and DWAB
* decompressors load on unaligned offsets. Therefore we can't avoid the memory copy. */
/**
* This is implementing regular `read`, not `readMemoryMapped`, because DWAA and DWAB
* decompressors load on unaligned offsets. Therefore we can't avoid the memory copy.
*/
bool read(char c[], int n) override
{
if (_exrpos + n > _exrsize) {
@@ -775,29 +776,35 @@ bool imb_save_openexr(ImBuf *ibuf, const char *filepath, int flags)
* - separated with a dot: the Layer name (like "Light1" or "Walls" or "Characters")
*/
/* flattened out channel */
/** Flattened out channel. */
struct ExrChannel {
/* Name and number of the part. */
/** Name and number of the part. */
std::string part_name;
int part_number = 0;
/* Full name of the chanel. */
/** Full name of the chanel. */
std::string name;
/* Name as stored in the header. */
/** Name as stored in the header. */
std::string internal_name;
/* Channel view. */
/** Channel view. */
std::string view;
/* Colorspace. */
/** Color-space. */
const ColorSpace *colorspace;
int xstride = 0, ystride = 0; /* step to next pixel, to next scan-line. */
float *rect = nullptr; /* first pointer to write in */
char chan_id = 0; /* quick lookup of channel char */
bool use_half_float = false; /* when saving use half float for file storage */
/** Step to next pixel. */
int xstride = 0;
/** Step to next scan-line. */
int ystride = 0;
/** First pointer to write in */
float *rect = nullptr;
/** Quick lookup of channel char */
char chan_id = 0;
/** When saving use half float for file storage. */
bool use_half_float = false;
};
/* hierarchical; layers -> passes -> channels[] */
/** Hierarchical; layers -> passes -> channels[]. */
struct ExrPass {
~ExrPass()
{
@@ -812,7 +819,8 @@ struct ExrPass {
ExrChannel *chan[EXR_PASS_MAXCHAN] = {};
char chan_id[EXR_PASS_MAXCHAN] = {};
std::string internal_name; /* Name with no view. */
/** Name with no view. */
std::string internal_name;
std::string view;
};
@@ -840,8 +848,10 @@ struct ExrHandle {
StringVector views;
blender::Vector<ExrChannel> channels; /* flattened out channels. */
blender::Vector<ExrLayer> layers; /* layers and passes. */
/** Flattened out channels. */
blender::Vector<ExrChannel> channels;
/** Layers and passes. */
blender::Vector<ExrLayer> layers;
};
static bool imb_exr_multilayer_parse_channels_from_file(ExrHandle *handle);
@@ -1580,8 +1590,10 @@ static bool exr_has_xyz_channels(ExrHandle *exr_handle)
return x_found && y_found && z_found;
}
/* Replacement for OpenEXR GetChannelsInMultiPartFile, that also handles the
* case where parts are used for passes instead of multiview. */
/**
* Replacement for OpenEXR GetChannelsInMultiPartFile, that also handles the
* case where parts are used for passes instead of multi-view.
*/
static blender::Vector<ExrChannel> exr_channels_in_multi_part_file(const MultiPartInputFile &file,
const bool parse_layers)
{
@@ -1592,14 +1604,14 @@ static blender::Vector<ExrChannel> exr_channels_in_multi_part_file(const MultiPa
for (int p = 0; p < file.parts(); p++) {
const ChannelList &c = file.header(p).channels();
/* Parse colorspace. Per part colorspaces are not currently used, but
/* Parse color-space. Per part color-spaces are not currently used, but
* might as well populate them for consistency with writing. */
const ColorSpace *colorspace = imb_exr_part_colorspace(file.header(p));
if (colorspace == nullptr) {
colorspace = global_colorspace;
}
/* There are two ways of storing multiview EXRs:
/* There are two ways of storing multi-view EXRs:
* - Multiple views in part with multiView attribute.
* - Each view in its own part with view attribute. */
const bool has_multiple_views_in_part = hasMultiView(file.header(p));
@@ -1762,7 +1774,7 @@ static bool imb_exr_multilayer_parse_channels_from_file(ExrHandle *handle)
return true;
}
/* creates channels, makes a hierarchy and assigns memory to channels */
/** Creates channels, makes a hierarchy and assigns memory to channels. */
static ExrHandle *imb_exr_begin_read_mem(IStream &file_stream,
MultiPartInputFile &file,
int width,
@@ -1815,7 +1827,7 @@ static void exr_print_filecontents(MultiPartInputFile &file)
}
}
/* For non-multi-layer, map R G B A channel names to something that's in this file. */
/** For non-multi-layer, map R G B A channel names to something that's in this file. */
static const char *exr_rgba_channelname(MultiPartInputFile &file, const char *chan)
{
const ChannelList &channels = file.header(0).channels();
@@ -1937,7 +1949,7 @@ static bool exr_has_multipart_file(MultiPartInputFile &file)
return file.parts() > 1;
}
/* it returns true if the file is multilayer or multiview */
/** It returns true if the file is multi-layer or multi-view. */
static bool imb_exr_is_multi(MultiPartInputFile &file)
{
/* Multipart files are treated as multilayer in blender -