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())
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 ))
519 sal_uInt8 nColor(
static_cast<sal_uInt8>( ::basegfx::fround( 255.0*(1.0 - fAlpha) + .5) ) );
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);
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))
624 aTransformed =
BitmapEx(aContent, aMaskBmp);
628 double fFullRotate, fFullShearX;
629 aFullTransform.
decompose(aFullScale, aFullTranslate, fFullRotate, fFullShearX);
631 double fSourceRatio = 1.0;
636 double fTargetRatio = 1.0;
637 if (aFullScale.
getY() != 0)
639 fTargetRatio = aFullScale.
getX() / aFullScale.
getY();
641 bool bAspectRatioKept = rtl::math::approxEqual(fSourceRatio, fTargetRatio);
642 if (bSheared || !bAspectRatioKept)
653 fFullRotate = fmod(fFullRotate * -1, 2 * M_PI);
656 fFullRotate += 2 * M_PI;
675 const Size aDestSize(
void BlendWith(const Bitmap &rOther)
void Erase(sal_uInt8 cTransparency)
const AlphaMask & GetAlphaMask() const
sal_Int64 GetSizeBytes() const
BitmapEx getTransformed(const basegfx::B2DHomMatrix &rTransformation, const basegfx::B2DRange &rVisibleRange, double fMaximumArea) const
Create transformed Bitmap.
SAL_DLLPRIVATE std::shared_ptr< SalBitmap > const & ImplGetBitmapSalBitmap() const
bool Rotate(Degree10 nAngle10, const Color &rFillColor)
Rotate bitmap by the specified angle.
bool Mirror(BmpMirrorFlags nMirrorFlags)
Mirror the bitmap.
Bitmap GetBitmap(Color aTransparentReplaceColor) const
const Size & GetSizePixel() const
const std::shared_ptr< SalBitmap > & ImplGetSalBitmap() const
bool Convert(BmpConversion eConversion)
Convert bitmap format.
Size GetSizePixel() const
bool Erase(const Color &rFillColor)
Fill the entire bitmap with the given color.
vcl::PixelFormat getPixelFormat() const
const Point & GetOrigin() const
virtual void InitClipRegion()
virtual void DrawDeviceBitmapEx(const Point &rDestPt, const Size &rDestSize, const Point &rSrcPtPixel, const Size &rSrcSizePixel, BitmapEx &rBitmapEx)
virtual vcl::Region GetActiveClipRegion() const
SAL_DLLPRIVATE tools::Long ImplLogicYToDevicePixel(tools::Long nY) const
Convert a logical Y coordinate to a device pixel's Y coordinate.
void EnableMapMode(bool bEnable=true)
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
void DrawTransformedBitmapEx(const basegfx::B2DHomMatrix &rTransformation, const BitmapEx &rBitmapEx, double fAlpha=1.0)
Draw BitmapEx transformed.
SAL_DLLPRIVATE bool is_double_buffered_window() const
SAL_DLLPRIVATE void DrawDeviceAlphaBitmap(const Bitmap &rBmp, const AlphaMask &rAlpha, const Point &rDestPt, const Size &rDestSize, const Point &rSrcPtPixel, const Size &rSrcSizePixel)
virtual bool AcquireGraphics() const =0
Acquire a graphics device that the output device uses to draw on.
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
Size GetOutputSizePixel() const
SAL_DLLPRIVATE bool ImplIsRecordLayout() const
void DrawRect(const tools::Rectangle &rRect)
SAL_DLLPRIVATE tools::Long ImplLogicHeightToDevicePixel(tools::Long nHeight) const
Convert a logical height to a height in units of device pixels.
bool IsClipRegion() const
SAL_DLLPRIVATE tools::Long ImplLogicWidthToDevicePixel(tools::Long nWidth) const
Convert a logical width to a width in units of device pixels.
SalGraphics * mpGraphics
Graphics context to draw on.
void DrawBitmap(const Point &rDestPt, const Bitmap &rBitmap)
virtual Bitmap GetBitmap(const Point &rSrcPt, const Size &rSize) const
bool IsDeviceOutputNecessary() const
VclPtr< VirtualDevice > mpAlphaVDev
const MapMode & GetMapMode() const
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...
virtual bool DrawTransformBitmapExDirect(const basegfx::B2DHomMatrix &aFullTransform, const BitmapEx &rBitmapEx, double fAlpha=1.0)
Transform and draw a bitmap directly.
SAL_DLLPRIVATE basegfx::B2DHomMatrix ImplGetDeviceTransformation() const
Get device transformation.
DrawModeFlags GetDrawMode() const
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.
SAL_DLLPRIVATE tools::Long ImplLogicXToDevicePixel(tools::Long nX) const
Convert a logical X coordinate to a device pixel's X coordinate.
BitmapEx GetBitmapEx(const Point &rSrcPt, const Size &rSize) const
Query extended bitmap (with alpha channel, if available).
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)
bool HasFastDrawTransformedBitmap() const
void DrawBitmap(const SalTwoRect &rPosAry, const SalBitmap &rSalBitmap, const OutputDevice &rOutDev)
bool DrawAlphaBitmap(const SalTwoRect &, const SalBitmap &rSourceBitmap, const SalBitmap &rAlphaBitmap, const OutputDevice &rOutDev)
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
constexpr tools::Long getWidth() const
constexpr tools::Long Width() const
SAL_DLLPRIVATE void ImplFillOpaqueRectangle(const tools::Rectangle &rRect)
Used for alpha VDev, to set areas to opaque.
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
void translate(double fX, double fY)
void scale(double fX, double fY)
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix &rMatrix)
B2DVector getRange() const
B2DPoint getMinimum() const
void intersect(const Range2D &rRange)
bool isInside(const Tuple2D< TYPE > &rTuple) const
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
B2DHomMatrix createScaleTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fTranslateX, double fTranslateY)
B2IRange fround(const B2DRange &rRange)
BitmapEx GetBitmapEx(BitmapEx const &rBitmapEx, DrawModeFlags nDrawMode)
BmpMirrorFlags AdjustTwoRect(SalTwoRect &rTwoRect, const Size &rSizePix)