1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <rtl/string.hxx>
#include <sal/log.hxx>
#include <sddllapi.h>
#include <svx/unoapi.hxx>
#include <tools/gen.hxx>
#include <tools/helpers.hxx>
#include <CustomAnimationEffect.hxx>
#include <deque>
#include <vector>
#include <optional>
#include <unordered_map>
#include <unordered_set>
class SdrPage;
class SdrModel;
class SdrObject;
class Size;
namespace com::sun::star::animations
{
class XAnimate;
}
namespace sdr::contact
{
class ViewObjectContactRedirector;
}
namespace sd
{
class RenderContext;
enum class RenderStage
{
Background = 0,
Master = 1,
Slide = 2,
TextFields = 3,
};
struct AnimationLayerInfo
{
OString msHash;
std::optional<bool> moInitiallyVisible;
};
struct AnimationRenderInfo
{
std::optional<AnimationLayerInfo> moObjectInfo;
std::vector<sal_Int32> maParagraphs;
std::unordered_map<sal_Int32, AnimationLayerInfo> maParagraphInfos;
};
// Holds information used when doing one rendering pass
struct RenderPass
{
RenderStage meStage = RenderStage::Background;
std::unordered_map<SdrObject*, std::deque<sal_Int32>> maObjectsAndParagraphs;
bool mbRenderObjectBackground = false;
bool mbAnimation = false;
SdrObject* mpObject = nullptr;
sal_Int32 mnParagraph = -1;
bool mbPlaceholder = false;
OUString maFieldType;
bool isEmpty() { return maObjectsAndParagraphs.empty(); }
};
/** Holds rendering state, properties and switches through all rendering passes */
struct RenderState
{
std::deque<RenderPass> maRenderPasses;
std::vector<RenderPass> maTextFields;
RenderStage meStage = RenderStage::Background;
std::unordered_map<SdrObject*, AnimationRenderInfo> maAnimationRenderInfoList;
std::array<sal_Int32, 4> maIndices = { 0, 0, 0, 0 };
SdrObject* mpCurrentTarget = nullptr;
sal_Int32 mnCurrentTargetParagraph = -1;
bool mbShowMasterPageObjects = false;
bool mbFooterEnabled = false;
bool mbDateTimeEnabled = false;
bool mbSlideNumberEnabled = false;
/// increments index depending on the current render stage
void incrementIndex() { maIndices[size_t(meStage)]++; }
/// returns the current stage as string
OString stageString() const
{
if (meStage == RenderStage::Master)
return "MasterPage"_ostr;
else if (meStage == RenderStage::Background)
return "Background"_ostr;
else if (meStage == RenderStage::TextFields)
return "TextFields"_ostr;
return "DrawPage"_ostr;
}
/// returns the current index depending on the current render stage
sal_Int32 currentIndex() const { return maIndices[size_t(meStage)]; }
/// should include background in rendering
bool includeBackground() const { return meStage == RenderStage::Background; }
};
/** Renders a slide */
class SD_DLLPUBLIC SlideshowLayerRenderer
{
private:
SdrPage& mrPage;
SdrModel& mrModel;
Size maSlideSize;
RenderState maRenderState;
void createViewAndDraw(RenderContext& rRenderContext,
sdr::contact::ViewObjectContactRedirector* pRedirector);
void writeBackgroundJSON(OString& rJsonMsg);
void writeJSON(OString& rJsonMsg, RenderPass const& rRenderPass);
void setupAnimations();
void setupMasterPageFields();
void resolveEffect(CustomAnimationEffectPtr const& rEffect);
public:
SlideshowLayerRenderer(SdrPage& rPage);
/** Calculate and set the slide size depending on input desired size (in pixels)
*
* Input the desired size in pixels, and the actual size pixels will be calculated
* depending on the size of the slide and the desired size. The size can differ,
* because the it must match the slide aspect ratio.
**/
Size calculateAndSetSizePixel(Size const& rDesiredSizePixel);
/** Renders one layer
*
* The slide layer is rendered into the input buffer, which must be the byte size
* of the calculated size in pixels * 4 (RGBA).
* The properties of the layer are written to the input string in JSON format.
*
* @returns false, if nothing was rendered and rendering is done */
bool render(unsigned char* pBuffer, double& scale, OString& rJsonMsg);
};
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|