Bloc icon indicating copy to clipboard operation
Bloc copied to clipboard

ad-hoc modularity: BlSpartaCanvasBuilder logic is calling for bugs and dependency mess

Open Ducasse opened this issue 5 years ago • 5 comments

When using class environment the tools that analyse dependency get confused.

forBufferOn: aRendererSurface
	<return: #SpartaCanvas>

	^ (self class environment at: #MozSkiaCanvas)
		createForData: aRendererSurface buffer
		type: (self class environment at: #MozBackendType) SKIA
		extent: aRendererSurface extent
		stride: aRendererSurface stride
		format: (self class environment at: #MozSurfaceFormat) B8G8R8A8
forOpenGLOn: aRendererSurface
	| aWebrender |
	<return: #SpartaCanvas>
	
	aWebrender := (self class environment at: #Webrender)
		init: ((self class environment at: #GtGleamGL) loadGl: [ :aSymbol | aRendererSurface context getProcAddress: aSymbol ])
		extent: aRendererSurface physicalSize asPoint
		options: ((self class environment at: #WebrenderRendererOptions) new
			debugFlag: (self class environment at: #WebrenderDebugFlags) PROFILER_DBG";
			debugFlag: (self class environment at: #WebrenderDebugFlags) COMPACT_PROFILER").

	aRendererSurface addUpdateAction: [
		aWebrender update.	
		aWebrender render: aRendererSurface physicalSize asPoint.
		aWebrender flushPipelineInfo ].
	aRendererSurface updateEveryFrame.

	^ (self class environment at: #WebrenderWindowCanvas)
		extent: aRendererSurface physicalSize asPoint
		webrender: aWebrender
forFormOn: aRendererSurface
	<return: #SpartaCanvas>

	^ (self class environment at: #SpartaCairoCanvas)
		createForData: aRendererSurface pointer
		extent: aRendererSurface extent
		stride: aRendererSurface stride
		format: (self class environment at: #SpartaCairoSurfaceFormat) CAIRO_FORMAT_ARGB32

Ducasse avatar Feb 14 '21 16:02 Ducasse

I looked at the senders of environement, and found:

  • 25 senders belong to Bloc-Sparta
  • 5 belong to Bloc package (4 are in Bloc class, 1 is in BlAttributeRope).

tinchodias avatar Mar 09 '21 23:03 tinchodias

We will have to check. For now I do not want to touch sparta :). Probably a subclass with the registration mechanism should do it.

Ducasse avatar Mar 09 '21 23:03 Ducasse

BTW why looking at environemtn. I would have looked the the key of the at:

Ducasse avatar Mar 09 '21 23:03 Ducasse

Why? only to locate the occurrences of "self class environment ..." that would need to be fixed.

tinchodias avatar Mar 09 '21 23:03 tinchodias

Note: it's not only at: but also includesKey:. Examples:

BlSpartaCairoCanvasBuilder >>
isSupported
	<return: #Boolean>
	^ self environment includesKey: #SpartaCairoCanvas
BlSpartaMozCanvasBuilder >>
isSupported
	<return: #Boolean>

	^ (self environment includesKey: #MozCanvas)
		and: [ (self environment at: #MozLibrary) uniqueInstance hasModule ]

and several other testing methods.

tinchodias avatar Mar 09 '21 23:03 tinchodias