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 CreateTexture(Texture& texture, StringView file_path) override;
35
36 void CreateTexture(Texture& texture, const BinaryData& data) override;
37
38 void CreateTexture(Texture& texture, 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(Font& font, Vector<String>& family_names, StringView file_path) override;
47
48 void CreateFontCollection(Font& font, Vector<String>& family_names, const BinaryData& data) override;
49
50 void CreateTextLayout(TextLayout& layout, StringView content, const TextStyle& style) override;
51
52 void CreateLineShape(Shape& shape, const Point& begin_pos, const Point& end_pos) override;
53
54 void CreateRectShape(Shape& shape, const Rect& rect) override;
55
56 void CreateRoundedRectShape(Shape& shape, const Rect& rect, const Vec2& radius) override;
57
58 void CreateEllipseShape(Shape& shape, const Point& center, const Vec2& radius) override;
59
60 void CreateShapeSink(ShapeMaker& maker) override;
61
62 void CreateBrush(Brush& brush, const Color& color) override;
63
64 void CreateBrush(Brush& brush, const LinearGradientStyle& style) override;
65
66 void CreateBrush(Brush& brush, const RadialGradientStyle& style) override;
67
68 void CreateBrush(Brush& brush, RefPtr<Texture> texture) override;
69
70 void CreateStrokeStyle(StrokeStyle& stroke_style) override;
71
72 RefPtr<RenderContext> CreateTextureRenderContext(RefPtr<Texture> texture, const PixelSize& desired_size) override;
73
74public:
75 void Clear() override;
76
77 void Present() override;
78
79 void Resize(uint32_t width, uint32_t height) override;
80
81 void MakeContextForWindow(RefPtr<Window> window) override;
82
83 void Destroy() override;
84
85 void HandleEvent(EventModuleContext& ctx) override;
86
87protected:
89
90private:
91 using ID2DDeviceResources = kiwano::graphics::directx::ID2DDeviceResources;
92 using ID3DDeviceResources = kiwano::graphics::directx::ID3DDeviceResources;
93
94 ComPtr<ID2DDeviceResources> d2d_res_;
95 ComPtr<ID3DDeviceResources> d3d_res_;
96
97 HMONITOR monitor_;
98};
99
102} // namespace kiwano
画刷
Definition: Brush.h:92
Definition: Color.h:41
时间模块上下文
Definition: Module.h:96
字体
Definition: Font.h:89
GIF图像
Definition: GifImage.h:38
引用计数智能指针
Definition: RefBasePtr.hpp:35
Definition: RendererImpl.h:30
渲染器
Definition: Renderer.h:47
形状生成器
Definition: ShapeMaker.h:45
形状
Definition: Shape.h:38
线条样式
Definition: StrokeStyle.h:68
文本布局
Definition: TextLayout.h:37
文本样式
Definition: TextStyle.h:51
纹理
Definition: Texture.h:64
PixelFormat
像素格式
Definition: Texture.h:54
二进制数据
Definition: BinaryData.h:30
GIF帧
Definition: GifImage.h:88
线性渐变样式
Definition: Brush.h:59
径向渐变样式
Definition: Brush.h:74