diff options
Diffstat (limited to 'vcl/unx/generic/gdi/openglx11cairotextrender.cxx')
-rw-r--r-- | vcl/unx/generic/gdi/openglx11cairotextrender.cxx | 53 |
1 files changed, 47 insertions, 6 deletions
diff --git a/vcl/unx/generic/gdi/openglx11cairotextrender.cxx b/vcl/unx/generic/gdi/openglx11cairotextrender.cxx index 64bf196ef54c..67024bf0f561 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; } |