Bug 458861. Validate TrueType headers before activating downloaded font. r=roc, sr...
[wine-gecko.git] / gfx / src / thebes / nsThebesDeviceContext.h
blob629c2ac6c03c7295477e11782a145271a885ab66
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
18 * mozilla.org.
19 * Portions created by the Initial Developer are Copyright (C) 2005
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Vladimir Vukicevic <vladimir@pobox.com>
24 * Stuart Parmenter <pavlov@pavlov.net>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef _NS_THEBESDEVICECONTEXT_H_
41 #define _NS_THEBESDEVICECONTEXT_H_
43 #include "nsIScreenManager.h"
45 #include "nsDeviceContext.h"
47 #include "nsRefPtrHashtable.h"
48 #include "nsHashKeys.h"
50 #include "prlog.h"
52 #include "gfxContext.h"
54 #ifdef PR_LOGGING
55 extern PRLogModuleInfo* gThebesGFXLog;
56 #endif
58 #ifdef XP_WIN
59 #include "gfxWindowsSurface.h"
60 #elif defined(XP_OS2)
61 #include "gfxOS2Surface.h"
62 #endif
64 class nsThebesDeviceContext : public DeviceContextImpl
66 public:
67 nsThebesDeviceContext();
68 virtual ~nsThebesDeviceContext();
70 static void Shutdown();
72 NS_DECL_ISUPPORTS_INHERITED
74 NS_IMETHOD Init(nsNativeWidget aWidget);
75 NS_IMETHOD InitForPrinting(nsIDeviceContextSpec *aDevSpec);
76 NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext);
78 NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext);
79 NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
80 NS_IMETHOD CreateRenderingContextInstance(nsIRenderingContext *&aContext);
82 NS_IMETHOD SupportsNativeWidgets(PRBool& aSupportsWidgets);
83 NS_IMETHOD PrepareNativeWidget(nsIWidget *aWidget, void **aOut);
85 NS_IMETHOD GetSystemFont(nsSystemFontID aID, nsFont *aFont) const;
86 NS_IMETHOD ClearCachedSystemFonts();
88 NS_IMETHOD CheckFontExistence(const nsString& aFaceName);
90 NS_IMETHOD GetDepth(PRUint32& aDepth);
92 NS_IMETHOD GetPaletteInfo(nsPaletteInfo& aPaletteInfo);
94 NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32& aPixel);
96 NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32& aWidth, PRInt32& aHeight);
97 NS_IMETHOD GetRect(nsRect& aRect);
98 NS_IMETHOD GetClientRect(nsRect& aRect);
100 /* printing goop */
101 NS_IMETHOD PrepareDocument(PRUnichar *aTitle,
102 PRUnichar *aPrintToFileName);
104 NS_IMETHOD BeginDocument(PRUnichar *aTitle,
105 PRUnichar *aPrintToFileName,
106 PRInt32 aStartPage,
107 PRInt32 aEndPage);
109 NS_IMETHOD EndDocument(void);
110 NS_IMETHOD AbortDocument(void);
111 NS_IMETHOD BeginPage(void);
112 NS_IMETHOD EndPage(void);
113 /* end printing goop */
115 static void DebugShowCairoSurface (const char *aName, cairo_surface_t *aSurface);
117 virtual PRBool CheckDPIChange();
119 virtual PRBool SetPixelScale(float aScale);
121 nsNativeWidget GetWidget() { return mWidget; }
122 #if defined(XP_WIN) || defined(XP_OS2)
123 HDC GetPrintHDC();
124 #endif
126 protected:
127 nsresult SetDPI();
128 void ComputeClientRectUsingScreen(nsRect *outRect);
129 void ComputeFullAreaUsingScreen(nsRect *outRect);
130 void FindScreen(nsIScreen **outScreen);
131 void CalcPrintingSize();
132 void UpdateScaledAppUnits();
134 PRUint32 mDepth;
136 private:
137 nsCOMPtr<nsIScreenManager> mScreenManager;
139 nscoord mWidth;
140 nscoord mHeight;
142 nsRefPtrHashtable<nsISupportsHashKey, gfxASurface> mWidgetSurfaceCache;
144 nsRefPtr<gfxASurface> mPrintingSurface;
145 float mPrintingScale;
146 nsCOMPtr<nsIDeviceContextSpec> mDeviceContextSpec;
149 #endif /* _NS_CAIRODEVICECONTEXT_H_ */