Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_outline_generator.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2004 Boudewijn Rempt <boud@valdyas.org>
3 * SPDX-FileCopyrightText: 2007, 2010 Sven Langkamp <sven.langkamp@gmail.com>
4 *
5 * Outline algorithm based of the limn of fontutils
6 * SPDX-FileCopyrightText: 1992 Karl Berry <karl@cs.umb.edu>
7 * SPDX-FileCopyrightText: 1992 Kathryn Hargreaves <letters@cs.umb.edu>
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
12#ifndef KIS_OUTLINE_GENERATOR_H
13#define KIS_OUTLINE_GENERATOR_H
14
15#include <QPolygon>
16
17#include "kritaimage_export.h"
18#include "kis_types.h"
20class KoColorSpace;
21
22
26class KRITAIMAGE_EXPORT KisOutlineGenerator
27{
28public:
29
35 KisOutlineGenerator(const KoColorSpace* cs, quint8 defaultOpacity);
36
46 QVector<QPolygon> outline(quint8* buffer, qint32 xOffset, qint32 yOffset, qint32 width, qint32 height);
47
48 QVector<QPolygon> outline(const KisPaintDevice *buffer, qint32 xOffset, qint32 yOffset, qint32 width, qint32 height);
49
50
55 void setSimpleOutline(bool simple);
56
57private:
58
59
60private:
61
62 enum EdgeType {
63 TopEdge = 1, LeftEdge = 2, BottomEdge = 3, RightEdge = 0, NoEdge = 4
64 };
65
66 template <class StorageStrategy>
67 QVector<QPolygon> outlineImpl(typename StorageStrategy::StorageType buffer,
68 qint32 xOffset, qint32 yOffset,
69 qint32 width, qint32 height);
70
71 template <class StorageStrategy>
72 bool isOutlineEdge(StorageStrategy &storage, EdgeType edge, qint32 x, qint32 y, qint32 bufWidth, qint32 bufHeight);
73
74 template <class StorageStrategy>
75 void nextOutlineEdge(StorageStrategy &storage, EdgeType *edge, qint32 *row, qint32 *col, qint32 width, qint32 height);
76
78 return edge == NoEdge ? edge : static_cast<EdgeType>((edge + 1) % 4);
79 }
80
81 void appendCoordinate(QPolygon * path, int x, int y, EdgeType edge, EdgeType prevEdge);
82
83private:
84
88
90};
91
92#endif // KIS_OUTLINE_GENERATOR_H
const KoColorSpace * m_cs
KisRandomConstAccessorSP m_accessor
EdgeType nextEdge(EdgeType edge)