Kaydet (Commit) 1042c2c5 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

use basegfx to convert circle/roundrect to a polygon

The tools::Polygon functions to draw a circle, roundrect are lower
quality.

Change-Id: I6226ac917d600b2a14a99c9a27aa371233799e16
Reviewed-on: https://gerrit.libreoffice.org/68692
Tested-by: Jenkins
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 2f8eb233
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
#include <rtl/bootstrap.hxx> #include <rtl/bootstrap.hxx>
#include <config_folders.h> #include <config_folders.h>
#include <basegfx/range/b2drectangle.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
namespace vcl namespace vcl
{ {
namespace namespace
...@@ -101,12 +104,15 @@ void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom ...@@ -101,12 +104,15 @@ void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom
{ {
auto const& rRectDrawCommand auto const& rRectDrawCommand
= static_cast<RectangleDrawCommand const&>(*pDrawCommand); = static_cast<RectangleDrawCommand const&>(*pDrawCommand);
Point aRectPoint(nX, nY);
Size aRectSize(nWidth - 1, nHeight - 1);
tools::Polygon aPolygon(tools::Rectangle(aRectPoint, aRectSize),
rRectDrawCommand.mnRx, rRectDrawCommand.mnRy);
basegfx::B2DPolygon aB2DPolygon(aPolygon.getB2DPolygon()); basegfx::B2DRectangle rRect(
nX + (nWidth * rRectDrawCommand.mfX1), nY + (nHeight * rRectDrawCommand.mfY1),
nX + (nWidth * rRectDrawCommand.mfX2), nY + (nHeight * rRectDrawCommand.mfY2));
basegfx::B2DPolygon aB2DPolygon = basegfx::utils::createPolygonFromRect(
rRect, rRectDrawCommand.mnRx / rRect.getWidth() * 2.0,
rRectDrawCommand.mnRy / rRect.getHeight() * 2.0);
rGraphics.SetLineColor(); rGraphics.SetLineColor();
rGraphics.SetFillColor(rRectDrawCommand.maFillColor); rGraphics.SetFillColor(rRectDrawCommand.maFillColor);
rGraphics.DrawPolyPolygon(basegfx::B2DHomMatrix(), rGraphics.DrawPolyPolygon(basegfx::B2DHomMatrix(),
...@@ -124,14 +130,15 @@ void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom ...@@ -124,14 +130,15 @@ void munchDrawCommands(std::vector<std::shared_ptr<DrawCommand>> const& rDrawCom
{ {
auto const& rCircleDrawCommand auto const& rCircleDrawCommand
= static_cast<CircleDrawCommand const&>(*pDrawCommand); = static_cast<CircleDrawCommand const&>(*pDrawCommand);
Point aRectPoint(nX + 1, nY + 1);
Size aRectSize(nWidth - 1, nHeight - 1);
tools::Rectangle aRectangle(aRectPoint, aRectSize); basegfx::B2DRectangle rRect(nX + (nWidth * rCircleDrawCommand.mfX1),
tools::Polygon aPolygon(aRectangle.Center(), aRectangle.GetWidth() >> 1, nY + (nHeight * rCircleDrawCommand.mfY1),
aRectangle.GetHeight() >> 1); nX + (nWidth * rCircleDrawCommand.mfX2),
nY + (nHeight * rCircleDrawCommand.mfY2));
basegfx::B2DPolygon aB2DPolygon = basegfx::utils::createPolygonFromEllipse(
rRect.getCenter(), rRect.getWidth() / 2.0, rRect.getHeight() / 2.0);
basegfx::B2DPolygon aB2DPolygon(aPolygon.getB2DPolygon());
rGraphics.SetLineColor(rCircleDrawCommand.maStrokeColor); rGraphics.SetLineColor(rCircleDrawCommand.maStrokeColor);
rGraphics.SetFillColor(rCircleDrawCommand.maFillColor); rGraphics.SetFillColor(rCircleDrawCommand.maFillColor);
rGraphics.DrawPolyPolygon(basegfx::B2DHomMatrix(), rGraphics.DrawPolyPolygon(basegfx::B2DHomMatrix(),
...@@ -177,10 +184,10 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart ...@@ -177,10 +184,10 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
bool bOldAA = m_rGraphics.getAntiAliasB2DDraw(); bool bOldAA = m_rGraphics.getAntiAliasB2DDraw();
m_rGraphics.setAntiAliasB2DDraw(true); m_rGraphics.setAntiAliasB2DDraw(true);
long nWidth = rControlRegion.GetWidth(); long nWidth = rControlRegion.GetWidth() - 1;
long nHeight = rControlRegion.GetHeight(); long nHeight = rControlRegion.GetHeight() - 1;
long nX = rControlRegion.Left() + 1; long nX = rControlRegion.Left();
long nY = rControlRegion.Top() + 1; long nY = rControlRegion.Top();
bool bOK = false; bool bOK = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment