summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config_host/config_skia.h.in4
-rw-r--r--vcl/skia/x11/gdiimpl.cxx10
2 files changed, 11 insertions, 3 deletions
diff --git a/config_host/config_skia.h.in b/config_host/config_skia.h.in
index db103238d4fc..c302dbcca3e6 100644
--- a/config_host/config_skia.h.in
+++ b/config_host/config_skia.h.in
@@ -51,6 +51,10 @@ are the same.
// those tests needed updating, which presumably has never happened.
#define SK_DRAWBITMAPRECT_FAST_OFFSET 1
+// Default to BGRA. Skia already defaults to that on Windows, and it seems
+// the default X11 visual is actually also BGRA.
+#define SK_R32_SHIFT 16
+
// Enable Skia's internal checks depending on DBG_UTIL mode. ENABLE_SKIA_DEBUG
// controls whether to build with or without optimizations (set in Makefile).
#ifdef DBG_UTIL
diff --git a/vcl/skia/x11/gdiimpl.cxx b/vcl/skia/x11/gdiimpl.cxx
index 635beb1edb09..9b93a603dc38 100644
--- a/vcl/skia/x11/gdiimpl.cxx
+++ b/vcl/skia/x11/gdiimpl.cxx
@@ -91,10 +91,14 @@ X11SkiaSalGraphicsImpl::createWindowContext(Display* display, Drawable drawable,
switch (renderMethod)
{
case SkiaHelper::RenderRaster:
- // TODO The Skia Xlib code actually requires the non-native color type to work properly.
+ // Make sure we ask for color type that matches the X11 visual. If red mask
+ // is larger value than blue mask, then on little endian this means blue is first.
+ // This should also preferably match SK_R32_SHIFT set in config_skia.h, as that
+ // improves performance, the common setup seems to be BGRA (possibly because of
+ // choosing OpenGL-capable visual).
displayParams.fColorType
- = (displayParams.fColorType == kBGRA_8888_SkColorType ? kRGBA_8888_SkColorType
- : kBGRA_8888_SkColorType);
+ = (visual->red_mask > visual->blue_mask ? kBGRA_8888_SkColorType
+ : kRGBA_8888_SkColorType);
return sk_app::window_context_factory::MakeRasterForXlib(winInfo, displayParams);
case SkiaHelper::RenderVulkan:
return sk_app::window_context_factory::MakeVulkanForXlib(winInfo, displayParams);