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
23#include <tools/debug.hxx>
24#include <vcl/metaact.hxx>
25#include <vcl/virdev.hxx>
26#include <vcl/gdimtf.hxx>
27#include <vcl/outdev.hxx>
28
29#include <salgdi.hxx>
30
32 const Point& rPos, const Size& rSize, const Size& rBackgroundSize) const
33{
34 rSaveDevice.DrawOutDev(Point(), rBackgroundSize, rPos, rSize, *this);
35}
36
38{
39
40 return PixelToLogic( maRegion );
41}
42
44{
45
46 if ( mpMetaFile )
48
49 SetDeviceClipRegion( nullptr );
50
51 if( mpAlphaVDev )
53}
54
56{
57
58 if ( mpMetaFile )
59 mpMetaFile->AddAction( new MetaClipRegionAction( rRegion, true ) );
60
61 if ( rRegion.IsNull() )
62 {
63 SetDeviceClipRegion( nullptr );
64 }
65 else
66 {
67 vcl::Region aRegion = LogicToPixel( rRegion );
68 SetDeviceClipRegion( &aRegion );
69 }
70
71 if( mpAlphaVDev )
72 mpAlphaVDev->SetClipRegion( rRegion );
73}
74
75bool OutputDevice::SelectClipRegion( const vcl::Region& rRegion, SalGraphics* pGraphics )
76{
78
79 if( !pGraphics )
80 {
81 if( !mpGraphics && !AcquireGraphics() )
82 return false;
83 assert(mpGraphics);
84 pGraphics = mpGraphics;
85 }
86
87 bool bClipRegion = pGraphics->SetClipRegion( rRegion, *this );
88 OSL_ENSURE( bClipRegion, "OutputDevice::SelectClipRegion() - can't create region" );
89 return bClipRegion;
90}
91
93{
94
95 if ( mbClipRegion )
96 {
97 if( mpMetaFile )
98 mpMetaFile->AddAction( new MetaMoveClipRegionAction( nHorzMove, nVertMove ) );
99
101 ImplLogicHeightToDevicePixel( nVertMove ) );
102 mbInitClipRegion = true;
103 }
104
105 if( mpAlphaVDev )
106 mpAlphaVDev->MoveClipRegion( nHorzMove, nVertMove );
107}
108
110{
111
112 if ( mpMetaFile )
114
115 tools::Rectangle aRect = LogicToPixel( rRect );
116 maRegion.Intersect( aRect );
117 mbClipRegion = true;
118 mbInitClipRegion = true;
119
120 if( mpAlphaVDev )
122}
123
125{
126
127 if(!rRegion.IsNull())
128 {
129 if ( mpMetaFile )
131
132 vcl::Region aRegion = LogicToPixel( rRegion );
133 maRegion.Intersect( aRegion );
134 mbClipRegion = true;
135 mbInitClipRegion = true;
136 }
137
138 if( mpAlphaVDev )
140}
141
143{
145
146 if ( mbClipRegion )
147 {
148 if ( maRegion.IsEmpty() )
149 mbOutputClipped = true;
150 else
151 {
152 mbOutputClipped = false;
153
154 // #102532# Respect output offset also for clip region
156
157 if ( aRegion.IsEmpty() )
158 {
159 mbOutputClipped = true;
160 }
161 else
162 {
163 mbOutputClipped = false;
164 SelectClipRegion( aRegion );
165 }
166 }
167
168 mbClipRegionSet = true;
169 }
170 else
171 {
172 if ( mbClipRegionSet )
173 {
174 if (mpGraphics)
176 mbClipRegionSet = false;
177 }
178
179 mbOutputClipped = false;
180 }
181
182 mbInitClipRegion = false;
183}
184
186{
188 mnOutOffY,
191 });
192 return aRegion;
193}
194
196{
197 return GetClipRegion();
198}
199
201{
202 // this is only used in Window, but we still need it as it's called
203 // on in other clipping functions
204}
205
207{
209
210 if ( !pRegion )
211 {
212 if ( mbClipRegion )
213 {
214 maRegion = vcl::Region(true);
215 mbClipRegion = false;
216 mbInitClipRegion = true;
217 }
218 }
219 else
220 {
221 maRegion = *pRegion;
222 mbClipRegion = true;
223 mbInitClipRegion = true;
224 }
225}
226
227/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddAction(const rtl::Reference< MetaAction > &pAction)
Definition: gdimtf.cxx:581
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:226
tools::Long mnOutOffY
Output offset for device output in pixel (pseudo window offset within window system's frames)
Definition: outdev.hxx:210
tools::Long GetOutputWidthPixel() const
Definition: outdev.hxx:317
bool mbOutputClipped
Definition: outdev.hxx:246
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:208
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
Definition: map.cxx:1169
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:186
tools::Long GetOutputHeightPixel() const
Definition: outdev.hxx:318
SAL_DLLPRIVATE tools::Long ImplLogicHeightToDevicePixel(tools::Long nHeight) const
Convert a logical height to a height in units of device pixels.
Definition: map.cxx:345
bool mbClipRegion
Definition: outdev.hxx:242
virtual void DrawOutDev(const Point &rDestPt, const Size &rDestSize, const Point &rSrcPt, const Size &rSrcSize)
Definition: outdev.cxx:418
SAL_DLLPRIVATE tools::Long ImplLogicWidthToDevicePixel(tools::Long nWidth) const
Convert a logical width to a width in units of device pixels.
Definition: map.cxx:337
virtual void ClipToPaintRegion(tools::Rectangle &rDstRect)
SalGraphics * mpGraphics
Graphics context to draw on.
Definition: outdev.hxx:183
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:253
void MoveClipRegion(tools::Long nHorzMove, tools::Long nVertMove)
bool mbClipRegionSet
Definition: outdev.hxx:254
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:938
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:197
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:636
SAL_DLLPRIVATE void SetDeviceClipRegion(const vcl::Region *pRegion)
virtual void ResetClipRegion()=0
bool SetClipRegion(const vcl::Region &, const OutputDevice &rOutDev)
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