LibreOffice Module vcl (master) 1
outdev/clipping.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21#include <osl/diagnose.h>
22#include <tools/debug.hxx>
23
24#include <vcl/metaact.hxx>
25#include <vcl/virdev.hxx>
26
27#include <salgdi.hxx>
28
30 const Point& rPos, const Size& rSize, const Size& rBackgroundSize) const
31{
32 rSaveDevice.DrawOutDev(Point(), rBackgroundSize, rPos, rSize, *this);
33}
34
36{
37
38 return PixelToLogic( maRegion );
39}
40
42{
43
44 if ( mpMetaFile )
46
47 SetDeviceClipRegion( nullptr );
48
49 if( mpAlphaVDev )
51}
52
54{
55
56 if ( mpMetaFile )
57 mpMetaFile->AddAction( new MetaClipRegionAction( rRegion, true ) );
58
59 if ( rRegion.IsNull() )
60 {
61 SetDeviceClipRegion( nullptr );
62 }
63 else
64 {
65 vcl::Region aRegion = LogicToPixel( rRegion );
66 SetDeviceClipRegion( &aRegion );
67 }
68
69 if( mpAlphaVDev )
70 mpAlphaVDev->SetClipRegion( rRegion );
71}
72
73bool OutputDevice::SelectClipRegion( const vcl::Region& rRegion, SalGraphics* pGraphics )
74{
76
77 if( !pGraphics )
78 {
79 if( !mpGraphics && !AcquireGraphics() )
80 return false;
81 assert(mpGraphics);
82 pGraphics = mpGraphics;
83 }
84
85 pGraphics->SetClipRegion( rRegion, *this );
86 return true;
87}
88
90{
91
92 if ( mbClipRegion )
93 {
94 if( mpMetaFile )
95 mpMetaFile->AddAction( new MetaMoveClipRegionAction( nHorzMove, nVertMove ) );
96
98 ImplLogicHeightToDevicePixel( nVertMove ) );
99 mbInitClipRegion = true;
100 }
101
102 if( mpAlphaVDev )
103 mpAlphaVDev->MoveClipRegion( nHorzMove, nVertMove );
104}
105
107{
108
109 if ( mpMetaFile )
111
112 tools::Rectangle aRect = LogicToPixel( rRect );
113 maRegion.Intersect( aRect );
114 mbClipRegion = true;
115 mbInitClipRegion = true;
116
117 if( mpAlphaVDev )
119}
120
122{
123
124 if(!rRegion.IsNull())
125 {
126 if ( mpMetaFile )
128
129 vcl::Region aRegion = LogicToPixel( rRegion );
130 maRegion.Intersect( aRegion );
131 mbClipRegion = true;
132 mbInitClipRegion = true;
133 }
134
135 if( mpAlphaVDev )
137}
138
140{
142
143 if ( mbClipRegion )
144 {
145 if ( maRegion.IsEmpty() )
146 mbOutputClipped = true;
147 else
148 {
149 mbOutputClipped = false;
150
151 // #102532# Respect output offset also for clip region
153
154 if ( aRegion.IsEmpty() )
155 {
156 mbOutputClipped = true;
157 }
158 else
159 {
160 mbOutputClipped = false;
161 SelectClipRegion( aRegion );
162 }
163 }
164
165 mbClipRegionSet = true;
166 }
167 else
168 {
169 if ( mbClipRegionSet )
170 {
171 if (mpGraphics)
173 mbClipRegionSet = false;
174 }
175
176 mbOutputClipped = false;
177 }
178
179 mbInitClipRegion = false;
180}
181
183{
185 mnOutOffY,
188 });
189 return aRegion;
190}
191
193{
194 return GetClipRegion();
195}
196
198{
199 // this is only used in Window, but we still need it as it's called
200 // on in other clipping functions
201}
202
204{
206
207 if ( !pRegion )
208 {
209 if ( mbClipRegion )
210 {
211 maRegion = vcl::Region(true);
212 mbClipRegion = false;
213 mbInitClipRegion = true;
214 }
215 }
216 else
217 {
218 maRegion = *pRegion;
219 mbClipRegion = true;
220 mbInitClipRegion = true;
221 }
222}
223
224/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:585
virtual void InitClipRegion()
virtual vcl::Region GetActiveClipRegion() const
virtual void SaveBackground(VirtualDevice &rSaveDevice, const Point &rPos, const Size &rSize, const Size &rBackgroundSize) const
vcl::Region GetClipRegion() const
vcl::Region maRegion
Definition: outdev.hxx:225
tools::Long mnOutOffY
Output offset for device output in pixel (pseudo window offset within window system's frames)
Definition: outdev.hxx:209
tools::Long GetOutputWidthPixel() const
Definition: outdev.hxx:316
bool mbOutputClipped
Definition: outdev.hxx:245
virtual bool AcquireGraphics() const =0
Acquire a graphics device that the output device uses to draw on.
tools::Long mnOutOffX
Output offset for device output in pixel (pseudo window offset within window system's frames)
Definition: outdev.hxx:207
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
Definition: map.cxx:1110
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:185
tools::Long GetOutputHeightPixel() const
Definition: outdev.hxx:317
SAL_DLLPRIVATE tools::Long ImplLogicHeightToDevicePixel(tools::Long nHeight) const
Convert a logical height to a height in units of device pixels.
Definition: map.cxx:288
bool mbClipRegion
Definition: outdev.hxx:241
virtual void DrawOutDev(const Point &rDestPt, const Size &rDestSize, const Point &rSrcPt, const Size &rSrcSize)
Definition: outdev.cxx:417
SAL_DLLPRIVATE tools::Long ImplLogicWidthToDevicePixel(tools::Long nWidth) const
Convert a logical width to a width in units of device pixels.
Definition: map.cxx:280
virtual void ClipToPaintRegion(tools::Rectangle &rDstRect)
SalGraphics * mpGraphics
Graphics context to draw on.
Definition: outdev.hxx:182
virtual vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const
Perform actual rect clip against outdev dimensions, to generate empty clips whenever one of the value...
bool mbInitClipRegion
Definition: outdev.hxx:252
void MoveClipRegion(tools::Long nHorzMove, tools::Long nVertMove)
bool mbClipRegionSet
Definition: outdev.hxx:253
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:879
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:196
bool SelectClipRegion(const vcl::Region &, SalGraphics *pGraphics=nullptr)
void IntersectClipRegion(const tools::Rectangle &rRect)
SAL_DLLPRIVATE vcl::Region ImplPixelToDevicePixel(const vcl::Region &rRegion) const
Convert a region in pixel units to a region in device pixel units and coords.
Definition: map.cxx:579
SAL_DLLPRIVATE void SetDeviceClipRegion(const vcl::Region *pRegion)
void SetClipRegion(const vcl::Region &, const OutputDevice &rOutDev)
virtual void ResetClipRegion()=0
void Move(tools::Long nHorzMove, tools::Long nVertMove)
Definition: region.cxx:401
bool IsNull() const
Definition: region.hxx:99
void Intersect(const tools::Rectangle &rRegion)
Definition: region.cxx:583
bool IsEmpty() const
Definition: region.cxx:229
#define DBG_TESTSOLARMUTEX()
long Long