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 GFXGDKNATIVERENDER_H_
39 #define GFXGDKNATIVERENDER_H_
48 * This class lets us take code that draws into an GDK drawable and lets us
49 * use it to draw into any Thebes context. The user should subclass this class,
50 * override NativeDraw, and then call Draw(). The drawing will be subjected
51 * to all Thebes transformations, clipping etc.
53 class THEBES_API gfxGdkNativeRenderer
{
56 * Perform the native drawing.
57 * @param offsetX draw at this offset into the given drawable
58 * @param offsetY draw at this offset into the given drawable
59 * @param clipRects an array of rects; clip to the union
60 * @param numClipRects the number of rects in the array, or zero if
61 * no clipping is required
63 virtual nsresult
NativeDraw(GdkDrawable
* drawable
, short offsetX
,
64 short offsetY
, GdkRectangle
* clipRects
, PRUint32 numClipRects
) = 0;
67 // If set, then Draw() is opaque, i.e., every pixel in the intersection
68 // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height)
69 // will be set and there is no dependence on what the existing pixels
70 // in the drawable are set to.
71 DRAW_IS_OPAQUE
= 0x01,
72 // If set, then offset may be non-zero; if not set, then Draw() can
73 // only be called with offset==(0,0)
74 DRAW_SUPPORTS_OFFSET
= 0x02,
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_NONDEFAULT_VISUAL
= 0x10,
83 // If set, then the Screen 'screen' in the callback can be different
84 // from the default Screen of the default display and can be
85 // on a different display.
86 DRAW_SUPPORTS_ALTERNATE_SCREEN
= 0x20
90 nsRefPtr
<gfxASurface
> mSurface
;
91 PRPackedBool mUniformAlpha
;
92 PRPackedBool mUniformColor
;
97 * @param flags see above
98 * @param bounds Draw()'s drawing is guaranteed to be restricted to
99 * the rectangle (offset.x,offset.y,bounds.width,bounds.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
, int width
, int height
,
107 PRUint32 flags
, DrawOutput
* output
);
110 #endif /*GFXGDKNATIVERENDER_H_*/