Skip to content

Commit

Permalink
Fixed invalid surface buffer
Browse files Browse the repository at this point in the history
Was being copied with `Data`
  • Loading branch information
colemancda committed Jun 6, 2017
1 parent 4cf7a26 commit 6b6dd74
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions Sources/Cacao/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6b6dd74

Please sign in to comment.