Changeset 769 for trunk/src/gui/painting


Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/painting/qbackingstore.cpp

    r651 r769  
    353353    dirtyOnScreen += toClean;
    354354
     355#ifdef Q_WS_QWS
     356    toClean.translate(tlwOffset);
     357#endif
     358
    355359#ifdef QT_NO_PAINT_DEBUG
    356360    windowSurface->beginPaint(toClean);
     
    767771        return;
    768772
    769     windowSurface->beginPaint(decorationRegion);
     773    //### The QWS decorations do not always paint the pixels they promise to paint.
     774    // This causes painting problems with QWSMemorySurface. Since none of the other
     775    // window surfaces actually use the region, passing an empty region is a safe
     776    // workaround.
     777
     778    windowSurface->beginPaint(QRegion());
    770779
    771780    QPaintEngine *engine = windowSurface->paintDevice()->paintEngine();
  • trunk/src/gui/painting/qbrush.cpp

    r651 r769  
    161161}
    162162
    163 Q_GUI_EXPORT
    164 QImage qt_imageForBrush(int brushStyle, bool invert)
     163Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert)
    165164{
    166165    return qt_brushPatternImageCache()->getImage(brushStyle, invert);
     
    990989     "RadialGradientPattern",
    991990     "ConicalGradientPattern",
    992      "TexturePattern"
     991     0, 0, 0, 0, 0, 0,
     992     "TexturePattern" // 24
    993993    };
    994994
  • trunk/src/gui/painting/qcups.cpp

    r651 r769  
    378378        return false;
    379379    const char *ppdFile = _cupsGetPPD(printerName);
    380     if (ppdFile != 0)
    381         unlink(ppdFile);
    382     return ppdFile != 0;
     380    unlink(ppdFile);
     381    return (ppdFile != 0);
    383382}
    384383
  • trunk/src/gui/painting/qdrawhelper.cpp

    r651 r769  
    12681268  d = d * cia
    12691269*/
     1270#define comp_func_Clear_impl(dest, length, const_alpha)\
     1271{\
     1272    if (const_alpha == 255) {\
     1273        QT_MEMFILL_UINT(dest, length, 0);\
     1274    } else {\
     1275        int ialpha = 255 - const_alpha;\
     1276        PRELOAD_INIT(dest)\
     1277        for (int i = 0; i < length; ++i) {\
     1278            PRELOAD_COND(dest)\
     1279            dest[i] = BYTE_MUL(dest[i], ialpha);\
     1280        }\
     1281    }\
     1282}
     1283
    12701284static void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha)
    12711285{
    1272     if (const_alpha == 255) {
    1273         QT_MEMFILL_UINT(dest, length, 0);
    1274     } else {
    1275         int ialpha = 255 - const_alpha;
    1276         PRELOAD_INIT(dest)
    1277         for (int i = 0; i < length; ++i) {
    1278             PRELOAD_COND(dest)
    1279             dest[i] = BYTE_MUL(dest[i], ialpha);
    1280         }
    1281     }
     1286    comp_func_Clear_impl(dest, length, const_alpha);
    12821287}
    12831288
    12841289static void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha)
    12851290{
    1286     if (const_alpha == 255) {
    1287         QT_MEMFILL_UINT(dest, length, 0);
    1288     } else {
    1289         int ialpha = 255 - const_alpha;
    1290         PRELOAD_INIT(dest)
    1291         for (int i = 0; i < length; ++i) {
    1292             PRELOAD_COND(dest)
    1293             dest[i] = BYTE_MUL(dest[i], ialpha);
    1294         }
    1295     }
     1291    comp_func_Clear_impl(dest, length, const_alpha);
    12961292}
    12971293
     
    24092405        return (dst * sa * 255 + da * (src2 - sa) * ((((16 * dst_np - 12 * 255) * dst_np + 3 * 65025) * dst_np) / 65025) + temp) / 65025;
    24102406    else {
     2407#   ifdef Q_CC_RVCT // needed to avoid compiler crash in RVCT 2.2
     2408        return (dst * sa * 255 + da * (src2 - sa) * (qIntSqrtInt(dst_np * 255) - dst_np) + temp) / 65025;
     2409#   else
    24112410        return (dst * sa * 255 + da * (src2 - sa) * (int(sqrt(qreal(dst_np * 255))) - dst_np) + temp) / 65025;
     2411#   endif
    24122412    }
    24132413}
     
    71757175
    71767176        int a = qGray(coverage);
    7177         sr = qt_div_255(sr * a);
    7178         sg = qt_div_255(sg * a);
    7179         sb = qt_div_255(sb * a);
     7177        sr = qt_div_255(qt_pow_rgb_invgamma[sr] * a);
     7178        sg = qt_div_255(qt_pow_rgb_invgamma[sg] * a);
     7179        sb = qt_div_255(qt_pow_rgb_invgamma[sb] * a);
    71807180
    71817181        int ia = 255 - a;
     
    80938093        }
    80948094#endif // 3DNOW
    8095         extern void qt_blend_rgb32_on_rgb32_sse(uchar *destPixels, int dbpl,
    8096                                                 const uchar *srcPixels, int sbpl,
    8097                                                 int w, int h,
    8098                                                 int const_alpha);
    8099         extern void qt_blend_argb32_on_argb32_sse(uchar *destPixels, int dbpl,
    8100                                                   const uchar *srcPixels, int sbpl,
    8101                                                   int w, int h,
    8102                                                   int const_alpha);
    8103 
    8104         qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse;
    8105         qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse;
    8106         qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse;
    8107         qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse;
    8108     }
     8095
     8096
     8097#ifdef QT_HAVE_SSE2
     8098        if (features & SSE2) {
     8099            extern void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl,
     8100                                                     const uchar *srcPixels, int sbpl,
     8101                                                     int w, int h,
     8102                                                     int const_alpha);
     8103            extern void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,
     8104                                                       const uchar *srcPixels, int sbpl,
     8105                                                       int w, int h,
     8106                                                       int const_alpha);
     8107
     8108
     8109            qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2;
     8110            qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2;
     8111            qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2;
     8112            qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2;
     8113        } else
     8114#endif
     8115        {
     8116            extern void qt_blend_rgb32_on_rgb32_sse(uchar *destPixels, int dbpl,
     8117                                                    const uchar *srcPixels, int sbpl,
     8118                                                    int w, int h,
     8119                                                    int const_alpha);
     8120            extern void qt_blend_argb32_on_argb32_sse(uchar *destPixels, int dbpl,
     8121                                                      const uchar *srcPixels, int sbpl,
     8122                                                      int w, int h,
     8123                                                      int const_alpha);
     8124
     8125
     8126            qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse;
     8127            qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse;
     8128            qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse;
     8129            qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse;
     8130        }
     8131}
    81098132#endif // SSE
    81108133
  • trunk/src/gui/painting/qdrawhelper_mmx_p.h

    r651 r769  
    147147  d = d * cia
    148148*/
     149#define comp_func_Clear_impl(dest, length, const_alpha)\
     150{\
     151    if (const_alpha == 255) {\
     152        qt_memfill(static_cast<quint32*>(dest), quint32(0), length);\
     153    } else {\
     154        C_FF; C_80; C_00;\
     155        m64 ia = MM::negate(MM::load_alpha(const_alpha));\
     156        for (int i = 0; i < length; ++i) {\
     157            dest[i] = MM::store(MM::byte_mul(MM::load(dest[i]), ia));\
     158        }\
     159        MM::end();\
     160    }\
     161}
     162
    149163template <class MM>
    150164static void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha)
    151165{
    152     if (!length)
    153         return;
    154 
    155     if (const_alpha == 255) {
    156         qt_memfill(static_cast<quint32*>(dest), quint32(0), length);
    157     } else {
    158         C_FF; C_80; C_00;
    159         m64 ia = MM::negate(MM::load_alpha(const_alpha));
    160         for (int i = 0; i < length; ++i) {
    161             dest[i] = MM::store(MM::byte_mul(MM::load(dest[i]), ia));
    162         }
    163     }
    164     MM::end();
     166    comp_func_Clear_impl(dest, length, const_alpha);
    165167}
    166168
     
    168170static void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha)
    169171{
    170     if (const_alpha == 255) {
    171         qt_memfill(static_cast<quint32*>(dest), quint32(0), length);
    172     } else {
    173         C_FF; C_80; C_00;
    174         m64 ia = MM::negate(MM::load_alpha(const_alpha));
    175         for (int i = 0; i < length; ++i)
    176             dest[i] = MM::store(MM::byte_mul(MM::load(dest[i]), ia));
    177     }
    178     MM::end();
     172    comp_func_Clear_impl(dest, length, const_alpha);
    179173}
    180174
     
    247241    if (const_alpha == 255) {
    248242        for (int i = 0; i < length; ++i) {
    249             if ((0xff000000 & src[i]) == 0xff000000) {
     243            const uint alphaMaskedSource = 0xff000000 & src[i];
     244            if (alphaMaskedSource == 0)
     245                continue;
     246            if (alphaMaskedSource == 0xff000000) {
    250247                dest[i] = src[i];
    251248            } else {
     
    258255        m64 ca = MM::load_alpha(const_alpha);
    259256        for (int i = 0; i < length; ++i) {
     257            if ((0xff000000 & src[i]) == 0)
     258                continue;
    260259            m64 s = MM::byte_mul(MM::load(src[i]), ca);
    261260            m64 ia = MM::negate(MM::alpha(s));
  • trunk/src/gui/painting/qdrawhelper_neon.cpp

    r651 r769  
    4949QT_BEGIN_NAMESPACE
    5050
    51 static inline int16x8_t qvdiv_255_s16(int16x8_t x, int16x8_t half)
     51static inline uint16x8_t qvdiv_255_u16(uint16x8_t x, uint16x8_t half)
    5252{
    5353    // result = (x + (x >> 8) + 0x80) >> 8
    5454
    55     const int16x8_t temp = vshrq_n_s16(x, 8); // x >> 8
    56     const int16x8_t sum_part = vaddq_s16(x, half); // x + 0x80
    57     const int16x8_t sum = vaddq_s16(temp, sum_part);
    58 
    59     return vreinterpretq_s16_u16(vshrq_n_u16(vreinterpretq_u16_s16(sum), 8));
    60 }
    61 
    62 static inline int16x8_t qvbyte_mul_s16(int16x8_t x, int16x8_t alpha, int16x8_t half)
     55    const uint16x8_t temp = vshrq_n_u16(x, 8); // x >> 8
     56    const uint16x8_t sum_part = vaddq_u16(x, half); // x + 0x80
     57    const uint16x8_t sum = vaddq_u16(temp, sum_part);
     58
     59    return vshrq_n_u16(sum, 8);
     60}
     61
     62static inline uint16x8_t qvbyte_mul_u16(uint16x8_t x, uint16x8_t alpha, uint16x8_t half)
    6363{
    6464    // t = qRound(x * alpha / 255.0)
    6565
    66     const int16x8_t t = vmulq_s16(x, alpha); // t
    67     return qvdiv_255_s16(t, half);
    68 }
    69 
    70 static inline int16x8_t qvinterpolate_pixel_255(int16x8_t x, int16x8_t a, int16x8_t y, int16x8_t b, int16x8_t half)
     66    const uint16x8_t t = vmulq_u16(x, alpha); // t
     67    return qvdiv_255_u16(t, half);
     68}
     69
     70static inline uint16x8_t qvinterpolate_pixel_255(uint16x8_t x, uint16x8_t a, uint16x8_t y, uint16x8_t b, uint16x8_t half)
    7171{
    7272    // t = x * a + y * b
    7373
    74     const int16x8_t ta = vmulq_s16(x, a);
    75     const int16x8_t tb = vmulq_s16(y, b);
    76 
    77     return qvdiv_255_s16(vaddq_s16(ta, tb), half);
    78 }
    79 
    80 static inline int16x8_t qvsource_over_s16(int16x8_t src16, int16x8_t dst16, int16x8_t half, int16x8_t full)
    81 {
    82     const int16x4_t alpha16_high = vdup_lane_s16(vget_high_s16(src16), 3);
    83     const int16x4_t alpha16_low = vdup_lane_s16(vget_low_s16(src16), 3);
    84 
    85     const int16x8_t alpha16 = vsubq_s16(full, vcombine_s16(alpha16_low, alpha16_high));
    86 
    87     return vaddq_s16(src16, qvbyte_mul_s16(dst16, alpha16, half));
     74    const uint16x8_t ta = vmulq_u16(x, a);
     75    const uint16x8_t tb = vmulq_u16(y, b);
     76
     77    return qvdiv_255_u16(vaddq_u16(ta, tb), half);
     78}
     79
     80static inline uint16x8_t qvsource_over_u16(uint16x8_t src16, uint16x8_t dst16, uint16x8_t half, uint16x8_t full)
     81{
     82    const uint16x4_t alpha16_high = vdup_lane_u16(vget_high_u16(src16), 3);
     83    const uint16x4_t alpha16_low = vdup_lane_u16(vget_low_u16(src16), 3);
     84
     85    const uint16x8_t alpha16 = vsubq_u16(full, vcombine_u16(alpha16_low, alpha16_high));
     86
     87    return vaddq_u16(src16, qvbyte_mul_u16(dst16, alpha16, half));
    8888}
    8989
     
    9595    const uint *src = (const uint *) srcPixels;
    9696    uint *dst = (uint *) destPixels;
    97     int16x8_t half = vdupq_n_s16(0x80);
    98     int16x8_t full = vdupq_n_s16(0xff);
     97    uint16x8_t half = vdupq_n_u16(0x80);
     98    uint16x8_t full = vdupq_n_u16(0xff);
    9999    if (const_alpha == 256) {
    100100        for (int y = 0; y < h; ++y) {
    101101            int x = 0;
    102102            for (; x < w-3; x += 4) {
    103                 int32x4_t src32 = vld1q_s32((int32_t *)&src[x]);
     103                uint32x4_t src32 = vld1q_u32((uint32_t *)&src[x]);
    104104                if ((src[x] & src[x+1] & src[x+2] & src[x+3]) >= 0xff000000) {
    105105                    // all opaque
    106                     vst1q_s32((int32_t *)&dst[x], src32);
     106                    vst1q_u32((uint32_t *)&dst[x], src32);
    107107                } else if (src[x] | src[x+1] | src[x+2] | src[x+3]) {
    108                     int32x4_t dst32 = vld1q_s32((int32_t *)&dst[x]);
    109 
    110                     const uint8x16_t src8 = vreinterpretq_u8_s32(src32);
    111                     const uint8x16_t dst8 = vreinterpretq_u8_s32(dst32);
     108                    uint32x4_t dst32 = vld1q_u32((uint32_t *)&dst[x]);
     109
     110                    const uint8x16_t src8 = vreinterpretq_u8_u32(src32);
     111                    const uint8x16_t dst8 = vreinterpretq_u8_u32(dst32);
    112112
    113113                    const uint8x8_t src8_low = vget_low_u8(src8);
     
    117117                    const uint8x8_t dst8_high = vget_high_u8(dst8);
    118118
    119                     const int16x8_t src16_low = vreinterpretq_s16_u16(vmovl_u8(src8_low));
    120                     const int16x8_t dst16_low = vreinterpretq_s16_u16(vmovl_u8(dst8_low));
    121 
    122                     const int16x8_t src16_high = vreinterpretq_s16_u16(vmovl_u8(src8_high));
    123                     const int16x8_t dst16_high = vreinterpretq_s16_u16(vmovl_u8(dst8_high));
    124 
    125                     const int16x8_t result16_low = qvsource_over_s16(src16_low, dst16_low, half, full);
    126                     const int16x8_t result16_high = qvsource_over_s16(src16_high, dst16_high, half, full);
    127 
    128                     const int32x2_t result32_low = vreinterpret_s32_s8(vmovn_s16(result16_low));
    129                     const int32x2_t result32_high = vreinterpret_s32_s8(vmovn_s16(result16_high));
    130 
    131                     vst1q_s32((int32_t *)&dst[x], vcombine_s32(result32_low, result32_high));
     119                    const uint16x8_t src16_low = vmovl_u8(src8_low);
     120                    const uint16x8_t dst16_low = vmovl_u8(dst8_low);
     121
     122                    const uint16x8_t src16_high = vmovl_u8(src8_high);
     123                    const uint16x8_t dst16_high = vmovl_u8(dst8_high);
     124
     125                    const uint16x8_t result16_low = qvsource_over_u16(src16_low, dst16_low, half, full);
     126                    const uint16x8_t result16_high = qvsource_over_u16(src16_high, dst16_high, half, full);
     127
     128                    const uint32x2_t result32_low = vreinterpret_u32_u8(vmovn_u16(result16_low));
     129                    const uint32x2_t result32_high = vreinterpret_u32_u8(vmovn_u16(result16_high));
     130
     131                    vst1q_u32((uint32_t *)&dst[x], vcombine_u32(result32_low, result32_high));
    132132                }
    133133            }
     
    144144    } else if (const_alpha != 0) {
    145145        const_alpha = (const_alpha * 255) >> 8;
    146         int16x8_t const_alpha16 = vdupq_n_s16(const_alpha);
     146        uint16x8_t const_alpha16 = vdupq_n_u16(const_alpha);
    147147        for (int y = 0; y < h; ++y) {
    148148            int x = 0;
    149149            for (; x < w-3; x += 4) {
    150150                if (src[x] | src[x+1] | src[x+2] | src[x+3]) {
    151                     int32x4_t src32 = vld1q_s32((int32_t *)&src[x]);
    152                     int32x4_t dst32 = vld1q_s32((int32_t *)&dst[x]);
    153 
    154                     const uint8x16_t src8 = vreinterpretq_u8_s32(src32);
    155                     const uint8x16_t dst8 = vreinterpretq_u8_s32(dst32);
     151                    uint32x4_t src32 = vld1q_u32((uint32_t *)&src[x]);
     152                    uint32x4_t dst32 = vld1q_u32((uint32_t *)&dst[x]);
     153
     154                    const uint8x16_t src8 = vreinterpretq_u8_u32(src32);
     155                    const uint8x16_t dst8 = vreinterpretq_u8_u32(dst32);
    156156
    157157                    const uint8x8_t src8_low = vget_low_u8(src8);
     
    161161                    const uint8x8_t dst8_high = vget_high_u8(dst8);
    162162
    163                     const int16x8_t src16_low = vreinterpretq_s16_u16(vmovl_u8(src8_low));
    164                     const int16x8_t dst16_low = vreinterpretq_s16_u16(vmovl_u8(dst8_low));
    165 
    166                     const int16x8_t src16_high = vreinterpretq_s16_u16(vmovl_u8(src8_high));
    167                     const int16x8_t dst16_high = vreinterpretq_s16_u16(vmovl_u8(dst8_high));
    168 
    169                     const int16x8_t srcalpha16_low = qvbyte_mul_s16(src16_low, const_alpha16, half);
    170                     const int16x8_t srcalpha16_high = qvbyte_mul_s16(src16_high, const_alpha16, half);
    171 
    172                     const int16x8_t result16_low = qvsource_over_s16(srcalpha16_low, dst16_low, half, full);
    173                     const int16x8_t result16_high = qvsource_over_s16(srcalpha16_high, dst16_high, half, full);
    174 
    175                     const int32x2_t result32_low = vreinterpret_s32_s8(vmovn_s16(result16_low));
    176                     const int32x2_t result32_high = vreinterpret_s32_s8(vmovn_s16(result16_high));
    177 
    178                     vst1q_s32((int32_t *)&dst[x], vcombine_s32(result32_low, result32_high));
     163                    const uint16x8_t src16_low = vmovl_u8(src8_low);
     164                    const uint16x8_t dst16_low = vmovl_u8(dst8_low);
     165
     166                    const uint16x8_t src16_high = vmovl_u8(src8_high);
     167                    const uint16x8_t dst16_high = vmovl_u8(dst8_high);
     168
     169                    const uint16x8_t srcalpha16_low = qvbyte_mul_u16(src16_low, const_alpha16, half);
     170                    const uint16x8_t srcalpha16_high = qvbyte_mul_u16(src16_high, const_alpha16, half);
     171
     172                    const uint16x8_t result16_low = qvsource_over_u16(srcalpha16_low, dst16_low, half, full);
     173                    const uint16x8_t result16_high = qvsource_over_u16(srcalpha16_high, dst16_high, half, full);
     174
     175                    const uint32x2_t result32_low = vreinterpret_u32_u8(vmovn_u16(result16_low));
     176                    const uint32x2_t result32_high = vreinterpret_u32_u8(vmovn_u16(result16_high));
     177
     178                    vst1q_u32((uint32_t *)&dst[x], vcombine_u32(result32_low, result32_high));
    179179                }
    180180            }
     
    207207            const uint *src = (const uint *) srcPixels;
    208208            uint *dst = (uint *) destPixels;
    209             int16x8_t half = vdupq_n_s16(0x80);
     209            uint16x8_t half = vdupq_n_u16(0x80);
    210210            const_alpha = (const_alpha * 255) >> 8;
    211211            int one_minus_const_alpha = 255 - const_alpha;
    212             int16x8_t const_alpha16 = vdupq_n_s16(const_alpha);
    213             int16x8_t one_minus_const_alpha16 = vdupq_n_s16(255 - const_alpha);
     212            uint16x8_t const_alpha16 = vdupq_n_u16(const_alpha);
     213            uint16x8_t one_minus_const_alpha16 = vdupq_n_u16(255 - const_alpha);
    214214            for (int y = 0; y < h; ++y) {
    215215                int x = 0;
    216216                for (; x < w-3; x += 4) {
    217                     int32x4_t src32 = vld1q_s32((int32_t *)&src[x]);
    218                     int32x4_t dst32 = vld1q_s32((int32_t *)&dst[x]);
    219 
    220                     const uint8x16_t src8 = vreinterpretq_u8_s32(src32);
    221                     const uint8x16_t dst8 = vreinterpretq_u8_s32(dst32);
     217                    uint32x4_t src32 = vld1q_u32((uint32_t *)&src[x]);
     218                    uint32x4_t dst32 = vld1q_u32((uint32_t *)&dst[x]);
     219
     220                    const uint8x16_t src8 = vreinterpretq_u8_u32(src32);
     221                    const uint8x16_t dst8 = vreinterpretq_u8_u32(dst32);
    222222
    223223                    const uint8x8_t src8_low = vget_low_u8(src8);
     
    227227                    const uint8x8_t dst8_high = vget_high_u8(dst8);
    228228
    229                     const int16x8_t src16_low = vreinterpretq_s16_u16(vmovl_u8(src8_low));
    230                     const int16x8_t dst16_low = vreinterpretq_s16_u16(vmovl_u8(dst8_low));
    231 
    232                     const int16x8_t src16_high = vreinterpretq_s16_u16(vmovl_u8(src8_high));
    233                     const int16x8_t dst16_high = vreinterpretq_s16_u16(vmovl_u8(dst8_high));
    234 
    235                     const int16x8_t result16_low = qvinterpolate_pixel_255(src16_low, const_alpha16, dst16_low, one_minus_const_alpha16, half);
    236                     const int16x8_t result16_high = qvinterpolate_pixel_255(src16_high, const_alpha16, dst16_high, one_minus_const_alpha16, half);
    237 
    238                     const int32x2_t result32_low = vreinterpret_s32_s8(vmovn_s16(result16_low));
    239                     const int32x2_t result32_high = vreinterpret_s32_s8(vmovn_s16(result16_high));
    240 
    241                     vst1q_s32((int32_t *)&dst[x], vcombine_s32(result32_low, result32_high));
     229                    const uint16x8_t src16_low = vmovl_u8(src8_low);
     230                    const uint16x8_t dst16_low = vmovl_u8(dst8_low);
     231
     232                    const uint16x8_t src16_high = vmovl_u8(src8_high);
     233                    const uint16x8_t dst16_high = vmovl_u8(dst8_high);
     234
     235                    const uint16x8_t result16_low = qvinterpolate_pixel_255(src16_low, const_alpha16, dst16_low, one_minus_const_alpha16, half);
     236                    const uint16x8_t result16_high = qvinterpolate_pixel_255(src16_high, const_alpha16, dst16_high, one_minus_const_alpha16, half);
     237
     238                    const uint32x2_t result32_low = vreinterpret_u32_u8(vmovn_u16(result16_low));
     239                    const uint32x2_t result32_high = vreinterpret_u32_u8(vmovn_u16(result16_high));
     240
     241                    vst1q_u32((uint32_t *)&dst[x], vcombine_u32(result32_low, result32_high));
    242242                }
    243243                for (; x<w; ++x) {
  • trunk/src/gui/painting/qdrawhelper_p.h

    r651 r769  
    15501550inline void qt_memfill(T *dest, T value, int count)
    15511551{
     1552    if (!count)
     1553        return;
     1554
    15521555    int n = (count + 7) / 8;
    15531556    switch (count & 0x07)
  • trunk/src/gui/painting/qdrawhelper_sse2.cpp

    r651 r769  
    5757
    5858QT_BEGIN_NAMESPACE
     59
     60/*
     61 * Multiply the components of pixelVector by alphaChannel
     62 * Each 32bits components of alphaChannel must be in the form 0x00AA00AA
     63 * colorMask must have 0x00ff00ff on each 32 bits component
     64 * half must have the value 128 (0x80) for each 32 bits compnent
     65 */
     66#define BYTE_MUL_SSE2(result, pixelVector, alphaChannel, colorMask, half) \
     67{ \
     68    /* 1. separate the colors in 2 vectors so each color is on 16 bits \
     69       (in order to be multiplied by the alpha \
     70       each 32 bit of dstVectorAG are in the form 0x00AA00GG \
     71       each 32 bit of dstVectorRB are in the form 0x00RR00BB */\
     72    __m128i pixelVectorAG = _mm_srli_epi16(pixelVector, 8); \
     73    __m128i pixelVectorRB = _mm_and_si128(pixelVector, colorMask); \
     74 \
     75    /* 2. multiply the vectors by the alpha channel */\
     76    pixelVectorAG = _mm_mullo_epi16(pixelVectorAG, alphaChannel); \
     77    pixelVectorRB = _mm_mullo_epi16(pixelVectorRB, alphaChannel); \
     78 \
     79    /* 3. devide by 255, that's the tricky part. \
     80       we do it like for BYTE_MUL(), with bit shift: X/255 ~= (X + X/256 + rounding)/256 */ \
     81    /** so first (X + X/256 + rounding) */\
     82    pixelVectorRB = _mm_add_epi16(pixelVectorRB, _mm_srli_epi16(pixelVectorRB, 8)); \
     83    pixelVectorRB = _mm_add_epi16(pixelVectorRB, half); \
     84    pixelVectorAG = _mm_add_epi16(pixelVectorAG, _mm_srli_epi16(pixelVectorAG, 8)); \
     85    pixelVectorAG = _mm_add_epi16(pixelVectorAG, half); \
     86 \
     87    /** second devide by 256 */\
     88    pixelVectorRB = _mm_srli_epi16(pixelVectorRB, 8); \
     89    /** for AG, we could >> 8 to divide followed by << 8 to put the \
     90        bytes in the correct position. By masking instead, we execute \
     91        only one instruction */\
     92    pixelVectorAG = _mm_andnot_si128(colorMask, pixelVectorAG); \
     93 \
     94    /* 4. combine the 2 pairs of colors */ \
     95    result = _mm_or_si128(pixelVectorAG, pixelVectorRB); \
     96}
     97
     98/*
     99 * Each 32bits components of alphaChannel must be in the form 0x00AA00AA
     100 * oneMinusAlphaChannel must be 255 - alpha for each 32 bits component
     101 * colorMask must have 0x00ff00ff on each 32 bits component
     102 * half must have the value 128 (0x80) for each 32 bits compnent
     103 */
     104#define INTERPOLATE_PIXEL_255_SSE2(result, srcVector, dstVector, alphaChannel, oneMinusAlphaChannel, colorMask, half) { \
     105    /* interpolate AG */\
     106    __m128i srcVectorAG = _mm_srli_epi16(srcVector, 8); \
     107    __m128i dstVectorAG = _mm_srli_epi16(dstVector, 8); \
     108    __m128i srcVectorAGalpha = _mm_mullo_epi16(srcVectorAG, alphaChannel); \
     109    __m128i dstVectorAGoneMinusAlphalpha = _mm_mullo_epi16(dstVectorAG, oneMinusAlphaChannel); \
     110    __m128i finalAG = _mm_add_epi16(srcVectorAGalpha, dstVectorAGoneMinusAlphalpha); \
     111    finalAG = _mm_add_epi16(finalAG, _mm_srli_epi16(finalAG, 8)); \
     112    finalAG = _mm_add_epi16(finalAG, half); \
     113    finalAG = _mm_andnot_si128(colorMask, finalAG); \
     114 \
     115    /* interpolate RB */\
     116    __m128i srcVectorRB = _mm_and_si128(srcVector, colorMask); \
     117    __m128i dstVectorRB = _mm_and_si128(dstVector, colorMask); \
     118    __m128i srcVectorRBalpha = _mm_mullo_epi16(srcVectorRB, alphaChannel); \
     119    __m128i dstVectorRBoneMinusAlphalpha = _mm_mullo_epi16(dstVectorRB, oneMinusAlphaChannel); \
     120    __m128i finalRB = _mm_add_epi16(srcVectorRBalpha, dstVectorRBoneMinusAlphalpha); \
     121    finalRB = _mm_add_epi16(finalRB, _mm_srli_epi16(finalRB, 8)); \
     122    finalRB = _mm_add_epi16(finalRB, half); \
     123    finalRB = _mm_srli_epi16(finalRB, 8); \
     124 \
     125    /* combine */\
     126    result = _mm_or_si128(finalAG, finalRB); \
     127}
     128
     129void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,
     130                                    const uchar *srcPixels, int sbpl,
     131                                    int w, int h,
     132                                    int const_alpha)
     133{
     134    const quint32 *src = (const quint32 *) srcPixels;
     135    quint32 *dst = (uint *) destPixels;
     136    if (const_alpha == 256) {
     137        const __m128i alphaMask = _mm_set1_epi32(0xff000000);
     138        const __m128i nullVector = _mm_set1_epi32(0);
     139        const __m128i half = _mm_set1_epi16(0x80);
     140        const __m128i one = _mm_set1_epi16(0xff);
     141        const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);
     142        for (int y = 0; y < h; ++y) {
     143            int x = 0;
     144            for (; x < w-3; x += 4) {
     145                const __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]);
     146                const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask);
     147                if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, alphaMask)) == 0xffff) {
     148                    // all opaque
     149                    _mm_storeu_si128((__m128i *)&dst[x], srcVector);
     150                } else if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, nullVector)) != 0xffff) {
     151                    // not fully transparent
     152                    // result = s + d * (1-alpha)
     153
     154                    // extract the alpha channel on 2 x 16 bits
     155                    // so we have room for the multiplication
     156                    // each 32 bits will be in the form 0x00AA00AA
     157                    // with A being the 1 - alpha
     158                    __m128i alphaChannel = _mm_srli_epi32(srcVector, 24);
     159                    alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16));
     160                    alphaChannel = _mm_sub_epi16(one, alphaChannel);
     161
     162                    const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]);
     163                    __m128i destMultipliedByOneMinusAlpha;
     164                    BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half);
     165
     166                    // result = s + d * (1-alpha)
     167                    const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha);
     168                    _mm_storeu_si128((__m128i *)&dst[x], result);
     169                }
     170            }
     171            for (; x<w; ++x) {
     172                uint s = src[x];
     173                if (s >= 0xff000000)
     174                    dst[x] = s;
     175                else if (s != 0)
     176                    dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
     177            }
     178            dst = (quint32 *)(((uchar *) dst) + dbpl);
     179            src = (const quint32 *)(((const uchar *) src) + sbpl);
     180        }
     181    } else if (const_alpha != 0) {
     182        // dest = (s + d * sia) * ca + d * cia
     183        //      = s * ca + d * (sia * ca + cia)
     184        //      = s * ca + d * (1 - sa*ca)
     185        const_alpha = (const_alpha * 255) >> 8;
     186        const __m128i nullVector = _mm_set1_epi32(0);
     187        const __m128i half = _mm_set1_epi16(0x80);
     188        const __m128i one = _mm_set1_epi16(0xff);
     189        const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);
     190        const __m128i constAlphaVector = _mm_set1_epi16(const_alpha);
     191        for (int y = 0; y < h; ++y) {
     192            int x = 0;
     193            for (; x < w-3; x += 4) {
     194                __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]);
     195                if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVector, nullVector)) != 0xffff) {
     196                    BYTE_MUL_SSE2(srcVector, srcVector, constAlphaVector, colorMask, half);
     197
     198                    __m128i alphaChannel = _mm_srli_epi32(srcVector, 24);
     199                    alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16));
     200                    alphaChannel = _mm_sub_epi16(one, alphaChannel);
     201
     202                    const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]);
     203                    __m128i destMultipliedByOneMinusAlpha;
     204                    BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half);
     205
     206                    const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha);
     207                    _mm_storeu_si128((__m128i *)&dst[x], result);
     208                }
     209            }
     210            for (; x<w; ++x) {
     211                quint32 s = src[x];
     212                if (s != 0) {
     213                    s = BYTE_MUL(s, const_alpha);
     214                    dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
     215                }
     216            }
     217            dst = (quint32 *)(((uchar *) dst) + dbpl);
     218            src = (const quint32 *)(((const uchar *) src) + sbpl);
     219        }
     220    }
     221}
     222
     223// qblendfunctions.cpp
     224void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl,
     225                             const uchar *srcPixels, int sbpl,
     226                             int w, int h,
     227                             int const_alpha);
     228
     229void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl,
     230                                 const uchar *srcPixels, int sbpl,
     231                                 int w, int h,
     232                                 int const_alpha)
     233{
     234    const quint32 *src = (const quint32 *) srcPixels;
     235    quint32 *dst = (uint *) destPixels;
     236    if (const_alpha != 256) {
     237        if (const_alpha != 0) {
     238            const __m128i nullVector = _mm_set1_epi32(0);
     239            const __m128i half = _mm_set1_epi16(0x80);
     240            const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);
     241
     242            const_alpha = (const_alpha * 255) >> 8;
     243            int one_minus_const_alpha = 255 - const_alpha;
     244            const __m128i constAlphaVector = _mm_set1_epi16(const_alpha);
     245            const __m128i oneMinusConstAlpha =  _mm_set1_epi16(one_minus_const_alpha);
     246            for (int y = 0; y < h; ++y) {
     247                int x = 0;
     248                for (; x < w-3; x += 4) {
     249                    __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]);
     250                    if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVector, nullVector)) != 0xffff) {
     251                        const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]);
     252                        __m128i result;
     253                        INTERPOLATE_PIXEL_255_SSE2(result, srcVector, dstVector, constAlphaVector, oneMinusConstAlpha, colorMask, half);
     254                        _mm_storeu_si128((__m128i *)&dst[x], result);
     255                    }
     256                }
     257                for (; x<w; ++x) {
     258                    quint32 s = src[x];
     259                    s = BYTE_MUL(s, const_alpha);
     260                    dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], one_minus_const_alpha);
     261                }
     262                dst = (quint32 *)(((uchar *) dst) + dbpl);
     263                src = (const quint32 *)(((const uchar *) src) + sbpl);
     264            }
     265        }
     266    } else {
     267        qt_blend_rgb32_on_rgb32(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
     268    }
     269}
    59270
    60271void qt_memfill32_sse2(quint32 *dest, quint32 value, int count)
  • trunk/src/gui/painting/qdrawhelper_x86_p.h

    r651 r769  
    115115                          quint32 color,
    116116                          const uchar *src, int width, int height, int stride);
     117void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,
     118                                    const uchar *srcPixels, int sbpl,
     119                                    int w, int h,
     120                                    int const_alpha);
     121void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl,
     122                                 const uchar *srcPixels, int sbpl,
     123                                 int w, int h,
     124                                 int const_alpha);
    117125#endif // QT_HAVE_SSE2
    118126
  • trunk/src/gui/painting/qdrawutil.cpp

    r651 r769  
    13621362        for (int i = 0; i < dataCount; ++i) {
    13631363            QTransform transform = oldTransform;
    1364             transform.translate(drawingData[i].point.x(), drawingData[i].point.y());
    1365             transform.rotate(drawingData[i].rotation);
     1364            qreal xOffset = 0;
     1365            qreal yOffset = 0;
     1366            if (drawingData[i].rotation == 0) {
     1367                xOffset = drawingData[i].point.x();
     1368                yOffset = drawingData[i].point.y();
     1369            } else {
     1370                transform.translate(drawingData[i].point.x(), drawingData[i].point.y());
     1371                transform.rotate(drawingData[i].rotation);
     1372            }
     1373            painter->setTransform(transform);
    13661374            painter->setOpacity(oldOpacity * drawingData[i].opacity);
    1367             painter->setTransform(transform);
    13681375
    13691376            qreal w = drawingData[i].scaleX * drawingData[i].source.width();
    13701377            qreal h = drawingData[i].scaleY * drawingData[i].source.height();
    1371             painter->drawPixmap(QRectF(-0.5 * w, -0.5 * h, w, h), pixmap, drawingData[i].source);
     1378            painter->drawPixmap(QRectF(-0.5 * w + xOffset, -0.5 * h + yOffset, w, h), pixmap, drawingData[i].source);
    13721379        }
    13731380
  • trunk/src/gui/painting/qgraphicssystem_raster.cpp

    r651 r769  
    4242#include "qgraphicssystem_raster_p.h"
    4343
     44#ifdef Q_OS_SYMBIAN
     45#include "private/qpixmap_s60_p.h"
     46#include "private/qwindowsurface_s60_p.h"
     47#else
    4448#include "private/qpixmap_raster_p.h"
    4549#include "private/qwindowsurface_raster_p.h"
     50#endif
    4651
    4752QT_BEGIN_NAMESPACE
     
    4954QPixmapData *QRasterGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
    5055{
     56#ifdef Q_OS_SYMBIAN
     57    return new QS60PixmapData(type);
     58#else
    5159    return new QRasterPixmapData(type);
     60#endif
    5261}
    5362
    5463QWindowSurface *QRasterGraphicsSystem::createWindowSurface(QWidget *widget) const
    5564{
     65#ifdef Q_OS_SYMBIAN
     66    return new QS60WindowSurface(widget);
     67#else
    5668    return new QRasterWindowSurface(widget);
     69#endif
    5770}
    5871
  • trunk/src/gui/painting/qmath_p.h

    r651 r769  
    5555
    5656#include <math.h>
     57#include <qmath.h>
    5758
    5859QT_BEGIN_NAMESPACE
     
    6263static const qreal Q_PI2  = qreal(1.57079632679489661923);   // pi/2
    6364
     65inline int qIntSqrtInt(int v)
     66{
     67    return static_cast<int>(qSqrt(static_cast<qreal>(v)));
     68}
     69
    6470QT_END_NAMESPACE
    6571
  • trunk/src/gui/painting/qpaintbuffer.cpp

    r651 r769  
    5353QT_BEGIN_NAMESPACE
    5454
    55 extern int qt_defaultDpiX();
    56 extern int qt_defaultDpiY();
     55Q_GUI_EXPORT extern int qt_defaultDpiX();
     56Q_GUI_EXPORT extern int qt_defaultDpiY();
    5757extern void qt_format_text(const QFont &font,
    5858                           const QRectF &_r, int tf, const QTextOption *option, const QString& str, QRectF *brect,
  • trunk/src/gui/painting/qpaintengine_alpha.cpp

    r651 r769  
    9494}
    9595
    96 extern int qt_defaultDpiX();
    97 extern int qt_defaultDpiY();
     96Q_GUI_EXPORT extern int qt_defaultDpiX();
     97Q_GUI_EXPORT extern int qt_defaultDpiY();
    9898
    9999bool QAlphaPaintEngine::end()
  • trunk/src/gui/painting/qpaintengine_raster.cpp

    r651 r769  
    101101#include <limits.h>
    102102
    103 #if defined(QT_NO_FPU) || (_MSC_VER >= 1300 && _MSC_VER < 1400)
    104 #  define FLOATING_POINT_BUGGY_OR_NO_FPU
    105 #endif
    106 
    107103QT_BEGIN_NAMESPACE
    108104
    109 extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp
     105Q_GUI_EXPORT extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp
    110106
    111107#define qreal_to_fixed_26_6(f) (int(f * 64))
     
    36803676         || (qpen_style(s->lastPen) == Qt::NoPen && !s->flags.antialiased))
    36813677        && qMax(rect.width(), rect.height()) < QT_RASTER_COORD_LIMIT
    3682 #ifdef FLOATING_POINT_BUGGY_OR_NO_FPU
    3683         && qMax(rect.width(), rect.height()) < 128 // integer math breakdown
    3684 #endif
    36853678        && s->matrix.type() <= QTransform::TxScale) // no shear
    36863679    {
     
    49854978}
    49864979
    4987 extern QImage qt_imageForBrush(int brushStyle, bool invert);
     4980Q_GUI_EXPORT extern QImage qt_imageForBrush(int brushStyle, bool invert);
    49884981
    49894982void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode)
     
    60556048                                   QSpanData *pen_data, QSpanData *brush_data)
    60566049{
    6057 #ifdef FLOATING_POINT_BUGGY_OR_NO_FPU // no fpu, so use fixed point
    6058     const QFixed a = QFixed(rect.width()) >> 1;
    6059     const QFixed b = QFixed(rect.height()) >> 1;
    6060     QFixed d = b*b - (a*a*b) + ((a*a) >> 2);
    6061 #else
    60626050    const qreal a = qreal(rect.width()) / 2;
    60636051    const qreal b = qreal(rect.height()) / 2;
    60646052    qreal d = b*b - (a*a*b) + 0.25*a*a;
    6065 #endif
    60666053
    60676054    int x = 0;
     
    60866073
    60876074    // region 2
    6088 #ifdef FLOATING_POINT_BUGGY_OR_NO_FPU
    6089     d = b*b*(x + (QFixed(1) >> 1))*(x + (QFixed(1) >> 1))
    6090         + a*a*((y - 1)*(y - 1) - b*b);
    6091 #else
    60926075    d = b*b*(x + 0.5)*(x + 0.5) + a*a*((y - 1)*(y - 1) - b*b);
    6093 #endif
    60946076    const int miny = rect.height() & 0x1;
    60956077    while (y > miny) {
  • trunk/src/gui/painting/qpaintengine_x11.cpp

    r651 r769  
    19901990        XFillRectangle(d->dpy, d->hd, d->gc, x, y, sw, sh);
    19911991        restore_clip = true;
     1992    } else if (mono_dst && !mono_src) {
     1993        QBitmap bitmap(pixmap);
     1994        XCopyArea(d->dpy, bitmap.handle(), d->hd, d->gc, sx, sy, sw, sh, x, y);
    19921995    } else {
    19931996        XCopyArea(d->dpy, pixmap.handle(), d->hd, d->gc, sx, sy, sw, sh, x, y);
  • trunk/src/gui/painting/qpaintengineex.cpp

    r651 r769  
    381381}
    382382
    383 extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp
     383Q_GUI_EXPORT extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp
    384384
    385385void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
  • trunk/src/gui/painting/qpainter.cpp

    r651 r769  
    709709        if (penBrush.style() == Qt::TexturePattern)
    710710            penTextureAlpha = qHasPixmapTexture(penBrush)
    711                               ? penBrush.texture().hasAlpha()
     711                              ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha()
    712712                              : penBrush.textureImage().hasAlphaChannel();
    713713        bool brushTextureAlpha = false;
    714         if (s->brush.style() == Qt::TexturePattern)
     714        if (s->brush.style() == Qt::TexturePattern) {
    715715            brushTextureAlpha = qHasPixmapTexture(s->brush)
    716                                 ? s->brush.texture().hasAlpha()
     716                                ? (s->brush.texture().depth() > 1) && s->brush.texture().hasAlpha()
    717717                                : s->brush.textureImage().hasAlphaChannel();
     718        }
    718719        if (((penBrush.style() == Qt::TexturePattern && penTextureAlpha)
    719720             || (s->brush.style() == Qt::TexturePattern && brushTextureAlpha))
     
    19871988
    19881989    Note that only the states the underlying paint engine changes will be reset
    1989     to their respective default states. If, for example, the OpenGL polygon
    1990     mode is changed by the user inside a beginNativePaint()/endNativePainting()
    1991     block, it will not be reset to the default state by endNativePainting().
    1992 
    1993     Here is an example that shows intermixing of painter commands
    1994     and raw OpenGL commands:
     1990    to their respective default states. The states we reset may change from
     1991    release to release. The following states are currently reset in the OpenGL
     1992    2 engine:
     1993
     1994    \list
     1995    \i blending is disabled
     1996    \i the depth, stencil and scissor tests are disabled
     1997    \i the active texture unit is reset to 0
     1998    \i the depth mask, depth function and the clear depth are reset to their
     1999    default values
     2000    \i the stencil mask, stencil operation and stencil function are reset to
     2001    their default values
     2002     \i the current color is reset to solid white
     2003    \endlist
     2004
     2005    If, for example, the OpenGL polygon mode is changed by the user inside a
     2006    beginNativePaint()/endNativePainting() block, it will not be reset to the
     2007    default state by endNativePainting(). Here is an example that shows
     2008    intermixing of painter commands and raw OpenGL commands:
    19952009
    19962010    \snippet doc/src/snippets/code/src_gui_painting_qpainter.cpp 21
     
    57605774        gf.chars = engine.layoutData->string.unicode() + si.position;
    57615775        gf.num_chars = engine.length(item);
    5762         gf.width = si.width;
     5776        if (engine.forceJustification) {
     5777            for (int j=0; j<gf.glyphs.numGlyphs; ++j)
     5778                gf.width += gf.glyphs.effectiveAdvance(j);
     5779        } else {
     5780            gf.width = si.width;
     5781        }
    57635782        gf.logClusters = engine.logClusters(&si);
    57645783
    57655784        drawTextItem(QPointF(x.toReal(), p.y()), gf);
    57665785
    5767         x += si.width;
     5786        x += gf.width;
    57685787    }
    57695788}
     
    77887807            QTextLine line = textLayout.lineAt(i);
    77897808
     7809            qreal advance = textLayout.engine()->lines[i].textAdvance.toReal();
    77907810            if (tf & Qt::AlignRight)
    7791                 xoff = r.width() - line.naturalTextWidth();
     7811                xoff = r.width() - advance;
    77927812            else if (tf & Qt::AlignHCenter)
    7793                 xoff = (r.width() - line.naturalTextWidth())/2;
     7813                xoff = (r.width() - advance)/2;
    77947814
    77957815            line.draw(painter, QPointF(r.x() + xoff + line.x(), r.y() + yoff));
  • trunk/src/gui/painting/qpathclipper.cpp

    r651 r769  
    16921692
    16931693    if (rect)
    1694         *rect = QRectF(QPointF(x1, y1), QPointF(x2, y2));
     1694        rect->setCoords(x1, y1, x2, y2);
    16951695
    16961696    return true;
  • trunk/src/gui/painting/qpdf.cpp

    r651 r769  
    5555QT_BEGIN_NAMESPACE
    5656
    57 extern int qt_defaultDpi();
     57Q_GUI_EXPORT extern int qt_defaultDpi();
    5858
    5959#ifndef QT_NO_PRINTER
     
    972972        return;
    973973
     974    Q_D(QPdfBaseEngine);
    974975    QPainterPath p;
    975976    for (int i=0; i!=pointCount;++i) {
     
    977978        p.lineTo(points[i] + QPointF(0, 0.001));
    978979    }
     980
     981    bool hadBrush = d->hasBrush;
     982    d->hasBrush = false;
    979983    drawPath(p);
     984    d->hasBrush = hadBrush;
    980985}
    981986
     
    985990        return;
    986991
     992    Q_D(QPdfBaseEngine);
    987993    QPainterPath p;
    988994    for (int i=0; i!=lineCount;++i) {
     
    990996        p.lineTo(lines[i].p2());
    991997    }
     998    bool hadBrush = d->hasBrush;
     999    d->hasBrush = false;
    9921000    drawPath(p);
     1001    d->hasBrush = hadBrush;
    9931002}
    9941003
  • trunk/src/gui/painting/qprintengine_ps.cpp

    r651 r769  
    486486    QByteArray header;
    487487    QPdf::ByteStream s(&header);
    488     s << "%!PS-Adobe-1.0";
    489488
    490489    qreal scale = 72. / ((qreal) q->metric(QPaintDevice::PdmDpiY));
     
    498497    int height = pageRect.height();
    499498    if (finished && pageCount == 1 && copies == 1 &&
    500         ((fullPage && qt_gen_epsf) || (outputFileName.endsWith(QLatin1String(".eps"))))
    501        ) {
     499        ((fullPage && qt_gen_epsf) || (outputFileName.endsWith(QLatin1String(".eps")))))
     500    {
     501        // According to the EPSF 3.0 spec it is required that the PS
     502        // version is PS-Adobe-3.0
     503        s << "%!PS-Adobe-3.0";
    502504        if (!boundingBox.isValid())
    503505            boundingBox.setRect(0, 0, width, height);
     
    506508                boundingBox.translate(-mleft, -mtop);
    507509            s << " EPSF-3.0\n%%BoundingBox: "
    508               << (int)(printer->height() - boundingBox.bottom())*scale // llx
    509               << (int)(printer->width() - boundingBox.right())*scale - 1 // lly
    510               << (int)(printer->height() - boundingBox.top())*scale + 1 // urx
    511               << (int)(printer->width() - boundingBox.left())*scale; // ury
     510              << int((printer->height() - boundingBox.bottom())*scale) // llx
     511              << int((printer->width() - boundingBox.right())*scale - 1) // lly
     512              << int((printer->height() - boundingBox.top())*scale + 1) // urx
     513              << int((printer->width() - boundingBox.left())*scale); // ury
    512514        } else {
    513515            if (!fullPage)
    514516                boundingBox.translate(mleft, -mtop);
    515517            s << " EPSF-3.0\n%%BoundingBox: "
    516               << (int)(boundingBox.left())*scale
    517               << (int)(printer->height() - boundingBox.bottom())*scale - 1
    518               << (int)(boundingBox.right())*scale + 1
    519               << (int)(printer->height() - boundingBox.top())*scale;
     518              << int((boundingBox.left())*scale)
     519              << int((printer->height() - boundingBox.bottom())*scale - 1)
     520              << int((boundingBox.right())*scale + 1)
     521              << int((printer->height() - boundingBox.top())*scale);
    520522        }
    521523    } else {
     524        s << "%!PS-Adobe-1.0";
    522525        int w = width + (fullPage ? 0 : mleft + mright);
    523526        int h = height + (fullPage ? 0 : mtop + mbottom);
  • trunk/src/gui/painting/qprintengine_win.cpp

    r651 r769  
    965965
    966966    QStringList info = output.split(QLatin1Char(','));
    967     if (info.size() > 0) {
     967    int infoSize = info.size();
     968    if (infoSize > 0) {
    968969        if (name.isEmpty())
    969970            name = info.at(0);
    970         if (program.isEmpty())
     971        if (program.isEmpty() && infoSize > 1)
    971972            program = info.at(1);
    972         if (port.isEmpty())
     973        if (port.isEmpty() && infoSize > 2)
    973974            port = info.at(2);
    974975    }
  • trunk/src/gui/painting/qregion.cpp

    r651 r769  
    31463146/* $XFree86: xc/lib/X11/PolyReg.c,v 1.1.1.2.8.2 1998/10/04 15:22:49 hohndel Exp $ */
    31473147
    3148 #define LARGE_COORDINATE 1000000
    3149 #define SMALL_COORDINATE -LARGE_COORDINATE
     3148#define LARGE_COORDINATE INT_MAX
     3149#define SMALL_COORDINATE INT_MIN
    31503150
    31513151/*
  • trunk/src/gui/painting/qstroker.cpp

    r651 r769  
    826826}
    827827
    828 void qt_find_ellipse_coords(const QRectF &r, qreal angle, qreal length,
     828Q_GUI_EXPORT void qt_find_ellipse_coords(const QRectF &r, qreal angle, qreal length,
    829829                            QPointF* startPoint, QPointF *endPoint);
    830830
  • trunk/src/gui/painting/qtransform.h

    r651 r769  
    294294    affine._dy  *= num;
    295295    m_33        *= num;
    296     m_dirty     |= TxScale;
     296    if (m_dirty < TxScale)
     297        m_dirty = TxScale;
    297298    return *this;
    298299}
     
    317318    affine._dy  += num;
    318319    m_33        += num;
    319     m_dirty     |= TxProject;
     320    m_dirty     = TxProject;
    320321    return *this;
    321322}
     
    333334    affine._dy  -= num;
    334335    m_33        -= num;
    335     m_dirty     |= TxProject;
     336    m_dirty     = TxProject;
    336337    return *this;
    337338}
  • trunk/src/gui/painting/qwindowsurface_qws.cpp

    r651 r769  
    8181inline bool isWidgetOpaque(const QWidget *w)
    8282{
    83     return w->d_func()->isOpaque;
     83    return w->d_func()->isOpaque && !w->testAttribute(Qt::WA_TranslucentBackground);
    8484}
    8585
     
    874874}
    875875
     876// ### copied from qwindowsurface_raster.cpp -- should be cross-platform
     877void QWSMemorySurface::beginPaint(const QRegion &rgn)
     878{
     879    if (!isWidgetOpaque(window())) {
     880        QPainter p(&img);
     881        p.setCompositionMode(QPainter::CompositionMode_Source);
     882        const QVector<QRect> rects = rgn.rects();
     883        const QColor blank = Qt::transparent;
     884        for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
     885            p.fillRect(*it, blank);
     886        }
     887    }
     888    QWSWindowSurface::beginPaint(rgn);
     889}
     890
    876891// from qwindowsurface.cpp
    877892extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
  • trunk/src/gui/painting/qwindowsurface_qws_p.h

    r651 r769  
    177177    QPoint painterOffset() const;
    178178
     179    void beginPaint(const QRegion &rgn);
     180
    179181    bool lock(int timeout = -1);
    180182    void unlock();
  • trunk/src/gui/painting/qwindowsurface_raster.cpp

    r758 r769  
    560560#ifndef QT_MAC_USE_COCOA
    561561    QDEndCGContext(port, &context);
    562 #else
    563     CGContextFlush(context);
    564 #endif
    565 #endif
     562#endif
     563#endif // Q_WS_MAC
    566564
    567565#ifdef Q_OS_SYMBIAN
  • trunk/src/gui/painting/qwindowsurface_s60.cpp

    r651 r769  
    7171    CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap);   // CBase derived object needs check on new
    7272    qt_symbian_throwIfError( bitmap->Create( TSize(0, 0), mode ) );
    73        
     73
    7474    QS60PixmapData *data = new QS60PixmapData(QPixmapData::PixmapType);
    7575    if (data) {
     
    7777        d_ptr->device = QPixmap(data);
    7878    }
    79        
     79
    8080    setStaticContentsSupport(true);
    8181}
     
    9090        QS60PixmapData *pixmapData = static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data());
    9191        pixmapData->beginDataAccess();
    92         QImage &image = pixmapData->image;
    93         QRgb *data = reinterpret_cast<QRgb *>(image.bits());
    94         const int row_stride = image.bytesPerLine() / 4;
    9592
     93        QPainter p(&pixmapData->image);
     94        p.setCompositionMode(QPainter::CompositionMode_Source);
    9695        const QVector<QRect> rects = rgn.rects();
     96        const QColor blank = Qt::transparent;
    9797        for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
    98             const int x_start = it->x();
    99             const int width = it->width();
     98            p.fillRect(*it, blank);
     99        }
    100100
    101             const int y_start = it->y();
    102             const int height = it->height();
    103 
    104             QRgb *row = data + row_stride * y_start;
    105             for (int y = 0; y < height; ++y) {
    106                 qt_memfill(row + x_start, 0U, width);
    107                 row += row_stride;
    108             }
    109         }
    110101        pixmapData->endDataAccess();
    111102    }
     
    129120    const QPoint off = offset(widget);
    130121    QImage *img = &(static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data())->image);
    131    
     122
    132123    QRect rect(off, widget->size());
    133124    rect &= QRect(QPoint(), img->size());
     
    150141    QTLWExtra *topExtra = window->d_func()->maybeTopData();
    151142    Q_ASSERT(topExtra);
     143    QRect qr = region.boundingRect();
    152144    if (!topExtra->inExpose) {
    153145        topExtra->inExpose = true; // Prevent DrawNow() from calling syncBackingStore() again
    154         TRect tr = qt_QRect2TRect(region.boundingRect());
     146        TRect tr = qt_QRect2TRect(qr);
    155147        widget->winId()->DrawNow(tr);
    156148        topExtra->inExpose = false;
     149    } else {
     150        // This handles the case when syncBackingStore updates content outside of the
     151        // original drawing rectangle. This might happen if there are pending update()
     152        // events at the same time as we get a Draw() from Symbian.
     153        QRect drawRect = qt_TRect2QRect(widget->winId()->DrawableWindow()->GetDrawRect());
     154        if (!drawRect.contains(qr))
     155            widget->winId()->DrawDeferred();
    157156    }
    158157}
Note: See TracChangeset for help on using the changeset viewer.