Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/animate/Animation.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
#ifndef INCLUDED_VCL_ANIMATE_ANIMATION_HXX
21
#define INCLUDED_VCL_ANIMATE_ANIMATION_HXX
22
23
#include <tools/solar.h>
24
#include <vcl/dllapi.h>
25
#include <vcl/timer.hxx>
26
#include <vcl/bitmap.hxx>
27
28
#include <vector>
29
30
class SvStream;
31
struct AnimationFrame;
32
33
52.0k
#define ANIMATION_TIMEOUT_ON_CLICK 2147483647L
34
35
class AnimationRenderer;
36
struct AnimationData;
37
38
class VCL_DLLPUBLIC Animation
39
{
40
public:
41
    Animation();
42
    Animation(const Animation& rAnimation);
43
    ~Animation();
44
45
    SAL_DLLPRIVATE Animation& operator=(const Animation& rAnimation);
46
    SAL_DLLPRIVATE bool operator==(const Animation& rAnimation) const;
47
0
    bool operator!=(const Animation& rAnimation) const { return !(*this == rAnimation); }
48
49
    void Clear();
50
51
    SAL_DLLPRIVATE bool Start(OutputDevice& rOutDev, const Point& rDestPt, const Size& rDestSz,
52
                              tools::Long nRendererId, OutputDevice* pFirstFrameOutDev);
53
54
    SAL_DLLPRIVATE void Stop(const OutputDevice* pOutDev = nullptr, tools::Long nRendererId = 0);
55
56
    SAL_DLLPRIVATE void Draw(OutputDevice& rOutDev, const Point& rDestPt) const;
57
    SAL_DLLPRIVATE void Draw(OutputDevice& rOutDev, const Point& rDestPt,
58
                             const Size& rDestSz) const;
59
60
57.9k
    bool IsInAnimation() const { return mbIsInAnimation; }
61
    SAL_DLLPRIVATE bool IsTransparent() const;
62
63
0
    const Size& GetDisplaySizePixel() const { return maGlobalSize; }
64
2.51k
    void SetDisplaySizePixel(const Size& rSize) { maGlobalSize = rSize; }
65
66
4.57k
    const Bitmap& GetBitmap() const { return maBitmap; }
67
0
    void SetBitmap(const Bitmap& rBmp) { maBitmap = rBmp; }
68
69
0
    sal_uInt32 GetLoopCount() const { return mnLoopCount; }
70
    void SetLoopCount(const sal_uInt32 nLoopCount);
71
    SAL_DLLPRIVATE void ResetLoopCount();
72
73
0
    void SetNotifyHdl(const Link<Animation*, void>& rLink) { maNotifyLink = rLink; }
74
0
    const Link<Animation*, void>& GetNotifyHdl() const { return maNotifyLink; }
75
76
0
    std::vector<std::unique_ptr<AnimationFrame>>& GetAnimationFrames() { return maFrames; }
77
71.3k
    size_t Count() const { return maFrames.size(); }
78
    bool Insert(const AnimationFrame& rAnimationFrame);
79
    const AnimationFrame& Get(sal_uInt16 nAnimation) const;
80
    void Replace(const AnimationFrame& rNewAnimationBmp, sal_uInt16 nAnimation);
81
82
    SAL_DLLPRIVATE sal_uLong GetSizeBytes() const;
83
    SAL_DLLPRIVATE BitmapChecksum GetChecksum() const;
84
85
public:
86
    SAL_DLLPRIVATE void Convert(BmpConversion eConversion);
87
    bool ReduceColors(sal_uInt16 nNewColorCount);
88
89
    bool Invert();
90
    SAL_DLLPRIVATE void Mirror(BmpMirrorFlags nMirrorFlags);
91
    SAL_DLLPRIVATE void Adjust(short nLuminancePercent, short nContrastPercent,
92
                               short nChannelRPercent, short nChannelGPercent,
93
                               short nChannelBPercent, double fGamma = 1.0, bool bInvert = false);
94
95
    friend SvStream& ReadAnimation(SvStream& rIStream, Animation& rAnimation);
96
    friend SvStream& WriteAnimation(SvStream& rOStream, const Animation& rAnimation);
97
98
public:
99
0
    SAL_DLLPRIVATE static void ImplIncAnimCount() { gAnimationRendererCount++; }
100
0
    SAL_DLLPRIVATE static void ImplDecAnimCount() { gAnimationRendererCount--; }
101
0
    SAL_DLLPRIVATE sal_uLong ImplGetCurPos() const { return mnFrameIndex; }
102
103
private:
104
    SAL_DLLPRIVATE static sal_uLong gAnimationRendererCount;
105
106
    std::vector<std::unique_ptr<AnimationFrame>> maFrames;
107
    std::vector<std::unique_ptr<AnimationRenderer>> maRenderers;
108
109
    Link<Animation*, void> maNotifyLink;
110
    Bitmap maBitmap;
111
    Timer maTimer;
112
    Size maGlobalSize;
113
    sal_uInt32 mnLoopCount;
114
    sal_uInt32 mnLoops;
115
    size_t mnFrameIndex;
116
    bool mbIsInAnimation;
117
    bool mbLoopTerminated;
118
119
    SAL_DLLPRIVATE std::vector<std::unique_ptr<AnimationData>> CreateAnimationDataItems();
120
    SAL_DLLPRIVATE void PopulateRenderers();
121
    SAL_DLLPRIVATE void RenderNextFrameInAllRenderers();
122
    SAL_DLLPRIVATE void PruneMarkedRenderers();
123
    SAL_DLLPRIVATE bool IsAnyRendererActive();
124
125
    SAL_DLLPRIVATE void ImplRestartTimer(sal_uLong nTimeout);
126
    DECL_DLLPRIVATE_LINK(ImplTimeoutHdl, Timer*, void);
127
};
128
129
#endif // INCLUDED_VCL_ANIMATE_ANIMATION_HXX
130
131
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */