+bool wxCairoContext::SetAntialiasMode(wxAntialiasMode antialias)
+{
+ if (m_antialias == antialias)
+ return true;
+
+ m_antialias = antialias;
+
+ cairo_antialias_t antialiasMode;
+ switch (antialias)
+ {
+ case wxANTIALIAS_DEFAULT:
+ antialiasMode = CAIRO_ANTIALIAS_DEFAULT;
+ break;
+ case wxANTIALIAS_NONE:
+ antialiasMode = CAIRO_ANTIALIAS_NONE;
+ break;
+ default:
+ return false;
+ }
+ cairo_set_antialias(m_context, antialiasMode);
+ return true;
+}
+
+bool wxCairoContext::SetCompositionMode(wxCompositionMode op)
+{
+ if ( m_composition == op )
+ return true;
+
+ m_composition = op;
+ cairo_operator_t cop;
+ switch (op)
+ {
+ case wxCOMPOSITION__CLEAR:
+ cop = CAIRO_OPERATOR_CLEAR;
+ break;
+ case wxCOMPOSITION_SOURCE:
+ cop = CAIRO_OPERATOR_SOURCE;
+ break;
+ case wxCOMPOSITION_OVER:
+ cop = CAIRO_OPERATOR_OVER;
+ break;
+ case wxCOMPOSITION_IN:
+ cop = CAIRO_OPERATOR_IN;
+ break;
+ case wxCOMPOSITION_OUT:
+ cop = CAIRO_OPERATOR_OUT;
+ break;
+ case wxCOMPOSITION_ATOP:
+ cop = CAIRO_OPERATOR_ATOP;
+ break;
+ case wxCOMPOSITION_DEST:
+ cop = CAIRO_OPERATOR_DEST;
+ break;
+ case wxCOMPOSITION_DEST_OVER:
+ cop = CAIRO_OPERATOR_DEST_OVER;
+ break;
+ case wxCOMPOSITION_DEST_IN:
+ cop = CAIRO_OPERATOR_DEST_IN;
+ break;
+ case wxCOMPOSITION_DEST_OUT:
+ cop = CAIRO_OPERATOR_DEST_OUT;
+ break;
+ case wxCOMPOSITION_DEST_ATOP:
+ cop = CAIRO_OPERATOR_DEST_ATOP;
+ break;
+ case wxCOMPOSITION_XOR:
+ cop = CAIRO_OPERATOR_XOR;
+ break;
+ case wxCOMPOSITION_ADD:
+ cop = CAIRO_OPERATOR_ADD;
+ break;
+ default:
+ return false;
+ }
+ cairo_set_operator(m_context, cop);
+ return true;
+}
+
+void wxCairoContext::BeginLayer(wxDouble opacity)
+{
+ m_layerOpacities.push_back(opacity);
+ cairo_push_group(m_context);
+}
+
+void wxCairoContext::EndLayer()
+{
+ float opacity = m_layerOpacities.back();
+ m_layerOpacities.pop_back();
+ cairo_pop_group_to_source(m_context);
+ cairo_paint_with_alpha(m_context,opacity);
+}
+