Ticket #5606: 5606-qt4-port-v1.patch

File 5606-qt4-port-v1.patch, 10.6 KB (added by danielk, 17 years ago)

Beginnings of a Qt4 port of MHEG code

  • libs/libmythtv/dsmccobjcarousel.cpp

     
    6767
    6868    if (m_blocks[ddb->block_number] == NULL)
    6969    {   // We haven't seen this block before.
    70         QByteArray *block = new QByteArray;
    71         block->duplicate((char*) data, ddb->len);
     70        QByteArray *block = new QByteArray((const char*) data, ddb->len);
    7271        // Add this to our set of blocks.
    7372        m_blocks[ddb->block_number] = block;
    7473        m_receivedData += ddb->len;
  • libs/libmythtv/dsmcccache.h

     
    1818class DSMCCCacheKey: public QByteArray
    1919{
    2020  public:
     21    DSMCCCacheKey(const char *data, uint sz) : QByteArray(data, (int) sz) {}
    2122    DSMCCCacheKey() {}
    2223    QString toString(void) const;
    2324    // Operator used in < for DSMCCCacheReference
  • libs/libmythtv/dsmcccache.cpp

     
    199199// Add a file to the directory.
    200200void DSMCCCache::AddFileInfo(DSMCCCacheDir *pDir, const BiopBinding *pBB)
    201201{
    202     QString name;
    203     name.setAscii(pBB->m_name.m_comps[0].m_id
    204                   /*, pBB->m_name.m_comps[0].m_id_len*/);
     202    QString name = QString::fromAscii(pBB->m_name.m_comps[0].m_id);
    205203
    206204    const DSMCCCacheReference *entry =
    207205        pBB->m_ior.m_profile_body->GetReference();
     
    217215void DSMCCCache::AddDirInfo(DSMCCCacheDir *pDir, const BiopBinding *pBB)
    218216{
    219217    // Is it already there?
    220     QString name;
    221     name.setAscii(pBB->m_name.m_comps[0].m_id
    222                   /*, pBB->m_name.m_comps[0].m_id_len*/);
     218    QString name =  QString::fromAscii(pBB->m_name.m_comps[0].m_id);
    223219    const DSMCCCacheReference *entry =
    224220        pBB->m_ior.m_profile_body->GetReference();
    225221
  • libs/libmythtv/mhi.h

     
    1818#include <QString>
    1919#include <QWaitCondition>
    2020#include <QImage>
     21
     22#ifdef QT3_SUPPORT
    2123#include <q3pointarray.h>
     24#endif
    2225
    2326// MythTV headers
    2427#include "../libmythfreemheg/freemheg.h"
     
    288291    virtual void DrawOval(int x, int y, int width, int height);
    289292    virtual void DrawArcSector(int x, int y, int width, int height,
    290293                               int start, int arc, bool isSector);
     294#ifdef QT3_SUPPORT
    291295    virtual void DrawPoly(bool isFilled, const Q3PointArray &points);
     296#else
     297    virtual void DrawPoly(bool isFilled, const QPolygon &points);
     298#endif
    292299
    293300  protected:
    294301    void DrawRect(int x, int y, int width, int height, MHRgba colour);
  • libs/libmythtv/dsmccbiop.cpp

     
    173173                       (buf[off + 2] << 8)  | (buf[off + 3]));
    174174    off += 4;
    175175    uint nObjLen = buf[off++];
    176     m_objkey.duplicate((const char*)buf + off, nObjLen);
     176    m_objkey = DSMCCCacheKey((const char*)buf + off, nObjLen);
    177177    off += nObjLen;
    178178    m_objkind_len = ((buf[off + 0] << 24) | (buf[off + 1] << 16) |
    179179                     (buf[off + 2] << 8)  | (buf[off + 3]));
     
    277277    DSMCCCacheReference ref(cachep->CarouselId(), cachep->ModuleId(),
    278278                            cachep->StreamId(), m_objkey);
    279279
    280     QByteArray filedata;
    281     filedata.duplicate((const char *)data+(*curp), content_len);
     280    QByteArray filedata = QByteArray((const char *)(data+(*curp)), content_len);
    282281    filecache->CacheFileData(ref, filedata);
    283282
    284283    (*curp) += content_len;
     
    416415    version_major = data[off++];
    417416    version_minor = data[off++];
    418417    uint objKeyLen = data[off++]; /* <= 4 */
    419     m_Reference.m_Key.duplicate((char*)data + off, objKeyLen);
     418    m_Reference.m_Key = DSMCCCacheKey((const char*)data + off, objKeyLen);
    420419    off += objKeyLen;
    421420    return off;
    422421}
  • libs/libmythtv/mhi.cpp

     
    11#include <unistd.h>
    22
     3#include <QPainter>
    34#include <QRegion>
    45#include <qbitarray.h>
    56
    6 #include <Q3MemArray>
     7#ifdef QT3_SUPPORT
     8#include <q3memarray.h>
     9#endif
    710
    811#include "mhi.h"
    912#include "osd.h"
     
    847850                GetHeight() / MHIContext::StdDisplayHeight,
    848851                Qt::IgnoreAspectRatio,
    849852                Qt::SmoothTransformation);
    850         AddToDisplay(q_scaled.convertDepth(32),
     853        AddToDisplay(q_scaled.convertToFormat(QImage::Format_RGB32),
    851854                     x * GetWidth() / MHIContext::StdDisplayWidth,
    852855                     y * GetHeight() / MHIContext::StdDisplayHeight);
    853856    }
    854857    else if (!displayRect.isEmpty())
    855858    { // We must clip the image.
    856         QImage clipped = qImage.convertDepth(32)
     859        QImage clipped = qImage.convertToFormat(QImage::Format_RGB32)
    857860            .copy(displayRect.x() - x, displayRect.y() - y,
    858861                  displayRect.width(), displayRect.height());
    859862        QImage q_scaled =
     
    876879// the screen that is not covered with other visibles.
    877880void MHIContext::DrawBackground(const QRegion &reg)
    878881{
    879     if (reg.isNull() || reg.isEmpty())
     882    if (reg.isEmpty())
    880883        return;
    881884
    882885    QRect bounds = reg.boundingRect();
     
    13131316void MHIDLA::DrawOval(int x, int y, int width, int height)
    13141317{
    13151318    // Simple but inefficient way of drawing a ellipse.
     1319
     1320#ifndef QT3_SUPPORT
     1321    QPolygon ellipse;
     1322#   warning MHEG not supported with Qt4
     1323#else
    13161324    Q3PointArray ellipse;
    13171325    ellipse.makeEllipse(x, y, width, height);
     1326#endif
     1327
    13181328    DrawPoly(true, ellipse);
    13191329}
    13201330
     
    13221332void MHIDLA::DrawArcSector(int x, int y, int width, int height,
    13231333                           int start, int arc, bool isSector)
    13241334{
    1325     Q3PointArray points;
    13261335    // MHEG and Qt both measure arcs as angles anticlockwise from
    13271336    // the 3 o'clock position but MHEG uses 64ths of a degree
    13281337    // whereas Qt uses 16ths.
     1338
     1339#ifndef QT3_SUPPORT
     1340    QPolygon points;
     1341#   warning MHEG not supported with Qt4
     1342#else
     1343    Q3PointArray points;
    13291344    points.makeArc(x, y, width, height, start/4, arc/4);
     1345#endif
     1346
    13301347    if (isSector)
    13311348    {
    13321349        // Have to add the centre as a point and fill the figure.
     
    13441361// a result of rounding when drawing ellipses.
    13451362typedef struct { int yBottom, yTop, xBottom; float slope; } lineSeg;
    13461363
     1364#ifndef QT3_SUPPORT
     1365void MHIDLA::DrawPoly(bool isFilled, const QPolygon &points)
     1366#else
    13471367void MHIDLA::DrawPoly(bool isFilled, const Q3PointArray &points)
     1368#endif
    13481369{
    13491370    int nPoints = points.size();
    13501371    if (nPoints < 2)
    13511372        return;
    13521373
     1374#ifndef QT3_SUPPORT
     1375#warning MHEG not supported with Qt4
     1376#else
    13531377    if (isFilled)
    13541378    {
    13551379        Q3MemArray <lineSeg> lineArray(nPoints);
     
    14321456            DrawLine(points[i].x(), points[i].y(), points[i-1].x(), points[i-1].y());
    14331457        }
    14341458    }
     1459#endif // QT3_SUPPORT
    14351460}
    14361461
    14371462
     
    14441469        // Construct an image the size of the bounding box and tile the
    14451470        // bitmap over this.
    14461471        QImage tiledImage = QImage(rect.width(), rect.height(),
    1447                                    m_image.depth());
     1472                                   m_image.format());
    14481473
    14491474        for (int i = 0; i < rect.width(); i += m_image.width())
    14501475        {
    14511476            for (int j = 0; j < rect.height(); j += m_image.height())
    14521477            {
    1453                 bitBlt( &tiledImage, i, j, &m_image, 0, 0, -1, -1, (Qt::ImageConversionFlags)0);
     1478                if (tiledImage.isNull() || m_image.isNull())
     1479                    continue;
     1480                QPainter p(&tiledImage);
     1481                p.drawImage(QPoint(i,j), m_image, QRect(0,0,-1,-1),
     1482                            (Qt::ImageConversionFlags)0);
    14541483            }
    14551484        }
    14561485        m_parent->DrawImage(rect.x(), rect.y(), rect, tiledImage);
     
    14641493// Create a bitmap from PNG.
    14651494void MHIBitmap::CreateFromPNG(const unsigned char *data, int length)
    14661495{
    1467     m_image.reset();
     1496    m_image = QImage();
    14681497
    14691498    if (!m_image.loadFromData(data, length, "PNG"))
    14701499    {
    1471         m_image.reset();
     1500        m_image = QImage();
    14721501        return;
    14731502    }
    14741503
    14751504    // Assume that if it has an alpha buffer then it's partly transparent.
    1476     m_opaque = ! m_image.hasAlphaBuffer();
     1505    bool can_be_transparent =
     1506        QImage::Format_ARGB32                 == m_image.format() ||
     1507        QImage::Format_ARGB32_Premultiplied   == m_image.format();
     1508    #if QT_VERSION >= 0x040400
     1509    can_be_transparent |=
     1510        QImage::Format_ARGB8565_Premultiplied == m_image.format() ||
     1511        QImage::Format_ARGB8555_Premultiplied == m_image.format() ||
     1512        QImage::Format_ARGB6666_Premultiplied == m_image.format() ||
     1513        QImage::Format_ARGB4444_Premultiplied == m_image.format();
     1514    #endif
     1515    m_opaque = !can_be_transparent;
    14771516}
    14781517
    14791518// Convert an MPEG I-frame into a bitmap.  This is used as the way of
     
    14871526    AVFrame *picture = NULL;
    14881527    uint8_t *buff = NULL, *buffPtr;
    14891528    int gotPicture = 0, len;
    1490     m_image.reset();
     1529    m_image = QImage();
    14911530
    14921531    // Find the mpeg2 video decoder.
    14931532    AVCodec *codec = avcodec_find_decoder(CODEC_ID_MPEG2VIDEO);
     
    15791618
    15801619    if (newWidth <= 0 || newHeight <= 0)
    15811620    { // This would be a bit silly but handle it anyway.
    1582         m_image.reset();
     1621        m_image = QImage();
    15831622        return;
    15841623    }
    15851624
  • libs/libmythfreemheg/freemheg.h

     
    2323#define FREEMHEG_H
    2424
    2525#include <qregion.h>
    26 #include <Q3PointArray>
    2726#include <stdio.h>
    2827#include <stdlib.h>
     28#ifdef QT3_SUPPORT
     29#include <q3pointarray.h>
     30#endif
    2931
    3032class MHDLADisplay;
    3133class MHTextDisplay;
     
    159161    virtual void DrawBorderedRectangle(int x, int y, int width, int height) = 0;
    160162    virtual void DrawOval(int x, int y, int width, int height) = 0;
    161163    virtual void DrawArcSector(int x, int y, int width, int height, int start, int arc, bool isSector) = 0;
     164
     165#ifdef QT3_SUPPORT
    162166    virtual void DrawPoly(bool isFilled, const Q3PointArray &points) = 0;
     167#else
     168    virtual void DrawPoly(bool isFilled, const QPolygon &points) = 0;
     169#endif
     170
    163171};
    164172
    165173class MHTextDisplay {