diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2015-03-05 22:25:45 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-03-12 04:23:50 +0000 |
commit | ce30394686a4ac2cfbda560c5d7113432d84314e (patch) | |
tree | cb9a52e376f3233e4c78d7e657f9243e454d955c /src/gui/image | |
parent | 6025c36d014d77091d09271d68154261d1977761 (diff) |
QtGui: Fix const correctness in old style casts
Found with GCC's -Wcast-qual.
Change-Id: Ia0aac2f09e9245339951ffff13c946844bc31eb8
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qbmphandler.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qimage.cpp | 20 | ||||
-rw-r--r-- | src/gui/image/qimage_conversions.cpp | 12 | ||||
-rw-r--r-- | src/gui/image/qimage_ssse3.cpp | 4 | ||||
-rw-r--r-- | src/gui/image/qjpeghandler.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qpicture.cpp | 4 | ||||
-rw-r--r-- | src/gui/image/qpnghandler.cpp | 8 |
7 files changed, 26 insertions, 26 deletions
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 61353ebe6d..7a491d8736 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -639,7 +639,7 @@ bool qt_write_dib(QDataStream &s, QImage image) if (nbits == 1 || nbits == 8) { // direct output for (y=image.height()-1; y>=0; y--) { - if (d->write((char*)image.constScanLine(y), bpl) == -1) + if (d->write((const char*)image.constScanLine(y), bpl) == -1) return false; } return true; diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index dba42d4698..8ca58d4e5e 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2053,7 +2053,7 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format, if (format == QImage::Format_Indexed8) { for (int y=0; y<h; ++y) { - QRgb *src_pixels = (QRgb *) src.scanLine(y); + const QRgb *src_pixels = (const QRgb *) src.scanLine(y); uchar *dest_pixels = (uchar *) dest.scanLine(y); for (int x=0; x<w; ++x) { int src_pixel = src_pixels[x]; @@ -2069,7 +2069,7 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format, QVector<QRgb> table = clut; table.resize(2); for (int y=0; y<h; ++y) { - QRgb *src_pixels = (QRgb *) src.scanLine(y); + const QRgb *src_pixels = (const QRgb *) src.scanLine(y); for (int x=0; x<w; ++x) { int src_pixel = src_pixels[x]; int value = cache.value(src_pixel, -1); @@ -2680,7 +2680,7 @@ QImage QImage::createHeuristicMask(bool clipTight) const return img32.createHeuristicMask(clipTight); } -#define PIX(x,y) (*((QRgb*)scanLine(y)+x) & 0x00ffffff) +#define PIX(x,y) (*((const QRgb*)scanLine(y)+x) & 0x00ffffff) int w = width(); int h = height(); @@ -2714,7 +2714,7 @@ QImage QImage::createHeuristicMask(bool clipTight) const ypp = ypc; ypc = ypn; ypn = (y == h-1) ? 0 : m.scanLine(y+1); - QRgb *p = (QRgb *)scanLine(y); + const QRgb *p = (const QRgb *)scanLine(y); for (x = 0; x < w; x++) { // slowness here - it's possible to do six of these tests // together in one go. oh well. @@ -2740,7 +2740,7 @@ QImage QImage::createHeuristicMask(bool clipTight) const ypp = ypc; ypc = ypn; ypn = (y == h-1) ? 0 : m.scanLine(y+1); - QRgb *p = (QRgb *)scanLine(y); + const QRgb *p = (const QRgb *)scanLine(y); for (x = 0; x < w; x++) { if ((*p & 0x00ffffff) != background) { if (x > 0) @@ -2784,7 +2784,7 @@ QImage QImage::createMaskFromColor(QRgb color, Qt::MaskMode mode) const if (depth() == 32) { for (int h = 0; h < d->height; h++) { - const uint *sl = (uint *) scanLine(h); + const uint *sl = (const uint *) scanLine(h); for (int w = 0; w < d->width; w++) { if (sl[w] == color) *(s + (w >> 3)) |= (1 << (w & 7)); @@ -3877,7 +3877,7 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth case 16: // 16 bpp transform while (dptr < maxp) { if (trigx < maxws && trigy < maxhs) - *((ushort*)dptr) = *((ushort *)(sptr+sbpl*(trigy>>12) + + *((ushort*)dptr) = *((const ushort *)(sptr+sbpl*(trigy>>12) + ((trigx>>12)<<1))); trigx += m11; trigy += m12; @@ -3903,7 +3903,7 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth case 32: // 32 bpp transform while (dptr < maxp) { if (trigx < maxws && trigy < maxhs) - *((uint*)dptr) = *((uint *)(sptr+sbpl*(trigy>>12) + + *((uint*)dptr) = *((const uint *)(sptr+sbpl*(trigy>>12) + ((trigx>>12)<<2))); trigx += m11; trigy += m12; @@ -4050,7 +4050,7 @@ void QImage::setAlphaChannel(const QImage &alphaChannel) // Slight optimization since alphachannels are returned as 8-bit grays. if (alphaChannel.format() == QImage::Format_Alpha8 ||( alphaChannel.d->depth == 8 && alphaChannel.isGrayscale())) { const uchar *src_data = alphaChannel.d->data; - const uchar *dest_data = d->data; + uchar *dest_data = d->data; for (int y=0; y<h; ++y) { const uchar *src = src_data; QRgb *dest = (QRgb *)dest_data; @@ -4071,7 +4071,7 @@ void QImage::setAlphaChannel(const QImage &alphaChannel) } else { const QImage sourceImage = alphaChannel.convertToFormat(QImage::Format_RGB32); const uchar *src_data = sourceImage.d->data; - const uchar *dest_data = d->data; + uchar *dest_data = d->data; for (int y=0; y<h; ++y) { const QRgb *src = (const QRgb *) src_data; QRgb *dest = (QRgb *) dest_data; diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index fe76c6d3ba..417c185c78 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -286,7 +286,7 @@ Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32(quint32 *dest_data, con // Handle 4 pixels at a time 12 bytes input to 16 bytes output. for (; pixel + 3 < len; pixel += 4) { - const quint32 *src_packed = (quint32 *) src_data; + const quint32 *src_packed = (const quint32 *) src_data; const quint32 src1 = qFromBigEndian(src_packed[0]); const quint32 src2 = qFromBigEndian(src_packed[1]); const quint32 src3 = qFromBigEndian(src_packed[2]); @@ -321,7 +321,7 @@ Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgbx8888(quint32 *dest_data, // Handle 4 pixels at a time 12 bytes input to 16 bytes output. for (; pixel + 3 < len; pixel += 4) { - const quint32 *src_packed = (quint32 *) src_data; + const quint32 *src_packed = (const quint32 *) src_data; const quint32 src1 = src_packed[0]; const quint32 src2 = src_packed[1]; const quint32 src3 = src_packed[2]; @@ -1092,12 +1092,12 @@ void dither_to_Mono(QImageData *dst, const QImageData *src, } else { // 32 bit image if (fromalpha) { while (p < end) { - *b2++ = 255 - (*(uint*)p >> 24); + *b2++ = 255 - (*(const uint*)p >> 24); p += 4; } } else { while (p < end) { - *b2++ = qGray(*(uint*)p); + *b2++ = qGray(*(const uint*)p); p += 4; } } @@ -1115,12 +1115,12 @@ void dither_to_Mono(QImageData *dst, const QImageData *src, } else { // 24 bit image if (fromalpha) { while (p < end) { - *b2++ = 255 - (*(uint*)p >> 24); + *b2++ = 255 - (*(const uint*)p >> 24); p += 4; } } else { while (p < end) { - *b2++ = qGray(*(uint*)p); + *b2++ = qGray(*(const uint*)p); p += 4; } } diff --git a/src/gui/image/qimage_ssse3.cpp b/src/gui/image/qimage_ssse3.cpp index 0f8244689e..4597661776 100644 --- a/src/gui/image/qimage_ssse3.cpp +++ b/src/gui/image/qimage_ssse3.cpp @@ -65,7 +65,7 @@ Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_ssse3(quint32 *dst, con // Mask to have alpha = 0xff const __m128i alphaMask = _mm_set1_epi32(0xff000000); - __m128i *inVectorPtr = (__m128i *)src; + const __m128i *inVectorPtr = (const __m128i *)src; __m128i *dstVectorPtr = (__m128i *)dst; const int simdRoundCount = (len - prologLength) / 16; // one iteration in the loop converts 16 pixels @@ -110,7 +110,7 @@ Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_ssse3(quint32 *dst, con _mm_store_si128(dstVectorPtr, _mm_or_si128(outputVector, alphaMask)); ++dstVectorPtr; } - src = (uchar *)inVectorPtr; + src = (const uchar *)inVectorPtr; dst = (quint32 *)dstVectorPtr; while (dst != end) { diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp index b1146c4297..aff7b79807 100644 --- a/src/gui/image/qjpeghandler.cpp +++ b/src/gui/image/qjpeghandler.cpp @@ -514,7 +514,7 @@ static inline void set_text(const QImage &image, j_compress_ptr cinfo, const QSt comment += it.value().toLatin1(); if (comment.length() > 65530) comment.truncate(65530); - jpeg_write_marker(cinfo, JPEG_COM, (JOCTET *)comment.constData(), comment.size()); + jpeg_write_marker(cinfo, JPEG_COM, (const JOCTET *)comment.constData(), comment.size()); } } diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index 8b62183c20..b63be19153 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -1362,7 +1362,7 @@ void QPictureIO::init() QPictureIO::~QPictureIO() { if (d->parameters) - delete [] (char*)d->parameters; + delete [] d->parameters; delete d; } @@ -1671,7 +1671,7 @@ const char *QPictureIO::parameters() const void QPictureIO::setParameters(const char *parameters) { if (d->parameters) - delete [] (char*)d->parameters; + delete [] d->parameters; d->parameters = qstrdup(parameters); } diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index c3ffd00e15..3c88d2e9c1 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -942,7 +942,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image, vo // 0123456789aBC data[0xB] = looping%0x100; data[0xC] = looping/0x100; - png_write_chunk(png_ptr, (png_byte*)"gIFx", data, 13); + png_write_chunk(png_ptr, const_cast<png_bytep>((const png_byte *)"gIFx"), data, 13); } if (ms_delay >= 0 || disposal!=Unspecified) { uchar data[4]; @@ -950,7 +950,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image, vo data[1] = 0; data[2] = (ms_delay/10)/0x100; // hundredths data[3] = (ms_delay/10)%0x100; - png_write_chunk(png_ptr, (png_byte*)"gIFg", data, 4); + png_write_chunk(png_ptr, const_cast<png_bytep>((const png_byte *)"gIFg"), data, 4); } int height = image.height(); @@ -966,7 +966,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image, vo { png_bytep* row_pointers = new png_bytep[height]; for (int y=0; y<height; y++) - row_pointers[y] = (png_bytep)image.constScanLine(y); + row_pointers[y] = const_cast<png_bytep>(image.constScanLine(y)); png_write_image(png_ptr, row_pointers); delete [] row_pointers; } @@ -978,7 +978,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image, vo png_bytep row_pointers[1]; for (int y=0; y<height; y++) { row = image.copy(0, y, width, 1).convertToFormat(fmt); - row_pointers[0] = png_bytep(row.constScanLine(0)); + row_pointers[0] = const_cast<png_bytep>(row.constScanLine(0)); png_write_rows(png_ptr, row_pointers, 1); } } |