| 
									
										
										
										
											2020-06-22 21:35:22 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											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/ImageDecoderClientEndpoint.h>
 | 
					
						
							|  |  |  | #include <ImageDecoder/ImageDecoderServerEndpoint.h>
 | 
					
						
							|  |  |  | #include <LibIPC/ServerConnection.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace ImageDecoderClient { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-29 22:30:48 +01:00
										 |  |  | struct Frame { | 
					
						
							|  |  |  |     RefPtr<Gfx::Bitmap> bitmap; | 
					
						
							|  |  |  |     u32 duration { 0 }; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct DecodedImage { | 
					
						
							|  |  |  |     bool is_animated { false }; | 
					
						
							|  |  |  |     u32 loop_count { 0 }; | 
					
						
							|  |  |  |     Vector<Frame> frames; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-20 11:35:00 +01:00
										 |  |  | class Client final | 
					
						
							| 
									
										
										
										
											2020-06-22 21:35:22 +02:00
										 |  |  |     : public IPC::ServerConnection<ImageDecoderClientEndpoint, ImageDecoderServerEndpoint> | 
					
						
							|  |  |  |     , public ImageDecoderClientEndpoint { | 
					
						
							|  |  |  |     C_OBJECT(Client); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     virtual void handshake() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-29 22:30:48 +01:00
										 |  |  |     Optional<DecodedImage> decode_image(const ByteBuffer&); | 
					
						
							| 
									
										
										
										
											2020-06-22 21:35:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-20 11:35:00 +01:00
										 |  |  |     Function<void()> on_death; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-22 21:35:22 +02:00
										 |  |  | private: | 
					
						
							|  |  |  |     Client(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-20 11:35:00 +01:00
										 |  |  |     virtual void die() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-02 19:54:34 +02:00
										 |  |  |     virtual void dummy() override; | 
					
						
							| 
									
										
										
										
											2020-06-22 21:35:22 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |