1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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>
29 //Using formats that match cairo's formats. For android we patch cairo,
30 //which is internal in that case, to swap the rgb components so that
31 //cairo then matches the OpenGL GL_RGBA format so we can use it there
32 //where we don't have GL_BGRA support.
33 // SVP_24BIT_FORMAT is used to store 24-bit images in 3-byte pixels to conserve memory.
34 #if defined(ANDROID) && !HAVE_FEATURE_ANDROID_LOK
35 #define SVP_24BIT_FORMAT (ScanlineFormat::N24BitTcRgb | ScanlineFormat::TopDown)
36 #define SVP_CAIRO_FORMAT (ScanlineFormat::N32BitTcRgba | ScanlineFormat::TopDown)
37 #define SVP_CAIRO_BLUE 1
38 #define SVP_CAIRO_GREEN 2
39 #define SVP_CAIRO_RED 0
40 #define SVP_CAIRO_ALPHA 3
41 #elif defined OSL_BIGENDIAN
42 #define SVP_24BIT_FORMAT (ScanlineFormat::N24BitTcRgb | ScanlineFormat::TopDown)
43 #define SVP_CAIRO_FORMAT (ScanlineFormat::N32BitTcArgb | ScanlineFormat::TopDown)
44 #define SVP_CAIRO_BLUE 3
45 #define SVP_CAIRO_GREEN 2
46 #define SVP_CAIRO_RED 1
47 #define SVP_CAIRO_ALPHA 0
49 #define SVP_24BIT_FORMAT (ScanlineFormat::N24BitTcBgr | ScanlineFormat::TopDown)
50 #define SVP_CAIRO_FORMAT (ScanlineFormat::N32BitTcBgra | ScanlineFormat::TopDown)
51 #define SVP_CAIRO_BLUE 0
52 #define SVP_CAIRO_GREEN 1
53 #define SVP_CAIRO_RED 2
54 #define SVP_CAIRO_ALPHA 3
57 typedef struct _cairo_surface cairo_surface_t
;
58 typedef struct _cairo cairo_t
;
64 typedef std::shared_ptr
<cairo_surface_t
> CairoSurfaceSharedPtr
;
65 typedef std::shared_ptr
<cairo_t
> CairoSharedPtr
;
67 typedef std::shared_ptr
<Surface
> SurfaceSharedPtr
;
69 /** Cairo surface interface
71 For each cairo-supported platform, there's an implementation of
80 virtual CairoSharedPtr
getCairo() const = 0;
81 virtual CairoSurfaceSharedPtr
getCairoSurface() const = 0;
82 virtual SurfaceSharedPtr
getSimilar(int cairo_content_type
, int width
, int height
) const = 0;
84 /// factory for VirDev on this surface
85 virtual VclPtr
<VirtualDevice
> createVirtualDevice() const = 0;
87 /// Resize the surface (possibly destroying content), only possible for X11 typically
88 /// so on failure caller must create a new surface instead
89 virtual bool Resize( int /*width*/, int /*height*/ ) { return false; }
91 /// Flush all pending output to surface
92 virtual void flush() const = 0;
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */