qt-fix.diff

Jürgen Fischer, 2010-10-04 04:39 PM

Download (14.3 KB)

View differences:

qt-win-opensource-src-4.5.2/src/gui/painting/qoutlinemapper.cpp 2009-09-12 11:19:10.156250000 +0200
74 74
    return QRectF(QPointF(minx, miny), QPointF(maxx, maxy));
75 75
}
76 76

  
77
static QPainterPath vp_convertToPainterPath(const QVectorPath &vp) 
78
{
79
    QPainterPath path;
80

  
81
    if (vp.elementCount() == 0)
82
	return path;
83

  
84
    const QPointF *points = (const QPointF *) vp.points();
85

  
86
    if (vp.elements()) {
87
	for (int i=0; i<vp.elementCount(); ++i) {
88
	    switch (vp.elements()[i]) {
89
		case QPainterPath::MoveToElement:
90
		    path.moveTo(points[i]);
91
		    break;
92
		case QPainterPath::LineToElement:
93
		    path.lineTo(points[i]);
94
		    break;
95
		case QPainterPath::CurveToElement:
96
		    path.cubicTo(points[i], points[i+1], points[i+2]);
97
		    break;
98
		default:
99
		    break;
100
	    }
101
	}
102
    } else {
103
	path.moveTo(points[0]);
104
	for (int i=1; i<vp.elementCount(); ++i)
105
	    path.lineTo(points[i]);
106
    }
107

  
108
    return path;
109
}
77 110

  
78 111
QT_FT_Outline *QOutlineMapper::convertPath(const QPainterPath &path)
79 112
{
......
198 231
                                          m_m22 * e.y() + m_m12 * e.x() + m_dy);
199 232
            }
200 233
        } else {
201
            // ## TODO: this case needs to be plain code polygonal paths
202
            QPainterPath path;
203
            if (m_element_types.isEmpty()) {
204
                if (!m_elements.isEmpty())
205
                    path.moveTo(m_elements.at(0));
206
                for (int i=1; i<m_elements.size(); ++i)
207
                    path.lineTo(m_elements.at(i));
208
            } else {
209
                for (int i=0; i<m_elements.size(); ++i) {
210
                    switch (m_element_types.at(i)) {
211
                    case QPainterPath::MoveToElement:
212
                        path.moveTo(m_elements.at(i));
213
                        break;
214
                    case QPainterPath::LineToElement:
215
                        path.lineTo(m_elements.at(i));
216
                        break;
217
                    case QPainterPath::CurveToElement:
218
                        path.cubicTo(m_elements.at(i), m_elements.at(i+1), m_elements.at(i+2));
219
                        i += 2;
220
                        break;
221
                    default:
222
                        Q_ASSERT(false);
223
                        break;
224
                    }
225
                }
226
            }
234
            const QVectorPath vp((qreal *)m_elements.data(), m_elements.size(), m_element_types.data());
235
            QPainterPath path = vp_convertToPainterPath(vp);
227 236
            path = QTransform(m_m11, m_m12, m_m13, m_m21, m_m22, m_m23, m_dx, m_dy, m_m33).map(path);
237
            if (!(m_outline.flags & QT_FT_OUTLINE_EVEN_ODD_FILL))
238
                path.setFillRule(Qt::WindingFill);
228 239
            uint old_txop = m_txop;
229 240
            m_txop = QTransform::TxNone;
230 241
            if (path.isEmpty())
......
254 265

  
255 266

  
256 267
    // Check for out of dev bounds...
257
    const bool do_clip = (controlPointRect.left() < -QT_RASTER_COORD_LIMIT
258
                          || controlPointRect.right() > QT_RASTER_COORD_LIMIT
259
                          || controlPointRect.top() < -QT_RASTER_COORD_LIMIT
260
                          || controlPointRect.bottom() > QT_RASTER_COORD_LIMIT);
268
    const bool do_clip = (controlPointRect.left() < -(QT_RASTER_COORD_LIMIT + 1)
269
                          || controlPointRect.right() > (QT_RASTER_COORD_LIMIT + 1)
270
                          || controlPointRect.top() < - (QT_RASTER_COORD_LIMIT + 1)
271
                          || controlPointRect.bottom() > (QT_RASTER_COORD_LIMIT + 1) );
261 272

  
262
    if (do_clip) {
273
    if (do_clip)
274
    {
275
      //if the path consists only of straight lines, we can use a faster clipping algorithm
276
      if(element_count > 10000 && !isCurved())
277
      {
278
        QDataBuffer<QPointF>* trimBuffer;
279
        if (m_txop == QTransform::TxNone)
280
        {
281
          trimBuffer = &m_elements;
282
        }
283
        else
284
        {
285
          trimBuffer = &m_elements_dev;
286
        }
287
        trimFeature(trimBuffer, trimBuffer->at(0) != trimBuffer->at(trimBuffer->size() - 1));
288
      }
289
      else
290
      {
263 291
        clipElements(elements, elementTypes(), element_count);
264
    } else {
292
      }
293
    }
294
    else
295
    {
265 296
        convertElements(elements, elementTypes(), element_count);
266 297
    }
267 298
}
......
409 440
    m_txop = old_txop;
410 441
}
411 442

  
443
bool QOutlineMapper::isCurved() const
444
{
445
  bool isCurved = false;
446
  for(int i = 0; i < m_element_types.size(); ++i)
447
  {
448
    if(m_element_types.at(i) == QPainterPath::CurveToElement || m_element_types.at(i) == QPainterPath::CurveToDataElement)
449
    {
450
      isCurved = true;
451
      break;
452
    }
453
  }
454
  return isCurved;
455
}
456

  
412 457
QT_END_NAMESPACE
qt-win-opensource-src-4.5.2/src/gui/painting/qoutlinemapper_p.h 2009-09-12 11:17:14.281250000 +0200
65 65
#include <private/qdatabuffer_p.h>
66 66
#include "qpaintengineex_p.h"
67 67

  
68
#include <cmath>
69

  
68 70
QT_BEGIN_NAMESPACE
69 71

  
70 72
// This limitations comes from qgrayraster.c. Any higher and
71 73
// rasterization of shapes will produce incorrect results.
72 74
const int QT_RASTER_COORD_LIMIT = 32767;
75
const int QT_NEGATIVE_RASTER_COORD_LIMIT = -32767;
76
static const double SMALL_NUM = 1e-12;
73 77

  
74 78
//#define QT_DEBUG_CONVERT
75 79

  
......
231 235

  
232 236
private:
233 237
    bool m_round_coords;
238

  
239
    // A handy way to refer to the four boundaries
240
    enum Boundary {XMax, XMin, YMax, YMin};
241

  
242
    /**Trims the feature to the bounding box defined by +-QT_RASTER_COORD_LIMIT.
243
// Uses Sutherland and Hodgman's polygon-clipping algorithm. See J. D. Foley, A. van Dam,
244
// S. K. Feiner, and J. F. Hughes, Computer Graphics, Principles and
245
// Practice. Addison-Wesley Systems Programming Series,
246
// Addison-Wesley, 2nd ed., 1991.*/
247
    void trimFeature(QDataBuffer<QPointF>* elements, bool shapeOpen);
248

  
249
    // Trims the given feature to the given boundary. Returns the
250
    // trimmed feature in the outX and outY vectors.
251
    void trimFeatureToBoundary( const QDataBuffer<QPointF>* in,
252
                                       QDataBuffer<QPointF>* out,
253
                                       Boundary b,
254
                                       bool shapeOpen );
255

  
256
    /**True if the path contains CurveToElement or CurveToDataElement, false if if only consists straight lines*/
257
    bool isCurved() const;
258

  
259
   // Determines if a point is inside or outside the given boundary
260
    static bool inside( const double x, const double y, Boundary b );
261

  
262
    // Calculates the intersection point between a line defined by a
263
    // (x1, y1), and (x2, y2) and the given boundary
264
    static QPointF intersect( const double x1, const double y1,
265
                               const double x2, const double y2,
266
                               Boundary b );
234 267
};
235 268

  
269

  
270
//inline functions
271
// An auxilary function to trimPolygonToBoundarY() that returns
272
// whether a point is inside or outside the given boundary.
273

  
274
inline void QOutlineMapper::trimFeature(QDataBuffer<QPointF>* elements, bool shapeOpen)
275
{
276
  QDataBuffer<QPointF> tmpElements;
277
  trimFeatureToBoundary( elements, &tmpElements, XMax, shapeOpen);
278
  elements->reset();
279
  trimFeatureToBoundary( &tmpElements, elements, YMax, shapeOpen );
280
  tmpElements.reset();
281
  trimFeatureToBoundary( elements, &tmpElements, XMin, shapeOpen );
282
  elements->reset();
283
  trimFeatureToBoundary( &tmpElements, elements, YMin, shapeOpen );
284
  tmpElements.reset();
285

  
286
  QPainterPath path;
287
  if(elements->size() > 0)
288
  {
289
    path.moveTo(elements->at(0));
290
  }
291
  for(int i = 1; i < elements->size(); ++i)
292
  {
293
    path.lineTo(elements->at(i));
294
  }
295
  uint old_txop = m_txop;
296
  m_txop = QTransform::TxNone;
297
  convertPath(path);
298
  m_txop = old_txop;
299
}
300

  
301
inline void QOutlineMapper::trimFeatureToBoundary( const QDataBuffer<QPointF>* in, QDataBuffer<QPointF>* out, Boundary b, bool shapeOpen )
302
{
303

  
304
  // The shapeOpen parameter selects whether this function treats the
305
  // shape as open or closed. False is appropriate for polygons and
306
  // true for polylines.
307
  unsigned int i1 = in->size() - 1;
308

  
309
  // and compare to the first point initially.
310
  for ( int i2 = 0; i2 < in->size() ; ++i2 )
311
  { // look at each edge of the polygon in turn
312
    if ( inside( in->at(i2).x(), in->at(i2).y(), b ) ) // end point of edge is inside boundary
313
    {
314
      if ( inside( in->at(i1).x(), in->at(i1).y(), b ) )
315
      {
316
        out->add(in->at(i2));
317
      }
318
      else
319
      {
320
        // edge crosses into the boundary, so trim back to the boundary, and
321
        // store both ends of the new edge
322
        if ( !( i2 == 0 && shapeOpen ) )
323
        {
324
          QPointF p = intersect( in->at(i1).x(), in->at(i1).y(), in->at(i2).x(), in->at(i2).y(), b);
325
          out->add(p);
326
        }
327
        out->add(in->at(i2));
328
      }
329
    }
330
    else // end point of edge is outside boundary
331
    {
332
      // start point is in boundary, so need to trim back
333
      if ( inside( in->at(i1).x(), in->at(i1).y(), b ) )
334
      {
335
        if ( !( i2 == 0 && shapeOpen ) )
336
        {
337
          QPointF p = intersect( in->at(i1).x(), in->at(i1).y(), in->at(i2).x(), in->at(i2).y(), b );
338
          out->add(p);
339
        }
340
      }
341
    }
342
    i1 = i2;
343
  }
344
}
345

  
346

  
347
inline bool QOutlineMapper::inside( const double x, const double y, Boundary b )
348
{
349
  switch ( b )
350
  {
351
    case XMax: // x < QT_RASTER_COORD_LIMIT is inside
352
      if ( x < QT_RASTER_COORD_LIMIT )
353
        return true;
354
      break;
355
    case XMin: // x > -QT_RASTER_COORD_LIMIT is inside
356
      if ( x > QT_NEGATIVE_RASTER_COORD_LIMIT )
357
        return true;
358
      break;
359
    case YMax: // y < QT_RASTER_COORD_LIMIT is inside
360
      if ( y <  QT_RASTER_COORD_LIMIT)
361
        return true;
362
      break;
363
    case YMin: // y > -QT_RASTER_COORD_LIMIT is inside
364
      if ( y > QT_NEGATIVE_RASTER_COORD_LIMIT )
365
        return true;
366
      break;
367
  }
368
  return false;
369
}
370

  
371
// An auxilary function to trimPolygonToBoundarY() that calculates and
372
// returns the intersection of the line defined by the given points
373
// and the given boundary.
374

  
375
inline QPointF QOutlineMapper::intersect( const double x1, const double y1,
376
                                       const double x2, const double y2,
377
                                       Boundary b )
378
{
379
  // This function assumes that the two given points (x1, y1), and
380
  // (x2, y2) cross the given boundary. Making this assumption allows
381
  // some optimisations.
382

  
383
  double r_n = SMALL_NUM, r_d = SMALL_NUM;
384

  
385
  switch ( b )
386
  {
387
    case XMax: // x = MAX_X boundary
388
      r_n = -( x1 - QT_RASTER_COORD_LIMIT ) * ( QT_RASTER_COORD_LIMIT - QT_NEGATIVE_RASTER_COORD_LIMIT );
389
      r_d = ( x2 - x1 )   * ( QT_RASTER_COORD_LIMIT - QT_NEGATIVE_RASTER_COORD_LIMIT );
390
      break;
391
    case XMin: // x = MIN_X boundary
392
      r_n = -( x1 - QT_NEGATIVE_RASTER_COORD_LIMIT ) * ( QT_RASTER_COORD_LIMIT - QT_NEGATIVE_RASTER_COORD_LIMIT );
393
      r_d = ( x2 - x1 )   * ( QT_RASTER_COORD_LIMIT - QT_NEGATIVE_RASTER_COORD_LIMIT );
394
      break;
395
    case YMax: // y = MAX_Y boundary
396
      r_n = ( y1 - QT_RASTER_COORD_LIMIT ) * ( QT_RASTER_COORD_LIMIT - QT_NEGATIVE_RASTER_COORD_LIMIT );
397
      r_d = -( y2 - y1 )   * ( QT_RASTER_COORD_LIMIT - QT_NEGATIVE_RASTER_COORD_LIMIT );
398
      break;
399
    case YMin: // y = MIN_Y boundary
400
      r_n = ( y1 - QT_NEGATIVE_RASTER_COORD_LIMIT ) * ( QT_RASTER_COORD_LIMIT - QT_NEGATIVE_RASTER_COORD_LIMIT );
401
      r_d = -( y2 - y1 )   * ( QT_RASTER_COORD_LIMIT - QT_NEGATIVE_RASTER_COORD_LIMIT );
402
      break;
403
  }
404

  
405
  QPointF p;
406

  
407
  if ( std::abs( r_d ) > SMALL_NUM && std::abs( r_n ) > SMALL_NUM )
408
  { // they cross
409
    double r = r_n / r_d;
410
    p.setX( x1 + r*( x2 - x1 ) );
411
    p.setY( y1 + r*( y2 - y1 ) );
412
  }
413
  else
414
  {
415
    // Should never get here, but if we do for some reason, cause a
416
    // clunk because something else is wrong if we do.
417
    Q_ASSERT( std::abs( r_d ) > SMALL_NUM && std::abs( r_n ) > SMALL_NUM );
418
  }
419

  
420
  return p;
421
}
422

  
236 423
QT_END_NAMESPACE
237 424

  
238 425
#endif // QOUTLINEMAPPER_P_H
qt-win-opensource-src-4.5.2/src/gui/painting/qprintengine_pdf.cpp 2010-04-01 11:18:56.390625000 +0200
99 99
inline QPaintEngine::PaintEngineFeatures qt_pdf_decide_features()
100 100
{
101 101
    QPaintEngine::PaintEngineFeatures f = QPaintEngine::AllFeatures;
102
    f &= ~(QPaintEngine::PorterDuff | QPaintEngine::PerspectiveTransform
102
    f &= (QPaintEngine::PorterDuff | QPaintEngine::PerspectiveTransform
103 103
           | QPaintEngine::ObjectBoundingModeGradients
104 104
#ifndef USE_NATIVE_GRADIENTS
105 105
           | QPaintEngine::LinearGradientFill
qt-win-opensource-src-4.5.2/src/plugins/sqldrivers/sqlite/sqlite.pro 2010-04-26 17:21:49.125000000 +0200
6 6

  
7 7
!system-sqlite:!contains( LIBS, .*sqlite.* ) {
8 8
    CONFIG(release, debug|release):DEFINES *= NDEBUG
9
    DEFINES += SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE 
9
    DEFINES += SQLITE_OMIT_COMPLETE 
10 10
    INCLUDEPATH += ../../../3rdparty/sqlite
11 11
    SOURCES += ../../../3rdparty/sqlite/sqlite3.c
12 12
} else {
qt-win-opensource-src-4.5.2/src/sql/models/qsqltablemodel.cpp 2010-04-01 12:20:26.484375000 +0200
202 202
                editQuery.addBindValue(rec.value(i));
203 203
        }
204 204
        for (i = 0; i < whereValues.count(); ++i) {
205
            if (whereValues.isGenerated(i))
205
            if (whereValues.isGenerated(i) && !whereValues.isNull(i))
206 206
                editQuery.addBindValue(whereValues.value(i));
207 207
        }
208 208