summaryrefslogtreecommitdiffstats
path: root/src/openvg
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvg')
-rw-r--r--src/openvg/openvg.pro9
-rw-r--r--src/openvg/qpaintengine_vg.cpp149
-rw-r--r--src/openvg/qpaintengine_vg_p.h10
-rw-r--r--src/openvg/qpixmapdata_vg.cpp278
-rw-r--r--src/openvg/qvg_p.h2
-rw-r--r--src/openvg/qvg_symbian.cpp398
-rw-r--r--src/openvg/qvgfontglyphcache_p.h95
-rw-r--r--src/openvg/qwindowsurface_vg.cpp2
-rw-r--r--src/openvg/qwindowsurface_vgegl.cpp43
-rw-r--r--src/openvg/qwindowsurface_vgegl_p.h2
10 files changed, 613 insertions, 375 deletions
diff --git a/src/openvg/openvg.pro b/src/openvg/openvg.pro
index 883f0f3..eb60331 100644
--- a/src/openvg/openvg.pro
+++ b/src/openvg/openvg.pro
@@ -17,7 +17,8 @@ HEADERS += \
qpixmapdata_vg_p.h \
qpixmapfilter_vg_p.h \
qvgcompositionhelper_p.h \
- qvgimagepool_p.h
+ qvgimagepool_p.h \
+ qvgfontglyphcache_p.h
SOURCES += \
qpaintengine_vg.cpp \
qpixmapdata_vg.cpp \
@@ -33,7 +34,11 @@ contains(QT_CONFIG, egl) {
qwindowsurface_vgegl.cpp
}
-symbian: DEFINES += QVG_RECREATE_ON_SIZE_CHANGE QVG_BUFFER_SCROLLING
+symbian {
+ DEFINES += QVG_RECREATE_ON_SIZE_CHANGE QVG_BUFFER_SCROLLING
+ SOURCES += \
+ qvg_symbian.cpp
+}
include(../qbase.pri)
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 318e2b1..75e5a60 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -44,16 +44,17 @@
#include "qpixmapfilter_vg_p.h"
#include "qvgcompositionhelper_p.h"
#include "qvgimagepool_p.h"
+#include "qvgfontglyphcache_p.h"
#if !defined(QT_NO_EGL)
-#include <QtGui/private/qegl_p.h>
+#include <QtGui/private/qeglcontext_p.h>
#include "qwindowsurface_vgegl_p.h"
#endif
#include <QtCore/qvarlengtharray.h>
#include <QtGui/private/qdrawhelper_p.h>
-#include <QtGui/private/qtextureglyphcache_p.h>
#include <QtGui/private/qtextengine_p.h>
#include <QtGui/private/qfontengine_p.h>
#include <QtGui/private/qpainterpath_p.h>
+#include <QtGui/private/qstatictext_p.h>
#include <QtCore/qmath.h>
#include <QDebug>
#include <QSet>
@@ -84,25 +85,6 @@ Q_DECL_IMPORT extern int qt_defaultDpiY();
class QVGPaintEnginePrivate;
-class QVGFontGlyphCache
-{
-public:
- QVGFontGlyphCache();
- ~QVGFontGlyphCache();
-
- void cacheGlyphs(QVGPaintEnginePrivate *d,
- const QTextItemInt &ti,
- const QVarLengthArray<glyph_t> &glyphs);
- void setScaleFromText(const QTextItemInt &ti);
-
- VGFont font;
- VGfloat scaleX;
- VGfloat scaleY;
-
- uint cachedGlyphsMask[256 / 32];
- QSet<glyph_t> cachedGlyphs;
-};
-
typedef QHash<QFontEngine*, QVGFontGlyphCache*> QVGFontCache;
#endif
@@ -1023,7 +1005,7 @@ static QImage colorizeBitmap(const QImage &image, const QColor &color)
int height = sourceImage.height();
int width = sourceImage.width();
for (int y=0; y<height; ++y) {
- uchar *source = sourceImage.scanLine(y);
+ const uchar *source = sourceImage.constScanLine(y);
QRgb *target = reinterpret_cast<QRgb *>(dest.scanLine(y));
for (int x=0; x < width; ++x)
target[x] = (source[x>>3] >> (x&7)) & 1 ? fg : bg;
@@ -1031,9 +1013,6 @@ static QImage colorizeBitmap(const QImage &image, const QColor &color)
return dest;
}
-// defined in qpixmapdata_vg.cpp.
-const uchar *qt_vg_imageBits(const QImage& image);
-
static VGImage toVGImage
(const QImage & image, Qt::ImageConversionFlags flags = Qt::AutoColor)
{
@@ -1067,7 +1046,7 @@ static VGImage toVGImage
break;
}
- const uchar *pixels = qt_vg_imageBits(img);
+ const uchar *pixels = img.constBits();
VGImage vgImg = QVGImagePool::instance()->createPermanentImage
(format, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER);
@@ -1111,7 +1090,7 @@ static VGImage toVGImageSubRect
break;
}
- const uchar *pixels = qt_vg_imageBits(img) + bpp * sr.x() +
+ const uchar *pixels = img.constBits() + bpp * sr.x() +
img.bytesPerLine() * sr.y();
VGImage vgImg = QVGImagePool::instance()->createPermanentImage
@@ -1133,7 +1112,7 @@ static VGImage toVGImageWithOpacity(const QImage & image, qreal opacity)
painter.drawImage(0, 0, image);
painter.end();
- const uchar *pixels = qt_vg_imageBits(img);
+ const uchar *pixels = img.constBits();
VGImage vgImg = QVGImagePool::instance()->createPermanentImage
(VG_sARGB_8888_PRE, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER);
@@ -1155,7 +1134,7 @@ static VGImage toVGImageWithOpacitySubRect
painter.drawImage(QPoint(0, 0), image, sr);
painter.end();
- const uchar *pixels = qt_vg_imageBits(img);
+ const uchar *pixels = img.constBits();
VGImage vgImg = QVGImagePool::instance()->createPermanentImage
(VG_sARGB_8888_PRE, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER);
@@ -3170,9 +3149,8 @@ void QVGPaintEngine::drawTiledPixmap
// (i.e. no opacity), no rotation or scaling, and drawing the full
// pixmap rather than parts of the pixmap. Even having just one of
// these conditions will improve performance.
-void QVGPaintEngine::drawPixmaps
- (const QDrawPixmaps::Data *drawingData, int dataCount,
- const QPixmap &pixmap, QFlags<QDrawPixmaps::DrawingHint> hints)
+void QVGPaintEngine::drawPixmapFragments(const QPainter::PixmapFragment *drawingData, int dataCount,
+ const QPixmap &pixmap, QFlags<QPainter::PixmapFragmentHint> hints)
{
#if !defined(QT_SHIVAVG)
Q_D(QVGPaintEngine);
@@ -3183,7 +3161,7 @@ void QVGPaintEngine::drawPixmaps
if (!pd)
return; // null QPixmap
if (pd->classId() != QPixmapData::OpenVGClass || !d->simpleTransform) {
- QPaintEngineEx::drawPixmaps(drawingData, dataCount, pixmap, hints);
+ QPaintEngineEx::drawPixmapFragments(drawingData, dataCount, pixmap, hints);
return;
}
@@ -3207,7 +3185,7 @@ void QVGPaintEngine::drawPixmaps
QVarLengthArray<QRect> cachedSources;
// Select the opacity paint object.
- if ((hints & QDrawPixmaps::OpaqueHint) != 0 && d->opacity == 1.0f) {
+ if ((hints & QPainter::OpaqueHint) != 0 && d->opacity == 1.0f) {
d->setImageMode(VG_DRAW_IMAGE_NORMAL);
} else {
hints = 0;
@@ -3219,12 +3197,13 @@ void QVGPaintEngine::drawPixmaps
for (int i = 0; i < dataCount; ++i) {
QTransform transform(d->imageTransform);
- transform.translate(drawingData[i].point.x(), drawingData[i].point.y());
+ transform.translate(drawingData[i].x, drawingData[i].y);
transform.rotate(drawingData[i].rotation);
VGImage child;
QSize imageSize = vgpd->size();
- QRectF sr = drawingData[i].source;
+ QRectF sr(drawingData[i].sourceLeft, drawingData[i].sourceTop,
+ drawingData[i].width, drawingData[i].height);
if (sr.topLeft().isNull() && sr.size() == imageSize) {
child = vgImg;
} else {
@@ -3253,7 +3232,7 @@ void QVGPaintEngine::drawPixmaps
transform.scale(scaleX, scaleY);
d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
- if ((hints & QDrawPixmaps::OpaqueHint) == 0) {
+ if ((hints & QPainter::OpaqueHint) == 0) {
qreal opacity = d->opacity * drawingData[i].opacity;
if (opacity != 1.0f) {
if (d->paintOpacity != opacity) {
@@ -3279,7 +3258,7 @@ void QVGPaintEngine::drawPixmaps
for (int i = 0; i < cachedImages.size(); ++i)
vgDestroyImage(cachedImages[i]);
#else
- QPaintEngineEx::drawPixmaps(drawingData, dataCount, pixmap, hints);
+ QPaintEngineEx::drawPixmapFragments(drawingData, dataCount, pixmap, hints);
#endif
}
@@ -3310,6 +3289,7 @@ QVGFontGlyphCache::QVGFontGlyphCache()
{
font = vgCreateFont(0);
scaleX = scaleY = 0.0;
+ invertedGlyphs = false;
memset(cachedGlyphsMask, 0, sizeof(cachedGlyphsMask));
}
@@ -3319,22 +3299,20 @@ QVGFontGlyphCache::~QVGFontGlyphCache()
vgDestroyFont(font);
}
-void QVGFontGlyphCache::setScaleFromText(const QTextItemInt &ti)
+void QVGFontGlyphCache::setScaleFromText(const QFont &font, QFontEngine *fontEngine)
{
- QFontInfo fi(ti.font());
+ QFontInfo fi(font);
qreal pixelSize = fi.pixelSize();
- qreal emSquare = ti.fontEngine->properties().emSquare.toReal();
+ qreal emSquare = fontEngine->properties().emSquare.toReal();
scaleX = scaleY = static_cast<VGfloat>(pixelSize / emSquare);
}
-void QVGFontGlyphCache::cacheGlyphs
- (QVGPaintEnginePrivate *d, const QTextItemInt &ti,
- const QVarLengthArray<glyph_t> &glyphs)
+void QVGFontGlyphCache::cacheGlyphs(QVGPaintEnginePrivate *d,
+ QFontEngine *fontEngine,
+ const glyph_t *g, int count)
{
VGfloat origin[2];
VGfloat escapement[2];
- const glyph_t *g = glyphs.constData();
- int count = glyphs.size();
glyph_metrics_t metrics;
// Some Qt font engines don't set yoff in getUnscaledGlyph().
// Zero the metric structure so that everything has a default value.
@@ -3353,21 +3331,21 @@ void QVGFontGlyphCache::cacheGlyphs
}
#if !defined(QVG_NO_IMAGE_GLYPHS)
Q_UNUSED(d);
- QImage scaledImage = ti.fontEngine->alphaMapForGlyph(glyph);
+ QImage scaledImage = fontEngine->alphaMapForGlyph(glyph);
VGImage vgImage = VG_INVALID_HANDLE;
- metrics = ti.fontEngine->boundingBox(glyph);
+ metrics = fontEngine->boundingBox(glyph);
if (!scaledImage.isNull()) { // Not a space character
if (scaledImage.format() == QImage::Format_Indexed8) {
vgImage = vgCreateImage(VG_A_8, scaledImage.width(), scaledImage.height(), VG_IMAGE_QUALITY_FASTER);
- vgImageSubData(vgImage, qt_vg_imageBits(scaledImage), scaledImage.bytesPerLine(), VG_A_8, 0, 0, scaledImage.width(), scaledImage.height());
+ vgImageSubData(vgImage, scaledImage.constBits(), scaledImage.bytesPerLine(), VG_A_8, 0, 0, scaledImage.width(), scaledImage.height());
} else if (scaledImage.format() == QImage::Format_Mono) {
QImage img = scaledImage.convertToFormat(QImage::Format_Indexed8);
vgImage = vgCreateImage(VG_A_8, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER);
- vgImageSubData(vgImage, qt_vg_imageBits(img), img.bytesPerLine(), VG_A_8, 0, 0, img.width(), img.height());
+ vgImageSubData(vgImage, img.constBits(), img.bytesPerLine(), VG_A_8, 0, 0, img.width(), img.height());
} else {
QImage img = scaledImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);
vgImage = vgCreateImage(VG_sARGB_8888_PRE, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER);
- vgImageSubData(vgImage, qt_vg_imageBits(img), img.bytesPerLine(), VG_sARGB_8888_PRE, 0, 0, img.width(), img.height());
+ vgImageSubData(vgImage, img.constBits(), img.bytesPerLine(), VG_sARGB_8888_PRE, 0, 0, img.width(), img.height());
}
}
origin[0] = -metrics.x.toReal();
@@ -3379,7 +3357,7 @@ void QVGFontGlyphCache::cacheGlyphs
#else
// Calculate the path for the glyph and cache it.
QPainterPath path;
- ti.fontEngine->getUnscaledGlyph(glyph, &path, &metrics);
+ fontEngine->getUnscaledGlyph(glyph, &path, &metrics);
VGPath vgPath;
if (!path.isEmpty()) {
vgPath = d->painterPathToVGPath(path);
@@ -3411,31 +3389,56 @@ void QVGPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
QPaintEngineEx::drawTextItem(p, textItem);
return;
}
-
+
// Get the glyphs and positions associated with the text item.
QVarLengthArray<QFixedPoint> positions;
QVarLengthArray<glyph_t> glyphs;
QTransform matrix;
ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
+ if (!drawCachedGlyphs(glyphs.size(), glyphs.data(), ti.font(), ti.fontEngine, p, positions.data()))
+ QPaintEngineEx::drawTextItem(p, textItem);
+#else
+ // OpenGL 1.0 does not have support for VGFont and glyphs,
+ // so fall back to the default Qt path stroking algorithm.
+ QPaintEngineEx::drawTextItem(p, textItem);
+#endif
+}
+
+void QVGPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
+{
+ drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->font, textItem->fontEngine,
+ QPointF(0, 0), textItem->glyphPositions);
+}
+
+ bool QVGPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFont &font,
+ QFontEngine *fontEngine, const QPointF &p,
+ const QFixedPoint *positions)
+ {
+#if !defined(QVG_NO_DRAW_GLYPHS)
+ Q_D(QVGPaintEngine);
+
// Find the glyph cache for this font.
- QVGFontCache::ConstIterator it = d->fontCache.constFind(ti.fontEngine);
+ QVGFontCache::ConstIterator it = d->fontCache.constFind(fontEngine);
QVGFontGlyphCache *glyphCache;
if (it != d->fontCache.constEnd()) {
glyphCache = it.value();
} else {
+#ifdef Q_OS_SYMBIAN
+ glyphCache = new QSymbianVGFontGlyphCache();
+#else
glyphCache = new QVGFontGlyphCache();
+#endif
if (glyphCache->font == VG_INVALID_HANDLE) {
qWarning("QVGPaintEngine::drawTextItem: OpenVG fonts are not supported by the OpenVG engine");
delete glyphCache;
- QPaintEngineEx::drawTextItem(p, textItem);
- return;
+ return false;
}
- glyphCache->setScaleFromText(ti);
- d->fontCache.insert(ti.fontEngine, glyphCache);
+ glyphCache->setScaleFromText(font, fontEngine);
+ d->fontCache.insert(fontEngine, glyphCache);
if (!d->fontEngineCleaner)
d->fontEngineCleaner = new QVGFontEngineCleaner(d);
- QObject::connect(ti.fontEngine, SIGNAL(destroyed()),
+ QObject::connect(fontEngine, SIGNAL(destroyed()),
d->fontEngineCleaner, SLOT(fontEngineDestroyed()));
}
@@ -3452,15 +3455,20 @@ void QVGPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
#if defined(QVG_NO_IMAGE_GLYPHS)
glyphTransform.scale(glyphCache->scaleX, glyphCache->scaleY);
#endif
+
+ // Some glyph caches can create the VGImage upright
+ if (glyphCache->invertedGlyphs)
+ glyphTransform.scale(1, -1);
+
d->setTransform(VG_MATRIX_GLYPH_USER_TO_SURFACE, glyphTransform);
// Add the glyphs from the text item into the glyph cache.
- glyphCache->cacheGlyphs(d, ti, glyphs);
+ glyphCache->cacheGlyphs(d, fontEngine, glyphs, numGlyphs);
// Create the array of adjustments between glyphs
- QVarLengthArray<VGfloat> adjustments_x(glyphs.size());
- QVarLengthArray<VGfloat> adjustments_y(glyphs.size());
- for (int i = 1; i < glyphs.size(); ++i) {
+ QVarLengthArray<VGfloat> adjustments_x(numGlyphs);
+ QVarLengthArray<VGfloat> adjustments_y(numGlyphs);
+ for (int i = 1; i < numGlyphs; ++i) {
adjustments_x[i-1] = (positions[i].x - positions[i-1].x).toReal();
adjustments_y[i-1] = (positions[i].y - positions[i-1].y).toReal();
}
@@ -3482,12 +3490,17 @@ void QVGPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
// Draw the glyphs. We need to fill with the brush associated with
// the Qt pen, not the Qt brush.
d->ensureBrush(state()->pen.brush());
- vgDrawGlyphs(glyphCache->font, glyphs.size(), (VGuint*)glyphs.data(),
+ vgDrawGlyphs(glyphCache->font, numGlyphs, (VGuint*)glyphs,
adjustments_x.data(), adjustments_y.data(), VG_FILL_PATH, VG_TRUE);
+ return true;
#else
- // OpenGL 1.0 does not have support for VGFont and glyphs,
- // so fall back to the default Qt path stroking algorithm.
- QPaintEngineEx::drawTextItem(p, textItem);
+ Q_UNUSED(numGlyphs);
+ Q_UNUSED(glyphs);
+ Q_UNUSED(font);
+ Q_UNUSED(fontEngine);
+ Q_UNUSED(p);
+ Q_UNUSED(positions);
+ return false;
#endif
}
@@ -3848,7 +3861,7 @@ void QVGCompositionHelper::drawCursorPixmap
if (vgImage == VG_INVALID_HANDLE)
return;
vgImageSubData
- (vgImage, qt_vg_imageBits(img) + img.bytesPerLine() * (img.height() - 1),
+ (vgImage, img.constBits() + img.bytesPerLine() * (img.height() - 1),
-(img.bytesPerLine()), VG_sARGB_8888_PRE, 0, 0,
img.width(), img.height());
diff --git a/src/openvg/qpaintengine_vg_p.h b/src/openvg/qpaintengine_vg_p.h
index 3f87a72..75cf053 100644
--- a/src/openvg/qpaintengine_vg_p.h
+++ b/src/openvg/qpaintengine_vg_p.h
@@ -54,9 +54,11 @@
//
#include <QtGui/private/qpaintengineex_p.h>
+#include <QtGui/private/qtextureglyphcache_p.h>
QT_BEGIN_NAMESPACE
+class QFixedPoint;
class QVGPaintEnginePrivate;
class QPixmapData;
class QVGEGLWindowSurfacePrivate;
@@ -136,9 +138,14 @@ public:
void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
- void drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QFlags<QDrawPixmaps::DrawingHint> hints);
+ void drawPixmapFragments(const QPainter::PixmapFragment *drawingData, int dataCount, const QPixmap &pixmap,
+ QFlags<QPainter::PixmapFragmentHint> hints);
void drawTextItem(const QPointF &p, const QTextItem &textItem);
+ void drawStaticTextItem(QStaticTextItem *staticTextItem);
+ bool drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFont &font,
+ QFontEngine *fontEngine, const QPointF &p,
+ const QFixedPoint *positions);
void setState(QPainterState *s);
QVGPainterState *state() { return static_cast<QVGPainterState *>(QPaintEngineEx::state()); }
@@ -165,7 +172,6 @@ private:
bool clearRect(const QRectF &rect, const QColor &color);
};
-
QT_END_NAMESPACE
#endif
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp
index 39c83d3..cb413d0 100644
--- a/src/openvg/qpixmapdata_vg.cpp
+++ b/src/openvg/qpixmapdata_vg.cpp
@@ -42,20 +42,12 @@
#include "qpixmapdata_vg_p.h"
#include "qpaintengine_vg_p.h"
#include <QtGui/private/qdrawhelper_p.h>
+#if !defined(QT_NO_EGL)
+#include <QtGui/private/qegl_p.h>
+#endif
#include "qvg_p.h"
#include "qvgimagepool_p.h"
-#if defined(Q_OS_SYMBIAN)
-#include <private/qt_s60_p.h>
-#include <fbs.h>
-#endif
-#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE
-#include <sgresource/sgimage.h>
-typedef EGLImageKHR (*pfnEglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, EGLint*);
-typedef EGLBoolean (*pfnEglDestroyImageKHR)(EGLDisplay, EGLImageKHR);
-typedef VGImage (*pfnVgCreateEGLImageTargetKHR)(VGeglImageKHR);
-#endif // QT_SYMBIAN_SUPPORTS_SGIMAGE
-
QT_BEGIN_NAMESPACE
static int qt_vg_pixmap_serial = 0;
@@ -233,14 +225,6 @@ QPaintEngine* QVGPixmapData::paintEngine() const
return source.paintEngine();
}
-// This function works around QImage::bits() making a deep copy if the
-// QImage is not const. We force it to be const and then get the bits.
-// XXX: Should add a QImage::constBits() in the future to replace this.
-const uchar *qt_vg_imageBits(const QImage& image)
-{
- return image.bits();
-}
-
VGImage QVGPixmapData::toVGImage()
{
if (!isValid())
@@ -273,7 +257,7 @@ VGImage QVGPixmapData::toVGImage()
if (!source.isNull() && recreate) {
vgImageSubData
(vgImage,
- qt_vg_imageBits(source), source.bytesPerLine(),
+ source.constBits(), source.bytesPerLine(),
VG_sARGB_8888_PRE, 0, 0, w, h);
}
@@ -428,258 +412,4 @@ Q_OPENVG_EXPORT VGImage qPixmapToVGImage(const QPixmap& pixmap)
return VG_INVALID_HANDLE;
}
-#if defined(Q_OS_SYMBIAN)
-
-static CFbsBitmap* createBlitCopy(CFbsBitmap* bitmap)
-{
- CFbsBitmap *copy = q_check_ptr(new CFbsBitmap);
- if(!copy)
- return 0;
-
- if (copy->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()) != KErrNone) {
- delete copy;
- copy = 0;
-
- return 0;
- }
-
- CFbsBitmapDevice* bitmapDevice = 0;
- CFbsBitGc *bitmapGc = 0;
- QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(copy));
- QT_TRAP_THROWING(bitmapGc = CFbsBitGc::NewL());
- bitmapGc->Activate(bitmapDevice);
-
- bitmapGc->BitBlt(TPoint(), bitmap);
-
- delete bitmapGc;
- delete bitmapDevice;
-
- return copy;
-}
-
-void QVGPixmapData::cleanup()
-{
- is_null = w = h = 0;
- recreate = false;
- source = QImage();
-}
-
-void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
-{
- if (type == QPixmapData::SgImage && pixmap) {
-#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
- RSgImage *sgImage = reinterpret_cast<RSgImage*>(pixmap);
-
- destroyImages();
- prevSize = QSize();
-
- TInt err = 0;
-
- RSgDriver driver;
- err = driver.Open();
- if (err != KErrNone) {
- cleanup();
- return;
- }
-
- if (sgImage->IsNull()) {
- cleanup();
- driver.Close();
- return;
- }
-
- TSgImageInfo sgImageInfo;
- err = sgImage->GetInfo(sgImageInfo);
- if (err != KErrNone) {
- cleanup();
- driver.Close();
- return;
- }
-
- pfnEglCreateImageKHR eglCreateImageKHR = (pfnEglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR");
- pfnEglDestroyImageKHR eglDestroyImageKHR = (pfnEglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR");
- pfnVgCreateEGLImageTargetKHR vgCreateEGLImageTargetKHR = (pfnVgCreateEGLImageTargetKHR) eglGetProcAddress("vgCreateEGLImageTargetKHR");
-
- if (eglGetError() != EGL_SUCCESS || !eglCreateImageKHR || !eglDestroyImageKHR || !vgCreateEGLImageTargetKHR) {
- cleanup();
- driver.Close();
- return;
- }
-
- const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE};
- EGLImageKHR eglImage = eglCreateImageKHR(QEglContext::display(),
- EGL_NO_CONTEXT,
- EGL_NATIVE_PIXMAP_KHR,
- (EGLClientBuffer)sgImage,
- (EGLint*)KEglImageAttribs);
-
- if (eglGetError() != EGL_SUCCESS) {
- cleanup();
- driver.Close();
- return;
- }
-
- vgImage = vgCreateEGLImageTargetKHR(eglImage);
- if (vgGetError() != VG_NO_ERROR) {
- cleanup();
- eglDestroyImageKHR(QEglContext::display(), eglImage);
- driver.Close();
- return;
- }
-
- w = sgImageInfo.iSizeInPixels.iWidth;
- h = sgImageInfo.iSizeInPixels.iHeight;
- d = 32; // We always use ARGB_Premultiplied for VG pixmaps.
- is_null = (w <= 0 || h <= 0);
- source = QImage();
- recreate = false;
- prevSize = QSize(w, h);
- setSerialNumber(++qt_vg_pixmap_serial);
- // release stuff
- eglDestroyImageKHR(QEglContext::display(), eglImage);
- driver.Close();
-#endif
- } else if (type == QPixmapData::FbsBitmap) {
- CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap*>(pixmap);
-
- bool deleteSourceBitmap = false;
-
-#ifdef Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE
-
- // Rasterize extended bitmaps
-
- TUid extendedBitmapType = bitmap->ExtendedBitmapType();
- if (extendedBitmapType != KNullUid) {
- bitmap = createBlitCopy(bitmap);
- deleteSourceBitmap = true;
- }
-#endif
-
- if (bitmap->IsCompressedInRAM()) {
- bitmap = createBlitCopy(bitmap);
- deleteSourceBitmap = true;
- }
-
- TDisplayMode displayMode = bitmap->DisplayMode();
- QImage::Format format = qt_TDisplayMode2Format(displayMode);
-
- TSize size = bitmap->SizeInPixels();
-
- bitmap->BeginDataAccess();
- uchar *bytes = (uchar*)bitmap->DataAddress();
- QImage img = QImage(bytes, size.iWidth, size.iHeight, format);
- img = img.copy();
- bitmap->EndDataAccess();
-
- if(displayMode == EGray2) {
- //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid
- //So invert mono bitmaps so that masks work correctly.
- img.invertPixels();
- } else if(displayMode == EColor16M) {
- img = img.rgbSwapped(); // EColor16M is BGR
- }
-
- fromImage(img, Qt::AutoColor);
-
- if(deleteSourceBitmap)
- delete bitmap;
- }
-}
-
-void* QVGPixmapData::toNativeType(NativeType type)
-{
- if (type == QPixmapData::SgImage) {
-#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
- toVGImage();
-
- if (!isValid() || vgImage == VG_INVALID_HANDLE)
- return 0;
-
- TInt err = 0;
-
- RSgDriver driver;
- err = driver.Open();
- if (err != KErrNone)
- return 0;
-
- TSgImageInfo sgInfo;
- sgInfo.iPixelFormat = EUidPixelFormatARGB_8888_PRE;
- sgInfo.iSizeInPixels.SetSize(w, h);
- sgInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface;
-
- RSgImage *sgImage = q_check_ptr(new RSgImage());
- err = sgImage->Create(sgInfo, NULL, NULL);
- if (err != KErrNone) {
- driver.Close();
- return 0;
- }
-
- pfnEglCreateImageKHR eglCreateImageKHR = (pfnEglCreateImageKHR) eglGetProcAddress("eglCreateImageKHR");
- pfnEglDestroyImageKHR eglDestroyImageKHR = (pfnEglDestroyImageKHR) eglGetProcAddress("eglDestroyImageKHR");
- pfnVgCreateEGLImageTargetKHR vgCreateEGLImageTargetKHR = (pfnVgCreateEGLImageTargetKHR) eglGetProcAddress("vgCreateEGLImageTargetKHR");
-
- if (eglGetError() != EGL_SUCCESS || !eglCreateImageKHR || !eglDestroyImageKHR || !vgCreateEGLImageTargetKHR) {
- driver.Close();
- return 0;
- }
-
- const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE};
- EGLImageKHR eglImage = eglCreateImageKHR(QEglContext::display(),
- EGL_NO_CONTEXT,
- EGL_NATIVE_PIXMAP_KHR,
- (EGLClientBuffer)sgImage,
- (EGLint*)KEglImageAttribs);
- if (eglGetError() != EGL_SUCCESS) {
- sgImage->Close();
- driver.Close();
- return 0;
- }
-
- VGImage dstVgImage = vgCreateEGLImageTargetKHR(eglImage);
- if (vgGetError() != VG_NO_ERROR) {
- eglDestroyImageKHR(QEglContext::display(), eglImage);
- sgImage->Close();
- driver.Close();
- return 0;
- }
-
- vgCopyImage(dstVgImage, 0, 0,
- vgImage, 0, 0,
- w, h, VG_FALSE);
-
- if (vgGetError() != VG_NO_ERROR) {
- sgImage->Close();
- sgImage = 0;
- }
- // release stuff
- vgDestroyImage(dstVgImage);
- eglDestroyImageKHR(QEglContext::display(), eglImage);
- driver.Close();
- return reinterpret_cast<void*>(sgImage);
-#endif
- } else if (type == QPixmapData::FbsBitmap) {
- CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap);
-
- if (bitmap) {
- if (bitmap->Create(TSize(source.width(), source.height()),
- EColor16MAP) == KErrNone) {
- const uchar *sptr = qt_vg_imageBits(source);
- bitmap->BeginDataAccess();
-
- uchar *dptr = (uchar*)bitmap->DataAddress();
- Mem::Copy(dptr, sptr, source.byteCount());
-
- bitmap->EndDataAccess();
- } else {
- delete bitmap;
- bitmap = 0;
- }
- }
-
- return reinterpret_cast<void*>(bitmap);
- }
- return 0;
-}
-#endif //Q_OS_SYMBIAN
-
QT_END_NAMESPACE
diff --git a/src/openvg/qvg_p.h b/src/openvg/qvg_p.h
index 7857bb6..51abbee 100644
--- a/src/openvg/qvg_p.h
+++ b/src/openvg/qvg_p.h
@@ -58,7 +58,7 @@
#include <QtGui/qimage.h>
#if !defined(QT_NO_EGL)
-#include <QtGui/private/qegl_p.h>
+#include <QtGui/private/qeglcontext_p.h>
#endif
QT_BEGIN_NAMESPACE
diff --git a/src/openvg/qvg_symbian.cpp b/src/openvg/qvg_symbian.cpp
new file mode 100644
index 0000000..0e6e773
--- /dev/null
+++ b/src/openvg/qvg_symbian.cpp
@@ -0,0 +1,398 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qpixmapdata_vg_p.h"
+#include "qvgfontglyphcache_p.h"
+#include <private/qt_s60_p.h>
+
+#include <fbs.h>
+#include <bitdev.h>
+
+#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE
+# include <sgresource/sgimage.h>
+# ifdef SYMBIAN_FBSERV_GLYPHDATA // defined in fbs.h
+# define QT_SYMBIAN_HARDWARE_GLYPH_CACHE
+# include <graphics/fbsglyphdataiterator.h>
+# include <private/qfontengine_s60_p.h>
+# endif
+#endif
+
+QT_BEGIN_NAMESPACE
+
+typedef VGImage (*_vgCreateEGLImageTargetKHR)(VGeglImageKHR);
+static _vgCreateEGLImageTargetKHR qt_vgCreateEGLImageTargetKHR = 0;
+
+namespace QVG
+{
+ VGImage vgCreateEGLImageTargetKHR(VGeglImageKHR eglImage);
+}
+
+VGImage QVG::vgCreateEGLImageTargetKHR(VGeglImageKHR eglImage)
+{
+ if (!qt_vgCreateEGLImageTargetKHR && QEgl::hasExtension("EGL_KHR_image"))
+ qt_vgCreateEGLImageTargetKHR = (_vgCreateEGLImageTargetKHR) eglGetProcAddress("vgCreateEGLImageTargetKHR");
+
+ return qt_vgCreateEGLImageTargetKHR ? qt_vgCreateEGLImageTargetKHR(eglImage) : 0;
+}
+
+extern int qt_vg_pixmap_serial;
+
+static CFbsBitmap* createBlitCopy(CFbsBitmap* bitmap)
+{
+ CFbsBitmap *copy = q_check_ptr(new CFbsBitmap);
+ if(!copy)
+ return 0;
+
+ if (copy->Create(bitmap->SizeInPixels(), bitmap->DisplayMode()) != KErrNone) {
+ delete copy;
+ copy = 0;
+
+ return 0;
+ }
+
+ CFbsBitmapDevice* bitmapDevice = 0;
+ CFbsBitGc *bitmapGc = 0;
+ QT_TRAP_THROWING(bitmapDevice = CFbsBitmapDevice::NewL(copy));
+ QT_TRAP_THROWING(bitmapGc = CFbsBitGc::NewL());
+ bitmapGc->Activate(bitmapDevice);
+
+ bitmapGc->BitBlt(TPoint(), bitmap);
+
+ delete bitmapGc;
+ delete bitmapDevice;
+
+ return copy;
+}
+
+#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE
+static VGImage sgImageToVGImage(QEglContext *context, const RSgImage &sgImage)
+{
+ // when "0" used as argument then
+ // default display, context are used
+ if (!context)
+ context = qt_vg_create_context(0, QInternal::Pixmap);
+
+ VGImage vgImage = VG_INVALID_HANDLE;
+
+ TInt err = 0;
+
+ RSgDriver driver;
+ err = driver.Open();
+ if (err != KErrNone) {
+ return vgImage;
+ }
+
+ if (sgImage.IsNull()) {
+ driver.Close();
+ return vgImage;
+ }
+
+ TSgImageInfo sgImageInfo;
+ err = sgImage.GetInfo(sgImageInfo);
+ if (err != KErrNone) {
+ driver.Close();
+ return vgImage;
+ }
+
+ const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE};
+ EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(),
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_PIXMAP_KHR,
+ (EGLClientBuffer)&sgImage,
+ (EGLint*)KEglImageAttribs);
+
+ if (!eglImage || eglGetError() != EGL_SUCCESS) {
+ driver.Close();
+ return vgImage;
+ }
+
+ vgImage = QVG::vgCreateEGLImageTargetKHR(eglImage);
+ if (!vgImage || vgGetError() != VG_NO_ERROR) {
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
+ driver.Close();
+ return vgImage;
+ }
+
+ //setSerialNumber(++qt_vg_pixmap_serial);
+ // release stuff
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
+ driver.Close();
+ return vgImage;
+}
+#endif
+
+void QVGPixmapData::cleanup()
+{
+ is_null = w = h = 0;
+ recreate = false;
+ source = QImage();
+}
+
+void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
+{
+ if (type == QPixmapData::SgImage && pixmap) {
+#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
+ RSgImage *sgImage = reinterpret_cast<RSgImage*>(pixmap);
+ destroyImages();
+ prevSize = QSize();
+
+ VGImage vgImage = sgImageToVGImage(context, *sgImage);
+ if (vgImage != VG_INVALID_HANDLE) {
+ w = vgGetParameteri(vgImage, VG_IMAGE_WIDTH);
+ h = vgGetParameteri(vgImage, VG_IMAGE_HEIGHT);
+ d = 32; // We always use ARGB_Premultiplied for VG pixmaps.
+ }
+
+ is_null = (w <= 0 || h <= 0);
+ source = QImage(); // vgGetImageSubData() some day?
+ recreate = false;
+ prevSize = QSize(w, h);
+ //setSerialNumber(++qt_vg_pixmap_serial);
+#endif
+ } else if (type == QPixmapData::FbsBitmap) {
+ CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap*>(pixmap);
+
+ bool deleteSourceBitmap = false;
+
+#ifdef Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE
+
+ // Rasterize extended bitmaps
+
+ TUid extendedBitmapType = bitmap->ExtendedBitmapType();
+ if (extendedBitmapType != KNullUid) {
+ bitmap = createBlitCopy(bitmap);
+ deleteSourceBitmap = true;
+ }
+#endif
+
+ if (bitmap->IsCompressedInRAM()) {
+ bitmap = createBlitCopy(bitmap);
+ deleteSourceBitmap = true;
+ }
+
+ TDisplayMode displayMode = bitmap->DisplayMode();
+ QImage::Format format = qt_TDisplayMode2Format(displayMode);
+
+ TSize size = bitmap->SizeInPixels();
+
+ bitmap->BeginDataAccess();
+ uchar *bytes = (uchar*)bitmap->DataAddress();
+ QImage img = QImage(bytes, size.iWidth, size.iHeight, format);
+ img = img.copy();
+ bitmap->EndDataAccess();
+
+ if(displayMode == EGray2) {
+ //Symbian thinks set pixels are white/transparent, Qt thinks they are foreground/solid
+ //So invert mono bitmaps so that masks work correctly.
+ img.invertPixels();
+ } else if(displayMode == EColor16M) {
+ img = img.rgbSwapped(); // EColor16M is BGR
+ }
+
+ fromImage(img, Qt::AutoColor);
+
+ if(deleteSourceBitmap)
+ delete bitmap;
+ }
+}
+
+void* QVGPixmapData::toNativeType(NativeType type)
+{
+ if (type == QPixmapData::SgImage) {
+#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
+ toVGImage();
+
+ if (!isValid() || vgImage == VG_INVALID_HANDLE)
+ return 0;
+
+ TInt err = 0;
+
+ RSgDriver driver;
+ err = driver.Open();
+ if (err != KErrNone)
+ return 0;
+
+ TSgImageInfo sgInfo;
+ sgInfo.iPixelFormat = EUidPixelFormatARGB_8888_PRE;
+ sgInfo.iSizeInPixels.SetSize(w, h);
+ sgInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface;
+
+ RSgImage *sgImage = q_check_ptr(new RSgImage());
+ err = sgImage->Create(sgInfo, NULL, NULL);
+ if (err != KErrNone) {
+ driver.Close();
+ return 0;
+ }
+
+ const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE};
+ EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(),
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_PIXMAP_KHR,
+ (EGLClientBuffer)sgImage,
+ (EGLint*)KEglImageAttribs);
+ if (!eglImage || eglGetError() != EGL_SUCCESS) {
+ sgImage->Close();
+ driver.Close();
+ return 0;
+ }
+
+ VGImage dstVgImage = QVG::vgCreateEGLImageTargetKHR(eglImage);
+ if (!dstVgImage || vgGetError() != VG_NO_ERROR) {
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
+ sgImage->Close();
+ driver.Close();
+ return 0;
+ }
+
+ vgCopyImage(dstVgImage, 0, 0,
+ vgImage, 0, 0,
+ w, h, VG_FALSE);
+
+ if (vgGetError() != VG_NO_ERROR) {
+ sgImage->Close();
+ sgImage = 0;
+ }
+ // release stuff
+ vgDestroyImage(dstVgImage);
+ QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
+ driver.Close();
+ return reinterpret_cast<void*>(sgImage);
+#endif
+ } else if (type == QPixmapData::FbsBitmap) {
+ CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap);
+
+ if (bitmap) {
+ if (bitmap->Create(TSize(source.width(), source.height()),
+ EColor16MAP) == KErrNone) {
+ const uchar *sptr = const_cast<const QImage&>(source).bits();
+ bitmap->BeginDataAccess();
+
+ uchar *dptr = (uchar*)bitmap->DataAddress();
+ Mem::Copy(dptr, sptr, source.byteCount());
+
+ bitmap->EndDataAccess();
+ } else {
+ delete bitmap;
+ bitmap = 0;
+ }
+ }
+
+ return reinterpret_cast<void*>(bitmap);
+ }
+ return 0;
+}
+
+QSymbianVGFontGlyphCache::QSymbianVGFontGlyphCache() : QVGFontGlyphCache()
+{
+#ifdef QT_SYMBIAN_HARDWARE_GLYPH_CACHE
+ invertedGlyphs = true;
+#endif
+}
+
+void QSymbianVGFontGlyphCache::cacheGlyphs(QVGPaintEnginePrivate *d,
+ QFontEngine *fontEngine,
+ const glyph_t *g, int count)
+{
+#ifdef QT_SYMBIAN_HARDWARE_GLYPH_CACHE
+ QFontEngineS60 *s60fontEngine = static_cast<QFontEngineS60*>(fontEngine);
+ if (s60fontEngine->m_activeFont->TypeUid() != KCFbsFontUid)
+ return QVGFontGlyphCache::cacheGlyphs(d, fontEngine, g, count);
+
+ QVector<glyph_t> uncachedGlyphs;
+ while (count-- > 0) {
+ // Skip this glyph if we have already cached it before.
+ glyph_t glyph = *g++;
+ if (((glyph < 256) && ((cachedGlyphsMask[glyph / 32] & (1 << (glyph % 32))) != 0))
+ || cachedGlyphs.contains(glyph))
+ continue;
+ if (!uncachedGlyphs.contains(glyph))
+ uncachedGlyphs.append(glyph);
+ }
+
+ if (!uncachedGlyphs.isEmpty()) {
+ CFbsFont *cfbsFont = static_cast<CFbsFont *>(s60fontEngine->m_activeFont);
+ RFbsGlyphDataIterator iter;
+
+ int err = iter.Open(*cfbsFont, (const unsigned int*)uncachedGlyphs.constData(), uncachedGlyphs.count());
+
+ if (err == KErrNotSupported || err == KErrInUse) { // Fallback in possibly supported error cases
+ iter.Close();
+ qWarning("Falling back to default QVGFontGlyphCache");
+ return QVGFontGlyphCache::cacheGlyphs(d, fontEngine, g, count);
+ }
+
+ for (; err == KErrNone; err = iter.Next()) {
+ const unsigned int glyph = iter.GlyphCode();
+
+ const RSgImage& image = iter.Image();
+ const TOpenFontCharMetrics& metrics = iter.Metrics();
+
+ TRect glyphBounds;
+ metrics.GetHorizBounds(glyphBounds);
+ VGImage vgImage = sgImageToVGImage(0, image);
+ VGfloat origin[2];
+ VGfloat escapement[2];
+ origin[0] = -glyphBounds.iTl.iX;
+ origin[1] = glyphBounds.iBr.iY;
+ escapement[0] = 0;
+ escapement[1] = 0;
+ vgSetGlyphToImage(font, glyph, vgImage, origin, escapement);
+ vgDestroyImage(vgImage);
+
+ // Add to cache
+ if (glyph < 256)
+ cachedGlyphsMask[glyph / 32] |= (1 << (glyph % 32));
+ else
+ cachedGlyphs.insert(glyph);
+ }
+ iter.Close();
+
+ if (err == KErrNoMemory || err == KErrNoGraphicsMemory)
+ qWarning("Not enough memory to cache glyph");
+ else if (err != KErrNotFound)
+ qWarning("Received error %d from glyph cache", err);
+ }
+#else
+ QVGFontGlyphCache::cacheGlyphs(d, fontEngine, g, count);
+#endif
+}
+
+QT_END_NAMESPACE
diff --git a/src/openvg/qvgfontglyphcache_p.h b/src/openvg/qvgfontglyphcache_p.h
new file mode 100644
index 0000000..b32a873
--- /dev/null
+++ b/src/openvg/qvgfontglyphcache_p.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenVG module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QVGFONTGLYPHCACHE_H
+#define QVGFONTGLYPHCACHE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qvarlengtharray.h>
+#include <QtGui/private/qfontengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QVGPaintEnginePrivate;
+
+class QVGFontGlyphCache
+{
+public:
+ QVGFontGlyphCache();
+ virtual ~QVGFontGlyphCache();
+
+ virtual void cacheGlyphs(QVGPaintEnginePrivate *d,
+ QFontEngine *fontEngine,
+ const glyph_t *g, int count);
+ void setScaleFromText(const QFont &font, QFontEngine *fontEngine);
+
+ VGFont font;
+ VGfloat scaleX;
+ VGfloat scaleY;
+ bool invertedGlyphs;
+ uint cachedGlyphsMask[256 / 32];
+ QSet<glyph_t> cachedGlyphs;
+};
+
+#if defined(Q_OS_SYMBIAN)
+class QSymbianVGFontGlyphCache : public QVGFontGlyphCache
+{
+public:
+ QSymbianVGFontGlyphCache();
+ void cacheGlyphs(QVGPaintEnginePrivate *d,
+ QFontEngine *fontEngine,
+ const glyph_t *g, int count);
+};
+#endif
+
+QT_END_NAMESPACE
+
+#endif // QVGFONTGLYPHCACHE_H
diff --git a/src/openvg/qwindowsurface_vg.cpp b/src/openvg/qwindowsurface_vg.cpp
index c19d5d1..55dcef3 100644
--- a/src/openvg/qwindowsurface_vg.cpp
+++ b/src/openvg/qwindowsurface_vg.cpp
@@ -47,7 +47,7 @@
#if !defined(QT_NO_EGL)
-#include <QtGui/private/qegl_p.h>
+#include <QtGui/private/qeglcontext_p.h>
#include <QtGui/private/qwidget_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp
index 99b614b..e3f52f4e 100644
--- a/src/openvg/qwindowsurface_vgegl.cpp
+++ b/src/openvg/qwindowsurface_vgegl.cpp
@@ -71,18 +71,13 @@ VGImageFormat qt_vg_config_to_vg_format(QEglContext *context)
QImage::Format qt_vg_config_to_image_format(QEglContext *context)
{
- EGLint red = 0;
- EGLint green = 0;
- EGLint blue = 0;
- EGLint alpha = 0;
- context->configAttrib(EGL_RED_SIZE, &red);
- context->configAttrib(EGL_GREEN_SIZE, &green);
- context->configAttrib(EGL_BLUE_SIZE, &blue);
- context->configAttrib(EGL_ALPHA_SIZE, &alpha);
+ EGLint red = context->configAttrib(EGL_RED_SIZE);
+ EGLint green = context->configAttrib(EGL_GREEN_SIZE);
+ EGLint blue = context->configAttrib(EGL_BLUE_SIZE);
+ EGLint alpha = context->configAttrib(EGL_ALPHA_SIZE);
QImage::Format argbFormat;
#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT
- EGLint type = 0;
- context->configAttrib(EGL_SURFACE_TYPE, &type);
+ EGLint type = context->configAttrib(EGL_SURFACE_TYPE);
if ((type & EGL_VG_ALPHA_FORMAT_PRE_BIT) != 0)
argbFormat = QImage::Format_ARGB32_Premultiplied;
else
@@ -210,11 +205,7 @@ void qt_vg_unregister_pixmap(QVGPixmapData *pd)
static bool isPremultipliedContext(const QEglContext *context)
{
- EGLint value = 0;
- if (context->configAttrib(EGL_SURFACE_TYPE, &value))
- return (value & EGL_VG_ALPHA_FORMAT_PRE_BIT) != 0;
- else
- return false;
+ return context->configAttrib(EGL_SURFACE_TYPE) & EGL_VG_ALPHA_FORMAT_PRE_BIT;
}
#endif
@@ -230,9 +221,9 @@ static QEglContext *createContext(QPaintDevice *device)
// Set the swap interval for the display.
QByteArray interval = qgetenv("QT_VG_SWAP_INTERVAL");
if (!interval.isEmpty())
- eglSwapInterval(QEglContext::display(), interval.toInt());
+ eglSwapInterval(QEgl::display(), interval.toInt());
else
- eglSwapInterval(QEglContext::display(), 1);
+ eglSwapInterval(QEgl::display(), 1);
#ifdef EGL_RENDERABLE_TYPE
// Has the user specified an explicit EGL configuration to use?
@@ -246,16 +237,16 @@ static QEglContext *createContext(QPaintDevice *device)
EGLint matching = 0;
EGLConfig cfg;
if (eglChooseConfig
- (QEglContext::display(), properties, &cfg, 1, &matching) &&
+ (QEgl::display(), properties, &cfg, 1, &matching) &&
matching > 0) {
// Check that the selected configuration actually supports OpenVG
// and then create the context with it.
EGLint id = 0;
EGLint type = 0;
eglGetConfigAttrib
- (QEglContext::display(), cfg, EGL_CONFIG_ID, &id);
+ (QEgl::display(), cfg, EGL_CONFIG_ID, &id);
eglGetConfigAttrib
- (QEglContext::display(), cfg, EGL_RENDERABLE_TYPE, &type);
+ (QEgl::display(), cfg, EGL_RENDERABLE_TYPE, &type);
if (cfgId == id && (type & EGL_OPENVG_BIT) != 0) {
context->setConfig(cfg);
if (!context->createContext()) {
@@ -334,7 +325,7 @@ static void qt_vg_destroy_shared_context(QVGSharedContext *shared)
shared->engine = 0;
shared->context->doneCurrent();
if (shared->surface != EGL_NO_SURFACE) {
- eglDestroySurface(QEglContext::display(), shared->surface);
+ eglDestroySurface(QEgl::display(), shared->surface);
shared->surface = EGL_NO_SURFACE;
}
delete shared->context;
@@ -412,7 +403,7 @@ EGLSurface qt_vg_shared_surface(void)
attribs[4] = EGL_NONE;
}
shared->surface = eglCreatePbufferSurface
- (QEglContext::display(), shared->context->config(), attribs);
+ (QEgl::display(), shared->context->config(), attribs);
}
return shared->surface;
}
@@ -555,7 +546,7 @@ void QVGEGLWindowSurfaceVGImage::beginPaint(QWidget *widget)
context->makeCurrent(mainSurface());
recreateBackBuffer = false;
if (backBufferSurface != EGL_NO_SURFACE) {
- eglDestroySurface(QEglContext::display(), backBufferSurface);
+ eglDestroySurface(QEgl::display(), backBufferSurface);
backBufferSurface = EGL_NO_SURFACE;
}
if (backBuffer != VG_INVALID_HANDLE) {
@@ -568,7 +559,7 @@ void QVGEGLWindowSurfaceVGImage::beginPaint(QWidget *widget)
if (backBuffer != VG_INVALID_HANDLE) {
// Create an EGL surface for rendering into the VGImage.
backBufferSurface = eglCreatePbufferFromClientBuffer
- (QEglContext::display(), EGL_OPENVG_IMAGE,
+ (QEgl::display(), EGL_OPENVG_IMAGE,
(EGLClientBuffer)(backBuffer),
context->config(), NULL);
if (backBufferSurface == EGL_NO_SURFACE) {
@@ -705,7 +696,7 @@ QEglContext *QVGEGLWindowSurfaceDirect::ensureContext(QWidget *widget)
#if defined(QVG_DIRECT_TO_WINDOW)
// Did we get a direct to window rendering surface?
EGLint buffer = 0;
- if (eglQueryContext(QEglContext::display(), context->context(),
+ if (eglQueryContext(QEgl::display(), context->context(),
EGL_RENDER_BUFFER, &buffer) &&
buffer == EGL_SINGLE_BUFFER) {
needToSwap = false;
@@ -719,7 +710,7 @@ QEglContext *QVGEGLWindowSurfaceDirect::ensureContext(QWidget *widget)
// Try to force the surface back buffer to preserve its contents.
if (needToSwap) {
eglGetError(); // Clear error state first.
- eglSurfaceAttrib(QEglContext::display(), windowSurface,
+ eglSurfaceAttrib(QEgl::display(), windowSurface,
EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
if (eglGetError() != EGL_SUCCESS) {
qWarning("QVG: could not enable preserved swap");
diff --git a/src/openvg/qwindowsurface_vgegl_p.h b/src/openvg/qwindowsurface_vgegl_p.h
index 892fd9d..fe62ed3 100644
--- a/src/openvg/qwindowsurface_vgegl_p.h
+++ b/src/openvg/qwindowsurface_vgegl_p.h
@@ -58,7 +58,7 @@
#if !defined(QT_NO_EGL)
-#include <QtGui/private/qegl_p.h>
+#include <QtGui/private/qeglcontext_p.h>
QT_BEGIN_NAMESPACE