1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SDR_OVERLAY_OVERLAYMANAGERBUFFERED_HXX
25 #define _SDR_OVERLAY_OVERLAYMANAGERBUFFERED_HXX
26 
27 #include <svx/sdr/overlay/overlaymanager.hxx>
28 #include <basegfx/range/b2irange.hxx>
29 #include <vcl/virdev.hxx>
30 
31 //////////////////////////////////////////////////////////////////////////////
32 // predeclarations
33 
34 class VirtualDevice;
35 
36 //////////////////////////////////////////////////////////////////////////////
37 
38 namespace sdr
39 {
40 	namespace overlay
41 	{
42 		class OverlayManagerBuffered : public OverlayManager
43 		{
44 		protected:
45 			// The VirtualDevice for draw window content buffering, this
46 			// is the view content without overlay
47 			VirtualDevice							maBufferDevice;
48 
49 			// #i73602# The VirtualDevice for OverlayPaint buffering. This
50 			// is an extra device to avoid flickering of overlay paints
51 			VirtualDevice							maOutputBufferDevice;
52 
53 			// Timer for buffering
54 			Timer									maBufferTimer;
55 
56 			// Range for buffering (in pixel to be independent from mapMode)
57 			basegfx::B2IRange						maBufferRememberedRangePixel;
58 
59 			// bitfield
60 			// Flag to decide if PreRendering shall be used for overlay refreshes.
61 			// Default is false.
62 			unsigned								mbRefreshWithPreRendering : 1;
63 
64 			// link for timer
65 			DECL_LINK(ImpBufferTimerHandler, AutoTimer*);
66 
67 			// Internal methods for buffering
68 			void ImpPrepareBufferDevice();
69 			void ImpRestoreBackground() const ;
70 			void ImpRestoreBackground(const Region& rRegionPixel) const;
71 			void ImpSaveBackground(const Region& rRegion, OutputDevice* pPreRenderDevice = 0L);
72 
73 		public:
74 			// when handing over another OverlayManager at construction, the OverlayObjects
75 			// will be taken over from it. The new one will have added all OverlayObjects
76 			// while the handed over one will have none
77 			OverlayManagerBuffered(
78 				OutputDevice& rOutputDevice,
79 				OverlayManager* pOldOverlayManager = 0,
80 				bool bRefreshWithPreRendering = false);
81 			virtual ~OverlayManagerBuffered();
82 
83 			// complete redraw
84 			virtual void completeRedraw(const Region& rRegion, OutputDevice* pPreRenderDevice = 0L) const;
85 
86 			// flush. Do buffered updates.
87 			virtual void flush();
88 
89 			// #i68597# part of content gets copied, react on it
90 			virtual void copyArea(const Point& rDestPt, const Point& rSrcPt, const Size& rSrcSize);
91 
92 			// restore part of background. Implemented form buffered versions only.
93 			virtual void restoreBackground(const Region& rRegion) const;
94 
95 			// invalidate the given range at local OutputDevice
96 			virtual void invalidateRange(const basegfx::B2DRange& rRange);
97 
98 			// access to RefreshWithPreRendering Flag
99 			bool DoRefreshWithPreRendering() const { return mbRefreshWithPreRendering; }
100 			void SetRefreshWithPreRendering(bool bNew);
101 		};
102 	} // end of namespace overlay
103 } // end of namespace sdr
104 
105 //////////////////////////////////////////////////////////////////////////////
106 
107 #endif //_SDR_OVERLAY_OVERLAYMANAGERBUFFERED_HXX
108 
109 // eof
110