src/gui/painting/qdrawhelper.cpp
branchRCL_3
changeset 7 3f74d0d4af4c
parent 4 3b1da2848fc7
equal deleted inserted replaced
6:dee5afe5301f 7:3f74d0d4af4c
  1265 
  1265 
  1266 /*
  1266 /*
  1267   result = 0
  1267   result = 0
  1268   d = d * cia
  1268   d = d * cia
  1269 */
  1269 */
       
  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 
  1270 static void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha)
  1284 static void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha)
  1271 {
  1285 {
  1272     if (const_alpha == 255) {
  1286     comp_func_Clear_impl(dest, length, const_alpha);
  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 }
  1287 }
  1283 
  1288 
  1284 static void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha)
  1289 static void QT_FASTCALL comp_func_Clear(uint *dest, const uint *, int length, uint const_alpha)
  1285 {
  1290 {
  1286     if (const_alpha == 255) {
  1291     comp_func_Clear_impl(dest, length, const_alpha);
  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     }
       
  1296 }
  1292 }
  1297 
  1293 
  1298 /*
  1294 /*
  1299   result = s
  1295   result = s
  1300   dest = s * ca + d * cia
  1296   dest = s * ca + d * cia
  2406     if (src2 < sa)
  2402     if (src2 < sa)
  2407         return (dst * (sa * 255 + (src2 - sa) * (255 - dst_np)) + temp) / 65025;
  2403         return (dst * (sa * 255 + (src2 - sa) * (255 - dst_np)) + temp) / 65025;
  2408     else if (4 * dst <= da)
  2404     else if (4 * dst <= da)
  2409         return (dst * sa * 255 + da * (src2 - sa) * ((((16 * dst_np - 12 * 255) * dst_np + 3 * 65025) * dst_np) / 65025) + temp) / 65025;
  2405         return (dst * sa * 255 + da * (src2 - sa) * ((((16 * dst_np - 12 * 255) * dst_np + 3 * 65025) * dst_np) / 65025) + temp) / 65025;
  2410     else {
  2406     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
  2411         return (dst * sa * 255 + da * (src2 - sa) * (int(sqrt(qreal(dst_np * 255))) - dst_np) + temp) / 65025;
  2410         return (dst * sa * 255 + da * (src2 - sa) * (int(sqrt(qreal(dst_np * 255))) - dst_np) + temp) / 65025;
       
  2411 #   endif
  2412     }
  2412     }
  2413 }
  2413 }
  2414 
  2414 
  2415 template <typename T>
  2415 template <typename T>
  2416 Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_SoftLight_impl(uint *dest, int length, uint color, const T &coverage)
  2416 Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_SoftLight_impl(uint *dest, int length, uint color, const T &coverage)
  7172         && qRed(*dst) <= da && qBlue(*dst) <= da && qGreen(*dst) <= da
  7172         && qRed(*dst) <= da && qBlue(*dst) <= da && qGreen(*dst) <= da
  7173 #endif
  7173 #endif
  7174         ) {
  7174         ) {
  7175 
  7175 
  7176         int a = qGray(coverage);
  7176         int a = qGray(coverage);
  7177         sr = qt_div_255(sr * a);
  7177         sr = qt_div_255(qt_pow_rgb_invgamma[sr] * a);
  7178         sg = qt_div_255(sg * a);
  7178         sg = qt_div_255(qt_pow_rgb_invgamma[sg] * a);
  7179         sb = qt_div_255(sb * a);
  7179         sb = qt_div_255(qt_pow_rgb_invgamma[sb] * a);
  7180 
  7180 
  7181         int ia = 255 - a;
  7181         int ia = 255 - a;
  7182         dr = qt_div_255(dr * ia);
  7182         dr = qt_div_255(dr * ia);
  7183         dg = qt_div_255(dg * ia);
  7183         dg = qt_div_255(dg * ia);
  7184         db = qt_div_255(db * ia);
  7184         db = qt_div_255(db * ia);
  8090             functionForModeAsm = qt_functionForMode_SSE3DNOW;
  8090             functionForModeAsm = qt_functionForMode_SSE3DNOW;
  8091             functionForModeSolidAsm = qt_functionForModeSolid_SSE3DNOW;
  8091             functionForModeSolidAsm = qt_functionForModeSolid_SSE3DNOW;
  8092             qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_sse3dnow;
  8092             qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_sse3dnow;
  8093         }
  8093         }
  8094 #endif // 3DNOW
  8094 #endif // 3DNOW
  8095         extern void qt_blend_rgb32_on_rgb32_sse(uchar *destPixels, int dbpl,
  8095 
  8096                                                 const uchar *srcPixels, int sbpl,
  8096 
  8097                                                 int w, int h,
  8097 #ifdef QT_HAVE_SSE2
  8098                                                 int const_alpha);
  8098         if (features & SSE2) {
  8099         extern void qt_blend_argb32_on_argb32_sse(uchar *destPixels, int dbpl,
  8099             extern void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl,
  8100                                                   const uchar *srcPixels, int sbpl,
  8100                                                      const uchar *srcPixels, int sbpl,
  8101                                                   int w, int h,
  8101                                                      int w, int h,
  8102                                                   int const_alpha);
  8102                                                      int const_alpha);
  8103 
  8103             extern void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,
  8104         qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse;
  8104                                                        const uchar *srcPixels, int sbpl,
  8105         qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse;
  8105                                                        int w, int h,
  8106         qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse;
  8106                                                        int const_alpha);
  8107         qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse;
  8107 
  8108     }
  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 }
  8109 #endif // SSE
  8132 #endif // SSE
  8110 
  8133 
  8111 #ifdef QT_HAVE_IWMMXT
  8134 #ifdef QT_HAVE_IWMMXT
  8112     if (features & IWMMXT) {
  8135     if (features & IWMMXT) {
  8113         functionForModeAsm = qt_functionForMode_IWMMXT;
  8136         functionForModeAsm = qt_functionForMode_IWMMXT;