Skip to content

Commit

Permalink
Avoid creation of SDL_Surface, as we only need a ByteArray.
Browse files Browse the repository at this point in the history
May fix #688
  • Loading branch information
tinchodias committed Feb 20, 2025
1 parent ce04fcb commit 4fe4846
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
9 changes: 1 addition & 8 deletions src/Bloc/BlHostRendererBufferSurface.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ Class {
#instVars : [
'stride',
'buffer',
'extent',
'strongReference'
'extent'
],
#category : #'Bloc-Universe - Renderer'
}
Expand Down Expand Up @@ -75,9 +74,3 @@ BlHostRendererBufferSurface >> stride: aNumber [

stride := aNumber
]

{ #category : #accessing }
BlHostRendererBufferSurface >> strongReference: anObject [

strongReference := anObject
]
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,23 @@ Class {
{ #category : #initialization }
BlOSWindowSDL2BufferSurfaceRenderer >> initializeForSurface: aBlHostRendererBufferSurface [

| textureExtent sdlSurface |
| textureExtent stride buffer |
textureExtent := aBlHostRendererBufferSurface physicalSize asPoint.

sdlSurface := SDL2
createRGBSurfaceForCairoWidth: textureExtent x
height: textureExtent y.

sdlRenderer := window backendWindow renderer sdlRenderer.

texture := sdlRenderer
createTextureFormat: SDL_PIXELFORMAT_XRGB8888
access: SDL_TEXTUREACCESS_STREAMING
access: SDL_TEXTUREACCESS_STATIC
width: textureExtent x
height: textureExtent y.

stride := textureExtent x * 4.
buffer := ByteArray new: stride * textureExtent y.

aBlHostRendererBufferSurface
strongReference: sdlSurface;
buffer: sdlSurface pixels;
stride: sdlSurface pitch;
buffer: buffer;
stride: stride;
extent: textureExtent
]

Expand Down

0 comments on commit 4fe4846

Please sign in to comment.