| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | // Copyright (c) 2016-2018 Easy2D - Nomango
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
					
						
							|  |  |  | // of this software and associated documentation files (the "Software"), to deal
 | 
					
						
							|  |  |  | // in the Software without restriction, including without limitation the rights
 | 
					
						
							|  |  |  | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
					
						
							|  |  |  | // copies of the Software, and to permit persons to whom the Software is
 | 
					
						
							|  |  |  | // furnished to do so, subject to the following conditions:
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // The above copyright notice and this permission notice shall be included in
 | 
					
						
							|  |  |  | // all copies or substantial portions of the Software.
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
					
						
							|  |  |  | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
					
						
							|  |  |  | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
					
						
							|  |  |  | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
					
						
							|  |  |  | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
					
						
							|  |  |  | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
					
						
							|  |  |  | // THE SOFTWARE.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2018-11-23 14:55:03 +08:00
										 |  |  | #include "include-forwards.h"
 | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | #include "Singleton.hpp"
 | 
					
						
							|  |  |  | #include "Font.hpp"
 | 
					
						
							|  |  |  | #include "Resource.h"
 | 
					
						
							|  |  |  | #include "TextRenderer.h"
 | 
					
						
							|  |  |  | #include "TextStyle.hpp"
 | 
					
						
							|  |  |  | #include "../math/Matrix.hpp"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace easy2d | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	class FactoryImpl | 
					
						
							|  |  |  | 		: protected Noncopyable | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		E2D_DECLARE_SINGLETON(FactoryImpl); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							| 
									
										
										
										
											2018-11-21 19:24:18 +08:00
										 |  |  | 		HRESULT Init(bool debug); | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		HRESULT CreateHwndRenderTarget( | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 			CpHwndRenderTarget& hwnd_render_target, | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 			D2D1_RENDER_TARGET_PROPERTIES const& properties, | 
					
						
							|  |  |  | 			D2D1_HWND_RENDER_TARGET_PROPERTIES const& hwnd_rt_properties | 
					
						
							|  |  |  | 		) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		HRESULT CreateTextRenderer( | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 			CpTextRenderer& text_renderer, | 
					
						
							|  |  |  | 			CpRenderTarget const& render_target, | 
					
						
							|  |  |  | 			CpSolidColorBrush const& brush | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 		); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		HRESULT CreateBitmapFromFile( | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 			CpBitmap& bitmap, | 
					
						
							|  |  |  | 			CpRenderTarget const& rt, | 
					
						
							| 
									
										
										
										
											2019-01-21 21:24:45 +08:00
										 |  |  | 			String const& file_path | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 		); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		HRESULT CreateBitmapFromResource( | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 			CpBitmap& bitmap, | 
					
						
							|  |  |  | 			CpRenderTarget const& rt, | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 			Resource const& res | 
					
						
							|  |  |  | 		); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		HRESULT CreateRectangleGeometry( | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 			CpRectangleGeometry& geo, | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 			Rect const& rect | 
					
						
							|  |  |  | 		) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		HRESULT CreateRoundedRectangleGeometry( | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 			CpRoundedRectangleGeometry& geo, | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 			Rect const& rect, | 
					
						
							|  |  |  | 			float radius_x, | 
					
						
							|  |  |  | 			float radius_y | 
					
						
							|  |  |  | 		) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		HRESULT CreateEllipseGeometry( | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 			CpEllipseGeometry& geo, | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 			Point const& center, | 
					
						
							|  |  |  | 			float radius_x, | 
					
						
							|  |  |  | 			float radius_y | 
					
						
							|  |  |  | 		) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		HRESULT CreateTransformedGeometry( | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 			CpTransformedGeometry& transformed, | 
					
						
							| 
									
										
										
										
											2018-11-25 15:00:15 +08:00
										 |  |  | 			Matrix const& matrix, | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 			CpGeometry const& geo | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 		) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		HRESULT CreatePathGeometry( | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 			CpPathGeometry& geometry | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 		) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		HRESULT CreateTextFormat( | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 			CpTextFormat& text_format, | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 			Font const& font, | 
					
						
							|  |  |  | 			TextStyle const& text_style | 
					
						
							|  |  |  | 		) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		HRESULT CreateTextLayout( | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 			CpTextLayout& text_layout, | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 			Size& layout_size, | 
					
						
							| 
									
										
										
										
											2019-01-21 21:24:45 +08:00
										 |  |  | 			String const& text, | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 			CpTextFormat const& text_format, | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 			TextStyle const& text_style | 
					
						
							|  |  |  | 		) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 		CpStrokeStyle const& GetStrokeStyle( | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 			StrokeStyle stroke | 
					
						
							|  |  |  | 		) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	protected: | 
					
						
							|  |  |  | 		FactoryImpl(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		~FactoryImpl(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	protected: | 
					
						
							| 
									
										
										
										
											2019-01-08 19:30:02 +08:00
										 |  |  | 		CpFactory			factory_; | 
					
						
							|  |  |  | 		CpImagingFactory	imaging_factory_; | 
					
						
							|  |  |  | 		CpWriteFactory		write_factory_; | 
					
						
							|  |  |  | 		CpStrokeStyle		miter_stroke_style_; | 
					
						
							|  |  |  | 		CpStrokeStyle		bevel_stroke_style_; | 
					
						
							|  |  |  | 		CpStrokeStyle		round_stroke_style_; | 
					
						
							| 
									
										
										
										
											2018-11-21 17:18:59 +08:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	E2D_DECLARE_SINGLETON_TYPE(FactoryImpl, Factory); | 
					
						
							|  |  |  | } |