Coverage Report

Created: 2025-11-16 09:57

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<
50
            ::canvas::BaseMutexHelper< CanvasBitmapBase_Base >,
51
            CanvasBitmapHelper,
52
            vclcanvastools::LocalGuard,
53
            ::cppu::OWeakObject> > CanvasBitmap_Base;
54
55
    class CanvasBitmap : public CanvasBitmap_Base,
56
                         public RepaintTarget
57
    {
58
    public:
59
        /** Must be called with locked Solar mutex
60
61
            @param rSize
62
            Size in pixel of the bitmap to generate
63
64
            @param bAlphaBitmap
65
            When true, bitmap will have an alpha channel
66
67
            @param rDevice
68
            Reference device, with which bitmap should be compatible
69
         */
70
        CanvasBitmap( const ::Size&                                rSize,
71
                      bool                                         bAlphaBitmap,
72
                      css::rendering::XGraphicDevice&              rDevice,
73
                      const OutDevProviderSharedPtr&               rOutDevProvider );
74
75
        /// Must be called with locked Solar mutex
76
        CanvasBitmap( const ::Bitmap&                              rBitmap,
77
                      css::rendering::XGraphicDevice&              rDevice,
78
                      const OutDevProviderSharedPtr&               rOutDevProvider );
79
80
        // XServiceInfo
81
        virtual OUString SAL_CALL getImplementationName(  ) override;
82
        virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
83
        virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) override;
84
85
        // RepaintTarget interface
86
        virtual bool repaint( const GraphicObjectSharedPtr&                   rGrf,
87
                              const css::rendering::ViewState&   viewState,
88
                              const css::rendering::RenderState& renderState,
89
                              const ::Point&                                  rPt,
90
                              const ::Size&                                   rSz,
91
                              const GraphicAttr&                              rAttr ) const override;
92
93
        /// Not threadsafe! Returned object is shared!
94
        ::Bitmap getBitmap() const;
95
96
        // XFastPropertySet
97
        // used to retrieve Bitmap pointer or X Pixmap handles for this bitmap
98
        // handle values have these meanings:
99
        // 0 ... get pointer to Bitmap
100
        // 1 ... get X pixmap handle to rgb content
101
        // 2 ... get X pixmap handle to alpha mask
102
        // returned any contains either Bitmap pointer or array of three Any value
103
        //     1st a bool value: true - free the pixmap after used by XFreePixmap, false do nothing, the pixmap is used internally in the canvas
104
        //     2nd the pixmap handle (sal_Int64)
105
        //     3rd the pixmap depth
106
        virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) override;
107
0
        virtual void SAL_CALL setFastPropertyValue(sal_Int32, const css::uno::Any&) override {}
108
109
    private:
110
        /** MUST hold here, too, since CanvasHelper only contains a
111
            raw pointer (without refcounting)
112
        */
113
        css::uno::Reference<css::rendering::XGraphicDevice> mxDevice;
114
    };
115
}
116
117
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */