20.34 Hardware brushes

Hardware brushes are used for hardware-accelerated drawing in connection with a hardware double buffer. To create a hardware brush, simply set the Hardware tag to True in LoadBrush() or @BRUSH. Alternatively, you can also create a hardware brush from a normal brush by using CopyBrush() and setting the Hardware tag to True in this function. To find out whether or not a brush has been successfully created in hardware, query the #ATTRHARDWARE attribute using GetAttribute(). Note that this attribute can return False even if you set the Hardware tag to True, because not all systems support hardware brushes. If the system Hollywood is running on does not support hardware brushes, a software brush will be created instead.

The advantage of hardware brushes is that they are stored completely in video memory and thus can be drawn extremely quickly. However, hardware brushes can only be drawn to hardware-accelerated double buffers. Nothing else can be done with hardware brushes than drawing them to a hardware-accelerated double buffer. That is why almost all functions of the brush library will not work with hardware brushes. If you would like to modify a hardware brush, you first have to create a software brush which you can modify and then convert it to a hardware brush. You can create a hardware-accelerated double buffer by passing True as the first argument to the BeginDoubleBuffer() function. See BeginDoubleBuffer for details.

Keep in mind that you should only draw to hardware-accelerated double buffers using hardware brushes. All other drawing commands will be much slower! Only by using hardware brushes can you get full hardware-accelerated drawing. Using normal drawing functions with a hardware double buffer can even be slower than using them on a software double buffer. This is especially the case with graphics that use an alpha channel, e.g. anti-aliased text or vector shapes, because for alpha channel drawing, Hollywood has to read from the destination device which will be very slow for hardware double buffers because reading from video memory is very slow. Thus, you should try to use hardware brushes whereever possible when you work with a hardware double buffer.

On some systems (e.g AmigaOS 4.1) the ScaleBrush(), RotateBrush(), and TransformBrush() functions as well as the standard draw tags for on-the-fly image manipulation (e.g. ScaleX and ScaleY) support hardware accelerated image scaling/transformation for hardware brushes. In that case, scaling and transforming brushes is extremely faster than in software mode, especially for antialiased transformations.

By default, hardware brushes are only supported on AmigaOS and Android. Since Hollywood 6.0, however, plugins that install a display adapter are also able to support hardware brushes for their display adapter. In that case you can also use hardware brushes on systems other than AmigaOS and Android. For example, the GL Galore and RebelSDL plugins allow you to use hardware brushes and hardware-accelerated double buffers on Windows, macOS, and Linux. See Obtaining plugins for details.

Hardware brushes can also be display-dependent. This means that they can only be drawn to the display that has been used to allocate them. This is often the case when using custom display adapters made available by plugins. Hollywood's inbuilt hardware brushes on AmigaOS and Android, however, are not display-dependent and can be drawn to any display that is currently open. To allocate a display-dependent hardware brush, you need to pass the identifier of the display that should own the hardware brush in the Display tag in LoadBrush(), @BRUSH or CopyBrush(). Note that all display-dependent hardware brushes are automatically freed by Hollywood when the display they belong to is closed.

Show TOC