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

gtk3: move createCairoContext down to svpgdi

Change-Id: Ib3c6d6689c4b79a636a3f2f0f985f3573aa46f3d
üst a8be3fba
...@@ -33,6 +33,10 @@ ...@@ -33,6 +33,10 @@
#include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolygontools.hxx>
#include <basebmp/scanlineformats.hxx> #include <basebmp/scanlineformats.hxx>
#if ENABLE_CAIRO_CANVAS
#include <cairo.h>
#endif
#if OSL_DEBUG_LEVEL > 2 #if OSL_DEBUG_LEVEL > 2
#include <basebmp/debug.hxx> #include <basebmp/debug.hxx>
#include <fstream> #include <fstream>
...@@ -738,6 +742,27 @@ bool SvpSalGraphics::supportsOperation( OutDevSupportType ) const ...@@ -738,6 +742,27 @@ bool SvpSalGraphics::supportsOperation( OutDevSupportType ) const
#if ENABLE_CAIRO_CANVAS #if ENABLE_CAIRO_CANVAS
cairo_t* SvpSalGraphics::createCairoContext(const basebmp::BitmapDeviceSharedPtr &rBuffer)
{
if (rBuffer->getScanlineFormat() != basebmp::Format::ThirtyTwoBitTcMaskBGRX)
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;
}
bool SvpSalGraphics::SupportsCairo() const bool SvpSalGraphics::SupportsCairo() const
{ {
return false; return false;
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
class GlyphCache; class GlyphCache;
class ServerFont; class ServerFont;
typedef struct _cairo cairo_t;
class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics
{ {
...@@ -210,6 +211,8 @@ public: ...@@ -210,6 +211,8 @@ public:
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE; virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE;
static cairo_t* createCairoContext(const basebmp::BitmapDeviceSharedPtr& rBuffer);
#endif // ENABLE_CAIRO_CANVAS #endif // ENABLE_CAIRO_CANVAS
virtual void BeginPaint() SAL_OVERRIDE { }; virtual void BeginPaint() SAL_OVERRIDE { };
......
...@@ -3465,17 +3465,8 @@ gboolean GtkSalFrame::signalCrossing( GtkWidget*, GdkEventCrossing* pEvent, gpoi ...@@ -3465,17 +3465,8 @@ gboolean GtkSalFrame::signalCrossing( GtkWidget*, GdkEventCrossing* pEvent, gpoi
cairo_t* GtkSalFrame::getCairoContext() const cairo_t* GtkSalFrame::getCairoContext() const
{ {
basebmp::RawMemorySharedArray data = m_aFrame->getBuffer(); cairo_t* cr = SvpSalGraphics::createCairoContext(m_aFrame);
basegfx::B2IVector size = m_aFrame->getSize(); assert(cr);
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);
return 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