bump product version to 7.2.5.1
[LibreOffice.git] / vcl / inc / quartz / salgdicommon.hxx
blob71c40acdfab6736716cc6ab60be3ecc5c113f7bd
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 <tools/color.hxx>
34 #include <vcl/salgtype.hxx>
36 // abstracting quartz color instead of having to use a CGFloat[] array
37 class RGBAColor
39 public:
40 RGBAColor( ::Color );
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]; }
50 private:
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 )
64 m_fRGBA[0] = fRed;
65 m_fRGBA[1] = fGreen;
66 m_fRGBA[2] = fBlue;
67 m_fRGBA[3] = fAlpha;
70 inline std::ostream &operator <<(std::ostream& s, const RGBAColor &aColor)
72 #ifndef SAL_LOG_INFO
73 (void) aColor;
74 #else
75 s << "{" << aColor.GetRed() << "," << aColor.GetGreen() << "," << aColor.GetBlue() << "," << aColor.GetAlpha() << "}";
76 #endif
77 return s;
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 .
84 class XorEmulation
86 public:
87 XorEmulation();
88 ~XorEmulation();
90 void SetTarget( int nWidth, int nHeight, int nBitmapDepth, CGContextRef, CGLayerRef );
91 bool UpdateTarget();
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); }
98 private:
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;
105 int m_nBufferLongs;
106 bool m_bIsEnabled;
109 #endif // INCLUDED_VCL_INC_QUARTZ_SALGDICOMMON_HXX
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */