Aros/Developer/Docs/Libraries/Layers

Introduction
A layer is a rectangular drawing area. Every Intuition window has an associated Layer structure. Intuition windows are the only supported method of adding layers to Intuition screens. Using Intuition window calls

Layers
The Layer Structure is Read-Only. Applications should never directly modify any of the elements of the Layer structure. In addition, applications should only read the front, back, rp, bounds, Flags, SuperBitMap and DamageList elements of the Layer structure.

When a layer is created, a RastPort is automatically to go along with it. The pointer to the RastPort is contained in the layer data structure. Using this RastPort, the application may draw anywhere into the layer’s bounds rectangle. If the application tries to draw outside of this rectangle, the graphics routines will clip the graphics.

Create rastport using layers.library calls and you get clipping. You just attach your bitmap to this rastport created by layers.lib. The normal graphics operations only perform clipping when there's a layer.

only one layer-type flag (LAYERSIMPLE, LAYERSMART and LAYERSUPER) should be specified.

created by using the primitives InitVPort, InitView, MakeVPort, MrgCop, and LoadView

layers.library depends on graphics.library which depends on layers.library - this circular dependency expected? It occurs due to the autogenerated __LIBS_LIST__ for layers.library. graphics.library explicitly calls OpenLibrary on layers.library

Graphics Primitives for creating a low-level graphics display on the common bit map by calling CreateUpfrontLayer or CreateBehindLayer

struct Layer_Info *NewLayerInfo( void );

void DisposeLayerInfo( struct Layer_Info *li );

How do you create a layer without a bitmap?

Usually call NewLayerInfo and CreateUpfrontLayer (which needs the bitmap pointer) and get a readily initialized RastPort from layer->rp.

RastPort width and height are 15 bits (struct Rectangle contains WORDs, not UWORDs). A bitmap with 32k pixel in a square would be more than 1000 megapixel.

Regions
Use the routine InstallClipRegion creates rectangle clipping (which allows graphic functions) within a layer

struct Region *NewRegion( void );

void DisposeRegion( struct Region *region );

ABIv1
Intuition and Layers, since  they  have their roots in MorphOS (because MorphOS has roots in AROS), but already have some extensions from OS4. The main question is window shaping implementation. Both MOS and AOS4 have this mechanism, with different API. Our own variant was close to AOS4 (perhaps they took it as base), so i fixed it up to be compatible (except ChangeLayerShape function - not done yet).

1. If anyone can confirm that the implementation is OS4-compatible? I tried to google for some AOS4 code sample, but failed to find one.

2. Can anyone help me to complete ChangeLayerShape ? It should use the  same   hook,   according   to  OS4  autodocs. Unfortunately my understanding of Layers is very poor.

3. Our  API  better  fits to follow MorphOS than OS4. This is mainly because  we   use  library  vectors  for  function  calls,  and  not interfaces. This allows to have a binary compatibility with MorphOS in future. So, it's  logical  to  implement MorphOS version of shaping. There's only one significant difference: MorphOS version is inverse of AOS one. I. e. in OS4 we provide a region describing visible area, in MorphOS we provide a region describing invisible one. So - would it be better to  switch to MorphOS  variant, or implement support for both? Both versions are not very redundant, i believe amount of code will be minimal.

BackFill Hooks
With a slightly modified version of Thomas Rapp's backfill example. Try to change the backfill hook function to use: (msg->bounds.MinX - layer->bounds.MinX); (msg->bounds.MinY - layer->bounds.MinY); in places where it used msg->offsetx msg->offsety See workbench/demos/winbackfill.c.