diff options
-rw-r--r-- | vcl/inc/unx/salinst.h | 2 | ||||
-rw-r--r-- | vcl/inc/win/salinst.h | 1 | ||||
-rw-r--r-- | vcl/skia/salbmp.cxx | 19 | ||||
-rw-r--r-- | vcl/unx/generic/app/salinst.cxx | 10 | ||||
-rw-r--r-- | vcl/win/app/salinst.cxx | 10 |
5 files changed, 33 insertions, 9 deletions
diff --git a/vcl/inc/unx/salinst.h b/vcl/inc/unx/salinst.h index beff802c40c7..05b9f45f72e8 100644 --- a/vcl/inc/unx/salinst.h +++ b/vcl/inc/unx/salinst.h @@ -80,6 +80,8 @@ public: virtual void AfterAppInit() override; + std::shared_ptr<vcl::BackendCapabilities> GetBackendCapabilities() override; + // dtrans implementation virtual css::uno::Reference< css::uno::XInterface > CreateClipboard( const css::uno::Sequence< css::uno::Any >& i_rArguments ) override; diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h index bcd3540ad8a9..c06e51c84050 100644 --- a/vcl/inc/win/salinst.h +++ b/vcl/inc/win/salinst.h @@ -73,6 +73,7 @@ public: virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override; virtual OUString getOSVersion() override; + virtual std::shared_ptr<vcl::BackendCapabilities> GetBackendCapabilities() override; static int WorkaroundExceptionHandlingInUSER32Lib(int nExcept, LPEXCEPTION_POINTERS pExceptionInfo); }; diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx index 9f81965de88d..4430d7f672cd 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -23,7 +23,9 @@ #include <tools/helpers.hxx> #include <salgdi.hxx> +#include <salinst.hxx> #include <scanlinewriter.hxx> +#include <svdata.hxx> #include <SkCanvas.h> #include <SkImage.h> @@ -108,16 +110,15 @@ bool SkiaSalBitmap::CreateBitmapData() } if (colorType != kUnknown_SkColorType) { - // TODO - // As long as vcl::BackendCapabilities::mbSupportsBitmap32 is not set, we must use - // unpremultiplied alpha. This is because without mbSupportsBitmap32 set VCL uses - // an extra bitmap for the alpha channel and then merges the channels together - // into colors. kPremul_SkAlphaType would provide better performance, but - // without mbSupportsBitmap32 BitmapReadAccess::ImplSetAccessPointers() would use - // functions that merely read RGB without A, so the premultiplied values would - // not be converted back to unpremultiplied values. + // If vcl::BackendCapabilities::mbSupportsBitmap32 is set, + // BitmapReadAccess::ImplSetAccessPointers() uses functions that use premultiplied + // alpha. If not set, it would use functions that would read just RGB, so using + // premultiplied alpha here would change those values. + // Using kPremul_SkAlphaType should be better for performance, so ensure + // the flag is set. + assert(ImplGetSVData()->mpDefInst->GetBackendCapabilities()->mbSupportsBitmap32); if (!mBitmap.tryAllocPixels( - SkImageInfo::Make(mSize.Width(), mSize.Height(), colorType, kUnpremul_SkAlphaType))) + SkImageInfo::Make(mSize.Width(), mSize.Height(), colorType, kPremul_SkAlphaType))) { return false; } diff --git a/vcl/unx/generic/app/salinst.cxx b/vcl/unx/generic/app/salinst.cxx index f253f70d7d93..e5b2a92b89ce 100644 --- a/vcl/unx/generic/app/salinst.cxx +++ b/vcl/unx/generic/app/salinst.cxx @@ -224,4 +224,14 @@ std::unique_ptr<GenPspGraphics> X11SalInstance::CreatePrintGraphics() return std::make_unique<GenPspGraphics>(); } +std::shared_ptr<vcl::BackendCapabilities> X11SalInstance::GetBackendCapabilities() +{ + auto pBackendCapabilities = SalInstance::GetBackendCapabilities(); +#if HAVE_FEATURE_SKIA + if( SkiaHelper::isVCLSkiaEnabled()) + pBackendCapabilities->mbSupportsBitmap32 = true; +#endif + return pBackendCapabilities; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx index cd9332e0c728..4b97215b6dac 100644 --- a/vcl/win/app/salinst.cxx +++ b/vcl/win/app/salinst.cxx @@ -1074,4 +1074,14 @@ OUString WinSalInstance::getOSVersion() return aVer.makeStringAndClear(); } +std::shared_ptr<vcl::BackendCapabilities> WinSalInstance::GetBackendCapabilities() +{ + auto pBackendCapabilities = SalInstance::GetBackendCapabilities(); +#if HAVE_FEATURE_SKIA + if( SkiaHelper::isVCLSkiaEnabled()) + pBackendCapabilities->mbSupportsBitmap32 = true; +#endif + return pBackendCapabilities; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |