54 * rPolygon.
getB2DPoint((nIndex + nCount - 1) % nCount)));
63 const bool bPrevVertical(aPrevTuple.getX() == aCurrTuple.getX());
64 const bool bNextVertical(aNextTuple.getX() == aCurrTuple.getX());
65 const bool bPrevHorizontal(aPrevTuple.getY() == aCurrTuple.getY());
66 const bool bNextHorizontal(aNextTuple.getY() == aCurrTuple.getY());
67 const bool bSnapX(bPrevVertical || bNextVertical);
68 const bool bSnapY(bPrevHorizontal || bNextHorizontal);
73 bSnapY ? aCurrTuple.getY() : aCurrPoint.getY());
87 const sal_uInt32 nPointCount(rPolygon.
count());
90 const bool bClosePath(rPolygon.
isClosed());
93 for (sal_uInt32 nPointIdx = 0, nPrevIdx = 0;; nPrevIdx = nPointIdx++)
95 int nClosedIdx = nPointIdx;
96 if (nPointIdx >= nPointCount)
99 if (bClosePath && (nPointIdx == nPointCount))
111 : impPixelSnap(rPolygon, *pViewInformation, nClosedIdx));
116 cairo_move_to(cr, aPoint.getX(), aPoint.getY());
121 bool bPendingCurve(
false);
131 cairo_line_to(cr, aPoint.getX(), aPoint.getY());
142 if (aCP1.
equal(aLast))
144 aCP1 = aLast + ((aCP2 - aLast) * 0.0005);
147 if (aCP2.
equal(aPoint))
149 aCP2 = aPoint + ((aCP1 - aPoint) * 0.0005);
152 cairo_curve_to(cr, aCP1.
getX(), aCP1.
getY(), aCP2.
getX(), aCP2.
getY(), aPoint.getX(),
161 cairo_close_path(cr);
166std::vector<sal_uInt8> createBitmapData(
const BitmapEx& rBitmapEx)
169 const bool bAlpha(rBitmapEx.
IsAlpha());
170 const sal_uInt32 nStride
171 = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, rSizePixel.Width());
172 std::vector<sal_uInt8>
aData(nStride * rSizePixel.Height());
184 unsigned char* pPixelData =
aData.data() + (nStride *
y);
187 const BitmapColor aColor(pReadAccess->GetColor(y, x));
188 const BitmapColor aAlpha(pAlphaReadAccess->GetColor(y, x));
189 const sal_uInt16 nAlpha(255 - aAlpha.GetRed());
207 unsigned char* pPixelData =
aData.data() + (nStride *
y);
210 const BitmapColor aColor(pReadAccess->GetColor(y, x));
228 , maBColorModifierStack()
236 , maBColorModifierStack()
241 cairo_t* pRT = cairo_create(pTarget);
242 cairo_set_antialias(pRT, rViewInformation.
getUseAntiAliasing() ? CAIRO_ANTIALIAS_DEFAULT
243 : CAIRO_ANTIALIAS_NONE);
259 if (!rPolygon.
count())
264 cairo_matrix_t aMatrix;
268 cairo_matrix_init(&aMatrix, rObjectToView.
a(), rObjectToView.
b(), rObjectToView.
c(),
269 rObjectToView.
d(), rObjectToView.
e() + fAAOffset,
270 rObjectToView.
f() + fAAOffset);
273 cairo_set_matrix(
mpRT, &aMatrix);
286 cairo_set_line_width(
mpRT, 1.44f);
306 cairo_matrix_t aMatrix;
310 cairo_matrix_init(&aMatrix, rObjectToView.
a(), rObjectToView.
b(), rObjectToView.
c(),
311 rObjectToView.
d(), rObjectToView.
e() + fAAOffset,
312 rObjectToView.
f() + fAAOffset);
315 cairo_set_matrix(
mpRT, &aMatrix);
321 for (
const auto& rPolygon : rPolyPolygon)
337 if (!rDiscreteViewPort.
isEmpty())
343 if (!aUnitRange.
overlaps(rDiscreteViewPort))
381 std::vector<sal_uInt8> aPixelData(createBitmapData(aBitmapEx));
384 aPixelData.data(), CAIRO_FORMAT_ARGB32, rSizePixel.
Width(), rSizePixel.
Height(),
385 cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, rSizePixel.
Width()));
389 cairo_matrix_t aMatrix;
391 cairo_matrix_init(&aMatrix, aLocalTransform.
a(), aLocalTransform.
b(), aLocalTransform.
c(),
392 aLocalTransform.
d(), aLocalTransform.
e() + fAAOffset,
393 aLocalTransform.
f() + fAAOffset);
396 cairo_set_matrix(
mpRT, &aMatrix);
399 cairo_rectangle(
mpRT, 0, 0, 1, 1);
402 cairo_set_source_surface(
mpRT, pBitmapSurface, 0, 0);
404 cairo_pattern_t* sourcepattern = cairo_get_source(
mpRT);
405 cairo_pattern_get_matrix(sourcepattern, &aMatrix);
407 cairo_matrix_scale(&aMatrix, rSizePixel.
Width(), rSizePixel.
Height());
408 cairo_pattern_set_matrix(sourcepattern, &aMatrix);
412 cairo_surface_destroy(pBitmapSurface);
422 cairo_surface_flush(pMask);
424 int nWidth = cairo_image_surface_get_width(pMask);
425 int nHeight = cairo_image_surface_get_height(pMask);
426 int nStride = cairo_image_surface_get_stride(pMask);
427 unsigned char* mask_surface_data = cairo_image_surface_get_data(pMask);
430 const double nRedMul = 0.2125 / 255.0;
431 const double nGreenMul = 0.7154 / 255.0;
432 const double nBlueMul = 0.0721 / 255.0;
433 for (
int y = 0;
y < nHeight; ++
y)
435 unsigned char* pMaskPixelData = mask_surface_data + (nStride *
y);
436 for (
int x = 0;
x < nWidth; ++
x)
448 cairo_surface_mark_dirty(pMask);
463 double clip_x1, clip_x2, clip_y1, clip_y2;
464 cairo_clip_extents(
mpRT, &clip_x1, &clip_y1, &clip_x2, &clip_y2);
487 cairo_surface_t* pMask = cairo_surface_create_similar_image(pTarget, CAIRO_FORMAT_ARGB32,
498 pTarget, cairo_surface_get_content(pTarget), ceil(aVisibleRange.
getWidth()),
504 cairo_set_source_surface(
mpRT, pContent, aVisibleRange.
getMinX(), aVisibleRange.
getMinY());
507 cairo_surface_destroy(pContent);
508 cairo_surface_destroy(pMask);
522 double clip_x1, clip_x2, clip_y1, clip_y2;
523 cairo_clip_extents(
mpRT, &clip_x1, &clip_y1, &clip_x2, &clip_y2);
530 if (!aViewRange.
overlaps(aMaskRange))
535 cairo_matrix_t aMatrix;
538 cairo_matrix_init(&aMatrix, rObjectToView.
a(), rObjectToView.
b(), rObjectToView.
c(),
539 rObjectToView.
d(), rObjectToView.
e(), rObjectToView.
f());
542 cairo_set_matrix(
mpRT, &aMatrix);
545 for (
const auto& rPolygon : aMask)
559 const std::vector<basegfx::B2DPoint>& rPositions(rPointArrayCandidate.
getPositions());
560 if (rPositions.empty())
569 const cairo_antialias_t eOldAAMode(cairo_get_antialias(
mpRT));
570 cairo_set_antialias(
mpRT, CAIRO_ANTIALIAS_NONE);
572 for (
auto const&
pos : rPositions)
576 const double fX(ceil(aDiscretePos.
getX()));
577 const double fY(ceil(aDiscretePos.
getY()));
579 cairo_rectangle(
mpRT, fX, fY, 1, 1);
583 cairo_set_antialias(
mpRT, eOldAAMode);
629 const bool bHairline(0.0 == rLineAttribute.
getWidth());
632 const double fDiscreteLineWidth(
645 process(rPolygonStrokeCandidate);
657 static bool bRenderDecomposeForCompareInRed(
false);
659 if (bRenderDecomposeForCompareInRed)
673 cairo_matrix_t aMatrix;
675 cairo_matrix_init(&aMatrix, rObjectToView.
a(), rObjectToView.
b(), rObjectToView.
c(),
676 rObjectToView.
d(), rObjectToView.
e() + fAAOffset,
677 rObjectToView.
f() + fAAOffset);
680 cairo_set_matrix(
mpRT, &aMatrix);
683 cairo_line_join_t eCairoLineJoin = CAIRO_LINE_JOIN_MITER;
687 eCairoLineJoin = CAIRO_LINE_JOIN_BEVEL;
690 eCairoLineJoin = CAIRO_LINE_JOIN_ROUND;
694 eCairoLineJoin = CAIRO_LINE_JOIN_MITER;
703 cairo_line_cap_t eCairoLineCap(CAIRO_LINE_CAP_BUTT);
709 eCairoLineCap = CAIRO_LINE_CAP_BUTT;
712 case css::drawing::LineCap_ROUND:
714 eCairoLineCap = CAIRO_LINE_CAP_ROUND;
717 case css::drawing::LineCap_SQUARE:
719 eCairoLineCap = CAIRO_LINE_CAP_SQUARE;
725 if (bRenderDecomposeForCompareInRed)
730 cairo_set_line_join(
mpRT, eCairoLineJoin);
731 cairo_set_line_cap(
mpRT, eCairoLineCap);
734 cairo_set_line_width(
mpRT, bHairline ? 1.44 : fDiscreteLineWidth);
735 cairo_set_miter_limit(
mpRT, fMiterLimit);
739 const bool bDashUsed(!rStrokeAttribute.
isDefault()
744 const std::vector<double>& rStroke = rStrokeAttribute.
getDotDashArray();
745 cairo_set_dash(
mpRT, rStroke.data(), rStroke.size(), 0.0);
766 cairo_matrix_t aMatrix;
770 cairo_matrix_init(&aMatrix, rObjectToView.
a(), rObjectToView.
b(), rObjectToView.
c(),
771 rObjectToView.
d(), rObjectToView.
e() + fAAOffset,
772 rObjectToView.
f() + fAAOffset);
775 cairo_set_matrix(
mpRT, &aMatrix);
785 cairo_set_line_width(
mpRT, fDiscreteLineWidth);
806 cairo_matrix_t aMatrix;
810 cairo_matrix_init(&aMatrix, rObjectToView.
a(), rObjectToView.
b(), rObjectToView.
c(),
811 rObjectToView.
d(), rObjectToView.
e() + fAAOffset,
812 rObjectToView.
f() + fAAOffset);
815 cairo_set_matrix(
mpRT, &aMatrix);
844 cairo_set_line_width(
mpRT, 1.44f);
846 cairo_move_to(
mpRT, aStart.
getX() + fAAOffset, aStart.
getY() + fAAOffset);
847 cairo_line_to(
mpRT, aEnd.
getX() + fAAOffset, aEnd.
getY() + fAAOffset);
struct _cairo_surface cairo_surface_t
Bitmap const & GetBitmap() const
const AlphaMask & GetAlphaMask() const
Bitmap GetBitmap(Color aTransparentReplaceColor) const
BitmapEx ModifyBitmapEx(const basegfx::BColorModifierStack &rBColorModifierStack) const
const Size & GetSizePixel() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
B2DRange getB2DRange() const
bool isPrevControlPointUsed(sal_uInt32 nIndex) const
bool isNextControlPointUsed(sal_uInt32 nIndex) const
basegfx::B2DPoint const & getB2DPoint(sal_uInt32 nIndex) const
basegfx::B2DPoint getPrevControlPoint(sal_uInt32 nIndex) const
bool areControlPointsUsed() const
basegfx::B2DPoint getNextControlPoint(sal_uInt32 nIndex) const
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix &rMatrix)
void push(const BColorModifierSharedPtr &rNew)
::basegfx::BColor getModifiedColor(const ::basegfx::BColor &rSource) const
void intersect(const Range2D &rRange)
bool overlaps(const Range2D &rRange) const
bool equal(const Tuple2D< TYPE > &rTup) const
double getMiterMinimumAngle() const
basegfx::B2DLineJoin getLineJoin() const
css::drawing::LineCap getLineCap() const
const basegfx::BColor & getColor() const
const ::std::vector< double > & getDotDashArray() const
double getFullDotDashLen() const
BackgroundColorPrimitive2D class.
virtual sal_uInt32 getPrimitive2DID() const =0
provide unique ID for fast identifying of known primitive implementations in renderers.
const basegfx::B2DHomMatrix & getTransform() const
const BitmapEx & getBitmap() const
data read access
FilledRectanglePrimitive2D class.
const basegfx::B2DRange & getB2DRange() const
data read access
const basegfx::BColor & getBColor() const
const Primitive2DContainer & getChildren() const
data read access
LineRectanglePrimitive2D class.
const basegfx::B2DRange & getB2DRange() const
data read access
const basegfx::BColor & getBColor() const
MarkerArrayPrimitive2D class.
const basegfx::B2DPolyPolygon & getMask() const
data read access
ModifiedColorPrimitive2D class.
const basegfx::BColorModifierSharedPtr & getColorModifier() const
data read access
PointArrayPrimitive2D class.
const basegfx::BColor & getRGBColor() const
const std::vector< basegfx::B2DPoint > & getPositions() const
data read access
PolyPolygonColorPrimitive2D class.
const basegfx::BColor & getBColor() const
const basegfx::B2DPolyPolygon & getB2DPolyPolygon() const
data read access
PolygonHairlinePrimitive2D class.
const basegfx::BColor & getBColor() const
const basegfx::B2DPolygon & getB2DPolygon() const
data read access
PolygonStrokePrimitive2D class.
const attribute::StrokeAttribute & getStrokeAttribute() const
const basegfx::B2DPolygon & getB2DPolygon() const
data read access
const attribute::LineAttribute & getLineAttribute() const
basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D &aViewInformation) const
SingleLinePrimitive2D class.
const basegfx::BColor & getBColor() const
const basegfx::B2DPoint & getStart() const
data read access
const basegfx::B2DPoint & getEnd() const
TransparencePrimitive2D class.
const Primitive2DContainer & getTransparence() const
data read access
UnifiedTransparencePrimitive2D class.
void process(const primitive2d::BasePrimitive2D &rCandidate)
void updateViewInformation(const geometry::ViewInformation2D &rViewInformation2D)
const geometry::ViewInformation2D & getViewInformation2D() const
data read access
void setRenderTarget(cairo_t *mpNewRT)
void processBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D &rBitmapCandidate)
void processPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D &rPointArrayCandidate)
void processUnifiedTransparencePrimitive2D(const primitive2d::UnifiedTransparencePrimitive2D &rTransCandidate)
void processLineRectanglePrimitive2D(const primitive2d::LineRectanglePrimitive2D &rLineRectanglePrimitive2D)
void processBackgroundColorPrimitive2D(const primitive2d::BackgroundColorPrimitive2D &rBackgroundColorCandidate)
void processPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D &rPolygonStrokeCandidate)
void processPolyPolygonColorPrimitive2D(const primitive2d::PolyPolygonColorPrimitive2D &rPolyPolygonColorPrimitive2D)
basegfx::BColorModifierStack maBColorModifierStack
void processPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D &rPolygonHairlinePrimitive2D)
virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D &rCandidate) override
void processTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D &rTransCandidate)
void processMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D &rMarkerArrayCandidate)
void processSingleLinePrimitive2D(const primitive2d::SingleLinePrimitive2D &rSingleLinePrimitive2D)
void processFilledRectanglePrimitive2D(const primitive2d::FilledRectanglePrimitive2D &rFilledRectanglePrimitive2D)
void processMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D &rMaskCandidate)
virtual ~CairoPixelProcessor2D() override
void processTransformPrimitive2D(const primitive2d::TransformPrimitive2D &rTransformCandidate)
CairoPixelProcessor2D(const geometry::ViewInformation2D &rViewInformation)
void processModifiedColorPrimitive2D(const primitive2d::ModifiedColorPrimitive2D &rModifiedCandidate)
#define PRIMITIVE2D_ID_LINERECTANGLEPRIMITIVE2D
#define PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D
#define PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D
#define PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D
#define PRIMITIVE2D_ID_INVERTPRIMITIVE2D
#define PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D
#define PRIMITIVE2D_ID_TRANSPARENCEPRIMITIVE2D
#define PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D
#define PRIMITIVE2D_ID_FILLEDRECTANGLEPRIMITIVE2D
#define PRIMITIVE2D_ID_SINGLELINEPRIMITIVE2D
#define PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D
#define PRIMITIVE2D_ID_MASKPRIMITIVE2D
#define PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D
#define PRIMITIVE2D_ID_BITMAPPRIMITIVE2D
#define PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D
#define PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D
#define SAL_INFO(area, stream)
constexpr OUStringLiteral aData
double getLength(const B2DPolygon &rCandidate)
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
B2DPolygon const & createUnitPolygon()
B2IRange fround(const B2DRange &rRange)
OUString idToString(sal_uInt32 nId)
sal_uInt8 premultiply(sal_uInt8 c, sal_uInt8 a)