src/gui/text/qstatictext_p.h
changeset 30 5dc02b23752f
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the test suite of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QSTATICTEXT_P_H
       
    43 #define QSTATICTEXT_P_H
       
    44 
       
    45 //
       
    46 //  W A R N I N G
       
    47 //  -------------
       
    48 //
       
    49 // This file is not part of the Qt API.  It exists for the convenience
       
    50 // of internal files.  This header file may change from version to version
       
    51 // without notice, or even be removed.
       
    52 //
       
    53 // We mean it.
       
    54 //
       
    55 
       
    56 #include <private/qtextureglyphcache_p.h>
       
    57 #include <QtGui/qcolor.h>
       
    58 
       
    59 QT_BEGIN_NAMESPACE
       
    60 
       
    61 class QStaticTextUserData
       
    62 {
       
    63 public:
       
    64     enum Type {
       
    65         NoUserData,
       
    66         OpenGLUserData
       
    67     };
       
    68 
       
    69     QStaticTextUserData(Type t) : type(t) {}
       
    70     virtual ~QStaticTextUserData() {}
       
    71 
       
    72     Type type;
       
    73 };
       
    74 
       
    75 class Q_GUI_EXPORT QStaticTextItem
       
    76 {
       
    77 public:    
       
    78     QStaticTextItem() : chars(0), numChars(0), fontEngine(0), userData(0),
       
    79                         useBackendOptimizations(false), userDataNeedsUpdate(0) {}
       
    80     ~QStaticTextItem() { delete userData; }
       
    81 
       
    82     void setUserData(QStaticTextUserData *newUserData)
       
    83     {
       
    84         if (userData == newUserData)
       
    85             return;
       
    86 
       
    87         delete userData;
       
    88         userData = newUserData;
       
    89     }
       
    90 
       
    91     QFixedPoint *glyphPositions;                 // 8 bytes per glyph
       
    92     glyph_t *glyphs;                             // 4 bytes per glyph
       
    93     const QChar *chars;                          // 2 bytes per glyph
       
    94                                                  // =================
       
    95                                                  // 14 bytes per glyph
       
    96 
       
    97                                                  // 12 bytes for pointers
       
    98     int numGlyphs;                               // 4 bytes per item
       
    99     int numChars;                                // 4 bytes per item
       
   100     QFontEngine *fontEngine;                     // 4 bytes per item
       
   101     QFont font;                                  // 8 bytes per item
       
   102     QColor color;                                // 10 bytes per item
       
   103     QStaticTextUserData *userData;               // 8 bytes per item
       
   104     char useBackendOptimizations : 1;            // 1 byte per item
       
   105     char userDataNeedsUpdate : 1;                //
       
   106                                                  // ================
       
   107                                                  // 51 bytes per item
       
   108 };
       
   109 
       
   110 class QStaticText;
       
   111 class Q_AUTOTEST_EXPORT QStaticTextPrivate
       
   112 {
       
   113 public:
       
   114     QStaticTextPrivate();
       
   115     QStaticTextPrivate(const QStaticTextPrivate &other);
       
   116     ~QStaticTextPrivate();
       
   117 
       
   118     void init();
       
   119     void paintText(const QPointF &pos, QPainter *p);
       
   120 
       
   121     void invalidate()
       
   122     {
       
   123         needsRelayout = true;
       
   124     }
       
   125 
       
   126     QAtomicInt ref;                      // 4 bytes per text
       
   127 
       
   128     QString text;                        // 4 bytes per text
       
   129     QFont font;                          // 8 bytes per text
       
   130     qreal textWidth;                     // 8 bytes per text
       
   131     QSizeF actualSize;                   // 16 bytes per text
       
   132     QPointF position;                    // 16 bytes per text
       
   133 
       
   134     QTransform matrix;                   // 80 bytes per text
       
   135     QStaticTextItem *items;              // 4 bytes per text
       
   136     int itemCount;                       // 4 bytes per text
       
   137     glyph_t *glyphPool;                  // 4 bytes per text
       
   138     QFixedPoint *positionPool;           // 4 bytes per text
       
   139 
       
   140     unsigned char needsRelayout : 1;
       
   141     unsigned char useBackendOptimizations : 1; // 1 byte per text
       
   142     unsigned char textFormat              : 2;
       
   143                                          // ================
       
   144                                          // 163 bytes per text
       
   145 
       
   146     static QStaticTextPrivate *get(const QStaticText *q);
       
   147 };
       
   148 
       
   149 QT_END_NAMESPACE
       
   150 
       
   151 #endif // QSTATICTEXT_P_H