summaryrefslogtreecommitdiffstats
path: root/src/extension/internal/cairo-renderer.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /src/extension/internal/cairo-renderer.h
parentInitial commit. (diff)
downloadinkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.tar.xz
inkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/extension/internal/cairo-renderer.h')
-rw-r--r--src/extension/internal/cairo-renderer.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/extension/internal/cairo-renderer.h b/src/extension/internal/cairo-renderer.h
new file mode 100644
index 0000000..934fa45
--- /dev/null
+++ b/src/extension/internal/cairo-renderer.h
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#ifndef EXTENSION_INTERNAL_CAIRO_RENDERER_H_SEEN
+#define EXTENSION_INTERNAL_CAIRO_RENDERER_H_SEEN
+
+/** \file
+ * Declaration of CairoRenderer, a class used for rendering via a CairoRenderContext.
+ */
+/*
+ * Authors:
+ * Miklos Erdelyi <erdelyim@gmail.com>
+ * Abhishek Sharma
+ *
+ * Copyright (C) 2006 Miklos Erdelyi
+ *
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+
+#include "extension/extension.h"
+#include <set>
+#include <string>
+
+//#include "libnrtype/font-instance.h"
+#include <cairo.h>
+
+class SPItem;
+class SPClipPath;
+class SPMask;
+class SPHatchPath;
+class SPPage;
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+class CairoRenderer;
+class CairoRenderContext;
+
+class CairoRenderer {
+public:
+ CairoRenderer();
+ virtual ~CairoRenderer();
+
+ CairoRenderContext *createContext();
+ void destroyContext(CairoRenderContext *ctx);
+
+ void setStateForItem(CairoRenderContext *ctx, SPItem const *item);
+
+ void applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp);
+ void applyMask(CairoRenderContext *ctx, SPMask const *mask);
+
+ /** Initializes the CairoRenderContext according to the specified
+ SPDocument. A set*Target function can only be called on the context
+ before setupDocument. */
+ bool setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, double bleedmargin_px, SPItem *base);
+
+ /** Traverses the object tree and invokes the render methods. */
+ void renderItem(CairoRenderContext *ctx, SPItem *item, SPItem *clone = nullptr, SPPage *page = nullptr);
+ void renderHatchPath(CairoRenderContext *ctx, SPHatchPath const &hatchPath, unsigned key);
+
+private:
+ /** Extract metadata from doc and set it on ctx. */
+ void setMetadata(CairoRenderContext *ctx, SPDocument *doc);
+
+ /** Decide whether the given item should be rendered as a bitmap. */
+ static bool _shouldRasterize(CairoRenderContext *ctx, SPItem const *item);
+
+ /** Render a single item in a fully set up context. */
+ static void _doRender(SPItem *item, CairoRenderContext *ctx, SPItem *origin = nullptr,
+ SPPage *page = nullptr);
+
+};
+
+// FIXME: this should be a static method of CairoRenderer
+void calculatePreserveAspectRatio(unsigned int aspect_align, unsigned int aspect_clip, double vp_width,
+ double vp_height, double *x, double *y, double *width, double *height);
+
+} /* namespace Internal */
+} /* namespace Extension */
+} /* namespace Inkscape */
+
+#endif /* !EXTENSION_INTERNAL_CAIRO_RENDERER_H_SEEN */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :