浏览代码

I have no idea why this commit fixes #15392

Juan Linietsky 7 年之前
父节点
当前提交
8daf5491ab
共有 2 个文件被更改,包括 12 次插入15 次删除
  1. 3 8
      scene/resources/dynamic_font.cpp
  2. 9 7
      scene/resources/dynamic_font.h

+ 3 - 8
scene/resources/dynamic_font.cpp

@@ -35,13 +35,7 @@
 
 
 bool DynamicFontData::CacheID::operator<(CacheID right) const {
 bool DynamicFontData::CacheID::operator<(CacheID right) const {
 
 
-	if (size < right.size)
-		return true;
-	if (mipmaps != right.mipmaps)
-		return right.mipmaps;
-	if (filter != right.filter)
-		return right.filter;
-	return false;
+	return key < right.key;
 }
 }
 
 
 Ref<DynamicFontAtSize> DynamicFontData::_get_dynamic_font_at_size(CacheID p_cache_id) {
 Ref<DynamicFontAtSize> DynamicFontData::_get_dynamic_font_at_size(CacheID p_cache_id) {
@@ -654,6 +648,7 @@ DynamicFontAtSize::~DynamicFontAtSize() {
 		FT_Done_FreeType(library);
 		FT_Done_FreeType(library);
 	}
 	}
 	font->size_cache.erase(id);
 	font->size_cache.erase(id);
+	font.unref();
 }
 }
 
 
 /////////////////////////
 /////////////////////////
@@ -983,7 +978,7 @@ void DynamicFont::update_oversampling() {
 	while (E) {
 	while (E) {
 
 
 		if (E->self()->data_at_size.is_valid() && E->self()->data_at_size->update_oversampling()) {
 		if (E->self()->data_at_size.is_valid() && E->self()->data_at_size->update_oversampling()) {
-			changed.push_back(E->self());
+			changed.push_back(Ref<DynamicFont>(E->self()));
 		}
 		}
 		E = E->next();
 		E = E->next();
 	}
 	}

+ 9 - 7
scene/resources/dynamic_font.h

@@ -50,15 +50,17 @@ class DynamicFontData : public Resource {
 public:
 public:
 	struct CacheID {
 	struct CacheID {
 
 
-		int size;
-		bool mipmaps;
-		bool filter;
-
+		union {
+			struct {
+				uint32_t size : 16;
+				bool mipmaps : 1;
+				bool filter : 1;
+			};
+			uint32_t key;
+		};
 		bool operator<(CacheID right) const;
 		bool operator<(CacheID right) const;
 		CacheID() {
 		CacheID() {
-			size = 16;
-			mipmaps = false;
-			filter = false;
+			key = 0;
 		}
 		}
 	};
 	};