# HG changeset patch # User Sebastien Jodogne # Date 1562752718 -7200 # Node ID 6e888cf6a48be44f3f281aa0409ae8a3c4d9fb56 # Parent 4bc8d9609447376985c129780b22c597503d8805 renderers now have access to canvas width/height diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/CairoCompositor.h --- 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 diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/CairoBaseRenderer.h --- 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()); - } + } }; } } diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/CairoColorTextureRenderer.h --- 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_); diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/CairoFloatTextureRenderer.cpp --- 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_); diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/CairoFloatTextureRenderer.h --- 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); }; } } diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/CairoInfoPanelRenderer.cpp --- 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(); diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/CairoInfoPanelRenderer.h --- 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); }; } } diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/CairoLookupTableTextureRenderer.cpp --- 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_); diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/CairoLookupTableTextureRenderer.h --- 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); }; } } diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/CairoPolylineRenderer.cpp --- 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(); diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/CairoPolylineRenderer.h --- 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); }; } } diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/CairoTextRenderer.cpp --- 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) diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/CairoTextRenderer.h --- 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); }; } } diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/CompositorHelper.cpp --- 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(canvasHeight) / 2.0); sceneTransform_ = AffineTransform2D::Combine(offset, scene_.GetSceneToCanvasTransform()); + canvasWidth_ = canvasWidth; + canvasHeight_ = canvasHeight; scene_.Apply(*this); } } diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/CompositorHelper.h --- 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, diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/ICairoContextProvider.h --- 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; }; } } diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/OpenGLAdvancedPolylineRenderer.h --- 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); } diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/OpenGLColorTextureRenderer.cpp --- 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) { diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/OpenGLColorTextureRenderer.h --- 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); }; diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.cpp --- 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) { diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/OpenGLFloatTextureRenderer.h --- 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); }; diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/OpenGLInfoPanelRenderer.cpp --- 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 diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/OpenGLInfoPanelRenderer.h --- 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) { diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/OpenGLLookupTableTextureRenderer.cpp --- 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) { diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/OpenGLLookupTableTextureRenderer.h --- 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); }; diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/OpenGLTextRenderer.cpp --- 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) { diff -r 4bc8d9609447 -r 6e888cf6a48b Framework/Scene2D/Internals/OpenGLTextRenderer.h --- 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); };