diff options
Diffstat (limited to 'scene/resources')
| -rw-r--r-- | scene/resources/audio_stream_sample.cpp | 2 | ||||
| -rw-r--r-- | scene/resources/curve.h | 6 | ||||
| -rwxr-xr-x | scene/resources/default_theme/make_header.py | 2 | ||||
| -rw-r--r-- | scene/resources/dynamic_font.cpp | 26 | ||||
| -rw-r--r-- | scene/resources/dynamic_font.h | 1 | ||||
| -rw-r--r-- | scene/resources/packed_scene.cpp | 2 | ||||
| -rw-r--r-- | scene/resources/shader.h | 2 | ||||
| -rw-r--r-- | scene/resources/texture.cpp | 2 |
8 files changed, 34 insertions, 9 deletions
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index b419f4b6be..8e40911887 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -289,7 +289,7 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in offset = loop_end_fp - (loop_begin_fp - offset); } } else { - /* check for sample not reaching begining */ + /* check for sample not reaching beginning */ if (offset < 0) { active = false; diff --git a/scene/resources/curve.h b/scene/resources/curve.h index 2a8fab7f4c..eae52d7bd4 100644 --- a/scene/resources/curve.h +++ b/scene/resources/curve.h @@ -135,7 +135,7 @@ public: float get_baked_length() const; Vector2 interpolate_baked(float p_offset, bool p_cubic = false) const; - PoolVector2Array get_baked_points() const; //useful for going thru + PoolVector2Array get_baked_points() const; //useful for going through PoolVector2Array tesselate(int p_max_stages = 5, float p_tolerance = 4) const; //useful for display @@ -203,8 +203,8 @@ public: float get_baked_length() const; Vector3 interpolate_baked(float p_offset, bool p_cubic = false) const; float interpolate_baked_tilt(float p_offset) const; - PoolVector3Array get_baked_points() const; //useful for going thru - PoolRealArray get_baked_tilts() const; //useful for going thru + PoolVector3Array get_baked_points() const; //useful for going through + PoolRealArray get_baked_tilts() const; //useful for going through PoolVector3Array tesselate(int p_max_stages = 5, float p_tolerance = 4) const; //useful for display diff --git a/scene/resources/default_theme/make_header.py b/scene/resources/default_theme/make_header.py index 68c9e92527..03c2c9be4a 100755 --- a/scene/resources/default_theme/make_header.py +++ b/scene/resources/default_theme/make_header.py @@ -8,7 +8,7 @@ import string f = open("theme_data.h", "wb") -f.write("// THIS FILE HAS BEEN AUTOGENERATED, DONT EDIT!!\n") +f.write("// THIS FILE HAS BEEN AUTOGENERATED, DON'T EDIT!!\n") f.write("\n\n") diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 08ebb954b2..3fbfbc705a 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -29,6 +29,7 @@ #ifdef FREETYPE_ENABLED #include "dynamic_font.h" #include "os/file_access.h" +#include "os/os.h" bool DynamicFontData::CacheID::operator<(CacheID right) const { @@ -98,6 +99,7 @@ DynamicFontData::~DynamicFontData() { } //////////////////// +HashMap<String, Vector<uint8_t> > DynamicFontAtSize::_fontdata; Error DynamicFontAtSize::_load() { @@ -106,7 +108,29 @@ Error DynamicFontAtSize::_load() { ERR_EXPLAIN(TTR("Error initializing FreeType.")); ERR_FAIL_COND_V(error != 0, ERR_CANT_CREATE); - if (font->font_path != String()) { + // FT_OPEN_STREAM is extremely slow only on Android. + if (OS::get_singleton()->get_name() == "Android" && font->font_mem == NULL && font->font_path != String()) { + // cache font only once for each font->font_path + if (_fontdata.has(font->font_path)) { + + font->set_font_ptr(_fontdata[font->font_path].ptr(), _fontdata[font->font_path].size()); + + } else { + + FileAccess *f = FileAccess::open(font->font_path, FileAccess::READ); + ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); + + size_t len = f->get_len(); + _fontdata[font->font_path] = Vector<uint8_t>(); + Vector<uint8_t> &fontdata = _fontdata[font->font_path]; + fontdata.resize(len); + f->get_buffer(fontdata.ptr(), len); + font->set_font_ptr(fontdata.ptr(), len); + f->close(); + } + } + + if (font->font_mem == NULL && font->font_path != String()) { FileAccess *f = FileAccess::open(font->font_path, FileAccess::READ); ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h index 9502943909..4243ab2c03 100644 --- a/scene/resources/dynamic_font.h +++ b/scene/resources/dynamic_font.h @@ -141,6 +141,7 @@ class DynamicFontAtSize : public Reference { Ref<DynamicFontData> font; DynamicFontData::CacheID id; + static HashMap<String, Vector<uint8_t> > _fontdata; Error _load(); protected: diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 76c6543a2f..2bb9eda198 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -533,7 +533,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map if (E->get().usage & PROPERTY_USAGE_NO_INSTANCE_STATE || E->get().name == "__meta__") { //property has requested that no instance state is saved, sorry - //also, meta won't be overriden or saved + //also, meta won't be overridden or saved continue; } diff --git a/scene/resources/shader.h b/scene/resources/shader.h index b7fa349dfe..bc98fbf737 100644 --- a/scene/resources/shader.h +++ b/scene/resources/shader.h @@ -54,7 +54,7 @@ private: // hack the name of performance // shaders keep a list of ShaderMaterial -> VisualServer name translations, to make - // convertion fast and save memory. + // conversion fast and save memory. mutable bool params_cache_dirty; mutable Map<StringName, StringName> params_cache; //map a shader param to a material param.. Map<StringName, Ref<Texture> > default_textures; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index f979c5c758..d08fc2634e 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -918,7 +918,7 @@ void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile } void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose) const { - //this might not necesarily work well if using a rect, needs to be fixed properly + //this might not necessarily work well if using a rect, needs to be fixed properly Rect2 rc = region; if (!atlas.is_valid()) |