summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-11-17 13:03:23 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-11-23 14:25:59 +0000
commitc43a3a58677b467274ce6c21d7db1a6c0cc65cb4 (patch)
tree3bb61dc498bd5ff72df4be4e0003ab284b0cc655 /vcl/unx
parentb0f5416d7ee7c988d316df7ffa0318fa6514e4de (diff)
establish that Virtual Devices either match Physical Device depth or ...
are 1 or (rarely) 8 bit and lock that down. Change-Id: I3d946ebef34ffb71c5adea7aa420af50e9584e05
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/generic/gdi/cairo_xlib_cairo.cxx22
-rw-r--r--vcl/unx/generic/gdi/cairo_xlib_cairo.hxx4
-rw-r--r--vcl/unx/generic/gdi/salvd.cxx28
-rw-r--r--vcl/unx/gtk/gtkinst.cxx6
-rw-r--r--vcl/unx/gtk3/cairo_gtk3_cairo.cxx2
5 files changed, 47 insertions, 15 deletions
diff --git a/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx b/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx
index 71cba584eb22..a45faa4f8061 100644
--- a/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx
+++ b/vcl/unx/generic/gdi/cairo_xlib_cairo.cxx
@@ -271,7 +271,7 @@ namespace cairo
return VclPtr<VirtualDevice>(
VclPtr<VirtualDevice>::Create(&aSystemGraphicsData,
Size(width, height),
- std::max(getDepth(), 0)));
+ getFormat()));
}
/**
@@ -306,6 +306,26 @@ namespace cairo
return -1;
}
+
+ /**
+ * Surface::getFormat: Get the device format of the Canvas surface.
+ *
+ * @return color format
+ **/
+ DeviceFormat X11Surface::getFormat() const
+ {
+ if (!maSysData.pRenderFormat)
+ return DeviceFormat::FULLCOLOR;
+ switch (static_cast<XRenderPictFormat*>(maSysData.pRenderFormat)->depth)
+ {
+ case 1:
+ return DeviceFormat::BITMASK;
+ case 8:
+ return DeviceFormat::GRAYSCALE;
+ default:
+ return DeviceFormat::FULLCOLOR;
+ }
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/gdi/cairo_xlib_cairo.hxx b/vcl/unx/generic/gdi/cairo_xlib_cairo.hxx
index 319344770a6a..0ccf98a92aca 100644
--- a/vcl/unx/generic/gdi/cairo_xlib_cairo.hxx
+++ b/vcl/unx/generic/gdi/cairo_xlib_cairo.hxx
@@ -21,10 +21,9 @@
#define INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_XLIB_CAIRO_HXX
#include <sal/config.h>
-
#include <sal/types.h>
-
#include <vcl/cairo.hxx>
+#include <vcl/salgtype.hxx>
struct BitmapSystemData;
struct SystemEnvData;
@@ -92,6 +91,7 @@ namespace cairo {
virtual void flush() const override;
int getDepth() const;
+ DeviceFormat getFormat() const;
X11PixmapSharedPtr getPixmap() const { return mpPixmap; }
void* getRenderFormat() const { return maSysData.pRenderFormat; }
long getDrawable() const { return mpPixmap ? mpPixmap->mhDrawable : maSysData.hDrawable; }
diff --git a/vcl/unx/generic/gdi/salvd.cxx b/vcl/unx/generic/gdi/salvd.cxx
index 8aa87bfc8d46..d86677beb12d 100644
--- a/vcl/unx/generic/gdi/salvd.cxx
+++ b/vcl/unx/generic/gdi/salvd.cxx
@@ -36,20 +36,20 @@
#include <opengl/x11/salvd.hxx>
SalVirtualDevice* X11SalInstance::CreateX11VirtualDevice(SalGraphics* pGraphics,
- long &nDX, long &nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData,
+ long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData,
X11SalGraphics* pNewGraphics)
{
assert(pNewGraphics);
if (OpenGLHelper::isVCLOpenGLEnabled())
- return new X11OpenGLSalVirtualDevice( pGraphics, nDX, nDY, nBitCount, pData, pNewGraphics );
+ return new X11OpenGLSalVirtualDevice( pGraphics, nDX, nDY, eFormat, pData, pNewGraphics );
else
- return new X11SalVirtualDevice(pGraphics, nDX, nDY, nBitCount, pData, pNewGraphics);
+ return new X11SalVirtualDevice(pGraphics, nDX, nDY, eFormat, pData, pNewGraphics);
}
SalVirtualDevice* X11SalInstance::CreateVirtualDevice(SalGraphics* pGraphics,
- long &nDX, long &nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData)
+ long &nDX, long &nDY, DeviceFormat eFormat, const SystemGraphicsData *pData)
{
- return CreateX11VirtualDevice(pGraphics, nDX, nDY, nBitCount, pData, new X11SalGraphics());
+ return CreateX11VirtualDevice(pGraphics, nDX, nDY, eFormat, pData, new X11SalGraphics());
}
void X11SalGraphics::Init( X11SalVirtualDevice *pDevice, SalColormap* pColormap,
@@ -89,7 +89,7 @@ void X11SalGraphics::Init( X11SalVirtualDevice *pDevice, SalColormap* pColormap,
}
X11SalVirtualDevice::X11SalVirtualDevice(SalGraphics* pGraphics, long &nDX, long &nDY,
- sal_uInt16 nBitCount, const SystemGraphicsData *pData,
+ DeviceFormat eFormat, const SystemGraphicsData *pData,
X11SalGraphics* pNewGraphics) :
pGraphics_(pNewGraphics),
m_nXScreen(0),
@@ -98,8 +98,20 @@ X11SalVirtualDevice::X11SalVirtualDevice(SalGraphics* pGraphics, long &nDX, long
SalColormap* pColormap = nullptr;
bool bDeleteColormap = false;
- if( !nBitCount && pGraphics )
- nBitCount = pGraphics->GetBitCount();
+ sal_uInt16 nBitCount;
+ switch (eFormat)
+ {
+ case DeviceFormat::BITMASK:
+ nBitCount = 1;
+ break;
+ case DeviceFormat::GRAYSCALE:
+ nBitCount = 8;
+ break;
+ default:
+ nBitCount = pGraphics->GetBitCount();
+ break;
+
+ }
pDisplay_ = vcl_sal::getSalDisplay(GetGenericData());
nDepth_ = nBitCount;
diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
index 0e7ba5e7e0cd..ec13855308bc 100644
--- a/vcl/unx/gtk/gtkinst.cxx
+++ b/vcl/unx/gtk/gtkinst.cxx
@@ -315,19 +315,19 @@ void GtkYieldMutex::ThreadsLeave()
SalVirtualDevice* GtkInstance::CreateVirtualDevice( SalGraphics *pG,
long &nDX, long &nDY,
- sal_uInt16 nBitCount,
+ DeviceFormat eFormat,
const SystemGraphicsData *pGd )
{
EnsureInit();
#if GTK_CHECK_VERSION(3,0,0)
(void)pG; (void) pGd;
- SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice( nBitCount );
+ SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice(eFormat);
pNew->SetSize( nDX, nDY );
return pNew;
#else
GtkSalGraphics *pGtkSalGraphics = dynamic_cast<GtkSalGraphics*>(pG);
assert(pGtkSalGraphics);
- return CreateX11VirtualDevice(pG, nDX, nDY, nBitCount, pGd,
+ return CreateX11VirtualDevice(pG, nDX, nDY, eFormat, pGd,
new GtkSalGraphics(pGtkSalGraphics->GetGtkFrame(), pGtkSalGraphics->GetGtkWidget()));
#endif
}
diff --git a/vcl/unx/gtk3/cairo_gtk3_cairo.cxx b/vcl/unx/gtk3/cairo_gtk3_cairo.cxx
index ec5e641f150e..25e5a0ce1264 100644
--- a/vcl/unx/gtk3/cairo_gtk3_cairo.cxx
+++ b/vcl/unx/gtk3/cairo_gtk3_cairo.cxx
@@ -109,7 +109,7 @@ namespace cairo
VclPtr<VirtualDevice> Gtk3Surface::createVirtualDevice() const
{
- return VclPtrInstance<VirtualDevice>(nullptr, Size(1, 1), 0);
+ return VclPtrInstance<VirtualDevice>(nullptr, Size(1, 1), DeviceFormat::FULLCOLOR);
}
}