summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-12-04 11:45:55 -0500
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-12-15 22:47:06 +0100
commitcf97d5ab928e9d3fb15167874c288381c13820c4 (patch)
tree07d64e02f576935e6cc82e0873aaa64c6648a094 /vcl
parent2b14154193bc26a4da022772de2cd6924edb8fb5 (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.hxx1
-rw-r--r--vcl/inc/openglgdiimpl.hxx2
-rw-r--r--vcl/opengl/gdiimpl.cxx5
-rw-r--r--vcl/unx/generic/gdi/cairotextrender.cxx4
-rw-r--r--vcl/unx/generic/gdi/openglx11cairotextrender.cxx39
-rw-r--r--vcl/unx/generic/gdi/openglx11cairotextrender.hxx1
-rw-r--r--vcl/unx/generic/gdi/x11cairotextrender.cxx6
-rw-r--r--vcl/unx/generic/gdi/x11cairotextrender.hxx1
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 3621aabb34e8..2c911eeb50d7 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -133,7 +133,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 611b72dc86ce..1b4d9d01cf26 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -226,6 +226,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;
};