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
|
|
|
|
|
|
|
|
#include <sddllapi.h>
|
|
|
|
#include <tools/gen.hxx>
|
|
|
|
#include <rtl/string.hxx>
|
2024-11-15 13:20:06 +01:00
|
|
|
#include <deque>
|
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-11-15 13:20:06 +01:00
|
|
|
|
2024-08-08 15:44:47 +02:00
|
|
|
class Size;
|
|
|
|
|
|
|
|
namespace sd
|
|
|
|
{
|
2024-08-19 20:51:18 +02:00
|
|
|
struct RenderContext;
|
|
|
|
|
2024-08-21 11:25:05 +02:00
|
|
|
enum class RenderStage
|
2024-11-15 13:20:06 +01:00
|
|
|
{
|
|
|
|
Master,
|
|
|
|
Slide
|
|
|
|
};
|
|
|
|
|
2024-08-21 11:25:05 +02:00
|
|
|
/** Holds rendering state, properties and switches through all rendering passes */
|
|
|
|
struct RenderState
|
|
|
|
{
|
|
|
|
RenderStage meStage = RenderStage::Master;
|
|
|
|
|
|
|
|
sal_Int32 mnMasterIndex = 0;
|
|
|
|
bool mbStopRenderingWhenField = true;
|
|
|
|
|
|
|
|
std::unordered_set<SdrObject*> maObjectsDone;
|
2024-08-30 16:56:59 +02:00
|
|
|
std::unordered_set<SdrObject*> maInAnimation;
|
2024-08-21 11:25:05 +02:00
|
|
|
sal_Int32 mnIndex = 0;
|
|
|
|
|
|
|
|
bool mbFirstObjectInPass = true;
|
|
|
|
bool mbPassHasOutput = false;
|
|
|
|
bool mbSkipAllInThisPass = false;
|
|
|
|
|
|
|
|
sal_Int32 mnCurrentPass = 0;
|
|
|
|
|
|
|
|
/// increments index depending on the current render stage
|
|
|
|
void incrementIndex()
|
|
|
|
{
|
|
|
|
if (meStage == RenderStage::Master)
|
|
|
|
mnMasterIndex++;
|
|
|
|
else
|
|
|
|
mnIndex++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// returns the current stage as string
|
|
|
|
OString stageString()
|
|
|
|
{
|
|
|
|
if (meStage == RenderStage::Master)
|
|
|
|
return "MasterPage"_ostr;
|
|
|
|
return "DrawPage"_ostr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// returns the current index depending on the current render stage
|
|
|
|
sal_Int32 currentIndex()
|
|
|
|
{
|
|
|
|
if (meStage == RenderStage::Master)
|
|
|
|
return mnMasterIndex;
|
|
|
|
return mnIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// resets properties that are valid for one pass
|
|
|
|
void resetPass()
|
|
|
|
{
|
|
|
|
mbFirstObjectInPass = true;
|
|
|
|
mbPassHasOutput = false;
|
|
|
|
mbSkipAllInThisPass = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// return if there was no rendering output in the pass
|
|
|
|
bool noMoreOutput()
|
|
|
|
{
|
|
|
|
// no output and we don't skip anything
|
|
|
|
return !mbPassHasOutput && !mbSkipAllInThisPass;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// should include background in rendering
|
|
|
|
bool includeBackground()
|
|
|
|
{
|
|
|
|
// include background only if we are rendering the first pass
|
|
|
|
return mnCurrentPass == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isObjectAlreadyRendered(SdrObject* pObject)
|
|
|
|
{
|
|
|
|
return maObjectsDone.find(pObject) != maObjectsDone.end();
|
|
|
|
}
|
2024-08-30 16:56:59 +02:00
|
|
|
|
|
|
|
bool isObjectInAnimation(SdrObject* pObject)
|
|
|
|
{
|
|
|
|
return maInAnimation.find(pObject) != maInAnimation.end();
|
|
|
|
}
|
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-08-21 11:25:05 +02:00
|
|
|
void createViewAndDraw(RenderContext& rRenderContext);
|
|
|
|
void writeJSON(OString& rJsonMsg);
|
2024-08-30 16:56:59 +02:00
|
|
|
void setupAnimations();
|
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-08-08 15:44:47 +02:00
|
|
|
bool render(unsigned char* pBuffer, OString& rJsonMsg);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end of namespace sd
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|