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 #ifndef INCLUDED_VCL_INC_QUARTZ_SALGDICOMMON_HXX
21 #define INCLUDED_VCL_INC_QUARTZ_SALGDICOMMON_HXX
27 #include <CoreGraphics/CoreGraphics.h>
29 #include <ApplicationServices/ApplicationServices.h>
33 #include <vcl/salgtype.hxx>
35 // abstracting quartz color instead of having to use an CGFloat[] array
39 RGBAColor( SalColor
);
40 RGBAColor( float fRed
, float fGreen
, float fBlue
, float fAlpha
); //NOTUSEDYET
41 const CGFloat
* AsArray() const { return m_fRGBA
; }
42 bool IsVisible() const { return m_fRGBA
[3] > 0; }
43 void SetAlpha( float fAlpha
) { m_fRGBA
[3] = fAlpha
; }
45 CGFloat
GetRed() const { return m_fRGBA
[0]; }
46 CGFloat
GetGreen() const { return m_fRGBA
[1]; }
47 CGFloat
GetBlue() const { return m_fRGBA
[2]; }
48 CGFloat
GetAlpha() const { return m_fRGBA
[3]; }
50 CGFloat m_fRGBA
[4]; // red, green, blue, alpha
53 inline RGBAColor::RGBAColor( SalColor nSalColor
)
55 m_fRGBA
[0] = SALCOLOR_RED(nSalColor
) * (1.0/255);
56 m_fRGBA
[1] = SALCOLOR_GREEN(nSalColor
) * (1.0/255);
57 m_fRGBA
[2] = SALCOLOR_BLUE(nSalColor
) * (1.0/255);
58 m_fRGBA
[3] = 1.0; // opaque
61 inline RGBAColor::RGBAColor( float fRed
, float fGreen
, float fBlue
, float fAlpha
)
69 inline std::ostream
&operator <<(std::ostream
& s
, const RGBAColor
&aColor
)
74 s
<< "{" << aColor
.GetRed() << "," << aColor
.GetGreen() << "," << aColor
.GetBlue() << "," << aColor
.GetAlpha() << "}";
79 // XOR emulation suckage.
80 // See http://www.openoffice.org/marketing/ooocon2008/programme/wednesday_1401.pdf
81 // and https://bugs.freedesktop.org/show_bug.cgi?id=38844 .
89 void SetTarget( int nWidth
, int nHeight
, int nBitmapDepth
, CGContextRef
, CGLayerRef
);
91 void Enable() { m_bIsEnabled
= true; }
92 void Disable() { m_bIsEnabled
= false; }
93 bool IsEnabled() const { return m_bIsEnabled
; }
94 CGContextRef
GetTargetContext() const { return m_xTargetContext
; }
95 CGContextRef
GetMaskContext() const { return (m_bIsEnabled
? m_xMaskContext
: NULL
); }
98 CGLayerRef m_xTargetLayer
;
99 CGContextRef m_xTargetContext
;
100 CGContextRef m_xMaskContext
;
101 CGContextRef m_xTempContext
;
102 sal_uLong
* m_pMaskBuffer
;
103 sal_uLong
* m_pTempBuffer
;
108 #endif // INCLUDED_VCL_INC_QUARTZ_SALGDICOMMON_HXX
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */