4727 for (
int i=0; i<contexts.
size(); ++i) {
4752 font_cache = dev_it.
value();
4758 if (cache_it == font_cache->
constEnd()) {
4760 font_cache->
insert(fontEngine, cache);
4763 cache = cache_it.
value();
4767 quint64 font_key = (
reinterpret_cast<quint64>(context_key ? context_key : context) << 32)
4768 |
reinterpret_cast<quint64>(fontEngine);
4772 GLuint font_texture;
4773 glGenTextures(1, &font_texture);
4779 if (tex_width > max_tex_size)
4780 tex_width = max_tex_size;
4782 font_tex->
texture = font_texture;
4785 font_tex->
width = tex_width;
4786 font_tex->
height = tex_height;
4792 font_tex = it.
value();
4796 for (
int i=0; i< numGlyphs; ++i) {
4802 int glyph_width = glyph_im.
width();
4806 if (glyph_width % 2 != 0)
4812 font_tex->
y_offset += strip_height;
4816 int old_tex_height = font_tex->
height;
4819 glDeleteTextures(1, &font_tex->
texture);
4820 glGenTextures(1, &font_tex->
texture);
4827 memcpy(font_tex->
data, old_tex_data, font_tex->
width*old_tex_height*2);
4833 while (it != cache->
end()) {
4834 it.
value()->height = (it.
value()->height * old_tex_height) / font_tex->
height;
4841 glyph_height =
qMin(glyph_height, glyph_im.height());
4846 qgl_glyph->width =
qreal(glyph_width) / font_tex->
width;
4847 qgl_glyph->height =
qreal(glyph_height) / font_tex->
height;
4848 qgl_glyph->log_width =
qreal(glyph_width);
4849 qgl_glyph->log_height = qgl_glyph->height * font_tex->
height;
4851 qgl_glyph->x_offset = -metrics.
x + 1;
4852 qgl_glyph->y_offset = metrics.
y - 2;
4854 qgl_glyph->x_offset = -metrics.
x;
4855 qgl_glyph->y_offset = metrics.
y;
4858 if (!glyph_im.isNull()) {
4860 uchar *tex_data = (
uchar *) malloc(glyph_width*glyph_height*2);
4861 memset(tex_data, 0, glyph_width*glyph_height*2);
4863 bool is8BitGray =
false;
4871 for (
int y=0; y<glyph_height; ++y) {
4873 int lineStart = idx;
4874 for (
int x=0; x<glyph_im.width(); ++x) {
4875 uchar alpha = is8BitGray ? *s :
qAlpha(glyph_im.color(*s));
4876 tex_data[idx] = alpha;
4877 tex_data[idx+1] = alpha;
4881 if (glyph_im.width()%2 != 0)
4884 memcpy(font_tex->
data+cacheLineStart, tex_data+lineStart, glyph_width*2);
4885 cacheLineStart += font_tex->
width*2;
4888 glyph_width, glyph_height,
4895 cache->
insert(glyphs[i], qgl_glyph);
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
virtual QImage alphaMapForGlyph(glyph_t)
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
void allocTexture(QGLFontTexture *)
QPointer< QWidget > widget
#define GL_MAX_TEXTURE_SIZE
#define it(className, varName)
QGLFontTexHash qt_font_textures
Q_GUI_EXPORT_INLINE int qAlpha(QRgb rgb)
static QGLSignalProxy * instance()
QGLContextHash qt_context_cache
T & value() const
Returns a modifiable reference to the current item's value.
void fontEngineDestroyed(QObject *)
The QHash class is a template class that provides a hash-table-based dictionary.
The QObject class is the base class of all Qt objects.
int qt_next_power_of_two(int v)
void widgetDestroyed(QObject *)
virtual int devType() const
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
static bool areSharing(const QGLContext *context1, const QGLContext *context2)
Returns true if context1 and context2 are sharing their GL resources such as textures, shader programs, etc; otherwise returns false.
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
The QGLContext class encapsulates an OpenGL rendering context.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
const T & at(int i) const
Returns the item at index position i in the list.
virtual QFixed ascent() const =0
QHash< glyph_t, QGLGlyphCoord * > QGLGlyphHash
virtual QFixed descent() const =0
const T & value() const
Returns the current item's value.
The QImage class provides a hardware-independent image representation that allows direct access to th...
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
#define GL_LUMINANCE_ALPHA
QPaintDevice * device() const
Returns the paint device set for this context.
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0
QHash< QFontEngine *, QGLGlyphHash * > QGLFontGlyphHash
void cleanupContext(const QGLContext *)
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
int width() const
Returns the width of the image.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
bool isValid() const
Returns true if a GL rendering context has been successfully created; otherwise returns false...
static const int y_margin
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
int size() const
Returns the number of items in the list.
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
QGLGlyphHash * current_cache
Q_DECL_CONSTEXPR int qRound(qreal d)
The QList class is a template class that provides lists.
static const int x_margin