LibreOffice Module vcl (master) 1
unx/salgdi.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#pragma once
21
22#include <sal/config.h>
23
24#include <X11/Xlib.h>
25#include <X11/Xutil.h>
26#include <X11/extensions/Xrender.h>
27
28#include <vcl/salgtype.hxx>
29#include <vcl/vclenum.hxx>
30
31#include <unx/saldisp.hxx>
32#include <salgdi.hxx>
33#include <salgeom.hxx>
34#include <sallayout.hxx>
35#include <vclpluginapi.h>
36#include <ControlCacheKey.hxx>
37
38#include "saltype.h"
39#include "saldisp.hxx"
40
41#include <memory>
42
43/* From <X11/Intrinsic.h> */
44typedef unsigned long Pixel;
45
46class SalBitmap;
47class SalColormap;
48class SalDisplay;
49class SalFrame;
51class X11SalGraphicsImpl;
53namespace vcl::font
54{
55class PhysicalFontCollection;
56class PhysicalFontFace;
57}
58class SalGraphicsImpl;
59class TextRenderImpl;
60
61namespace basegfx {
62 class B2DTrapezoid;
63}
64
66{
67public:
68 Drawable m_hDrawable;
71
73
75
76 static void releaseCairoContext(cairo_t* cr);
77
78 bool SupportsCairo() const;
79
80 const SalColormap& GetColormap() const { return *m_pColormap; }
81 const SalDisplay* GetDisplay() const { return GetColormap().GetDisplay(); }
82 const SalVisual& GetVisual() const { return GetColormap().GetVisual(); }
83 Display* GetXDisplay() const { return GetColormap().GetXDisplay(); }
84 Pixel GetPixel(Color nColor) const { return GetColormap().GetPixel(nColor); }
85 Drawable GetDrawable() const { return m_hDrawable; }
86};
87
89{
90 friend class X11SalGraphicsImpl;
91 friend class X11CairoTextRender;
92
93public:
95 virtual ~X11SalGraphics() COVERITY_NOEXCEPT_FALSE override;
96
97 void Init( SalFrame *pFrame, Drawable aDrawable, SalX11Screen nXScreen );
98 void Init( X11SalVirtualDevice *pVirtualDevice, cairo_surface_t* pPreExistingTarget = nullptr,
99 SalColormap* pColormap = nullptr, bool bDeleteColormap = false );
100 void Init( X11SkiaSalVirtualDevice *pVirtualDevice );
101 void DeInit();
102
103 virtual SalGraphicsImpl* GetImpl() const override;
105 void SetDrawable(Drawable d, cairo_surface_t* surface, SalX11Screen nXScreen);
106 XRenderPictFormat* GetXRenderFormat() const;
107 void SetXRenderFormat( XRenderPictFormat* pXRenderFormat ) { m_pXRenderFormat = pXRenderFormat; }
108
109 const SalX11Screen& GetScreenNumber() const { return m_nXScreen; }
110
111 void Flush();
112
113 // override all pure virtual methods
114 virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) override;
115
116 virtual void SetTextColor( Color nColor ) override;
117 virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
118 virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
119 virtual FontCharMapRef GetFontCharMap() const override;
120 virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
122 virtual void ClearDevFontCache() override;
123 virtual bool AddTempDevFont( vcl::font::PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) override;
124
125 virtual std::unique_ptr<GenericSalLayout>
126 GetTextLayout(int nFallbackLevel) override;
127 virtual void DrawTextLayout( const GenericSalLayout& ) override;
128
129 virtual SystemGraphicsData GetGraphicsData() const override;
130
131#if ENABLE_CAIRO_CANVAS
132 virtual bool SupportsCairo() const override;
133 virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
134 virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const override;
135 virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const override;
136 virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const override;
137#endif // ENABLE_CAIRO_CANVAS
138
139 /* use to handle GraphicsExpose/NoExpose after XCopyArea & friends
140 * if pFrame is not NULL, corresponding Paint events are generated
141 * and dispatched to pFrame
142 *
143 * it is imperative to eat up graphics exposes even in case you don't need
144 * them because the next one using XCopyArea can depend on them
145 */
147
149 static void releaseCairoContext(cairo_t* cr);
150
151
152private:
154 void SetClipRegion( GC pGC, Region pXReg = nullptr ) const;
155 bool GetDitherPixmap ( Color nColor );
156
158
159 SalFrame* m_pFrame; // the SalFrame which created this Graphics or NULL
160 SalVirtualDevice* m_pVDev; // the SalVirtualDevice which created this Graphics or NULL
161
162
163 std::unique_ptr<SalColormap> m_pDeleteColormap;
164
166 mutable XRenderPictFormat* m_pXRenderFormat;
168
170 Pixmap hBrush_; // Dither
171
172 bool bWindow_ : 1; // is Window
173 bool bVirDev_ : 1; // is VirDev
174
175 std::unique_ptr<SalGraphicsImpl> mxImpl;
176 std::unique_ptr<TextRenderImpl> mxTextRenderImpl;
178
179public:
180 Drawable GetDrawable() const { return maX11Common.GetDrawable(); }
181 const SalColormap& GetColormap() const { return maX11Common.GetColormap(); }
182 const SalDisplay* GetDisplay() const { return maX11Common.GetDisplay(); }
183 const SalVisual& GetVisual() const { return maX11Common.GetVisual(); }
185 Pixel GetPixel(Color nColor) const { return maX11Common.GetPixel(nColor); }
186};
187
188/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _cairo_surface cairo_surface_t
Definition: CairoCommon.hxx:72
struct _cairo cairo_t
Definition: CairoCommon.hxx:71
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
Display * GetXDisplay() const
Definition: saldisp.hxx:394
const SalDisplay * GetDisplay() const
Definition: saldisp.hxx:142
const SalVisual & GetVisual() const
Definition: saldisp.hxx:144
Pixel GetPixel(Color nColor) const
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:115
Interface used to share logic on sizing between SalVirtualDevices and SalFrames.
Definition: salgeom.hxx:80
Implementation class for SalGraphics.
Definition: salgdiimpl.hxx:51
Color GetPixel(tools::Long nX, tools::Long nY, const OutputDevice &rOutDev)
A non-visible drawable/buffer (e.g. an X11 Pixmap).
Definition: salvd.hxx:30
Drawable m_hDrawable
Definition: unx/salgdi.h:68
const SalColormap * m_pColormap
Definition: unx/salgdi.h:69
const SalColormap & GetColormap() const
Definition: unx/salgdi.h:80
const SalVisual & GetVisual() const
Definition: unx/salgdi.h:82
static void releaseCairoContext(cairo_t *cr)
bool SupportsCairo() const
cairo_surface_t * m_pExternalSurface
Definition: unx/salgdi.h:70
const SalDisplay * GetDisplay() const
Definition: unx/salgdi.h:81
cairo_t * getCairoContext()
Drawable GetDrawable() const
Definition: unx/salgdi.h:85
Display * GetXDisplay() const
Definition: unx/salgdi.h:83
Pixel GetPixel(Color nColor) const
Definition: unx/salgdi.h:84
SalX11Screen m_nXScreen
Definition: unx/salgdi.h:165
static void releaseCairoContext(cairo_t *cr)
virtual SystemGraphicsData GetGraphicsData() const override
Pixmap hBrush_
Definition: unx/salgdi.h:170
const SalColormap & GetColormap() const
Definition: unx/salgdi.h:181
XID m_aXRenderPicture
Definition: unx/salgdi.h:167
Display * GetXDisplay() const
Definition: unx/salgdi.h:184
Region mpClipRegion
Definition: unx/salgdi.h:169
std::unique_ptr< TextRenderImpl > mxTextRenderImpl
Definition: unx/salgdi.h:176
void YieldGraphicsExpose()
Drawable GetDrawable() const
Definition: unx/salgdi.h:180
void SetClipRegion(GC pGC, Region pXReg=nullptr) const
void SetXRenderFormat(XRenderPictFormat *pXRenderFormat)
Definition: unx/salgdi.h:107
X11Common maX11Common
Definition: unx/salgdi.h:177
std::unique_ptr< SalColormap > m_pDeleteColormap
Definition: unx/salgdi.h:163
virtual void SetTextColor(Color nColor) override
const SalVisual & GetVisual() const
Definition: unx/salgdi.h:183
XRenderPictFormat * GetXRenderFormat() const
friend class X11SalGraphicsImpl
Definition: unx/salgdi.h:90
virtual void SetFont(LogicalFontInstance *, int nFallbackLevel) override
bool GetDitherPixmap(Color nColor)
void Init(SalFrame *pFrame, Drawable aDrawable, SalX11Screen nXScreen)
const SalDisplay * GetDisplay() const
Definition: unx/salgdi.h:182
virtual SalGraphicsImpl * GetImpl() const override
SalVirtualDevice * m_pVDev
Definition: unx/salgdi.h:160
virtual std::unique_ptr< GenericSalLayout > GetTextLayout(int nFallbackLevel) override
SalGeometryProvider * GetGeometryProvider() const
cairo_t * getCairoContext()
virtual FontCharMapRef GetFontCharMap() const override
virtual ~X11SalGraphics() COVERITY_NOEXCEPT_FALSE override
std::unique_ptr< SalGraphicsImpl > mxImpl
Definition: unx/salgdi.h:175
Pixel GetPixel(Color nColor) const
Definition: unx/salgdi.h:185
virtual void DrawTextLayout(const GenericSalLayout &) override
virtual void GetFontMetric(ImplFontMetricDataRef &, int nFallbackLevel) override
virtual void GetDevFontList(vcl::font::PhysicalFontCollection *) override
virtual bool AddTempDevFont(vcl::font::PhysicalFontCollection *, const OUString &rFileURL, const OUString &rFontName) override
virtual void ClearDevFontCache() override
const SalX11Screen & GetScreenNumber() const
Definition: unx/salgdi.h:109
void SetDrawable(Drawable d, cairo_surface_t *surface, SalX11Screen nXScreen)
SalFrame * m_pFrame
Definition: unx/salgdi.h:159
XRenderPictFormat * m_pXRenderFormat
Definition: unx/salgdi.h:166
virtual void GetResolution(sal_Int32 &rDPIX, sal_Int32 &rDPIY) override
void freeResources()
virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override
std::shared_ptr< Surface > SurfaceSharedPtr
Definition: cairo.hxx:36
std::shared_ptr< cairo_surface_t > CairoSurfaceSharedPtr
Definition: cairo.hxx:34
Display
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...
unsigned long Pixel
Definition: saldisp.hxx:48
unsigned long Pixel
Definition: unx/salgdi.h:44