summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp52
-rw-r--r--core/bind/core_bind.h1
-rw-r--r--core/image.cpp17
-rw-r--r--core/image.h3
-rw-r--r--core/io/resource_format_binary.cpp9
-rw-r--r--core/io/resource_format_xml.cpp9
-rw-r--r--core/io/resource_loader.cpp3
-rw-r--r--core/variant_call.cpp3
-rw-r--r--core/variant_op.cpp3
-rw-r--r--core/vmap.h6
10 files changed, 103 insertions, 3 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 61209ecb90..73f6f753b9 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -413,6 +413,56 @@ void _OS::dump_memory_to_file(const String& p_file) {
OS::get_singleton()->dump_memory_to_file(p_file.utf8().get_data());
}
+struct _OSCoreBindImg {
+
+ String path;
+ Size2 size;
+ int fmt;
+ ObjectID id;
+ int vram;
+ bool operator<(const _OSCoreBindImg& p_img) const { return vram==p_img.vram ? id<p_img.id : vram > p_img.vram; }
+};
+
+void _OS::print_all_textures_by_size() {
+
+
+ List<_OSCoreBindImg> imgs;
+ int total=0;
+ {
+ List<Ref<Resource> > rsrc;
+ ResourceCache::get_cached_resources(&rsrc);
+
+ for (List<Ref<Resource> >::Element *E=rsrc.front();E;E=E->next()) {
+
+ if (!E->get()->is_type("ImageTexture"))
+ continue;
+
+ Size2 size = E->get()->call("get_size");
+ int fmt = E->get()->call("get_format");
+
+ _OSCoreBindImg img;
+ img.size=size;
+ img.fmt=fmt;
+ img.path=E->get()->get_path();
+ img.vram=Image::get_image_data_size(img.size.width,img.size.height,Image::Format(img.fmt));
+ img.id=E->get()->get_instance_ID();
+ total+=img.vram;
+ imgs.push_back(img);
+ }
+ }
+
+ imgs.sort();
+
+ for(List<_OSCoreBindImg>::Element *E=imgs.front();E;E=E->next()) {
+
+ print_line(E->get().path+" - "+String::humanize_size(E->get().vram)+" ("+E->get().size+") - total:"+String::humanize_size(total) );
+ total-=E->get().vram;
+ }
+
+
+
+}
+
void _OS::print_all_resources(const String& p_to_file ) {
OS::get_singleton()->print_all_resources(p_to_file);
@@ -516,6 +566,8 @@ void _OS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_frames_per_second"),&_OS::get_frames_per_second);
+ ObjectTypeDB::bind_method(_MD("print_all_textures_by_size"),&_OS::print_all_textures_by_size);
+
BIND_CONSTANT( DAY_SUNDAY );
BIND_CONSTANT( DAY_MONDAY );
BIND_CONSTANT( DAY_TUESDAY );
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index e47c9c434a..9545fc65fb 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -128,6 +128,7 @@ public:
void print_resources_in_use(bool p_short=false);
void print_all_resources(const String& p_to_file);
+ void print_all_textures_by_size();
bool has_touchscreen_ui_hint() const;
diff --git a/core/image.cpp b/core/image.cpp
index a9485feff2..ccabd04d6f 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -1260,6 +1260,12 @@ int Image::get_format_pixel_size(Format p_format) {
return 1;
} break;
+ case FORMAT_ATC:
+ case FORMAT_ATC_ALPHA_EXPLICIT:
+ case FORMAT_ATC_ALPHA_INTERPOLATED: {
+
+ return 1;
+ } break;
case FORMAT_ETC: {
return 1;
@@ -1323,6 +1329,15 @@ void Image::_get_format_min_data_size(Format p_format,int &r_w, int &r_h) {
r_w=8;
r_h=8;
} break;
+ case FORMAT_ATC:
+ case FORMAT_ATC_ALPHA_EXPLICIT:
+ case FORMAT_ATC_ALPHA_INTERPOLATED: {
+
+ r_w=8;
+ r_h=8;
+
+ } break;
+
case FORMAT_ETC: {
r_w=4;
@@ -1339,7 +1354,7 @@ void Image::_get_format_min_data_size(Format p_format,int &r_w, int &r_h) {
int Image::get_format_pixel_rshift(Format p_format) {
- if (p_format==FORMAT_BC1 || p_format==FORMAT_BC4 || p_format==FORMAT_PVRTC4 || p_format==FORMAT_PVRTC4_ALPHA || p_format==FORMAT_ETC)
+ if (p_format==FORMAT_BC1 || p_format==FORMAT_BC4 || p_format==FORMAT_ATC || p_format==FORMAT_PVRTC4 || p_format==FORMAT_PVRTC4_ALPHA || p_format==FORMAT_ETC)
return 1;
else if (p_format==FORMAT_PVRTC2 || p_format==FORMAT_PVRTC2_ALPHA)
return 2;
diff --git a/core/image.h b/core/image.h
index 4ab2870c23..186aceb1bf 100644
--- a/core/image.h
+++ b/core/image.h
@@ -70,6 +70,9 @@ public:
FORMAT_PVRTC4,
FORMAT_PVRTC4_ALPHA,
FORMAT_ETC, // regular ETC, no transparency
+ FORMAT_ATC,
+ FORMAT_ATC_ALPHA_EXPLICIT,
+ FORMAT_ATC_ALPHA_INTERPOLATED,
/*FORMAT_ETC2_R, for the future..
FORMAT_ETC2_RG,
FORMAT_ETC2_RGB,
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index d2461498a6..c54398935e 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -90,6 +90,9 @@ enum {
IMAGE_FORMAT_PVRTC4=14,
IMAGE_FORMAT_PVRTC4_ALPHA=15,
IMAGE_FORMAT_ETC=16,
+ IMAGE_FORMAT_ATC=17,
+ IMAGE_FORMAT_ATC_ALPHA_EXPLICIT=18,
+ IMAGE_FORMAT_ATC_ALPHA_INTERPOLATED=19,
IMAGE_FORMAT_CUSTOM=30,
@@ -283,6 +286,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
case IMAGE_FORMAT_PVRTC4: { fmt=Image::FORMAT_PVRTC4; } break;
case IMAGE_FORMAT_PVRTC4_ALPHA: { fmt=Image::FORMAT_PVRTC4_ALPHA; } break;
case IMAGE_FORMAT_ETC: { fmt=Image::FORMAT_ETC; } break;
+ case IMAGE_FORMAT_ATC: { fmt=Image::FORMAT_ATC; } break;
+ case IMAGE_FORMAT_ATC_ALPHA_EXPLICIT: { fmt=Image::FORMAT_ATC_ALPHA_EXPLICIT; } break;
+ case IMAGE_FORMAT_ATC_ALPHA_INTERPOLATED: { fmt=Image::FORMAT_ATC_ALPHA_INTERPOLATED; } break;
case IMAGE_FORMAT_CUSTOM: { fmt=Image::FORMAT_CUSTOM; } break;
default: {
@@ -1335,6 +1341,9 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property,
case Image::FORMAT_PVRTC4: f->store_32(IMAGE_FORMAT_PVRTC4 ); break;
case Image::FORMAT_PVRTC4_ALPHA: f->store_32(IMAGE_FORMAT_PVRTC4_ALPHA ); break;
case Image::FORMAT_ETC: f->store_32(IMAGE_FORMAT_ETC); break;
+ case Image::FORMAT_ATC: f->store_32(IMAGE_FORMAT_ATC); break;
+ case Image::FORMAT_ATC_ALPHA_EXPLICIT: f->store_32(IMAGE_FORMAT_ATC_ALPHA_EXPLICIT); break;
+ case Image::FORMAT_ATC_ALPHA_INTERPOLATED: f->store_32(IMAGE_FORMAT_ATC_ALPHA_INTERPOLATED); break;
case Image::FORMAT_CUSTOM: f->store_32(IMAGE_FORMAT_CUSTOM ); break;
default: {}
diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp
index bd8e46556c..fc5aecfd99 100644
--- a/core/io/resource_format_xml.cpp
+++ b/core/io/resource_format_xml.cpp
@@ -551,6 +551,12 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name)
imgformat=Image::FORMAT_PVRTC4_ALPHA;
} else if (format=="etc") {
imgformat=Image::FORMAT_ETC;
+ } else if (format=="atc") {
+ imgformat=Image::FORMAT_ATC;
+ } else if (format=="atcai") {
+ imgformat=Image::FORMAT_ATC_ALPHA_INTERPOLATED;
+ } else if (format=="atcae") {
+ imgformat=Image::FORMAT_ATC_ALPHA_EXPLICIT;
} else if (format=="custom") {
imgformat=Image::FORMAT_CUSTOM;
} else {
@@ -1937,6 +1943,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V
case Image::FORMAT_PVRTC4: params+=" format=\"pvrtc4\""; break;
case Image::FORMAT_PVRTC4_ALPHA: params+=" format=\"pvrtc4a\""; break;
case Image::FORMAT_ETC: params+=" format=\"etc\""; break;
+ case Image::FORMAT_ATC: params+=" format=\"atc\""; break;
+ case Image::FORMAT_ATC_ALPHA_EXPLICIT: params+=" format=\"atcae\""; break;
+ case Image::FORMAT_ATC_ALPHA_INTERPOLATED: params+=" format=\"atcai\""; break;
case Image::FORMAT_CUSTOM: params+=" format=\"custom\" custom_size=\""+itos(img.get_data().size())+"\""; break;
default: {}
}
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 3bae6be83c..5ee48bae25 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -192,6 +192,7 @@ RES ResourceLoader::load(const String &p_path,const String& p_type_hint,bool p_n
res->set_last_modified_time(mt);
}
#endif
+
return res;
}
@@ -246,7 +247,7 @@ String ResourceLoader::find_complete_path(const String& p_path,const String& p_t
String path = local_path+E->get();
- if (FileAccess::exists(path)) {
+ if (PathRemap::get_singleton()->has_remap(path) || FileAccess::exists(path)) {
candidates.push_back(path);
}
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 846b924a42..be1b0eb3d3 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -1487,6 +1487,9 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
_VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC4"]=Image::FORMAT_PVRTC4;
_VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC4_ALPHA"]=Image::FORMAT_PVRTC4_ALPHA;
_VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ETC"]=Image::FORMAT_ETC;
+ _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC"]=Image::FORMAT_ATC;
+ _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC_ALPHA_EXPLICIT"]=Image::FORMAT_ATC_ALPHA_EXPLICIT;
+ _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC_ALPHA_INTERPOLATED"]=Image::FORMAT_ATC_ALPHA_INTERPOLATED;
_VariantCall::constant_data[Variant::IMAGE].value["FORMAT_CUSTOM"]=Image::FORMAT_CUSTOM;
}
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 109e4ab387..50908bbf94 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -1319,7 +1319,7 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
return;
int type=p_value;
- if (type<0 || type>=6)
+ if (type<0 || type>=InputEvent::TYPE_MAX)
return; //fail
valid=true;
ie.type=InputEvent::Type(type);
@@ -2765,6 +2765,7 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
InputEvent ie = operator InputEvent();
+
p_list->push_back( PropertyInfo(Variant::INT,"type"));
p_list->push_back( PropertyInfo(Variant::INT,"device"));
p_list->push_back( PropertyInfo(Variant::INT,"ID"));
diff --git a/core/vmap.h b/core/vmap.h
index c6c3d50bc7..516299280b 100644
--- a/core/vmap.h
+++ b/core/vmap.h
@@ -142,6 +142,12 @@ public:
}
+ int find_nearest(const T& p_val) const {
+
+ bool exact;
+ return _find(p_val,exact);
+
+ }
_FORCE_INLINE_ int size() const { return _data.size(); }
_FORCE_INLINE_ bool empty() const { return _data.empty(); }