summaryrefslogtreecommitdiff
path: root/modules/tinyexr
diff options
context:
space:
mode:
Diffstat (limited to 'modules/tinyexr')
-rw-r--r--modules/tinyexr/image_loader_tinyexr.cpp18
-rw-r--r--modules/tinyexr/image_saver_tinyexr.cpp24
2 files changed, 20 insertions, 22 deletions
diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp
index 79cb135abb..41938f5b42 100644
--- a/modules/tinyexr/image_loader_tinyexr.cpp
+++ b/modules/tinyexr/image_loader_tinyexr.cpp
@@ -37,12 +37,12 @@
Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
- PoolVector<uint8_t> src_image;
+ Vector<uint8_t> src_image;
int src_image_len = f->get_len();
ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
src_image.resize(src_image_len);
- PoolVector<uint8_t>::Write w = src_image.write();
+ uint8_t *w = src_image.ptrw();
f->get_buffer(&w[0], src_image_len);
@@ -60,13 +60,13 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
InitEXRHeader(&exr_header);
- int ret = ParseEXRVersionFromMemory(&exr_version, w.ptr(), src_image_len);
+ int ret = ParseEXRVersionFromMemory(&exr_version, w, src_image_len);
if (ret != TINYEXR_SUCCESS) {
return ERR_FILE_CORRUPT;
}
- ret = ParseEXRHeaderFromMemory(&exr_header, &exr_version, w.ptr(), src_image_len, &err);
+ ret = ParseEXRHeaderFromMemory(&exr_header, &exr_version, w, src_image_len, &err);
if (ret != TINYEXR_SUCCESS) {
if (err) {
ERR_PRINT(String(err));
@@ -82,7 +82,7 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
}
InitEXRImage(&exr_image);
- ret = LoadEXRImageFromMemory(&exr_image, &exr_header, w.ptr(), src_image_len, &err);
+ ret = LoadEXRImageFromMemory(&exr_image, &exr_header, w, src_image_len, &err);
if (ret != TINYEXR_SUCCESS) {
if (err) {
ERR_PRINT(String(err));
@@ -136,7 +136,7 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
// EXR image data loaded, now parse it into Godot-friendly image data
- PoolVector<uint8_t> imgdata;
+ Vector<uint8_t> imgdata;
Image::Format format;
int output_channels = 0;
@@ -180,8 +180,8 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
}
{
- PoolVector<uint8_t>::Write wd = imgdata.write();
- uint16_t *iw = (uint16_t *)wd.ptr();
+ uint8_t *wd = imgdata.ptrw();
+ uint16_t *iw = (uint16_t *)wd;
// Assume `out_rgba` have enough memory allocated.
for (int tile_index = 0; tile_index < num_tiles; tile_index++) {
@@ -235,8 +235,6 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
p_image->create(exr_image.width, exr_image.height, false, format, imgdata);
- w.release();
-
FreeEXRHeader(&exr_header);
FreeEXRImage(&exr_image);
diff --git a/modules/tinyexr/image_saver_tinyexr.cpp b/modules/tinyexr/image_saver_tinyexr.cpp
index a0c01f7e65..05080289bd 100644
--- a/modules/tinyexr/image_saver_tinyexr.cpp
+++ b/modules/tinyexr/image_saver_tinyexr.cpp
@@ -159,7 +159,7 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
// Godot does not support more than 4 channels,
// so we can preallocate header infos on the stack and use only the subset we need
- PoolByteArray channels[max_channels];
+ PackedByteArray channels[max_channels];
unsigned char *channels_ptrs[max_channels];
EXRChannelInfo channel_infos[max_channels];
int pixel_types[max_channels];
@@ -188,25 +188,25 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
const int *channel_mapping = channel_mappings[channel_count - 1];
{
- PoolByteArray src_data = p_img->get_data();
- PoolByteArray::Read src_r = src_data.read();
+ PackedByteArray src_data = p_img->get_data();
+ const uint8_t *src_r = src_data.ptr();
for (int channel_index = 0; channel_index < channel_count; ++channel_index) {
// De-interleave channels
- PoolByteArray &dst = channels[channel_index];
+ PackedByteArray &dst = channels[channel_index];
dst.resize(pixel_count * target_pixel_type_size);
- PoolByteArray::Write dst_w = dst.write();
+ uint8_t *dst_w = dst.ptrw();
if (src_pixel_type == SRC_FLOAT && target_pixel_type == TINYEXR_PIXELTYPE_FLOAT) {
// Note: we don't save mipmaps
CRASH_COND(src_data.size() < pixel_count * channel_count * target_pixel_type_size);
- const float *src_rp = (float *)src_r.ptr();
- float *dst_wp = (float *)dst_w.ptr();
+ const float *src_rp = (float *)src_r;
+ float *dst_wp = (float *)dst_w;
for (int i = 0; i < pixel_count; ++i) {
dst_wp[i] = src_rp[channel_index + i * channel_count];
@@ -216,8 +216,8 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
CRASH_COND(src_data.size() < pixel_count * channel_count * target_pixel_type_size);
- const uint16_t *src_rp = (uint16_t *)src_r.ptr();
- uint16_t *dst_wp = (uint16_t *)dst_w.ptr();
+ const uint16_t *src_rp = (uint16_t *)src_r;
+ uint16_t *dst_wp = (uint16_t *)dst_w;
for (int i = 0; i < pixel_count; ++i) {
dst_wp[i] = src_rp[channel_index + i * channel_count];
@@ -227,8 +227,8 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
CRASH_COND(src_data.size() < pixel_count * channel_count);
- const uint8_t *src_rp = (uint8_t *)src_r.ptr();
- uint16_t *dst_wp = (uint16_t *)dst_w.ptr();
+ const uint8_t *src_rp = (uint8_t *)src_r;
+ uint16_t *dst_wp = (uint16_t *)dst_w;
for (int i = 0; i < pixel_count; ++i) {
dst_wp[i] = Math::make_half_float(src_rp[channel_index + i * channel_count] / 255.f);
@@ -240,7 +240,7 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
int remapped_index = channel_mapping[channel_index];
- channels_ptrs[remapped_index] = dst_w.ptr();
+ channels_ptrs[remapped_index] = dst_w;
// No conversion
pixel_types[remapped_index] = target_pixel_type;