gfx/thebes/cairo-xlib-utils.h

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 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef CAIROXLIBUTILS_H_
michael@0 7 #define CAIROXLIBUTILS_H_
michael@0 8
michael@0 9 #include "cairo.h"
michael@0 10 #include <X11/Xlib.h>
michael@0 11
michael@0 12 CAIRO_BEGIN_DECLS
michael@0 13
michael@0 14 /**
michael@0 15 * This callback encapsulates Xlib-based rendering. We assume that the
michael@0 16 * execution of the callback is equivalent to compositing some RGBA image of
michael@0 17 * size (bounds_width, bounds_height) onto the drawable at offset (offset_x,
michael@0 18 * offset_y), clipped to the union of the clip_rects if num_rects is greater
michael@0 19 * than zero. This includes the assumption that the same RGBA image
michael@0 20 * is composited if you call the callback multiple times with the same closure,
michael@0 21 * display and visual during a single cairo_draw_with_xlib call.
michael@0 22 *
michael@0 23 * @return True on success, False on non-recoverable error
michael@0 24 */
michael@0 25 typedef cairo_bool_t (* cairo_xlib_drawing_callback)
michael@0 26 (void *closure,
michael@0 27 Screen *screen,
michael@0 28 Drawable drawable,
michael@0 29 Visual *visual,
michael@0 30 short offset_x, short offset_y,
michael@0 31 XRectangle* clip_rects, unsigned int num_rects);
michael@0 32
michael@0 33 /**
michael@0 34 * This structure captures the result of the native drawing, in case the
michael@0 35 * caller may wish to reapply the drawing efficiently later.
michael@0 36 */
michael@0 37 typedef struct {
michael@0 38 cairo_surface_t *surface;
michael@0 39 cairo_bool_t uniform_alpha;
michael@0 40 cairo_bool_t uniform_color;
michael@0 41 double alpha; /* valid only if uniform_alpha is TRUE */
michael@0 42 double r, g, b; /* valid only if uniform_color is TRUE */
michael@0 43 } cairo_xlib_drawing_result_t;
michael@0 44
michael@0 45 /**
michael@0 46 * This type specifies whether the native drawing callback draws all pixels
michael@0 47 * in its bounds opaquely, independent of the contents of the target drawable,
michael@0 48 * or whether it leaves pixels transparent/translucent or depends on the
michael@0 49 * existing contents of the target drawable in some way.
michael@0 50 */
michael@0 51 typedef enum _cairo_xlib_drawing_opacity {
michael@0 52 CAIRO_XLIB_DRAWING_OPAQUE,
michael@0 53 CAIRO_XLIB_DRAWING_TRANSPARENT
michael@0 54 } cairo_xlib_drawing_opacity_t;
michael@0 55
michael@0 56 /**
michael@0 57 * This type encodes the capabilities of the native drawing callback.
michael@0 58 *
michael@0 59 * If CAIRO_XLIB_DRAWING_SUPPORTS_OFFSET is set, 'offset_x' and 'offset_y'
michael@0 60 * can be nonzero in the call to the callback; otherwise they will be zero.
michael@0 61 *
michael@0 62 * If CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_RECT is set, then 'num_rects' can be
michael@0 63 * zero or one in the call to the callback. If
michael@0 64 * CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_LIST is set, then 'num_rects' can be
michael@0 65 * anything in the call to the callback. Otherwise 'num_rects' will be zero.
michael@0 66 * Do not set both of these values.
michael@0 67 *
michael@0 68 * If CAIRO_XLIB_DRAWING_SUPPORTS_ALTERNATE_SCREEN is set, then 'screen' can
michael@0 69 * be any screen on any display, otherwise it will be the default screen of
michael@0 70 * the display passed into cairo_draw_with_xlib.
michael@0 71 *
michael@0 72 * If CAIRO_XLIB_DRAWING_SUPPORTS_NONDEFAULT_VISUAL is set, then 'visual' can be
michael@0 73 * any visual, otherwise it will be equal to
michael@0 74 * DefaultVisualOfScreen (screen).
michael@0 75 */
michael@0 76 typedef enum {
michael@0 77 CAIRO_XLIB_DRAWING_SUPPORTS_OFFSET = 0x01,
michael@0 78 CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_RECT = 0x02,
michael@0 79 CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_LIST = 0x04,
michael@0 80 CAIRO_XLIB_DRAWING_SUPPORTS_ALTERNATE_SCREEN = 0x08,
michael@0 81 CAIRO_XLIB_DRAWING_SUPPORTS_NONDEFAULT_VISUAL = 0x10
michael@0 82 } cairo_xlib_drawing_support_t;
michael@0 83
michael@0 84 /**
michael@0 85 * Draw Xlib output into any cairo context. All cairo transforms and effects
michael@0 86 * are honored, including the current operator. This is equivalent to a
michael@0 87 * cairo_set_source_surface and then cairo_paint.
michael@0 88 * @param cr the context to draw into
michael@0 89 * @param callback the code to perform Xlib rendering
michael@0 90 * @param closure associated data
michael@0 91 * @param dpy an X display to use in case the cairo context has no associated X display
michael@0 92 * @param width the width of the putative image drawn by the callback
michael@0 93 * @param height the height of the putative image drawn by the callback
michael@0 94 * @param is_opaque set to CAIRO_XLIB_DRAWING_IS_OPAQUE to indicate
michael@0 95 * that all alpha values of the putative image will be 1.0; the pixels drawn into
michael@0 96 * the Drawable must not depend on the prior contents of the Drawable
michael@0 97 * in any way
michael@0 98 * @param capabilities the capabilities of the callback as described above.
michael@0 99 * @param result if non-NULL, we *may* fill in the struct with information about
michael@0 100 * the rendered image. 'surface' may be filled in with a surface representing
michael@0 101 * the image, similar to the target of 'cr'. If 'uniform_alpha' is True then
michael@0 102 * every pixel of the image has the same alpha value 'alpha'. If
michael@0 103 * 'uniform_color' is True then every pixel of the image has the same RGB
michael@0 104 * color (r, g, b). If the image has uniform color and alpha (or alpha is zero,
michael@0 105 * in which case the color is always uniform) then we won't bother returning
michael@0 106 * a surface for it.
michael@0 107 */
michael@0 108 void cairo_draw_with_xlib (cairo_t *cr,
michael@0 109 cairo_xlib_drawing_callback callback,
michael@0 110 void *closure,
michael@0 111 Display *dpy,
michael@0 112 unsigned int width, unsigned int height,
michael@0 113 cairo_xlib_drawing_opacity_t is_opaque,
michael@0 114 cairo_xlib_drawing_support_t capabilities,
michael@0 115 cairo_xlib_drawing_result_t *result);
michael@0 116
michael@0 117 CAIRO_END_DECLS
michael@0 118
michael@0 119 #endif /*CAIROXLIBUTILS_H_*/

mercurial