Graphics Device Interface

The Graphics Device Interface (GDI) is a Microsoft Windows application programming interface and core operating system component responsible for representing graphical objects and transmitting them to output devices such as monitors and printers.

GDI is responsible for tasks such as drawing lines and curves, rendering fonts and handling palettes. It is not directly responsible for drawing windows, menus, etc.; that task is reserved for the user subsystem, which resides in user32.dll and is built atop GDI. Other systems have components that are similar to GDI, for example macOS' Quartz and X Window System's Xlib/XCB.

GDI's most significant advantages over more direct methods of accessing the hardware are perhaps its scaling capabilities and its abstract representation of target devices. Using GDI, it is very easy to draw on multiple devices, such as a screen and a printer, and expect proper reproduction in each case. This capability is at the center of most What You See Is What You Get applications for Microsoft Windows.

Simple games that do not require fast graphics rendering may use GDI. However, GDI is relatively hard to use for advanced animation, and lacks a notion for synchronizing with individual video frames in the video card, lacks hardware rasterization for 3D, etc. Modern games usually use DirectX or OpenGL instead, which let programmers exploit the features of modern hardware.

Technical details

A Device Context (DC) is used to define the attributes of text and images that are output to the screen or printer. The actual context is maintained by GDI. A handle to the Device Context (HDC) is obtained before output is written and then released after elements have been written. GDI uses Bresenham's line drawing algorithm to draw aliased lines.[1]

Version history

Early versions

GDI was present in the initial release of Windows. MS-DOS programs had hitherto manipulated the graphics hardware using software interrupts (sometimes via the Video BIOS) and by manipulating video memory directly. Code written in this way expects that it is the only user of the video memory, which was not tenable on a windowed system like Microsoft Windows, where multiple applications would want to write (to their own subwindows) concurrently. BYTE in December 1983 discussed Microsoft's plans for a system to output graphics to both printers and monitors with the same code in the forthcoming first release of Windows.[2]

Windows XP

With the introduction of Windows XP, GDI was complemented by the C++-based GDI+ subsystem. GDI+ adds anti-aliased 2D graphics, floating point coordinates, gradient shading, more complex path management, intrinsic support for modern graphics-file formats like JPEG and PNG, and support for composition of affine transformations in the 2D view pipeline. GDI+ uses ARGB values to represent color. Use of these features is apparent in Windows XP's user interface and several of its applications such as Microsoft Paint, Windows Picture and Fax Viewer, Photo Printing Wizard, and My Pictures Slideshow screensaver, and their presence in the basic graphics layer greatly simplifies implementations of vector-graphics systems such as Flash or SVG.

GDI+ is included with all versions of Windows from Windows XP. The GDI+ dynamic library can also be shipped with an application and used under older versions of Windows from Windows 98 and Windows NT 4.0 onwards.[3]

Because of the additional text processing and resolution independence capabilities in GDI+, text rendering is performed by the CPU[4] and it is nearly an order of magnitude slower than in hardware accelerated GDI.[5] Chris Jackson published some tests indicating that a piece of text rendering code he had written could render 99,000 glyphs per second in GDI, but the same code using GDI+ rendered 16,600 glyphs per second.

The Microsoft .NET class library provides a managed interface for GDI+ via the System.Drawing namespace.

GDI+ is similar (in purpose and structure) to Apple's QuickDraw GX subsystem, and the open-source libart and Cairo libraries.

Windows Vista

In Windows Vista, all Windows applications including GDI and GDI+ applications run in the new compositing engine, Desktop Window Manager (DWM) which is built atop the Windows Display Driver Model. GDI rendering is implemented with the Canonical Display Driver (cdd.dll), which draws into system memory surfaces which are then redirected through DWM, and GDI is no longer hardware-accelerated by the video card driver.[6][7][8] However, due to the nature of desktop composition (internal management of moving bitmaps and transparency and anti-aliasing of GDI+ being handled at the DWM core), operations like window moves can be faster or more responsive because underlying content does not need to be re-rendered by the application.[7]

Windows 7

Windows 7 includes GDI hardware acceleration for blitting operations in the Windows Display Driver Model v1.1. This improves GDI performance of the Canonical Display Driver and allows DWM engine to use local video memory for compositing, thereby reducing system memory footprint and increasing the performance of graphics operations. Most primitive GDI operations are still not hardware-accelerated, unlike Direct2D. As of November 2009, both AMD and Nvidia have released WDDM v1.1 compatible video drivers.

GDI+ continues to rely on software rendering in Windows 7.[9]

GDI printers

A GDI printer or Winprinter (analogous to a Winmodem) is a printer designed to accept output from a host computer running the GDI under Windows. The host computer does all print processing: the GDI software renders a page as a bitmap which is sent to a software printer driver, usually supplied by the printer manufacturer, for processing for the particular printer, and then to the printer.[10] The combination of the GDI and the driver is bidirectional; they receive information from the printer such as whether it is ready to print, if it is out of paper or ink, and so on.

Non-GDI printers require hardware, firmware, and memory for page rendering; a GDI printer uses the host computer for this, making it cheaper to manufacture than a similar non-GDI printer. Some manufacturers produce essentially the same printer in a version compatible with a printer control language such as PCL or PostScript, and a cheaper GDI-only version. In most cases only the very lowest-cost models in any given manufacturer's range support only GDI.

A printer with its own control language can accept input from any device with a suitable driver; a GDI printer requires a PC running Windows, and is not compatible with other hardware and operating systems. In general GDI printers are not compatible with hardware print servers, although some servers have built-in processing capability making them compatible with specified GDI printers. GDI printers can be made available to computers on a network if they are connected as shared printers on a computer which is on and running Windows. Some "generic" GDI drivers such as pnm2ppa have been written which make some GDI printers compatible with non-Windows operating systems such as FreeBSD, but there is no guarantee that any particular GDI printer will be supported.[10]

In order to allow simpler creation of drivers for Winprinters, the Microsoft Universal Printer Driver was created. This allows printer vendors to write Generic Printer Description (GPD) "minidrivers", which describe the printer's capabilities and command set in plaintext, rather than having to do kernel mode driver development.

Limitations

IE7 Errors caused by 10000 GDI Objects 1
IE7 Errors caused by 10000 GDI Objects 2
GDI overflow in Internet Explorer 7 prevents the graphical elements of the browser tabs from drawing correctly, and the address bar incorrectly appears by itself in the top-left corner of the desktop display area. In these example screenshots, approximately 49 windows were opened at the same time, using Windows XP with Service Pack 3 and Internet Explorer 7.

Each time a window is opened, it consumes GDI objects. As the complexity of the window increases, with additional features such as buttons and images, its GDI object usage also increases. When too many objects are in use, Windows is unable to draw any more GDI objects, leading to misbehaving software and frozen and unresponsive program operation.[11] Many applications are also incorrectly coded and fail to release GDI objects after use, which further adds to the problem.[12] The total available GDI objects varies from one version of Windows to the next: Windows 95, 98, and Millennium had a limit of 1,200 total objects; Windows 2000 has a limit of 16,384 objects; and Windows XP, Vista, and Windows 7 have a configurable limit (via the registry) that defaults to 10,000 objects per process (but a theoretical maximum of 65,536 for the entire session).[13][14] Windows 8 and 8.1 further increase the GDI object limit to 65,536 per user logon session.

Earlier versions of Windows such as Windows 3.1 and Windows 98 included a Resource Meter program to allow the user to monitor how much of the total system GDI resources were in use. Unfortunately, this resource meter consumed GDI objects itself. Later versions such as Windows 2000 and Windows XP can report GDI object usage for each program in the Task Manager, but they cannot tell the user the total GDI capacity available.

Overflowing GDI capacity can affect Windows itself, preventing new windows from opening, menus from displaying, and alert boxes from appearing. The situation can be difficult to clear and can potentially require a forced hard-reset of the system, since it prevents core system programs from functioning. In Windows 8 and 8.1, forced logoffs occur as a result of GDI capacity overflow instead of a hard reboot.

For example, forcing a frozen process to end using the Task Manager normally makes an "Are you sure" alert window appear. With no free GDI, Windows beeps an error and the alert choice does not appear, so the GDI-overflowing processes cannot be terminated (unless the user uses taskkill command).

Successor: Direct2D and DirectWrite

Direct2D and DirectWrite were designed to replace GDI/GDI+ and Uniscribe, respectively, for screen-oriented rendering and were shipped with Windows 7 and Windows Server 2008 R2, as well as Windows Vista and Windows Server 2008 (with Platform Update installed). For WPF/UWP based-Application Win2D is a GDI like Class Library developed by Microsoft that can be downloaded inside Visual Studio using NuGet. Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics rendering with GPU acceleration.[15][16]

See also

Notes and references

  1. ^ Comparing Direct2D and GDI Hardware Acceleration. https://msdn.microsoft.com/en-us/library/windows/desktop/ff729480(v=vs.85).aspx
  2. ^ Butler, John (December 1983). "Device-Independent Graphics Output for Microsoft Windows". BYTE. p. 49. Retrieved 20 October 2013.
  3. ^ GDI+
  4. ^ "2D Drawing APIs in Windows -". DirectX Developer Blog. MSDN Blogs. May 12, 2009. Retrieved July 19, 2012.
  5. ^ Jackson, Chris. "GDI vs. GDI+ Text Rendering Performance". Chris Jackson's Semantic Consonance. Microsoft.
  6. ^ MSDN: Comparing Direct2D and GDI Hardware Acceleration
  7. ^ a b GDI is not hardware accelerated in Windows Vista
  8. ^ Layered windows...SW is sometimes faster than HW. Avalite on MSDN Blogs.
  9. ^ Thomas Olsen (October 29, 2008). "Introducing the Microsoft Direct2D API".
  10. ^ a b "linuxprinting.org about GDI printer". The Linux Foundation. Archived from the original on September 14, 2007. Retrieved September 22, 2007.
  11. ^ Microsoft Knowledgebase article 838283 - Desktop application menus are improperly displayed if a process exceeds its GDI object quota in Windows XP or in Windows 2000 http://support.microsoft.com/kb/838283
  12. ^ Microsoft Developer Network Blog - GDI leak in Outlook 2007 causes problems when GDI usage reaches 10,000 objects http://blogs.msdn.com/rgregg/archive/2007/09/03/outlook-2007-gdi-leak-hotfix.aspx
  13. ^ Microsoft Developer Network - GDI Object limits http://msdn.microsoft.com/en-us/library/ms724291(VS.85).aspx
  14. ^ Microsoft Knowledge base Article 894500 - .NET programs designed on newer NT operating systems may malfunction on older Win 95 / Win 98 / Win ME due to lower GDI usage limits http://support.microsoft.com/kb/894500
  15. ^ Win2D GitHub Docs
  16. ^ Win2D Example Gallery

External links

Barbarians Led by Bill Gates

Barbarians Led by Bill Gates: Microsoft from the Inside is a book that was jointly written by Jennifer Edstrom and Marlin Eller, an American programmer who was a manager and a software developer at Microsoft Corporation from 1982–95, and development lead for the Graphics Device Interface (GDI) of Windows 1.0 and also for Pen Windows. Written as a third-person account of Eller's experiences at Microsoft, it goes into detail about the early years of Microsoft and its emergence as a massive corporation.

Two chapters of the book deal specifically with the business contacts between Microsoft and GO Corporation. In April 2008, as part of a larger federal court case, the gesture features of the Windows/Tablet PC operating system and hardware were found to infringe on a patent by GO Corp. concerning gesture interfaces in operating systems for portable computers.

Canvas element

The canvas element is part of HTML5 and allows for dynamic, scriptable rendering of 2D shapes and bitmap images. It is a low level, procedural model that updates a bitmap and does not have a built-in scene graph; however through WebGL allows 3D shapes and images and so-on.

Client/Server Runtime Subsystem

Client Server Runtime Subsystem, or csrss.exe, is a component of the Windows NT family of operating systems that provides the user mode side of the Win32 subsystem and is included in Windows NT 3.1 and later. Because most of the Win32 subsystem operations have been moved to kernel mode drivers in Windows NT 4 and later, CSRSS is mainly responsible for Win32 console handling and GUI shutdown. It is critical to system operation; therefore, terminating this process will result in system failure. Under normal circumstances, CSRSS cannot be terminated with the taskkill command or with Windows Task Manager, although it is possible in Windows Vista if the Task Manager is run in Administrator mode. On Windows 7 and later, Task Manager will inform the user that terminating the process may result in system failure, and prompt if they want to continue.

Desktop Window Manager

Desktop Window Manager (DWM, previously Desktop Compositing Engine or DCE) is the window manager in Windows Vista, Windows 7, Windows 8 and Windows 10 that enables the use of hardware acceleration to render the graphical user interface of Windows.

It was originally created to enable portions of the new "Windows Aero" user experience, which allowed for effects such as transparency, 3D window switching and more. It is also included with Windows Server 2008, but requires the "Desktop Experience" feature and compatible graphics drivers to be installed.

Graphical Data Display Manager

GDDM (Graphical Data Display Manager) is a computer graphics system for the IBM System/370 which was developed in IBM's Hursley lab, and first released in 1979. GDDM was originally designed to provide programming support for the IBM 3279 colour display terminal and the associated 3287 colour printer. The 3279 was a colour graphics terminal designed to be used in a general business environment.

GDDM was extended in the early 1980s to provide graphics support for all of IBM's display terminals and printers, and ran on all of IBM's mainframe operating systems.

GDDM also provided support for the (then current) international standards for interactive computer graphics: GKS and PHIGS. Both GKS and PHIGS were designed around the requirements of CAD systems.

GDDM comprises a number of components:

Graphics primitives - lines, circles, boxes etc.

Graphing - through the Presentation Graphics Feature (PGF)

Language support - PL/I, REXX, COBOL etc.

Conversion capabilities - for example to GIF format.

Interactive Chart Utility (ICU).GDDM remains in widespread use today, embedded in many z/OS applications, as well as in System programs.

Hybrid kernel

A hybrid kernel is an operating system kernel architecture that attempts to combine aspects and benefits of microkernel and monolithic kernel architectures used in computer operating systems.

List of Microsoft Windows application programming interfaces and frameworks

The following is a list of Microsoft APIs and frameworks.

Marlin Eller

Marlin Eller is an American programmer who was a manager and a software developer at Microsoft Corporation from 1982–1995, and he was development lead for the Graphics Device Interface of Windows 1.0 and also for Pen Windows. He was also a co-founder and the CEO of Sunhawk Digital Music LLC. He was later chairman of the game development company Reflexive Entertainment.Eller also co-authored the book Barbarians Led by Bill Gates with Jennifer Edstrom.

Eller received his Bachelor of Arts in Mathematics from Whitman College in 1974. He then went on for his Master of Science in Mathematics from the University of Washington.

Microsoft Windows library files

The Microsoft Windows operating system supports a form of shared libraries known as "dynamic-link libraries", which are code libraries that can be used by multiple processes while only one copy is loaded into memory. This article provides an overview of the core libraries that are included with every modern Windows installation, on top of which most Windows applications are built.

Orbit-Vis

Orbit-Vis is an orbit simulation program which is designed to allow users to simulate a satellite in any orbit around the Earth, and to give the user data on the position and motion of the satellite in both visual and numerical form. It is based on information from the book 'Satellite Orbits - Models, Methods and Applications', and is an example of an orbit propagation program utilising the Kepler Two-body problem for solving elliptical orbits.It uses the Graphics Device Interface to display the calculated orbit as it progresses.

Page printer

A page printer is a computer printer which processes and prints a whole page at a time, as opposed to printers which print one line or character at a time such as line printers and dot-matrix printers. Page printers are often all incorrectly termed “laser printers”—although virtually all laser printers are page printers, other page printing technologies also exist.

Screensaver

A screensaver (or screen saver) is a computer program that blanks the screen or fills it with moving images or patterns when the computer is not in use. The original purpose of screensavers was to prevent phosphor burn-in on CRT and plasma computer monitors (hence the name). Though modern monitors are not susceptible to this issue, screensavers are still used for other purposes. Screensavers are often set up to offer a basic layer of security, by requiring a password to re-access the device. Some screensavers use the otherwise unused computer resources to do useful work, such as processing for distributed computing projects.

As well as computers, modern television operating systems, media players and other digital entertainment systems include optional screensavers.

Windows.h

windows.h is a Windows-specific header file for the C and C++ programming languages which contains declarations for all of the functions in the Windows API, all the common macros used by Windows programmers, and all the data types used by the various functions and subsystems. It defines a very large number of Windows specific functions that can be used in C. The Win32 API can be added to a C programming project by including the header file and linking to the appropriate libraries. To use functions in xxxx.dll, the program must be linked to xxxx.lib (or libxxxx.dll.a in MinGW). Some headers are not associated with a .dll but with a static library (e.g. scrnsave.h needs scrnsave.lib).

Windows API

The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. The name Windows API collectively refers to several different platform implementations that are often referred to by their own names (for example, Win32 API); see the versions section. Almost all Windows programs interact with the Windows API. On the Windows NT line of operating systems, a small number (such as programs started early in the Windows startup process) use the Native API.Developer support is available in the form of a software development kit, Microsoft Windows SDK, providing documentation and tools needed to build software based on the Windows API and associated Windows interfaces.

The Windows API (Win32) is focused mainly on the programming language C in that its exposed functions and data structures are described in that language in recent versions of its documentation. However the API may be used by any programming language compiler or assembler able to handle the (well-defined) low-level data structures along with the prescribed calling conventions for calls and callbacks. Similarly, the internal implementation of the API's function has been developed in several languages, historically. Despite the fact that C is not an object-oriented programming language, the Windows API and Windows have both historically been described as object-oriented. There have also been many wrapper classes and extensions (from Microsoft and others) for object-oriented languages that make this object-oriented structure more explicit (Microsoft Foundation Class Library (MFC), Visual Component Library (VCL), GDI+, etc.). For instance, Windows 8 provides the Windows API and the WinRT API, which is implemented in C++ and is object-oriented by design.

Windows Metafile

Windows Metafile (WMF) is an image file format originally designed for Microsoft Windows in the 1990s. Windows Metafiles are intended to be portable between applications and may contain both vector graphics and bitmap components. It acts in a similar manner to SVG files.

Essentially, a WMF file stores a list of function calls that have to be issued to the Windows Graphics Device Interface (GDI) layer to display an image on screen. Since some GDI functions accept pointers to callback functions for error handling, a WMF file may erroneously include executable code.WMF is a 16-bit format introduced in Windows 3.0. It is the native vector format for Microsoft Office applications such as Word, PowerPoint, and Publisher. As of 2017 revision 14 of the Windows Metafile Format specification is available for online reading or download as PDF.

Windows USER

Windows USER is a component of the Microsoft Windows operating system that provides core functionality for building simple user interfaces. The component has existed in all versions of Windows, and includes functionality for window management, message passing, input processing and standard controls.

Management
tools
Apps
Shell
Services
File systems
Server
Architecture
Security
Compatibility
API
Games
Discontinued
Spun off to
Microsoft Store
Graphics
Audio
Multimedia
Web
Data access
Networking
Communication
Administration and
management
Component model
Libraries
Device drivers
Security
.NET
Software factories
IPC
Accessibility
Text and multilingual
support

This page is based on a Wikipedia article written by authors (here).
Text is available under the CC BY-SA 3.0 license; additional terms may apply.
Images, videos and audio are available under their respective licenses.