X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0b7dce5480b8cf7ce4368122744d853f7a684e34..0a84f928e9a273248a4843f6282507a39212d2d1:/include/wx/graphics.h?ds=sidebyside diff --git a/include/wx/graphics.h b/include/wx/graphics.h index ede12ad06c..322e2b769f 100644 --- a/include/wx/graphics.h +++ b/include/wx/graphics.h @@ -18,6 +18,39 @@ #include "wx/geometry.h" #include "wx/dynarray.h" +#include "wx/dc.h" + +enum wxAntialiasMode +{ + wxANTIALIAS_NONE, // should be 0 + wxANTIALIAS_DEFAULT, +}; + +enum wxCompositionMode +{ + // R = Result, S = Source, D = Destination, premultiplied with alpha + // Ra, Sa, Da their alpha components + + // classic Porter-Duff compositions + // http://keithp.com/~keithp/porterduff/p253-porter.pdf + + wxCOMPOSITION_CLEAR, /* R = 0 */ + wxCOMPOSITION_SOURCE, /* R = S */ + wxCOMPOSITION_OVER, /* R = S + D*(1 - Sa) */ + wxCOMPOSITION_IN, /* R = S*Da */ + wxCOMPOSITION_OUT, /* R = S*(1 - Da) */ + wxCOMPOSITION_ATOP, /* R = S*Da + D*(1 - Sa) */ + + wxCOMPOSITION_DEST, /* R = D, essentially a noop */ + wxCOMPOSITION_DEST_OVER, /* R = S*(1 - Da) + D */ + wxCOMPOSITION_DEST_IN, /* R = D*Sa */ + wxCOMPOSITION_DEST_OUT, /* R = D*(1 - Sa) */ + wxCOMPOSITION_DEST_ATOP, /* R = S*(1 - Da) + D*Sa */ + wxCOMPOSITION_XOR, /* R = S*(1 - Da) + D*(1 - Sa) */ + + // mathematical compositions + wxCOMPOSITION_ADD, /* R = S + D */ +}; class WXDLLIMPEXP_FWD_CORE wxWindowDC; class WXDLLIMPEXP_FWD_CORE wxMemoryDC; @@ -256,8 +289,8 @@ public: virtual void GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h)const; wxRect2DDouble GetBox()const; - virtual bool Contains( wxDouble x, wxDouble y, int fillStyle = wxODDEVEN_RULE)const; - bool Contains( const wxPoint2DDouble& c, int fillStyle = wxODDEVEN_RULE)const; + virtual bool Contains( wxDouble x, wxDouble y, wxPolygonFillMode fillStyle = wxODDEVEN_RULE)const; + bool Contains( const wxPoint2DDouble& c, wxPolygonFillMode fillStyle = wxODDEVEN_RULE)const; const wxGraphicsPathData* GetPathData() const { return (const wxGraphicsPathData*) GetRefData(); } @@ -355,11 +388,17 @@ public: // returns the native context virtual void * GetNativeContext() = 0; - // returns the current logical function - virtual int GetLogicalFunction() const { return m_logicalFunction; } + // returns the current shape antialiasing mode + virtual wxAntialiasMode GetAntialiasMode() const { return m_antialias; } + + // sets the antialiasing mode, returns true if it supported + virtual bool SetAntialiasMode(wxAntialiasMode antialias) = 0; - // sets the current logical function, returns true if it supported - virtual bool SetLogicalFunction(int function); + // returns the current compositing operator + virtual wxCompositionMode GetCompositionMode() const { return m_composition; } + + // sets the compositing operator, returns true if it supported + virtual bool SetCompositionMode(wxCompositionMode op) = 0; // returns the size of the graphics context in device coordinates virtual void GetSize( wxDouble* width, wxDouble* height); @@ -374,6 +413,14 @@ public: // returns the alpha on this context virtual wxDouble GetAlpha() const; #endif + + // all rendering is done into a fully transparent temporary context + virtual void BeginLayer(wxDouble opacity) = 0; + + // composites back the drawings into the context with the opacity given at + // the BeginLayer call + virtual void EndLayer() = 0; + // // transformation : changes the current transformation matrix CTM of the context // @@ -419,10 +466,10 @@ public: virtual void StrokePath( const wxGraphicsPath& path ) = 0; // fills a path with the current brush - virtual void FillPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ) = 0; + virtual void FillPath( const wxGraphicsPath& path, wxPolygonFillMode fillStyle = wxODDEVEN_RULE ) = 0; // draws a path by first filling and then stroking - virtual void DrawPath( const wxGraphicsPath& path, int fillStyle = wxODDEVEN_RULE ); + virtual void DrawPath( const wxGraphicsPath& path, wxPolygonFillMode fillStyle = wxODDEVEN_RULE ); // // text @@ -452,9 +499,7 @@ public: // image support // -#ifndef __WXGTK20__ virtual void DrawBitmap( const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; -#endif virtual void DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; @@ -474,9 +519,9 @@ public: virtual void StrokeLines( size_t n, const wxPoint2DDouble *beginPoints, const wxPoint2DDouble *endPoints); // draws a polygon - virtual void DrawLines( size_t n, const wxPoint2DDouble *points, int fillStyle = wxODDEVEN_RULE ); + virtual void DrawLines( size_t n, const wxPoint2DDouble *points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE ); - // draws a polygon + // draws a rectangle virtual void DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h); // draws an ellipse @@ -495,9 +540,10 @@ protected: wxGraphicsPen m_pen; wxGraphicsBrush m_brush; wxGraphicsFont m_font; - int m_logicalFunction; + wxAntialiasMode m_antialias; + wxCompositionMode m_composition; -private: +protected: // implementations of overloaded public functions: we use different names // for them to avoid the virtual function hiding problems in the derived // classes @@ -511,7 +557,7 @@ private: wxDouble angle, const wxGraphicsBrush& backgroundBrush); - DECLARE_NO_COPY_CLASS(wxGraphicsContext) + wxDECLARE_NO_COPY_CLASS(wxGraphicsContext); DECLARE_ABSTRACT_CLASS(wxGraphicsContext) }; @@ -609,17 +655,14 @@ public: // sets the font virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) = 0; -#ifndef __WXGTK20__ // create a native bitmap representation virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap ) = 0; // create a subimage from a native image representation virtual wxGraphicsBitmap CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; -#endif - private: - DECLARE_NO_COPY_CLASS(wxGraphicsRenderer) + wxDECLARE_NO_COPY_CLASS(wxGraphicsRenderer); DECLARE_ABSTRACT_CLASS(wxGraphicsRenderer) };