00001 // $Id: capturemanager.h 751 2006-03-31 15:43:49Z 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 00100 // CaptureManager.h 00101 // 00102 // Created: 29/06/2004 by Phil 00103 // 00104 00105 #ifndef INC_CaptureManager 00106 #define INC_CaptureManager 00107 00108 00109 00110 00111 // Forward references 00112 class Capture; 00113 class ClipRegionAttribute; 00114 00115 00116 // Typedefs 00117 typedef CMapPtrToPtr ClipRegionMap; 00118 00119 00120 00121 /******************************************************************************************** 00122 00123 < CAPTUREINFO 00124 00125 Comment: Info structure stored in a CaptureManager instance, describing how it should 00126 behave in relation to other Captures 00127 SeeAlso: RenderRegion::StartCapture 00128 00129 ********************************************************************************************/ 00130 00131 typedef enum 00132 { 00133 ctDISABLED = 0, // Don't allow capture to start up 00134 ctNESTABLE, // New captures should be nested inside existing ones 00135 ctREUSE, // New captures will be ignored if there's one already running 00136 ctRESTART // New captures will stop existing captures 00137 } CaptureType; 00138 00139 // -------------------------------------------------------------------------------------- 00140 typedef enum 00141 { 00142 cfNONE = 0x00, 00143 cfMASTER = 0x01, // This is the Master Capture 00144 cfCOLLAPSETOMASTER = 0x02, // This Capture can be collapsed on demand 00145 cfGRABRENDERED = 0x04, // This Capture should not have a bitmap of its own 00146 cfDEBUG = 0x08, // This Capture should be debugged 00147 cfLOCKEDTRANSPARENT = 0x10, // This Capture should remain transparent no matter what! 00148 cfQUALITYNORMAL = 0x20, // This Capture will force non-AntiAliased rendering 00149 cfBITMAPSMOOTHING = 0x40, // This Capture will set the BitmapSmoothing flag 00150 cfTILEFILTERING = 0x80, // This Capture will set the TileFiltering flag 00151 cfALLOWDIRECT = 0x100, // This Capture can get a bitmap directly from a supplier node 00152 cfDIRECT = 0x200, // This Capture is "Direct" (gets the bitmap of a child) 00153 cfFULLCOVERAGE = 0x400, // This Capture covers its owner entirely 00154 cfUNCLIP = 0x800, // This Capture removes any clip regions in force when it starts 00155 cfPIXWIDTHSCALE = 0x1000 // This Capture allows ScaledPixelWidth to differ from PixelWidth 00156 } CaptureFlagBits; 00157 00158 // -------------------------------------------------------------------------------------- 00159 typedef struct tagCaptureFlags 00160 { 00161 tagCaptureFlags() 00162 { 00163 Master = FALSE; 00164 CollapseToMaster = FALSE; 00165 GrabRendered = FALSE; 00166 Debug = FALSE; 00167 LockedTransparent = FALSE; 00168 QualityNormal = FALSE; 00169 BitmapSmoothing = FALSE; 00170 TileFiltering = FALSE; 00171 AllowDirect = FALSE; 00172 Direct = FALSE; 00173 FullCoverage = FALSE; 00174 UnClip = FALSE; 00175 CalcScaledPixWidth = FALSE; 00176 00177 HasBeenSuppliedWithBitmap = FALSE; 00178 } 00179 tagCaptureFlags(UINT32 flagbits) 00180 { 00181 Master = ((flagbits & cfMASTER) == cfMASTER); 00182 CollapseToMaster = ((flagbits & cfCOLLAPSETOMASTER) == cfCOLLAPSETOMASTER); 00183 GrabRendered = ((flagbits & cfGRABRENDERED) == cfGRABRENDERED); 00184 Debug = ((flagbits & cfDEBUG) == cfDEBUG); 00185 LockedTransparent = ((flagbits & cfLOCKEDTRANSPARENT) == cfLOCKEDTRANSPARENT); 00186 QualityNormal = ((flagbits & cfQUALITYNORMAL) == cfQUALITYNORMAL); 00187 BitmapSmoothing = ((flagbits & cfBITMAPSMOOTHING) == cfBITMAPSMOOTHING); 00188 TileFiltering = ((flagbits & cfTILEFILTERING) == cfTILEFILTERING); 00189 AllowDirect = ((flagbits & cfALLOWDIRECT) == cfALLOWDIRECT); 00190 Direct = ((flagbits & cfDIRECT) == cfDIRECT); 00191 FullCoverage = ((flagbits & cfFULLCOVERAGE) == cfFULLCOVERAGE); 00192 UnClip = ((flagbits & cfUNCLIP) == cfUNCLIP); 00193 CalcScaledPixWidth = ((flagbits & cfPIXWIDTHSCALE) == cfPIXWIDTHSCALE); 00194 00195 HasBeenSuppliedWithBitmap = FALSE; 00196 } 00197 // tagCaptureFlags(UINT32 flagbits); 00198 00199 BOOL Master : 1; // This is the Master Capture 00200 BOOL CollapseToMaster : 1; // This Capture can be collapsed on demand 00201 BOOL GrabRendered : 1; // This Capture should not have a bitmap of its own 00202 BOOL Debug : 1; // This Capture should be debugged 00203 BOOL LockedTransparent : 1; // This Capture should remain transparent no matter what! 00204 BOOL QualityNormal : 1; // This Capture will force normal quality rendering 00205 BOOL BitmapSmoothing : 1; // This Capture will set the BitmapSmoothing flag 00206 BOOL TileFiltering : 1; // This Capture will set the TileFiltering flag 00207 BOOL AllowDirect : 1; // This Capture can get its data from a supplier node 00208 BOOL Direct : 1; // This Capture is "Direct" (gets the bitmap of a child) 00209 BOOL FullCoverage : 1; // This Capture covers its owner entirely 00210 BOOL UnClip : 1; // This Capture removes any clip regions in force when it starts 00211 BOOL CalcScaledPixWidth : 1; // This Capture allows ScaledPixelWidth to differ from PixelWidth 00212 00213 BOOL HasBeenSuppliedWithBitmap : 1; // Supplier has called ConsumeDirectBitmap 00214 00215 } CaptureFlags; 00216 00217 // -------------------------------------------------------------------------------------- 00218 typedef struct tagCaptureInfo 00219 { 00220 tagCaptureInfo() {caType = ctDISABLED, caFlags = CaptureFlags(0);} 00221 tagCaptureInfo(CaptureType cctype, CaptureFlags ccflags) {caType=cctype; caFlags=ccflags;} 00222 tagCaptureInfo(CaptureType cctype, UINT32 ccflags) {caType=cctype; caFlags=CaptureFlags(ccflags);} 00223 00224 CaptureType caType; 00225 CaptureFlags caFlags; 00226 } CAPTUREINFO; 00227 00228 00229 00230 00231 /******************************************************************************************** 00232 00233 > class Capture : public CCObject 00234 00235 Author: Phil_Martin (Xara Group Ltd) <camelotdev@xara.com> 00236 Created: 19/07/2004 00237 Purpose: Hold current bitmap cacheing state during rendering and functionality 00238 to store bitmaps in cache, detect limits of cached spans, etc. 00239 00240 This class is instantiated while a chunk of the tree is being rendered 00241 with the intention of capturing it in the BitmapCache. 00242 When the chunk ends, the CaptureManager decides whether it can 00243 store the bitmap or not and then dies. 00244 The "chunk" of tree may be a single node, a subtree or an arbitrary span 00245 of nodes from point A to point B 00246 00247 A Capture may own a bitmap but doesn't always do so. 00248 00249 Note! This class replaces OffscreenState and CaptureManager. 00250 This is how it should have been implemented in the first place...! 00251 00252 SeeAlso: RenderRegion; RenderRegion::RenderTree; Node::RenderSubtree 00253 00254 ********************************************************************************************/ 00255 00256 class Capture : public CCObject 00257 { 00258 public: 00259 CC_DECLARE_DYNAMIC(Capture); 00260 00261 Capture(); // Default constructor 00262 Capture(CCObject* pOwner, // New Capture constructor 00263 CAPTUREINFO cinfo, 00264 Matrix cMatrix, 00265 DocRect cRect, 00266 double PixelsPerInch, 00267 ColourContext* pcColourContext 00268 ); 00269 Capture(Capture* pSourceCapture, // Copy constructor 00270 BOOL bCopyBitmap = FALSE); 00271 ~Capture(); 00272 00273 // Operating functions 00274 public: 00275 BOOL IsTransparent() const {return (lpBitmapInfo && lpBitmapInfo->bmiHeader.biCompression==0x80000001);} 00276 BOOL IsMaster() const {return info.caFlags.Master; } 00277 BOOL IsDirect() const {return info.caFlags.Direct; } 00278 BOOL HasFullCoverage() const {return info.caFlags.FullCoverage; } 00279 BOOL IsUnclipped() const {return info.caFlags.UnClip; } 00280 CCObject* GetOwner() const {return m_pOwner;} 00281 BOOL OwnsBitmap() const {return lpBitmapInfo!=NULL && lpBits!=NULL;} 00282 // BOOL AllocateDIB(BOOL bTransparent = FALSE); 00283 BOOL SetDIB(LPBITMAPINFO lpnewInfo, LPBYTE lpnewBits) {lpBitmapInfo = lpnewInfo; lpBits = lpnewBits; return TRUE;} 00284 BOOL SetClipRect(DocRect NewClipRect) {CaptureRect = NewClipRect; return TRUE;} 00285 void SetTransparent(BOOL bNewState); 00286 BOOL FreeDIB(); 00287 void SetDirectSupplier(NodeRenderableInk* pSupplier) {m_pDirectBitmapSupplier = pSupplier;} 00288 NodeRenderableInk* GetDirectSupplier() const {return m_pDirectBitmapSupplier;} 00289 BOOL ConsumeDirectBitmap(NodeRenderableInk* pSupplier); 00290 void SetClipRegionAttrValue(ClipRegionAttribute* pClipRegion) {m_pClipRegionAttrValue = pClipRegion;} 00291 00292 const REGION* GetCachedClipRegion(ClipRegionAttribute* pClipAttr); 00293 void SetCachedClipRegion(ClipRegionAttribute* pClipAttr, const REGION* pClipRegion); 00294 void RemoveCachedClipRegion(ClipRegionAttribute* pClipAttr); 00295 void RemoveAllCachedClipRegions(); 00296 00297 // Public Properties 00298 public: 00299 // These values record the state of THIS capture! NOT the values to restore 00300 // when this capture ends! 00301 DocRect CaptureRect; 00302 LPBITMAPINFO lpBitmapInfo; 00303 LPBYTE lpBits; 00304 Matrix CaptureMatrix; 00305 ColourContext* pColContext; 00306 CAPTUREINFO info; 00307 double dPixelsPerInch; 00308 00309 // Private members 00310 private: 00311 CCObject* m_pOwner; 00312 NodeRenderableInk* m_pDirectBitmapSupplier; 00313 ClipRegionMap m_ClipRegionMap; 00314 ClipRegionAttribute* m_pClipRegionAttrValue; 00315 00316 }; 00317 00318 #endif // INC_CaptureManager