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/.
11 #ifndef INCLUDED_VCL_INC_QUARTZ_CGHELPER_HXX
12 #define INCLUDED_VCL_INC_QUARTZ_CGHELPER_HXX
15 #include <CoreGraphics/CoreGraphics.h>
18 #include <quartz/utils.h>
25 // Layer's scaling factor
35 CGLayerHolder(CGLayerRef pLayer
, float fScale
= 1.0)
41 // Just the size of the layer in pixels
42 CGSize
getSizePixels() const
47 aSize
= CGLayerGetSize(mpLayer
);
52 // Size in points is size in pixels divided by the scaling factor
53 CGSize
getSizePoints() const
58 const CGSize aLayerSize
= getSizePixels();
59 aSize
.width
= aLayerSize
.width
/ mfScale
;
60 aSize
.height
= aLayerSize
.height
/ mfScale
;
65 CGLayerRef
get() const { return mpLayer
; }
67 bool isSet() const { return mpLayer
!= nullptr; }
69 void set(CGLayerRef
const& pLayer
) { mpLayer
= pLayer
; }
71 float getScale() const { return mfScale
; }
73 void setScale(float fScale
) { mfScale
= fScale
; }
79 CGContextRef mpContext
;
87 CGContextHolder(CGContextRef pContext
)
92 CGContextRef
get() const { return mpContext
; }
94 bool isSet() const { return mpContext
!= nullptr; }
96 void set(CGContextRef
const& pContext
) { mpContext
= pContext
; }
98 void saveState() { CGContextSaveGState(mpContext
); }
100 void restoreState() { CGContextRestoreGState(mpContext
); }
103 #endif // INCLUDED_VCL_INC_QUARTZ_CGHELPER_HXX
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */