| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | // Copyright (c) 2016-2019 Kiwano - 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
 | 
					
						
							| 
									
										
										
										
											2019-11-13 14:33:15 +08:00
										 |  |  |  | #include <kiwano/core/time.h>
 | 
					
						
							| 
									
										
										
										
											2019-12-27 10:51:34 +08:00
										 |  |  |  | #include <kiwano/core/ObjectBase.h>
 | 
					
						
							| 
									
										
										
										
											2019-12-26 19:25:43 +08:00
										 |  |  |  | #include <kiwano/core/win32/ComPtr.hpp>
 | 
					
						
							| 
									
										
										
										
											2019-10-11 21:55:29 +08:00
										 |  |  |  | #include <kiwano/renderer/Brush.h>
 | 
					
						
							|  |  |  |  | #include <kiwano/renderer/Texture.h>
 | 
					
						
							|  |  |  |  | #include <kiwano/renderer/Geometry.h>
 | 
					
						
							|  |  |  |  | #include <kiwano/renderer/TextLayout.h>
 | 
					
						
							|  |  |  |  | #include <kiwano/renderer/LayerArea.h>
 | 
					
						
							|  |  |  |  | #include <kiwano/renderer/win32/TextRenderer.h>
 | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace kiwano | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-12-27 10:51:34 +08:00
										 |  |  |  | 	class Renderer; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	KGE_DECLARE_SMART_PTR(RenderTarget); | 
					
						
							|  |  |  |  | 	KGE_DECLARE_SMART_PTR(TextureRenderTarget); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-21 16:33:41 +08:00
										 |  |  |  | 	// <20><><EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>ģʽ
 | 
					
						
							|  |  |  |  | 	enum class TextAntialiasMode | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		Default,	// ϵͳĬ<CDB3><C4AC>
 | 
					
						
							|  |  |  |  | 		ClearType,	// ClearType <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 		GrayScale,	// <20>Ҷȿ<D2B6><C8BF><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 		None		// <20><><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 	}; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 	// <20><>ȾĿ<C8BE><C4BF>
 | 
					
						
							|  |  |  |  | 	class KGE_API RenderTarget | 
					
						
							| 
									
										
										
										
											2019-12-27 10:51:34 +08:00
										 |  |  |  | 		: public ObjectBase | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 	public: | 
					
						
							| 
									
										
										
										
											2019-08-20 19:32:36 +08:00
										 |  |  |  | 		bool IsValid() const; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 		void BeginDraw(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void EndDraw(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void DrawGeometry( | 
					
						
							|  |  |  |  | 			Geometry const& geometry, | 
					
						
							| 
									
										
										
										
											2019-09-29 22:23:13 +08:00
										 |  |  |  | 			float stroke_width, | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 			StrokeStyle stroke = StrokeStyle::Miter | 
					
						
							| 
									
										
										
										
											2019-12-11 13:44:40 +08:00
										 |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void FillGeometry( | 
					
						
							| 
									
										
										
										
											2019-09-09 22:02:53 +08:00
										 |  |  |  | 			Geometry const& geometry | 
					
						
							| 
									
										
										
										
											2019-12-11 13:44:40 +08:00
										 |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void DrawLine( | 
					
						
							|  |  |  |  | 			Point const& point1, | 
					
						
							|  |  |  |  | 			Point const& point2, | 
					
						
							| 
									
										
										
										
											2019-09-29 22:23:13 +08:00
										 |  |  |  | 			float stroke_width, | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 			StrokeStyle stroke = StrokeStyle::Miter | 
					
						
							| 
									
										
										
										
											2019-12-11 13:44:40 +08:00
										 |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void DrawRectangle( | 
					
						
							|  |  |  |  | 			Rect const& rect, | 
					
						
							| 
									
										
										
										
											2019-09-29 22:23:13 +08:00
										 |  |  |  | 			float stroke_width, | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 			StrokeStyle stroke = StrokeStyle::Miter | 
					
						
							| 
									
										
										
										
											2019-12-11 13:44:40 +08:00
										 |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void FillRectangle( | 
					
						
							| 
									
										
										
										
											2019-09-09 22:02:53 +08:00
										 |  |  |  | 			Rect const& rect | 
					
						
							| 
									
										
										
										
											2019-12-11 13:44:40 +08:00
										 |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void DrawRoundedRectangle( | 
					
						
							|  |  |  |  | 			Rect const& rect, | 
					
						
							|  |  |  |  | 			Vec2 const& radius, | 
					
						
							| 
									
										
										
										
											2019-09-29 22:23:13 +08:00
										 |  |  |  | 			float stroke_width, | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 			StrokeStyle stroke = StrokeStyle::Miter | 
					
						
							| 
									
										
										
										
											2019-12-11 13:44:40 +08:00
										 |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void FillRoundedRectangle( | 
					
						
							|  |  |  |  | 			Rect const& rect, | 
					
						
							| 
									
										
										
										
											2019-09-09 22:02:53 +08:00
										 |  |  |  | 			Vec2 const& radius | 
					
						
							| 
									
										
										
										
											2019-12-11 13:44:40 +08:00
										 |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void DrawEllipse( | 
					
						
							|  |  |  |  | 			Point const& center, | 
					
						
							|  |  |  |  | 			Vec2 const& radius, | 
					
						
							| 
									
										
										
										
											2019-09-29 22:23:13 +08:00
										 |  |  |  | 			float stroke_width, | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 			StrokeStyle stroke = StrokeStyle::Miter | 
					
						
							| 
									
										
										
										
											2019-12-11 13:44:40 +08:00
										 |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void FillEllipse( | 
					
						
							|  |  |  |  | 			Point const& center, | 
					
						
							| 
									
										
										
										
											2019-09-09 22:02:53 +08:00
										 |  |  |  | 			Vec2 const& radius | 
					
						
							| 
									
										
										
										
											2019-12-11 13:44:40 +08:00
										 |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-21 16:33:41 +08:00
										 |  |  |  | 		void DrawTexture( | 
					
						
							| 
									
										
										
										
											2019-12-26 19:25:43 +08:00
										 |  |  |  | 			Texture const& texture, | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 			Rect const& src_rect, | 
					
						
							| 
									
										
										
										
											2019-12-27 23:42:51 +08:00
										 |  |  |  | 			Rect const& dest_rect, | 
					
						
							|  |  |  |  | 			float opacity = 1.0f | 
					
						
							| 
									
										
										
										
											2019-12-11 13:44:40 +08:00
										 |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-21 16:33:41 +08:00
										 |  |  |  | 		void DrawTexture( | 
					
						
							| 
									
										
										
										
											2019-12-26 19:25:43 +08:00
										 |  |  |  | 			Texture const& texture, | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 			const Rect* src_rect = nullptr, | 
					
						
							| 
									
										
										
										
											2019-12-27 23:42:51 +08:00
										 |  |  |  | 			const Rect* dest_rect = nullptr, | 
					
						
							|  |  |  |  | 			float opacity = 1.0f | 
					
						
							| 
									
										
										
										
											2019-12-11 13:44:40 +08:00
										 |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void DrawTextLayout( | 
					
						
							|  |  |  |  | 			TextLayout const& layout, | 
					
						
							|  |  |  |  | 			Point const& offset = Point{} | 
					
						
							| 
									
										
										
										
											2019-12-11 13:44:40 +08:00
										 |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-27 10:51:34 +08:00
										 |  |  |  | 		void CreateTexture( | 
					
						
							|  |  |  |  | 			Texture& texture, | 
					
						
							|  |  |  |  | 			math::Vec2T<uint32_t> size, | 
					
						
							|  |  |  |  | 			D2D1_PIXEL_FORMAT format | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void CreateLayer( | 
					
						
							|  |  |  |  | 			LayerArea& layer | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 		void PushClipRect( | 
					
						
							|  |  |  |  | 			Rect const& clip_rect | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void PopClipRect(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void PushLayer( | 
					
						
							| 
									
										
										
										
											2019-08-20 19:32:36 +08:00
										 |  |  |  | 			LayerArea& layer | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void PopLayer(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void Clear(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void Clear( | 
					
						
							|  |  |  |  | 			Color const& clear_color | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-27 23:42:51 +08:00
										 |  |  |  | 		BrushPtr GetCurrentBrush() const; | 
					
						
							| 
									
										
										
										
											2019-09-09 22:02:53 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-20 23:51:12 +08:00
										 |  |  |  | 		Matrix3x2 GetGlobalTransform() const; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-09 22:02:53 +08:00
										 |  |  |  | 		void SetCurrentBrush( | 
					
						
							| 
									
										
										
										
											2019-12-27 23:42:51 +08:00
										 |  |  |  | 			BrushPtr brush | 
					
						
							| 
									
										
										
										
											2019-09-09 22:02:53 +08:00
										 |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 		void SetTransform( | 
					
						
							|  |  |  |  | 			const Matrix3x2& matrix | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-20 23:51:12 +08:00
										 |  |  |  | 		void SetGlobalTransform( | 
					
						
							|  |  |  |  | 			const Matrix3x2& matrix | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-21 12:47:19 +08:00
										 |  |  |  | 		void SetGlobalTransform( | 
					
						
							|  |  |  |  | 			const Matrix3x2* matrix | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 		// <20><><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>ģʽ
 | 
					
						
							|  |  |  |  | 		void SetAntialiasMode( | 
					
						
							|  |  |  |  | 			bool enabled | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>ģʽ
 | 
					
						
							|  |  |  |  | 		void SetTextAntialiasMode( | 
					
						
							| 
									
										
										
										
											2019-08-21 16:33:41 +08:00
										 |  |  |  | 			TextAntialiasMode mode | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-21 12:47:19 +08:00
										 |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2019-08-20 19:32:36 +08:00
										 |  |  |  | 		bool CheckVisibility( | 
					
						
							| 
									
										
										
										
											2019-08-20 21:15:15 +08:00
										 |  |  |  | 			Rect const& bounds, | 
					
						
							| 
									
										
										
										
											2019-08-20 19:32:36 +08:00
										 |  |  |  | 			Matrix3x2 const& transform | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 	public: | 
					
						
							|  |  |  |  | 		struct Status | 
					
						
							|  |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2019-09-29 22:23:13 +08:00
										 |  |  |  | 			int primitives; | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 			Time start; | 
					
						
							|  |  |  |  | 			Duration duration; | 
					
						
							| 
									
										
										
										
											2019-08-27 15:29:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 			Status() : primitives(0) {} | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 		}; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void SetCollectingStatus(bool collecting); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void IncreasePrimitivesCount() const; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-29 22:23:13 +08:00
										 |  |  |  | 		inline Status const&				GetStatus() const						{ return status_; } | 
					
						
							| 
									
										
										
										
											2019-08-21 16:33:41 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-27 10:51:34 +08:00
										 |  |  |  | 	protected: | 
					
						
							| 
									
										
										
										
											2019-09-29 22:23:13 +08:00
										 |  |  |  | 		inline ComPtr<ID2D1RenderTarget>	GetRenderTarget() const					{ KGE_ASSERT(render_target_); return render_target_; } | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-29 22:23:13 +08:00
										 |  |  |  | 		inline ComPtr<ITextRenderer>		GetTextRenderer() const					{ KGE_ASSERT(text_renderer_); return text_renderer_; } | 
					
						
							| 
									
										
										
										
											2019-08-20 19:32:36 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-11 13:44:40 +08:00
										 |  |  |  | 		ComPtr<ID2D1StrokeStyle>			GetStrokeStyle(StrokeStyle style); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-27 10:51:34 +08:00
										 |  |  |  | 	protected: | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 		RenderTarget(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-27 10:51:34 +08:00
										 |  |  |  | 		HRESULT CreateDeviceResources(ComPtr<ID2D1RenderTarget> rt, ComPtr<ID2DDeviceResources> dev_res); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-20 19:32:36 +08:00
										 |  |  |  | 		void DiscardDeviceResources(); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-23 18:05:08 +08:00
										 |  |  |  | 	private: | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 		bool							antialias_; | 
					
						
							| 
									
										
										
										
											2019-08-21 12:47:19 +08:00
										 |  |  |  | 		bool							fast_global_transform_; | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 		mutable bool					collecting_status_; | 
					
						
							|  |  |  |  | 		mutable Status					status_; | 
					
						
							| 
									
										
										
										
											2019-08-21 16:33:41 +08:00
										 |  |  |  | 		TextAntialiasMode				text_antialias_; | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 		ComPtr<ITextRenderer>			text_renderer_; | 
					
						
							| 
									
										
										
										
											2019-08-20 19:32:36 +08:00
										 |  |  |  | 		ComPtr<ID2D1RenderTarget>		render_target_; | 
					
						
							|  |  |  |  | 		ComPtr<ID2DDeviceResources>		device_resources_; | 
					
						
							| 
									
										
										
										
											2019-12-27 23:42:51 +08:00
										 |  |  |  | 		BrushPtr						current_brush_; | 
					
						
							| 
									
										
										
										
											2019-08-21 12:47:19 +08:00
										 |  |  |  | 		Matrix3x2						global_transform_; | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 	}; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-27 23:42:51 +08:00
										 |  |  |  | 	/// \~chinese
 | 
					
						
							|  |  |  |  | 	/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȾĿ<C8BE><C4BF>
 | 
					
						
							|  |  |  |  | 	/// @details <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȾĿ<C8BE>꽫<EFBFBD><EABDAB>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2019-08-21 16:33:41 +08:00
										 |  |  |  | 	class KGE_API TextureRenderTarget | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 		: public RenderTarget | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2019-12-27 10:51:34 +08:00
										 |  |  |  | 		friend class Renderer; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 	public: | 
					
						
							| 
									
										
										
										
											2019-12-27 23:42:51 +08:00
										 |  |  |  | 		/// \~chinese
 | 
					
						
							|  |  |  |  | 		/// @brief <20>Ƿ<EFBFBD><C7B7><EFBFBD>Ч
 | 
					
						
							| 
									
										
										
										
											2019-12-27 10:51:34 +08:00
										 |  |  |  | 		bool IsValid() const; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-27 23:42:51 +08:00
										 |  |  |  | 		/// \~chinese
 | 
					
						
							|  |  |  |  | 		/// @brief <20><>ȡ<EFBFBD><C8A1>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 		bool GetOutput(Texture& texture); | 
					
						
							| 
									
										
										
										
											2019-12-27 10:51:34 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	private: | 
					
						
							| 
									
										
										
										
											2019-08-21 16:33:41 +08:00
										 |  |  |  | 		TextureRenderTarget(); | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-27 10:51:34 +08:00
										 |  |  |  | 		ComPtr<ID2D1BitmapRenderTarget> GetBitmapRenderTarget() const; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		void SetBitmapRenderTarget(ComPtr<ID2D1BitmapRenderTarget> rt); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	private: | 
					
						
							|  |  |  |  | 		ComPtr<ID2D1BitmapRenderTarget> bitmap_rt_; | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2019-12-27 10:51:34 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-27 23:42:51 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	inline BrushPtr RenderTarget::GetCurrentBrush() const | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		return current_brush_; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	inline Matrix3x2 RenderTarget::GetGlobalTransform() const | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		return global_transform_; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	inline void RenderTarget::SetGlobalTransform(const Matrix3x2& matrix) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		SetGlobalTransform(&matrix); | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	inline void RenderTarget::SetCurrentBrush(BrushPtr brush) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		current_brush_ = brush; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-27 10:51:34 +08:00
										 |  |  |  | 	inline bool TextureRenderTarget::IsValid() const | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2019-12-27 23:42:51 +08:00
										 |  |  |  | 		return bitmap_rt_ != nullptr; | 
					
						
							| 
									
										
										
										
											2019-12-27 10:51:34 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	inline ComPtr<ID2D1BitmapRenderTarget> TextureRenderTarget::GetBitmapRenderTarget() const | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		return bitmap_rt_; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	inline void TextureRenderTarget::SetBitmapRenderTarget(ComPtr<ID2D1BitmapRenderTarget> rt) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		bitmap_rt_ = rt; | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-08-16 00:50:54 +08:00
										 |  |  |  | } |