7#include "private/qfontengine_p.h"
8#include "private/qnumeric_p.h"
10#include <QtGui/qpainterpath.h>
26 const int NumSubpixelPositions = 12;
30 for (
int i = 0;
i < NumSubpixelPositions; ++
i) {
45 for (
int j = 0;
j < numImages; ++
j) {
63 QPainter::RenderHints renderHints,
64 bool includeGlyphCacheScale)
67 printf(
"Populating with %lld glyphs\n",
static_cast<long long>(
numGlyphs));
73 const int paddingDoubled = padding * 2;
79 if (!supportsSubPixelPositions) {
104 if (supportsSubPixelPositions) {
106 if (includeGlyphCacheScale) {
111 if (!verticalSubPixelPositions)
112 subPixelPosition.
y = 0;
123 printf(
"(%4x): w=%.2f, h=%.2f, xoff=%.2f, yoff=%.2f, x=%.2f, y=%.2f\n",
133 int glyph_width =
metrics.width.ceil().toInt();
134 int glyph_height =
metrics.height.ceil().toInt();
135 if (glyph_height == 0 || glyph_width == 0) {
137 Coord c = { 0, 0, 0, 0, 0, 0 };
143 glyph_width = (glyph_width+7)&~7;
152 rowHeight =
qMax(rowHeight, glyph_height);
154 if (listItemCoordinates.
isEmpty())
157 rowHeight += paddingDoubled;
168 int requiredWidth =
m_w;
169 while (
iter != listItemCoordinates.
end()) {
174 if (
m_cx +
c.w + padding > requiredWidth) {
175 int new_width = requiredWidth*2;
176 while (new_width <
m_cx +
c.w + padding)
179 requiredWidth = new_width;
199 m_cx +=
c.w + paddingDoubled;
211 int requiredHeight =
m_h;
212 int requiredWidth =
m_w;
217 requiredHeight =
qMax(requiredHeight,
c.y +
c.h);
218 requiredWidth =
qMax(requiredWidth,
c.x +
c.w);
223 if (
isNull() || requiredHeight >
m_h || requiredWidth >
m_w) {
306 printf(
"fillTexture of %dx%d at %d,%d in the cache of %dx%d\n",
c.w,
c.h,
c.x,
c.y, m_image.
width(), m_image.
height());
307 if (
mask.width() >
c.w ||
mask.height() >
c.h) {
308 printf(
" ERROR; mask is bigger than reserved space! %dx%d instead of %dx%d\n",
mask.width(),
mask.height(),
c.w,
c.h);
321 p.fillRect(0, 0,
c.w,
c.h,
QColor(0,0,0,0));
322 p.drawImage(0, 0,
mask);
325 if (
mask.depth() > 1) {
338 for (
int y = 0;
y <
c.h; ++
y) {
339 uchar *dest =
d + (
c.y +
y) *dbpl +
c.x/8;
343 for (
int x = 0;
x <
c.w/8; ++
x) {
350 for (
int x = 0;
x <
c.w/8; ++
x)
360 if (
mask.depth() == 1) {
361 for (
int y = 0;
y <
c.h; ++
y) {
365 for (
int x = 0;
x <
c.w; ++
x) {
367 dest[
x] = (
src[
x >> 3] & (1 << (7 - (
x & 7)))) > 0 ? 255 : 0;
371 }
else if (
mask.depth() == 8) {
372 for (
int y = 0;
y <
c.h; ++
y) {
376 for (
int x = 0;
x <
c.w; ++
x) {
The QColor class provides colors based on RGB, HSV or CMYK values.
const QTransform & transform() const
QFontEngine::GlyphFormat m_format
const QColor & color() const
virtual QImage bitmapForGlyph(glyph_t, const QFixedPoint &subPixelPosition, const QTransform &t, const QColor &color=QColor())
virtual glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, const QFixedPoint &, const QTransform &matrix, GlyphFormat)
int m_subPixelPositionCount
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags)
virtual qreal maxCharWidth() const =0
virtual int glyphMargin(GlyphFormat format)
virtual QImage alphaMapForGlyph(glyph_t)
virtual QImage alphaRGBMapForGlyph(glyph_t, const QFixedPoint &subPixelPosition, const QTransform &t)
virtual bool supportsVerticalSubPixelPositions() const
bool supportsSubPixelPositions() const
virtual QFixedPoint subPixelPositionFor(const QFixedPoint &position) const
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
bool isEmpty() const noexcept
Returns true if the hash contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
virtual void createTextureData(int width, int height) override
~QImageTextureGlyphCache()
virtual void resizeTextureData(int width, int height) override
virtual void fillTexture(const Coord &c, glyph_t glyph, const QFixedPoint &subPixelPosition) override
qsizetype bytesPerLine() const
Returns the number of bytes per image scanline.
void setPixel(int x, int y, uint index_or_rgb)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
int width() const
Returns the width of the image.
bool save(const QString &fileName, const char *format=nullptr, int quality=-1) const
Saves the image to the file with the given fileName, using the given image file format and quality fa...
uchar * bits()
Returns a pointer to the first pixel data.
int height() const
Returns the height of the image.
@ Format_ARGB32_Premultiplied
void fill(uint pixel)
Fills the entire image with the given pixelValue.
Format format() const
Returns the format of the image.
QRect rect() const
Returns the enclosing rectangle (0, 0, width(), height()) of the image.
The QPainter class performs low-level painting on widgets and other paint devices.
@ VerticalSubpixelPositioning
\inmodule QtCore\reentrant
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void fillInPendingGlyphs()
QFontEngine * m_current_fontengine
int calculateSubPixelPositionCount(glyph_t) const
virtual int maxTextureHeight() const
void resizeCache(int width, int height)
virtual void endFillTexture()
bool hasPendingGlyphs() const
virtual void fillTexture(const Coord &coord, glyph_t glyph, const QFixedPoint &subPixelPosition)=0
virtual void beginFillTexture()
QImage textureMapForGlyph(glyph_t g, const QFixedPoint &subPixelPosition) const
void createCache(int width, int height)
QHash< GlyphAndSubPixelPosition, Coord > m_pendingGlyphs
bool populate(QFontEngine *fontEngine, qsizetype numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions, QPainter::RenderHints renderHints=QPainter::RenderHints(), bool includeGlyphCacheScale=false)
virtual int maxTextureWidth() const
virtual int glyphPadding() const
Combined button and popup list for selecting options.
static const QCssKnownValue positions[NumKnownPositionModes - 1]
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter * iter
constexpr quint32 qNextPowerOfTwo(quint32 v)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLsizei const GLubyte GLsizei GLenum const void * coords
GLenum const void GLbitfield GLsizei numGlyphs
GLsizei GLenum const void GLuint GLsizei GLfloat * metrics
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLsizei const GLchar *const * path
#define QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH
QList< QImage > images
[6]
static constexpr QFixed fromReal(qreal r)