summaryrefslogtreecommitdiff
path: root/gdk/directfb
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-07-12 16:50:00 +0200
committerBenjamin Otte <otte@redhat.com>2010-08-10 21:02:25 +0200
commit4f8dbd4a8dd72dddfa81ed9db44a30544b35b1bc (patch)
treeaa0d20bdcedbc400016efd2f6e36761ba7a0aa32 /gdk/directfb
parent11ee2abaccb8102abd2bdf92d1844eba6d71ab1a (diff)
downloadgtk+-4f8dbd4a8dd72dddfa81ed9db44a30544b35b1bc.tar.gz
API: Remove gdk_draw_pixbuf()
Diffstat (limited to 'gdk/directfb')
-rw-r--r--gdk/directfb/gdkdrawable-directfb.c445
1 files changed, 0 insertions, 445 deletions
diff --git a/gdk/directfb/gdkdrawable-directfb.c b/gdk/directfb/gdkdrawable-directfb.c
index 98047e54e5..de50d7b4be 100644
--- a/gdk/directfb/gdkdrawable-directfb.c
+++ b/gdk/directfb/gdkdrawable-directfb.c
@@ -129,19 +129,6 @@ static gboolean accelerated_alpha_blending = FALSE;
static gpointer parent_class = NULL;
static const cairo_user_data_key_t gdk_directfb_cairo_key;
-static void (*real_draw_pixbuf) (GdkDrawable *drawable,
- GdkGC *gc,
- GdkPixbuf *pixbuf,
- gint src_x,
- gint src_y,
- gint dest_x,
- gint dest_y,
- gint width,
- gint height,
- GdkRgbDither dither,
- gint x_dither,
- gint y_dither);
-
/**********************************************************
* DirectFB specific implementations of generic functions *
@@ -963,438 +950,6 @@ gdk_directfb_draw_image (GdkDrawable *drawable,
temp_region_deinit( &clip );
}
-static void
-composite (guchar *src_buf,
- gint src_rowstride,
- guchar *dest_buf,
- gint dest_rowstride,
- gint width,
- gint height)
-{
- guchar *src = src_buf;
- guchar *dest = dest_buf;
-
- while (height--)
- {
- gint twidth = width;
- guchar *p = src;
- guchar *q = dest;
-
- while (twidth--)
- {
- guchar a = p[3];
- guint t;
-
- t = a * p[0] + (255 - a) * q[0] + 0x80;
- q[0] = (t + (t >> 8)) >> 8;
- t = a * p[1] + (255 - a) * q[1] + 0x80;
- q[1] = (t + (t >> 8)) >> 8;
- t = a * p[2] + (255 - a) * q[2] + 0x80;
- q[2] = (t + (t >> 8)) >> 8;
-
- p += 4;
- q += 3;
- }
-
- src += src_rowstride;
- dest += dest_rowstride;
- }
-}
-
-static void
-composite_0888 (guchar *src_buf,
- gint src_rowstride,
- guchar *dest_buf,
- gint dest_rowstride,
- GdkByteOrder dest_byte_order,
- gint width,
- gint height)
-{
- guchar *src = src_buf;
- guchar *dest = dest_buf;
-
- while (height--)
- {
- gint twidth = width;
- guchar *p = src;
- guchar *q = dest;
-
- if (dest_byte_order == GDK_LSB_FIRST)
- {
- while (twidth--)
- {
- guint t;
-
- t = p[3] * p[2] + (255 - p[3]) * q[0] + 0x80;
- q[0] = (t + (t >> 8)) >> 8;
- t = p[3] * p[1] + (255 - p[3]) * q[1] + 0x80;
- q[1] = (t + (t >> 8)) >> 8;
- t = p[3] * p[0] + (255 - p[3]) * q[2] + 0x80;
- q[2] = (t + (t >> 8)) >> 8;
- p += 4;
- q += 4;
- }
- }
- else
- {
- while (twidth--)
- {
- guint t;
-
- t = p[3] * p[0] + (255 - p[3]) * q[1] + 0x80;
- q[1] = (t + (t >> 8)) >> 8;
- t = p[3] * p[1] + (255 - p[3]) * q[2] + 0x80;
- q[2] = (t + (t >> 8)) >> 8;
- t = p[3] * p[2] + (255 - p[3]) * q[3] + 0x80;
- q[3] = (t + (t >> 8)) >> 8;
- p += 4;
- q += 4;
- }
- }
-
- src += src_rowstride;
- dest += dest_rowstride;
- }
-}
-
-/* change the last value to adjust the size of the device (1-4) */
-#define SET_PIXEL_DUFFS_DEVICE( D, S, w ) \
- SET_PIXEL_DUFFS_DEVICE_N( D, S, w, 2 )
-
-/* From DirectFB's gfx/generic/generic.c" */
-#define SET_PIXEL( D, S ) \
- switch (S >> 26) { \
- case 0: \
- break; \
- case 0x3f: \
- D = ((S << 8) & 0xF800) | \
- ((S >> 5) & 0x07E0) | \
- ((S >> 19) & 0x001F); \
- break; \
- default: \
- D = (((( (((S<<8) & 0xf800) | ((S>>19) & 0x001f)) \
- - (D & 0xf81f)) * ((S>>26)+1) + ((D & 0xf81f)<<6)) & 0x003e07c0) \
- + \
- ((( ((S>>5) & 0x07e0) \
- - (D & 0x07e0)) * ((S>>26)+1) + ((D & 0x07e0)<<6)) & 0x0001f800)) >> 6; \
- }
-
-static void
-composite_565 (guchar *src_buf,
- gint src_rowstride,
- guchar *dest_buf,
- gint dest_rowstride,
- GdkByteOrder dest_byte_order,
- gint width,
- gint height)
-{
- while (height--) {
- int w = width;
- u16 *D = (u16*) dest_buf;
- u32 *S = (u32*) src_buf;
-#if 1
- if ((unsigned long)D & 2) {
- SET_PIXEL( D[0], S[0] );
- w--;
- D++;
- S++;
- }
-
- int i;
- int w2 = w / 2;
- u32 *D32 = (u32*) D;
-
- for (i=0; i<w2; i++) {
- register u32 S0 = S[(i << 1) + 0];
- register u32 S1 = S[(i << 1) + 1];
-
- if ((S0 >> 26) == 0x3f && (S1 >> 26) == 0x3f) {
- D32[i] = ((S0 << 8) & 0x0000F800) |
- ((S0 >> 5) & 0x000007E0) |
- ((S0 >> 19) & 0x0000001F) |
- ((S1 << 24) & 0xF8000000) |
- ((S1 << 11) & 0x07E00000) |
- ((S1 >> 3) & 0x001F0000);
- }
- else {
- SET_PIXEL( D[(i << 1) + 0], S0 );
- SET_PIXEL( D[(i << 1) + 1], S1 );
- }
- }
-
- if (w & 1)
- SET_PIXEL( D[w-1], S[w-1] );
-#else
- SET_PIXEL_DUFFS_DEVICE( D, S, w );
-#endif
-
- dest_buf += dest_rowstride;
- src_buf += src_rowstride;
- }
-}
-
-#undef SET_PIXEL
-#undef SET_PIXEL_DUFFS_DEVICE
-
-static void
-gdk_directfb_draw_pixbuf (GdkDrawable *drawable,
- GdkGC *gc,
- GdkPixbuf *pixbuf,
- gint src_x,
- gint src_y,
- gint dest_x,
- gint dest_y,
- gint width,
- gint height,
- GdkRgbDither dither,
- gint x_dither,
- gint y_dither)
-{
- GdkPixbuf *composited = NULL;
-#if 0
- cairo_region_t *clip;
- cairo_region_t *drect;
- GdkRectangle tmp_rect;
-#endif
- GdkDrawableImplDirectFB *impl = GDK_DRAWABLE_IMPL_DIRECTFB (drawable);
-
- g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
- g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB);
- g_return_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4);
- g_return_if_fail (pixbuf->bits_per_sample == 8);
-
- g_return_if_fail (drawable != NULL);
-
- if (width == -1)
- width = pixbuf->width;
- if (height == -1)
- height = pixbuf->height;
-
- g_return_if_fail (width >= 0 && height >= 0);
- g_return_if_fail (src_x >= 0 && src_x + width <= pixbuf->width);
- g_return_if_fail (src_y >= 0 && src_y + height <= pixbuf->height);
-
- D_DEBUG_AT( GDKDFB_Drawable, "%s( %p, %p, %p, %4d,%4d -> %4d,%4d - %dx%d )\n", G_STRFUNC,
- drawable, gc, pixbuf, src_x, src_y, dest_x, dest_y, width, height );
-
- /* Clip to the drawable; this is required for get_from_drawable() so
- * can't be done implicitly
- */
-
- if (dest_x < 0)
- {
- src_x -= dest_x;
- width += dest_x;
- dest_x = 0;
- }
-
- if (dest_y < 0)
- {
- src_y -= dest_y;
- height += dest_y;
- dest_y = 0;
- }
-
- if ((dest_x + width) > impl->width)
- width = impl->width - dest_x;
-
- if ((dest_y + height) > impl->height)
- height = impl->height - dest_y;
-
- if (width <= 0 || height <= 0)
- return;
-
-#if 0
- /* Clip to the clip region; this avoids getting more
- * image data from the server than we need to.
- */
-
- tmp_rect.x = dest_x;
- tmp_rect.y = dest_y;
- tmp_rect.width = width;
- tmp_rect.height = height;
-
- drect = cairo_region_create_rectangle (&tmp_rect);
- clip = gdk_drawable_get_clip_region (drawable);
-
- cairo_region_intersect (drect, clip);
-
- cairo_region_get_extents (drect, &tmp_rect);
-
- cairo_region_destroy (drect);
- cairo_region_destroy (clip);
-
- if (tmp_rect.width == 0 ||
- tmp_rect.height == 0)
- return;
-#endif
-
- if (pixbuf->has_alpha && impl->format == DSPF_RGB16) {
- void *data;
- int pitch;
-
- if (impl->surface->Lock( impl->surface, DSLF_READ | DSLF_WRITE, &data, &pitch ) == DFB_OK) {
- composite_565( pixbuf->pixels + src_y * pixbuf->rowstride + src_x * 4,
- pixbuf->rowstride,
- data + dest_y * pitch + dest_x * 2,
- pitch,
- #if G_BYTE_ORDER == G_BIG_ENDIAN
- GDK_MSB_FIRST,
- #else
- GDK_LSB_FIRST,
- #endif
- width, height );
-
- impl->surface->Unlock( impl->surface );
-
- return;
- }
- }
-
- /* Actually draw */
- if (!gc)
- gc = _gdk_drawable_get_scratch_gc (drawable, FALSE);
-
- if (pixbuf->has_alpha)
- {
- GdkVisual *visual = gdk_drawable_get_visual (drawable);
- void (*composite_func) (guchar *src_buf,
- gint src_rowstride,
- guchar *dest_buf,
- gint dest_rowstride,
- GdkByteOrder dest_byte_order,
- gint width,
- gint height) = NULL;
-
- /* First we see if we have a visual-specific composition function that can composite
- * the pixbuf data directly onto the image
- */
- if (visual)
- {
- gint bits_per_pixel = _gdk_windowing_get_bits_for_depth (gdk_drawable_get_display (drawable),
- visual->depth);
-
- if (visual->byte_order == (G_BYTE_ORDER == G_BIG_ENDIAN ? GDK_MSB_FIRST : GDK_LSB_FIRST) &&
- visual->depth == 16 &&
- visual->red_mask == 0xf800 &&
- visual->green_mask == 0x07e0 &&
- visual->blue_mask == 0x001f)
- composite_func = composite_565;
- else if (visual->depth == 24 && bits_per_pixel == 32 &&
- visual->red_mask == 0xff0000 &&
- visual->green_mask == 0x00ff00 &&
- visual->blue_mask == 0x0000ff)
- composite_func = composite_0888;
- }
-
- /* We can't use our composite func if we are required to dither
- */
- if (composite_func && !(dither == GDK_RGB_DITHER_MAX && visual->depth != 24))
- {
-#if 0
- gint x0, y0;
- for (y0 = 0; y0 < height; y0 += GDK_SCRATCH_IMAGE_HEIGHT)
- {
- gint height1 = MIN (height - y0, GDK_SCRATCH_IMAGE_HEIGHT);
- for (x0 = 0; x0 < width; x0 += GDK_SCRATCH_IMAGE_WIDTH)
- {
- gint xs0, ys0;
-
- gint width1 = MIN (width - x0, GDK_SCRATCH_IMAGE_WIDTH);
-
- GdkImage *image = _gdk_image_get_scratch (gdk_drawable_get_screen (drawable),
- width1, height1,
- gdk_drawable_get_depth (drawable), &xs0, &ys0);
-
- gdk_drawable_copy_to_image (drawable, image,
- dest_x + x0, dest_y + y0,
- xs0, ys0,
- width1, height1);
- (*composite_func) (pixbuf->pixels + (src_y + y0) * pixbuf->rowstride + (src_x + x0) * 4,
- pixbuf->rowstride,
- (guchar*)image->mem + ys0 * image->bpl + xs0 * image->bpp,
- image->bpl,
- visual->byte_order,
- width1, height1);
- gdk_draw_image (drawable, gc, image,
- xs0, ys0,
- dest_x + x0, dest_y + y0,
- width1, height1);
- }
- }
-#else
- void *data;
- int pitch;
-
- if (impl->surface->Lock( impl->surface, DSLF_READ | DSLF_WRITE, &data, &pitch ) == DFB_OK) {
- (*composite_func) (pixbuf->pixels + src_y * pixbuf->rowstride + src_x * 4,
- pixbuf->rowstride,
- data + dest_y * pitch + DFB_BYTES_PER_LINE( impl->format, dest_x ),
- pitch,
- visual->byte_order,
- width, height);
-
- impl->surface->Unlock( impl->surface );
- }
-#endif
- goto out;
- }
- else
- {
- /* No special composition func, convert dest to 24 bit RGB data, composite against
- * that, and convert back.
- */
- composited = gdk_pixbuf_get_from_drawable (NULL,
- drawable,
- NULL,
- dest_x, dest_y,
- 0, 0,
- width, height);
-
- if (composited)
- composite (pixbuf->pixels + src_y * pixbuf->rowstride + src_x * 4,
- pixbuf->rowstride,
- composited->pixels,
- composited->rowstride,
- width, height);
- }
- }
-
- if (composited)
- {
- src_x = 0;
- src_y = 0;
- pixbuf = composited;
- }
-
- if (pixbuf->n_channels == 4)
- {
- guchar *buf = pixbuf->pixels + src_y * pixbuf->rowstride + src_x * 4;
-
- gdk_draw_rgb_32_image_dithalign (drawable, gc,
- dest_x, dest_y,
- width, height,
- dither,
- buf, pixbuf->rowstride,
- x_dither, y_dither);
- }
- else /* n_channels == 3 */
- {
- guchar *buf = pixbuf->pixels + src_y * pixbuf->rowstride + src_x * 3;
-
- gdk_draw_rgb_image_dithalign (drawable, gc,
- dest_x, dest_y,
- width, height,
- dither,
- buf, pixbuf->rowstride,
- x_dither, y_dither);
- }
-
- out:
- if (composited)
- g_object_unref (composited);
-}
-
static inline void
convert_rgba_pixbuf_to_image (guint32 *src,
guint src_pitch,