Bugfix : Zooming works correct, no more errors on screen.
[xara-cairo.git] / wxOil / offscrn.h
blob85ecad8ddf2c3327b8b5c2cf6971ccca72fc04f7
1 // $Id: offscrn.h 1361 2006-06-25 16:43:38Z alex $
2 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
3 ================================XARAHEADERSTART===========================
5 Xara LX, a vector drawing and manipulation program.
6 Copyright (C) 1993-2006 Xara Group Ltd.
7 Copyright on certain contributions may be held in joint with their
8 respective authors. See AUTHORS file for details.
10 LICENSE TO USE AND MODIFY SOFTWARE
11 ----------------------------------
13 This file is part of Xara LX.
15 Xara LX is free software; you can redistribute it and/or modify it
16 under the terms of the GNU General Public License version 2 as published
17 by the Free Software Foundation.
19 Xara LX and its component source files are distributed in the hope
20 that it will be useful, but WITHOUT ANY WARRANTY; without even the
21 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 See the GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License along
25 with Xara LX (see the file GPL in the root directory of the
26 distribution); if not, write to the Free Software Foundation, Inc., 51
27 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 ADDITIONAL RIGHTS
31 -----------------
33 Conditional upon your continuing compliance with the GNU General Public
34 License described above, Xara Group Ltd grants to you certain additional
35 rights.
37 The additional rights are to use, modify, and distribute the software
38 together with the wxWidgets library, the wxXtra library, and the "CDraw"
39 library and any other such library that any version of Xara LX relased
40 by Xara Group Ltd requires in order to compile and execute, including
41 the static linking of that library to XaraLX. In the case of the
42 "CDraw" library, you may satisfy obligation under the GNU General Public
43 License to provide source code by providing a binary copy of the library
44 concerned and a copy of the license accompanying it.
46 Nothing in this section restricts any of the rights you have under
47 the GNU General Public License.
50 SCOPE OF LICENSE
51 ----------------
53 This license applies to this program (XaraLX) and its constituent source
54 files only, and does not necessarily apply to other Xara products which may
55 in part share the same code base, and are subject to their own licensing
56 terms.
58 This license does not apply to files in the wxXtra directory, which
59 are built into a separate library, and are subject to the wxWindows
60 license contained within that directory in the file "WXXTRA-LICENSE".
62 This license does not apply to the binary libraries (if any) within
63 the "libs" directory, which are subject to a separate license contained
64 within that directory in the file "LIBS-LICENSE".
67 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
68 ----------------------------------------------
70 Subject to the terms of the GNU Public License (see above), you are
71 free to do whatever you like with your modifications. However, you may
72 (at your option) wish contribute them to Xara's source tree. You can
73 find details of how to do this at:
74 http://www.xaraxtreme.org/developers/
76 Prior to contributing your modifications, you will need to complete our
77 contributor agreement. This can be found at:
78 http://www.xaraxtreme.org/developers/contribute/
80 Please note that Xara will not accept modifications which modify any of
81 the text between the start and end of this header (marked
82 XARAHEADERSTART and XARAHEADEREND).
85 MARKS
86 -----
88 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
89 designs are registered or unregistered trademarks, design-marks, and/or
90 service marks of Xara Group Ltd. All rights in these marks are reserved.
93 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
94 http://www.xara.com/
96 =================================XARAHEADEREND============================
99 #ifndef INC_OFFSCREEN_RR
100 #define INC_OFFSCREEN_RR
102 // structs, typedefs, defines
103 //#include "gconsts.h" // GCONTEXT - in camtypes.h [AUTOMATICALLY REMOVED]
105 // class definitions
106 // 1 - call classes member functions,
107 // 2 - use the class type for one of the members (not required if have pointer to class ??)
108 // 3 - to derive a superclass??
110 // class predeclarations
111 class GRenderDIB;
112 class GRenderRegion;
113 class ConcurrentRenderer;
115 // constants for view scaling.
116 // the pixel values apply for 100% zoom.
117 #define PIXELS_PER_INCH 96.0
118 #define MILLIPOINTS_PER_INCH 72000.0
119 #define INCHES_PER_METRE (100.0 / 2.54)
122 /////////////////////////////////////////////////////////////////////////////////////////////
124 // GRenderRegionWrappers
126 /////////////////////////////////////////////////////////////////////////////////////////////
128 This class encapsulates the functionality required to temporarily use GDraw to render
129 into a new bitmap, and then return it to the state that it was in.
131 It is intended for use when you need to render a bitmap dynamically inside any of the
132 following functions:-
133 1) Node::Render
134 2) Node::PreRenderChildren
135 3) Node::GoingOutOfScope
136 4) Node::ExportRender
137 5) Node::PreExportRender
139 It is designed to create bitmaps based on the screen resolution.
141 class GRenderRegionWrapper : public CCObject // CC_CLASS_MEMDUMP
143 CC_DECLARE_MEMDUMP(GRenderRegionWrapper)
145 public:
147 GRenderRegionWrapper() {}
148 ~GRenderRegionWrapper() {}
150 // Setup and restore
151 static GRenderRegionWrapper* GetAppropriateRenderWrapper (
152 GRenderRegion* pActiveRR,
153 double ResFactor,
154 DocRect AreaOfDocumentToRender,
155 UINT32 bpp,
156 BOOL NeedsTransp
158 static ConcurrentRenderer* GetConcurrentRenderer (
159 GRenderRegion* pSourceRR,
160 double ResFactor,
161 DocRect AreaOfDocumentToRender,
162 UINT32 bpp,
163 BOOL NeedsTransp
165 virtual BOOL Initialise(
166 GRenderRegion* pActiveRR,
167 double ResFactor,
168 DocRect AreaOfDocumentToRender,
169 UINT32 bpp,
170 BOOL NeedsTransp
171 ) = 0;
172 virtual BOOL RestorePreviousRendererState() = 0;
173 static void NewWrappedRRCreated(GRenderRegion* pGrr);
175 // Under the hood access
176 virtual GRenderRegion* GetRenderRegion() = 0;
177 void GetBitmapPointers(LPBITMAPINFO* bi, LPBYTE *by);
179 // Karim 06/07/2000
180 // I'm commenting these pre-processor directives out, to fix a bug with the new shadowing
181 // code, where shadows at anything other than 100% zoom are incorrectly scaled. This is a
182 // BODGE, and this code should be revisited at a later date.
184 //#ifdef _DEBUG
185 static void GetBitmapPointers(GRenderRegion* pGrr, LPBITMAPINFO* bi, LPBYTE *by);
186 //#endif
187 void SetBitmapPointers(LPBITMAPINFO bi, LPBYTE by);
189 // Extract bmp in a convenient form
190 KernelBitmap* GetKernelBitmap();
193 // Borrows GDraw from currently active RR by leveraging GRenderRegions offscreen rendering
194 // system
195 // Should be faster than ConcurrentRenderer because it doesn't need to create a new GRenderRegion
196 // class
197 class GDrawBorrower: public GRenderRegionWrapper
199 public:
201 GDrawBorrower();
202 ~GDrawBorrower();
204 virtual BOOL Initialise(
205 GRenderRegion* pActiveRR,
206 double ResFactor,
207 DocRect AreaOfDocumentToRender,
208 UINT32 bpp,
209 BOOL NeedsTransp
211 virtual BOOL RestorePreviousRendererState();
212 virtual GRenderRegion* GetRenderRegion() { return m_pBorrowedRR; }
214 private:
215 GRenderRegion* m_pBorrowedRR;
218 // 'Quick' in that it saves you having to construct a GRenderDIB and manually perform all
219 // the initialisation steps which are required before you can render using the GRenderDIB
220 // class
221 class QuickRenderer : public GRenderRegionWrapper
223 public:
225 QuickRenderer();
226 ~QuickRenderer();
228 virtual BOOL Initialise(
229 GRenderRegion* pActiveRR,
230 double ResFactor,
231 DocRect AreaOfDocumentToRender,
232 UINT32 bpp,
233 BOOL NeedsTransp
235 virtual BOOL RestorePreviousRendererState();
236 virtual GRenderRegion* GetRenderRegion() { return (GRenderRegion*) m_pNewRR; }
238 static GRenderDIB* CreateGRenderDIB(
239 double ResFactor,
240 DocRect AreaOfDocumentToRender,
241 UINT32 bpp,
242 BOOL NeedsTransp,
243 Matrix* pMat = NULL);
245 protected:
246 void RestoreSimple();
247 GRenderDIB* m_pNewRR;
250 // Saves GDraw context of currently active GRenderRegion
251 // Creates a new GRenderDIB (using QuickRenderer static fn)
252 class ConcurrentRenderer : public QuickRenderer
254 public:
256 ConcurrentRenderer();
257 ~ConcurrentRenderer();
259 virtual BOOL Initialise(
260 GRenderRegion* pActiveRR,
261 double ResFactor,
262 DocRect AreaOfDocumentToRender,
263 UINT32 bpp,
264 BOOL NeedsTransp
266 virtual BOOL RestorePreviousRendererState();
268 private:
269 GDrawContext* m_pOldGD;
270 GDrawContext* m_pNewGD;
271 View* m_pView;
274 #endif //INC_OFFSCREEN_RR