Changeset 769 for trunk/src/openvg/qpaintengine_vg.cpp
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/openvg/qpaintengine_vg.cpp
r651 r769 76 76 #if !defined(QVG_NO_DRAW_GLYPHS) 77 77 78 extern int qt_defaultDpiX();79 extern int qt_defaultDpiY();78 Q_DECL_IMPORT extern int qt_defaultDpiX(); 79 Q_DECL_IMPORT extern int qt_defaultDpiY(); 80 80 81 81 class QVGPaintEnginePrivate; … … 121 121 { 122 122 public: 123 // Extra blending modes from VG_KHR_advanced_blending extension. 124 // Use the QT_VG prefix to avoid conflicts with any definitions 125 // that may come in via <VG/vgext.h>. 126 enum AdvancedBlending { 127 QT_VG_BLEND_OVERLAY_KHR = 0x2010, 128 QT_VG_BLEND_HARDLIGHT_KHR = 0x2011, 129 QT_VG_BLEND_SOFTLIGHT_SVG_KHR = 0x2012, 130 QT_VG_BLEND_SOFTLIGHT_KHR = 0x2013, 131 QT_VG_BLEND_COLORDODGE_KHR = 0x2014, 132 QT_VG_BLEND_COLORBURN_KHR = 0x2015, 133 QT_VG_BLEND_DIFFERENCE_KHR = 0x2016, 134 QT_VG_BLEND_SUBTRACT_KHR = 0x2017, 135 QT_VG_BLEND_INVERT_KHR = 0x2018, 136 QT_VG_BLEND_EXCLUSION_KHR = 0x2019, 137 QT_VG_BLEND_LINEARDODGE_KHR = 0x201a, 138 QT_VG_BLEND_LINEARBURN_KHR = 0x201b, 139 QT_VG_BLEND_VIVIDLIGHT_KHR = 0x201c, 140 QT_VG_BLEND_LINEARLIGHT_KHR = 0x201d, 141 QT_VG_BLEND_PINLIGHT_KHR = 0x201e, 142 QT_VG_BLEND_HARDMIX_KHR = 0x201f, 143 QT_VG_BLEND_CLEAR_KHR = 0x2020, 144 QT_VG_BLEND_DST_KHR = 0x2021, 145 QT_VG_BLEND_SRC_OUT_KHR = 0x2022, 146 QT_VG_BLEND_DST_OUT_KHR = 0x2023, 147 QT_VG_BLEND_SRC_ATOP_KHR = 0x2024, 148 QT_VG_BLEND_DST_ATOP_KHR = 0x2025, 149 QT_VG_BLEND_XOR_KHR = 0x2026 150 }; 151 123 152 QVGPaintEnginePrivate(); 124 153 ~QVGPaintEnginePrivate(); … … 218 247 #endif 219 248 249 bool hasAdvancedBlending; 250 220 251 QScopedPointer<QPixmapFilter> convolutionFilter; 221 252 QScopedPointer<QPixmapFilter> colorizeFilter; … … 370 401 fontEngineCleaner = 0; 371 402 #endif 403 404 hasAdvancedBlending = false; 372 405 373 406 clearModes(); … … 447 480 vgAppendPathData(linePath, 2, segments, coords); 448 481 #endif 482 483 const char *extensions = reinterpret_cast<const char *>(vgGetString(VG_EXTENSIONS)); 484 if (extensions) 485 hasAdvancedBlending = strstr(extensions, "VG_KHR_advanced_blending") != 0; 449 486 } 450 487 … … 497 534 } 498 535 499 extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale);536 Q_DECL_IMPORT extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); 500 537 501 538 void QVGPaintEnginePrivate::updateTransform(QPaintDevice *pdev) 502 539 { 503 VGfloat devh = pdev->height() - 1;540 VGfloat devh = pdev->height(); 504 541 505 542 // Construct the VG transform by combining the Qt transform with 506 543 // the following viewport transformation: 507 // | 1 0 0 | | 1 0 0.5 | | 1 0 0.5 |508 // | 0 -1 devh | * | 0 1 -0.5 | = | 0 -1 (0.5 + devh) |509 // | 0 0 1 | | 0 0 1 | | 0 0 1 |544 // | 1 0 0 | 545 // | 0 -1 devh | 546 // | 0 0 1 | 510 547 // The full VG transform is effectively: 511 548 // 1. Apply the user's transformation matrix. 512 // 2. Translate by (0.5, -0.5) to correct for Qt and VG putting 513 // the centre of the pixel at different positions. 514 // 3. Flip the co-ordinate system upside down. 549 // 2. Flip the co-ordinate system upside down. 515 550 QTransform viewport(1.0f, 0.0f, 0.0f, 516 551 0.0f, -1.0f, 0.0f, 517 0.5f, devh + 0.5f, 1.0f); 518 519 // The image transform is always the full transformation, 520 // because it can be projective. 521 imageTransform = transform * viewport; 522 523 // Determine if the transformation is projective. 524 bool projective = (imageTransform.m13() != 0.0f || 525 imageTransform.m23() != 0.0f || 526 imageTransform.m33() != 1.0f); 552 0.0f, devh, 1.0f); 553 554 // Compute the path transform and determine if it is projective. 555 pathTransform = transform * viewport; 556 bool projective = (pathTransform.m13() != 0.0f || 557 pathTransform.m23() != 0.0f || 558 pathTransform.m33() != 1.0f); 527 559 if (projective) { 528 560 // The engine cannot do projective path transforms for us, … … 532 564 simpleTransform = false; 533 565 } else { 534 pathTransform = imageTransform;535 566 simpleTransform = true; 536 567 } 537 568 pathTransformSet = false; 569 570 // The image transform is always the full transformation, 571 imageTransform = transform * viewport; 538 572 539 573 // Calculate the scaling factor to use for turning cosmetic pens … … 968 1002 } 969 1003 970 extern QImage qt_imageForBrush(int style, bool invert);1004 Q_DECL_IMPORT extern QImage qt_imageForBrush(int style, bool invert); 971 1005 972 1006 static QImage colorizeBitmap(const QImage &image, const QColor &color) … … 2063 2097 (QVGPaintEngine *engine, int width, int height) 2064 2098 { 2099 scissorMask = false; 2065 2100 if (maskIsSet) { 2066 2101 vgMask(VG_INVALID_HANDLE, VG_FILL_MASK, 0, 0, width, height); … … 2295 2330 d->dirty |= QPaintEngine::DirtyCompositionMode; 2296 2331 2297 VG BlendModevgMode = VG_BLEND_SRC_OVER;2332 VGint vgMode = VG_BLEND_SRC_OVER; 2298 2333 2299 2334 switch (state()->composition_mode) { … … 2329 2364 break; 2330 2365 default: 2331 qWarning() << "QVGPaintEngine::compositionModeChanged unsupported mode" << state()->composition_mode; 2332 break; // Fall back to VG_BLEND_SRC_OVER. 2333 } 2334 2335 d->setBlendMode(vgMode); 2366 if (d->hasAdvancedBlending) { 2367 switch (state()->composition_mode) { 2368 case QPainter::CompositionMode_Overlay: 2369 vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_OVERLAY_KHR; 2370 break; 2371 case QPainter::CompositionMode_ColorDodge: 2372 vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_COLORDODGE_KHR; 2373 break; 2374 case QPainter::CompositionMode_ColorBurn: 2375 vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_COLORBURN_KHR; 2376 break; 2377 case QPainter::CompositionMode_HardLight: 2378 vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_HARDLIGHT_KHR; 2379 break; 2380 case QPainter::CompositionMode_SoftLight: 2381 vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SOFTLIGHT_KHR; 2382 break; 2383 case QPainter::CompositionMode_Difference: 2384 vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DIFFERENCE_KHR; 2385 break; 2386 case QPainter::CompositionMode_Exclusion: 2387 vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_EXCLUSION_KHR; 2388 break; 2389 case QPainter::CompositionMode_SourceOut: 2390 vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SRC_OUT_KHR; 2391 break; 2392 case QPainter::CompositionMode_DestinationOut: 2393 vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DST_OUT_KHR; 2394 break; 2395 case QPainter::CompositionMode_SourceAtop: 2396 vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SRC_ATOP_KHR; 2397 break; 2398 case QPainter::CompositionMode_DestinationAtop: 2399 vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DST_ATOP_KHR; 2400 break; 2401 case QPainter::CompositionMode_Xor: 2402 vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_XOR_KHR; 2403 break; 2404 default: break; // Fall back to VG_BLEND_SRC_OVER. 2405 } 2406 } 2407 if (vgMode == VG_BLEND_SRC_OVER) 2408 qWarning() << "QVGPaintEngine::compositionModeChanged unsupported mode" << state()->composition_mode; 2409 break; 2410 } 2411 2412 d->setBlendMode(VGBlendMode(vgMode)); 2336 2413 } 2337 2414 … … 2400 2477 2401 2478 // Check to see if we can use vgClear() for faster filling. 2402 if (brush.style() == Qt::SolidPattern && 2479 if (brush.style() == Qt::SolidPattern && brush.isOpaque() && 2403 2480 clipTransformIsSimple(d->transform) && d->opacity == 1.0f && 2404 2481 clearRect(rect, brush.color())) { … … 2443 2520 2444 2521 // Check to see if we can use vgClear() for faster filling. 2445 if (clipTransformIsSimple(d->transform) && d->opacity == 1.0f && 2522 if (clipTransformIsSimple(d->transform) && d->opacity == 1.0f && color.alpha() == 255 && 2446 2523 clearRect(rect, color)) { 2447 2524 return; … … 3240 3317 } 3241 3318 } 3242 origin[0] = -metrics.x.toReal() + 0.5f;3243 origin[1] = -metrics.y.toReal() + 0.5f;3244 escapement[0] = metrics.xoff.toReal();3245 escapement[1] = metrics.yoff.toReal();3319 origin[0] = -metrics.x.toReal(); 3320 origin[1] = -metrics.y.toReal(); 3321 escapement[0] = 0; 3322 escapement[1] = 0; 3246 3323 vgSetGlyphToImage(font, glyph, vgImage, origin, escapement); 3247 3324 vgDestroyImage(vgImage); // Reduce reference count. … … 3259 3336 origin[0] = 0; 3260 3337 origin[1] = 0; 3261 escapement[0] = metrics.xoff.toReal();3262 escapement[1] = metrics.yoff.toReal();3338 escapement[0] = 0; 3339 escapement[1] = 0; 3263 3340 vgSetGlyphToPath(font, glyph, vgPath, VG_FALSE, origin, escapement); 3264 3341 vgDestroyPath(vgPath); // Reduce reference count. … … 3285 3362 QVarLengthArray<QFixedPoint> positions; 3286 3363 QVarLengthArray<glyph_t> glyphs; 3287 QTransform matrix = d->transform; 3288 matrix.translate(p.x(), p.y()); 3289 ti.fontEngine->getGlyphPositions 3290 (ti.glyphs, matrix, ti.flags, glyphs, positions); 3364 QTransform matrix; 3365 ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); 3291 3366 3292 3367 // Find the glyph cache for this font. … … 3322 3397 glyphCache->cacheGlyphs(d, ti, glyphs); 3323 3398 3399 // Create the array of adjustments between glyphs 3400 QVarLengthArray<VGfloat> adjustments_x(glyphs.size()); 3401 QVarLengthArray<VGfloat> adjustments_y(glyphs.size()); 3402 for (int i = 1; i < glyphs.size(); ++i) { 3403 adjustments_x[i-1] = (positions[i].x - positions[i-1].x).toReal(); 3404 adjustments_y[i-1] = (positions[i].y - positions[i-1].y).toReal(); 3405 } 3406 3324 3407 // Set the glyph drawing origin. 3325 3408 VGfloat origin[2]; 3326 origin[0] = 0;3327 origin[1] = 0;3409 origin[0] = positions[0].x.toReal(); 3410 origin[1] = positions[0].y.toReal(); 3328 3411 vgSetfv(VG_GLYPH_ORIGIN, 2, origin); 3329 3412 … … 3340 3423 d->ensureBrush(state()->pen.brush()); 3341 3424 vgDrawGlyphs(glyphCache->font, glyphs.size(), (VGuint*)glyphs.data(), 3342 NULL, NULL, VG_FILL_PATH, VG_TRUE);3425 adjustments_x.data(), adjustments_y.data(), VG_FILL_PATH, VG_TRUE); 3343 3426 #else 3344 3427 // OpenGL 1.0 does not have support for VGFont and glyphs, … … 3645 3728 } else { 3646 3729 // Set the path transform to the default viewport transformation. 3647 VGfloat devh = screenSize.height() - 1;3730 VGfloat devh = screenSize.height(); 3648 3731 QTransform viewport(1.0f, 0.0f, 0.0f, 3649 3732 0.0f, -1.0f, 0.0f, 3650 -0.5f, devh + 0.5f, 1.0f);3733 0.0f, devh, 1.0f); 3651 3734 d->setTransform(VG_MATRIX_PATH_USER_TO_SURFACE, viewport); 3652 3735 … … 3684 3767 3685 3768 // Set the image transformation and modes. 3686 VGfloat devh = screenSize.height() - 1;3769 VGfloat devh = screenSize.height(); 3687 3770 QTransform transform(1.0f, 0.0f, 0.0f, 3688 3771 0.0f, -1.0f, 0.0f, 3689 -0.5f, devh + 0.5f, 1.0f);3772 0.0f, devh, 1.0f); 3690 3773 transform.translate(offset.x(), offset.y()); 3691 3774 d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
Note:
See TracChangeset
for help on using the changeset viewer.