InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IDVOffscreenPortData Class Referenceabstract

#include <IDVOffscreenPortData.h>

Inheritance diagram for IDVOffscreenPortData:
IPMUnknown

Public Types

enum  { kDefaultIID = IID_IDVOFFSCREENPORTDATA }
 

Public Member Functions

virtual void SetTargetBitmap (IDVPlatformOffscreen *bitmap, bool16 isStraight=kFalse)=0
 
virtual IDVPlatformOffscreenQueryTargetBitmap ()=0
 
virtual const Int32RectGetTargetBitmapBounds ()=0
 
virtual dvaui::drawbot::Drawbot * GetDrawbot () const =0
 
virtual bool16 UpdateTargetBitmap (const Int32Rect &newbounds, PMReal uiScaleFactor)=0
 
virtual bool16 UpdateTargetBitmapIfDiffSize (const Int32Rect &newBounds, PMReal uiScaleFactor)=0
 
- Public Member Functions inherited from IPMUnknown
virtual IPMUnknownQueryInterface (PMIID interfaceID) const =0
 
virtual void AddRef () const =0
 
virtual void Release () const =0
 

Detailed Description

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:

  1. 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.
  2. Copy the area to update from the background to the foreground.
  3. Draw the selection into the foreground.
  4. 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

Member Enumeration Documentation

anonymous enum

Default IID

Member Function Documentation

virtual dvaui::drawbot::Drawbot* IDVOffscreenPortData::GetDrawbot () const
pure virtual
   GetDrawbot- returns the underlying drawbot object

Parameters
none
Returns
Drawbot*
virtual const Int32Rect& IDVOffscreenPortData::GetTargetBitmapBounds ()
pure virtual
   GetTargetBitmapBounds - returns bounding box of the platform bitmap 

Parameters
none
Returns
const
virtual IDVPlatformOffscreen* IDVOffscreenPortData::QueryTargetBitmap ()
pure virtual
   QueryTargetBitmap - Returns an addreferenced pointer to the platform offscreen setup 

via SetTargetBitmap.

Parameters
none
Returns
IDVPlatformOffscreen*
virtual void IDVOffscreenPortData::SetTargetBitmap (IDVPlatformOffscreenbitmap,
bool16 isStraight = kFalse 
)
pure virtual
   SetTargetBitmap() - loads the offscreen port with the bitmap to draw on 

Parameters
bitmap
virtual bool16 IDVOffscreenPortData::UpdateTargetBitmap (const Int32Rectnewbounds,
PMReal uiScaleFactor 
)
pure virtual
   UpdateTargetBitmap - used to resize the bitmap that has been loaded into an offscreen port 

returns ktrue if bitmap resize. returns kfalse if bitmap not resize (i.e. the bitmap was already big enough or bigger). It also sets the origin to newBounds.left and newBounds.top

Parameters
newbounds
Returns
bool16
virtual bool16 IDVOffscreenPortData::UpdateTargetBitmapIfDiffSize (const Int32RectnewBounds,
PMReal uiScaleFactor 
)
pure virtual
   UpdateTargetBitmapIfDiffSize - same as UpdateTargetBitmap except that it will resize 

the bitmap if the newBounds are not equal to the current size.

Parameters
newBoundsIN
Returns
bool16