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

« back to all changes in this revision

Viewing changes to backend/dvi/cairo-device.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:
202
202
                        int    density)
203
203
{
204
204
        double  frac;
205
 
        GdkColor color, color_fg, color_bg;
 
205
        GdkColor color, color_fg;
206
206
        int     i, n;
207
 
 
208
 
        color_bg.red = (bg >> 16) & 0xff;
209
 
        color_bg.green = (bg >> 8) & 0xff;
210
 
        color_bg.blue = (bg >> 0) & 0xff;
 
207
        unsigned int alpha;
211
208
 
212
209
        color_fg.red = (fg >> 16) & 0xff;
213
210
        color_fg.green = (fg >> 8) & 0xff;
219
216
                        pow ((double)i / n, 1 / gamma) :
220
217
                        1 - pow ((double)(n - i) / n, -gamma);
221
218
                
222
 
                color.red = frac * ((double)color_fg.red - color_bg.red) + color_bg.red;
223
 
                color.green = frac * ((double)color_fg.green - color_bg.green) + color_bg.green;
224
 
                color.blue = frac * ((double)color_fg.blue - color_bg.blue) + color_bg.blue;
225
 
                
226
 
                pixels[i] = (color.red << 16) + (color.green << 8) + color.blue + 0xff000000;
 
219
                color.red = frac * color_fg.red;
 
220
                color.green = frac * color_fg.green;
 
221
                color.blue = frac * color_fg.blue;
 
222
                alpha = frac * 0xFF;
 
223
 
 
224
                pixels[i] = (alpha << 24) + (color.red << 16) + (color.green << 8) + color.blue;
227
225
        }
228
226
 
229
227
        return npixels;
235
233
                        Uint  height,
236
234
                        Uint  bpp)
237
235
{
238
 
        return cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
 
236
        return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
239
237
}
240
238
 
241
239
static void
256
254
        rowstride = cairo_image_surface_get_stride (surface);
257
255
        p = (guint32*) (cairo_image_surface_get_data (surface) + y * rowstride + x * 4);
258
256
 
 
257
        /* per cairo docs, must flush before modifying outside of cairo */
 
258
        cairo_surface_flush(surface);
259
259
        *p = color;
260
260
}
261
261
 
262
262
static void
 
263
dvi_cairo_image_done (void *ptr)
 
264
{
 
265
        cairo_surface_mark_dirty((cairo_surface_t *)ptr);
 
266
}
 
267
 
 
268
static void
263
269
dvi_cairo_set_color (void *device_data, Ulong fg, Ulong bg)
264
270
{
265
271
        DviCairoDevice *cairo_device = (DviCairoDevice *) device_data;
280
286
        device->create_image = dvi_cairo_create_image;
281
287
        device->free_image = dvi_cairo_free_image;
282
288
        device->put_pixel = dvi_cairo_put_pixel;
 
289
        device->image_done = dvi_cairo_image_done;
283
290
        device->set_color = dvi_cairo_set_color;
284
291
#ifdef HAVE_SPECTRE
285
292
        device->draw_ps = dvi_cairo_draw_ps;
319
326
        gint             page_width;
320
327
        gint             page_height;
321
328
        cairo_surface_t *surface;
322
 
        guchar          *pixels;
323
 
        gint             rowstride;
324
 
        static const cairo_user_data_key_t key;
325
329
 
326
330
        cairo_device = (DviCairoDevice *) dvi->device.device_data;
327
331
 
331
335
        page_width = dvi->dvi_page_w * dvi->params.conv + 2 * cairo_device->xmargin;
332
336
        page_height = dvi->dvi_page_h * dvi->params.vconv + 2 * cairo_device->ymargin;
333
337
 
334
 
        rowstride = page_width * 4;
335
 
        pixels = (guchar *) g_malloc (page_height * rowstride);
336
 
        memset (pixels, 0xff, page_height * rowstride);
337
 
 
338
 
        surface = cairo_image_surface_create_for_data (pixels,
339
 
                                                       CAIRO_FORMAT_RGB24,
340
 
                                                       page_width, page_height,
341
 
                                                       rowstride);
342
 
        cairo_surface_set_user_data (surface, &key,
343
 
                                     pixels, (cairo_destroy_func_t)g_free);
 
338
        surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
 
339
                                              page_width, page_height);
344
340
 
345
341
        cairo_device->cr = cairo_create (surface);
346
 
        cairo_surface_destroy (surface);
 
342
        cairo_surface_destroy (surface);
 
343
 
 
344
        cairo_set_source_rgb (cairo_device->cr, 1., 1., 1.);
 
345
        cairo_paint (cairo_device->cr);
347
346
 
348
347
        mdvi_dopage (dvi, dvi->currpage);
349
348
}