YSTest: yblit.cpp 源文件

YSTest PreAlpha_b500_20140530 The YSLib Test Project

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

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
yblit.cpp
浏览该文件的文档.
1 /*
2 © 2011-2014 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 #include "YSLib/Service/YModules.h"
29 #include YFM_YSLib_Service_YBlit
30
31 using namespace ystdex;
32
33 namespace YSLib
34 {
35
36 namespace Drawing
37 {
38
39 namespace
40 {
41
43 inline SDst
44 blit_min(SPos s, SPos d)
45 {
46 return max<SPos>(max<SPos>(0, s), s - d);
47 }
48
49 inline SPos
50 blit_max(SPos s, SPos d, SDst sl, SDst dl, SDst cl)
51 {
52 return min<SPos>(min<SPos>(sl, s + cl), s + dl - d);
53 }
54
55 } // unnamed namespace;
56
57 bool
58 BlitBounds(const Point& dp, const Point& sp,
59 const Size& ds, const Size& ss, const Size& sc,
60 SDst& min_x, SDst& min_y, SDst& delta_x, SDst& delta_y)
61 {
62 SPos max_x, max_y;
63
64 yunseq(min_x = blit_min(sp.X, dp.X), min_y = blit_min(sp.Y, dp.Y),
65 max_x = blit_max(sp.X, dp.X, ss.Width, ds.Width, sc.Width),
66 max_y = blit_max(sp.Y, dp.Y, ss.Height, ds.Height, sc.Height));
67 if(min_x < max_x && min_y < max_y)
68 {
69 yunseq(delta_x = max_x - min_x, delta_y = max_y - min_y);
70 return true;
71 }
72 return false;
73 }
74
75
76 void
77 CopyBuffer(const Graphics& dst, const Graphics& src)
78 {
79 YAssertNonnull(dst.GetBufferPtr()), YAssertNonnull(src.GetBufferPtr());
80 YAssert(dst.GetSize() == src.GetSize(), "Source and destination sizes"
81 "are not same.");
82
83 if(YB_LIKELY(dst.GetBufferPtr() != src.GetBufferPtr()))
84 std::copy_n(src.GetBufferPtr(), GetAreaOf(src.GetSize()),
85 dst.GetBufferPtr());
86 }
87
88 void
89 ClearImage(const Graphics& g)
90 {
91 ClearPixel(g.GetBufferPtr(), GetAreaOf(g.GetSize()));
92 }
93
94 void
95 Fill(const Graphics& g, Color c)
96 {
97 FillPixel<PixelType>(g.GetBufferPtr(), GetAreaOf(g.GetSize()), c);
98 }
99
100 } // namespace Drawing;
101
102 } // namespace YSLib;
103
YSLib::Drawing::ClearPixel
_tOut ClearPixel(_tOut dst, size_t n) ynothrow
清除指定位置的 n 个连续像素。
Definition: yblit.h:424
YSLib::Drawing::ClearImage
YF_API void ClearImage(const Graphics &)
清除图形接口上下文缓冲区。
Definition: yblit.cpp:89
YSLib::Drawing::Size::Height
SDst Height
宽和高。
Definition: ygdibase.h:258
YSLib::Drawing::GetAreaOf
yconstfn auto GetAreaOf(const Size &s) ynothrow-> decltype(s.Width *s.Height)
取面积。
Definition: ygdibase.h:404
platform::SDst
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:39
platform::SPos
std::int16_t SPos
屏幕坐标度量。
Definition: Video.h:38
YSLib::Drawing::BlitBounds
YF_API bool BlitBounds(const Point &, const Point &, const Size &, const Size &, const Size &, SDst &, SDst &, SDst &, SDst &)
贴图边界计算器。
Definition: yblit.cpp:58
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:748
YSLib::Drawing::GBinaryGroup::Y
_type Y
分量。
Definition: ygdibase.h:59
YSLib::Drawing::GBinaryGroup< SPos >
YAssertNonnull
#define YAssertNonnull(_expr)
Definition: cassert.h:81
YSLib::Drawing::GBinaryGroup::X
_type X
Definition: ygdibase.h:59
YSLib::Drawing::Graphics
二维图形接口上下文。
Definition: ygdibase.h:721
platform_ex::Windows::s
return s
Definition: MinGW32.cpp:49
YSLib::Drawing::Fill
YF_API void Fill(const Graphics &, Color)
使用指定颜色填充图形接口上下文缓冲区。
Definition: yblit.cpp:95
YSLib::Drawing::g
c yconstfn g
Definition: ystyle.h:104
YB_LIKELY
#define YB_LIKELY(expr)
Definition: ydef.h:297
YSLib::Drawing::CopyBuffer
YF_API void CopyBuffer(const Graphics &, const Graphics &)
以第一个参数作为目标，复制第二个参数的缓冲区内容。
Definition: yblit.cpp:77
CHRLib::c
c
Definition: chrproc.h:76
platform::Color
颜色。
Definition: Video.h:339
YModules.h
YSLib::Drawing::Size
屏幕区域大小。
Definition: ygdibase.h:249
YSLib::Drawing::Size::Width
SDst Width
Definition: ygdibase.h:258
YAssert
#define YAssert(_expr, _msg)
Definition: cassert.h:73