YSTest: YBlit.cpp 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

YBlit.cpp
浏览该文件的文档.
1 /*
2 © 2011-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 #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 SDst(max<SPos>(max(SPos(), s), s - d));
47 }
48
49 inline SPos
50 blit_max(SPos s, SPos d, SDst sl, SDst dl, SDst cl)
51 {
52 // XXX: Conversion to 'SPos' might be implementation-defined.
53 return min<SPos>(min<SPos>(SPos(sl), s + SPos(cl)), s + SPos(dl) - d);
54 }
55
56 } // unnamed namespace;
57
58 bool
59 BlitBounds(const Point& dp, const Point& sp,
60 const Size& ds, const Size& ss, const Size& sc,
61 SDst& min_x, SDst& min_y, SDst& delta_x, SDst& delta_y)
62 {
63 SPos max_x, max_y;
64
65 yunseq(min_x = blit_min(sp.X, dp.X), min_y = blit_min(sp.Y, dp.Y),
66 max_x = blit_max(sp.X, dp.X, ss.Width, ds.Width, sc.Width),
67 max_y = blit_max(sp.Y, dp.Y, ss.Height, ds.Height, sc.Height));
68 if(max_x >= 0 && max_y >= 0 && min_x < SDst(max_x) && min_y < SDst(max_y))
69 {
70 yunseq(delta_x = SDst(max_x) - min_x, delta_y = SDst(max_y) - min_y);
71 return true;
72 }
73 return {};
74 }
75
76
77 void
78 CopyBuffer(const Graphics& dst, const ConstGraphics& src)
79 {
80 YAssert(dst.GetSize() == src.GetSize(), "Source and destination sizes"
81 "are not same.");
82
83 if(YB_LIKELY(Nonnull(dst.GetBufferPtr()) != Nonnull(src.GetBufferPtr())))
84 CopyBitmapBuffer(dst.GetBufferPtr(), src.GetBufferPtr(), src.GetSize());
85 }
86
87 void
88 ClearImage(const Graphics& g)
89 {
90 ClearPixels(g.GetBufferPtr(), size_t(GetAreaOf(g.GetSize())));
91 }
92
93 void
94 Fill(const Graphics& g, Color c)
95 {
96 FillPixels<Pixel>(g.GetBufferPtr(), size_t(GetAreaOf(g.GetSize())), c);
97 }
98
99 } // namespace Drawing;
100
101 } // namespace YSLib;
102
YSLib::Drawing::Fill
YF_API void Fill(const Graphics &, Color)
使用指定颜色填充图形接口上下文缓冲区。
Definition: YBlit.cpp:94
platform::Nonnull
_type && Nonnull(_type &&p) ynothrow
断言并返回非空指针。
Definition: Debug.h:411
YSLib::Drawing::ClearImage
YF_API void ClearImage(const Graphics &)
清除图形接口上下文缓冲区。
Definition: YBlit.cpp:88
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
platform::Color
颜色。
Definition: Video.h:451
YSLib::Drawing::GBinaryGroup::X
_type X
Definition: YGDIBase.h:63
YSLib::Drawing::Size::Width
SDst Width
Definition: YGDIBase.h:302
platform::size_t
YF_API size_t
Definition: FileIO.h:1262
YSLib::Drawing::GBinaryGroup::Y
_type Y
分量。
Definition: YGDIBase.h:63
YAssert
#define YAssert(_expr, _msg)
Definition: cassert.h:105
CHRLib::d
_tDst * d
Definition: CharacterProcessing.h:139
YSLib::Drawing::BlitBounds
YF_API bool BlitBounds(const Point &, const Point &, const Size &, const Size &, const Size &, SDst &, SDst &, SDst &, SDst &)
块传输边界计算器。
Definition: YBlit.cpp:59
CHRLib::c
c
Definition: CharacterProcessing.h:81
YSLib::Drawing::CopyBuffer
YF_API void CopyBuffer(const Graphics &, const ConstGraphics &)
以第一个参数作为目标，复制第二个参数的缓冲区内容。
Definition: YBlit.cpp:78
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
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:996
ystdex
特性测试宏。
Definition: ydef.h:796
ystdex::max
const _type & max(const _type &a, const _type &b, _fComp comp=less< _type >())
取较大的元素。
Definition: algorithm.hpp:543
YSLib::Drawing::Size
屏幕区域大小。
Definition: YGDIBase.h:293
Drawing
YSLib::Drawing::CopyBitmapBuffer
void CopyBitmapBuffer(_tOut p_dst, _tIn p_src, const Size &s)
Definition: YGraphics.h:50
YB_LIKELY
#define YB_LIKELY(_expr)
Definition: ydef.h:437
YSLib::Drawing::Size::Height
SDst Height
宽和高。
Definition: YGDIBase.h:302
YSLib::Drawing::ClearPixels
_tOut ClearPixels(_tOut dst, size_t n) ynothrowv
清除指定位置的 n 个连续像素。
Definition: YBlit.h:517
YSLib::Drawing::GGraphics
二维图形接口上下文模板。
Definition: YGraphics.h:62
YSLib::Drawing::g
The boundary is out of the const Graphics & g
Definition: YDraw.h:161
CHRLib::s
_tDst const _tSrc * s
Definition: CharacterProcessing.h:140
platform::SDst
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:43
YSLib::Drawing::GBinaryGroup
屏幕二元组。
Definition: YGDIBase.h:54