Initial Commit of full native bitmap macOS implementation

Right now, to better test regressions, with dual implementation
This commit is contained in:
Stefan Csomor
2018-09-07 21:44:19 +02:00
committed by Vadim Zeitlin
parent a5aa044a7b
commit e7d21f6638
10 changed files with 532 additions and 302 deletions

View File

@@ -2584,7 +2584,6 @@ typedef int (* LINKAGEMODE wxListIterateFunction)(void *current);
#define WX_OPAQUE_TYPE( name ) struct wxOpaque##name
typedef void* WXHBITMAP;
typedef void* WXHCURSOR;
typedef void* WXRECTPTR;
typedef void* WXPOINTPTR;
@@ -2628,6 +2627,7 @@ DECLARE_WXOSX_OPAQUE_CGREF( CGFont )
typedef CGColorRef WXCOLORREF;
typedef CGImageRef WXCGIMAGEREF;
typedef CGContextRef WXHDC;
typedef CGContextRef WXHBITMAP;
/*
* carbon

View File

@@ -30,7 +30,7 @@ class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
// 8 bit is chosen only for performance reasons, note also that this is the inverse value range
// from alpha, where 0 = invisible , 255 = fully drawn
class WXDLLIMPEXP_CORE wxMask: public wxObject
class WXDLLIMPEXP_CORE wxMask: public wxMaskBase
{
wxDECLARE_DYNAMIC_CLASS(wxMask);
@@ -52,8 +52,6 @@ public:
virtual ~wxMask();
bool Create(const wxBitmap& bitmap, const wxColour& colour);
bool Create(const wxBitmap& bitmap);
bool Create(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ;
wxBitmap GetBitmap() const;
@@ -64,20 +62,36 @@ public:
// a 8 bit depth mask
void* GetRawAccess() const;
int GetBytesPerRow() const { return m_bytesPerRow ; }
int GetBytesPerRow() const;
int GetWidth() const;
int GetHeight() const;
// renders/updates native representation when necessary
void RealizeNative() ;
WXHBITMAP GetHBITMAP() const ;
protected:
// this function is called from Create() to free the existing mask data
virtual void FreeData() wxOVERRIDE;
// these functions must be overridden to implement the corresponding public
// Create() methods, they shouldn't call FreeData() as it's already called
// by the public wrappers
virtual bool InitFromColour(const wxBitmap& bitmap,
const wxColour& colour) wxOVERRIDE;
virtual bool InitFromMonoBitmap(const wxBitmap& bitmap) wxOVERRIDE;
private:
#if !wxOSX_BITMAP_NATIVE_ACCESS
wxMemoryBuffer m_memBuf ;
int m_bytesPerRow ;
int m_width ;
int m_height ;
#endif
void DoCreateMaskBitmap(int width, int height, int bytesPerRow = -1);
WXHBITMAP m_maskBitmap ;
wxCFRef<CGContextRef> m_maskBitmap ;
};
@@ -146,7 +160,10 @@ public:
virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
wxBitmapRefData *GetBitmapData() const
const wxBitmapRefData *GetBitmapData() const
{ return (const wxBitmapRefData *)m_refData; }
wxBitmapRefData *GetBitmapData()
{ return (wxBitmapRefData *)m_refData; }
// copies the contents and mask of the given (colour) icon to the bitmap
@@ -155,10 +172,17 @@ public:
int GetWidth() const;
int GetHeight() const;
int GetDepth() const;
#if WXWIN_COMPATIBILITY_3_0
wxDEPRECATED_MSG("this value is determined during creation, this method could lead to inconsistencies")
void SetWidth(int w);
wxDEPRECATED_MSG("this value is determined during creation, this method could lead to inconsistencies")
void SetHeight(int h);
wxDEPRECATED_MSG("this value is determined during creation, this method could lead to inconsistencies")
void SetDepth(int d);
wxDEPRECATED_MSG("this value is determined during creation, this method could lead to inconsistencies")
void SetOk(bool isOk);
#endif
#if wxUSE_PALETTE
wxPalette* GetPalette() const;
@@ -193,18 +217,34 @@ public:
// returns an autoreleased version of the image
WX_UIImage GetUIImage() const;
#endif
#if WXWIN_COMPATIBILITY_3_0
#if wxOSX_USE_ICONREF
// returns a IconRef which must be retained before and released after usage
wxDEPRECATED_MSG("IconRefs are deprecated, this will be removed in the future")
IconRef GetIconRef() const;
// returns a IconRef which must be released after usage
wxDEPRECATED_MSG("IconRefs are deprecated, this will be removed in the future")
IconRef CreateIconRef() const;
#endif
// get read only access to the underlying buffer
void *GetRawAccess() const ;
wxDEPRECATED_MSG("use GetRawData for accessing the buffer")
const void *GetRawAccess() const;
// brackets to the underlying OS structure for read/write access
// makes sure that no cached images will be constructed until terminated
void *BeginRawAccess() ;
void EndRawAccess() ;
wxDEPRECATED_MSG("use GetRawData for accessing the buffer")
void *BeginRawAccess();
wxDEPRECATED_MSG("use GetRawData for accessing the buffer")
void EndRawAccess();
#endif
double GetScaleFactor() const;
void SetSelectedInto(wxDC *dc);
wxDC *GetSelectedInto() const;
protected:
virtual wxGDIRefData *CreateGDIRefData() const;
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;

View File

@@ -32,8 +32,11 @@ OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
CGContextRef inContext,
const CGRect * inBounds,
CGImageRef inImage) ;
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetSystemImage(const wxString& name);
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCGImage( CGImageRef image, double scale = 1.0, bool isTemplate = false);
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromIconRef( WXHICON iconref );
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetIconForType(OSType type );
void WXDLLIMPEXP_CORE wxOSXSetImageSize(WX_NSImage image, CGFloat width, CGFloat height);
CGImageRef WXDLLIMPEXP_CORE wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage, double *scale = NULL );
CGImageRef WXDLLIMPEXP_CORE wxOSXGetCGImageFromNSImage( WX_NSImage nsimage, CGRect* r, CGContextRef cg);
CGContextRef WXDLLIMPEXP_CORE wxOSXCreateBitmapContextFromNSImage( WX_NSImage nsimage, bool *isTemplate = NULL);

View File

@@ -51,7 +51,9 @@ public:
wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
#if wxOSX_USE_ICONREF
WXHICON GetHICON() const;
#endif
#if wxOSX_USE_COCOA
WX_NSImage GetNSImage() const ;

View File

@@ -1622,6 +1622,13 @@
// make sure we have the proper dispatcher for the console event loop
#define wxUSE_SELECT_DISPATCHER 1
#define wxUSE_EPOLL_DISPATCHER 0
// set to 1 if you have older code that still needs icon refs
#define wxOSX_USE_ICONREF 0
// set to 0 if you have code that has problems with the new bitmap implementation
#define wxOSX_BITMAP_NATIVE_ACCESS 1
/* --- end OSX options --- */
#endif