From b7abb46ee7bf0305aa1803cd405a82b75b00a017 Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Fri, 13 Jul 2018 10:21:17 +0300 Subject: [PATCH] [libbreezecommon] Fix build when qreal is float MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: ``` 06:47:17 CMakeFiles/Makefile2:118: recipe for target 'libbreezecommon/CMakeFiles/breezecommon4.dir/all' failed 06:47:17 /workspace/build/libbreezecommon/breezeboxshadowhelper.cpp: In function ‘void Breeze::BoxShadowHelper::blurAlphaNaive(QImage&, int)’: 06:47:17 /workspace/build/libbreezecommon/breezeboxshadowhelper.cpp:138:56: error: conversion from ‘QVector’ to non-scalar type ‘const QVector’ requested 06:47:17 const QVector kernel = computeGaussianKernel(radius); 06:47:17 ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~ 06:47:17 In file included from /usr/include/qt4/QtGui/qpolygon.h:45:0, 06:47:17 from /usr/include/qt4/QtGui/qmatrix.h:45, 06:47:17 from /usr/include/qt4/QtGui/qtransform.h:44, 06:47:17 from /usr/include/qt4/QtGui/qimage.h:45, 06:47:17 from /usr/include/qt4/QtGui/qpixmap.h:50, 06:47:17 from /usr/include/qt4/QtGui/qpainter.h:49, 06:47:17 from /usr/include/qt4/QtGui/QPainter:1, 06:47:17 from /workspace/build/libbreezecommon/breezeboxshadowhelper.h:27, 06:47:17 from /workspace/build/libbreezecommon/breezeboxshadowhelper.cpp:21: 06:47:17 /usr/include/qt4/QtCore/qvector.h: In instantiation of ‘int QVector::sizeOfTypedData() [with T = double]’: 06:47:17 /usr/include/qt4/QtCore/qvector.h:503:49: required from ‘void QVector::realloc(int, int) [with T = double]’ 06:47:17 /usr/include/qt4/QtCore/qvector.h:340:32: required from ‘void QVector::reserve(int) [with T = double]’ 06:47:17 /workspace/build/libbreezecommon/breezeboxshadowhelper.cpp:62:30: required from here 06:47:17 /usr/include/qt4/QtCore/qvector.h:323:49: warning: cast from ‘QVector*’ to ‘const Data* {aka const QVectorTypedData*}’ increases required alignment of target type [-Wcast-align] 06:47:17 return reinterpret_cast(&(reinterpret_cast(this))->array[1]) - reinterpret_cast(this); 06:47:17 ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 06:47:17 make[5]: [libbreezecommon/CMakeFiles/breezecommon4.dir/breezeboxshadowhelper.cpp.o] Error 1 06:47:17 make[4]: [libbreezecommon/CMakeFiles/breezecommon4.dir/all] Error 2 ``` Reviewers: #plasma, hpereiradacosta Subscribers: anthonyfieroni, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D14090 --- libbreezecommon/breezeboxshadowhelper.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libbreezecommon/breezeboxshadowhelper.cpp b/libbreezecommon/breezeboxshadowhelper.cpp index 17d18ecd..1f345e3a 100644 --- a/libbreezecommon/breezeboxshadowhelper.cpp +++ b/libbreezecommon/breezeboxshadowhelper.cpp @@ -85,7 +85,7 @@ QVector computeGaussianKernel(int radius) // is transposed. So, the dst image should have proper size, e.g. if the src // image have (wxh) size then the dst image should have (hxw) size. The // result is transposed so we read memory in linear order. -void blurAlphaNaivePass(const QImage &src, QImage &dst, const QVector &kernel) +void blurAlphaNaivePass(const QImage &src, QImage &dst, const QVector &kernel) { const int alphaOffset = QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 3; const int alphaStride = src.depth() >> 3; @@ -97,7 +97,7 @@ void blurAlphaNaivePass(const QImage &src, QImage &dst, const QVector &ke for (int x = 0; x < radius; x++) { const uchar *window = in; - qreal alpha = 0; + double alpha = 0.0; for (int k = radius - x; k < kernel.size(); k++) { alpha += *window * kernel[k]; window += alphaStride; @@ -108,7 +108,7 @@ void blurAlphaNaivePass(const QImage &src, QImage &dst, const QVector &ke for (int x = radius; x < src.width() - radius; x++) { const uchar *window = in + (x - radius) * alphaStride; - qreal alpha = 0; + double alpha = 0.0; for (int k = 0; k < kernel.size(); k++) { alpha += *window * kernel[k]; window += alphaStride; @@ -119,7 +119,7 @@ void blurAlphaNaivePass(const QImage &src, QImage &dst, const QVector &ke for (int x = src.width() - radius; x < src.width(); x++) { const uchar *window = in + (x - radius - 1) * alphaStride; - qreal alpha = 0; + double alpha = 0.0; const int outside = x + radius - src.width(); for (int k = 0; k < kernel.size() - outside; k++) { alpha += *window * kernel[k]; @@ -135,7 +135,7 @@ void blurAlphaNaivePass(const QImage &src, QImage &dst, const QVector &ke // gaussian kernel. Not very efficient with big blur radii. void blurAlphaNaive(QImage &img, int radius) { - const QVector kernel = computeGaussianKernel(radius); + const QVector kernel = computeGaussianKernel(radius); QImage tmp(img.height(), img.width(), img.format()); blurAlphaNaivePass(img, tmp, kernel); // horizontal pass @@ -224,7 +224,7 @@ void blurAlphaFFT(QImage &img, int radius) fftw_execute(imageIFFT); // Copy result back. Please note, result is scaled by `width x height` so we need to scale it down. - const qreal invSize = 1.0 / size; + const double invSize = 1.0 / size; data = img.scanLine(0) + alphaOffset; for (int i = 0; i < size; i++) { *data = imageIn[i][0] * invSize;