src/gui/painting/qpaintengine_raster.cpp
branchRCL_3
changeset 7 3f74d0d4af4c
parent 5 d3bac044e0f0
child 13 c0432d11811c
equal deleted inserted replaced
6:dee5afe5301f 7:3f74d0d4af4c
    98 #if defined(Q_WS_WIN64)
    98 #if defined(Q_WS_WIN64)
    99 #  include <malloc.h>
    99 #  include <malloc.h>
   100 #endif
   100 #endif
   101 #include <limits.h>
   101 #include <limits.h>
   102 
   102 
   103 #if defined(QT_NO_FPU) || (_MSC_VER >= 1300 && _MSC_VER < 1400)
       
   104 #  define FLOATING_POINT_BUGGY_OR_NO_FPU
       
   105 #endif
       
   106 
       
   107 QT_BEGIN_NAMESPACE
   103 QT_BEGIN_NAMESPACE
   108 
   104 
   109 extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp
   105 extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp
   110 
   106 
   111 #define qreal_to_fixed_26_6(f) (int(f * 64))
   107 #define qreal_to_fixed_26_6(f) (int(f * 64))
  3677 
  3673 
  3678     ensurePen();
  3674     ensurePen();
  3679     if (((qpen_style(s->lastPen) == Qt::SolidLine && s->flags.fast_pen)
  3675     if (((qpen_style(s->lastPen) == Qt::SolidLine && s->flags.fast_pen)
  3680          || (qpen_style(s->lastPen) == Qt::NoPen && !s->flags.antialiased))
  3676          || (qpen_style(s->lastPen) == Qt::NoPen && !s->flags.antialiased))
  3681         && qMax(rect.width(), rect.height()) < QT_RASTER_COORD_LIMIT
  3677         && qMax(rect.width(), rect.height()) < QT_RASTER_COORD_LIMIT
  3682 #ifdef FLOATING_POINT_BUGGY_OR_NO_FPU
       
  3683         && qMax(rect.width(), rect.height()) < 128 // integer math breakdown
       
  3684 #endif
       
  3685         && s->matrix.type() <= QTransform::TxScale) // no shear
  3678         && s->matrix.type() <= QTransform::TxScale) // no shear
  3686     {
  3679     {
  3687         ensureBrush();
  3680         ensureBrush();
  3688         const QRectF r = s->matrix.mapRect(rect);
  3681         const QRectF r = s->matrix.mapRect(rect);
  3689         ProcessSpans penBlend = d->getPenFunc(r, &s->penData);
  3682         ProcessSpans penBlend = d->getPenFunc(r, &s->penData);
  6052 */
  6045 */
  6053 static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip,
  6046 static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip,
  6054                                    ProcessSpans pen_func, ProcessSpans brush_func,
  6047                                    ProcessSpans pen_func, ProcessSpans brush_func,
  6055                                    QSpanData *pen_data, QSpanData *brush_data)
  6048                                    QSpanData *pen_data, QSpanData *brush_data)
  6056 {
  6049 {
  6057 #ifdef FLOATING_POINT_BUGGY_OR_NO_FPU // no fpu, so use fixed point
       
  6058     const QFixed a = QFixed(rect.width()) >> 1;
       
  6059     const QFixed b = QFixed(rect.height()) >> 1;
       
  6060     QFixed d = b*b - (a*a*b) + ((a*a) >> 2);
       
  6061 #else
       
  6062     const qreal a = qreal(rect.width()) / 2;
  6050     const qreal a = qreal(rect.width()) / 2;
  6063     const qreal b = qreal(rect.height()) / 2;
  6051     const qreal b = qreal(rect.height()) / 2;
  6064     qreal d = b*b - (a*a*b) + 0.25*a*a;
  6052     qreal d = b*b - (a*a*b) + 0.25*a*a;
  6065 #endif
       
  6066 
  6053 
  6067     int x = 0;
  6054     int x = 0;
  6068     int y = (rect.height() + 1) / 2;
  6055     int y = (rect.height() + 1) / 2;
  6069     int startx = x;
  6056     int startx = x;
  6070 
  6057 
  6083     }
  6070     }
  6084     drawEllipsePoints(startx, y, x - startx + 1, rect, clip,
  6071     drawEllipsePoints(startx, y, x - startx + 1, rect, clip,
  6085                       pen_func, brush_func, pen_data, brush_data);
  6072                       pen_func, brush_func, pen_data, brush_data);
  6086 
  6073 
  6087     // region 2
  6074     // region 2
  6088 #ifdef FLOATING_POINT_BUGGY_OR_NO_FPU
       
  6089     d = b*b*(x + (QFixed(1) >> 1))*(x + (QFixed(1) >> 1))
       
  6090         + a*a*((y - 1)*(y - 1) - b*b);
       
  6091 #else
       
  6092     d = b*b*(x + 0.5)*(x + 0.5) + a*a*((y - 1)*(y - 1) - b*b);
  6075     d = b*b*(x + 0.5)*(x + 0.5) + a*a*((y - 1)*(y - 1) - b*b);
  6093 #endif
       
  6094     const int miny = rect.height() & 0x1;
  6076     const int miny = rect.height() & 0x1;
  6095     while (y > miny) {
  6077     while (y > miny) {
  6096         if (d < 0) { // select SE
  6078         if (d < 0) { // select SE
  6097             d += b*b*(2*x + 2) + a*a*(-2*y + 3);
  6079             d += b*b*(2*x + 2) + a*a*(-2*y + 3);
  6098             ++x;
  6080             ++x;