]> git.saurik.com Git - wxWidgets.git/commitdiff
adding raster op hook to graphics context
authorStefan Csomor <csomor@advancedconcepts.ch>
Sun, 3 Dec 2006 15:23:42 +0000 (15:23 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Sun, 3 Dec 2006 15:23:42 +0000 (15:23 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43761 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/dcgraph.h
src/common/dcgraph.cpp
src/common/graphcmn.cpp

index 091ebdfc32107a21e3482b49d97872e5f39f07b5..9115ec0af40376a87673da0431c21599d1a78aa9 100755 (executable)
@@ -171,6 +171,7 @@ protected:
 
 protected:
     // scaling variables
+    bool m_logicalFunctionSupported;
     double       m_mm_to_pix_x, m_mm_to_pix_y;
     wxGraphicsMatrix m_matrixOriginal;
     wxGraphicsMatrix m_matrixCurrent;
index fc1a6a89e743a7a59852be76d3dc68930ba6ab18..a7d8e0781eb709eb5510fe2d1939d12b5c3f9818 100644 (file)
     #include "wx/region.h"
 #endif
 
-#ifndef wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
-    #define wxMAC_USE_CORE_GRAPHICS_BLEND_MODES 0
-#endif
-
 //-----------------------------------------------------------------------------
 // constants
 //-----------------------------------------------------------------------------
@@ -103,6 +99,7 @@ void wxGCDC::Init()
     m_brush = *wxWHITE_BRUSH;
 
     m_graphicContext = NULL;
+    m_logicalFunctionSupported = true;
 }
 
 
@@ -378,7 +375,7 @@ void wxGCDC::SetBrush( const wxBrush &brush )
         m_graphicContext->SetBrush( m_brush );
     }
 }
-
 void wxGCDC::SetBackground( const wxBrush &brush )
 {
     if (m_backgroundBrush == brush)
@@ -395,17 +392,10 @@ void wxGCDC::SetLogicalFunction( int function )
         return;
 
     m_logicalFunction = function;
-#if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
-
-    CGContextRef cgContext = ((wxCairoContext*)(m_graphicContext))->GetNativeContext();
-    if ( m_logicalFunction == wxCOPY )
-        CGContextSetBlendMode( cgContext, kCGBlendModeNormal );
-    else if ( m_logicalFunction == wxINVERT )
-        CGContextSetBlendMode( cgContext, kCGBlendModeExclusion );
+    if ( m_graphicContext->SetLogicalFunction( function ) )
+        m_logicalFunctionSupported=true;
     else
-        CGContextSetBlendMode( cgContext, kCGBlendModeNormal );
-#endif
-
+        m_logicalFunctionSupported=false;
 }
 
 bool wxGCDC::DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
@@ -424,11 +414,8 @@ void wxGCDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
 {
     wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLine - invalid DC") );
 
-#if !wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
-
-    if ( m_logicalFunction != wxCOPY )
+    if ( !m_logicalFunctionSupported )
         return;
-#endif
 
     m_graphicContext->StrokeLine(x1,y1,x2,y2);
 
@@ -440,7 +427,7 @@ void wxGCDC::DoCrossHair( wxCoord x, wxCoord y )
 {
     wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoCrossHair - invalid DC") );
 
-    if ( m_logicalFunction != wxCOPY )
+    if ( !m_logicalFunctionSupported )
         return;
 
     int w = 0, h = 0;
@@ -460,7 +447,7 @@ void wxGCDC::DoDrawArc( wxCoord x1, wxCoord y1,
 {
     wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawArc - invalid DC") );
 
-    if ( m_logicalFunction != wxCOPY )
+    if ( !m_logicalFunctionSupported )
         return;
 
     double dx = x1 - xc;
@@ -505,7 +492,7 @@ void wxGCDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
 {
     wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipticArc - invalid DC") );
 
-    if ( m_logicalFunction != wxCOPY )
+    if ( !m_logicalFunctionSupported )
         return;
 
     bool fill = m_brush.GetStyle() != wxTRANSPARENT;
@@ -538,11 +525,8 @@ void wxGCDC::DoDrawLines(int n, wxPoint points[],
 {
     wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") );
 
-#if !wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
-
-    if ( m_logicalFunction != wxCOPY )
+    if ( !m_logicalFunctionSupported )
         return;
-#endif
 
     wxPoint2DDouble* pointsD = new wxPoint2DDouble[n];
     for( int i = 0; i < n; ++i)
@@ -560,7 +544,7 @@ void wxGCDC::DoDrawSpline(wxList *points)
 {
     wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") );
 
-    if ( m_logicalFunction != wxCOPY )
+    if ( !m_logicalFunctionSupported )
         return;
 
     wxGraphicsPath path = m_graphicContext->CreatePath();
@@ -622,7 +606,7 @@ void wxGCDC::DoDrawPolygon( int n, wxPoint points[],
 
     if ( n <= 0 || (m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT ) )
         return;
-    if ( m_logicalFunction != wxCOPY )
+    if ( !m_logicalFunctionSupported )
         return;
 
     bool closeIt = false;
@@ -675,7 +659,7 @@ void wxGCDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
 {
     wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRectangle - invalid DC") );
 
-    if ( m_logicalFunction != wxCOPY )
+    if ( !m_logicalFunctionSupported )
         return;
 
     // CMB: draw nothing if transformed w or h is 0
@@ -698,7 +682,7 @@ void wxGCDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
 {
     wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRoundedRectangle - invalid DC") );
 
-    if ( m_logicalFunction != wxCOPY )
+    if ( !m_logicalFunctionSupported )
         return;
 
     if (radius < 0.0)
@@ -715,7 +699,7 @@ void wxGCDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
 {
     wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipse - invalid DC") );
 
-    if ( m_logicalFunction != wxCOPY )
+    if ( !m_logicalFunctionSupported )
         return;
 
     m_graphicContext->DrawEllipse(x,y,w,h);
@@ -773,7 +757,7 @@ void wxGCDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
 
     if ( str.length() == 0 )
         return;
-    if ( m_logicalFunction != wxCOPY )
+    if ( !m_logicalFunctionSupported )
         return;
 
     if ( m_backgroundMode == wxTRANSPARENT )
@@ -788,7 +772,8 @@ void wxGCDC::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
 
     if ( str.length() == 0 )
         return;
-    if ( m_logicalFunction != wxCOPY )
+
+    if ( !m_logicalFunctionSupported )
         return;
 
     if ( m_backgroundMode == wxTRANSPARENT )
index fe68a237c57dcccabf668a08003b635c752e4e34..15057e108b9c9d92a966ef00fc3fbd6fc876ec78 100644 (file)
@@ -495,6 +495,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxGraphicsContext, wxObject)
 
 wxGraphicsContext::wxGraphicsContext(wxGraphicsRenderer* renderer) : wxGraphicsObject(renderer) 
 {
+    m_logicalFunction = wxCOPY;
 }
 
 wxGraphicsContext::~wxGraphicsContext() 
@@ -535,6 +536,16 @@ void wxGraphicsContext::SetFont( const wxGraphicsFont& font )
     m_font = font;
 }
 
+bool wxGraphicsContext::SetLogicalFunction( int function )
+{
+    if ( function == wxCOPY )
+    {
+        m_logicalFunction = function;
+        return true;
+    }
+    return false;
+}
+
 void wxGraphicsContext::SetFont( const wxFont& font, const wxColour& colour )
 {
     if ( font.Ok() )