Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/canvas/source/vcl/canvasbitmap.hxx
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
#pragma once
21
22
#include <cppuhelper/compbase.hxx>
23
24
#include <com/sun/star/lang/XServiceInfo.hpp>
25
#include <com/sun/star/rendering/XBitmapCanvas.hpp>
26
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
27
#include <com/sun/star/beans/XFastPropertySet.hpp>
28
29
#include <vcl/bitmap.hxx>
30
31
#include <base/bitmapcanvasbase.hxx>
32
#include <base/basemutexhelper.hxx>
33
#include <base/integerbitmapbase.hxx>
34
#include "canvasbitmaphelper.hxx"
35
36
#include "impltools.hxx"
37
#include "repainttarget.hxx"
38
39
40
/* Definition of CanvasBitmap class */
41
42
namespace vclcanvas
43
{
44
    typedef ::cppu::WeakComponentImplHelper< css::rendering::XBitmapCanvas,
45
                                             css::rendering::XIntegerBitmap,
46
                                             css::lang::XServiceInfo,
47
                                             css::beans::XFastPropertySet >    CanvasBitmapBase_Base;
48
    typedef ::canvas::IntegerBitmapBase<
49
        canvas::BitmapCanvasBase2<::canvas::BaseMutexHelper<CanvasBitmapBase_Base>,
50
                                  CanvasBitmapHelper, vclcanvastools::LocalGuard>>
51
        CanvasBitmap_Base;
52
53
    class CanvasBitmap : public CanvasBitmap_Base,
54
                         public RepaintTarget
55
    {
56
    public:
57
        /** Must be called with locked Solar mutex
58
59
            @param rSize
60
            Size in pixel of the bitmap to generate
61
62
            @param bAlphaBitmap
63
            When true, bitmap will have an alpha channel
64
65
            @param rDevice
66
            Reference device, with which bitmap should be compatible
67
         */
68
        CanvasBitmap( const ::Size&                                rSize,
69
                      bool                                         bAlphaBitmap,
70
                      css::rendering::XGraphicDevice&              rDevice,
71
                      const OutDevProviderSharedPtr&               rOutDevProvider );
72
73
        /// Must be called with locked Solar mutex
74
        CanvasBitmap( const ::Bitmap&                              rBitmap,
75
                      css::rendering::XGraphicDevice&              rDevice,
76
                      const OutDevProviderSharedPtr&               rOutDevProvider );
77
78
        // XServiceInfo
79
        virtual OUString SAL_CALL getImplementationName(  ) override;
80
        virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
81
        virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) override;
82
83
        // RepaintTarget interface
84
        virtual bool repaint( const GraphicObjectSharedPtr&                   rGrf,
85
                              const css::rendering::ViewState&   viewState,
86
                              const css::rendering::RenderState& renderState,
87
                              const ::Point&                                  rPt,
88
                              const ::Size&                                   rSz,
89
                              const GraphicAttr&                              rAttr ) const override;
90
91
        /// Not threadsafe! Returned object is shared!
92
        ::Bitmap getBitmap() const;
93
94
        // XFastPropertySet
95
        // used to retrieve Bitmap pointer or X Pixmap handles for this bitmap
96
        // handle values have these meanings:
97
        // 0 ... get pointer to Bitmap
98
        // 1 ... get X pixmap handle to rgb content
99
        // 2 ... get X pixmap handle to alpha mask
100
        // returned any contains either Bitmap pointer or array of three Any value
101
        //     1st a bool value: true - free the pixmap after used by XFreePixmap, false do nothing, the pixmap is used internally in the canvas
102
        //     2nd the pixmap handle (sal_Int64)
103
        //     3rd the pixmap depth
104
        virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) override;
105
0
        virtual void SAL_CALL setFastPropertyValue(sal_Int32, const css::uno::Any&) override {}
106
107
    private:
108
        /** MUST hold here, too, since CanvasHelper only contains a
109
            raw pointer (without refcounting)
110
        */
111
        css::uno::Reference<css::rendering::XGraphicDevice> mxDevice;
112
    };
113
}
114
115
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */