Remove Z Buffer from ImBuf #109687
|
@ -78,7 +78,6 @@ char BKE_ftype_to_imtype(int ftype, const struct ImbFormatOptions *options);
|
||||||
int BKE_imtype_to_ftype(char imtype, struct ImbFormatOptions *r_options);
|
int BKE_imtype_to_ftype(char imtype, struct ImbFormatOptions *r_options);
|
||||||
|
|
||||||
bool BKE_imtype_is_movie(char imtype);
|
bool BKE_imtype_is_movie(char imtype);
|
||||||
bool BKE_imtype_supports_zbuf(char imtype);
|
|
||||||
bool BKE_imtype_supports_compress(char imtype);
|
bool BKE_imtype_supports_compress(char imtype);
|
||||||
bool BKE_imtype_supports_quality(char imtype);
|
bool BKE_imtype_supports_quality(char imtype);
|
||||||
bool BKE_imtype_requires_linear_float(char imtype);
|
bool BKE_imtype_requires_linear_float(char imtype);
|
||||||
|
|
|
@ -2550,7 +2550,7 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *filepath, const ImageFormatData *im
|
||||||
|
|
||||||
BLI_file_ensure_parent_dir_exists(filepath);
|
BLI_file_ensure_parent_dir_exists(filepath);
|
||||||
|
|
||||||
const bool ok = IMB_saveiff(ibuf, filepath, IB_rect | IB_zbuf | IB_zbuffloat);
|
const bool ok = IMB_saveiff(ibuf, filepath, IB_rect);
|
||||||
if (ok == 0) {
|
if (ok == 0) {
|
||||||
perror(filepath);
|
perror(filepath);
|
||||||
}
|
}
|
||||||
|
@ -4320,7 +4320,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
|
||||||
{
|
{
|
||||||
Render *re;
|
Render *re;
|
||||||
RenderView *rv;
|
RenderView *rv;
|
||||||
RenderBuffer *combined_buffer, *z_buffer;
|
RenderBuffer *combined_buffer;
|
||||||
RenderByteBuffer *byte_buffer;
|
RenderByteBuffer *byte_buffer;
|
||||||
float dither;
|
float dither;
|
||||||
int channels, layer, pass;
|
int channels, layer, pass;
|
||||||
|
@ -4382,12 +4382,10 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
|
||||||
if (rv == nullptr) {
|
if (rv == nullptr) {
|
||||||
byte_buffer = &rres.byte_buffer;
|
byte_buffer = &rres.byte_buffer;
|
||||||
combined_buffer = &rres.combined_buffer;
|
combined_buffer = &rres.combined_buffer;
|
||||||
z_buffer = &rres.z_buffer;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
byte_buffer = &rv->byte_buffer;
|
byte_buffer = &rv->byte_buffer;
|
||||||
combined_buffer = &rv->combined_buffer;
|
combined_buffer = &rv->combined_buffer;
|
||||||
z_buffer = &rv->z_buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dither = iuser->scene->r.dither_intensity;
|
dither = iuser->scene->r.dither_intensity;
|
||||||
|
@ -4416,12 +4414,6 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
|
||||||
dither = 0.0f; /* don't dither passes */
|
dither = 0.0f; /* don't dither passes */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (rpass = static_cast<RenderPass *>(rl->passes.first); rpass; rpass = rpass->next) {
|
|
||||||
if (STREQ(rpass->name, RE_PASSNAME_Z) && rpass->view_id == actview) {
|
|
||||||
z_buffer = &rpass->buffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4474,13 +4466,6 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
|
||||||
IMB_assign_float_buffer(ibuf, nullptr, IB_DO_NOT_TAKE_OWNERSHIP);
|
IMB_assign_float_buffer(ibuf, nullptr, IB_DO_NOT_TAKE_OWNERSHIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (z_buffer) {
|
|
||||||
IMB_assign_shared_float_z_buffer(ibuf, z_buffer->data, z_buffer->sharing_info);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
IMB_assign_float_z_buffer(ibuf, nullptr, IB_DO_NOT_TAKE_OWNERSHIP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO(sergey): Make this faster by either simply referencing the stamp
|
/* TODO(sergey): Make this faster by either simply referencing the stamp
|
||||||
* or by changing both ImBuf and RenderResult to use same data type to
|
* or by changing both ImBuf and RenderResult to use same data type to
|
||||||
* store metadata. */
|
* store metadata. */
|
||||||
|
|
|
@ -196,16 +196,6 @@ bool BKE_imtype_is_movie(const char imtype)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BKE_imtype_supports_zbuf(const char imtype)
|
|
||||||
{
|
|
||||||
switch (imtype) {
|
|
||||||
case R_IMF_IMTYPE_IRIZ:
|
|
||||||
case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BKE_imtype_supports_compress(const char imtype)
|
bool BKE_imtype_supports_compress(const char imtype)
|
||||||
{
|
{
|
||||||
switch (imtype) {
|
switch (imtype) {
|
||||||
|
@ -642,11 +632,6 @@ void BKE_image_format_to_imbuf(ImBuf *ibuf, const ImageFormatData *imf)
|
||||||
ibuf->foptions.flag |= OPENEXR_HALF;
|
ibuf->foptions.flag |= OPENEXR_HALF;
|
||||||
}
|
}
|
||||||
ibuf->foptions.flag |= (imf->exr_codec & OPENEXR_COMPRESS);
|
ibuf->foptions.flag |= (imf->exr_codec & OPENEXR_COMPRESS);
|
||||||
|
|
||||||
if (!(imf->flag & R_IMF_FLAG_ZBUF)) {
|
|
||||||
/* Signal for exr saving. */
|
|
||||||
IMB_freezbuffloatImBuf(ibuf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_CINEON
|
#ifdef WITH_CINEON
|
||||||
|
@ -800,9 +785,6 @@ void BKE_image_format_from_imbuf(ImageFormatData *im_format, const ImBuf *imbuf)
|
||||||
if (custom_flags & OPENEXR_COMPRESS) {
|
if (custom_flags & OPENEXR_COMPRESS) {
|
||||||
im_format->exr_codec = R_IMF_EXR_CODEC_ZIP; /* Can't determine compression */
|
im_format->exr_codec = R_IMF_EXR_CODEC_ZIP; /* Can't determine compression */
|
||||||
}
|
}
|
||||||
if (imbuf->float_z_buffer.data) {
|
|
||||||
im_format->flag |= R_IMF_FLAG_ZBUF;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -301,8 +301,6 @@ static void image_save_post(ReportList *reports,
|
||||||
* created. */
|
* created. */
|
||||||
imb_freerectImBuf(ibuf);
|
imb_freerectImBuf(ibuf);
|
||||||
imb_freerectfloatImBuf(ibuf);
|
imb_freerectfloatImBuf(ibuf);
|
||||||
IMB_freezbufImBuf(ibuf);
|
|
||||||
IMB_freezbuffloatImBuf(ibuf);
|
|
||||||
}
|
}
|
||||||
if (ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER)) {
|
if (ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER)) {
|
||||||
ima->source = IMA_SRC_FILE;
|
ima->source = IMA_SRC_FILE;
|
||||||
|
@ -717,7 +715,6 @@ bool BKE_image_render_write_exr(ReportList *reports,
|
||||||
void *exrhandle = IMB_exr_get_handle();
|
void *exrhandle = IMB_exr_get_handle();
|
||||||
const bool half_float = (imf && imf->depth == R_IMF_CHAN_DEPTH_16);
|
const bool half_float = (imf && imf->depth == R_IMF_CHAN_DEPTH_16);
|
||||||
const bool multi_layer = !(imf && imf->imtype == R_IMF_IMTYPE_OPENEXR);
|
const bool multi_layer = !(imf && imf->imtype == R_IMF_IMTYPE_OPENEXR);
|
||||||
const bool write_z = !multi_layer && (imf && (imf->flag & R_IMF_FLAG_ZBUF));
|
|
||||||
const int channels = (!multi_layer && imf && imf->planes == R_IMF_PLANES_RGB) ? 3 : 4;
|
const int channels = (!multi_layer && imf && imf->planes == R_IMF_PLANES_RGB) ? 3 : 4;
|
||||||
Vector<float *> tmp_output_rects;
|
Vector<float *> tmp_output_rects;
|
||||||
|
|
||||||
|
@ -782,12 +779,6 @@ bool BKE_image_render_write_exr(ReportList *reports,
|
||||||
IMB_exr_add_channel(
|
IMB_exr_add_channel(
|
||||||
exrhandle, layname, passname, viewname, 4, 4 * rr->rectx, output_rect + a, half_float);
|
exrhandle, layname, passname, viewname, 4, 4 * rr->rectx, output_rect + a, half_float);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (write_z && rview->z_buffer.data) {
|
|
||||||
const char *layname = (multi_layer) ? "Composite" : "";
|
|
||||||
IMB_exr_add_channel(
|
|
||||||
exrhandle, layname, "Z", viewname, 1, rr->rectx, rview->z_buffer.data, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,9 +794,7 @@ bool BKE_image_render_write_exr(ReportList *reports,
|
||||||
|
|
||||||
LISTBASE_FOREACH (RenderPass *, rp, &rl->passes) {
|
LISTBASE_FOREACH (RenderPass *, rp, &rl->passes) {
|
||||||
/* Skip non-RGBA and Z passes if not using multi layer. */
|
/* Skip non-RGBA and Z passes if not using multi layer. */
|
||||||
if (!multi_layer && !(STREQ(rp->name, RE_PASSNAME_COMBINED) || STREQ(rp->name, "") ||
|
if (!multi_layer && !(STREQ(rp->name, RE_PASSNAME_COMBINED) || STREQ(rp->name, ""))) {
|
||||||
(STREQ(rp->name, RE_PASSNAME_Z) && write_z)))
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,9 +178,6 @@ static void do_versions_image_settings_2_60(Scene *sce)
|
||||||
if (rd->subimtype & R_PREVIEW_JPG) {
|
if (rd->subimtype & R_PREVIEW_JPG) {
|
||||||
imf->flag |= R_IMF_FLAG_PREVIEW_JPG;
|
imf->flag |= R_IMF_FLAG_PREVIEW_JPG;
|
||||||
}
|
}
|
||||||
if (rd->subimtype & R_OPENEXR_ZBUF) {
|
|
||||||
imf->flag |= R_IMF_FLAG_ZBUF;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case R_IMF_IMTYPE_TIFF:
|
case R_IMF_IMTYPE_TIFF:
|
||||||
if (rd->subimtype & R_TIFF_16BIT) {
|
if (rd->subimtype & R_TIFF_16BIT) {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "DNA_lightprobe_types.h"
|
#include "DNA_lightprobe_types.h"
|
||||||
#include "DNA_modifier_types.h"
|
#include "DNA_modifier_types.h"
|
||||||
#include "DNA_movieclip_types.h"
|
#include "DNA_movieclip_types.h"
|
||||||
|
#include "DNA_scene_types.h"
|
||||||
|
|
||||||
#include "DNA_genfile.h"
|
#include "DNA_genfile.h"
|
||||||
|
|
||||||
|
@ -278,5 +279,13 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||||
lightprobe->surfel_density = 1.0f;
|
lightprobe->surfel_density = 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Clear removed "Z Buffer" flag. */
|
||||||
|
{
|
||||||
|
const int R_IMF_FLAG_ZBUF_LEGACY = 1 << 0;
|
||||||
|
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||||
|
scene->r.im_format.flag &= ~R_IMF_FLAG_ZBUF_LEGACY;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ void CompositorNode::convert_to_operations(NodeConverter &converter,
|
||||||
|
|
||||||
NodeInput *image_socket = this->get_input_socket(0);
|
NodeInput *image_socket = this->get_input_socket(0);
|
||||||
NodeInput *alpha_socket = this->get_input_socket(1);
|
NodeInput *alpha_socket = this->get_input_socket(1);
|
||||||
NodeInput *depth_socket = this->get_input_socket(2);
|
|
||||||
|
|
||||||
CompositorOperation *compositor_operation = new CompositorOperation();
|
CompositorOperation *compositor_operation = new CompositorOperation();
|
||||||
compositor_operation->set_scene(context.get_scene());
|
compositor_operation->set_scene(context.get_scene());
|
||||||
|
@ -43,7 +42,6 @@ void CompositorNode::convert_to_operations(NodeConverter &converter,
|
||||||
else {
|
else {
|
||||||
converter.map_input_socket(alpha_socket, compositor_operation->get_input_socket(1));
|
converter.map_input_socket(alpha_socket, compositor_operation->get_input_socket(1));
|
||||||
}
|
}
|
||||||
converter.map_input_socket(depth_socket, compositor_operation->get_input_socket(2));
|
|
||||||
|
|
||||||
converter.add_node_input_preview(image_socket);
|
converter.add_node_input_preview(image_socket);
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,21 +225,9 @@ void ImageNode::convert_to_operations(NodeConverter &converter,
|
||||||
|
|
||||||
converter.map_output_socket(alpha_image, alpha_operation->get_output_socket());
|
converter.map_output_socket(alpha_image, alpha_operation->get_output_socket());
|
||||||
}
|
}
|
||||||
if (number_of_outputs > 2) {
|
else {
|
||||||
NodeOutput *depth_image = this->get_output_socket(2);
|
|
||||||
ImageDepthOperation *depth_operation = new ImageDepthOperation();
|
|
||||||
depth_operation->set_image(image);
|
|
||||||
depth_operation->set_image_user(imageuser);
|
|
||||||
depth_operation->set_framenumber(framenumber);
|
|
||||||
depth_operation->set_render_data(context.get_render_data());
|
|
||||||
depth_operation->set_view_name(context.get_view_name());
|
|
||||||
converter.add_operation(depth_operation);
|
|
||||||
|
|
||||||
converter.map_output_socket(depth_image, depth_operation->get_output_socket());
|
|
||||||
}
|
|
||||||
if (number_of_outputs > 3) {
|
|
||||||
/* happens when unlinking image datablock from multilayer node */
|
/* happens when unlinking image datablock from multilayer node */
|
||||||
for (int i = 3; i < number_of_outputs; i++) {
|
for (int i = 2; i < number_of_outputs; i++) {
|
||||||
|
|||||||
NodeOutput *output = this->get_output_socket(i);
|
NodeOutput *output = this->get_output_socket(i);
|
||||||
NodeOperation *operation = nullptr;
|
NodeOperation *operation = nullptr;
|
||||||
switch (output->get_data_type()) {
|
switch (output->get_data_type()) {
|
||||||
|
|
|
@ -23,7 +23,6 @@ void ViewerNode::convert_to_operations(NodeConverter &converter,
|
||||||
|
|
||||||
NodeInput *image_socket = this->get_input_socket(0);
|
NodeInput *image_socket = this->get_input_socket(0);
|
||||||
NodeInput *alpha_socket = this->get_input_socket(1);
|
NodeInput *alpha_socket = this->get_input_socket(1);
|
||||||
NodeInput *depth_socket = this->get_input_socket(2);
|
|
||||||
Image *image = (Image *)this->get_bnode()->id;
|
Image *image = (Image *)this->get_bnode()->id;
|
||||||
ImageUser *image_user = (ImageUser *)this->get_bnode()->storage;
|
ImageUser *image_user = (ImageUser *)this->get_bnode()->storage;
|
||||||
ViewerOperation *viewer_operation = new ViewerOperation();
|
ViewerOperation *viewer_operation = new ViewerOperation();
|
||||||
|
@ -58,7 +57,6 @@ void ViewerNode::convert_to_operations(NodeConverter &converter,
|
||||||
else {
|
else {
|
||||||
converter.map_input_socket(alpha_socket, viewer_operation->get_input_socket(1));
|
converter.map_input_socket(alpha_socket, viewer_operation->get_input_socket(1));
|
||||||
}
|
}
|
||||||
converter.map_input_socket(depth_socket, viewer_operation->get_input_socket(2));
|
|
||||||
|
|
||||||
converter.add_node_input_preview(image_socket);
|
converter.add_node_input_preview(image_socket);
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,11 @@ CompositorOperation::CompositorOperation()
|
||||||
{
|
{
|
||||||
this->add_input_socket(DataType::Color);
|
this->add_input_socket(DataType::Color);
|
||||||
this->add_input_socket(DataType::Value);
|
this->add_input_socket(DataType::Value);
|
||||||
this->add_input_socket(DataType::Value);
|
|
||||||
|
|
||||||
this->set_render_data(nullptr);
|
this->set_render_data(nullptr);
|
||||||
output_buffer_ = nullptr;
|
output_buffer_ = nullptr;
|
||||||
depth_buffer_ = nullptr;
|
|
||||||
image_input_ = nullptr;
|
image_input_ = nullptr;
|
||||||
alpha_input_ = nullptr;
|
alpha_input_ = nullptr;
|
||||||
depth_input_ = nullptr;
|
|
||||||
|
|
||||||
use_alpha_input_ = false;
|
use_alpha_input_ = false;
|
||||||
active_ = false;
|
active_ = false;
|
||||||
|
@ -44,15 +41,10 @@ void CompositorOperation::init_execution()
|
||||||
/* When initializing the tree during initial load the width and height can be zero. */
|
/* When initializing the tree during initial load the width and height can be zero. */
|
||||||
image_input_ = get_input_socket_reader(0);
|
image_input_ = get_input_socket_reader(0);
|
||||||
alpha_input_ = get_input_socket_reader(1);
|
alpha_input_ = get_input_socket_reader(1);
|
||||||
depth_input_ = get_input_socket_reader(2);
|
|
||||||
if (this->get_width() * this->get_height() != 0) {
|
if (this->get_width() * this->get_height() != 0) {
|
||||||
output_buffer_ = (float *)MEM_callocN(
|
output_buffer_ = (float *)MEM_callocN(
|
||||||
sizeof(float[4]) * this->get_width() * this->get_height(), "CompositorOperation");
|
sizeof(float[4]) * this->get_width() * this->get_height(), "CompositorOperation");
|
||||||
}
|
}
|
||||||
if (depth_input_ != nullptr) {
|
|
||||||
depth_buffer_ = (float *)MEM_callocN(sizeof(float) * this->get_width() * this->get_height(),
|
|
||||||
"CompositorOperation");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompositorOperation::deinit_execution()
|
void CompositorOperation::deinit_execution()
|
||||||
|
@ -69,7 +61,6 @@ void CompositorOperation::deinit_execution()
|
||||||
RenderView *rv = RE_RenderViewGetByName(rr, view_name_);
|
RenderView *rv = RE_RenderViewGetByName(rr, view_name_);
|
||||||
|
|
||||||
RE_RenderBuffer_assign_data(&rv->combined_buffer, output_buffer_);
|
RE_RenderBuffer_assign_data(&rv->combined_buffer, output_buffer_);
|
||||||
RE_RenderBuffer_assign_data(&rv->z_buffer, depth_buffer_);
|
|
||||||
|
|
||||||
rr->have_combined = true;
|
rr->have_combined = true;
|
||||||
}
|
}
|
||||||
|
@ -77,9 +68,6 @@ void CompositorOperation::deinit_execution()
|
||||||
if (output_buffer_) {
|
if (output_buffer_) {
|
||||||
MEM_freeN(output_buffer_);
|
MEM_freeN(output_buffer_);
|
||||||
}
|
}
|
||||||
if (depth_buffer_) {
|
|
||||||
MEM_freeN(depth_buffer_);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (re) {
|
if (re) {
|
||||||
|
@ -97,23 +85,17 @@ void CompositorOperation::deinit_execution()
|
||||||
if (output_buffer_) {
|
if (output_buffer_) {
|
||||||
MEM_freeN(output_buffer_);
|
MEM_freeN(output_buffer_);
|
||||||
}
|
}
|
||||||
if (depth_buffer_) {
|
|
||||||
MEM_freeN(depth_buffer_);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
output_buffer_ = nullptr;
|
output_buffer_ = nullptr;
|
||||||
depth_buffer_ = nullptr;
|
|
||||||
image_input_ = nullptr;
|
image_input_ = nullptr;
|
||||||
alpha_input_ = nullptr;
|
alpha_input_ = nullptr;
|
||||||
depth_input_ = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompositorOperation::execute_region(rcti *rect, uint /*tile_number*/)
|
void CompositorOperation::execute_region(rcti *rect, uint /*tile_number*/)
|
||||||
{
|
{
|
||||||
float color[8]; /* 7 is enough. */
|
float color[8]; /* 7 is enough. */
|
||||||
float *buffer = output_buffer_;
|
float *buffer = output_buffer_;
|
||||||
float *zbuffer = depth_buffer_;
|
|
||||||
|
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
return;
|
return;
|
||||||
|
@ -180,8 +162,6 @@ void CompositorOperation::execute_region(rcti *rect, uint /*tile_number*/)
|
||||||
|
|
||||||
copy_v4_v4(buffer + offset4, color);
|
copy_v4_v4(buffer + offset4, color);
|
||||||
|
|
||||||
depth_input_->read_sampled(color, input_x, input_y, PixelSampler::Nearest);
|
|
||||||
zbuffer[offset] = color[0];
|
|
||||||
offset4 += COM_DATA_TYPE_COLOR_CHANNELS;
|
offset4 += COM_DATA_TYPE_COLOR_CHANNELS;
|
||||||
offset++;
|
offset++;
|
||||||
if (is_braked()) {
|
if (is_braked()) {
|
||||||
|
@ -205,8 +185,6 @@ void CompositorOperation::update_memory_buffer_partial(MemoryBuffer * /*output*/
|
||||||
if (use_alpha_input_) {
|
if (use_alpha_input_) {
|
||||||
output_buf.copy_from(inputs[1], area, 0, COM_DATA_TYPE_VALUE_CHANNELS, 3);
|
output_buf.copy_from(inputs[1], area, 0, COM_DATA_TYPE_VALUE_CHANNELS, 3);
|
||||||
}
|
}
|
||||||
MemoryBuffer depth_buf(depth_buffer_, COM_DATA_TYPE_VALUE_CHANNELS, get_width(), get_height());
|
|
||||||
depth_buf.copy_from(inputs[2], area);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompositorOperation::determine_canvas(const rcti & /*preferred_area*/, rcti &r_area)
|
void CompositorOperation::determine_canvas(const rcti & /*preferred_area*/, rcti &r_area)
|
||||||
|
|
|
@ -31,11 +31,6 @@ class CompositorOperation : public MultiThreadedOperation {
|
||||||
*/
|
*/
|
||||||
float *output_buffer_;
|
float *output_buffer_;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief reference to the output depth float buffer
|
|
||||||
*/
|
|
||||||
float *depth_buffer_;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief local reference to the input image operation
|
* \brief local reference to the input image operation
|
||||||
*/
|
*/
|
||||||
|
@ -46,11 +41,6 @@ class CompositorOperation : public MultiThreadedOperation {
|
||||||
*/
|
*/
|
||||||
SocketReader *alpha_input_;
|
SocketReader *alpha_input_;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief local reference to the depth operation
|
|
||||||
*/
|
|
||||||
SocketReader *depth_input_;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ignore any alpha input
|
* \brief Ignore any alpha input
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,8 +22,6 @@ BaseImageOperation::BaseImageOperation()
|
||||||
imagewidth_ = 0;
|
imagewidth_ = 0;
|
||||||
imageheight_ = 0;
|
imageheight_ = 0;
|
||||||
framenumber_ = 0;
|
framenumber_ = 0;
|
||||||
image_depth_buffer_ = nullptr;
|
|
||||||
depth_buffer_ = nullptr;
|
|
||||||
number_of_channels_ = 0;
|
number_of_channels_ = 0;
|
||||||
rd_ = nullptr;
|
rd_ = nullptr;
|
||||||
view_name_ = nullptr;
|
view_name_ = nullptr;
|
||||||
|
@ -36,10 +34,6 @@ ImageAlphaOperation::ImageAlphaOperation() : BaseImageOperation()
|
||||||
{
|
{
|
||||||
this->add_output_socket(DataType::Value);
|
this->add_output_socket(DataType::Value);
|
||||||
}
|
}
|
||||||
ImageDepthOperation::ImageDepthOperation() : BaseImageOperation()
|
|
||||||
{
|
|
||||||
this->add_output_socket(DataType::Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImBuf *BaseImageOperation::get_im_buf()
|
ImBuf *BaseImageOperation::get_im_buf()
|
||||||
{
|
{
|
||||||
|
@ -71,10 +65,6 @@ void BaseImageOperation::init_execution()
|
||||||
if (stackbuf) {
|
if (stackbuf) {
|
||||||
image_float_buffer_ = stackbuf->float_buffer.data;
|
image_float_buffer_ = stackbuf->float_buffer.data;
|
||||||
image_byte_buffer_ = stackbuf->byte_buffer.data;
|
image_byte_buffer_ = stackbuf->byte_buffer.data;
|
||||||
image_depth_buffer_ = stackbuf->float_z_buffer.data;
|
|
||||||
if (stackbuf->float_z_buffer.data) {
|
|
||||||
depth_buffer_ = new MemoryBuffer(stackbuf->float_z_buffer.data, 1, stackbuf->x, stackbuf->y);
|
|
||||||
}
|
|
||||||
imagewidth_ = stackbuf->x;
|
imagewidth_ = stackbuf->x;
|
||||||
imageheight_ = stackbuf->y;
|
imageheight_ = stackbuf->y;
|
||||||
number_of_channels_ = stackbuf->channels;
|
number_of_channels_ = stackbuf->channels;
|
||||||
|
@ -86,10 +76,6 @@ void BaseImageOperation::deinit_execution()
|
||||||
image_float_buffer_ = nullptr;
|
image_float_buffer_ = nullptr;
|
||||||
image_byte_buffer_ = nullptr;
|
image_byte_buffer_ = nullptr;
|
||||||
BKE_image_release_ibuf(image_, buffer_, nullptr);
|
BKE_image_release_ibuf(image_, buffer_, nullptr);
|
||||||
if (depth_buffer_) {
|
|
||||||
delete depth_buffer_;
|
|
||||||
depth_buffer_ = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseImageOperation::determine_canvas(const rcti & /*preferred_area*/, rcti &r_area)
|
void BaseImageOperation::determine_canvas(const rcti & /*preferred_area*/, rcti &r_area)
|
||||||
|
@ -187,35 +173,4 @@ void ImageAlphaOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||||
output->copy_from(buffer_, area, 3, COM_DATA_TYPE_VALUE_CHANNELS, 0);
|
output->copy_from(buffer_, area, 3, COM_DATA_TYPE_VALUE_CHANNELS, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageDepthOperation::execute_pixel_sampled(float output[4],
|
|
||||||
float x,
|
|
||||||
float y,
|
|
||||||
PixelSampler /*sampler*/)
|
|
||||||
{
|
|
||||||
if (image_depth_buffer_ == nullptr) {
|
|
||||||
output[0] = 0.0f;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (x < 0 || y < 0 || x >= this->get_width() || y >= this->get_height()) {
|
|
||||||
output[0] = 0.0f;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int offset = y * get_width() + x;
|
|
||||||
output[0] = image_depth_buffer_[offset];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImageDepthOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
|
||||||
const rcti &area,
|
|
||||||
Span<MemoryBuffer *> /*inputs*/)
|
|
||||||
{
|
|
||||||
if (depth_buffer_) {
|
|
||||||
output->copy_from(depth_buffer_, area);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
output->fill(area, COM_VALUE_ZERO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace blender::compositor
|
} // namespace blender::compositor
|
||||||
|
|
|
@ -27,9 +27,7 @@ class BaseImageOperation : public MultiThreadedOperation {
|
||||||
/* TODO: Remove raw buffers when removing Tiled implementation. */
|
/* TODO: Remove raw buffers when removing Tiled implementation. */
|
||||||
float *image_float_buffer_;
|
float *image_float_buffer_;
|
||||||
uint8_t *image_byte_buffer_;
|
uint8_t *image_byte_buffer_;
|
||||||
float *image_depth_buffer_;
|
|
||||||
|
|
||||||
MemoryBuffer *depth_buffer_;
|
|
||||||
int imageheight_;
|
int imageheight_;
|
||||||
int imagewidth_;
|
int imagewidth_;
|
||||||
int framenumber_;
|
int framenumber_;
|
||||||
|
@ -93,17 +91,4 @@ class ImageAlphaOperation : public BaseImageOperation {
|
||||||
const rcti &area,
|
const rcti &area,
|
||||||
Span<MemoryBuffer *> inputs) override;
|
Span<MemoryBuffer *> inputs) override;
|
||||||
};
|
};
|
||||||
class ImageDepthOperation : public BaseImageOperation {
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
ImageDepthOperation();
|
|
||||||
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override;
|
|
||||||
|
|
||||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
|
||||||
const rcti &area,
|
|
||||||
Span<MemoryBuffer *> inputs) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace blender::compositor
|
} // namespace blender::compositor
|
||||||
|
|
|
@ -18,20 +18,16 @@ ViewerOperation::ViewerOperation()
|
||||||
this->set_image(nullptr);
|
this->set_image(nullptr);
|
||||||
this->set_image_user(nullptr);
|
this->set_image_user(nullptr);
|
||||||
output_buffer_ = nullptr;
|
output_buffer_ = nullptr;
|
||||||
depth_buffer_ = nullptr;
|
|
||||||
active_ = false;
|
active_ = false;
|
||||||
do_depth_buffer_ = false;
|
|
||||||
view_settings_ = nullptr;
|
view_settings_ = nullptr;
|
||||||
display_settings_ = nullptr;
|
display_settings_ = nullptr;
|
||||||
use_alpha_input_ = false;
|
use_alpha_input_ = false;
|
||||||
|
|
||||||
this->add_input_socket(DataType::Color);
|
this->add_input_socket(DataType::Color);
|
||||||
this->add_input_socket(DataType::Value);
|
this->add_input_socket(DataType::Value);
|
||||||
this->add_input_socket(DataType::Value);
|
|
||||||
|
|
||||||
image_input_ = nullptr;
|
image_input_ = nullptr;
|
||||||
alpha_input_ = nullptr;
|
alpha_input_ = nullptr;
|
||||||
depth_input_ = nullptr;
|
|
||||||
rd_ = nullptr;
|
rd_ = nullptr;
|
||||||
view_name_ = nullptr;
|
view_name_ = nullptr;
|
||||||
flags_.use_viewer_border = true;
|
flags_.use_viewer_border = true;
|
||||||
|
@ -43,8 +39,6 @@ void ViewerOperation::init_execution()
|
||||||
/* When initializing the tree during initial load the width and height can be zero. */
|
/* When initializing the tree during initial load the width and height can be zero. */
|
||||||
image_input_ = get_input_socket_reader(0);
|
image_input_ = get_input_socket_reader(0);
|
||||||
alpha_input_ = get_input_socket_reader(1);
|
alpha_input_ = get_input_socket_reader(1);
|
||||||
depth_input_ = get_input_socket_reader(2);
|
|
||||||
do_depth_buffer_ = (depth_input_ != nullptr);
|
|
||||||
|
|
||||||
if (is_active_viewer_output() && !exec_system_->is_breaked()) {
|
if (is_active_viewer_output() && !exec_system_->is_breaked()) {
|
||||||
init_image();
|
init_image();
|
||||||
|
@ -55,14 +49,12 @@ void ViewerOperation::deinit_execution()
|
||||||
{
|
{
|
||||||
image_input_ = nullptr;
|
image_input_ = nullptr;
|
||||||
alpha_input_ = nullptr;
|
alpha_input_ = nullptr;
|
||||||
depth_input_ = nullptr;
|
|
||||||
output_buffer_ = nullptr;
|
output_buffer_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewerOperation::execute_region(rcti *rect, uint /*tile_number*/)
|
void ViewerOperation::execute_region(rcti *rect, uint /*tile_number*/)
|
||||||
{
|
{
|
||||||
float *buffer = output_buffer_;
|
float *buffer = output_buffer_;
|
||||||
float *depthbuffer = depth_buffer_;
|
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +66,7 @@ void ViewerOperation::execute_region(rcti *rect, uint /*tile_number*/)
|
||||||
const int offsetadd4 = offsetadd * 4;
|
const int offsetadd4 = offsetadd * 4;
|
||||||
int offset = (y1 * this->get_width() + x1);
|
int offset = (y1 * this->get_width() + x1);
|
||||||
int offset4 = offset * 4;
|
int offset4 = offset * 4;
|
||||||
float alpha[4], depth[4];
|
float alpha[4];
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
bool breaked = false;
|
bool breaked = false;
|
||||||
|
@ -86,8 +78,6 @@ void ViewerOperation::execute_region(rcti *rect, uint /*tile_number*/)
|
||||||
alpha_input_->read_sampled(alpha, x, y, PixelSampler::Nearest);
|
alpha_input_->read_sampled(alpha, x, y, PixelSampler::Nearest);
|
||||||
buffer[offset4 + 3] = alpha[0];
|
buffer[offset4 + 3] = alpha[0];
|
||||||
}
|
}
|
||||||
depth_input_->read_sampled(depth, x, y, PixelSampler::Nearest);
|
|
||||||
depthbuffer[offset] = depth[0];
|
|
||||||
|
|
||||||
offset++;
|
offset++;
|
||||||
offset4 += 4;
|
offset4 += 4;
|
||||||
|
@ -140,7 +130,6 @@ void ViewerOperation::init_image()
|
||||||
|
|
||||||
imb_freerectImBuf(ibuf);
|
imb_freerectImBuf(ibuf);
|
||||||
imb_freerectfloatImBuf(ibuf);
|
imb_freerectfloatImBuf(ibuf);
|
||||||
IMB_freezbuffloatImBuf(ibuf);
|
|
||||||
ibuf->x = get_width();
|
ibuf->x = get_width();
|
||||||
ibuf->y = get_height();
|
ibuf->y = get_height();
|
||||||
/* zero size can happen if no image buffers exist to define a sensible resolution */
|
/* zero size can happen if no image buffers exist to define a sensible resolution */
|
||||||
|
@ -151,20 +140,12 @@ void ViewerOperation::init_image()
|
||||||
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
|
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_depth_buffer_) {
|
|
||||||
addzbuffloatImBuf(ibuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now we combine the input with ibuf */
|
/* now we combine the input with ibuf */
|
||||||
output_buffer_ = ibuf->float_buffer.data;
|
output_buffer_ = ibuf->float_buffer.data;
|
||||||
|
|
||||||
/* needed for display buffer update */
|
/* needed for display buffer update */
|
||||||
ibuf_ = ibuf;
|
ibuf_ = ibuf;
|
||||||
|
|
||||||
if (do_depth_buffer_) {
|
|
||||||
depth_buffer_ = ibuf->float_z_buffer.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
BKE_image_release_ibuf(image_, ibuf_, lock);
|
BKE_image_release_ibuf(image_, ibuf_, lock);
|
||||||
|
|
||||||
BLI_thread_unlock(LOCK_DRAW_IMAGE);
|
BLI_thread_unlock(LOCK_DRAW_IMAGE);
|
||||||
|
@ -224,13 +205,6 @@ void ViewerOperation::update_memory_buffer_partial(MemoryBuffer * /*output*/,
|
||||||
output_buffer.copy_from(input_alpha, area, 0, COM_DATA_TYPE_VALUE_CHANNELS, 3);
|
output_buffer.copy_from(input_alpha, area, 0, COM_DATA_TYPE_VALUE_CHANNELS, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (depth_buffer_) {
|
|
||||||
MemoryBuffer depth_buffer(
|
|
||||||
depth_buffer_, COM_DATA_TYPE_VALUE_CHANNELS, get_width(), get_height());
|
|
||||||
const MemoryBuffer *input_depth = inputs[2];
|
|
||||||
depth_buffer.copy_from(input_depth, area);
|
|
||||||
}
|
|
||||||
|
|
||||||
update_image(&area);
|
update_image(&area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ class ViewerOperation : public MultiThreadedOperation {
|
||||||
private:
|
private:
|
||||||
/* TODO(manzanilla): To be removed together with tiled implementation. */
|
/* TODO(manzanilla): To be removed together with tiled implementation. */
|
||||||
float *output_buffer_;
|
float *output_buffer_;
|
||||||
float *depth_buffer_;
|
|
||||||
|
|
||||||
Image *image_;
|
Image *image_;
|
||||||
ImageUser *image_user_;
|
ImageUser *image_user_;
|
||||||
|
@ -23,7 +22,6 @@ class ViewerOperation : public MultiThreadedOperation {
|
||||||
float center_x_;
|
float center_x_;
|
||||||
float center_y_;
|
float center_y_;
|
||||||
ChunkOrdering chunk_order_;
|
ChunkOrdering chunk_order_;
|
||||||
bool do_depth_buffer_;
|
|
||||||
ImBuf *ibuf_;
|
ImBuf *ibuf_;
|
||||||
bool use_alpha_input_;
|
bool use_alpha_input_;
|
||||||
const RenderData *rd_;
|
const RenderData *rd_;
|
||||||
|
@ -34,7 +32,6 @@ class ViewerOperation : public MultiThreadedOperation {
|
||||||
|
|
||||||
SocketReader *image_input_;
|
SocketReader *image_input_;
|
||||||
SocketReader *alpha_input_;
|
SocketReader *alpha_input_;
|
||||||
SocketReader *depth_input_;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ViewerOperation();
|
ViewerOperation();
|
||||||
|
|
|
@ -187,9 +187,7 @@ void ED_image_draw_info(struct Scene *scene,
|
||||||
int y,
|
int y,
|
||||||
const unsigned char cp[4],
|
const unsigned char cp[4],
|
||||||
const float fp[4],
|
const float fp[4],
|
||||||
const float linearcol[4],
|
const float linearcol[4]);
|
||||||
const int *zp,
|
|
||||||
const float *zpf);
|
|
||||||
|
|
||||||
bool ED_space_image_show_cache(const struct SpaceImage *sima);
|
bool ED_space_image_show_cache(const struct SpaceImage *sima);
|
||||||
bool ED_space_image_show_cache_and_mval_over(const struct SpaceImage *sima,
|
bool ED_space_image_show_cache_and_mval_over(const struct SpaceImage *sima,
|
||||||
|
|
|
@ -2415,10 +2415,7 @@ void uiTemplateImage(uiLayout *layout,
|
||||||
struct PointerRNA *userptr,
|
struct PointerRNA *userptr,
|
||||||
bool compact,
|
bool compact,
|
||||||
bool multiview);
|
bool multiview);
|
||||||
void uiTemplateImageSettings(uiLayout *layout,
|
void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, bool color_management);
|
||||||
struct PointerRNA *imfptr,
|
|
||||||
bool color_management,
|
|
||||||
bool show_z_buffer);
|
|
||||||
void uiTemplateImageStereo3d(uiLayout *layout, struct PointerRNA *stereo3d_format_ptr);
|
void uiTemplateImageStereo3d(uiLayout *layout, struct PointerRNA *stereo3d_format_ptr);
|
||||||
void uiTemplateImageViews(uiLayout *layout, struct PointerRNA *imaptr);
|
void uiTemplateImageViews(uiLayout *layout, struct PointerRNA *imaptr);
|
||||||
void uiTemplateImageFormatViews(uiLayout *layout,
|
void uiTemplateImageFormatViews(uiLayout *layout,
|
||||||
|
|
|
@ -218,7 +218,7 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op)
|
||||||
/* image template */
|
/* image template */
|
||||||
PointerRNA ptr;
|
PointerRNA ptr;
|
||||||
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &scd->im_format, &ptr);
|
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &scd->im_format, &ptr);
|
||||||
uiTemplateImageSettings(layout, &ptr, false, true);
|
uiTemplateImageSettings(layout, &ptr, false);
|
||||||
|
|
||||||
/* main draw call */
|
/* main draw call */
|
||||||
uiDefAutoButsRNA(
|
uiDefAutoButsRNA(
|
||||||
|
|
|
@ -962,10 +962,7 @@ void uiTemplateImage(uiLayout *layout,
|
||||||
UI_block_funcN_set(block, NULL, NULL, NULL);
|
UI_block_funcN_set(block, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiTemplateImageSettings(uiLayout *layout,
|
void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, bool color_management)
|
||||||
PointerRNA *imfptr,
|
|
||||||
bool color_management,
|
|
||||||
bool show_z_buffer)
|
|
||||||
{
|
{
|
||||||
ImageFormatData *imf = imfptr->data;
|
ImageFormatData *imf = imfptr->data;
|
||||||
ID *id = imfptr->owner_id;
|
ID *id = imfptr->owner_id;
|
||||||
|
@ -1017,10 +1014,6 @@ void uiTemplateImageSettings(uiLayout *layout,
|
||||||
uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE);
|
uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BKE_imtype_supports_zbuf(imf->imtype) && show_z_buffer) {
|
|
||||||
uiItemR(col, imfptr, "use_zbuffer", 0, NULL, ICON_NONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_render_out && ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
|
if (is_render_out && ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
|
||||||
uiItemR(col, imfptr, "use_preview", 0, NULL, ICON_NONE);
|
uiItemR(col, imfptr, "use_preview", 0, NULL, ICON_NONE);
|
||||||
}
|
}
|
||||||
|
@ -1224,9 +1217,6 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
|
||||||
ofs += BLI_strncpy_rlen(str + ofs, TIP_(" RGB byte"), len - ofs);
|
ofs += BLI_strncpy_rlen(str + ofs, TIP_(" RGB byte"), len - ofs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ibuf->z_buffer.data || ibuf->float_z_buffer.data) {
|
|
||||||
ofs += BLI_strncpy_rlen(str + ofs, TIP_(" + Z"), len - ofs);
|
|
||||||
}
|
|
||||||
|
|
||||||
eGPUTextureFormat texture_format = IMB_gpu_get_texture_format(
|
eGPUTextureFormat texture_format = IMB_gpu_get_texture_format(
|
||||||
ibuf, ima->flag & IMA_HIGH_BITDEPTH, ibuf->planes >= 8);
|
ibuf, ima->flag & IMA_HIGH_BITDEPTH, ibuf->planes >= 8);
|
||||||
|
|
|
@ -129,9 +129,7 @@ void ED_image_draw_info(Scene *scene,
|
||||||
int y,
|
int y,
|
||||||
const uchar cp[4],
|
const uchar cp[4],
|
||||||
const float fp[4],
|
const float fp[4],
|
||||||
const float linearcol[4],
|
const float linearcol[4])
|
||||||
const int *zp,
|
|
||||||
const float *zpf)
|
|
||||||
{
|
{
|
||||||
rcti color_rect;
|
rcti color_rect;
|
||||||
char str[256];
|
char str[256];
|
||||||
|
@ -177,21 +175,6 @@ void ED_image_draw_info(Scene *scene,
|
||||||
BLF_draw(blf_mono_font, str, sizeof(str));
|
BLF_draw(blf_mono_font, str, sizeof(str));
|
||||||
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
||||||
|
|
||||||
if (zp) {
|
|
||||||
BLF_color3ub(blf_mono_font, 255, 255, 255);
|
|
||||||
SNPRINTF(str, " Z:%-.4f |", 0.5f + 0.5f * (((float)*zp) / (float)0x7fffffff));
|
|
||||||
BLF_position(blf_mono_font, dx, dy, 0);
|
|
||||||
BLF_draw(blf_mono_font, str, sizeof(str));
|
|
||||||
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
|
||||||
}
|
|
||||||
if (zpf) {
|
|
||||||
BLF_color3ub(blf_mono_font, 255, 255, 255);
|
|
||||||
SNPRINTF(str, " Z:%-.3f |", *zpf);
|
|
||||||
BLF_position(blf_mono_font, dx, dy, 0);
|
|
||||||
BLF_draw(blf_mono_font, str, sizeof(str));
|
|
||||||
dx += BLF_width(blf_mono_font, str, sizeof(str));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channels == 1 && (cp != NULL || fp != NULL)) {
|
if (channels == 1 && (cp != NULL || fp != NULL)) {
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
SNPRINTF(str, " Val:%-.3f |", fp[0]);
|
SNPRINTF(str, " Val:%-.3f |", fp[0]);
|
||||||
|
|
|
@ -198,7 +198,7 @@ int ED_space_image_get_display_channel_mask(ImBuf *ibuf)
|
||||||
|
|
||||||
const bool color = ibuf->channels >= 3;
|
const bool color = ibuf->channels >= 3;
|
||||||
const bool alpha = ibuf->channels == 4;
|
const bool alpha = ibuf->channels == 4;
|
||||||
const bool zbuf = ibuf->z_buffer.data || ibuf->float_z_buffer.data || (ibuf->channels == 1);
|
const bool zbuf = ibuf->channels == 1;
|
||||||
|
|
||||||
if (!alpha) {
|
if (!alpha) {
|
||||||
result &= ~(SI_USE_ALPHA | SI_SHOW_ALPHA);
|
result &= ~(SI_USE_ALPHA | SI_SHOW_ALPHA);
|
||||||
|
|
|
@ -2007,7 +2007,7 @@ static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op)
|
||||||
|
|
||||||
/* Image format settings. */
|
/* Image format settings. */
|
||||||
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &isd->opts.im_format, &imf_ptr);
|
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, &isd->opts.im_format, &imf_ptr);
|
||||||
uiTemplateImageSettings(layout, &imf_ptr, save_as_render, true);
|
uiTemplateImageSettings(layout, &imf_ptr, save_as_render);
|
||||||
|
|
||||||
if (!save_as_render) {
|
if (!save_as_render) {
|
||||||
PointerRNA linear_settings_ptr = RNA_pointer_get(&imf_ptr, "linear_colorspace_settings");
|
PointerRNA linear_settings_ptr = RNA_pointer_get(&imf_ptr, "linear_colorspace_settings");
|
||||||
|
@ -2258,7 +2258,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
|
||||||
ibuf = IMB_moviecacheIter_getImBuf(iter);
|
ibuf = IMB_moviecacheIter_getImBuf(iter);
|
||||||
|
|
||||||
if (ibuf != NULL && ibuf->userflags & IB_BITMAPDIRTY) {
|
if (ibuf != NULL && ibuf->userflags & IB_BITMAPDIRTY) {
|
||||||
if (0 == IMB_saveiff(ibuf, ibuf->filepath, IB_rect | IB_zbuf | IB_zbuffloat)) {
|
if (0 == IMB_saveiff(ibuf, ibuf->filepath, IB_rect)) {
|
||||||
BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno));
|
BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,12 +415,6 @@ struct ImageSampleInfo {
|
||||||
float colf[4];
|
float colf[4];
|
||||||
float linearcol[4];
|
float linearcol[4];
|
||||||
|
|
||||||
int z;
|
|
||||||
float zf;
|
|
||||||
|
|
||||||
int *zp;
|
|
||||||
float *zfp;
|
|
||||||
|
|
||||||
int draw;
|
int draw;
|
||||||
int color_manage;
|
int color_manage;
|
||||||
};
|
};
|
||||||
|
@ -440,9 +434,7 @@ static void sample_draw(const bContext *C, ARegion *region, void *arg_info)
|
||||||
info->y,
|
info->y,
|
||||||
info->col,
|
info->col,
|
||||||
info->colf,
|
info->colf,
|
||||||
info->linearcol,
|
info->linearcol);
|
||||||
info->zp,
|
|
||||||
info->zfp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,9 +567,6 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
info->draw = 1;
|
info->draw = 1;
|
||||||
info->channels = ibuf->channels;
|
info->channels = ibuf->channels;
|
||||||
|
|
||||||
info->zp = nullptr;
|
|
||||||
info->zfp = nullptr;
|
|
||||||
|
|
||||||
if (ibuf->byte_buffer.data) {
|
if (ibuf->byte_buffer.data) {
|
||||||
cp = ibuf->byte_buffer.data + 4 * (y * ibuf->x + x);
|
cp = ibuf->byte_buffer.data + 4 * (y * ibuf->x + x);
|
||||||
|
|
||||||
|
@ -608,15 +597,6 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
info->color_manage = true;
|
info->color_manage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ibuf->z_buffer.data) {
|
|
||||||
info->z = ibuf->z_buffer.data[y * ibuf->x + x];
|
|
||||||
info->zp = &info->z;
|
|
||||||
}
|
|
||||||
if (ibuf->float_z_buffer.data) {
|
|
||||||
info->zf = ibuf->float_z_buffer.data[y * ibuf->x + x];
|
|
||||||
info->zfp = &info->zf;
|
|
||||||
}
|
|
||||||
|
|
||||||
ED_node_sample_set(info->colf);
|
ED_node_sample_set(info->colf);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -229,25 +229,6 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event
|
||||||
info->color_manage = true;
|
info->color_manage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ibuf->z_buffer.data) {
|
|
||||||
/* TODO: blend depth (not urgent). */
|
|
||||||
info->z = ibuf->z_buffer.data[y * ibuf->x + x];
|
|
||||||
info->zp = &info->z;
|
|
||||||
/* NOTE: Follows legacy code. Although it is unclear how z-buffer can be the same as a 4
|
|
||||||
* channel RGBA 8bpp buffer. */
|
|
||||||
if (ibuf->z_buffer.data == (int *)ibuf->byte_buffer.data) {
|
|
||||||
info->colp = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ibuf->float_z_buffer.data) {
|
|
||||||
/* TODO: blend depth (not urgent). */
|
|
||||||
info->zf = ibuf->float_z_buffer.data[y * ibuf->x + x];
|
|
||||||
info->zfp = &info->zf;
|
|
||||||
if (ibuf->float_z_buffer.data == ibuf->float_buffer.data) {
|
|
||||||
info->colfp = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curve_mapping && ibuf->channels == 4) {
|
if (curve_mapping && ibuf->channels == 4) {
|
||||||
/* we reuse this callback for set curves point operators */
|
/* we reuse this callback for set curves point operators */
|
||||||
if (RNA_struct_find_property(op->ptr, "point")) {
|
if (RNA_struct_find_property(op->ptr, "point")) {
|
||||||
|
@ -415,9 +396,7 @@ void ED_imbuf_sample_draw(const bContext *C, ARegion *region, void *arg_info)
|
||||||
info->y,
|
info->y,
|
||||||
info->colp,
|
info->colp,
|
||||||
info->colfp,
|
info->colfp,
|
||||||
info->linearcol,
|
info->linearcol);
|
||||||
info->zp,
|
|
||||||
info->zfp);
|
|
||||||
|
|
||||||
if (info->sample_size > 1) {
|
if (info->sample_size > 1) {
|
||||||
ScrArea *area = CTX_wm_area(C);
|
ScrArea *area = CTX_wm_area(C);
|
||||||
|
|
|
@ -164,9 +164,6 @@ void IMB_assign_shared_byte_buffer(struct ImBuf *ibuf,
|
||||||
void IMB_assign_shared_float_buffer(struct ImBuf *ibuf,
|
void IMB_assign_shared_float_buffer(struct ImBuf *ibuf,
|
||||||
float *buffer_data,
|
float *buffer_data,
|
||||||
const ImplicitSharingInfoHandle *implicit_sharing);
|
const ImplicitSharingInfoHandle *implicit_sharing);
|
||||||
void IMB_assign_shared_float_z_buffer(struct ImBuf *ibuf,
|
|
||||||
float *buffer_data,
|
|
||||||
const ImplicitSharingInfoHandle *implicit_sharing);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign the content of the corresponding buffer with the given data and ownership.
|
* Assign the content of the corresponding buffer with the given data and ownership.
|
||||||
|
@ -177,8 +174,6 @@ void IMB_assign_shared_float_z_buffer(struct ImBuf *ibuf,
|
||||||
*/
|
*/
|
||||||
void IMB_assign_byte_buffer(struct ImBuf *ibuf, uint8_t *buffer_data, ImBufOwnership ownership);
|
void IMB_assign_byte_buffer(struct ImBuf *ibuf, uint8_t *buffer_data, ImBufOwnership ownership);
|
||||||
void IMB_assign_float_buffer(struct ImBuf *ibuf, float *buffer_data, ImBufOwnership ownership);
|
void IMB_assign_float_buffer(struct ImBuf *ibuf, float *buffer_data, ImBufOwnership ownership);
|
||||||
void IMB_assign_z_buffer(struct ImBuf *ibuf, int *buffer_data, ImBufOwnership ownership);
|
|
||||||
void IMB_assign_float_z_buffer(struct ImBuf *ibuf, float *buffer_data, ImBufOwnership ownership);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make corresponding buffers available for modification.
|
* Make corresponding buffers available for modification.
|
||||||
|
@ -212,12 +207,6 @@ struct ImBuf *IMB_makeSingleUser(struct ImBuf *ibuf);
|
||||||
*/
|
*/
|
||||||
struct ImBuf *IMB_dupImBuf(const struct ImBuf *ibuf1);
|
struct ImBuf *IMB_dupImBuf(const struct ImBuf *ibuf1);
|
||||||
|
|
||||||
/**
|
|
||||||
* \attention Defined in allocimbuf.c
|
|
||||||
*/
|
|
||||||
bool addzbufImBuf(struct ImBuf *ibuf);
|
|
||||||
bool addzbuffloatImBuf(struct ImBuf *ibuf);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Approximate size of ImBuf in memory
|
* Approximate size of ImBuf in memory
|
||||||
*
|
*
|
||||||
|
@ -777,12 +766,6 @@ void IMB_flipy(struct ImBuf *ibuf);
|
||||||
void IMB_premultiply_alpha(struct ImBuf *ibuf);
|
void IMB_premultiply_alpha(struct ImBuf *ibuf);
|
||||||
void IMB_unpremultiply_alpha(struct ImBuf *ibuf);
|
void IMB_unpremultiply_alpha(struct ImBuf *ibuf);
|
||||||
|
|
||||||
/**
|
|
||||||
* \attention Defined in allocimbuf.c
|
|
||||||
*/
|
|
||||||
void IMB_freezbufImBuf(struct ImBuf *ibuf);
|
|
||||||
void IMB_freezbuffloatImBuf(struct ImBuf *ibuf);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \attention Defined in rectop.c
|
* \attention Defined in rectop.c
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -133,10 +133,8 @@ typedef struct ImbFormatOptions {
|
||||||
typedef enum eImBufFlags {
|
typedef enum eImBufFlags {
|
||||||
IB_rect = 1 << 0,
|
IB_rect = 1 << 0,
|
||||||
IB_test = 1 << 1,
|
IB_test = 1 << 1,
|
||||||
IB_zbuf = 1 << 3,
|
|
||||||
IB_mem = 1 << 4,
|
IB_mem = 1 << 4,
|
||||||
IB_rectfloat = 1 << 5,
|
IB_rectfloat = 1 << 5,
|
||||||
IB_zbuffloat = 1 << 6,
|
|
||||||
IB_multilayer = 1 << 7,
|
IB_multilayer = 1 << 7,
|
||||||
IB_metadata = 1 << 8,
|
IB_metadata = 1 << 8,
|
||||||
IB_animdeinterlace = 1 << 9,
|
IB_animdeinterlace = 1 << 9,
|
||||||
|
@ -247,12 +245,6 @@ typedef struct ImBuf {
|
||||||
/** Resolution in pixels per meter. Multiply by `0.0254` for DPI. */
|
/** Resolution in pixels per meter. Multiply by `0.0254` for DPI. */
|
||||||
double ppm[2];
|
double ppm[2];
|
||||||
|
|
||||||
/* zbuffer */
|
|
||||||
/** z buffer data, original zbuffer */
|
|
||||||
ImBufIntBuffer z_buffer;
|
|
||||||
/** z buffer data, camera coordinates */
|
|
||||||
ImBufFloatBuffer float_z_buffer;
|
|
||||||
|
|
||||||
/* parameters used by conversion between byte and float */
|
/* parameters used by conversion between byte and float */
|
||||||
/** random dither value, for conversion from float -> byte rect */
|
/** random dither value, for conversion from float -> byte rect */
|
||||||
float dither;
|
float dither;
|
||||||
|
|
|
@ -237,34 +237,10 @@ static void freeencodedbufferImBuf(ImBuf *ibuf)
|
||||||
ibuf->flags &= ~IB_mem;
|
ibuf->flags &= ~IB_mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMB_freezbufImBuf(ImBuf *ibuf)
|
|
||||||
{
|
|
||||||
if (ibuf == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
imb_free_buffer(ibuf->z_buffer);
|
|
||||||
|
|
||||||
ibuf->flags &= ~IB_zbuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IMB_freezbuffloatImBuf(ImBuf *ibuf)
|
|
||||||
{
|
|
||||||
if (ibuf == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
imb_free_buffer(ibuf->float_z_buffer);
|
|
||||||
|
|
||||||
ibuf->flags &= ~IB_zbuffloat;
|
|
||||||
}
|
|
||||||
|
|
||||||
void imb_freerectImbuf_all(ImBuf *ibuf)
|
void imb_freerectImbuf_all(ImBuf *ibuf)
|
||||||
{
|
{
|
||||||
imb_freerectImBuf(ibuf);
|
imb_freerectImBuf(ibuf);
|
||||||
imb_freerectfloatImBuf(ibuf);
|
imb_freerectfloatImBuf(ibuf);
|
||||||
IMB_freezbufImBuf(ibuf);
|
|
||||||
IMB_freezbuffloatImBuf(ibuf);
|
|
||||||
freeencodedbufferImBuf(ibuf);
|
freeencodedbufferImBuf(ibuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,40 +307,6 @@ ImBuf *IMB_makeSingleUser(ImBuf *ibuf)
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool addzbufImBuf(ImBuf *ibuf)
|
|
||||||
{
|
|
||||||
if (ibuf == nullptr) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
IMB_freezbufImBuf(ibuf);
|
|
||||||
|
|
||||||
if (!imb_alloc_buffer(ibuf->z_buffer, ibuf->x, ibuf->y, 1, sizeof(uint))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ibuf->flags |= IB_zbuf;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool addzbuffloatImBuf(ImBuf *ibuf)
|
|
||||||
{
|
|
||||||
if (ibuf == nullptr) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
IMB_freezbuffloatImBuf(ibuf);
|
|
||||||
|
|
||||||
if (!imb_alloc_buffer(ibuf->float_z_buffer, ibuf->x, ibuf->y, 1, sizeof(float))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ibuf->flags |= IB_zbuffloat;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool imb_addencodedbufferImBuf(ImBuf *ibuf)
|
bool imb_addencodedbufferImBuf(ImBuf *ibuf)
|
||||||
{
|
{
|
||||||
if (ibuf == nullptr) {
|
if (ibuf == nullptr) {
|
||||||
|
@ -478,10 +420,6 @@ bool imb_addrectImBuf(ImBuf *ibuf)
|
||||||
|
|
||||||
ibuf->flags |= IB_rect;
|
ibuf->flags |= IB_rect;
|
||||||
|
|
||||||
if (ibuf->planes > 32) {
|
|
||||||
return addzbufImBuf(ibuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,19 +485,6 @@ void IMB_assign_shared_float_buffer(ImBuf *ibuf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMB_assign_shared_float_z_buffer(ImBuf *ibuf,
|
|
||||||
float *buffer_data,
|
|
||||||
const ImplicitSharingInfoHandle *implicit_sharing)
|
|
||||||
{
|
|
||||||
imb_free_buffer(ibuf->float_z_buffer);
|
|
||||||
ibuf->flags &= ~IB_zbuffloat;
|
|
||||||
|
|
||||||
if (buffer_data) {
|
|
||||||
imb_assign_shared_buffer(ibuf->float_z_buffer, buffer_data, implicit_sharing);
|
|
||||||
ibuf->flags |= IB_zbuffloat;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IMB_assign_byte_buffer(ImBuf *ibuf, uint8_t *buffer_data, const ImBufOwnership ownership)
|
void IMB_assign_byte_buffer(ImBuf *ibuf, uint8_t *buffer_data, const ImBufOwnership ownership)
|
||||||
{
|
{
|
||||||
imb_free_buffer(ibuf->byte_buffer);
|
imb_free_buffer(ibuf->byte_buffer);
|
||||||
|
@ -586,32 +511,6 @@ void IMB_assign_float_buffer(ImBuf *ibuf, float *buffer_data, const ImBufOwnersh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMB_assign_z_buffer(ImBuf *ibuf, int *buffer_data, ImBufOwnership ownership)
|
|
||||||
{
|
|
||||||
imb_free_buffer(ibuf->z_buffer);
|
|
||||||
ibuf->flags &= ~IB_zbuf;
|
|
||||||
|
|
||||||
if (buffer_data) {
|
|
||||||
ibuf->z_buffer.ownership = ownership;
|
|
||||||
ibuf->z_buffer.data = buffer_data;
|
|
||||||
|
|
||||||
ibuf->flags |= IB_zbuf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IMB_assign_float_z_buffer(ImBuf *ibuf, float *buffer_data, ImBufOwnership ownership)
|
|
||||||
{
|
|
||||||
imb_free_buffer(ibuf->float_z_buffer);
|
|
||||||
ibuf->flags &= ~IB_zbuffloat;
|
|
||||||
|
|
||||||
if (buffer_data) {
|
|
||||||
ibuf->float_z_buffer.ownership = ownership;
|
|
||||||
ibuf->float_z_buffer.data = buffer_data;
|
|
||||||
|
|
||||||
ibuf->flags |= IB_zbuffloat;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImBuf *IMB_allocFromBufferOwn(
|
ImBuf *IMB_allocFromBufferOwn(
|
||||||
uint8_t *byte_buffer, float *float_buffer, uint w, uint h, uint channels)
|
uint8_t *byte_buffer, float *float_buffer, uint w, uint h, uint channels)
|
||||||
{
|
{
|
||||||
|
@ -711,18 +610,6 @@ bool IMB_initImBuf(ImBuf *ibuf, uint x, uint y, uchar planes, uint flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & IB_zbuf) {
|
|
||||||
if (addzbufImBuf(ibuf) == false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & IB_zbuffloat) {
|
|
||||||
if (addzbuffloatImBuf(ibuf) == false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* assign default spaces */
|
/* assign default spaces */
|
||||||
colormanage_imbuf_set_default_spaces(ibuf);
|
colormanage_imbuf_set_default_spaces(ibuf);
|
||||||
|
|
||||||
|
@ -747,12 +634,6 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
|
||||||
if (ibuf1->float_buffer.data) {
|
if (ibuf1->float_buffer.data) {
|
||||||
flags |= IB_rectfloat;
|
flags |= IB_rectfloat;
|
||||||
}
|
}
|
||||||
if (ibuf1->z_buffer.data) {
|
|
||||||
flags |= IB_zbuf;
|
|
||||||
}
|
|
||||||
if (ibuf1->float_z_buffer.data) {
|
|
||||||
flags |= IB_zbuffloat;
|
|
||||||
}
|
|
||||||
|
|
||||||
x = ibuf1->x;
|
x = ibuf1->x;
|
||||||
y = ibuf1->y;
|
y = ibuf1->y;
|
||||||
|
@ -772,14 +653,6 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
|
||||||
size_t(ibuf1->channels) * x * y * sizeof(float));
|
size_t(ibuf1->channels) * x * y * sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & IB_zbuf) {
|
|
||||||
memcpy(ibuf2->z_buffer.data, ibuf1->z_buffer.data, size_t(x) * y * sizeof(int));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & IB_zbuffloat) {
|
|
||||||
memcpy(ibuf2->float_buffer.data, ibuf1->float_buffer.data, size_t(x) * y * sizeof(float));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ibuf1->encoded_buffer.data) {
|
if (ibuf1->encoded_buffer.data) {
|
||||||
ibuf2->encoded_buffer_size = ibuf1->encoded_buffer_size;
|
ibuf2->encoded_buffer_size = ibuf1->encoded_buffer_size;
|
||||||
if (imb_addencodedbufferImBuf(ibuf2) == false) {
|
if (imb_addencodedbufferImBuf(ibuf2) == false) {
|
||||||
|
@ -800,8 +673,6 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
|
||||||
tbuf.byte_buffer = ibuf2->byte_buffer;
|
tbuf.byte_buffer = ibuf2->byte_buffer;
|
||||||
tbuf.float_buffer = ibuf2->float_buffer;
|
tbuf.float_buffer = ibuf2->float_buffer;
|
||||||
tbuf.encoded_buffer = ibuf2->encoded_buffer;
|
tbuf.encoded_buffer = ibuf2->encoded_buffer;
|
||||||
tbuf.z_buffer = ibuf2->z_buffer;
|
|
||||||
tbuf.float_z_buffer = ibuf2->float_z_buffer;
|
|
||||||
for (a = 0; a < IMB_MIPMAP_LEVELS; a++) {
|
for (a = 0; a < IMB_MIPMAP_LEVELS; a++) {
|
||||||
tbuf.mipmap[a] = nullptr;
|
tbuf.mipmap[a] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,29 +201,6 @@ static void readtab(MFileOffset *inf, uint *tab, int len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_endian_zbuf(ImBuf *ibuf)
|
|
||||||
{
|
|
||||||
int len;
|
|
||||||
int *zval;
|
|
||||||
|
|
||||||
/* `BIG_LONG(1) == 1`, no change needed. */
|
|
||||||
#ifdef __BIG_ENDIAN__
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ibuf->z_buffer.data == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
len = ibuf->x * ibuf->y;
|
|
||||||
zval = ibuf->z_buffer.data;
|
|
||||||
|
|
||||||
while (len--) {
|
|
||||||
zval[0] = BIG_LONG(zval[0]);
|
|
||||||
zval++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* From misc_util: flip the bytes from x. */
|
/* From misc_util: flip the bytes from x. */
|
||||||
#define GS(x) (((uchar *)(x))[0] << 8 | ((uchar *)(x))[1])
|
#define GS(x) (((uchar *)(x))[0] << 8 | ((uchar *)(x))[1])
|
||||||
|
|
||||||
|
@ -242,7 +219,6 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
|
||||||
{
|
{
|
||||||
uint *base, *lptr = nullptr;
|
uint *base, *lptr = nullptr;
|
||||||
float *fbase, *fptr = nullptr;
|
float *fbase, *fptr = nullptr;
|
||||||
uint *zbase, *zptr;
|
|
||||||
const uchar *rledat;
|
const uchar *rledat;
|
||||||
const uchar *mem_end = mem + size;
|
const uchar *mem_end = mem + size;
|
||||||
MFileOffset _inf_data = {mem, 0}, *inf = &_inf_data;
|
MFileOffset _inf_data = {mem, 0}, *inf = &_inf_data;
|
||||||
|
@ -283,7 +259,9 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
|
||||||
|
|
||||||
const int xsize = image.xsize;
|
const int xsize = image.xsize;
|
||||||
const int ysize = image.ysize;
|
const int ysize = image.ysize;
|
||||||
const int zsize = image.zsize;
|
|
||||||
|
const int zsize_file = image.zsize;
|
||||||
|
const int zsize_read = min_ii(image.zsize, 4);
|
||||||
|
|
||||||
if (flags & IB_test) {
|
if (flags & IB_test) {
|
||||||
ibuf = IMB_allocImBuf(image.xsize, image.ysize, 8 * image.zsize, 0);
|
ibuf = IMB_allocImBuf(image.xsize, image.ysize, 8 * image.zsize, 0);
|
||||||
|
@ -294,7 +272,7 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rle) {
|
if (rle) {
|
||||||
size_t tablen = size_t(ysize) * size_t(zsize) * sizeof(int);
|
size_t tablen = size_t(ysize) * size_t(zsize_file) * sizeof(int);
|
||||||
MFILE_SEEK(inf, HEADER_SIZE);
|
MFILE_SEEK(inf, HEADER_SIZE);
|
||||||
|
|
||||||
uint *starttab = static_cast<uint *>(MEM_mallocN(tablen, "iris starttab"));
|
uint *starttab = static_cast<uint *>(MEM_mallocN(tablen, "iris starttab"));
|
||||||
|
@ -316,7 +294,7 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
|
||||||
cur = 0;
|
cur = 0;
|
||||||
badorder = 0;
|
badorder = 0;
|
||||||
for (size_t y = 0; y < ysize; y++) {
|
for (size_t y = 0; y < ysize; y++) {
|
||||||
for (size_t z = 0; z < zsize; z++) {
|
for (size_t z = 0; z < zsize_file; z++) {
|
||||||
if (starttab[y + z * ysize] < cur) {
|
if (starttab[y + z * ysize] < cur) {
|
||||||
badorder = 1;
|
badorder = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -330,7 +308,7 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
|
||||||
|
|
||||||
if (bpp == 1) {
|
if (bpp == 1) {
|
||||||
|
|
||||||
ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize, IB_rect);
|
ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize_read, IB_rect);
|
||||||
if (!ibuf) {
|
if (!ibuf) {
|
||||||
goto fail_rle;
|
goto fail_rle;
|
||||||
}
|
}
|
||||||
|
@ -338,10 +316,9 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
|
||||||
ibuf->planes = 32;
|
ibuf->planes = 32;
|
||||||
}
|
}
|
||||||
base = (uint *)ibuf->byte_buffer.data;
|
base = (uint *)ibuf->byte_buffer.data;
|
||||||
zbase = (uint *)ibuf->z_buffer.data;
|
|
||||||
|
|
||||||
if (badorder) {
|
if (badorder) {
|
||||||
for (size_t z = 0; z < zsize; z++) {
|
for (size_t z = 0; z < zsize_read; z++) {
|
||||||
lptr = base;
|
lptr = base;
|
||||||
for (size_t y = 0; y < ysize; y++) {
|
for (size_t y = 0; y < ysize; y++) {
|
||||||
MFILE_SEEK(inf, starttab[y + z * ysize]);
|
MFILE_SEEK(inf, starttab[y + z * ysize]);
|
||||||
|
@ -357,13 +334,11 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lptr = base;
|
lptr = base;
|
||||||
zptr = zbase;
|
|
||||||
for (size_t y = 0; y < ysize; y++) {
|
for (size_t y = 0; y < ysize; y++) {
|
||||||
|
|
||||||
uint *lptr_next = lptr + xsize;
|
uint *lptr_next = lptr + xsize;
|
||||||
uint *zptr_next = zptr + xsize;
|
|
||||||
|
|
||||||
for (size_t z = 0; z < zsize; z++) {
|
for (size_t z = 0; z < zsize_read; z++) {
|
||||||
MFILE_SEEK(inf, starttab[y + z * ysize]);
|
MFILE_SEEK(inf, starttab[y + z * ysize]);
|
||||||
rledat = MFILE_DATA(inf);
|
rledat = MFILE_DATA(inf);
|
||||||
MFILE_STEP(inf, lengthtab[y + z * ysize]);
|
MFILE_STEP(inf, lengthtab[y + z * ysize]);
|
||||||
|
@ -373,13 +348,11 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
|
||||||
dirty_flag |= expandrow(
|
dirty_flag |= expandrow(
|
||||||
(uchar *)lptr, (uchar *)lptr_next, rledat, rledat_next, 3 - z);
|
(uchar *)lptr, (uchar *)lptr_next, rledat, rledat_next, 3 - z);
|
||||||
}
|
}
|
||||||
else if (z < 8) {
|
else {
|
||||||
dirty_flag |= expandrow(
|
break;
|
||||||
(uchar *)zptr, (uchar *)zptr_next, rledat, rledat_next, 7 - z);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lptr = lptr_next;
|
lptr = lptr_next;
|
||||||
zptr = zptr_next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,7 +366,7 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
|
||||||
fbase = ibuf->float_buffer.data;
|
fbase = ibuf->float_buffer.data;
|
||||||
|
|
||||||
if (badorder) {
|
if (badorder) {
|
||||||
for (size_t z = 0; z < zsize; z++) {
|
for (size_t z = 0; z < zsize_read; z++) {
|
||||||
fptr = fbase;
|
fptr = fbase;
|
||||||
for (size_t y = 0; y < ysize; y++) {
|
for (size_t y = 0; y < ysize; y++) {
|
||||||
MFILE_SEEK(inf, starttab[y + z * ysize]);
|
MFILE_SEEK(inf, starttab[y + z * ysize]);
|
||||||
|
@ -413,7 +386,7 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
|
||||||
|
|
||||||
for (size_t y = 0; y < ysize; y++) {
|
for (size_t y = 0; y < ysize; y++) {
|
||||||
|
|
||||||
for (size_t z = 0; z < zsize; z++) {
|
for (size_t z = 0; z < zsize_read; z++) {
|
||||||
MFILE_SEEK(inf, starttab[y + z * ysize]);
|
MFILE_SEEK(inf, starttab[y + z * ysize]);
|
||||||
rledat = MFILE_DATA(inf);
|
rledat = MFILE_DATA(inf);
|
||||||
MFILE_STEP(inf, lengthtab[y + z * ysize]);
|
MFILE_STEP(inf, lengthtab[y + z * ysize]);
|
||||||
|
@ -445,7 +418,7 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
|
||||||
|
|
||||||
if (bpp == 1) {
|
if (bpp == 1) {
|
||||||
|
|
||||||
ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize, IB_rect);
|
ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize_read, IB_rect);
|
||||||
if (!ibuf) {
|
if (!ibuf) {
|
||||||
goto fail_uncompressed;
|
goto fail_uncompressed;
|
||||||
}
|
}
|
||||||
|
@ -454,18 +427,17 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
|
||||||
}
|
}
|
||||||
|
|
||||||
base = (uint *)ibuf->byte_buffer.data;
|
base = (uint *)ibuf->byte_buffer.data;
|
||||||
zbase = (uint *)ibuf->z_buffer.data;
|
|
||||||
|
|
||||||
MFILE_SEEK(inf, HEADER_SIZE);
|
MFILE_SEEK(inf, HEADER_SIZE);
|
||||||
rledat = MFILE_DATA(inf);
|
rledat = MFILE_DATA(inf);
|
||||||
|
|
||||||
for (size_t z = 0; z < zsize; z++) {
|
for (size_t z = 0; z < zsize_read; z++) {
|
||||||
|
|
||||||
if (z < 4) {
|
if (z < 4) {
|
||||||
lptr = base;
|
lptr = base;
|
||||||
}
|
}
|
||||||
else if (z < 8) {
|
else {
|
||||||
lptr = zbase;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t y = 0; y < ysize; y++) {
|
for (size_t y = 0; y < ysize; y++) {
|
||||||
|
@ -490,7 +462,7 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
|
||||||
MFILE_SEEK(inf, HEADER_SIZE);
|
MFILE_SEEK(inf, HEADER_SIZE);
|
||||||
rledat = MFILE_DATA(inf);
|
rledat = MFILE_DATA(inf);
|
||||||
|
|
||||||
for (size_t z = 0; z < zsize; z++) {
|
for (size_t z = 0; z < zsize_read; z++) {
|
||||||
|
|
||||||
fptr = fbase;
|
fptr = fbase;
|
||||||
|
|
||||||
|
@ -578,8 +550,6 @@ ImBuf *imb_loadiris(const uchar *mem, size_t size, int flags, char colorspace[IM
|
||||||
}
|
}
|
||||||
ibuf->ftype = IMB_FTYPE_IMAGIC;
|
ibuf->ftype = IMB_FTYPE_IMAGIC;
|
||||||
|
|
||||||
test_endian_zbuf(ibuf);
|
|
||||||
|
|
||||||
if (ibuf->byte_buffer.data) {
|
if (ibuf->byte_buffer.data) {
|
||||||
IMB_convert_rgba_to_abgr(ibuf);
|
IMB_convert_rgba_to_abgr(ibuf);
|
||||||
}
|
}
|
||||||
|
@ -963,22 +933,15 @@ static int compressrow(const uchar *lbuf, uchar *rlebuf, const int z, const int
|
||||||
|
|
||||||
bool imb_saveiris(ImBuf *ibuf, const char *filepath, int flags)
|
bool imb_saveiris(ImBuf *ibuf, const char *filepath, int flags)
|
||||||
{
|
{
|
||||||
short zsize;
|
const short zsize = (ibuf->planes + 7) >> 3;
|
||||||
|
|
||||||
zsize = (ibuf->planes + 7) >> 3;
|
|
||||||
if (flags & IB_zbuf && ibuf->z_buffer.data != nullptr) {
|
|
||||||
zsize = 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
IMB_convert_rgba_to_abgr(ibuf);
|
IMB_convert_rgba_to_abgr(ibuf);
|
||||||
test_endian_zbuf(ibuf);
|
|
||||||
|
|
||||||
const bool ok = output_iris(
|
const bool ok = output_iris(
|
||||||
filepath, (uint *)ibuf->byte_buffer.data, ibuf->z_buffer.data, ibuf->x, ibuf->y, zsize);
|
filepath, (uint *)ibuf->byte_buffer.data, nullptr, ibuf->x, ibuf->y, zsize);
|
||||||
|
|
||||||
/* restore! Quite clumsy, 2 times a switch... maybe better a malloc ? */
|
/* restore! Quite clumsy, 2 times a switch... maybe better a malloc ? */
|
||||||
IMB_convert_rgba_to_abgr(ibuf);
|
IMB_convert_rgba_to_abgr(ibuf);
|
||||||
test_endian_zbuf(ibuf);
|
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,6 @@ static struct ExrPass *imb_exr_get_pass(ListBase *lb, char *passname);
|
||||||
static bool exr_has_multiview(MultiPartInputFile &file);
|
static bool exr_has_multiview(MultiPartInputFile &file);
|
||||||
static bool exr_has_multipart_file(MultiPartInputFile &file);
|
static bool exr_has_multipart_file(MultiPartInputFile &file);
|
||||||
static bool exr_has_alpha(MultiPartInputFile &file);
|
static bool exr_has_alpha(MultiPartInputFile &file);
|
||||||
static bool exr_has_zbuffer(MultiPartInputFile &file);
|
|
||||||
static void exr_printf(const char *__restrict fmt, ...);
|
static void exr_printf(const char *__restrict fmt, ...);
|
||||||
static void imb_exr_type_by_channels(ChannelList &channels,
|
static void imb_exr_type_by_channels(ChannelList &channels,
|
||||||
StringVector &views,
|
StringVector &views,
|
||||||
|
@ -463,8 +462,6 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *filepath, const int f
|
||||||
{
|
{
|
||||||
const int channels = ibuf->channels;
|
const int channels = ibuf->channels;
|
||||||
const bool is_alpha = (channels >= 4) && (ibuf->planes == 32);
|
const bool is_alpha = (channels >= 4) && (ibuf->planes == 32);
|
||||||
const bool is_zbuf = (flags & IB_zbuffloat) &&
|
|
||||||
ibuf->float_z_buffer.data != nullptr; /* summarize */
|
|
||||||
const int width = ibuf->x;
|
const int width = ibuf->x;
|
||||||
const int height = ibuf->y;
|
const int height = ibuf->y;
|
||||||
OStream *file_stream = nullptr;
|
OStream *file_stream = nullptr;
|
||||||
|
@ -482,10 +479,6 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *filepath, const int f
|
||||||
if (is_alpha) {
|
if (is_alpha) {
|
||||||
header.channels().insert("A", Channel(HALF));
|
header.channels().insert("A", Channel(HALF));
|
||||||
}
|
}
|
||||||
if (is_zbuf) {
|
|
||||||
/* z we do as float always */
|
|
||||||
header.channels().insert("Z", Channel(Imf::FLOAT));
|
|
||||||
}
|
|
||||||
|
|
||||||
FrameBuffer frameBuffer;
|
FrameBuffer frameBuffer;
|
||||||
|
|
||||||
|
@ -511,13 +504,6 @@ static bool imb_save_openexr_half(ImBuf *ibuf, const char *filepath, const int f
|
||||||
if (is_alpha) {
|
if (is_alpha) {
|
||||||
frameBuffer.insert("A", Slice(HALF, (char *)&to->a, xstride, ystride));
|
frameBuffer.insert("A", Slice(HALF, (char *)&to->a, xstride, ystride));
|
||||||
}
|
}
|
||||||
if (is_zbuf) {
|
|
||||||
frameBuffer.insert("Z",
|
|
||||||
Slice(Imf::FLOAT,
|
|
||||||
(char *)(ibuf->float_z_buffer.data + (height - 1) * width),
|
|
||||||
sizeof(float),
|
|
||||||
sizeof(float) * -width));
|
|
||||||
}
|
|
||||||
if (ibuf->float_buffer.data) {
|
if (ibuf->float_buffer.data) {
|
||||||
float *from;
|
float *from;
|
||||||
|
|
||||||
|
@ -577,8 +563,6 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *filepath, const int
|
||||||
{
|
{
|
||||||
const int channels = ibuf->channels;
|
const int channels = ibuf->channels;
|
||||||
const bool is_alpha = (channels >= 4) && (ibuf->planes == 32);
|
const bool is_alpha = (channels >= 4) && (ibuf->planes == 32);
|
||||||
const bool is_zbuf = (flags & IB_zbuffloat) &&
|
|
||||||
ibuf->float_z_buffer.data != nullptr; /* summarize */
|
|
||||||
const int width = ibuf->x;
|
const int width = ibuf->x;
|
||||||
const int height = ibuf->y;
|
const int height = ibuf->y;
|
||||||
OStream *file_stream = nullptr;
|
OStream *file_stream = nullptr;
|
||||||
|
@ -596,9 +580,6 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *filepath, const int
|
||||||
if (is_alpha) {
|
if (is_alpha) {
|
||||||
header.channels().insert("A", Channel(Imf::FLOAT));
|
header.channels().insert("A", Channel(Imf::FLOAT));
|
||||||
}
|
}
|
||||||
if (is_zbuf) {
|
|
||||||
header.channels().insert("Z", Channel(Imf::FLOAT));
|
|
||||||
}
|
|
||||||
|
|
||||||
FrameBuffer frameBuffer;
|
FrameBuffer frameBuffer;
|
||||||
|
|
||||||
|
@ -629,13 +610,6 @@ static bool imb_save_openexr_float(ImBuf *ibuf, const char *filepath, const int
|
||||||
if (is_alpha) {
|
if (is_alpha) {
|
||||||
frameBuffer.insert("A", Slice(Imf::FLOAT, (char *)rect[3], xstride, ystride));
|
frameBuffer.insert("A", Slice(Imf::FLOAT, (char *)rect[3], xstride, ystride));
|
||||||
}
|
}
|
||||||
if (is_zbuf) {
|
|
||||||
frameBuffer.insert("Z",
|
|
||||||
Slice(Imf::FLOAT,
|
|
||||||
(char *)(ibuf->float_z_buffer.data + (height - 1) * width),
|
|
||||||
sizeof(float),
|
|
||||||
sizeof(float) * -width));
|
|
||||||
}
|
|
||||||
|
|
||||||
file.setFrameBuffer(frameBuffer);
|
file.setFrameBuffer(frameBuffer);
|
||||||
file.writePixels(height);
|
file.writePixels(height);
|
||||||
|
@ -1851,12 +1825,6 @@ static bool exr_has_chroma(MultiPartInputFile &file)
|
||||||
header.channels().findChannel("RY") != nullptr;
|
header.channels().findChannel("RY") != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool exr_has_zbuffer(MultiPartInputFile &file)
|
|
||||||
{
|
|
||||||
const Header &header = file.header(0);
|
|
||||||
return !(header.channels().findChannel("Z") == nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool exr_has_alpha(MultiPartInputFile &file)
|
static bool exr_has_alpha(MultiPartInputFile &file)
|
||||||
{
|
{
|
||||||
const Header &header = file.header(0);
|
const Header &header = file.header(0);
|
||||||
|
@ -2100,16 +2068,6 @@ ImBuf *imb_load_openexr(const uchar *mem, size_t size, int flags, char colorspac
|
||||||
frameBuffer.insert(exr_rgba_channelname(*file, "A"),
|
frameBuffer.insert(exr_rgba_channelname(*file, "A"),
|
||||||
Slice(Imf::FLOAT, (char *)(first + 3), xstride, ystride, 1, 1, 1.0f));
|
Slice(Imf::FLOAT, (char *)(first + 3), xstride, ystride, 1, 1, 1.0f));
|
||||||
|
|
||||||
if (exr_has_zbuffer(*file)) {
|
|
||||||
float *firstz;
|
|
||||||
|
|
||||||
addzbuffloatImBuf(ibuf);
|
|
||||||
firstz = ibuf->float_z_buffer.data - (dw.min.x - dw.min.y * width);
|
|
||||||
firstz += (height - 1) * width;
|
|
||||||
frameBuffer.insert(
|
|
||||||
"Z", Slice(Imf::FLOAT, (char *)firstz, sizeof(float), -width * sizeof(float)));
|
|
||||||
}
|
|
||||||
|
|
||||||
InputPart in(*file, 0);
|
InputPart in(*file, 0);
|
||||||
in.setFrameBuffer(frameBuffer);
|
in.setFrameBuffer(frameBuffer);
|
||||||
in.readPixels(dw.min.y, dw.max.y);
|
in.readPixels(dw.min.y, dw.max.y);
|
||||||
|
|
|
@ -255,8 +255,6 @@ void IMB_rect_crop(ImBuf *ibuf, const rcti *crop)
|
||||||
|
|
||||||
/* TODO(sergey: Validate ownership. */
|
/* TODO(sergey: Validate ownership. */
|
||||||
rect_crop_4bytes((void **)&ibuf->byte_buffer.data, size_src, crop);
|
rect_crop_4bytes((void **)&ibuf->byte_buffer.data, size_src, crop);
|
||||||
rect_crop_4bytes((void **)&ibuf->z_buffer.data, size_src, crop);
|
|
||||||
rect_crop_4bytes((void **)&ibuf->float_z_buffer.data, size_src, crop);
|
|
||||||
rect_crop_16bytes((void **)&ibuf->float_buffer.data, size_src, crop);
|
rect_crop_16bytes((void **)&ibuf->float_buffer.data, size_src, crop);
|
||||||
|
|
||||||
ibuf->x = size_dst[0];
|
ibuf->x = size_dst[0];
|
||||||
|
@ -293,8 +291,6 @@ void IMB_rect_size_set(ImBuf *ibuf, const uint size[2])
|
||||||
|
|
||||||
/* TODO(sergey: Validate ownership. */
|
/* TODO(sergey: Validate ownership. */
|
||||||
rect_realloc_4bytes((void **)&ibuf->byte_buffer.data, size);
|
rect_realloc_4bytes((void **)&ibuf->byte_buffer.data, size);
|
||||||
rect_realloc_4bytes((void **)&ibuf->z_buffer.data, size);
|
|
||||||
rect_realloc_4bytes((void **)&ibuf->float_z_buffer.data, size);
|
|
||||||
rect_realloc_16bytes((void **)&ibuf->float_buffer.data, size);
|
rect_realloc_16bytes((void **)&ibuf->float_buffer.data, size);
|
||||||
|
|
||||||
ibuf->x = size[0];
|
ibuf->x = size[0];
|
||||||
|
|
|
@ -1565,70 +1565,6 @@ static ImBuf *scaleupy(ImBuf *ibuf, int newy)
|
||||||
return ibuf;
|
return ibuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy)
|
|
||||||
{
|
|
||||||
int *zbuf, *newzbuf, *_newzbuf = nullptr;
|
|
||||||
float *zbuf_float, *newzbuf_float, *_newzbuf_float = nullptr;
|
|
||||||
int x, y;
|
|
||||||
int ofsx, ofsy, stepx, stepy;
|
|
||||||
|
|
||||||
if (ibuf->z_buffer.data) {
|
|
||||||
_newzbuf = static_cast<int *>(MEM_mallocN(newx * newy * sizeof(int), __func__));
|
|
||||||
if (_newzbuf == nullptr) {
|
|
||||||
IMB_freezbufImBuf(ibuf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ibuf->float_z_buffer.data) {
|
|
||||||
_newzbuf_float = static_cast<float *>(
|
|
||||||
MEM_mallocN(size_t(newx) * newy * sizeof(float), __func__));
|
|
||||||
if (_newzbuf_float == nullptr) {
|
|
||||||
IMB_freezbuffloatImBuf(ibuf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_newzbuf && !_newzbuf_float) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
stepx = round(65536.0 * (ibuf->x - 1.0) / (newx - 1.0));
|
|
||||||
stepy = round(65536.0 * (ibuf->y - 1.0) / (newy - 1.0));
|
|
||||||
ofsy = 32768;
|
|
||||||
|
|
||||||
newzbuf = _newzbuf;
|
|
||||||
newzbuf_float = _newzbuf_float;
|
|
||||||
|
|
||||||
for (y = newy; y > 0; y--, ofsy += stepy) {
|
|
||||||
if (newzbuf) {
|
|
||||||
zbuf = ibuf->z_buffer.data;
|
|
||||||
zbuf += (ofsy >> 16) * ibuf->x;
|
|
||||||
ofsx = 32768;
|
|
||||||
for (x = newx; x > 0; x--, ofsx += stepx) {
|
|
||||||
*newzbuf++ = zbuf[ofsx >> 16];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newzbuf_float) {
|
|
||||||
zbuf_float = ibuf->float_z_buffer.data;
|
|
||||||
zbuf_float += (ofsy >> 16) * ibuf->x;
|
|
||||||
ofsx = 32768;
|
|
||||||
for (x = newx; x > 0; x--, ofsx += stepx) {
|
|
||||||
*newzbuf_float++ = zbuf_float[ofsx >> 16];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_newzbuf) {
|
|
||||||
IMB_freezbufImBuf(ibuf);
|
|
||||||
IMB_assign_z_buffer(ibuf, _newzbuf, IB_TAKE_OWNERSHIP);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_newzbuf_float) {
|
|
||||||
IMB_freezbuffloatImBuf(ibuf);
|
|
||||||
IMB_assign_float_z_buffer(ibuf, _newzbuf_float, IB_TAKE_OWNERSHIP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IMB_scaleImBuf(ImBuf *ibuf, uint newx, uint newy)
|
bool IMB_scaleImBuf(ImBuf *ibuf, uint newx, uint newy)
|
||||||
{
|
{
|
||||||
BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!");
|
BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!");
|
||||||
|
@ -1644,10 +1580,6 @@ bool IMB_scaleImBuf(ImBuf *ibuf, uint newx, uint newy)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scale-up / scale-down functions below change ibuf->x and ibuf->y
|
|
||||||
* so we first scale the Z-buffer (if any). */
|
|
||||||
scalefast_Z_ImBuf(ibuf, newx, newy);
|
|
||||||
|
|
||||||
/* try to scale common cases in a fast way */
|
/* try to scale common cases in a fast way */
|
||||||
/* disabled, quality loss is unacceptable, see report #18609 (ton) */
|
/* disabled, quality loss is unacceptable, see report #18609 (ton) */
|
||||||
if (0 && q_scale_linear_interpolation(ibuf, newx, newy)) {
|
if (0 && q_scale_linear_interpolation(ibuf, newx, newy)) {
|
||||||
|
@ -1764,8 +1696,6 @@ bool IMB_scalefastImBuf(ImBuf *ibuf, uint newx, uint newy)
|
||||||
IMB_assign_float_buffer(ibuf, reinterpret_cast<float *>(_newrectf), IB_TAKE_OWNERSHIP);
|
IMB_assign_float_buffer(ibuf, reinterpret_cast<float *>(_newrectf), IB_TAKE_OWNERSHIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
scalefast_Z_ImBuf(ibuf, newx, newy);
|
|
||||||
|
|
||||||
ibuf->x = newx;
|
ibuf->x = newx;
|
||||||
ibuf->y = newy;
|
ibuf->y = newy;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1339,31 +1339,6 @@ void IMB_ImBufFromStereo3d(const Stereo3dFormat *s3d,
|
||||||
|
|
||||||
imb_stereo3d_read_doit(&s3d_data, s3d);
|
imb_stereo3d_read_doit(&s3d_data, s3d);
|
||||||
|
|
||||||
if (ibuf_stereo3d->flags & (IB_zbuf | IB_zbuffloat)) {
|
|
||||||
if (is_float) {
|
|
||||||
addzbuffloatImBuf(ibuf_left);
|
|
||||||
addzbuffloatImBuf(ibuf_right);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addzbufImBuf(ibuf_left);
|
|
||||||
addzbufImBuf(ibuf_right);
|
|
||||||
}
|
|
||||||
|
|
||||||
imb_stereo3d_data_init(&s3d_data,
|
|
||||||
is_float,
|
|
||||||
ibuf_left->x,
|
|
||||||
ibuf_left->y,
|
|
||||||
1,
|
|
||||||
ibuf_left->z_buffer.data,
|
|
||||||
ibuf_right->z_buffer.data,
|
|
||||||
ibuf_stereo3d->z_buffer.data,
|
|
||||||
ibuf_left->float_z_buffer.data,
|
|
||||||
ibuf_right->float_z_buffer.data,
|
|
||||||
ibuf_stereo3d->float_z_buffer.data);
|
|
||||||
|
|
||||||
imb_stereo3d_read_doit(&s3d_data, s3d);
|
|
||||||
}
|
|
||||||
|
|
||||||
IMB_freeImBuf(ibuf_stereo3d);
|
IMB_freeImBuf(ibuf_stereo3d);
|
||||||
|
|
||||||
*r_ibuf_left = ibuf_left;
|
*r_ibuf_left = ibuf_left;
|
||||||
|
|
|
@ -505,7 +505,7 @@ enum {
|
||||||
|
|
||||||
/** #ImageFormatData::flag */
|
/** #ImageFormatData::flag */
|
||||||
enum {
|
enum {
|
||||||
R_IMF_FLAG_ZBUF = 1 << 0,
|
// R_IMF_FLAG_ZBUF = 1 << 0, /* DEPRECATED, and cleared. */
|
||||||
R_IMF_FLAG_PREVIEW_JPG = 1 << 1,
|
R_IMF_FLAG_PREVIEW_JPG = 1 << 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5907,13 +5907,6 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna)
|
||||||
"100 = maximum lossless compression with slow file output");
|
"100 = maximum lossless compression with slow file output");
|
||||||
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
|
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
|
||||||
|
|
||||||
/* flag */
|
|
||||||
prop = RNA_def_property(srna, "use_zbuffer", PROP_BOOLEAN, PROP_NONE);
|
|
||||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", R_IMF_FLAG_ZBUF);
|
|
||||||
RNA_def_property_ui_text(
|
|
||||||
prop, "Z Buffer", "Save the z-depth per pixel (32-bit unsigned integer z-buffer)");
|
|
||||||
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
|
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "use_preview", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "use_preview", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", R_IMF_FLAG_PREVIEW_JPG);
|
RNA_def_property_boolean_sdna(prop, nullptr, "flag", R_IMF_FLAG_PREVIEW_JPG);
|
||||||
RNA_def_property_ui_text(
|
RNA_def_property_ui_text(
|
||||||
|
|
|
@ -1664,7 +1664,6 @@ void RNA_api_ui_layout(StructRNA *srna)
|
||||||
parm = RNA_def_pointer(func, "image_settings", "ImageFormatSettings", "", "");
|
parm = RNA_def_pointer(func, "image_settings", "ImageFormatSettings", "", "");
|
||||||
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
||||||
RNA_def_boolean(func, "color_management", false, "", "Show color management settings");
|
RNA_def_boolean(func, "color_management", false, "", "Show color management settings");
|
||||||
RNA_def_boolean(func, "show_z_buffer", true, "", "Show option to save z-buffer");
|
|
||||||
|
|
||||||
func = RNA_def_function(srna, "template_image_stereo_3d", "uiTemplateImageStereo3d");
|
func = RNA_def_function(srna, "template_image_stereo_3d", "uiTemplateImageStereo3d");
|
||||||
RNA_def_function_ui_description(func, "User interface for setting image stereo 3d options");
|
RNA_def_function_ui_description(func, "User interface for setting image stereo 3d options");
|
||||||
|
|
|
@ -28,7 +28,6 @@ static void cmp_node_composite_declare(NodeDeclarationBuilder &b)
|
||||||
{
|
{
|
||||||
b.add_input<decl::Color>("Image").default_value({0.0f, 0.0f, 0.0f, 1.0f});
|
b.add_input<decl::Color>("Image").default_value({0.0f, 0.0f, 0.0f, 1.0f});
|
||||||
b.add_input<decl::Float>("Alpha").default_value(1.0f).min(0.0f).max(1.0f);
|
b.add_input<decl::Float>("Alpha").default_value(1.0f).min(0.0f).max(1.0f);
|
||||||
b.add_input<decl::Float>("Z").default_value(1.0f).min(0.0f).max(1.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void node_composit_buts_composite(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
|
static void node_composit_buts_composite(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
|
||||||
|
|
|
@ -209,17 +209,6 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree,
|
||||||
&prev_index);
|
&prev_index);
|
||||||
|
|
||||||
if (ima) {
|
if (ima) {
|
||||||
if (!ima->rr) {
|
|
||||||
cmp_node_image_add_pass_output(ntree,
|
|
||||||
node,
|
|
||||||
RE_PASSNAME_Z,
|
|
||||||
RE_PASSNAME_Z,
|
|
||||||
-1,
|
|
||||||
SOCK_FLOAT,
|
|
||||||
false,
|
|
||||||
available_sockets,
|
|
||||||
&prev_index);
|
|
||||||
}
|
|
||||||
BKE_image_release_ibuf(ima, ibuf, nullptr);
|
BKE_image_release_ibuf(ima, ibuf, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,11 +305,9 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi
|
||||||
const bool multilayer = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER;
|
const bool multilayer = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER;
|
||||||
const bool is_exr = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_OPENEXR;
|
const bool is_exr = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_OPENEXR;
|
||||||
const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
|
const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
|
||||||
/* Unclear where to get z-information from, so deactivate it. */
|
|
||||||
const bool show_z_buffer = false;
|
|
||||||
|
|
||||||
node_composit_buts_file_output(layout, C, ptr);
|
node_composit_buts_file_output(layout, C, ptr);
|
||||||
uiTemplateImageSettings(layout, &imfptr, true, show_z_buffer);
|
uiTemplateImageSettings(layout, &imfptr, true);
|
||||||
|
|
||||||
/* disable stereo output for multilayer, too much work for something that no one will use */
|
/* disable stereo output for multilayer, too much work for something that no one will use */
|
||||||
/* if someone asks for that we can implement it */
|
/* if someone asks for that we can implement it */
|
||||||
|
@ -432,7 +430,7 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi
|
||||||
const bool use_color_management = RNA_boolean_get(&active_input_ptr, "save_as_render");
|
const bool use_color_management = RNA_boolean_get(&active_input_ptr, "save_as_render");
|
||||||
|
|
||||||
col = uiLayoutColumn(layout, false);
|
col = uiLayoutColumn(layout, false);
|
||||||
uiTemplateImageSettings(col, &imfptr, use_color_management, show_z_buffer);
|
uiTemplateImageSettings(col, &imfptr, use_color_management);
|
||||||
|
|
||||||
if (is_multiview) {
|
if (is_multiview) {
|
||||||
col = uiLayoutColumn(layout, false);
|
col = uiLayoutColumn(layout, false);
|
||||||
|
|
|
@ -33,7 +33,6 @@ static void cmp_node_viewer_declare(NodeDeclarationBuilder &b)
|
||||||
{
|
{
|
||||||
b.add_input<decl::Color>("Image").default_value({0.0f, 0.0f, 0.0f, 1.0f});
|
b.add_input<decl::Color>("Image").default_value({0.0f, 0.0f, 0.0f, 1.0f});
|
||||||
b.add_input<decl::Float>("Alpha").default_value(1.0f).min(0.0f).max(1.0f);
|
b.add_input<decl::Float>("Alpha").default_value(1.0f).min(0.0f).max(1.0f);
|
||||||
b.add_input<decl::Float>("Z").default_value(1.0f).min(0.0f).max(1.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void node_composit_init_viewer(bNodeTree * /*ntree*/, bNode *node)
|
static void node_composit_init_viewer(bNodeTree * /*ntree*/, bNode *node)
|
||||||
|
|
|
@ -330,7 +330,6 @@ class Context : public realtime_compositor::Context {
|
||||||
if (image_buffer->x != render_size.x || image_buffer->y != render_size.y) {
|
if (image_buffer->x != render_size.x || image_buffer->y != render_size.y) {
|
||||||
imb_freerectImBuf(image_buffer);
|
imb_freerectImBuf(image_buffer);
|
||||||
imb_freerectfloatImBuf(image_buffer);
|
imb_freerectfloatImBuf(image_buffer);
|
||||||
IMB_freezbuffloatImBuf(image_buffer);
|
|
||||||
image_buffer->x = render_size.x;
|
image_buffer->x = render_size.x;
|
||||||
image_buffer->y = render_size.y;
|
image_buffer->y = render_size.y;
|
||||||
imb_addrectfloatImBuf(image_buffer, 4);
|
imb_addrectfloatImBuf(image_buffer, 4);
|
||||||
|
|
|
@ -1003,7 +1003,6 @@ ImBuf *RE_render_result_rect_to_ibuf(RenderResult *rr,
|
||||||
/* if not exists, BKE_imbuf_write makes one */
|
/* if not exists, BKE_imbuf_write makes one */
|
||||||
IMB_assign_shared_byte_buffer(ibuf, rv->byte_buffer.data, rv->byte_buffer.sharing_info);
|
IMB_assign_shared_byte_buffer(ibuf, rv->byte_buffer.data, rv->byte_buffer.sharing_info);
|
||||||
IMB_assign_shared_float_buffer(ibuf, rv->combined_buffer.data, rv->combined_buffer.sharing_info);
|
IMB_assign_shared_float_buffer(ibuf, rv->combined_buffer.data, rv->combined_buffer.sharing_info);
|
||||||
IMB_assign_shared_float_z_buffer(ibuf, rv->z_buffer.data, rv->z_buffer.sharing_info);
|
|
||||||
|
|
||||||
/* float factor for random dither, imbuf takes care of it */
|
/* float factor for random dither, imbuf takes care of it */
|
||||||
ibuf->dither = dither;
|
ibuf->dither = dither;
|
||||||
|
|
|
@ -306,7 +306,7 @@ static void seq_proxy_build_frame(const SeqRenderData *context,
|
||||||
|
|
||||||
BLI_file_ensure_parent_dir_exists(filepath);
|
BLI_file_ensure_parent_dir_exists(filepath);
|
||||||
|
|
||||||
const bool ok = IMB_saveiff(ibuf, filepath, IB_rect | IB_zbuf | IB_zbuffloat);
|
const bool ok = IMB_saveiff(ibuf, filepath, IB_rect);
|
||||||
if (ok == false) {
|
if (ok == false) {
|
||||||
perror(filepath);
|
perror(filepath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1581,11 +1581,6 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
|
||||||
IMB_assign_shared_float_buffer(
|
IMB_assign_shared_float_buffer(
|
||||||
ibufs_arr[view_id], rres.combined_buffer.data, rres.combined_buffer.sharing_info);
|
ibufs_arr[view_id], rres.combined_buffer.data, rres.combined_buffer.sharing_info);
|
||||||
|
|
||||||
if (rres.z_buffer.data) {
|
|
||||||
IMB_assign_shared_float_z_buffer(
|
|
||||||
ibufs_arr[view_id], rres.z_buffer.data, rres.z_buffer.sharing_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* float buffers in the sequencer are not linear */
|
/* float buffers in the sequencer are not linear */
|
||||||
seq_imbuf_to_sequencer_space(context->scene, ibufs_arr[view_id], false);
|
seq_imbuf_to_sequencer_space(context->scene, ibufs_arr[view_id], false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Change 3 to 2.