QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskVertex.cpp
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#include "QskVertex.h"
7
8using namespace QskVertex;
9
10#ifndef QT_NO_DEBUG_STREAM
11
12#include <qdebug.h>
13
14QDebug operator<<( QDebug debug, Color color )
15{
16 QDebugStateSaver saver( debug );
17 debug.nospace();
18 debug << "C" << '(';
19 debug << color.r << "," << color.g << "," << color.b << "," << color.a;
20 debug << ')';
21
22 return debug;
23}
24
25QDebug operator<<( QDebug debug, const ColoredLine& line )
26{
27 qDebug() << qRound( line.p1.x ) << qRound( line.p1.y )
28 << "->" << qRound( line.p2.x ) << qRound( line.p2.y );
29
30 return debug;
31}
32
33QDebug operator<<( QDebug debug, const Line& line )
34{
35 qDebug() << qRound( line.p1.x ) << qRound( line.p1.y )
36 << "->" << qRound( line.p2.x ) << qRound( line.p2.y );
37
38 return debug;
39}
40
41#endif
42
43template< class Line >
44static inline void qskDebugGeometry( const Line* lines, int count )
45{
46#ifndef QT_NO_DEBUG_STREAM
47 for ( int i = 0; i < count; i++ )
48 {
49 const auto l = lines[i];
50
51 qDebug() << i << ":"
52 << qRound( l.p1.x ) << qRound( l.p1.y )
53 << "->" << qRound( l.p2.x ) << qRound( l.p2.y );
54 }
55#endif
56}
57
58void QskVertex::debugGeometry( const QSGGeometry& geometry )
59{
60 const auto lineCount = geometry.vertexCount() / 2;
61
62 if ( geometry.attributeCount() == 1 )
63 {
64 const auto lines = reinterpret_cast< const Line* >( geometry.vertexData() );
65 qskDebugGeometry( lines, lineCount );
66 }
67 else if ( geometry.attributeCount() == 2 )
68 {
69 const auto lines = reinterpret_cast< const ColoredLine* >( geometry.vertexData() );
70 qskDebugGeometry( lines, lineCount );
71 }
72}