⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 microwindows_architecture.html

📁 Nano-x的设计架及相关文档----这是网上下载的中文翻译版本, E文的可以在其网站上下载.
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<html><head><meta http-equiv="Content-Language" content="en-us"><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><meta name="GENERATOR" content="Microsoft FrontPage 4.0"><meta name="ProgId" content="FrontPage.Editor.Document"><title>MicroWindows Architecture</title></head><body><h1 align="left"><img border="0" src="file:///C:/My%20Documents/My%20Webs/myweb2/images/clouds.gif" width="72" height="33">Microwindows Architecture</h1><p align="left">1999/12/04 Copyright (c) 1999 Greg Haerr &lt;<a href="mailto:greg@censoft.com">greg@censoft.com</a>&gt; All Rights Reserved.</p><p align="left">This is my first cut at getting the architecture and implementationspilled out.&nbsp; Please let me know if there's more detail needed in some areas, orwhether you're confused by my explanations.&nbsp; This document is for educational andporting purposes, so please read on.</p><h3>Contents</h3><p>1. Architecture<br>&nbsp;&nbsp;&nbsp; 1.1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Layered Design<br>&nbsp;&nbsp;&nbsp; 1.2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Device Drivers<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.2.1&nbsp;&nbsp;&nbsp;&nbsp; Screen Driver<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.2.2&nbsp;&nbsp;&nbsp;&nbsp; Mouse Driver<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.2.3&nbsp;&nbsp;&nbsp;&nbsp; Keyboard Driver<br>&nbsp;&nbsp;&nbsp; 1.3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MicroGUI - DeviceIndependent Graphics Engine&nbsp;<br>&nbsp;&nbsp;&nbsp; 1.4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Applications ProgrammerInterfaces<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.4.1&nbsp;&nbsp;&nbsp; Microwindows API<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.4.2&nbsp;&nbsp;&nbsp; Nano-X API</p><p>2. Device-Independent Engine Features<br>&nbsp;&nbsp;&nbsp; 2.1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Graphics Engine Featuresand Implementation<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.1.1&nbsp;&nbsp;&nbsp; Regions<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.1.2&nbsp;&nbsp;&nbsp; Clipping<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.1.3&nbsp;&nbsp;&nbsp; Line Drawing<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.1.4&nbsp;&nbsp;&nbsp; Rectangles, Circles,Ellipses<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.1.5&nbsp;&nbsp;&nbsp; Polygons<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.1.6&nbsp;&nbsp;&nbsp; Area Fills<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.1.7&nbsp;&nbsp;&nbsp; Fonts<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.1.8&nbsp;&nbsp;&nbsp; Text Drawing<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.1.9&nbsp;&nbsp;&nbsp; Color model andpalettes<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.1.10&nbsp; Image Drawing<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.1.11&nbsp; Blitting</p><p>3. Microwindows API<br>&nbsp;&nbsp;&nbsp; 3.1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Message-passingarchitecture<br>&nbsp;&nbsp;&nbsp; 3.2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Window creation anddestruction<br>&nbsp;&nbsp;&nbsp; 3.3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Window showing, hidingand moving<br>&nbsp;&nbsp;&nbsp; 3.4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Window painting<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.4.1&nbsp;&nbsp;&nbsp; Client and screencoordinates<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.4.2&nbsp;&nbsp;&nbsp; Device contexts<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.4.3&nbsp;&nbsp;&nbsp; Graphics drawing API<br>&nbsp;&nbsp;&nbsp; 3.5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Utility functions<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.5.1&nbsp;&nbsp;&nbsp; Setting window focus<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.5.2&nbsp;&nbsp;&nbsp; Mouse capture<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.5.3&nbsp;&nbsp;&nbsp; Rectangle and Regionmanagement</p><p>4. Nano-X API<br>&nbsp;&nbsp;&nbsp; 4.1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Client/Server model<br>&nbsp;&nbsp;&nbsp; 4.2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Events<br>&nbsp;&nbsp;&nbsp; 4.3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Window creation anddestruction<br>&nbsp;&nbsp;&nbsp; 4.4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Window showing, hidingand moving<br>&nbsp;&nbsp;&nbsp; 4.5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Drawing to a window<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.5.1&nbsp;&nbsp;&nbsp; Graphics contexts<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.5.2&nbsp;&nbsp;&nbsp; Graphics drawing API<br>&nbsp;&nbsp;&nbsp; 4.6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Utility functions</p><h3>1. Architecture</h3><h3>1.1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Layered Design</h3><p>Microwindows is essentially a layered design that allows different layers to be used orrewritten to suite the needs of the implementation.&nbsp; At the lowest level, screen,mouse/touchpad and keyboard drivers provide access to the actual display and otheruser-input hardware.&nbsp; At the mid level, a portable graphics engine is implemented,providing support for line draws, area fills, polygons, clipping and color models.&nbsp;At the upper level, various API's are implemented providing access to the graphicsapplications programmer.&nbsp; These APIs may or may not provide desktop and/or windowlook and feel.&nbsp; Currently, Microwindows supports the ECMA APIW and Nano-X APIs.&nbsp;These APIs provide close compatibility with the Win32 and X Window systems, allowingprograms to be ported from other systems easily.</p><h3>1.2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Device Drivers</h3><p>The device driver interfaces are defined in device.h.&nbsp; A given implementation ofMicrowindows will link at least one screen, mouse and keyboard driver into thesystem.&nbsp; The mid level routines in the device-independent graphics engine core thencall the device driver directly to perform the hardware-specific operations.&nbsp; Thissetup allows varying hardware devices to be added to the Microwindows system withoutaffecting the way the entire system works.</p><h3>1.2.1&nbsp;&nbsp;&nbsp;&nbsp; Screen Driver</h3><p>There are currently screen drivers written for Linux 2.2.x framebuffer systems, as wellas 16-bit ELKS and MSDOS drivers for real-mode VGA cards.&nbsp; The real mode drivers(scr_bios.c, vgaplan4.c, mempl4.c, scr_her.c) can be configured to initialize the VGAhardware directly, or utilize the PC BIOS to begin and end graphics mode.&nbsp; Theframebuffer drivers (scr_fb.c, fb.c, fblin?.c) have routines for 1, 2, 4 and 8bpppalletized displays, as well as 8, 15, 16, and 32 bpp truecolor displays.&nbsp; Theframebuffer system works in Linux by opening /dev/fd0 (or getenv(&quot;FRAMEBUFFER&quot;))and mmap()ing the display memory into a linear buffer in memory.&nbsp; Some display modes,like the VGA 4 planes mode, require that OUT instructions be issued by the screen driver,while packed pixel drivers typically can get away with just reading and writing theframebuffer only.&nbsp; All the graphics mode initialization and deinitialization ishandled by the Linux kernel.&nbsp; Getting this set up can be a real pain.</p><p>The screen driver is the most complex driver in the system, but was designed so that itcan be extremely easy to port new hardware to Microwindows.&nbsp; For this reason, thereare but a few entry points that must actually talk to the hardware, while other routinesare provided that allow just the small set of core routines to be used, if desired.&nbsp;For example, a screen driver must implement ReadPixel, DrawPixel, DrawHorzLine, andDrawVertLine.&nbsp; These routines read and write a pixel from display memory, as well asdraw a horizontal and vertical line.&nbsp; Clipping is handled at the device-independentlayer.&nbsp; Currently, all mouse movement, text drawing, and bitmap drawing run on top ofthese low level functions.&nbsp; In the future, entry points will be provided for fasttext and bitmap drawing capabilities.&nbsp; If the display is palletized, a SetPaletteroutine must be included, unless a static palette that matches the system palette islinked into the system.&nbsp; The screen driver, on initialization, returns values tellingthe system the x,y size of the screen, along with the color model supported.</p><p>Two font models are currently provided, to be linked in at your desire.&nbsp; Theproportional font model has in-core font tables built from .bdf and other font conversionutilities provided.&nbsp; The rom-based font uses the PC BIOS to find the charactergenerator table address and has routines to draw that fixed-pitch font format.</p><p>The screen driver can choose to implement bitblitting, by ORing in PSF_HAVEBLIT intothe returned flags field.&nbsp; When present, bit blitting allows Microwindows to performoff-screen drawing.&nbsp; Microwindows allows any graphics operation that can be performedon a physical screen to be performed off-screen, and then copied (bit-blitted) to thephysical screen.&nbsp; Implementing a blitting screen driver can be fairly complex.&nbsp;The first consideration in implementing a blitting driver is whether the low-level displayhardware can be passed a hardware address for a framebuffer.&nbsp; If so, then the sameroutines that draw to the physical screen can be used to draw to off-screen buffers.&nbsp;This is the method used for the linear framebuffer drivers provided for Linux packed-pixeldisplays.&nbsp; The system replaces the mmap()'d physical framebuffer address with amalloc()'d memory address and calls the original screen driver entry point.&nbsp; In thecase where the system doesn't use an actual physical memory address, like when running ontop of X or MS Windows, then two sets of routines must be written; one to write the theunderlying graphics system hardware, and another to write to memory addresses.&nbsp; Inaddition, the blit entry point must then know how to copy both ways between the twoformats.&nbsp; In fact, all four operations, screen-to-memory, memory-to-screen,memory-to-memory, and screen-to-screen are supported by Microwindows and may need to beperformed.&nbsp; And of course the bit blitting routine must be _fast_.&nbsp; See thefiles fblin8.c and mempl4.c for examples of supporting both types of display hardware.</p><p>If writing your first screen driver, I would recommend you start with the PC BIOS realmode driver, scr_bios.c, or take a look at the framebuffer driver, scr_fb.c, which isessentially a wrapper around all the fblin?.c routines to read and write variousframebuffer formats.&nbsp; Don't set the PSF_HAVEBLIT flag at first, and you won't have towrite a bitblit routine from the start.</p><p>Note that currently, all SCREENDEVICE function pointers must be filled in to at least avoid function.&nbsp; For speed reasons, the system always assumes that the functionpointers are valid.&nbsp; Thus, even if not implementing bitblit, a do-nothing bit-blitprocedure must be provided.</p><h3>1.2.2&nbsp;&nbsp;&nbsp;&nbsp; Mouse Driver</h3><p>There are three mouse drivers currently included in Microwindows.&nbsp; A GPM driverfor Linux, mou_gpm.c, as well as a serial port mouse driver for Linux and ELKS,mou_ser.c.&nbsp; For MSDOS, an int33 driver mou_dos.c is provided.&nbsp; The providedmouse drivers decode MS, PC and Logitech mice formats.&nbsp; A mouse driver's basicfunction is to decode the mouse data and return either relative or absolute data for themouse position and buttons.</p><p>In addition, Brad LaRonde has written a touch panel driver mou_tp.c, which masqueradesas a mouse driver.&nbsp; It returns the value of x, y value of the pen on the displaysurface, and can be used like a mouse.</p><p>Under Linux, the main loop of Microwindows is a select() statement, with filedescriptors for the mouse and keyboard driver always passed in.&nbsp; If the system thatMicrowindows is running on doesn't support select() or doesn't pass mouse data through afile descriptor, a Poll() entry point is provided.</p><h3>1.2.3&nbsp;&nbsp;&nbsp;&nbsp; Keyboard Driver</h3><p>There are two keyboard drivers provided.&nbsp; The first, kbd_tty.c, is used for Linuxand ELKS systems where the keyboard is opened and read as through a file descriptor.&nbsp;The second, kbd_bios.c, read the PC BIOS for keystrokes and is used in MSDOS realmode.&nbsp; The keyboard driver currently returns 8-bit data from the keyboard, butdoesn't decode multi-character function key codes. This functionality will need to beadded soon, by reading termcap files or the like.</p><h3>1.3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MicroGUI - Device Independent GraphicsEngine</h3><p>&nbsp;The core graphics functionality of Microwindows resides in the device independent

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -