~ubuntu-branches/ubuntu/quantal/imagination/quantal

« back to all changes in this revision

Viewing changes to transitions/bar_wipe.c

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2009-11-06 14:29:06 UTC
  • mfrom: (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20091106142906-4g7wf3el6p5v9son
Tags: 2.0-1ubuntu1
* Merge from debian testing, Ubuntu remaining changes:
  - Move *-extra-* packages from Suggests to Recommends, as upstream's per
    request.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *
18
18
 */
19
19
 
20
 
#include "export_to_ppm.h"
21
 
#include <gdk/gdk.h>
 
20
#include <cairo.h>
 
21
#include <glib.h>
22
22
 
23
23
/* Local functions declarations */
24
24
static void
25
 
transition_render( GdkDrawable *window,
26
 
                                   GdkPixbuf   *image_from,
27
 
                                   GdkPixbuf   *image_to,
28
 
                                   gdouble      progress,
29
 
                                   gint         file_desc,
30
 
                                   gint         direction );
 
25
transition_render( cairo_t         *cr,
 
26
                                   cairo_surface_t *image_from,
 
27
                                   cairo_surface_t *image_to,
 
28
                                   gdouble          progress,
 
29
                                   gint             direction );
31
30
 
32
31
/* Plug-in API */
33
32
void
55
54
}
56
55
 
57
56
void
58
 
img_left( GdkDrawable *window,
59
 
                  GdkPixbuf   *image_from, 
60
 
                  GdkPixbuf   *image_to,
61
 
                  gdouble      progress,
62
 
                  gint         file_desc )
63
 
{
64
 
        transition_render( window, image_from, image_to, progress, file_desc, 1 );
65
 
}
66
 
 
67
 
void
68
 
img_top( GdkDrawable *window,
69
 
                 GdkPixbuf   *image_from, 
70
 
                 GdkPixbuf   *image_to,
71
 
                 gdouble      progress,
72
 
                 gint         file_desc )
73
 
{
74
 
        transition_render( window, image_from, image_to, progress, file_desc, 2 );
75
 
}
76
 
 
77
 
void
78
 
img_right( GdkDrawable *window,
79
 
                   GdkPixbuf   *image_from, 
80
 
                   GdkPixbuf   *image_to,
81
 
                   gdouble      progress,
82
 
                   gint         file_desc )
83
 
{
84
 
        transition_render( window, image_from, image_to, progress, file_desc, 3 );
85
 
}
86
 
 
87
 
void
88
 
img_bottom( GdkDrawable *window,
89
 
                        GdkPixbuf   *image_from, 
90
 
                        GdkPixbuf   *image_to,
91
 
                        gdouble      progress,
92
 
                        gint         file_desc )
93
 
{
94
 
        transition_render( window, image_from, image_to, progress, file_desc, 4 );
 
57
img_left( cairo_t         *cr,
 
58
                  cairo_surface_t *image_from,
 
59
                  cairo_surface_t *image_to,
 
60
                  gdouble          progress )
 
61
{
 
62
        transition_render( cr, image_from, image_to, progress, 1 );
 
63
}
 
64
 
 
65
void
 
66
img_top( cairo_t         *cr,
 
67
                 cairo_surface_t *image_from,
 
68
                 cairo_surface_t *image_to,
 
69
                 gdouble          progress )
 
70
{
 
71
        transition_render( cr, image_from, image_to, progress, 2 );
 
72
}
 
73
 
 
74
void
 
75
img_right( cairo_t         *cr,
 
76
                   cairo_surface_t *image_from,
 
77
                   cairo_surface_t *image_to,
 
78
                   gdouble          progress )
 
79
{
 
80
        transition_render( cr, image_from, image_to, progress, 3 );
 
81
}
 
82
 
 
83
void
 
84
img_bottom( cairo_t         *cr,
 
85
                        cairo_surface_t *image_from,
 
86
                        cairo_surface_t *image_to,
 
87
                        gdouble          progress )
 
88
{
 
89
        transition_render( cr, image_from, image_to, progress, 4 );
95
90
}
96
91
 
97
92
/* Local functions definitions */
98
93
static void
99
 
transition_render( GdkDrawable *window,
100
 
                                   GdkPixbuf   *image_from,
101
 
                                   GdkPixbuf   *image_to,
102
 
                                   gdouble      progress,
103
 
                                   gint         file_desc,
104
 
                                   gint         direction )
 
94
transition_render( cairo_t         *cr,
 
95
                                   cairo_surface_t *image_from,
 
96
                                   cairo_surface_t *image_to,
 
97
                                   gdouble          progress,
 
98
                                   gint             direction )
105
99
{
106
 
        cairo_t         *cr;
107
 
        cairo_surface_t *surface;
108
 
        gint             width, height;
109
 
 
110
 
        gdk_drawable_get_size( window, &width, &height );
111
 
 
112
 
        if( file_desc < 0 )
113
 
        {
114
 
                cr = gdk_cairo_create( window );
115
 
        }
116
 
        else
117
 
        {
118
 
                surface = cairo_image_surface_create( CAIRO_FORMAT_RGB24,
119
 
                                                                                          width, height );
120
 
                cr = cairo_create( surface );
121
 
        }
122
 
 
123
 
        gdk_cairo_set_source_pixbuf( cr, image_from, 0, 0 );
 
100
        gint width, height;
 
101
 
 
102
        width  = cairo_image_surface_get_width( image_from );
 
103
        height = cairo_image_surface_get_height( image_from );
 
104
 
 
105
        cairo_set_source_surface( cr, image_from, 0, 0 );
124
106
        cairo_paint( cr );
125
107
 
126
 
        gdk_cairo_set_source_pixbuf( cr, image_to, 0, 0 );
 
108
        cairo_set_source_surface( cr, image_to, 0, 0 );
127
109
 
128
110
        switch( direction )
129
111
        {
140
122
                        cairo_rectangle( cr, 0, height * ( 1 - progress ), width, height );
141
123
                        break;
142
124
        }
143
 
 
144
 
        cairo_clip(cr);
145
 
        cairo_paint(cr);
146
 
        cairo_destroy(cr);
147
 
 
148
 
        if(file_desc < 0)
149
 
                return;
150
 
 
151
 
        img_export_cairo_to_ppm(surface, file_desc);
152
 
        cairo_surface_destroy(surface);
 
125
        cairo_fill( cr );
153
126
}