summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2015-06-05 14:00:34 +0200
committerJan Holesovsky <kendy@collabora.com>2015-06-05 14:00:34 +0200
commitd79fa4ee0fd5b6e9787838f74cc45c9c9b93a5b3 (patch)
tree6ffe77e049063b10b2e58c04f6f28409f4089e7c /vcl
parent0394d49a70e14e176c047ced39e2e754fcc26f3d (diff)
Revert "Cleanup crossplatform cairo"
Unfortunately this breaks Android and iOS. This reverts commit e4d55e8045c99af65a2cae57b26ec076825c9673.
Diffstat (limited to 'vcl')
-rw-r--r--vcl/Library_vcl.mk2
-rw-r--r--vcl/inc/quartz/salgdi.h6
-rw-r--r--vcl/inc/salgdi.hxx9
-rw-r--r--vcl/inc/win/salgdi.h6
-rw-r--r--vcl/quartz/salgdi.cxx10
-rw-r--r--vcl/quartz/salgdicommon.cxx118
-rw-r--r--vcl/source/outdev/font.cxx4
-rw-r--r--vcl/source/outdev/outdev.cxx9
-rw-r--r--vcl/win/source/gdi/salgdi.cxx139
-rw-r--r--vcl/win/source/gdi/salgdi3.cxx15
10 files changed, 301 insertions, 17 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 0ce40d39eb46..7c99bed96ec3 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -499,6 +499,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/osx/PictToBmpFlt \
vcl/osx/clipboard \
vcl/osx/service_entry \
+ vcl/quartz/cairo_quartz_cairo \
$(vcl_quartz_code) \
vcl/quartz/salgdiutils \
vcl/osx/salnativewidgets \
@@ -668,6 +669,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/win/source/app/salinst \
vcl/win/source/app/salshl \
vcl/win/source/app/saltimer \
+ vcl/win/source/gdi/cairo_win32_cairo \
vcl/win/source/gdi/gdiimpl \
vcl/win/source/gdi/salbmp \
vcl/win/source/gdi/salgdi \
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 7292479e8c9b..12c314482bba 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -414,6 +414,12 @@ public:
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 EndPaint() SAL_OVERRIDE { };
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 8c98d08b7b3e..50e5e5a30646 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -36,8 +36,6 @@
#include <map>
#include <set>
-#include <config_cairo_canvas.h>
-
class PhysicalFontCollection;
class SalBitmap;
class FontSelectPattern;
@@ -51,10 +49,7 @@ class OpenGLContext;
class OutputDevice;
class ServerFontLayout;
struct SystemGraphicsData;
-
-#if ENABLE_CAIRO_CANVAS
struct SystemFontData;
-#endif // ENABLE_CAIRO_CANVAS
namespace basegfx {
class B2DVector;
@@ -443,8 +438,6 @@ public:
virtual SystemGraphicsData GetGraphicsData() const = 0;
-#if ENABLE_CAIRO_CANVAS
-
/// Check whether cairo will work
virtual bool SupportsCairo() const = 0;
/// Create Surface from given cairo surface
@@ -457,8 +450,6 @@ public:
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const = 0;
-#endif // ENABLE_CAIRO_CANVAS
-
protected:
virtual bool setClipRegion( const vcl::Region& ) = 0;
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 504737a7eca5..fdd931ce5fe6 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -448,6 +448,12 @@ public:
virtual bool IsNativeControlSupported( ControlType nType, ControlPart nPart ) 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 EndPaint() SAL_OVERRIDE;
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 4f2104d79659..52cf48acf816 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -750,6 +750,16 @@ void AquaSalGraphics::FreeEmbedFontData( const void* pData, long /*nDataLen*/ )
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
{
#ifdef MACOSX
diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index b4e50e454dac..1464f18ce323 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -39,6 +39,11 @@
#include <vcl/sysdata.hxx>
#endif
+#include <config_cairo_canvas.h>
+#if ENABLE_CAIRO_CANVAS
+#include "cairo_quartz_cairo.hxx"
+#endif
+
#if defined(IOS) && defined(DBG_UTIL)
// Variables in TiledView.m
@@ -1445,6 +1450,119 @@ SystemGraphicsData AquaSalGraphics::GetGraphicsData() const
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 w = 0;
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index d9f239bc6f5c..216c8a6f8fcd 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -280,8 +280,6 @@ bool OutputDevice::GetFontCapabilities( vcl::FontCapabilities& rFontCapabilities
return mpGraphics->GetFontCapabilities(rFontCapabilities);
}
-#if ENABLE_CAIRO_CANVAS
-
SystemFontData OutputDevice::GetSysFontData(int nFallbacklevel) const
{
SystemFontData aSysFontData;
@@ -296,8 +294,6 @@ SystemFontData OutputDevice::GetSysFontData(int nFallbacklevel) const
return aSysFontData;
}
-#endif // ENABLE_CAIRO_CANVAS
-
void OutputDevice::ImplGetEmphasisMark( tools::PolyPolygon& rPolyPoly, bool& rPolyLine,
Rectangle& rRect1, Rectangle& rRect2,
long& rYOff, long& rWidth,
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index 0b6d0aa7ec01..2ae452e70d63 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -324,10 +324,9 @@ SystemGraphicsData OutputDevice::GetSystemGfxData() const
return mpGraphics->GetGraphicsData();
}
-#if ENABLE_CAIRO_CANVAS
-
bool OutputDevice::SupportsCairo() const
{
+#if ENABLE_CAIRO_CANVAS
if (!mpGraphics)
{
if (!AcquireGraphics())
@@ -335,6 +334,10 @@ bool OutputDevice::SupportsCairo() const
}
return mpGraphics->SupportsCairo();
+#else
+ (void) this; // loplugin:staticmethods
+ return false;
+#endif
}
cairo::SurfaceSharedPtr OutputDevice::CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const
@@ -377,8 +380,6 @@ css::uno::Any OutputDevice::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSur
return mpGraphics->GetNativeSurfaceHandle(rSurface, rSize);
}
-#endif // ENABLE_CAIRO_CANVAS
-
css::uno::Any OutputDevice::GetSystemGfxDataAny() const
{
const SystemGraphicsData aSysData = GetSystemGfxData();
diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index 95a5e94d15ec..23d4e5ca1924 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -36,6 +36,10 @@
#include "salgdiimpl.hxx"
#include "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>
@@ -1074,6 +1078,141 @@ SystemGraphicsData WinSalGraphics::GetGraphicsData() const
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()
{
return mpImpl->beginPaint();
diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx
index 76cbc222926e..89b8d96e2526 100644
--- a/vcl/win/source/gdi/salgdi3.cxx
+++ b/vcl/win/source/gdi/salgdi3.cxx
@@ -2773,4 +2773,19 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont,
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: */