| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2021-06-16 19:18:01 +02:00
										 |  |  |  * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> | 
					
						
							| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-09 02:06:04 +01:00
										 |  |  | #include <AK/StdLibExtras.h>
 | 
					
						
							| 
									
										
										
										
											2020-02-15 00:58:14 +01:00
										 |  |  | #include <AK/String.h>
 | 
					
						
							| 
									
										
										
										
											2020-02-14 21:41:10 +01:00
										 |  |  | #include <AK/Vector.h>
 | 
					
						
							| 
									
										
										
										
											2021-06-13 06:13:06 -06:00
										 |  |  | #include <LibGfx/Line.h>
 | 
					
						
							| 
									
										
										
										
											2020-02-14 21:41:10 +01:00
										 |  |  | #include <LibGfx/Rect.h>
 | 
					
						
							| 
									
										
										
										
											2020-03-29 19:03:13 +02:00
										 |  |  | #include <LibIPC/Decoder.h>
 | 
					
						
							| 
									
										
										
										
											2020-05-12 18:05:43 +02:00
										 |  |  | #include <LibIPC/Encoder.h>
 | 
					
						
							| 
									
										
										
										
											2019-01-09 02:06:04 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-06 13:02:38 +01:00
										 |  |  | namespace Gfx { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-25 21:31:47 -07:00
										 |  |  | template<> | 
					
						
							| 
									
										
										
										
											2020-06-10 10:57:59 +02:00
										 |  |  | String IntRect::to_string() const | 
					
						
							| 
									
										
										
										
											2020-02-15 00:58:14 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-04-21 21:11:16 +02:00
										 |  |  |     return String::formatted("[{},{} {}x{}]", x(), y(), width(), height()); | 
					
						
							| 
									
										
										
										
											2020-02-15 00:58:14 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-25 21:31:47 -07:00
										 |  |  | template<> | 
					
						
							|  |  |  | String FloatRect::to_string() const | 
					
						
							| 
									
										
										
										
											2020-02-15 00:58:14 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-04-15 00:36:14 -07:00
										 |  |  |     return String::formatted("[{},{} {}x{}]", x(), y(), width(), height()); | 
					
						
							| 
									
										
										
										
											2020-02-15 00:58:14 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-06 13:02:38 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-02-15 12:04:35 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace IPC { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-16 19:18:01 +02:00
										 |  |  | bool encode(Encoder& encoder, Gfx::IntRect const& rect) | 
					
						
							| 
									
										
										
										
											2020-05-12 18:05:43 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     encoder << rect.location() << rect.size(); | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-28 11:56:31 +01:00
										 |  |  | ErrorOr<void> decode(Decoder& decoder, Gfx::IntRect& rect) | 
					
						
							| 
									
										
										
										
											2020-02-15 12:04:35 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-06-10 10:57:59 +02:00
										 |  |  |     Gfx::IntPoint point; | 
					
						
							|  |  |  |     Gfx::IntSize size; | 
					
						
							| 
									
										
										
										
											2021-11-28 11:56:31 +01:00
										 |  |  |     TRY(decoder.decode(point)); | 
					
						
							|  |  |  |     TRY(decoder.decode(size)); | 
					
						
							| 
									
										
										
										
											2020-02-15 12:04:35 +01:00
										 |  |  |     rect = { point, size }; | 
					
						
							| 
									
										
										
										
											2021-11-28 11:56:31 +01:00
										 |  |  |     return {}; | 
					
						
							| 
									
										
										
										
											2020-02-15 12:04:35 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-07-25 21:31:47 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | template class Gfx::Rect<int>; | 
					
						
							|  |  |  | template class Gfx::Rect<float>; |