YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
yrender.cpp
浏览该文件的文档.
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 #include "YSLib/UI/yrender.h"
29 #include "YSLib/UI/ycontrol.h"
30 #include "YSLib/Service/ydraw.h"
31 
33 
35 
36 Rect
38 {
39  YAssert(&e.GetSender().GetRenderer() == this, "Invalid widget found.");
40 
41  CallEvent<UI::Paint>(wgt, e);
42  return e.ClipArea;
43 }
44 
45 
46 bool
47 BufferedRenderer::RequiresRefresh() const
48 {
49  return bool(rInvalidated);
50 }
51 
52 void
53 BufferedRenderer::SetSize(const Size& s)
54 {
55  Buffer.SetSize(s.Width, s.Height);
56  rInvalidated.GetSizeRef() = s;
57 }
58 
59 Rect
60 BufferedRenderer::CommitInvalidation(const Rect& r)
61 {
62  return rInvalidated |= r;
63 }
64 
65 Rect
67 {
68  YAssert(&e.GetSender().GetRenderer() == this, "Invalid widget found.");
69 
70  const Rect& r(Validate(wgt, e.GetSender(), e));
71 
72  UpdateTo(e);
73  return r;
74 }
75 
76 void
77 BufferedRenderer::UpdateTo(const PaintContext& pc) const
78 {
79  const auto& g(pc.Target);
80  const Rect& r(pc.ClipArea);
81 
82  CopyTo(g.GetBufferPtr(), GetContext(), g.GetSize(), r.GetPoint(),
83  r.GetPoint() - pc.Location, r.GetSize());
84 }
85 
86 Rect
88  const PaintContext& pc)
89 {
90  if(RequiresRefresh())
91  {
92  const auto& l(GetLocationOf(sender));
93 
94  if(!IgnoreBackground && FetchContainerPtr(sender))
95  Invalidate(sender);
96 
97  const Rect& clip(pc.ClipArea & (rInvalidated + l));
98 
99  if(!IgnoreBackground && FetchContainerPtr(sender))
100  {
101  const auto& g(GetContext());
102 
103  CopyTo(g.GetBufferPtr(), pc.Target, g.GetSize(),
104  clip.GetPoint() - pc.Location, clip.GetPoint(), clip.GetSize());
105  }
106 
107  PaintEventArgs e(sender, {GetContext(), Point(), clip - l});
108 
109  CallEvent<UI::Paint>(wgt, e);
110  //清除无效区域:只设置一个分量为零可能会使 CommitInvalidation 结果错误。
111  rInvalidated.GetSizeRef() = Size();
112  return e.ClipArea;
113  }
114  return {};
115 }
116 
118 
119 YSL_END
120