Tue, 06 Jan 2015 21:39:09 +0100
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.
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef GFXQTNATIVERENDER_H_
7 #define GFXQTNATIVERENDER_H_
9 #include "gfxColor.h"
10 #include "gfxContext.h"
11 #include "gfxXlibSurface.h"
13 class QRect;
14 struct nsIntRect;
16 /**
17 * This class lets us take code that draws into an Xlib surface drawable and lets us
18 * use it to draw into any Thebes context. The user should subclass this class,
19 * override NativeDraw, and then call Draw(). The drawing will be subjected
20 * to all Thebes transformations, clipping etc.
21 */
22 class gfxQtNativeRenderer {
23 public:
24 /**
25 * Perform the native drawing.
26 * @param offsetX draw at this offset into the given drawable
27 * @param offsetY draw at this offset into the given drawable
28 * @param clipRects an array of rects; clip to the union
29 * @param numClipRects the number of rects in the array, or zero if
30 * no clipping is required
31 */
32 virtual nsresult DrawWithXlib(cairo_surface_t* surface,
33 nsIntPoint offset,
34 nsIntRect* clipRects, uint32_t numClipRects) = 0;
36 enum {
37 // If set, then Draw() is opaque, i.e., every pixel in the intersection
38 // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height)
39 // will be set and there is no dependence on what the existing pixels
40 // in the drawable are set to.
41 DRAW_IS_OPAQUE = 0x01,
42 // If set, then numClipRects can be zero or one
43 DRAW_SUPPORTS_CLIP_RECT = 0x04,
44 // If set, then numClipRects can be any value. If neither this
45 // nor CLIP_RECT are set, then numClipRects will be zero
46 DRAW_SUPPORTS_CLIP_LIST = 0x08,
47 // If set, then the visual passed in can be any visual, otherwise the
48 // visual passed in must be the default visual for dpy's default screen
49 DRAW_SUPPORTS_ALTERNATE_VISUAL = 0x10,
50 // If set, then the Screen 'screen' in the callback can be different
51 // from the default Screen of the display passed to 'Draw' and can be
52 // on a different display.
53 DRAW_SUPPORTS_ALTERNATE_SCREEN = 0x20
54 };
56 /**
57 * @param flags see above
58 * @param size Draw()'s drawing is guaranteed to be restricted to
59 * the rectangle (offset.x,offset.y,size.width,size.height)
60 * @param dpy a display to use for the drawing if ctx doesn't have one
61 * @param resultSurface if non-null, we will try to capture a copy of the
62 * rendered image into a surface similar to the surface of ctx; if
63 * successful, a pointer to the new gfxASurface is stored in *resultSurface,
64 * otherwise *resultSurface is set to nullptr.
65 */
66 nsresult Draw(gfxContext* ctx, nsIntSize size,
67 uint32_t flags, Screen* screen, Visual* visual);
68 };
70 #endif /*GFXQTNATIVERENDER_H_*/