# Aros/Developer/Docs/Libraries/Layers

* Navbar for the Aros wikibook
* Aros User
* Aros User Docs
* Aros User FAQs
* Aros User Applications
* Aros User DOS Shell
* Aros/User/AmigaLegacy
* Aros Dev Docs
* Aros Developer Docs
* Porting Software from AmigaOS/SDL
* For Zune Beginners
* Zune .MUI Classes
* For SDL Beginners
* Aros Developer BuildSystem
* Specific platforms
* Aros x86 Complete System HCL
* Aros x86 Audio/Video Support
* Aros x86 Network Support
* Aros Intel AMD x86 Installing
* Aros Storage Support IDE SATA etc
* Aros Poseidon USB Support
* x86-64 Support
* Motorola 68k Amiga Support
* Linux and FreeBSD Support
* Windows Mingw and MacOSX Support
* Android Support
* Arm Raspberry Pi Support
* PPC Power Architecture
* misc
* Aros Public License

## 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
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

## Misc
### 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:
in places where it used
See workbench/demos/winbackfill.c.