2024-08-08 15:44:47 +02:00
|
|
|
/* -*- 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
|
|
|
|
|
2024-09-09 23:40:05 +02:00
|
|
|
#include <rtl/string.hxx>
|
|
|
|
#include <sal/log.hxx>
|
2024-08-08 15:44:47 +02:00
|
|
|
#include <sddllapi.h>
|
2024-09-09 23:40:05 +02:00
|
|
|
#include <svx/unoapi.hxx>
|
2024-08-08 15:44:47 +02:00
|
|
|
#include <tools/gen.hxx>
|
2024-09-09 23:40:05 +02:00
|
|
|
#include <tools/helpers.hxx>
|
|
|
|
|
2024-09-25 15:10:05 +02:00
|
|
|
#include <CustomAnimationEffect.hxx>
|
|
|
|
|
2024-11-15 13:20:06 +01:00
|
|
|
#include <deque>
|
2024-09-25 15:10:05 +02:00
|
|
|
#include <vector>
|
|
|
|
#include <optional>
|
|
|
|
#include <unordered_map>
|
2024-08-21 11:25:05 +02:00
|
|
|
#include <unordered_set>
|
2024-08-08 15:44:47 +02:00
|
|
|
|
|
|
|
class SdrPage;
|
2024-11-15 13:20:06 +01:00
|
|
|
class SdrModel;
|
2024-08-21 11:25:05 +02:00
|
|
|
class SdrObject;
|
2024-08-08 15:44:47 +02:00
|
|
|
class Size;
|
|
|
|
|
2024-09-25 15:10:05 +02:00
|
|
|
namespace com::sun::star::animations
|
|
|
|
{
|
|
|
|
class XAnimate;
|
|
|
|
}
|
|
|
|
|
2024-10-23 11:30:19 +02:00
|
|
|
namespace sdr::contact
|
|
|
|
{
|
|
|
|
class ViewObjectContactRedirector;
|
|
|
|
}
|
|
|
|
|
2024-08-08 15:44:47 +02:00
|
|
|
namespace sd
|
|
|
|
{
|
2024-10-23 11:30:19 +02:00
|
|
|
class RenderContext;
|
2024-08-19 20:51:18 +02:00
|
|
|
|
2024-08-21 11:25:05 +02:00
|
|
|
enum class RenderStage
|
2024-11-15 13:20:06 +01:00
|
|
|
{
|
2024-10-23 11:30:19 +02:00
|
|
|
Background = 0,
|
|
|
|
Master = 1,
|
|
|
|
Slide = 2,
|
|
|
|
TextFields = 3,
|
2024-11-15 13:20:06 +01:00
|
|
|
};
|
|
|
|
|
2024-09-25 15:10:05 +02:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2024-10-23 11:30:19 +02:00
|
|
|
// Holds information used when doing one rendering pass
|
|
|
|
struct RenderPass
|
2024-08-21 11:25:05 +02:00
|
|
|
{
|
2024-09-09 17:34:03 +02:00
|
|
|
RenderStage meStage = RenderStage::Background;
|
2024-10-23 11:30:19 +02:00
|
|
|
std::unordered_map<SdrObject*, std::deque<sal_Int32>> maObjectsAndParagraphs;
|
|
|
|
bool mbRenderObjectBackground = false;
|
2024-08-21 11:25:05 +02:00
|
|
|
|
2024-10-23 11:30:19 +02:00
|
|
|
bool mbAnimation = false;
|
|
|
|
SdrObject* mpAnimatedObject = nullptr;
|
|
|
|
sal_Int32 mnAnimatedParagraph = -1;
|
2024-09-25 15:10:05 +02:00
|
|
|
|
2024-10-23 11:30:19 +02:00
|
|
|
bool isEmpty() { return maObjectsAndParagraphs.empty(); }
|
|
|
|
};
|
2024-09-25 15:10:05 +02:00
|
|
|
|
2024-10-23 11:30:19 +02:00
|
|
|
/** Holds rendering state, properties and switches through all rendering passes */
|
|
|
|
struct RenderState
|
|
|
|
{
|
|
|
|
std::deque<RenderPass> maRenderPasses;
|
2024-09-25 15:10:05 +02:00
|
|
|
|
2024-10-23 11:30:19 +02:00
|
|
|
RenderStage meStage = RenderStage::Background;
|
2024-08-21 11:25:05 +02:00
|
|
|
|
2024-10-23 11:30:19 +02:00
|
|
|
std::unordered_map<SdrObject*, AnimationRenderInfo> maAnimationRenderInfoList;
|
2024-08-21 11:25:05 +02:00
|
|
|
|
2024-10-23 11:30:19 +02:00
|
|
|
std::array<sal_Int32, 4> maIndices = { 0, 0, 0, 0 };
|
2024-08-21 11:25:05 +02:00
|
|
|
|
2024-10-23 11:30:19 +02:00
|
|
|
SdrObject* mpCurrentTarget = nullptr;
|
|
|
|
sal_Int32 mnCurrentTargetParagraph = -1;
|
2024-09-25 15:10:05 +02:00
|
|
|
|
2024-08-21 11:25:05 +02:00
|
|
|
/// increments index depending on the current render stage
|
2024-10-23 11:30:19 +02:00
|
|
|
void incrementIndex() { maIndices[size_t(meStage)]++; }
|
2024-08-21 11:25:05 +02:00
|
|
|
|
|
|
|
/// returns the current stage as string
|
2024-09-04 21:38:29 +02:00
|
|
|
OString stageString() const
|
2024-08-21 11:25:05 +02:00
|
|
|
{
|
|
|
|
if (meStage == RenderStage::Master)
|
|
|
|
return "MasterPage"_ostr;
|
2024-09-09 17:34:03 +02:00
|
|
|
else if (meStage == RenderStage::Background)
|
|
|
|
return "Background"_ostr;
|
|
|
|
else if (meStage == RenderStage::TextFields)
|
|
|
|
return "TextFields"_ostr;
|
2024-08-21 11:25:05 +02:00
|
|
|
return "DrawPage"_ostr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// returns the current index depending on the current render stage
|
2024-10-23 11:30:19 +02:00
|
|
|
sal_Int32 currentIndex() const { return maIndices[size_t(meStage)]; }
|
2024-08-21 11:25:05 +02:00
|
|
|
|
2024-09-04 21:38:29 +02:00
|
|
|
/// returns the current target element for which layer is created if any
|
|
|
|
SdrObject* currentTarget() const { return mpCurrentTarget; }
|
|
|
|
|
2024-09-25 15:10:05 +02:00
|
|
|
/// returns the current target paragraph index or -1 if paragraph is not relevant
|
|
|
|
sal_Int32 currentTargetParagraph() const { return mnCurrentTargetParagraph; }
|
|
|
|
|
2024-08-21 11:25:05 +02:00
|
|
|
/// resets properties that are valid for one pass
|
|
|
|
void resetPass()
|
|
|
|
{
|
2024-09-04 21:38:29 +02:00
|
|
|
mpCurrentTarget = nullptr;
|
2024-09-25 15:10:05 +02:00
|
|
|
mnCurrentTargetParagraph = -1;
|
2024-08-21 11:25:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// should include background in rendering
|
2024-09-09 17:34:03 +02:00
|
|
|
bool includeBackground() const { return meStage == RenderStage::Background; }
|
2024-08-21 11:25:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Renders a slide */
|
2024-08-08 15:44:47 +02:00
|
|
|
class SD_DLLPUBLIC SlideshowLayerRenderer
|
|
|
|
{
|
2024-08-21 11:25:05 +02:00
|
|
|
private:
|
2024-11-15 13:20:06 +01:00
|
|
|
SdrPage& mrPage;
|
|
|
|
SdrModel& mrModel;
|
2024-08-08 15:44:47 +02:00
|
|
|
Size maSlideSize;
|
2024-08-21 11:25:05 +02:00
|
|
|
RenderState maRenderState;
|
2024-11-15 13:20:06 +01:00
|
|
|
|
2024-10-23 11:30:19 +02:00
|
|
|
void createViewAndDraw(RenderContext& rRenderContext,
|
|
|
|
sdr::contact::ViewObjectContactRedirector* pRedirector);
|
2024-08-21 11:25:05 +02:00
|
|
|
void writeJSON(OString& rJsonMsg);
|
2024-09-25 15:10:05 +02:00
|
|
|
|
2024-08-30 16:56:59 +02:00
|
|
|
void setupAnimations();
|
2024-09-25 15:10:05 +02:00
|
|
|
void resolveEffect(CustomAnimationEffectPtr const& rEffect);
|
2024-08-19 20:51:18 +02:00
|
|
|
|
2024-08-08 15:44:47 +02:00
|
|
|
public:
|
2024-11-15 13:20:06 +01:00
|
|
|
SlideshowLayerRenderer(SdrPage& rPage);
|
2024-08-21 11:25:05 +02:00
|
|
|
|
|
|
|
/** Calculate and set the slide size depending on input desired size (in pixels)
|
|
|
|
*
|
2024-11-21 15:36:48 +01:00
|
|
|
* Input the desired size in pixels, and the actual size pixels will be calculated
|
2024-08-21 11:25:05 +02:00
|
|
|
* depending on the size of the slide and the desired size. The size can differ,
|
|
|
|
* because the it must match the slide aspect ratio.
|
|
|
|
**/
|
2024-08-08 15:44:47 +02:00
|
|
|
Size calculateAndSetSizePixel(Size const& rDesiredSizePixel);
|
2024-08-21 11:25:05 +02:00
|
|
|
|
|
|
|
/** Renders one layer
|
|
|
|
*
|
|
|
|
* The slide layer is rendered into the input buffer, which must be the byte size
|
2024-11-21 15:36:48 +01:00
|
|
|
* of the calculated size in pixels * 4 (RGBA).
|
2024-08-21 11:25:05 +02:00
|
|
|
* The properties of the layer are written to the input string in JSON format.
|
|
|
|
*
|
|
|
|
* @returns false, if nothing was rendered and rendering is done */
|
2024-12-16 07:42:05 -04:00
|
|
|
bool render(unsigned char* pBuffer, double& scale, OString& rJsonMsg);
|
2024-08-08 15:44:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end of namespace sd
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|