Bug 574778 - Fix win widget's ConstrainPosition so that it supports full screen windo...
[mozilla-central.git] / gfx / thebes / gfxQtNativeRenderer.h
blob36c23f0993c2840fad34e5a7a64f8f3557ff579d
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Novell code.
17 * The Initial Developer of the Original Code is Novell.
18 * Portions created by the Initial Developer are Copyright (C) 2006
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * rocallahan@novell.com
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef GFXQTNATIVERENDER_H_
39 #define GFXQTNATIVERENDER_H_
41 #include "gfxColor.h"
42 #include "gfxASurface.h"
43 #include "gfxContext.h"
44 #include "gfxXlibSurface.h"
45 #include "nsRect.h"
47 class QRect;
49 /**
50 * This class lets us take code that draws into an Xlib surface drawable and lets us
51 * use it to draw into any Thebes context. The user should subclass this class,
52 * override NativeDraw, and then call Draw(). The drawing will be subjected
53 * to all Thebes transformations, clipping etc.
55 class THEBES_API gfxQtNativeRenderer {
56 public:
57 /**
58 * Perform the native drawing.
59 * @param offsetX draw at this offset into the given drawable
60 * @param offsetY draw at this offset into the given drawable
61 * @param clipRects an array of rects; clip to the union
62 * @param numClipRects the number of rects in the array, or zero if
63 * no clipping is required
65 virtual nsresult DrawWithXlib(gfxXlibSurface *xsurf,
66 nsIntPoint offset,
67 nsIntRect* clipRects, PRUint32 numClipRects) = 0;
69 enum {
70 // If set, then Draw() is opaque, i.e., every pixel in the intersection
71 // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height)
72 // will be set and there is no dependence on what the existing pixels
73 // in the drawable are set to.
74 DRAW_IS_OPAQUE = 0x01,
75 // If set, then numClipRects can be zero or one
76 DRAW_SUPPORTS_CLIP_RECT = 0x04,
77 // If set, then numClipRects can be any value. If neither this
78 // nor CLIP_RECT are set, then numClipRects will be zero
79 DRAW_SUPPORTS_CLIP_LIST = 0x08,
80 // If set, then the visual passed in can be any visual, otherwise the
81 // visual passed in must be the default visual for dpy's default screen
82 DRAW_SUPPORTS_ALTERNATE_VISUAL = 0x10,
83 // If set, then the Screen 'screen' in the callback can be different
84 // from the default Screen of the display passed to 'Draw' and can be
85 // on a different display.
86 DRAW_SUPPORTS_ALTERNATE_SCREEN = 0x20
89 struct DrawOutput {
90 nsRefPtr<gfxASurface> mSurface;
91 PRPackedBool mUniformAlpha;
92 PRPackedBool mUniformColor;
93 gfxRGBA mColor;
96 /**
97 * @param flags see above
98 * @param size Draw()'s drawing is guaranteed to be restricted to
99 * the rectangle (offset.x,offset.y,size.width,size.height)
100 * @param dpy a display to use for the drawing if ctx doesn't have one
101 * @param resultSurface if non-null, we will try to capture a copy of the
102 * rendered image into a surface similar to the surface of ctx; if
103 * successful, a pointer to the new gfxASurface is stored in *resultSurface,
104 * otherwise *resultSurface is set to nsnull.
106 nsresult Draw(gfxContext* ctx, nsIntSize size,
107 PRUint32 flags, Screen* screen, Visual* visual,
108 DrawOutput* output);
111 #endif /*GFXQTNATIVERENDER_H_*/