⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdrawhelper.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            const uchar *scanLine = data->texture.scanLine(py);            *b = out ? uint(0) : fetch(scanLine, px, data->texture.colorTable);            fx += fdx;            fy += fdy;            fw += fdw;            //force increment to avoid /0            if (!fw) {                fw += fdw;            }            ++b;        }    }    return buffer;}static const uint * QT_FASTCALL fetchTransformedTiled_generic(uint *buffer, const Operator *, const QSpanData *data,                                                              int y, int x, int length){    FetchPixelProc fetch = fetchPixelProc[data->texture.format];    int image_width = data->texture.width;    int image_height = data->texture.height;    // The increment pr x in the scanline    int fdx = (int)(data->m11 * fixed_scale);    int fdy = (int)(data->m12 * fixed_scale);    bool affine = !data->m13 && !data->m23;    int fx = int((data->m21 * (y + 0.5)                  + data->m11 * (x + 0.5) + data->dx) * fixed_scale);    int fy = int((data->m22 * (y + 0.5)                  + data->m12 * (x + 0.5) + data->dy) * fixed_scale);    const uint *end = buffer + length;    uint *b = buffer;    if (affine) {        while (b < end) {            int px = fx >> 16;            int py = fy >> 16;            px %= image_width;            py %= image_height;            if (px < 0) px += image_width;            if (py < 0) py += image_height;            const uchar *scanLine = data->texture.scanLine(py);            *b = fetch(scanLine, px, data->texture.colorTable);            fx += fdx;            fy += fdy;            ++b;        }    } else {        int fdw = (int)(data->m13 * fixed_scale);        int fw = int((data->m13 * (x + 0.5)                     + data->m23 * (y + 0.5) + 1.) * fixed_scale);        if (!fw)            fw = 1;        while (b < end) {            int px = fx/fw;            int py = fy/fw;            px %= image_width;            py %= image_height;            if (px < 0) px += image_width;            if (py < 0) py += image_height;            const uchar *scanLine = data->texture.scanLine(py);            *b = fetch(scanLine, px, data->texture.colorTable);            fx += fdx;            fy += fdy;            fw += fdw;            //force increment to avoid /0            if (!fw) {                fw += fdw;            }            ++b;        }    }    return buffer;}static const uint * QT_FASTCALL fetchTransformedBilinear_generic(uint *buffer, const Operator *, const QSpanData *data,                                                                 int y, int x, int length){    FetchPixelProc fetch = fetchPixelProc[data->texture.format];    int image_width = data->texture.width;    int image_height = data->texture.height;    // The increment pr x in the scanline    int fdx = (int)(data->m11 * fixed_scale);    int fdy = (int)(data->m12 * fixed_scale);    bool affine = !data->m13 && !data->m23;    int fx = int((data->m21 * (y + 0.5)                  + data->m11 * (x + 0.5) + data->dx) * fixed_scale) - half_point;    int fy = int((data->m22 * (y + 0.5)                  + data->m12 * (x + 0.5) + data->dy) * fixed_scale) - half_point;    const uint *end = buffer + length;    uint *b = buffer;    if (affine) {        while (b < end) {            int x1 = (fx >> 16);            int x2 = x1 + 1;            int y1 = (fy >> 16);            int y2 = y1 + 1;            int distx = ((fx - (x1 << 16)) >> 8);            int disty = ((fy - (y1 << 16)) >> 8);            int idistx = 256 - distx;            int idisty = 256 - disty;            x1 = qBound(0, x1, image_width - 1);            x2 = qBound(0, x2, image_width - 1);            y1 = qBound(0, y1, image_height - 1);            y2 = qBound(0, y2, image_height - 1);            const uchar *s1 = data->texture.scanLine(y1);            const uchar *s2 = data->texture.scanLine(y2);            uint tl = fetch(s1, x1, data->texture.colorTable);            uint tr = fetch(s1, x2, data->texture.colorTable);            uint bl = fetch(s2, x1, data->texture.colorTable);            uint br = fetch(s2, x2, data->texture.colorTable);            uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx);            uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx);            *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty);            fx += fdx;            fy += fdy;            ++b;        }    } else {        int fdw = (int)(data->m13 * fixed_scale);        int fw = int((data->m13 * (x + 0.5)                      + data->m23 * (y + 0.5) + 1.) * fixed_scale);        if (!fw)            fw = 1;        while (b < end) {            int x1 = fx/fw;            int x2 = x1 + 1;            int y1 = fy/fw;            int y2 = y1 + 1;            int distx = ((fx -(x1*fw)) >> 8) & 0xff;            int disty = ((fy -(y1*fw)) >> 8) & 0xff;            int idistx = 256 - distx;            int idisty = 256 - disty;            x1 = qBound(0, x1, image_width - 1);            x2 = qBound(0, x2, image_width - 1);            y1 = qBound(0, y1, image_height - 1);            y2 = qBound(0, y2, image_height - 1);            const uchar *s1 = data->texture.scanLine(y1);            const uchar *s2 = data->texture.scanLine(y2);            uint tl = fetch(s1, x1, data->texture.colorTable);            uint tr = fetch(s1, x2, data->texture.colorTable);            uint bl = fetch(s2, x1, data->texture.colorTable);            uint br = fetch(s2, x2, data->texture.colorTable);            uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx);            uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx);            *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty);            fx += fdx;            fy += fdy;            fw += fdw;            //force increment to avoid /0            if (!fw) {                fw += fdw;            }            ++b;        }    }    return buffer;}static const uint * QT_FASTCALL fetchTransformedBilinearTiled_generic(uint *buffer, const Operator *, const QSpanData *data,                                                                     int y, int x, int length){    FetchPixelProc fetch = fetchPixelProc[data->texture.format];    int image_width = data->texture.width;    int image_height = data->texture.height;    bool affine = !data->m13 && !data->m23;    // The increment pr x in the scanline    int fdx = (int)(data->m11 * fixed_scale);    int fdy = (int)(data->m12 * fixed_scale);    int fx = int((data->m21 * (y + 0.5)                  + data->m11 * (x + 0.5) + data->dx) * fixed_scale) - half_point;    int fy = int((data->m22 * (y + 0.5)                  + data->m12 * (x + 0.5) + data->dy) * fixed_scale) - half_point;    const uint *end = buffer + length;    uint *b = buffer;    if (affine) {        while (b < end) {            int x1 = (fx >> 16);            int x2 = x1 + 1;            int y1 = (fy >> 16);            int y2 = y1 + 1;            int distx = ((fx - (x1 << 16)) >> 8);            int disty = ((fy - (y1 << 16)) >> 8);            int idistx = 256 - distx;            int idisty = 256 - disty;            x1 %= image_width;            x2 %= image_width;            y1 %= image_height;            y2 %= image_height;            if (x1 < 0) x1 += image_width;            if (x2 < 0) x2 += image_width;            if (y1 < 0) y1 += image_height;            if (y2 < 0) y2 += image_height;            Q_ASSERT(x1 >= 0 && x1 < image_width);            Q_ASSERT(x2 >= 0 && x2 < image_width);            Q_ASSERT(y1 >= 0 && y1 < image_height);            Q_ASSERT(y2 >= 0 && y2 < image_height);            const uchar *s1 = data->texture.scanLine(y1);            const uchar *s2 = data->texture.scanLine(y2);            uint tl = fetch(s1, x1, data->texture.colorTable);            uint tr = fetch(s1, x2, data->texture.colorTable);            uint bl = fetch(s2, x1, data->texture.colorTable);            uint br = fetch(s2, x2, data->texture.colorTable);            uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx);            uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx);            *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty);            fx += fdx;            fy += fdy;            ++b;        }    } else {        int fdw = (int)(data->m13 * fixed_scale);        int fw = int((data->m13 * (x + 0.5)                      + data->m23 * (y + 0.5) + 1.) * fixed_scale);        if (!fw)            fw = 1;        while (b < end) {            int x1 = fx/fw;            int x2 = x1 + 1;            int y1 = fy/fw;            int y2 = y1 + 1;            int distx = ((fx -(x1*fw)) >> 8) & 0xff;            int disty = ((fy -(y1*fw)) >> 8) & 0xff;            int idistx = 256 - distx;            int idisty = 256 - disty;            x1 %= image_width;            x2 %= image_width;            y1 %= image_height;            y2 %= image_height;            if (x1 < 0) x1 += image_width;            if (x2 < 0) x2 += image_width;            if (y1 < 0) y1 += image_height;            if (y2 < 0) y2 += image_height;            Q_ASSERT(x1 >= 0 && x1 < image_width);            Q_ASSERT(x2 >= 0 && x2 < image_width);            Q_ASSERT(y1 >= 0 && y1 < image_height);            Q_ASSERT(y2 >= 0 && y2 < image_height);            const uchar *s1 = data->texture.scanLine(y1);            const uchar *s2 = data->texture.scanLine(y2);            uint tl = fetch(s1, x1, data->texture.colorTable);            uint tr = fetch(s1, x2, data->texture.colorTable);            uint bl = fetch(s2, x1, data->texture.colorTable);            uint br = fetch(s2, x2, data->texture.colorTable);            uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx);            uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx);            *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty);            fx += fdx;            fy += fdy;            fw += fdw;            //force increment to avoid /0            if (!fw) {                fw += fdw;            }            ++b;        }    }    return buffer;}static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {    // Untransformed    {        0, // Invalid        fetch_generic,   // Mono        fetch_generic,   // MonoLsb        fetch_generic,   // Indexed8        fetch_generic,   // RGB32        fetch_generic,   // ARGB32        fetch_generic,   // ARGB32_Premultiplied        fetch_generic    // RGB16    },    // Tiled    {        0, // Invalid        fetch_generic,   // Mono        fetch_generic,   // MonoLsb        fetch_generic,   // Indexed8        fetch_generic,   // RGB32        fetch_generic,   // ARGB32        fetch_generic,   // ARGB32_Premultiplied        fetch_generic    // RGB16    },    // Transformed    {        0, // Invalid        fetchTransformed_generic,   // Mono        fetchTransformed_generic,   // MonoLsb        fetchTransformed_generic,   // Indexed8        fetchTransformed_generic,   // RGB32        fetchTransformed_generic,   // ARGB32        fetchTransformed_generic,   // ARGB32_Premultiplied        fetchTransformed_generic    // RGB16    },    {        0, // TransformedTiled        fetchTransformedTiled_generic,   // Mono        fetchTransformedTiled_generic,   // MonoLsb        fetchTransformedTiled_generic,   // Indexed8        fetchTransformedTiled_generic,   // RGB32        fetchTransformedTiled_generic,   // ARGB32        fetchTransformedTiled_generic,   // ARGB32_Premultiplied        fetchTransformedTiled_generic    // RGB16    },    {        0, // Bilinear        fetchTransformedBilinear_generic,   // Mono        fetchTransformedBilinear_generic,   // MonoLsb        fetchTransformedBilinear_generic,   // Indexed8        fetchTransformedBilinear_generic,   // RGB32        fetchTransformedBilinear_generic,   // ARGB32        fetchTransformedBilinear_generic,   // ARGB32_Premultiplied        fetchTransformedBilinear_generic    // RGB16    },    {        0, // BilinearTiled        fetchTransformedBilinearTiled_generic,   // Mono        fetchTransformedBilinearTiled_generic,   // MonoLsb        fetchTransformedBilinearTiled_generic,   // Indexed8        fetchTransformedBilinearTiled_generic,   // RGB32        fetchTransformedBilinearTiled_generic,   // ARGB32        fetchTransformedBilinearTiled_generic,   // ARGB32_Premultiplied        fetchTransformedBilinearTiled_generic    // RGB16    },};static uint qt_gradient_pixel(const GradientData *data, qreal pos){    int ipos = qRound(pos * GRADIENT_STOPTABLE_SIZE - 1);  // calculate the actual offset.    if (ipos < 0 || ipos >= GRADIENT_STOPTABLE_SIZE) {        if (data->spread == QGradient::RepeatSpread) {            ipos = ipos % GRADIENT_STOPTABLE_SIZE;            ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos;        } else if (data->spread == QGradient::ReflectSpread) {            const int limit = GRADIENT_STOPTABLE_SIZE * 2 - 1;            ipos = ipos % limit;            ipos = ipos < 0 ? limit + ipos : ipos;            ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - ipos : ipos;        } else {            if (ipos < 0) ipos = 0;            else if (ipos >= GRADIENT_STOPTABLE_SIZE) ipos = GRADIENT_STOPTABLE_SIZE-1;        }    }    Q_ASSERT(ipos >= 0);    Q_ASSERT(ipos < GRADIENT_STOPTABLE_SIZE);    return data->colorTable[ipos];}#ifdef Q_WS_QWS#define FIXPT_BITS 8#define FIXPT_SIZE (1<<FIXPT_BITS)static uint qt_gradient_pixel_fixed(const GradientData *data, int fixed_pos){    int ipos = ((fixed_pos + FIXPT_SIZE / 2) >> FIXPT_BITS) - 1;    // calculate the actual offset.    if (ipos < 0 || ipos >= GRADIENT_STOPTABLE_SIZE) {        if (data->spread == QGradient::RepeatSpread) {            ipos = ipos % GRADIENT_STOPTABLE_SIZE;            ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos;        } else if (data->spread == QGradient::ReflectSpread) {            const int limit = GRADIENT_STOPTABLE_SIZE * 2 - 1;            ipos = ipos % limit;            ipos = ipos < 0 ? limit + ipos : ipos;            ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - ipos : ipos;        } else {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -