63class ID2D1GlobalFactoryProvider
65 sal::systools::COMReference<ID2D1Factory> mpD2DFactory;
68 ID2D1GlobalFactoryProvider()
69 : mpD2DFactory(nullptr)
71 const HRESULT
hr(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,
72 __uuidof(ID2D1Factory),
nullptr,
73 reinterpret_cast<void**
>(&mpD2DFactory)));
79 sal::systools::COMReference<ID2D1Factory>& getID2D1Factory() {
return mpD2DFactory; }
82ID2D1GlobalFactoryProvider aID2D1GlobalFactoryProvider;
84class ID2D1GlobalRenderTargetProvider
86 sal::systools::COMReference<ID2D1DCRenderTarget> mpID2D1DCRenderTarget;
89 ID2D1GlobalRenderTargetProvider()
90 : mpID2D1DCRenderTarget()
94 sal::systools::COMReference<ID2D1DCRenderTarget>& getID2D1DCRenderTarget()
96 if (!mpID2D1DCRenderTarget && aID2D1GlobalFactoryProvider.getID2D1Factory())
98 const D2D1_RENDER_TARGET_PROPERTIES aRTProps(D2D1::RenderTargetProperties(
99 D2D1_RENDER_TARGET_TYPE_DEFAULT,
100 D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM,
101 D2D1_ALPHA_MODE_IGNORE),
102 0, 0, D2D1_RENDER_TARGET_USAGE_NONE, D2D1_FEATURE_LEVEL_DEFAULT));
104 const HRESULT
hr(aID2D1GlobalFactoryProvider.getID2D1Factory()->CreateDCRenderTarget(
105 &aRTProps, &mpID2D1DCRenderTarget));
114 mpID2D1DCRenderTarget.clear();
117 return mpID2D1DCRenderTarget;
121ID2D1GlobalRenderTargetProvider aID2D1GlobalRenderTargetProvider;
126 sal::systools::COMReference<ID2D1PathGeometry> mpID2D1PathGeometry;
129 SystemDependentData_ID2D1PathGeometry(
130 sal::systools::COMReference<ID2D1PathGeometry>& rID2D1PathGeometry)
132 , mpID2D1PathGeometry(rID2D1PathGeometry)
136 const sal::systools::COMReference<ID2D1PathGeometry>& getID2D1PathGeometry()
const
138 return mpID2D1PathGeometry;
143sal_Int64 SystemDependentData_ID2D1PathGeometry::estimateUsageInBytes()
const
145 sal_Int64 aRetval(0);
147 if (getID2D1PathGeometry())
150 const HRESULT
hr(getID2D1PathGeometry()->GetSegmentCount(&nCount));
158 aRetval =
static_cast<sal_Int64
>(
nCount) * (6 *
sizeof(
double));
174 * rPolygon.
getB2DPoint((nIndex + nCount - 1) % nCount)));
183 const bool bPrevVertical(aPrevTuple.getX() == aCurrTuple.getX());
184 const bool bNextVertical(aNextTuple.getX() == aCurrTuple.getX());
185 const bool bPrevHorizontal(aPrevTuple.getY() == aCurrTuple.getY());
186 const bool bNextHorizontal(aNextTuple.getY() == aCurrTuple.getY());
187 const bool bSnapX(bPrevVertical || bNextVertical);
188 const bool bSnapY(bPrevHorizontal || bNextHorizontal);
190 if (bSnapX || bSnapY)
193 bSnapY ? aCurrTuple.getY() : aCurrPoint.getY());
197 return aSnappedPoint;
203void addB2DPolygonToPathGeometry(sal::systools::COMReference<ID2D1GeometrySink>& rSink,
207 const sal_uInt32 nPointCount(rPolygon.
count());
208 const sal_uInt32 nEdgeCount(rPolygon.
isClosed() ? nPointCount : nPointCount - 1);
211 for (sal_uInt32
a(0);
a < nEdgeCount;
a++)
216 nullptr == pViewInformation
218 : impPixelSnap(rPolygon, *pViewInformation, (a + 1) % nPointCount));
227 D2D1::Point2F(aEndPoint.getX(), aEndPoint.getY())));
231 rSink->AddLine(D2D1::Point2F(aEndPoint.getX(), aEndPoint.getY()));
236std::shared_ptr<SystemDependentData_ID2D1PathGeometry>
241 std::shared_ptr<SystemDependentData_ID2D1PathGeometry> pSystemDependentData_ID2D1PathGeometry(
244 if (pSystemDependentData_ID2D1PathGeometry)
249 pSystemDependentData_ID2D1PathGeometry.reset();
254 return pSystemDependentData_ID2D1PathGeometry;
258 sal::systools::COMReference<ID2D1PathGeometry> pID2D1PathGeometry;
260 aID2D1GlobalFactoryProvider.getID2D1Factory()->CreatePathGeometry(&pID2D1PathGeometry));
261 const sal_uInt32 nPointCount(rPolygon.
count());
263 if (SUCCEEDED(hr) && nPointCount)
265 sal::systools::COMReference<ID2D1GeometrySink> pSink;
266 hr = pID2D1PathGeometry->Open(&pSink);
268 if (SUCCEEDED(hr) && pSink)
272 : impPixelSnap(rPolygon, rViewInformation, 0));
274 pSink->BeginFigure(D2D1::Point2F(aStart.getX(), aStart.getY()),
275 D2D1_FIGURE_BEGIN_HOLLOW);
276 addB2DPolygonToPathGeometry(pSink, rPolygon, &rViewInformation);
277 pSink->EndFigure(rPolygon.
isClosed() ? D2D1_FIGURE_END_CLOSED : D2D1_FIGURE_END_OPEN);
283 if (pID2D1PathGeometry)
288 return std::make_shared<SystemDependentData_ID2D1PathGeometry>(pID2D1PathGeometry);
297 return std::shared_ptr<SystemDependentData_ID2D1PathGeometry>();
300std::shared_ptr<SystemDependentData_ID2D1PathGeometry>
304 std::shared_ptr<SystemDependentData_ID2D1PathGeometry> pSystemDependentData_ID2D1PathGeometry(
307 if (pSystemDependentData_ID2D1PathGeometry)
310 return pSystemDependentData_ID2D1PathGeometry;
313 sal::systools::COMReference<ID2D1PathGeometry> pID2D1PathGeometry;
315 aID2D1GlobalFactoryProvider.getID2D1Factory()->CreatePathGeometry(&pID2D1PathGeometry));
318 if (SUCCEEDED(hr) && nCount)
320 sal::systools::COMReference<ID2D1GeometrySink> pSink;
321 hr = pID2D1PathGeometry->Open(&pSink);
323 if (SUCCEEDED(hr) && pSink)
328 const sal_uInt32 nPointCount(rPolygon.
count());
334 pSink->BeginFigure(D2D1::Point2F(aStart.getX(), aStart.getY()),
335 D2D1_FIGURE_BEGIN_FILLED);
336 addB2DPolygonToPathGeometry(pSink, rPolygon,
nullptr);
337 pSink->EndFigure(D2D1_FIGURE_END_CLOSED);
346 if (pID2D1PathGeometry)
352 return std::shared_ptr<SystemDependentData_ID2D1PathGeometry>();
358 sal::systools::COMReference<ID2D1Bitmap> mpD2DBitmap;
359 const std::shared_ptr<SalBitmap> maAssociatedAlpha;
362 SystemDependentData_ID2D1Bitmap(sal::systools::COMReference<ID2D1Bitmap>& rD2DBitmap,
363 const std::shared_ptr<SalBitmap>& rAssociatedAlpha)
365 , mpD2DBitmap(rD2DBitmap)
366 , maAssociatedAlpha(rAssociatedAlpha)
370 const sal::systools::COMReference<ID2D1Bitmap>& getID2D1Bitmap()
const {
return mpD2DBitmap; }
371 const std::shared_ptr<SalBitmap>& getAssociatedAlpha()
const {
return maAssociatedAlpha; }
376sal_Int64 SystemDependentData_ID2D1Bitmap::estimateUsageInBytes()
const
378 sal_Int64 aRetval(0);
380 if (getID2D1Bitmap())
383 const D2D1_SIZE_U aSizePixel(getID2D1Bitmap()->GetPixelSize());
384 aRetval =
static_cast<sal_Int64
>(aSizePixel.width)
385 *
static_cast<sal_Int64
>(aSizePixel.height) * 4;
391sal::systools::COMReference<ID2D1Bitmap> createB2DBitmap(
const BitmapEx& rBitmapEx)
394 const bool bAlpha(rBitmapEx.
IsAlpha());
395 const sal_uInt32 nPixelCount(rSizePixel.Width() * rSizePixel.Height());
396 std::unique_ptr<sal_uInt32[]>
aData(
new sal_uInt32[nPixelCount]);
397 sal_uInt32* pTarget =
aData.get();
411 const BitmapColor aColor(pReadAccess->GetColor(y, x));
412 const BitmapColor aAlpha(pAlphaReadAccess->GetColor(y, x));
413 const sal_uInt16 nAlpha(aAlpha.GetRed());
416 ColorAlpha,
sal_uInt8((sal_uInt16(aColor.GetRed()) * nAlpha) >> 8),
417 sal_uInt8((sal_uInt16(aColor.GetGreen()) * nAlpha) >> 8),
418 sal_uInt8((sal_uInt16(aColor.GetBlue()) * nAlpha) >> 8), aAlpha.GetRed()));
432 const BitmapColor aColor(pReadAccess->GetColor(y, x));
433 *pTarget++ = sal_uInt32(aColor);
444 sal::systools::COMReference<ID2D1Bitmap> pID2D1Bitmap;
446 if (aID2D1GlobalRenderTargetProvider.getID2D1DCRenderTarget())
448 const HRESULT
hr(aID2D1GlobalRenderTargetProvider.getID2D1DCRenderTarget()->CreateBitmap(
449 D2D1::SizeU(rSizePixel.Width(), rSizePixel.Height()), &aData[0],
450 rSizePixel.Width() *
sizeof(sal_uInt32),
451 D2D1::BitmapProperties(
452 D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM,
453 bAlpha ? D2D1_ALPHA_MODE_PREMULTIPLIED
454 : D2D1_ALPHA_MODE_IGNORE)),
458 pID2D1Bitmap.clear();
464sal::systools::COMReference<ID2D1Bitmap>
465getOrCreateB2DBitmap(sal::systools::COMReference<ID2D1RenderTarget>& rRT,
const BitmapEx& rBitmapEx)
469 std::shared_ptr<SystemDependentData_ID2D1Bitmap> pSystemDependentData_ID2D1Bitmap;
471 if (
nullptr != pHolder)
474 pSystemDependentData_ID2D1Bitmap
475 = std::static_pointer_cast<SystemDependentData_ID2D1Bitmap>(
476 pHolder->getSystemDependentData(
477 typeid(SystemDependentData_ID2D1Bitmap).hash_code()));
480 if (pSystemDependentData_ID2D1Bitmap
481 && pSystemDependentData_ID2D1Bitmap->getAssociatedAlpha()
485 pSystemDependentData_ID2D1Bitmap.reset();
489 if (!pSystemDependentData_ID2D1Bitmap)
492 sal::systools::COMReference<ID2D1Bitmap> pID2D1Bitmap(createB2DBitmap(rBitmapEx));
497 pSystemDependentData_ID2D1Bitmap = std::make_shared<SystemDependentData_ID2D1Bitmap>(
501 if (
nullptr != pHolder
502 && pSystemDependentData_ID2D1Bitmap->calculateCombinedHoldCyclesInSeconds() > 0)
506 ->addOrReplaceSystemDependentData(r2);
511 sal::systools::COMReference<ID2D1Bitmap> pWrappedD2DBitmap;
513 if (pSystemDependentData_ID2D1Bitmap)
517 const HRESULT
hr(rRT->CreateSharedBitmap(
518 __uuidof(ID2D1Bitmap),
519 static_cast<void*
>(pSystemDependentData_ID2D1Bitmap->getID2D1Bitmap()),
nullptr,
520 &pWrappedD2DBitmap));
523 pWrappedD2DBitmap.clear();
526 return pWrappedD2DBitmap;
539 sal::systools::COMReference<ID2D1BitmapRenderTarget> mpBitmapRenderTarget;
545 sal_uInt32 nWidth, sal_uInt32 nHeight,
546 const sal::systools::COMReference<ID2D1RenderTarget>& rParent)
547 :
drawinglayer::processor2d::D2DPixelProcessor2D(rViewInformation)
548 , mpBitmapRenderTarget()
550 if (0 == nWidth || 0 == nHeight)
559 const D2D1_SIZE_U aRenderTargetSizePixel(D2D1::SizeU(nWidth, nHeight));
560 const HRESULT
hr(rParent->CreateCompatibleRenderTarget(
561 nullptr, &aRenderTargetSizePixel,
nullptr,
562 D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE, &mpBitmapRenderTarget));
564 if (!SUCCEEDED(hr) ||
nullptr == mpBitmapRenderTarget)
571 sal::systools::COMReference<ID2D1RenderTarget> pRT;
572 mpBitmapRenderTarget->QueryInterface(__uuidof(ID2D1RenderTarget),
573 reinterpret_cast<void**
>(&pRT));
588 aInvViewTransform.invert();
589 aViewport.transform(aInvViewTransform);
590 aViewInformation.setViewport(aViewport);
601 sal::systools::COMReference<ID2D1Bitmap> getID2D1Bitmap()
const
603 sal::systools::COMReference<ID2D1Bitmap> pResult;
606 if (mpBitmapRenderTarget)
608 mpBitmapRenderTarget->GetBitmap(&pResult);
615bool createBitmapSubContent(sal::systools::COMReference<ID2D1Bitmap>& rResult,
619 const sal::systools::COMReference<ID2D1RenderTarget>& rRenderTarget)
621 if (rContent.empty() || !rRenderTarget)
628 rDiscreteVisibleRange, rContent.
getB2DRange(rViewInformation2D), rViewInformation2D);
630 if (rDiscreteVisibleRange.
isEmpty())
640 const double fTargetWidth(ceil(rDiscreteVisibleRange.
getWidth()));
641 const double fTargetHeight(ceil(rDiscreteVisibleRange.
getHeight()));
648 -rDiscreteVisibleRange.
getMinY())
650 aAdaptedViewInformation2D.setViewTransformation(aAdapted);
657 D2DBitmapPixelProcessor2D aSubContentRenderer(aAdaptedViewInformation2D, fTargetWidth,
658 fTargetHeight, rRenderTarget);
660 if (!aSubContentRenderer.valid())
667 aSubContentRenderer.process(rContent);
670 rResult = aSubContentRenderer.getID2D1Bitmap();
679 , maBColorModifierStack()
681 , mnRecursionCounter(0)
689 , maBColorModifierStack()
691 , mnRecursionCounter(0)
694 sal::systools::COMReference<ID2D1DCRenderTarget> pDCRT;
699 aOutWidth = GetDeviceCaps(aHdc, HORZRES);
700 aOutHeight = GetDeviceCaps(aHdc, VERTRES);
703 if (aOutWidth > 0 && aOutHeight > 0 && aID2D1GlobalFactoryProvider.getID2D1Factory())
705 const D2D1_RENDER_TARGET_PROPERTIES aRTProps(D2D1::RenderTargetProperties(
706 D2D1_RENDER_TARGET_TYPE_DEFAULT,
707 D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM,
708 D2D1_ALPHA_MODE_IGNORE),
709 0, 0, D2D1_RENDER_TARGET_USAGE_NONE, D2D1_FEATURE_LEVEL_DEFAULT));
712 aID2D1GlobalFactoryProvider.getID2D1Factory()->CreateDCRenderTarget(&aRTProps, &pDCRT));
721 { 0, 0, o3tl::narrowing<LONG>(aOutWidth), o3tl::narrowing<LONG>(aOutHeight) });
722 const HRESULT
hr(pDCRT->BindDC(aHdc, &rc));
732 D2D1_ANTIALIAS_MODE eAAMode = D2D1_ANTIALIAS_MODE_PER_PRIMITIVE;
733 pDCRT->SetAntialiasMode(eAAMode);
737 D2D1_ANTIALIAS_MODE eAAMode = D2D1_ANTIALIAS_MODE_ALIASED;
738 pDCRT->SetAntialiasMode(eAAMode);
750 SetWorldTransform(aHdc, &aXForm);
755 sal::systools::COMReference<ID2D1RenderTarget> pRT;
756 pDCRT->QueryInterface(__uuidof(ID2D1RenderTarget),
reinterpret_cast<void**
>(&pRT));
770 if (!rPolygon.
count())
777 std::shared_ptr<SystemDependentData_ID2D1PathGeometry> pSystemDependentData_ID2D1PathGeometry(
780 if (pSystemDependentData_ID2D1PathGeometry)
782 sal::systools::COMReference<ID2D1TransformedGeometry> pTransformedGeometry;
786 HRESULT
hr(aID2D1GlobalFactoryProvider.getID2D1Factory()->CreateTransformedGeometry(
787 pSystemDependentData_ID2D1PathGeometry->getID2D1PathGeometry(),
788 D2D1::Matrix3x2F(rObjectToView.
a(), rObjectToView.
b(), rObjectToView.
c(),
789 rObjectToView.
d(), rObjectToView.
e() + fAAOffset,
790 rObjectToView.
f() + fAAOffset),
791 &pTransformedGeometry));
793 if (SUCCEEDED(
hr) && pTransformedGeometry)
797 const D2D1::ColorF aD2DColor(aHairlineColor.
getRed(), aHairlineColor.
getGreen(),
799 sal::systools::COMReference<ID2D1SolidColorBrush> pColorBrush;
802 if (SUCCEEDED(
hr) && pColorBrush)
811 getRenderTarget()->DrawGeometry(pTransformedGeometry, pColorBrush, 1.44f);
825 std::shared_ptr<SystemDependentData_ID2D1PathGeometry> pSystemDependentData_ID2D1PathGeometry(
826 getOrCreateFillGeometry(rPolyPolygon));
828 if (pSystemDependentData_ID2D1PathGeometry)
830 sal::systools::COMReference<ID2D1TransformedGeometry> pTransformedGeometry;
834 HRESULT
hr(aID2D1GlobalFactoryProvider.getID2D1Factory()->CreateTransformedGeometry(
835 pSystemDependentData_ID2D1PathGeometry->getID2D1PathGeometry(),
836 D2D1::Matrix3x2F(aTansformation.
a(), aTansformation.
b(), aTansformation.
c(),
837 aTansformation.
d(), aTansformation.
e() + fAAOffset,
838 aTansformation.
f() + fAAOffset),
839 &pTransformedGeometry));
841 if (SUCCEEDED(
hr) && pTransformedGeometry)
844 const D2D1::ColorF aD2DColor(aFillColor.
getRed(), aFillColor.
getGreen(),
847 sal::systools::COMReference<ID2D1SolidColorBrush> pColorBrush;
850 if (SUCCEEDED(
hr) && pColorBrush)
875 rPolyPolygonColorPrimitive2D.
getBColor()));
897 if (aDiscreteVisibleRange.
isEmpty())
939 sal::systools::COMReference<ID2D1Bitmap> pD2DBitmap(
949 aLocalTransform.
a(), aLocalTransform.
b(), aLocalTransform.
c(), aLocalTransform.
d(),
950 aLocalTransform.
e() + fAAOffset, aLocalTransform.
f() + fAAOffset));
953 getRenderTarget()->DrawBitmap(pD2DBitmap, D2D1::RectF(0.0, 0.0, 1.0, 1.0));
967 sal::systools::COMReference<ID2D1DeviceContext> pID2D1DeviceContext;
969 reinterpret_cast<void**
>(&pID2D1DeviceContext));
970 sal::systools::COMReference<ID2D1Bitmap> pRetval;
972 if (!pID2D1DeviceContext)
980 pID2D1DeviceContext.clear();
983 if (!createBitmapSubContent(pRetval, aDiscreteVisibleRange, rTransCandidate.
getTransparence(),
998 sal::systools::COMReference<ID2D1BitmapRenderTarget> pContent;
999 const D2D1_PIXEL_FORMAT aAlphaFormat(
1000 D2D1::PixelFormat(DXGI_FORMAT_A8_UNORM, D2D1_ALPHA_MODE_STRAIGHT));
1001 const D2D1_SIZE_U aRenderTargetSizePixel(D2D1::SizeU(ceil(aDiscreteVisibleRange.
getWidth()),
1002 ceil(aDiscreteVisibleRange.
getHeight())));
1004 nullptr, &aRenderTargetSizePixel, &aAlphaFormat, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE,
1007 if (SUCCEEDED(
hr) && pContent)
1010 pContent->QueryInterface(__uuidof(ID2D1DeviceContext),
1011 reinterpret_cast<void**
>(&pID2D1DeviceContext));
1013 if (pID2D1DeviceContext)
1016 sal::systools::COMReference<ID2D1Effect> pLuminanceToAlpha;
1017 pID2D1DeviceContext->CreateEffect(CLSID_D2D1LuminanceToAlpha, &pLuminanceToAlpha);
1019 if (pLuminanceToAlpha)
1022 pLuminanceToAlpha->SetInput(0, pRetval);
1024 pID2D1DeviceContext->BeginDraw();
1025 pID2D1DeviceContext->Clear(D2D1::ColorF(0.0f, 0.0f, 0.0f, 0.0f));
1026 pID2D1DeviceContext->DrawImage(pLuminanceToAlpha);
1027 pID2D1DeviceContext->EndDraw();
1030 pContent->GetBitmap(&pRetval);
1044 const sal_uInt32 nDiscreteClippedWidth(ceil(rVisibleRange.
getWidth()));
1045 const sal_uInt32 nDiscreteClippedHeight(ceil(rVisibleRange.
getHeight()));
1046 const sal_uInt32 nMaximumQuadraticPixels(250000);
1063 std::move(xEmbedSeq), aEmptyViewInformation2D, nDiscreteClippedWidth,
1064 nDiscreteClippedHeight, nMaximumQuadraticPixels,
true));
1065 sal::systools::COMReference<ID2D1Bitmap> pRetval;
1075 const sal_uInt32 nPixelCount(rSizePixel.
Width() * rSizePixel.
Height());
1088 *pTarget++ = aColor.GetLuminance();
1092 const D2D1_BITMAP_PROPERTIES aBmProps(D2D1::BitmapProperties(
1093 D2D1::PixelFormat(DXGI_FORMAT_A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED)));
1098 if (!SUCCEEDED(
hr) || !pRetval)
1109 if (
static_cast<sal_uInt32
>(rBitmapExSizePixel.
Width()) != nDiscreteClippedWidth
1110 ||
static_cast<sal_uInt32
>(rBitmapExSizePixel.
Height()) != nDiscreteClippedHeight)
1114 const double fScaleX(
static_cast<double>(rBitmapExSizePixel.
Width())
1115 /
static_cast<double>(nDiscreteClippedWidth));
1116 const double fScaleY(
static_cast<double>(rBitmapExSizePixel.
Height())
1117 /
static_cast<double>(nDiscreteClippedHeight));
1119 const double fScale(1.0 / ((fScaleX + fScaleY) * 0.5));
1120 rMaskScale = D2D1::Matrix3x2F::Scale(fScale, fScale);
1147 if (aDiscreteVisibleRange.
isEmpty())
1156 D2D1_MATRIX_3X2_F aMaskScale(D2D1::Matrix3x2F::Identity());
1172 sal::systools::COMReference<ID2D1Layer> pLayer;
1176 if (SUCCEEDED(
hr) && pLayer)
1178 sal::systools::COMReference<ID2D1BitmapBrush> pBitmapBrush;
1181 if (SUCCEEDED(
hr) && pBitmapBrush)
1184 pBitmapBrush->SetTransform(aMaskScale);
1189 floor(aDiscreteVisibleRange.
getMinX()), floor(aDiscreteVisibleRange.
getMinY())));
1191 getRenderTarget()->PushLayer(D2D1::LayerParameters(D2D1::InfiniteRect(),
nullptr,
1192 D2D1_ANTIALIAS_MODE_PER_PRIMITIVE,
1193 D2D1::Matrix3x2F::Identity(), 1.0,
1240 if (aDiscreteVisibleRange.
isEmpty())
1247 sal::systools::COMReference<ID2D1Layer> pLayer;
1250 if (SUCCEEDED(
hr) && pLayer)
1256 D2D1::LayerParameters(D2D1::InfiniteRect(),
nullptr, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE,
1257 D2D1::IdentityMatrix(),
1291 if (aDiscreteVisibleRange.
isEmpty())
1298 std::shared_ptr<SystemDependentData_ID2D1PathGeometry> pSystemDependentData_ID2D1MaskGeometry(
1299 getOrCreateFillGeometry(rMaskCandidate.
getMask()));
1301 if (pSystemDependentData_ID2D1MaskGeometry)
1303 sal::systools::COMReference<ID2D1TransformedGeometry> pTransformedMaskGeometry;
1306 HRESULT
hr(aID2D1GlobalFactoryProvider.getID2D1Factory()->CreateTransformedGeometry(
1307 pSystemDependentData_ID2D1MaskGeometry->getID2D1PathGeometry(),
1308 D2D1::Matrix3x2F(rObjectToView.
a(), rObjectToView.
b(), rObjectToView.
c(),
1309 rObjectToView.
d(), rObjectToView.
e(), rObjectToView.
f()),
1310 &pTransformedMaskGeometry));
1312 if (SUCCEEDED(
hr) && pTransformedMaskGeometry)
1314 sal::systools::COMReference<ID2D1Layer> pLayer;
1317 if (SUCCEEDED(
hr) && pLayer)
1323 D2D1::LayerParameters(D2D1::InfiniteRect(), pTransformedMaskGeometry), pLayer);
1338 const std::vector<basegfx::B2DPoint>& rPositions(rPointArrayCandidate.
getPositions());
1340 if (rPositions.empty())
1348 sal::systools::COMReference<ID2D1SolidColorBrush> pColorBrush;
1350 const HRESULT
hr(
getRenderTarget()->CreateSolidColorBrush(aD2DColor, &pColorBrush));
1353 if (SUCCEEDED(
hr) && pColorBrush)
1359 const D2D1_ANTIALIAS_MODE aOldAAMode(
getRenderTarget()->GetAntialiasMode());
1362 for (
auto const&
pos : rPositions)
1366 const double fX(ceil(aDiscretePos.
getX()));
1367 const double fY(ceil(aDiscretePos.
getY()));
1384 const std::vector<basegfx::B2DPoint>& rPositions(rMarkerArrayCandidate.
getPositions());
1386 if (rPositions.empty())
1400 sal::systools::COMReference<ID2D1Bitmap> pD2DBitmap(
1414 const D2D1_ANTIALIAS_MODE aOldAAMode(
getRenderTarget()->GetAntialiasMode());
1417 for (
auto const&
pos : rPositions)
1421 const double fX(ceil(aDiscretePos.
getX()));
1422 const double fY(ceil(aDiscretePos.
getY()));
1423 const D2D1_RECT_F rect
1445 const D2D1::ColorF aD2DColor(rBackgroundColorCandidate.
getBColor().
getRed(),
1496 const bool bHairline(0.0 == rLineAttribute.
getWidth());
1499 const double fDiscreteLineWidth(
1512 process(rPolygonStrokeCandidate);
1524 static bool bRenderDecomposeForCompareInRed(
false);
1526 if (bRenderDecomposeForCompareInRed)
1539 std::shared_ptr<SystemDependentData_ID2D1PathGeometry> pSystemDependentData_ID2D1PathGeometry(
1542 if (pSystemDependentData_ID2D1PathGeometry)
1544 sal::systools::COMReference<ID2D1TransformedGeometry> pTransformedGeometry;
1546 HRESULT
hr(aID2D1GlobalFactoryProvider.getID2D1Factory()->CreateTransformedGeometry(
1547 pSystemDependentData_ID2D1PathGeometry->getID2D1PathGeometry(),
1548 D2D1::Matrix3x2F(rObjectToView.
a(), rObjectToView.
b(), rObjectToView.
c(),
1549 rObjectToView.
d(), rObjectToView.
e() + fAAOffset,
1550 rObjectToView.
f() + fAAOffset),
1551 &pTransformedGeometry));
1553 if (SUCCEEDED(
hr) && pTransformedGeometry)
1557 D2D1::ColorF aD2DColor(aLineColor.
getRed(), aLineColor.
getGreen(),
1560 if (bRenderDecomposeForCompareInRed)
1565 sal::systools::COMReference<ID2D1SolidColorBrush> pColorBrush;
1568 if (SUCCEEDED(
hr) && pColorBrush)
1570 sal::systools::COMReference<ID2D1StrokeStyle> pStrokeStyle;
1571 D2D1_CAP_STYLE aCapStyle(D2D1_CAP_STYLE_FLAT);
1572 D2D1_LINE_JOIN aLineJoin(D2D1_LINE_JOIN_MITER);
1575 const bool bDashUsed(!rStrokeAttribute.
isDefault()
1578 D2D1_DASH_STYLE aDashStyle(bDashUsed ? D2D1_DASH_STYLE_CUSTOM
1579 : D2D1_DASH_STYLE_SOLID);
1580 std::vector<float> dashes;
1581 float miterLimit(1.0);
1585 case css::drawing::LineCap_ROUND:
1586 aCapStyle = D2D1_CAP_STYLE_ROUND;
1588 case css::drawing::LineCap_SQUARE:
1589 aCapStyle = D2D1_CAP_STYLE_SQUARE;
1600 aLineJoin = D2D1_LINE_JOIN_BEVEL;
1622 aLineJoin = D2D1_LINE_JOIN_MITER_OR_BEVEL;
1625 double fVal(::basegfx::snapToZeroRange(
1629 const double fSmallValue(M_PI * 0.0000001);
1630 fVal = std::max(fSmallValue, fVal);
1631 fVal = std::min(M_PI - fSmallValue, fVal);
1634 fVal = 1.0 / sin(fVal);
1638 const double fCorrector(2.0 * 0.9925);
1640 miterLimit = fVal * fCorrector;
1644 aLineJoin = D2D1_LINE_JOIN_ROUND;
1657 / fDiscreteLineWidth);
1661 hr = aID2D1GlobalFactoryProvider.getID2D1Factory()->CreateStrokeStyle(
1662 D2D1::StrokeStyleProperties(aCapStyle,
1669 bDashUsed ? dashes.data() :
nullptr, bDashUsed ? dashes.size() : 0,
1672 if (SUCCEEDED(
hr) && pStrokeStyle)
1676 pTransformedGeometry, pColorBrush,
1678 bHairline ? 1.44 : fDiscreteLineWidth, pStrokeStyle);
1688 process(rPolygonStrokeCandidate);
1703 const D2D1::ColorF aD2DColor(aHairlineColor.
getRed(), aHairlineColor.
getGreen(),
1705 sal::systools::COMReference<ID2D1SolidColorBrush> pColorBrush;
1706 const HRESULT
hr(
getRenderTarget()->CreateSolidColorBrush(aD2DColor, &pColorBrush));
1709 if (SUCCEEDED(
hr) && pColorBrush)
1715 aLocalTransform.
a(), aLocalTransform.
b(), aLocalTransform.
c(), aLocalTransform.
d(),
1716 aLocalTransform.
e() + fAAOffset, aLocalTransform.
f() + fAAOffset));
1720 const double fDiscreteLineWidth(
1725 getRenderTarget()->DrawRectangle(&rect, pColorBrush, fDiscreteLineWidth);
1745 sal::systools::COMReference<ID2D1SolidColorBrush> pColorBrush;
1746 const HRESULT
hr(
getRenderTarget()->CreateSolidColorBrush(aD2DColor, &pColorBrush));
1749 if (SUCCEEDED(
hr) && pColorBrush)
1755 aLocalTransform.
a(), aLocalTransform.
b(), aLocalTransform.
c(), aLocalTransform.
d(),
1756 aLocalTransform.
e() + fAAOffset, aLocalTransform.
f() + fAAOffset));
1775 sal::systools::COMReference<ID2D1SolidColorBrush> pColorBrush;
1776 const HRESULT
hr(
getRenderTarget()->CreateSolidColorBrush(aD2DColor, &pColorBrush));
1779 if (SUCCEEDED(
hr) && pColorBrush)
1788 const D2D1_POINT_2F aD2D1Start
1790 const D2D1_POINT_2F aD2D1End
1793 getRenderTarget()->DrawLine(aD2D1Start, aD2D1End, pColorBrush, 1.44f);
1806 static double fBigDiscreteArea(300.0 * 300.0);
1811 aPreparedBitmap, aFillUnitRange, fBigDiscreteArea))
1817 if (aPreparedBitmap.
IsEmpty())
1821 process(rFillGraphicPrimitive2D);
1831 if (aPreparedBitmap.
IsEmpty())
1857 sal::systools::COMReference<ID2D1Bitmap> pD2DBitmap(
1862 sal::systools::COMReference<ID2D1BitmapBrush> pBitmapBrush;
1863 const HRESULT
hr(
getRenderTarget()->CreateBitmapBrush(pD2DBitmap, &pBitmapBrush));
1865 if (SUCCEEDED(
hr) && pBitmapBrush)
1868 pBitmapBrush->SetExtendModeX(D2D1_EXTEND_MODE_WRAP);
1869 pBitmapBrush->SetExtendModeY(D2D1_EXTEND_MODE_WRAP);
1875 sal::systools::COMReference<ID2D1BitmapBrush1> pBrush1;
1876 pBitmapBrush->QueryInterface(__uuidof(ID2D1BitmapBrush1),
1877 reinterpret_cast<void**
>(&pBrush1));
1881 pBrush1->SetInterpolationMode1(D2D1_INTERPOLATION_MODE_MULTI_SAMPLE_LINEAR);
1885 pBitmapBrush->SetInterpolationMode(D2D1_BITMAP_INTERPOLATION_MODE_LINEAR);
1891 const D2D1_SIZE_U aBMSPixel(pD2DBitmap->GetPixelSize());
1892 const double fScaleX((aFillUnitRange.
getMaxX() - aFillUnitRange.
getMinX())
1894 const double fScaleY((aFillUnitRange.
getMaxY() - aFillUnitRange.
getMinY())
1895 / aBMSPixel.height);
1896 const D2D1_MATRIX_3X2_F aBTrans(D2D1::Matrix3x2F(
1897 fScaleX, 0.0, 0.0, fScaleY, aFillUnitRange.
getMinX(), aFillUnitRange.
getMinY()));
1898 pBitmapBrush->SetTransform(&aBTrans);
1908 aLocalTransform.
a(), aLocalTransform.
b(), aLocalTransform.
c(), aLocalTransform.
d(),
1909 aLocalTransform.
e() + fAAOffset, aLocalTransform.
f() + fAAOffset));
1967 sal::systools::COMReference<ID2D1DeviceContext> pID2D1DeviceContext;
1969 reinterpret_cast<void**
>(&pID2D1DeviceContext));
1971 if (!pID2D1DeviceContext)
1981 sal::systools::COMReference<ID2D1Bitmap> pInBetweenResult;
1986 if (!createBitmapSubContent(pInBetweenResult, aDiscreteVisibleRange,
1996 if (pInBetweenResult)
1999 const D2D1_POINT_2F aTopLeft = {
FLOAT(floor(aDiscreteVisibleRange.
getMinX())),
2002 pID2D1DeviceContext->DrawImage(pInBetweenResult, aTopLeft, D2D1_INTERPOLATION_MODE_LINEAR,
2003 D2D1_COMPOSITE_MODE_XOR);
Bitmap const & GetBitmap() const
const AlphaMask & GetAlphaMask() const
Bitmap GetBitmap(Color aTransparentReplaceColor) const
BitmapEx ModifyBitmapEx(const basegfx::BColorModifierStack &rBColorModifierStack) const
const Size & GetSizePixel() const
const std::shared_ptr< SalBitmap > & ImplGetSalBitmap() const
Size GetSizePixel() const
BitmapReadAccess * AcquireReadAccess()
const basegfx::SystemDependentDataHolder * accessSystemDependentDataHolder() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const B2DPoint & getControlPointB() const
const B2DPoint & getEndPoint() const
const B2DPoint & getControlPointA() const
B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const
B2DRange getB2DRange() const
std::shared_ptr< T > addOrReplaceSystemDependentData(Args &&... args) const
std::shared_ptr< T > getSystemDependentData() const
std::shared_ptr< T > getSystemDependentData() const
basegfx::B2DPoint const & getB2DPoint(sal_uInt32 nIndex) const
void transform(const basegfx::B2DHomMatrix &rMatrix)
void getBezierSegment(sal_uInt32 nIndex, B2DCubicBezier &rTarget) const
std::shared_ptr< T > addOrReplaceSystemDependentData(Args &&... args) const
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix &rMatrix)
static BASEGFX_DLLPUBLIC const B2DRange & getUnitB2DRange()
void push(const BColorModifierSharedPtr &rNew)
::basegfx::BColor getModifiedColor(const ::basegfx::BColor &rSource) const
virtual sal_Int64 estimateUsageInBytes() const
const basegfx::B2DRange & getGraphicRange() 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.
const basegfx::BColor & getBColor() const
data read access
double getTransparency() const
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
FillGradientPrimitive2D class.
basegfx::B2DPolygon getUnitPolygon() const
helpers that support e.g. direct paint/geometry creation
const basegfx::B2DRange & getOutputRange() const
data read access
basegfx::BColor getOuterColor() const
void generateMatricesAndColors(std::function< void(const basegfx::B2DHomMatrix &rMatrix, const basegfx::BColor &rColor)> aCallback) const
FillGraphicPrimitive2D class.
const attribute::FillGraphicAttribute & getFillGraphic() const
const basegfx::B2DHomMatrix & getTransformation() 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 std::vector< basegfx::B2DPoint > & getPositions() const
data read access
const BitmapEx & getMarker() const
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.
double getTransparence() const
data read access
void process(const primitive2d::BasePrimitive2D &rCandidate)
void updateViewInformation(const geometry::ViewInformation2D &rViewInformation2D)
const geometry::ViewInformation2D & getViewInformation2D() const
data read access
void processFillGradientPrimitive2D(const primitive2d::FillGradientPrimitive2D &rFillGradientPrimitive2D)
void processBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D &rBitmapCandidate)
void processPolyPolygonColorPrimitive2D(const primitive2d::PolyPolygonColorPrimitive2D &rPolyPolygonColorPrimitive2D)
void processUnifiedTransparencePrimitive2D(const primitive2d::UnifiedTransparencePrimitive2D &rTransCandidate)
void setRenderTarget(const sal::systools::COMReference< ID2D1RenderTarget > &rNewRT)
void processPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D &rPolygonHairlinePrimitive2D)
sal::systools::COMReference< ID2D1RenderTarget > & getRenderTarget()
basegfx::BColorModifierStack maBColorModifierStack
sal::systools::COMReference< ID2D1Bitmap > implCreateAlpha_B2DBitmap(const primitive2d::TransparencePrimitive2D &rTransCandidate, const basegfx::B2DRange &rVisibleRange, D2D1_MATRIX_3X2_F &rMaskScale)
bool hasRenderTarget() const
virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D &rCandidate) override
void processMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D &rMarkerArrayCandidate)
void processLineRectanglePrimitive2D(const primitive2d::LineRectanglePrimitive2D &rLineRectanglePrimitive2D)
void processModifiedColorPrimitive2D(const primitive2d::ModifiedColorPrimitive2D &rModifiedCandidate)
void processPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D &rPolygonStrokeCandidate)
void processTransformPrimitive2D(const primitive2d::TransformPrimitive2D &rTransformCandidate)
void processPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D &rPointArrayCandidate)
void processMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D &rMaskCandidate)
void processInvertPrimitive2D(const primitive2d::InvertPrimitive2D &rInvertPrimitive2D)
bool drawPolyPolygonColorTransformed(const basegfx::B2DHomMatrix &rTansformation, const basegfx::B2DPolyPolygon &rPolyPolygon, const basegfx::BColor &rColor)
sal::systools::COMReference< ID2D1Bitmap > implCreateAlpha_Direct(const primitive2d::TransparencePrimitive2D &rTransCandidate)
void processBackgroundColorPrimitive2D(const primitive2d::BackgroundColorPrimitive2D &rBackgroundColorCandidate)
void processFillGraphicPrimitive2D(const primitive2d::FillGraphicPrimitive2D &rFillGraphicPrimitive2D)
void processSingleLinePrimitive2D(const primitive2d::SingleLinePrimitive2D &rSingleLinePrimitive2D)
sal_uInt32 mnRecursionCounter
void processTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D &rTransCandidate)
void processFilledRectanglePrimitive2D(const primitive2d::FilledRectanglePrimitive2D &rFilledRectanglePrimitive2D)
D2DPixelProcessor2D(const geometry::ViewInformation2D &rViewInformation)
#define PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D
#define PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D
#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)
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
B2DPolygon const & createUnitPolygon()
std::shared_ptr< SystemDependentData > SystemDependentData_SharedPtr
B2IRange fround(const B2DRange &rRange)
OUString idToString(sal_uInt32 nId)
bool prepareBitmapForDirectRender(const drawinglayer::primitive2d::FillGraphicPrimitive2D &rFillGraphicPrimitive2D, const drawinglayer::geometry::ViewInformation2D &rViewInformation2D, BitmapEx &rTarget, basegfx::B2DRange &rFillUnitRange, double fBigDiscreteArea)
helper to process FillGraphicPrimitive2D:
void calculateDiscreteVisibleRange(basegfx::B2DRange &rDiscreteVisibleRange, const basegfx::B2DRange &rContentRange, const drawinglayer::geometry::ViewInformation2D &rViewInformation2D)
helper to calculate a discrete visible range based on a given logic range and a current ViewInformati...
AlphaMask createAlphaMask(drawinglayer::primitive2d::Primitive2DContainer &&rSeq, const geometry::ViewInformation2D &rViewInformation2D, sal_uInt32 nDiscreteWidth, sal_uInt32 nDiscreteHeight, sal_uInt32 nMaxSquarePixels, bool bUseLuminance)