PoolVector is gone, replaced by Vector

Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are
sugar for `Vector<Type>`.
This commit is contained in:
Juan Linietsky
2020-02-17 18:06:54 -03:00
committed by Juan Linietsky
parent fb8c93c10b
commit 3205a92ad8
406 changed files with 5314 additions and 8271 deletions

View File

@ -101,16 +101,16 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) {
}
const png_uint_32 stride = PNG_IMAGE_ROW_STRIDE(png_img);
PoolVector<uint8_t> buffer;
Vector<uint8_t> buffer;
Error err = buffer.resize(PNG_IMAGE_BUFFER_SIZE(png_img, stride));
if (err) {
png_image_free(&png_img); // only required when we return before finish_read
return err;
}
PoolVector<uint8_t>::Write writer = buffer.write();
uint8_t *writer = buffer.ptrw();
// read image data to buffer and release libpng resources
success = png_image_finish_read(&png_img, NULL, writer.ptr(), stride, NULL);
success = png_image_finish_read(&png_img, NULL, writer, stride, NULL);
ERR_FAIL_COND_V_MSG(check_error(png_img), ERR_FILE_CORRUPT, png_img.message);
ERR_FAIL_COND_V(!success, ERR_FILE_CORRUPT);
@ -120,7 +120,7 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) {
return OK;
}
Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) {
Error image_to_png(const Ref<Image> &p_image, Vector<uint8_t> &p_buffer) {
Ref<Image> source_image = p_image->duplicate();
@ -158,8 +158,8 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) {
}
}
const PoolVector<uint8_t> image_data = source_image->get_data();
const PoolVector<uint8_t>::Read reader = image_data.read();
const Vector<uint8_t> image_data = source_image->get_data();
const uint8_t *reader = image_data.ptr();
// we may be passed a buffer with existing content we're expected to append to
const int buffer_offset = p_buffer.size();
@ -173,9 +173,9 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) {
Error err = p_buffer.resize(buffer_offset + png_size_estimate);
ERR_FAIL_COND_V(err, err);
PoolVector<uint8_t>::Write writer = p_buffer.write();
uint8_t *writer = p_buffer.ptrw();
success = png_image_write_to_memory(&png_img, &writer[buffer_offset],
&compressed_size, 0, reader.ptr(), 0, NULL);
&compressed_size, 0, reader, 0, NULL);
ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message);
}
if (!success) {
@ -187,9 +187,9 @@ Error image_to_png(const Ref<Image> &p_image, PoolVector<uint8_t> &p_buffer) {
Error err = p_buffer.resize(buffer_offset + compressed_size);
ERR_FAIL_COND_V(err, err);
PoolVector<uint8_t>::Write writer = p_buffer.write();
uint8_t *writer = p_buffer.ptrw();
success = png_image_write_to_memory(&png_img, &writer[buffer_offset],
&compressed_size, 0, reader.ptr(), 0, NULL);
&compressed_size, 0, reader, 0, NULL);
ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message);
ERR_FAIL_COND_V(!success, FAILED);
}