diff options
author | Armin Le Grand (Allotropia) <Armin.Le.Grand@me.com> | 2023-01-17 12:13:26 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2023-01-17 14:53:40 +0000 |
commit | 6c8b6fa6c6d4a1a20d8ebaf36b16c1d20cf109e0 (patch) | |
tree | 6df2c21aac8d516ccc0edcd7de879b2a1fd7ca17 /drawinglayer/source/processor2d | |
parent | 8446cac7d39d3f09f9dd0d5b513ceb96184b0da8 (diff) |
SDPR: use correct Viewport for sub renderer
Change-Id: Ia10731fbe44c812120ed6594959ddee909568187
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145666
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'drawinglayer/source/processor2d')
-rw-r--r-- | drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx b/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx index e93e1375bc07..21a441783ca6 100644 --- a/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx @@ -575,6 +575,20 @@ public: if (hasRenderTarget()) { + // set Viewort if none was given. We have a fixed pixel target, s we know the + // exact Viewport to work on + if (getViewInformation2D().getViewport().isEmpty()) + { + drawinglayer::geometry::ViewInformation2D aViewInformation(getViewInformation2D()); + basegfx::B2DRange aViewport(0.0, 0.0, nWidth, nHeight); + basegfx::B2DHomMatrix aInvViewTransform(aViewInformation.getViewTransformation()); + + aInvViewTransform.invert(); + aViewport.transform(aInvViewTransform); + aViewInformation.setViewport(aViewport); + updateViewInformation(aViewInformation); + } + // clear as render preparation getRenderTarget()->BeginDraw(); getRenderTarget()->Clear(D2D1::ColorF(0.0f, 0.0f, 0.0f, 0.0f)); @@ -936,14 +950,25 @@ sal::systools::COMReference<ID2D1Bitmap> D2DPixelProcessor2D::implCreateAlpha_Di // locally and Clear() it (see class def above). // That way it is not necessary to patch/relocate all the local variables (safer) // and the renderer has no real overhead itself - const basegfx::B2DHomMatrix aEmbedTransform(basegfx::utils::createTranslateB2DHomMatrix( - -rVisibleRange.getMinX(), -rVisibleRange.getMinY())); - geometry::ViewInformation2D aViewInformation2D(getViewInformation2D()); - aViewInformation2D.setViewTransformation(aEmbedTransform - * getViewInformation2D().getViewTransformation()); - D2DBitmapPixelProcessor2D aSubContentRenderer( - aViewInformation2D, ceil(rVisibleRange.getWidth()), ceil(rVisibleRange.getHeight()), - getRenderTarget()); + geometry::ViewInformation2D aAdaptedViewInformation2D(getViewInformation2D()); + const double fTargetWidth(ceil(rVisibleRange.getWidth())); + const double fTargetHeight(ceil(rVisibleRange.getHeight())); + + { + // create adapted ViewTransform, needs to be offset in discrete coordinates, + // so multiply from left + basegfx::B2DHomMatrix aAdapted(basegfx::utils::createTranslateB2DHomMatrix( + -rVisibleRange.getMinX(), -rVisibleRange.getMinY()) + * getViewInformation2D().getViewTransformation()); + aAdaptedViewInformation2D.setViewTransformation(aAdapted); + + // reset Viewport (world coordinates), so the helper renderer will create it's + // own based on it's given internal discrete size + aAdaptedViewInformation2D.setViewport(basegfx::B2DRange()); + } + + D2DBitmapPixelProcessor2D aSubContentRenderer(aAdaptedViewInformation2D, fTargetWidth, + fTargetHeight, getRenderTarget()); if (!aSubContentRenderer.valid()) { |