# HG changeset patch # User Chris Cannam # Date 1479383339 0 # Node ID d89e04b0eff3c8cdfe598c2337682b6fdc4a4d51 # Parent c036560a7205ac3826c61c027caf6be4d28071b0 Backed out changeset c036560a7205 diff -r c036560a7205 -r d89e04b0eff3 layer/Colour3DPlotRenderer.cpp --- a/layer/Colour3DPlotRenderer.cpp Thu Nov 17 11:48:42 2016 +0000 +++ b/layer/Colour3DPlotRenderer.cpp Thu Nov 17 11:48:59 2016 +0000 @@ -31,7 +31,7 @@ #include -#define DEBUG_COLOUR_PLOT_REPAINT 1 +//#define DEBUG_COLOUR_PLOT_REPAINT 1 using namespace std; @@ -578,66 +578,6 @@ } } -QImage -Colour3DPlotRenderer::scaleDrawBufferImage(QImage image, - int targetWidth, - int targetHeight) const -{ - int sourceWidth = image.width(); - int sourceHeight = image.height(); - - // We can only do this if we're making the image larger -- - // otherwise peaks may be lost. So this should be called only when - // rendering in DrawBufferBinResolution mode. Whenever the bin - // size is smaller than the pixel size, in either x or y axis, we - // should be using DrawBufferPixelResolution mode instead - - if (targetWidth < sourceWidth || targetHeight < sourceHeight) { - throw std::logic_error("Colour3DPlotRenderer::scaleDrawBufferImage: Can only use this function when making the image larger; should be rendering DrawBufferPixelResolution instead"); - } - - if (sourceWidth <= 0 || sourceHeight <= 0) { - throw std::logic_error("Colour3DPlotRenderer::scaleDrawBufferImage: Source image is empty"); - } - - if (targetWidth <= 0 || targetHeight <= 0) { - throw std::logic_error("Colour3DPlotRenderer::scaleDrawBufferImage: Target image is empty"); - } - - // This function exists because of some unpredictable behaviour - // from Qt when scaling images with FastTransformation mode. We - // continue to use Qt's scaler for SmoothTransformation but let's - // bring the non-interpolated version "in-house" so we know what - // it's really doing. - - if (m_params.interpolate) { - return image.scaled(targetWidth, targetHeight, - Qt::IgnoreAspectRatio, - Qt::SmoothTransformation); - } - - // Same format as the target cache - QImage target(targetWidth, targetHeight, QImage::Format_ARGB32_Premultiplied); - - for (int y = 0; y < targetHeight; ++y) { - - QRgb *targetLine = reinterpret_cast(target.scanLine(y)); - - int sy = int((uint64_t(y) * sourceHeight) / targetHeight); - if (sy == sourceHeight) --sy; - - for (int x = 0; x < targetWidth; ++x) { - - int sx = int((uint64_t(x) * sourceWidth) / targetWidth); - if (sx == sourceWidth) --sx; - - targetLine[x] = image.pixel(sx, sy); - } - } - - return target; -} - void Colour3DPlotRenderer::renderToCacheBinResolution(const LayerGeometryProvider *v, int x0, int repaintWidth) @@ -710,7 +650,8 @@ binforx[x] = int(leftBoundaryFrame / binResolution) + x; } - SVDEBUG << "[BIN] binResolution " << binResolution << endl; + SVDEBUG << "[BIN] binResolution " << binResolution + << endl; for (int y = 0; y < h; ++y) { binfory[y] = m_sources.verticalBinLayer->getBinForY(v, h - y - 1); @@ -734,9 +675,12 @@ << " to " << (scaledRight - scaledLeft) << " (nb drawBufferWidth = " << drawBufferWidth << ")" << endl; #endif - - QImage scaled = scaleDrawBufferImage - (m_drawBuffer, scaledRight - scaledLeft, h); + + QImage scaled = m_drawBuffer.scaled + (scaledRight - scaledLeft, h, + Qt::IgnoreAspectRatio, (m_params.interpolate ? + Qt::SmoothTransformation : + Qt::FastTransformation)); int scaledLeftCrop = v->getXForFrame(leftCropFrame); int scaledRightCrop = v->getXForFrame(rightCropFrame); @@ -800,11 +744,8 @@ int divisor = 1; const DenseThreeDimensionalModel *sourceModel = m_sources.source; if (usePeakCache) { - cerr << "usePeakCache is true, with divisor " << divisor << endl; divisor = m_sources.peakCache->getColumnsPerPeak(); sourceModel = m_sources.peakCache; - } else { - cerr << "usePeakCache is false" << endl; } int sh = sourceModel->getHeight(); @@ -860,7 +801,7 @@ if (sx1 <= sx0) sx1 = sx0 + 1; #ifdef DEBUG_COLOUR_PLOT_REPAINT -// cerr << "x = " << x << ", binforx[x] = " << binforx[x] << ", sx range " << sx0 << " -> " << sx1 << endl; + cerr << "x = " << x << ", binforx[x] = " << binforx[x] << ", sx range " << sx0 << " -> " << sx1 << endl; #endif vector pixelPeakColumn; diff -r c036560a7205 -r d89e04b0eff3 layer/Colour3DPlotRenderer.h --- a/layer/Colour3DPlotRenderer.h Thu Nov 17 11:48:42 2016 +0000 +++ b/layer/Colour3DPlotRenderer.h Thu Nov 17 11:48:59 2016 +0000 @@ -302,9 +302,6 @@ RenderType decideRenderType(const LayerGeometryProvider *) const; - QImage scaleDrawBufferImage(QImage source, int targetWidth, int targetHeight) - const; - ColumnOp::Column getColumn(int sx, int minbin, int nbins, bool usePeakCache) const; };