YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
HostWindow.cpp
浏览该文件的文档.
1 /*
2  © 2013-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 "Helper/YModules.h"
29 #include YFM_Helper_Host
30 #include YFM_Helper_GUIApplication // for FetchEnvironent;
31 #include YFM_YCLib_Input // for platform::ClearKeyStates;
32 
33 namespace YSLib
34 {
35 
36 using namespace Drawing;
37 
38 #if YF_Hosted
39 namespace Host
40 {
41 
42 
44  : Window(h, FetchEnvironment())
45 {}
46 Window::Window(NativeWindowHandle h, Environment& e)
47  : HostWindow(h), env(e)
48 {
49 # if YCL_Win32
50  e.AddMappedItem(h, this);
51  MessageMap[WM_KILLFOCUS] += []{
53  };
54 # endif
55 }
56 Window::~Window()
57 {
58  env.get().RemoveMappedItem(GetNativeHandle());
59 }
60 
61 pair<Point, Point>
62 Window::GetInputBounds() const ynothrow
63 {
64 # if YCL_Win32
65  ::RECT rect;
66 
67  if(YB_UNLIKELY(!::GetClientRect(GetNativeHandle(), &rect)))
68  return {};
69  YAssert(rect.right - rect.left >= 0 && rect.bottom - rect.top >= 0,
70  "Invalid boundary found.");
71  return {Point(rect.left, rect.top), Point(rect.right, rect.bottom)};
72 # elif YCL_Android
73  return {};
74 # endif
75 }
76 
77 void
79 {
80  const auto h_wnd(GetNativeHandle());
81 
82 # if YCL_Win32
83  if(UseOpacity)
84  {
85  rbuf.Premultiply(buf);
86  rbuf.UpdatePremultipliedTo(h_wnd, Opacity);
87  }
88  else
89 #endif
90  {
91  rbuf.UpdateFrom(buf);
92  rbuf.UpdateTo(h_wnd);
93  }
94 }
95 
96 } // namespace Host;
97 #endif
98 
99 } // namespace YSLib;
100 
Window(const Rect &={}, unique_ptr< Renderer >=make_unique< BufferedRenderer >())
构造:使用指定边界并设置渲染器。
Definition: ywindow.cpp:40
窗口背景。
Definition: ystyle.h:182
#define YB_UNLIKELY(expr)
分支预测提示。
Definition: ydef.h:298
GBinaryGroup< SPos > Point
屏幕二维点(直角坐标表示)。
Definition: ygdibase.h:235
DefGetter(ynothrow, ScreenBuffer &, ScreenBufferRef,*this) using ScreenBuffer voi UpdateFrom)(YSLib::Drawing::BitmapPtr) ynothrow
Definition: Android.h:234
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
::ANativeWindow * NativeWindowHandle
Definition: Android.h:50
YF_API void ClearKeyStates()
清除按键缓冲。
Definition: Input.cpp:155
PixelType * BitmapPtr
Definition: Video.h:295
ScreenRegionBuffer(const YSLib::Drawing::Size &, YSLib::SDst)
构造:使用指定的缓冲区大小和像素跨距。 像素跨距小于缓冲区大小。
#define YAssert(_expr, _msg)
Definition: cassert.h:73