Commit 2eb744a3 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Added virtual functions set_pixel, get_color, fill_span and draw_drawable

2000-11-15  Alexander Larsson  <alla@lysator.liu.se>

	* gdk/linux-fb/gdkprivate-fb.h:
	Added virtual functions set_pixel, get_color,
	fill_span and draw_drawable to the GC.
	Added global _gdk_fb_screen_gc to use instead of
	NULL when drawing to the screen.
	Added _gdk_fb_gc_calc_state() prototype.

	* gdk/linux-fb/gdkgc-fb.c:
	Call _gdk_fb_gc_calc_state() on any gc state change.

	* gdk/linux-fb/gdkglobals-fb.c:
	Add _gdk_fb_screen_gc

	* gdk/linux-fb/gdkdrawable-fb2.c:
	_gdk_fb_gc_calc_state() calculates best functions
	for the GC state and depth.
	Moved bpp specialized code to separate functions.
	Added optimized 24 bpp AA draw_drawable.

	* gdk/linux-fb/gdkevents-fb.c:
	Silence gcc warning.

	* gdk/linux-fb/gdkimage-fb.c:
	Use _gdk_fb_screen_gc

	* gdk/linux-fb/gdkwindow-fb.c:
	Init and use _gdk_fb_screen_gc

	* gdk/linux-fb/mitypes.h:
	Remove unused types.
parent 376d6c19
2000-11-15 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkprivate-fb.h:
Added virtual functions set_pixel, get_color,
fill_span and draw_drawable to the GC.
Added global _gdk_fb_screen_gc to use instead of
NULL when drawing to the screen.
Added _gdk_fb_gc_calc_state() prototype.
* gdk/linux-fb/gdkgc-fb.c:
Call _gdk_fb_gc_calc_state() on any gc state change.
* gdk/linux-fb/gdkglobals-fb.c:
Add _gdk_fb_screen_gc
* gdk/linux-fb/gdkdrawable-fb2.c:
_gdk_fb_gc_calc_state() calculates best functions
for the GC state and depth.
Moved bpp specialized code to separate functions.
Added optimized 24 bpp AA draw_drawable.
* gdk/linux-fb/gdkevents-fb.c:
Silence gcc warning.
* gdk/linux-fb/gdkimage-fb.c:
Use _gdk_fb_screen_gc
* gdk/linux-fb/gdkwindow-fb.c:
Init and use _gdk_fb_screen_gc
* gdk/linux-fb/mitypes.h:
Remove unused types.
2000-11-14 Havoc Pennington <hp@pobox.com>
* gtk/gtktextlayout.c (add_cursor): use PANGO_PIXELS() to convert
......
2000-11-15 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkprivate-fb.h:
Added virtual functions set_pixel, get_color,
fill_span and draw_drawable to the GC.
Added global _gdk_fb_screen_gc to use instead of
NULL when drawing to the screen.
Added _gdk_fb_gc_calc_state() prototype.
* gdk/linux-fb/gdkgc-fb.c:
Call _gdk_fb_gc_calc_state() on any gc state change.
* gdk/linux-fb/gdkglobals-fb.c:
Add _gdk_fb_screen_gc
* gdk/linux-fb/gdkdrawable-fb2.c:
_gdk_fb_gc_calc_state() calculates best functions
for the GC state and depth.
Moved bpp specialized code to separate functions.
Added optimized 24 bpp AA draw_drawable.
* gdk/linux-fb/gdkevents-fb.c:
Silence gcc warning.
* gdk/linux-fb/gdkimage-fb.c:
Use _gdk_fb_screen_gc
* gdk/linux-fb/gdkwindow-fb.c:
Init and use _gdk_fb_screen_gc
* gdk/linux-fb/mitypes.h:
Remove unused types.
2000-11-14 Havoc Pennington <hp@pobox.com>
* gtk/gtktextlayout.c (add_cursor): use PANGO_PIXELS() to convert
......
2000-11-15 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkprivate-fb.h:
Added virtual functions set_pixel, get_color,
fill_span and draw_drawable to the GC.
Added global _gdk_fb_screen_gc to use instead of
NULL when drawing to the screen.
Added _gdk_fb_gc_calc_state() prototype.
* gdk/linux-fb/gdkgc-fb.c:
Call _gdk_fb_gc_calc_state() on any gc state change.
* gdk/linux-fb/gdkglobals-fb.c:
Add _gdk_fb_screen_gc
* gdk/linux-fb/gdkdrawable-fb2.c:
_gdk_fb_gc_calc_state() calculates best functions
for the GC state and depth.
Moved bpp specialized code to separate functions.
Added optimized 24 bpp AA draw_drawable.
* gdk/linux-fb/gdkevents-fb.c:
Silence gcc warning.
* gdk/linux-fb/gdkimage-fb.c:
Use _gdk_fb_screen_gc
* gdk/linux-fb/gdkwindow-fb.c:
Init and use _gdk_fb_screen_gc
* gdk/linux-fb/mitypes.h:
Remove unused types.
2000-11-14 Havoc Pennington <hp@pobox.com>
* gtk/gtktextlayout.c (add_cursor): use PANGO_PIXELS() to convert
......
2000-11-15 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkprivate-fb.h:
Added virtual functions set_pixel, get_color,
fill_span and draw_drawable to the GC.
Added global _gdk_fb_screen_gc to use instead of
NULL when drawing to the screen.
Added _gdk_fb_gc_calc_state() prototype.
* gdk/linux-fb/gdkgc-fb.c:
Call _gdk_fb_gc_calc_state() on any gc state change.
* gdk/linux-fb/gdkglobals-fb.c:
Add _gdk_fb_screen_gc
* gdk/linux-fb/gdkdrawable-fb2.c:
_gdk_fb_gc_calc_state() calculates best functions
for the GC state and depth.
Moved bpp specialized code to separate functions.
Added optimized 24 bpp AA draw_drawable.
* gdk/linux-fb/gdkevents-fb.c:
Silence gcc warning.
* gdk/linux-fb/gdkimage-fb.c:
Use _gdk_fb_screen_gc
* gdk/linux-fb/gdkwindow-fb.c:
Init and use _gdk_fb_screen_gc
* gdk/linux-fb/mitypes.h:
Remove unused types.
2000-11-14 Havoc Pennington <hp@pobox.com>
* gtk/gtktextlayout.c (add_cursor): use PANGO_PIXELS() to convert
......
2000-11-15 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkprivate-fb.h:
Added virtual functions set_pixel, get_color,
fill_span and draw_drawable to the GC.
Added global _gdk_fb_screen_gc to use instead of
NULL when drawing to the screen.
Added _gdk_fb_gc_calc_state() prototype.
* gdk/linux-fb/gdkgc-fb.c:
Call _gdk_fb_gc_calc_state() on any gc state change.
* gdk/linux-fb/gdkglobals-fb.c:
Add _gdk_fb_screen_gc
* gdk/linux-fb/gdkdrawable-fb2.c:
_gdk_fb_gc_calc_state() calculates best functions
for the GC state and depth.
Moved bpp specialized code to separate functions.
Added optimized 24 bpp AA draw_drawable.
* gdk/linux-fb/gdkevents-fb.c:
Silence gcc warning.
* gdk/linux-fb/gdkimage-fb.c:
Use _gdk_fb_screen_gc
* gdk/linux-fb/gdkwindow-fb.c:
Init and use _gdk_fb_screen_gc
* gdk/linux-fb/mitypes.h:
Remove unused types.
2000-11-14 Havoc Pennington <hp@pobox.com>
* gtk/gtktextlayout.c (add_cursor): use PANGO_PIXELS() to convert
......
2000-11-15 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkprivate-fb.h:
Added virtual functions set_pixel, get_color,
fill_span and draw_drawable to the GC.
Added global _gdk_fb_screen_gc to use instead of
NULL when drawing to the screen.
Added _gdk_fb_gc_calc_state() prototype.
* gdk/linux-fb/gdkgc-fb.c:
Call _gdk_fb_gc_calc_state() on any gc state change.
* gdk/linux-fb/gdkglobals-fb.c:
Add _gdk_fb_screen_gc
* gdk/linux-fb/gdkdrawable-fb2.c:
_gdk_fb_gc_calc_state() calculates best functions
for the GC state and depth.
Moved bpp specialized code to separate functions.
Added optimized 24 bpp AA draw_drawable.
* gdk/linux-fb/gdkevents-fb.c:
Silence gcc warning.
* gdk/linux-fb/gdkimage-fb.c:
Use _gdk_fb_screen_gc
* gdk/linux-fb/gdkwindow-fb.c:
Init and use _gdk_fb_screen_gc
* gdk/linux-fb/mitypes.h:
Remove unused types.
2000-11-14 Havoc Pennington <hp@pobox.com>
* gtk/gtktextlayout.c (add_cursor): use PANGO_PIXELS() to convert
......
2000-11-15 Alexander Larsson <alla@lysator.liu.se>
* gdk/linux-fb/gdkprivate-fb.h:
Added virtual functions set_pixel, get_color,
fill_span and draw_drawable to the GC.
Added global _gdk_fb_screen_gc to use instead of
NULL when drawing to the screen.
Added _gdk_fb_gc_calc_state() prototype.
* gdk/linux-fb/gdkgc-fb.c:
Call _gdk_fb_gc_calc_state() on any gc state change.
* gdk/linux-fb/gdkglobals-fb.c:
Add _gdk_fb_screen_gc
* gdk/linux-fb/gdkdrawable-fb2.c:
_gdk_fb_gc_calc_state() calculates best functions
for the GC state and depth.
Moved bpp specialized code to separate functions.
Added optimized 24 bpp AA draw_drawable.
* gdk/linux-fb/gdkevents-fb.c:
Silence gcc warning.
* gdk/linux-fb/gdkimage-fb.c:
Use _gdk_fb_screen_gc
* gdk/linux-fb/gdkwindow-fb.c:
Init and use _gdk_fb_screen_gc
* gdk/linux-fb/mitypes.h:
Remove unused types.
2000-11-14 Havoc Pennington <hp@pobox.com>
* gtk/gtktextlayout.c (add_cursor): use PANGO_PIXELS() to convert
......
......@@ -5,23 +5,11 @@
#include <string.h>
#ifndef g_alloca
#define g_alloca alloca
#endif
typedef enum {
GPR_USED_BG,
GPR_AA_GRAYVAL,
GPR_NONE,
GPR_ERR_BOUNDS
} GetPixelRet;
static void gdk_fb_drawable_set_pixel (GdkDrawable *drawable,
GdkGC *gc,
int x,
int y,
GdkColor *spot,
gboolean abs_coords);
static GetPixelRet gdk_fb_drawable_get_pixel (GdkDrawable *drawable,
GdkGC *gc,
int x,
......@@ -329,11 +317,10 @@ gdk_fb_clip_region (GdkDrawable *drawable,
}
static void
gdk_fb_fill_span (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *cur,
GdkColor *color,
GdkVisual *visual)
gdk_fb_fill_span_general (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *cur,
GdkColor *color)
{
int curx, cury;
GdkColor spot = *color;
......@@ -342,270 +329,376 @@ gdk_fb_fill_span (GdkDrawable *drawable,
private = GDK_DRAWABLE_FBDATA (drawable);
gc_private = GDK_GC_FBDATA (gc);
if (gc &&
(gc_private->values.clip_mask ||
gc_private->values.tile ||
gc_private->values.stipple ||
gc_private->values.function == GDK_INVERT))
{
int clipxoff, clipyoff; /* Amounts to add to curx & cury to get x & y in clip mask */
int tsxoff, tsyoff;
GdkDrawable *cmask;
guchar *clipmem;
guint mask_rowstride;
GdkPixmap *ts = NULL;
GdkDrawableFBData *ts_private;
gboolean solid_stipple;
GdkFunction func = gc_private->values.function;
ts_private = GDK_DRAWABLE_IMPL_FBDATA (ts);
cmask = gc_private->values.clip_mask;
clipxoff = clipyoff = tsxoff = tsyoff = 0;
mask_rowstride = 0;
solid_stipple = FALSE;
clipmem = NULL;
if (cmask)
{
GdkDrawableFBData *cmask_private;
cmask_private = GDK_DRAWABLE_IMPL_FBDATA (cmask);
clipmem = cmask_private->mem;
clipxoff = cmask_private->abs_x - gc_private->values.clip_x_origin - private->abs_x;
clipyoff = cmask_private->abs_y - gc_private->values.clip_y_origin - private->abs_y;
mask_rowstride = cmask_private->rowstride;
}
if (gc_private->values.fill == GDK_TILED &&
gc_private->values.tile)
{
gint xstep, ystep;
gint relx, rely;
GdkFBDrawingContext *dc, dc_data;
dc = &dc_data;
g_assert (gc);
{
int clipxoff, clipyoff; /* Amounts to add to curx & cury to get x & y in clip mask */
int tsxoff, tsyoff;
GdkDrawable *cmask;
guchar *clipmem;
guint mask_rowstride;
GdkPixmap *ts = NULL;
GdkDrawableFBData *ts_private;
gboolean solid_stipple;
GdkFunction func = gc_private->values.function;
cmask = gc_private->values.clip_mask;
clipxoff = clipyoff = tsxoff = tsyoff = 0;
mask_rowstride = 0;
solid_stipple = FALSE;
clipmem = NULL;
if (cmask)
{
GdkDrawableFBData *cmask_private;
cmask_private = GDK_DRAWABLE_IMPL_FBDATA (cmask);
clipmem = cmask_private->mem;
clipxoff = cmask_private->abs_x - gc_private->values.clip_x_origin - private->abs_x;
clipyoff = cmask_private->abs_y - gc_private->values.clip_y_origin - private->abs_y;
mask_rowstride = cmask_private->rowstride;
}
if (gc_private->values.fill == GDK_TILED &&
gc_private->values.tile)
{
gint xstep, ystep;
gint relx, rely;
GdkFBDrawingContext *dc, dc_data;
dc = &dc_data;
gdk_fb_drawing_context_init (dc, drawable, gc, FALSE, TRUE);
ts = gc_private->values.tile;
ts_private = GDK_DRAWABLE_IMPL_FBDATA (ts);
for (cury = cur->y1; cury < cur->y2; cury += ystep)
{
int drawh;
rely = cury - private->abs_y;
drawh = (rely + gc_private->values.ts_y_origin) % ts_private->height;
if (drawh < 0)
drawh += GDK_DRAWABLE_FBDATA (ts)->height;
ystep = MIN (ts_private->height - drawh, cur->y2 - rely);
for (curx = cur->x1; curx < cur->x2; curx += xstep)
{
int draww;
relx = curx - private->abs_x;
draww = (relx + gc_private->values.ts_x_origin) % ts_private->width;
if (draww < 0)
draww += ts_private->width;
xstep = MIN (ts_private->width - draww, cur->x2 - relx);
gdk_fb_draw_drawable_3 (drawable, gc, GDK_DRAWABLE_IMPL (ts),
dc,
draww, drawh,
relx, rely,
xstep, ystep);
}
}
gdk_fb_drawing_context_finalize (dc);
return;
}
else if ((gc_private->values.fill == GDK_STIPPLED ||
gc_private->values.fill == GDK_OPAQUE_STIPPLED) &&
gc_private->values.stipple)
{
ts = gc_private->values.stipple;
tsxoff = GDK_DRAWABLE_FBDATA (ts)->abs_x - gc_private->values.ts_x_origin - private->abs_x;
tsyoff = GDK_DRAWABLE_FBDATA (ts)->abs_y - gc_private->values.ts_y_origin - private->abs_y;
solid_stipple = (gc_private->values.fill == GDK_OPAQUE_STIPPLED);
}
for (cury = cur->y1; cury < cur->y2; cury++)
{
for (curx = cur->x1; curx < cur->x2; curx++)
{
int maskx = curx+clipxoff, masky = cury + clipyoff;
guchar foo;
if (cmask)
{
foo = clipmem[masky*mask_rowstride + (maskx >> 3)];
if (!(foo & (1 << (maskx % 8))))
continue;
}
if (func == GDK_INVERT)
{
(gc_private->get_color) (drawable, gc, curx, cury, &spot);
spot.pixel = ~spot.pixel;
spot.red = ~spot.red;
spot.green = ~spot.green;
spot.blue = ~spot.blue;
}
else if (ts)
{
int wid, hih;
ts_private = GDK_DRAWABLE_IMPL_FBDATA (ts);
wid = ts_private->width;
hih = ts_private->height;
maskx = (curx+tsxoff)%wid;
masky = (cury+tsyoff)%hih;
if (maskx < 0)
maskx += wid;
if (masky < 0)
masky += hih;
foo = ts_private->mem[(maskx >> 3) + ts_private->rowstride*masky];
if (foo & (1 << (maskx % 8)))
{
spot = gc_private->values.foreground;
}
else if (solid_stipple)
{
spot = gc_private->values.background;
}
else
continue;
}
(gc_private->set_pixel) (drawable, gc, curx, cury, spot.pixel);
}
}
}
}
gdk_fb_drawing_context_init (dc, drawable, gc, FALSE, TRUE);
static void
gdk_fb_fill_span_simple_1 (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *cur,
GdkColor *color)
{
int curx, cury;
GdkGCFBData *gc_private;
GdkDrawableFBData *private;
guchar *mem, *ptr;
guint rowstride;
ts = gc_private->values.tile;
for (cury = cur->y1; cury < cur->y2; cury += ystep)
{
int drawh;
rely = cury - private->abs_y;
drawh = (rely + gc_private->values.ts_y_origin) % ts_private->height;
if (drawh < 0)
drawh += GDK_DRAWABLE_FBDATA (ts)->height;
private = GDK_DRAWABLE_FBDATA (drawable);
gc_private = GDK_GC_FBDATA (gc);
ystep = MIN (ts_private->height - drawh, cur->y2 - rely);
g_assert (gc);
for (curx = cur->x1; curx < cur->x2; curx += xstep)
{
int draww;
g_assert (!gc_private->values.clip_mask &&
!gc_private->values.tile &&
!gc_private->values.stipple &&
gc_private->values.function != GDK_INVERT);
relx = curx - private->abs_x;
mem = private->mem;
rowstride = private->rowstride;
draww = (relx + gc_private->values.ts_x_origin) % ts_private->width;
if (draww < 0)
draww += ts_private->width;
{
int fromx = MIN ((cur->x1+7)&(~7), cur->x2);
int begn = fromx - cur->x1, begoff = cur->x1 % 8, endn;
guchar begmask, endmask;
int body_end = cur->x2 & ~7;
int body_len = (body_end - fromx)/8;
begmask = ((1 << (begn + begoff)) - 1)
& ~((1 << (begoff)) - 1);
endn = cur->x2 - body_end;
endmask = (1 << endn) - 1;
for (cury = cur->y1; cury < cur->y2; cury++)
{
ptr = mem + cury*rowstride + (cur->x1 >> 3);
if (color->pixel)
*ptr |= begmask;
else
*ptr &= ~begmask;
curx = fromx;
if (curx < cur->x2)
{
ptr = mem + cury*rowstride + (curx >> 3);
memset (ptr, color->pixel?0xFF:0, body_len);
if (endn)
{
ptr = mem + cury*rowstride + (body_end >> 3);
if (color->pixel)
*ptr |= endmask;
else
*ptr &= ~endmask;
}
}
}
}
}
xstep = MIN (ts_private->width - draww, cur->x2 - relx);
static void
gdk_fb_fill_span_simple_8 (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *cur,
GdkColor *color)
{
int cury;
GdkGCFBData *gc_private;
GdkDrawableFBData *private;
guchar *mem, *ptr;
guint rowstride;
gdk_fb_draw_drawable_3 (drawable, gc, GDK_DRAWABLE_IMPL (ts),
dc,
draww, drawh,
relx, rely,
xstep, ystep);
}
}
private = GDK_DRAWABLE_FBDATA (drawable);
gc_private = GDK_GC_FBDATA (gc);
gdk_fb_drawing_context_finalize (dc);
g_assert (gc);
return;
}
else if ((gc_private->values.fill == GDK_STIPPLED ||
gc_private->values.fill == GDK_OPAQUE_STIPPLED) &&
gc_private->values.stipple)
{
ts = gc_private->values.stipple;
tsxoff = GDK_DRAWABLE_FBDATA (ts)->abs_x - gc_private->values.ts_x_origin - private->abs_x;
tsyoff = GDK_DRAWABLE_FBDATA (ts)->abs_y - gc_private->values.ts_y_origin - private->abs_y;
solid_stipple = (gc_private->values.fill == GDK_OPAQUE_STIPPLED);
}
g_assert (!gc_private->values.clip_mask &&
!gc_private->values.tile &&
!gc_private->values.stipple &&
gc_private->values.function != GDK_INVERT);
for (cury = cur->y1; cury < cur->y2; cury++)
{
for (curx = cur->x1; curx < cur->x2; curx++)
{
int maskx = curx+clipxoff, masky = cury + clipyoff;
guchar foo;
mem = private->mem;
rowstride = private->rowstride;
if (cmask)
{
foo = clipmem[masky*mask_rowstride + (maskx >> 3)];
if (!(foo & (1 << (maskx % 8))))
continue;
}
if (func == GDK_INVERT)
{
gdk_fb_drawable_get_pixel (drawable, gc, curx, cury, &spot, TRUE, NULL, NULL);
spot.pixel = ~spot.pixel;
spot.red = ~spot.red;
spot.green = ~spot.green;
spot.blue = ~spot.blue;
}
else if (ts)
{
int wid = ts_private->width, hih = ts_private->height;
maskx = (curx+tsxoff)%wid;
masky = (cury+tsyoff)%hih;
if (maskx < 0)
maskx += wid;
if (masky < 0)
masky += hih;
foo = ts_private->mem[(maskx >> 3) + ts_private->rowstride*masky];
if (foo & (1 << (maskx % 8)))
{
spot = gc_private->values.foreground;
}
else if (solid_stipple)
{
spot = gc_private->values.background;
}
else
continue;
}
gdk_fb_drawable_set_pixel (drawable, gc, curx, cury, &spot, TRUE);
}
}
for (cury = cur->y1; cury < cur->y2; cury++)
{
ptr = mem + cury*rowstride + cur->x1;
memset (ptr, color->pixel, cur->x2 - cur->x1);
}
else
}
static void
gdk_fb_fill_span_simple_16 (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *cur,
GdkColor *color)
{
int cury;
GdkGCFBData *gc_private;
GdkDrawableFBData *private;
guchar *mem;
guint rowstride;
int n;
int i;
private = GDK_DRAWABLE_FBDATA (drawable);
gc_private = GDK_GC_FBDATA (gc);
g_assert (gc);
g_assert (!gc_private->values.clip_mask &&
!gc_private->values.tile &&
!gc_private->values.stipple &&
gc_private->values.function != GDK_INVERT);
mem = private->mem;
rowstride = private->rowstride;
n = cur->x2 - cur->x1;
for (cury = cur->y1; cury < cur->y2; cury++)
{
guchar *mem = private->mem, *ptr;
guint rowstride = private->rowstride;
int n;
guint16 *p16 = (guint16 *)(mem + cury * rowstride + cur->x1*2);
for (i = 0; i < n; i++)
*(p16++) = color->pixel;
}
}
switch (private->depth)
{
case 1:
{
int fromx = MIN ((cur->x1+7)&(~7), cur->x2);
int begn = fromx - cur->x1, begoff = cur->x1 % 8, endn;
guchar begmask, endmask;
int body_end = cur->x2 & ~7;
int body_len = (body_end - fromx)/8;
begmask = ((1 << (begn + begoff)) - 1)
& ~((1 << (begoff)) - 1);
endn = cur->x2 - body_end;
endmask = (1 << endn) - 1;
for (cury = cur->y1; cury < cur->y2; cury++)
{
ptr = mem + cury*rowstride + (cur->x1 >> 3);
static void
gdk_fb_fill_span_simple_24 (GdkDrawable *drawable,
GdkGC *gc,