summaryrefslogtreecommitdiff
path: root/modules/basis_universal
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2020-02-17 18:06:54 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-02-18 10:10:36 +0100
commit3205a92ad872f918c8322cdcd1434c231a1fd251 (patch)
treedb44242ca27432eb8ea849679752d0835d2ae41a /modules/basis_universal
parentfb8c93c10b4b73d5f18f1ed287497728800e22b5 (diff)
PoolVector is gone, replaced by Vector
Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are sugar for `Vector<Type>`.
Diffstat (limited to 'modules/basis_universal')
-rw-r--r--modules/basis_universal/register_types.cpp28
-rw-r--r--modules/basis_universal/texture_basisu.cpp20
-rw-r--r--modules/basis_universal/texture_basisu.h6
3 files changed, 27 insertions, 27 deletions
diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp
index f5ae424b56..13f4d5fc48 100644
--- a/modules/basis_universal/register_types.cpp
+++ b/modules/basis_universal/register_types.cpp
@@ -52,9 +52,9 @@ enum BasisDecompressFormat {
basist::etc1_global_selector_codebook *sel_codebook = nullptr;
-static PoolVector<uint8_t> basis_universal_packer(const Ref<Image> &p_image, Image::UsedChannels p_channels) {
+static Vector<uint8_t> basis_universal_packer(const Ref<Image> &p_image, Image::UsedChannels p_channels) {
- PoolVector<uint8_t> budata;
+ Vector<uint8_t> budata;
#ifdef TOOLS_ENABLED
@@ -74,10 +74,10 @@ static PoolVector<uint8_t> basis_universal_packer(const Ref<Image> &p_image, Ima
basisu::image buimg(image->get_width(), image->get_height());
{
- PoolVector<uint8_t> vec = image->get_data();
- PoolVector<uint8_t>::Read r = vec.read();
+ Vector<uint8_t> vec = image->get_data();
+ const uint8_t *r = vec.ptr();
- memcpy(buimg.get_ptr(), r.ptr(), vec.size());
+ memcpy(buimg.get_ptr(), r, vec.size());
}
//image->save_png("pepeche.png");
@@ -145,10 +145,10 @@ static PoolVector<uint8_t> basis_universal_packer(const Ref<Image> &p_image, Ima
budata.resize(buvec.size() + 4);
{
- PoolVector<uint8_t>::Write w = budata.write();
- uint32_t *decf = (uint32_t *)w.ptr();
+ uint8_t *w = budata.ptrw();
+ uint32_t *decf = (uint32_t *)w;
*decf = decompress_format;
- memcpy(w.ptr() + 4, &buvec[0], buvec.size());
+ memcpy(w + 4, &buvec[0], buvec.size());
}
}
@@ -156,11 +156,11 @@ static PoolVector<uint8_t> basis_universal_packer(const Ref<Image> &p_image, Ima
return budata;
}
-static Ref<Image> basis_universal_unpacker(const PoolVector<uint8_t> &p_buffer) {
+static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
Ref<Image> image;
- PoolVector<uint8_t>::Read r = p_buffer.read();
- const uint8_t *ptr = r.ptr();
+ const uint8_t *r = p_buffer.ptr();
+ const uint8_t *ptr = r;
int size = p_buffer.size();
basist::transcoder_texture_format format;
@@ -241,12 +241,12 @@ static Ref<Image> basis_universal_unpacker(const PoolVector<uint8_t> &p_buffer)
tr.get_image_info(ptr, size, info, 0);
int block_size = basist::basis_get_bytes_per_block(format);
- PoolVector<uint8_t> gpudata;
+ Vector<uint8_t> gpudata;
gpudata.resize(info.m_total_blocks * block_size);
{
- PoolVector<uint8_t>::Write w = gpudata.write();
- uint8_t *dst = w.ptr();
+ uint8_t *w = gpudata.ptrw();
+ uint8_t *dst = w;
for (int i = 0; i < gpudata.size(); i++)
dst[i] = 0x00;
diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp
index 3b3805157b..12f3241c98 100644
--- a/modules/basis_universal/texture_basisu.cpp
+++ b/modules/basis_universal/texture_basisu.cpp
@@ -44,7 +44,7 @@ void TextureBasisU::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_basisu_data"), &TextureBasisU::get_data);
ClassDB::bind_method(D_METHOD("import"), &TextureBasisU::import);
- ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "basisu_data"), "set_basisu_data", "get_basisu_data");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "basisu_data"), "set_basisu_data", "get_basisu_data");
};
@@ -81,13 +81,13 @@ uint32_t TextureBasisU::get_flags() const {
};
-void TextureBasisU::set_basisu_data(const PoolVector<uint8_t>& p_data) {
+void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) {
#ifdef TOOLS_ENABLED
data = p_data;
#endif
- PoolVector<uint8_t>::Read r = p_data.read();
+ const uint8_t* r = p_data.ptr();
const void* ptr = r.ptr();
int size = p_data.size();
@@ -114,11 +114,11 @@ void TextureBasisU::set_basisu_data(const PoolVector<uint8_t>& p_data) {
tex_size = Size2(info.m_width, info.m_height);
int block_size = basist::basis_get_bytes_per_block(format);
- PoolVector<uint8_t> gpudata;
+ Vector<uint8_t> gpudata;
gpudata.resize(info.m_total_blocks * block_size);
{
- PoolVector<uint8_t>::Write w = gpudata.write();
+ uint8_t* w = gpudata.ptrw();
uint8_t* dst = w.ptr();
for (int i=0; i<gpudata.size(); i++)
dst[i] = 0x00;
@@ -152,7 +152,7 @@ Error TextureBasisU::import(const Ref<Image>& p_img) {
#ifdef TOOLS_ENABLED
- PoolVector<uint8_t> budata;
+ Vector<uint8_t> budata;
{
Image::Format format = p_img->get_format();
@@ -168,9 +168,9 @@ Error TextureBasisU::import(const Ref<Image>& p_img) {
basisu::image buimg(p_img->get_width(), p_img->get_height());
int size = p_img->get_width() * p_img->get_height() * 4;
- PoolVector<uint8_t> vec = copy->get_data();
+ Vector<uint8_t> vec = copy->get_data();
{
- PoolVector<uint8_t>::Read r = vec.read();
+ const uint8_t* r = vec.ptr();
memcpy(buimg.get_ptr(), r.ptr(), size);
};
@@ -198,7 +198,7 @@ Error TextureBasisU::import(const Ref<Image>& p_img) {
budata.resize(buvec.size());
{
- PoolVector<uint8_t>::Write w = budata.write();
+ uint8_t* w = budata.ptrw();
memcpy(w.ptr(), &buvec[0], budata.size());
};
};
@@ -213,7 +213,7 @@ Error TextureBasisU::import(const Ref<Image>& p_img) {
};
-PoolVector<uint8_t> TextureBasisU::get_basisu_data() const {
+Vector<uint8_t> TextureBasisU::get_basisu_data() const {
return data;
};
diff --git a/modules/basis_universal/texture_basisu.h b/modules/basis_universal/texture_basisu.h
index 8474a63258..8de151ede0 100644
--- a/modules/basis_universal/texture_basisu.h
+++ b/modules/basis_universal/texture_basisu.h
@@ -47,7 +47,7 @@ class TextureBasisU : public Texture {
uint32_t flags;
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
static void _bind_methods();
@@ -64,9 +64,9 @@ public:
Error import(const Ref<Image> &p_img);
- void set_basisu_data(const PoolVector<uint8_t>& p_data);
+ void set_basisu_data(const Vector<uint8_t>& p_data);
- PoolVector<uint8_t> get_basisu_data() const;
+ Vector<uint8_t> get_basisu_data() const;
String get_img_path() const;
TextureBasisU();