Cleanup crossplatform cairo

Mac / Win cairo is not built / used, this cairo code can be removed to
reduce code bloat.

Change-Id: I758d674291e25e0722f5c66a0096295e903786b1
Reviewed-on: https://gerrit.libreoffice.org/16049
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
This commit is contained in:
Mox Soini 2015-06-02 23:52:56 +03:00 committed by Thorsten Behrens
parent 8854643a0a
commit e4d55e8045
12 changed files with 29 additions and 402 deletions

View File

@ -26,15 +26,6 @@
#include <vcl/metric.hxx> #include <vcl/metric.hxx>
#include <vcl/virdev.hxx> #include <vcl/virdev.hxx>
#ifdef WNT
#ifdef max
#undef max
#endif
#ifdef min
#undef min
#endif
#endif
#include <vcl/sysdata.hxx> #include <vcl/sysdata.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/matrix/b2dhommatrix.hxx>
@ -45,21 +36,12 @@
#include "cairo_textlayout.hxx" #include "cairo_textlayout.hxx"
#include "cairo_spritecanvas.hxx" #include "cairo_spritecanvas.hxx"
#ifdef CAIRO_HAS_QUARTZ_SURFACE #if defined CAIRO_HAS_FT_FONT
#include <cairo-quartz.h>
#elif defined CAIRO_HAS_WIN32_SURFACE
# include "cairo_win32_cairo.hxx"
# include <cairo-win32.h>
#elif defined CAIRO_HAS_FT_FONT
# include <cairo-ft.h> # include <cairo-ft.h>
#else #else
# error Native API needed. # error Native API needed.
#endif #endif
#ifdef IOS
#include <CoreText/CoreText.h>
#endif
using namespace ::cairo; using namespace ::cairo;
using namespace ::com::sun::star; using namespace ::com::sun::star;
@ -309,7 +291,7 @@ namespace cairocanvas
**/ **/
bool TextLayout::isCairoRenderable(SystemFontData aSysFontData) const bool TextLayout::isCairoRenderable(SystemFontData aSysFontData) const
{ {
#if defined UNX && !defined MACOSX && !defined IOS #if defined CAIRO_HAS_FT_FONT
// is font usable? // is font usable?
if (!aSysFontData.nFontId) if (!aSysFontData.nFontId)
return false; return false;
@ -325,46 +307,6 @@ namespace cairocanvas
return true; return true;
} }
#ifdef CAIRO_HAS_WIN32_SURFACE
namespace
{
/**
* cairo::ucs4toindex: Convert ucs4 char to glyph index
* @param ucs4 an ucs4 char
* @param hfont current font
*
* @return true if successful
**/
unsigned long ucs4toindex(unsigned int ucs4, HFONT hfont)
{
wchar_t unicode[2];
WORD glyph_index;
HDC hdc = NULL;
hdc = CreateCompatibleDC (NULL);
if (!hdc) return 0;
if (!SetGraphicsMode (hdc, GM_ADVANCED))
{
DeleteDC (hdc);
return 0;
}
SelectObject (hdc, hfont);
SetMapMode (hdc, MM_TEXT);
unicode[0] = ucs4;
unicode[1] = 0;
if (GetGlyphIndicesW (hdc, unicode, 1, &glyph_index, 0) == GDI_ERROR)
{
glyph_index = 0;
}
DeleteDC (hdc);
return glyph_index;
}
}
#endif
/** /**
* TextLayout::draw * TextLayout::draw
@ -385,9 +327,6 @@ namespace cairocanvas
{ {
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
SystemTextLayoutData aSysLayoutData; SystemTextLayoutData aSysLayoutData;
#if (defined CAIRO_HAS_WIN32_SURFACE) && (OSL_DEBUG_LEVEL > 1)
LOGFONTW logfont;
#endif
setupLayoutMode( rOutDev, mnTextDirection ); setupLayoutMode( rOutDev, mnTextDirection );
// TODO(P2): cache that // TODO(P2): cache that
@ -484,11 +423,6 @@ namespace cairocanvas
cairo_glyph_t aGlyph; cairo_glyph_t aGlyph;
aGlyph.index = systemGlyph.index; aGlyph.index = systemGlyph.index;
#ifdef CAIRO_HAS_WIN32_SURFACE
// Cairo requires standard glyph indexes (ETO_GLYPH_INDEX), while vcl/win/* uses ucs4 chars.
// Convert to standard indexes
aGlyph.index = ucs4toindex((unsigned int) aGlyph.index, rSysFontData.hFont);
#endif
aGlyph.x = systemGlyph.x; aGlyph.x = systemGlyph.x;
aGlyph.y = systemGlyph.y; aGlyph.y = systemGlyph.y;
cairo_glyphs.push_back(aGlyph); cairo_glyphs.push_back(aGlyph);
@ -502,24 +436,7 @@ namespace cairocanvas
**/ **/
cairo_font_face_t* font_face = NULL; cairo_font_face_t* font_face = NULL;
#ifdef CAIRO_HAS_QUARTZ_SURFACE #if defined CAIRO_HAS_FT_FONT
# ifdef MACOSX
// TODO: use cairo_quartz_font_face_create_for_cgfont(cgFont)
// when CGFont (Mac OS X 10.5 API) is provided by the AQUA VCL backend.
font_face = cairo_quartz_font_face_create_for_atsu_font_id((ATSUFontID) rSysFontData.aATSUFontID);
# else // iOS
font_face = cairo_quartz_font_face_create_for_cgfont( CTFontCopyGraphicsFont( rSysFontData.rCTFont, NULL ) );
# endif
#elif defined CAIRO_HAS_WIN32_SURFACE
# if (OSL_DEBUG_LEVEL > 1)
GetObjectW( rSysFontData.hFont, sizeof(logfont), &logfont );
# endif
// Note: cairo library uses logfont fallbacks when lfEscapement, lfOrientation and lfWidth are not zero.
// VCL always has non-zero value for lfWidth
font_face = cairo_win32_font_face_create_for_hfont(rSysFontData.hFont);
#elif defined CAIRO_HAS_FT_FONT
font_face = cairo_ft_font_face_create_for_ft_face(static_cast<FT_Face>(rSysFontData.nFontId), font_face = cairo_ft_font_face_create_for_ft_face(static_cast<FT_Face>(rSysFontData.nFontId),
rSysFontData.nFontFlags); rSysFontData.nFontFlags);
#else #else
@ -567,11 +484,6 @@ namespace cairocanvas
cairo_set_font_matrix(pSCairo.get(), &m); cairo_set_font_matrix(pSCairo.get(), &m);
#if (defined CAIRO_HAS_WIN32_SURFACE) && (OSL_DEBUG_LEVEL > 1)
# define TEMP_TRACE_FONT OUString(reinterpret_cast<const sal_Unicode*> (logfont.lfFaceName))
#else
# define TEMP_TRACE_FONT aFont.GetName()
#endif
SAL_INFO( SAL_INFO(
"canvas.cairo", "canvas.cairo",
"Size:(" << aFont.GetWidth() << "," << aFont.GetHeight() "Size:(" << aFont.GetWidth() << "," << aFont.GetHeight()
@ -586,9 +498,8 @@ namespace cairocanvas
<< (rSysFontData.bAntialias ? "AA " : "") << (rSysFontData.bAntialias ? "AA " : "")
<< (rSysFontData.bFakeBold ? "FB " : "") << (rSysFontData.bFakeBold ? "FB " : "")
<< (rSysFontData.bFakeItalic ? "FI " : "") << " || Name:" << (rSysFontData.bFakeItalic ? "FI " : "") << " || Name:"
<< TEMP_TRACE_FONT << " - " << aFont.GetName() << " - "
<< maText.Text.copy(maText.StartPosition, maText.Length)); << maText.Text.copy(maText.StartPosition, maText.Length));
#undef TEMP_TRACE_FONT
cairo_show_glyphs(pSCairo.get(), &cairo_glyphs[0], cairo_glyphs.size()); cairo_show_glyphs(pSCairo.get(), &cairo_glyphs[0], cairo_glyphs.size());

View File

@ -23,6 +23,8 @@
#include <vector> #include <vector>
#include <cstddef> #include <cstddef>
#include <config_cairo_canvas.h>
#ifdef MACOSX #ifdef MACOSX
// predeclare the native classes to avoid header/include problems // predeclare the native classes to avoid header/include problems
typedef struct CGContext *CGContextRef; typedef struct CGContext *CGContextRef;
@ -200,13 +202,12 @@ struct SystemGlyphData
int fallbacklevel; int fallbacklevel;
}; };
#if ENABLE_CAIRO_CANVAS
struct SystemFontData struct SystemFontData
{ {
unsigned long nSize; // size in bytes of this structure unsigned long nSize; // size in bytes of this structure
#if defined( WNT ) #if defined( UNX )
HFONT hFont; // native font object
#elif defined( MACOSX )
#elif defined( UNX )
void* nFontId; // native font id void* nFontId; // native font id
int nFontFlags; // native font flags int nFontFlags; // native font flags
#endif #endif
@ -217,10 +218,7 @@ struct SystemFontData
SystemFontData() SystemFontData()
: nSize( sizeof( SystemFontData ) ) : nSize( sizeof( SystemFontData ) )
#if defined( WNT ) #if defined( UNX )
, hFont( 0 )
#elif defined( MACOSX )
#elif defined( UNX )
, nFontId( NULL ) , nFontId( NULL )
, nFontFlags( 0 ) , nFontFlags( 0 )
#endif #endif
@ -232,6 +230,8 @@ struct SystemFontData
} }
}; };
#endif // ENABLE_CAIRO_CANVAS
typedef std::vector<SystemGlyphData> SystemGlyphDataVector; typedef std::vector<SystemGlyphData> SystemGlyphDataVector;
struct SystemTextLayoutData struct SystemTextLayoutData

View File

@ -499,7 +499,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/osx/PictToBmpFlt \ vcl/osx/PictToBmpFlt \
vcl/osx/clipboard \ vcl/osx/clipboard \
vcl/osx/service_entry \ vcl/osx/service_entry \
vcl/quartz/cairo_quartz_cairo \
$(vcl_quartz_code) \ $(vcl_quartz_code) \
vcl/quartz/salgdiutils \ vcl/quartz/salgdiutils \
vcl/osx/salnativewidgets \ vcl/osx/salnativewidgets \
@ -669,7 +668,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/win/source/app/salinst \ vcl/win/source/app/salinst \
vcl/win/source/app/salshl \ vcl/win/source/app/salshl \
vcl/win/source/app/saltimer \ vcl/win/source/app/saltimer \
vcl/win/source/gdi/cairo_win32_cairo \
vcl/win/source/gdi/gdiimpl \ vcl/win/source/gdi/gdiimpl \
vcl/win/source/gdi/salbmp \ vcl/win/source/gdi/salbmp \
vcl/win/source/gdi/salgdi \ vcl/win/source/gdi/salgdi \

View File

@ -414,12 +414,6 @@ public:
virtual SystemGraphicsData virtual SystemGraphicsData
GetGraphicsData() const SAL_OVERRIDE; GetGraphicsData() const SAL_OVERRIDE;
virtual bool SupportsCairo() const SAL_OVERRIDE;
virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const SAL_OVERRIDE;
virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const SAL_OVERRIDE;
virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const SAL_OVERRIDE;
virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& rSize) const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int /* nFallbacklevel */ ) const SAL_OVERRIDE;
virtual void BeginPaint() SAL_OVERRIDE { }; virtual void BeginPaint() SAL_OVERRIDE { };
virtual void EndPaint() SAL_OVERRIDE { }; virtual void EndPaint() SAL_OVERRIDE { };

View File

@ -36,6 +36,8 @@
#include <map> #include <map>
#include <set> #include <set>
#include <config_cairo_canvas.h>
class PhysicalFontCollection; class PhysicalFontCollection;
class SalBitmap; class SalBitmap;
class FontSelectPattern; class FontSelectPattern;
@ -49,7 +51,10 @@ class OpenGLContext;
class OutputDevice; class OutputDevice;
class ServerFontLayout; class ServerFontLayout;
struct SystemGraphicsData; struct SystemGraphicsData;
#if ENABLE_CAIRO_CANVAS
struct SystemFontData; struct SystemFontData;
#endif // ENABLE_CAIRO_CANVAS
namespace basegfx { namespace basegfx {
class B2DVector; class B2DVector;
@ -438,6 +443,8 @@ public:
virtual SystemGraphicsData GetGraphicsData() const = 0; virtual SystemGraphicsData GetGraphicsData() const = 0;
#if ENABLE_CAIRO_CANVAS
/// Check whether cairo will work /// Check whether cairo will work
virtual bool SupportsCairo() const = 0; virtual bool SupportsCairo() const = 0;
/// Create Surface from given cairo surface /// Create Surface from given cairo surface
@ -450,6 +457,8 @@ public:
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const = 0; virtual SystemFontData GetSysFontData( int nFallbacklevel ) const = 0;
#endif // ENABLE_CAIRO_CANVAS
protected: protected:
virtual bool setClipRegion( const vcl::Region& ) = 0; virtual bool setClipRegion( const vcl::Region& ) = 0;

View File

@ -448,12 +448,6 @@ public:
virtual bool IsNativeControlSupported( ControlType nType, ControlPart nPart ) SAL_OVERRIDE; virtual bool IsNativeControlSupported( ControlType nType, ControlPart nPart ) SAL_OVERRIDE;
virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE; virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE;
virtual bool SupportsCairo() const SAL_OVERRIDE;
virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const SAL_OVERRIDE;
virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const SAL_OVERRIDE;
virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const SAL_OVERRIDE;
virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& rSize) const SAL_OVERRIDE;
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE;
virtual void BeginPaint() SAL_OVERRIDE; virtual void BeginPaint() SAL_OVERRIDE;
virtual void EndPaint() SAL_OVERRIDE; virtual void EndPaint() SAL_OVERRIDE;

View File

@ -750,16 +750,6 @@ void AquaSalGraphics::FreeEmbedFontData( const void* pData, long /*nDataLen*/ )
DBG_ASSERT( (pData!=NULL), "AquaSalGraphics::FreeEmbedFontData() is not implemented\n"); DBG_ASSERT( (pData!=NULL), "AquaSalGraphics::FreeEmbedFontData() is not implemented\n");
} }
SystemFontData AquaSalGraphics::GetSysFontData( int /* nFallbacklevel */ ) const
{
SystemFontData aSysFontData;
aSysFontData.nSize = sizeof( SystemFontData );
aSysFontData.bAntialias = !mbNonAntialiasedText;
return aSysFontData;
}
bool AquaSalGraphics::IsFlipped() const bool AquaSalGraphics::IsFlipped() const
{ {
#ifdef MACOSX #ifdef MACOSX

View File

@ -39,11 +39,6 @@
#include <vcl/sysdata.hxx> #include <vcl/sysdata.hxx>
#endif #endif
#include <config_cairo_canvas.h>
#if ENABLE_CAIRO_CANVAS
#include "cairo_quartz_cairo.hxx"
#endif
#if defined(IOS) && defined(DBG_UTIL) #if defined(IOS) && defined(DBG_UTIL)
// Variables in TiledView.m // Variables in TiledView.m
@ -1450,119 +1445,6 @@ SystemGraphicsData AquaSalGraphics::GetGraphicsData() const
return aRes; return aRes;
} }
bool AquaSalGraphics::SupportsCairo() const
{
#if ENABLE_CAIRO_CANVAS
return true;
#else
return false;
#endif
}
/**
* cairo::createSurface: Create generic Canvas surface using given Cairo Surface
*
* @param rSurface Cairo Surface
*
* @return new Surface
*/
cairo::SurfaceSharedPtr AquaSalGraphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const
{
#if ENABLE_CAIRO_CANVAS
return cairo::SurfaceSharedPtr(new cairo::QuartzSurface(rSurface));
#else
(void)rSurface;
return cairo::SurfaceSharedPtr();
#endif
}
/**
* cairo::createSurface: Create Canvas surface using given VCL Window or Virtualdevice
*
* @param rSurface Cairo Surface
*
* For VCL Window, use platform native system environment data (struct SystemEnvData in vcl/inc/sysdata.hxx)
* For VCL Virtualdevice, use platform native system graphics data (struct SystemGraphicsData in vcl/inc/sysdata.hxx)
*
* @return new Surface
*/
cairo::SurfaceSharedPtr AquaSalGraphics::CreateSurface( const OutputDevice& rRefDevice,
int x, int y, int width, int height ) const
{
cairo::SurfaceSharedPtr surf;
#if ENABLE_CAIRO_CANVAS
if( rRefDevice.GetOutDevType() == OUTDEV_WINDOW )
{
const vcl::Window &rWindow = (const vcl::Window &) rRefDevice;
const SystemEnvData* pSysData = GetSysData(&rWindow);
if (pSysData)
surf = cairo::SurfaceSharedPtr(new cairo::QuartzSurface(pSysData->pView, x, y, width, height));
}
else if( rRefDevice.GetOutDevType() == OUTDEV_VIRDEV )
{
SystemGraphicsData aSysData = ((const VirtualDevice&) rRefDevice).GetSystemGfxData();
if (aSysData.rCGContext)
surf = cairo::SurfaceSharedPtr(new cairo::QuartzSurface(aSysData.rCGContext, x, y, width, height));
}
#else
(void)rRefDevice;
(void)x;
(void)y;
(void)width;
(void)height;
#endif
return surf;
}
/**
* cairo::createBitmapSurface: Create platform native Canvas surface from BitmapSystemData
* @param OutputDevice (not used)
* @param rData Platform native image data (struct BitmapSystemData in vcl/inc/bitmap.hxx)
* @param rSize width and height of the new surface
*
* Create a surface based on image data on rData
*
* @return new surface or empty surface
**/
cairo::SurfaceSharedPtr AquaSalGraphics::CreateBitmapSurface( const OutputDevice& /* rRefDevice */,
const BitmapSystemData& rData,
const Size& rSize ) const
{
#if ENABLE_CAIRO_CANVAS
OSL_TRACE( "requested size: %d x %d available size: %d x %d",
rSize.Width(), rSize.Height(), rData.mnWidth, rData.mnHeight );
if ( rData.mnWidth == rSize.Width() && rData.mnHeight == rSize.Height() )
{
CGContextRef rContext = (CGContextRef)rData.rImageContext;
OSL_TRACE("Canvas::cairo::createBitmapSurface(): New native image surface, context = %p.", rData.rImageContext);
return cairo::SurfaceSharedPtr(new cairo::QuartzSurface(rContext, 0, 0, rData.mnWidth, rData.mnHeight));
}
#else
(void)rData;
(void)rSize;
#endif
return cairo::SurfaceSharedPtr();
}
css::uno::Any AquaSalGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& /*rSize*/) const
{
sal_IntPtr handle;
#if ENABLE_CAIRO_CANVAS
cairo::QuartzSurface* pQuartzSurface = dynamic_cast<cairo::QuartzSurface*>(rSurface.get());
OSL_ASSERT(pQuartzSurface);
handle = sal_IntPtr (pQuartzSurface->getCGContext());
#else
handle = 0;
(void)rSurface;
#endif
css::uno::Sequence< css::uno::Any > args( 1 );
args[0] = css::uno::Any( handle );
return css::uno::Any( args );
}
long AquaSalGraphics::GetGraphicsWidth() const long AquaSalGraphics::GetGraphicsWidth() const
{ {
long w = 0; long w = 0;

View File

@ -280,6 +280,8 @@ bool OutputDevice::GetFontCapabilities( vcl::FontCapabilities& rFontCapabilities
return mpGraphics->GetFontCapabilities(rFontCapabilities); return mpGraphics->GetFontCapabilities(rFontCapabilities);
} }
#if ENABLE_CAIRO_CANVAS
SystemFontData OutputDevice::GetSysFontData(int nFallbacklevel) const SystemFontData OutputDevice::GetSysFontData(int nFallbacklevel) const
{ {
SystemFontData aSysFontData; SystemFontData aSysFontData;
@ -294,6 +296,8 @@ SystemFontData OutputDevice::GetSysFontData(int nFallbacklevel) const
return aSysFontData; return aSysFontData;
} }
#endif // ENABLE_CAIRO_CANVAS
void OutputDevice::ImplGetEmphasisMark( tools::PolyPolygon& rPolyPoly, bool& rPolyLine, void OutputDevice::ImplGetEmphasisMark( tools::PolyPolygon& rPolyPoly, bool& rPolyLine,
Rectangle& rRect1, Rectangle& rRect2, Rectangle& rRect1, Rectangle& rRect2,
long& rYOff, long& rWidth, long& rYOff, long& rWidth,

View File

@ -324,9 +324,10 @@ SystemGraphicsData OutputDevice::GetSystemGfxData() const
return mpGraphics->GetGraphicsData(); return mpGraphics->GetGraphicsData();
} }
#if ENABLE_CAIRO_CANVAS
bool OutputDevice::SupportsCairo() const bool OutputDevice::SupportsCairo() const
{ {
#if ENABLE_CAIRO_CANVAS
if (!mpGraphics) if (!mpGraphics)
{ {
if (!AcquireGraphics()) if (!AcquireGraphics())
@ -334,10 +335,6 @@ bool OutputDevice::SupportsCairo() const
} }
return mpGraphics->SupportsCairo(); return mpGraphics->SupportsCairo();
#else
(void) this; // loplugin:staticmethods
return false;
#endif
} }
cairo::SurfaceSharedPtr OutputDevice::CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const cairo::SurfaceSharedPtr OutputDevice::CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const
@ -380,6 +377,8 @@ css::uno::Any OutputDevice::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSur
return mpGraphics->GetNativeSurfaceHandle(rSurface, rSize); return mpGraphics->GetNativeSurfaceHandle(rSurface, rSize);
} }
#endif // ENABLE_CAIRO_CANVAS
css::uno::Any OutputDevice::GetSystemGfxDataAny() const css::uno::Any OutputDevice::GetSystemGfxDataAny() const
{ {
const SystemGraphicsData aSysData = GetSystemGfxData(); const SystemGraphicsData aSysData = GetSystemGfxData();

View File

@ -36,10 +36,6 @@
#include "salgdiimpl.hxx" #include "salgdiimpl.hxx"
#include "gdiimpl.hxx" #include "gdiimpl.hxx"
#include "opengl/win/gdiimpl.hxx" #include "opengl/win/gdiimpl.hxx"
#include <config_cairo_canvas.h>
#if ENABLE_CAIRO_CANVAS
#include "cairo_win32_cairo.cxx"
#endif
#include <vcl/opengl/OpenGLHelper.hxx> #include <vcl/opengl/OpenGLHelper.hxx>
@ -1078,141 +1074,6 @@ SystemGraphicsData WinSalGraphics::GetGraphicsData() const
return aRes; return aRes;
} }
bool WinSalGraphics::SupportsCairo() const
{
#if ENABLE_CAIRO_CANVAS
return true;
#else
return false;
#endif
}
/**
* cairo::createSurface: Create generic Canvas surface using given Cairo Surface
*
* @param rSurface Cairo Surface
*
* @return new Surface
*/
cairo::SurfaceSharedPtr WinSalGraphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const
{
#if ENABLE_CAIRO_CANVAS
return cairo::SurfaceSharedPtr(new cairo::Win32Surface(rSurface));
#else
(void)rSurface;
return cairo::SurfaceSharedPtr();
#endif
}
/**
* cairo::createSurface: Create Canvas surface using given VCL Window or Virtualdevice
*
* @param rSurface Cairo Surface
*
* For VCL Window, use platform native system environment data (struct SystemEnvData in vcl/inc/sysdata.hxx)
* For VCL Virtualdevice, use platform native system graphics data (struct SystemGraphicsData in vcl/inc/sysdata.hxx)
*
* @return new Surface
*/
cairo::SurfaceSharedPtr WinSalGraphics::CreateSurface( const OutputDevice& rRefDevice,
int x, int y, int /* width */, int /* height */) const
{
cairo::SurfaceSharedPtr surf;
#if ENABLE_CAIRO_CANVAS
if( rRefDevice.GetOutDevType() == OUTDEV_WINDOW )
{
const vcl::Window &rWindow = (const vcl::Window &) rRefDevice;
const SystemEnvData* pSysData = GetSysData(&rWindow);
if (pSysData && pSysData->hWnd)
surf = cairo::SurfaceSharedPtr(new cairo::Win32Surface(GetDC((HWND) pSysData->hWnd), x, y));
}
else if( rRefDevice.GetOutDevType() == OUTDEV_VIRDEV )
{
SystemGraphicsData aSysData = ((const VirtualDevice&) rRefDevice).GetSystemGfxData();
if (aSysData.hDC)
surf = cairo::SurfaceSharedPtr(new cairo::Win32Surface((HDC) aSysData.hDC, x, y));
}
#else
(void)rRefDevice;
(void)x;
(void)y;
#endif
return surf;
}
/**
* cairo::createBitmapSurface: Create platform native Canvas surface from BitmapSystemData
* @param OutputDevice (not used)
* @param rData Platform native image data (struct BitmapSystemData in vcl/inc/bitmap.hxx)
* @param rSize width and height of the new surface
*
* Create a surface based on image data on rData
*
* @return new surface or empty surface
**/
cairo::SurfaceSharedPtr WinSalGraphics::CreateBitmapSurface( const OutputDevice& /* rRefDevice */,
const BitmapSystemData& rData,
const Size& rSize ) const
{
OSL_TRACE( "requested size: %d x %d available size: %d x %d",
rSize.Width(), rSize.Height(), rData.mnWidth, rData.mnHeight );
#if ENABLE_CAIRO_CANVAS
if ( rData.mnWidth == rSize.Width() && rData.mnHeight == rSize.Height() )
return cairo::SurfaceSharedPtr(new cairo::Win32Surface( rData ));
#else
(void)rData;
(void)rSize;
#endif
return cairo::SurfaceSharedPtr();
}
#if ENABLE_CAIRO_CANVAS
namespace
{
HBITMAP surface2HBitmap( const SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize )
{
// can't seem to retrieve HBITMAP from cairo. copy content then
HDC hScreenDC=GetDC(NULL);
HBITMAP hBmpBitmap = CreateCompatibleBitmap( hScreenDC,
rSize.getX(),
rSize.getY() );
HDC hBmpDC = CreateCompatibleDC( 0 );
HBITMAP hBmpOld = (HBITMAP) SelectObject( hBmpDC, hBmpBitmap );
BitBlt( hBmpDC, 0, 0, rSize.getX(), rSize.getX(),
cairo_win32_surface_get_dc(rSurface->getCairoSurface().get()),
0, 0, SRCCOPY );
SelectObject( hBmpDC, hBmpOld );
DeleteDC( hBmpDC );
return hBmpBitmap;
}
}
#endif
css::uno::Any WinSalGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const ::basegfx::B2ISize& rSize) const
{
// TODO(F2): check whether under all circumstances,
// the alpha channel is ignored here.
css::uno::Sequence< css::uno::Any > args( 1 );
sal_Int64 nHandle;
#if ENABLE_CAIRO_CANVAS
nHandle = sal_Int64(surface2HBitmap(rSurface, rSize));
#else
(void)rSurface;
(void)rSize;
nHandle = 0;
#endif
args[1] = css::uno::Any(nHandle);
// caller frees the bitmap
return css::uno::Any( args );
}
void WinSalGraphics::BeginPaint() void WinSalGraphics::BeginPaint()
{ {
return mpImpl->beginPaint(); return mpImpl->beginPaint();

View File

@ -2773,19 +2773,4 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont,
void WinSalGraphics::DrawServerFontLayout( const ServerFontLayout& ) void WinSalGraphics::DrawServerFontLayout( const ServerFontLayout& )
{} {}
SystemFontData WinSalGraphics::GetSysFontData( int nFallbacklevel ) const
{
SystemFontData aSysFontData;
if (nFallbacklevel >= MAX_FALLBACK) nFallbacklevel = MAX_FALLBACK - 1;
if (nFallbacklevel < 0 ) nFallbacklevel = 0;
aSysFontData.hFont = mhFonts[nFallbacklevel];
OSL_TRACE("\r\n:WinSalGraphics::GetSysFontData(): FontID: %p, Fallback level: %d",
aSysFontData.hFont, nFallbacklevel);
return aSysFontData;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */