Kiwano Engine v1.3.x
RenderContextImpl.h
1// Copyright (c) 2016-2019 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/RenderContext.h>
23#include <kiwano/render/DirectX/TextRenderer.h>
24
25namespace kiwano
26{
27namespace graphics
28{
29namespace directx
30{
31
32class KGE_API RenderContextImpl : public RenderContext
33{
34public:
36
37 virtual ~RenderContextImpl();
38
39 HRESULT CreateDeviceResources(ComPtr<ID2D1Factory> factory, ComPtr<ID2D1DeviceContext> ctx);
40
41 void BeginDraw() override;
42
43 void EndDraw() override;
44
45 void CreateTexture(Texture& texture, const PixelSize& size) override;
46
47 void DrawTexture(const Texture& texture, const Rect* src_rect, const Rect* dest_rect) override;
48
49 void DrawTextLayout(const TextLayout& layout, const Point& offset, RefPtr<Brush> outline_brush) override;
50
51 void DrawShape(const Shape& shape) override;
52
53 void DrawLine(const Point& point1, const Point& point2) override;
54
55 void DrawRectangle(const Rect& rect) override;
56
57 void DrawRoundedRectangle(const Rect& rect, const Vec2& radius) override;
58
59 void DrawEllipse(const Point& center, const Vec2& radius) override;
60
61 void FillShape(const Shape& shape) override;
62
63 void FillRectangle(const Rect& rect) override;
64
65 void FillRoundedRectangle(const Rect& rect, const Vec2& radius) override;
66
67 void FillEllipse(const Point& center, const Vec2& radius) override;
68
69 void PushClipRect(const Rect& clip_rect) override;
70
71 void PopClipRect() override;
72
73 void PushLayer(Layer& layer) override;
74
75 void PopLayer() override;
76
77 void Clear() override;
78
79 void Clear(const Color& clear_color) override;
80
81 Size GetSize() const override;
82
83 void SetCurrentBrush(RefPtr<Brush> brush) override;
84
85 void SetCurrentStrokeStyle(RefPtr<StrokeStyle> stroke_style) override;
86
87 void SetTransform(const Matrix3x2& matrix) override;
88
89 void SetBlendMode(BlendMode blend) override;
90
91 void SetAntialiasMode(bool enabled) override;
92
93 void SetTextAntialiasMode(TextAntialiasMode mode) override;
94
95 bool CheckVisibility(const Rect& bounds, const Matrix3x2& transform) override;
96
97 void Resize(const Size& size) override;
98
99 RefPtr<Texture> GetTarget() const override;
100
101private:
102 void DiscardDeviceResources();
103
104 void SaveDrawingState();
105
106 void RestoreDrawingState();
107
108private:
109 ComPtr<ITextRenderer> text_renderer_;
110 ComPtr<ID2D1DeviceContext> render_ctx_;
111 ComPtr<ID2D1DrawingStateBlock> drawing_state_;
112};
113
114} // namespace directx
115} // namespace graphics
116} // namespace kiwano
Definition: Color.h:41
图层
Definition: Layer.h:37
引用计数智能指针
Definition: RefBasePtr.hpp:35
渲染上下文
Definition: RenderContext.h:62
形状
Definition: Shape.h:38
文本布局
Definition: TextLayout.h:37
纹理
Definition: Texture.h:64
Definition: RenderContextImpl.h:33
TextAntialiasMode
文字抗锯齿模式
Definition: RenderContext.h:40
BlendMode
混合模式
Definition: RenderContext.h:50