~ubuntu-branches/ubuntu/oneiric/evince/oneiric-updates

« back to all changes in this revision

Viewing changes to libdocument/ev-document-misc.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya, Josselin Mouette, Rodrigo Moya
  • Date: 2011-05-19 12:12:42 UTC
  • mfrom: (1.1.65 upstream) (1.3.6 experimental)
  • Revision ID: james.westby@ubuntu.com-20110519121242-967hbn2nh2hunp4y
Tags: 3.0.0-4ubuntu1
[ Josselin Mouette ]
* bug-presubj: please document where to report rendering bugs.
* evince.mime: dropped. We have desktop files to handle MIME 
  associations, no need to maintain an alternate system by hand.
  Closes: #619564, #627027, #551734, #581441.

[ Rodrigo Moya ]
* Rebase from Debian and GNOME3 PPA (thanks to Rico Tzschichholz).
  Remaining Ubuntu changes:
* debian/apparmor-profile:
* debian/apparmor-profile.abstraction:
* debian/evince.apport:
* debian/evince-common.dirs:
* debian/evince-common.postinst:
* debian/evince-common.postrm:
  - Add apparmor profile
* debian/control:
  - Build-Depend on debhelper (>= 7.4.20ubuntu5), gnome-common,
    hardening-includes and liblaunchpad-integration-3.0-dev
  - Standards-Version is 3.9.1
  - Depend on apparmor
* debian/rules:
  - Include hardening.make
  - Add rule to install apparmor files
* debian/watch:
  - Watch unstable series
* debian/patches/01_lpi.patch:
  - Launchpad integration patch
* debian/patches/04_gold.patch:
  - Link against libz
* debian/patches/05_library-path.patch:
  - Fix library path for g-ir-scanner

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
        }
57
57
 
58
58
        /* make sure no one is passing us garbage */
59
 
        g_assert (width_r >= 0 && height_r >= 0);
 
59
        g_return_val_if_fail (width_r >= 0 && height_r >= 0, NULL);
60
60
 
61
61
        retval = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
62
62
                                 TRUE, 8,
140
140
                                 gboolean      highlight,
141
141
                                 gboolean      inverted_colors)
142
142
{
143
 
        GtkStyle    *style = gtk_widget_get_style (widget);
144
 
        GtkStateType state = gtk_widget_get_state (widget);
145
 
 
146
 
        gdk_cairo_set_source_color (cr, highlight ? &style->text[state] : &style->dark[state]);
 
143
        GtkStyleContext *context = gtk_widget_get_style_context (widget);
 
144
        GtkStateFlags state = gtk_widget_get_state_flags (widget);
 
145
        GdkRGBA fg, bg, shade_bg;
 
146
        GtkSymbolicColor *c1, *c2;
 
147
 
 
148
        gtk_style_context_get_background_color (context, state, &bg);
 
149
        gtk_style_context_get_color (context, state, &fg);
 
150
 
 
151
        // FIXME: should we cache the shade_bg?
 
152
        c1 = gtk_symbolic_color_new_literal (&bg);
 
153
        c2 = gtk_symbolic_color_new_shade (c1, 0.7);
 
154
        gtk_symbolic_color_resolve (c2, NULL, &shade_bg);
 
155
        gtk_symbolic_color_unref (c1);
 
156
        gtk_symbolic_color_unref (c2);
 
157
 
 
158
        gdk_cairo_set_source_rgba (cr, highlight ? &fg : &shade_bg);
147
159
        gdk_cairo_rectangle (cr, area);
148
160
        cairo_fill (cr);
149
161
 
158
170
                         area->height - (border->top + border->bottom));
159
171
        cairo_fill (cr);
160
172
 
161
 
        gdk_cairo_set_source_color (cr, &style->mid[state]);
 
173
        gdk_cairo_set_source_rgba (cr, &bg);
162
174
        cairo_rectangle (cr,
163
175
                         area->x,
164
176
                         area->y + area->height - (border->bottom - border->top),
180
192
        cairo_surface_t *surface;
181
193
        cairo_t         *cr;
182
194
 
 
195
        g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
 
196
 
183
197
        surface = cairo_image_surface_create (gdk_pixbuf_get_has_alpha (pixbuf) ?
184
198
                                              CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24,
185
199
                                              gdk_pixbuf_get_width (pixbuf),
195
209
GdkPixbuf *
196
210
ev_document_misc_pixbuf_from_surface (cairo_surface_t *surface)
197
211
{
198
 
        GdkPixbuf       *pixbuf;
199
 
        cairo_surface_t *image;
200
 
        cairo_t         *cr;
201
 
        gboolean         has_alpha;
202
 
        gint             width, height;
203
 
        cairo_format_t   surface_format;
204
 
        gint             pixbuf_n_channels;
205
 
        gint             pixbuf_rowstride;
206
 
        guchar          *pixbuf_pixels;
207
 
        gint             x, y;
208
 
 
209
 
        width = cairo_image_surface_get_width (surface);
210
 
        height = cairo_image_surface_get_height (surface);
211
 
        
212
 
        surface_format = cairo_image_surface_get_format (surface);
213
 
        has_alpha = (surface_format == CAIRO_FORMAT_ARGB32);
214
 
 
215
 
        pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
216
 
                                 TRUE, 8,
217
 
                                 width, height);
218
 
        pixbuf_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
219
 
        pixbuf_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
220
 
        pixbuf_pixels = gdk_pixbuf_get_pixels (pixbuf);
221
 
 
222
 
        image = cairo_image_surface_create_for_data (pixbuf_pixels,
223
 
                                                     surface_format,
224
 
                                                     width, height,
225
 
                                                     pixbuf_rowstride);
226
 
        cr = cairo_create (image);
227
 
        cairo_set_source_surface (cr, surface, 0, 0);
228
 
 
229
 
        if (has_alpha)
230
 
                cairo_mask_surface (cr, surface, 0, 0);
231
 
        else
232
 
                cairo_paint (cr);
233
 
 
234
 
        cairo_destroy (cr);
235
 
        cairo_surface_destroy (image);
236
 
 
237
 
        for (y = 0; y < height; y++) {
238
 
                guchar *p = pixbuf_pixels + y * pixbuf_rowstride;
239
 
 
240
 
                for (x = 0; x < width; x++) {
241
 
                        guchar tmp;
242
 
                        
243
 
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
244
 
                        tmp = p[0];
245
 
                        p[0] = p[2];
246
 
                        p[2] = tmp;
247
 
                        p[3] = (has_alpha) ? p[3] : 0xff;
248
 
#else
249
 
                        tmp = p[0];
250
 
                        p[0] = p[1];
251
 
                        p[1] = p[2];
252
 
                        p[2] = p[3];
253
 
                        p[3] = (has_alpha) ? tmp : 0xff;
254
 
#endif                  
255
 
                        p += pixbuf_n_channels;
256
 
                }
257
 
        }
258
 
 
259
 
        return pixbuf;
 
212
        g_return_val_if_fail (surface, NULL);   
 
213
 
 
214
        return gdk_pixbuf_get_from_surface (surface,
 
215
                                            0, 0,
 
216
                                            cairo_image_surface_get_width (surface),
 
217
                                            cairo_image_surface_get_height (surface));
260
218
}
261
219
 
262
220
cairo_surface_t *