LibreOffice Module vcl (master) 1
cairo.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#include <sal/config.h>
23#include <osl/endian.h>
24#include <vcl/Scanline.hxx>
25#include <vcl/vclptr.hxx>
26#include <config_features.h>
27#include <config_cairo_rgba.h>
28#include <memory>
29
30// Using formats that match cairo's formats.
31// SVP_24BIT_FORMAT is used to store 24-bit images in 3-byte pixels to conserve memory.
32
33/*
34 For internal cairo we have the option --enable-cairo-rgba which is potentially
35 useful for Android or Online to switch the rgb components. For Android cairo then
36 matches the OpenGL GL_RGBA format so we can use it there where we don't have
37 GL_BGRA support. Similarly for Online we can then use cairo's pixel data
38 without needing to swizzle it for use as a canvas ImageData.
39*/
40#if ENABLE_CAIRO_RGBA
41#define SVP_24BIT_FORMAT (ScanlineFormat::N24BitTcRgb | ScanlineFormat::TopDown)
42#define SVP_CAIRO_FORMAT (ScanlineFormat::N32BitTcRgba | ScanlineFormat::TopDown)
43#define SVP_CAIRO_BLUE 1
44#define SVP_CAIRO_GREEN 2
45#define SVP_CAIRO_RED 0
46#define SVP_CAIRO_ALPHA 3
47#elif defined OSL_BIGENDIAN
48#define SVP_24BIT_FORMAT (ScanlineFormat::N24BitTcRgb | ScanlineFormat::TopDown)
49#define SVP_CAIRO_FORMAT (ScanlineFormat::N32BitTcArgb | ScanlineFormat::TopDown)
50#define SVP_CAIRO_BLUE 3
51#define SVP_CAIRO_GREEN 2
52#define SVP_CAIRO_RED 1
53#define SVP_CAIRO_ALPHA 0
54#else
55#define SVP_24BIT_FORMAT (ScanlineFormat::N24BitTcBgr | ScanlineFormat::TopDown)
56#define SVP_CAIRO_FORMAT (ScanlineFormat::N32BitTcBgra | ScanlineFormat::TopDown)
57#define SVP_CAIRO_BLUE 0
58#define SVP_CAIRO_GREEN 1
59#define SVP_CAIRO_RED 2
60#define SVP_CAIRO_ALPHA 3
61#endif
62
63typedef struct _cairo_surface cairo_surface_t;
64typedef struct _cairo cairo_t;
65
66class VirtualDevice;
67
68namespace cairo {
69
70 typedef std::shared_ptr<cairo_surface_t> CairoSurfaceSharedPtr;
71 typedef std::shared_ptr<cairo_t> CairoSharedPtr;
72 struct Surface;
73 typedef std::shared_ptr<Surface> SurfaceSharedPtr;
74
80 struct Surface
81 {
82 public:
83 virtual ~Surface() {}
84
85 // Query methods
86 virtual CairoSharedPtr getCairo() const = 0;
88 virtual SurfaceSharedPtr getSimilar(int cairo_content_type, int width, int height) const = 0;
89
92
95 virtual bool Resize( int /*width*/, int /*height*/ ) { return false; }
96
98 virtual void flush() const = 0;
99 };
100
101}
102
103/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _cairo_surface cairo_surface_t
Definition: CairoCommon.hxx:46
struct _cairo cairo_t
Definition: CairoCommon.hxx:45
std::shared_ptr< Surface > SurfaceSharedPtr
Definition: cairo.hxx:72
std::shared_ptr< cairo_t > CairoSharedPtr
Definition: cairo.hxx:71
std::shared_ptr< cairo_surface_t > CairoSurfaceSharedPtr
Definition: cairo.hxx:70
Cairo surface interface.
Definition: cairo.hxx:81
virtual ~Surface()
Definition: cairo.hxx:83
virtual void flush() const =0
Flush all pending output to surface.
virtual CairoSurfaceSharedPtr getCairoSurface() const =0
virtual bool Resize(int, int)
Resize the surface (possibly destroying content), only possible for X11 typically so on failure calle...
Definition: cairo.hxx:95
virtual VclPtr< VirtualDevice > createVirtualDevice() const =0
factory for VirDev on this surface
virtual SurfaceSharedPtr getSimilar(int cairo_content_type, int width, int height) const =0
virtual CairoSharedPtr getCairo() const =0