Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / inc / quartz / salgdicommon.hxx
blobb0d9a2fdea7c6158bb75bec9b6cbb7be8dc5e8ca
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
23 #include <iostream>
25 #include <premac.h>
26 #ifdef IOS
27 #include <CoreGraphics/CoreGraphics.h>
28 #else
29 #include <ApplicationServices/ApplicationServices.h>
30 #endif
31 #include <postmac.h>
33 #include <vcl/salgtype.hxx>
35 // abstracting quartz color instead of having to use an CGFloat[] array
36 class RGBAColor
38 public:
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]; }
49 private:
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 )
63 m_fRGBA[0] = fRed;
64 m_fRGBA[1] = fGreen;
65 m_fRGBA[2] = fBlue;
66 m_fRGBA[3] = fAlpha;
69 inline std::ostream &operator <<(std::ostream& s, const RGBAColor &aColor)
71 #ifndef SAL_LOG_INFO
72 (void) aColor;
73 #else
74 s << "{" << aColor.GetRed() << "," << aColor.GetGreen() << "," << aColor.GetBlue() << "," << aColor.GetAlpha() << "}";
75 #endif
76 return s;
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 .
83 class XorEmulation
85 public:
86 XorEmulation();
87 ~XorEmulation();
89 void SetTarget( int nWidth, int nHeight, int nBitmapDepth, CGContextRef, CGLayerRef );
90 bool UpdateTarget();
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); }
97 private:
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;
104 int m_nBufferLongs;
105 bool m_bIsEnabled;
108 #endif // INCLUDED_VCL_INC_QUARTZ_SALGDICOMMON_HXX
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */