IDVOffscreenPortData is an interface for creating and updating platform offscreens.
InDesign uses platform offscreen for two reasons: 1) to reduce screen flicker; 2) as a cache to avoid having to instantiate an item on a page in order to ask it to draw.
On Mac OS X, the screen flicker case is handled by the OS so we don't need platform offscreens for that case. However, the optimizations that reason 2 provides forces us to continue using offscreens.
This interface has methods to maintain 1 or more offscreens as used by the IDVOffscreenViewPortCache. The IDVOffscreenViewPortCache maintains two IDVOffscreenPortData ptrs: 1 for the background and 1 for the foreground. In the case of the layout window, the background offscreen is the contents of the window/document in an unselected state. The foreground is used as a composite. That is, if an update event occurs, we do the following:
- Make sure the background offscreen is up to date. If nobody has called ILayoutController->InvalidateContent(), then there is nothing to do in this step. Typically, InvalidateContent() gets called by a document observer after a command has been processed which changes a page item or the layout in some way.
- Copy the area to update from the background to the foreground.
- Draw the selection into the foreground.
- Draw the foreground to the window.
With the introduction of Mac OS X, the foreground buffer is not needed. Rather, the OS provided back buffer can serve the purpose of the foreground/composite buffer. Hence, we need two different update methods in the IDVOffscreenPortData interface. One (the original UpdateTargetBitmap()) which allocates a new platform offscreen if the bounds are larger than the current one, and another, UpdateTargetBitmapIfDiffSize(), which allocates a new platform offscreen if the bounds are different.
History:
Prior to InDesign 3.0, there was 1 background and 1 foreground offscreen shared among all layout windows. As a result, if you had multiple documents open, switching between documents/windows caused a performance hit as we updated the contents of the bitmap. In addition, the size of the offscreen was the size of the largest window. Also, the IDVOffscreenViewPortCache interface lived on the Session boss since it was not associated with any window.
For InDesign 3.0, I wanted to provide an offscreen per layout window. Hence, I added the IDVOffscreenViewPortCache to kLayoutWidgetBoss. As a result, we no longer need to have the background offscreen be the size of the largest window. However, since the foreground offscreen is simply a compositing buffer, I did not want to add a foreground offscreen per window. Therefore, the IDVOffscreenViewPortCache::QueryForegroundViewPort() implementation on the layout boss will simply query for the foreground viewport on the session boss. And, when it is time to update it due to a window resize, then the original UpdateTargetBitmap() function will be called.
- See Also
- IDVOffscreenViewPortCache