Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_qimage_pyramid.cpp File Reference
#include "kis_qimage_pyramid.h"
#include <limits>
#include <QPainter>
#include <kis_debug.h>

Go to the source code of this file.

Macros

#define MAX_MIPMAP_SCALE   8.0
 
#define MIPMAP_SIZE_THRESHOLD   512
 
#define QPAINTER_WORKAROUND_BORDER   1
 

Functions

QTransform baseBrushTransform (KisDabShape const &shape, qreal subPixelX, qreal subPixelY, const QRectF &baseBounds)
 
QRect roundRect (const QRectF &rc)
 

Macro Definition Documentation

◆ MAX_MIPMAP_SCALE

#define MAX_MIPMAP_SCALE   8.0

Definition at line 14 of file kis_qimage_pyramid.cpp.

◆ MIPMAP_SIZE_THRESHOLD

#define MIPMAP_SIZE_THRESHOLD   512

Definition at line 13 of file kis_qimage_pyramid.cpp.

◆ QPAINTER_WORKAROUND_BORDER

#define QPAINTER_WORKAROUND_BORDER   1

Definition at line 16 of file kis_qimage_pyramid.cpp.

Function Documentation

◆ baseBrushTransform()

QTransform baseBrushTransform ( KisDabShape const & shape,
qreal subPixelX,
qreal subPixelY,
const QRectF & baseBounds )

Definition at line 131 of file kis_qimage_pyramid.cpp.

134{
135 QTransform transform;
136 transform.scale(shape.scaleX(), shape.scaleY());
137
138 if (!qFuzzyCompare(shape.rotation(), 0) && !qIsNaN(shape.rotation())) {
139 transform = transform * QTransform().rotateRadians(shape.rotation());
140 QRectF rotatedBounds = transform.mapRect(baseBounds);
141 transform = transform * QTransform::fromTranslate(-rotatedBounds.x(), -rotatedBounds.y());
142 }
143
144 return transform * QTransform::fromTranslate(subPixelX, subPixelY);
145}
static bool qFuzzyCompare(half p1, half p2)

References qFuzzyCompare(), KisDabShape::rotation(), KisDabShape::scaleX(), and KisDabShape::scaleY().

◆ roundRect()

QRect roundRect ( const QRectF & rc)
inline

This is an analog of toAlignedRect() with the only difference that it ensures the rect position will never be below zero.

Warning: be very careful with using bottom()/right() values of a pure QRect (we don't use it here for the dangers it can lead to).

Definition at line 91 of file kis_qimage_pyramid.cpp.

92{
102 QRectF rect(rc);
103
104 KIS_SAFE_ASSERT_RECOVER_NOOP(rect.x() > -0.000001);
105 KIS_SAFE_ASSERT_RECOVER_NOOP(rect.y() > -0.000001);
106
107 if (rect.x() < 0.000001) {
108 rect.setLeft(0.0);
109 }
110
111 if (rect.y() < 0.000001) {
112 rect.setTop(0.0);
113 }
114
115 qreal w_rounded = qRound(rect.width());
116 qreal h_rounded = qRound(rect.height());
117
118 //Take care of the float precision errors
119 if (qAbs(rect.width() - w_rounded) < 0.000001) {
120 rect.setWidth(w_rounded);
121 }
122
123 if (qAbs(rect.height() - h_rounded) < 0.000001) {
124 rect.setHeight(h_rounded);
125 }
126
127
128 return rect.toAlignedRect();
129}
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References KIS_SAFE_ASSERT_RECOVER_NOOP.