NPAPI:CoreGraphicsDrawing: Difference between revisions

Clarify that this spec assumes the Carbon model, and explain the precedence, since it's a common point of confusion
No edit summary
(Clarify that this spec assumes the Carbon model, and explain the precedence, since it's a common point of confusion)
 
(6 intermediate revisions by 2 users not shown)
Line 11: Line 11:
== Overview ==
== Overview ==


Quickdraw is deprecated in 32-bit Mac OS X and entirely gone in 64-bit Mac OS X. The Core Graphics drawing model is an alternative drawing model for 32-bit Mac OS X plugins, and the default drawing model for 64-bit Mac OS X plugins.
The Core Graphics drawing model is an alternative drawing model for 32-bit Mac OS X plugins and the default drawing model for 64-bit Mac OS X plugins.
 
<i>Note: This specification pre-dates the Cocoa specification, so it assumes the Carbon event model. Discussions of "changes" refer to differences from the QuickDraw drawing model. When using CoreGraphics with the [[NPAPI:CocoaEventModel|Cocoa event model]], changes in the Cocoa model may supersede information given here.</i>


== Negotiating Core Graphics Drawing ==
== Negotiating Core Graphics Drawing ==
Line 17: Line 19:
For documentation on negotiating drawing models, see [[NPAPI:Models]]. The drawing model variables for Core Graphics are:
For documentation on negotiating drawing models, see [[NPAPI:Models]]. The drawing model variables for Core Graphics are:


* NPDrawingModelCoreGraphics
* NPDrawingModelCoreGraphics (NPDrawingModel = 1)
* NPNVsupportsCoreGraphicsBool
* NPNVsupportsCoreGraphicsBool (NPNVariable = 2001)


== Excluding QuickDraw ==
== Excluding QuickDraw ==


QuickDraw is default drawing model for 32-bit Mac OS X plugins. In 64-bit, the QuickDraw drawing model does not exist, Core Graphics is the default drawing model. The drawing model variables for Quickdraw are:
QuickDraw is default drawing model for 32-bit Mac OS X plugins. The QuickDraw drawing model does not exist for 64-bit Mac OS X. The drawing model variables for Quickdraw are:


* NPDrawingModelQuickDraw
* NPDrawingModelQuickDraw (NPDrawingModel = 0)
* NPNVsupportsQuickDrawBool
* NPNVsupportsQuickDrawBool (NPNVariable = 2000)


Plugins and browsers that are compiled 64-bit must entirely exclude QuickDraw support, since there will be no 64-bit QuickDraw.
Plugins and browsers that are compiled 64-bit must entirely exclude QuickDraw support, since there will be no 64-bit QuickDraw.
Line 34: Line 36:
     #define NP_NO_QUICKDRAW
     #define NP_NO_QUICKDRAW
  #endif
  #endif
You'll see this #define used throughout this proposal.


== The Core Graphics Drawing Model ==
== The Core Graphics Drawing Model ==
Line 41: Line 41:
If a plugin sets the drawing model to NPDrawingModelCoreGraphics, then the meanings of some of the NPAPI data structures change:
If a plugin sets the drawing model to NPDrawingModelCoreGraphics, then the meanings of some of the NPAPI data structures change:


- NPWindow's 'window' field becomes a NP_CGContext:
- NPWindow's 'window' field (under the Carbon event model) becomes a NP_CGContext:


  /* NP_CGContext is the type of the NPWindow's 'window' when the
  /* NP_CGContext is the type of the NPWindow's 'window' when the
Line 77: Line 77:
== Bridging QuickDraw and CoreGraphics ==
== Bridging QuickDraw and CoreGraphics ==


You might be asking yourself, "Great...  So now I can make a plugin that draws using CoreGraphics, but it will only run in browsers that support this NPAPI extension?"
There is a way for plugins to draw using CoreGraphics, yet remain compatible with QuickDraw-only browsers.  The idea is to use QDBeginCGContext() and QDEndCGContext() to obtain a CGContextRef for the CGrafPtr provided by the browser.
 
Don't worry!  There is a way for plugins to draw using CoreGraphics, yet remain compatible with QuickDraw-only browsers.  The idea is to use QDBeginCGContext() and QDEndCGContext() to obtain a CGContextRef for the CGrafPtr provided by the browser. We will be shipping some sample code to demonstrate this technique, but here is a little snippet for your enjoyment:


  static CGContextRef beginQDPluginUpdate(NPWindow *window)
  static CGContextRef beginQDPluginUpdate(NPWindow *window)
70

edits