117ca54c3Smrg The DAMAGE Extension 217ca54c3Smrg Protocol Version 1.1 317ca54c3Smrg Document Revision 1 417ca54c3Smrg 2007-01-08 517ca54c3Smrg 617ca54c3Smrg Keith Packard 717ca54c3Smrg keithp@keithp.com 817ca54c3Smrg 917ca54c3Smrg Eric Anholt 1017ca54c3Smrg eric@anholt.net 1117ca54c3Smrg Open Source Technology Center 1217ca54c3Smrg Intel Corporation 1317ca54c3Smrg1. Introduction 1417ca54c3Smrg 1517ca54c3SmrgMonitoring the regions affected by rendering has wide-spread use, from 1617ca54c3SmrgVNC-like systems scraping the screen to screen magnifying applications 1717ca54c3Smrgdesigned to aid users with limited visual acuity. The DAMAGE extension is 1817ca54c3Smrgdesigned to make such applications reasonably efficient in the face of 1917ca54c3Smrgserver-client latency. 2017ca54c3Smrg 2117ca54c3Smrg2. Acknowledgements 2217ca54c3Smrg 2317ca54c3SmrgAs usual, the author had significant input from many people, in particular: 2417ca54c3Smrg 2517ca54c3Smrg + Havoc Pennington who designed and implemented a Damage extension 2617ca54c3Smrg last year which was then lost to the mists of time. 2717ca54c3Smrg 2817ca54c3Smrg + Bill Haneman whose work on accessibility in the Gnome environment 2917ca54c3Smrg is legendary. 3017ca54c3Smrg 3117ca54c3Smrg + Jim Gettys who found a way to avoid streaming damage rectangles 3217ca54c3Smrg to the client in many cases. 3317ca54c3Smrg 3417ca54c3Smrg + Owen Taylor who suggested that streaming damage rectangles may 3517ca54c3Smrg be warranted in some cases after all. 3617ca54c3Smrg 3717ca54c3Smrg3. Damage Model 3817ca54c3Smrg 3917ca54c3SmrgWe call changes made to pixel contents of windows and pixmaps 'damage' 4017ca54c3Smrgthroughout this extension. Another notion of 'damage' are drawable regions 4117ca54c3Smrgwhich are in need of redisplay to repair the effects of window manipulation 4217ca54c3Smrgor other data loss. This extension doesn't deal with this second notion at 4317ca54c3Smrgall; suggestions on a better term which isn't easily conflated with existing 4417ca54c3Smrgnotions are eagerly solicited. 4517ca54c3Smrg 4617ca54c3SmrgDamage accumulates as drawing occurs in the drawable. Each drawing operation 4717ca54c3Smrg'damages' one or more rectangular areas within the drawable. The rectangles 4817ca54c3Smrgare guaranteed to include the set of pixels modified by each operation, but 4917ca54c3Smrgmay include significantly more than just those pixels. The desire is for 5017ca54c3Smrgthe damage to strike a balance between the number of rectangles reported and 5117ca54c3Smrgthe extraneous area included. A reasonable goal is for each primitive 5217ca54c3Smrgobject drawn (line, string, rectangle) to be represented as a single 5317ca54c3Smrgrectangle and for the damage area of the operation to be the union of these 5417ca54c3Smrgrectangles. 5517ca54c3Smrg 5617ca54c3SmrgThe DAMAGE extension allows applications to either receive the raw 5717ca54c3Smrgrectangles as a stream of events, or to have them partially processed within 5817ca54c3Smrgthe X server to reduce the amount of data transmitted as well as reduce the 5917ca54c3Smrgprocessing latency once the repaint operation has started. 6017ca54c3Smrg 6117ca54c3SmrgDamage to a window reflects both drawing within the window itself as well as 6217ca54c3Smrgdrawing within any inferior window that affects pixels seen by 6317ca54c3SmrgIncludeInferiors rendering operations. To reduce the computational 6417ca54c3Smrgcomplexity of this, the DAMAGE extension allows the server to monitor all 6517ca54c3Smrgrendering operations within the physical target pixel storage that fall 6617ca54c3Smrgwithin the bounds of the window. In a system with a single frame buffer 6717ca54c3Smrgholding all windows, this means that damage will accumulate for all 6817ca54c3Smrgrendering operations that lie within the visible part of the window. 6917ca54c3Smrg 7017ca54c3SmrgThe precise reason for this architecture is to enable the Composite 7117ca54c3Smrgextension which provides multiple pixel storage areas for the screen 7217ca54c3Smrgcontents. 7317ca54c3Smrg 7417ca54c3Smrg3.1 Additions in the 1.1 version of the protocol 7517ca54c3Smrg 7617ca54c3SmrgDamage is automatically computed by the X Server for X rendering operations, 7717ca54c3Smrgbut direct rendering extensions have allowed clients to perform rendering 7817ca54c3Smrgoutside of the control of the X Server. The 1.1 version of the protocol 7917ca54c3Smrgadded a request to allow direct rendering clients to report damage to a 8017ca54c3Smrgdrawable. Some direct rendering clients, due to architectural limitations, 8117ca54c3Smrgalways perform rendering to the root window, even in when it should be 8217ca54c3Smrgperformed to the backing pixmap in the Composite case. To provide 8317ca54c3Smrgless-incorrect rendering in this cases, the direct rendering client should 8417ca54c3Smrgtranslate its damage region to screen coordinates and report the damage against 8517ca54c3Smrgthe root window rather than the drawable. 8617ca54c3Smrg 8717ca54c3Smrg4. Data types 8817ca54c3Smrg 8917ca54c3SmrgThe "Damage" object holds any accumulated damage region and reflects the 9017ca54c3Smrgrelationship between the drawable selected for damage notification and the 9117ca54c3Smrgdrawable for which damage is tracked. 9217ca54c3Smrg 9317ca54c3Smrg5. Errors 9417ca54c3Smrg 9517ca54c3SmrgDamage 9617ca54c3Smrg A value for a DAMAGE argument does not name a defined DAMAGE. 9717ca54c3Smrg 9817ca54c3Smrg6. Types 9917ca54c3Smrg 10017ca54c3Smrg DAMAGE 32-bit value (top three bits guaranteed to be zero) 10117ca54c3Smrg 10217ca54c3Smrg DamageReportLevel { DamageReportRawRectangles, 10317ca54c3Smrg DamageReportDeltaRectangles, 10417ca54c3Smrg DamageReportBoundingBox, 10517ca54c3Smrg DamageReportNonEmpty } 10617ca54c3Smrg 10717ca54c3Smrg DamageReportRawRectangles 10817ca54c3Smrg 10917ca54c3Smrg Delivers DamageNotify events each time the screen 11017ca54c3Smrg is modified with rectangular bounds that circumscribe 11117ca54c3Smrg the damaged area. No attempt to compress out overlapping 11217ca54c3Smrg rectangles is made. 11317ca54c3Smrg 11417ca54c3Smrg DamageReportDeltaRectangles 11517ca54c3Smrg 11617ca54c3Smrg Delivers DamageNotify events each time damage occurs 11717ca54c3Smrg which is not included in the damage region. The 11817ca54c3Smrg reported rectangles include only the changes to that 11917ca54c3Smrg area, not the raw damage data. 12017ca54c3Smrg 12117ca54c3Smrg DamageReportBoundingBox 12217ca54c3Smrg 12317ca54c3Smrg Delivers DamageNotify events each time the bounding 12417ca54c3Smrg box enclosing the damage region increases in size. 12517ca54c3Smrg The reported rectangle encloses the entire damage region, 12617ca54c3Smrg not just the changes to that size. 12717ca54c3Smrg 12817ca54c3Smrg DamageReportNonEmpty 12917ca54c3Smrg 13017ca54c3Smrg Delivers a single DamageNotify event each time the 13117ca54c3Smrg damage rectangle changes from empty to non-empty, and 13217ca54c3Smrg also whenever the result of a DamageSubtract request 13317ca54c3Smrg results in a non-empty region. 13417ca54c3Smrg 13517ca54c3Smrg7. Events 13617ca54c3Smrg 13717ca54c3SmrgDamageNotify 13817ca54c3Smrg 13917ca54c3Smrg level: DamageReportLevel 14017ca54c3Smrg drawable: Drawable 14117ca54c3Smrg damage: DAMAGE 14217ca54c3Smrg more: Bool 14317ca54c3Smrg timestamp: Timestamp 14417ca54c3Smrg area: Rectangle 14517ca54c3Smrg drawable-geometry: Rectangle 14617ca54c3Smrg 14717ca54c3Smrg 'more' indicates whether there are subsequent damage events 14817ca54c3Smrg being delivered immediately as part of a larger damage region 14917ca54c3Smrg 15017ca54c3Smrg8. Extension Initialization 15117ca54c3Smrg 15217ca54c3SmrgThe client must negotiate the version of the extension before executing 15317ca54c3Smrgextension requests. Otherwise, the server will return BadRequest for any 15417ca54c3Smrgoperations other than QueryVersion. 15517ca54c3Smrg 15617ca54c3SmrgQueryVersion 15717ca54c3Smrg 15817ca54c3Smrg client-major-version: CARD32 15917ca54c3Smrg client-minor-version: CARD32 16017ca54c3Smrg 16117ca54c3Smrg -> 16217ca54c3Smrg 16317ca54c3Smrg major-version: CARD32 16417ca54c3Smrg minor-version: CARD32 16517ca54c3Smrg 16617ca54c3Smrg The client sends the highest supported version to the server and 16717ca54c3Smrg the server sends the highest version it supports, but no higher than 16817ca54c3Smrg the requested version. Major versions changes can introduce 16917ca54c3Smrg incompatibilities in existing functionality, minor version 17017ca54c3Smrg changes introduce only backward compatible changes. It is 17117ca54c3Smrg the clients responsibility to ensure that the server supports 17217ca54c3Smrg a version which is compatible with its expectations. Servers 17317ca54c3Smrg are encouraged to support multiple versions of the extension. 17417ca54c3Smrg 17517ca54c3Smrg9. Enable Monitoring 17617ca54c3Smrg 17717ca54c3SmrgDamageCreate 17817ca54c3Smrg 17917ca54c3Smrg damage: DAMAGE 18017ca54c3Smrg drawable: Drawable 18117ca54c3Smrg level: DamageReportLevel 18217ca54c3Smrg 18317ca54c3Smrg Creates a damage object to monitor changes to Drawable 18417ca54c3Smrg 18517ca54c3SmrgDamageDestroy 18617ca54c3Smrg damage: DAMAGE 18717ca54c3Smrg 18817ca54c3Smrg Destroys damage. 18917ca54c3Smrg 19017ca54c3SmrgDamageSubtract 19117ca54c3Smrg 19217ca54c3Smrg damage: DAMAGE 19317ca54c3Smrg repair: Region or None 19417ca54c3Smrg parts: Region or None 19517ca54c3Smrg 19617ca54c3Smrg Synchronously modifies the regions in the following manner: 19717ca54c3Smrg 19817ca54c3Smrg If repair is None: 19917ca54c3Smrg 20017ca54c3Smrg 1) if parts is not None, parts = damage 20117ca54c3Smrg 2) damage = <empty> 20217ca54c3Smrg 20317ca54c3Smrg Otherwise: 20417ca54c3Smrg 20517ca54c3Smrg 1) tmp = damage INTERSECT repair 20617ca54c3Smrg 2) damage = damage - tmp 20717ca54c3Smrg 3) if parts is not None, parts = tmp 20817ca54c3Smrg 4) Generate DamageNotify for remaining damage areas 20917ca54c3Smrg 21017ca54c3SmrgDamageAdd 21117ca54c3Smrg 21217ca54c3Smrg drawable: Drawable 21317ca54c3Smrg region: Region 21417ca54c3Smrg 21517ca54c3Smrg Reports damage of the region within the given drawable. This may be 21617ca54c3Smrg used by direct rendering clients to report damage that the server would 21717ca54c3Smrg otherwise be unaware of. The damage region is relative to the origin 21817ca54c3Smrg of the drawable. 21917ca54c3Smrg 22017ca54c3Smrg Damage posted in this way will appear in DamageNotify events as normal, 22117ca54c3Smrg and also in server internal damage tracking (for shadow framebuffer 22217ca54c3Smrg updates, pixmap damage, and other uses). 223