Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-11-06 19:49:09 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-11-06 20:08:25 +0300
commit16732def37c5a66f3ea28dbe247b09cc6bca6677 (patch)
tree5d14f5c920a1411e336bd80b12becbb3f73de19a /source/blender/imbuf
parent88926375a0e4e45f72c87b9e487c060ddd3c9216 (diff)
Cleanup: Clang-Tidy modernize-use-nullptr
Replace `NULL` with `nullptr` in C++ code. No functional changes.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp2
-rw-r--r--source/blender/imbuf/intern/dds/Image.cpp4
-rw-r--r--source/blender/imbuf/intern/dds/dds_api.cpp26
-rw-r--r--source/blender/imbuf/intern/oiio/openimageio_api.cpp24
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp84
5 files changed, 70 insertions, 70 deletions
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index 3e459934db7..37e30d30e2c 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -1130,7 +1130,7 @@ void *DirectDrawSurface::readData(uint &rsize)
if (stream.failed) {
free(data);
- data = NULL;
+ data = nullptr;
rsize = 0;
}
diff --git a/source/blender/imbuf/intern/dds/Image.cpp b/source/blender/imbuf/intern/dds/Image.cpp
index 4cfd7178f29..7958a586c7d 100644
--- a/source/blender/imbuf/intern/dds/Image.cpp
+++ b/source/blender/imbuf/intern/dds/Image.cpp
@@ -32,7 +32,7 @@
#include <stdio.h> /* printf */
-Image::Image() : m_width(0), m_height(0), m_format(Format_RGB), m_data(NULL)
+Image::Image() : m_width(0), m_height(0), m_format(Format_RGB), m_data(nullptr)
{
}
@@ -52,7 +52,7 @@ void Image::allocate(uint w, uint h)
void Image::free()
{
delete[] m_data;
- m_data = NULL;
+ m_data = nullptr;
}
uint Image::width() const
diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp
index 1d29dd4a26b..e620c968f1c 100644
--- a/source/blender/imbuf/intern/dds/dds_api.cpp
+++ b/source/blender/imbuf/intern/dds/dds_api.cpp
@@ -47,10 +47,10 @@ int imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/)
return 0; /* todo: finish this function */
/* check image buffer */
- if (ibuf == 0) {
+ if (ibuf == nullptr) {
return 0;
}
- if (ibuf->rect == 0) {
+ if (ibuf->rect == nullptr) {
return 0;
}
@@ -91,7 +91,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
int flags,
char colorspace[IM_MAX_SPACE])
{
- struct ImBuf *ibuf = NULL;
+ struct ImBuf *ibuf = nullptr;
DirectDrawSurface dds((unsigned char *)mem, size); /* reads header */
unsigned char bits_per_pixel;
unsigned int *rect;
@@ -100,7 +100,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
int col;
unsigned char *cp = (unsigned char *)&col;
Color32 pixel;
- Color32 *pixels = 0;
+ Color32 *pixels = nullptr;
/* OCIO_TODO: never was able to save DDS, so can't test loading
* but profile used to be set to sRGB and can't see rect_float here, so
@@ -109,27 +109,27 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
if (!imb_is_a_dds(mem)) {
- return 0;
+ return nullptr;
}
/* check if DDS is valid and supported */
if (!dds.isValid()) {
/* no need to print error here, just testing if it is a DDS */
if (flags & IB_test) {
- return 0;
+ return nullptr;
}
printf("DDS: not valid; header follows\n");
dds.printInfo();
- return 0;
+ return nullptr;
}
if (!dds.isSupported()) {
printf("DDS: format not supported\n");
- return 0;
+ return nullptr;
}
if ((dds.width() > 65535) || (dds.height() > 65535)) {
printf("DDS: dimensions too large\n");
- return 0;
+ return nullptr;
}
/* convert DDS into ImBuf */
@@ -148,8 +148,8 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
}
}
ibuf = IMB_allocImBuf(dds.width(), dds.height(), bits_per_pixel, 0);
- if (ibuf == 0) {
- return 0; /* memory allocation failed */
+ if (ibuf == nullptr) {
+ return nullptr; /* memory allocation failed */
}
ibuf->ftype = IMB_FTYPE_DDS;
@@ -160,7 +160,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
if (!imb_addrectImBuf(ibuf)) {
return ibuf;
}
- if (ibuf->rect == 0) {
+ if (ibuf->rect == nullptr) {
return ibuf;
}
@@ -188,7 +188,7 @@ struct ImBuf *imb_load_dds(const unsigned char *mem,
}
}
else {
- ibuf->dds_data.data = NULL;
+ ibuf->dds_data.data = nullptr;
ibuf->dds_data.size = 0;
}
diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
index 71774b335d7..d62258fbd2f 100644
--- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp
+++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
@@ -101,7 +101,7 @@ static ImBuf *imb_oiio_load_image(
IMB_freeImBuf(ibuf);
}
- return NULL;
+ return nullptr;
}
}
catch (const std::exception &exc) {
@@ -110,7 +110,7 @@ static ImBuf *imb_oiio_load_image(
IMB_freeImBuf(ibuf);
}
- return NULL;
+ return nullptr;
}
/* ImBuf always needs 4 channels */
@@ -141,7 +141,7 @@ static ImBuf *imb_oiio_load_image_float(
IMB_freeImBuf(ibuf);
}
- return NULL;
+ return nullptr;
}
}
catch (const std::exception &exc) {
@@ -150,7 +150,7 @@ static ImBuf *imb_oiio_load_image_float(
IMB_freeImBuf(ibuf);
}
- return NULL;
+ return nullptr;
}
/* ImBuf always needs 4 channels */
@@ -169,7 +169,7 @@ int imb_is_a_photoshop(const char *filename)
".psd",
".pdd",
".psb",
- NULL,
+ nullptr,
};
return BLI_path_extension_check_array(filename, photoshop_extension);
@@ -190,7 +190,7 @@ int imb_save_photoshop(struct ImBuf *ibuf, const char * /*name*/, int flags)
struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspace[IM_MAX_SPACE])
{
- struct ImBuf *ibuf = NULL;
+ struct ImBuf *ibuf = nullptr;
int width, height, components;
bool is_float, is_alpha, is_half;
int basesize;
@@ -199,7 +199,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
/* load image from file through OIIO */
if (imb_is_a_photoshop(filename) == 0) {
- return NULL;
+ return nullptr;
}
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
@@ -208,7 +208,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
if (!in) {
std::cerr << __func__ << ": ImageInput::create() failed:" << std::endl
<< OIIO_NAMESPACE::geterror() << std::endl;
- return NULL;
+ return nullptr;
}
ImageSpec spec, config;
@@ -217,7 +217,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
if (!in->open(filename, spec, config)) {
std::cerr << __func__ << ": ImageInput::open() failed:" << std::endl
<< in->geterror() << std::endl;
- return NULL;
+ return nullptr;
}
if (!is_colorspace_manually_set) {
@@ -248,7 +248,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
if (in) {
in->close();
}
- return NULL;
+ return nullptr;
}
if (is_float) {
@@ -263,7 +263,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
}
if (!ibuf) {
- return NULL;
+ return nullptr;
}
/* ImBuf always needs 4 channels */
@@ -281,7 +281,7 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac
IMB_freeImBuf(ibuf);
}
- return NULL;
+ return nullptr;
}
}
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index 89be0a051c0..70a0585347c 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -407,10 +407,10 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *name, const int flags
{
const int channels = ibuf->channels;
const bool is_alpha = (channels >= 4) && (ibuf->planes == 32);
- const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */
+ const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != nullptr; /* summarize */
const int width = ibuf->x;
const int height = ibuf->y;
- OStream *file_stream = NULL;
+ OStream *file_stream = nullptr;
try {
Header header(width, height);
@@ -514,10 +514,10 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *name, const int flag
{
const int channels = ibuf->channels;
const bool is_alpha = (channels >= 4) && (ibuf->planes == 32);
- const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */
+ const bool is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != nullptr; /* summarize */
const int width = ibuf->x;
const int height = ibuf->y;
- OStream *file_stream = NULL;
+ OStream *file_stream = nullptr;
try {
Header header(width, height);
@@ -551,7 +551,7 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *name, const int flag
int ystride = -xstride * width;
/* last scanline, stride negative */
- float *rect[4] = {NULL, NULL, NULL, NULL};
+ float *rect[4] = {nullptr, nullptr, nullptr, nullptr};
rect[0] = ibuf->rect_float + channels * (height - 1) * width;
rect[1] = (channels >= 2) ? rect[0] + 1 : rect[0];
rect[2] = (channels >= 3) ? rect[0] + 2 : rect[0];
@@ -598,7 +598,7 @@ int imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags)
}
/* when no float rect, we save as half (16 bits is sufficient) */
- if (ibuf->rect_float == NULL) {
+ if (ibuf->rect_float == nullptr) {
return (int)imb_save_openexr_half(ibuf, name, flags);
}
@@ -614,7 +614,7 @@ int imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags)
* - separated with a dot: the Layer name (like "Light1" or "Walls" or "Characters")
*/
-static ListBase exrhandles = {NULL, NULL};
+static ListBase exrhandles = {nullptr, nullptr};
typedef struct ExrHandle {
struct ExrHandle *next, *prev;
@@ -691,7 +691,7 @@ void *IMB_exr_get_handle_name(const char *name)
{
ExrHandle *data = (ExrHandle *)BLI_rfindstring(&exrhandles, name, offsetof(ExrHandle, name));
- if (data == NULL) {
+ if (data == nullptr) {
data = (ExrHandle *)IMB_exr_get_handle();
BLI_strncpy(data->name, name, strlen(name) + 1);
}
@@ -754,8 +754,8 @@ static void imb_exr_insert_view_name(char *name_full, const char *passname, cons
{
BLI_assert(!ELEM(name_full, passname, viewname));
- if (viewname == NULL || viewname[0] == '\0') {
- BLI_strncpy(name_full, passname, sizeof(((ExrChannel *)NULL)->name));
+ if (viewname == nullptr || viewname[0] == '\0') {
+ BLI_strncpy(name_full, passname, sizeof(((ExrChannel *)nullptr)->name));
return;
}
@@ -882,11 +882,11 @@ int IMB_exr_begin_write(void *handle,
delete data->ofile;
delete data->ofile_stream;
- data->ofile = NULL;
- data->ofile_stream = NULL;
+ data->ofile = nullptr;
+ data->ofile_stream = nullptr;
}
- return (data->ofile != NULL);
+ return (data->ofile != nullptr);
}
/* only used for writing temp. render results (not image files)
@@ -951,8 +951,8 @@ void IMB_exrtile_begin_write(
delete data->mpofile;
delete data->ofile_stream;
- data->mpofile = NULL;
- data->ofile_stream = NULL;
+ data->mpofile = nullptr;
+ data->ofile_stream = nullptr;
}
}
@@ -973,8 +973,8 @@ int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *heig
delete data->ifile;
delete data->ifile_stream;
- data->ifile = NULL;
- data->ifile_stream = NULL;
+ data->ifile = nullptr;
+ data->ifile_stream = nullptr;
}
if (data->ifile) {
@@ -989,7 +989,7 @@ int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *heig
for (size_t i = 0; i < channels.size(); i++) {
IMB_exr_add_channel(
- data, NULL, channels[i].name.c_str(), channels[i].view.c_str(), 0, 0, NULL, false);
+ data, nullptr, channels[i].name.c_str(), channels[i].view.c_str(), 0, 0, nullptr, false);
echan = (ExrChannel *)data->channels.last;
echan->m->name = channels[i].name;
@@ -1074,7 +1074,7 @@ float *IMB_exr_channel_rect(void *handle,
return echan->rect;
}
- return NULL;
+ return nullptr;
}
void IMB_exr_clear_channels(void *handle)
@@ -1097,7 +1097,7 @@ void IMB_exr_write_channels(void *handle)
if (data->channels.first) {
const size_t num_pixels = ((size_t)data->width) * data->height;
- half *rect_half = NULL, *current_rect_half = NULL;
+ half *rect_half = nullptr, *current_rect_half = nullptr;
/* We allocate teporary storage for half pixels for all the channels at once. */
if (data->num_half_channels != 0) {
@@ -1138,7 +1138,7 @@ void IMB_exr_write_channels(void *handle)
std::cerr << "OpenEXR-writePixels: ERROR: " << exc.what() << std::endl;
}
/* Free temporary buffers. */
- if (rect_half != NULL) {
+ if (rect_half != nullptr) {
MEM_freeN(rect_half);
}
}
@@ -1323,7 +1323,7 @@ void IMB_exr_multilayer_convert(void *handle,
pass->totchan,
pass->chan_id,
pass->view);
- pass->rect = NULL;
+ pass->rect = nullptr;
}
}
}
@@ -1343,11 +1343,11 @@ void IMB_exr_close(void *handle)
delete data->ofile_stream;
delete data->multiView;
- data->ifile = NULL;
- data->ifile_stream = NULL;
- data->ofile = NULL;
- data->mpofile = NULL;
- data->ofile_stream = NULL;
+ data->ifile = nullptr;
+ data->ifile_stream = nullptr;
+ data->ofile = nullptr;
+ data->mpofile = nullptr;
+ data->ofile_stream = nullptr;
for (chan = (ExrChannel *)data->channels.first; chan; chan = chan->next) {
delete chan->m;
@@ -1491,7 +1491,7 @@ static ExrLayer *imb_exr_get_layer(ListBase *lb, char *layname)
{
ExrLayer *lay = (ExrLayer *)BLI_findstring(lb, layname, offsetof(ExrLayer, name));
- if (lay == NULL) {
+ if (lay == nullptr) {
lay = (ExrLayer *)MEM_callocN(sizeof(ExrLayer), "exr layer");
BLI_addtail(lb, lay);
BLI_strncpy(lay->name, layname, EXR_LAY_MAXNAME);
@@ -1504,7 +1504,7 @@ static ExrPass *imb_exr_get_pass(ListBase *lb, char *passname)
{
ExrPass *pass = (ExrPass *)BLI_findstring(lb, passname, offsetof(ExrPass, name));
- if (pass == NULL) {
+ if (pass == nullptr) {
pass = (ExrPass *)MEM_callocN(sizeof(ExrPass), "exr pass");
if (STREQ(passname, "Combined")) {
@@ -1546,7 +1546,7 @@ static ExrHandle *imb_exr_begin_read_mem(IStream &file_stream,
for (size_t i = 0; i < channels.size(); i++) {
IMB_exr_add_channel(
- data, NULL, channels[i].name.c_str(), channels[i].view.c_str(), 0, 0, NULL, false);
+ data, nullptr, channels[i].name.c_str(), channels[i].view.c_str(), 0, 0, nullptr, false);
echan = (ExrChannel *)data->channels.last;
echan->m->name = channels[i].name;
@@ -1588,7 +1588,7 @@ static ExrHandle *imb_exr_begin_read_mem(IStream &file_stream,
if (echan) {
printf("error, too many channels in one pass: %s\n", echan->m->name.c_str());
IMB_exr_close(data);
- return NULL;
+ return nullptr;
}
/* with some heuristics, try to merge the channels in buffers */
@@ -1723,7 +1723,7 @@ static int exr_has_rgb(MultiPartInputFile &file, const char *rgb_channels[3])
{
/* Common names for RGB-like channels in order. */
static const char *channel_names[] = {
- "R", "Red", "G", "Green", "B", "Blue", "AR", "RA", "AG", "GA", "AB", "BA", NULL};
+ "R", "Red", "G", "Green", "B", "Blue", "AR", "RA", "AG", "GA", "AB", "BA", nullptr};
const Header &header = file.header(0);
int num_channels = 0;
@@ -1746,26 +1746,26 @@ static bool exr_has_luma(MultiPartInputFile &file)
* optionally it could be also channels for chromas called BY and RY.
*/
const Header &header = file.header(0);
- return header.channels().findChannel("Y") != NULL;
+ return header.channels().findChannel("Y") != nullptr;
}
static bool exr_has_chroma(MultiPartInputFile &file)
{
const Header &header = file.header(0);
- return header.channels().findChannel("BY") != NULL &&
- header.channels().findChannel("RY") != NULL;
+ return header.channels().findChannel("BY") != nullptr &&
+ header.channels().findChannel("RY") != nullptr;
}
static bool exr_has_zbuffer(MultiPartInputFile &file)
{
const Header &header = file.header(0);
- return !(header.channels().findChannel("Z") == NULL);
+ return !(header.channels().findChannel("Z") == nullptr);
}
static bool exr_has_alpha(MultiPartInputFile &file)
{
const Header &header = file.header(0);
- return !(header.channels().findChannel("A") == NULL);
+ return !(header.channels().findChannel("A") == nullptr);
}
static bool exr_is_half_float(MultiPartInputFile &file)
@@ -1895,12 +1895,12 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
int flags,
char colorspace[IM_MAX_SPACE])
{
- struct ImBuf *ibuf = NULL;
- IMemStream *membuf = NULL;
- MultiPartInputFile *file = NULL;
+ struct ImBuf *ibuf = nullptr;
+ IMemStream *membuf = nullptr;
+ MultiPartInputFile *file = nullptr;
if (imb_is_a_openexr(mem) == 0) {
- return NULL;
+ return nullptr;
}
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT);
@@ -2084,7 +2084,7 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
delete file;
delete membuf;
- return 0;
+ return nullptr;
}
}