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
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.
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_
50 * This class lets us take code that draws into an Qt 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
{
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
NativeDraw(QWidget
* drawable
, short offsetX
,
66 short offsetY
, QRect
* clipRects
, PRUint32 numClipRects
) = 0;
69 // If set, then Draw() is opaque, i.e., every pixel in the intersection
70 // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height)
71 // will be set and there is no dependence on what the existing pixels
72 // in the drawable are set to.
73 DRAW_IS_OPAQUE
= 0x01,
74 // If set, then offset may be non-zero; if not set, then Draw() can
75 // only be called with offset==(0,0)
76 DRAW_SUPPORTS_OFFSET
= 0x02,
77 // If set, then numClipRects can be zero or one
78 DRAW_SUPPORTS_CLIP_RECT
= 0x04,
79 // If set, then numClipRects can be any value. If neither this
80 // nor CLIP_RECT are set, then numClipRects will be zero
81 DRAW_SUPPORTS_CLIP_LIST
= 0x08,
82 // If set, then the visual passed in can be any visual, otherwise the
83 // visual passed in must be the default visual for dpy's default screen
84 DRAW_SUPPORTS_NONDEFAULT_VISUAL
= 0x10,
85 // If set, then the Screen 'screen' in the callback can be different
86 // from the default Screen of the display passed to 'Draw' and can be
87 // on a different display.
88 DRAW_SUPPORTS_ALTERNATE_SCREEN
= 0x20
92 nsRefPtr
<gfxASurface
> mSurface
;
93 PRPackedBool mUniformAlpha
;
94 PRPackedBool mUniformColor
;
99 * @param flags see above
100 * @param bounds Draw()'s drawing is guaranteed to be restricted to
101 * the rectangle (offset.x,offset.y,bounds.width,bounds.height)
102 * @param dpy a display to use for the drawing if ctx doesn't have one
103 * @param resultSurface if non-null, we will try to capture a copy of the
104 * rendered image into a surface similar to the surface of ctx; if
105 * successful, a pointer to the new gfxASurface is stored in *resultSurface,
106 * otherwise *resultSurface is set to nsnull.
108 nsresult
Draw(gfxContext
* ctx
, int width
, int height
,
109 PRUint32 flags
, DrawOutput
* output
);
112 #endif /*GFXQTNATIVERENDER_H_*/