YSTest: CharRenderer.h 源文件

YSTest PreAlpha_b500_20140530 The YSLib Test Project

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

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
CharRenderer.h
浏览该文件的文档.
1 /*
2 © 2009-2013 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 auto& r(pc.ClipArea);
64
65 if(neg_pitch)
66 BlitLines<false, true>(scanner, dst, src, ds, ss, r.GetPoint(),
67 pc.Location, r.GetSize());
68 else
69 BlitLines<false, false>(scanner, dst, src, ds, ss, r.GetPoint(),
70 pc.Location, r.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 auto& r(pc.ClipArea);
96
97 if(neg_pitch)
98 BlitPixels<false, true>(blit, dst, src, ds, ss, r.GetPoint(),
99 pc.Location, r.GetSize());
100 else
101 BlitPixels<false, false>(blit, dst, src, ds, ss, r.GetPoint(),
102 pc.Location, r.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 SDst
136 GetEndOfLinePositionOf(const _tRenderer& r)
137 {
138 return r.GetTextState().Margin.Right;
139 }
140
146 template<class _tRenderer>
147 void
148 PrintChar(_tRenderer& r, ucs4_t c)
149 {
150 if(YB_LIKELY(std::iswprint(c)))
151 r(c);
152 }
153
159 YF_API u8
160 PutCharBase(TextState&, SDst, ucs4_t);
161
169 template<class _tRenderer>
170 u8
171 PutChar(_tRenderer& r, ucs4_t c)
172 {
173 const u8 res(PutCharBase(r.GetTextState(),
174 r.GetContext().GetWidth() - GetEndOfLinePositionOf(r), c));
175
176 switch(res)
177 {
178 case 2:
179 r(c);
180 return 0;
181 default:
182 return res;
183 }
184 }
185
186 } // namespace Drawing;
187
188 } // namespace YSLib;
189
190 #endif
191
YSLib::Drawing::PrintChar
void PrintChar(_tRenderer &r, ucs4_t c)
打印单个可打印字符。
Definition: CharRenderer.h:148
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::PutCharBase
YF_API u8 PutCharBase(TextState &, SDst, ucs4_t)
使用指定的文本状态和行末位置（横坐标）按需打印换行并判断是否需要渲染单个字符。
Definition: CharRenderer.cpp:179
YF_API
#define YF_API
Definition: Platform.h:64
YSLib::Drawing::PutChar
u8 PutChar(_tRenderer &r, ucs4_t c)
打印单个字符。
Definition: CharRenderer.h:171
platform::SDst
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:39
YSLib::Drawing::TextState
文本状态。
Definition: TextBase.h:87
YSLib::Drawing::CharBitmap::BufferType
::FT_Byte * BufferType
Definition: Font.h:360
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::RenderChar
YF_API void RenderChar(PaintContext &&pc, Color, bool, CharBitmap::BufferType, CharBitmap::FormatType, const Size &)
渲染单个字符。
Definition: CharRenderer.cpp:120
YSLib::u8
std::uint8_t u8
通用数据类型。
Definition: yadaptor.h:67
YSLib::Drawing::c
c
Definition: ystyle.h:93
CHRLib::ucs4_t
char32_t ucs4_t
UCS-4 字符类型。
Definition: chrdef.h:45
YSLib::Drawing::r
bounds & r
Definition: ydraw.h:220
YSLib::Drawing::GetEndOfLinePositionOf
SDst GetEndOfLinePositionOf(const _tRenderer &r)
取文本渲染器的行末位置（横坐标）。
Definition: CharRenderer.h:136
YB_LIKELY
#define YB_LIKELY(expr)
Definition: ydef.h:297
platform::Color
颜色。
Definition: Video.h:339
YModules.h
YSLib::Drawing::Size
屏幕区域大小。
Definition: ygdibase.h:249
YSLib::Drawing::CharBitmap::FormatType
FormatType
Definition: Font.h:362
platform::AlphaType
ystdex::octet AlphaType
Definition: Video.h:186
YSLib::Drawing::RenderCharAlpha
YF_API void RenderCharAlpha(PaintContext &&pc, Color, bool, CharBitmap::BufferType, CharBitmap::FormatType, const Size &, AlphaType *)
渲染带 Alpha 缓冲的单个字符。
Definition: CharRenderer.cpp:149