Cogl.Onscreen.add_dirty_callback

### Method

# Cogl Onscreenadd_dirty_callback

#### Declaration [src]

    CoglOnscreenDirtyClosure*
    cogl_onscreen_add_dirty_callback (
      CoglOnscreen* onscreen,
      CoglOnscreenDirtyCallback callback,
      void* user_data,
      CoglUserDataDestroyCallback destroy
    )

#### Description [src]

Installs a `callback` function that will be called whenever the window system has lost the contents of a region of the onscreen buffer and the application should redraw it to repair the buffer. For example this may happen in a window system without a compositor if a window that was previously covering up the onscreen window has been moved causing a region of the onscreen to be exposed.

The `callback` will be passed a `CoglOnscreenDirtyInfo` struct which describes a rectangle containing the newly dirtied region. Note that this may be called multiple times to describe a non-rectangular region composed of multiple smaller rectangles.

The dirty events are separate from `COGL_FRAME_EVENT_SYNC` events so the application should also listen for this event before rendering the dirty region to ensure that the framebuffer is actually ready for rendering.

#### Parameters

`callback`

  Type: `CoglOnscreenDirtyCallback`

  A callback function to call for dirty events.

`user_data`

  Type: `void*`

  A private pointer to be passed to `callback`.

  The argument can be `NULL`.
  The data is owned by the caller of the method.

`destroy`

  Type: `CoglUserDataDestroyCallback`

  An optional callback to destroy `user_data` when the `callback` is removed or `onscreen` is freed.

  The argument can be `NULL`.

#### Return value

Type: `CoglOnscreenDirtyClosure`

A `CoglOnscreenDirtyClosure` pointer that can be used to remove the callback and associated `user_data` later.

The caller of the method takes ownership of the data, and is responsible for freeing it.