YSTest: YBlend.h 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

YBlend.h
浏览该文件的文档.
1 /*
2 © 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_YBlend_h_
29 #define YSL_INC_Service_YBlend_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_Service_YPixel
33 #include YFM_YSLib_Service_YBlit
34
35 namespace YSLib
36 {
37
38 namespace Drawing
39 {
40
41 namespace Shaders
42 {
43
50 struct BlitTransparentPoint
51 {
53 template<typename _tOut, typename _tIn>
54 inline void
55 operator()(_tOut dst_iter, _tIn src_iter)
56 {
57 if(FetchAlpha(*src_iter))
58 *dst_iter = *src_iter;
59 }
64 template<typename _tOut, typename _tInAlpha>
65 inline void
66 operator()(_tOut dst_iter,
67 ystdex::pair_iterator<ConstBitmapPtr, _tInAlpha> src_iter)
68 {
69 *dst_iter = *get<1>(src_iter.base()) & 0x80 ? FetchOpaque(*src_iter)
70 : FetchOpaque(Pixel());
71 }
72 };
73
74
80 struct BlitAlphaPoint
81 {
82 private:
84 template<typename _type>
85 using ABitTrait = typename ystdex::decay_t<_type>::Trait;
86
87 public:
89 template<typename _tOut, typename _tInPixel, typename _tInAlpha>
90 inline void
91 operator()(_tOut dst_iter,
92 ystdex::pair_iterator<_tInPixel, _tInAlpha> src_iter)
93 {
94 static_assert(std::is_convertible<ystdex::remove_reference_t<
95 decltype(*dst_iter)>, Pixel>(), "Wrong type found.");
96
97 *dst_iter = Shaders::BlendAlpha<ABitTrait<decltype(*dst_iter)>::ABitsN,
98 8>(*dst_iter, *src_iter, AlphaType(*get<1>(src_iter.base())));
99 }
101 template<typename _tOut, typename _tIn>
102 inline void
103 operator()(_tOut dst_iter, _tIn src_iter)
104 {
105 static_assert(std::is_convertible<ystdex::remove_reference_t<
106 decltype(*dst_iter)>, Pixel>(), "Wrong type found.");
107
108 *dst_iter = Shaders::Composite<ABitTrait<decltype(*dst_iter)>::ABitsN,
109 ABitTrait<decltype(*src_iter)>::ABitsN>(*dst_iter, *src_iter);
110 }
111 };
112
113 } // namespace Shaders;
114
116
117
119 template<typename _tPixel, typename _tOut, typename... _tParams>
120 inline void
121 BlendRectRaw(_tOut dst, _tPixel c, _tParams&&... args)
122 {
123 using namespace ystdex;
124 using bl_it = pseudo_iterator<const Pixel>;
125
126 Drawing::BlitRectPixels(Shaders::BlitAlphaPoint(), dst,
127 pair_iterator<bl_it, ConstBitmapPtr>(bl_it(c), dst), yforward(args)...);
128 }
129
130 YF_API void
131 BlendRect(const Graphics&, const Rect&, Color);
133
134
136
137 template<typename _tPixel, typename _tOut, typename... _tParams>
138 inline void
139 CompositeRectRaw(_tOut dst, _tPixel c, _tParams&&... args)
140 {
141 Drawing::BlitRectPixels(Shaders::BlitAlphaPoint(), dst,
142 ystdex::pseudo_iterator<const _tPixel>(c), yforward(args)...);
143 }
144
145 YF_API void
146 CompositeRect(const Graphics&, const Rect&, Color);
148
149
150 } // namespace Drawing;
151
152 } // namespace YSLib;
153
154 #endif
155
YSLib::Drawing::Shaders::BlitTransparentPoint::operator()
void operator()(_tOut dst_iter, ystdex::pair_iterator< ConstBitmapPtr, _tInAlpha > src_iter)
Definition: YBlend.h:66
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
platform::Color
颜色。
Definition: Video.h:451
YSLib::Drawing::Shaders::BlitTransparentPoint::operator()
void operator()(_tOut dst_iter, _tIn src_iter)
Definition: YBlend.h:55
YSLib::Drawing::BlendRectRaw
void BlendRectRaw(_tOut dst, _tPixel c, _tParams &&...args)
使用指定像素 Alpha 混合指定的标准矩形区域。
Definition: YBlend.h:121
ystdex::cpp2014::remove_reference_t
typename remove_reference< _type >::type remove_reference_t
Definition: type_traits.hpp:304
platform::AlphaType
octet AlphaType
Definition: Video.h:289
NPL::dst
YF_API const char src const string const char * dst
Definition: Dependency.h:93
YModules.h
YSLib::Drawing::CompositeRect
YF_API void CompositeRect(const Graphics &, const Rect &, Color)
Definition: YBlend.cpp:48
YSLib::Drawing::BlendRect
YF_API void BlendRect(const Graphics &, const Rect &, Color)
Definition: YBlend.cpp:40
ystdex::tuple_iterator::base
base_type & base()
Definition: iterator.hpp:748
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::Shaders::BlitTransparentPoint
像素迭代器透明操作。
Definition: YBlend.h:50
YSLib::Drawing::Rect
屏幕标准矩形：表示屏幕矩形区域。
Definition: YGDIBase.h:540
YSLib::Drawing::Shaders::BlitAlphaPoint
像素计算：Alpha 混合。
Definition: YBlend.h:80
ystdex
特性测试宏。
Definition: ydef.h:796
YSLib::Drawing::Shaders::BlitAlphaPoint::operator()
void operator()(_tOut dst_iter, ystdex::pair_iterator< _tInPixel, _tInAlpha > src_iter)
Definition: YBlend.h:91
YSLib::Drawing::CompositeRectRaw
void CompositeRectRaw(_tOut dst, _tPixel c, _tParams &&...args)
使用指定像素 Alpha 组合指定的标准矩形区域。
Definition: YBlend.h:139
Drawing
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
ystdex::pseudo_iterator
伪迭代器。
Definition: iterator.hpp:62
YSLib::Drawing::GGraphics
二维图形接口上下文模板。
Definition: YGraphics.h:62
YSLib::Drawing::BlitRectPixels
void BlitRectPixels(_fPixelShader shader, _tOut dst, _tIn src, _tParams &&...args)
Definition: YBlit.h:397
YSLib::Drawing::Shaders::BlitAlphaPoint::operator()
void operator()(_tOut dst_iter, _tIn src_iter)
Definition: YBlend.h:103
ystdex::tuple_iterator
元组迭代器。
Definition: iterator.hpp:647
YSLib::Drawing::Shaders::BlitAlphaPoint::ABitTrait
typename ystdex::decay_t< _type >::Trait ABitTrait
Definition: YBlend.h:85