Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

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

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/painting/qdrawhelper_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6363#endif
    6464#include "private/qrasterdefs_p.h"
     65#include <private/qsimd_p.h>
    6566
    6667#ifdef Q_WS_QWS
    6768#include "QtGui/qscreen_qws.h"
    68 #endif
    69 
    70 // Disable MMX and SSE on Mac/PPC builds, or if the compiler
    71 // does not support -Xarch argument passing
    72 #if defined(QT_NO_MAC_XARCH) || (defined(Q_OS_DARWIN) && (defined(__ppc__) || defined(__ppc64__)))
    73 #undef QT_HAVE_SSE2
    74 #undef QT_HAVE_SSE
    75 #undef QT_HAVE_3DNOW
    76 #undef QT_HAVE_MMX
    7769#endif
    7870
     
    9385#  define Q_STATIC_INLINE_FUNCTION static inline
    9486#endif
     87
     88static const uint AMASK = 0xff000000;
     89static const uint RMASK = 0x00ff0000;
     90static const uint GMASK = 0x0000ff00;
     91static const uint BMASK = 0x000000ff;
    9592
    9693/*******************************************************************************
     
    155152                                     int const_alpha);
    156153
     154typedef void (*MemRotateFunc)(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl);
    157155
    158156struct DrawHelper {
     
    168166extern SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats];
    169167extern SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFormats];
     168extern MemRotateFunc qMemRotateFunctions[QImage::NImageFormats][3];
    170169
    171170extern DrawHelper qDrawHelper[QImage::NImageFormats];
     
    310309};
    311310
    312 
    313 Q_STATIC_INLINE_FUNCTION uint BYTE_MUL_RGB16(uint x, uint a) {
    314     a += 1;
    315     uint t = (((x & 0x07e0)*a) >> 8) & 0x07e0;
    316     t |= (((x & 0xf81f)*(a>>2)) >> 6) & 0xf81f;
    317     return t;
    318 }
    319 
    320 Q_STATIC_INLINE_FUNCTION uint BYTE_MUL_RGB16_32(uint x, uint a) {
    321     uint t = (((x & 0xf81f07e0) >> 5)*a) & 0xf81f07e0;
    322     t |= (((x & 0x07e0f81f)*a) >> 5) & 0x07e0f81f;
    323     return t;
     311#if defined(Q_CC_RVCT)
     312#  pragma push
     313#  pragma arm
     314#endif
     315Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_255(uint x, uint a, uint y, uint b) {
     316    uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
     317    t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
     318    t &= 0xff00ff;
     319
     320    x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
     321    x = (x + ((x >> 8) & 0xff00ff) + 0x800080);
     322    x &= 0xff00ff00;
     323    x |= t;
     324    return x;
     325}
     326#if defined(Q_CC_RVCT)
     327#  pragma pop
     328#endif
     329
     330#if QT_POINTER_SIZE == 8 // 64-bit versions
     331
     332Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) {
     333    quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
     334    t += (((quint64(y)) | ((quint64(y)) << 24)) & 0x00ff00ff00ff00ff) * b;
     335    t >>= 8;
     336    t &= 0x00ff00ff00ff00ff;
     337    return (uint(t)) | (uint(t >> 24));
     338}
     339
     340Q_STATIC_INLINE_FUNCTION uint BYTE_MUL(uint x, uint a) {
     341    quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
     342    t = (t + ((t >> 8) & 0xff00ff00ff00ff) + 0x80008000800080) >> 8;
     343    t &= 0x00ff00ff00ff00ff;
     344    return (uint(t)) | (uint(t >> 24));
     345}
     346
     347Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x) {
     348    uint a = x >> 24;
     349    quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
     350    t = (t + ((t >> 8) & 0xff00ff00ff00ff) + 0x80008000800080) >> 8;
     351    t &= 0x000000ff00ff00ff;
     352    return (uint(t)) | (uint(t >> 24)) | (a << 24);
     353}
     354
     355#else // 32-bit versions
     356
     357Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) {
     358    uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
     359    t >>= 8;
     360    t &= 0xff00ff;
     361
     362    x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
     363    x &= 0xff00ff00;
     364    x |= t;
     365    return x;
    324366}
    325367
     
    354396    x |= t | (a << 24);
    355397    return x;
     398}
     399#endif
     400
     401
     402Q_STATIC_INLINE_FUNCTION uint BYTE_MUL_RGB16(uint x, uint a) {
     403    a += 1;
     404    uint t = (((x & 0x07e0)*a) >> 8) & 0x07e0;
     405    t |= (((x & 0xf81f)*(a>>2)) >> 6) & 0xf81f;
     406    return t;
     407}
     408
     409Q_STATIC_INLINE_FUNCTION uint BYTE_MUL_RGB16_32(uint x, uint a) {
     410    uint t = (((x & 0xf81f07e0) >> 5)*a) & 0xf81f07e0;
     411    t |= (((x & 0x07e0f81f)*a) >> 5) & 0x07e0f81f;
     412    return t;
    356413}
    357414
     
    16281685QT_TRIVIAL_MEMCONVERT_IMPL(qrgb666)
    16291686QT_TRIVIAL_MEMCONVERT_IMPL(quint16)
    1630 #ifdef Q_WS_QWS
    16311687QT_TRIVIAL_MEMCONVERT_IMPL(qrgb565)
    1632 #endif
    16331688QT_TRIVIAL_MEMCONVERT_IMPL(qargb8565)
    16341689QT_TRIVIAL_MEMCONVERT_IMPL(qargb8555)
     
    16501705    }
    16511706
    1652     const int align = (long(dest) & 3);
     1707    const int align = (quintptr(dest) & 3);
    16531708    switch (align) {
    16541709    case 1: *dest++ = qrgb666(*src++); --count;
     
    17271782QT_RECTCONVERT_TRIVIAL_IMPL(qargb6666)
    17281783QT_RECTCONVERT_TRIVIAL_IMPL(qrgb666)
    1729 #ifdef Q_WS_QWS
    17301784QT_RECTCONVERT_TRIVIAL_IMPL(qrgb565)
    1731 #endif
    17321785QT_RECTCONVERT_TRIVIAL_IMPL(qargb8565)
    17331786QT_RECTCONVERT_TRIVIAL_IMPL(quint16)
     
    18421895    return (b << 3) | (b >> 2);
    18431896}
    1844 
    1845 #if 1
    1846 Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) {
    1847     uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
    1848     t >>= 8;
    1849     t &= 0xff00ff;
    1850 
    1851     x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
    1852     x &= 0xff00ff00;
    1853     x |= t;
    1854     return x;
    1855 }
    1856 
    1857 #if defined(Q_CC_RVCT)
    1858 #  pragma push
    1859 #  pragma arm
    1860 #endif
    1861 Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_255(uint x, uint a, uint y, uint b) {
    1862     uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
    1863     t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
    1864     t &= 0xff00ff;
    1865 
    1866     x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
    1867     x = (x + ((x >> 8) & 0xff00ff) + 0x800080);
    1868     x &= 0xff00ff00;
    1869     x |= t;
    1870     return x;
    1871 }
    1872 #if defined(Q_CC_RVCT)
    1873 #  pragma pop
    1874 #endif
    1875 #else
    1876 // possible implementation for 64 bit
    1877 Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) {
    1878     ulong t = (((ulong(x)) | ((ulong(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
    1879     t += (((ulong(y)) | ((ulong(y)) << 24)) & 0x00ff00ff00ff00ff) * b;
    1880     t >>= 8;
    1881     t &= 0x00ff00ff00ff00ff;
    1882     return (uint(t)) | (uint(t >> 24));
    1883 }
    1884 
    1885 Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_255(uint x, uint a, uint y, uint b) {
    1886     ulong t = (((ulong(x)) | ((ulong(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
    1887     t += (((ulong(y)) | ((ulong(y)) << 24)) & 0x00ff00ff00ff00ff) * b;
    1888     t = (t + ((t >> 8) & 0xff00ff00ff00ff) + 0x80008000800080);
    1889     t &= 0x00ff00ff00ff00ff;
    1890     return (uint(t)) | (uint(t >> 24));
    1891 }
    1892 
    1893 Q_STATIC_INLINE_FUNCTION uint BYTE_MUL(uint x, uint a) {
    1894     ulong t = (((ulong(x)) | ((ulong(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
    1895     t = (t + ((t >> 8) & 0xff00ff00ff00ff) + 0x80008000800080);
    1896     t &= 0x00ff00ff00ff00ff;
    1897     return (uint(t)) | (uint(t >> 24));
    1898 }
    1899 
    1900 Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x) {
    1901     uint a = x >> 24;
    1902     ulong t = (((ulong(x)) | ((ulong(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
    1903     t = (t + ((t >> 8) & 0xff00ff00ff00ff) + 0x80008000800080);
    1904     t &= 0x00ff00ff00ff00ff;
    1905     return (uint(t)) | (uint(t >> 24)) | 0xff000000;
    1906 }
    1907 #endif
    19081897
    19091898const uint qt_bayer_matrix[16][16] = {
     
    19461935
    19471936
     1937#if QT_POINTER_SIZE == 8 // 64-bit versions
     1938#define AMIX(mask) (qMin(((qint64(s)&mask) + (qint64(d)&mask)), qint64(mask)))
     1939#define MIX(mask) (qMin(((qint64(s)&mask) + (qint64(d)&mask)), qint64(mask)))
     1940#else // 32 bits
     1941// The mask for alpha can overflow over 32 bits
     1942#define AMIX(mask) quint32(qMin(((qint64(s)&mask) + (qint64(d)&mask)), qint64(mask)))
     1943#define MIX(mask) (qMin(((quint32(s)&mask) + (quint32(d)&mask)), quint32(mask)))
     1944#endif
     1945
     1946inline int comp_func_Plus_one_pixel_const_alpha(uint d, const uint s, const uint const_alpha, const uint one_minus_const_alpha)
     1947{
     1948    const int result = (AMIX(AMASK) | MIX(RMASK) | MIX(GMASK) | MIX(BMASK));
     1949    return INTERPOLATE_PIXEL_255(result, const_alpha, d, one_minus_const_alpha);
     1950}
     1951
     1952inline int comp_func_Plus_one_pixel(uint d, const uint s)
     1953{
     1954    const int result = (AMIX(AMASK) | MIX(RMASK) | MIX(GMASK) | MIX(BMASK));
     1955    return result;
     1956}
     1957
     1958#undef MIX
     1959#undef AMIX
     1960
     1961// prototypes of all the composition functions
     1962void QT_FASTCALL comp_func_SourceOver(uint *dest, const uint *src, int length, uint const_alpha);
     1963void QT_FASTCALL comp_func_DestinationOver(uint *dest, const uint *src, int length, uint const_alpha);
     1964void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha);
     1965void QT_FASTCALL comp_func_Source(uint *dest, const uint *src, int length, uint const_alpha);
     1966void QT_FASTCALL comp_func_Destination(uint *, const uint *, int, uint);
     1967void QT_FASTCALL comp_func_SourceIn(uint *dest, const uint *src, int length, uint const_alpha);
     1968void QT_FASTCALL comp_func_DestinationIn(uint *dest, const uint *src, int length, uint const_alpha);
     1969void QT_FASTCALL comp_func_SourceOut(uint *dest, const uint *src, int length, uint const_alpha);
     1970void QT_FASTCALL comp_func_DestinationOut(uint *dest, const uint *src, int length, uint const_alpha);
     1971void QT_FASTCALL comp_func_SourceAtop(uint *dest, const uint *src, int length, uint const_alpha);
     1972void QT_FASTCALL comp_func_DestinationAtop(uint *dest, const uint *src, int length, uint const_alpha);
     1973void QT_FASTCALL comp_func_XOR(uint *dest, const uint *src, int length, uint const_alpha);
     1974void QT_FASTCALL comp_func_Plus(uint *dest, const uint *src, int length, uint const_alpha);
     1975void QT_FASTCALL comp_func_Multiply(uint *dest, const uint *src, int length, uint const_alpha);
     1976void QT_FASTCALL comp_func_Screen(uint *dest, const uint *src, int length, uint const_alpha);
     1977void QT_FASTCALL comp_func_Overlay(uint *dest, const uint *src, int length, uint const_alpha);
     1978void QT_FASTCALL comp_func_Darken(uint *dest, const uint *src, int length, uint const_alpha);
     1979void QT_FASTCALL comp_func_Lighten(uint *dest, const uint *src, int length, uint const_alpha);
     1980void QT_FASTCALL comp_func_ColorDodge(uint *dest, const uint *src, int length, uint const_alpha);
     1981void QT_FASTCALL comp_func_ColorBurn(uint *dest, const uint *src, int length, uint const_alpha);
     1982void QT_FASTCALL comp_func_HardLight(uint *dest, const uint *src, int length, uint const_alpha);
     1983void QT_FASTCALL comp_func_SoftLight(uint *dest, const uint *src, int length, uint const_alpha);
     1984void QT_FASTCALL comp_func_Difference(uint *dest, const uint *src, int length, uint const_alpha);
     1985void QT_FASTCALL comp_func_Exclusion(uint *dest, const uint *src, int length, uint const_alpha);
     1986void QT_FASTCALL rasterop_SourceOrDestination(uint *dest, const uint *src, int length, uint const_alpha);
     1987void QT_FASTCALL rasterop_SourceAndDestination(uint *dest, const uint *src, int length, uint const_alpha);
     1988void QT_FASTCALL rasterop_SourceXorDestination(uint *dest, const uint *src, int length, uint const_alpha);
     1989void QT_FASTCALL rasterop_NotSourceAndNotDestination(uint *dest, const uint *src, int length, uint const_alpha);
     1990void QT_FASTCALL rasterop_NotSourceOrNotDestination(uint *dest, const uint *src, int length, uint const_alpha);
     1991void QT_FASTCALL rasterop_NotSourceXorDestination(uint *dest, const uint *src, int length, uint const_alpha);
     1992void QT_FASTCALL rasterop_NotSource(uint *dest, const uint *src, int length, uint const_alpha);
     1993void QT_FASTCALL rasterop_NotSourceAndDestination(uint *dest, const uint *src, int length, uint const_alpha);
     1994void QT_FASTCALL rasterop_SourceAndNotDestination(uint *dest, const uint *src, int length, uint const_alpha);
     1995
     1996// prototypes of all the solid composition functions
     1997void QT_FASTCALL comp_func_solid_SourceOver(uint *dest, int length, uint color, uint const_alpha);
     1998void QT_FASTCALL comp_func_solid_DestinationOver(uint *dest, int length, uint color, uint const_alpha);
     1999void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint color, uint const_alpha);
     2000void QT_FASTCALL comp_func_solid_Source(uint *dest, int length, uint color, uint const_alpha);
     2001void QT_FASTCALL comp_func_solid_Destination(uint *dest, int length, uint color, uint const_alpha);
     2002void QT_FASTCALL comp_func_solid_SourceIn(uint *dest, int length, uint color, uint const_alpha);
     2003void QT_FASTCALL comp_func_solid_DestinationIn(uint *dest, int length, uint color, uint const_alpha);
     2004void QT_FASTCALL comp_func_solid_SourceOut(uint *dest, int length, uint color, uint const_alpha);
     2005void QT_FASTCALL comp_func_solid_DestinationOut(uint *dest, int length, uint color, uint const_alpha);
     2006void QT_FASTCALL comp_func_solid_SourceAtop(uint *dest, int length, uint color, uint const_alpha);
     2007void QT_FASTCALL comp_func_solid_DestinationAtop(uint *dest, int length, uint color, uint const_alpha);
     2008void QT_FASTCALL comp_func_solid_XOR(uint *dest, int length, uint color, uint const_alpha);
     2009void QT_FASTCALL comp_func_solid_Plus(uint *dest, int length, uint color, uint const_alpha);
     2010void QT_FASTCALL comp_func_solid_Multiply(uint *dest, int length, uint color, uint const_alpha);
     2011void QT_FASTCALL comp_func_solid_Screen(uint *dest, int length, uint color, uint const_alpha);
     2012void QT_FASTCALL comp_func_solid_Overlay(uint *dest, int length, uint color, uint const_alpha);
     2013void QT_FASTCALL comp_func_solid_Darken(uint *dest, int length, uint color, uint const_alpha);
     2014void QT_FASTCALL comp_func_solid_Lighten(uint *dest, int length, uint color, uint const_alpha);
     2015void QT_FASTCALL comp_func_solid_ColorDodge(uint *dest, int length, uint color, uint const_alpha);
     2016void QT_FASTCALL comp_func_solid_ColorBurn(uint *dest, int length, uint color, uint const_alpha);
     2017void QT_FASTCALL comp_func_solid_HardLight(uint *dest, int length, uint color, uint const_alpha);
     2018void QT_FASTCALL comp_func_solid_SoftLight(uint *dest, int length, uint color, uint const_alpha);
     2019void QT_FASTCALL comp_func_solid_Difference(uint *dest, int length, uint color, uint const_alpha);
     2020void QT_FASTCALL comp_func_solid_Exclusion(uint *dest, int length, uint color, uint const_alpha);
     2021void QT_FASTCALL rasterop_solid_SourceOrDestination(uint *dest, int length, uint color, uint const_alpha);
     2022void QT_FASTCALL rasterop_solid_SourceAndDestination(uint *dest, int length, uint color, uint const_alpha);
     2023void QT_FASTCALL rasterop_solid_SourceXorDestination(uint *dest, int length, uint color, uint const_alpha);
     2024void QT_FASTCALL rasterop_solid_NotSourceAndNotDestination(uint *dest, int length, uint color, uint const_alpha);
     2025void QT_FASTCALL rasterop_solid_NotSourceOrNotDestination(uint *dest, int length, uint color, uint const_alpha);
     2026void QT_FASTCALL rasterop_solid_NotSourceXorDestination(uint *dest, int length, uint color, uint const_alpha);
     2027void QT_FASTCALL rasterop_solid_NotSource(uint *dest, int length, uint color, uint const_alpha);
     2028void QT_FASTCALL rasterop_solid_NotSourceAndDestination(uint *dest, int length, uint color, uint const_alpha);
     2029void QT_FASTCALL rasterop_solid_SourceAndNotDestination(uint *dest, int length, uint color, uint const_alpha);
     2030
    19482031QT_END_NAMESPACE
    19492032
Note: See TracChangeset for help on using the changeset viewer.