Commit 73d7327b authored by Michael David Emmel's avatar Michael David Emmel
Browse files

Lots of changes the major change is GdkPaintable is not implemented by window

This code also requires a major redo of the cairo implementation now in
cairo cvs.
parent 6a246cb5
2006-07-13 Michael Emmel <mike.emmel@gmail.com>
* gdk/directfb/gdkdrawable-directfb.c
Remove +1 in fill and draw rect this may be wrong.
Commented out update calls left for reference the should not be needed.
Comment out subsurface for cairo remove when proved its not needed
* gdk/directfb/gdkkeys-directfb.c
Allow multiple calls and return if initalized
* gdk/directfb/gdkmain-directfb.c
Make sure string is malloced since its freed by apps
* gdk/directfb/gdkprivate-directfb.c
Added back pointer to window for paintable impl
* gdk/directfb/gdkvisual-directfb.c
Fix for Bug 346733 make sure visual list is populated
* gdk/directfb/gdkwindow-directfb.c
Finally removed uneeded pixmap buffering now implements GdkPainter
2006-07-11 Emmanuele Bassi <ebassi@gnome.org>
* gtk/gtkrecentchooser.c (gtk_recent_chooser_set_show_numbers),
......
2006-07-13 Michael Emmel <mike.emmel@gmail.com>
* gdk/directfb/gdkdrawable-directfb.c
Remove +1 in fill and draw rect this may be wrong.
Commented out update calls left for reference the should not be needed.
Comment out subsurface for cairo remove when proved its not needed
* gdk/directfb/gdkkeys-directfb.c
Allow multiple calls and return if initalized
* gdk/directfb/gdkmain-directfb.c
Make sure string is malloced since its freed by apps
* gdk/directfb/gdkprivate-directfb.c
Added back pointer to window for paintable impl
* gdk/directfb/gdkvisual-directfb.c
Fix for Bug 346733 make sure visual list is populated
* gdk/directfb/gdkwindow-directfb.c
Finally removed uneeded pixmap buffering now implements GdkPainter
2006-07-11 Emmanuele Bassi <ebassi@gnome.org>
* gtk/gtkrecentchooser.c (gtk_recent_chooser_set_show_numbers),
......
......@@ -32,6 +32,7 @@
#include <config.h>
#include "gdk.h"
#include <assert.h>
#include <string.h>
......@@ -456,17 +457,17 @@ _gdk_directfb_draw_rectangle (GdkDrawable *drawable,
else
{
DFBRegion region = { x, y, x + width+1, y + height+1 };
DFBRegion region = { x, y, x + width, y + height };
impl->surface->SetClip (impl->surface, &region);
/* DirectFB does not draw rectangles the X way. Using DirectFB,
a filled Rectangle has the same size as a drawn one, while
X draws the rectangle one pixel taller and wider. */
impl->surface->DrawRectangle (impl->surface,
x, y, width + 1, height + 1);
x, y, width , height);
impl->surface->SetClip (impl->surface, NULL);
_gdk_directfb_update (impl, &region);
//_gdk_directfb_update (impl, &region);
}
}
......@@ -679,7 +680,7 @@ gdk_directfb_draw_points (GdkDrawable *drawable,
gdk_region_destroy (clip);
_gdk_directfb_update (impl, &region);
//_gdk_directfb_update (impl, &region);
}
static void
......@@ -759,7 +760,7 @@ gdk_directfb_draw_segments (GdkDrawable *drawable,
region.y2 = segs->y2;
}
_gdk_directfb_update (impl, &region);
//_gdk_directfb_update (impl, &region);
}
static void
......@@ -828,7 +829,7 @@ gdk_directfb_draw_lines (GdkDrawable *drawable,
gdk_region_destroy (clip);
_gdk_directfb_update (impl, &region);
//_gdk_directfb_update (impl, &region);
}
static void
......@@ -1078,14 +1079,17 @@ gdk_directfb_ref_cairo_surface (GdkDrawable *drawable)
GdkDrawableImplDirectFB *impl = GDK_DRAWABLE_IMPL_DIRECTFB (drawable);
IDirectFB *dfb = GDK_DISPLAY_DFB(gdk_drawable_get_display(drawable))->directfb;
if (!impl->cairo_surface) {
IDirectFBSurface *surface;
if (impl->surface->GetSubSurface (impl->surface, NULL, &surface) == DFB_OK) {
impl->cairo_surface = cairo_directfb_surface_create (dfb, surface);
// IDirectFBSurface *surface;
// if (impl->surface->GetSubSurface (impl->surface, NULL, &surface) == DFB_OK) {
//impl->cairo_surface = cairo_directfb_surface_create (dfb, surface);
g_assert( impl->surface != NULL);
impl->cairo_surface = cairo_directfb_surface_create (dfb,impl->surface);
g_assert( impl->cairo_surface != NULL);
cairo_surface_set_user_data (impl->cairo_surface,
&gdk_directfb_cairo_key, drawable,
gdk_directfb_cairo_surface_destroy);
surface->Release (surface);
}
// surface->Release (surface);
//}
} else {
cairo_surface_reference (impl->cairo_surface);
}
......
......@@ -1670,6 +1670,8 @@ _gdk_directfb_keyboard_init (void)
if (!keyboard)
return;
if( directfb_keymap )
return;
keyboard->GetDescription (keyboard, &desc);
_gdk_display->keymap=g_object_new (gdk_keymap_get_type (), NULL);
......@@ -1682,7 +1684,6 @@ _gdk_directfb_keyboard_init (void)
length = directfb_max_keycode - desc.min_keycode + 1;
g_assert (directfb_keymap == NULL);
directfb_keymap = g_new0 (guint, 4 * length);
......
......@@ -105,7 +105,7 @@ _gdk_windowing_exit (void)
gchar *
gdk_get_display (void)
{
return "DirectFB";
return g_strdup (gdk_display_get_name (gdk_display_get_default ()));
}
......
......@@ -70,7 +70,6 @@ struct _GdkDrawableImplDirectFB
GdkRegion *paint_region;
gint paint_depth;
gint width;
gint height;
gint abs_x;
......@@ -140,6 +139,7 @@ typedef struct
struct _GdkWindowImplDirectFB
{
GdkDrawableImplDirectFB drawable;
GdkWindow *gdkWindow;
IDirectFBWindow *window;
......
......@@ -54,12 +54,12 @@ static GdkVisualDirectFB * gdk_directfb_visual_create (DFBSurfacePixelFormat pi
static DFBSurfacePixelFormat formats[] =
{
DSPF_RGB32,
DSPF_ARGB,
DSPF_LUT8,
DSPF_RGB32,
DSPF_RGB24,
DSPF_RGB16,
DSPF_ARGB1555,
DSPF_LUT8,
DSPF_RGB332
};
......@@ -133,6 +133,10 @@ _gdk_visual_init ()
If you want to use a special pixelformat that is not registered
here, you can create it using the DirectFB-specific function
gdk_directfb_visual_by_format().
Note:
changed to do all formats but we should redo this code
to ensure the base format ARGB LUT8 RGB etc then add ones supported
by the hardware
*/
for (i = 0, c = 0; i < G_N_ELEMENTS (formats); i++)
{
......@@ -143,12 +147,13 @@ _gdk_visual_init ()
desc.width = 8;
desc.height = 8;
desc.pixelformat = formats[i];
//call direct so fail silently is ok
if (_gdk_display->directfb->CreateSurface (_gdk_display->directfb,
&desc, &src) != DFB_OK)
&desc, &src) != DFB_OK)
continue;
visuals[i] = gdk_directfb_visual_create (formats[i]);
dest->GetAccelerationMask (dest, src, &acc);
if (acc & DFXL_BLIT || formats[i] == dlc.pixelformat)
......@@ -162,17 +167,11 @@ _gdk_visual_init ()
dest->Release (dest);
//fallback to ARGB
//fallback to ARGB must be supported
if (!system_visual)
{
for (i = 0; i < G_N_ELEMENTS (formats); i++) {
if (formats[i] == DSPF_ARGB ) {
if( visuals[i] == NULL )
visuals[i] = gdk_directfb_visual_create (formats[i]);
system_visual = visuals[i];
break;
}
}
g_assert (visuals[DSPF_ARGB] != NULL);
system_visual = GDK_VISUAL(visuals[DSPF_ARGB]);
}
g_assert (system_visual != NULL);
......@@ -210,10 +209,12 @@ gdk_visual_get_best_with_depth (gint depth)
for (i = 0; visuals[i]; i++)
{
GdkVisual *visual = GDK_VISUAL (visuals[i]);
if( visuals[i] ) {
GdkVisual *visual = GDK_VISUAL (visuals[i]);
if (depth == visual->depth)
return visual;
if (depth == visual->depth)
return visual;
}
}
return NULL;
......@@ -226,10 +227,12 @@ gdk_visual_get_best_with_type (GdkVisualType visual_type)
for (i = 0; visuals[i]; i++)
{
GdkVisual *visual = GDK_VISUAL (visuals[i]);
if( visuals[i] ) {
GdkVisual *visual = GDK_VISUAL (visuals[i]);
if (visual_type == visual->type)
return visual;
if (visual_type == visual->type)
return visual;
}
}
return NULL;
......@@ -243,10 +246,12 @@ gdk_visual_get_best_with_both (gint depth,
for (i = 0; visuals[i]; i++)
{
GdkVisual *visual = GDK_VISUAL (visuals[i]);
if( visuals[i] ) {
GdkVisual *visual = GDK_VISUAL (visuals[i]);
if (depth == visual->depth && visual_type == visual->type)
return visual;
if (depth == visual->depth && visual_type == visual->type)
return visual;
}
}
return system_visual;
......@@ -285,7 +290,10 @@ gdk_screen_list_visuals (GdkScreen *screen)
gint i;
for (i = 0; visuals[i]; i++)
list = g_list_append (list, visuals[i]);
if( visuals[i] ) {
GdkVisual * vis = GDK_VISUAL(visuals[i]);
list = g_list_append (list,vis);
}
return list;
}
......@@ -313,7 +321,7 @@ gdk_directfb_visual_by_format (DFBSurfacePixelFormat pixel_format)
/* first check if one the registered visuals matches */
for (i = 0; visuals[i]; i++)
if (visuals[i]->format == pixel_format)
if ( visuals[i] && visuals[i]->format == pixel_format)
return GDK_VISUAL (visuals[i]);
/* none matched, try to create a new one for this pixel_format */
......@@ -332,9 +340,7 @@ gdk_directfb_visual_by_format (DFBSurfacePixelFormat pixel_format)
test->Release (test);
}
visuals[i] = gdk_directfb_visual_create (pixel_format);
return GDK_VISUAL (visuals[i]);
return GDK_VISUAL(gdk_directfb_visual_create (pixel_format));
}
GdkScreen *
......
......@@ -44,6 +44,7 @@
#include "gdkinternals.h"
#include "gdkalias.h"
#include "cairo.h"
#include <assert.h>
static GdkRegion * gdk_window_impl_directfb_get_visible_region (GdkDrawable *drawable);
static void gdk_window_impl_directfb_set_colormap (GdkDrawable *drawable,
......@@ -60,11 +61,76 @@ typedef struct
} GdkWindowChildHandlerData;
/* Code for dirty-region queueing
*/
static GSList *update_windows = NULL;
static guint update_idle = 0;
static gboolean debug_updates = FALSE;
static void
gdk_window_directfb_process_all_updates (void)
{
GSList *old_update_windows = update_windows;
GSList *tmp_list = update_windows;
if (update_idle)
g_source_remove (update_idle);
update_windows = NULL;
update_idle = 0;
g_slist_foreach (old_update_windows, (GFunc)g_object_ref, NULL);
while (tmp_list)
{
GdkWindowObject *private = (GdkWindowObject *)tmp_list->data;
if (private->update_freeze_count)
update_windows = g_slist_prepend (update_windows, private);
else
gdk_window_process_updates(tmp_list->data,TRUE);
g_object_unref (tmp_list->data);
tmp_list = tmp_list->next;
}
g_slist_free (old_update_windows);
}
static gboolean
gdk_window_update_idle (gpointer data)
{
GDK_THREADS_ENTER ();
gdk_window_directfb_process_all_updates ();
GDK_THREADS_LEAVE ();
return FALSE;
}
static void
gdk_window_schedule_update (GdkWindow *window)
{
if (window && GDK_WINDOW_OBJECT (window)->update_freeze_count)
return;
if (!update_idle)
{
update_idle = g_idle_add_full (GDK_PRIORITY_REDRAW,
gdk_window_update_idle, NULL, NULL);
}
}
static GdkWindow *gdk_directfb_window_containing_pointer = NULL;
static GdkWindow *gdk_directfb_focused_window = NULL;
static gpointer parent_class = NULL;
GdkWindow * _gdk_parent_root = NULL;
static void
gdk_window_impl_directfb_paintable_init (GdkPaintableIface *iface);
GType
......@@ -87,9 +153,20 @@ gdk_window_impl_directfb_get_type (void)
(GInstanceInitFunc) gdk_window_impl_directfb_init,
};
static const GInterfaceInfo paintable_info =
{
(GInterfaceInitFunc) gdk_window_impl_directfb_paintable_init,
NULL,
NULL
};
object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_DIRECTFB,
"GdkWindowImplDirectFB",
&object_info, 0);
g_type_add_interface_static (object_type,
GDK_TYPE_PAINTABLE,
&paintable_info);
}
return object_type;
......@@ -176,7 +253,7 @@ gdk_window_impl_directfb_get_visible_region (GdkDrawable *drawable)
DFBRectangle drect = { 0, 0, 0, 0 };
if (priv->surface)
priv->surface->GetVisibleRectangle (priv->surface, &drect);
priv->surface->GetVisibleRectangle (priv->surface, &drect);
rect.x= drect.x;
rect.y= drect.y;
rect.width=drect.w;
......@@ -223,8 +300,9 @@ create_directfb_window (GdkWindowImplDirectFB *impl,
}
if ((desc->flags & DWDESC_CAPS) && (desc->caps & DWCAPS_INPUTONLY))
{
impl->drawable.surface = NULL;
else
} else
window->GetSurface (window, &impl->drawable.surface);
if (window_options)
......@@ -258,7 +336,8 @@ _gdk_windowing_window_init (void)
private->window_type = GDK_WINDOW_ROOT;
private->state = 0;
private->children = NULL;
impl->drawable.paint_region = NULL;
impl->gdkWindow = _gdk_parent_root;
impl->window = NULL;
impl->drawable.abs_x = 0;
impl->drawable.abs_y = 0;
......@@ -331,6 +410,7 @@ gdk_directfb_window_new (GdkWindow *parent,
impl = GDK_WINDOW_IMPL_DIRECTFB (private->impl);
impl->drawable.wrapper = GDK_DRAWABLE (window);
impl->gdkWindow = window;
private->x = x;
private->y = y;
......@@ -420,9 +500,9 @@ gdk_directfb_window_new (GdkWindow *parent,
impl->window=NULL;
if (!private->input_only && parent_impl->drawable.surface)
{
DFBRectangle rect =
{ x, y, impl->drawable.width, impl->drawable.height };
parent_impl->drawable.surface->GetSubSurface (parent_impl->drawable.surface,
&rect,
&impl->drawable.surface);
......@@ -1191,8 +1271,12 @@ _gdk_directfb_move_resize_child (GdkWindow *window,
{
if (impl->drawable.surface)
{
GdkDrawableImplDirectFB *dimpl;
dimpl = GDK_DRAWABLE_IMPL_DIRECTFB (private->impl);
impl->drawable.surface->Release (impl->drawable.surface);
impl->drawable.surface = NULL;
cairo_surface_destroy(dimpl->cairo_surface);
dimpl->cairo_surface= NULL;
}
parent_impl = GDK_WINDOW_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (private->parent)->impl);
......@@ -1214,6 +1298,9 @@ _gdk_directfb_move_resize_child (GdkWindow *window,
_gdk_directfb_move_resize_child (list->data,
private->x, private->y,
impl->drawable.width, impl->drawable.height);
//FIXEME should this really happen ?
if( impl->drawable.surface )
impl->drawable.surface->GetPosition(impl->drawable.surface,&x,&y);
}
}
......@@ -1287,7 +1374,7 @@ gdk_window_move_resize (GdkWindow *window,
}
}
}
//XXX BROKE if top LEVEL WINDOW ~~~
void
gdk_window_reparent (GdkWindow *window,
GdkWindow *new_parent,
......@@ -2345,73 +2432,6 @@ gdk_window_set_static_gravities (GdkWindow *window,
return FALSE;
}
#if 0
void
gdk_window_begin_paint_region (GdkWindow *window,
GdkRegion *region)
{
GdkDrawableImplDirectFB *impl;
gint i;
g_return_if_fail (GDK_IS_WINDOW (window));
impl = GDK_DRAWABLE_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (window)->impl);
impl->buffered = TRUE;
impl->paint_depth++;
if (!region)
return;
if (impl->paint_region)
gdk_region_union (impl->paint_region, region);
else
impl->paint_region = gdk_region_copy (region);
for (i = 0; i < region->numRects; i++)
{
GdkRegionBox *box = &region->rects[i];
_gdk_windowing_window_clear_area (window,
box->x1,
box->y1,
box->x2 - box->x1,
box->y2 - box->y1);
}
}
void
gdk_window_end_paint (GdkWindow *window)
{
GdkDrawableImplDirectFB *impl;
g_return_if_fail (GDK_IS_WINDOW (window));
impl = GDK_DRAWABLE_IMPL_DIRECTFB (GDK_WINDOW_OBJECT (window)->impl);
g_return_if_fail (impl->paint_depth > 0);
impl->paint_depth--;
if (impl->paint_depth == 0)
{
impl->buffered = FALSE;
if (impl->paint_region)
{
DFBRegion reg = { impl->paint_region->extents.x1,
impl->paint_region->extents.y1,
impl->paint_region->extents.x2 - 1,
impl->paint_region->extents.y2 - 1 };
_gdk_directfb_update (impl, &reg);
gdk_region_destroy (impl->paint_region);
impl->paint_region = NULL;
}
}
}
#endif
void
gdk_window_begin_resize_drag (GdkWindow *window,
......@@ -2739,6 +2759,255 @@ gdk_window_set_urgency_hint (GdkWindow *window,
}
static void
gdk_window_impl_directfb_invalidate_maybe_recurse (GdkPaintable *paintable,
GdkRegion *region,
gboolean (*child_func) (GdkWindow *, gpointer),
gpointer user_data)
{
GdkWindow *window;
GdkWindowObject *private;
GdkWindowImplDirectFB *wimpl;
GdkDrawableImplDirectFB *impl;
wimpl = GDK_WINDOW_IMPL_DIRECTFB (paintable);
impl = (GdkDrawableImplDirectFB *)wimpl;
window = wimpl->gdkWindow;
private = (GdkWindowObject *)window;
GdkRegion *visible_region;
GList *tmp_list;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
if (GDK_WINDOW_DESTROYED (window))
return;
if (private->input_only || !GDK_WINDOW_IS_MAPPED (window))
return;
visible_region = gdk_drawable_get_visible_region (window);
gdk_region_intersect (visible_region, region);
tmp_list = private->children;
while (tmp_list)
{
GdkWindowObject *child = tmp_list->data;
if (!child->input_only)
{
GdkRegion *child_region;
GdkRectangle child_rect;
gdk_window_get_position ((GdkWindow *)child,
&child_rect.x, &child_rect.y);
gdk_drawable_get_size ((GdkDrawable *)child,
&child_rect.width, &child_rect.height);
child_region = gdk_region_rectangle (&child_rect);
/* remove child area from the invalid area of the parent */
if (GDK_WINDOW_IS_MAPPED (child) && !child->shaped)
gdk_region_subtract (visible_region, child_region);
if (child_func && (*child_func) ((GdkWindow *)child, user_data))
{
gdk_region_offset (region, - child_rect.x, - child_rect.y);
gdk_region_offset (child_region, - child_rect.x, - child_rect.y);
gdk_region_intersect (child_region, region);
gdk_window_invalidate_maybe_recurse ((GdkWindow *)child,
child_region, child_func, user_data);
gdk_region_offset (region, child_rect.x, child_rect.y);
}
gdk_region_destroy (child_region);