docs: def pixbuf_to_cairo_slices(pixbuf):
      """Convert from PixBuf to ImageSurface, using slice-based byte swapping.
  
      This method is 2~5x slower than GDK but does not support an alpha channel.
      (cairo uses pre-multiplied alpha, but not Pixbuf.)
  
      """
      assert pixbuf.get_colorspace() == gdk_pixbuf.GDK_COLORSPACE_RGB
      assert pixbuf.get_n_channels() == 3
      assert pixbuf.get_bits_per_sample() == 8
      width = pixbuf.get_width()
      height = pixbuf.get_height()
      rowstride = pixbuf.get_rowstride()
      pixels = ffi.buffer(pixbuf.get_pixels(), pixbuf.get_byte_length())
      # TODO: remove this when cffi buffers support slicing with a stride.
      pixels = pixels[:]
  
      # Convert GdkPixbuf’s big-endian RGBA to cairo’s native-endian ARGB
      cairo_stride = ImageSurface.format_stride_for_width(
          constants.FORMAT_RGB24, width)
      data = bytearray(cairo_stride * height)
      big_endian = sys.byteorder == 'big'
      pixbuf_row_length = width * 3  # stride == row_length + padding
      cairo_row_length = width * 4  # stride == row_length + padding
      alpha = b'\xff' * width  # opaque
      for y in range(height):
          offset = rowstride * y
          end = offset + pixbuf_row_length
          red = pixels[offset:end:3]
          green = pixels[offset + 1:end:3]
          blue = pixels[offset + 2:end:3]
  
          offset = cairo_stride * y
          end = offset + cairo_row_length
          if big_endian:  # pragma: no cover
              data[offset:end:4] = alpha
              data[offset + 1:end:4] = red
              data[offset + 2:end:4] = green
              data[offset + 3:end:4] = blue
          else:
              data[offset + 3:end:4] = alpha
              data[offset + 2:end:4] = red
              data[offset + 1:end:4] = green
              data[offset:end:4] = blue
  
      data = array('B', data)
      return ImageSurface(constants.FORMAT_RGB24,
                          width, height, data, cairo_stride)