Kiwano Engine v1.3.x
RendererImpl.h
1// Copyright (c) 2016-2018 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22#include <kiwano/render/Renderer.h>
23#include <kiwano/render/DirectX/D3DDeviceResources.h>
24#include <kiwano/render/DirectX/RenderContextImpl.h>
25
26namespace kiwano
27{
28
29class KGE_API RendererImpl : public Renderer
30{
31public:
32 static RendererImpl& GetInstance();
33
34 void CreateBitmap(Bitmap& bitmap, StringView file_path) override;
35
36 void CreateBitmap(Bitmap& bitmap, const BinaryData& data) override;
37
38 void CreateBitmap(Bitmap& bitmap, const PixelSize& size, const BinaryData& data, PixelFormat format) override;
39
40 void CreateGifImage(GifImage& gif, StringView file_path) override;
41
42 void CreateGifImage(GifImage& gif, const BinaryData& data) override;
43
44 void CreateGifImageFrame(GifImage::Frame& frame, const GifImage& gif, size_t frame_index) override;
45
46 void CreateFontCollection(FontCollection& collection, Vector<String>& family_names,
47 const Vector<String>& file_paths) override;
48
49 void CreateFontCollection(FontCollection& collection, Vector<String>& family_names,
50 const Vector<BinaryData>& datas) override;
51
52 void CreateTextLayout(TextLayout& layout, StringView content, const TextStyle& style) override;
53
54 void CreateLineShape(Shape& shape, const Point& begin_pos, const Point& end_pos) override;
55
56 void CreateRectShape(Shape& shape, const Rect& rect) override;
57
58 void CreateRoundedRectShape(Shape& shape, const Rect& rect, const Vec2& radius) override;
59
60 void CreateEllipseShape(Shape& shape, const Point& center, const Vec2& radius) override;
61
62 void CreateShapeSink(ShapeMaker& maker) override;
63
64 void CreateBrush(Brush& brush, const Color& color) override;
65
66 void CreateBrush(Brush& brush, const LinearGradientStyle& style) override;
67
68 void CreateBrush(Brush& brush, const RadialGradientStyle& style) override;
69
70 void CreateBrush(Brush& brush, RefPtr<Image> image, const Rect& src_rect) override;
71
72 void CreateStrokeStyle(StrokeStyle& stroke_style) override;
73
74 void CreatePixelShader(PixelShader& shader, const BinaryData& cso_data) override;
75
76 RefPtr<RenderContext> CreateContextForBitmap(RefPtr<Bitmap> bitmap, const Size& desired_size) override;
77
78 RefPtr<RenderContext> CreateContextForBitmapInPixels(RefPtr<Bitmap> bitmap, const PixelSize& desired_size) override;
79
80 RefPtr<RenderContext> CreateContextForCommandList(RefPtr<Image> cmd_list) override;
81
82public:
83 void Clear() override;
84
85 void Present() override;
86
87 void Resize(uint32_t width, uint32_t height) override;
88
89 void MakeContextForWindow(RefPtr<Window> window) override;
90
91 void Destroy() override;
92
93 void HandleEvent(EventModuleContext& ctx) override;
94
95protected:
97
98private:
99 using ID2DDeviceResources = kiwano::graphics::directx::ID2DDeviceResources;
100 using ID3DDeviceResources = kiwano::graphics::directx::ID3DDeviceResources;
101
102 ComPtr<ID2DDeviceResources> d2d_res_;
103 ComPtr<ID3DDeviceResources> d3d_res_;
104
105 HMONITOR monitor_;
106};
107
110} // namespace kiwano
位图
Definition: Bitmap.h:95
画刷
Definition: Brush.h:92
Definition: Color.h:41
时间模块上下文
Definition: Module.h:96
字体集合
Definition: Font.h:89
GIF图像
Definition: GifImage.h:38
像素着色器
Definition: Shader.h:53
引用计数智能指针
Definition: RefBasePtr.hpp:35
Definition: RendererImpl.h:30
渲染器
Definition: Renderer.h:48
形状生成器
Definition: ShapeMaker.h:45
形状
Definition: Shape.h:38
线条样式
Definition: StrokeStyle.h:68
文本布局
Definition: TextLayout.h:37
文本样式
Definition: TextStyle.h:64
PixelFormat
像素格式
Definition: Bitmap.h:54
二进制数据
Definition: BinaryData.h:30
GIF帧
Definition: GifImage.h:88
线性渐变样式
Definition: Brush.h:59
径向渐变样式
Definition: Brush.h:74