LibreOffice Module vcl (master)  1
svpgdi.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 #pragma once
21 
22 #ifdef IOS
23 #error This file is not for iOS
24 #endif
25 
26 #include <sal/config.h>
27 #include <config_features.h>
28 
29 #include <osl/endian.h>
30 #include <vcl/sysdata.hxx>
31 #include <config_cairo_canvas.h>
32 
34 #include <salgdi.hxx>
35 #include <sallayout.hxx>
36 #include "svpcairotextrender.hxx"
37 #include <impfontmetricdata.hxx>
38 
40 #include <headless/CairoCommon.hxx>
41 
42 struct BitmapBuffer;
43 class FreetypeFont;
44 
46 {
48 
49 public:
50  void setSurface(cairo_surface_t* pSurface, const basegfx::B2IVector& rSize);
51  cairo_surface_t* getSurface() const { return m_aCairoCommon.m_pSurface; }
53  {
55  }
56 
57 protected:
59  std::unique_ptr<SvpGraphicsBackend> m_pBackend;
60 
61  cairo_t* createTmpCompatibleCairoContext() const;
62 
63 public:
65  virtual ~SvpSalGraphics() override;
66 
67  virtual SalGraphicsImpl* GetImpl() const override { return m_pBackend.get(); }
68  std::unique_ptr<SvpGraphicsBackend> const& getSvpBackend() { return m_pBackend; }
69 
70  virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) override;
71 
72  virtual void SetTextColor( Color nColor ) override;
73  virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
74  virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
75  virtual FontCharMapRef GetFontCharMap() const override;
76  virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
77  virtual void GetDevFontList( vcl::font::PhysicalFontCollection* ) override;
78  virtual void ClearDevFontCache() override;
79  virtual bool AddTempDevFont( vcl::font::PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) override;
80  virtual bool CreateFontSubset( const OUString& rToFile,
82  const sal_GlyphId* pGlyphIds,
83  const sal_uInt8* pEncoding,
84  sal_Int32* pWidths,
85  int nGlyphs,
86  FontSubsetInfo& rInfo
87  ) override;
88  virtual const void* GetEmbedFontData(const vcl::font::PhysicalFontFace*, tools::Long* pDataLen) override;
89  virtual void FreeEmbedFontData( const void* pData, tools::Long nDataLen ) override;
90  virtual void GetGlyphWidths( const vcl::font::PhysicalFontFace*,
91  bool bVertical,
92  std::vector< sal_Int32 >& rWidths,
93  Ucs2UIntMap& rUnicodeEnc ) override;
94  virtual std::unique_ptr<GenericSalLayout>
95  GetTextLayout(int nFallbackLevel) override;
96  virtual void DrawTextLayout( const GenericSalLayout& ) override;
97 
98  virtual SystemGraphicsData GetGraphicsData() const override;
99 
100 #if ENABLE_CAIRO_CANVAS
101  virtual bool SupportsCairo() const override;
102  virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
103  virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const override;
104  virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const override;
105  virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const override;
106 #endif // ENABLE_CAIRO_CANVAS
107 
109  {
110  return m_aCairoCommon.getCairoContext(/*bXorModeAllowed*/false, getAntiAlias());
111  }
112 
113  void releaseCairoContext(cairo_t* cr, const basegfx::B2DRange& rExtents) const
114  {
115  return m_aCairoCommon.releaseCairoContext(cr, /*bXorModeAllowed*/false, rExtents);
116  }
117 
118  void clipRegion(cairo_t* cr)
119  {
120  m_aCairoCommon.clipRegion(cr);
121  }
122  void copySource(const SalTwoRect& rTR, cairo_surface_t* source)
123  {
124  m_aCairoCommon.copySource(rTR, source, getAntiAlias());
125  }
126 };
127 
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void clipRegion(cairo_t *cr)
virtual void ClearDevFontCache()=0
virtual void DrawTextLayout(const GenericSalLayout &)=0
struct _cairo cairo_t
Definition: CairoCommon.hxx:71
cairo_surface_t * getSurface() const
Definition: svpgdi.hxx:51
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const =0
std::unique_ptr< SvpGraphicsBackend > m_pBackend
Definition: svpgdi.hxx:59
virtual bool AddTempDevFont(vcl::font::PhysicalFontCollection *, const OUString &rFileURL, const OUString &rFontName)=0
void copySource(const SalTwoRect &rTR, cairo_surface_t *source, bool bAntiAlias)
void releaseCairoContext(cairo_t *cr, bool bXorModeAllowed, const basegfx::B2DRange &rExtents) const
virtual std::unique_ptr< GenericSalLayout > GetTextLayout(int nFallbackLevel)=0
sal_uInt16 sal_GlyphId
Definition: glyphid.hxx:24
void clipRegion(cairo_t *cr)
Definition: svpgdi.hxx:118
virtual FontCharMapRef GetFontCharMap() const =0
SvpCairoTextRender m_aTextRenderImpl
Definition: svpgdi.hxx:58
virtual void GetGlyphWidths(const vcl::font::PhysicalFontFace *pFont, bool bVertical, std::vector< sal_Int32 > &rWidths, Ucs2UIntMap &rUnicodeEnc)=0
virtual void FreeEmbedFontData(const void *pData, tools::Long nDataLen)=0
void releaseCairoContext(cairo_t *cr, const basegfx::B2DRange &rExtents) const
Definition: svpgdi.hxx:113
cairo_t * getCairoContext() const
Definition: svpgdi.hxx:108
cairo_surface_t * m_pSurface
std::shared_ptr< Surface > SurfaceSharedPtr
Definition: cairo.hxx:36
virtual void GetResolution(sal_Int32 &rDPIX, sal_Int32 &rDPIY)=0
static cairo_user_data_key_t * getDamageKey()
virtual bool CreateFontSubset(const OUString &rToFile, const vcl::font::PhysicalFontFace *pFont, const sal_GlyphId *pGlyphIDs, const sal_uInt8 *pEncoding, sal_Int32 *pWidths, int nGlyphs, FontSubsetInfo &rInfo)=0
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:175
static cairo_user_data_key_t * getDamageKey()
Definition: svpgdi.hxx:52
std::shared_ptr< cairo_surface_t > CairoSurfaceSharedPtr
Definition: cairo.hxx:34
virtual SystemGraphicsData GetGraphicsData() const =0
std::unique_ptr< SvpGraphicsBackend > const & getSvpBackend()
Definition: svpgdi.hxx:68
void copySource(const SalTwoRect &rTR, cairo_surface_t *source)
Definition: svpgdi.hxx:122
cairo_t * getCairoContext(bool bXorModeAllowed, bool bAntiAlias) const
abstract base class for physical font faces
unsigned char sal_uInt8
virtual SalGraphicsImpl * GetImpl() const override
Definition: svpgdi.hxx:67
virtual void GetFontMetric(ImplFontMetricDataRef &, int nFallbackLevel)=0
struct _cairo_user_data_key cairo_user_data_key_t
Definition: CairoCommon.hxx:73
virtual void GetDevFontList(vcl::font::PhysicalFontCollection *)=0
virtual void SetFont(LogicalFontInstance *, int nFallbackLevel)=0
CairoCommon m_aCairoCommon
Definition: svpgdi.hxx:47
bool getAntiAlias() const
Definition: salgdi.hxx:94
std::map< sal_Ucs, sal_uInt32 > Ucs2UIntMap
Definition: salgdi.hxx:66
virtual const void * GetEmbedFontData(const vcl::font::PhysicalFontFace *pFont, tools::Long *pDataLen)=0
virtual void SetTextColor(Color nColor)=0
struct _cairo_surface cairo_surface_t
Definition: CairoCommon.hxx:72
Implementation class for SalGraphics.
Definition: salgdiimpl.hxx:50