Kaydet (Commit) 144eb666 authored tarafından Armin Le Grand's avatar Armin Le Grand

i110384 added better fat line rendering where possible

üst be3f4139
......@@ -28,6 +28,15 @@
#include <drawinglayer/processor2d/vclprocessor2d.hxx>
#include <vcl/outdev.hxx>
//////////////////////////////////////////////////////////////////////////////
// predefines
namespace drawinglayer { namespace primitive2d {
class PolyPolygonColorPrimitive2D;
class PolygonHairlinePrimitive2D;
class PolygonStrokePrimitive2D;
}}
//////////////////////////////////////////////////////////////////////////////
namespace drawinglayer
......@@ -49,6 +58,11 @@ namespace drawinglayer
*/
virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate);
// some helpers to try direct paints (shortcuts)
bool tryDrawPolyPolygonColorPrimitive2DDirect(const drawinglayer::primitive2d::PolyPolygonColorPrimitive2D& rSource, double fTransparency);
bool tryDrawPolygonHairlinePrimitive2DDirect(const drawinglayer::primitive2d::PolygonHairlinePrimitive2D& rSource, double fTransparency);
bool tryDrawPolygonStrokePrimitive2DDirect(const drawinglayer::primitive2d::PolygonStrokePrimitive2D& rSource, double fTransparency);
public:
/// constructor/destructor
VclPixelProcessor2D(
......
......@@ -41,7 +41,6 @@ namespace drawinglayer { namespace primitive2d {
class FillGraphicPrimitive2D;
class PolyPolygonGradientPrimitive2D;
class PolyPolygonGraphicPrimitive2D;
class PolyPolygonColorPrimitive2D;
class MetafilePrimitive2D;
class MaskPrimitive2D;
class UnifiedTransparencePrimitive2D;
......@@ -98,7 +97,6 @@ namespace drawinglayer
void RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate);
void RenderFillGraphicPrimitive2D(const primitive2d::FillGraphicPrimitive2D& rFillBitmapCandidate);
void RenderPolyPolygonGraphicPrimitive2D(const primitive2d::PolyPolygonGraphicPrimitive2D& rPolygonCandidate);
void RenderPolyPolygonColorPrimitive2D(const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate);
void RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate);
void RenderModifiedColorPrimitive2D(const primitive2d::ModifiedColorPrimitive2D& rModifiedCandidate);
void RenderUnifiedTransparencePrimitive2D(const primitive2d::UnifiedTransparencePrimitive2D& rTransCandidate);
......
......@@ -756,86 +756,6 @@ namespace drawinglayer
}
}
// direct draw of PolyPolygon with color
void VclProcessor2D::RenderPolyPolygonColorPrimitive2D(const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate)
{
const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor()));
mpOutputDevice->SetFillColor(Color(aPolygonColor));
mpOutputDevice->SetLineColor();
basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
aLocalPolyPolygon.transform(maCurrentTransformation);
static bool bCheckTrapezoidDecomposition(false);
static bool bShowOutlinesThere(false);
if(bCheckTrapezoidDecomposition)
{
// clip against discrete ViewPort
const basegfx::B2DRange& rDiscreteViewport = getViewInformation2D().getDiscreteViewport();
aLocalPolyPolygon = basegfx::tools::clipPolyPolygonOnRange(
aLocalPolyPolygon, rDiscreteViewport, true, false);
if(aLocalPolyPolygon.count())
{
// subdivide
aLocalPolyPolygon = basegfx::tools::adaptiveSubdivideByDistance(
aLocalPolyPolygon, 0.5);
// trapezoidize
basegfx::B2DTrapezoidVector aB2DTrapezoidVector;
basegfx::tools::trapezoidSubdivide(aB2DTrapezoidVector, aLocalPolyPolygon);
const sal_uInt32 nCount(aB2DTrapezoidVector.size());
if(nCount)
{
basegfx::BColor aInvPolygonColor(aPolygonColor);
aInvPolygonColor.invert();
for(sal_uInt32 a(0); a < nCount; a++)
{
const basegfx::B2DPolygon aTempPolygon(aB2DTrapezoidVector[a].getB2DPolygon());
if(bShowOutlinesThere)
{
mpOutputDevice->SetFillColor(Color(aPolygonColor));
mpOutputDevice->SetLineColor();
}
mpOutputDevice->DrawPolygon(aTempPolygon);
if(bShowOutlinesThere)
{
mpOutputDevice->SetFillColor();
mpOutputDevice->SetLineColor(Color(aInvPolygonColor));
mpOutputDevice->DrawPolyLine(aTempPolygon, 0.0);
}
}
}
}
}
else
{
mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
if(mnPolygonStrokePrimitive2D
&& getOptionsDrawinglayer().IsAntiAliasing()
&& (mpOutputDevice->GetAntialiasing() & ANTIALIASING_ENABLE_B2DDRAW))
{
// when AA is on and this filled polygons are the result of stroked line geometry,
// draw the geometry once extra as lines to avoid AA 'gaps' between partial polygons
mpOutputDevice->SetFillColor();
mpOutputDevice->SetLineColor(Color(aPolygonColor));
const sal_uInt32 nCount(aLocalPolyPolygon.count());
for(sal_uInt32 a(0); a < nCount; a++)
{
mpOutputDevice->DrawPolyLine(aLocalPolyPolygon.getB2DPolygon(a), 0.0);
}
}
}
}
// mask group. Force output to VDev and create mask from given mask
void VclProcessor2D::RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate)
{
......
......@@ -562,6 +562,7 @@ public:
SAL_DLLPRIVATE bool ImpTryDrawPolyLineDirect(
const basegfx::B2DPolygon& rB2DPolygon,
double fLineWidth = 0.0,
double fTransparency = 0.0,
basegfx::B2DLineJoin eLineJoin = basegfx::B2DLINEJOIN_NONE,
com::sun::star::drawing::LineCap eLineCap = com::sun::star::drawing::LineCap_BUTT);
......@@ -699,6 +700,12 @@ public:
double fLineWidth = 0.0,
basegfx::B2DLineJoin = basegfx::B2DLINEJOIN_ROUND,
com::sun::star::drawing::LineCap = com::sun::star::drawing::LineCap_BUTT);
bool TryDrawPolyLineDirect(
const basegfx::B2DPolygon& rB2DPolygon,
double fLineWidth = 0.0,
double fTransparency = 0.0,
basegfx::B2DLineJoin eLineJoin = basegfx::B2DLINEJOIN_NONE,
com::sun::star::drawing::LineCap eLineCap = com::sun::star::drawing::LineCap_BUTT);
/** Render the given polygon as a line stroke
......
......@@ -2260,6 +2260,7 @@ void OutputDevice::ImpDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyPo
bool OutputDevice::ImpTryDrawPolyLineDirect(
const basegfx::B2DPolygon& rB2DPolygon,
double fLineWidth,
double fTransparency,
basegfx::B2DLineJoin eLineJoin,
com::sun::star::drawing::LineCap eLineCap)
{
......@@ -2289,13 +2290,64 @@ bool OutputDevice::ImpTryDrawPolyLineDirect(
// draw the polyline
return mpGraphics->DrawPolyLine(
aB2DPolygon,
0.0,
fTransparency,
aB2DLineWidth,
eLineJoin,
eLineCap,
this);
}
bool OutputDevice::TryDrawPolyLineDirect(
const basegfx::B2DPolygon& rB2DPolygon,
double fLineWidth,
double fTransparency,
basegfx::B2DLineJoin eLineJoin,
com::sun::star::drawing::LineCap eLineCap)
{
// AW: Do NOT paint empty PolyPolygons
if(!rB2DPolygon.count())
return true;
// we need a graphics
if( !mpGraphics )
if( !ImplGetGraphics() )
return false;
if( mbInitClipRegion )
ImplInitClipRegion();
if( mbOutputClipped )
return true;
if( mbInitLineColor )
ImplInitLineColor();
const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW)
&& mpGraphics->supportsOperation(OutDevSupport_B2DDraw)
&& ROP_OVERPAINT == GetRasterOp()
&& IsLineColor());
if(bTryAA)
{
if(ImpTryDrawPolyLineDirect(rB2DPolygon, fLineWidth, fTransparency, eLineJoin, eLineCap))
{
// worked, add metafile action (if recorded) and return true
if( mpMetaFile )
{
LineInfo aLineInfo;
if( fLineWidth != 0.0 )
aLineInfo.SetWidth( static_cast<long>(fLineWidth+0.5) );
const Polygon aToolsPolygon( rB2DPolygon );
mpMetaFile->AddAction( new MetaPolyLineAction( aToolsPolygon, aLineInfo ) );
}
return true;
}
}
return false;
}
void OutputDevice::DrawPolyLine(
const basegfx::B2DPolygon& rB2DPolygon,
double fLineWidth,
......@@ -2304,8 +2356,6 @@ void OutputDevice::DrawPolyLine(
{
DBG_TRACE( "OutputDevice::DrawPolyLine(B2D&)" );
DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
(void)eLineJoin; // ATM used in UNX, but not in WNT, access it for warning-free
(void)eLineCap;
#if 0 // MetaB2DPolyLineAction is not implemented yet:
// according to AW adding it is very dangerous since there is a lot
......@@ -2347,7 +2397,7 @@ void OutputDevice::DrawPolyLine(
&& IsLineColor());
// use b2dpolygon drawing if possible
if(bTryAA && ImpTryDrawPolyLineDirect(rB2DPolygon, fLineWidth, eLineJoin, eLineCap))
if(bTryAA && ImpTryDrawPolyLineDirect(rB2DPolygon, fLineWidth, 0.0, eLineJoin, eLineCap))
{
return;
}
......
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