diff options
Diffstat (limited to 'modules/etc/texture_loader_pkm.cpp')
-rw-r--r-- | modules/etc/texture_loader_pkm.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp index 27c2358306..c40e9612a8 100644 --- a/modules/etc/texture_loader_pkm.cpp +++ b/modules/etc/texture_loader_pkm.cpp @@ -42,19 +42,21 @@ struct ETC1Header { uint16_t origHeight; }; -RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, Error *r_error) { - - if (r_error) +RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { + if (r_error) { *r_error = ERR_CANT_OPEN; + } Error err; FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err); - if (!f) + if (!f) { return RES(); + } FileAccessRef fref(f); - if (r_error) + if (r_error) { *r_error = ERR_FILE_CORRUPT; + } ERR_FAIL_COND_V_MSG(err != OK, RES(), "Unable to open PKM texture file '" + p_path + "'."); @@ -71,13 +73,12 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, h.origWidth = f->get_16(); h.origHeight = f->get_16(); - PoolVector<uint8_t> src_data; + Vector<uint8_t> src_data; uint32_t size = h.texWidth * h.texHeight / 2; src_data.resize(size); - PoolVector<uint8_t>::Write wb = src_data.write(); - f->get_buffer(wb.ptr(), size); - wb.release(); + uint8_t *wb = src_data.ptrw(); + f->get_buffer(wb, size); int mipmaps = h.format; int width = h.origWidth; @@ -88,8 +89,9 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, Ref<ImageTexture> texture = memnew(ImageTexture); texture->create_from_image(img); - if (r_error) + if (r_error) { *r_error = OK; + } f->close(); memdelete(f); @@ -97,18 +99,16 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, } void ResourceFormatPKM::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("pkm"); } bool ResourceFormatPKM::handles_type(const String &p_type) const { - - return ClassDB::is_parent_class(p_type, "Texture"); + return ClassDB::is_parent_class(p_type, "Texture2D"); } String ResourceFormatPKM::get_resource_type(const String &p_path) const { - - if (p_path.get_extension().to_lower() == "pkm") + if (p_path.get_extension().to_lower() == "pkm") { return "ImageTexture"; + } return ""; } |