00001 // $Id: offscrn.h 1361 2006-06-25 16:43:38Z alex $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 00099 #ifndef INC_OFFSCREEN_RR 00100 #define INC_OFFSCREEN_RR 00101 00102 // structs, typedefs, defines 00103 //#include "gconsts.h" // GCONTEXT - in camtypes.h [AUTOMATICALLY REMOVED] 00104 00105 // class definitions 00106 // 1 - call classes member functions, 00107 // 2 - use the class type for one of the members (not required if have pointer to class ??) 00108 // 3 - to derive a superclass?? 00109 00110 // class predeclarations 00111 class GRenderDIB; 00112 class GRenderRegion; 00113 class ConcurrentRenderer; 00114 00115 // constants for view scaling. 00116 // the pixel values apply for 100% zoom. 00117 #define PIXELS_PER_INCH 96.0 00118 #define MILLIPOINTS_PER_INCH 72000.0 00119 #define INCHES_PER_METRE (100.0 / 2.54) 00120 00121 00123 // 00124 // GRenderRegionWrappers 00125 // 00127 /* 00128 This class encapsulates the functionality required to temporarily use GDraw to render 00129 into a new bitmap, and then return it to the state that it was in. 00130 00131 It is intended for use when you need to render a bitmap dynamically inside any of the 00132 following functions:- 00133 1) Node::Render 00134 2) Node::PreRenderChildren 00135 3) Node::GoingOutOfScope 00136 4) Node::ExportRender 00137 5) Node::PreExportRender 00138 00139 It is designed to create bitmaps based on the screen resolution. 00140 */ 00141 class GRenderRegionWrapper : public CCObject // CC_CLASS_MEMDUMP 00142 { 00143 CC_DECLARE_MEMDUMP(GRenderRegionWrapper) 00144 00145 public: 00146 00147 GRenderRegionWrapper() {} 00148 ~GRenderRegionWrapper() {} 00149 00150 // Setup and restore 00151 static GRenderRegionWrapper* GetAppropriateRenderWrapper ( 00152 GRenderRegion* pActiveRR, 00153 double ResFactor, 00154 DocRect AreaOfDocumentToRender, 00155 UINT32 bpp, 00156 BOOL NeedsTransp 00157 ); 00158 static ConcurrentRenderer* GetConcurrentRenderer ( 00159 GRenderRegion* pSourceRR, 00160 double ResFactor, 00161 DocRect AreaOfDocumentToRender, 00162 UINT32 bpp, 00163 BOOL NeedsTransp 00164 ); 00165 virtual BOOL Initialise( 00166 GRenderRegion* pActiveRR, 00167 double ResFactor, 00168 DocRect AreaOfDocumentToRender, 00169 UINT32 bpp, 00170 BOOL NeedsTransp 00171 ) = 0; 00172 virtual BOOL RestorePreviousRendererState() = 0; 00173 static void NewWrappedRRCreated(GRenderRegion* pGrr); 00174 00175 // Under the hood access 00176 virtual GRenderRegion* GetRenderRegion() = 0; 00177 void GetBitmapPointers(LPBITMAPINFO* bi, LPBYTE *by); 00178 00179 // Karim 06/07/2000 00180 // I'm commenting these pre-processor directives out, to fix a bug with the new shadowing 00181 // code, where shadows at anything other than 100% zoom are incorrectly scaled. This is a 00182 // BODGE, and this code should be revisited at a later date. 00183 00184 //#ifdef _DEBUG 00185 static void GetBitmapPointers(GRenderRegion* pGrr, LPBITMAPINFO* bi, LPBYTE *by); 00186 //#endif 00187 void SetBitmapPointers(LPBITMAPINFO bi, LPBYTE by); 00188 00189 // Extract bmp in a convenient form 00190 KernelBitmap* GetKernelBitmap(); 00191 }; 00192 00193 // Borrows GDraw from currently active RR by leveraging GRenderRegions offscreen rendering 00194 // system 00195 // Should be faster than ConcurrentRenderer because it doesn't need to create a new GRenderRegion 00196 // class 00197 class GDrawBorrower: public GRenderRegionWrapper 00198 { 00199 public: 00200 00201 GDrawBorrower(); 00202 ~GDrawBorrower(); 00203 00204 virtual BOOL Initialise( 00205 GRenderRegion* pActiveRR, 00206 double ResFactor, 00207 DocRect AreaOfDocumentToRender, 00208 UINT32 bpp, 00209 BOOL NeedsTransp 00210 ); 00211 virtual BOOL RestorePreviousRendererState(); 00212 virtual GRenderRegion* GetRenderRegion() { return m_pBorrowedRR; } 00213 00214 private: 00215 GRenderRegion* m_pBorrowedRR; 00216 }; 00217 00218 // 'Quick' in that it saves you having to construct a GRenderDIB and manually perform all 00219 // the initialisation steps which are required before you can render using the GRenderDIB 00220 // class 00221 class QuickRenderer : public GRenderRegionWrapper 00222 { 00223 public: 00224 00225 QuickRenderer(); 00226 ~QuickRenderer(); 00227 00228 virtual BOOL Initialise( 00229 GRenderRegion* pActiveRR, 00230 double ResFactor, 00231 DocRect AreaOfDocumentToRender, 00232 UINT32 bpp, 00233 BOOL NeedsTransp 00234 ); 00235 virtual BOOL RestorePreviousRendererState(); 00236 virtual GRenderRegion* GetRenderRegion() { return (GRenderRegion*) m_pNewRR; } 00237 00238 static GRenderDIB* CreateGRenderDIB( 00239 double ResFactor, 00240 DocRect AreaOfDocumentToRender, 00241 UINT32 bpp, 00242 BOOL NeedsTransp, 00243 Matrix* pMat = NULL); 00244 00245 protected: 00246 void RestoreSimple(); 00247 GRenderDIB* m_pNewRR; 00248 }; 00249 00250 // Saves GDraw context of currently active GRenderRegion 00251 // Creates a new GRenderDIB (using QuickRenderer static fn) 00252 class ConcurrentRenderer : public QuickRenderer 00253 { 00254 public: 00255 00256 ConcurrentRenderer(); 00257 ~ConcurrentRenderer(); 00258 00259 virtual BOOL Initialise( 00260 GRenderRegion* pActiveRR, 00261 double ResFactor, 00262 DocRect AreaOfDocumentToRender, 00263 UINT32 bpp, 00264 BOOL NeedsTransp 00265 ); 00266 virtual BOOL RestorePreviousRendererState(); 00267 00268 private: 00269 GDrawContext* m_pOldGD; 00270 GDrawContext* m_pNewGD; 00271 View* m_pView; 00272 }; 00273 00274 #endif //INC_OFFSCREEN_RR