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