[Libreoffice-commits] core.git: config_host/config_skia.h.in vcl/skia

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Sun Oct 4 09:11:12 UTC 2020


 config_host/config_skia.h.in |    4 ++++
 vcl/skia/x11/gdiimpl.cxx     |   10 +++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

New commits:
commit 138cd28e2605740bbcacd22bac14aeb6bc5763cd
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Oct 2 20:36:27 2020 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Sun Oct 4 11:10:19 2020 +0200

    default to BGRA for Skia, even on X11
    
    As that seems to be the X11 setup, at least on my machine.
    This applies even to Vulkan, as we pass the XVisual to Skia.
    
    Change-Id: I2f1ee21c2bcf87bbb3bea7114b3b9a9aa060db13
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103870
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

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);


More information about the Libreoffice-commits mailing list