Changeset 712


Ignore:
Timestamp:
Apr 27, 2010, 4:15:04 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Fixed widget painting in Dive mode when the screen color format is not 32-bit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/painting/qwindowsurface_pm.cpp

    r710 r712  
    4242****************************************************************************/
    4343
    44 #include "qt_os2.h"
    45 #include "qlibrary.h"
     44#include <qdebug.h>
     45
     46//#define QDIVE_DEBUG
     47
     48#if defined QDIVE_DEBUG
     49#define DEBUG(a) qDebug a
     50#define DEBUG_VAR(v) DEBUG(() << #v << v)
     51#define DEBUG_VAR_HEX(v) DEBUG(() << #v << qDebugFmtHex(v))
     52#else
     53#define DEBUG(a) do {} while(0)
     54#define DEBUG_VAR(v) do {} while(0)
     55#define DEBUG_VAR_HEX(v) do {} while(0)
     56#endif
     57
     58#include <qt_os2.h>
     59#include <qlibrary.h>
    4660
    4761#include "qwindowsurface_pm_p.h"
    4862#include "private/qnativeimage_p.h"
    49 
    50 #include "qdebug.h"
    5163
    5264////////////////////////////////////////////////////////////////////////////////
     
    7789#define DIVE_BUFFER_GRAPHICS_PLANE                       0x00000001
    7890#define DIVE_BUFFER_ALTERNATE_PLANE                      0x00000002
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
    79114
    80115typedef struct _SETUP_BLITTER {
     
    140175
    141176static
     177
     178
     179
     180
    142181ULONG (APIENTRY *DiveOpen) ( HDIVE *phDiveInst,
    143182                             BOOL   fNonScreenInstance,
     
    186225static struct { const char *name; void **entry; } diveDllFuncs[] =
    187226{
     227
    188228    FUNC_ENTRY(DiveOpen),
    189229    FUNC_ENTRY(DiveSetupBlitter),
     
    200240static bool diveDllOK = false;
    201241
     242
     243
    202244////////////////////////////////////////////////////////////////////////////////
    203245
    204246QT_BEGIN_NAMESPACE
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
    205279
    206280struct QPMDiveWindowSurfacePrivate
     
    235309    memset(&d->setup, 0, sizeof(SETUP_BLITTER));
    236310
    237     // Note that DiveBlitImage() seems to ignore fccSrcColorFormat and
    238     // fccSrcColorFormat which is not a big surprise because both values are
    239     // known (the source color format is specified at buffer creation time
    240     // and the screen color format is always known). Also note that specifying
    241     // values other than FOURCC_LUT8/R565/BGR3 causes a crash in DiveBlitImage()
    242     // no matter what the actual source format is. FOURCC_SCRN seems to work.
    243     d->setup.fccSrcColorFormat = FOURCC_SCRN;
     311    // note that fccSrcColorFormat overrides the value specified during the
     312    // source buffer creation, so they must match
     313    d->setup.fccSrcColorFormat = fourccScreenToBuffer(diveCaps.fccColorEncoding);
    244314    d->setup.fccDstColorFormat = FOURCC_SCRN;
    245315
     
    296366void QPMDiveWindowSurface::doFlush(const QRect &from, const QPoint &to)
    297367{
    298 #if 0
    299     qDebug() << "QPMDiveWindowSurface::doFlush:" << window()
    300              << "from" << from << "to" << to;
    301 #endif
     368    DEBUG(() << "QPMDiveWindowSurface::doFlush:" << window()
     369             << "from" << from << "to" << to);
    302370
    303371    // make sure from doesn't exceed the backing storage size (it may happen
     
    320388        d->setup.lScreenPosY = ptl.y;
    321389        d->setup.ulStructLen = offsetof(SETUP_BLITTER, ulNumDstRects);
     390
     391
     392
    322393    }
    323394
     
    353424        GpiDestroyRegion(hps, hrgn);
    354425        window()->releasePS(hps);
     426
     427
     428
     429
     430
     431
    355432    }
    356433
     
    441518        QImage *oldImage = d->image;
    442519
    443         d->image = new QImage(width, height, QImage::Format_RGB32);
     520        QImage::Format format = fourccToFormat(d->setup.fccSrcColorFormat);
     521        Q_ASSERT(format != QImage::Format_Invalid);
     522        d->image = new QImage(width, height, format);
    444523
    445524        // associate the image data pointer with the buffer number
    446525        DiveFreeImageBuffer(d->hDive, d->bufNum);
    447526        d->bufNum = 0;
    448         ULONG rc = DiveAllocImageBuffer(d->hDive, &d->bufNum, FOURCC_BGR4,
     527        ULONG rc = DiveAllocImageBuffer(d->hDive, &d->bufNum,
     528                                        d->setup.fccSrcColorFormat,
    449529                                        width, height,
    450530                                        d->image->bytesPerLine(),
    451531                                        (PBYTE)const_cast<const QImage *>(d->image)->bits());
    452 
    453532        if (rc != DIVE_SUCCESS) {
    454533            qWarning("QPMDiveWindowSurface::setGeometry: DiveAllocImageBuffer "
     
    528607            }
    529608        }
     609
     610
     611
     612
     613
     614
     615
     616
     617
     618
     619
     620
     621
     622
     623
     624
     625
     626
     627
     628
     629
     630
     631
     632
     633
     634
     635
     636
     637
     638
     639
     640
     641
    530642    }
    531643
Note: See TracChangeset for help on using the changeset viewer.