diff options
Diffstat (limited to 'tdegtk/tqtcairopainter.cpp')
-rw-r--r-- | tdegtk/tqtcairopainter.cpp | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/tdegtk/tqtcairopainter.cpp b/tdegtk/tqtcairopainter.cpp index 25024ee..90a6d3b 100644 --- a/tdegtk/tqtcairopainter.cpp +++ b/tdegtk/tqtcairopainter.cpp @@ -332,12 +332,22 @@ void TQt3CairoPaintDevice::transferIntermediateSurface() { if (!m_clipRegionEnabled) { // Clipping disabled + cairo_save(m_devicePainter); + cairo_reset_clip(m_devicePainter); + cairo_set_matrix(m_devicePainter, &m_deviceMatrix); + cairo_set_source_surface(m_devicePainter, m_intermediateSurface, m_offsetX, m_offsetY); cairo_set_operator(m_devicePainter, overlayMerge?CAIRO_OPERATOR_OVER:CAIRO_OPERATOR_SOURCE); cairo_paint(m_devicePainter); + + cairo_restore(m_devicePainter); } else { // Clipping enabled + cairo_save(m_devicePainter); + cairo_reset_clip(m_devicePainter); + cairo_set_matrix(m_devicePainter, &m_deviceMatrix); + cairo_surface_t* maskSurface = TQImageToCairoSurface(m_clipRegion); cairo_set_source_surface(m_devicePainter, m_intermediateSurface, m_offsetX, m_offsetY); cairo_set_operator(m_devicePainter, overlayMerge?CAIRO_OPERATOR_OVER:CAIRO_OPERATOR_SOURCE); @@ -378,6 +388,8 @@ void TQt3CairoPaintDevice::transferIntermediateSurface() { cairo_mask_surface(m_devicePainter, maskSurface, m_offsetX, m_offsetY); } cairo_surface_destroy(maskSurface); + + cairo_restore(m_devicePainter); } // Clear intermediate surface @@ -520,13 +532,21 @@ void TQt3CairoPaintDevice::updatePen(bool backgroundStroke) { } + TQRgb color = (backgroundStroke)?m_bgColor.rgb():m_pen.color().rgb(); + cairo_set_dash(m_painter, dashes, dash_len, dash_offset); cairo_set_line_cap(m_painter, cp); cairo_set_line_join(m_painter, jn); cairo_set_line_width(m_painter, ((!allow_zero_lw) && (m_pen.width() == 0)) ? 1 : m_pen.width()); - - TQRgb color = (backgroundStroke)?m_bgColor.rgb():m_pen.color().rgb(); cairo_set_source_rgba(m_painter, tqRed(color)/255.0, tqGreen(color)/255.0, tqBlue(color)/255.0, tqAlpha(color)/255.0); + + // BEGIN DUPLICATE + cairo_set_dash(m_devicePainter, dashes, dash_len, dash_offset); + cairo_set_line_cap(m_devicePainter, cp); + cairo_set_line_join(m_devicePainter, jn); + cairo_set_line_width(m_devicePainter, ((!allow_zero_lw) && (m_pen.width() == 0)) ? 1 : m_pen.width()); + cairo_set_source_rgba(m_devicePainter, tqRed(color)/255.0, tqGreen(color)/255.0, tqBlue(color)/255.0, tqAlpha(color)/255.0); + // END DUPLICATE } void TQt3CairoPaintDevice::updateBrush(bool backgroundStroke, cairo_fill_rule_t fillMethod) { @@ -538,7 +558,9 @@ void TQt3CairoPaintDevice::updateBrush(bool backgroundStroke, cairo_fill_rule_t TQRgb color = m_bgColor.rgb(); cairo_pattern_t* pattern = cairo_pattern_create_rgba(tqRed(color)/255.0, tqGreen(color)/255.0, tqBlue(color)/255.0, tqAlpha(color)/255.0); cairo_set_source(m_painter, pattern); + cairo_set_source(m_devicePainter, pattern); cairo_pattern_set_extend(cairo_get_source(m_painter), CAIRO_EXTEND_REPEAT); + cairo_pattern_set_extend(cairo_get_source(m_devicePainter), CAIRO_EXTEND_REPEAT); cairo_pattern_destroy(pattern); } else { @@ -636,7 +658,9 @@ void TQt3CairoPaintDevice::updateBrush(bool backgroundStroke, cairo_fill_rule_t cairo_matrix_init_translate(&brush_translation_matrix, m_brushOrigin.x()+1, m_brushOrigin.y()); cairo_pattern_set_matrix(pattern, &brush_translation_matrix); cairo_set_source(m_painter, pattern); + cairo_set_source(m_devicePainter, pattern); cairo_pattern_set_extend(cairo_get_source(m_painter), CAIRO_EXTEND_REPEAT); + cairo_pattern_set_extend(cairo_get_source(m_devicePainter), CAIRO_EXTEND_REPEAT); cairo_pattern_destroy(pattern); cairo_surface_destroy(brushSurface); } @@ -644,11 +668,14 @@ void TQt3CairoPaintDevice::updateBrush(bool backgroundStroke, cairo_fill_rule_t TQRgb color = m_brush.color().rgb(); cairo_pattern_t* pattern = cairo_pattern_create_rgba(tqRed(color)/255.0, tqGreen(color)/255.0, tqBlue(color)/255.0, tqAlpha(color)/255.0); cairo_set_source(m_painter, pattern); + cairo_set_source(m_devicePainter, pattern); cairo_pattern_set_extend(cairo_get_source(m_painter), CAIRO_EXTEND_REPEAT); + cairo_pattern_set_extend(cairo_get_source(m_devicePainter), CAIRO_EXTEND_REPEAT); cairo_pattern_destroy(pattern); } } cairo_set_fill_rule(m_painter, fillMethod); + cairo_set_fill_rule(m_devicePainter, fillMethod); } static inline void fix_neg_rect( int *x, int *y, int *w, int *h ) { @@ -1528,6 +1555,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) else { m_devicePainter = cairo_create(m_surface); } + cairo_get_matrix(m_devicePainter, &m_deviceMatrix); cairo_set_antialias(m_devicePainter, CAIRO_ANTIALIAS_NONE); m_pen = TQPen(); m_brush = TQBrush(); @@ -1562,9 +1590,11 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) break; case PdcSave: cairo_save(m_painter); + cairo_save(m_devicePainter); break; case PdcRestore: cairo_restore(m_painter); + cairo_restore(m_devicePainter); break; case PdcSetBkColor: if (p) { @@ -1659,6 +1689,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) if ((p) && (m_painter)) { m_viewportMatrixEnabled = p[0].ival; setCairoTransformations(m_painter); + setCairoTransformations(m_devicePainter); } break; case PdcSetWindow: @@ -1676,6 +1707,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) double scaleH = (double)vh/(double)wh; cairo_matrix_init(&m_viewportMatrix, scaleW, 0, 0, scaleH, vx - wx*scaleW, vy - wy*scaleH); setCairoTransformations(m_painter); + setCairoTransformations(m_devicePainter); } break; case PdcSetViewport: @@ -1693,12 +1725,14 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) double scaleH = (double)vh/(double)wh; cairo_matrix_init(&m_viewportMatrix, scaleW, 0, 0, scaleH, vx - wx*scaleW, vy - wy*scaleH); setCairoTransformations(m_painter); + setCairoTransformations(m_devicePainter); } break; case PdcSetWXform: if ((p) && (m_painter)) { m_worldMatrixEnabled = p[0].ival; setCairoTransformations(m_painter); + setCairoTransformations(m_devicePainter); } break; case PdcSetWMatrix: @@ -1717,6 +1751,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) cairo_matrix_init(&m_worldMatrix, tqt3matrix->m11(), tqt3matrix->m12(), tqt3matrix->m21(), tqt3matrix->m22(), tqt3matrix->dx(), tqt3matrix->dy()); } setCairoTransformations(m_painter); + setCairoTransformations(m_devicePainter); } } break; |