From 114c26e88f3814bc9d864faa0b46b00c19b8513b Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Mon, 19 Nov 2012 02:10:46 -0600 Subject: Add GtkSwitch support Speed up drawing operations on newer GTK/Cairo versions --- tdegtk/tqtcairopainter.cpp | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'tdegtk/tqtcairopainter.cpp') diff --git a/tdegtk/tqtcairopainter.cpp b/tdegtk/tqtcairopainter.cpp index 9c7d010..a2867f0 100644 --- a/tdegtk/tqtcairopainter.cpp +++ b/tdegtk/tqtcairopainter.cpp @@ -381,6 +381,8 @@ void TQt3CairoPaintDevice::transferIntermediateSurface() { cairo_set_source_rgba(m_painter, 0.0, 0.0, 0.0, 0.0); cairo_paint(m_painter); cairo_restore(m_painter); + + m_transferNeeded = false; } void TQt3CairoPaintDevice::dualStrokePen() { @@ -394,7 +396,7 @@ void TQt3CairoPaintDevice::dualStrokePen() { // Draw foreground updatePen(FALSE); cairo_stroke(m_painter); - transferIntermediateSurface(); + m_transferNeeded = true; } void TQt3CairoPaintDevice::dualStrokeBrush(cairo_fill_rule_t fillMethod) { @@ -408,7 +410,7 @@ void TQt3CairoPaintDevice::dualStrokeBrush(cairo_fill_rule_t fillMethod) { // Draw foreground updateBrush(FALSE, fillMethod); cairo_fill(m_painter); - transferIntermediateSurface(); + m_transferNeeded = true; } void TQt3CairoPaintDevice::updatePen(bool backgroundStroke) { @@ -989,7 +991,7 @@ void TQt3CairoPaintDevice::drawText(TQPainter *p, int x, int y, const TQString & g_object_unref(layout); - transferIntermediateSurface(); + m_transferNeeded = true; } void TQt3CairoPaintDevice::drawTextInRect(TQPainter *p, TQRect rect, int textFlags, const TQString &str) { @@ -1084,7 +1086,7 @@ void TQt3CairoPaintDevice::drawTextInRect(TQPainter *p, TQRect rect, int textFla g_object_unref(layout); - transferIntermediateSurface(); + m_transferNeeded = true; } void TQt3CairoPaintDevice::setCairoTransformations(cairo_t* cr, bool forceDisable) { @@ -1186,6 +1188,8 @@ void TQt3CairoPaintDevice::init() { m_overridePainter = NULL; m_tabStops = NULL; m_tabStopArray = NULL; + + m_transferNeeded = false; } void TQt3CairoPaintDevice::updateSurfaceDimensions() const { @@ -1253,7 +1257,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) cairo_stroke(m_painter); } cairo_restore(m_painter); - transferIntermediateSurface(); + m_transferNeeded = true; } break; case PdcMoveTo: @@ -1485,7 +1489,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) cairo_surface_destroy(sourceSurface); } cairo_restore(m_painter); - transferIntermediateSurface(); + m_transferNeeded = true; } break; case PdcDrawImage: @@ -1501,11 +1505,12 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) cairo_surface_destroy(sourceSurface); } cairo_restore(m_painter); - transferIntermediateSurface(); + m_transferNeeded = true; } break; case PdcBegin: if (!m_painter) { + m_transferNeeded = false; m_bgColor = TQColor(0,0,0); m_bgColorMode = TQt::TransparentMode; resetIntermediateSurface(); @@ -1536,6 +1541,9 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) break; case PdcEnd: if (m_painter) { + if (m_transferNeeded) { + transferIntermediateSurface(); + } cairo_destroy(m_painter); m_painter = NULL; } @@ -1567,6 +1575,10 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) break; case PdcSetROP: if ((p) && (m_painter)) { + if (m_transferNeeded) { + transferIntermediateSurface(); + } + TQt::RasterOp rop = (TQt::RasterOp)p[0].ival; m_rop = rop; } @@ -1726,11 +1738,17 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) break; case PdcSetClip: if ((p) && (m_painter)) { + if (m_transferNeeded) { + transferIntermediateSurface(); + } m_clipRegionEnabled = p[0].ival; } break; case PdcSetClipRegion: if ((p) && (m_painter)) { + if (m_transferNeeded) { + transferIntermediateSurface(); + } // SLOW TQRect tqt3br = p[0].rgn->boundingRect(); if (!tqt3br.isNull()) { @@ -1751,6 +1769,11 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) } } break; + case PdcFlush: + case PdcFlushRegion: + if (m_transferNeeded) { + transferIntermediateSurface(); + } default: #if defined(QT_CHECK_RANGE) tqWarning( "TQt3CairoPaintDevice::cmd: Invalid command %d", c ); -- cgit v1.2.1