NPAPI:ContentsScaleFactor
Status
Accepted, ready for implementation.
Contributors
- Last modified: September 8 2011
- Author: Anders Carlsson (Apple Inc.)
- Contributors: Stuart Morgan (Google)
Overview
This proposal allows plug-ins using the Core Animation and Core Graphics drawing models to work better under scaled display modes.
Background
In OS X Lion and going forward, the backing scale factor is no longer a global; it can vary by display and window. Because of this, plug-ins need a mechanism to query for the current backing scale factor and also get notified when it changes.
Current Proposal
We propose adding a new NPNV variable:
NPNVcontentsScaleFactor = 1001
The plug-in can retrieve the current contents scale factor by calling NPN_GetValue, passing the NPNVcontentsScaleFactor variable and a pointer to a double. The double holds the contents scale factor. The contents scale factor will currently be 2.0 for plug-ins in windows with high resolution scaled display modes, and 1.0 for all other cases. When a plug-in's contents scale factor changes, the browser will call NPP_SetValue passing the NPNVcontentsScaleFactor and a pointer to a double. The double holds the new contents scale factor.
Core Animation plug-ins would typically set the 'contentsScale' CALayer property on relevant layers; this will set the layer's backing store scale. (See the -[CALayer contentsScale] documentation on http://developer.apple.com for more information).
For Core Graphics plug-ins, the CGContext sent along with the NPCocoaEventDrawRect will already be scaled, so plug-ins using simple drawing will work without modifications. If a plug-in draws images or uses a backing buffer, the buffer size in pixels should be scaled appropriately using the contents scale factor.