summaryrefslogtreecommitdiffstats
path: root/tdegtk/tqtcairopainter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tdegtk/tqtcairopainter.cpp')
-rw-r--r--tdegtk/tqtcairopainter.cpp69
1 files changed, 53 insertions, 16 deletions
diff --git a/tdegtk/tqtcairopainter.cpp b/tdegtk/tqtcairopainter.cpp
index 6d3b2cf..9c7d010 100644
--- a/tdegtk/tqtcairopainter.cpp
+++ b/tdegtk/tqtcairopainter.cpp
@@ -336,7 +336,42 @@ void TQt3CairoPaintDevice::transferIntermediateSurface() {
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);
- cairo_mask_surface(m_devicePainter, maskSurface, m_offsetX, m_offsetY);
+
+ // Clipping enabled
+ if (m_worldMatrixEnabled || m_viewportMatrixEnabled) {
+ // The mask needs to be transformed before application
+ cairo_surface_t* maskSurface = TQImageToCairoSurface(m_clipRegion);
+ cairo_surface_t *transformedMaskSurface;
+ cairo_t *cr2;
+ int maxSize;
+ int w = cairo_image_surface_get_width(maskSurface);
+ int h = cairo_image_surface_get_height(maskSurface);
+ if (w>h) {
+ maxSize = w*2;
+ }
+ else {
+ maxSize = h*2;
+ }
+ transformedMaskSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, maxSize, maxSize);
+ cr2 = cairo_create(transformedMaskSurface);
+ setCairoTransformations(cr2);
+ cairo_set_source_surface (cr2, maskSurface, 0, 0);
+ cairo_set_operator(cr2, CAIRO_OPERATOR_SOURCE);
+ cairo_paint(cr2);
+
+ // Paint intermediate surface to final surface through mask
+ 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_mask_surface(m_devicePainter, transformedMaskSurface, m_offsetX, m_offsetY);
+ cairo_surface_destroy(transformedMaskSurface);
+ }
+ else {
+ // Paint intermediate surface to final surface through mask
+ 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);
+ cairo_mask_surface(m_devicePainter, maskSurface, m_offsetX, m_offsetY);
+ }
cairo_surface_destroy(maskSurface);
}
@@ -1052,21 +1087,23 @@ void TQt3CairoPaintDevice::drawTextInRect(TQPainter *p, TQRect rect, int textFla
transferIntermediateSurface();
}
-void TQt3CairoPaintDevice::setCairoTransformations() {
+void TQt3CairoPaintDevice::setCairoTransformations(cairo_t* cr, bool forceDisable) {
cairo_matrix_t combinedMatrix;
cairo_matrix_t tempMatrix;
cairo_matrix_init_identity(&combinedMatrix);
- if (m_worldMatrixEnabled) {
- cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &m_worldMatrix);
- combinedMatrix = tempMatrix;
- }
- if (m_viewportMatrixEnabled) {
- cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &m_viewportMatrix);
- combinedMatrix = tempMatrix;
+ if (!forceDisable) {
+ if (m_worldMatrixEnabled) {
+ cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &m_worldMatrix);
+ combinedMatrix = tempMatrix;
+ }
+ if (m_viewportMatrixEnabled) {
+ cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &m_viewportMatrix);
+ combinedMatrix = tempMatrix;
+ }
}
- cairo_set_matrix(m_painter, &combinedMatrix);
+ cairo_set_matrix(cr, &combinedMatrix);
}
/*!
@@ -1488,7 +1525,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
m_viewportMatrixEnabled = false;
cairo_matrix_init_identity(&m_worldMatrix);
cairo_matrix_init_identity(&m_viewportMatrix);
- setCairoTransformations();
+ setCairoTransformations(m_painter);
m_rop = TQPainter::CopyROP;
m_clipRegion = TQImage();
m_clipRegionEnabled = false;
@@ -1603,7 +1640,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
case PdcSetVXform:
if ((p) && (m_painter)) {
m_viewportMatrixEnabled = p[0].ival;
- setCairoTransformations();
+ setCairoTransformations(m_painter);
}
break;
case PdcSetWindow:
@@ -1620,7 +1657,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
double scaleW = (double)vw/(double)ww;
double scaleH = (double)vh/(double)wh;
cairo_matrix_init(&m_viewportMatrix, scaleW, 0, 0, scaleH, vx - wx*scaleW, vy - wy*scaleH);
- setCairoTransformations();
+ setCairoTransformations(m_painter);
}
break;
case PdcSetViewport:
@@ -1637,13 +1674,13 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
double scaleW = (double)vw/(double)ww;
double scaleH = (double)vh/(double)wh;
cairo_matrix_init(&m_viewportMatrix, scaleW, 0, 0, scaleH, vx - wx*scaleW, vy - wy*scaleH);
- setCairoTransformations();
+ setCairoTransformations(m_painter);
}
break;
case PdcSetWXform:
if ((p) && (m_painter)) {
m_worldMatrixEnabled = p[0].ival;
- setCairoTransformations();
+ setCairoTransformations(m_painter);
}
break;
case PdcSetWMatrix:
@@ -1661,7 +1698,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
// Replace
cairo_matrix_init(&m_worldMatrix, tqt3matrix->m11(), tqt3matrix->m12(), tqt3matrix->m21(), tqt3matrix->m22(), tqt3matrix->dx(), tqt3matrix->dy());
}
- setCairoTransformations();
+ setCairoTransformations(m_painter);
}
}
break;