[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/Library_vcl.mk vcl/Library_vclplug_gen.mk vcl/Library_vclplug_gtk3.mk vcl/unx

Caolán McNamara caolanm at redhat.com
Tue Mar 3 01:43:13 PST 2015


 vcl/Library_vcl.mk                            |    4 ++-
 vcl/Library_vclplug_gen.mk                    |    1 
 vcl/Library_vclplug_gtk3.mk                   |    1 
 vcl/headless/svptextrender.cxx                |    5 +++
 vcl/inc/cairotextrender.hxx                   |    6 +---
 vcl/inc/devicetextrender.hxx                  |   24 ------------------
 vcl/inc/headless/svpgdi.hxx                   |    8 +++---
 vcl/inc/headless/svptextrender.hxx            |    4 +--
 vcl/inc/textrender.hxx                        |    4 ++-
 vcl/inc/unx/gtk/gtkgdi.hxx                    |    8 ++++--
 vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx |   33 ++++++++++++++++++++++++++
 11 files changed, 60 insertions(+), 38 deletions(-)

New commits:
commit 7b4c2d836463efab19201fb466a137b2023cb52a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 2 11:44:42 2015 +0000

    render text with cairo under gtk3, not headless solution
    
    Change-Id: I309eaef08f597658c068170875733e5e1daa56ef
    Reviewed-on: https://gerrit.libreoffice.org/14715
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index a9430a5..6809333 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -566,7 +566,8 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/unx/generic/plugadapt/salplug \
     vcl/unx/generic/printer/jobdata \
     vcl/unx/generic/printer/ppdparser \
-	vcl/unx/generic/gdi/x11windowprovider \
+    vcl/unx/generic/gdi/cairotextrender \
+    vcl/unx/generic/gdi/x11windowprovider \
     $(if $(filter TRUE,$(ENABLE_CUPS)),\
         vcl/unx/generic/printer/cupsmgr \
         vcl/unx/generic/printer/printerinfomanager \
@@ -582,6 +583,7 @@ $(eval $(call gb_Library_use_libraries,vcl,\
 ))
 
 $(eval $(call gb_Library_use_externals,vcl,\
+	cairo \
 	cups \
 	dbus \
 	fontconfig \
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index 9b216dd..56135af 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -89,7 +89,6 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
     vcl/unx/generic/dtrans/X11_selection \
     vcl/unx/generic/dtrans/X11_service \
     vcl/unx/generic/dtrans/X11_transferable \
-    vcl/unx/generic/gdi/cairotextrender \
     vcl/unx/generic/gdi/x11cairotextrender \
     vcl/unx/generic/gdi/gcach_xpeer \
 	vcl/unx/generic/gdi/gdiimpl \
diff --git a/vcl/Library_vclplug_gtk3.mk b/vcl/Library_vclplug_gtk3.mk
index 917039b..5ba5722 100644
--- a/vcl/Library_vclplug_gtk3.mk
+++ b/vcl/Library_vclplug_gtk3.mk
@@ -102,6 +102,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gtk3,\
     vcl/unx/gtk3/app/gtk3gtkinst \
     vcl/unx/gtk3/app/gtk3gtksys \
     vcl/unx/gtk3/app/gtk3fpicker \
+    vcl/unx/gtk3/gdi/gtk3cairotextrender \
     vcl/unx/gtk3/gdi/gtk3gtkprintwrapper \
     vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk \
     vcl/unx/gtk3/gdi/gtk3salprn-gtk \
diff --git a/vcl/headless/svptextrender.cxx b/vcl/headless/svptextrender.cxx
index 334c341..72f4a85 100644
--- a/vcl/headless/svptextrender.cxx
+++ b/vcl/headless/svptextrender.cxx
@@ -487,4 +487,9 @@ void SvpTextRender::setDevice( basebmp::BitmapDeviceSharedPtr& rDevice )
     }
 }
 
+GlyphCache& SvpSalGraphics::getPlatformGlyphCache()
+{
+    return SvpGlyphCache::GetInstance();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/cairotextrender.hxx b/vcl/inc/cairotextrender.hxx
index ff4f7e4..26ab3c9 100644
--- a/vcl/inc/cairotextrender.hxx
+++ b/vcl/inc/cairotextrender.hxx
@@ -34,11 +34,9 @@ class ImplLayoutArgs;
 class ServerFontLayout;
 class PhysicalFontCollection;
 class PhysicalFontFace;
-struct _cairo_surface_t;
-typedef struct _cairo_surface cairo_surface_t;
 typedef struct _cairo cairo_t;
 
-class CairoFontsCache
+class VCL_DLLPUBLIC CairoFontsCache
 {
 public:
     struct CacheId
@@ -68,7 +66,7 @@ public:
     static void*                FindCachedFont(const CacheId &rId);
 };
 
-class CairoTextRender : public TextRenderImpl
+class VCL_DLLPUBLIC CairoTextRender : public TextRenderImpl
 {
     ServerFont*     mpServerFont[ MAX_FALLBACK ];
 
diff --git a/vcl/inc/devicetextrender.hxx b/vcl/inc/devicetextrender.hxx
deleted file mode 100644
index 3880e88..0000000
--- a/vcl/inc/devicetextrender.hxx
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_VCL_INC_DEVICETEXTRENDER_HXX
-#define INCLUDED_VCL_INC_DEVICETEXTRENDER_HXX
-
-#include <basebmp/bitmapdevice.hxx>
-#include "textrender.hxx"
-
-class VCL_DLLPUBLIC DeviceTextRenderImpl : public TextRenderImpl
-{
-public:
-    virtual void setDevice(basebmp::BitmapDeviceSharedPtr& rDevice) = 0;
-};
-
-#endif
-
-/* vim:set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 0c2f581..e9f5110 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -27,12 +27,13 @@
 
 #include "salgdi.hxx"
 #include "sallayout.hxx"
-#include "devicetextrender.hxx"
+#include "textrender.hxx"
 
 #ifdef IOS
 #define SvpSalGraphics AquaSalGraphics
 #else
 
+class GlyphCache;
 class ServerFont;
 
 class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics
@@ -53,6 +54,7 @@ protected:
     basegfx::B2IVector                   GetSize() { return m_aOrigDevice->getSize(); }
 
 public:
+    GlyphCache& getPlatformGlyphCache();
     void setDevice(basebmp::BitmapDeviceSharedPtr& rDevice);
     void BlendTextColor(const basebmp::Color &rTextColor, const basebmp::BitmapDeviceSharedPtr &rAlphaMask,
                         const basegfx::B2IPoint &rDstPoint);
@@ -69,8 +71,8 @@ private:
     void ensureClip();
 
 protected:
-    vcl::Region                           m_aClipRegion;
-    std::unique_ptr<DeviceTextRenderImpl> m_xTextRenderImpl;
+    vcl::Region                         m_aClipRegion;
+    std::unique_ptr<TextRenderImpl>     m_xTextRenderImpl;
 
 protected:
     virtual bool blendBitmap( const SalTwoRect&, const SalBitmap& rBitmap ) SAL_OVERRIDE;
diff --git a/vcl/inc/headless/svptextrender.hxx b/vcl/inc/headless/svptextrender.hxx
index a4a9415..13d99f4 100644
--- a/vcl/inc/headless/svptextrender.hxx
+++ b/vcl/inc/headless/svptextrender.hxx
@@ -20,11 +20,11 @@
 #ifndef INCLUDED_VCL_INC_HEADLESS_SVPTEXTRENDER_HXX
 #define INCLUDED_VCL_INC_HEADLESS_SVPTEXTRENDER_HXX
 
-#include "devicetextrender.hxx"
+#include "textrender.hxx"
 #include <vcl/region.hxx>
 #include <deque>
 
-class VCL_DLLPUBLIC SvpTextRender : public DeviceTextRenderImpl
+class VCL_DLLPUBLIC SvpTextRender : public TextRenderImpl
 {
 private:
     SvpSalGraphics& m_rParent;
diff --git a/vcl/inc/textrender.hxx b/vcl/inc/textrender.hxx
index a3a8876..12c47c3 100644
--- a/vcl/inc/textrender.hxx
+++ b/vcl/inc/textrender.hxx
@@ -24,7 +24,7 @@
 #include <vcl/salgtype.hxx>
 #include <vcl/vclenum.hxx>
 #include <vcl/metric.hxx>
-
+#include <basebmp/bitmapdevice.hxx>
 #include "salgdi.hxx"
 #include "salglyphid.hxx"
 #include "fontsubset.hxx"
@@ -42,6 +42,8 @@ class TextRenderImpl
 public:
     virtual ~TextRenderImpl() {}
 
+    virtual void setDevice(basebmp::BitmapDeviceSharedPtr& /*rDevice*/) {}
+
     virtual void                    SetTextColor( SalColor nSalColor ) = 0;
     virtual sal_uInt16              SetFont( FontSelectPattern*, int nFallbackLevel ) = 0;
     virtual void                    GetFontMetric( ImplFontMetricData*, int nFallbackLevel ) = 0;
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 15742da..2cbe6e0 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -26,11 +26,10 @@
 #include <gdk/gdkkeysyms.h>
 #include <postx.h>
 
-#include <unx/salgdi.h>
-
 #if GTK_CHECK_VERSION(3,0,0)
 
 #include <headless/svpgdi.hxx>
+#include "textrender.hxx"
 
 class GtkSalFrame;
 class GtkSalGraphics : public SvpSalGraphics
@@ -57,6 +56,10 @@ public:
     void updateSettings( AllSettings& rSettings );
     static void refreshFontconfig( GtkSettings *pSettings );
     static void signalSettingsNotify( GObject*, GParamSpec *pSpec, gpointer );
+
+    cairo_t* getCairoContext();
+    void clipRegion(cairo_t* cr);
+
 private:
     GtkWidget       *mpWindow;
     static GtkStyleContext *mpButtonStyle;
@@ -113,6 +116,7 @@ private:
 };
 
 #else
+#include <unx/salgdi.h>
 
 class GdkX11Pixmap;
 class GtkSalGraphics : public X11SalGraphics
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index e23f103..774be5a 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -16,6 +16,7 @@
 #include <unx/gtk/gtkgdi.hxx>
 #include <vcl/settings.hxx>
 #include "fontmanager.hxx"
+#include "gtk3cairotextrender.hxx"
 
 GtkStyleContext* GtkSalGraphics::mpButtonStyle = NULL;
 GtkStyleContext* GtkSalGraphics::mpEntryStyle = NULL;
@@ -1471,6 +1472,8 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
       mpFrame( pFrame ),
       mpWindow( pWindow )
 {
+    m_xTextRenderImpl.reset(new GtkCairoTextRender(*this));
+
     if(style_loaded)
         return;
 
@@ -1630,4 +1633,34 @@ void GtkSalGraphics::copyArea( long nDestX, long nDestY,
 #endif
 }
 
+cairo_t* GtkSalGraphics::getCairoContext()
+{
+    basebmp::RawMemorySharedArray data = mpFrame->m_aFrame->getBuffer();
+    basegfx::B2IVector size = mpFrame->m_aFrame->getSize();
+    sal_Int32 nStride = mpFrame->m_aFrame->getScanlineStride();
+    cairo_surface_t *target =
+        cairo_image_surface_create_for_data(data.get(),
+                                        CAIRO_FORMAT_RGB24,
+                                        size.getX(), size.getY(),
+                                        nStride);
+    cairo_t* cr = cairo_create(target);
+    cairo_surface_destroy(target);
+    return cr;
+//    return gdk_cairo_create(gtk_widget_get_window(mpFrame->getWindow()));
+}
+
+void GtkSalGraphics::clipRegion(cairo_t* cr)
+{
+    if (!m_aClipRegion.IsEmpty())
+    {
+        RectangleVector aRectangles;
+        m_aClipRegion.GetRegionRectangles(aRectangles);
+        for (RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
+        {
+            cairo_rectangle(cr, aRectIter->Left(), aRectIter->Top(), aRectIter->GetWidth(), aRectIter->GetHeight());
+        }
+        cairo_clip(cr);
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list