| 
									
										
										
										
											2020-06-22 21:35:22 +02:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2024-10-04 13:19:50 +02:00
										 |  |  |  * Copyright (c) 2020, Andreas Kling <andreas@ladybird.org> | 
					
						
							| 
									
										
										
										
											2020-06-22 21:35:22 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-06-22 21:35:22 +02:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/HashMap.h>
 | 
					
						
							|  |  |  | #include <ImageDecoder/Forward.h>
 | 
					
						
							| 
									
										
										
										
											2020-09-12 11:44:00 +02:00
										 |  |  | #include <ImageDecoder/ImageDecoderClientEndpoint.h>
 | 
					
						
							| 
									
										
										
										
											2020-06-22 21:35:22 +02:00
										 |  |  | #include <ImageDecoder/ImageDecoderServerEndpoint.h>
 | 
					
						
							| 
									
										
										
										
											2024-09-18 17:37:44 -04:00
										 |  |  | #include <LibGfx/BitmapSequence.h>
 | 
					
						
							| 
									
										
										
										
											2022-02-25 12:18:30 +02:00
										 |  |  | #include <LibIPC/ConnectionFromClient.h>
 | 
					
						
							| 
									
										
										
										
											2024-04-23 18:58:52 -06:00
										 |  |  | #include <LibThreading/BackgroundAction.h>
 | 
					
						
							| 
									
										
										
										
											2020-06-22 21:35:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace ImageDecoder { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-25 12:18:30 +02:00
										 |  |  | class ConnectionFromClient final | 
					
						
							|  |  |  |     : public IPC::ConnectionFromClient<ImageDecoderClientEndpoint, ImageDecoderServerEndpoint> { | 
					
						
							|  |  |  |     C_OBJECT(ConnectionFromClient); | 
					
						
							| 
									
										
										
										
											2020-06-22 21:35:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2022-03-23 20:58:03 -06:00
										 |  |  |     ~ConnectionFromClient() override = default; | 
					
						
							| 
									
										
										
										
											2020-06-22 21:35:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     virtual void die() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-23 18:58:52 -06:00
										 |  |  |     struct DecodeResult { | 
					
						
							|  |  |  |         bool is_animated = false; | 
					
						
							|  |  |  |         u32 loop_count = 0; | 
					
						
							|  |  |  |         Gfx::FloatPoint scale { 1, 1 }; | 
					
						
							| 
									
										
										
										
											2024-09-18 17:37:44 -04:00
										 |  |  |         Gfx::BitmapSequence bitmaps; | 
					
						
							| 
									
										
										
										
											2024-04-23 18:58:52 -06:00
										 |  |  |         Vector<u32> durations; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-22 21:35:22 +02:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2024-04-23 18:58:52 -06:00
										 |  |  |     using Job = Threading::BackgroundAction<DecodeResult>; | 
					
						
							| 
									
										
										
										
											2024-04-19 14:23:16 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-22 15:47:33 -06:00
										 |  |  |     explicit ConnectionFromClient(IPC::Transport); | 
					
						
							| 
									
										
										
										
											2021-10-31 23:38:04 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-23 13:56:23 -05:00
										 |  |  |     virtual Messages::ImageDecoderServer::DecodeImageResponse decode_image(Core::AnonymousBuffer const&, Optional<Gfx::IntSize> const& ideal_size, Optional<ByteString> const& mime_type) override; | 
					
						
							| 
									
										
										
										
											2024-04-19 14:23:16 -06:00
										 |  |  |     virtual void cancel_decoding(i64 image_id) override; | 
					
						
							| 
									
										
										
										
											2024-06-26 13:44:42 -06:00
										 |  |  |     virtual Messages::ImageDecoderServer::ConnectNewClientsResponse connect_new_clients(size_t count) override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ErrorOr<IPC::File> connect_new_client(); | 
					
						
							| 
									
										
										
										
											2024-04-19 14:23:16 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-23 18:58:52 -06:00
										 |  |  |     NonnullRefPtr<Job> make_decode_image_job(i64 image_id, Core::AnonymousBuffer, Optional<Gfx::IntSize> ideal_size, Optional<ByteString> mime_type); | 
					
						
							| 
									
										
										
										
											2024-04-19 14:23:16 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     i64 m_next_image_id { 0 }; | 
					
						
							| 
									
										
										
										
											2024-04-23 18:58:52 -06:00
										 |  |  |     HashMap<i64, NonnullRefPtr<Job>> m_pending_jobs; | 
					
						
							| 
									
										
										
										
											2020-06-22 21:35:22 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |