📄 qdrawhelper.cpp
字号:
if (!op.func) return; int image_width = data->texture.width; int image_height = data->texture.height; int xoff = qRound(data->dx) % image_width; int yoff = qRound(data->dy) % image_height; if (xoff < 0) xoff += image_width; if (yoff < 0) yoff += image_height; while (count--) { int x = spans->x; int length = spans->len; int sx = (xoff + spans->x) % image_width; int sy = (spans->y + yoff) % image_height; if (sx < 0) sx += image_width; if (sy < 0) sy += image_height; while (length) { int l = qMin(image_width - sx, length); if (buffer_size < l) l = buffer_size; uint *dest = ((uint *)data->rasterBuffer->scanLine(spans->y)) + x; const uint *src = (uint *)data->texture.scanLine(sy) + sx; op.func(dest, src, l, spans->coverage); x += l; length -= l; sx = 0; } ++spans; }}#ifdef Q_WS_QWSstatic void blend_tiled_rgb16(int count, const QSpan *spans, void *userData){ QSpanData *data = reinterpret_cast<QSpanData *>(userData); if (data->texture.format != QImage::Format_RGB16 && data->texture.format != QImage::Format_ARGB32_Premultiplied) { blend_tiled_generic(count, spans, userData); return; } Operator op = getOperator(data); if (!op.func) return; int image_width = data->texture.width; int image_height = data->texture.height; int xoff = qRound(data->dx) % image_width; int yoff = qRound(data->dy) % image_height; if (xoff < 0) xoff += image_width; if (yoff < 0) yoff += image_height; if (data->texture.format == QImage::Format_ARGB32_Premultiplied) { while (count--) { int x = spans->x; int length = spans->len; int sx = (xoff + spans->x) % image_width; int sy = (spans->y + yoff) % image_height; if (sx < 0) sx += image_width; if (sy < 0) sy += image_height; if (spans->coverage == 255) { while (length) { int l = qMin(image_width - sx, length); if (buffer_size < l) l = buffer_size; ushort *dest = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + x; const uint *src = (uint *)data->texture.scanLine(sy) + sx; for (int i = 0; i < l; ++i) { uint s = src[i]; int alpha = qAlpha(s); s = qConvertRgb32To16(s); if (alpha != 255) s += BYTE_MUL_RGB16(dest[i], 255 - alpha); dest[i] = s; } x += l; length -= l; sx = 0; } } else { while (length) { int l = qMin(image_width - sx, length); if (buffer_size < l) l = buffer_size; ushort *dest = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + x; const uint *src = (uint *)data->texture.scanLine(sy) + sx; for (int i = 0; i < l; ++i) { uint s = src[i]; MASK(s, spans->coverage); int alpha = qAlpha(s); s = qConvertRgb32To16(s); if (alpha != 255) s += BYTE_MUL_RGB16(dest[i], 255 - alpha); dest[i] = s; } x += l; length -= l; sx = 0; } } ++spans; } return; } // texture is RGB16 while (count--) { int x = spans->x; int length = spans->len; int sx = (xoff + spans->x) % image_width; int sy = (spans->y + yoff) % image_height; if (sx < 0) sx += image_width; if (sy < 0) sy += image_height; if (spans->coverage == 255) { while (length) { int l = qMin(image_width - sx, length); if (buffer_size < l) l = buffer_size; ushort *dest = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + x; const ushort *src = (ushort *)data->texture.scanLine(sy) + sx; memcpy(dest, src, l*sizeof(quint16)); x += l; length -= l; sx = 0; } } else { int ialpha = 255 - spans->coverage; while (length) { int l = qMin(image_width - sx, length); if (buffer_size < l) l = buffer_size; ushort *dest = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + x; const ushort *src = (ushort *)data->texture.scanLine(sy) + sx; for (int i = 0; i < l; ++i) dest[i] = qConvertRgb32To16(INTERPOLATE_PIXEL_255(qConvertRgb16To32(src[i]), spans->coverage, qConvertRgb16To32(dest[i]), ialpha)); x += l; length -= l; sx = 0; } } ++spans; }}#endifstatic void blend_transformed_bilinear_argb(int count, const QSpan *spans, void *userData){ QSpanData *data = reinterpret_cast<QSpanData *>(userData); if (data->texture.format != QImage::Format_ARGB32_Premultiplied && data->texture.format != QImage::Format_RGB32) { blend_src_generic(count, spans, userData); return; } CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; if (!func) return; uint buffer[buffer_size]; 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); while (count--) { void *t = data->rasterBuffer->scanLine(spans->y); uint *target = ((uint *)t) + spans->x; uint *image_bits = (uint *)data->texture.imageData; int x = int((data->m21 * (spans->y + 0.5) + data->m11 * (spans->x + 0.5) + data->dx) * fixed_scale) - half_point; int y = int((data->m22 * (spans->y + 0.5) + data->m12 * (spans->x + 0.5) + data->dy) * fixed_scale) - half_point; int length = spans->len; while (length) { int l = qMin(length, buffer_size); const uint *end = buffer + l; uint *b = buffer; while (b < end) { int x1 = (x >> 16); int x2 = x1 + 1; int y1 = (y >> 16); int y2 = y1 + 1; int distx = ((x - (x1 << 16)) >> 8); int disty = ((y - (y1 << 16)) >> 8); int idistx = 256 - distx; int idisty = 256 - disty; bool x1_out = ((x1 < 0) || (x1 >= image_width)); bool x2_out = ((x2 < 0) || (x2 >= image_width)); bool y1_out = ((y1 < 0) || (y1 >= image_height)); bool y2_out = ((y2 < 0) || (y2 >= image_height)); int y1_offset = y1 * image_width; int y2_offset = y1_offset + image_width;#if defined(Q_IRIX_GCC3_3_WORKAROUND) uint tl = gccBug((x1_out || y1_out) ? uint(0) : image_bits[y1_offset + x1]); uint tr = gccBug((x2_out || y1_out) ? uint(0) : image_bits[y1_offset + x2]); uint bl = gccBug((x1_out || y2_out) ? uint(0) : image_bits[y2_offset + x1]); uint br = gccBug((x2_out || y2_out) ? uint(0) : image_bits[y2_offset + x2]);#else uint tl = (x1_out || y1_out) ? uint(0) : image_bits[y1_offset + x1]; uint tr = (x2_out || y1_out) ? uint(0) : image_bits[y1_offset + x2]; uint bl = (x1_out || y2_out) ? uint(0) : image_bits[y2_offset + x1]; uint br = (x2_out || y2_out) ? uint(0) : image_bits[y2_offset + x2];#endif 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); ++b; x += fdx; y += fdy; } func(target, buffer, l, spans->coverage); target += l; length -= l; } ++spans; }}static void blend_transformed_bilinear_tiled_argb(int count, const QSpan *spans, void *userData){ QSpanData *data = reinterpret_cast<QSpanData *>(userData); if (data->texture.format != QImage::Format_ARGB32_Premultiplied && data->texture.format != QImage::Format_RGB32) { blend_src_generic(count, spans, userData); return; } CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; if (!func) return; uint buffer[buffer_size]; 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); while (count--) { void *t = data->rasterBuffer->scanLine(spans->y); uint *target = ((uint *)t) + spans->x; uint *image_bits = (uint *)data->texture.imageData; int x = int((data->m21 * (spans->y + 0.5) + data->m11 * (spans->x + 0.5) + data->dx) * fixed_scale) - half_point; int y = int((data->m22 * (spans->y + 0.5) + data->m12 * (spans->x + 0.5) + data->dy) * fixed_scale) - half_point; int length = spans->len; while (length) { int l = qMin(length, buffer_size); const uint *end = buffer + l; uint *b = buffer; while (b < end) { int x1 = (x >> 16); int x2 = (x1 + 1); int y1 = (y >> 16); int y2 = (y1 + 1); int distx = ((x - (x1 << 16)) >> 8); int disty = ((y - (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); int y1_offset = y1 * image_width; int y2_offset = y2 * image_width;#if defined(Q_IRIX_GCC3_3_WORKAROUND) uint tl = gccBug(image_bits[y1_offset + x1]); uint tr = gccBug(image_bits[y1_offset + x2]); uint bl = gccBug(image_bits[y2_offset + x1]); uint br = gccBug(image_bits[y2_offset + x2]);#else uint tl = image_bits[y1_offset + x1]; uint tr = image_bits[y1_offset + x2]; uint bl = image_bits[y2_offset + x1]; uint br = image_bits[y2_offset + x2];#endif 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); ++b; x += fdx; y += fdy; } func(target, buffer, l, spans->coverage); target += l; length -= l; } ++spans; }}static void blend_transformed_argb(int count, const QSpan *spans, void *userData){ QSpanData *data = reinterpret_cast<QSpanData *>(userData); if (data->texture.format != QImage::Format_ARGB32_Premultiplied && data->texture.format != QImage::Format_RGB32) { blend_src_generic(count, spans, userData); return; } CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; if (!func) return; uint buffer[buffer_size]; 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); while (count--) { void *t = data->rasterBuffer->scanLine(spans->y); uint *target = ((uint *)t) + spans->x; uint *image_bits = (uint *)data->texture.imageData; int x = int((data->m21 * (spans->y + 0.5) + data->m11 * (spans->x + 0.5) + data->dx) * fixed_scale); int y = int((data->m22 * (spans->y + 0.5) + data->m12 * (spans->x + 0.5) + data->dy) * fixed_scale); int length = spans->len; while (length) { int l = qMin(length, buffer_size); const uint *end = buffer + l; uint *b = buffer; while (b < end) { int px = x >> 16; int py = y >> 16; bool out = (px < 0) || (px >= image_width) || (py < 0) || (py >= image_height); int y_offset = py * image_width; *b = out ? uint(0) : image_bits[y_offset + px]; x += fdx; y += fdy; ++b; } func(target, buffer, l, spans->coverage); target += l; length -= l; } ++spans; }}static void blend_transformed_tiled_argb(int count, const QSpan *spans, void *userData){ QSpanData *data = reinterpret_cast<QSpanData *>(userData); if (data->texture.format != QImage::Format_ARGB32_Premultiplied && data->texture.format != QImage::Format_RGB32) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -