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 <tools/color.hxx>
34 #include <vcl/salgtype.hxx>
36 // abstracting quartz color instead of having to use a CGFloat[] array
41 RGBAColor( float fRed
, float fGreen
, float fBlue
, float fAlpha
); //NOTUSEDYET
42 const CGFloat
* AsArray() const { return m_fRGBA
; }
43 bool IsVisible() const { return m_fRGBA
[3] > 0; }
44 void SetAlpha( float fAlpha
) { m_fRGBA
[3] = fAlpha
; }
46 CGFloat
GetRed() const { return m_fRGBA
[0]; }
47 CGFloat
GetGreen() const { return m_fRGBA
[1]; }
48 CGFloat
GetBlue() const { return m_fRGBA
[2]; }
49 CGFloat
GetAlpha() const { return m_fRGBA
[3]; }
51 CGFloat m_fRGBA
[4]; // red, green, blue, alpha
54 inline RGBAColor::RGBAColor( ::Color nColor
)
56 m_fRGBA
[0] = nColor
.GetRed() * (1.0/255);
57 m_fRGBA
[1] = nColor
.GetGreen() * (1.0/255);
58 m_fRGBA
[2] = nColor
.GetBlue() * (1.0/255);
59 m_fRGBA
[3] = 1.0; // opaque
62 inline RGBAColor::RGBAColor( float fRed
, float fGreen
, float fBlue
, float fAlpha
)
70 inline std::ostream
&operator <<(std::ostream
& s
, const RGBAColor
&aColor
)
75 s
<< "{" << aColor
.GetRed() << "," << aColor
.GetGreen() << "," << aColor
.GetBlue() << "," << aColor
.GetAlpha() << "}";
80 // XOR emulation suckage.
81 // See http://www.openoffice.org/marketing/ooocon2008/programme/wednesday_1401.pdf
82 // and https://bugs.freedesktop.org/show_bug.cgi?id=38844 .
90 void SetTarget( int nWidth
, int nHeight
, int nBitmapDepth
, CGContextRef
, CGLayerRef
);
92 void Enable() { m_bIsEnabled
= true; }
93 void Disable() { m_bIsEnabled
= false; }
94 bool IsEnabled() const { return m_bIsEnabled
; }
95 CGContextRef
GetTargetContext() const { return m_xTargetContext
; }
96 CGContextRef
GetMaskContext() const { return (m_bIsEnabled
? m_xMaskContext
: nullptr); }
99 CGLayerRef m_xTargetLayer
;
100 CGContextRef m_xTargetContext
;
101 CGContextRef m_xMaskContext
;
102 CGContextRef m_xTempContext
;
103 sal_uLong
* m_pMaskBuffer
;
104 sal_uLong
* m_pTempBuffer
;
109 #endif // INCLUDED_VCL_INC_QUARTZ_SALGDICOMMON_HXX
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */