YSTest: CharRenderer.h 源文件

YSTest PreAlpha_b400_20130424 The YSLib Test Project

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

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
CharRenderer.h
浏览该文件的文档.
1 ﻿/*
2 Copyright by FrankHB 2009 - 2013.
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 "TextBase.h"
32 #include "YSLib/Service/yblit.h"
33 #include <cwctype>
34
35 YSL_BEGIN
36
37 YSL_BEGIN_NAMESPACE(Drawing)
38
39
50 template<template<bool> class _gBlitLoop, typename _tOut, typename _tIn>
51 inline void
52 BlitChar(_tOut dst, _tIn src, const Size& ss, const PaintContext& pc)
53 {
54 const auto& g(pc.Target);
55 const auto& r(pc.ClipArea);
56
57 Blit<_gBlitLoop, false, false>(dst, g.GetSize(), src, ss,
58 r.GetPoint(), pc.Location, r.GetSize());
59 }
60
61
69 YF_API void
70 RenderChar(PaintContext&& pc, Color, CharBitmap::BufferType, const Size&);
71
78 YF_API void
79 RenderCharAlpha(PaintContext&& pc, Color, CharBitmap::BufferType, const Size&,
80 u8*);
81
82
87 template<class _tRenderer>
88 inline SDst
89 GetEndOfLinePositionOf(const _tRenderer& r)
90 {
91 return r.GetTextState().Margin.Right;
92 }
93
99 template<class _tRenderer>
100 void
101 PrintChar(_tRenderer& r, ucs4_t c)
102 {
103 if(YB_LIKELY(std::iswprint(c)))
104 r(c);
105 }
106
112 YF_API u8
113 PutCharBase(TextState&, SDst, ucs4_t);
114
122 template<class _tRenderer>
123 u8
124 PutChar(_tRenderer& r, ucs4_t c)
125 {
126 const u8 res(PutCharBase(r.GetTextState(),
127 r.GetContext().GetWidth() - GetEndOfLinePositionOf(r), c));
128
129 switch(res)
130 {
131 case 2:
132 r(c);
133 return 0;
134 default:
135 return res;
136 }
137 }
138
139 YSL_END_NAMESPACE(Drawing)
140
141 YSL_END
142
143 #endif
144