vcl/inc/cairotextrender.hxx | 2 vcl/source/opengl/OpenGLHelper.cxx | 6 ++ vcl/unx/generic/gdi/cairotextrender.cxx | 2 vcl/unx/generic/gdi/openglx11cairotextrender.cxx | 53 ++++++++++++++++++++--- vcl/unx/generic/gdi/openglx11cairotextrender.hxx | 2 vcl/unx/generic/gdi/x11cairotextrender.cxx | 3 - vcl/unx/generic/gdi/x11cairotextrender.hxx | 3 - 7 files changed, 60 insertions(+), 11 deletions(-)
New commits: commit fa4327421ebaaf562d8689b454117b101c5eee24 Author: Chris Sherlock <chris.sherloc...@gmail.com> Date: Sat Jan 24 14:26:25 2015 +1100 vcl: OpenGLHelper::isVCLOpenGLEnabled() returns false when console only Change-Id: I7bcda46c73b958637073f8ec95d093385a81df3f diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index 99ef093..af1d8e7 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -18,6 +18,7 @@ #include <boost/scoped_array.hpp> #include <vcl/pngwrite.hxx> #include <vcl/graph.hxx> +#include <vcl/svapp.hxx> #include <officecfg/Office/Common.hxx> #include <vector> @@ -408,6 +409,11 @@ bool OpenGLHelper::isVCLOpenGLEnabled() static bool bSet = false; static bool bEnable = false; static bool bForceOpenGL = false; + + // If we are a console app, then we don't use OpenGL + if ( Application::IsConsoleOnly() ) + return false; + if (bSet) { return bForceOpenGL || bEnable; commit 35131df0ff833423809ea38621002322cf2d75b2 Author: Chris Sherlock <chris.sherloc...@gmail.com> Date: Mon Jan 19 16:04:24 2015 +1100 vcl: Reduce OpenGLX11CairoTextRender surface area to size of text bounds With this patch I get the text boundary and use it to reduce the size of the surface to this area. However, this is mainly needed for OpenGLX11CairoTextRender, which creates a surface image and uses this for OpenGL rendering. Change-Id: Icffc19bed89aaa2ff84ae845d274258a6fca27da diff --git a/vcl/inc/cairotextrender.hxx b/vcl/inc/cairotextrender.hxx index d59d75c..6eb887d 100644 --- a/vcl/inc/cairotextrender.hxx +++ b/vcl/inc/cairotextrender.hxx @@ -80,7 +80,7 @@ class CairoTextRender : public TextRenderImpl protected: virtual GlyphCache& getPlatformGlyphCache() = 0; - virtual cairo_surface_t* getCairoSurface() = 0; + virtual cairo_surface_t* getCairoSurface( const ServerFontLayout &rLayout ) = 0; virtual void getSurfaceOffset(double& nDX, double& nDY) = 0; virtual void drawSurface(cairo_t* cr) = 0; diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx index 7b0438e..1ad5936 100644 --- a/vcl/unx/generic/gdi/cairotextrender.cxx +++ b/vcl/unx/generic/gdi/cairotextrender.cxx @@ -204,7 +204,7 @@ void CairoTextRender::DrawServerFontLayout( const ServerFontLayout& rLayout ) if (cairo_glyphs.empty()) return; - cairo_surface_t *surface = getCairoSurface(); + cairo_surface_t *surface = getCairoSurface( rLayout ); DBG_ASSERT( surface!=NULL, "no cairo surface for text" ); if( !surface ) diff --git a/vcl/unx/generic/gdi/openglx11cairotextrender.cxx b/vcl/unx/generic/gdi/openglx11cairotextrender.cxx index 64bf196..67024bf 100644 --- a/vcl/unx/generic/gdi/openglx11cairotextrender.cxx +++ b/vcl/unx/generic/gdi/openglx11cairotextrender.cxx @@ -20,23 +20,64 @@ OpenGLX11CairoTextRender::OpenGLX11CairoTextRender(bool bPrinter, X11SalGraphics { } -cairo_surface_t* OpenGLX11CairoTextRender::getCairoSurface() +cairo_surface_t* OpenGLX11CairoTextRender::getCairoSurface( const ServerFontLayout& rLayout ) { // static size_t id = 0; // OString aFileName = OString("/tmp/libo_logs/text_rendering") + OString::number(id++) + OString(".svg"); // cairo_surface_t* surface = cairo_svg_surface_create(aFileName.getStr(), GetWidth(), GetHeight()); cairo_surface_t* surface = NULL; + Rectangle aTextBoundRect; OpenGLSalGraphicsImpl *pImpl = dynamic_cast< OpenGLSalGraphicsImpl* >(mrParent.GetImpl()); - if( pImpl ) + + if (pImpl) { Rectangle aClipRect = pImpl->getClipRegion().GetBoundRect(); - if( aClipRect.GetWidth() == 0 || aClipRect.GetHeight() == 0 ) + + // no clipping area, we need to take the whole area + if ( aClipRect.IsEmpty() ) + { + aClipRect.setWidth(GetWidth()); + aClipRect.setHeight(GetHeight()); + } + + if (!rLayout.GetOrientation() ) + { + // GetBoundRect can fail! + if ( rLayout.GetBoundRect(mrParent, aTextBoundRect) ) + { + // we need to take into account SalLayout's drawing offset + int nOffsetX = rLayout.DrawOffset().X() - rLayout.DrawBase().X(); + int nOffsetY = rLayout.DrawOffset().Y() - rLayout.DrawBase().Y(); + + aTextBoundRect.Left() += nOffsetX; + aTextBoundRect.Top() += nOffsetY; + + aTextBoundRect = aTextBoundRect.Intersection(aClipRect); + } + else + { + SAL_WARN("vcl.layout", "GetBoundRect() failed"); + } + } + else { - aClipRect.setWidth( GetWidth() ); - aClipRect.setHeight( GetHeight() ); + aTextBoundRect = aClipRect; } - surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, aClipRect.GetWidth(), aClipRect.GetHeight() ); } + else + { + SAL_WARN("vcl.opengl", "No OpenGLSalGraphicsImpl!"); + return NULL; + } + + + double nDX=0, nDY=0; + getSurfaceOffset(nDX, nDY); + + // add cairo surface offsets to work out surface width and height + surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, aTextBoundRect.GetWidth() + nDX, + aTextBoundRect.GetHeight() + nDY ); + return surface; } diff --git a/vcl/unx/generic/gdi/openglx11cairotextrender.hxx b/vcl/unx/generic/gdi/openglx11cairotextrender.hxx index 1719496..4f8a055 100644 --- a/vcl/unx/generic/gdi/openglx11cairotextrender.hxx +++ b/vcl/unx/generic/gdi/openglx11cairotextrender.hxx @@ -17,7 +17,7 @@ class OpenGLX11CairoTextRender : public X11CairoTextRender public: OpenGLX11CairoTextRender(bool bPrinter, X11SalGraphics& rParent); - virtual cairo_surface_t* getCairoSurface() SAL_OVERRIDE; + virtual cairo_surface_t* getCairoSurface( const ServerFontLayout& rLayout ) SAL_OVERRIDE; virtual void getSurfaceOffset(double& nDX, double& nDY) SAL_OVERRIDE; virtual void drawSurface(cairo_t* cr) SAL_OVERRIDE; }; diff --git a/vcl/unx/generic/gdi/x11cairotextrender.cxx b/vcl/unx/generic/gdi/x11cairotextrender.cxx index f3aa47d..2519816 100644 --- a/vcl/unx/generic/gdi/x11cairotextrender.cxx +++ b/vcl/unx/generic/gdi/x11cairotextrender.cxx @@ -53,7 +53,8 @@ GlyphCache& X11CairoTextRender::getPlatformGlyphCache() return X11GlyphCache::GetInstance(); } -cairo_surface_t* X11CairoTextRender::getCairoSurface() + +cairo_surface_t* X11CairoTextRender::getCairoSurface( const ServerFontLayout& ) { // find a XRenderPictFormat compatible with the Drawable XRenderPictFormat* pVisualFormat = mrParent.GetXRenderFormat(); diff --git a/vcl/unx/generic/gdi/x11cairotextrender.hxx b/vcl/unx/generic/gdi/x11cairotextrender.hxx index 1449b3a..57c85696 100644 --- a/vcl/unx/generic/gdi/x11cairotextrender.hxx +++ b/vcl/unx/generic/gdi/x11cairotextrender.hxx @@ -21,6 +21,7 @@ #define INCLUDED_VCL_UNX_GENERIC_GDI_X11CAIROTEXTRENDER_HXX value #include "cairotextrender.hxx" +#include "generic/glyphcache.hxx" #include "unx/saldata.hxx" #include "unx/saldisp.hxx" @@ -40,7 +41,7 @@ public: X11CairoTextRender(bool bPrinter, X11SalGraphics& rParent); virtual GlyphCache& getPlatformGlyphCache() SAL_OVERRIDE; - virtual cairo_surface_t* getCairoSurface() SAL_OVERRIDE; + virtual cairo_surface_t* getCairoSurface( const ServerFontLayout &rLayout ) SAL_OVERRIDE; virtual void getSurfaceOffset(double& nDX, double& nDY) SAL_OVERRIDE; virtual void clipRegion(cairo_t* cr) SAL_OVERRIDE; virtual void drawSurface(cairo_t* cr) SAL_OVERRIDE; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits