Think of something that you wish Authorware could do but it doesn't?  Let the our good friends at Macromedia know via the wishlist.

Please let us know if you find any of the materials on this site inappropriate or offensive. Please include the url and why the material should be reviewed.

Comments and questions about the site are also welcome. Please no Authorware questions, use the AWARE list.


11015 - Authorware layers and graphic performance

by - Paul Hamilton & Dietrich Schultz

Article appears courtesy of Danny Engelman’s Gems and Jewels of the AWARE list

Does placing displays in multiple layers slow APW down or speed it up?

Things that remain static should be in the background layer (layer 0), everyting else should b in a layer higher if it moves or displays momentarily.

Do a lot of blank layers slow APW down? We want to ensure the Glossary always appears in front of everything so we may assign it to layer 9.


Here is how it works internally.

There are 2 offscreen buffers. One is called the "background" and another is called "animation". All objects in layer 0 are always drawn into the background buffer, and other layered objects are in the animation buffer.

So if an object is moved in the background buffer, then the object is updated in the background buffer, then the area that is changed (called the "inval" region) is drawn onto the screen, and then that same area in the animation buffer (even if it hasn't changed) is drawn onto the screen on top. so everytime you change something in the background buffer you will redraw the animation buffer too.

If an object in the animation buffer changes, we only need to copy the image from the background buffer that is exposed and then draw the rest from the animation buffer.

So why don't you just put everything into animation buffer?

Imagine you have 20 overlapping objects in the same buffer. everytime you want to move one in front, all objects behind it need to be redrawn individually. If they are in a separate buffer, then we just drawn the bitmap of what they look like rather than asking them to redraw (which could take a while if they are objects).

I hope this helps a little bit.

Paul. ----------------------------------------------------- Paul Hamilton Authorware Development Engineer Macromedia

FW: Layers and screen redraw: Further clarification

Segmenting a bitmap can be a benefit regardless of which buffer it's in. I'll try to describe a simple test you can do to see what segmenting can buy you. I encourage you to try this out for yourself.

Load a full screen, 256-color bitmap into a display icon. Put a decision after the display and set it to repeat 100 times. Attach a display to the decision that contains a small rectangle in the middle of the screen (say 50 pixels high, or so). The idea here to to have a small object display AND ERASE 100 times. Run this simple file and time how long it takes for the decision loop to complete.

Next, take the bitmap into Paintbrush and slice it into three horizontal pieces. The middle piece should be at least as high as the square you drew previously but not too much higher or the benefit of segmenting is diminished. Now replace the display icon containing the single bitmap with one containing the same bitmap sliced into three pieces. You have to ensure that the foreground rectangle will overlap the middle slice of the bitmap, but not the other two slices. Run the file now and it should be considerably faster. On my machine the times were about 5:1. You can take this one more step and break the middle segment into three vertical pieces, with the center piece just big enough to sit under the foreground rectangle.

The actual benefit of this technique will vary based on your machine, the relative size of the images, etc but should almost always provide some improvement.

An important point here is that the "foreground" object was also being drawn at layer 0, ie. into the background buffer. That meant that every time the foreground object was erased Authorware had to restore that portion of the background buffer that was affected. This redraw operation is more efficient in the segmented case because a smaller bitmap was involved. The redraw also requires less memory since a smaller bitmap is loaded in the segmented case--that can make a difference if memory is tight.

You can get this sample to run even faster, with or without segmenting the background, by moving the foreground object to the animation buffer (ie. set it's layer to 1 or more). If you do that it doesn't matter whether the background is segmented or not because Authorware doesn't have to reload the original bitmap to redraw anything. The foreground object was never in the background buffer so erasing it doesn't disturb the background pixels.

Rules of thumb: - This only matters if your background is relative slow to draw (a large bitmap, complex object graphics, or text). - Use layering when the foreground object will be displayed and erased quickly. - Segmenting a bitmap speeds up ERASING objects that sit on top of it (and in the same buffer). It doesn't speed up the original display of the bitmap. In fact, it may slow it down a little. - It's usually best to break a bitmap into horizontal segments. Vertical segments can work, too. In extreme cases you could break it into vertical and horizonal pieces. - This is all pretty tweaky and is best left towards the end of a project when the screen layout isn't going to change.

Also, see my answers to your specific questions below.

Dietrich Schultz Macromedia

How do segmenting graphics and using different layers relate (if at all) to each other?

They're different techniques and don't relate directly.

We have our background at layer 0, and animations at layer 1. Does segmenting the background have any effect on when Authorware copies "the image from the background buffer that is exposed." Is the redrawn area just the exposed part of the graphic, or does this refer to the whole graphic, as #3026 seems to imply?

I'm not sure exactly which case you're referring to as I can't find that phrase in the copy of TN3026 that's currently on our web site. However, segmenting will only provide a performance benefit if the object being erased is in the same buffer as the one behind it.

If a large graphic is placed on the screen, another smaller graphic placed over it, then a third smaller graphic placed over just the second graphic, which graphics must be redrawn? Does using different layers effect which graphics are redrawn?

Good question. Assuming all the objects are in the same buffer and all are rectangular and opaque and you're erasing just the top one, then Authorware has to redraw just the middle one. In general, Authorware recognizes opaque objects and doesn't needlessly redraw objects behind them.

My assumption (and resulting action) from Paul's posting was to place graphics that stay on the screen for awhile at layer 0, and temporary graphics at layer 1 or higher. TechNote #3026 seems to imply that by not also segmenting the background, everytime a graphic in layer 1 or higher changes, the whole background must be redrawn. This seems to go against the benefit of two buffers, and the reason for my confusion.

Your actions are good. Don't bother segmenting the background if you're using layering.

Thanks for any insight and clarification on how the two statements above effect each other.

Clear as mud?

There are 0 reviews
Add your review