summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpainter.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote branch 'origin/4.6' into qt-4.7-from-4.6Olivier Goffart2010-05-171-2/+7
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: demos/demos.pro mkspecs/features/resources.prf mkspecs/features/uic.prf src/corelib/io/qurl.cpp src/corelib/tools/qlocale_symbian.cpp src/gui/graphicsview/qgraphicsscene.cpp src/gui/graphicsview/qgraphicswidget_p.cpp src/gui/graphicsview/qgraphicswidget_p.h src/gui/util/qsystemtrayicon_win.cpp src/multimedia/audio/qaudioinput.cpp tests/auto/qhostinfo/qhostinfo.pro
| * Recalculate script item widths when forcing justificationEskil Abrahamsen Blomfeldt2010-05-061-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When going through the special WebKit code path for text drawing and forcing justification for text, we would set the justification in the text engine, but never actually update the widths of the script items. Since the width of the script item is used to position the text, the text would be drawn with the correct justification, but the position would be set based on the non-justified text width. The result was overlapping text whenever the script of the text changed. The fix goes through the justified glyphs and sets the width and position based on the new effective advance. Task-number: QTBUG-10421 Reviewed-by: Simon Hausmann
* | Fix setting font for QStaticText on Linux and MacEskil Abrahamsen Blomfeldt2010-03-301-5/+5
| | | | | | | | | | | | | | | | When using the fallback in QStaticText we have to update its font to the current painter's font, otherwise we will override the painter's font with the one cached in the QStaticText object. Reviewed-by: Olivier
* | Implement proper QStaticText support in QPaintBufferEskil Abrahamsen Blomfeldt2010-03-291-0/+10
| | | | | | | | | | | | | | | | | | Use qt_draw_glyphs() to implement a QPaintBuffer::drawStaticText() which will actually replay via drawStaticTextItem() on engines that support it. Task-number: QTBUG-9064 Reviewed-by: Gunnar
* | Make QStaticText layout lazyEskil Abrahamsen Blomfeldt2010-03-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | To avoid the unnecessary overhead of doing the text layout every time a part of the QStaticText object is changed, we mark it as invalid instead and do the layout when we have to. This means an overhead on the first paint event for most users. The overhead can be avoided by using the QStaticText::prepare() function and will probably not be noticable anyway, since it's a one-time thing. Task-number: QTBUG-9030 Reviewed-by: Gunnar
* | Change QStaticText::setMaximumSize() to setTextWidth()Eskil Abrahamsen Blomfeldt2010-03-291-23/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To avoid having to precalculate the height of the laid out text, we now only supply a maximum text width to QStaticText. The only usage of the maximum height would be to clip the results, and clipping should be set separately from the QStaticText call, since this has no impact on the layout of the glyphs. The tests have been updated to reflect the change in logic. We also need a consistent way of specifying the position of the text. Before, the position meant "baseline position" for unbroken text and "top left position" for text with a specified layout width. We want to be consistent, and since baseline position makes no sense for multiline text, we standardize on top left position. Task-number: QTBUG-9029 Reviewed-by: Gunnar
* | Respect QPainter::pen() in QPainter::drawStaticText()Eskil Abrahamsen Blomfeldt2010-03-291-1/+1
| | | | | | | | | | | | | | | | | | | | QStaticText needs to support changing the pen on the painter to support rich text, but it should not override the pen unless it has been explicitly set in the rich text. We do this by marking the pen as dirty in updateState() when we record the text items. Task-number: QTBUG-8908 Reviewed-by: Gunnar
* | Add new function QTextLine::horizontalAdvance()Eskil Abrahamsen Blomfeldt2010-03-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Add a function to QTextLine which returns the accumulated advance of the glyphs in the text. Previously QTextLine::naturalTextWidth() was used for both this purpose and for calculating the pixel width of the text. Since these two metrics are not the same, either of the two usages would be wrong. QTextLine::naturalTextWidth() has been changed to do what its documentation claims it does, and horizontalAdvance() should now be used for laying out text horizontally. Reviewed-by: Simon Hausmann
* | Fixed performance issues when falling back to raster for sub-pixmaps.Samuel Rødal2010-03-221-2/+7
| | | | | | | | | | | | | | Copy the sub-pixmap so that we don't need to convert the entire pixmap to a QImage each time. Reviewed-by: Gunnar Sletta
* | Merge branch '4.7-cutoff' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into ↵Qt Continuous Integration System2010-03-091-4/+4
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 4.7-integration * '4.7-cutoff' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (82 commits) Revert 12b6987031be9faee3886d7623888feb4e1762af Changed TEST_COMPILER from CC to CXX in configure script. doc: Fixed several qdoc errors. Carbon: Native filedialog does not apply filters on app-bundles Cocoa: Native filedialog does not apply filters on app-bundles Improve performance of QTimer::singleShot Add a benchmark comparing single shot timer with invokeMethod use Qt's private mac functions, reduce code redundancy Assistant: Fix compile warning for empty header. Doc: mark QEasingCurve support functions as new in 4.7. Modify the XML test suite not to use non-characters. Autotest: Fix failing QTextCodec tests Doc: mark methods as internal (as they were in previous releases) Doc: add image for Qt Quick to "What's New" page. qdoc: Clear a static multimap after each qdocconf file. qdoc: Added some debug output to track down a crash Fixed mouse wheel handling in scrollareas. Added two missing keys for X11 Carbon: usage of menu bars can cause exceptions to be thrown Mac: compile fix ...
| * | doc: Fixed several qdoc errors.Martin Smith2010-03-091-4/+4
| | |
* | | Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7Eskil Abrahamsen Blomfeldt2010-03-091-23/+30
|\ \ \
| * | | Renamed QPainter::Fragment/Hint -> QPainter::PixmapFragment/HintTrond Kjernåsen2010-03-091-20/+20
| |/ / | | | | | | | | | Reviewed-by: Kim
| * | Fixed qDrawPixmaps() to draw on integer coordinates on Mac OS X.Trond Kjernåsen2010-03-011-3/+10
| | | | | | | | | | | | | | | | | | | | | This is the 4.7 port of d04f5336f769d9e5d2f9105e1da4a7d23ea91795. Task-number: related to QTBUG-8455 Reviewed-by: Kim
* | | Fix alignment of text with negative right bearingEskil Abrahamsen Blomfeldt2010-03-091-2/+3
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In change 5364fd96a72c89b281f0540da909fe64d0575ccf and some related changes, we made sure that the natural text width used for calculating bounding rects and line breaks in the text, takes the right bearing of the last glyph into consideration. As a side-effect, this broke alignment of text, as we want to align based on the accumulated advance of the glyphs, not based on the actual width. This is in particular important when aligning monospaced text, since the text can become misaligned if the glyphs extend beyond their advance. The bug was visible e.g. in line numbers ending with 2 in Qt Creator on X11, which would be shifted one pixel to the left compared to other line numbers. Task-number: QTBUG-8864 Reviewed-by: Thorbjørn
* | Merge branch 'master' of scm.dev.nokia.troll.no:qt/qtRhys Weatherley2010-02-241-0/+1
|\ \ | | | | | | | | | | | | Conflicts: configure
| * \ Merge remote branch 'origin/master' into bearermanagement/unit-testsAaron McCarthy2010-02-221-3/+141
| |\ \ | | | | | | | | | | | | | | | | Conflicts: src/network/access/qnetworkaccessmanager.cpp
| * \ \ Merge remote branch 'origin/4.6' into bearermanagement/integrationAaron McCarthy2010-02-111-7/+20
| |\ \ \ | | | | | | | | | | | | | | | | | | | | Conflicts: src/s60installs/s60installs.pro
| * \ \ \ Merge commit 'origin/4.6' into bearermanagement/integration-4Aaron McCarthy2010-01-291-13/+131
| |\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure src/gui/painting/qpainter.cpp src/s60installs/s60installs.pro
| * | | | | Fix build on Maemo, force type to qreal.Aaron McCarthy2010-01-071-1/+2
| | | | | |
* | | | | | Add private qt_draw_glyphs() APIEskil Abrahamsen Blomfeldt2010-02-231-0/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In some use cases where you use an external font engine and want to use Qt's font engine for painting, you might need a function which will give you direct access to the underlying font. A generic API for this requires a lot of API changes, so in the meantime, we implement an internal, specialized API to support the use cases where it is required. The API is considered internal and experimental, and not guaranteed to be stable or even exist across releases. This is API which provides several fun ways to shoot yourself in the foot, but if used properly, it will allow you to paint glyph ids at precalculated positions. Task-number: QTBUG-7844 Reviewed-by: Trond
* | | | | | Made the qDrawPixmaps() API public (with modifications).Trond Kjernåsen2010-02-231-0/+154
| |_|_|/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QPainter has now gotten a drawPixmapFragments() function together with a Fragment class that describes how each pixmap fragment is supposed to be drawn. Reviewed-by: Gunnar Reviewed-by: Samuel
* | | | | Merge remote branch 'origin/master' into qt-master-from-4.6Thiago Macieira2010-02-201-0/+137
|\ \ \ \ \ | |_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure.exe src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp src/opengl/qgl.cpp
| * | | | Fix fallback for QStaticText when it's unsupported in paint engineEskil Abrahamsen Blomfeldt2010-02-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the paint engine does not support QStaticText, we fall back to regular drawText() calls. This fallback would previously paint all text to (0, 0). This fixes the qstatictext autotest on Linux. Reviewed-by: Olivier
| * | | | doc: Update documentation for QStaticTextEskil Abrahamsen Blomfeldt2010-02-161-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make some smaller modifications, fixes and additions. Remove \internal because the API is public now, and add documentation for QPainter::drawStaticText() since this was missing. Reviewed-by: TrustMe
| * | | | Separate out textFormat property from setText() function and removeEskil Abrahamsen Blomfeldt2010-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | isEmpty() function in QStaticText To make the return value of text() more intuitively clearer, and to make the API more readable, I've separated out the text format into a separate property. The isEmpty() function seemed out-of-place in the API, as suggested by reviews, so it has been removed.
| * | | | Add API for rich text and getting actual size of QStaticTextEskil Abrahamsen Blomfeldt2010-02-141-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Required for several use cases, support for some html tags to change font, color and do advanced text layouts, as well as getting the bounds of the text when drawn.
| * | | | Make QStaticText public API againEskil Abrahamsen Blomfeldt2010-02-101-41/+41
| | | | | | | | | | | | | | | | | | | | | | | | | QStaticText was previously made private API to support inclusion in Qt 4.6.x. This change turns it back into public API for Qt 4.7.0.
| * | | | Merge branch '4.6' into qstatictext-4.6Eskil Abrahamsen Blomfeldt2010-02-101-5/+18
| |\ \ \ \ | | | |_|/ | | |/| |
| * | | | Temporarily remove QPainter::drawStaticText() for Qt 4.6.x integrationEskil Abrahamsen Blomfeldt2010-02-051-50/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can't add new symbols to QPainter for Qt 4.6.x, as we would not be able to remove them again if we regretted the API. Hence, I've made removable symbols instead, a private global function and a drawStaticText() in QPainterPrivate. In order to tie things together, I needed a static private-getter in QPainterPrivate, and hence it had to be a friend of QPainter. Reviewed-by: Trond
| * | | | Merge branch '4.6' into qstatictext-4.6Eskil Abrahamsen Blomfeldt2010-02-011-12/+46
| |\ \ \ \
| * | | | | Clarify comment in QPainterEskil Abrahamsen Blomfeldt2010-02-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We support affine transformations in the drawStaticTextItem() backends, but for non-affine transformation, the fallback will be taken.
| * | | | | Make QStaticText private APIEskil Abrahamsen Blomfeldt2010-02-011-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Turns QStaticText into private API in preparation for Qt 4.6.x. The related functions in QPainter are marked as internal in the docs. There are already internal functions in QPainter, so this seemed like a reasonable solution. Since the functions require QStaticText they will not be accessible to anyone who does not include private API.
| * | | | | Improve performance of QStaticText on OpenGL by caching data on GPUEskil Abrahamsen Blomfeldt2010-01-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a big improvement to be seen in the OpenGL engine by caching the vertex data for the QStaticText in VBOs. In order to have the buffers properly disposed, I've implemented a userdata concept for QStaticTextItem. By default, the optimizations will be turned off, and can be turned on by using the useBackendOptimizations flag.
| * | | | | Use fallback when drawing projected textEskil Abrahamsen Blomfeldt2010-01-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Projected text always has to go via paths, so we use the fall back for this.
| * | | | | Optimize drawStaticText() with rectangle destinationEskil Abrahamsen Blomfeldt2010-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to be feature consistent with drawText(), we have to clip the text whenever the text expands beyond its borders. This is a performance hit, but luckily we can detect the cases where it's necessary before-hand.
| * | | | | Implement drawStaticTextItem() in OpenGL paint enginesEskil Abrahamsen Blomfeldt2010-01-141-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The OpenGL and OpenGL2 engines now have support for static text, as well as the QEmulationPaintEngine. Also contains an optimization: Instead of passing both the position and glyph positions to drawStaticTextItem() we add the position into the glyph position and update it only when it changes. Otherwise we would have to do this work in all engines for every call. This means we have to cache the position in QStaticTextPrivate as well, but it seems like a small price to pay, since it's a per-text overhead and only 16 bytes.
| * | | | | Remove font property in QStaticText and fix handling translation onEskil Abrahamsen Blomfeldt2010-01-141-11/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | painter 1. The font property in QStaticText has been removed. Rather than set a font on the text explicitly, it picks up the font from the painter. If you change the font on the painter, the text layout will have to be updated, like with a matrix. 2. The translation might not be the only transformation on the painter, so rather than translate back to origo, we explicitly set dx and dy on the transform to 0.0 for the duration of the function. 3. Update test to reflect changes
| * | | | | Apply painter matrix to position in QPainter::drawStaticText()Eskil Abrahamsen Blomfeldt2010-01-141-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to transform the position of the text in accordance with the painter's matrix. Also, use state->matrix directly instead of calling a function to get it.
| * | | | | Support transformations in drawStaticText() and optimize for spaceEskil Abrahamsen Blomfeldt2010-01-141-4/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Support transformations on the painter in drawStaticText(). Transforming the painter will cause the text layout to be recalculated, except for translations, which are handled by shifting the position of the text items. 2. Make const length arrays of the internal data in QStaticTextItem in order to minimize the memory consumption.
| * | | | | Optimize QStaticText for spaceEskil Abrahamsen Blomfeldt2010-01-141-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By caching the results of getGlyphPositions() we can make a code path in the critical paint engines which is optimal both in space and speed. The engines where speed is of less importance (pdf engine etc.) which may need more information, we choose the slower code path of drawText() which lays out the text again. We should have optimal paths in raster, vg and GL2 paint engines. The others are less important. Memory consumption of static text is now 14 bytes per glyph, 8 bytes per item and a static overhead of 40 bytes per QStaticText object.
| * | | | | Respect font settings of QStaticText and clip to maximum sizeEskil Abrahamsen Blomfeldt2010-01-141-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | drawText() that renders into a QRect will clip the text (unless otherwise set by the text flags passed to the function.) In drawStaticText() we should do the same for identical behavior. We also need to respect the font set on the QStaticText object.
| * | | | | Support maximumSize for the layout of the text in a QStaticTextEskil Abrahamsen Blomfeldt2010-01-141-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Put back maximumSize property in QStaticText to allow matching calls to drawText with a target rectangle. Implementation is done by having a dummy paint engine which records the calls to drawTextItem() and storing these, then replaying them later.
| * | | | | Speed optimization for QStaticTextEskil Abrahamsen Blomfeldt2010-01-141-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't use QVector to store the text items, but put them in a regular array for quick access. drawStaticText() is now about 2.7 times the speed of drawText().
| * | | | | Space optimization in QStaticTextEskil Abrahamsen Blomfeldt2010-01-141-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The engine.layoutData's glyph count is the number allocated, which may be larger than the actual number of glyphs. To minimize the space needed we base allocation on "used" which contains the number of glyphs actually used to represent the text.
| * | | | | Optimize QStaticText for one line stringsEskil Abrahamsen Blomfeldt2010-01-141-20/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QTextLayout takes a lot of memory. We can get a bigger speed-up and a more reasonable memory consumption by only supporting the single line static texts and caching the text items. We need to copy some structs from the text engine, since this is on the stack.
| * | | | | doc: Add documentation for QStaticText and QPainter::drawStaticText()Eskil Abrahamsen Blomfeldt2010-01-141-3/+25
| | | | | |
| * | | | | Fix formatting/clipping rectangle in QPainter::drawStaticText()Eskil Abrahamsen Blomfeldt2010-01-141-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The rectangle should clip the text vertically and break lines horizontally, to mirror behavior of QPainter::drawText().
| * | | | | Simplify QStaticTextEskil Abrahamsen Blomfeldt2010-01-141-25/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not much to gain by going directly to the QTextEngine, and the code is a lot simpler if we just use the QTextLayout instead.
| * | | | | Introduce QStaticText APIEskil Abrahamsen Blomfeldt2010-01-141-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Much of the time in drawText() is used on text layouting, which is wasted time when the text is not updated every frame. QStaticText is meant to cache the relevant parts of this work. It currently uses a copy-paste of the layout code in QPainter::drawText() and 99% of the time in QPainter::drawStaticText() is spent in drawTextItem(). We can use QTextLayout here instead without losing much.