summaryrefslogtreecommitdiff
path: root/vcl/inc/skia
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-10-06 22:56:40 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-10-07 16:18:16 +0200
commit3f359a03308493e59e0c29572fff7b0194c4aea1 (patch)
tree6b59220d693c712da2b0c6727b9cfa8603775e5e /vcl/inc/skia
parent6456ffec9d2082cc61d4ae60cad99e3c4ebfe82d (diff)
try more to match Skia's alpha type for source and destination
This is an extension of the other recent commit, matching alpha type is faster, and knowing the content is opaque should also allow more optimizations. Change-Id: I632d3f50e3f4729a64403c3c3ed1b79d63f0c5dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104046 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/inc/skia')
-rw-r--r--vcl/inc/skia/salbmp.hxx2
-rw-r--r--vcl/inc/skia/utils.hxx18
2 files changed, 17 insertions, 3 deletions
diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx
index 0cd48c8c46c2..49aabcf69a7f 100644
--- a/vcl/inc/skia/salbmp.hxx
+++ b/vcl/inc/skia/salbmp.hxx
@@ -82,6 +82,8 @@ public:
// Returns true if it is known that this bitmap can be ignored if it's to be used
// as an alpha bitmap. An optimization, not guaranteed to return true for all such cases.
bool IsFullyOpaqueAsAlpha() const;
+ // Alpha type best suitable for the content.
+ SkAlphaType alphaType() const;
#ifdef DBG_UTIL
void dump(const char* file) const;
diff --git a/vcl/inc/skia/utils.hxx b/vcl/inc/skia/utils.hxx
index b3a2045eea96..00feccedfdae 100644
--- a/vcl/inc/skia/utils.hxx
+++ b/vcl/inc/skia/utils.hxx
@@ -37,11 +37,23 @@ void disableRenderMethod(RenderMethod method);
// Create SkSurface, GPU-backed if possible.
VCL_DLLPUBLIC sk_sp<SkSurface> createSkSurface(int width, int height,
- SkColorType type = kN32_SkColorType);
+ SkColorType type = kN32_SkColorType,
+ SkAlphaType alpha = kPremul_SkAlphaType);
-inline sk_sp<SkSurface> createSkSurface(const Size& size, SkColorType type = kN32_SkColorType)
+inline sk_sp<SkSurface> createSkSurface(const Size& size, SkColorType type = kN32_SkColorType,
+ SkAlphaType alpha = kPremul_SkAlphaType)
{
- return createSkSurface(size.Width(), size.Height(), type);
+ return createSkSurface(size.Width(), size.Height(), type, alpha);
+}
+
+inline sk_sp<SkSurface> createSkSurface(int width, int height, SkAlphaType alpha)
+{
+ return createSkSurface(width, height, kN32_SkColorType, alpha);
+}
+
+inline sk_sp<SkSurface> createSkSurface(const Size& size, SkAlphaType alpha)
+{
+ return createSkSurface(size.Width(), size.Height(), kN32_SkColorType, alpha);
}
// Create SkImage, GPU-backed if possible.