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
4 : *
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/
9 : *
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.
14 : *
15 : * The Original Code is Novell code.
16 : *
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.
20 : *
21 : * Contributor(s):
22 : * rocallahan@novell.com
23 : *
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.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef GFXGDKNATIVERENDER_H_
39 : #define GFXGDKNATIVERENDER_H_
40 :
41 : #include <gdk/gdk.h>
42 : #include "nsSize.h"
43 : #ifdef MOZ_X11
44 : #include "gfxXlibNativeRenderer.h"
45 : #endif
46 :
47 : class gfxASurface;
48 : class gfxContext;
49 :
50 : /**
51 : * This class lets us take code that draws into an GDK drawable and lets us
52 : * use it to draw into any Thebes context. The user should subclass this class,
53 : * override DrawWithGDK, and then call Draw(). The drawing will be subjected
54 : * to all Thebes transformations, clipping etc.
55 : */
56 : class THEBES_API gfxGdkNativeRenderer
57 : #ifdef MOZ_X11
58 : : private gfxXlibNativeRenderer
59 : #endif
60 0 : {
61 : public:
62 : /**
63 : * Perform the native drawing.
64 : * @param offsetX draw at this offset into the given drawable
65 : * @param offsetY draw at this offset into the given drawable
66 : * @param clipRects an array of rects; clip to the union
67 : * @param numClipRects the number of rects in the array, or zero if
68 : * no clipping is required
69 : */
70 : virtual nsresult DrawWithGDK(GdkDrawable * drawable, gint offsetX,
71 : gint offsetY, GdkRectangle * clipRects, PRUint32 numClipRects) = 0;
72 :
73 : enum {
74 : // If set, then Draw() is opaque, i.e., every pixel in the intersection
75 : // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height)
76 : // will be set and there is no dependence on what the existing pixels
77 : // in the drawable are set to.
78 : DRAW_IS_OPAQUE =
79 : #ifdef MOZ_X11
80 : gfxXlibNativeRenderer::DRAW_IS_OPAQUE
81 : #else
82 : 0x1
83 : #endif
84 : // If set, then numClipRects can be zero or one.
85 : // If not set, then numClipRects will be zero.
86 : , DRAW_SUPPORTS_CLIP_RECT =
87 : #ifdef MOZ_X11
88 : gfxXlibNativeRenderer::DRAW_SUPPORTS_CLIP_RECT
89 : #else
90 : 0x2
91 : #endif
92 : };
93 :
94 : /**
95 : * @param flags see above
96 : * @param bounds Draw()'s drawing is guaranteed to be restricted to
97 : * the rectangle (offset.x,offset.y,bounds.width,bounds.height)
98 : * @param dpy a display to use for the drawing if ctx doesn't have one
99 : */
100 : void Draw(gfxContext* ctx, nsIntSize size,
101 : PRUint32 flags, GdkColormap* colormap);
102 :
103 : private:
104 : #ifdef MOZ_X11
105 : // for gfxXlibNativeRenderer:
106 : virtual nsresult DrawWithXlib(gfxXlibSurface* surface,
107 : nsIntPoint offset,
108 : nsIntRect* clipRects, PRUint32 numClipRects);
109 :
110 : GdkColormap *mColormap;
111 : #endif
112 : };
113 :
114 : #endif /*GFXGDKNATIVERENDER_H_*/
|