本帖最后由 zhouao1999 于 2013-1-29 11:43 编辑
作者原文
http://www.msfn.org/board/topic/161788-aero-glass-for-win8-v01/
How does it work?
I have developed DLL library in C++ which is injected into dwm.exe process (no system files replacement is required). Then, the functions used for window border drawing are hooked with my own implementation. This ensures that anytime DWM wants to draw the window border, the code is redirected into my library where I can change the parameters of vertex buffer, blend state and other stuff. Then I redirect back to the original drawing function. Transparent window border is drawn! Does it provide more functionality than pure windows border transparency?
Currently, I implemented only blur effect using Direct2D. My plan is to return glow effect to the window caption, better shadow around the windows, and, if anyone is interested, try to reimplement Flip3D functionality. Are there any drawbacks?
There is a main problem that DWM implements dirty region management which ensures that only changed regions of the screen are redrawn. This simply does not redraw the content which is obscured by other windows. And, unfortunately, it pays for the content under window border too. Thus, it requires to force DWM redraw content under transparent borders. Since touching the dirty region management is not possible (at least, I have not found a way), we have two possibilities: 1) modify vertex buffer to always redraw whole window texture. It surely brings some performance penalty and does not work for windows which are totally obscured (because Draw function is not called for them at all). For other cases, this works perfectly.
2) set each visible window to be layered with alpha value of 254 because DWM also repaints dirty regions beneath them. I have selected this method because it seems to work perfectly in most of the cases, except the situation when some window denies WS_EX_LAYERED style. I am not aware of any other problems with layered windows. When will this be released?
I will try to release it in a few days including the source code. Since I don’t have much experience with Direct3D, I have used Direct2D for any drawing because it has much simpler API, built-in effects and programmer does not have to care about shaders, vertex buffers etc. I will also be glad if someone gives me a hand with this small project. There are still some known problems which I need to solve, e.g. unlike Windows 7, DWM restart is not possible in Windows 8 but it is needed for the correct Direct3D functions hooking. Extract downloaded archive into C:\DWM folder. If there is any bug and DWM crashes, it will generate crash log in this folder. 目前只供64位使用
Aero Glass For Win8 0.1下载:
DWMHook01c.7z
(936.33 KB, 下载次数: 203)
VSDLLs.7z
(561.02 KB, 下载次数: 126)
目前已知问题:
1、会使窗口移动变缓慢(有点迟钝) 2、要使功能实现,不能关闭DWM.exe运行窗口 ……
使用说明
1、解压DWMHook01c.7z到 C:\DWM 2、运行DWMLoader.exe(可能会有短暂黑屏),若无法运行请解压 VSDLLs.7z 至C:/windows/system32 3、Enjoy yourself!
|