src/gui/text/qtextengine_p.h
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
   414 class QFontPrivate;
   414 class QFontPrivate;
   415 class QTextFormatCollection;
   415 class QTextFormatCollection;
   416 
   416 
   417 class Q_GUI_EXPORT QTextEngine {
   417 class Q_GUI_EXPORT QTextEngine {
   418 public:
   418 public:
       
   419     enum LayoutState {
       
   420         LayoutEmpty,
       
   421         InLayout,
       
   422         LayoutFailed,
       
   423     };
   419     struct LayoutData {
   424     struct LayoutData {
   420         LayoutData(const QString &str, void **stack_memory, int mem_size);
   425         LayoutData(const QString &str, void **stack_memory, int mem_size);
   421         LayoutData();
   426         LayoutData();
   422         ~LayoutData();
   427         ~LayoutData();
   423         mutable QScriptItemArray items;
   428         mutable QScriptItemArray items;
   426         void **memory;
   431         void **memory;
   427         unsigned short *logClustersPtr;
   432         unsigned short *logClustersPtr;
   428         QGlyphLayout glyphLayout;
   433         QGlyphLayout glyphLayout;
   429         mutable int used;
   434         mutable int used;
   430         uint hasBidi : 1;
   435         uint hasBidi : 1;
   431         uint inLayout : 1;
   436         uint layoutState : 2;
   432         uint memory_on_stack : 1;
   437         uint memory_on_stack : 1;
   433         bool haveCharAttributes;
   438         bool haveCharAttributes;
   434         QString string;
   439         QString string;
   435         void reallocate(int totalGlyphs);
   440         bool reallocate(int totalGlyphs);
   436     };
   441     };
   437 
   442 
   438     QTextEngine(LayoutData *data);
   443     QTextEngine(LayoutData *data);
   439     QTextEngine();
   444     QTextEngine();
   440     QTextEngine(const QString &str, const QFont &f);
   445     QTextEngine(const QString &str, const QFont &f);
   518      */
   523      */
   519     inline QGlyphLayout shapedGlyphs(const QScriptItem *si) const {
   524     inline QGlyphLayout shapedGlyphs(const QScriptItem *si) const {
   520         return layoutData->glyphLayout.mid(si->glyph_data_offset, si->num_glyphs);
   525         return layoutData->glyphLayout.mid(si->glyph_data_offset, si->num_glyphs);
   521     }
   526     }
   522 
   527 
   523     inline void ensureSpace(int nGlyphs) const {
   528     inline bool ensureSpace(int nGlyphs) const {
   524         if (layoutData->glyphLayout.numGlyphs - layoutData->used < nGlyphs)
   529         if (layoutData->glyphLayout.numGlyphs - layoutData->used < nGlyphs)
   525             layoutData->reallocate((((layoutData->used + nGlyphs)*3/2 + 15) >> 4) << 4);
   530             return layoutData->reallocate((((layoutData->used + nGlyphs)*3/2 + 15) >> 4) << 4);
       
   531         return true;
   526     }
   532     }
   527 
   533 
   528     void freeMemory();
   534     void freeMemory();
   529 
   535 
   530     int findItem(int strPos) const;
   536     int findItem(int strPos) const;