# HG changeset patch # User Chris Cannam # Date 1468936186 -3600 # Node ID 261a000109180b1b51c80fa6967b6ff2c8ca1a68 # Parent d578b685d9126cbb34e0b52dbc0997b4b5ecf810 Consts and willRenderOpaque diff -r d578b685d912 -r 261a00010918 layer/Colour3DPlotLayer.cpp --- a/layer/Colour3DPlotLayer.cpp Tue Jul 19 10:12:30 2016 +0100 +++ b/layer/Colour3DPlotLayer.cpp Tue Jul 19 14:49:46 2016 +0100 @@ -614,9 +614,9 @@ if (m_normalizeVisibleArea) { return false; } -//!!! if (shouldPaintDenseIn(v)) { -// return true; -// } + if (getRenderer(v)->willRenderOpaque(v)) { + return true; + } QPoint discard; return !v->shouldIlluminateLocalFeatures(this, discard); } @@ -724,7 +724,7 @@ } double -Colour3DPlotLayer::getYForBin(LayerGeometryProvider *v, double bin) const +Colour3DPlotLayer::getYForBin(const LayerGeometryProvider *v, double bin) const { double y = bin; if (!m_model) return y; @@ -742,7 +742,7 @@ } double -Colour3DPlotLayer::getBinForY(LayerGeometryProvider *v, double y) const +Colour3DPlotLayer::getBinForY(const LayerGeometryProvider *v, double y) const { double bin = y; if (!m_model) return bin; @@ -1064,7 +1064,7 @@ } */ Colour3DPlotRenderer * -Colour3DPlotLayer::getRenderer(LayerGeometryProvider *v) const +Colour3DPlotLayer::getRenderer(const LayerGeometryProvider *v) const { if (m_renderers.find(v->getId()) == m_renderers.end()) { diff -r d578b685d912 -r 261a00010918 layer/Colour3DPlotLayer.h --- a/layer/Colour3DPlotLayer.h Tue Jul 19 10:12:30 2016 +0100 +++ b/layer/Colour3DPlotLayer.h Tue Jul 19 14:49:46 2016 +0100 @@ -187,7 +187,7 @@ typedef std::map ViewRendererMap; // key is view id mutable ViewRendererMap m_renderers; - Colour3DPlotRenderer *getRenderer(LayerGeometryProvider *) const; + Colour3DPlotRenderer *getRenderer(const LayerGeometryProvider *) const; void invalidateRenderers(); /** @@ -196,7 +196,7 @@ * and the vertical scale is the usual way up). Bin number may be * fractional, to obtain a position part-way through a bin. */ - double getYForBin(LayerGeometryProvider *, double bin) const; + double getYForBin(const LayerGeometryProvider *, double bin) const; /** * Return the bin number, possibly fractional, at the given y @@ -204,7 +204,7 @@ * at which the bins "start" (i.e. the bottom of the visible bin, * if the vertical scale is the usual way up). */ - double getBinForY(LayerGeometryProvider *, double y) const; + double getBinForY(const LayerGeometryProvider *, double y) const; DenseThreeDimensionalModel::Column getColumn(int col) const; diff -r d578b685d912 -r 261a00010918 layer/Colour3DPlotRenderer.cpp --- a/layer/Colour3DPlotRenderer.cpp Tue Jul 19 10:12:30 2016 +0100 +++ b/layer/Colour3DPlotRenderer.cpp Tue Jul 19 14:49:46 2016 +0100 @@ -33,13 +33,13 @@ using namespace std; Colour3DPlotRenderer::RenderResult -Colour3DPlotRenderer::render(LayerGeometryProvider *v, QPainter &paint, QRect rect) +Colour3DPlotRenderer::render(const LayerGeometryProvider *v, QPainter &paint, QRect rect) { return render(v, paint, rect, false); } Colour3DPlotRenderer::RenderResult -Colour3DPlotRenderer::renderTimeConstrained(LayerGeometryProvider *v, +Colour3DPlotRenderer::renderTimeConstrained(const LayerGeometryProvider *v, QPainter &paint, QRect rect) { return render(v, paint, rect, true); @@ -62,7 +62,7 @@ } Colour3DPlotRenderer::RenderResult -Colour3DPlotRenderer::render(LayerGeometryProvider *v, +Colour3DPlotRenderer::render(const LayerGeometryProvider *v, QPainter &paint, QRect rect, bool timeConstrained) { RenderType renderType = decideRenderType(v); @@ -223,7 +223,7 @@ } Colour3DPlotRenderer::RenderType -Colour3DPlotRenderer::decideRenderType(LayerGeometryProvider *v) const +Colour3DPlotRenderer::decideRenderType(const LayerGeometryProvider *v) const { const DenseThreeDimensionalModel *model = m_sources.source; if (!model || !v || !(v->getViewManager())) { @@ -261,7 +261,7 @@ } void -Colour3DPlotRenderer::renderDirectTranslucent(LayerGeometryProvider *v, +Colour3DPlotRenderer::renderDirectTranslucent(const LayerGeometryProvider *v, QPainter &paint, QRect rect) { @@ -421,7 +421,7 @@ } void -Colour3DPlotRenderer::renderToCachePixelResolution(LayerGeometryProvider *v, +Colour3DPlotRenderer::renderToCachePixelResolution(const LayerGeometryProvider *v, int x0, int repaintWidth, bool rightToLeft, bool timeConstrained) @@ -513,7 +513,7 @@ } void -Colour3DPlotRenderer::renderToCacheBinResolution(LayerGeometryProvider *v, +Colour3DPlotRenderer::renderToCacheBinResolution(const LayerGeometryProvider *v, int x0, int repaintWidth) { cerr << "renderToCacheBinResolution" << endl; @@ -788,7 +788,7 @@ } int -Colour3DPlotRenderer::renderDrawBufferPeakFrequencies(LayerGeometryProvider *v, +Colour3DPlotRenderer::renderDrawBufferPeakFrequencies(const LayerGeometryProvider *v, int w, int h, const vector &binforx, const vector &binfory, diff -r d578b685d912 -r 261a00010918 layer/Colour3DPlotRenderer.h --- a/layer/Colour3DPlotRenderer.h Tue Jul 19 10:12:30 2016 +0100 +++ b/layer/Colour3DPlotRenderer.h Tue Jul 19 14:49:46 2016 +0100 @@ -120,7 +120,7 @@ * that the LayerGeometryProvider returns valid results; it is the * caller's responsibility to ensure these. */ - RenderResult render(LayerGeometryProvider *v, QPainter &paint, QRect rect); + RenderResult render(const LayerGeometryProvider *v, QPainter &paint, QRect rect); /** * Render the requested area using the given painter, obtaining @@ -147,7 +147,7 @@ * that the LayerGeometryProvider returns valid results; it is the * caller's responsibility to ensure these. */ - RenderResult renderTimeConstrained(LayerGeometryProvider *v, + RenderResult renderTimeConstrained(const LayerGeometryProvider *v, QPainter &paint, QRect rect); /** @@ -163,6 +163,15 @@ * Returns an empty QRect if the cache is entirely valid. */ QRect getLargestUncachedRect(); + + /** + * Return true if the rendering will be opaque. This may be used + * by the calling layer to determine whether it can scroll + * directly without regard to any other layers beneath. + */ + bool willRenderOpaque(const LayerGeometryProvider *v) { + return decideRenderType(v) != DirectTranslucent; + } private: Sources m_sources; @@ -183,17 +192,17 @@ // then repainting from cache to the requested painter. ScrollableImageCache m_cache; - RenderResult render(LayerGeometryProvider *v, + RenderResult render(const LayerGeometryProvider *v, QPainter &paint, QRect rect, bool timeConstrained); - void renderDirectTranslucent(LayerGeometryProvider *v, + void renderDirectTranslucent(const LayerGeometryProvider *v, QPainter &paint, QRect rect); - void renderToCachePixelResolution(LayerGeometryProvider *v, int x0, + void renderToCachePixelResolution(const LayerGeometryProvider *v, int x0, int repaintWidth, bool rightToLeft, bool timeConstrained); - void renderToCacheBinResolution(LayerGeometryProvider *v, int x0, + void renderToCacheBinResolution(const LayerGeometryProvider *v, int x0, int repaintWidth); int renderDrawBuffer(int w, int h, @@ -203,7 +212,7 @@ bool rightToLeft, bool timeConstrained); - int renderDrawBufferPeakFrequencies(LayerGeometryProvider *v, + int renderDrawBufferPeakFrequencies(const LayerGeometryProvider *v, int w, int h, const std::vector &binforx, const std::vector &binfory, @@ -219,7 +228,7 @@ DirectTranslucent }; - RenderType decideRenderType(LayerGeometryProvider *) const; + RenderType decideRenderType(const LayerGeometryProvider *) const; }; #endif diff -r d578b685d912 -r 261a00010918 layer/ScrollableImageCache.cpp --- a/layer/ScrollableImageCache.cpp Tue Jul 19 10:12:30 2016 +0100 +++ b/layer/ScrollableImageCache.cpp Tue Jul 19 14:49:46 2016 +0100 @@ -20,7 +20,8 @@ #define DEBUG_SCROLLABLE_IMAGE_CACHE 1 void -ScrollableImageCache::scrollTo(LayerGeometryProvider *v, sv_frame_t newStartFrame) +ScrollableImageCache::scrollTo(const LayerGeometryProvider *v, + sv_frame_t newStartFrame) { if (m_startFrame == newStartFrame) { // haven't moved diff -r d578b685d912 -r 261a00010918 layer/ScrollableImageCache.h --- a/layer/ScrollableImageCache.h Tue Jul 19 10:12:30 2016 +0100 +++ b/layer/ScrollableImageCache.h Tue Jul 19 14:49:46 2016 +0100 @@ -116,7 +116,7 @@ * also moving along any existing valid data within the cache so * that it continues to be valid for the new start frame. */ - void scrollTo(LayerGeometryProvider *v, sv_frame_t newStartFrame); + void scrollTo(const LayerGeometryProvider *v, sv_frame_t newStartFrame); /** * Take a left coordinate and width describing a region, and diff -r d578b685d912 -r 261a00010918 layer/SpectrogramLayer.cpp --- a/layer/SpectrogramLayer.cpp Tue Jul 19 10:12:30 2016 +0100 +++ b/layer/SpectrogramLayer.cpp Tue Jul 19 14:49:46 2016 +0100 @@ -1089,13 +1089,13 @@ } double -SpectrogramLayer::getYForBin(LayerGeometryProvider *, double) const { +SpectrogramLayer::getYForBin(const LayerGeometryProvider *, double) const { //!!! not implemented throw std::logic_error("not implemented"); } double -SpectrogramLayer::getBinForY(LayerGeometryProvider *v, double y) const +SpectrogramLayer::getBinForY(const LayerGeometryProvider *v, double y) const { //!!! overlap with range methods above (but using double arg) //!!! tidy this diff -r d578b685d912 -r 261a00010918 layer/SpectrogramLayer.h --- a/layer/SpectrogramLayer.h Tue Jul 19 10:12:30 2016 +0100 +++ b/layer/SpectrogramLayer.h Tue Jul 19 14:49:46 2016 +0100 @@ -195,8 +195,8 @@ double getFrequencyForY(const LayerGeometryProvider *v, int y) const; //!!! VerticalBinLayer methods. Note overlap with get*BinRange() - double getYForBin(LayerGeometryProvider *, double bin) const; - double getBinForY(LayerGeometryProvider *, double y) const; + double getYForBin(const LayerGeometryProvider *, double bin) const; + double getBinForY(const LayerGeometryProvider *, double y) const; virtual int getCompletion(LayerGeometryProvider *v) const; virtual QString getError(LayerGeometryProvider *v) const; diff -r d578b685d912 -r 261a00010918 layer/VerticalBinLayer.h --- a/layer/VerticalBinLayer.h Tue Jul 19 10:12:30 2016 +0100 +++ b/layer/VerticalBinLayer.h Tue Jul 19 14:49:46 2016 +0100 @@ -33,12 +33,12 @@ * and the vertical scale is the usual way up). Bin number may be * fractional, to obtain a position part-way through a bin. */ - virtual double getYForBin(LayerGeometryProvider *, double bin) const = 0; + virtual double getYForBin(const LayerGeometryProvider *, double bin) const = 0; /** * As getYForBin, but rounding to integer values. */ - virtual int getIYForBin(LayerGeometryProvider *v, int bin) const { + virtual int getIYForBin(const LayerGeometryProvider *v, int bin) const { return int(round(getYForBin(v, bin))); } @@ -48,12 +48,12 @@ * at which the bins "start" (i.e. the bottom of the visible bin, * if the vertical scale is the usual way up). */ - virtual double getBinForY(LayerGeometryProvider *, double y) const = 0; + virtual double getBinForY(const LayerGeometryProvider *, double y) const = 0; /** * As getBinForY, but rounding to integer values. */ - virtual int getIBinForY(LayerGeometryProvider *v, int y) const { + virtual int getIBinForY(const LayerGeometryProvider *v, int y) const { return int(floor(getBinForY(v, y))); } };