LibreOffice Module vcl (master)  1
quartz/salbmp.h
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_SALBMP_H
21 #define INCLUDED_VCL_INC_QUARTZ_SALBMP_H
22 
23 #include <tools/gen.hxx>
24 
25 #include <vcl/BitmapBuffer.hxx>
26 #include <vcl/BitmapPalette.hxx>
27 
28 #include <quartz/salgdi.h>
29 
30 #include <salinst.hxx>
31 #include <salvd.hxx>
32 #include <salbmp.hxx>
33 
34 #include <memory>
35 
36 
37 struct BitmapBuffer;
38 class BitmapPalette;
39 
40 class QuartzSalBitmap : public SalBitmap
41 {
42 public:
44  mutable CGImageRef mxCachedImage;
46  std::shared_ptr<sal_uInt8> m_pUserBuffer;
47  std::shared_ptr<sal_uInt8> m_pContextBuffer;
48  sal_uInt16 mnBits;
49  int mnWidth;
50  int mnHeight;
51  sal_uInt32 mnBytesPerRow;
52 
53 public:
55  virtual ~QuartzSalBitmap() override;
56 
57 public:
58 
59  // SalBitmap methods
60  bool Create( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal ) override;
61  bool Create( const SalBitmap& rSalBmp ) override;
62  bool Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics ) override;
63  bool Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount ) override;
64  virtual bool Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas,
65  Size& rSize,
66  bool bMask = false ) override;
67 
68  void Destroy() override;
69 
70  Size GetSize() const override;
71  sal_uInt16 GetBitCount() const override;
72 
73  BitmapBuffer *AcquireBuffer( BitmapAccessMode nMode ) override;
74  void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) override;
75 
76  bool GetSystemData( BitmapSystemData& rData ) override;
77 
78  bool ScalingSupported() const override;
79  bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) override;
80  bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) override;
81 
82 private:
83  // quartz helper
84  bool CreateContext();
85  void DestroyContext();
86  bool AllocateUserData();
87 
88  void ConvertBitmapData( sal_uInt32 nWidth, sal_uInt32 nHeight,
89  sal_uInt16 nDestBits, sal_uInt32 nDestBytesPerRow, const BitmapPalette& rDestPalette, sal_uInt8* pDestData,
90  sal_uInt16 nSrcBits, sal_uInt32 nSrcBytesPerRow, const BitmapPalette& rSrcPalette, sal_uInt8* pSrcData );
91 
92 public:
93  bool Create(CGLayerHolder const & rLayerHolder, int nBitCount, int nX, int nY, int nWidth, int nHeight, bool bFlipped);
94 
95 public:
96  CGImageRef CreateWithMask( const QuartzSalBitmap& rMask, int nX, int nY, int nWidth, int nHeight ) const;
97  CGImageRef CreateColorMask( int nX, int nY, int nWidth, int nHeight, Color nMaskColor ) const;
98  CGImageRef CreateCroppedImage( int nX, int nY, int nWidth, int nHeight ) const;
99 
100  void doDestroy();
101 };
102 
103 #endif // INCLUDED_VCL_INC_QUARTZ_SALBMP_H
104 
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::shared_ptr< sal_uInt8 > m_pUserBuffer
Definition: quartz/salbmp.h:46
bool Replace(const Color &rSearchColor, const Color &rReplaceColor, sal_uInt8 nTol) override
CGImageRef CreateColorMask(int nX, int nY, int nWidth, int nHeight, Color nMaskColor) const
CGContextHolder maGraphicContext
Definition: quartz/salbmp.h:43
BitmapPalette maPalette
Definition: quartz/salbmp.h:45
bool AllocateUserData()
void ReleaseBuffer(BitmapBuffer *pBuffer, BitmapAccessMode nMode) override
CGImageRef mxCachedImage
Definition: quartz/salbmp.h:44
sal_uInt32 mnBytesPerRow
Definition: quartz/salbmp.h:51
bool ScalingSupported() const override
bool Create(const Size &rSize, sal_uInt16 nBitCount, const BitmapPalette &rPal) override
Size GetSize() const override
virtual ~QuartzSalBitmap() override
bool Scale(const double &rScaleX, const double &rScaleY, BmpScaleFlag nScaleFlag) override
std::shared_ptr< sal_uInt8 > m_pContextBuffer
Definition: quartz/salbmp.h:47
sal_uInt16 GetBitCount() const override
BitmapAccessMode
BitmapBuffer * AcquireBuffer(BitmapAccessMode nMode) override
BmpScaleFlag
Definition: bitmap.hxx:48
CGImageRef CreateCroppedImage(int nX, int nY, int nWidth, int nHeight) const
CGImageRef CreateWithMask(const QuartzSalBitmap &rMask, int nX, int nY, int nWidth, int nHeight) const
unsigned char sal_uInt8
sal_uInt16 mnBits
Definition: quartz/salbmp.h:48
void DestroyContext()
void Destroy() override
bool GetSystemData(BitmapSystemData &rData) override
void ConvertBitmapData(sal_uInt32 nWidth, sal_uInt32 nHeight, sal_uInt16 nDestBits, sal_uInt32 nDestBytesPerRow, const BitmapPalette &rDestPalette, sal_uInt8 *pDestData, sal_uInt16 nSrcBits, sal_uInt32 nSrcBytesPerRow, const BitmapPalette &rSrcPalette, sal_uInt8 *pSrcData)
bool CreateContext()