diff options
author | Louis-Francis Ratté-Boulianne <lfrb@collabora.com> | 2014-12-04 11:45:55 -0500 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-12-11 07:57:30 +0100 |
commit | f0f5f50243810762e27f1207b3c08b60ed888ee3 (patch) | |
tree | 738410582d7ad74dfa765aa3d9a74e2ca6600d3f /vcl | |
parent | 6e4a34018473652e981f1b85ebfaedddc9e0aea2 (diff) |
vcl: Limit Cairo surface size to the clipping region to improve performance
Conflicts:
vcl/unx/generic/gdi/openglx11cairotextrender.cxx
Change-Id: I469b34c9f1047a274550229391d3dfb578291df6
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/cairotextrender.hxx | 1 | ||||
-rw-r--r-- | vcl/inc/openglgdiimpl.hxx | 2 | ||||
-rw-r--r-- | vcl/opengl/gdiimpl.cxx | 5 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/cairotextrender.cxx | 4 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/openglx11cairotextrender.cxx | 39 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/openglx11cairotextrender.hxx | 1 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/x11cairotextrender.cxx | 6 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/x11cairotextrender.hxx | 1 |
8 files changed, 57 insertions, 2 deletions
diff --git a/vcl/inc/cairotextrender.hxx b/vcl/inc/cairotextrender.hxx index e5db2ab7e612..2b8a21ef68fb 100644 --- a/vcl/inc/cairotextrender.hxx +++ b/vcl/inc/cairotextrender.hxx @@ -77,6 +77,7 @@ class CairoTextRender : public TextRenderImpl protected: virtual GlyphCache& getPlatformGlyphCache() = 0; virtual cairo_surface_t* getCairoSurface() = 0; + virtual void getSurfaceOffset(double& nDX, double& nDY) = 0; virtual void drawSurface(cairo_t* cr) = 0; bool setFont( const FontSelectPattern *pEntry, int nFallbackLevel ); diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 03d1c239b0d6..a8ffe4db7b2f 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -129,7 +129,9 @@ public: virtual void freeResources() SAL_OVERRIDE; + virtual const vcl::Region& getClipRegion() const; virtual bool setClipRegion( const vcl::Region& ) SAL_OVERRIDE; + // // get the depth of the device virtual sal_uInt16 GetBitCount() const SAL_OVERRIDE; diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index f4fb17d8bacd..86a592952234 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -225,6 +225,11 @@ void OpenGLSalGraphicsImpl::ImplInitClipRegion() CHECK_GL_ERROR(); } +const vcl::Region& OpenGLSalGraphicsImpl::getClipRegion() const +{ + return maClipRegion; +} + bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip ) { SAL_INFO( "vcl.opengl", "::setClipRegion " << rClip ); diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx index 5b31b92fd42a..589b53ae2dd1 100644 --- a/vcl/unx/generic/gdi/cairotextrender.cxx +++ b/vcl/unx/generic/gdi/cairotextrender.cxx @@ -222,6 +222,10 @@ void CairoTextRender::DrawServerFontLayout( const ServerFontLayout& rLayout ) if (const void *pOptions = Application::GetSettings().GetStyleSettings().GetCairoFontOptions()) cairo_set_font_options(cr, static_cast<const cairo_font_options_t*>(pOptions)); + double nDX, nDY; + getSurfaceOffset(nDX, nDY); + cairo_translate(cr, nDX, nDY); + clipRegion(cr); cairo_set_source_rgb(cr, diff --git a/vcl/unx/generic/gdi/openglx11cairotextrender.cxx b/vcl/unx/generic/gdi/openglx11cairotextrender.cxx index f16fe966b4b7..7b4e6643eb1a 100644 --- a/vcl/unx/generic/gdi/openglx11cairotextrender.cxx +++ b/vcl/unx/generic/gdi/openglx11cairotextrender.cxx @@ -25,10 +25,32 @@ cairo_surface_t* OpenGLX11CairoTextRender::getCairoSurface() // 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 = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, GetWidth(), GetHeight()); + cairo_surface_t* surface = NULL; + OpenGLSalGraphicsImpl *pImpl = dynamic_cast< OpenGLSalGraphicsImpl* >(mrParent.GetImpl()); + if( pImpl ) + { + Rectangle aClipRect = pImpl->getClipRegion().GetBoundRect(); + if( aClipRect.GetWidth() == 0 || aClipRect.GetHeight() == 0 ) + { + aClipRect.setWidth( GetWidth() ); + aClipRect.setHeight( GetHeight() ); + } + surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, aClipRect.GetWidth(), aClipRect.GetHeight() ); + } return surface; } +void OpenGLX11CairoTextRender::getSurfaceOffset( double& nDX, double& nDY ) +{ + OpenGLSalGraphicsImpl *pImpl = dynamic_cast< OpenGLSalGraphicsImpl* >(mrParent.GetImpl()); + if( pImpl ) + { + Rectangle aClipRect = pImpl->getClipRegion().GetBoundRect(); + nDX = -aClipRect.Left(); + nDY = -aClipRect.Top(); + } +} + void OpenGLX11CairoTextRender::drawSurface(cairo_t* cr) { // XXX: lfrb: GLES 2.0 doesn't support GL_UNSIGNED_INT_8_8_8_8_REV @@ -42,7 +64,20 @@ void OpenGLX11CairoTextRender::drawSurface(cairo_t* cr) cairo_surface_flush( pSurface ); unsigned char *pSrc = cairo_image_surface_get_data( pSurface ); - SalTwoRect aRect(0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight); + // XXX: lfrb: GLES 2.0 doesn't support GL_UNSIGNED_INT_8_8_8_8_REV + Rectangle aClipRect = pImpl->getClipRegion().GetBoundRect(); + + SalTwoRect aRect(0, 0, nWidth, nHeight, + aClipRect.Left(), aClipRect.Top(), nWidth, nHeight); + aRect.mnSrcX = 0; + aRect.mnSrcY = 0; + aRect.mnSrcWidth = nWidth; + aRect.mnSrcHeight = nHeight; + aRect.mnDestX = aClipRect.Left(); + aRect.mnDestY = aClipRect.Top(); + aRect.mnDestWidth = nWidth; + aRect.mnDestHeight = nHeight; + // Cairo surface data is ARGB with premultiplied alpha and is Y-inverted OpenGLTexture aTexture( nWidth, nHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pSrc ); pImpl->PreDraw(); diff --git a/vcl/unx/generic/gdi/openglx11cairotextrender.hxx b/vcl/unx/generic/gdi/openglx11cairotextrender.hxx index 87ef9483cacb..171949651635 100644 --- a/vcl/unx/generic/gdi/openglx11cairotextrender.hxx +++ b/vcl/unx/generic/gdi/openglx11cairotextrender.hxx @@ -18,6 +18,7 @@ public: OpenGLX11CairoTextRender(bool bPrinter, X11SalGraphics& rParent); virtual cairo_surface_t* getCairoSurface() 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 0449b98148b1..f3aa47d07800 100644 --- a/vcl/unx/generic/gdi/x11cairotextrender.cxx +++ b/vcl/unx/generic/gdi/x11cairotextrender.cxx @@ -77,6 +77,12 @@ cairo_surface_t* X11CairoTextRender::getCairoSurface() return surface; } +void X11CairoTextRender::getSurfaceOffset( double& nDX, double& nDY ) +{ + nDX = 0; + nDY = 0; +} + void X11CairoTextRender::clipRegion(cairo_t* cr) { Region pClipRegion = mrParent.mpClipRegion; diff --git a/vcl/unx/generic/gdi/x11cairotextrender.hxx b/vcl/unx/generic/gdi/x11cairotextrender.hxx index fb0c130ab292..1449b3aa0dc5 100644 --- a/vcl/unx/generic/gdi/x11cairotextrender.hxx +++ b/vcl/unx/generic/gdi/x11cairotextrender.hxx @@ -41,6 +41,7 @@ public: virtual GlyphCache& getPlatformGlyphCache() SAL_OVERRIDE; virtual cairo_surface_t* getCairoSurface() 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; }; |