Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / inc / quartz / salbmp.h
blob49679f07336324c9ace1df0fe57016e0b5cb1547
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_SALBMP_H
21 #define INCLUDED_VCL_INC_QUARTZ_SALBMP_H
23 #include "tools/gen.hxx"
25 #include "basebmp/bitmapdevice.hxx"
27 #include "vcl/salbtype.hxx"
29 #include "quartz/salgdi.h"
31 #include "salinst.hxx"
32 #include "salvd.hxx"
33 #include "salbmp.hxx"
35 // - SalBitmap -
37 struct BitmapBuffer;
38 class BitmapPalette;
40 class QuartzSalBitmap : public SalBitmap
42 public:
43 CGContextRef mxGraphicContext;
44 mutable CGImageRef mxCachedImage;
45 BitmapPalette maPalette;
46 basebmp::RawMemorySharedArray maUserBuffer;
47 basebmp::RawMemorySharedArray maContextBuffer;
48 sal_uInt16 mnBits;
49 int mnWidth;
50 int mnHeight;
51 sal_uInt32 mnBytesPerRow;
53 public:
54 QuartzSalBitmap();
55 virtual ~QuartzSalBitmap();
57 public:
59 // SalBitmap methods
60 bool Create( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal ) SAL_OVERRIDE;
61 bool Create( const SalBitmap& rSalBmp ) SAL_OVERRIDE;
62 bool Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics ) SAL_OVERRIDE;
63 bool Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount ) SAL_OVERRIDE;
64 virtual bool Create( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas >& rBitmapCanvas,
65 Size& rSize,
66 bool bMask = false ) SAL_OVERRIDE;
68 void Destroy() SAL_OVERRIDE;
70 Size GetSize() const SAL_OVERRIDE;
71 sal_uInt16 GetBitCount() const SAL_OVERRIDE;
73 BitmapBuffer *AcquireBuffer( BitmapAccessMode nMode ) SAL_OVERRIDE;
74 void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) SAL_OVERRIDE;
76 bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE;
78 bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
79 bool Erase( const Color& rFillColor ) SAL_OVERRIDE;
80 bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) SAL_OVERRIDE;
81 bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) SAL_OVERRIDE;
83 private:
84 // quartz helper
85 bool CreateContext();
86 void DestroyContext();
87 bool AllocateUserData();
89 void ConvertBitmapData( sal_uInt32 nWidth, sal_uInt32 nHeight,
90 sal_uInt16 nDestBits, sal_uInt32 nDestBytesPerRow, const BitmapPalette& rDestPalette, sal_uInt8* pDestData,
91 sal_uInt16 nSrcBits, sal_uInt32 nSrcBytesPerRow, const BitmapPalette& rSrcPalette, sal_uInt8* pSrcData );
93 public:
94 bool Create( CGLayerRef xLayer, int nBitCount, int nX, int nY, int nWidth, int nHeight );
96 public:
97 CGImageRef CreateWithMask( const QuartzSalBitmap& rMask, int nX, int nY, int nWidth, int nHeight ) const;
98 CGImageRef CreateColorMask( int nX, int nY, int nWidth, int nHeight, SalColor nMaskColor ) const;
99 CGImageRef CreateCroppedImage( int nX, int nY, int nWidth, int nHeight ) const;
102 #endif // INCLUDED_VCL_INC_QUARTZ_SALBMP_H
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */