### Virtual Method

# Cogl Onscreen swap_buffers_with_damage

#### Declaration [src]

    void
    swap_buffers_with_damage (
      CoglOnscreen* onscreen,
      const int* rectangles,
      int n_rectangles,
      CoglFrameInfo* info,
      gpointer user_data
    )

#### Description [src]

Swaps the current back buffer being rendered too, to the front for display and provides information to any system compositor about what regions of the buffer have changed (damage) with respect to the last swapped buffer.

This function has the same semantics as `cogl_framebuffer_swap_buffers()` except that it additionally allows applications to pass a list of damaged rectangles which may be passed on to a compositor so that it can minimize how much of the screen is redrawn in response to this applications newly swapped front buffer.

For example if your application is only animating a small object in the corner of the screen and everything else is remaining static then it can help the compositor to know that only the bottom right corner of your newly swapped buffer has really changed with respect to your previously swapped front buffer.

If `n_rectangles` is 0 then the whole buffer will implicitly be reported as damaged as if `cogl_onscreen_swap_buffers()` had been called.

This function also implicitly discards the contents of the color, depth and stencil buffers as if `cogl_framebuffer_discard_buffers()` were used. The significance of the discard is that you should not expect to be able to start a new frame that incrementally builds on the contents of the previous frame. If you want to perform incremental updates to older back buffers then please refer to the `cogl_onscreen_get_buffer_age()` api.

Whenever possible it is recommended that applications use this function instead of `cogl_onscreen_swap_buffers()` to improve performance when running under a compositor.

It is highly recommended to use this API in conjunction with the `cogl_onscreen_get_buffer_age()` api so that your application can perform incremental rendering based on old back buffers.

#### Parameters

`rectangles`

  Type: An array of `int`

  An array of integer 4-tuples representing damaged rectangles as (x, y, width, height) tuples.

  The length of the array is specified in the `n_rectangles` argument.
  The data is owned by the caller of the method.

`n_rectangles`

  Type: `int`

  The number of 4-tuples to be read from `rectangles`.

`info`

  Type: `CoglFrameInfo`

  No description available.

  The data is owned by the caller of the method.

`user_data`

  Type: `gpointer`

  No description available.

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