vcl: move SystemDependentData classes to BitmapHelper
SystemDependentData_BitmapHelper, SystemDependentData_MaskHelper to BitmapHelper.{hxx,cxx} files. Change-Id: I23f3b4badd8e262c442e5c6387876b078f22fd73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127926 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
fed7cc51c9
commit
5a7cdbfbd3
@@ -121,4 +121,66 @@ MaskHelper::MaskHelper(const SalBitmap& rAlphaBitmap)
|
||||
pMaskBuf->mnScanlineSize));
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
// check for env var that decides for using downscale pattern
|
||||
const char* pDisableDownScale(getenv("SAL_DISABLE_CAIRO_DOWNSCALE"));
|
||||
bool bDisableDownScale(nullptr != pDisableDownScale);
|
||||
|
||||
sal_Int64 estimateUsageInBytesForSurfaceHelper(const SurfaceHelper* pHelper)
|
||||
{
|
||||
sal_Int64 nRetval(0);
|
||||
|
||||
if (nullptr != pHelper)
|
||||
{
|
||||
cairo_surface_t* pSurface(pHelper->getSurface());
|
||||
|
||||
if (pSurface)
|
||||
{
|
||||
const tools::Long nStride(cairo_image_surface_get_stride(pSurface));
|
||||
const tools::Long nHeight(cairo_image_surface_get_height(pSurface));
|
||||
|
||||
nRetval = nStride * nHeight;
|
||||
|
||||
// if we do downscale, size will grow by 1/4 + 1/16 + 1/32 + ...,
|
||||
// rough estimation just multiplies by 1.25, should be good enough
|
||||
// for estimation of buffer survival time
|
||||
if (!bDisableDownScale)
|
||||
{
|
||||
nRetval = (nRetval * 5) / 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nRetval;
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
SystemDependentData_BitmapHelper::SystemDependentData_BitmapHelper(
|
||||
basegfx::SystemDependentDataManager& rSystemDependentDataManager,
|
||||
const std::shared_ptr<BitmapHelper>& rBitmapHelper)
|
||||
: basegfx::SystemDependentData(rSystemDependentDataManager)
|
||||
, maBitmapHelper(rBitmapHelper)
|
||||
{
|
||||
}
|
||||
|
||||
sal_Int64 SystemDependentData_BitmapHelper::estimateUsageInBytes() const
|
||||
{
|
||||
return estimateUsageInBytesForSurfaceHelper(maBitmapHelper.get());
|
||||
}
|
||||
|
||||
SystemDependentData_MaskHelper::SystemDependentData_MaskHelper(
|
||||
basegfx::SystemDependentDataManager& rSystemDependentDataManager,
|
||||
const std::shared_ptr<MaskHelper>& rMaskHelper)
|
||||
: basegfx::SystemDependentData(rSystemDependentDataManager)
|
||||
, maMaskHelper(rMaskHelper)
|
||||
{
|
||||
}
|
||||
|
||||
sal_Int64 SystemDependentData_MaskHelper::estimateUsageInBytes() const
|
||||
{
|
||||
return estimateUsageInBytesForSurfaceHelper(maMaskHelper.get());
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -1180,34 +1180,6 @@ const char* pDisableDownScale(getenv("SAL_DISABLE_CAIRO_DOWNSCALE"));
|
||||
bool bDisableDownScale(nullptr != pDisableDownScale);
|
||||
}
|
||||
|
||||
sal_Int64 estimateUsageInBytesForSurfaceHelper(const SurfaceHelper* pHelper)
|
||||
{
|
||||
sal_Int64 nRetval(0);
|
||||
|
||||
if (nullptr != pHelper)
|
||||
{
|
||||
cairo_surface_t* pSurface(pHelper->getSurface());
|
||||
|
||||
if (pSurface)
|
||||
{
|
||||
const tools::Long nStride(cairo_image_surface_get_stride(pSurface));
|
||||
const tools::Long nHeight(cairo_image_surface_get_height(pSurface));
|
||||
|
||||
nRetval = nStride * nHeight;
|
||||
|
||||
// if we do downscale, size will grow by 1/4 + 1/16 + 1/32 + ...,
|
||||
// rough estimation just multiplies by 1.25, should be good enough
|
||||
// for estimation of buffer survival time
|
||||
if (!bDisableDownScale)
|
||||
{
|
||||
nRetval = (nRetval * 5) / 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nRetval;
|
||||
}
|
||||
|
||||
cairo_surface_t* SurfaceHelper::implCreateOrReuseDownscale(unsigned long nTargetWidth,
|
||||
unsigned long nTargetHeight)
|
||||
{
|
||||
|
@@ -46,7 +46,6 @@
|
||||
#include <basegfx/polygon/b2dpolygontools.hxx>
|
||||
#include <basegfx/matrix/b2dhommatrix.hxx>
|
||||
#include <basegfx/utils/canvastools.hxx>
|
||||
#include <basegfx/utils/systemdependentdata.hxx>
|
||||
#include <basegfx/matrix/b2dhommatrixtools.hxx>
|
||||
#include <comphelper/lok.hxx>
|
||||
#include <unx/gendata.hxx>
|
||||
@@ -60,60 +59,12 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
class SystemDependentData_BitmapHelper : public basegfx::SystemDependentData
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<BitmapHelper> maBitmapHelper;
|
||||
|
||||
public:
|
||||
SystemDependentData_BitmapHelper(
|
||||
basegfx::SystemDependentDataManager& rSystemDependentDataManager,
|
||||
const std::shared_ptr<BitmapHelper>& rBitmapHelper)
|
||||
: basegfx::SystemDependentData(rSystemDependentDataManager),
|
||||
maBitmapHelper(rBitmapHelper)
|
||||
{
|
||||
}
|
||||
|
||||
const std::shared_ptr<BitmapHelper>& getBitmapHelper() const { return maBitmapHelper; };
|
||||
virtual sal_Int64 estimateUsageInBytes() const override;
|
||||
};
|
||||
|
||||
sal_Int64 SystemDependentData_BitmapHelper::estimateUsageInBytes() const
|
||||
{
|
||||
return estimateUsageInBytesForSurfaceHelper(maBitmapHelper.get());
|
||||
}
|
||||
|
||||
class SystemDependentData_MaskHelper : public basegfx::SystemDependentData
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<MaskHelper> maMaskHelper;
|
||||
|
||||
public:
|
||||
SystemDependentData_MaskHelper(
|
||||
basegfx::SystemDependentDataManager& rSystemDependentDataManager,
|
||||
const std::shared_ptr<MaskHelper>& rMaskHelper)
|
||||
: basegfx::SystemDependentData(rSystemDependentDataManager),
|
||||
maMaskHelper(rMaskHelper)
|
||||
{
|
||||
}
|
||||
|
||||
const std::shared_ptr<MaskHelper>& getMaskHelper() const { return maMaskHelper; };
|
||||
virtual sal_Int64 estimateUsageInBytes() const override;
|
||||
};
|
||||
|
||||
sal_Int64 SystemDependentData_MaskHelper::estimateUsageInBytes() const
|
||||
{
|
||||
return estimateUsageInBytesForSurfaceHelper(maMaskHelper.get());
|
||||
}
|
||||
|
||||
// MM02 decide to use buffers or not
|
||||
const char* pDisableMM02Goodies(getenv("SAL_DISABLE_MM02_GOODIES"));
|
||||
bool bUseBuffer(nullptr == pDisableMM02Goodies);
|
||||
const tools::Long nMinimalSquareSizeToBuffer(64*64);
|
||||
|
||||
void tryToUseSourceBuffer(
|
||||
const SalBitmap& rSourceBitmap,
|
||||
std::shared_ptr<BitmapHelper>& rSurface)
|
||||
void tryToUseSourceBuffer(const SalBitmap& rSourceBitmap, std::shared_ptr<BitmapHelper>& rSurface)
|
||||
{
|
||||
// MM02 try to access buffered BitmapHelper
|
||||
std::shared_ptr<SystemDependentData_BitmapHelper> pSystemDependentData_BitmapHelper;
|
||||
@@ -148,9 +99,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void tryToUseMaskBuffer(
|
||||
const SalBitmap& rMaskBitmap,
|
||||
std::shared_ptr<MaskHelper>& rMask)
|
||||
void tryToUseMaskBuffer(const SalBitmap& rMaskBitmap, std::shared_ptr<MaskHelper>& rMask)
|
||||
{
|
||||
// MM02 try to access buffered MaskHelper
|
||||
std::shared_ptr<SystemDependentData_MaskHelper> pSystemDependentData_MaskHelper;
|
||||
|
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <headless/CairoCommon.hxx>
|
||||
#include <headless/svpbmp.hxx>
|
||||
#include <basegfx/utils/systemdependentdata.hxx>
|
||||
|
||||
class BitmapHelper : public SurfaceHelper
|
||||
{
|
||||
@@ -45,4 +46,31 @@ public:
|
||||
explicit MaskHelper(const SalBitmap& rAlphaBitmap);
|
||||
};
|
||||
|
||||
class SystemDependentData_BitmapHelper : public basegfx::SystemDependentData
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<BitmapHelper> maBitmapHelper;
|
||||
|
||||
public:
|
||||
SystemDependentData_BitmapHelper(
|
||||
basegfx::SystemDependentDataManager& rSystemDependentDataManager,
|
||||
const std::shared_ptr<BitmapHelper>& rBitmapHelper);
|
||||
|
||||
const std::shared_ptr<BitmapHelper>& getBitmapHelper() const { return maBitmapHelper; };
|
||||
virtual sal_Int64 estimateUsageInBytes() const override;
|
||||
};
|
||||
|
||||
class SystemDependentData_MaskHelper : public basegfx::SystemDependentData
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<MaskHelper> maMaskHelper;
|
||||
|
||||
public:
|
||||
SystemDependentData_MaskHelper(basegfx::SystemDependentDataManager& rSystemDependentDataManager,
|
||||
const std::shared_ptr<MaskHelper>& rMaskHelper);
|
||||
|
||||
const std::shared_ptr<MaskHelper>& getMaskHelper() const { return maMaskHelper; };
|
||||
virtual sal_Int64 estimateUsageInBytes() const override;
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -227,6 +227,4 @@ public:
|
||||
unsigned long nTargetHeight = 0) const;
|
||||
};
|
||||
|
||||
VCL_DLLPUBLIC sal_Int64 estimateUsageInBytesForSurfaceHelper(const SurfaceHelper* pHelper);
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
Reference in New Issue
Block a user