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