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

tweak to return a cairo_context instead of a cairo_surface

Change-Id: Ifd5c9b1c2cc1561d9ca5dfd70ab7c3c74a1af216
üst 95493cd4
......@@ -79,7 +79,7 @@ class CairoTextRender : public TextRenderImpl
protected:
virtual GlyphCache& getPlatformGlyphCache() = 0;
virtual cairo_surface_t* getCairoSurface() = 0;
virtual cairo_t* getCairoContext() = 0;
virtual void getSurfaceOffset(double& nDX, double& nDY) = 0;
virtual void drawSurface(cairo_t* cr) = 0;
......
......@@ -199,20 +199,18 @@ void CairoTextRender::DrawServerFontLayout( const ServerFontLayout& rLayout )
if (cairo_glyphs.empty())
return;
cairo_surface_t *surface = getCairoSurface();
DBG_ASSERT( surface!=NULL, "no cairo surface for text" );
if( !surface )
return;
/*
* It might be ideal to cache surface and cairo context between calls and
* only destroy it when the drawable changes, but to do that we need to at
* least change the SalFrame etc impls to dtor the SalGraphics *before* the
* destruction of the windows they reference
*/
cairo_t *cr = cairo_create(surface);
cairo_surface_destroy(surface);
cairo_t *cr = getCairoContext();
if (!cr)
{
SAL_WARN("vcl", "no cairo context for text");
return;
}
if (const void *pOptions = Application::GetSettings().GetStyleSettings().GetCairoFontOptions())
cairo_set_font_options(cr, static_cast<const cairo_font_options_t*>(pOptions));
......
......@@ -20,7 +20,7 @@ OpenGLX11CairoTextRender::OpenGLX11CairoTextRender(X11SalGraphics& rParent)
{
}
cairo_surface_t* OpenGLX11CairoTextRender::getCairoSurface()
cairo_t* OpenGLX11CairoTextRender::getCairoContext()
{
// static size_t id = 0;
// OString aFileName = OString("/tmp/libo_logs/text_rendering") + OString::number(id++) + OString(".svg");
......@@ -37,7 +37,11 @@ cairo_surface_t* OpenGLX11CairoTextRender::getCairoSurface()
}
surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, aClipRect.GetWidth(), aClipRect.GetHeight() );
}
return surface;
if (!surface)
return NULL;
cairo_t *cr = cairo_create(surface);
cairo_surface_destroy(surface);
return cr;
}
void OpenGLX11CairoTextRender::getSurfaceOffset( double& nDX, double& nDY )
......
......@@ -17,7 +17,7 @@ class OpenGLX11CairoTextRender : public X11CairoTextRender
public:
OpenGLX11CairoTextRender(X11SalGraphics& rParent);
virtual cairo_surface_t* getCairoSurface() SAL_OVERRIDE;
virtual cairo_t* getCairoContext() SAL_OVERRIDE;
virtual void getSurfaceOffset(double& nDX, double& nDY) SAL_OVERRIDE;
virtual void drawSurface(cairo_t* cr) SAL_OVERRIDE;
};
......
......@@ -52,7 +52,7 @@ GlyphCache& X11CairoTextRender::getPlatformGlyphCache()
return X11GlyphCache::GetInstance();
}
cairo_surface_t* X11CairoTextRender::getCairoSurface()
cairo_t* X11CairoTextRender::getCairoContext()
{
// find a XRenderPictFormat compatible with the Drawable
XRenderPictFormat* pVisualFormat = mrParent.GetXRenderFormat();
......@@ -73,7 +73,12 @@ cairo_surface_t* X11CairoTextRender::getCairoSurface()
mrParent.GetVisual().visual, SAL_MAX_INT16, SAL_MAX_INT16);
}
return surface;
if (!surface)
return NULL;
cairo_t *cr = cairo_create(surface);
cairo_surface_destroy(surface);
return cr;
}
void X11CairoTextRender::getSurfaceOffset( double& nDX, double& nDY )
......
......@@ -40,7 +40,7 @@ public:
X11CairoTextRender(X11SalGraphics& rParent);
virtual GlyphCache& getPlatformGlyphCache() SAL_OVERRIDE;
virtual cairo_surface_t* getCairoSurface() SAL_OVERRIDE;
virtual cairo_t* getCairoContext() 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;
......
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