Is there anything that one should know about things to avoid to do with Layers.library when OS 4.1 compositing mode is on ? Now I'm new to Layers.library, I just want to be sure that following is legal : - creating a compatible bitmap using p96AllocBitMap() from window->RPort->BitMap - creating a NewLayerInfo() - creating a behind layer calling CreateBehindLayer() and passing it the previously created bitmap and layer info, - then extracting the rastport from this layer info - using this rastport to do the graphics things (mainly BltBitMapRastPort()) - then extracting the layer from the rastport, - using this extracted layer in InstallClipRegion( , NULL ) - deleting the layer using DeleteLayer() - extracting the bitmap from the rastport and p96FreeBitMap()'ing it
Especially it's not clear what happens to the layer's rastport after the layer has passed through DeleteLayer() (as I'm trying to retrieve its bitmap after DeleteLayer())
DeleteLayer will free all memory allocated by Create#?Layer, so your RastPort will be gone and you must not access it any more.
The question is why you would need to extract the bitmap from the rastport although you already know it because you allocated it yourself ?
The same applies to extracting the layer from the rastport when you extracted the rastport from the layer just before. A little too much "extracting" for my taste.
And why do you InstallClipRegion(NULL) if you never did InstallClipRegion(anything) ?
First this is not my code I'm trying to understand why it might crash...
Quote:
DeleteLayer will free all memory allocated by Create#?Layer, so your RastPort will be gone and you must not access it any more.
I feared this, can it be possible that such sort of things were possible with previous AOS memory allocator while it's not anymore in current AOS4's one ?
Quote:
The question is why you would need to extract the bitmap from the rastport although you already know it because you allocated it yourself ?
Because it's a port and the previous porter choosed to use the rastport as being the "handle" abstracted and carried along everywhere in the API. As such it is created in one function (the four first items), used in many other (symbolized by the fifth) , and deleted in another one (described by the four last items).
Quote:
The same applies to extracting the layer from the rastport when you extracted the rastport from the layer just before. A little too much "extracting" for my taste.
Same answer.
Quote:
And why do you InstallClipRegion(NULL) if you never did InstallClipRegion(anything) ?
Because I do but in another function. Anyway what nasty thing can it cause even if not clip were installed ?
Yes that's what I started to do but I wanted to knwo if with compositing mode on there can be restriction to what things we can access (i.e. layer->rastport, rastport->layer, rastport->bitmap, etc.) or things we must take care of (for example non constant bitmap for a given rastport, or such sort of things)
Also, remember that it's a bit dangerous to play with layers on an Intuition screen (except from the locking functions and a few others) because you may confuse Intuition input handler.