[Libreoffice-commits] core.git: 3 commits - vcl/headless vcl/inc vcl/unx
Caolán McNamara
caolanm at redhat.com
Thu Jun 25 01:24:38 PDT 2015
vcl/headless/svpgdi.cxx | 148 +++++++++++++++++++++-----
vcl/inc/headless/svpgdi.hxx | 1
vcl/inc/unx/gtk/gtkgdi.hxx | 2
vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 14 --
4 files changed, 123 insertions(+), 42 deletions(-)
New commits:
commit 8eb8ef879320960fe2147a039bbb933484856693
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 24 10:30:28 2015 +0100
gtk3: fix 'degenerate' clip in cairo clipping
fix spelling in basebmp clipping case and downgrade
to INFO
Change-Id: I16ec943bd4be8ca374ded7827e4ec24e7df03e8e
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index afc1bc4..ebacfbb 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -119,10 +119,13 @@ namespace
void SvpSalGraphics::clipRegion(cairo_t* cr)
{
+ RectangleVector aRectangles;
if (!m_aClipRegion.IsEmpty())
{
- RectangleVector aRectangles;
m_aClipRegion.GetRegionRectangles(aRectangles);
+ }
+ if (!aRectangles.empty())
+ {
for (RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
{
cairo_rectangle(cr, aRectIter->Left(), aRectIter->Top(), aRectIter->GetWidth(), aRectIter->GetHeight());
@@ -149,6 +152,8 @@ bool SvpSalGraphics::drawAlphaRect(long nX, long nY, long nWidth, long nHeight,
cairo_translate(cr, 0.0, -m_aDevice->getSize().getY());
}
+ clipRegion(cr);
+
const double fTransparency = (100 - nTransparency) * (1.0/100);
cairo_set_source_rgba(cr, m_aFillColor.getRed()/255.0,
m_aFillColor.getGreen()/255.0,
@@ -326,7 +331,7 @@ bool SvpSalGraphics::isClippedSetup( const basegfx::B2IBox &aRange, SvpSalGraphi
if( nHit == 0 ) // rendering outside any clipping region
{
- SAL_WARN("vcl.headless", "SvpSalGraphics::isClippedSetup: denegerate case detected ...\n");
+ SAL_INFO("vcl.headless", "SvpSalGraphics::isClippedSetup: degenerate case detected ...");
return true;
}
else if( nHit == 1 ) // common path: rendering against just one clipping region
@@ -335,10 +340,10 @@ bool SvpSalGraphics::isClippedSetup( const basegfx::B2IBox &aRange, SvpSalGraphi
{
//The region to be painted (aRect) is equal to or inside the
//current clipping region
- SAL_WARN("vcl.headless", "SvpSalGraphics::isClippedSetup: is inside ! avoid deeper clip ...\n");
+ SAL_INFO("vcl.headless", "SvpSalGraphics::isClippedSetup: is inside ! avoid deeper clip ...");
return false;
}
- SAL_WARN("vcl.headless", "SvpSalGraphics::isClippedSetup: operation only overlaps with a single clip zone\n");
+ SAL_INFO("vcl.headless", "SvpSalGraphics::isClippedSetup: operation only overlaps with a single clip zone");
rUndo.m_aDevice = m_aDevice;
m_aDevice = basebmp::subsetBitmapDevice( m_aOrigDevice,
basegfx::B2IBox (aHitRect.Left(),
commit edf56cb4300f68a3e513420feccbf8d5287a0428
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 24 10:09:26 2015 +0100
gtk3: move cairo region clipping to svp
Change-Id: I4b4f09ee3fb7edbda3b6bb5af024c0966e3a2082
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 4fe1689..afc1bc4 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -117,6 +117,20 @@ namespace
}
}
+void SvpSalGraphics::clipRegion(cairo_t* cr)
+{
+ if (!m_aClipRegion.IsEmpty())
+ {
+ RectangleVector aRectangles;
+ m_aClipRegion.GetRegionRectangles(aRectangles);
+ for (RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
+ {
+ cairo_rectangle(cr, aRectIter->Left(), aRectIter->Top(), aRectIter->GetWidth(), aRectIter->GetHeight());
+ }
+ cairo_clip(cr);
+ }
+}
+
#endif
bool SvpSalGraphics::drawAlphaRect(long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency)
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index aacbf99..587d488 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -212,6 +212,7 @@ public:
virtual SystemFontData GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE;
static cairo_t* createCairoContext(const basebmp::BitmapDeviceSharedPtr& rBuffer);
+ void clipRegion(cairo_t* cr);
#endif // ENABLE_CAIRO_CANVAS
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 0d02188..80de62b 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -61,8 +61,6 @@ public:
cairo_t* getCairoContext() const;
- void clipRegion(cairo_t* cr);
-
private:
GtkWidget *mpWindow;
static GtkStyleContext *mpButtonStyle;
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index 9457902..985db9e 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -2103,18 +2103,4 @@ cairo_t* GtkSalGraphics::getCairoContext() const
return mpFrame->getCairoContext();
}
-void GtkSalGraphics::clipRegion(cairo_t* cr)
-{
- if (!m_aClipRegion.IsEmpty())
- {
- RectangleVector aRectangles;
- m_aClipRegion.GetRegionRectangles(aRectangles);
- for (RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
- {
- cairo_rectangle(cr, aRectIter->Left(), aRectIter->Top(), aRectIter->GetWidth(), aRectIter->GetHeight());
- }
- cairo_clip(cr);
- }
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 65d31de78dd3f5055102122e60b7261f8b170df5
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 24 10:07:14 2015 +0100
gtk3: alpha rects using cairo
Change-Id: I7fdcd6336fdc7ea8149c385a177db91ffaa61c94
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index bdc20bb..4fe1689 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -95,10 +95,86 @@ bool SvpSalGraphics::drawTransformedBitmap(
return false;
}
-bool SvpSalGraphics::drawAlphaRect( long /*nX*/, long /*nY*/, long /*nWidth*/, long /*nHeight*/, sal_uInt8 /*nTransparency*/ )
+#if ENABLE_CAIRO_CANVAS
+
+namespace
{
- // TODO(P3) implement alpha blending
+ bool isCairoCompatible(const basebmp::BitmapDeviceSharedPtr &rBuffer)
+ {
+ if (!rBuffer)
+ return false;
+
+ if (rBuffer->getScanlineFormat() != basebmp::Format::ThirtyTwoBitTcMaskBGRX)
+ return false;
+
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
+ basegfx::B2IVector size = rBuffer->getSize();
+ sal_Int32 nStride = rBuffer->getScanlineStride();
+ return (cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, size.getX()) == nStride);
+#else
+ return false;
+#endif
+ }
+}
+
+#endif
+
+bool SvpSalGraphics::drawAlphaRect(long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency)
+{
+#if ENABLE_CAIRO_CANVAS
+ if (m_bUseLineColor || !m_bUseFillColor)
+ return false;
+
+ cairo_t* cr = createCairoContext(m_aDevice);
+ if (!cr)
+ return false;
+
+ if (!m_aDevice->isTopDown())
+ {
+ cairo_scale(cr, 1, -1.0);
+ cairo_translate(cr, 0.0, -m_aDevice->getSize().getY());
+ }
+
+ const double fTransparency = (100 - nTransparency) * (1.0/100);
+ cairo_set_source_rgba(cr, m_aFillColor.getRed()/255.0,
+ m_aFillColor.getGreen()/255.0,
+ m_aFillColor.getBlue()/255.0,
+ fTransparency);
+ cairo_rectangle(cr, nX, nY, nWidth, nHeight);
+
+
+ cairo_rectangle_int_t extents;
+ basebmp::IBitmapDeviceDamageTrackerSharedPtr xDamageTracker(m_aDevice->getDamageTracker());
+ if (xDamageTracker)
+ {
+ double x1, y1, x2, y2;
+
+ cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
+ extents.x = x1, extents.y = x2, extents.width = x2-x1, extents.height = y2-y1;
+ cairo_region_t *region = cairo_region_create_rectangle(&extents);
+
+ cairo_fill_extents(cr, &x1, &y1, &x2, &y2);
+ extents.x = x1, extents.y = x2, extents.width = x2-x1, extents.height = y2-y1;
+ cairo_region_intersect_rectangle(region, &extents);
+
+ cairo_region_get_extents(region, &extents);
+ cairo_region_destroy(region);
+ }
+
+ cairo_fill(cr);
+
+ cairo_surface_flush(cairo_get_target(cr));
+ cairo_destroy(cr); // unref
+
+ if (xDamageTracker)
+ {
+ xDamageTracker->damaged(basegfx::B2IBox(extents.x, extents.y, extents.x + extents.width,
+ extents.y + extents.height));
+ }
+ return true;
+#else
return false;
+#endif
}
SvpSalGraphics::SvpSalGraphics() :
@@ -726,32 +802,15 @@ bool SvpSalGraphics::drawEPS( long, long, long, long, void*, sal_uLong )
return false;
}
-#ifndef IOS
-
-SystemGraphicsData SvpSalGraphics::GetGraphicsData() const
-{
- return SystemGraphicsData();
-}
-
-bool SvpSalGraphics::supportsOperation( OutDevSupportType ) const
-{
- return false;
-}
-
-#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::ThirtyTwoBitTcMaskBGRX)
+ if (!isCairoCompatible(rBuffer))
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 =
@@ -762,9 +821,6 @@ cairo_t* SvpSalGraphics::createCairoContext(const basebmp::BitmapDeviceSharedPtr
cairo_t* cr = cairo_create(target);
cairo_surface_destroy(target);
return cr;
-#else
- return NULL;
-#endif
}
bool SvpSalGraphics::SupportsCairo() const
@@ -794,4 +850,25 @@ css::uno::Any SvpSalGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& /*
#endif // ENABLE_CAIRO_CANVAS
+#ifndef IOS
+
+SystemGraphicsData SvpSalGraphics::GetGraphicsData() const
+{
+ return SystemGraphicsData();
+}
+
+bool SvpSalGraphics::supportsOperation(OutDevSupportType eType) const
+{
+#if ENABLE_CAIRO_CANVAS
+ return m_aDrawMode != basebmp::DrawMode::XOR &&
+ OutDevSupport_TransparentRect == eType &&
+ isCairoCompatible(m_aDevice);
+#else
+ (void)eType;
+ return false;
+#endif
+}
+
+#endif
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list