// classic Porter-Duff compositions
// http://keithp.com/~keithp/porterduff/p253-porter.pdf
+ wxCOMPOSITION_INVALID = -1, /* indicates invalid/unsupported mode */
wxCOMPOSITION_CLEAR, /* R = 0 */
wxCOMPOSITION_SOURCE, /* R = S */
wxCOMPOSITION_OVER, /* R = S + D*(1 - Sa) */
*/
enum wxCompositionMode
{
+ /**
+ Indicates invalid or unsupported composition mode.
+
+ This value can't be passed to wxGraphicsContext::SetCompositionMode().
+
+ @since 2.9.2
+ */
+ wxCOMPOSITION_INVALID = -1,
wxCOMPOSITION_CLEAR, /**< @e R = 0 */
wxCOMPOSITION_SOURCE, /**< @e R = S */
wxCOMPOSITION_OVER, /**< @e R = @e S + @e D*(1 - @e Sa) */
return (deg * M_PI) / 180.0;
}
-static bool TranslateRasterOp(wxRasterOperationMode function, wxCompositionMode *op)
+static wxCompositionMode TranslateRasterOp(wxRasterOperationMode function)
{
switch ( function )
{
case wxCOPY: // src
// since we are supporting alpha, _OVER is closer to the intention than _SOURCE
// since the latter would overwrite even when alpha is not set to opaque
- *op = wxCOMPOSITION_OVER;
- break;
+ return wxCOMPOSITION_OVER;
+
case wxOR: // src OR dst
- *op = wxCOMPOSITION_ADD;
- break;
+ return wxCOMPOSITION_ADD;
+
case wxNO_OP: // dst
- *op = wxCOMPOSITION_DEST; // ignore the source
- break;
+ return wxCOMPOSITION_DEST; // ignore the source
+
case wxCLEAR: // 0
- *op = wxCOMPOSITION_CLEAR;// clear dst
- break;
+ return wxCOMPOSITION_CLEAR;// clear dst
+
case wxXOR: // src XOR dst
- *op = wxCOMPOSITION_XOR;
- break;
+ return wxCOMPOSITION_XOR;
case wxAND: // src AND dst
case wxAND_INVERT: // (NOT src) AND dst
case wxOR_REVERSE: // src OR (NOT dst)
case wxSET: // 1
case wxSRC_INVERT: // NOT src
- default:
- return false;
+ break;
}
- return true;
+
+ return wxCOMPOSITION_INVALID;
}
//-----------------------------------------------------------------------------
m_logicalFunction = function;
- wxCompositionMode mode;
- m_logicalFunctionSupported = TranslateRasterOp( function, &mode);
+ wxCompositionMode mode = TranslateRasterOp( function );
+ m_logicalFunctionSupported = mode != wxCOMPOSITION_INVALID;
if (m_logicalFunctionSupported)
m_logicalFunctionSupported = m_graphicContext->SetCompositionMode(mode);
if ( logical_func == wxNO_OP )
return true;
- wxCompositionMode mode;
- if ( !TranslateRasterOp(logical_func, &mode) )
+ wxCompositionMode mode = TranslateRasterOp(logical_func);
+ if ( mode == wxCOMPOSITION_INVALID )
{
wxFAIL_MSG( wxT("Blitting is not supported with this logical operation.") );
return false;