|
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/. */ |
|
5 |
|
6 #ifndef GFXGDKNATIVERENDER_H_ |
|
7 #define GFXGDKNATIVERENDER_H_ |
|
8 |
|
9 #include <gdk/gdk.h> |
|
10 #include "nsSize.h" |
|
11 #ifdef MOZ_X11 |
|
12 #include "gfxXlibNativeRenderer.h" |
|
13 #endif |
|
14 |
|
15 class gfxContext; |
|
16 |
|
17 /** |
|
18 * This class lets us take code that draws into an GDK drawable and lets us |
|
19 * use it to draw into any Thebes context. The user should subclass this class, |
|
20 * override DrawWithGDK, and then call Draw(). The drawing will be subjected |
|
21 * to all Thebes transformations, clipping etc. |
|
22 */ |
|
23 class gfxGdkNativeRenderer |
|
24 #ifdef MOZ_X11 |
|
25 : private gfxXlibNativeRenderer |
|
26 #endif |
|
27 { |
|
28 public: |
|
29 /** |
|
30 * Perform the native drawing. |
|
31 * @param offsetX draw at this offset into the given drawable |
|
32 * @param offsetY draw at this offset into the given drawable |
|
33 * @param clipRects an array of rects; clip to the union |
|
34 * @param numClipRects the number of rects in the array, or zero if |
|
35 * no clipping is required |
|
36 */ |
|
37 |
|
38 #if (MOZ_WIDGET_GTK == 2) |
|
39 virtual nsresult DrawWithGDK(GdkDrawable * drawable, gint offsetX, |
|
40 gint offsetY, GdkRectangle * clipRects, uint32_t numClipRects) = 0; |
|
41 #endif |
|
42 |
|
43 enum { |
|
44 // If set, then Draw() is opaque, i.e., every pixel in the intersection |
|
45 // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height) |
|
46 // will be set and there is no dependence on what the existing pixels |
|
47 // in the drawable are set to. |
|
48 DRAW_IS_OPAQUE = |
|
49 #ifdef MOZ_X11 |
|
50 gfxXlibNativeRenderer::DRAW_IS_OPAQUE |
|
51 #else |
|
52 0x1 |
|
53 #endif |
|
54 // If set, then numClipRects can be zero or one. |
|
55 // If not set, then numClipRects will be zero. |
|
56 , DRAW_SUPPORTS_CLIP_RECT = |
|
57 #ifdef MOZ_X11 |
|
58 gfxXlibNativeRenderer::DRAW_SUPPORTS_CLIP_RECT |
|
59 #else |
|
60 0x2 |
|
61 #endif |
|
62 }; |
|
63 |
|
64 /** |
|
65 * @param flags see above |
|
66 * @param bounds Draw()'s drawing is guaranteed to be restricted to |
|
67 * the rectangle (offset.x,offset.y,bounds.width,bounds.height) |
|
68 * @param dpy a display to use for the drawing if ctx doesn't have one |
|
69 */ |
|
70 #if (MOZ_WIDGET_GTK == 2) |
|
71 void Draw(gfxContext* ctx, nsIntSize size, |
|
72 uint32_t flags, GdkColormap* colormap); |
|
73 #endif |
|
74 |
|
75 private: |
|
76 #ifdef MOZ_X11 |
|
77 // for gfxXlibNativeRenderer: |
|
78 virtual nsresult DrawWithXlib(cairo_surface_t* surface, |
|
79 nsIntPoint offset, |
|
80 nsIntRect* clipRects, uint32_t numClipRects) MOZ_OVERRIDE; |
|
81 |
|
82 #if (MOZ_WIDGET_GTK == 2) |
|
83 GdkColormap *mColormap; |
|
84 #endif |
|
85 #endif |
|
86 }; |
|
87 |
|
88 #endif /*GFXGDKNATIVERENDER_H_*/ |