diff options
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qcolor.cpp | 4 | ||||
-rw-r--r-- | src/gui/painting/qgraphicssystemex_symbian.cpp | 107 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 8 | ||||
-rw-r--r-- | src/gui/painting/qpaintengineex.cpp | 12 | ||||
-rw-r--r-- | src/gui/painting/qpainter.cpp | 16 | ||||
-rw-r--r-- | src/gui/painting/qrasterizer.cpp | 10 | ||||
-rw-r--r-- | src/gui/painting/qtessellator.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qwindowsurface_raster.cpp | 5 |
8 files changed, 122 insertions, 42 deletions
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 3d895b7753..2fe68a8e58 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -1578,7 +1578,7 @@ QColor QColor::toRgb() const } // chromatic case - const qreal h = ct.ahsv.hue == 36000 ? 0 : ct.ahsv.hue / 6000.; + const qreal h = ct.ahsv.hue == 36000 ? 0 : ct.ahsv.hue / qreal(6000.); const qreal s = ct.ahsv.saturation / qreal(USHRT_MAX); const qreal v = ct.ahsv.value / qreal(USHRT_MAX); const int i = int(h); @@ -1638,7 +1638,7 @@ QColor QColor::toRgb() const color.ct.argb.red = color.ct.argb.green = color.ct.argb.blue = 0; } else { // chromatic case - const qreal h = ct.ahsl.hue == 36000 ? 0 : ct.ahsl.hue / 36000.; + const qreal h = ct.ahsl.hue == 36000 ? 0 : ct.ahsl.hue / qreal(36000.); const qreal s = ct.ahsl.saturation / qreal(USHRT_MAX); const qreal l = ct.ahsl.lightness / qreal(USHRT_MAX); diff --git a/src/gui/painting/qgraphicssystemex_symbian.cpp b/src/gui/painting/qgraphicssystemex_symbian.cpp index 4469704668..32e040fdc8 100644 --- a/src/gui/painting/qgraphicssystemex_symbian.cpp +++ b/src/gui/painting/qgraphicssystemex_symbian.cpp @@ -46,31 +46,108 @@ #include <e32property.h> +#ifdef Q_SYMBIAN_SUPPORTS_SURFACES +#include "private/qegl_p.h" +#endif + QT_BEGIN_NAMESPACE static bool bcm2727Initialized = false; static bool bcm2727 = false; +#ifdef Q_SYMBIAN_SUPPORTS_SURFACES +typedef EGLBoolean (*NOK_resource_profiling)(EGLDisplay, EGLint, EGLint*, EGLint, EGLint*); +#define EGL_PROF_TOTAL_MEMORY_NOK 0x3070 +#endif + +// Detect if Qt is running on BCM2727 chip. +// BCM2727 is a special case on Symbian because +// it has only 32MB GPU memory which exposes +// significant limitations to hw accelerated UI. bool QSymbianGraphicsSystemEx::hasBCM2727() { if (bcm2727Initialized) return bcm2727; - const TUid KIvePropertyCat = {0x2726beef}; - enum TIvePropertyChipType { - EVCBCM2727B1 = 0x00000000, - EVCBCM2763A0 = 0x04000100, - EVCBCM2763B0 = 0x04000102, - EVCBCM2763C0 = 0x04000103, - EVCBCM2763C1 = 0x04000104, - EVCBCMUnknown = 0x7fffffff - }; - - TInt chipType = EVCBCMUnknown; - if (RProperty::Get(KIvePropertyCat, 0, chipType) == KErrNone) { - if (chipType == EVCBCM2727B1) +#ifdef Q_SYMBIAN_SUPPORTS_SURFACES + EGLDisplay display = QEgl::display(); +#if 1 + // Hacky but fast ~0ms. + const char* vendor = eglQueryString(display, EGL_VENDOR); + if (strstr(vendor, "Broadcom")) { + const TUid KIvePropertyCat = {0x2726beef}; + enum TIvePropertyChipType { + EVCBCM2727B1 = 0x00000000, + EVCBCM2763A0 = 0x04000100, + EVCBCM2763B0 = 0x04000102, + EVCBCM2763C0 = 0x04000103, + EVCBCM2763C1 = 0x04000104, + EVCBCMUnknown = 0x7fffffff + }; + + // Broadcom driver publishes KIvePropertyCat PS key on + // devices which are running on BCM2727 chip and post Anna Symbian. + TInt chipType = EVCBCMUnknown; + if (RProperty::Get(KIvePropertyCat, 0, chipType) == KErrNone) { + if (chipType == EVCBCM2727B1) + bcm2727 = true; + } else if (QSysInfo::symbianVersion() <= QSysInfo::SV_SF_3) { + // Device is running on Symbian Anna or older Symbian^3 in which + // KIvePropertyCat is not published. These ones are always 32MB devices. + bcm2727 = true; + } else { + // We have some other Broadcom chip on post Anna Symbian. + // Should have > 32MB GPU memory. + } + } +#else + // Fool proof but takes 15-20ms and we don't want this delay on app startup... + + // All devices with <= 32MB GPU memory should be + // dealed in similar manner to BCM2727 + // So let's query max GPU memory amount. + NOK_resource_profiling eglQueryProfilingData = (NOK_resource_profiling)eglGetProcAddress("eglQueryProfilingDataNOK"); + if (eglQueryProfilingData) { + EGLint dataCount; + eglQueryProfilingData(display, + EGL_PROF_QUERY_GLOBAL_BIT_NOK | + EGL_PROF_QUERY_MEMORY_USAGE_BIT_NOK, + NULL, + 0, + (EGLint*)&dataCount); + + // Allocate room for the profiling data + EGLint* profData = (EGLint*)malloc(dataCount * sizeof(EGLint)); + memset(profData,0,dataCount * sizeof(EGLint)); + + // Retrieve the profiling data + eglQueryProfilingData(display, + EGL_PROF_QUERY_GLOBAL_BIT_NOK | + EGL_PROF_QUERY_MEMORY_USAGE_BIT_NOK, + profData, + dataCount, + (EGLint*)&dataCount); + + int totalMemory; + EGLint i = 0; + while (profData && i < dataCount) { + switch (profData[i++]) { + case EGL_PROF_TOTAL_MEMORY_NOK: + totalMemory = profData[i++]; + break; + default: + i++; + } + } + + // ok, hasBCM2727() naming is a bit misleading but Qt must + // behave the same on all chips like BCM2727 (<= 32MB GPU memory) + // and our code (and others) are already using this function. + if (totalMemory <= 33554432) bcm2727 = true; } +#endif +#endif // Q_SYMBIAN_SUPPORTS_SURFACES bcm2727Initialized = true; @@ -80,7 +157,9 @@ bool QSymbianGraphicsSystemEx::hasBCM2727() void QSymbianGraphicsSystemEx::releaseCachedGpuResources() { // Do nothing here - // This is implemented in graphics system specific plugin + + // This virtual function should be implemented in graphics system specific + // plugin } void QSymbianGraphicsSystemEx::releaseAllGpuResources() diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index bcc5f9d9b7..0fea2daf08 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1649,8 +1649,8 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) if (lines[i].p1() == lines[i].p2()) { if (s->lastPen.capStyle() != Qt::FlatCap) { QPointF p = lines[i].p1(); - QLineF line = s->matrix.map(QLineF(QPointF(p.x() - width*0.5, p.y()), - QPointF(p.x() + width*0.5, p.y()))); + QLineF line = s->matrix.map(QLineF(QPointF(p.x() - width*qreal(0.5), p.y()), + QPointF(p.x() + width*qreal(0.5), p.y()))); d->rasterizer->rasterizeLine(line.p1(), line.p2(), 1); } continue; @@ -5117,7 +5117,7 @@ static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip, { const qreal a = qreal(rect.width()) / 2; const qreal b = qreal(rect.height()) / 2; - qreal d = b*b - (a*a*b) + 0.25*a*a; + qreal d = b*b - (a*a*b) + qreal(0.25)*a*a; int x = 0; int y = (rect.height() + 1) / 2; @@ -5140,7 +5140,7 @@ static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip, pen_func, brush_func, pen_data, brush_data); // region 2 - d = b*b*(x + 0.5)*(x + 0.5) + a*a*((y - 1)*(y - 1) - b*b); + d = b*b*(x + qreal(0.5))*(x + qreal(0.5)) + a*a*((y - 1)*(y - 1) - b*b); const int miny = rect.height() & 0x1; while (y > miny) { if (d < 0) { // select SE diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 6df410b27d..eaedc4c8b4 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -748,8 +748,8 @@ void QPaintEngineEx::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yR qreal y2 = rect.bottom(); if (mode == Qt::RelativeSize) { - xRadius = xRadius * rect.width() / 200.; - yRadius = yRadius * rect.height() / 200.; + xRadius = xRadius * rect.width() / qreal(200.); + yRadius = yRadius * rect.height() / qreal(200.); } xRadius = qMin(xRadius, rect.width() / 2); @@ -863,7 +863,7 @@ void QPaintEngineEx::drawPoints(const QPointF *points, int pointCount) for (int i=0; i<count; ++i) { pts[++oset] = points[i].x(); pts[++oset] = points[i].y(); - pts[++oset] = points[i].x() + 1/63.; + pts[++oset] = points[i].x() + 1/qreal(63.); pts[++oset] = points[i].y(); } QVectorPath path(pts, count * 2, qpaintengineex_line_types_16, QVectorPath::LinesHint); @@ -873,7 +873,7 @@ void QPaintEngineEx::drawPoints(const QPointF *points, int pointCount) } } else { for (int i=0; i<pointCount; ++i) { - qreal pts[] = { points[i].x(), points[i].y(), points[i].x() + 1/63., points[i].y() }; + qreal pts[] = { points[i].x(), points[i].y(), points[i].x() + 1/qreal(63.), points[i].y() }; QVectorPath path(pts, 2, 0); stroke(path, pen); } @@ -894,7 +894,7 @@ void QPaintEngineEx::drawPoints(const QPoint *points, int pointCount) for (int i=0; i<count; ++i) { pts[++oset] = points[i].x(); pts[++oset] = points[i].y(); - pts[++oset] = points[i].x() + 1/63.; + pts[++oset] = points[i].x() + 1/qreal(63.); pts[++oset] = points[i].y(); } QVectorPath path(pts, count * 2, qpaintengineex_line_types_16, QVectorPath::LinesHint); @@ -905,7 +905,7 @@ void QPaintEngineEx::drawPoints(const QPoint *points, int pointCount) } else { for (int i=0; i<pointCount; ++i) { qreal pts[] = { qreal(points[i].x()), qreal(points[i].y()), - qreal(points[i].x() +1/63.), qreal(points[i].y()) }; + qreal(points[i].x() +1/qreal(63.)), qreal(points[i].y()) }; QVectorPath path(pts, 2, 0); stroke(path, pen); } diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index efb016e9e2..fb5ce96ec7 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -403,8 +403,8 @@ void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperatio QPainterPath stroke = stroker.createStroke(originalPath); strokeBounds = (stroke * state->matrix).boundingRect(); } else { - strokeOffsetX = qAbs(penWidth * state->matrix.m11() / 2.0); - strokeOffsetY = qAbs(penWidth * state->matrix.m22() / 2.0); + strokeOffsetX = qAbs(penWidth * state->matrix.m11() / qreal(2.0)); + strokeOffsetY = qAbs(penWidth * state->matrix.m22() / qreal(2.0)); } } } @@ -4460,8 +4460,8 @@ void QPainter::drawArc(const QRectF &r, int a, int alen) QRectF rect = r.normalized(); QPainterPath path; - path.arcMoveTo(rect, a/16.0); - path.arcTo(rect, a/16.0, alen/16.0); + path.arcMoveTo(rect, a/qreal(16.0)); + path.arcTo(rect, a/qreal(16.0), alen/qreal(16.0)); strokePath(path, d->state->pen); } @@ -4531,7 +4531,7 @@ void QPainter::drawPie(const QRectF &r, int a, int alen) QPainterPath path; path.moveTo(rect.center()); - path.arcTo(rect.x(), rect.y(), rect.width(), rect.height(), a/16.0, alen/16.0); + path.arcTo(rect.x(), rect.y(), rect.width(), rect.height(), a/qreal(16.0), alen/qreal(16.0)); path.closeSubpath(); drawPath(path); @@ -4592,8 +4592,8 @@ void QPainter::drawChord(const QRectF &r, int a, int alen) QRectF rect = r.normalized(); QPainterPath path; - path.arcMoveTo(rect, a/16.0); - path.arcTo(rect, a/16.0, alen/16.0); + path.arcMoveTo(rect, a/qreal(16.0)); + path.arcTo(rect, a/qreal(16.0), alen/qreal(16.0)); path.closeSubpath(); drawPath(path); } @@ -9242,7 +9242,7 @@ void QPainter::drawPixmapFragments(const PixmapFragment *fragments, int fragment qreal h = fragments[i].scaleY * fragments[i].height; QRectF sourceRect(fragments[i].sourceLeft, fragments[i].sourceTop, fragments[i].width, fragments[i].height); - drawPixmap(QRectF(-0.5 * w + xOffset, -0.5 * h + yOffset, w, h), pixmap, sourceRect); + drawPixmap(QRectF(qreal(-0.5) * w + xOffset, qreal(-0.5) * h + yOffset, w, h), pixmap, sourceRect); } setOpacity(oldOpacity); diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index 1d3f581b88..ca10e6aa68 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -51,8 +51,8 @@ QT_BEGIN_NAMESPACE typedef int Q16Dot16; -#define Q16Dot16ToFloat(i) ((i)/65536.) -#define FloatToQ16Dot16(i) (int)((i) * 65536.) +#define Q16Dot16ToFloat(i) ((i)/qreal(65536.)) +#define FloatToQ16Dot16(i) (int)((i) * qreal(65536.)) #define IntToQ16Dot16(i) ((i) << 16) #define Q16Dot16ToInt(i) ((i) >> 16) #define Q16Dot16Factor 65536 @@ -701,7 +701,7 @@ static Q16Dot16 intersectPixelFP(int x, Q16Dot16 top, Q16Dot16 bottom, Q16Dot16 static inline bool q26Dot6Compare(qreal p1, qreal p2) { - return int((p2 - p1) * 64.) == 0; + return int((p2 - p1) * qreal(64.)) == 0; } static inline qreal qFloorF(qreal v) @@ -1210,8 +1210,8 @@ void QRasterizer::rasterize(const QPainterPath &path, Qt::FillRule fillRule) QRectF bounds = path.controlPointRect(); - int iTopBound = qMax(d->clipRect.top(), int(bounds.top() + 0.5 + (COORD_OFFSET - COORD_ROUNDING)/64.)); - int iBottomBound = qMin(d->clipRect.bottom(), int(bounds.bottom() - 0.5 + (COORD_OFFSET - COORD_ROUNDING)/64.)); + int iTopBound = qMax(d->clipRect.top(), int(bounds.top() + qreal(0.5) + (COORD_OFFSET - COORD_ROUNDING)/qreal(64.))); + int iBottomBound = qMin(d->clipRect.bottom(), int(bounds.bottom() - qreal(0.5) + (COORD_OFFSET - COORD_ROUNDING)/qreal(64.))); if (iTopBound > iBottomBound) return; diff --git a/src/gui/painting/qtessellator.cpp b/src/gui/painting/qtessellator.cpp index 94a5128d90..15e4f65469 100644 --- a/src/gui/painting/qtessellator.cpp +++ b/src/gui/painting/qtessellator.cpp @@ -1400,7 +1400,7 @@ void QTessellator::tessellateRect(const QPointF &a_, const QPointF &b_, qreal wi if (delta.x == 0 && delta.y == 0) return; - qreal hw = 0.5 * width; + qreal hw = qreal(0.5) * width; if (delta.x == 0) { Q27Dot5 halfWidth = FloatToQ27Dot5(hw); diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index 15ff044977..2a25bff712 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -254,8 +254,9 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi } else #endif { + int depth = widget->x11Info().depth(); const QImage &src = d->image->image; - if (src.format() != QImage::Format_RGB32 || widget->x11Info().depth() < 24) { + if (src.format() != QImage::Format_RGB32 || depth < 24 || X11->bppForDepth.value(depth) != 32) { Q_ASSERT(src.depth() >= 16); const QImage sub_src(src.scanLine(br.y()) + br.x() * (uint(src.depth()) / 8), br.width(), br.height(), src.bytesPerLine(), src.format()); @@ -267,7 +268,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi } else { // qpaintengine_x11.cpp extern void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const QImage &image, Drawable hd, GC gc, Display *dpy, Visual *visual, int depth); - qt_x11_drawImage(br, wpos, src, widget->handle(), d_ptr->gc, X11->display, (Visual *)widget->x11Info().visual(), widget->x11Info().depth()); + qt_x11_drawImage(br, wpos, src, widget->handle(), d_ptr->gc, X11->display, (Visual *)widget->x11Info().visual(), depth); } } |