diff options
Diffstat (limited to 'cocoa')
| -rw-r--r-- | cocoa/PlatCocoa.h | 3 | ||||
| -rw-r--r-- | cocoa/PlatCocoa.mm | 13 | ||||
| -rw-r--r-- | cocoa/ScintillaCocoa.mm | 21 | 
3 files changed, 20 insertions, 17 deletions
| diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h index d11b52336..83b724df9 100644 --- a/cocoa/PlatCocoa.h +++ b/cocoa/PlatCocoa.h @@ -82,6 +82,7 @@ public:  	void Init(SurfaceID sid, WindowID wid) override;  	void InitPixMap(int width, int height, Surface *surface_, WindowID wid) override;  	std::unique_ptr<Surface> AllocatePixMap(int width, int height) override; +	std::unique_ptr<SurfaceImpl> AllocatePixMapImplementation(int width, int height);  	CGContextRef GetContext() { return gc; }  	void SetMode(SurfaceMode mode) override; @@ -93,7 +94,7 @@ public:  	/** Returns a CGImageRef that represents the surface. Returns NULL if this is not possible. */  	CGImageRef CreateImage(); -	void CopyImageRectangle(Surface &surfaceSource, PRectangle srcRect, PRectangle dstRect); +	void CopyImageRectangle(SurfaceImpl *source, PRectangle srcRect, PRectangle dstRect);  	int LogPixelsY() override;  	int PixelDivisions() override; diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index c9cca0ded..d509145d2 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -532,6 +532,10 @@ std::unique_ptr<Surface> SurfaceImpl::AllocatePixMap(int width, int height) {  	return std::make_unique<SurfaceImpl>(this, width, height);  } +std::unique_ptr<SurfaceImpl> SurfaceImpl::AllocatePixMapImplementation(int width, int height) { +	return std::make_unique<SurfaceImpl>(this, width, height); +} +  //--------------------------------------------------------------------------------------------------  void SurfaceImpl::SetMode(SurfaceMode mode_) { @@ -1387,9 +1391,8 @@ void SurfaceImpl::Stadium(PRectangle rc, FillStroke fillStroke, Ends ends) {  	CGContextSetLineWidth(gc, 1.0f);  } -void SurfaceImpl::CopyImageRectangle(Surface &surfaceSource, PRectangle srcRect, PRectangle dstRect) { -	SurfaceImpl &source = static_cast<SurfaceImpl &>(surfaceSource); -	CGImageRef image = source.CreateImage(); +void SurfaceImpl::CopyImageRectangle(SurfaceImpl *source, PRectangle srcRect, PRectangle dstRect) { +	CGImageRef image = source->CreateImage();  	CGRect src = PRectangleToCGRect(srcRect);  	CGRect dst = PRectangleToCGRect(dstRect); @@ -1999,8 +2002,8 @@ static NSImage *ImageFromXPM(XPM *pxpm) {  		const int width = pxpm->GetWidth();  		const int height = pxpm->GetHeight();  		PRectangle rcxpm(0, 0, width, height); -		std::unique_ptr<Surface> surfaceXPM(Surface::Allocate(SC_TECHNOLOGY_DEFAULT)); -		surfaceXPM->InitPixMap(width, height, NULL, NULL); +		std::unique_ptr<Surface> surfaceBase(Surface::Allocate(SC_TECHNOLOGY_DEFAULT)); +		std::unique_ptr<Surface> surfaceXPM = surfaceBase->AllocatePixMap(width, height);  		SurfaceImpl *surfaceIXPM = static_cast<SurfaceImpl *>(surfaceXPM.get());  		CGContextClearRect(surfaceIXPM->GetContext(), CGRectMake(0, 0, width, height));  		pxpm->Draw(surfaceXPM.get(), rcxpm); diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 4a688bdff..4c3b50d28 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -1411,36 +1411,35 @@ void ScintillaCocoa::StartDrag() {  	SCIContentView *content = ContentView();  	// To get a bitmap of the text we're dragging, we just use Paint on a pixmap surface. -	SurfaceImpl sw; -	sw.InitPixMap(static_cast<int>(client.Width()), static_cast<int>(client.Height()), NULL, NULL); +	SurfaceImpl si; +	si.SetMode(SurfaceMode(CodePage(), BidirectionalR2L())); +	std::unique_ptr<SurfaceImpl> sw = si.AllocatePixMapImplementation(static_cast<int>(client.Width()), static_cast<int>(client.Height()));  	const bool lastHideSelection = view.hideSelection;  	view.hideSelection = true;  	PRectangle imageRect = rcSel;  	paintState = PaintState::painting;  	paintingAllText = true; -	CGContextRef gcsw = sw.GetContext(); +	CGContextRef gcsw = sw->GetContext();  	CGContextTranslateCTM(gcsw, -client.left, -client.top); -	Paint(&sw, client); +	Paint(sw.get(), client);  	paintState = PaintState::notPainting;  	view.hideSelection = lastHideSelection; -	SurfaceImpl pixmap; -	pixmap.InitPixMap(static_cast<int>(imageRect.Width()), static_cast<int>(imageRect.Height()), NULL, NULL); -	pixmap.SetMode(SurfaceMode(CodePage(), BidirectionalR2L())); - -	CGContextRef gc = pixmap.GetContext(); +	std::unique_ptr<SurfaceImpl> pixmap = si.AllocatePixMapImplementation(static_cast<int>(imageRect.Width()), +								  static_cast<int>(imageRect.Height())); +	CGContextRef gc = pixmap->GetContext();  	// To make Paint() work on a bitmap, we have to flip our coordinates and translate the origin  	CGContextTranslateCTM(gc, 0, imageRect.Height());  	CGContextScaleCTM(gc, 1.0, -1.0); -	pixmap.CopyImageRectangle(sw, imageRect, PRectangle(0.0f, 0.0f, imageRect.Width(), imageRect.Height())); +	pixmap->CopyImageRectangle(sw.get(), imageRect, PRectangle(0.0f, 0.0f, imageRect.Width(), imageRect.Height()));  	// XXX TODO: overwrite any part of the image that is not part of the  	//           selection to make it transparent.  right now we just use  	//           the full rectangle which may include non-selected text.  	NSBitmapImageRep *bitmap = NULL; -	CGImageRef imagePixmap = pixmap.CreateImage(); +	CGImageRef imagePixmap = pixmap->CreateImage();  	if (imagePixmap)  		bitmap = [[NSBitmapImageRep alloc] initWithCGImage: imagePixmap];  	CGImageRelease(imagePixmap); | 
