From 6b6dd742e248204b5a499f399bde42c3eae19e07 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Tue, 6 Jun 2017 08:38:01 -0500 Subject: [PATCH] Fixed invalid surface buffer Was being copied with `Data` --- Sources/Cacao/Application.swift | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Sources/Cacao/Application.swift b/Sources/Cacao/Application.swift index 2e4b7d9..e9a7dbd 100644 --- a/Sources/Cacao/Application.swift +++ b/Sources/Cacao/Application.swift @@ -86,19 +86,13 @@ public extension Application { let nativeSize = windowSize // FIXME: Retina display sdlImageSurface = SDL_CreateRGBSurface(0, CInt(nativeSize.width), CInt(nativeSize.height), 32, 0, 0, 0, 0)! - - let dataLength = sdlImageSurface.pointee.h * sdlImageSurface.pointee.pitch - - let data = Data(bytesNoCopy: sdlImageSurface.pointee.pixels, count: Int(dataLength), deallocator: .none) - let surface = try! Cairo.Surface.Image(data: data, + let surface = try! Cairo.Surface.Image(mutableBytes: sdlImageSurface.pointee.pixels.assumingMemoryBound(to: UInt8.self), format: .argb32, width: Int(sdlImageSurface.pointee.w), height: Int(sdlImageSurface.pointee.h), stride: Int(sdlImageSurface.pointee.pitch)) - - if screen == nil { screen = Screen(surface: surface, nativeSize: nativeSize, size: windowSize)