diff options
Diffstat (limited to 'modules/pvr/texture_loader_pvr.cpp')
-rw-r--r-- | modules/pvr/texture_loader_pvr.cpp | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index 65c21d5af8..179c6f692b 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -51,7 +51,7 @@ enum PVRFLags { }; -RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path, Error *r_error) { +RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) { if (r_error) *r_error = ERR_CANT_OPEN; @@ -96,12 +96,12 @@ RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path, print_line("surfcount: "+itos(surfcount)); */ - PoolVector<uint8_t> data; + Vector<uint8_t> data; data.resize(surfsize); ERR_FAIL_COND_V(data.size() == 0, RES()); - PoolVector<uint8_t>::Write w = data.write(); + uint8_t *w = data.ptrw(); f->get_buffer(&w[0], surfsize); err = f->get_error(); ERR_FAIL_COND_V(err != OK, RES()); @@ -152,18 +152,11 @@ RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path, ERR_FAIL_V_MSG(RES(), "Unsupported format in PVR texture: " + itos(flags & 0xFF) + "."); } - w.release(); - - int tex_flags = Texture::FLAG_FILTER | Texture::FLAG_REPEAT; - - if (mipmaps) - tex_flags |= Texture::FLAG_MIPMAPS; - Ref<Image> image = memnew(Image(width, height, mipmaps, format, data)); ERR_FAIL_COND_V(image->empty(), RES()); Ref<ImageTexture> texture = memnew(ImageTexture); - texture->create_from_image(image, tex_flags); + texture->create_from_image(image); if (r_error) *r_error = OK; @@ -177,12 +170,12 @@ void ResourceFormatPVR::get_recognized_extensions(List<String> *p_extensions) co } bool ResourceFormatPVR::handles_type(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture"); + return ClassDB::is_parent_class(p_type, "Texture2D"); } String ResourceFormatPVR::get_resource_type(const String &p_path) const { if (p_path.get_extension().to_lower() == "pvr") - return "Texture"; + return "Texture2D"; return ""; } @@ -205,10 +198,10 @@ static void _compress_pvrtc4(Image *p_img) { new_img.instance(); new_img->create(img->get_width(), img->get_height(), img->has_mipmaps(), use_alpha ? Image::FORMAT_PVRTC4A : Image::FORMAT_PVRTC4); - PoolVector<uint8_t> data = new_img->get_data(); + Vector<uint8_t> data = new_img->get_data(); { - PoolVector<uint8_t>::Write wr = data.write(); - PoolVector<uint8_t>::Read r = img->get_data().read(); + uint8_t *wr = data.ptrw(); + const uint8_t *r = img->get_data().ptr(); for (int i = 0; i <= new_img->get_mipmap_count(); i++) { @@ -645,17 +638,14 @@ static void _pvrtc_decompress(Image *p_img) { bool _2bit = (p_img->get_format() == Image::FORMAT_PVRTC2 || p_img->get_format() == Image::FORMAT_PVRTC2A); - PoolVector<uint8_t> data = p_img->get_data(); - PoolVector<uint8_t>::Read r = data.read(); + Vector<uint8_t> data = p_img->get_data(); + const uint8_t *r = data.ptr(); - PoolVector<uint8_t> newdata; + Vector<uint8_t> newdata; newdata.resize(p_img->get_width() * p_img->get_height() * 4); - PoolVector<uint8_t>::Write w = newdata.write(); - - decompress_pvrtc((PVRTCBlock *)r.ptr(), _2bit, p_img->get_width(), p_img->get_height(), 0, (unsigned char *)w.ptr()); + uint8_t *w = newdata.ptrw(); - w.release(); - r.release(); + decompress_pvrtc((PVRTCBlock *)r, _2bit, p_img->get_width(), p_img->get_height(), 0, (unsigned char *)w); bool make_mipmaps = p_img->has_mipmaps(); p_img->create(p_img->get_width(), p_img->get_height(), false, Image::FORMAT_RGBA8, newdata); |