diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-01-07 18:25:37 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-01-07 18:26:38 -0300 |
commit | 2ab83e1abbf5ee6d00e16056a9e9394114026f28 (patch) | |
tree | 7efbb375cc4d00d8e8589fcf1b6a1303bec5df2d /drivers/png | |
parent | 2a38a5eaa844043b846e03d6655f84caf8a31e74 (diff) |
Memory pool vectors (DVector) have been enormously simplified in code, and renamed to PoolVector
Diffstat (limited to 'drivers/png')
-rw-r--r-- | drivers/png/image_loader_png.cpp | 32 | ||||
-rw-r--r-- | drivers/png/resource_saver_png.cpp | 2 |
2 files changed, 17 insertions, 17 deletions
diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp index d74a12ba93..de095c20ac 100644 --- a/drivers/png/image_loader_png.cpp +++ b/drivers/png/image_loader_png.cpp @@ -181,11 +181,11 @@ Error ImageLoaderPNG::_load_image(void *rf_up,png_rw_ptr p_func,Image *p_image) //int rowsize = png_get_rowbytes(png, info); int rowsize = components * width; - DVector<uint8_t> dstbuff; + PoolVector<uint8_t> dstbuff; dstbuff.resize( rowsize * height ); - DVector<uint8_t>::Write dstbuff_write = dstbuff.write(); + PoolVector<uint8_t>::Write dstbuff_write = dstbuff.write(); uint8_t* data = dstbuff_write.ptr(); @@ -265,10 +265,10 @@ static Image _load_mem_png(const uint8_t* p_png,int p_size) { } -static Image _lossless_unpack_png(const DVector<uint8_t>& p_data) { +static Image _lossless_unpack_png(const PoolVector<uint8_t>& p_data) { int len = p_data.size(); - DVector<uint8_t>::Read r = p_data.read(); + PoolVector<uint8_t>::Read r = p_data.read(); ERR_FAIL_COND_V(r[0]!='P' || r[1]!='N' || r[2]!='G' || r[3]!=' ',Image()); return _load_mem_png(&r[4],len-4); @@ -276,17 +276,17 @@ static Image _lossless_unpack_png(const DVector<uint8_t>& p_data) { static void _write_png_data(png_structp png_ptr,png_bytep data, png_size_t p_length) { - DVector<uint8_t> &v = *(DVector<uint8_t>*)png_get_io_ptr(png_ptr); + PoolVector<uint8_t> &v = *(PoolVector<uint8_t>*)png_get_io_ptr(png_ptr); int vs = v.size(); v.resize(vs+p_length); - DVector<uint8_t>::Write w = v.write(); + PoolVector<uint8_t>::Write w = v.write(); copymem(&w[vs],data,p_length); //print_line("png write: "+itos(p_length)); } -static DVector<uint8_t> _lossless_pack_png(const Image& p_image) { +static PoolVector<uint8_t> _lossless_pack_png(const Image& p_image) { Image img = p_image; @@ -294,7 +294,7 @@ static DVector<uint8_t> _lossless_pack_png(const Image& p_image) { img.decompress(); - ERR_FAIL_COND_V(img.is_compressed(), DVector<uint8_t>()); + ERR_FAIL_COND_V(img.is_compressed(), PoolVector<uint8_t>()); png_structp png_ptr; png_infop info_ptr; @@ -304,16 +304,16 @@ static DVector<uint8_t> _lossless_pack_png(const Image& p_image) { /* initialize stuff */ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - ERR_FAIL_COND_V(!png_ptr,DVector<uint8_t>()); + ERR_FAIL_COND_V(!png_ptr,PoolVector<uint8_t>()); info_ptr = png_create_info_struct(png_ptr); - ERR_FAIL_COND_V(!info_ptr,DVector<uint8_t>()); + ERR_FAIL_COND_V(!info_ptr,PoolVector<uint8_t>()); if (setjmp(png_jmpbuf(png_ptr))) { - ERR_FAIL_V(DVector<uint8_t>()); + ERR_FAIL_V(PoolVector<uint8_t>()); } - DVector<uint8_t> ret; + PoolVector<uint8_t> ret; ret.push_back('P'); ret.push_back('N'); ret.push_back('G'); @@ -323,7 +323,7 @@ static DVector<uint8_t> _lossless_pack_png(const Image& p_image) { /* write header */ if (setjmp(png_jmpbuf(png_ptr))) { - ERR_FAIL_V(DVector<uint8_t>()); + ERR_FAIL_V(PoolVector<uint8_t>()); } int pngf=0; @@ -379,11 +379,11 @@ static DVector<uint8_t> _lossless_pack_png(const Image& p_image) { /* write bytes */ if (setjmp(png_jmpbuf(png_ptr))) { - ERR_FAIL_V(DVector<uint8_t>()); + ERR_FAIL_V(PoolVector<uint8_t>()); } - DVector<uint8_t>::Read r = img.get_data().read(); + PoolVector<uint8_t>::Read r = img.get_data().read(); row_pointers = (png_bytep*)memalloc(sizeof(png_bytep)*h); for(int i=0;i<h;i++) { @@ -397,7 +397,7 @@ static DVector<uint8_t> _lossless_pack_png(const Image& p_image) { /* end write */ if (setjmp(png_jmpbuf(png_ptr))) { - ERR_FAIL_V(DVector<uint8_t>()); + ERR_FAIL_V(PoolVector<uint8_t>()); } png_write_end(png_ptr, NULL); diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index b06b02b200..a9a199bb59 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -193,7 +193,7 @@ Error ResourceSaverPNG::save_image(const String &p_path, Image &p_img) { } - DVector<uint8_t>::Read r = p_img.get_data().read(); + PoolVector<uint8_t>::Read r = p_img.get_data().read(); row_pointers = (png_bytep*)memalloc(sizeof(png_bytep)*h); for(int i=0;i<h;i++) { |