historie 08.11.2018 vjj 1
08.11.2018 vjj 2 pravěk INPUT PROGRAM OUTPUT
08.11.2018 vjj 3 dávkové zpracování evoluce interaktivní práce prompt GUI
08.11.2018 vjj 4 evoluce INPUT PROGRAM OUTPUT
08.11.2018 vjj 5 evoluce Windows bitmap graphics model - Device Context Windows does not retain a copy of what the application drew Windows 3.0 (1990) bitmap graphics model - layered Device Context Windows does retain a copy of the drawing as a bitmap Windows 2000 (beta 1998).NET Framework (2001-2005) vector graphics model WPF (on DirectX) tree of user-interface elements with objects representing graphical shapes Windows Vista,.NET Framework 3.0 (2006) Metro - deterioration Windows 8,.NET Framework 4.5 (2012)
08.11.2018 vjj 6 1: Win32 API classique
8.11.18 vjj 7 Uživatel (mouse, keyboard) Fronta zpráv GetMessage hardware interrupt DRIVER DispatchMessage System message queue RIT Raw Input Thread WindowProc WindowProc Fronta zpráv
08.11.2018 vjj 8 WM_PAINT každý ovládací prvek je samostatným oknem s vlastní procedurou na zpracovávání zpráv celá stavba programu/algoritmu se točila kolem přípravy dat pro vykreslení obsahu okna vždy, když přišla zpráva WM_PAINT (a že chodila často) během přímého kreslení se výstup do momentálně neviditelné části okna nikam nezapsal
08.11.2018 vjj 9 User Windows OS Invalidate... Program WM_PAINT GetDC Program Funkce GDI32 / GDI+ Graphics Card Frame Buffer for Screen Image data only retained as long as it remains visible on screen
08.11.2018 vjj 10 PROGRAM: direct Device Context OUTPUT PROGRAM WM_PAINT PROGRAM WM_PAINT PROGRAM WM_PAINT PROGRAM WM_PAINT PROGRAM WM_PAINT
08.11.2018 vjj 11 standardní funkce TextOut DrawText DrawIcon BitBlt stretchblt MoveToEx LineTo Rectangle Ellipse Pie Arc Chord Polyline Polygon
08.11.2018 vjj 12 Device Context standardní funkce pro kreslení do okna vyžadují hdc jako svůj první parametr datová struktura popisující vlastnosti výstupu, např. font text pero čárová grafika štětec pozadí Update Region hdc z funkcí BeginPaint, GetDC,... CS_CLASSDC, CS_OWNDC
08.11.2018 vjj 13 bitmap graphics model each UI element (HWND) has exclusive ownership of some region of the application's window within each top-level window, any given pixel in that window is controlled completely by exactly one UI element this prevents elements from being partially transparent it also preludes the use of anti-aliasing around the edges of elements
08.11.2018 vjj 29 TextOut TextOut (hdc, x, y, "text", délka) ; SetTextAlign (hdc, TA_LEFT TA_TOP) ; TA_RIGHT TA_BOTTOM TA_CENTER TA_NOUPDATECP TA_UPDATECP SetTextColor (hdc, dwcolorrgb) ; RGB (255, 255, 255) dwcolorrgb = GetTextColor (hdc) ;
08.11.2018 vjj 34 Čárová grafika MoveToEx (hdc, dox, doy, NULL) ; LineTo (hdc, dox, doy) ; Rectangle (hdc, leftx, topy, rightx, bottomy) ; Ellipse (hdc, leftx, topy, rightx, bottomy) ; Pie (hdc, leftx, topy, rightx, bottomy, x3, y3, x4, y4) ; Arc (hdc, leftx, topy, rightx, bottomy, x3, y3, x4, y4) ; Chord(hDC, leftx, topy, rightx, bottomy, x3, y3, x4, y4); Polyline (hdc, CONST POINT *lppoints, int npočet) ; Polygon (hdc, CONST POINT *lppoints, int npočet) ; SetPolyFillMode (hdc, ALTERNATE nebo WINDING);
Bitmap 08.11.2018 vjj 43
08.11.2018 vjj 70 2: layered window Win32 API upgrade
08.11.2018 vjj 71 layered window Windows WM_PAINT Program Funkce GDI32 / GDI+ off-screen Layered Window Buffer Desktop Compositing Engine (DCE) Graphics Card Frame Buffer for Screen
08.11.2018 vjj 77 2½: Windows.Forms 1st generation of.net
08.11.2018 vjj 78.NET GDI Graphics Model Aplikace Drawing Objects Funkce GDI32 / GDI+ Buffer for the Window Windows.NET runtime Funkce GDI32 / GDI+ off-screen Layered Window Buffer Desktop Window Manager (DWM) Graphics Card Buffer
3: DirectX 08.11.2018 vjj 86
3½: WPF 08.11.2018 vjj 88
08.11.2018 vjj 89 Desktop Window Manager DWM.EXE http://en.wikipedia.org/wiki/desktop_window_manager
08.11.2018 vjj 90 window undercoat DWM window with non-rectangular area window chrome window without title bar window content GDI, DirectX (WPF) window composition partial transparency, blur, outer glow, anti-aliasing
08.11.2018 vjj 91 DWM It was originally created to enable portions of the "Windows Aero" user experience (Windows Vista, Windows 7), which allowed for effects such as transparency, 3D window switching and more it has been subsequently severely reduced, blocked - with advent of Windows 8 severely reduced, code removed Windows 8, 8.1 partially revived several updates of Windows 10
window chrome 08.11.2018 vjj 92
08.11.2018 vjj 93 with UI chrome WindowStyle="ThreeDBorderWindow"
08.11.2018 vjj 94 without UI chrome WindowStyle="None"
non-rectangular window 08.11.2018 vjj 95
08.11.2018 vjj 96 Win32 API SetWindowRgn SetWindowPos (hmymainwindow, 0, 100, 100, 800, 400, SWP_NOZORDER) ; rg1 = CreateEllipticRgn (0, -400, 800, 400) ; rg2 = CreateRectRgn (0, 0, 800, 400) ; CombineRgn (rg1, rg1, rg2, RGN_AND) ; rg2 = CreateEllipticRgn (500, 50, 700, 150) ; CombineRgn (rg1, rg1, rg2, RGN_DIFF) ; SetWindowRgn (hmymainwindow, rg1, TRUE) ;
Win32 API SetWindowRgn 08.11.2018 vjj 97
08.11.2018 vjj 98 WPF VisualClip this.visualclip = new EllipseGeometry (new Rect(new Point(0, 0), new Size(400, 400)));
08.11.2018 vjj 99 WPF VisualClip WindowStyle="ThreeDBorderWindow"
08.11.2018 vjj 100 WindowStyle="None" WPF VisualClip
08.11.2018 vjj 101 AllowsTransparency <Window x:class="glassw.window1" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" AllowsTransparency="True" WindowStyle="None"> requires WindowStyle="None AllowsTransparency cannot be changed after a Window has been shown or WindowInteropHelper.EnsureHandle has been called
08.11.2018 vjj 102 WindowStyle="None" WPF AllowsTransparency="True"
window opacity 08.11.2018 vjj 103
08.11.2018 vjj 104 Opacity="0.4" Opacity
08.11.2018 vjj 105 Opacity WindowStyle="None" AllowsTransparency="True" Background="Transparent"
08.11.2018 vjj 106 Aero blur DwmIsCompositionEnabled DwmExtendFrameIntoClientArea DwmEnableBlurBehindWindow
08.11.2018 vjj 107 Aero blur <Window x:class="glassw.window1" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" AllowsTransparency="False" WindowStyle="None" Background="Transparent"> requires desktop Aero Theme
DwmExtendFrameIntoClientArea 08.11.2018 vjj 108
DwmExtendFrameIntoClientArea 08.11.2018 vjj 109
DwmExtendFrameIntoClientArea 08.11.2018 vjj 110
08.11.2018 vjj 111 DwmExtendFrameIntoClientArea public class GlassHelper { [StructLayout(LayoutKind.Sequential)] struct MARGINS { public MARGINS( Thickness t ) { Left = (int)t.left; Right = (int)t.right; Top = (int)t.top; Bottom = (int)t.bottom; } public int Left; public int Right; public int Top; public int Bottom; } // P/Invoke [DllImport("dwmapi.dll", PreserveSig = false)] static extern void DwmExtendFrameIntoClientArea( IntPtr hwnd, ref MARGINS pmarinset); [DllImport("dwmapi.dll", PreserveSig = false)] static extern bool DwmIsCompositionEnabled();
08.11.2018 vjj 112 DwmExtendFrameIntoClientArea public static bool ExtendGlassFrame( System.Windows.Window window, Thickness margin) { IntPtr hwnd = new WindowInteropHelper( window ).Handle; if (hwnd == IntPtr.Zero) return false; if (! DwmIsCompositionEnabled() ) return false; MARGINS margins = new MARGINS( margin ); DwmExtendFrameIntoClientArea( hwnd, ref margins ); } return true; } // class GlassHelper
08.11.2018 vjj 113 DwmExtendFrameIntoClientArea private void mybackgroundvisibility_unchecked( object sender, RoutedEventArgs e) { // Set the WPF background to transparent this.background = Brushes.Transparent; } // Set the Win32 background to transparent IntPtr hwnd = new WindowInteropHelper(this).Handle; if (hwnd == IntPtr.Zero) return; HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;
DwmEnableBlurBehindWindow 08.11.2018 vjj 114
08.11.2018 vjj 115 DwmEnableBlurBehindWindow [DllImport("dwmapi.dll", PreserveSig = false)] static extern void DwmEnableBlurBehindWindow( IntPtr hwnd, ref DWM_BLURBEHIND pblurbehind); [StructLayout(LayoutKind.Sequential)] struct DWM_BLURBEHIND { public DWM_BB dwflags; public bool fenable; public IntPtr hrgnblur; public bool ftransitiononmaximized; public DWM_BLURBEHIND(bool enabled) { fenable = enabled? true : false; hrgnblur = IntPtr.Zero; ftransitiononmaximized = false; dwflags = DWM_BB.Enable; } DWM_BLURBEHIND bb = new DWM_BLURBEHIND(bbb); DwmEnableBlurBehindWindow(hwnd, ref bb);
WPF 08.11.2018 vjj 116
08.11.2018 vjj 118 WPF zjednodušení stromové struktury oken, ze kterých se skládá UI aplikace všechny ovládací prvky uvnitř okna už nejsou samostatnými okny, ale jen ilustracemi o rozlišení událostí, které se jich týkají, se místo jádra Windows (vlákno RAW) stará.net runtime (tj. DLL uvnitř Win32 API aplikace hostující.net, která zpracovává Win32 API zprávy) Metro šlo ve zjednodušení stromové struktury oken ještě dál - runtime + všechny apps = jediný Win32 API proces s jediným oknem (full screen)
08.11.2018 vjj 119 WPF Graphics Model Windows Presentation Foundation (Avalon) nadstavba nad DirectX HW akcelerace transformace jsou aplikovány na libovolnou část vizuálního stromu, tj. ne pouze na kompletní uživatelskou oblast okna jako u Win32 API nezávislé na hardwaru a na rozlišení vždy vektorové jednotky: "device-independent pixels" = 1/96 th of an inch výpočty - float WPF Windows are based on old fashioned Win32 window objects. The frame (even the modern Vista frame) is rendered by GDI/GDI+. Only the client area is done by WPF itself o vykreslování kompletních oken na desktop se stará Desktop Window Manager
08.11.2018 vjj 120 borders - WindowStyle.NET 4.5, 4.6 ve Windows 7
DWM basics 08.11.2018 vjj 121
08.11.2018 vjj 122 W7 Graphics Model Program UI Chrome Visual Objects Media Integration Layer (MIL) funkce DirectX Graphics Card Buffer for the Window DWM - MIL GDI Frame Windows Funkce DirectX Graphics Card Buffer for the Screen
08.11.2018 vjj 123 Desktop Window Manager Desktop Window Manager (DWM, previously Desktop Compositing Engine or DCE) is the desktop graphical user interface system in Windows Vista, 7 that enables the Windows Aero graphical user interface and visual theme. The Desktop Window Manager requires video cards supporting DirectX 9.0 and Shader Model 2.0.
08.11.2018 vjj 124 DWM visual effects Windows 7 desktop composition is enabled only with the AERO Glass Theme Windows Flip, automatic scaling for high resolution (DPI) scaling, thumbnail previews, and full screen magnifier Windows 8 AERO Glass composition is removed desktop composition for all themes, support for Stereoscopic 3D, and management, separation, and protection of the experience with Windows Store apps Windows Flip, automatic scaling for high resolution (DPI) scaling, thumbnail previews, and full screen magnifier
Windows flip 08.11.2018 vjj 125
08.11.2018 vjj 126 DWM visual effects transparency of the non-client region of a window transition effects rounded window corners Glass sheet Glow around caption buttons Transparent background to title bar text (In Windows 8.1, the background text was drawn over an opaque background which is the same color as the personalization color chosen by the user. This restricts theme assets from being anything other than 100% transparent, otherwise the text displays incorrectly) Title bar text glow
08.11.2018 vjj 127 system chrome The 'system chrome' include the non-client area of all desktop windows, which DWM (as the desktop compositor) is completely responsible for. The code for rendering window borders (including things like the colorized regions, aka the glass regions) are all a part of the udwm component. An application may override this behavior by handling the WM_NCPAINT message, but it is otherwise rendered entirely by DWM making use of the system theme resources as necessary. It is also responsible for rendering glass regions that the user draws in the client area either via the adjustment of border margins, or via rendering of shapes using a color key for said regions.
08.11.2018 vjj 128 off-screen buffer The Desktop Window Manager is a Compositing window manager, each program has an off-screen buffer that it writes data to, the DWM then composites each program's buffer into a final image, and redraws windows when necessary. compared to the stacking window manager in Windows XP and earlier (and Windows 7 and Vista with Aero disabled) which has each program writing to the same main buffer.
08.11.2018 vjj 130 DirectX compositing and rendering Because the compositor has access to the graphics of all applications, it easily allows visual effects that string together visuals from multiple applications, such as transparency. The DWM uses DirectX to perform the function of compositing and rendering in the GPU, freeing the CPU of the task of managing the rendering from the offscreen buffers to the display. However, it does not affect applications painting to the offscreen buffers; depending on the technologies used for that, it might still be CPU-bound.
08.11.2018 vjj 131 DirectX compositing and rendering DWM-agnostic rendering techniques like GDI are redirected to the buffers by rendering the UI as bitmaps. DWM-aware rendering technologies like WPF directly make the internal data structures available in a DWM-compatible format. The window contents in the buffers are then converted to DirectX textures.
08.11.2018 vjj 132 desktop and windows The desktop itself is a full-screen Direct3D surface, with windows being represented as a mesh consisting of two adjacent (and mutually-inverted) triangles, which are transformed to represent a 2D rectangle. The texture, representing the UI chrome, is then mapped onto these rectangles.
08.11.2018 vjj 133 DWM possibilities underlying Direct3D surface default black rectangle (AllowsTransparency = "False") transparent (AllowsTransparency = "True" WindowStyle = "None") blur (DwmEnableBlurBehindWindow) chrome (WindowStyle = "ThreeDBorderWindow") blured - Window Style Aero frame extended into a client area (DwmExtendFrameIntoClientArea)
08.11.2018 vjj 134 desktop and windows Window transitions are implemented as transformations of the meshes, using shader programs. With Windows Vista, the transitions are limited to the set of built-in shaders that implement the transformations. Greg Schechter, a developer at Microsoft has suggested that it might be opened up for developers and users to plug in their own effects in a future release. The DWM only maps the primary desktop object as a 3D surface; other desktop objects, including virtual desktops as well as the secure desktop used by User Account Control are not.
08.11.2018 vjj 135 using the off-screen buffer Since all applications render to an off-screen buffer, they can be read off the buffer embedded in other applications as well. Since the off-screen buffer is constantly updated by the application, the embedded rendering will be a dynamic representation of the application window and not a static rendering. This is how the live thumbnail previews, Windows Flip and Windows Flip 3D work in Windows Vista. The DWM exposes a public API that allows applications to access these thumbnail representations. The size of the thumbnail is not fixed; applications can request the thumbnails at any size - smaller than the original window, at the same size or even larger - and DWM will scale them properly before returning. Windows Flip 3D uses the thumbnail APIs to get the window representations as bitmaps, and then uses that as texture for 2D rectangles, which are further processed by custom shaders to transform them to 3D meshes and rotate them in a 3D plane.
08.11.2018 vjj 136 DWM thumbnail API HRESULT hr = S_OK; HTHUMBNAIL thumbnail = NULL; // Register the thumbnail hr = DwmRegisterThumbnail(hwnd, FindWindow(_T("Progman"), NULL), &thumbnail); if (SUCCEEDED(hr)) { // Specify the destination rectangle size RECT dest = {0,50,100,150}; // Set the thumbnail properties for use DWM_THUMBNAIL_PROPERTIES dskthumbprops; dskthumbprops.dwflags = DWM_TNP_SOURCECLIENTAREAONLY DWM_TNP_VISIBLE DWM_TNP_OPACITY DWM_TNP_RECTDESTINATION; dskthumbprops.fsourceclientareaonly = FALSE; dskthumbprops.fvisible = TRUE; dskthumbprops.opacity = (255 * 70)/100; dskthumbprops.rcdestination = dest; // Display the thumbnail hr = DwmUpdateThumbnailProperties(thumbnail,&dskThumbProps); if (SUCCEEDED(hr)) { //... } } return hr;