wxCocoa: Added preliminary Blit support
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22241 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
68d31398dd
commit
2c23fe91e3
@ -56,6 +56,10 @@ protected:
|
|||||||
void CocoaApplyTransformations();
|
void CocoaApplyTransformations();
|
||||||
float m_cocoaHeight;
|
float m_cocoaHeight;
|
||||||
bool m_cocoaFlipped;
|
bool m_cocoaFlipped;
|
||||||
|
// Blitting
|
||||||
|
virtual bool CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
|
||||||
|
wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
|
||||||
|
int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask);
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Implementation
|
// Implementation
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
@ -29,6 +29,10 @@ protected:
|
|||||||
// DC stack
|
// DC stack
|
||||||
virtual bool CocoaLockFocus();
|
virtual bool CocoaLockFocus();
|
||||||
virtual bool CocoaUnlockFocus();
|
virtual bool CocoaUnlockFocus();
|
||||||
|
// Blitting
|
||||||
|
virtual bool CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
|
||||||
|
wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
|
||||||
|
int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __WX_COCOA_DCMEMORY_H__
|
#endif // __WX_COCOA_DCMEMORY_H__
|
||||||
|
@ -447,6 +447,16 @@ void wxDC::DoCrossHair(wxCoord x, wxCoord y)
|
|||||||
|
|
||||||
|
|
||||||
bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask , wxCoord xsrcMask, wxCoord ysrcMask)
|
bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask , wxCoord xsrcMask, wxCoord ysrcMask)
|
||||||
|
{
|
||||||
|
if(!CocoaTakeFocus()) return false;
|
||||||
|
if(!source) return false;
|
||||||
|
return source->CocoaDoBlitOnFocusedDC(xdest,ydest,width,height,
|
||||||
|
xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxDC::CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
|
||||||
|
wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
|
||||||
|
int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,11 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "wx/dcmemory.h"
|
#include "wx/dcmemory.h"
|
||||||
|
#include "wx/log.h"
|
||||||
|
|
||||||
#import <AppKit/NSImage.h>
|
#import <AppKit/NSImage.h>
|
||||||
|
#import <AppKit/NSAffineTransform.h>
|
||||||
|
#import <AppKit/NSGraphicsContext.h>
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxMemoryDC
|
// wxMemoryDC
|
||||||
@ -77,3 +80,41 @@ void wxMemoryDC::DoGetSize( int *width, int *height ) const
|
|||||||
*height = m_selectedBitmap.GetHeight();
|
*height = m_selectedBitmap.GetHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxMemoryDC::CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
|
||||||
|
wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
|
||||||
|
int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask)
|
||||||
|
{
|
||||||
|
if(!m_selectedBitmap.Ok())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NSAffineTransform *transform = [NSAffineTransform transform];
|
||||||
|
[transform translateXBy:xdest yBy:ydest];
|
||||||
|
|
||||||
|
NSAffineTransform *flipTransform = [NSAffineTransform transform];
|
||||||
|
/* x' = 1x + 0y + 0
|
||||||
|
y' = 0x + -1y + window's height
|
||||||
|
*/
|
||||||
|
NSAffineTransformStruct matrix = {
|
||||||
|
1, 0
|
||||||
|
, 0, -1
|
||||||
|
, 0, height
|
||||||
|
};
|
||||||
|
[flipTransform setTransformStruct: matrix];
|
||||||
|
|
||||||
|
NSGraphicsContext *context = [NSGraphicsContext currentContext];
|
||||||
|
[context saveGraphicsState];
|
||||||
|
[transform concat];
|
||||||
|
[flipTransform concat];
|
||||||
|
|
||||||
|
wxLogDebug("[m_cocoaNSImage isFlipped]=%d", [m_cocoaNSImage isFlipped]);
|
||||||
|
[m_cocoaNSImage drawAtPoint: NSMakePoint(0,0)
|
||||||
|
fromRect: NSMakeRect(xsrc,
|
||||||
|
m_selectedBitmap.GetHeight()-height-ysrc,
|
||||||
|
width, height)
|
||||||
|
operation: NSCompositeCopy // FIXME: raster ops
|
||||||
|
fraction: 1.0];
|
||||||
|
|
||||||
|
[context restoreGraphicsState];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user