Cleanup: use const vars/args

This commit is contained in:
Campbell Barton
2024-08-21 19:18:55 +10:00
parent 844d6d2df0
commit 5a0e8317f4
8 changed files with 44 additions and 40 deletions

View File

@@ -316,7 +316,7 @@ static void gwl_window_cursor_custom_store(GWL_WindowCursorCustomShape &ccs,
ccs.can_invert_color = can_invert_color;
}
static GHOST_TSuccess gwl_window_cursor_custom_load(GWL_WindowCursorCustomShape &ccs,
static GHOST_TSuccess gwl_window_cursor_custom_load(const GWL_WindowCursorCustomShape &ccs,
GHOST_SystemWayland *system)
{
return system->cursor_shape_custom_set(ccs.bitmap,
@@ -2892,7 +2892,7 @@ bool GHOST_WindowWayland::outputs_leave(GWL_Output *output)
#ifdef USE_EVENT_BACKGROUND_THREAD
void GHOST_WindowWayland::pending_actions_handle()
const void GHOST_WindowWayland::pending_actions_handle()
{
/* Caller must lock `server_mutex`, while individual actions could lock,
* it's simpler to lock once when handling all window actions. */

View File

@@ -199,7 +199,7 @@ class GHOST_WindowWayland : public GHOST_Window {
void outputs_changed_update_scale_tag();
#ifdef USE_EVENT_BACKGROUND_THREAD
void pending_actions_handle();
const void pending_actions_handle();
#endif
private:

View File

@@ -125,7 +125,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filepath, int use_cineon
for (y = 0; y < ibuf->y; y++) {
float *dst_ptr = fbuf + 4 * ((ibuf->y - y - 1) * ibuf->x);
float *src_ptr = ibuf->float_buffer.data + 4 * (y * ibuf->x);
const float *src_ptr = ibuf->float_buffer.data + 4 * (y * ibuf->x);
memcpy(dst_ptr, src_ptr, 4 * ibuf->x * sizeof(float));
}

View File

@@ -41,7 +41,7 @@ static void fillCineonMainHeader(LogImageFile *cineon,
const char *creator)
{
time_t fileClock;
tm *fileTime;
const tm *fileTime;
int i;
memset(header, 0, sizeof(CineonMainHeader));

View File

@@ -45,7 +45,7 @@ static void fillDpxMainHeader(LogImageFile *dpx,
const char *creator)
{
time_t fileClock;
tm *fileTime;
const tm *fileTime;
memset(header, 0, sizeof(DpxMainHeader));

View File

@@ -64,12 +64,12 @@ static int logImageElementGetData12Packed(LogImageFile *logImage,
static int logImageElementGetData16(LogImageFile *logImage,
const LogImageElement &logElement,
float *data);
static int convertLogElementToRGBA(float *src,
static int convertLogElementToRGBA(const float *src,
float *dst,
LogImageFile *logImage,
const LogImageElement &logElement,
int dstIsLinearRGB);
static int convertRGBAToLogElement(float *src,
static int convertRGBAToLogElement(const float *src,
float *dst,
LogImageFile *logImage,
const LogImageElement &logElement,
@@ -245,7 +245,7 @@ size_t getRowLength(size_t width, const LogImageElement *logElement)
* Data writing
*/
int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB)
int logImageSetDataRGBA(LogImageFile *logImage, const float *data, int dataIsLinearRGB)
{
float *elementData;
int returnValue;
@@ -1222,14 +1222,14 @@ static float *getSrgbToLinLut(const LogImageElement &logElement)
return lut;
}
static int convertRGBA_RGB(float *src,
static int convertRGBA_RGB(const float *src,
float *dst,
LogImageFile *logImage,
const LogImageElement &logElement,
int elementIsSource)
{
uint i;
float *src_ptr = src;
const float *src_ptr = src;
float *dst_ptr = dst;
switch (logElement.transfer) {
@@ -1277,14 +1277,14 @@ static int convertRGBA_RGB(float *src,
}
}
static int convertRGB_RGBA(float *src,
static int convertRGB_RGBA(const float *src,
float *dst,
LogImageFile *logImage,
const LogImageElement &logElement,
int elementIsSource)
{
uint i;
float *src_ptr = src;
const float *src_ptr = src;
float *dst_ptr = dst;
switch (logElement.transfer) {
@@ -1332,14 +1332,14 @@ static int convertRGB_RGBA(float *src,
}
}
static int convertRGBA_RGBA(float *src,
static int convertRGBA_RGBA(const float *src,
float *dst,
LogImageFile *logImage,
const LogImageElement &logElement,
int elementIsSource)
{
uint i;
float *src_ptr = src;
const float *src_ptr = src;
float *dst_ptr = dst;
switch (logElement.transfer) {
@@ -1377,14 +1377,14 @@ static int convertRGBA_RGBA(float *src,
}
}
static int convertABGR_RGBA(float *src,
static int convertABGR_RGBA(const float *src,
float *dst,
LogImageFile *logImage,
const LogImageElement &logElement,
int elementIsSource)
{
uint i;
float *src_ptr = src;
const float *src_ptr = src;
float *dst_ptr = dst;
switch (logElement.transfer) {
@@ -1431,14 +1431,14 @@ static int convertABGR_RGBA(float *src,
}
}
static int convertCbYCr_RGBA(float *src,
static int convertCbYCr_RGBA(const float *src,
float *dst,
LogImageFile *logImage,
const LogImageElement &logElement)
{
uint i;
float conversionMatrix[9], refLowData, y, cb, cr;
float *src_ptr = src;
const float *src_ptr = src;
float *dst_ptr = dst;
if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) {
@@ -1463,14 +1463,14 @@ static int convertCbYCr_RGBA(float *src,
return 0;
}
static int convertCbYCrA_RGBA(float *src,
static int convertCbYCrA_RGBA(const float *src,
float *dst,
LogImageFile *logImage,
const LogImageElement &logElement)
{
uint i;
float conversionMatrix[9], refLowData, y, cb, cr, a;
float *src_ptr = src;
const float *src_ptr = src;
float *dst_ptr = dst;
if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) {
@@ -1496,14 +1496,14 @@ static int convertCbYCrA_RGBA(float *src,
return 0;
}
static int convertCbYCrY_RGBA(float *src,
static int convertCbYCrY_RGBA(const float *src,
float *dst,
LogImageFile *logImage,
const LogImageElement &logElement)
{
uint i;
float conversionMatrix[9], refLowData, y1, y2, cb, cr;
float *src_ptr = src;
const float *src_ptr = src;
float *dst_ptr = dst;
if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) {
@@ -1548,14 +1548,14 @@ static int convertCbYCrY_RGBA(float *src,
return 0;
}
static int convertCbYACrYA_RGBA(float *src,
static int convertCbYACrYA_RGBA(const float *src,
float *dst,
LogImageFile *logImage,
const LogImageElement &logElement)
{
uint i;
float conversionMatrix[9], refLowData, y1, y2, cb, cr, a1, a2;
float *src_ptr = src;
const float *src_ptr = src;
float *dst_ptr = dst;
if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) {
@@ -1602,14 +1602,14 @@ static int convertCbYACrYA_RGBA(float *src,
return 0;
}
static int convertLuminance_RGBA(float *src,
static int convertLuminance_RGBA(const float *src,
float *dst,
LogImageFile *logImage,
const LogImageElement &logElement)
{
uint i;
float conversionMatrix[9], value, refLowData;
float *src_ptr = src;
const float *src_ptr = src;
float *dst_ptr = dst;
if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) {
@@ -1628,14 +1628,14 @@ static int convertLuminance_RGBA(float *src,
return 0;
}
static int convertYA_RGBA(float *src,
static int convertYA_RGBA(const float *src,
float *dst,
LogImageFile *logImage,
const LogImageElement &logElement)
{
uint i;
float conversionMatrix[9], value, refLowData;
float *src_ptr = src;
const float *src_ptr = src;
float *dst_ptr = dst;
if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) {
@@ -1654,7 +1654,7 @@ static int convertYA_RGBA(float *src,
return 0;
}
static int convertLogElementToRGBA(float *src,
static int convertLogElementToRGBA(const float *src,
float *dst,
LogImageFile *logImage,
const LogImageElement &logElement,
@@ -1727,7 +1727,7 @@ static int convertLogElementToRGBA(float *src,
return 0;
}
static int convertRGBAToLogElement(float *src,
static int convertRGBAToLogElement(const float *src,
float *dst,
LogImageFile *logImage,
const LogImageElement &logElement,
@@ -1735,21 +1735,24 @@ static int convertRGBAToLogElement(float *src,
{
uint i;
int rvalue;
float *srgbSrc;
const float *srgbSrc;
float *srgbSrc_alloc;
float *srgbSrc_ptr;
float *src_ptr = src;
const float *src_ptr = src;
float *lut;
if (srcIsLinearRGB != 0) {
/* we need to convert src to sRGB */
srgbSrc = (float *)imb_alloc_pixels(
srgbSrc_alloc = (float *)imb_alloc_pixels(
logImage->width, logImage->height, 4, sizeof(float), false, __func__);
if (srgbSrc == nullptr) {
if (srgbSrc_alloc == nullptr) {
return 1;
}
memcpy(srgbSrc, src, 4 * size_t(logImage->width) * size_t(logImage->height) * sizeof(float));
srgbSrc_ptr = srgbSrc;
memcpy(srgbSrc_alloc,
src,
4 * size_t(logImage->width) * size_t(logImage->height) * sizeof(float));
srgbSrc_ptr = srgbSrc_alloc;
/* convert data from Linear RGB to sRGB via lut */
lut = getLinToSrgbLut(logElement);
@@ -1761,6 +1764,7 @@ static int convertRGBAToLogElement(float *src,
src_ptr++;
}
MEM_freeN(lut);
srgbSrc = srgbSrc_alloc;
}
else {
srgbSrc = src;
@@ -1790,7 +1794,7 @@ static int convertRGBAToLogElement(float *src,
}
if (srcIsLinearRGB != 0) {
MEM_freeN(srgbSrc);
MEM_freeN(srgbSrc_alloc);
}
return rvalue;

View File

@@ -193,7 +193,7 @@ void logImageClose(LogImageFile *logImage);
/* Data handling */
size_t getRowLength(size_t width, const LogImageElement *logElement);
int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB);
int logImageSetDataRGBA(LogImageFile *logImage, const float *data, int dataIsLinearRGB);
int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB);
/*

View File

@@ -1158,7 +1158,7 @@ void IMB_exr_write_channels(void *handle)
LISTBASE_FOREACH (ExrChannel *, echan, &data->channels) {
/* Writing starts from last scan-line, stride negative. */
if (echan->use_half_float) {
float *rect = echan->rect;
const float *rect = echan->rect;
half *cur = current_rect_half;
for (size_t i = 0; i < num_pixels; i++, cur++) {
*cur = float_to_half_safe(rect[i * echan->xstride]);