1ebfcd9afSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3ebfcd9afSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4ebfcd9afSAndrew Rist * or more contributor license agreements. See the NOTICE file
5ebfcd9afSAndrew Rist * distributed with this work for additional information
6ebfcd9afSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7ebfcd9afSAndrew Rist * to you under the Apache License, Version 2.0 (the
8ebfcd9afSAndrew Rist * "License"); you may not use this file except in compliance
9ebfcd9afSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11ebfcd9afSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13ebfcd9afSAndrew Rist * Unless required by applicable law or agreed to in writing,
14ebfcd9afSAndrew Rist * software distributed under the License is distributed on an
15ebfcd9afSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ebfcd9afSAndrew Rist * KIND, either express or implied. See the License for the
17ebfcd9afSAndrew Rist * specific language governing permissions and limitations
18ebfcd9afSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20ebfcd9afSAndrew Rist *************************************************************/
21ebfcd9afSAndrew Rist
22ebfcd9afSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef _SV_XRENDER_PEER_HXX
25cdf0e10cSrcweir #define _SV_XRENDER_PEER_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <tools/prex.h>
28cdf0e10cSrcweir struct _XTrap; // on some older systems this is not declared within Xrender.h
29cdf0e10cSrcweir #include <X11/extensions/Xrender.h>
30cdf0e10cSrcweir #include <tools/postx.h>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include <vcl/salgtype.hxx>
33cdf0e10cSrcweir #include <osl/module.h>
34cdf0e10cSrcweir
35*248a599fSHerbert Dürr typedef Glyph XRenderGlyph;
36*248a599fSHerbert Dürr
37cdf0e10cSrcweir class XRenderPeer
38cdf0e10cSrcweir {
39cdf0e10cSrcweir public:
40cdf0e10cSrcweir static XRenderPeer& GetInstance();
41cdf0e10cSrcweir int GetVersion() const;
42cdf0e10cSrcweir
43cdf0e10cSrcweir sal_uInt32 InitRenderText();
44cdf0e10cSrcweir
45cdf0e10cSrcweir protected:
46cdf0e10cSrcweir XRenderPeer();
47cdf0e10cSrcweir ~XRenderPeer();
48cdf0e10cSrcweir void InitRenderLib();
49cdf0e10cSrcweir
50cdf0e10cSrcweir Display* mpDisplay;
51cdf0e10cSrcweir XRenderPictFormat* mpStandardFormatA8;
52cdf0e10cSrcweir int mnRenderVersion;
53cdf0e10cSrcweir oslModule mpRenderLib;
54cdf0e10cSrcweir
55cdf0e10cSrcweir public:
56cdf0e10cSrcweir XRenderPictFormat* GetStandardFormatA8() const;
57cdf0e10cSrcweir XRenderPictFormat* FindStandardFormat(int nFormat) const;
58cdf0e10cSrcweir
59cdf0e10cSrcweir // the methods below are thin wrappers for the XRENDER API
60cdf0e10cSrcweir XRenderPictFormat* FindVisualFormat( Visual* ) const;
61cdf0e10cSrcweir XRenderPictFormat* FindPictureFormat( unsigned long nMask,
62cdf0e10cSrcweir const XRenderPictFormat& ) const;
63cdf0e10cSrcweir Picture CreatePicture( Drawable, const XRenderPictFormat*,
64cdf0e10cSrcweir unsigned long nDrawable, const XRenderPictureAttributes* ) const;
65cdf0e10cSrcweir void ChangePicture( Picture, unsigned long nValueMask,
66cdf0e10cSrcweir const XRenderPictureAttributes* ) const;
67cdf0e10cSrcweir void SetPictureClipRegion( Picture, XLIB_Region ) const;
68cdf0e10cSrcweir void CompositePicture( int nOp, Picture aSrc, Picture aMask, Picture aDst,
69cdf0e10cSrcweir int nXSrc, int nYSrc, int nXMask, int nYMask,
70cdf0e10cSrcweir int nXDst, int nYDst, unsigned nWidth, unsigned nHeight ) const;
71cdf0e10cSrcweir void FreePicture( Picture ) const;
72cdf0e10cSrcweir
73cdf0e10cSrcweir GlyphSet CreateGlyphSet() const;
74cdf0e10cSrcweir void FreeGlyphSet( GlyphSet ) const;
75*248a599fSHerbert Dürr void AddGlyph( GlyphSet, XRenderGlyph nXRGlyph, const XGlyphInfo&,
76cdf0e10cSrcweir const char* pBuffer, int nBufSize ) const;
77*248a599fSHerbert Dürr void FreeGlyph( GlyphSet, XRenderGlyph nXRGlyphId ) const;
78cdf0e10cSrcweir void CompositeString32( Picture aSrc, Picture aDst, GlyphSet,
79cdf0e10cSrcweir int nDstX, int nDstY, const unsigned* pText, int nTextLen ) const;
80cdf0e10cSrcweir void FillRectangle( int nOp, Picture aDst, const XRenderColor*,
81cdf0e10cSrcweir int nX, int nY, unsigned nW, unsigned nH ) const;
82cdf0e10cSrcweir void CompositeTrapezoids( int nOp, Picture aSrc, Picture aDst,
83cdf0e10cSrcweir const XRenderPictFormat*, int nXSrc, int nYSrc,
84cdf0e10cSrcweir const XTrapezoid*, int nCount ) const;
85cdf0e10cSrcweir bool AddTraps( Picture aDst, int nXOfs, int nYOfs,
86cdf0e10cSrcweir const _XTrap*, int nCount ) const;
87cdf0e10cSrcweir
AreTrapezoidsSupported() const88cdf0e10cSrcweir bool AreTrapezoidsSupported() const
89cdf0e10cSrcweir #ifdef XRENDER_LINK
90cdf0e10cSrcweir { return true; }
91cdf0e10cSrcweir #else
92cdf0e10cSrcweir { return mpXRenderCompositeTrapezoids!=NULL; }
93cdf0e10cSrcweir
94cdf0e10cSrcweir private:
95cdf0e10cSrcweir XRenderPictFormat* (*mpXRenderFindFormat)(Display*,unsigned long,
96cdf0e10cSrcweir const XRenderPictFormat*,int);
97cdf0e10cSrcweir XRenderPictFormat* (*mpXRenderFindVisualFormat)(Display*,Visual*);
98cdf0e10cSrcweir XRenderPictFormat* (*mpXRenderFindStandardFormat)(Display*,int);
99cdf0e10cSrcweir Bool (*mpXRenderQueryExtension)(Display*,int*,int*);
100cdf0e10cSrcweir void (*mpXRenderQueryVersion)(Display*,int*,int*);
101cdf0e10cSrcweir
102cdf0e10cSrcweir Picture (*mpXRenderCreatePicture)(Display*,Drawable, const XRenderPictFormat*,
103cdf0e10cSrcweir unsigned long,const XRenderPictureAttributes*);
104cdf0e10cSrcweir void (*mpXRenderChangePicture)(Display*,Picture,
105cdf0e10cSrcweir unsigned long,const XRenderPictureAttributes*);
106cdf0e10cSrcweir void (*mpXRenderSetPictureClipRegion)(Display*,Picture,XLIB_Region);
107cdf0e10cSrcweir void (*mpXRenderFreePicture)(Display*,Picture);
108cdf0e10cSrcweir void (*mpXRenderComposite)(Display*,int,Picture,Picture,Picture,
109cdf0e10cSrcweir int,int,int,int,int,int,unsigned,unsigned);
110cdf0e10cSrcweir
111cdf0e10cSrcweir GlyphSet (*mpXRenderCreateGlyphSet)(Display*, const XRenderPictFormat*);
112cdf0e10cSrcweir void (*mpXRenderFreeGlyphSet)(Display*,GlyphSet);
113cdf0e10cSrcweir void (*mpXRenderAddGlyphs)(Display*,GlyphSet,Glyph*,
114cdf0e10cSrcweir const XGlyphInfo*,int,const char*,int);
115cdf0e10cSrcweir void (*mpXRenderFreeGlyphs)(Display*,GlyphSet,Glyph*,int);
116cdf0e10cSrcweir void (*mpXRenderCompositeString32)(Display*,int,Picture,Picture,
117cdf0e10cSrcweir const XRenderPictFormat*,GlyphSet,int,int,int,int,const unsigned*,int);
118cdf0e10cSrcweir void (*mpXRenderFillRectangle)(Display*,int,Picture,
119cdf0e10cSrcweir const XRenderColor*,int,int,unsigned int,unsigned int);
120cdf0e10cSrcweir void (*mpXRenderCompositeTrapezoids)(Display*,int,Picture,Picture,
121cdf0e10cSrcweir const XRenderPictFormat*,int,int,const XTrapezoid*,int);
122cdf0e10cSrcweir void (*mpXRenderAddTraps)(Display*,Picture,int,int,const _XTrap*,int);
123cdf0e10cSrcweir #endif // XRENDER_LINK
124cdf0e10cSrcweir };
125cdf0e10cSrcweir
126cdf0e10cSrcweir //=====================================================================
127cdf0e10cSrcweir
128cdf0e10cSrcweir class ScopedPic
129cdf0e10cSrcweir {
130cdf0e10cSrcweir public:
131cdf0e10cSrcweir ScopedPic( XRenderPeer& rPeer, Picture& rPic );
132cdf0e10cSrcweir ~ScopedPic();
133cdf0e10cSrcweir Picture& Get();
134cdf0e10cSrcweir
135cdf0e10cSrcweir private:
136cdf0e10cSrcweir XRenderPeer& mrRenderPeer;
137cdf0e10cSrcweir Picture maPicture;
138cdf0e10cSrcweir
139cdf0e10cSrcweir private: // prevent copy and assignmet
140cdf0e10cSrcweir ScopedPic( const ScopedPic& );
141cdf0e10cSrcweir void operator=( const ScopedPic& );
142cdf0e10cSrcweir };
143cdf0e10cSrcweir
144cdf0e10cSrcweir //=====================================================================
145cdf0e10cSrcweir
GetVersion() const146cdf0e10cSrcweir inline int XRenderPeer::GetVersion() const
147cdf0e10cSrcweir {
148cdf0e10cSrcweir return mnRenderVersion;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir
GetStandardFormatA8() const151cdf0e10cSrcweir inline XRenderPictFormat* XRenderPeer::GetStandardFormatA8() const
152cdf0e10cSrcweir {
153cdf0e10cSrcweir return mpStandardFormatA8;
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
FindStandardFormat(int nFormat) const156cdf0e10cSrcweir inline XRenderPictFormat* XRenderPeer::FindStandardFormat(int nFormat) const
157cdf0e10cSrcweir {
158cdf0e10cSrcweir #ifdef XRENDER_LINK
159cdf0e10cSrcweir return XRenderFindStandardFormat(mpDisplay, nFormat);
160cdf0e10cSrcweir #else
161cdf0e10cSrcweir return (*mpXRenderFindStandardFormat)(mpDisplay, nFormat);
162cdf0e10cSrcweir #endif
163cdf0e10cSrcweir }
164cdf0e10cSrcweir
FindVisualFormat(Visual * pVisual) const165cdf0e10cSrcweir inline XRenderPictFormat* XRenderPeer::FindVisualFormat( Visual* pVisual ) const
166cdf0e10cSrcweir {
167cdf0e10cSrcweir #ifdef XRENDER_LINK
168cdf0e10cSrcweir return XRenderFindVisualFormat ( mpDisplay, pVisual );
169cdf0e10cSrcweir #else
170cdf0e10cSrcweir return (*mpXRenderFindVisualFormat)( mpDisplay, pVisual );
171cdf0e10cSrcweir #endif
172cdf0e10cSrcweir }
173cdf0e10cSrcweir
FindPictureFormat(unsigned long nFormatMask,const XRenderPictFormat & rFormatAttr) const174cdf0e10cSrcweir inline XRenderPictFormat* XRenderPeer::FindPictureFormat( unsigned long nFormatMask,
175cdf0e10cSrcweir const XRenderPictFormat& rFormatAttr ) const
176cdf0e10cSrcweir {
177cdf0e10cSrcweir #ifdef XRENDER_LINK
178cdf0e10cSrcweir return XRenderFindFormat( mpDisplay, nFormatMask, &rFormatAttr, 0 );
179cdf0e10cSrcweir #else
180cdf0e10cSrcweir return (*mpXRenderFindFormat)( mpDisplay, nFormatMask, &rFormatAttr, 0 );
181cdf0e10cSrcweir #endif
182cdf0e10cSrcweir }
183cdf0e10cSrcweir
CreatePicture(Drawable aDrawable,const XRenderPictFormat * pVisFormat,unsigned long nValueMask,const XRenderPictureAttributes * pRenderAttr) const184cdf0e10cSrcweir inline Picture XRenderPeer::CreatePicture( Drawable aDrawable,
185cdf0e10cSrcweir const XRenderPictFormat* pVisFormat, unsigned long nValueMask,
186cdf0e10cSrcweir const XRenderPictureAttributes* pRenderAttr ) const
187cdf0e10cSrcweir {
188cdf0e10cSrcweir #ifdef XRENDER_LINK
189cdf0e10cSrcweir return XRenderCreatePicture( mpDisplay, aDrawable, pVisFormat,
190cdf0e10cSrcweir nValueMask, pRenderAttr );
191cdf0e10cSrcweir #else
192cdf0e10cSrcweir return (*mpXRenderCreatePicture)( mpDisplay, aDrawable, pVisFormat,
193cdf0e10cSrcweir nValueMask, pRenderAttr );
194cdf0e10cSrcweir #endif
195cdf0e10cSrcweir }
196cdf0e10cSrcweir
ChangePicture(Picture aPicture,unsigned long nValueMask,const XRenderPictureAttributes * pRenderAttr) const197cdf0e10cSrcweir inline void XRenderPeer::ChangePicture( Picture aPicture,
198cdf0e10cSrcweir unsigned long nValueMask, const XRenderPictureAttributes* pRenderAttr ) const
199cdf0e10cSrcweir {
200cdf0e10cSrcweir #ifdef XRENDER_LINK
201cdf0e10cSrcweir XRenderChangePicture( mpDisplay, aPicture, nValueMask, pRenderAttr );
202cdf0e10cSrcweir #else
203cdf0e10cSrcweir (*mpXRenderChangePicture)( mpDisplay, aPicture, nValueMask, pRenderAttr );
204cdf0e10cSrcweir #endif
205cdf0e10cSrcweir }
206cdf0e10cSrcweir
SetPictureClipRegion(Picture aPicture,XLIB_Region aXlibRegion) const207cdf0e10cSrcweir inline void XRenderPeer::SetPictureClipRegion( Picture aPicture,
208cdf0e10cSrcweir XLIB_Region aXlibRegion ) const
209cdf0e10cSrcweir {
210cdf0e10cSrcweir #ifdef XRENDER_LINK
211cdf0e10cSrcweir XRenderSetPictureClipRegion( mpDisplay, aPicture, aXlibRegion );
212cdf0e10cSrcweir #else
213cdf0e10cSrcweir (*mpXRenderSetPictureClipRegion)( mpDisplay, aPicture, aXlibRegion );
214cdf0e10cSrcweir #endif
215cdf0e10cSrcweir }
216cdf0e10cSrcweir
CompositePicture(int nXRenderOp,Picture aSrcPic,Picture aMaskPic,Picture aDstPic,int nSrcX,int nSrcY,int nMaskX,int nMaskY,int nDstX,int nDstY,unsigned nWidth,unsigned nHeight) const217cdf0e10cSrcweir inline void XRenderPeer::CompositePicture( int nXRenderOp,
218cdf0e10cSrcweir Picture aSrcPic, Picture aMaskPic, Picture aDstPic,
219cdf0e10cSrcweir int nSrcX, int nSrcY, int nMaskX, int nMaskY, int nDstX, int nDstY,
220cdf0e10cSrcweir unsigned nWidth, unsigned nHeight ) const
221cdf0e10cSrcweir {
222cdf0e10cSrcweir #ifdef XRENDER_LINK
223cdf0e10cSrcweir XRenderComposite( mpDisplay, nXRenderOp, aSrcPic, aMaskPic, aDstPic,
224cdf0e10cSrcweir nSrcX, nSrcY, nMaskX, nMaskY, nDstX, nDstY, nWidth, nHeight );
225cdf0e10cSrcweir #else
226cdf0e10cSrcweir (*mpXRenderComposite)( mpDisplay, nXRenderOp, aSrcPic, aMaskPic, aDstPic,
227cdf0e10cSrcweir nSrcX, nSrcY, nMaskX, nMaskY, nDstX, nDstY, nWidth, nHeight );
228cdf0e10cSrcweir #endif
229cdf0e10cSrcweir }
230cdf0e10cSrcweir
FreePicture(Picture aPicture) const231cdf0e10cSrcweir inline void XRenderPeer::FreePicture( Picture aPicture ) const
232cdf0e10cSrcweir {
233cdf0e10cSrcweir #ifdef XRENDER_LINK
234cdf0e10cSrcweir XRenderFreePicture( mpDisplay, aPicture );
235cdf0e10cSrcweir #else
236cdf0e10cSrcweir (*mpXRenderFreePicture)( mpDisplay, aPicture );
237cdf0e10cSrcweir #endif
238cdf0e10cSrcweir }
239cdf0e10cSrcweir
CreateGlyphSet() const240cdf0e10cSrcweir inline GlyphSet XRenderPeer::CreateGlyphSet() const
241cdf0e10cSrcweir {
242cdf0e10cSrcweir #ifdef XRENDER_LINK
243cdf0e10cSrcweir return XRenderCreateGlyphSet( mpDisplay, mpStandardFormatA8 );
244cdf0e10cSrcweir #else
245cdf0e10cSrcweir return (*mpXRenderCreateGlyphSet)( mpDisplay, mpStandardFormatA8 );
246cdf0e10cSrcweir #endif
247cdf0e10cSrcweir }
248cdf0e10cSrcweir
FreeGlyphSet(GlyphSet aGS) const249cdf0e10cSrcweir inline void XRenderPeer::FreeGlyphSet( GlyphSet aGS ) const
250cdf0e10cSrcweir {
251cdf0e10cSrcweir #ifdef XRENDER_LINK
252cdf0e10cSrcweir XRenderFreeGlyphSet( mpDisplay, aGS );
253cdf0e10cSrcweir #else
254cdf0e10cSrcweir (*mpXRenderFreeGlyphSet)( mpDisplay, aGS );
255cdf0e10cSrcweir #endif
256cdf0e10cSrcweir }
257cdf0e10cSrcweir
AddGlyph(GlyphSet aGS,XRenderGlyph nXRGlyph,const XGlyphInfo & rGI,const char * pBuffer,int nBufSize) const258*248a599fSHerbert Dürr inline void XRenderPeer::AddGlyph( GlyphSet aGS, XRenderGlyph nXRGlyph,
259cdf0e10cSrcweir const XGlyphInfo& rGI, const char* pBuffer, int nBufSize ) const
260cdf0e10cSrcweir {
261cdf0e10cSrcweir #ifdef XRENDER_LINK
262*248a599fSHerbert Dürr XRenderAddGlyphs( mpDisplay, aGS, &nXRGlyph, &rGI, 1,
263cdf0e10cSrcweir const_cast<char*>(pBuffer), nBufSize );
264cdf0e10cSrcweir #else
265*248a599fSHerbert Dürr (*mpXRenderAddGlyphs)( mpDisplay, aGS, &nXRGlyph, &rGI, 1,
266cdf0e10cSrcweir const_cast<char*>(pBuffer), nBufSize );
267cdf0e10cSrcweir #endif
268cdf0e10cSrcweir }
269cdf0e10cSrcweir
FreeGlyph(GlyphSet aGS,XRenderGlyph nXRGlyph) const270*248a599fSHerbert Dürr inline void XRenderPeer::FreeGlyph( GlyphSet aGS, XRenderGlyph nXRGlyph ) const
271cdf0e10cSrcweir {
272*248a599fSHerbert Dürr (void)aGS; (void)nXRGlyph;
273cdf0e10cSrcweir
274cdf0e10cSrcweir // XRenderFreeGlyphs not implemented yet for version<=0.2
275cdf0e10cSrcweir // #108209# disabled because of crash potential,
276cdf0e10cSrcweir // the glyph leak is not too bad because they will
277cdf0e10cSrcweir // be cleaned up when the glyphset is released
278cdf0e10cSrcweir #if 0 // TODO: reenable when it works without problems
279cdf0e10cSrcweir if( mnRenderVersion >= 0x05 )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir #ifdef XRENDER_LINK
282*248a599fSHerbert Dürr XRenderFreeGlyphs( mpDisplay, aGS, &nXRGlyph, 1 );
283cdf0e10cSrcweir #else
284*248a599fSHerbert Dürr (*mpXRenderFreeGlyphs)( mpDisplay, aGS, &nXRGlyph, 1 );
285cdf0e10cSrcweir #endif
286cdf0e10cSrcweir }
287cdf0e10cSrcweir #endif
288cdf0e10cSrcweir }
289cdf0e10cSrcweir
CompositeString32(Picture aSrc,Picture aDst,GlyphSet aGlyphSet,int nDstX,int nDstY,const unsigned * pText,int nTextLen) const290cdf0e10cSrcweir inline void XRenderPeer::CompositeString32( Picture aSrc, Picture aDst,
291cdf0e10cSrcweir GlyphSet aGlyphSet, int nDstX, int nDstY,
292cdf0e10cSrcweir const unsigned* pText, int nTextLen ) const
293cdf0e10cSrcweir {
294cdf0e10cSrcweir #ifdef XRENDER_LINK
295cdf0e10cSrcweir XRenderCompositeString32( mpDisplay, PictOpOver, aSrc, aDst, NULL,
296cdf0e10cSrcweir aGlyphSet, 0, 0, nDstX, nDstY, pText, nTextLen );
297cdf0e10cSrcweir #else
298cdf0e10cSrcweir (*mpXRenderCompositeString32)( mpDisplay, PictOpOver, aSrc, aDst, NULL,
299cdf0e10cSrcweir aGlyphSet, 0, 0, nDstX, nDstY, pText, nTextLen );
300cdf0e10cSrcweir #endif
301cdf0e10cSrcweir }
302cdf0e10cSrcweir
FillRectangle(int a,Picture b,const XRenderColor * c,int d,int e,unsigned int f,unsigned int g) const303cdf0e10cSrcweir inline void XRenderPeer::FillRectangle( int a, Picture b, const XRenderColor* c,
304cdf0e10cSrcweir int d, int e, unsigned int f, unsigned int g) const
305cdf0e10cSrcweir {
306cdf0e10cSrcweir #ifdef XRENDER_LINK
307cdf0e10cSrcweir XRenderFillRectangle( mpDisplay, a, b, c, d, e, f, g );
308cdf0e10cSrcweir #else
309cdf0e10cSrcweir (*mpXRenderFillRectangle)( mpDisplay, a, b, c, d, e, f, g );
310cdf0e10cSrcweir #endif
311cdf0e10cSrcweir }
312cdf0e10cSrcweir
313cdf0e10cSrcweir
CompositeTrapezoids(int nOp,Picture aSrc,Picture aDst,const XRenderPictFormat * pXRPF,int nXSrc,int nYSrc,const XTrapezoid * pXT,int nCount) const314cdf0e10cSrcweir inline void XRenderPeer::CompositeTrapezoids( int nOp,
315cdf0e10cSrcweir Picture aSrc, Picture aDst, const XRenderPictFormat* pXRPF,
316cdf0e10cSrcweir int nXSrc, int nYSrc, const XTrapezoid* pXT, int nCount ) const
317cdf0e10cSrcweir {
318cdf0e10cSrcweir #ifdef XRENDER_LINK
319cdf0e10cSrcweir XRenderCompositeTrapezoids( mpDisplay, nOp, aSrc, aDst, pXRPF,
320cdf0e10cSrcweir nXSrc, nYSrc, pXT, nCount );
321cdf0e10cSrcweir #else
322cdf0e10cSrcweir (*mpXRenderCompositeTrapezoids)( mpDisplay, nOp, aSrc, aDst, pXRPF,
323cdf0e10cSrcweir nXSrc, nYSrc, pXT, nCount );
324cdf0e10cSrcweir #endif
325cdf0e10cSrcweir }
326cdf0e10cSrcweir
AddTraps(Picture aDst,int nXOfs,int nYOfs,const _XTrap * pTraps,int nCount) const327cdf0e10cSrcweir inline bool XRenderPeer::AddTraps( Picture aDst, int nXOfs, int nYOfs,
328cdf0e10cSrcweir const _XTrap* pTraps, int nCount ) const
329cdf0e10cSrcweir {
330cdf0e10cSrcweir #ifdef XRENDER_LINK
331cdf0e10cSrcweir XRenderAddTraps( mpDisplay, aDst, nXOfs, nYOfs, pTraps, nCount );
332cdf0e10cSrcweir #else
333cdf0e10cSrcweir if( !mpXRenderAddTraps )
334cdf0e10cSrcweir return false;
335cdf0e10cSrcweir (*mpXRenderAddTraps)( mpDisplay, aDst, nXOfs, nYOfs, pTraps, nCount );
336cdf0e10cSrcweir #endif
337cdf0e10cSrcweir return true;
338cdf0e10cSrcweir }
339cdf0e10cSrcweir
340cdf0e10cSrcweir //=====================================================================
341cdf0e10cSrcweir
ScopedPic(XRenderPeer & rPeer,Picture & rPic)342cdf0e10cSrcweir inline ScopedPic::ScopedPic( XRenderPeer& rPeer, Picture& rPic )
343cdf0e10cSrcweir : mrRenderPeer( rPeer)
344cdf0e10cSrcweir , maPicture( rPic )
345cdf0e10cSrcweir {}
346cdf0e10cSrcweir
~ScopedPic()347cdf0e10cSrcweir inline ScopedPic::~ScopedPic()
348cdf0e10cSrcweir {
349cdf0e10cSrcweir if( maPicture )
350cdf0e10cSrcweir mrRenderPeer.FreePicture( maPicture );
351cdf0e10cSrcweir }
352cdf0e10cSrcweir
Get()353cdf0e10cSrcweir inline Picture& ScopedPic::Get()
354cdf0e10cSrcweir {
355cdf0e10cSrcweir return maPicture;
356cdf0e10cSrcweir }
357cdf0e10cSrcweir
358cdf0e10cSrcweir //=====================================================================
359cdf0e10cSrcweir
GetXRenderColor(const SalColor & rSalColor,double fTransparency=0.0)360cdf0e10cSrcweir inline XRenderColor GetXRenderColor( const SalColor& rSalColor, double fTransparency = 0.0 )
361cdf0e10cSrcweir {
362cdf0e10cSrcweir XRenderColor aRetVal;
363cdf0e10cSrcweir // convert the SalColor
364cdf0e10cSrcweir aRetVal.red = SALCOLOR_RED( rSalColor ); aRetVal.red |= (aRetVal.red << 8);
365cdf0e10cSrcweir aRetVal.green = SALCOLOR_GREEN( rSalColor ); aRetVal.green |= (aRetVal.green << 8);
366cdf0e10cSrcweir aRetVal.blue = SALCOLOR_BLUE( rSalColor ); aRetVal.blue |= (aRetVal.blue << 8);
367cdf0e10cSrcweir
368cdf0e10cSrcweir // handle transparency
369cdf0e10cSrcweir aRetVal.alpha = 0xFFFF; // default to opaque
370cdf0e10cSrcweir if( fTransparency != 0 )
371cdf0e10cSrcweir {
372cdf0e10cSrcweir const double fAlpha = 1.0 - fTransparency;
373cdf0e10cSrcweir aRetVal.alpha = static_cast<sal_uInt16>(fAlpha * 0xFFFF + 0.5);
374cdf0e10cSrcweir // xrender wants pre-multiplied colors
375cdf0e10cSrcweir aRetVal.red = static_cast<sal_uInt16>(fAlpha * aRetVal.red + 0.5);
376cdf0e10cSrcweir aRetVal.green = static_cast<sal_uInt16>(fAlpha * aRetVal.green + 0.5);
377cdf0e10cSrcweir aRetVal.blue = static_cast<sal_uInt16>(fAlpha * aRetVal.blue + 0.5);
378cdf0e10cSrcweir }
379cdf0e10cSrcweir
380cdf0e10cSrcweir return aRetVal;
381cdf0e10cSrcweir }
382cdf0e10cSrcweir
383cdf0e10cSrcweir //=====================================================================
384cdf0e10cSrcweir
385cdf0e10cSrcweir #endif // _SV_XRENDER_PEER_HXX
386