summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qstatictext.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Initialize member variables in QStaticTextPrivate constructorEskil Abrahamsen Blomfeldt2010-01-291-0/+1
| | | | Avoid crash when copying a QStaticTextPrivate object
* CompileEskil Abrahamsen Blomfeldt2010-01-201-1/+1
| | | | | Compile QStaticText and also use font object in QPaintBuffer since it's now available
* Add font object to QStaticTextEskil Abrahamsen Blomfeldt2010-01-201-0/+1
| | | | This will be needed by OpenVG paint engine, and is useful elsewhere.
* doc: Add some performance hints to the documentationEskil Abrahamsen Blomfeldt2010-01-151-4/+11
|
* Fix crash when wrapping textEskil Abrahamsen Blomfeldt2010-01-151-1/+1
| | | | | | | | The two runs (counting the number of items and then storing the information) needs to be identical, so they need to have the same text flags set. Otherwise we would count more items than we actually generated and crash later when we tried to access an uninitialized item.
* Optimize drawStaticText() with rectangle destinationEskil Abrahamsen Blomfeldt2010-01-141-4/+11
| | | | | | | 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.
* Add prepare() function to QStaticTextEskil Abrahamsen Blomfeldt2010-01-141-0/+23
| | | | | | Allow the QStaticText layout to be completely defined prior to painting by introducing a function for setting the font and transform on the object ahead of using it with a QPainter.
* Implement drawStaticTextItem() in OpenGL paint enginesEskil Abrahamsen Blomfeldt2010-01-141-0/+2
| | | | | | | | | | | | 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-29/+4
| | | | | | | | | | | | | 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
* Speed up QStaticText initializationEskil Abrahamsen Blomfeldt2010-01-141-10/+5
| | | | | | Instead of translating each position manually afterwards, just have the matrix do it when calculating the positions inside getGlyphPositions().
* Some documentation fixesEskil Abrahamsen Blomfeldt2010-01-141-4/+7
| | | | Clarify the use of transformations combined with static texts.
* Support transformations in drawStaticText() and optimize for spaceEskil Abrahamsen Blomfeldt2010-01-141-15/+62
| | | | | | | | | | 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-67/+26
| | | | | | | | | | | 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-0/+2
| | | | | | | 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-50/+221
| | | | | | | 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-17/+20
| | | | | | | 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-8/+7
| | | | | | | 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-59/+69
| | | | | | | 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.
* Fix memory leakEskil Abrahamsen Blomfeldt2010-01-141-1/+3
|
* Add operators and implicit sharing to QStaticTextEskil Abrahamsen Blomfeldt2010-01-141-24/+81
| | | | | Adds copy constructor, operator==, operator= and operator!= to QStaticText. Implemented using an implicitly shared private object.
* Add lazy initialization to QStaticTextEskil Abrahamsen Blomfeldt2010-01-141-10/+98
| | | | | | People should be able to initialize the QStaticText lazily, or change its data after instantiation. Each of the setters will recalculate the layout to make sure it's always in sync.
* doc: Add documentation for QStaticText and QPainter::drawStaticText()Eskil Abrahamsen Blomfeldt2010-01-141-0/+61
|
* Fix formatting/clipping rectangle in QPainter::drawStaticText()Eskil Abrahamsen Blomfeldt2010-01-141-6/+20
| | | | | The rectangle should clip the text vertically and break lines horizontally, to mirror behavior of QPainter::drawText().
* Start support for formatting text within a bounding rectEskil Abrahamsen Blomfeldt2010-01-141-5/+5
| | | | | Support to mirror drawText(QRectF, QString). Instead of a rect you give the text a static size and then paint it to an arbitrary point later on.
* WhitespaceEskil Abrahamsen Blomfeldt2010-01-141-3/+2
| | | | Trailing spaces and an extra line of whitespace.
* Fix position of QStaticText textEskil Abrahamsen Blomfeldt2010-01-141-1/+1
| | | | | To mirror the behavior of drawText() the y-position origin should be the baseline of the text.
* Simplify QStaticTextEskil Abrahamsen Blomfeldt2010-01-141-25/+17
| | | | | 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/+91
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.