mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 04:12:43 +00:00 
			
		
		
		
	LibDraw: Store emojis in a HashMap<u32, RefPtr<GraphicsBitmap>>
Get rid of the dedicated Emoji class to make it easier to store a null value signifying a failed lookup. This allows us to remember failed lookups, making subsequent failures for the same codepoint much faster. :^)
This commit is contained in:
		
							parent
							
								
									b3a63e1d50
								
							
						
					
					
						commit
						0d8aaaaa44
					
				
					 5 changed files with 19 additions and 29 deletions
				
			
		|  | @ -556,10 +556,10 @@ void Painter::draw_scaled_bitmap(const Rect& a_dst_rect, const GraphicsBitmap& s | |||
|     draw_bitmap(point, font.glyph_bitmap(ch), color); | ||||
| } | ||||
| 
 | ||||
| void Painter::draw_emoji(const Point& point, const Emoji& emoji, const Font& font) | ||||
| void Painter::draw_emoji(const Point& point, const GraphicsBitmap& emoji, const Font& font) | ||||
| { | ||||
|     if (!font.is_fixed_width()) | ||||
|         blit(point, emoji.bitmap(), emoji.bitmap().rect()); | ||||
|         blit(point, emoji, emoji.rect()); | ||||
|     else { | ||||
|         Rect dst_rect { | ||||
|             point.x(), | ||||
|  | @ -567,7 +567,7 @@ void Painter::draw_emoji(const Point& point, const Emoji& emoji, const Font& fon | |||
|             font.glyph_width('x'), | ||||
|             font.glyph_height() | ||||
|         }; | ||||
|         draw_scaled_bitmap(dst_rect, emoji.bitmap(), emoji.bitmap().rect()); | ||||
|         draw_scaled_bitmap(dst_rect, emoji, emoji.rect()); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -580,9 +580,11 @@ void Painter::draw_glyph_or_emoji(const Point& point, u32 codepoint, const Font& | |||
|     } | ||||
| 
 | ||||
|     // Perhaps it's an emoji?
 | ||||
|     const Emoji* emoji = Emoji::emoji_for_codepoint(codepoint); | ||||
|     auto* emoji = Emoji::emoji_for_codepoint(codepoint); | ||||
|     if (emoji == nullptr) { | ||||
| #ifdef EMOJI_DEBUG | ||||
|         dbg() << "Failed to find an emoji for codepoint " << codepoint; | ||||
| #endif | ||||
|         draw_glyph(point, '?', font, color); | ||||
|         return; | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling