Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/canvas/source/vcl/canvasbitmap.cxx
Line
Count
Source
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
#include <sal/config.h>
21
22
#include <cppuhelper/supportsservice.hxx>
23
#include <vcl/alpha.hxx>
24
25
#include "canvasbitmap.hxx"
26
27
28
using namespace ::com::sun::star;
29
30
31
namespace vclcanvas
32
{
33
    // Currently, the only way to generate an XBitmap is from
34
    // XGraphicDevice.getCompatibleBitmap(). Therefore, we don't even
35
    // take a bitmap here, but a VDev directly.
36
    CanvasBitmap::CanvasBitmap( const ::Size&                  rSize,
37
                                bool                           bAlphaBitmap,
38
                                rendering::XGraphicDevice&     rDevice,
39
                                const OutDevProviderSharedPtr& rOutDevProvider )
40
0
    {
41
        // create bitmap for given reference device
42
        // ========================================
43
44
        // only create alpha channel bitmap, if factory requested
45
        // that. Providing alpha-channeled bitmaps by default has,
46
        // especially under VCL, a huge performance penalty (have to
47
        // use alpha VDev, then).
48
0
        if( bAlphaBitmap )
49
0
        {
50
0
            maCanvasHelper.init( Bitmap(rSize, vcl::PixelFormat::N32_BPP),
51
0
                                 rDevice,
52
0
                                 rOutDevProvider );
53
0
        }
54
0
        else
55
0
        {
56
0
            maCanvasHelper.init( Bitmap(rSize, vcl::PixelFormat::N24_BPP),
57
0
                                 rDevice,
58
0
                                 rOutDevProvider );
59
0
        }
60
0
    }
61
62
    CanvasBitmap::CanvasBitmap( const ::Bitmap&                rBitmap,
63
                                rendering::XGraphicDevice&     rDevice,
64
                                const OutDevProviderSharedPtr& rOutDevProvider )
65
0
    {
66
0
        maCanvasHelper.init( rBitmap, rDevice, rOutDevProvider );
67
0
    }
68
69
70
    OUString SAL_CALL CanvasBitmap::getImplementationName(  )
71
0
    {
72
0
        return u"VCLCanvas.CanvasBitmap"_ustr;
73
0
    }
74
75
    sal_Bool SAL_CALL CanvasBitmap::supportsService( const OUString& ServiceName )
76
0
    {
77
0
        return cppu::supportsService( this, ServiceName );
78
0
    }
79
80
    uno::Sequence< OUString > SAL_CALL CanvasBitmap::getSupportedServiceNames(  )
81
0
    {
82
0
        return { u"com.sun.star.rendering.CanvasBitmap"_ustr };
83
0
    }
84
85
    Bitmap CanvasBitmap::getBitmap() const
86
0
    {
87
0
        SolarMutexGuard aGuard;
88
89
        // TODO(T3): Rework to use shared_ptr all over the place for
90
        // BmpEx. This is highly un-threadsafe
91
0
        return maCanvasHelper.getBitmap();
92
0
    }
93
94
    bool CanvasBitmap::repaint( const GraphicObjectSharedPtr& rGrf,
95
                                const rendering::ViewState&   viewState,
96
                                const rendering::RenderState& renderState,
97
                                const ::Point&                rPt,
98
                                const ::Size&                 rSz,
99
                                const GraphicAttr&            rAttr ) const
100
0
    {
101
0
        SolarMutexGuard aGuard;
102
103
0
        mbSurfaceDirty = true;
104
105
0
        return maCanvasHelper.repaint( rGrf, viewState, renderState, rPt, rSz, rAttr );
106
0
    }
107
108
    uno::Any SAL_CALL CanvasBitmap::getFastPropertyValue( sal_Int32 nHandle )
109
0
    {
110
0
        if( nHandle == 0 ) {
111
0
            Bitmap* pBitmap = new Bitmap( getBitmap() );
112
113
0
            return uno::Any( reinterpret_cast<sal_Int64>( pBitmap ) );
114
0
        }
115
116
0
        return uno::Any( sal_Int64(0) );
117
0
    }
118
}
119
120
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */