+wxBitmap wxGTKCairoDCImpl::DoGetAsBitmap(const wxRect* /*subrect*/) const
+{
+ wxFAIL_MSG("DoGetAsBitmap not implemented");
+ return wxBitmap();
+}
+
+bool wxGTKCairoDCImpl::DoGetPixel(int x, int y, wxColour* col) const
+{
+ if (col)
+ {
+ cairo_t* cr = NULL;
+ if (m_graphicContext)
+ cr = static_cast<cairo_t*>(m_graphicContext->GetNativeContext());
+ if (cr)
+ {
+ cairo_surface_t* surface = cairo_get_target(cr);
+ x = LogicalToDeviceX(x);
+ y = LogicalToDeviceY(y);
+ GdkPixbuf* pixbuf = gdk_pixbuf_get_from_surface(surface, x, y, 1, 1);
+ if (pixbuf)
+ {
+ const guchar* src = gdk_pixbuf_get_pixels(pixbuf);
+ col->Set(src[0], src[1], src[2]);
+ g_object_unref(pixbuf);
+ return true;
+ }
+ *col = wxColour();
+ }
+ }
+ return false;
+}
+
+void wxGTKCairoDCImpl::DoGetSize(int* width, int* height) const
+{
+ if (width)
+ *width = m_width;
+ if (height)
+ *height = m_height;
+}
+
+bool wxGTKCairoDCImpl::DoStretchBlit(int xdest, int ydest, int dstWidth, int dstHeight, wxDC* source, int xsrc, int ysrc, int srcWidth, int srcHeight, wxRasterOperationMode rop, bool useMask, int xsrcMask, int ysrcMask)
+{
+ wxCHECK_MSG(IsOk(), false, "invalid DC");
+ wxCHECK_MSG(source && source->IsOk(), false, "invalid source DC");
+
+ cairo_t* cr = NULL;
+ if (m_graphicContext)
+ cr = static_cast<cairo_t*>(m_graphicContext->GetNativeContext());
+ cairo_t* cr_src = NULL;
+ wxGraphicsContext* gc_src = source->GetGraphicsContext();
+ if (gc_src)
+ cr_src = static_cast<cairo_t*>(gc_src->GetNativeContext());
+
+ if (cr == NULL || cr_src == NULL)
+ return false;
+
+ const int xsrc_dev = source->LogicalToDeviceX(xsrc);
+ const int ysrc_dev = source->LogicalToDeviceY(ysrc);
+
+ cairo_surface_t* surface = cairo_get_target(cr_src);
+ cairo_surface_flush(surface);
+ cairo_save(cr);
+ cairo_translate(cr, xdest, ydest);
+ cairo_rectangle(cr, 0, 0, dstWidth, dstHeight);
+ double sx, sy;
+ source->GetUserScale(&sx, &sy);
+ cairo_scale(cr, dstWidth / (sx * srcWidth), dstHeight / (sy * srcHeight));
+ cairo_set_source_surface(cr, surface, -xsrc_dev, -ysrc_dev);
+ const wxRasterOperationMode rop_save = m_logicalFunction;
+ SetLogicalFunction(rop);
+ cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_NEAREST);
+ cairo_surface_t* maskSurf = NULL;
+ if (useMask)
+ {
+ const wxBitmap& bitmap = source->GetImpl()->GetSelectedBitmap();
+ if (bitmap.IsOk())
+ {
+ wxMask* mask = bitmap.GetMask();
+ if (mask)
+ maskSurf = *mask;
+ }
+ }
+ if (maskSurf)
+ {
+ int xsrcMask_dev = xsrc_dev;
+ int ysrcMask_dev = ysrc_dev;
+ if (xsrcMask != -1)
+ xsrcMask_dev = source->LogicalToDeviceX(xsrcMask);
+ if (ysrcMask != -1)
+ ysrcMask_dev = source->LogicalToDeviceY(ysrcMask);
+ cairo_clip(cr);
+ cairo_mask_surface(cr, maskSurf, -xsrcMask_dev, -ysrcMask_dev);
+ }
+ else
+ {
+ cairo_fill(cr);
+ }
+ cairo_restore(cr);
+ m_logicalFunction = rop_save;
+ return true;
+}
+
+void* wxGTKCairoDCImpl::GetCairoContext() const
+{
+ cairo_t* cr = NULL;
+ if (m_graphicContext)
+ cr = static_cast<cairo_t*>(m_graphicContext->GetNativeContext());
+ if (cr)
+ cairo_reference(cr);
+ return cr;