LibreOffice Module vcl (master) 1
salgdicommon.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_VCL_INC_QUARTZ_SALGDICOMMON_HXX
21#define INCLUDED_VCL_INC_QUARTZ_SALGDICOMMON_HXX
22
23#include <iostream>
24
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>
32
33#include <tools/color.hxx>
34#include <vcl/salgtype.hxx>
35
36// abstracting quartz color instead of having to use a CGFloat[] array
38{
39public:
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; }
45
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]; }
50private:
51 CGFloat m_fRGBA[4]; // red, green, blue, alpha
52};
53
55{
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
60}
61
62inline RGBAColor::RGBAColor( float fRed, float fGreen, float fBlue, float fAlpha )
63{
64 m_fRGBA[0] = fRed;
65 m_fRGBA[1] = fGreen;
66 m_fRGBA[2] = fBlue;
67 m_fRGBA[3] = fAlpha;
68}
69
70inline std::ostream &operator <<(std::ostream& s, const RGBAColor &aColor)
71{
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;
78}
79
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 .
83
85{
86public:
89
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); }
97
98private:
99 CGLayerRef m_xTargetLayer;
100 CGContextRef m_xTargetContext;
101 CGContextRef m_xMaskContext;
102 CGContextRef m_xTempContext;
107};
108
109#endif // INCLUDED_VCL_INC_QUARTZ_SALGDICOMMON_HXX
110
111/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt8 GetBlue() const
sal_uInt8 GetRed() const
sal_uInt8 GetGreen() const
CGFloat m_fRGBA[4]
bool IsVisible() const
CGFloat GetAlpha() const
const CGFloat * AsArray() const
RGBAColor(::Color)
CGFloat GetBlue() const
void SetAlpha(float fAlpha)
CGFloat GetGreen() const
CGFloat GetRed() const
CGContextRef m_xTargetContext
CGContextRef m_xMaskContext
CGContextRef m_xTempContext
bool UpdateTarget()
void SetTarget(int nWidth, int nHeight, int nBitmapDepth, CGContextRef, CGLayerRef)
CGLayerRef m_xTargetLayer
CGContextRef GetTargetContext() const
CGContextRef GetMaskContext() const
bool IsEnabled() const
sal_uLong * m_pMaskBuffer
sal_uLong * m_pTempBuffer
std::ostream & operator<<(std::ostream &s, const RGBAColor &aColor)
sal_uIntPtr sal_uLong