damageproto.txt 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. The DAMAGE Extension
  2. Protocol Version 1.1
  3. Document Revision 1
  4. 2007-01-08
  5. Keith Packard
  6. keithp@keithp.com
  7. Eric Anholt
  8. eric@anholt.net
  9. Open Source Technology Center
  10. Intel Corporation
  11. 1. Introduction
  12. Monitoring the regions affected by rendering has wide-spread use, from
  13. VNC-like systems scraping the screen to screen magnifying applications
  14. designed to aid users with limited visual acuity. The DAMAGE extension is
  15. designed to make such applications reasonably efficient in the face of
  16. server-client latency.
  17. 2. Acknolwedgements
  18. As usual, the author had significant input from many people, in particular:
  19. + Havoc Pennington who designed and implemented a Damage extension
  20. last year which was then lost to the mists of time.
  21. + Bill Haneman whose work on accessibility in the Gnome environment
  22. is legendary.
  23. + Jim Gettys who found a way to avoid streaming damage rectangles
  24. to the client in many cases.
  25. + Owen Taylor who suggested that streaming damage rectangles may
  26. be warranted in some cases after all.
  27. 3. Damage Model
  28. We call changes made to pixel contents of windows and pixmaps 'damage'
  29. throughout this extension. Another notion of 'damage' are drawable regions
  30. which are in need of redisplay to repair the effects of window manipulation
  31. or other data loss. This extension doesn't deal with this second notion at
  32. all; suggestions on a better term which isn't easily conflated with existing
  33. notions are eagerly solicited.
  34. Damage accumulates as drawing occurs in the drawable. Each drawing operation
  35. 'damages' one or more rectangular areas within the drawable. The rectangles
  36. are guaranteed to include the set of pixels modified by each operation, but
  37. may include significantly more than just those pixels. The desire is for
  38. the damage to strike a balance between the number of rectangles reported and
  39. the extraneous area included. A reasonable goal is for each primitive
  40. object drawn (line, string, rectangle) to be represented as a single
  41. rectangle and for the damage area of the operation to be the union of these
  42. rectangles.
  43. The DAMAGE extension allows applications to either receive the raw
  44. rectangles as a stream of events, or to have them partially processed within
  45. the X server to reduce the amount of data transmitted as well as reduce the
  46. processing latency once the repaint operation has started.
  47. Damage to a window reflects both drawing within the window itself as well as
  48. drawing within any inferior window that affects pixels seen by
  49. IncludeInferiors rendering operations. To reduce the computational
  50. complexity of this, the DAMAGE extension allows the server to monitor all
  51. rendering operations within the physical target pixel storage that fall
  52. within the bounds of the window. In a system with a single frame buffer
  53. holding all windows, this means that damage will accumulate for all
  54. rendering operations that lie within the visible part of the window.
  55. The precise reason for this architecture is to enable the Composite
  56. extension which provides multiple pixel storage areas for the screen
  57. contents.
  58. 3.1 Additions in the 1.1 version of the protocol
  59. Damage is automatically computed by the X Server for X rendering operations,
  60. but direct rendering extensions have allowed clients to perform rendering
  61. outside of the control of the X Server. The 1.1 version of the protocol
  62. added a request to allow direct rendering clients to report damage to a
  63. drawable. Some direct rendering clients, due to architectural limitations,
  64. always perform rendering to the root window, even in when it should be
  65. performed to the backing pixmap in the Composite case. To provide
  66. less-incorrect rendering in this cases, the direct rendering client should
  67. translate its damage region to screen coordinates and report the damage against
  68. the root window rather than the drawable.
  69. 4. Data types
  70. The "Damage" object holds any accumulated damage region and reflects the
  71. relationship between the drawable selected for damage notification and the
  72. drawable for which damage is tracked.
  73. 5. Errors
  74. Damage
  75. A value for a DAMAGE argument does not name a defined DAMAGE.
  76. 6. Types
  77. DAMAGE 32-bit value (top three bits guaranteed to be zero)
  78. DamageReportLevel { DamageReportRawRectangles,
  79. DamageReportDeltaRectangles,
  80. DamageReportBoundingBox,
  81. DamageReportNonEmpty }
  82. DamageReportRawRectangles
  83. Delivers DamageNotify events each time the screen
  84. is modified with rectangular bounds that circumscribe
  85. the damaged area. No attempt to compress out overlapping
  86. rectangles is made.
  87. DamageReportDeltaRectangles
  88. Delivers DamageNotify events each time damage occurs
  89. which is not included in the damage region. The
  90. reported rectangles include only the changes to that
  91. area, not the raw damage data.
  92. DamageReportBoundingBox
  93. Delivers DamageNotify events each time the bounding
  94. box enclosing the damage region increases in size.
  95. The reported rectangle encloses the entire damage region,
  96. not just the changes to that size.
  97. DamageReportNonEmpty
  98. Delivers a single DamageNotify event each time the
  99. damage rectangle changes from empty to non-empty, and
  100. also whenever the result of a DamageSubtract request
  101. results in a non-empty region.
  102. 7. Events
  103. DamageNotify
  104. level: DamageReportLevel
  105. drawable: Drawable
  106. damage: DAMAGE
  107. more: Bool
  108. timestamp: Timestamp
  109. area: Rectangle
  110. drawable-geometry: Rectangle
  111. 'more' indicates whether there are subsequent damage events
  112. being delivered immediately as part of a larger damage region
  113. 8. Extension Initialization
  114. The client must negotiate the version of the extension before executing
  115. extension requests. Otherwise, the server will return BadRequest for any
  116. operations other than QueryVersion.
  117. QueryVersion
  118. client-major-version: CARD32
  119. client-minor-version: CARD32
  120. ->
  121. major-version: CARD32
  122. minor-version: CARD32
  123. The client sends the highest supported version to the server and
  124. the server sends the highest version it supports, but no higher than
  125. the requested version. Major versions changes can introduce
  126. incompatibilities in existing functionality, minor version
  127. changes introduce only backward compatible changes. It is
  128. the clients responsibility to ensure that the server supports
  129. a version which is compatible with its expectations. Servers
  130. are encouraged to support multiple versions of the extension.
  131. 9. Enable Monitoring
  132. DamageCreate
  133. damage: DAMAGE
  134. drawable: Drawable
  135. level: DamageReportLevel
  136. Creates a damage object to monitor changes to Drawable
  137. DamageDestroy
  138. damage: DAMAGE
  139. Destroys damage.
  140. DamageSubtract
  141. damage: DAMAGE
  142. repair: Region or None
  143. parts: Region or None
  144. Synchronously modifies the regions in the following manner:
  145. If repair is None:
  146. 1) if parts is not None, parts = damage
  147. 2) damage = <empty>
  148. Otherwise:
  149. 1) tmp = damage INTERSECT repair
  150. 2) damage = damage - tmp
  151. 3) if parts is not None, parts = tmp
  152. 4) Generate DamageNotify for remaining damage areas
  153. DamageAdd
  154. drawable: Drawable
  155. region: Region
  156. Reports damage of the region within the given drawable. This may be
  157. used by direct rendering clients to report damage that the server would
  158. otherwise be unaware of. The damage region is relative to the origin
  159. of the drawable.
  160. Damage posted in this way will appear in DamageNotify events as normal,
  161. and also in server internal damage tracking (for shadow framebuffer
  162. updates, pixmap damage, and other uses).