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

gtk3: move createCairoContext down to svpgdi

(cherry picked from commit 253c0f07)

Change-Id: Ib3c6d6689c4b79a636a3f2f0f985f3573aa46f3d

cairo_format_stride_for_width is 1.6 onwards

(cherry picked from commit 5ce9954c)

Change-Id: Ic233b4b6c7067f2473eb76b0c7e520cfe1dfcd14
üst 69e5b158
......@@ -32,6 +32,10 @@
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <basebmp/scanlineformats.hxx>
#if ENABLE_CAIRO_CANVAS
#include <cairo.h>
#endif
#if OSL_DEBUG_LEVEL > 2
#include <basebmp/debug.hxx>
#include <fstream>
......@@ -737,6 +741,35 @@ bool SvpSalGraphics::supportsOperation( OutDevSupportType ) const
#endif
#if ENABLE_CAIRO_CANVAS
cairo_t* SvpSalGraphics::createCairoContext(const basebmp::BitmapDeviceSharedPtr &rBuffer)
{
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
if (rBuffer->getScanlineFormat() != basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_BGRX)
return NULL;
basegfx::B2IVector size = rBuffer->getSize();
sal_Int32 nStride = rBuffer->getScanlineStride();
if (cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, size.getX()) != nStride)
return NULL;
basebmp::RawMemorySharedArray data = rBuffer->getBuffer();
cairo_surface_t *target =
cairo_image_surface_create_for_data(data.get(),
CAIRO_FORMAT_RGB24,
size.getX(), size.getY(),
nStride);
cairo_t* cr = cairo_create(target);
cairo_surface_destroy(target);
return cr;
#else
return NULL;
#endif
}
#endif
bool SvpSalGraphics::SupportsCairo() const
{
return false;
......
......@@ -24,6 +24,7 @@
#include <basebmp/color.hxx>
#include <vcl/sysdata.hxx>
#include <vcl/metric.hxx>
#include <config_cairo_canvas.h>
#include "salgdi.hxx"
#include "sallayout.hxx"
......@@ -35,6 +36,7 @@
class GlyphCache;
class ServerFont;
typedef struct _cairo cairo_t;
class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics
{
......@@ -207,6 +209,12 @@ public:
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE;
#if ENABLE_CAIRO_CANVAS
static cairo_t* createCairoContext(const basebmp::BitmapDeviceSharedPtr& rBuffer);
#endif // ENABLE_CAIRO_CANVAS
virtual void BeginPaint() SAL_OVERRIDE { };
virtual void EndPaint() SAL_OVERRIDE { };
};
......
......@@ -3550,17 +3550,8 @@ gboolean GtkSalFrame::signalCrossing( GtkWidget*, GdkEventCrossing* pEvent, gpoi
cairo_t* GtkSalFrame::getCairoContext() const
{
basebmp::RawMemorySharedArray data = m_aFrame->getBuffer();
basegfx::B2IVector size = m_aFrame->getSize();
sal_Int32 nStride = m_aFrame->getScanlineStride();
assert(cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, size.getX()) == nStride);
cairo_surface_t *target =
cairo_image_surface_create_for_data(data.get(),
CAIRO_FORMAT_RGB24,
size.getX(), size.getY(),
nStride);
cairo_t* cr = cairo_create(target);
cairo_surface_destroy(target);
cairo_t* cr = SvpSalGraphics::createCairoContext(m_aFrame);
assert(cr);
return cr;
}
......
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