Mercurial > hg > orthanc-stone
changeset 888:6e888cf6a48b
renderers now have access to canvas width/height
line wrap: on
line diff
--- a/Framework/Scene2D/CairoCompositor.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/CairoCompositor.h Wed Jul 10 11:58:38 2019 +0200 @@ -44,16 +44,6 @@ virtual cairo_t* GetCairoContext(); - virtual unsigned int GetCairoWidth() - { - return canvas_.GetWidth(); - } - - virtual unsigned int GetCairoHeight() - { - return canvas_.GetHeight(); - } - virtual Internals::CompositorHelper::ILayerRenderer* Create(const ISceneLayer& layer); public: @@ -67,6 +57,16 @@ { return canvas_; } + + unsigned int GetCanvasWidth() const + { + return canvas_.GetWidth(); + } + + unsigned int GetCanvasHeight() const + { + return canvas_.GetHeight(); + } void SetFont(size_t index, GlyphBitmapAlphabet* dict); // Takes ownership
--- a/Framework/Scene2D/Internals/CairoBaseRenderer.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/CairoBaseRenderer.h Wed Jul 10 11:58:38 2019 +0200 @@ -57,7 +57,7 @@ virtual void Update(const ISceneLayer& layer) { layer_.reset(layer.Clone()); - } + } }; } }
--- a/Framework/Scene2D/Internals/CairoColorTextureRenderer.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/CairoColorTextureRenderer.h Wed Jul 10 11:58:38 2019 +0200 @@ -43,7 +43,9 @@ virtual void Update(const ISceneLayer& layer); - virtual void Render(const AffineTransform2D& transform) + virtual void Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight) { RenderColorTexture(target_, transform, texture_, textureTransform_, isLinearInterpolation_);
--- a/Framework/Scene2D/Internals/CairoFloatTextureRenderer.cpp Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/CairoFloatTextureRenderer.cpp Wed Jul 10 11:58:38 2019 +0200 @@ -88,7 +88,9 @@ } - void CairoFloatTextureRenderer::Render(const AffineTransform2D& transform) + void CairoFloatTextureRenderer::Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight) { CairoColorTextureRenderer::RenderColorTexture(target_, transform, texture_, textureTransform_, isLinearInterpolation_);
--- a/Framework/Scene2D/Internals/CairoFloatTextureRenderer.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/CairoFloatTextureRenderer.h Wed Jul 10 11:58:38 2019 +0200 @@ -47,7 +47,9 @@ virtual void Update(const ISceneLayer& layer); - virtual void Render(const AffineTransform2D& transform); + virtual void Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight); }; } }
--- a/Framework/Scene2D/Internals/CairoInfoPanelRenderer.cpp Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/CairoInfoPanelRenderer.cpp Wed Jul 10 11:58:38 2019 +0200 @@ -37,12 +37,14 @@ } - void CairoInfoPanelRenderer::Render(const AffineTransform2D& transform) + void CairoInfoPanelRenderer::Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight) { int dx, dy; InfoPanelSceneLayer::ComputeAnchorLocation( dx, dy, anchor_, texture_.GetWidth(), texture_.GetHeight(), - target_.GetCairoWidth(), target_.GetCairoHeight()); + canvasWidth, canvasHeight); cairo_t* cr = target_.GetCairoContext();
--- a/Framework/Scene2D/Internals/CairoInfoPanelRenderer.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/CairoInfoPanelRenderer.h Wed Jul 10 11:58:38 2019 +0200 @@ -47,7 +47,9 @@ virtual void Update(const ISceneLayer& layer); - virtual void Render(const AffineTransform2D& transform); + virtual void Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight); }; } }
--- a/Framework/Scene2D/Internals/CairoLookupTableTextureRenderer.cpp Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/CairoLookupTableTextureRenderer.cpp Wed Jul 10 11:58:38 2019 +0200 @@ -99,7 +99,9 @@ cairo_surface_mark_dirty(texture_.GetObject()); } - void CairoLookupTableTextureRenderer::Render(const AffineTransform2D& transform) + void CairoLookupTableTextureRenderer::Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight) { CairoColorTextureRenderer::RenderColorTexture(target_, transform, texture_, textureTransform_, isLinearInterpolation_);
--- a/Framework/Scene2D/Internals/CairoLookupTableTextureRenderer.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/CairoLookupTableTextureRenderer.h Wed Jul 10 11:58:38 2019 +0200 @@ -47,7 +47,9 @@ virtual void Update(const ISceneLayer& layer); - virtual void Render(const AffineTransform2D& transform); + virtual void Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight); }; } }
--- a/Framework/Scene2D/Internals/CairoPolylineRenderer.cpp Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/CairoPolylineRenderer.cpp Wed Jul 10 11:58:38 2019 +0200 @@ -27,7 +27,9 @@ { namespace Internals { - void CairoPolylineRenderer::Render(const AffineTransform2D& transform) + void CairoPolylineRenderer::Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight) { const PolylineSceneLayer& layer = GetLayer<PolylineSceneLayer>();
--- a/Framework/Scene2D/Internals/CairoPolylineRenderer.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/CairoPolylineRenderer.h Wed Jul 10 11:58:38 2019 +0200 @@ -36,7 +36,9 @@ { } - virtual void Render(const AffineTransform2D& transform); + virtual void Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight); }; } }
--- a/Framework/Scene2D/Internals/CairoTextRenderer.cpp Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/CairoTextRenderer.cpp Wed Jul 10 11:58:38 2019 +0200 @@ -75,7 +75,9 @@ } - void CairoTextRenderer::Render(const AffineTransform2D& transform) + void CairoTextRenderer::Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight) { if (text_.GetWidth() != 0 && text_.GetHeight() != 0)
--- a/Framework/Scene2D/Internals/CairoTextRenderer.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/CairoTextRenderer.h Wed Jul 10 11:58:38 2019 +0200 @@ -40,7 +40,9 @@ const GlyphBitmapAlphabet& alphabet, const TextSceneLayer& layer); - virtual void Render(const AffineTransform2D& transform); + virtual void Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight); }; } }
--- a/Framework/Scene2D/Internals/CompositorHelper.cpp Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/CompositorHelper.cpp Wed Jul 10 11:58:38 2019 +0200 @@ -107,7 +107,7 @@ if (renderer.get() != NULL) { - renderer->Render(sceneTransform_); + renderer->Render(sceneTransform_, canvasWidth_, canvasHeight_); content_[depth] = new Item(renderer.release(), layer, layerIdentifier); } } @@ -121,7 +121,7 @@ found->second->UpdateRenderer(); } - found->second->GetRenderer().Render(sceneTransform_); + found->second->GetRenderer().Render(sceneTransform_, canvasWidth_, canvasHeight_); } // Check invariants @@ -150,6 +150,8 @@ static_cast<double>(canvasHeight) / 2.0); sceneTransform_ = AffineTransform2D::Combine(offset, scene_.GetSceneToCanvasTransform()); + canvasWidth_ = canvasWidth; + canvasHeight_ = canvasHeight; scene_.Apply(*this); } }
--- a/Framework/Scene2D/Internals/CompositorHelper.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/CompositorHelper.h Wed Jul 10 11:58:38 2019 +0200 @@ -41,7 +41,9 @@ { } - virtual void Render(const AffineTransform2D& transform) = 0; + virtual void Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight) = 0; // "Update()" is only called if the type of the layer has not changed virtual void Update(const ISceneLayer& layer) = 0; @@ -65,8 +67,12 @@ const Scene2D& scene_; IRendererFactory& factory_; Content content_; + + // Only valid during a call to Refresh() AffineTransform2D sceneTransform_; - + unsigned int canvasWidth_; + unsigned int canvasHeight_; + protected: virtual void Visit(const ISceneLayer& layer, uint64_t layerIdentifier,
--- a/Framework/Scene2D/Internals/ICairoContextProvider.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/ICairoContextProvider.h Wed Jul 10 11:58:38 2019 +0200 @@ -37,10 +37,6 @@ } virtual cairo_t* GetCairoContext() = 0; - - virtual unsigned int GetCairoWidth() = 0; - - virtual unsigned int GetCairoHeight() = 0; }; } }
--- a/Framework/Scene2D/Internals/OpenGLAdvancedPolylineRenderer.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLAdvancedPolylineRenderer.h Wed Jul 10 11:58:38 2019 +0200 @@ -43,7 +43,9 @@ OpenGLLinesProgram& program, const PolylineSceneLayer& layer); - virtual void Render(const AffineTransform2D& transform) + virtual void Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight) { program_.Apply(*data_, transform, true, true); }
--- a/Framework/Scene2D/Internals/OpenGLColorTextureRenderer.cpp Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLColorTextureRenderer.cpp Wed Jul 10 11:58:38 2019 +0200 @@ -44,7 +44,9 @@ } - void OpenGLColorTextureRenderer::Render(const AffineTransform2D& transform) + void OpenGLColorTextureRenderer::Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight) { if (texture_.get() != NULL) {
--- a/Framework/Scene2D/Internals/OpenGLColorTextureRenderer.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLColorTextureRenderer.h Wed Jul 10 11:58:38 2019 +0200 @@ -44,7 +44,9 @@ OpenGLColorTextureProgram& program, const ColorTextureSceneLayer& layer); - virtual void Render(const AffineTransform2D& transform); + virtual void Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight); virtual void Update(const ISceneLayer& layer); };
--- a/Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.cpp Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.cpp Wed Jul 10 11:58:38 2019 +0200 @@ -49,7 +49,9 @@ } - void OpenGLFloatTextureRenderer::Render(const AffineTransform2D& transform) + void OpenGLFloatTextureRenderer::Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight) { if (texture_.get() != NULL) {
--- a/Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.h Wed Jul 10 11:58:38 2019 +0200 @@ -47,7 +47,9 @@ OpenGLFloatTextureProgram& program, const FloatTextureSceneLayer& layer); - virtual void Render(const AffineTransform2D& transform); + virtual void Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight); virtual void Update(const ISceneLayer& layer); };
--- a/Framework/Scene2D/Internals/OpenGLInfoPanelRenderer.cpp Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLInfoPanelRenderer.cpp Wed Jul 10 11:58:38 2019 +0200 @@ -44,14 +44,16 @@ } - void OpenGLInfoPanelRenderer::Render(const AffineTransform2D& transform) + void OpenGLInfoPanelRenderer::Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight) { if (texture_.get() != NULL) { int dx, dy; InfoPanelSceneLayer::ComputeAnchorLocation( dx, dy, anchor_, texture_->GetWidth(), texture_->GetHeight(), - context_.GetCanvasWidth(), context_.GetCanvasHeight()); + canvasWidth, canvasHeight); // The position of this type of layer is layer: Ignore the // "transform" coming from the scene
--- a/Framework/Scene2D/Internals/OpenGLInfoPanelRenderer.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLInfoPanelRenderer.h Wed Jul 10 11:58:38 2019 +0200 @@ -44,7 +44,9 @@ OpenGLColorTextureProgram& program, const InfoPanelSceneLayer& layer); - virtual void Render(const AffineTransform2D& transform); + virtual void Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight); virtual void Update(const ISceneLayer& layer) {
--- a/Framework/Scene2D/Internals/OpenGLLookupTableTextureRenderer.cpp Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLLookupTableTextureRenderer.cpp Wed Jul 10 11:58:38 2019 +0200 @@ -119,7 +119,9 @@ } - void OpenGLLookupTableTextureRenderer::Render(const AffineTransform2D& transform) + void OpenGLLookupTableTextureRenderer::Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight) { if (glTexture_.get() != NULL) {
--- a/Framework/Scene2D/Internals/OpenGLLookupTableTextureRenderer.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLLookupTableTextureRenderer.h Wed Jul 10 11:58:38 2019 +0200 @@ -48,7 +48,9 @@ OpenGLColorTextureProgram& program, const LookupTableTextureSceneLayer& layer); - virtual void Render(const AffineTransform2D& transform); + virtual void Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight); virtual void Update(const ISceneLayer& layer); };
--- a/Framework/Scene2D/Internals/OpenGLTextRenderer.cpp Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLTextRenderer.cpp Wed Jul 10 11:58:38 2019 +0200 @@ -45,7 +45,9 @@ } - void OpenGLTextRenderer::Render(const AffineTransform2D& transform) + void OpenGLTextRenderer::Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight) { if (data_.get() != NULL) {
--- a/Framework/Scene2D/Internals/OpenGLTextRenderer.h Tue Jun 25 18:17:33 2019 +0200 +++ b/Framework/Scene2D/Internals/OpenGLTextRenderer.h Wed Jul 10 11:58:38 2019 +0200 @@ -46,7 +46,9 @@ OpenGL::OpenGLTexture& texture, const TextSceneLayer& layer); - virtual void Render(const AffineTransform2D& transform); + virtual void Render(const AffineTransform2D& transform, + unsigned int canvasWidth, + unsigned int canvasHeight); virtual void Update(const ISceneLayer& layer); };