diff --git a/ChangeLog b/ChangeLog index c6c48bd6a..d262cf72b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,41 @@ +2005-04-22 mallum,,, + + * clutter/Makefile.am: + * clutter/cltr-button.c: + * clutter/cltr-button.h: + * clutter/cltr-core.c: (cltr_init): + * clutter/cltr-overlay.c: + * clutter/cltr-overlay.h: + * clutter/cltr-photo-grid.c: (cltr_photo_grid_handle_xevent), + (cltr_photo_grid_cell_new), (ctrl_photo_grid_get_zoomed_coords), + (cell_is_offscreen), (cltr_photo_grid_idle_cb), + (cltr_photo_grid_navigate), (cltr_photo_grid_activate_cell), + (cltr_photo_grid_populate), (cltr_photo_grid_update_visual_state), + (cltr_photo_grid_paint), (cltr_photo_grid_show), + (cltr_photo_grid_set_fps), (cltr_photo_grid_get_fps), + (cltr_photo_grid_set_anim_steps), (cltr_photo_grid_get_anim_steps), + (cltr_photo_grid_new): + Fix up grid so external prog can load images. + * clutter/cltr-photo-grid.h: + * clutter/cltr-texture.c: (cltr_texture_realize), + (cltr_texture_new): + * clutter/cltr-texture.h: + * clutter/cltr-window.c: (cltr_window_set_fullscreen): + * clutter/cltr.h: + * clutter/pixbuf.c: (pixbuf_scale_down), (ConvolveImage), + (GaussianBlurImage): + * clutter/pixbuf.h: + New experimental Methods + * configure.ac: + * examples/Makefile.am: + * examples/photos.c: + * examples/player.c: + Add new examples + * gst/Makefile.am: + * gst/cltrimagesink.c: + * gst/cltrimagesink.h: + Add initial crusty ( broken ) gst stuff + 2005-04-13 mallum,,, * bootstrap-autotools.sh: diff --git a/Makefile.am b/Makefile.am index fed7ad01c..5a09d1b6d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1 +1 @@ -SUBDIRS=clutter examples \ No newline at end of file +SUBDIRS=clutter gst examples \ No newline at end of file diff --git a/clutter/Makefile.am b/clutter/Makefile.am index 32ee920f6..3871a94c9 100644 --- a/clutter/Makefile.am +++ b/clutter/Makefile.am @@ -8,6 +8,8 @@ source_h = pixbuf.h util.h fonts.h \ cltr-window.h \ cltr-photo-grid.h \ cltr-list.h \ + cltr-overlay.h \ + cltr-button.h \ cltr-scratch.h source_c = pixbuf.c util.c fonts.c \ @@ -19,6 +21,8 @@ source_c = pixbuf.c util.c fonts.c \ cltr-window.c \ cltr-photo-grid.c \ cltr-list.c \ + cltr-overlay.c \ + cltr-button.c \ cltr-scratch.c AM_CFLAGS = @GCC_FLAGS@ @CLTR_CFLAGS@ diff --git a/clutter/cltr-button.c b/clutter/cltr-button.c new file mode 100644 index 000000000..784b43b8c --- /dev/null +++ b/clutter/cltr-button.c @@ -0,0 +1,54 @@ +#include "cltr-button.h" +#include "cltr-private.h" + +struct CltrButton +{ + CltrWidget widget; +}; + +static void +cltr_button_show(CltrWidget *widget); + +static gboolean +cltr_button_handle_xevent (CltrWidget *widget, XEvent *xev); + +static void +cltr_button_paint(CltrWidget *widget); + + +CltrWidget* +cltr_button_new(int width, int height) +{ + CltrButton *button; + + button = g_malloc0(sizeof(CltrButton)); + + button->widget.width = width; + button->widget.height = height; + + button->widget.show = cltr_button_show; + button->widget.paint = cltr_button_paint; + + button->widget.xevent_handler = cltr_button_handle_xevent; + + return CLTR_WIDGET(button); +} + +static void +cltr_button_show(CltrWidget *widget) +{ + +} + +static gboolean +cltr_button_handle_xevent (CltrWidget *widget, XEvent *xev) +{ + +} + +static void +cltr_button_paint(CltrWidget *widget) +{ + + +} diff --git a/clutter/cltr-button.h b/clutter/cltr-button.h new file mode 100644 index 000000000..8e4966f65 --- /dev/null +++ b/clutter/cltr-button.h @@ -0,0 +1,14 @@ +#ifndef _HAVE_CLTR_BUTTON_H +#define _HAVE_CLTR_BUTTON_H + +#include "cltr.h" + +typedef struct CltrButton CltrButton; + +#define CLTR_BUTTON(w) ((CltrButton*)(w)) + +CltrWidget* +cltr_button_new(int width, int height); + + +#endif diff --git a/clutter/cltr-core.c b/clutter/cltr-core.c index 034c9aca8..cfcbcbdb4 100644 --- a/clutter/cltr-core.c +++ b/clutter/cltr-core.c @@ -4,20 +4,38 @@ int cltr_init(int *argc, char ***argv) { + +#define GLX_SAMPLE_BUFFERS_ARB 100000 +#define GLX_SAMPLES_ARB 100001 + + int gl_attributes[] = { GLX_RGBA, GLX_DOUBLEBUFFER, + GLX_STENCIL_SIZE, 1, + GLX_DEPTH_SIZE, 24, + + /* + GLX_SAMPLE_BUFFERS_ARB, 1, + GLX_SAMPLES_ARB, 0, + + */ + /* GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, + + + + */ 0 }; XVisualInfo *vinfo; - - g_thread_init (NULL); + if (!g_thread_supported ()) + g_thread_init (NULL); // XInitThreads (); if ((CltrCntx.xdpy = XOpenDisplay(getenv("DISPLAY"))) == NULL) @@ -28,6 +46,10 @@ cltr_init(int *argc, char ***argv) CltrCntx.xscreen = DefaultScreen(CltrCntx.xdpy); CltrCntx.xwin_root = RootWindow(CltrCntx.xdpy, CltrCntx.xscreen); + CLTR_DBG("EXT : %s", glXQueryExtensionsString( CltrCntx.xdpy, + CltrCntx.xscreen)); + + if ((vinfo = glXChooseVisual(CltrCntx.xdpy, CltrCntx.xscreen, gl_attributes)) == NULL) diff --git a/clutter/cltr-overlay.c b/clutter/cltr-overlay.c new file mode 100644 index 000000000..077a7bdb9 --- /dev/null +++ b/clutter/cltr-overlay.c @@ -0,0 +1,54 @@ +#include "cltr-overlay.h" +#include "cltr-private.h" + +struct CltrOverlay +{ + CltrWidget widget; +}; + +static void +cltr_overlay_show(CltrWidget *widget); + +static gboolean +cltr_overlay_handle_xevent (CltrWidget *widget, XEvent *xev); + +static void +cltr_overlay_paint(CltrWidget *widget); + + +CltrWidget* +cltr_overlay_new(int width, int height) +{ + CltrOverlay *overlay; + + overlay = g_malloc0(sizeof(CltrOverlay)); + + overlay->widget.width = width; + overlay->widget.height = height; + + overlay->widget.show = cltr_overlay_show; + overlay->widget.paint = cltr_overlay_paint; + + overlay->widget.xevent_handler = cltr_overlay_handle_xevent; + + return CLTR_WIDGET(overlay); +} + +static void +cltr_overlay_show(CltrWidget *widget) +{ + +} + +static gboolean +cltr_overlay_handle_xevent (CltrWidget *widget, XEvent *xev) +{ + +} + +static void +cltr_overlay_paint(CltrWidget *widget) +{ + + +} diff --git a/clutter/cltr-overlay.h b/clutter/cltr-overlay.h new file mode 100644 index 000000000..2d6d1a3e4 --- /dev/null +++ b/clutter/cltr-overlay.h @@ -0,0 +1,14 @@ +#ifndef _HAVE_CLTR_OVERLAY_H +#define _HAVE_CLTR_OVERLAY_H + +#include "cltr.h" + +typedef struct CltrOverlay CltrOverlay; + +#define CLTR_OVERLAY(w) ((CltrOverlay*)(w)) + +CltrWidget* +cltr_overlay_new(int width, int height); + + +#endif diff --git a/clutter/cltr-photo-grid.c b/clutter/cltr-photo-grid.c index 47650c3c4..0f2569815 100644 --- a/clutter/cltr-photo-grid.c +++ b/clutter/cltr-photo-grid.c @@ -22,7 +22,6 @@ */ -#define ANIM_FPS 60 #define FPS_TO_TIMEOUT(t) (1000/(t)) struct CltrPhotoGridCell @@ -51,10 +50,12 @@ struct CltrPhotoGrid GList *cells_tail; GList *cell_active; + gboolean is_populated; + /* animation / zoom etc stuff */ /* current anim frame position */ - int anim_n_steps, anim_step; + int anim_fps, anim_n_steps, anim_step; /* start / end points for animations */ float zoom_min, zoom_max, zoom_step; @@ -64,9 +65,10 @@ struct CltrPhotoGrid /* Values calucated from above for setting up the GL tranforms and 'view' */ float paint_trans_x, paint_trans_y, paint_zoom; int paint_start_y; + GList *paint_cell_item; - + GMutex *mutex; CltrPhotoGridState state; }; @@ -84,9 +86,17 @@ static void cltr_photo_grid_update_visual_state(CltrPhotoGrid *grid); -/* this likely shouldn'y go here */ -static GMutex *Mutex_GRID = NULL; +GMutex* +cltr_photo_grid_mutex(CltrPhotoGrid *grid) +{ + return grid->mutex; +} +void +cltr_photo_grid_set_populated(CltrPhotoGrid *grid, gboolean populated) +{ + grid->is_populated = populated; +} static void cltr_photo_grid_handle_xkeyevent(CltrPhotoGrid *grid, XKeyEvent *xkeyev) @@ -140,12 +150,12 @@ cltr_photo_grid_handle_xevent (CltrWidget *widget, XEvent *xev) CltrPhotoGridCell* cltr_photo_grid_cell_new(CltrPhotoGrid *grid, - Pixbuf *pixb, - const gchar *filename) + Pixbuf *pixb) { CltrPhotoGridCell *cell = NULL; int maxw = grid->widget.width, maxh = grid->widget.height; int neww = 0, newh = 0; + Pixbuf *tmp_pixb = NULL; cell = g_malloc0(sizeof(CltrPhotoGridCell)); @@ -173,7 +183,7 @@ cltr_photo_grid_cell_new(CltrPhotoGrid *grid, } else cell->pixb = pixb; - CLTR_DBG ("loaded %s at %ix%i", filename, neww, newh); + cell->texture = cltr_texture_new(cell->pixb); cell->angle = 6.0 - (rand()%12); @@ -183,6 +193,44 @@ cltr_photo_grid_cell_new(CltrPhotoGrid *grid, return cell; } +Pixbuf* +cltr_photo_grid_cell_pixbuf(CltrPhotoGridCell *cell) +{ + return cell->pixb; +} + +CltrPhotoGridCell* +cltr_photo_grid_get_active_cell(CltrPhotoGrid *grid) +{ + if (grid->cell_active) + return grid->cell_active->data; + else + return NULL; +} + +void +cltr_photo_grid_set_active_cell(CltrPhotoGrid *grid, CltrPhotoGridCell *cell) +{ + GList *cell_item = NULL; + + cell_item = g_list_find(g_list_first(grid->cells_tail), (gconstpointer)cell); + + if (cell_item) + grid->cell_active = cell_item; +} + +CltrPhotoGridCell* +cltr_photo_grid_get_first_cell(CltrPhotoGrid *grid) +{ + GList *cell_item = NULL; + + cell_item = g_list_first(grid->cells_tail); + + if (cell_item) + return cell_item->data; + return NULL; +} + void cltr_photo_grid_append_cell(CltrPhotoGrid *grid, CltrPhotoGridCell *cell) @@ -258,10 +306,11 @@ cltr_photo_grid_idle_cb(gpointer data) cltr_widget_queue_paint(CLTR_WIDGET(grid)); + if (!grid->is_populated) + return TRUE; + switch(grid->state) { - case CLTR_PHOTO_GRID_STATE_LOADING: - case CLTR_PHOTO_GRID_STATE_LOAD_COMPLETE: case CLTR_PHOTO_GRID_STATE_ZOOM_IN: case CLTR_PHOTO_GRID_STATE_ZOOM_OUT: case CLTR_PHOTO_GRID_STATE_ZOOMED_MOVE: @@ -330,7 +379,7 @@ cltr_photo_grid_navigate(CltrPhotoGrid *grid, } if (grid->state != CLTR_PHOTO_GRID_STATE_ZOOMED) - g_timeout_add(FPS_TO_TIMEOUT(ANIM_FPS), + g_timeout_add(FPS_TO_TIMEOUT(grid->anim_fps), cltr_photo_grid_idle_cb, grid); } @@ -343,7 +392,7 @@ cltr_photo_grid_navigate(CltrPhotoGrid *grid, grid->anim_step = 0; zoom = grid->zoom_max; - g_timeout_add(FPS_TO_TIMEOUT(ANIM_FPS), + g_timeout_add(FPS_TO_TIMEOUT(grid->anim_fps), cltr_photo_grid_idle_cb, grid); } @@ -367,7 +416,7 @@ cltr_photo_grid_activate_cell(CltrPhotoGrid *grid) grid->state = CLTR_PHOTO_GRID_STATE_ZOOM_IN; - g_timeout_add(FPS_TO_TIMEOUT(ANIM_FPS), + g_timeout_add(FPS_TO_TIMEOUT(grid->anim_fps), cltr_photo_grid_idle_cb, grid); } else if (grid->state == CLTR_PHOTO_GRID_STATE_ZOOMED) @@ -378,11 +427,12 @@ cltr_photo_grid_activate_cell(CltrPhotoGrid *grid) grid->view_min_x = 0.0; grid->view_min_y = 0.0; /*- (grid->row_offset * grid->cell_height);*/ - g_timeout_add(FPS_TO_TIMEOUT(ANIM_FPS), + g_timeout_add(FPS_TO_TIMEOUT(grid->anim_fps), cltr_photo_grid_idle_cb, grid); } } +#if 0 gpointer cltr_photo_grid_populate(gpointer data) { @@ -426,9 +476,10 @@ cltr_photo_grid_populate(gpointer data) if (pixb) { CltrPhotoGridCell *cell; - gchar buf[24]; + gchar buf[24]; + Pixbuf *tmp_pixb; - cell = cltr_photo_grid_cell_new(grid, pixb, entry); + cell = cltr_photo_grid_cell_new(grid, pixb); g_snprintf(&buf[0], 24, "%i", i); font_draw(font, cell->pixb, buf, 10, 10, &font_col); @@ -437,10 +488,13 @@ cltr_photo_grid_populate(gpointer data) cell->texture = cltr_texture_new(cell->pixb); - g_mutex_unlock(Mutex_GRID); + if (!grid->cell_active) + grid->cell_active = g_list_first(grid->cells_tail); cltr_photo_grid_append_cell(grid, cell); + g_mutex_unlock(Mutex_GRID); + i++; } @@ -451,9 +505,7 @@ cltr_photo_grid_populate(gpointer data) g_mutex_lock(Mutex_GRID); - grid->cell_active = g_list_first(grid->cells_tail); - - grid->state = CLTR_PHOTO_GRID_STATE_LOAD_COMPLETE; + grid->is_populated = TRUE; g_mutex_unlock(Mutex_GRID); @@ -461,6 +513,7 @@ cltr_photo_grid_populate(gpointer data) return NULL; } +#endif static void cltr_photo_grid_update_visual_state(CltrPhotoGrid *grid) @@ -478,9 +531,7 @@ cltr_photo_grid_update_visual_state(CltrPhotoGrid *grid) grid->paint_cell_item = g_list_nth(grid->cells_tail, grid->n_cols * grid->row_offset); - if (grid->state != CLTR_PHOTO_GRID_STATE_BROWSE - && grid->state != CLTR_PHOTO_GRID_STATE_LOADING - && grid->state != CLTR_PHOTO_GRID_STATE_LOAD_COMPLETE) + if (grid->state != CLTR_PHOTO_GRID_STATE_BROWSE) { float scroll_min_y_offset = (float)(row_offset_h); @@ -710,7 +761,7 @@ cltr_photo_grid_paint(CltrWidget *widget) glEnable(GL_TEXTURE_2D); - g_mutex_lock(Mutex_GRID); + g_mutex_lock(grid->mutex); cltr_texture_render_to_gl_quad(cell->texture, -(thumb_w/2), @@ -718,7 +769,7 @@ cltr_photo_grid_paint(CltrWidget *widget) (thumb_w/2), (thumb_h/2)); - g_mutex_unlock(Mutex_GRID); + g_mutex_unlock(grid->mutex); glDisable(GL_TEXTURE_2D); @@ -738,16 +789,19 @@ cltr_photo_grid_paint(CltrWidget *widget) cltr_glu_rounded_rect(-(thumb_w/2)-4, -(thumb_h/2)-4, (thumb_w/2)+4, (thumb_h/2)+ns_border, - thumb_w/40, + thumb_w/30, NULL); - glColor4f(0.1, 0.1, 0.1, 0.5); + /* shadow */ - cltr_glu_rounded_rect(-(thumb_w/2)-4, -(thumb_h/2)-4+1, - (thumb_w/2)+4, (thumb_h/2)+ns_border+1, - thumb_w/40, + glColor4f(0.1, 0.1, 0.1, 0.3); + + cltr_glu_rounded_rect(-(thumb_w/2)-4 + 1, -(thumb_h/2)-4 + 1, + (thumb_w/2)+4 + 1, (thumb_h/2)+ns_border +1, + thumb_w/30, NULL); + glColor4f(1.0, 1.0, 1.0, 1.0); glEnable(GL_TEXTURE_2D); @@ -776,14 +830,6 @@ cltr_photo_grid_paint(CltrWidget *widget) glColor3f(0.6, 0.6, 0.62); glRecti(0, 0, widget->width, widget->height); - g_mutex_lock(Mutex_GRID); - - /* Hack, so final item get painted via threaded load */ - if (grid->state == CLTR_PHOTO_GRID_STATE_LOAD_COMPLETE) - grid->state = CLTR_PHOTO_GRID_STATE_BROWSE; - - g_mutex_unlock(Mutex_GRID); - /* reset */ glDisable(GL_POLYGON_SMOOTH); @@ -795,21 +841,51 @@ static void cltr_photo_grid_show(CltrWidget *widget) { CltrPhotoGrid *grid = CLTR_PHOTO_GRID(widget); - GThread *loader_thread; - grid->state = CLTR_PHOTO_GRID_STATE_LOADING; + /* + GThread *loader_thread; loader_thread = g_thread_create (cltr_photo_grid_populate, (gpointer)grid, TRUE, NULL); + */ - g_timeout_add(FPS_TO_TIMEOUT(20), - cltr_photo_grid_idle_cb, grid); + grid->state = CLTR_PHOTO_GRID_STATE_BROWSE; + + if (!grid->is_populated) + g_timeout_add(FPS_TO_TIMEOUT(20), + cltr_photo_grid_idle_cb, grid); cltr_widget_queue_paint(widget); } +void +cltr_photo_grid_set_fps(CltrPhotoGrid *grid, int fps) +{ + grid->anim_fps = fps; +} + +int +cltr_photo_grid_get_fps(CltrPhotoGrid *grid) +{ + return grid->anim_fps; +} + +void +cltr_photo_grid_set_anim_steps(CltrPhotoGrid *grid, int steps) +{ + grid->anim_n_steps = steps; +} + +int +cltr_photo_grid_get_anim_steps(CltrPhotoGrid *grid) +{ + return grid->anim_n_steps; +} + + + CltrWidget* cltr_photo_grid_new(int width, int height, @@ -836,9 +912,12 @@ cltr_photo_grid_new(int width, grid->cell_width = grid->widget.width / n_cols; grid->cell_height = grid->widget.height / n_rows; - grid->state = CLTR_PHOTO_GRID_STATE_LOADING; + grid->state = CLTR_PHOTO_GRID_STATE_BROWSE; + grid->is_populated = FALSE; - grid->anim_n_steps = 20; /* value needs to be calced dep on rows */ + grid->anim_fps = 50; + + grid->anim_n_steps = 10; /* value needs to be calced dep on rows */ grid->anim_step = 0; /* Default 'browse view' */ @@ -851,7 +930,7 @@ cltr_photo_grid_new(int width, grid->row_offset = 0; - Mutex_GRID = g_mutex_new(); + grid->mutex = g_mutex_new(); return CLTR_WIDGET(grid); } diff --git a/clutter/cltr-photo-grid.h b/clutter/cltr-photo-grid.h index 69c90de68..e26498f6f 100644 --- a/clutter/cltr-photo-grid.h +++ b/clutter/cltr-photo-grid.h @@ -11,8 +11,6 @@ typedef struct CltrPhotoGridCell CltrPhotoGridCell; typedef enum CltrPhotoGridState { - CLTR_PHOTO_GRID_STATE_LOADING , - CLTR_PHOTO_GRID_STATE_LOAD_COMPLETE , CLTR_PHOTO_GRID_STATE_BROWSE , CLTR_PHOTO_GRID_STATE_ZOOM_IN , CLTR_PHOTO_GRID_STATE_ZOOMED , @@ -29,11 +27,28 @@ typedef enum CltrPhotoGridCellState } CltrPhotoGridCellState; +GMutex* +cltr_photo_grid_mutex(CltrPhotoGrid *grid); + +void +cltr_photo_grid_set_populated(CltrPhotoGrid *grid, gboolean populated); CltrPhotoGridCell* cltr_photo_grid_cell_new(CltrPhotoGrid *grid, - Pixbuf *pixb, - const gchar *filename); + Pixbuf *pixb); + +Pixbuf* +cltr_photo_grid_cell_pixbuf(CltrPhotoGridCell *cell); + +CltrPhotoGridCell* +cltr_photo_grid_get_active_cell(CltrPhotoGrid *grid); + +void +cltr_photo_grid_set_active_cell(CltrPhotoGrid *grid, CltrPhotoGridCell *cell); + +CltrPhotoGridCell* +cltr_photo_grid_get_first_cell(CltrPhotoGrid *grid); + void cltr_photo_grid_append_cell(CltrPhotoGrid *grid, diff --git a/clutter/cltr-texture.c b/clutter/cltr-texture.c index 6ff32cb5b..3b5525cc7 100644 --- a/clutter/cltr-texture.c +++ b/clutter/cltr-texture.c @@ -259,7 +259,7 @@ cltr_texture_realize(CltrTexture *texture) Pixbuf *pixtmp; int src_h, src_w; - pixtmp = pixbuf_new(texture->tile_x_size[x], texture->tile_y_size[y]); + src_w = texture->tile_x_size[x]; src_h = texture->tile_y_size[y]; @@ -276,13 +276,21 @@ cltr_texture_realize(CltrTexture *texture) texture->tile_y_waste[y]); */ - pixbuf_copy(texture->pixb, - pixtmp, - texture->tile_x_position[x], - texture->tile_y_position[y], - texture->tile_x_size[x], - texture->tile_y_size[y], - 0,0); + /* Only break the pixbuf up if we have multiple tiles */ + if (texture->n_x_tiles > 1 && texture->n_y_tiles >1) + { + pixtmp = pixbuf_new(texture->tile_x_size[x], + texture->tile_y_size[y]); + + pixbuf_copy(texture->pixb, + pixtmp, + texture->tile_x_position[x], + texture->tile_y_position[y], + texture->tile_x_size[x], + texture->tile_y_size[y], + 0,0); + } + else pixtmp = texture->pixb; glBindTexture(GL_TEXTURE_2D, texture->tiles[i]); @@ -303,7 +311,8 @@ cltr_texture_realize(CltrTexture *texture) CLTR_GLERR(); - pixbuf_unref(pixtmp); + if (pixtmp != texture->pixb) + pixbuf_unref(pixtmp); i++; @@ -332,3 +341,15 @@ cltr_texture_new(Pixbuf *pixb) return texture; } + +Pixbuf* +cltr_texture_get_pixbuf(CltrTexture* texture) +{ + return texture->pixb; +} + +void +cltr_texture_resync_pixbuf(CltrTexture* texture) +{ + cltr_texture_unrealize(texture); +} diff --git a/clutter/cltr-texture.h b/clutter/cltr-texture.h index 833822850..8a8b0846b 100644 --- a/clutter/cltr-texture.h +++ b/clutter/cltr-texture.h @@ -37,4 +37,11 @@ cltr_texture_render_to_gl_quad(CltrTexture *texture, int x2, int y2); +Pixbuf* +cltr_texture_get_pixbuf(CltrTexture* texture); + +void +cltr_texture_resync_pixbuf(CltrTexture* texture); + + #endif diff --git a/clutter/cltr-window.c b/clutter/cltr-window.c index 097f2ddc7..a7c841873 100644 --- a/clutter/cltr-window.c +++ b/clutter/cltr-window.c @@ -149,6 +149,11 @@ cltr_window_set_fullscreen(CltrWindow *win) atom_WINDOW_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *)&atom_WINDOW_STATE_FULLSCREEN, 1); + + /* + XF86VidModeSwitchToMode (GLWin.dpy, GLWin.screen, &GLWin.deskMode); + XF86VidModeSetViewPort (GLWin.dpy, GLWin.screen, 0, 0); + */ } diff --git a/clutter/cltr.h b/clutter/cltr.h index 28cb84b1c..601fd043a 100644 --- a/clutter/cltr.h +++ b/clutter/cltr.h @@ -49,7 +49,8 @@ CltrRect; #include "cltr-events.h" #include "cltr-widget.h" #include "cltr-window.h" - +#include "cltr-overlay.h" +#include "cltr-button.h" #include "cltr-photo-grid.h" #endif diff --git a/clutter/pixbuf.c b/clutter/pixbuf.c index c5b82536b..e825e7782 100644 --- a/clutter/pixbuf.c +++ b/clutter/pixbuf.c @@ -19,6 +19,8 @@ #include "pixbuf.h" #include "util.h" +#define CLTR_CLAMP(x, y) ((x) > (y)) ? (y) : (x); + static int* load_png_file( const char *file, int *width, @@ -672,6 +674,100 @@ pixbuf_scale_down(Pixbuf *pixb, return pixb_scaled; } +Pixbuf* +pixbuf_clone(Pixbuf *pixb) +{ + Pixbuf *clone; + + clone = util_malloc0(sizeof(Pixbuf)); + + clone->width = pixb->width; + clone->height = pixb->height; + clone->bytes_per_pixel = pixb->bytes_per_pixel; + clone->channels = pixb->channels; + clone->bytes_per_line = pixb->bytes_per_line; + clone->data = malloc(pixb->bytes_per_line * pixb->height); + + memcpy(clone->data, pixb->data, pixb->bytes_per_line * pixb->height); + + return clone; +} + +Pixbuf* +pixbuf_convolve(Pixbuf *pixb, + int *kernel, + int kernel_size, + int kernel_divisor) +{ + int padding, x, y, r, g, b, a, l, k; + PixbufPixel pixel; + Pixbuf *clone_pixb; + + padding = ( kernel_size - 1 ) / 2; + clone_pixb = pixbuf_clone(pixb); + + for( y = padding; y < pixb->height - padding; y++ ) + { + for( x = padding; x < pixb->width - padding; x++ ) + { + r = b = g = a = 0; + + for( l = 0; l < kernel_size; l++ ) + { + for( k = 0; k < kernel_size; k++ ) + { + pixbuf_get_pixel(pixb, (x+k-padding), (y+l-padding), &pixel); + + r += pixel.r * kernel[k + l * kernel_size]; + g += pixel.g * kernel[k + l * kernel_size]; + b += pixel.b * kernel[k + l * kernel_size]; + a += pixel.a * kernel[k + l * kernel_size]; + } + } + + r = CLTR_CLAMP( r / kernel_divisor, 0xff); + g = CLTR_CLAMP( g / kernel_divisor, 0xff); + b = CLTR_CLAMP( b / kernel_divisor, 0xff); + a = CLTR_CLAMP( a / kernel_divisor, 0xff); + + pixel_set_vals(&pixel, r, g, b, a); + + pixbuf_set_pixel(clone_pixb, x, y, &pixel); + + } + } + + return clone_pixb; +} + +Pixbuf* +pixbuf_blur(Pixbuf *pixb) +{ + /* + int kernel[] = { 1, 1, 1, + 1, 0, 1, + 1, 1, 1 }; + */ + + int kernel[] = { 1, 1, 1, + 1, 1, 1, + 1, 1, 1 }; + + + return pixbuf_convolve( pixb, kernel, 3, 9 ); +} + +Pixbuf* +pixbuf_sharpen(Pixbuf *pixb) +{ + int kernel[] = {-1, -1, -1, + -1, 9, -1, + -1, -1, -1 }; + + return pixbuf_convolve( pixb, kernel, 3, 1 ); +} + + #if 0 /* @@ -927,4 +1023,89 @@ MagickExport Image *GaussianBlurImage(Image *image,const double radius, return(blur_image); } +/* GPE-gallery convolve code */ + +static void +image_convolve( GdkPixbuf *pixbuf, + int *mask, + int mask_size, + int mask_divisor ) { + + int x, y, k, l, b, rowstride, width, height, channels, padding, new_value; + int* temp_pixel; + guchar *temp_image, *image; + + rowstride = gdk_pixbuf_get_rowstride( GDK_PIXBUF( pixbuf ) ); + channels = gdk_pixbuf_get_n_channels( GDK_PIXBUF( pixbuf ) ); + + width = gdk_pixbuf_get_width( GDK_PIXBUF( pixbuf ) ); + height = gdk_pixbuf_get_height( GDK_PIXBUF( pixbuf ) ); + + // fprintf( stderr, "Rowstride: %d, width: %d, height: %d, channels: %d\n", rowstride, width, height, channels ); + + + padding = ( mask_size - 1 ) / 2; + + image = gdk_pixbuf_get_pixels( GDK_PIXBUF( pixbuf ) ); + temp_image = (guchar*) malloc( width * height * channels * sizeof( guchar ) ); + memcpy( temp_image, image, width * height * channels * sizeof( guchar ) ); + temp_pixel =(int*) malloc( channels * sizeof( int ) ); + for( y = padding; y < height - padding; y++ ) { + + for( x = padding; x < width - padding; x++ ) { + + for( b = 0; b < channels; b++ ) + temp_pixel[b] = 0; + + for( l = 0; l < mask_size; l++ ) { + + for( k = 0; k < mask_size; k++ ) { + + for( b = 0; b < channels; b++ ) + temp_pixel[b] += temp_image[ ( y + l - padding ) * rowstride + + ( x + k - padding ) * channels + b ] * mask[ k + l * + mask_size ]; + + } + + } + + for( b = 0; b < channels; b++ ) { + + new_value = temp_pixel[b] / mask_divisor; + image[ y * rowstride + x * channels + b ] = ( new_value > 255 ? 255 + : new_value < 0 ? 0 : new_value ); + + } + + } + + } + + + free( temp_image ); + free( temp_pixel ); + +} + +void image_tools_blur( GdkPixbuf* pixbuf ) { + + int mask[] = { 1, 1, 1, + 1, 1, 1, + 1, 1, 1 }; + + image_convolve( pixbuf, mask, 3, 9 ); + +} + +void image_tools_sharpen( GdkPixbuf* pixbuf ) { + + int mask[] = {-1, -1, -1, + -1, 9, -1, + -1, -1, -1 }; + + image_convolve( pixbuf, mask, 3, 1 ); + +} + #endif diff --git a/clutter/pixbuf.h b/clutter/pixbuf.h index 85069ed6c..155d0b953 100644 --- a/clutter/pixbuf.h +++ b/clutter/pixbuf.h @@ -86,4 +86,20 @@ pixbuf_scale_down(Pixbuf *pixb, int new_width, int new_height); +Pixbuf* +pixbuf_clone(Pixbuf *pixb); + +Pixbuf* +pixbuf_convolve(Pixbuf *pixb, + int *kernel, + int kernel_size, + int kernel_divisor) ; + +Pixbuf* +pixbuf_blur(Pixbuf *pixb); + +Pixbuf* +pixbuf_sharpen(Pixbuf *pixb); + + #endif diff --git a/configure.ac b/configure.ac index 756e827d0..e1e67427f 100644 --- a/configure.ac +++ b/configure.ac @@ -66,9 +66,13 @@ PKG_CHECK_MODULES(CLTR, pangoft2 pango glib-2.0 gthread-2.0) dnl ----- Gstreamer --------------------------------------------------------- -pkg_modules="gstreamer-0.8 gstreamer-interfaces-0.8 gthread-2.0" +pkg_modules="gstreamer-0.8 gstreamer-interfaces-0.8 gthread-2.0 gstreamer-play-0.8 gstreamer-gconf-0.8" PKG_CHECK_MODULES(GST, [$pkg_modules]) +dnl ----- Gconf ------------------------------------------------------------- + +PKG_CHECK_MODULES(GCONF, gconf-2.0, HAVE_GCONF="yes", HAVE_GCONF="no") + dnl ------ Check for PNG --------------------------------------------------- AC_MSG_CHECKING(for libpng12) @@ -110,14 +114,17 @@ AC_SUBST(GCC_FLAGS) AC_SUBST(GST_CFLAGS) AC_SUBST(GST_LIBS) +AC_SUBST(GCONF_CFLAGS) +AC_SUBST(GCONF_LIBS) + CLTR_CFLAGS="$GLX_CLAGS $CLTR_CFLAGS" CLTR_LIBS="$GLX_LIBS $PNG_LIBS $JPEG_LIBS $CLTR_LIBS" AC_SUBST(CLTR_CFLAGS) AC_SUBST(CLTR_LIBS) - AC_OUTPUT([Makefile clutter/Makefile examples/Makefile +gst/Makefile ]) diff --git a/examples/Makefile.am b/examples/Makefile.am index 1f2290940..100271882 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,7 +1,23 @@ -noinst_PROGRAMS = scratch +noinst_PROGRAMS = scratch photos player scratch_SOURCES = scratch.c scratch_CFLAGS = $(CLTR_CFLAGS) scratch_LDFLAGS = \ $(CLTR_LIBS) \ $(top_builddir)/clutter/libclutter.la + +photos_SOURCES = photos.c +photos_CFLAGS = $(CLTR_CFLAGS) +photos_LDFLAGS = \ + $(CLTR_LIBS) \ + $(top_builddir)/clutter/libclutter.la + +player_SOURCES = player.c +player_CFLAGS = $(CLTR_CFLAGS) $(GST_CFLAGS) $(GCONF_CFLAGS) +player_LDFLAGS = \ + $(CLTR_LIBS) \ + $(GST_LIBS) \ + $(GCONF_LIBS) \ + $(top_builddir)/clutter/libclutter.la + + diff --git a/examples/photos.c b/examples/photos.c new file mode 100644 index 000000000..d8615dc84 --- /dev/null +++ b/examples/photos.c @@ -0,0 +1,157 @@ +#include + +gchar *ImgPath = NULL; + +int +usage(char *progname) +{ + fprintf(stderr, "Usage ... check source for now\n"); + exit(-1); +} + +gpointer +photo_grid_populate(gpointer data) +{ + CltrPhotoGrid *grid = (CltrPhotoGrid *)data; + GDir *dir; + GError *error; + const gchar *entry = NULL; + gchar *fullpath = NULL; + int n_pixb = 0, i =0; + ClutterFont *font = NULL; + PixbufPixel font_col = { 255, 255, 255, 255 }; + + font = font_new("Sans Bold 96"); + + if ((dir = g_dir_open (ImgPath, 0, &error)) == NULL) + { + /* handle this much better */ + fprintf(stderr, "failed to open '%s'\n", ImgPath); + return NULL; + } + + while ((entry = g_dir_read_name (dir)) != NULL) + { + if (!strcasecmp(&entry[strlen(entry)-4], ".png") + || !strcasecmp(&entry[strlen(entry)-4], ".jpg") + || !strcasecmp(&entry[strlen(entry)-5], ".jpeg")) + n_pixb++; + } + + g_dir_rewind (dir); + + while ((entry = g_dir_read_name (dir)) != NULL) + { + Pixbuf *pixb = NULL; + fullpath = g_strconcat(ImgPath, "/", entry, NULL); + + pixb = pixbuf_new_from_file(fullpath); + + if (pixb) + { + CltrPhotoGridCell *cell; + gchar buf[24]; + Pixbuf *tmp_pixb; + + cell = cltr_photo_grid_cell_new(grid, pixb); + + g_snprintf(&buf[0], 24, "%i", i); + font_draw(font, cltr_photo_grid_cell_pixbuf(cell), + buf, 10, 10, &font_col); + + g_mutex_lock(cltr_photo_grid_mutex(grid)); + + if (!cltr_photo_grid_get_active_cell(grid)) + cltr_photo_grid_set_active_cell(grid, + cltr_photo_grid_get_first_cell(grid)); + + cltr_photo_grid_append_cell(grid, cell); + + g_mutex_unlock(cltr_photo_grid_mutex(grid)); + + i++; + } + + g_free(fullpath); + } + + g_dir_close (dir); + + g_mutex_lock(cltr_photo_grid_mutex(grid)); + + cltr_photo_grid_set_populated(grid, TRUE); + + g_mutex_unlock(cltr_photo_grid_mutex(grid)); + + cltr_widget_queue_paint(CLTR_WIDGET(grid)); + + return NULL; +} + +int +main(int argc, char **argv) +{ + CltrWidget *win = NULL, *grid = NULL; + gchar *img_path = NULL; + gboolean want_fullscreen = FALSE; + gint i, cols = 3; + + GThread *loader_thread; + + cltr_init(&argc, &argv); + + if (argc < 2) + usage(argv[0]); + + for (i = 1; i < argc; i++) + { + if (!strcmp ("--image-path", argv[i]) || !strcmp ("-i", argv[i])) + { + if (++i>=argc) usage (argv[0]); + ImgPath = argv[i]; + continue; + } + if (!strcmp ("--cols", argv[i]) || !strcmp ("-c", argv[i])) + { + if (++i>=argc) usage (argv[0]); + cols = atoi(argv[i]); + continue; + } + if (!strcmp ("-fs", argv[i]) || !strcmp ("--fullscreen", argv[i])) + { + want_fullscreen = TRUE; + continue; + } + if (!strcmp("--help", argv[i]) || !strcmp("-h", argv[i])) + { + usage(argv[0]); + } + + usage(argv[0]); + } + + win = cltr_window_new(800, 600); + + if (want_fullscreen) + cltr_window_set_fullscreen(CLTR_WINDOW(win)); + + grid = cltr_photo_grid_new(800, 600, cols, cols, ImgPath); + + cltr_window_focus_widget(CLTR_WINDOW(win), grid); + + cltr_widget_add_child(win, grid, 0, 0); + + cltr_widget_show_all(win); + + /* grid->state = CLTR_PHOTO_GRID_STATE_BROWSE; */ + + loader_thread = g_thread_create (photo_grid_populate, + (gpointer)grid, + TRUE, + NULL); + + + cltr_main_loop(); + + return 0; +} diff --git a/examples/player.c b/examples/player.c new file mode 100644 index 000000000..9cdd96738 --- /dev/null +++ b/examples/player.c @@ -0,0 +1,196 @@ +/* GStreamer + * Copyright (C) 2003 Julien Moutte + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +#include +#include + +static GMainLoop *loop = NULL; +static gint64 length = 0; + +static void +print_tag (const GstTagList * list, const gchar * tag, gpointer unused) +{ + gint i, count; + + count = gst_tag_list_get_tag_size (list, tag); + + for (i = 0; i < count; i++) { + gchar *str; + + if (gst_tag_get_type (tag) == G_TYPE_STRING) { + if (!gst_tag_list_get_string_index (list, tag, i, &str)) + g_assert_not_reached (); + } else { + str = + g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i)); + } + + if (i == 0) { + g_print ("%15s: %s\n", gst_tag_get_nick (tag), str); + } else { + g_print (" : %s\n", str); + } + + g_free (str); + } +} + +static void +got_found_tag (GstPlay * play, GstElement * source, GstTagList * tag_list) +{ + gst_tag_list_foreach (tag_list, print_tag, NULL); +} + +static void +got_time_tick (GstPlay * play, gint64 time_nanos) +{ + g_print ("time tick %f\n", time_nanos / (float) GST_SECOND); +} + +static void +got_stream_length (GstPlay * play, gint64 length_nanos) +{ + g_print ("got length %" G_GUINT64_FORMAT "\n", length_nanos); + length = length_nanos; +} + +static void +got_video_size (GstPlay * play, gint width, gint height) +{ + g_print ("got video size %d, %d\n", width, height); +} + +static void +got_eos (GstPlay * play) +{ + g_print ("End Of Stream\n"); + g_main_loop_quit (loop); +} + +static gboolean +seek_timer (GstPlay * play) +{ + gst_play_seek_to_time (play, length / 2); + return FALSE; +} + +int +main (int argc, char *argv[]) +{ + GstPlay *play; + GstElement *data_src, *video_sink, *audio_sink, *vis_element; + GError *error = NULL; + + CltrWidget *win; + + /* Initing GStreamer library */ + gst_init (&argc, &argv); + cltr_init (&argc, &argv); + + if (argc != 2) { + g_print ("usage: %s