gfx/cairo/win32-transparent-surface.patch

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
michael@0 2 --- a/gfx/cairo/cairo/src/cairo-win32-surface.c
michael@0 3 +++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
michael@0 4 @@ -1709,40 +1709,23 @@ _cairo_win32_surface_show_glyphs (void
michael@0 5 }
michael@0 6 #else
michael@0 7 return CAIRO_INT_STATUS_UNSUPPORTED;
michael@0 8 #endif
michael@0 9 }
michael@0 10
michael@0 11 #undef STACK_GLYPH_SIZE
michael@0 12
michael@0 13 -/**
michael@0 14 - * cairo_win32_surface_create:
michael@0 15 - * @hdc: the DC to create a surface for
michael@0 16 - *
michael@0 17 - * Creates a cairo surface that targets the given DC. The DC will be
michael@0 18 - * queried for its initial clip extents, and this will be used as the
michael@0 19 - * size of the cairo surface. The resulting surface will always be of
michael@0 20 - * format %CAIRO_FORMAT_RGB24; should you need another surface format,
michael@0 21 - * you will need to create one through
michael@0 22 - * cairo_win32_surface_create_with_dib().
michael@0 23 - *
michael@0 24 - * Return value: the newly created surface
michael@0 25 - **/
michael@0 26 -cairo_surface_t *
michael@0 27 -cairo_win32_surface_create (HDC hdc)
michael@0 28 +static cairo_surface_t *
michael@0 29 +cairo_win32_surface_create_internal (HDC hdc, cairo_format_t format)
michael@0 30 {
michael@0 31 cairo_win32_surface_t *surface;
michael@0 32
michael@0 33 - cairo_format_t format;
michael@0 34 RECT rect;
michael@0 35
michael@0 36 - /* Assume that everything coming in as a HDC is RGB24 */
michael@0 37 - format = CAIRO_FORMAT_RGB24;
michael@0 38 -
michael@0 39 surface = malloc (sizeof (cairo_win32_surface_t));
michael@0 40 if (surface == NULL)
michael@0 41 return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
michael@0 42
michael@0 43 if (_cairo_win32_save_initial_clip (hdc, surface) != CAIRO_STATUS_SUCCESS) {
michael@0 44 free (surface);
michael@0 45 return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
michael@0 46 }
michael@0 47 @@ -1765,17 +1748,58 @@ cairo_win32_surface_create (HDC hdc)
michael@0 48 surface->extents.width = rect.right - rect.left;
michael@0 49 surface->extents.height = rect.bottom - rect.top;
michael@0 50
michael@0 51 surface->flags = _cairo_win32_flags_for_dc (surface->dc);
michael@0 52
michael@0 53 _cairo_surface_init (&surface->base, &cairo_win32_surface_backend,
michael@0 54 _cairo_content_from_format (format));
michael@0 55
michael@0 56 - return (cairo_surface_t *)surface;
michael@0 57 + return &surface->base;
michael@0 58 +}
michael@0 59 +
michael@0 60 +/**
michael@0 61 + * cairo_win32_surface_create:
michael@0 62 + * @hdc: the DC to create a surface for
michael@0 63 + *
michael@0 64 + * Creates a cairo surface that targets the given DC. The DC will be
michael@0 65 + * queried for its initial clip extents, and this will be used as the
michael@0 66 + * size of the cairo surface. The resulting surface will always be of
michael@0 67 + * format %CAIRO_FORMAT_RGB24; should you need another surface format,
michael@0 68 + * you will need to create one through
michael@0 69 + * cairo_win32_surface_create_with_dib() or call
michael@0 70 + * cairo_win32_surface_create_with_alpha.
michael@0 71 + *
michael@0 72 + * Return value: the newly created surface
michael@0 73 + **/
michael@0 74 +cairo_surface_t *
michael@0 75 +cairo_win32_surface_create (HDC hdc)
michael@0 76 +{
michael@0 77 + /* Assume everything comes in as RGB24 */
michael@0 78 + return cairo_win32_surface_create_internal(hdc, CAIRO_FORMAT_RGB24);
michael@0 79 +}
michael@0 80 +
michael@0 81 +/**
michael@0 82 + * cairo_win32_surface_create_with_alpha:
michael@0 83 + * @hdc: the DC to create a surface for
michael@0 84 + *
michael@0 85 + * Creates a cairo surface that targets the given DC. The DC will be
michael@0 86 + * queried for its initial clip extents, and this will be used as the
michael@0 87 + * size of the cairo surface. The resulting surface will always be of
michael@0 88 + * format %CAIRO_FORMAT_ARGB32; this format is used when drawing into
michael@0 89 + * transparent windows.
michael@0 90 + *
michael@0 91 + * Return value: the newly created surface
michael@0 92 + *
michael@0 93 + * Since: 1.10
michael@0 94 + **/
michael@0 95 +cairo_surface_t *
michael@0 96 +cairo_win32_surface_create_with_alpha (HDC hdc)
michael@0 97 +{
michael@0 98 + return cairo_win32_surface_create_internal(hdc, CAIRO_FORMAT_ARGB32);
michael@0 99 }
michael@0 100
michael@0 101 /**
michael@0 102 * cairo_win32_surface_create_with_dib:
michael@0 103 * @format: format of pixels in the surface to create
michael@0 104 * @width: width of the surface, in pixels
michael@0 105 * @height: height of the surface, in pixels
michael@0 106 *
michael@0 107 diff --git a/gfx/cairo/cairo/src/cairo-win32.h b/gfx/cairo/cairo/src/cairo-win32.h
michael@0 108 --- a/gfx/cairo/cairo/src/cairo-win32.h
michael@0 109 +++ b/gfx/cairo/cairo/src/cairo-win32.h
michael@0 110 @@ -44,16 +44,19 @@
michael@0 111 #include <windows.h>
michael@0 112
michael@0 113 CAIRO_BEGIN_DECLS
michael@0 114
michael@0 115 cairo_public cairo_surface_t *
michael@0 116 cairo_win32_surface_create (HDC hdc);
michael@0 117
michael@0 118 cairo_public cairo_surface_t *
michael@0 119 +cairo_win32_surface_create_with_alpha (HDC hdc);
michael@0 120 +
michael@0 121 +cairo_public cairo_surface_t *
michael@0 122 cairo_win32_printing_surface_create (HDC hdc);
michael@0 123
michael@0 124 cairo_public cairo_surface_t *
michael@0 125 cairo_win32_surface_create_with_ddb (HDC hdc,
michael@0 126 cairo_format_t format,
michael@0 127 int width,
michael@0 128 int height);
michael@0 129

mercurial