Bug 460926 A11y hierachy is broken on Ubuntu 8.10 (GNOME 2.24), r=Evan.Yan sr=roc
[wine-gecko.git] / gfx / thebes / public / gfxWindowsNativeDrawing.h
blob1dc2310a32ea0c5dab97891efadb8304eda8446c
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 Thebes gfx.
17 * The Initial Developer of the Original Code is Mozilla Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 2007
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * Vladimir Vukicevic <vladimir@pobox.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 _GFXWINDOWSNATIVEDRAWING_H_
39 #define _GFXWINDOWSNATIVEDRAWING_H_
41 #include <windows.h>
43 #include "gfxContext.h"
44 #include "gfxWindowsSurface.h"
46 class THEBES_API gfxWindowsNativeDrawing {
47 public:
49 /* Flags for notifying this class what kind of operations the native
50 * drawing supports
53 enum {
54 /* Whether the native drawing can draw to a surface of content COLOR_ALPHA */
55 CAN_DRAW_TO_COLOR_ALPHA = 1 << 0,
56 CANNOT_DRAW_TO_COLOR_ALPHA = 0 << 0,
58 /* Whether the native drawing can be scaled using SetWorldTransform */
59 CAN_AXIS_ALIGNED_SCALE = 1 << 1,
60 CANNOT_AXIS_ALIGNED_SCALE = 0 << 1,
62 /* Whether the native drawing can be both scaled and rotated arbitrarily using SetWorldTransform */
63 CAN_COMPLEX_TRANSFORM = 1 << 2,
64 CANNOT_COMPLEX_TRANSFORM = 0 << 2,
66 /* If we have to do transforms with cairo, should we use nearest-neighbour filtering? */
67 DO_NEAREST_NEIGHBOR_FILTERING = 1 << 3,
68 DO_BILINEAR_FILTERING = 0 << 3
71 /* Create native win32 drawing for a rectangle bounded by
72 * nativeRect.
74 * Typical usage looks like:
76 * gfxWindowsNativeDrawing nativeDraw(ctx, destGfxRect, capabilities);
77 * do {
78 * HDC dc = nativeDraw.BeginNativeDrawing();
79 * if (!dc)
80 * return NS_ERROR_FAILURE;
82 * RECT winRect;
83 * nativeDraw.TransformToNativeRect(rect, winRect);
85 * ... call win32 operations on HDC to draw to winRect ...
87 * nativeDraw.EndNativeDrawing();
88 * } while (nativeDraw.ShouldRenderAgain());
89 * nativeDraw.PaintToContext();
91 gfxWindowsNativeDrawing(gfxContext *ctx,
92 const gfxRect& nativeRect,
93 PRUint32 nativeDrawFlags = CANNOT_DRAW_TO_COLOR_ALPHA |
94 CANNOT_AXIS_ALIGNED_SCALE |
95 CANNOT_COMPLEX_TRANSFORM |
96 DO_BILINEAR_FILTERING);
98 /* Returns a HDC which may be used for native drawing. This HDC is valid
99 * until EndNativeDrawing is called; if it is used for drawing after that time,
100 * the result is undefined. */
101 HDC BeginNativeDrawing();
103 /* Transform the native rect into something valid for rendering
104 * to the HDC. This may or may not change RECT, depending on
105 * whether SetWorldTransform is used or not. */
106 void TransformToNativeRect(const gfxRect& r, RECT& rout);
108 /* Marks the end of native drawing */
109 void EndNativeDrawing();
111 /* Returns PR_TRUE if the native drawing should be executed again */
112 PRBool ShouldRenderAgain();
114 /* Places the result to the context, if necessary */
115 void PaintToContext();
117 private:
119 nsRefPtr<gfxContext> mContext;
120 gfxRect mNativeRect;
121 PRUint32 mNativeDrawFlags;
123 // what state the rendering is in
124 PRUint8 mRenderState;
126 gfxPoint mDeviceOffset;
127 nsRefPtr<gfxPattern> mBlackPattern, mWhitePattern;
129 enum TransformType {
130 TRANSLATION_ONLY,
131 AXIS_ALIGNED_SCALE,
132 COMPLEX
135 TransformType mTransformType;
136 gfxPoint mTranslation;
137 gfxSize mScale;
138 XFORM mWorldTransform;
140 // saved state
141 nsRefPtr<gfxWindowsSurface> mWinSurface, mBlackSurface, mWhiteSurface;
142 HDC mDC;
143 XFORM mOldWorldTransform;
144 POINT mOrigViewportOrigin;
145 gfxIntSize mTempSurfaceSize;
148 #endif