summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/direct2d
Commit message (Collapse)AuthorAgeFilesLines
...
* direct2d: Fix composition mode supportLouai Al-Khanji2014-09-265-22/+188
| | | | | | | | | | | | When the composition mode changes to a mode which is not supported by Direct2D's primitive blending, the rendering follows the emulated (slow) code path using rasterFill(). This allows the direct2d paint engine to handle all composition modes supported by QImage. Task-number: QTBUG-40602 Change-Id: I0ac0b5c89aab2483cb2ef7768d6dec8e16913249 Done-with: Andrew Knight <andrew.knight@digia.com> Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* Update license headers and add new license filesMatti Paaso2014-09-2422-396/+220
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* direct2d: Fix font size when display scaling is in useLouai Al-Khanji2014-09-231-15/+8
| | | | | | | | | Since we already tell direct2d that we are using pixel sizes in the QWindowsDirect2DDeviceContextPrivate constructor and thereby enable scaling inside direct2d, there is no need to scale the font size again. Change-Id: Id9c9ed4d2848bcd09f997e41fb87802a3fe2432b Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* direct2d qpa: fix text selectionLouai Al-Khanji2014-09-223-5/+13
| | | | | | | | 1cdcf64ad5c0f42d23ad1a53c965df5c69a6bb4b recently introduced a rendering bug whereby certain clips would be handled incorrectly. Change-Id: I3f486819c66b1d665243c8dc1e9d077dd2f64f25 Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* direct2d: Work around ClearType rendering bug in translucent modeAndrew Knight2014-09-037-15/+36
| | | | | | | | | | | | This switches the font rendering to use gray scale antialiasing when in translucent rendering mode. It does so by adding a flags argument to the paint engine, allowing for future expansion in communicating render hints from the device to the engine. Task-number: QTBUG-41002 Change-Id: I0265154716a12060e851b603a109e9c693f5e843 Reviewed-by: Louai Al-Khanji <louai.al-khanji@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* direct2d: Fix translucent/frameless window renderingAndrew Knight2014-09-014-41/+135
| | | | | | | | | | | | | | | | | | | | When using WA_TranslucentBackground/FramelessWindowHint, the backing store must paint to an offscreen texture instead of the swap chain in order to achieve the desired results. This texture is then presented to the screen using UpdateLayeredWindowIndirect(). As the swap chain is not needed in this mode, its construction is skipped if indirect rendering is active. Furthermore, the layering options were updated to fix an issue with transparent layers overpainting the background. The layer options were switched to D2D1_LAYER_OPTIONS1_NONE, which appears to work for both translucent and non-translucent rendering modes. Task-number: QTBUG-40601 Change-Id: I656f7cdfb424d1eda6f82c2c69500e78d8c1726a Reviewed-by: Louai Al-Khanji <louai.al-khanji@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Fix QGlyphRun text renderingLouai Al-Khanji2014-08-192-129/+95
| | | | | | | | | | | When drawing QGlyphRun objects through QPainter the QFont passed in QStaticTextItem/QTextItem is not properly initialized with the correct size, weight, style strategy etc. Shuffle things around so we always go through QFontEngine for font data, as that should be more reliable. Change-Id: I43811c868ebd4fb1d9e937ee28a6d637267b4c7f Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* Fix linking of the Direct2D platform plugin with dynamic Open GL.Friedemann Kleint2014-07-311-1/+1
| | | | | Change-Id: I0a3272233de7e685c750f001eb45a5e326d0f35b Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
* Windows/Direct2D platform plugins: Add Q_DECL_OVERRIDE.Friedemann Kleint2014-07-291-9/+9
| | | | | | | | | | | | Replace old virtual declarations by Q_DECL_OVERRIDE where applicable. Errors discovered: QWindowsScreen::primaryOrientation() did not overwrite any method, changed to orientation(). Task-number: QTBUG-38858 Task-number: QTBUG-38993 Change-Id: Ie85d5235f3cd35c7a24cac3c1c7693c6508b1009 Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
* Direct2D QPA: Match raster engine line outputLouai Al-Khanji2014-05-261-0/+27
| | | | | | | | | | For whatever reason direct2d and the raster engine disagree by one pixel about the positioning of positively sloping aliased lines. To get the same output, we shift such lines by one pixel. Change-Id: I4b20319770c02e3fdd212b3535ccae3c27ca9f2f Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Direct2D QPA: Fix HighRes paintingLouai Al-Khanji2014-05-232-11/+10
| | | | | | | | | | | | | | | | | | | It turns out that supporting HighRes painting with Direct2D is quite simple. Two things are necessary. First, we set the unit mode to D2D1_UNIT_MODE_PIXELS on all our device contexts, which tells Direct2D that we specify everything in pixels. Direct2D will internally do the required conversions. Second, we scale font sizes according to DPI. Previously rendering errors resulted when a highres mode was used, this fixes those errors. Task-number: QTBUG-39105 Change-Id: Ibb4dbea4746687228249e2c36d48c4bd6c5c7bf9 Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Direct2D QPA: Add missing break statementLouai Al-Khanji2014-05-231-0/+1
| | | | | | Change-Id: Ib40daa1ba56cce423b29ac8f1ab50e4638980728 Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Direct2D QPA: Move QVectorPath conversion function into private classLouai Al-Khanji2014-05-221-101/+103
| | | | | | | | | | The function already needs information from the engine for conversion, moving it into the private class makes it possible to get this info directly in the method and makes calling the method nicer. Change-Id: I47fa9a4531d0d0605aa587fba90fbfdf036f0998 Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Direct2D QPA: Get rid of QPainterPath conversion functionLouai Al-Khanji2014-05-221-46/+3
| | | | | | | | | | This function was used only in one place and duplicated a lot of logic with the very similar QVectorPath conversion function. Just use QVectorPath everywhere instead. Change-Id: I3a4821f0452634c309ca0730047ea6ef7a7591ca Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Direct2D QPA: Cache QVectorPaths if drawn more than onceLouai Al-Khanji2014-05-221-6/+43
| | | | | | | | | | Hooking into the caching mechanism gets us a measurable performance boost for paths that are drawn repeatedly, around 10% on my machine when drawing aliased arcs. Change-Id: I32f4ed7daa8a51b5c5a9c6d5414ab5d4ef759f70 Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Direct2D QPA: Use correct buffer size constantLouai Al-Khanji2014-05-191-2/+2
| | | | | Change-Id: I2d8ec5faed959d6d642242b3e26ee0f185ee3d53 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Direct2D QPA: Stroke using direct2d primitivesLouai Al-Khanji2014-05-192-1/+84
| | | | | | | | | | | | | Use native direct2d stroking instead of falling back to QPaintEngineEx::stroke which in turn calls the pure virtual QPaintEngineEx::fill which is reimplemented in QWindowsDirect2DPaintEngine. In some cases like arc stroking this is significantly faster (up to 3x in my measurements) and results in better visual quality. Change-Id: I1c86ff772ba591432ff6550c7c59704ace4f0e0f Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Direct2D QPA: Fix version checkLouai Al-Khanji2014-05-191-2/+2
| | | | | | | | | | | It turns out that the version we were testing against was more recent than basic Windows 7 SP1 + Platform Update. The direct2d version that combination produces without any other updates is 6.2.9200.16492, and it is sufficient for us. Change-Id: Ib9840647371e2bb5c71bf74486348444ed4b4c19 Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Direct2D QPA: Fix check for cosmetic penLouai Al-Khanji2014-05-141-3/+7
| | | | | | | | | When checking whether a QPen should be treated as cosmetic we need to take into account the render hints set on the painter as well. Change-Id: I8200611af08000d2d1626d8ef97eb3f6dac4951c Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* Direct2D QPA: Choose linear interpolation for smooth pixmap transformLouai Al-Khanji2014-05-121-2/+1
| | | | | | | | Let's do the same thing the raster engine does. Much faster too. Change-Id: I88ea9d2c2ac78feee1193b75a9e96c62a7bd5979 Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Direct2D QPA: Never queue more than one frameLouai Al-Khanji2014-05-121-1/+4
| | | | | | | | | | | | | | Microsoft recommends setting the maximum frame latency to 1: http://blogs.windows.com/windows/b/appbuilder/archive/2013/12/18/optimizing-directx-apps-for-low-latency-input-and-longer-battery-life.aspx http://msdn.microsoft.com/en-us/library/windows/desktop/hh780339(v=vs.85).aspx Apparently it slightly reduces power consumption and it also slightly increases performance. So let's set it. Change-Id: I8a540f1e54e83d6dc13f25564e10b751e202ce66 Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Direct2D QPA: Bump copyright year to match realityLouai Al-Khanji2014-05-0914-14/+14
| | | | | Change-Id: I443b74e3d464285febc28345f35d1445e8102015 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Direct2D QPA: Check Direct2D versionLouai Al-Khanji2014-05-072-2/+135
| | | | | | | | | | | Since we require a relatively recent system, check the version of the direct2d dll on disk and report an error to the user if it is too old. Previously only a cryptic runtime error resulted from a direct2d version that was too old. Change-Id: I6c3955e1a98326fca6bcdc871b0a25291391ba88 Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Direct2D QPA: Speed up text renderingLouai Al-Khanji2014-05-072-53/+60
| | | | | | | | | | | | | | | | | | | | After analysing text drawing performance two things seem to take up most of the time. The first is font lookup, the second is QVector initialization. To address the first point a per paint engine instance font cache is introduced. At the moment no mechanism exists to clear this cache and it is unbounded. To address the second point, we simply switch to using QVarLengthArray instead of QVector. In an artificial benchmark that draws text in a tight loop, the first change raised fps from ~70 to ~100. The second change further raised this number to ~115 fps. Change-Id: Iafa25c3e35bc42bd7c1582b0636e721c5193b494 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Direct2D QPA: Fix DXGI Factory discovery magicLouai Al-Khanji2014-05-051-1/+1
| | | | | | | | | | | | | | On some Intel configurations the current DXGI discovery breaks. Fix this by adhering to Microsoft's guidelines for discovery of the DXGI factory: http://msdn.microsoft.com/en-us/library/windows/desktop/hh780339(v=vs.85).aspx Not querying the adapter directly as in the code snippet on the site above seems to have been a typo originally. Change-Id: Ibd7546462cdab7e5ad03db9abc16fe1615b631f4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* Direct2D QPA: Draw directly to swap chainLouai Al-Khanji2014-05-056-44/+149
| | | | | | | | | | | | | | | | | | | Remove the intermediate pixmap in the backing store and draw directly to the window swap chain. This is faster and reduces memory pressure on the graphics card. In case of native child widgets we need to read back the back buffer, which incurs an extra copy in this case. In an artificial benchmark drawing animated full screen gradients as fast as possible this patch increases performance by 42% on my current machine from 480fps to around 680fps, i.e. the time for actually getting the pixels to the screen is now lower. Change-Id: Ifbeda0e199afec03cecfe76337679a9e9d082bdd Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* Merge "Merge remote-tracking branch 'origin/release' into stable" into ↵Frederik Gladhorn2014-05-021-0/+1
|\ | | | | | | refs/staging/stable
| * Merge remote-tracking branch 'origin/release' into stableFrederik Gladhorn2014-05-011-0/+1
| |\ | | | | | | | | | | | | | | | This merge adds the opengl rename. Change-Id: I84ea0b6abee9780ebb2cf3f64ab9e3fdf2acab3e
| | * deprecate import_qpa_plugin and qpa_minimal_pluginOswald Buddenhagen2014-04-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | they have been fully superseded by 4255ba40ab073afcf2a095b135883612859af4c2. Change-Id: If7ac14c8b7d3cf00fb0cb916036b62eb86c9cee0 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* | | Direct2D QPA: Add handlers for individual primitivesLouai Al-Khanji2014-05-012-21/+269
|/ / | | | | | | | | | | | | | | | | | | | | Directly handling primitives is faster than using the catch-all fill function which converts arbitrary paths into a direct2d geometry. So do so. Change-Id: I71ce73dbe75aa9b61e741c358d8787d0ea48ee46 Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* | Direct2D QPA: Pixel-align aliased drawingLouai Al-Khanji2014-04-301-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | Aliased drawing has so far not been perfectly pixel aligned, resulting in less than stellar output in some instances. Although a little hacky, adding 0.5 to all coordinates when in aliased mode fixes things up nicely. There doesn't appear to be a better way to get d2d to cooperate as we would like it to. Change-Id: I10ee494d2f576bfd0eca6d4429095a3726c0bf14 Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* | Direct2D QPA: Correctly set active state in paint engineLouai Al-Khanji2014-04-291-0/+1
| | | | | | | | | | | | Change-Id: I4eea073ad11ba8684212258b344c1f237598a9c5 Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* | Direct2D QPA: Speed up widget paintingLouai Al-Khanji2014-04-292-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | By only starting/ending drawing once in the backing store, we can avoid multiple start/ends and thus flushes of the direct2d device context. This can potentially be much faster with some drivers when many widgets that draw to the same backing store need to redraw. Because starts/ends of QWindowsDirect2DDeviceContext are already refcounted this works out of the box. Change-Id: Ib48edceef6a1041ae0509587c77ac0caa8b29fc6 Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* | Direct2D QPA: Improve software fallback mechanismLouai Al-Khanji2014-04-253-45/+80
| | | | | | | | | | | | | | | | | | | | | | Improve the way we fall back to the raster engine by forwarding painting state. Amongst other things this makes perspective transforms appear correct. Change-Id: I729de56ef3112bbc01516fc11c295f33a2aada0d Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* | Direct2D QPA: Fix paint engine state handlingLouai Al-Khanji2014-04-252-13/+57
| | | | | | | | | | | | | | | | | | | | | | Fix the paint handling to support QPaintEngineEx style state updates. This fixes most of the outstanding issues, as QPainter save and restore were essentially broken before Change-Id: I477d8acfd71bba32dfac4c491bc5bbaad1804ec5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* | Direct2D QPA: Optimize ClippingLouai Al-Khanji2014-04-252-62/+64
| | | | | | | | | | | | | | | | | | | | Use axis aligned clips when possible instead of layer-clipping. This can be much faster when a lot of clipping operations take place. Change-Id: I6865d69fc917a7da858033b4c362b307724d9006 Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* | Direct2D QPA: Disable vsyncLouai Al-Khanji2014-04-251-1/+1
| | | | | | | | | | | | | | | | | | We shouldn't block the whole gui thread for vsyncing. This can slow things down a lot if a lot of drawing happens. Change-Id: Ie459f9dee2271e7908e2b7f56873393c67f82836 Reviewed-by: Risto Avila <risto.avila@digia.com> Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* | Direct2D QPA: Do not attempt to create swap chain for desktop widgetLouai Al-Khanji2014-04-241-0/+3
| | | | | | | | | | | | | | | | | | We can't and don't need to create a swap chain for the desktop widget. Change-Id: I84cd5c753710af09bab5c7afc27e202e661343db Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Andrew Knight <andrew.knight@digia.com> Reviewed-by: Risto Avila <risto.avila@digia.com>
* | Direct2D QPA: Fix text drawing with brush but no penLouai Al-Khanji2014-04-161-2/+2
| | | | | | | | | | | | | | | | | | We were incorrectly bailing out early in the text drawing code when there was no pen. This is incorrect as drawing with only a brush should be possible. Change-Id: I94eaadd3cf6c4d82033b5d74d7ca47a05601083f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* | Direct2D QPA: Refactor code to reduce code duplicationLouai Al-Khanji2014-04-161-102/+120
| | | | | | | | | | | | | | | | | | Refactor duplicate logic in painterPathToPathGeometry and vectorPathToID2D1PathGeometry into one utility class. At the same time make the naming of the two functions consistent with each other. Change-Id: I03c8fc183863473b7337223e51835cf080914a41 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* | Direct2D QPA: Optimize rectangle fills.Louai Al-Khanji2014-04-161-6/+18
| | | | | | | | | | | | | | Detect rectangle hints in the QVectorPath and react accordingly. Change-Id: Ic72ce0c46d10e995c0824972854e2d88162eae45 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* | Direct2D QPA: Improve gradient supportLouai Al-Khanji2014-04-161-10/+87
|/ | | | | | | | | This change adds support for those gradients which can be expressed using Direct2D. At the moment this means linear and radial gradient with pad spread only. Change-Id: Ib1b1bc38a793dd826a259bbf8a7b31c25906dd59 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Fix Direct2D clipping when Qt::WA_OpaquePaintEvent is trueRisto Avila2014-03-141-11/+40
| | | | | | | | | | | | Changed clip rectangle handling from bounding rect to region. Now also sub region rectangles are taken in to account. Task-number: QTBUG-37199 Change-Id: I9e09376e2c6d3fee8f85db753295a6138a03096f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Janne Koskinen <janne.p.koskinen@digia.com> Reviewed-by: Louai Al-Khanji <louai.al-khanji@digia.com> Reviewed-by: Andrew Knight <andrew.knight@digia.com>
* Move Direct2D paint engine on top of QPaintEngineExLouai Al-Khanji2014-01-313-468/+531
| | | | | | | | | | | | | | | | | Make QWindowsDirect2DPaintEngine a subclass of QPaintEngineEx instead of QPaintEngine like the other paint engines inside Qt. This should both be faster and better supported, as the code paths handling QPaintEngineEx in QPainter are tested more. Additionally the visual output is closer to the raster engine, as all primitives are drawn using the same mechanism, resulting in fewer off-by-one-pixel errors. This change also makes designer work mostly correctly, apart from some remaining clipping bugs. Change-Id: I53d36c08e73883ff35e389d57f9d30b482fc6721 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Improve direct2d backing store implementationLouai Al-Khanji2014-01-277-166/+288
| | | | | | | | | | | | | | | | | | | | | | Add a per-window swap chain to a QPlatformWindow subclass instead of tying it to the backing store. This is needed to support native widgets (as opposed to alien widgets). Change the backing store to draw to an intermediate pixmap and flush to the requested window by using the per-window swap chain. This also opens the door for faster window presentation later on by using the swap chain more intelligently. Also add a changelog entry for the direct2d plugin, which was omitted earlier. [ChangeLog][QtGui][Windows] Introduce experimental direct2d platform plugin for Windows. This plugin shares most code with the current windows plugin, but substitutes a direct2d-based paint engine for window backing stores and pixmaps. Change-Id: I5f54e7e4c1fb15b1639bd26b712fb40ac141e4ac Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Fix Q_ASSERT in direct2d qpa pluginLouai Al-Khanji2014-01-241-1/+1
| | | | | | | | When calling end the refcount should be greater than zero, as calls to begin/end should match. Change-Id: I49adbf6f9f1c21cb60985ba4e02574e6c0841b74 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Add new direct2d platform pluginLouai Al-Khanji2014-01-1022-0/+3328
This is an alternative plugin for the windows platform. It shares most code with the current windows plugin, but substitutes a direct2d-based paint engine for window backing stores and pixmaps. Change-Id: I78fafd9c5871fa090b49436f5b40ec80f8789f8b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>