Add wxCOMPOSITION_INVALID mode and use it to simplify the code.
Having an invalid element in wxCompositionMode enum allows to directly return it from TranslateRasterOp() function instead of needing a separate bool parameter to indicate that a ROP couldn't be translated. This also incidentally fixes warnings about possibly uninitialized variables in optimized g++ builds. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68127 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -49,6 +49,7 @@ enum wxCompositionMode
|
|||||||
// classic Porter-Duff compositions
|
// classic Porter-Duff compositions
|
||||||
// http://keithp.com/~keithp/porterduff/p253-porter.pdf
|
// http://keithp.com/~keithp/porterduff/p253-porter.pdf
|
||||||
|
|
||||||
|
wxCOMPOSITION_INVALID = -1, /* indicates invalid/unsupported mode */
|
||||||
wxCOMPOSITION_CLEAR, /* R = 0 */
|
wxCOMPOSITION_CLEAR, /* R = 0 */
|
||||||
wxCOMPOSITION_SOURCE, /* R = S */
|
wxCOMPOSITION_SOURCE, /* R = S */
|
||||||
wxCOMPOSITION_OVER, /* R = S + D*(1 - Sa) */
|
wxCOMPOSITION_OVER, /* R = S + D*(1 - Sa) */
|
||||||
|
@@ -241,6 +241,14 @@ enum wxInterpolationQuality
|
|||||||
*/
|
*/
|
||||||
enum wxCompositionMode
|
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_CLEAR, /**< @e R = 0 */
|
||||||
wxCOMPOSITION_SOURCE, /**< @e R = S */
|
wxCOMPOSITION_SOURCE, /**< @e R = S */
|
||||||
wxCOMPOSITION_OVER, /**< @e R = @e S + @e D*(1 - @e Sa) */
|
wxCOMPOSITION_OVER, /**< @e R = @e S + @e D*(1 - @e Sa) */
|
||||||
|
@@ -53,27 +53,26 @@ static inline double DegToRad(double deg)
|
|||||||
return (deg * M_PI) / 180.0;
|
return (deg * M_PI) / 180.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool TranslateRasterOp(wxRasterOperationMode function, wxCompositionMode *op)
|
static wxCompositionMode TranslateRasterOp(wxRasterOperationMode function)
|
||||||
{
|
{
|
||||||
switch ( function )
|
switch ( function )
|
||||||
{
|
{
|
||||||
case wxCOPY: // src
|
case wxCOPY: // src
|
||||||
// since we are supporting alpha, _OVER is closer to the intention than _SOURCE
|
// 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
|
// since the latter would overwrite even when alpha is not set to opaque
|
||||||
*op = wxCOMPOSITION_OVER;
|
return wxCOMPOSITION_OVER;
|
||||||
break;
|
|
||||||
case wxOR: // src OR dst
|
case wxOR: // src OR dst
|
||||||
*op = wxCOMPOSITION_ADD;
|
return wxCOMPOSITION_ADD;
|
||||||
break;
|
|
||||||
case wxNO_OP: // dst
|
case wxNO_OP: // dst
|
||||||
*op = wxCOMPOSITION_DEST; // ignore the source
|
return wxCOMPOSITION_DEST; // ignore the source
|
||||||
break;
|
|
||||||
case wxCLEAR: // 0
|
case wxCLEAR: // 0
|
||||||
*op = wxCOMPOSITION_CLEAR;// clear dst
|
return wxCOMPOSITION_CLEAR;// clear dst
|
||||||
break;
|
|
||||||
case wxXOR: // src XOR dst
|
case wxXOR: // src XOR dst
|
||||||
*op = wxCOMPOSITION_XOR;
|
return wxCOMPOSITION_XOR;
|
||||||
break;
|
|
||||||
|
|
||||||
case wxAND: // src AND dst
|
case wxAND: // src AND dst
|
||||||
case wxAND_INVERT: // (NOT src) AND dst
|
case wxAND_INVERT: // (NOT src) AND dst
|
||||||
@@ -86,10 +85,10 @@ static bool TranslateRasterOp(wxRasterOperationMode function, wxCompositionMode
|
|||||||
case wxOR_REVERSE: // src OR (NOT dst)
|
case wxOR_REVERSE: // src OR (NOT dst)
|
||||||
case wxSET: // 1
|
case wxSET: // 1
|
||||||
case wxSRC_INVERT: // NOT src
|
case wxSRC_INVERT: // NOT src
|
||||||
default:
|
break;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
return wxCOMPOSITION_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -502,8 +501,8 @@ void wxGCDCImpl::SetLogicalFunction( wxRasterOperationMode function )
|
|||||||
|
|
||||||
m_logicalFunction = function;
|
m_logicalFunction = function;
|
||||||
|
|
||||||
wxCompositionMode mode;
|
wxCompositionMode mode = TranslateRasterOp( function );
|
||||||
m_logicalFunctionSupported = TranslateRasterOp( function, &mode);
|
m_logicalFunctionSupported = mode != wxCOMPOSITION_INVALID;
|
||||||
if (m_logicalFunctionSupported)
|
if (m_logicalFunctionSupported)
|
||||||
m_logicalFunctionSupported = m_graphicContext->SetCompositionMode(mode);
|
m_logicalFunctionSupported = m_graphicContext->SetCompositionMode(mode);
|
||||||
|
|
||||||
@@ -874,8 +873,8 @@ bool wxGCDCImpl::DoStretchBlit(
|
|||||||
if ( logical_func == wxNO_OP )
|
if ( logical_func == wxNO_OP )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
wxCompositionMode mode;
|
wxCompositionMode mode = TranslateRasterOp(logical_func);
|
||||||
if ( !TranslateRasterOp(logical_func, &mode) )
|
if ( mode == wxCOMPOSITION_INVALID )
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( wxT("Blitting is not supported with this logical operation.") );
|
wxFAIL_MSG( wxT("Blitting is not supported with this logical operation.") );
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user