1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <poll.h>
#include "salgdiimpl.hxx"
#include "vcl/salbtype.hxx"
#include "unx/pixmap.hxx"
#include "unx/salunx.h"
#include "unx/saldata.hxx"
#include "unx/saldisp.hxx"
#include "unx/salbmp.h"
#include "unx/salgdi.h"
#include "unx/salframe.h"
#include "unx/salvd.h"
#include "unx/x11/x11gdiimpl.h"
#include <unx/x11/xlimits.hxx>
#include "xrender_peer.hxx"
#include "unx/printergfx.hxx"
#include "vcl/bmpacc.hxx"
#include <outdata.hxx>
void X11SalGraphics::CopyScreenArea( Display* pDisplay,
Drawable aSrc, SalX11Screen nXScreenSrc, int nSrcDepth,
Drawable aDest, SalX11Screen nXScreenDest, int nDestDepth,
GC aDestGC,
int src_x, int src_y,
unsigned int w, unsigned int h,
int dest_x, int dest_y )
{
if( nSrcDepth == nDestDepth )
{
if( nXScreenSrc == nXScreenDest )
XCopyArea( pDisplay, aSrc, aDest, aDestGC,
src_x, src_y, w, h, dest_x, dest_y );
else
{
GetGenericData()->ErrorTrapPush();
XImage* pImage = XGetImage( pDisplay, aSrc, src_x, src_y, w, h,
AllPlanes, ZPixmap );
if( pImage )
{
if( pImage->data )
XPutImage( pDisplay, aDest, aDestGC, pImage,
0, 0, dest_x, dest_y, w, h );
XDestroyImage( pImage );
}
GetGenericData()->ErrorTrapPop();
}
}
else
{
X11SalBitmap aBM;
aBM.ImplCreateFromDrawable( aSrc, nXScreenSrc, nSrcDepth, src_x, src_y, w, h );
SalTwoRect aTwoRect(0, 0, w, h, dest_x, dest_y, w, h);
aBM.ImplDraw(aDest, nXScreenDest, nDestDepth, aTwoRect,aDestGC);
}
}
bool X11SalGraphics::FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, int nY )
{
X11GraphicsImpl& rImpl = dynamic_cast<X11GraphicsImpl&>(*mxImpl.get());
return rImpl.FillPixmapFromScreen( pPixmap, nX, nY );
}
bool X11SalGraphics::RenderPixmapToScreen( X11Pixmap* pPixmap, X11Pixmap* pMask, int nX, int nY )
{
SAL_INFO( "vcl", "RenderPixmapToScreen" );
X11GraphicsImpl& rImpl = dynamic_cast<X11GraphicsImpl&>(*mxImpl.get());
return rImpl.RenderPixmapToScreen( pPixmap, pMask, nX, nY );
}
bool X11SalGraphics::TryRenderCachedNativeControl(ControlCacheKey& rControlCacheKey, int nX, int nY)
{
SAL_INFO( "vcl", "TryRenderCachedNativeControl" );
X11GraphicsImpl& rImpl = dynamic_cast<X11GraphicsImpl&>(*mxImpl.get());
return rImpl.TryRenderCachedNativeControl(rControlCacheKey, nX, nY);
}
bool X11SalGraphics::RenderAndCacheNativeControl(X11Pixmap* pPixmap, X11Pixmap* pMask, int nX, int nY,
ControlCacheKey& rControlCacheKey)
{
SAL_INFO( "vcl", "RenderAndCachePixmap" );
X11GraphicsImpl& rImpl = dynamic_cast<X11GraphicsImpl&>(*mxImpl.get());
return rImpl.RenderAndCacheNativeControl(pPixmap, pMask, nX, nY, rControlCacheKey);
}
extern "C"
{
static Bool GraphicsExposePredicate( Display*, XEvent* pEvent, XPointer pFrameWindow )
{
Bool bRet = False;
if( (pEvent->type == GraphicsExpose || pEvent->type == NoExpose) &&
pEvent->xnoexpose.drawable == reinterpret_cast<Drawable>(pFrameWindow) )
{
bRet = True;
}
return bRet;
}
}
void X11SalGraphics::YieldGraphicsExpose()
{
// get frame if necessary
SalFrame* pFrame = m_pFrame;
Display* pDisplay = GetXDisplay();
::Window aWindow = GetDrawable();
if( ! pFrame )
{
const std::list< SalFrame* >& rFrames = vcl_sal::getSalDisplay(GetGenericData())->getFrames();
for( std::list< SalFrame* >::const_iterator it = rFrames.begin(); it != rFrames.end() && ! pFrame; ++it )
{
const SystemEnvData* pEnvData = (*it)->GetSystemData();
if( Drawable(pEnvData->aWindow) == aWindow )
pFrame = *it;
}
if( ! pFrame )
return;
}
XEvent aEvent;
while( XCheckTypedWindowEvent( pDisplay, aWindow, Expose, &aEvent ) )
{
SalPaintEvent aPEvt( aEvent.xexpose.x, aEvent.xexpose.y, aEvent.xexpose.width+1, aEvent.xexpose.height+1 );
pFrame->CallCallback( SALEVENT_PAINT, &aPEvt );
}
do
{
if( ! GetDisplay()->XIfEventWithTimeout( &aEvent, reinterpret_cast<XPointer>(aWindow), GraphicsExposePredicate ) )
// this should not happen at all; still sometimes it happens
break;
if( aEvent.type == NoExpose )
break;
if( pFrame )
{
SalPaintEvent aPEvt( aEvent.xgraphicsexpose.x, aEvent.xgraphicsexpose.y, aEvent.xgraphicsexpose.width+1, aEvent.xgraphicsexpose.height+1 );
pFrame->CallCallback( SALEVENT_PAINT, &aPEvt );
}
} while( aEvent.xgraphicsexpose.count != 0 );
}
void X11SalGraphics::copyBits( const SalTwoRect& rPosAry,
SalGraphics *pSSrcGraphics )
{
mxImpl->copyBits( rPosAry, pSSrcGraphics );
}
void X11SalGraphics::copyArea ( long nDestX, long nDestY,
long nSrcX, long nSrcY,
long nSrcWidth, long nSrcHeight,
sal_uInt16 n )
{
mxImpl->copyArea( nDestX, nDestY, nSrcX, nSrcY, nSrcWidth, nSrcHeight, n );
}
bool X11SalGraphics::blendBitmap( const SalTwoRect& rTR,
const SalBitmap& rBitmap )
{
return mxImpl->blendBitmap( rTR, rBitmap );
}
bool X11SalGraphics::blendAlphaBitmap( const SalTwoRect& rTR,
const SalBitmap& rSrcBitmap,
const SalBitmap& rMaskBitmap,
const SalBitmap& rAlphaBitmap )
{
return mxImpl->blendAlphaBitmap( rTR, rSrcBitmap, rMaskBitmap, rAlphaBitmap );
}
void X11SalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap )
{
mxImpl->drawBitmap( rPosAry, rSalBitmap );
}
void X11SalGraphics::drawBitmap( const SalTwoRect& rPosAry,
const SalBitmap& rSrcBitmap,
const SalBitmap& rMaskBitmap )
{
mxImpl->drawBitmap( rPosAry, rSrcBitmap, rMaskBitmap );
}
bool X11SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
const SalBitmap& rSrcBitmap, const SalBitmap& rAlphaBmp )
{
return mxImpl->drawAlphaBitmap( rTR, rSrcBitmap, rAlphaBmp );
}
bool X11SalGraphics::drawTransformedBitmap(
const basegfx::B2DPoint& rNull,
const basegfx::B2DPoint& rX,
const basegfx::B2DPoint& rY,
const SalBitmap& rSourceBitmap,
const SalBitmap* pAlphaBitmap)
{
return mxImpl->drawTransformedBitmap( rNull, rX, rY, rSourceBitmap, pAlphaBitmap );
}
bool X11SalGraphics::drawAlphaRect( long nX, long nY, long nWidth,
long nHeight, sal_uInt8 nTransparency )
{
return mxImpl->drawAlphaRect( nX, nY, nWidth, nHeight, nTransparency );
}
void X11SalGraphics::drawMask( const SalTwoRect& rPosAry,
const SalBitmap &rSalBitmap,
SalColor nMaskColor )
{
mxImpl->drawMask( rPosAry, rSalBitmap, nMaskColor );
}
SalBitmap *X11SalGraphics::getBitmap( long nX, long nY, long nDX, long nDY )
{
return mxImpl->getBitmap( nX, nY, nDX, nDY );
}
SalColor X11SalGraphics::getPixel( long nX, long nY )
{
return mxImpl->getPixel( nX, nY );
}
void X11SalGraphics::invert( long nX,
long nY,
long nDX,
long nDY,
SalInvert nFlags )
{
mxImpl->invert( nX, nY, nDX, nDY, nFlags );
}
bool X11SalGraphics::supportsOperation( OutDevSupportType eType ) const
{
bool bRet = false;
switch( eType )
{
case OutDevSupport_TransparentRect:
case OutDevSupport_B2DDraw:
{
XRenderPeer& rPeer = XRenderPeer::GetInstance();
const SalDisplay* pSalDisp = GetDisplay();
const SalVisual& rSalVis = pSalDisp->GetVisual( m_nXScreen );
Visual* pDstXVisual = rSalVis.GetVisual();
XRenderPictFormat* pDstVisFmt = rPeer.FindVisualFormat( pDstXVisual );
if( pDstVisFmt )
bRet = true;
}
break;
default: break;
}
return bRet;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|