YSTest: CharRenderer.h 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

CharRenderer.h
浏览该文件的文档.
1 /*
2 © 2009-2015 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YSL_INC_Service_CharRenderer_h_
29 #define YSL_INC_Service_CharRenderer_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_Service_TextBase
33 #include YFM_YSLib_Service_YBlit
34 #include <cwctype>
35
36 namespace YSLib
37 {
38
39 namespace Drawing
40 {
41
57 template<typename _tOut, typename _tIn, typename _fBlitScanner>
58 void
59 BlitGlyphLines(_fBlitScanner scanner, _tOut dst, _tIn src, const Size& ss,
60 const PaintContext& pc, bool neg_pitch)
61 {
62 const auto& ds(pc.Target.GetSize());
63 const Rect& bounds(pc.ClipArea);
64
65 if(neg_pitch)
66 BlitLines<false, true>(scanner, dst, src, ds, ss, bounds.GetPoint(),
67 pc.Location, bounds.GetSize());
68 else
69 BlitLines<false, false>(scanner, dst, src, ds, ss, bounds.GetPoint(),
70 pc.Location, bounds.GetSize());
71 }
72
73
89 template<typename _tOut, typename _tIn, typename _fPixelShader>
90 void
91 BlitGlyphPixels(_fPixelShader blit, _tOut dst, _tIn src, const Size& ss,
92 const PaintContext& pc, bool neg_pitch)
93 {
94 const auto& ds(pc.Target.GetSize());
95 const Rect& bounds(pc.ClipArea);
96
97 if(neg_pitch)
98 BlitPixels<false, true>(blit, dst, src, ds, ss, bounds.GetPoint(),
99 pc.Location, bounds.GetSize());
100 else
101 BlitPixels<false, false>(blit, dst, src, ds, ss, bounds.GetPoint(),
102 pc.Location, bounds.GetSize());
103 }
104
105
114 YF_API void
115 RenderChar(PaintContext&& pc, Color, bool, CharBitmap::BufferType,
116 CharBitmap::FormatType, const Size&);
117
125 YF_API void
126 RenderCharAlpha(PaintContext&& pc, Color, bool, CharBitmap::BufferType,
127 CharBitmap::FormatType, const Size&, AlphaType*);
128
129
134 template<class _tRenderer>
135 inline SPos
136 GetEndOfLinePositionOf(const _tRenderer& rd)
137 {
138 return rd.GetTextState().Margin.Right;
139 }
140
146 template<class _tRenderer>
147 inline SPos
148 GetEndOfLineOffsetOf(const _tRenderer& rd)
149 {
150 return SPos(rd.GetContext().GetWidth()) - GetEndOfLinePositionOf(rd);
151 }
152
158 template<class _tRenderer>
159 void
160 PrintChar(_tRenderer& rd, char32_t c)
161 {
162 if(YB_LIKELY(Text::IsPrint(c)))
163 rd(c);
164 }
165
167
168 enum class PutCharResult
170 {
172 NeedNewline,
174 PutNewline,
176 NotPrintable,
178 Normal
179 };
180
181
183
184 YF_API PutCharResult
186 PutCharBase(TextState&, SDst, char32_t);
187
195 template<class _tRenderer>
196 PutCharResult
197 PutChar(_tRenderer& rd, char32_t c, SDst eol)
198 {
199 const auto res(PutCharBase(rd.GetTextState(), eol, c));
200
201 if(res == PutCharResult::Normal)
202 rd(c);
203 return res;
204 }
205 template<class _tRenderer>
206 PutCharResult
207 PutChar(_tRenderer& rd, char32_t c)
208 {
209 const SPos seol(GetEndOfLineOffsetOf(rd));
210
211 if(seol >= 0)
212 return PutChar(rd, c, SDst(seol));
213 return PutCharResult::NeedNewline;
214 }
216
218 template<class _tRenderer, typename _tChar, typename... _tParams>
219 inline PutCharResult
220 PutChar(_tRenderer& rd, _tChar c, _tParams&&... args)
221 {
222 return PutChar(rd, char32_t(c), yforward(args)...);
223 }
225
226
227 } // namespace Drawing;
228
229 } // namespace YSLib;
230
231 #endif
232
YSLib::Drawing::BlitGlyphLines
void BlitGlyphLines(_fBlitScanner scanner, _tOut dst, _tIn src, const Size &ss, const PaintContext &pc, bool neg_pitch)
字符按扫描线块传输。
Definition: CharRenderer.h:59
YSLib::Drawing::PutCharResult::Normal
可继续在同一行输出可打印字符。
YSLib::Drawing::PutCharResult::NotPrintable
遇到不可打印字符。
YSLib::Drawing::GetEndOfLinePositionOf
SPos GetEndOfLinePositionOf(const _tRenderer &rd)
取文本渲染器的行末位置（横坐标）。
Definition: CharRenderer.h:136
YSLib::Drawing::GetEndOfLineOffsetOf
SPos GetEndOfLineOffsetOf(const _tRenderer &rd)
取文本渲染器的行末位置剩余偏移。
Definition: CharRenderer.h:148
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
platform::Color
颜色。
Definition: Video.h:451
YSLib::Drawing::PutCharBase
YF_API PutCharResult PutCharBase(TextState &, SDst, char32_t)
使用指定的文本状态和行末位置按需打印换行并判断是否需要渲染单个字符。
Definition: CharRenderer.cpp:170
YSLib::Drawing::bounds
The boundary is out of the const Rect & bounds
Definition: YDraw.h:127
YSLib::Drawing::PrintChar
void PrintChar(_tRenderer &rd, char32_t c)
打印单个可打印字符。
Definition: CharRenderer.h:160
platform::AlphaType
octet AlphaType
Definition: Video.h:289
YSLib::Drawing::char32_t
tr TextRegion &tr char32_t
Definition: TextLayout.h:92
YSLib::Drawing::CharBitmap::FormatType
FormatType
Definition: Font.h:392
NPL::dst
YF_API const char src const string const char * dst
Definition: Dependency.h:93
YModules.h
platform::SPos
std::int16_t SPos
屏幕坐标度量。
Definition: Video.h:42
YSLib::Drawing::BlitGlyphPixels
void BlitGlyphPixels(_fPixelShader blit, _tOut dst, _tIn src, const Size &ss, const PaintContext &pc, bool neg_pitch)
字符按像素块传输。
Definition: CharRenderer.h:91
YSLib::Drawing::c
The boundary is out of the const Graphics const Rect const Point const Point Color c const Rect const Rect Color c
Definition: YDraw.h:174
YSLib::Drawing::RenderChar
YF_API void RenderChar(PaintContext &&pc, Color, bool, CharBitmap::BufferType, CharBitmap::FormatType, const Size &)
渲染单个字符。
Definition: CharRenderer.cpp:109
YSLib::Drawing::Rect
屏幕标准矩形：表示屏幕矩形区域。
Definition: YGDIBase.h:540
YSLib::Drawing::Size
屏幕区域大小。
Definition: YGDIBase.h:293
Drawing
YSLib::Drawing::CharBitmap::BufferType
byte * BufferType
Definition: Font.h:387
YB_LIKELY
#define YB_LIKELY(_expr)
Definition: ydef.h:437
YSLib::Drawing::PutCharResult
PutCharResult
输出字符结果。
Definition: CharRenderer.h:169
YSLib::Drawing::PutCharResult::NeedNewline
行内无法容纳而换行。
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:969
YF_API
#define YF_API
Definition: Platform.h:56
CHRLib::args
_tParams && args
Definition: CharacterProcessing.h:538
YSLib::Drawing::RenderCharAlpha
YF_API void RenderCharAlpha(PaintContext &&pc, Color, bool, CharBitmap::BufferType, CharBitmap::FormatType, const Size &, AlphaType *)
渲染带 Alpha 缓冲的单个字符。
Definition: CharRenderer.cpp:140
YSLib::Drawing::PutChar
PutCharResult PutChar(_tRenderer &rd, char32_t c, SDst eol)
打印单个字符。
Definition: CharRenderer.h:197
YSLib::Drawing::PutCharResult::PutNewline
输出换行符。
Definition: TextBase.cpp:52
platform::SDst
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:43