예제 #1
0
파일: gskcairoblur.c 프로젝트: GNOME/gtk
/*
 * _gsk_cairo_blur_surface:
 * @surface: a cairo image surface.
 * @radius: the blur radius.
 *
 * Blurs the cairo image surface at the given radius.
 */
void
gsk_cairo_blur_surface (cairo_surface_t* surface,
                        double           radius_d,
                        GskBlurFlags     flags)
{
  int radius = radius_d;

  g_return_if_fail (surface != NULL);
  g_return_if_fail (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE);
  g_return_if_fail (cairo_image_surface_get_format (surface) == CAIRO_FORMAT_A8);

  /* The code doesn't actually do any blurring for radius 1, as it
   * ends up with box filter size 1 */
  if (radius <= 1)
    return;

  if ((flags & (GSK_BLUR_X|GSK_BLUR_Y)) == 0)
    return;

  /* Before we mess with the surface, execute any pending drawing. */
  cairo_surface_flush (surface);

  _boxblur (cairo_image_surface_get_data (surface),
            cairo_image_surface_get_stride (surface),
            cairo_image_surface_get_height (surface),
            radius, flags);

  /* Inform cairo we altered the surface contents. */
  cairo_surface_mark_dirty (surface);
}
예제 #2
0
/*
 * _gtk_cairo_blur_surface:
 * @surface: a cairo image surface.
 * @radius: the blur radius.
 *
 * Blurs the cairo image surface at the given radius.
 */
void
_gtk_cairo_blur_surface (cairo_surface_t* surface,
                         double           radius_d)
{
  cairo_format_t format;
  int radius = radius_d;

  g_return_if_fail (surface != NULL);
  g_return_if_fail (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE);

  format = cairo_image_surface_get_format (surface);
  g_return_if_fail (format == CAIRO_FORMAT_A8);

  if (radius == 0)
    return;

  /* Before we mess with the surface, execute any pending drawing. */
  cairo_surface_flush (surface);

  _boxblur (cairo_image_surface_get_data (surface),
            cairo_image_surface_get_stride (surface),
            cairo_image_surface_get_height (surface),
            radius);

  /* Inform cairo we altered the surface contents. */
  cairo_surface_mark_dirty (surface);
}