Kaydet (Commit) 7b4c2d83 authored tarafından Caolán McNamara's avatar Caolán McNamara

render text with cairo under gtk3, not headless solution

Change-Id: I309eaef08f597658c068170875733e5e1daa56ef
Reviewed-on: https://gerrit.libreoffice.org/14715Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst c5d8c466
...@@ -566,7 +566,8 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ ...@@ -566,7 +566,8 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/unx/generic/plugadapt/salplug \ vcl/unx/generic/plugadapt/salplug \
vcl/unx/generic/printer/jobdata \ vcl/unx/generic/printer/jobdata \
vcl/unx/generic/printer/ppdparser \ 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)),\ $(if $(filter TRUE,$(ENABLE_CUPS)),\
vcl/unx/generic/printer/cupsmgr \ vcl/unx/generic/printer/cupsmgr \
vcl/unx/generic/printer/printerinfomanager \ vcl/unx/generic/printer/printerinfomanager \
...@@ -582,6 +583,7 @@ $(eval $(call gb_Library_use_libraries,vcl,\ ...@@ -582,6 +583,7 @@ $(eval $(call gb_Library_use_libraries,vcl,\
)) ))
$(eval $(call gb_Library_use_externals,vcl,\ $(eval $(call gb_Library_use_externals,vcl,\
cairo \
cups \ cups \
dbus \ dbus \
fontconfig \ fontconfig \
......
...@@ -89,7 +89,6 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\ ...@@ -89,7 +89,6 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
vcl/unx/generic/dtrans/X11_selection \ vcl/unx/generic/dtrans/X11_selection \
vcl/unx/generic/dtrans/X11_service \ vcl/unx/generic/dtrans/X11_service \
vcl/unx/generic/dtrans/X11_transferable \ vcl/unx/generic/dtrans/X11_transferable \
vcl/unx/generic/gdi/cairotextrender \
vcl/unx/generic/gdi/x11cairotextrender \ vcl/unx/generic/gdi/x11cairotextrender \
vcl/unx/generic/gdi/gcach_xpeer \ vcl/unx/generic/gdi/gcach_xpeer \
vcl/unx/generic/gdi/gdiimpl \ vcl/unx/generic/gdi/gdiimpl \
......
...@@ -102,6 +102,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gtk3,\ ...@@ -102,6 +102,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gtk3,\
vcl/unx/gtk3/app/gtk3gtkinst \ vcl/unx/gtk3/app/gtk3gtkinst \
vcl/unx/gtk3/app/gtk3gtksys \ vcl/unx/gtk3/app/gtk3gtksys \
vcl/unx/gtk3/app/gtk3fpicker \ vcl/unx/gtk3/app/gtk3fpicker \
vcl/unx/gtk3/gdi/gtk3cairotextrender \
vcl/unx/gtk3/gdi/gtk3gtkprintwrapper \ vcl/unx/gtk3/gdi/gtk3gtkprintwrapper \
vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk \ vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk \
vcl/unx/gtk3/gdi/gtk3salprn-gtk \ vcl/unx/gtk3/gdi/gtk3salprn-gtk \
......
...@@ -487,4 +487,9 @@ void SvpTextRender::setDevice( basebmp::BitmapDeviceSharedPtr& rDevice ) ...@@ -487,4 +487,9 @@ void SvpTextRender::setDevice( basebmp::BitmapDeviceSharedPtr& rDevice )
} }
} }
GlyphCache& SvpSalGraphics::getPlatformGlyphCache()
{
return SvpGlyphCache::GetInstance();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -34,11 +34,9 @@ class ImplLayoutArgs; ...@@ -34,11 +34,9 @@ class ImplLayoutArgs;
class ServerFontLayout; class ServerFontLayout;
class PhysicalFontCollection; class PhysicalFontCollection;
class PhysicalFontFace; class PhysicalFontFace;
struct _cairo_surface_t;
typedef struct _cairo_surface cairo_surface_t;
typedef struct _cairo cairo_t; typedef struct _cairo cairo_t;
class CairoFontsCache class VCL_DLLPUBLIC CairoFontsCache
{ {
public: public:
struct CacheId struct CacheId
...@@ -68,7 +66,7 @@ public: ...@@ -68,7 +66,7 @@ public:
static void* FindCachedFont(const CacheId &rId); static void* FindCachedFont(const CacheId &rId);
}; };
class CairoTextRender : public TextRenderImpl class VCL_DLLPUBLIC CairoTextRender : public TextRenderImpl
{ {
ServerFont* mpServerFont[ MAX_FALLBACK ]; ServerFont* mpServerFont[ MAX_FALLBACK ];
......
/* -*- 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: */
...@@ -27,12 +27,13 @@ ...@@ -27,12 +27,13 @@
#include "salgdi.hxx" #include "salgdi.hxx"
#include "sallayout.hxx" #include "sallayout.hxx"
#include "devicetextrender.hxx" #include "textrender.hxx"
#ifdef IOS #ifdef IOS
#define SvpSalGraphics AquaSalGraphics #define SvpSalGraphics AquaSalGraphics
#else #else
class GlyphCache;
class ServerFont; class ServerFont;
class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics
...@@ -53,6 +54,7 @@ protected: ...@@ -53,6 +54,7 @@ protected:
basegfx::B2IVector GetSize() { return m_aOrigDevice->getSize(); } basegfx::B2IVector GetSize() { return m_aOrigDevice->getSize(); }
public: public:
GlyphCache& getPlatformGlyphCache();
void setDevice(basebmp::BitmapDeviceSharedPtr& rDevice); void setDevice(basebmp::BitmapDeviceSharedPtr& rDevice);
void BlendTextColor(const basebmp::Color &rTextColor, const basebmp::BitmapDeviceSharedPtr &rAlphaMask, void BlendTextColor(const basebmp::Color &rTextColor, const basebmp::BitmapDeviceSharedPtr &rAlphaMask,
const basegfx::B2IPoint &rDstPoint); const basegfx::B2IPoint &rDstPoint);
...@@ -69,8 +71,8 @@ private: ...@@ -69,8 +71,8 @@ private:
void ensureClip(); void ensureClip();
protected: protected:
vcl::Region m_aClipRegion; vcl::Region m_aClipRegion;
std::unique_ptr<DeviceTextRenderImpl> m_xTextRenderImpl; std::unique_ptr<TextRenderImpl> m_xTextRenderImpl;
protected: protected:
virtual bool blendBitmap( const SalTwoRect&, const SalBitmap& rBitmap ) SAL_OVERRIDE; virtual bool blendBitmap( const SalTwoRect&, const SalBitmap& rBitmap ) SAL_OVERRIDE;
......
...@@ -20,11 +20,11 @@ ...@@ -20,11 +20,11 @@
#ifndef INCLUDED_VCL_INC_HEADLESS_SVPTEXTRENDER_HXX #ifndef INCLUDED_VCL_INC_HEADLESS_SVPTEXTRENDER_HXX
#define INCLUDED_VCL_INC_HEADLESS_SVPTEXTRENDER_HXX #define INCLUDED_VCL_INC_HEADLESS_SVPTEXTRENDER_HXX
#include "devicetextrender.hxx" #include "textrender.hxx"
#include <vcl/region.hxx> #include <vcl/region.hxx>
#include <deque> #include <deque>
class VCL_DLLPUBLIC SvpTextRender : public DeviceTextRenderImpl class VCL_DLLPUBLIC SvpTextRender : public TextRenderImpl
{ {
private: private:
SvpSalGraphics& m_rParent; SvpSalGraphics& m_rParent;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <vcl/salgtype.hxx> #include <vcl/salgtype.hxx>
#include <vcl/vclenum.hxx> #include <vcl/vclenum.hxx>
#include <vcl/metric.hxx> #include <vcl/metric.hxx>
#include <basebmp/bitmapdevice.hxx>
#include "salgdi.hxx" #include "salgdi.hxx"
#include "salglyphid.hxx" #include "salglyphid.hxx"
#include "fontsubset.hxx" #include "fontsubset.hxx"
...@@ -42,6 +42,8 @@ class TextRenderImpl ...@@ -42,6 +42,8 @@ class TextRenderImpl
public: public:
virtual ~TextRenderImpl() {} virtual ~TextRenderImpl() {}
virtual void setDevice(basebmp::BitmapDeviceSharedPtr& /*rDevice*/) {}
virtual void SetTextColor( SalColor nSalColor ) = 0; virtual void SetTextColor( SalColor nSalColor ) = 0;
virtual sal_uInt16 SetFont( FontSelectPattern*, int nFallbackLevel ) = 0; virtual sal_uInt16 SetFont( FontSelectPattern*, int nFallbackLevel ) = 0;
virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ) = 0; virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ) = 0;
......
...@@ -26,11 +26,10 @@ ...@@ -26,11 +26,10 @@
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include <postx.h> #include <postx.h>
#include <unx/salgdi.h>
#if GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,0,0)
#include <headless/svpgdi.hxx> #include <headless/svpgdi.hxx>
#include "textrender.hxx"
class GtkSalFrame; class GtkSalFrame;
class GtkSalGraphics : public SvpSalGraphics class GtkSalGraphics : public SvpSalGraphics
...@@ -57,6 +56,10 @@ public: ...@@ -57,6 +56,10 @@ public:
void updateSettings( AllSettings& rSettings ); void updateSettings( AllSettings& rSettings );
static void refreshFontconfig( GtkSettings *pSettings ); static void refreshFontconfig( GtkSettings *pSettings );
static void signalSettingsNotify( GObject*, GParamSpec *pSpec, gpointer ); static void signalSettingsNotify( GObject*, GParamSpec *pSpec, gpointer );
cairo_t* getCairoContext();
void clipRegion(cairo_t* cr);
private: private:
GtkWidget *mpWindow; GtkWidget *mpWindow;
static GtkStyleContext *mpButtonStyle; static GtkStyleContext *mpButtonStyle;
...@@ -113,6 +116,7 @@ private: ...@@ -113,6 +116,7 @@ private:
}; };
#else #else
#include <unx/salgdi.h>
class GdkX11Pixmap; class GdkX11Pixmap;
class GtkSalGraphics : public X11SalGraphics class GtkSalGraphics : public X11SalGraphics
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <unx/gtk/gtkgdi.hxx> #include <unx/gtk/gtkgdi.hxx>
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
#include "fontmanager.hxx" #include "fontmanager.hxx"
#include "gtk3cairotextrender.hxx"
GtkStyleContext* GtkSalGraphics::mpButtonStyle = NULL; GtkStyleContext* GtkSalGraphics::mpButtonStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpEntryStyle = NULL; GtkStyleContext* GtkSalGraphics::mpEntryStyle = NULL;
...@@ -1471,6 +1472,8 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ) ...@@ -1471,6 +1472,8 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
mpFrame( pFrame ), mpFrame( pFrame ),
mpWindow( pWindow ) mpWindow( pWindow )
{ {
m_xTextRenderImpl.reset(new GtkCairoTextRender(*this));
if(style_loaded) if(style_loaded)
return; return;
...@@ -1630,4 +1633,34 @@ void GtkSalGraphics::copyArea( long nDestX, long nDestY, ...@@ -1630,4 +1633,34 @@ void GtkSalGraphics::copyArea( long nDestX, long nDestY,
#endif #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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment