20 #include <config_features.h>
22 #include <rtl/math.hxx>
71 const Point& rSrcPtPixel,
const Size& rSrcSizePixel,
90 const Point& rSrcPtPixel,
const Size& rSrcSizePixel,
126 rSrcPtPixel, rSrcSizePixel, aBmpEx ) );
168 const Point& rSrcPtPixel,
const Size& rSrcSizePixel,
190 rBitmapEx.
Mirror(nMirrFlags);
197 bool bTryDirectPaint(pSalSrcBmp);
234 if (!aClipRegionBounds.
IsEmpty() &&
248 if (!aClipRegionBounds.
IsEmpty())
312 aAlphaBitmap = rBitmapEx.
GetAlpha();
335 aAlpha.
Erase( ( 1 - fAlpha ) * 255 );
345 double &fMaximumArea)
351 aFullPixelRange.
transform(aFullTransform);
387 if(!aOutPixel.
isInside(aFullPixelRange))
391 if(aVisiblePixelRange.
isEmpty())
402 aVisibleRange = aVisiblePixelRange;
406 aMakeVisibleRangeRelative.
scale(
409 aVisibleRange.
transform(aMakeVisibleRangeRelative);
416 const double fNewMaxArea(aVisiblePixelRange.
getWidth() * aVisiblePixelRange.
getHeight());
418 fMaximumArea = std::min(4096000.0, fNewMaxArea + 1.0);
431 const sal_uInt64 nStartTime;
432 LocalTimeTest() : nStartTime(
tools::
Time::GetSystemTicks()) {}
436 const sal_uInt64 nDiffTime(nEndTime - nStartTime);
440 OStringBuffer aOutput(
"Time: ");
441 OString aNumber(OString::number(nDiffTime));
442 aOutput.append(aNumber);
443 OSL_FAIL(aOutput.getStr());
462 if(rtl::math::approxEqual( fAlpha, 0.0 ))
489 static const char* pEnableBitmapDrawTimerTimer(getenv(
"SAL_ENABLE_TIMER_BITMAPDRAW"));
490 static bool bUseTimer(
nullptr != pEnableBitmapDrawTimerTimer);
491 std::unique_ptr<LocalTimeTest> aTimeTest(
493 ?
new LocalTimeTest()
501 const bool bTryDirectPaint(!bInvert && !bBitmapChangedColor && !bMetafile);
508 if(!rtl::math::approxEqual( fAlpha, 1.0 ))
520 AlphaMask aAlpha( bitmapEx.GetSizePixel(), &nColor );
521 if( bitmapEx.IsAlpha())
523 bitmapEx =
BitmapEx( bitmapEx.GetBitmap(), aAlpha );
525 if(rtl::math::approxEqual( fAlpha, 1.0 ))
535 double fRotate, fShearX;
536 rTransformation.
decompose(aScale, aTranslate, fRotate, fShearX);
542 if(!bRotated && !bSheared && !bMirroredX && !bMirroredY)
548 const Size aDestSize(
554 aDestPt.Move(aOrigin.getX(), aOrigin.getY());
562 aDestPt.Move(-aOrigin.getX(), -aOrigin.getY());
572 if(!bRotated && !bSheared)
578 const Size aDestSize(
587 assert(bSheared || bRotated);
597 const Size& rOriginalSizePixel(bitmapEx.GetSizePixel());
598 const double fOrigArea(rOriginalSizePixel.Width() * rOriginalSizePixel.Height() * 0.5);
599 const double fOrigAreaScaled(fOrigArea * 1.44);
600 double fMaximumArea(std::clamp(fOrigAreaScaled, 1000000.0, 4500000.0));
616 if(!aTransformed.
IsAlpha() && (bSheared || bRotated))
621 AlphaMask aMaskBmp(aContent.GetSizePixel());
624 aTransformed =
BitmapEx(aContent, aMaskBmp);
630 double fFullRotate, fFullShearX;
631 aFullTransform.
decompose(aFullScale, aFullTranslate, fFullRotate, fFullShearX);
633 if (aFullScale.
getX() > 0 && aFullScale.
getY() > 0)
636 rOriginalSizePixel.getWidth() / aFullScale.
getX(),
637 rOriginalSizePixel.getHeight() / aFullScale.
getY());
638 aFullTransform *= aTransform;
641 double fSourceRatio = 1.0;
642 if (rOriginalSizePixel.getHeight() != 0)
644 fSourceRatio = rOriginalSizePixel.getWidth() / rOriginalSizePixel.getHeight();
646 double fTargetRatio = 1.0;
647 if (aFullScale.
getY() != 0)
649 fTargetRatio = aFullScale.
getX() / aFullScale.
getY();
651 bool bAspectRatioKept = rtl::math::approxEqual(fSourceRatio, fTargetRatio);
652 if (bSheared || !bAspectRatioKept)
663 fFullRotate = fmod(fFullRotate * -1, 2 * M_PI);
666 fFullRotate += 2 * M_PI;
685 const Size aDestSize(
BitmapEx GetBitmapEx(BitmapEx const &rBitmapEx, DrawModeFlags nDrawMode)
SAL_DLLPRIVATE bool ImplIsRecordLayout() const
virtual bool DrawTransformBitmapExDirect(const basegfx::B2DHomMatrix &aFullTransform, const BitmapEx &rBitmapEx, double fAlpha=1.0)
Transform and draw a bitmap directly.
bool HasFastDrawTransformedBitmap() const
void intersect(const Range2D &rRange)
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
const std::shared_ptr< SalBitmap > & ImplGetSalBitmap() const
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
BmpMirrorFlags AdjustTwoRect(SalTwoRect &rTwoRect, const Size &rSizePix)
BitmapEx getTransformed(const basegfx::B2DHomMatrix &rTransformation, const basegfx::B2DRange &rVisibleRange, double fMaximumArea) const
Create transformed Bitmap.
SAL_DLLPRIVATE bool is_double_buffered_window() const
const MapMode & GetMapMode() const
B2DVector getRange() const
void EnableMapMode(bool bEnable=true)
bool DrawTransformedBitmap(const basegfx::B2DPoint &rNull, const basegfx::B2DPoint &rX, const basegfx::B2DPoint &rY, const SalBitmap &rSourceBitmap, const SalBitmap *pAlphaBitmap, double fAlpha, const OutputDevice &rOutDev)
constexpr tools::Long Width() const
SAL_DLLPRIVATE tools::Long ImplLogicXToDevicePixel(tools::Long nX) const
Convert a logical X coordinate to a device pixel's X coordinate.
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix &rMatrix)
B2DHomMatrix createScaleB2DHomMatrix(double fScaleX, double fScaleY)
void DrawBitmap(const SalTwoRect &rPosAry, const SalBitmap &rSalBitmap, const OutputDevice &rOutDev)
virtual Bitmap GetBitmap(const Point &rSrcPt, const Size &rSize) const
B2DHomMatrix createScaleTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fTranslateX, double fTranslateY)
B2IRange fround(const B2DRange &rRange)
void DrawRect(const tools::Rectangle &rRect)
bool Mirror(BmpMirrorFlags nMirrorFlags)
Mirror the bitmap.
SalGraphics * mpGraphics
Graphics context to draw on.
SAL_DLLPRIVATE basegfx::B2DHomMatrix ImplGetDeviceTransformation() const
Get device transformation.
void DrawTransformedBitmapEx(const basegfx::B2DHomMatrix &rTransformation, const BitmapEx &rBitmapEx, double fAlpha=1.0)
Draw BitmapEx transformed.
void BlendWith(const Bitmap &rOther)
void Erase(sal_uInt8 cTransparency)
bool IsClipRegion() const
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
virtual bool AcquireGraphics() const =0
Acquire a graphics device that the output device uses to draw on.
SAL_DLLPRIVATE tools::Long ImplLogicWidthToDevicePixel(tools::Long nWidth) const
Convert a logical width to a width in units of device pixels.
SAL_DLLPRIVATE void ImplFillOpaqueRectangle(const tools::Rectangle &rRect)
Used for alpha VDev, to set areas to opaque.
virtual void DrawDeviceBitmapEx(const Point &rDestPt, const Size &rDestSize, const Point &rSrcPtPixel, const Size &rSrcSizePixel, BitmapEx &rBitmapEx)
void scale(double fX, double fY)
Size GetOutputSizePixel() const
DrawModeFlags GetDrawMode() const
void DrawBitmap(const Point &rDestPt, const Bitmap &rBitmap)
SAL_DLLPRIVATE void DrawDeviceAlphaBitmap(const Bitmap &rBmp, const AlphaMask &rAlpha, const Point &rDestPt, const Size &rDestSize, const Point &rSrcPtPixel, const Size &rSrcSizePixel)
bool Rotate(Degree10 nAngle10, const Color &rFillColor)
Rotate bitmap by the specified angle.
bool DrawAlphaBitmap(const SalTwoRect &, const SalBitmap &rSourceBitmap, const SalBitmap &rAlphaBitmap, const OutputDevice &rOutDev)
Bitmap GetBitmap(Color aTransparentReplaceColor) const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_DLLPRIVATE std::shared_ptr< SalBitmap > const & ImplGetBitmapSalBitmap() const
VclPtr< VirtualDevice > mpAlphaVDev
SAL_DLLPRIVATE vcl::Region ImplPixelToDevicePixel(const vcl::Region &rRegion) const
Convert a region in pixel units to a region in device pixel units and coords.
AlphaMask GetAlpha() const
constexpr tools::Long Height() const
bool Convert(BmpConversion eConversion)
Convert bitmap format.
virtual vcl::Region GetActiveClipRegion() const
sal_Int64 GetSizeBytes() const
B2DPoint getMinimum() const
virtual void InitClipRegion()
bool isInside(const Tuple2D< double > &rTuple) const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
const Point & GetOrigin() const
void translate(double fX, double fY)
bool Erase(const Color &rFillColor)
Fill the entire bitmap with the given color.
BitmapEx GetBitmapEx(const Point &rSrcPt, const Size &rSize) const
Query extended bitmap (with alpha channel, if available).
virtual bool TransformAndReduceBitmapExToTargetRange(const basegfx::B2DHomMatrix &aFullTransform, basegfx::B2DRange &aVisibleRange, double &fMaximumArea)
Transform and reduce the area that needs to be drawn of the bitmap and return the new visible range a...
SAL_DLLPRIVATE tools::Long ImplLogicYToDevicePixel(tools::Long nY) const
Convert a logical Y coordinate to a device pixel's Y coordinate.
const Size & GetSizePixel() const
bool IsDeviceOutputNecessary() const
SAL_DLLPRIVATE tools::Long ImplLogicHeightToDevicePixel(tools::Long nHeight) const
Convert a logical height to a height in units of device pixels.