1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <salgdiimpl.hxx>
22 #include <vcl/sysdata.hxx>
24 #include <unx/saldisp.hxx>
25 #include <unx/salgdi.h>
26 #include <unx/x11/xrender_peer.hxx>
27 #include <salframe.hxx>
31 static Bool
GraphicsExposePredicate( Display
*, XEvent
* pEvent
, const XPointer pFrameWindow
)
34 if( (pEvent
->type
== GraphicsExpose
|| pEvent
->type
== NoExpose
) &&
35 pEvent
->xnoexpose
.drawable
== reinterpret_cast<Drawable
>(pFrameWindow
) )
43 void X11SalGraphics::YieldGraphicsExpose()
45 // get frame if necessary
46 SalFrame
* pFrame
= m_pFrame
;
47 Display
* pDisplay
= GetXDisplay();
48 ::Window aWindow
= GetDrawable();
51 for (auto pSalFrame
: vcl_sal::getSalDisplay(GetGenericUnixSalData())->getFrames() )
53 const SystemEnvData
* pEnvData
= pSalFrame
->GetSystemData();
54 if( Drawable(pEnvData
->GetWindowHandle(pSalFrame
)) == aWindow
)
65 while( XCheckTypedWindowEvent( pDisplay
, aWindow
, Expose
, &aEvent
) )
67 SalPaintEvent
aPEvt( aEvent
.xexpose
.x
, aEvent
.xexpose
.y
, aEvent
.xexpose
.width
+1, aEvent
.xexpose
.height
+1 );
68 pFrame
->CallCallback( SalEvent::Paint
, &aPEvt
);
73 if( ! GetDisplay()->XIfEventWithTimeout( &aEvent
, reinterpret_cast<XPointer
>(aWindow
), GraphicsExposePredicate
) )
74 // this should not happen at all; still sometimes it happens
77 if( aEvent
.type
== NoExpose
)
82 SalPaintEvent
aPEvt( aEvent
.xgraphicsexpose
.x
, aEvent
.xgraphicsexpose
.y
, aEvent
.xgraphicsexpose
.width
+1, aEvent
.xgraphicsexpose
.height
+1 );
83 pFrame
->CallCallback( SalEvent::Paint
, &aPEvt
);
85 } while( aEvent
.xgraphicsexpose
.count
!= 0 );
88 void X11SalGraphics::copyBits( const SalTwoRect
& rPosAry
,
89 SalGraphics
*pSSrcGraphics
)
91 mxImpl
->copyBits( rPosAry
, pSSrcGraphics
);
94 void X11SalGraphics::copyArea ( tools::Long nDestX
, tools::Long nDestY
,
95 tools::Long nSrcX
, tools::Long nSrcY
,
96 tools::Long nSrcWidth
, tools::Long nSrcHeight
,
97 bool bWindowInvalidate
)
99 mxImpl
->copyArea( nDestX
, nDestY
, nSrcX
, nSrcY
, nSrcWidth
, nSrcHeight
, bWindowInvalidate
);
102 bool X11SalGraphics::blendBitmap( const SalTwoRect
& rTR
,
103 const SalBitmap
& rBitmap
)
105 return mxImpl
->blendBitmap( rTR
, rBitmap
);
108 bool X11SalGraphics::blendAlphaBitmap( const SalTwoRect
& rTR
,
109 const SalBitmap
& rSrcBitmap
,
110 const SalBitmap
& rMaskBitmap
,
111 const SalBitmap
& rAlphaBitmap
)
113 return mxImpl
->blendAlphaBitmap( rTR
, rSrcBitmap
, rMaskBitmap
, rAlphaBitmap
);
116 void X11SalGraphics::drawBitmap( const SalTwoRect
& rPosAry
, const SalBitmap
& rSalBitmap
)
118 mxImpl
->drawBitmap( rPosAry
, rSalBitmap
);
121 void X11SalGraphics::drawBitmap( const SalTwoRect
& rPosAry
,
122 const SalBitmap
& rSrcBitmap
,
123 const SalBitmap
& rMaskBitmap
)
125 mxImpl
->drawBitmap( rPosAry
, rSrcBitmap
, rMaskBitmap
);
128 bool X11SalGraphics::drawAlphaBitmap( const SalTwoRect
& rTR
,
129 const SalBitmap
& rSrcBitmap
, const SalBitmap
& rAlphaBmp
)
131 return mxImpl
->drawAlphaBitmap( rTR
, rSrcBitmap
, rAlphaBmp
);
134 bool X11SalGraphics::drawTransformedBitmap(
135 const basegfx::B2DPoint
& rNull
,
136 const basegfx::B2DPoint
& rX
,
137 const basegfx::B2DPoint
& rY
,
138 const SalBitmap
& rSourceBitmap
,
139 const SalBitmap
* pAlphaBitmap
)
141 return mxImpl
->drawTransformedBitmap( rNull
, rX
, rY
, rSourceBitmap
, pAlphaBitmap
);
144 bool X11SalGraphics::drawAlphaRect( tools::Long nX
, tools::Long nY
, tools::Long nWidth
,
145 tools::Long nHeight
, sal_uInt8 nTransparency
)
147 return mxImpl
->drawAlphaRect( nX
, nY
, nWidth
, nHeight
, nTransparency
);
150 void X11SalGraphics::drawMask( const SalTwoRect
& rPosAry
,
151 const SalBitmap
&rSalBitmap
,
154 mxImpl
->drawMask( rPosAry
, rSalBitmap
, nMaskColor
);
157 std::shared_ptr
<SalBitmap
> X11SalGraphics::getBitmap( tools::Long nX
, tools::Long nY
, tools::Long nDX
, tools::Long nDY
)
159 return mxImpl
->getBitmap( nX
, nY
, nDX
, nDY
);
162 Color
X11SalGraphics::getPixel( tools::Long nX
, tools::Long nY
)
164 return mxImpl
->getPixel( nX
, nY
);
167 void X11SalGraphics::invert( tools::Long nX
,
173 mxImpl
->invert( nX
, nY
, nDX
, nDY
, nFlags
);
176 bool X11SalGraphics::supportsOperation( OutDevSupportType eType
) const
178 return mxImpl
->supportsOperation(eType
);
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */