YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
YBrush.h
浏览该文件的文档.
1 /*
2  © 2012-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_UI_YBrush_h_
29 #define YSL_INC_UI_YBrush_h_ 1
30 
31 #include "YModules.h"
32 #include YFM_YSLib_UI_YWidgetEvent
33 #include YFM_YSLib_Service_YResource
34 #include YFM_YSLib_Service_YBlit // for Drawing::BlitPixels;
35 
36 namespace YSLib
37 {
38 
39 namespace UI
40 {
41 
47 {
48 public:
50 
52  : Color(c)
53  {}
54 
55  void
56  operator()(PaintEventArgs&&);
57 };
58 
59 
68 template<typename _type>
69 using GBrushUpdater = std::function<void(const PaintContext&, _type,
70  const Point&, const Point&)>;
71 
72 
78 {
79 public:
84  GBrushUpdater<const Drawing::Image&> Update{DefaultUpdate};
85 
87  mutable shared_ptr<Drawing::Image> ImagePtr;
89  Point DstOffset{};
91  Point SrcOffset{};
92 
94  ImageBrush(const shared_ptr<Drawing::Image>& h)
95  : ImagePtr(h)
96  {}
97  ImageBrush(shared_ptr<Drawing::Image>&& h)
98  : ImagePtr(std::move(h))
99  {}
102 
105 
110  void
111  operator()(PaintEventArgs&&);
112 
117  static void
118  DefaultUpdate(const PaintContext&, const Drawing::Image&, const Point&,
119  const Point&);
120 
125  static void
126  UpdateComposite(const PaintContext&, const Drawing::Image&, const Point&,
127  const Point&);
128 };
129 
130 
136 template<typename _fPixelShader, bool _bSwapLR = false, bool _bSwapUD = false>
137 void
138 UpdatePixels(_fPixelShader shader, const PaintContext& pc,
139  const Drawing::Image& img, const Point& dst_offset, const Point& src_offset)
140 {
141  const auto& g(pc.Target);
142  const Rect& r(pc.ClipArea);
143  const auto& src(img.GetContext());
144 
145  Drawing::BlitPixels<_bSwapLR, _bSwapUD>(shader, g.GetBufferPtr(),
146  src.GetBufferPtr(), g.GetSize(), src.GetSize(), r.GetPoint(),
147  r.GetPoint() + src_offset - dst_offset, r.GetSize());
148 }
149 
150 } // namespace UI;
151 
152 } // namespace YSLib;
153 
154 #endif
155 
Drawing::Color Color
Definition: YBrush.h:49
yconstfn DefDeCtor(ImageBrush) ImageBrush(const shared_ptr< Drawing
Definition: YBrush.h:93
#define DefDeCopyCtor(_t)
Definition: YBaseMacro.h:136
SolidBrush(Drawing::Color c)
Definition: YBrush.h:51
部件绘制参数。
Definition: ywgtevt.h:276
#define YF_API
Definition: Platform.h:64
void UpdatePixels(_fPixelShader shader, const PaintContext &pc, const Drawing::Image &img, const Point &dst_offset, const Point &src_offset)
更新:逐像素操作。
Definition: YBrush.h:138
shared_ptr< Drawing::Image > ImagePtr
Definition: YBrush.h:87
屏幕标准矩形:表示屏幕矩形区域。
Definition: ygdibase.h:416
std::function< void(const PaintContext &, _type, const Point &, const Point &)> GBrushUpdater
画刷更新器类型。
Definition: YBrush.h:70
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:463
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:159
Selected const shared_ptr< ListType > const pair< Color, Color > & DefDeMoveCtor(TextList) DefPredMem(const ynothrow
单色画刷。
Definition: YBrush.h:46
图像画刷。
Definition: YBrush.h:77
bounds & r
Definition: ydraw.h:220
c yconstfn g
Definition: ystyle.h:104
ImageBrush(shared_ptr< Drawing::Image > &&h)
Definition: YBrush.h:97
颜色。
Definition: Video.h:339
#define DefDeCopyAssignment(_t)
Definition: YBaseMacro.h:154