mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 08:32:43 +00:00 
			
		
		
		
	LibWeb: Share decoded images at the Resource level :^)
This patch adds ImageResource as a subclass of Resource. This new class also keeps a Gfx::ImageDecoder so that we can share decoded bitmaps between all clients of an image resource inside LibWeb. With this, we now share both encoded and decoded data for images. :^) I had to change how the purgeable-volatile flag is updated to keep the volatile-images-outside-the-visible-viewport optimization working. HTMLImageElement now inherits from ImageResourceClient (a subclass of ResourceClient with additional image-specific stuff) and informs its ImageResource about whether it's inside the viewport or outside. This is pretty awesome! :^)
This commit is contained in:
		
							parent
							
								
									1c6e4e04a8
								
							
						
					
					
						commit
						d4ddb0013c
					
				
					 14 changed files with 200 additions and 30 deletions
				
			
		|  | @ -34,6 +34,7 @@ | |||
| #include <AK/URL.h> | ||||
| #include <AK/WeakPtr.h> | ||||
| #include <AK/Weakable.h> | ||||
| #include <LibGfx/Forward.h> | ||||
| #include <LibWeb/Forward.h> | ||||
| #include <LibWeb/Loader/LoadRequest.h> | ||||
| 
 | ||||
|  | @ -46,8 +47,13 @@ class Resource : public RefCounted<Resource> { | |||
|     AK_MAKE_NONMOVABLE(Resource); | ||||
| 
 | ||||
| public: | ||||
|     static NonnullRefPtr<Resource> create(Badge<ResourceLoader>, const LoadRequest&); | ||||
|     ~Resource(); | ||||
|     enum class Type { | ||||
|         Generic, | ||||
|         Image, | ||||
|     }; | ||||
| 
 | ||||
|     static NonnullRefPtr<Resource> create(Badge<ResourceLoader>, Type, const LoadRequest&); | ||||
|     virtual ~Resource(); | ||||
| 
 | ||||
|     bool is_loaded() const { return m_loaded; } | ||||
| 
 | ||||
|  | @ -67,11 +73,13 @@ public: | |||
|     void did_load(Badge<ResourceLoader>, const ByteBuffer& data, const HashMap<String, String, CaseInsensitiveStringTraits>& headers); | ||||
|     void did_fail(Badge<ResourceLoader>, const String& error); | ||||
| 
 | ||||
| private: | ||||
|     explicit Resource(const LoadRequest&); | ||||
| protected: | ||||
|     explicit Resource(Type, const LoadRequest&); | ||||
| 
 | ||||
| private: | ||||
|     LoadRequest m_request; | ||||
|     ByteBuffer m_encoded_data; | ||||
|     Type m_type { Type::Generic }; | ||||
|     bool m_loaded { false }; | ||||
|     bool m_failed { false }; | ||||
|     String m_error; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling