3

What Mechanism does compiz use when copying from a xclient's frontbuffer to the backbuffer of root window?

I can't seem to find this procedure in the compiz source. Is there a function that it calls whenever the xclient's window' frontbuffer is updated to update the root backbuffer?

Nicol Bolas
  • 378,677
  • 53
  • 635
  • 829
LZOO
  • 125
  • 8

1 Answers1

3

Copiz uses the X Composite extension to redirect windows into an offscreen pixmap. Then it uses the GLX_EXT_texture_from_pixmap extension to GLX/OpenGL to transfer those offscreen pixmaps into OpenGL textures.

For composition a Composite enabled X server provides a special composite window layer, which is placed between the root window (and windows of which the root window is the parent) and the screen saver layer. Compiz creates a window in that composite layer, creates a OpenGL context for that window and performs composition using OpenGL drawing commands.

There are also compositors that don't use OpenGL. They then either use server side composition (which is rather useless, except for testing the Composite protocol itself) or they use XRender drawing methods. Technically X core drawing methods would work, too, but those don't support transformations and scaling; things you'd normally want to have for a compositor.

Nothing is drawn to the root window by a compositor. All composition goes to the composite layer.

datenwolf
  • 149,702
  • 12
  • 167
  • 273
  • So as I understand, The composite layer is like a full screen backbuffer to the on screen buffer? Assuming that what is compiz's mechanism to fransfer the textures (from children windows' pixmaps) onto the composite layer? – LZOO Sep 03 '13 at 15:47
  • @LZOO: No, the composite layer is what you actually see, when a compositor is active. Windows get **redirected** to an off-screen pixmap, which could be considered to bing a off-screen back buffer. But there's no single "huge" full screen back buffer. All what happens is, that each window will be treated as a off-screen pixmap, as created with XCreatePixmap instead of XCreateWindow. That's what RedirectWindow does; after you cann RedirectWindow on a window, it will disappear from the main screen and its contents need to be somehow fetched and drawn to a visible buffer by a compositor. – datenwolf Sep 03 '13 at 15:52
  • @LZOO: The reason for there being a composite layer is, that the compositor will usually also redirect the root window. But everything that's a child of a redirected window goes off-screen as well. But the compositor needs *something* **on** screen to draw the composition to. That's where the composite layer enters the picture, quite literally. – datenwolf Sep 03 '13 at 15:54
  • @LZOO: This whole window redirection business also implies, that some of the dirty hacks, used to take screenshots by reading back from a bottom most Z, background less, content less window no longer works. Without composition each window is an actual *window* to the screen framebuffer. To mask the window while drawing a pixel ownership mask is applied so as not to overdraw the contents of other windows. But with composite redirection each window has its own framebuffer all for itself, which render such information leakage hacks ineffective. – datenwolf Sep 03 '13 at 15:58