summaryrefslogtreecommitdiffstats
path: root/tdegtk/tqtcairopainter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tdegtk/tqtcairopainter.cpp')
-rw-r--r--tdegtk/tqtcairopainter.cpp267
1 files changed, 146 insertions, 121 deletions
diff --git a/tdegtk/tqtcairopainter.cpp b/tdegtk/tqtcairopainter.cpp
index 90a6d3b..041e076 100644
--- a/tdegtk/tqtcairopainter.cpp
+++ b/tdegtk/tqtcairopainter.cpp
@@ -37,6 +37,11 @@
#define SET_BIT(x, y) (x |= 1 << y)
#define TEST_BIT(x, y) ((x & (1 << y)) >> y)
+// SLOW BUT VERIFIED CORRECT
+//#define FASTEST_AVAILABLE_PAINTER (m_painter)
+// FAST BUT EXPERIMENTAL AND UNVERIFIED
+#define FASTEST_AVAILABLE_PAINTER (intermediateSurfaceInUse()?m_painter:m_devicePainter)
+
// Little endian
#define ARGB_A_BYTE_NUMBER 3
#define ARGB_R_BYTE_NUMBER 2
@@ -403,31 +408,35 @@ void TQt3CairoPaintDevice::transferIntermediateSurface() {
m_transferNeeded = false;
}
+bool TQt3CairoPaintDevice::intermediateSurfaceInUse() const {
+ return (m_clipRegionEnabled || (m_rop != TQPainter::CopyROP));
+}
+
void TQt3CairoPaintDevice::dualStrokePen() {
if (m_bgColorMode == TQt::OpaqueMode) {
// Draw background
- cairo_save(m_painter);
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
updatePen(TRUE);
- cairo_stroke(m_painter);
- cairo_restore(m_painter);
+ cairo_stroke(FASTEST_AVAILABLE_PAINTER);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
// Draw foreground
updatePen(FALSE);
- cairo_stroke(m_painter);
+ cairo_stroke(FASTEST_AVAILABLE_PAINTER);
m_transferNeeded = true;
}
void TQt3CairoPaintDevice::dualStrokeBrush(cairo_fill_rule_t fillMethod) {
if (m_bgColorMode == TQt::OpaqueMode) {
// Draw background
- cairo_save(m_painter);
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
updateBrush(TRUE, fillMethod);
- cairo_fill(m_painter);
- cairo_restore(m_painter);
+ cairo_fill(FASTEST_AVAILABLE_PAINTER);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
// Draw foreground
updateBrush(FALSE, fillMethod);
- cairo_fill(m_painter);
+ cairo_fill(FASTEST_AVAILABLE_PAINTER);
m_transferNeeded = true;
}
@@ -692,8 +701,8 @@ static inline void fix_neg_rect( int *x, int *y, int *w, int *h ) {
void TQt3CairoPaintDevice::drawPolygon(const TQPointArray* pointarray, bool winding, bool fill, bool close) {
int i;
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
if (pointarray) {
int x;
int y;
@@ -703,15 +712,15 @@ void TQt3CairoPaintDevice::drawPolygon(const TQPointArray* pointarray, bool wind
for (i=0;i<pointarray->count();i++) {
pointarray->point(i, &x, &y);
if (first) {
- cairo_move_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
+ cairo_move_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
first = false;
}
else {
- cairo_line_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
+ cairo_line_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
}
}
if (close) {
- cairo_close_path(m_painter);
+ cairo_close_path(FASTEST_AVAILABLE_PAINTER);
}
dualStrokeBrush((winding)?CAIRO_FILL_RULE_EVEN_ODD:CAIRO_FILL_RULE_WINDING);
}
@@ -720,25 +729,25 @@ void TQt3CairoPaintDevice::drawPolygon(const TQPointArray* pointarray, bool wind
for (i=0;i<pointarray->count();i++) {
pointarray->point(i, &x, &y);
if (first) {
- cairo_move_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
+ cairo_move_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
first = false;
}
else {
- cairo_line_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
+ cairo_line_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
}
}
if (close) {
- cairo_close_path(m_painter);
+ cairo_close_path(FASTEST_AVAILABLE_PAINTER);
}
dualStrokePen();
}
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
}
void TQt3CairoPaintDevice::drawRoundRect(int x, int y, int w, int h, int xRnd, int yRnd) {
- if (!m_painter) {
+ if (!FASTEST_AVAILABLE_PAINTER) {
return;
}
@@ -801,7 +810,7 @@ void TQt3CairoPaintDevice::drawRoundRect(int x, int y, int w, int h, int xRnd, i
}
void TQt3CairoPaintDevice::drawEllipse(int x, int y, int w, int h) {
- if (!m_painter) {
+ if (!FASTEST_AVAILABLE_PAINTER) {
return;
}
@@ -815,7 +824,7 @@ void TQt3CairoPaintDevice::drawEllipse(int x, int y, int w, int h) {
}
void TQt3CairoPaintDevice::drawArc(int x, int y, int w, int h, int a, int alen) {
- if (!m_painter) {
+ if (!FASTEST_AVAILABLE_PAINTER) {
return;
}
@@ -829,7 +838,7 @@ void TQt3CairoPaintDevice::drawArc(int x, int y, int w, int h, int a, int alen)
}
void TQt3CairoPaintDevice::drawPie(int x, int y, int w, int h, int a, int alen) {
- if (!m_painter) {
+ if (!FASTEST_AVAILABLE_PAINTER) {
return;
}
@@ -861,7 +870,7 @@ void TQt3CairoPaintDevice::drawPie(int x, int y, int w, int h, int a, int alen)
}
void TQt3CairoPaintDevice::drawChord(int x, int y, int w, int h, int a, int alen) {
- if (!m_painter) {
+ if (!FASTEST_AVAILABLE_PAINTER) {
return;
}
@@ -997,29 +1006,29 @@ void TQt3CairoPaintDevice::pangoSetupTextPath(PangoLayout *layout, const char* t
}
void TQt3CairoPaintDevice::drawText(TQPainter *p, int x, int y, const TQString &str) {
- if ((!m_painter) || (!p)) {
+ if ((!FASTEST_AVAILABLE_PAINTER) || (!p)) {
return;
}
PangoLayout *layout;
- layout = pango_cairo_create_layout(m_painter);
+ layout = pango_cairo_create_layout(FASTEST_AVAILABLE_PAINTER);
TQFont::StyleStrategy qt3fontstrategy = m_font.styleStrategy();
pangoSetupTextPath(layout, str.utf8());
int baseline_y = pango_layout_get_baseline(layout)/PANGO_SCALE;
- cairo_new_path(m_painter);
- cairo_move_to(m_painter, x, y-baseline_y);
+ cairo_new_path(FASTEST_AVAILABLE_PAINTER);
+ cairo_move_to(FASTEST_AVAILABLE_PAINTER, x, y-baseline_y);
updatePen(FALSE);
- pango_cairo_update_layout(m_painter, layout);
- pango_cairo_layout_path(m_painter, layout);
+ pango_cairo_update_layout(FASTEST_AVAILABLE_PAINTER, layout);
+ pango_cairo_layout_path(FASTEST_AVAILABLE_PAINTER, layout);
if ((qt3fontstrategy & TQFont::PreferOutline) || (qt3fontstrategy & TQFont::ForceOutline)) {
- cairo_stroke_preserve(m_painter);
+ cairo_stroke_preserve(FASTEST_AVAILABLE_PAINTER);
}
else {
- cairo_fill(m_painter);
+ cairo_fill(FASTEST_AVAILABLE_PAINTER);
}
g_object_unref(layout);
@@ -1028,12 +1037,12 @@ void TQt3CairoPaintDevice::drawText(TQPainter *p, int x, int y, const TQString &
}
void TQt3CairoPaintDevice::drawTextInRect(TQPainter *p, TQRect rect, int textFlags, const TQString &str) {
- if ((!m_painter) || (!p)) {
+ if ((!FASTEST_AVAILABLE_PAINTER) || (!p)) {
return;
}
PangoLayout *layout;
- layout = pango_cairo_create_layout(m_painter);
+ layout = pango_cairo_create_layout(FASTEST_AVAILABLE_PAINTER);
TQFont::StyleStrategy qt3fontstrategy = m_font.styleStrategy();
pangoSetupTextPath(layout, str.utf8());
@@ -1048,8 +1057,8 @@ void TQt3CairoPaintDevice::drawTextInRect(TQPainter *p, TQRect rect, int textFla
pango_layout_set_height(layout, 0);
}
if (!(textFlags & TQt::DontClip)) {
- cairo_rectangle(m_painter, rect.x()+CAIRO_PEN_PIXEL_OFFSET, rect.y()+CAIRO_PEN_PIXEL_OFFSET, rect.width(), rect.height());
- cairo_clip(m_painter);
+ cairo_rectangle(FASTEST_AVAILABLE_PAINTER, rect.x()+CAIRO_PEN_PIXEL_OFFSET, rect.y()+CAIRO_PEN_PIXEL_OFFSET, rect.width(), rect.height());
+ cairo_clip(FASTEST_AVAILABLE_PAINTER);
}
if (textFlags & TQt::ExpandTabs) {
// FIXME
@@ -1102,32 +1111,44 @@ void TQt3CairoPaintDevice::drawTextInRect(TQPainter *p, TQRect rect, int textFla
fudgedOffsetY = ((rect.height()-stockHeight)/2);
}
- cairo_new_path(m_painter);
- cairo_move_to(m_painter, rect.x(), rect.y() + fudgedOffsetY);
+ cairo_new_path(FASTEST_AVAILABLE_PAINTER);
+ cairo_move_to(FASTEST_AVAILABLE_PAINTER, rect.x(), rect.y() + fudgedOffsetY);
updatePen(FALSE);
- pango_cairo_update_layout(m_painter, layout);
- pango_cairo_layout_path(m_painter, layout);
+ pango_cairo_update_layout(FASTEST_AVAILABLE_PAINTER, layout);
+ pango_cairo_layout_path(FASTEST_AVAILABLE_PAINTER, layout);
if ((qt3fontstrategy & TQFont::PreferOutline) || (qt3fontstrategy & TQFont::ForceOutline)) {
- cairo_stroke_preserve(m_painter);
+ cairo_stroke_preserve(FASTEST_AVAILABLE_PAINTER);
}
else {
- cairo_fill(m_painter);
+ cairo_fill(FASTEST_AVAILABLE_PAINTER);
}
- cairo_reset_clip(m_painter);
+ cairo_reset_clip(FASTEST_AVAILABLE_PAINTER);
g_object_unref(layout);
m_transferNeeded = true;
}
-void TQt3CairoPaintDevice::setCairoTransformations(cairo_t* cr, bool forceDisable) {
+void TQt3CairoPaintDevice::setCairoTransformations(cairo_t* cr, bool forceDisable, bool applyBaseDeviceTransform) {
cairo_matrix_t combinedMatrix;
cairo_matrix_t tempMatrix;
cairo_matrix_init_identity(&combinedMatrix);
if (!forceDisable) {
+ if (applyBaseDeviceTransform) {
+ // Handle specified offsets
+ cairo_matrix_t offsetMatrix;
+ cairo_matrix_init_identity(&offsetMatrix);
+ cairo_matrix_init_translate(&offsetMatrix, m_offsetX, m_offsetY);
+
+ cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &m_deviceMatrix);
+ combinedMatrix = tempMatrix;
+
+ cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &offsetMatrix);
+ combinedMatrix = tempMatrix;
+ }
if (m_worldMatrixEnabled) {
cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &m_worldMatrix);
combinedMatrix = tempMatrix;
@@ -1280,63 +1301,63 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
case PdcNOP:
break;
case PdcDrawPoint:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
if (m_pen.style() != TQPen::NoPen) {
- cairo_move_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
- cairo_line_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
+ cairo_move_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
+ cairo_line_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
updatePen(FALSE);
- cairo_set_line_cap(m_painter, CAIRO_LINE_CAP_ROUND);
- cairo_stroke(m_painter);
+ cairo_set_line_cap(FASTEST_AVAILABLE_PAINTER, CAIRO_LINE_CAP_ROUND);
+ cairo_stroke(FASTEST_AVAILABLE_PAINTER);
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
m_transferNeeded = true;
}
break;
case PdcMoveTo:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
if (m_pen.style() != TQPen::NoPen) {
- cairo_move_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
+ cairo_move_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
break;
case PdcLineTo:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
if (m_pen.style() != TQPen::NoPen) {
- cairo_line_to(m_painter, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET);
+ cairo_line_to(FASTEST_AVAILABLE_PAINTER, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET);
dualStrokePen();
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
break;
case PdcDrawLine:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
if (m_pen.style() != TQPen::NoPen) {
- cairo_move_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
- cairo_line_to(m_painter, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET);
+ cairo_move_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
+ cairo_line_to(FASTEST_AVAILABLE_PAINTER, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET);
dualStrokePen();
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
break;
case PdcDrawRect:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
int adjustment = cairoPainterRectSubtraction(&m_pen);
if (m_brush.style() != TQBrush::NoBrush) {
int line_width = m_pen.width();
- cairo_rectangle(m_painter, x+line_width+CAIRO_BRUSH_PIXEL_OFFSET, y+line_width+CAIRO_BRUSH_PIXEL_OFFSET, width-(line_width*2)-adjustment, height-(line_width*2)-adjustment);
+ cairo_rectangle(FASTEST_AVAILABLE_PAINTER, x+line_width+CAIRO_BRUSH_PIXEL_OFFSET, y+line_width+CAIRO_BRUSH_PIXEL_OFFSET, width-(line_width*2)-adjustment, height-(line_width*2)-adjustment);
dualStrokeBrush(CAIRO_FILL_RULE_EVEN_ODD);
}
if (m_pen.style() != TQPen::NoPen) {
- cairo_rectangle(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET, width-adjustment, height-adjustment);
+ cairo_rectangle(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET, width-adjustment, height-adjustment);
dualStrokePen();
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
else {
#if defined(QT_CHECK_RANGE)
@@ -1345,58 +1366,58 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
}
break;
case PdcDrawRoundRect:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
int adjustment = cairoPainterRectSubtraction(&m_pen);
if (p) {
drawRoundRect(x, y, width-adjustment, height-adjustment, p[1].ival, p[2].ival);
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
break;
case PdcDrawEllipse:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
int adjustment = cairoPainterRectSubtraction(&m_pen);
if (p) {
drawEllipse(x, y, width-adjustment, height-adjustment);
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
break;
case PdcDrawArc:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
int adjustment = cairoPainterRectSubtraction(&m_pen);
if (p) {
drawArc(x, y, width-adjustment, height-adjustment, p[1].ival, p[2].ival);
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
break;
case PdcDrawPie:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
int adjustment = cairoPainterRectSubtraction(&m_pen);
if (p) {
drawPie(x, y, width-adjustment, height-adjustment, p[1].ival, p[2].ival);
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
break;
case PdcDrawChord:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
int adjustment = cairoPainterRectSubtraction(&m_pen);
if (p) {
drawChord(x, y, width-adjustment, height-adjustment, p[1].ival, p[2].ival);
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
break;
case PdcDrawLineSegments:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
if (p) {
int x;
int y;
@@ -1408,14 +1429,14 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
for (i=0;i<pointarray->count();i=i+2) {
pointarray->point(i+0, &x, &y);
pointarray->point(i+1, &x2, &y2);
- cairo_move_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
- cairo_line_to(m_painter, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET);
+ cairo_move_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
+ cairo_line_to(FASTEST_AVAILABLE_PAINTER, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET);
dualStrokePen();
}
}
}
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
break;
case PdcDrawPolyline:
@@ -1429,8 +1450,8 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
}
break;
case PdcDrawCubicBezier:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
if (p) {
int x;
int y;
@@ -1448,61 +1469,61 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
pointarray->point(i+1, &x2, &y2);
pointarray->point(i+2, &x3, &y3);
pointarray->point(i+3, &x4, &y4);
- cairo_move_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
- cairo_curve_to(m_painter, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET, x3+CAIRO_PEN_PIXEL_OFFSET, y3+CAIRO_PEN_PIXEL_OFFSET, x4+CAIRO_PEN_PIXEL_OFFSET, y4+CAIRO_PEN_PIXEL_OFFSET);
+ cairo_move_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET);
+ cairo_curve_to(FASTEST_AVAILABLE_PAINTER, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET, x3+CAIRO_PEN_PIXEL_OFFSET, y3+CAIRO_PEN_PIXEL_OFFSET, x4+CAIRO_PEN_PIXEL_OFFSET, y4+CAIRO_PEN_PIXEL_OFFSET);
dualStrokePen();
}
}
}
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
break;
case PdcDrawText:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
if (p) {
TQString string = *p[1].str;
drawText(pt, p[0].rect->x()+CAIRO_PEN_PIXEL_OFFSET, p[0].rect->y()+CAIRO_PEN_PIXEL_OFFSET, string);
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
break;
case PdcDrawTextFormatted:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
if (p) {
TQRect rect = *p[0].rect;
TQString string = *p[2].str;
drawTextInRect(pt, rect, p[1].ival, string);
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
break;
case PdcDrawText2:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
if (p) {
TQString string = *p[1].str;
drawText(pt, p[0].rect->x()+CAIRO_PEN_PIXEL_OFFSET, p[0].rect->y()+CAIRO_PEN_PIXEL_OFFSET, string);
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
break;
case PdcDrawText2Formatted:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
if (p) {
TQRect rect = *p[0].rect;
TQString string = *p[2].str;
drawTextInRect(pt, rect, p[1].ival, string);
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
}
break;
case PdcDrawPixmap:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
if (p) {
TQImage sourceImage;
const TQBitmap* bitmap = dynamic_cast<const TQBitmap*>(p[1].pixmap);
@@ -1516,28 +1537,28 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
sourceImage = p[1].pixmap->convertToImage();
}
cairo_surface_t* sourceSurface = TQImageToCairoSurface(sourceImage);
- cairo_rectangle(m_painter, p[0].rect->x(), p[0].rect->y(), p[0].rect->width(), p[0].rect->height());
- cairo_set_source_surface(m_painter, sourceSurface, p[0].rect->x(), p[0].rect->y());
- cairo_fill(m_painter);
+ cairo_rectangle(FASTEST_AVAILABLE_PAINTER, p[0].rect->x(), p[0].rect->y(), p[0].rect->width(), p[0].rect->height());
+ cairo_set_source_surface(FASTEST_AVAILABLE_PAINTER, sourceSurface, p[0].rect->x(), p[0].rect->y());
+ cairo_fill(FASTEST_AVAILABLE_PAINTER);
cairo_surface_destroy(sourceSurface);
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
m_transferNeeded = true;
}
break;
case PdcDrawImage:
- if (m_painter) {
- cairo_save(m_painter);
+ if (FASTEST_AVAILABLE_PAINTER) {
+ cairo_save(FASTEST_AVAILABLE_PAINTER);
if (p) {
TQRect rect = *p[0].rect;
TQImage image = *p[1].image;
cairo_surface_t* sourceSurface = TQImageToCairoSurface(image);
- cairo_rectangle(m_painter, rect.x(), rect.y(), rect.width(), rect.height());
- cairo_set_source_surface(m_painter, sourceSurface, rect.x(), rect.y());
- cairo_fill(m_painter);
+ cairo_rectangle(FASTEST_AVAILABLE_PAINTER, rect.x(), rect.y(), rect.width(), rect.height());
+ cairo_set_source_surface(FASTEST_AVAILABLE_PAINTER, sourceSurface, rect.x(), rect.y());
+ cairo_fill(FASTEST_AVAILABLE_PAINTER);
cairo_surface_destroy(sourceSurface);
}
- cairo_restore(m_painter);
+ cairo_restore(FASTEST_AVAILABLE_PAINTER);
m_transferNeeded = true;
}
break;
@@ -1565,6 +1586,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
cairo_matrix_init_identity(&m_worldMatrix);
cairo_matrix_init_identity(&m_viewportMatrix);
setCairoTransformations(m_painter);
+ setCairoTransformations(m_devicePainter, false, true);
m_rop = TQPainter::CopyROP;
m_clipRegion = TQImage();
m_clipRegionEnabled = false;
@@ -1585,6 +1607,9 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
if (!m_overridePainter) {
cairo_destroy(m_devicePainter);
}
+ else {
+ cairo_set_matrix(m_devicePainter, &m_deviceMatrix);
+ }
m_devicePainter = NULL;
}
break;
@@ -1689,7 +1714,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);
+ setCairoTransformations(m_devicePainter, false, true);
}
break;
case PdcSetWindow:
@@ -1707,7 +1732,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);
+ setCairoTransformations(m_devicePainter, false, true);
}
break;
case PdcSetViewport:
@@ -1725,14 +1750,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);
+ setCairoTransformations(m_devicePainter, false, true);
}
break;
case PdcSetWXform:
if ((p) && (m_painter)) {
m_worldMatrixEnabled = p[0].ival;
setCairoTransformations(m_painter);
- setCairoTransformations(m_devicePainter);
+ setCairoTransformations(m_devicePainter, false, true);
}
break;
case PdcSetWMatrix:
@@ -1751,7 +1776,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);
+ setCairoTransformations(m_devicePainter, false, true);
}
}
break;